Gdn_ApplicationManager::availableApplications PHP Method

availableApplications() public method

Looks through the root Garden directory for valid applications and returns them as an associative array of "Application Name" => "Application Info Array". It also adds a "Folder" definition to the Application Info Array for each application.
    public function availableApplications()
    {
        if (!is_array($this->availableApplications)) {
            $ApplicationInfo = array();
            $AppFolders = Gdn_FileSystem::folders(PATH_APPLICATIONS);
            // Get an array of all application folders
            // Now look for about files within them.
            $ApplicationAboutFiles = Gdn_FileSystem::findAll(PATH_APPLICATIONS, 'settings' . DS . 'about.php', $AppFolders);
            // Include them all right here and fill the application info array
            $ApplicationCount = count($ApplicationAboutFiles);
            for ($i = 0; $i < $ApplicationCount; ++$i) {
                include $ApplicationAboutFiles[$i];
                // Define the folder name for the newly added item
                foreach ($ApplicationInfo as $ApplicationName => $Info) {
                    if (array_key_exists('Folder', $ApplicationInfo[$ApplicationName]) === false) {
                        $Folder = substr($ApplicationAboutFiles[$i], strlen(PATH_APPLICATIONS));
                        if (substr($Folder, 0, 1) == DS) {
                            $Folder = substr($Folder, 1);
                        }
                        $Folder = substr($Folder, 0, strpos($Folder, DS));
                        $ApplicationInfo[$ApplicationName]['Folder'] = $Folder;
                    }
                }
            }
            // Add all of the indexes to the applications.
            foreach ($ApplicationInfo as $Index => &$Info) {
                $Info['Index'] = $Index;
            }
            $this->availableApplications = $ApplicationInfo;
        }
        return $this->availableApplications;
    }

Usage Example

Esempio n. 1
0
 /**
  *
  *
  * @param bool $Enabled
  * @return array
  */
 public function getAddons($Enabled = false)
 {
     $Addons = array();
     // Get the core.
     self::_addAddon(array('AddonKey' => 'vanilla', 'AddonType' => 'core', 'Version' => APPLICATION_VERSION, 'Folder' => '/'), $Addons);
     // Get a list of all of the applications.
     $ApplicationManager = new Gdn_ApplicationManager();
     if ($Enabled) {
         $Applications = $ApplicationManager->availableApplications();
     } else {
         $Applications = $ApplicationManager->enabledApplications();
     }
     foreach ($Applications as $Key => $Info) {
         // Exclude core applications.
         if (in_array(strtolower($Key), array('conversations', 'dashboard', 'skeleton', 'vanilla'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'application', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, strtolower($Key)));
         self::_AddAddon($Addon, $Addons);
     }
     // Get a list of all of the plugins.
     $PluginManager = Gdn::pluginManager();
     if ($Enabled) {
         $Plugins = $PluginManager->enabledPlugins();
     } else {
         $Plugins = $PluginManager->availablePlugins();
     }
     foreach ($Plugins as $Key => $Info) {
         // Exclude core plugins.
         if (in_array(strtolower($Key), array())) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'plugin', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, $Key));
         self::_addAddon($Addon, $Addons);
     }
     // Get a list of all the themes.
     $ThemeManager = new Gdn_ThemeManager();
     if ($Enabled) {
         $Themes = $ThemeManager->enabledThemeInfo(true);
     } else {
         $Themes = $ThemeManager->availableThemes();
     }
     foreach ($Themes as $Key => $Info) {
         // Exclude core themes.
         if (in_array(strtolower($Key), array('default'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'theme', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/themes/' . GetValue('Folder', $Info, $Key));
         self::_addAddon($Addon, $Addons);
     }
     // Get a list of all locales.
     $LocaleModel = new LocaleModel();
     if ($Enabled) {
         $Locales = $LocaleModel->enabledLocalePacks(true);
     } else {
         $Locales = $LocaleModel->availableLocalePacks();
     }
     foreach ($Locales as $Key => $Info) {
         // Exclude core themes.
         if (in_array(strtolower($Key), array('skeleton'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'locale', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/locales/' . GetValue('Folder', $Info, $Key));
         self::_addAddon($Addon, $Addons);
     }
     return $Addons;
 }