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 85 of file aliroExtensionHandler.php.


Constructor & Destructor Documentation

aliroExtensionHandler::__construct (  )  [protected]

Definition at line 91 of file aliroExtensionHandler.php.

References aliroCoreDatabase::getInstance().

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


Member Function Documentation

static aliroExtensionHandler::getInstance (  )  [static]

aliroExtensionHandler::checkStarterPack (  ) 

Definition at line 108 of file aliroExtensionHandler.php.

References criticalInfo::getInstance().

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

aliroExtensionHandler::getTemplateExtensions (  ) 

Definition at line 119 of file aliroExtensionHandler.php.

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

aliroExtensionHandler::removeExtensions ( formalnames,
isUpgrade = false 
)

Definition at line 125 of file aliroExtensionHandler.php.

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

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

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

Definition at line 147 of file aliroExtensionHandler.php.

Referenced by removeExtensions().

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

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

Definition at line 151 of file aliroExtensionHandler.php.

Referenced by removeExtensions().

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

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

Definition at line 158 of file aliroExtensionHandler.php.

Referenced by removeExtensions().

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

aliroExtensionHandler::getExtensions ( type = ''  ) 

Definition at line 165 of file aliroExtensionHandler.php.

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

aliroExtensionHandler::getExtensionByName ( formalname  ) 

Definition at line 170 of file aliroExtensionHandler.php.

Referenced by getXMLFileName(), and removeExtensions().

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

aliroExtensionHandler::getXMLFileName ( formalname  ) 

Definition at line 174 of file aliroExtensionHandler.php.

References getExtensionByName().

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

static aliroExtensionHandler::getExtensionTypeHandler ( type  )  [static]

Definition at line 179 of file aliroExtensionHandler.php.

References aliro::getInstance().

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

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


Member Data Documentation

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

Definition at line 86 of file aliroExtensionHandler.php.

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

Definition at line 87 of file aliroExtensionHandler.php.

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

Definition at line 88 of file aliroExtensionHandler.php.

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

Definition at line 89 of file aliroExtensionHandler.php.


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

Generated on Thu Apr 17 13:03:29 2008 for ALIRO by  doxygen 1.5.5