1
TopKnot
Help to switch 2 lines of code on the fly
  • 2007/3/8 12:51

  • TopKnot

  • Just popping in

  • Posts: 70

  • Since: 2005/9/27


The Wish:
Create a switchable (On/OFF) button that will change change two lines of code.

What the button will accomplish:
Allow "Tinyeditor" to be turned on and off as the default editor.

File that Needs to be Modified:
class/xoopsform/formdhtmltextarea.php

I have to manually change this file everytime I want to use TinyEditor in most modules and block. The problem is, I don't wish to give "users" the ability of use "TinyEditor". Just me...the Admin.

Section of Code that is Involved:
Around line 72-74 of formdhtmltextarea.php

Code from formdhtmltextarea.php:

/*var $htmlEditor = array();*/


var $htmlEditor = array( 'XoopsFormTinyeditorTextArea', '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php' );

Explanation of the Code:
As you can see, one line is commented out and one line is NOT commented out.

What I Would Like Help With:
Creating a button somewhere in the Adin Section of my XOOPS Site that would in effect:
When Selecting the "Off" button, it would Comment out:

var $htmlEditor = array( 'XoopsFormTinyeditorTextArea', '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php' );

AND "uncomment" out:

/*var $htmlEditor = array();*/

Questions:
1. Is this something that can easily be accomplished with php coding by a novice php person?
2. Can some point me in the right direction or some documentation so I can figure out how to do this?

2
zyspec
Re: Help to switch 2 lines of code on the fly
  • 2007/3/8 13:21

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


You could just enable it for Admin automatically unless you really WANT a button....

Just comment out both of the lines and then you should be able to do something like:
if ($xoopsUser && ($xoopsUser->isAdmin())) {
  var 
$htmlEditor = array( 'XoopsFormTinyeditorTextArea''/class/xoopseditor/tinyeditor/formtinyeditortextarea.php' );
} else {
  var 
$htmlEditor = array();
}


You might have to add 'global $xoopsUser;' somewhere near the beginning of the file/function - but this should only use TinyE if use is an administrator.

3
TopKnot
Re: Help to switch 2 lines of code on the fly
  • 2007/3/9 20:15

  • TopKnot

  • Just popping in

  • Posts: 70

  • Since: 2005/9/27


Thanks zyspec for the reply. Your suggestion sounds like a good workaround for what I want.

I have been digging through php help sites trying to figure out way to add a button in the admin section. I guess the only way I can do this is by getting my hands dirty and just start experimenting with php code and XOOPS. Good learning experience.

But before I start the hacking and mod'ing, I will use the "zyspec" method as a tempo fix.

THANK YOU zyspec and XOOPS

Login

Who's Online

276 user(s) are online (151 user(s) are browsing Support Forums)


Members: 0


Guests: 276


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits