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; }
/** * Method to detect the extension type from a package directory * * @param string $p_dir Path to package directory * * @return mixed Extension type string or boolean false on fail * * @since 11.1 */ public static function detectType($p_dir) { // Search the install dir for an XML file $files = JFolder::files($p_dir, '\\.xml$', 1, true); if (!count($files)) { JCKHelper::error(JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE')); return false; } foreach ($files as $file) { if (!($xml = JCKHelper::getXML($file))) { continue; } if ($xml->getName() != 'extension' && $xml->getName() != 'install') { unset($xml); continue; } $type = (string) $xml->attributes()->type; // Free up memory unset($xml); return $type; } JCKHelper::error(JText::_('JLIB_INSTALLER_ERROR_NOTFINDJOOMLAXMLSETUPFILE')); // Free up memory. unset($xml); return false; }