From Joomla! Documentation

< API16:JInstallerPackage

The "API16" 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.


Custom uninstall method

<! removed transcluded page call, red link never existed >


Parameter Name Default Value Description
$id $id The id of the package to uninstall


boolean True on success

Defined in



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

Source Body

function uninstall($id)
        // Initialise variables.
        $row    = null;
        $retval = true;

        $row = & JTable::getInstance('extension');

        $manifestFile = JPATH_MANIFESTS.DS.'packages' . DS . $row->get('element') .'.xml';
        $manifest = new JPackageManifest($manifestFile);

        // Set the plugin root path
        $this->parent->setPath('extension_root', JPATH_MANIFESTS.DS.'packages'.DS.$manifest->packagename);

        // Because libraries may not have their own folders we cannot use the standard method of finding an installation manifest
        if (file_exists($manifestFile))
                $xml =JFactory::getXML($manifestFile);

                // If we cannot load the xml file return false
                if (!$xml)
                        JError::raiseWarning(100, JText::_('Package').' '.JText::_('Uninstall').': '.JText::_('Could not load manifest file'));
                        return false;

                 * Check for a valid XML root tag.
                 * @todo: Remove backwards compatability in a future version
                 * Should be 'extension', but for backward compatability we will accept 'install'.
                if ($xml->getName() != 'install' && $xml->getName() != 'extension')
                        JError::raiseWarning(100, JText::_('Package').' '.JText::_('Uninstall').': '.JText::_('Invalid manifest file'));
                        return false;

                $error = false;
                foreach ($manifest->filelist as $extension)
                        $tmpInstaller = new JInstaller();
                        $id = $this->_getExtensionID($extension->type, $extension->id, $extension->client, $extension->group);
                        $client = JApplicationHelper::getClientInfo($extension->client,true);
                        if (!$tmpInstaller->uninstall($extension->type, $id, $client->id))
                                $error = true;
                                JError::raiseWarning(100, JText::_('Package').' '.JText::_('Uninstall').': '.
//                                                      JText::_('There was an error removing an extension!') . ' ' .
                                                JText::_('This extension may have already been uninstalled or might not have been uninstall properly') .': ' .
                                //$this->parent->abort(JText::_('Package').' '.JText::_('Uninstall').': '.JText::_('There was an error removing an extension, try reinstalling:') . basename($extension->filename));
                                //return false;
                // clean up manifest file after we're done if there were no errors
                if (!$error) {
                else {
                        JError::raiseWarning(100, JText::_('Package'). ' ' . JText::_('Uninstall'). ': '.
                                JText::_('Errors were detected, manifest file not removed!'));
                JError::raiseWarning(100, JText::_('Package').' '.JText::_('Uninstall').': '.
                        JText::_('Manifest File invalid or not found') . $id);
                return false;

        return $retval;

<! removed transcluded page call, red link never existed >


Code Examples