aliroExtensionHandler Class Reference

Inheritance diagram for aliroExtensionHandler:

cachedSingleton

List of all members.

Public Member Functions

 checkStarterPack ()
 getTemplateExtensions ()
 removeExtensions ($formalnames, $isUpgrade=false)
 getExtensions ($type='')
 getExtensionByName ($formalname)
 getXMLFileName ($formalname)

Static Public Member Functions

static getInstance ()
static getExtensionTypeHandler ($type)

Protected Member Functions

 __construct ()

Static Protected Attributes

static $instance = __CLASS__

Private Member Functions

 deleteFromTable ($extlist, $table, $fieldname, $database)
 removeExtensionFiles ($handler, $extension)
 uninstallExtension ($handler, $extension)

Private Attributes

 $extensions = array()
 $extensionsByType = array()
 $templates = array()


Detailed Description

Definition at line 86 of file aliroExtensionHandler.php.


Constructor & Destructor Documentation

aliroExtensionHandler::__construct (  )  [protected]

Definition at line 92 of file aliroExtensionHandler.php.

References aliroCoreDatabase::getInstance().

00092                                       {
00093         $results = aliroCoreDatabase::getInstance()->doSQLget("SELECT * FROM #__extensions", 'aliroExtension');
00094         if ($results) {
00095             foreach ($results as $extension) {
00096                 $this->extensions[$extension->formalname] = $extension;
00097                 if ($extension->type == 'template') $this->templates[] = $extension->formalname;
00098             }
00099             // Sort by formal name (unique)
00100             ksort($this->extensions);
00101             foreach ($this->extensions as $extension) $this->extensionsByType[$extension->type][$extension->formalname] = $extension;
00102         }
00103     }


Member Function Documentation

static aliroExtensionHandler::getInstance (  )  [static]

aliroExtensionHandler::checkStarterPack (  ) 

Definition at line 109 of file aliroExtensionHandler.php.

References criticalInfo::getInstance().

00109                                         {
00110         if (0 == count($this->extensions)) {
00111             $starterpack = criticalInfo::getInstance()->admin_absolute_path.'/starterpack/';
00112             $dir = new aliroDirectory($starterpack);
00113             foreach ($dir->listAll() as $package) if ('index.html' != $package) {
00114                 $installer = new aliroInstaller();
00115                 $installer->installfromfile($starterpack.$package);
00116             }
00117         }
00118     }

aliroExtensionHandler::getTemplateExtensions (  ) 

Definition at line 120 of file aliroExtensionHandler.php.

00120                                              {
00121         $result = array();
00122         foreach ($this->templates as $templatename) $result[$templatename] = $this->extensions[$templatename];
00123         return $result;
00124     }

aliroExtensionHandler::removeExtensions ( formalnames,
isUpgrade = false 
)

Definition at line 126 of file aliroExtensionHandler.php.

References cachedSingleton::clearCache(), deleteFromTable(), getExtensionByName(), getExtensionTypeHandler(), aliroMenuHandler::getInstance(), aliroCoreDatabase::getInstance(), removeExtensionFiles(), and uninstallExtension().

00126                                                                       {
00127         $extlist = implode("', '", (array) $formalnames);
00128         foreach ((array) $formalnames as $formalname) {
00129             if ($extension = $this->getExtensionByName ($formalname)) {
00130                 $handler = aliroExtensionHandler::getExtensionTypeHandler($extension->type);
00131                 if (!$isUpgrade) $this->uninstallExtension($handler, $extension);
00132                 $this->removeExtensionFiles($handler, $extension);
00133             }
00134         }
00135         $database = aliroCoreDatabase::getInstance();
00136         $this->deleteFromTable($extlist, 'extensions', 'formalname', $database);
00137         $this->deleteFromTable($extlist, 'components', 'option', $database);
00138         if (!$isUpgrade) $this->deleteFromTable($extlist, 'modules', 'module', $database);
00139         $this->deleteFromTable($extlist, 'mambots', 'element', $database);
00140         $this->deleteFromTable($extlist, 'classmap', 'formalname', $database);
00141         if (!$isUpgrade) $database->doSQL("DELETE FROM `#__menu` WHERE `component` != '' AND `component` IN ('$extlist')");
00142         $database->doSQL("DELETE FROM `#__admin_menu` WHERE `component` != '' AND `component` IN ('$extlist')");
00143         $database->doSQL("DELETE `#__modules_menu` FROM `#__modules_menu` LEFT JOIN `#__modules` ON `moduleid`=`id` WHERE `id` IS NULL");
00144         aliroMenuHandler::getInstance()->clearCache();
00145         $this->clearCache();
00146     }

aliroExtensionHandler::deleteFromTable ( extlist,
table,
fieldname,
database 
) [private]

Definition at line 148 of file aliroExtensionHandler.php.

Referenced by removeExtensions().

00148                                                                                {
00149         $database->doSQL("DELETE FROM `#__$table` WHERE `$fieldname` IN ('$extlist')");
00150     }

aliroExtensionHandler::removeExtensionFiles ( handler,
extension 
) [private]

Definition at line 152 of file aliroExtensionHandler.php.

Referenced by removeExtensions().

00152                                                                  {
00153         if ($handler) {
00154             $handler->remove($extension->formalname, $extension->admin);
00155             $handler->clearCache();
00156         }
00157     }

aliroExtensionHandler::uninstallExtension ( handler,
extension 
) [private]

Definition at line 159 of file aliroExtensionHandler.php.

Referenced by removeExtensions().

00159                                                                {
00160         if ('component' == $extension->type AND file_exists(_ALIRO_ABSOLUTE_PATH.$extension->xmlfile)) {
00161             $installer = new aliroExtensionInstaller(_ALIRO_ABSOLUTE_PATH.$extension->xmlfile);
00162             $installer->removeComponent($handler, $extension);
00163         }
00164     }

aliroExtensionHandler::getExtensions ( type = ''  ) 

Definition at line 166 of file aliroExtensionHandler.php.

00166                                              {
00167         if ($type) return isset($this->extensionsByType[$type]) ? $this->extensionsByType[$type] : array();
00168         return $this->extensions;
00169     }

aliroExtensionHandler::getExtensionByName ( formalname  ) 

Definition at line 171 of file aliroExtensionHandler.php.

Referenced by getXMLFileName(), and removeExtensions().

00171                                                      {
00172         return isset($this->extensions[$formalname]) ? $this->extensions[$formalname] : null;
00173     }

aliroExtensionHandler::getXMLFileName ( formalname  ) 

Definition at line 175 of file aliroExtensionHandler.php.

References getExtensionByName().

00175                                                  {
00176         if ($ext = $this->getExtensionByName ($formalname)) return $ext->xmlfile;
00177         return '';
00178     }

static aliroExtensionHandler::getExtensionTypeHandler ( type  )  [static]

Definition at line 180 of file aliroExtensionHandler.php.

References aliro::getInstance().

Referenced by aliroExtensionInstaller::install(), and removeExtensions().

00180                                                            {
00181         $prettytype = strtoupper(substr($type,0,1)).strtolower(substr($type,1));
00182         $handlername = 'aliro'.$prettytype.'Handler';
00183         if (aliro::getInstance()->classExists($handlername)) return call_user_func(array($handlername, 'getInstance'));
00184         else return null;
00185     }


Member Data Documentation

aliroExtensionHandler::$instance = __CLASS__ [static, protected]

Definition at line 87 of file aliroExtensionHandler.php.

aliroExtensionHandler::$extensions = array() [private]

Definition at line 88 of file aliroExtensionHandler.php.

aliroExtensionHandler::$extensionsByType = array() [private]

Definition at line 89 of file aliroExtensionHandler.php.

aliroExtensionHandler::$templates = array() [private]

Definition at line 90 of file aliroExtensionHandler.php.


The documentation for this class was generated from the following file:

Generated on Wed May 14 13:01:58 2008 for ALIRO by  doxygen 1.5.5