Actions

API15

JInstallerTemplate/uninstall

From Joomla! Documentation

< API15:JInstallerTemplate
Revision as of 17:23, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
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

[Edit Descripton]

Description:JInstallerTemplate/uninstall

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

[Edit See Also] SeeAlso:JInstallerTemplate/uninstall

Examples

<CodeExamplesForm />