示例#1
0
文件: inihelper.php 项目: 01J/furcom
 /**
  * Parses the GUI INI files and returns an array of groups and their data
  *
  * @return  array
  */
 public static function getGUIGroups()
 {
     // This is a static cache which persists between subsequent calls, but not
     // between successive page loads.
     static $gui_list = array();
     // Try to serve cached data first
     if (!empty($gui_list) && is_array($gui_list)) {
         if (count($gui_list) > 0) {
             return $gui_list;
         }
     }
     // Find absolute path to normal and plugins directories
     $path_list = static::getPaths('gui');
     // Initialize the array where we store our data
     $gui_list = array();
     // Loop for the paths where engines can be found
     foreach ($path_list as $path) {
         if (is_dir($path)) {
             if (is_readable($path)) {
                 if ($handle = @opendir($path)) {
                     // Store INI names in temp array because we'll sort based on filename (GUI order IS IMPORTANT!!)
                     $allINIs = array();
                     while (false !== ($filename = @readdir($handle))) {
                         if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . '/' . $filename)) {
                             $allINIs[] = $path . '/' . $filename;
                         }
                     }
                     // while readdir
                     @closedir($handle);
                     if (!empty($allINIs)) {
                         // Sort GUI files alphabetically
                         asort($allINIs);
                         // Include each GUI def file
                         foreach ($allINIs as $filename) {
                             $information = array();
                             $parameters = array();
                             AEUtilINI::parseInterfaceINI($filename, $information, $parameters);
                             // This effectively skips non-GUI INIs (e.g. the scripting INI)
                             if (!empty($information['description'])) {
                                 if (!isset($information['merge'])) {
                                     $information['merge'] = 0;
                                 }
                                 $group_name = substr(basename($filename), 0, -4);
                                 $def = array('information' => $information, 'parameters' => $parameters);
                                 if (!$information['merge'] || !isset($gui_list[$group_name])) {
                                     $gui_list[$group_name] = $def;
                                 } else {
                                     $gui_list[$group_name]['information'] = array_merge($gui_list[$group_name]['information'], $def['information']);
                                     $gui_list[$group_name]['parameters'] = array_merge($gui_list[$group_name]['parameters'], $def['parameters']);
                                 }
                             }
                         }
                     }
                 }
                 // if opendir
             }
             // if readable
         }
         // if is_dir
     }
     ksort($gui_list);
     // Push stack filter settings to the 03.filters section
     $path_list = static::getPaths('filter');
     // Loop for the paths where optional filters can be found
     foreach ($path_list as $path) {
         if (is_dir($path)) {
             if (is_readable($path)) {
                 if ($handle = @opendir($path)) {
                     // Store INI names in temp array because we'll sort based on filename (GUI order IS IMPORTANT!!)
                     $allINIs = array();
                     while (false !== ($filename = @readdir($handle))) {
                         if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . '/' . $filename)) {
                             $allINIs[] = $path . '/' . $filename;
                         }
                     }
                     // while readdir
                     @closedir($handle);
                     if (!empty($allINIs)) {
                         // Sort filter files alphabetically
                         asort($allINIs);
                         // Include each filter def file
                         foreach ($allINIs as $filename) {
                             $information = array();
                             $parameters = array();
                             AEUtilINI::parseInterfaceINI($filename, $information, $parameters);
                             if (!array_key_exists('03.filters', $gui_list)) {
                                 $gui_list['03.filters'] = array('parameters' => array());
                             }
                             if (!array_key_exists('parameters', $gui_list['03.filters'])) {
                                 $gui_list['03.filters']['parameters'] = array();
                             }
                             if (!is_array($parameters)) {
                                 $parameters = array();
                             }
                             $gui_list['03.filters']['parameters'] = array_merge($gui_list['03.filters']['parameters'], $parameters);
                         }
                     }
                 }
                 // if opendir
             }
             // if readable
         }
         // if is_dir
     }
     return $gui_list;
 }
示例#2
0
 /**
  * Parses the GUI INI files and returns an array of groups and their data
  * @return array
  */
 public static function getGUIGroups()
 {
     // This is a static cache which persists between subsequent calls, but not
     // between successive page loads.
     static $gui_list = array();
     // Try to serve cached data first
     if (!empty($gui_list) && is_array($qui_list)) {
         if (count($gui_list) > 0) {
             return $gui_list;
         }
     }
     // Find absolute path to normal and plugins directories
     $ds = DIRECTORY_SEPARATOR;
     $path_list = array(AEFactory::getAkeebaRoot() . '/core');
     if (AKEEBA_PRO) {
         $path_list[] = AEFactory::getAkeebaRoot() . '/plugins/core';
     }
     // Initialize the array where we store our data
     $gui_list = array();
     // Loop for the paths where engines can be found
     foreach ($path_list as $path) {
         if (is_dir($path)) {
             if (is_readable($path)) {
                 if ($handle = @opendir($path)) {
                     // Store INI names in temp array because we'll sort based on filename (GUI order IS IMPORTANT!!)
                     $allINIs = array();
                     while (false !== ($filename = @readdir($handle))) {
                         if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . $ds . $filename)) {
                             $allINIs[] = $path . $ds . $filename;
                         }
                     }
                     // while readdir
                     @closedir($handle);
                     if (!empty($allINIs)) {
                         // Sort GUI files alphabetically
                         asort($allINIs);
                         // Include each GUI def file
                         foreach ($allINIs as $filename) {
                             $information = array();
                             $parameters = array();
                             AEUtilINI::parseInterfaceINI($filename, $information, $parameters);
                             // This effectively skips non-GUI INIs (e.g. the scripting INI)
                             if (!empty($information['description'])) {
                                 $group_name = substr(basename($filename), 0, -4);
                                 $gui_list[$group_name] = array('information' => $information, 'parameters' => $parameters);
                             }
                         }
                     }
                 }
                 // if opendir
             }
             // if readable
         }
         // if is_dir
     }
     ksort($gui_list);
     // Push stack filter settings to the 03.filters section
     $path_list = array(AEFactory::getAkeebaRoot() . $ds . 'platform' . $ds . 'filters' . $ds . 'stack', AEFactory::getAkeebaRoot() . $ds . 'filters' . $ds . 'stack', AEFactory::getAkeebaRoot() . $ds . 'plugins' . $ds . 'filters' . $ds . 'stack');
     // Loop for the paths where optional filters can be found
     foreach ($path_list as $path) {
         if (is_dir($path)) {
             if (is_readable($path)) {
                 if ($handle = @opendir($path)) {
                     // Store INI names in temp array because we'll sort based on filename (GUI order IS IMPORTANT!!)
                     $allINIs = array();
                     while (false !== ($filename = @readdir($handle))) {
                         if (strtolower(substr($filename, -4)) == '.ini' && @is_file($path . $ds . $filename)) {
                             $allINIs[] = $path . $ds . $filename;
                         }
                     }
                     // while readdir
                     @closedir($handle);
                     if (!empty($allINIs)) {
                         // Sort filter files alphabetically
                         asort($allINIs);
                         // Include each filter def file
                         foreach ($allINIs as $filename) {
                             $information = array();
                             $parameters = array();
                             AEUtilINI::parseInterfaceINI($filename, $information, $parameters);
                             if (!empty($gui_list['03.filters']['parameters'])) {
                                 $gui_list['03.filters']['parameters'][] = array('title' => '', 'description' => '', 'type' => 'separator', 'default' => '');
                             }
                             $gui_list['03.filters']['parameters'] = array_merge($gui_list['03.filters']['parameters'], $parameters);
                         }
                     }
                 }
                 // if opendir
             }
             // if readable
         }
         // if is_dir
     }
     return $gui_list;
 }