API15:JInstallerTemplate/uninstall
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Custom uninstall method
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
uninstall($name, $clientId)
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | $path The template name | |
| $clientId | $clientId The id of the client |
Returns
boolean True on success
Defined in
libraries/joomla/installer/adapters/template.php
Importing
jimport( 'joomla.installer.adapters.template' );
Source Body
function uninstall( $name, $clientId ) { // Initialize variables $retval = true; // For a template the id will be the template name which represents the subfolder of the templates folder that the template resides in. if (!$name) { JError::raiseWarning(100, JText::_('Template').' '.JText::_('Uninstall').': '.JText::_('Template id is empty, cannot uninstall files')); return false; } // Get the template root path $client =& JApplicationHelper::getClientInfo( $clientId ); if (!$client) { JError::raiseWarning(100, JText::_('Template').' '.JText::_('Uninstall').': '.JText::_('Invalid application')); return false; } $this->parent->setPath('extension_root', $client->path.DS.'templates'.DS.$name); $this->parent->setPath('source', $this->parent->getPath('extension_root')); $manifest =& $this->parent->getManifest(); if (!is_a($manifest, 'JSimpleXML')) { // Make sure we delete the folders JFolder::delete($this->parent->getPath('extension_root')); JError::raiseWarning(100, JTEXT::_('Template').' '.JTEXT::_('Uninstall').': '.JTEXT::_('Package manifest file invalid or not found')); return false; } $root =& $manifest->document; // Remove files $this->parent->removeFiles($root->getElementByPath('media'), $clientId); $this->parent->removeFiles($root->getElementByPath('languages')); $this->parent->removeFiles($root->getElementByPath('administration/languages'), 1); // Delete the template directory if (JFolder::exists($this->parent->getPath('extension_root'))) { $retval = JFolder::delete($this->parent->getPath('extension_root')); } else { JError::raiseWarning(100, JText::_('Template').' '.JText::_('Uninstall').': '.JText::_('Directory does not exist, cannot remove files')); $retval = false; } return $retval; }
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />
