Beispiel #1
0
 function prepareForm(&$item)
 {
     if ($item->iscore) {
         @($data = file_get_contents(JPATH_COMPONENT . DS . 'editor' . DS . 'plugins' . DS . $item->name . '.xml'));
     } else {
         @($data = file_get_contents(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $item->name . DS . $item->name . '.xml'));
     }
     if ($data) {
         $data = preg_replace(array('/\\<params group="options">/i', '/\\<params>/i', '/\\<params(.*)\\<\\/params\\>/is'), array('<params name="advanced">', '<params name="basic">', '<config><fields name="params"><fieldset$1</fieldset></fields></config>'), $data);
         $data = str_replace(array('<install', '</install', '<params', '</params', '<param', '</param'), array('<form', '</form', '<fieldset', '</fieldset', '<field', '</field'), $data);
         // Re-style fields to J3.0
         // Can't just str_replace because fields might already have a class
         $xml = JCKHelper::getXML($data, false);
         $nodes = $xml->xpath('//field[@type="radio" or @type="resizeradio"]');
         foreach ($nodes as $node) {
             $radio = 'btn-group';
             $class = (string) $node->attributes()->class ? (string) $node->attributes()->class . chr(32) . $radio : $radio;
             if ($node->attributes()->class) {
                 $node->attributes()->class = $class;
             } else {
                 $node->addAttribute('class', $class);
             }
         }
         $data = $xml->asXML();
     } else {
         $data = '<install><form>dummy data</form></install>';
     }
     //end if
     JCKForm::addFieldPath(JPATH_COMPONENT . DS . 'models' . DS . 'fields');
     $form = JCKForm::getInstance('com_jckman.plugin', $data, array(), true, '//config');
     //$model 	= $this->getModel();
     //$form 	= $model->getPluginForm($data);
     //load plugins language file
     $lang = JFactory::getLanguage();
     $lang->load('com_plugins', JPATH_ADMINISTRATOR, null, false, false);
     JPluginHelper::importPlugin('content');
     $dispatcher = JDispatcher::getInstance();
     // Trigger the form preparation event.
     $jpara = new JRegistry($item->params);
     $data = $jpara->toArray();
     $results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
     $form->bind($data);
     return $form;
 }
Beispiel #2
0
 function prepareForm(&$row)
 {
     if ($row->iscore) {
         @($data = file_get_contents(JPATH_COMPONENT . DS . 'editor' . DS . 'plugins' . DS . $row->name . '.xml'));
     } else {
         @($data = file_get_contents(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $row->name . DS . $row->name . '.xml'));
     }
     if ($data) {
         $data = preg_replace(array('/\\<params group="options">/i', '/\\<params>/i', '/\\<params(.*)\\<\\/params\\>/is'), array('<params name="advanced">', '<params name="basic">', '<config><fields name="params"><fieldset$1</fieldset></fields></config>'), $data);
         $data = str_replace(array('<install', '</install', '<params', '</params', '<param', '</param'), array('<form', '</form', '<fieldset', '</fieldset', '<field', '</field'), $data);
     } else {
         $data = '<install><form>dummy data</form></install>';
     }
     //end if
     JCKForm::addFieldPath(JPATH_COMPONENT . DS . 'models' . DS . 'fields');
     $form = JCKForm::getInstance('com_jckman.plugin', $data, array(), true, '//config');
     //load plugins language file
     $lang = JFactory::getLanguage();
     $lang->load('com_plugins', JPATH_ADMINISTRATOR, null, false, false);
     JPluginHelper::importPlugin('content');
     $dispatcher = JDispatcher::getInstance();
     // Trigger the form preparation event.
     $jpara = new JRegistry($row->params);
     $data = $jpara->toArray();
     $results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
     $form->bind($data);
     return $form;
 }