Example #1
0
 /**
  * Custom uninstall method
  *
  * @access	public
  * @param	int		$path		The template name
  * @param	int		$clientId	The id of the client
  * @return	boolean	True on success
  * @since	1.5
  */
 function _actionUninstall()
 {
     $ids = (array) KRequest::get('post.id', 'string');
     // For a template the id will be the template name which represents the subfolder of the templates folder that the template resides in.
     if (empty($ids)) {
         JError::raiseWarning(100, KInflector::singularize($this->_identifier->name) . ' ' . JText::_('Uninstall') . ': ' . JText::_(KInflector::singularize($this->_identifier->name) . ' id is empty, cannot uninstall files'));
         return false;
     }
     foreach ($ids as $id) {
         $this->set('extension_root', $this->_basepath . DS . $id);
         $this->set('source', $this->get('extension_root'));
         $manifest =& $this->_findManifest();
         if (!is_a($manifest, 'JSimpleXML')) {
             // Make sure we delete the folders
             JFolder::delete($this->installer->getPath('extension_root'));
             JError::raiseWarning(100, KInflector::singularize($this->_identifier->name) . ' ' . JTEXT::_('Uninstall') . ': ' . JTEXT::_('Package manifest file invalid or not found'));
             return false;
         }
         $root =& $manifest->document;
         // Remove files
         Napi::import('lib.joomla.installer.installer');
         JInstaller::removeFiles($root->getElementByPath('media'), 0);
         JInstaller::removeFiles($root->getElementByPath('languages'));
         JInstaller::removeFiles($root->getElementByPath('administration/languages'), 1);
         // Delete the template directory
         if (JFolder::exists($this->get('extension_root'))) {
             JFolder::delete($this->get('extension_root'));
         } else {
             JError::raiseWarning(100, KInflector::singularize($this->_identifier->name) . ' ' . JText::_('Uninstall') . ': ' . JText::_('Directory does not exist, cannot remove files'));
             return false;
         }
     }
     $text = count($ids) > 1 ? KInflector::pluralize($this->_identifier->name) . ' successfully removed' : KInflector::singularize($this->_identifier->name) . ' successfully removed';
     $this->setRedirect('view=' . KInflector::pluralize($this->_identifier->name) . '&format=' . KRequest::get('get.format', 'cmd', 'html'), JText::_($text));
     return true;
 }