JInstallerLibrary/uninstall
From Joomla! Documentation
< API16:JInstallerLibraryRevision as of 22:01, 13 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
Revision as of 22:01, 13 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
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.
Description[edit]
Custom uninstall method
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
uninstall($id)
Parameter Name | Default Value | Description |
---|---|---|
$id | $id The id of the library to uninstall |
Returns[edit]
boolean True on success
Defined in[edit]
libraries/joomla/installer/adapters/library.php
Importing[edit]
jimport( 'joomla.installer.adapters.library' );
Source Body[edit]
function uninstall($id)
{
// Initialise variables.
$retval = true;
// First order of business will be to load the module object table from the database.
// This should give us the necessary information to proceed.
$row = & JTable::getInstance('extension');
if (!$row->load((int) $id) || !strlen($row->element))
{
JError::raiseWarning(100, JText::_('ERRORUNKOWNEXTENSION'));
return false;
}
// Is the library we are trying to uninstall a core one?
// Because that is not a good idea...
if ($row->protected)
{
JError::raiseWarning(100, JText::_('Library').' '.JText::_('Uninstall').': '.JText::sprintf('WARNCOREMODULE', $row->name)."<br />".JText::_('WARNCOREMODULE2'));
return false;
}
$manifestFile = JPATH_MANIFESTS.DS.'libraries' . DS . $row->element .'.xml';
// Because libraries may not have their own folders we cannot use the standard method of finding an installation manifest
if (file_exists($manifestFile))
{
$manifest = new JLibraryManifest($manifestFile);
// Set the plugin root path
$this->parent->setPath('extension_root', JPATH_ROOT.DS.'libraries'.DS.$manifest->libraryname);
$xml = JFactory::getXML($manifestFile);
// If we cannot load the xml file return null
if ( ! $xml)
{
JError::raiseWarning(100, JText::_('Library').' '.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::_('Library').' '.JText::_('Uninstall').': '.JText::_('Invalid manifest file'));
return false;
}
$this->parent->removeFiles($xml->files, -1);
JFile::delete($manifestFile);
}
else
{
// remove this row entry since its invalid
$row->delete($row->extension_id);
unset($row);
JError::raiseWarning(100, 'Library Uninstall: Manifest File invalid or not found');
return false;
}
// TODO: Change this so it walked up the path backwards so we clobber multiple empties
// If the folder is empty, let's delete it
if (JFolder::exists($this->parent->getPath('extension_root')))
{
if (is_dir($this->parent->getPath('extension_root')))
{
$files = JFolder::files($this->parent->getPath('extension_root'));
if (!count($files)) {
JFolder::delete($this->parent->getPath('extension_root'));
}
}
}
$this->parent->removeFiles($xml->languages);
$row->delete($row->extension_id);
unset($row);
return $retval;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />