Example #1
0
 /**
  * Constructor
  *
  * @param string $caption   Caption
  * @param string $name      Name for textarea field
  * @param array  $configs   configures: editor - editor identifier; name - textarea field name; width, height - dimensions for textarea; value - text content
  * @param bool   $nohtml    use non-WYSIWYG editor onfailure
  * @param string $OnFailure editor to be used if current one failed
  *
  */
 public function __construct($caption, $name, $configs = null, $nohtml = false, $OnFailure = '')
 {
     // Backward compatibility: $name -> editor name; $configs['name'] -> textarea field name
     if (!isset($configs['editor'])) {
         $configs['editor'] = $name;
         $name = $configs['name'];
         // New: $name -> textarea field name; $configs['editor'] -> editor name; $configs['name'] -> textarea field name
     } else {
         $configs['name'] = $name;
     }
     parent::__construct($caption, $name);
     xoops_load('XoopsEditorHandler');
     $editor_handler = XoopsEditorHandler::getInstance();
     $this->editor = $editor_handler->get($configs['editor'], $configs, $nohtml, $OnFailure);
 }
 /**
  * Constructor
  *
  * @param string $caption    Caption
  * @param string $name       "name" attribute
  * @param string $value      Initial text
  * @param int    $rows       Number of rows
  * @param int    $cols       Number of columns
  * @param string $hiddentext Identifier for hidden Text
  * @param array  $options    Extra options
  */
 public function __construct($caption, $name, $value = '', $rows = 5, $cols = 50, $hiddentext = 'xoopsHiddenText', $options = array())
 {
     global $xoopsConfig;
     static $inLoop = 0;
     ++$inLoop;
     // Second loop, invalid, return directly
     if ($inLoop > 2) {
         return null;
     }
     // Else, initialize
     parent::__construct($caption, $name, $value, $rows, $cols);
     $this->_hiddenText = $hiddentext;
     if ($inLoop > 1) {
         return null;
     }
     if (!isset($options['editor'])) {
         if (isset($xoopsConfig['editor'])) {
             $options['editor'] = $xoopsConfig['editor'];
         }
     }
     if (!empty($this->htmlEditor) || !empty($options['editor'])) {
         $options['name'] = $this->getName();
         $options['value'] = $this->getValue();
         if (!empty($options['editor'])) {
             $this->htmlEditor = is_array($options['editor']) ? $options['editor'] : array($options['editor']);
         }
         if (count($this->htmlEditor) == 1) {
             xoops_load('XoopsEditorHandler');
             $editor_handler = XoopsEditorHandler::getInstance();
             $this->htmlEditor = $editor_handler->get($this->htmlEditor[0], $options);
             if ($inLoop > 1) {
                 $this->htmlEditor = null;
             }
         } else {
             list($class, $path) = $this->htmlEditor;
             include_once XOOPS_ROOT_PATH . $path;
             if (class_exists($class)) {
                 $this->htmlEditor = new $class($options);
             }
             if ($inLoop > 1) {
                 $this->htmlEditor = null;
             }
         }
     }
     $inLoop = 0;
 }