API15

JInstallerTemplate/uninstall

From Joomla! Documentation

< API15:JInstallerTemplate
Revision as of 17:23, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Custom uninstall method <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</no...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Custom uninstall method

[Edit Descripton]

Template:Description:JInstallerTemplate/uninstall

Syntax[edit]

uninstall($name, $clientId)
Parameter Name Default Value Description
$name $path The template name
$clientId $clientId The id of the client

Returns[edit]

boolean True on success

Defined in[edit]

libraries/joomla/installer/adapters/template.php

Importing[edit]

jimport( 'joomla.installer.adapters.template' );

Source Body[edit]

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] Template:SeeAlso:JInstallerTemplate/uninstall

Examples[edit]

<CodeExamplesForm />