tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Source for file tangra_module_info_loader_file.class.php

Documentation is available at tangra_module_info_loader_file.class.php

  1. <?php
  2.  
  3. // $Id$
  4.  
  5. /**
  6.  * Contains class Tangra_Module_Info_Loader_File
  7.  *
  8.  * @package  tangra_lib
  9.  * @subpackage  modules_manager
  10.  */
  11.  
  12. /**
  13.  *
  14.  */
  15. require_once(TANGRA_MAIN_DIR.'modules_manager/module_ctrl_xml_importer.class.php');
  16.  
  17.  
  18. /**
  19.  * Loads module.ctrl.xml file and returns basic info about it - HID and version
  20.  *
  21.  * @package  tangra_lib
  22.  * @subpackage  modules_manager
  23.  */
  24.     /**
  25.      * Path to module.ctrl.xml file
  26.      *
  27.      * @var string 
  28.      * @internal
  29.      */
  30.     private $file_path;
  31.  
  32.  
  33.     /**
  34.      * Constructor
  35.      *
  36.      * @param string $file_path Path to module.ctrl.xml file
  37.      */
  38.     function __construct($file_path ''{
  39.         if (file_exists($file_path)) {
  40.             $this->file_path = $file_path;
  41.         else {
  42.             throw new Tangra_Exception('File not exist: '.$file_path);
  43.         }
  44.     }
  45.  
  46.  
  47.     /**
  48.      * Returns module info
  49.      *
  50.      * @return array  array('hid' =>  MODULE_ ID, 'version' => VERSION;
  51.      */
  52.     public function get_module_info({
  53.         $ret array('hid' => '''version' => '');
  54.  
  55.         $xml_str @file_get_contents($this->file_path);
  56.  
  57.         if ($xml_str{
  58.             $xml @simplexml_load_string($xml_str);
  59.             if ($xml !== false{
  60.                 $mod_release_details Module_CTRL_XML_Importer::capture_module_release_details($xml);
  61.  
  62.                 $ret['hid'$mod_release_details['mod_release']['hid'];
  63.                 $ret['version'$mod_release_details['mod_release']['version'];
  64.             }
  65.         }
  66.  
  67.         return $ret;
  68.     }
  69. }