/** * 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; }