Subversion Repositories personal-webbase

Rev

Rev 1 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. class WebBase_Module_Info
  4. {
  5.         private $f_name;
  6.         private $f_author;
  7.         private $f_version;
  8.         private $f_language;
  9.  
  10.         // 0 = Public Freeware
  11.         // 1 = Public Shareware
  12.         // 2 = Private Secured
  13.         // 3 = Personal WebBase-Core
  14.         // 4 = Personal WebBase-Enclosure
  15.         private $f_license;
  16.  
  17.         function name() {
  18.                 return $this->f_name;
  19.         }
  20.  
  21.         function author() {
  22.                 return $this->f_author;
  23.         }
  24.  
  25.         function version() {
  26.                 return $this->f_version;
  27.         }
  28.  
  29.         function language() {
  30.                 return $this->f_language;
  31.         }
  32.  
  33.         function license() {
  34.                 return $this->f_license;
  35.         }
  36.  
  37.         function WebBase_Module_Info($name, $author, $version, $language, $license) {
  38.                 $this->f_name = $name;
  39.                 $this->f_author = $author;
  40.                 $this->f_version = $version;
  41.                 $this->f_language = $language;
  42.                 $this->f_license = $license;
  43.         }
  44. };
  45.  
  46. class WBModuleHandler {
  47.  
  48.         private static $cache_module_information = Array();
  49.  
  50.         function get_module_information($modulename)
  51.         {
  52.                 if (isset(self::$cache_module_information[$modulename])) {
  53.                         return self::$cache_module_information[$modulename];
  54.                 }
  55.  
  56.                 if (function_exists('getmicrotime')) $ss = getmicrotime();
  57.  
  58.                 $xml = new xml();
  59.  
  60.                 if ((!strpos($modulename, '..')) && (file_exists('modules/'.$modulename.'/info.xml')))
  61.                 {
  62.                         $object = $xml->xml_file_to_object('modules/'.$modulename.'/info.xml');
  63.  
  64.                         if ($object->name == 'moduleinfo')
  65.                         {
  66.                                 $v_expected_name = '';
  67.                                 $v_author = '';
  68.                                 $v_version = '';
  69.                                 $v_language = '';
  70.                                 $v_license = '';
  71.  
  72.                                 foreach ($object->children as $m1 => $m2)
  73.                                 {
  74.                                         if ($object->children[$m1]->name == 'expected_name') $v_expected_name = $object->children[$m1]->content;
  75.                                         if ($object->children[$m1]->name == 'author') $v_author = $object->children[$m1]->content;
  76.                                         if ($object->children[$m1]->name == 'version') $v_version = $object->children[$m1]->content;
  77.                                         if ($object->children[$m1]->name == 'language') $v_language = $object->children[$m1]->content;
  78.                                         if ($object->children[$m1]->name == 'license') $v_license = $object->children[$m1]->content;
  79.                                 }
  80.  
  81.                                 $output = new WebBase_Module_Info($v_expected_name, $v_author, $v_version, $v_language, $v_license);
  82.  
  83.                                 if ($output->caption == '') $output->caption = $modulename;
  84.  
  85.                                 if (function_exists('getmicrotime')) {
  86.                                         $ee = getmicrotime();
  87.                                         global $xml_time;
  88.                                         $xml_time += $ee-$ss;
  89.                                         global $xml_count;
  90.                                         $xml_count++;
  91.                                 }
  92.  
  93.                                 self::$cache_module_information[$modulename] = $output;
  94.  
  95.                                 return $output;
  96.                         }
  97.                         else
  98.                         {
  99.                                 return NULL;
  100.                         }
  101.                 }
  102.                 else
  103.                 {
  104.                         return NULL;
  105.                 }
  106.         }
  107.  
  108. }
  109.  
  110. ?>