/**
  * Changes the editor on the fly
  *
  * @param string $editor String name of editor, excluding the word 'Helper'
  * @return void
  * @author Jose Diaz-Gonzalez
  **/
 public function changeEditor($editor)
 {
     $this->helper = ucfirst($editor);
     $prefix = '';
     if ($editor !== 'Form') {
         $prefix = 'Wysiwyg.';
     }
     if (!$this->importedHelpers[$this->helper]) {
         $this->importedHelpers[$this->helper] = true;
         $this->helpers[] = $prefix . $this->helper;
         $this->_helperMap = ObjectCollection::normalizeObjectArray($this->helpers);
     }
 }
Example #2
0
 /**
  * Default Constructor
  *
  * @param View $View The View this helper is being attached to.
  * @param array $settings Configuration settings for the helper.
  */
 public function __construct(View $View, $settings = array())
 {
     $this->_View = $View;
     $this->request = $View->request;
     if (!empty($this->helpers)) {
         $this->_helperMap = ObjectCollection::normalizeObjectArray($this->helpers);
     }
 }
Example #3
0
 /**
  * test normalizeObjectArray
  *
  * @return void
  */
 public function testnormalizeObjectArray()
 {
     $components = array('Html', 'Foo.Bar' => array('one', 'two'), 'Something', 'Banana.Apple' => array('foo' => 'bar'));
     $result = ObjectCollection::normalizeObjectArray($components);
     $expected = array('Html' => array('class' => 'Html', 'settings' => array()), 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), 'Something' => array('class' => 'Something', 'settings' => array()), 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')));
     $this->assertEquals($expected, $result);
     // This is the result after Controller::_mergeVars
     $components = array('Html' => null, 'Foo.Bar' => array('one', 'two'), 'Something' => null, 'Banana.Apple' => array('foo' => 'bar'));
     $result = ObjectCollection::normalizeObjectArray($components);
     $this->assertEquals($expected, $result);
 }
Example #4
0
 /**
  * Changes the editor on the fly
  *
  * @param string $editor String name of editor, excluding the word 'Helper'
  * @param array $helperOptions Each type of wysiwyg helper takes different options.
  * @return void
  * @throws MissingHelperException
  **/
 public function changeEditor($editor, $helperOptions = array())
 {
     $this->helper = ucfirst($editor);
     if (!empty($helperOptions)) {
         $this->updateSettings($helperOptions);
     }
     if (!isset($this->importedHelpers[$this->helper])) {
         throw new MissingHelperException(sprintf("Missing Wysiwyg.%s Helper", $this->helper));
     }
     if (!$this->importedHelpers[$this->helper]) {
         $class = 'Wysiwyg.' . $this->helper;
         $helpers = ObjectCollection::normalizeObjectArray(array($class));
         foreach ($helpers as $properties) {
             list($plugin, $class) = pluginSplit($properties['class']);
             $this->{$class} = $this->_View->Helpers->load($properties['class'], $properties['settings']);
         }
         $this->importedHelpers[$this->helper] = true;
     }
 }