Exemplo n.º 1
0
 /**
  * Get extension versions
  * @return Array
  */
 public function getVersions()
 {
     $db = JFactory::getDBO();
     $versions = array('joomla' => array(), 'jce' => array());
     // Get Component xml
     $com_xml = WFXMLHelper::parseInstallManifest(JPATH_ADMINISTRATOR . '/components/com_jce/jce.xml');
     // set component version
     $versions['joomla']['com_jce'] = $com_xml['version'];
     // get mediabox version
     $mediabox_xml_file = WF_JOOMLA15 ? JPATH_PLUGINS . '/system/jcemediabox.xml' : JPATH_PLUGINS . '/system/jcemediabox/jcemediabox.xml';
     // set mediabox version
     if (file_exists($mediabox_xml_file)) {
         $mediabox_xml = WFXMLHelper::parseInstallManifest($mediabox_xml_file);
         $versions['joomla']['plg_jcemediabox'] = $mediabox_xml['version'];
     }
     wfimport('admin.models.plugins');
     $model = new WFModelPlugins();
     // get all plugins
     $plugins = $model->getPlugins();
     // get all extensions
     $extensions = $model->getExtensions();
     foreach ($plugins as $plugin) {
         if ($plugin->core == 0) {
             $file = WF_EDITOR_PLUGINS . '/' . $plugin->name . '/' . $plugin->name . '.xml';
             $xml = WFXMLHelper::parseInstallManifest($file);
             $versions['jce']['jce_' . $plugin->name] = $xml['version'];
         }
     }
     foreach ($extensions as $extension) {
         if ($extension->core == 0) {
             $file = WF_EDITOR_EXTENSIONS . '/' . $extension->folder . '/' . $extension->extension . '.xml';
             $xml = WFXMLHelper::parseInstallManifest($file);
             $versions['jce']['jce_' . $extension->folder . '_' . $extension->extension] = $xml['version'];
         }
     }
     return $versions;
 }
Exemplo n.º 2
0
 public function getPlugins()
 {
     wfimport('admin.models.plugins');
     $model = new WFModelPlugins();
     // get an array of all installed plugins in plugins folder
     $plugins = $model->getPlugins();
     $rows = array();
     $language = JFactory::getLanguage();
     foreach ($plugins as $plugin) {
         if ($plugin->core == 0) {
             $rows[] = $plugin;
             $language->load('com_jce_' . trim($plugin->name), JPATH_SITE);
         }
     }
     return $rows;
 }
Exemplo n.º 3
0
 /**
  * Return a list of icons for each JCE editor row
  *
  * @access public
  * @param string  The number of rows
  * @return The row array
  */
 private function getToolbar()
 {
     wfimport('admin.models.plugins');
     $model = new WFModelPlugins();
     $wf = WFEditor::getInstance();
     $rows = array('theme_advanced_buttons1' => '', 'theme_advanced_buttons2' => '', 'theme_advanced_buttons3' => '');
     // we need a profile object and some defined rows
     if (!is_object($this->profile) || empty($this->profile->rows)) {
         return $rows;
     }
     // get plugins
     $plugins = $model->getPlugins();
     // get core commands
     $commands = $model->getCommands();
     // merge plugins and commands
     $icons = array_merge($commands, $plugins);
     // create an array of rows
     $lists = explode(';', $this->profile->rows);
     // backwards compatability map
     $map = array('paste' => 'clipboard', 'spacer' => '|', 'forecolor' => 'fontcolor', 'backcolor' => 'backcolor');
     $x = 0;
     for ($i = 1; $i <= count($lists); $i++) {
         $buttons = array();
         $items = explode(',', $lists[$x]);
         foreach ($items as $item) {
             // set the plugin/command name
             $name = $item;
             // map legacy values etc.
             if (array_key_exists($item, $map)) {
                 $item = $map[$item];
             }
             // check if button should be in toolbar
             if ($item !== "|") {
                 if (array_key_exists($item, $icons) === false) {
                     continue;
                 }
                 // assign icon
                 $item = $icons[$item]->icon;
             }
             // check for custom plugin buttons
             if (array_key_exists($name, $plugins)) {
                 $custom = $wf->getParam($name . '.buttons');
                 if (!empty($custom)) {
                     $custom = array_filter((array) $custom);
                     if (empty($custom)) {
                         $item = "";
                     } else {
                         $a = array();
                         foreach (explode(',', $item) as $s) {
                             if (in_array($s, $custom) || $s == "|") {
                                 $a[] = $s;
                             }
                         }
                         $item = implode(',', $a);
                         // remove leading or trailing |
                         $item = trim($item, '|');
                     }
                 }
             }
             if (!empty($item)) {
                 // remove double |
                 $item = preg_replace('#(\\|,)+#', '|,', $item);
                 $buttons[] = $item;
             }
         }
         if (!empty($buttons)) {
             $rows['theme_advanced_buttons' . $i] = implode(',', $buttons);
         }
         $x++;
     }
     return $rows;
 }
Exemplo n.º 4
0
 /**
  * Uninstall method
  *
  * @access  public
  * @param 	string   $name  The name of the plugin to uninstall
  * @return  boolean True on success
  */
 public function uninstall($name)
 {
     // Initialize variables
     $row = null;
     $retval = true;
     $db = $this->parent->getDBO();
     $parts = explode('.', $name);
     // get name
     $name = array_pop($parts);
     // get type eg: plugin or extension
     $type = array_shift($parts);
     $this->parent->set('name', $name);
     // Load the language file
     $language = JFactory::getLanguage();
     switch ($type) {
         case 'plugin':
             // create $path
             $path = JPATH_COMPONENT_SITE . '/editor/tiny_mce/plugins/' . $name;
             // load language file
             $language->load('com_jce_' . $name, JPATH_SITE);
             break;
         case 'extension':
             $parts[] = $name;
             $path = dirname(JPATH_COMPONENT_SITE . '/editor/extensions/' . implode('/', $parts));
             // load language file
             $language->load('com_jce_' . trim(implode('_', $parts)), JPATH_SITE);
             break;
     }
     // Set the plugin root path
     $this->parent->setPath('extension_root', $path);
     // set manifest path
     $manifest = $this->parent->getPath('extension_root') . '/' . $name . '.xml';
     if (file_exists($manifest)) {
         $xml = WFXMLHelper::getXML($manifest);
         if (!$xml) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_INVALID'));
         }
         $this->parent->set('name', (string) $xml->name);
         $this->parent->set('version', (string) $xml->version);
         $this->parent->set('message', (string) $xml->description);
         // can't remove a core plugin
         if ((int) $xml->attributes()->core == 1) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_WARNCOREPLUGIN', WFText::_((string) $xml->name)));
             return false;
         }
         if ($type == 'extension') {
             $this->parent->removeFiles($xml->files, -1);
             JFile::delete($manifest);
         }
         // Remove all media and languages as well
         $this->parent->removeFiles($xml->languages, 0);
         $this->parent->removeFiles($xml->media, 0);
         /**
          * ---------------------------------------------------------------------------------------------
          * Custom Uninstallation Script Section
          * ---------------------------------------------------------------------------------------------
          */
         // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
         $uninstall = (string) $xml->children('uninstall.script');
         if ($uninstall) {
             // Element exists, does the file exist?
             if (is_file($this->parent->getPath('extension_root') . '/' . $uninstall)) {
                 ob_start();
                 ob_implicit_flush(false);
                 require_once $this->parent->getPath('extension_root') . '/' . $uninstall;
                 if (function_exists('com_uninstall')) {
                     if (com_uninstall() === false) {
                         JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_UNINSTALL_ERROR'));
                         $retval = false;
                     }
                 }
                 $msg = ob_get_contents();
                 ob_end_clean();
                 if ($msg != '') {
                     $this->parent->set('extension.message', $msg);
                 }
             }
         }
         // remove form profile
         if ($xml->icon) {
             $plugin = new StdClass();
             $plugin->name = (string) $xml->plugin;
             $plugin->icon = (string) $xml->icon;
             $plugin->path = $this->parent->getPath('extension_root');
             wfimport('admin.models.plugins');
             $model = new WFModelPlugins();
             $model->postInstall('uninstall', $plugin, $this);
         }
     } else {
         JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_ERROR'));
         $retval = false;
     }
     // set plugin path
     $path = $this->parent->getPath('extension_root');
     // set extension path
     if ($type == 'extension') {
         $path = $this->parent->getPath('extension_root') . '/' . $name;
     }
     if (JFolder::exists($path)) {
         // remove the plugin folder
         if (!JFolder::delete($path)) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_PLUGIN_FOLDER_ERROR'));
             $retval = false;
         }
     }
     return $retval;
 }