Пример #1
0
 /**
  * Parse a XML file to complete an array of extension objects
  * @brief Create extension from XML.
  * @param type $p_file filename
  * @return array of Extension
  */
 static function read_definition($p_file)
 {
     global $cn;
     $dom = new DomDocument('1.0');
     $dom->load($p_file);
     $xml = simplexml_import_dom($dom);
     $nb_plugin = count($xml->plugin);
     $a_extension = array();
     for ($i = 0; $i < $nb_plugin; $i++) {
         $extension = new Extension($cn);
         try {
             $extension->check_xml($xml);
         } catch (Exception $ex) {
             echo_warning($e->getMessage());
             if ($ex->getCode() == 1) {
                 continue;
             }
         }
         $extension->me_file = trim($xml->plugin[$i]->root) . '/' . trim($xml->plugin[$i]->file);
         $extension->me_code = trim($xml->plugin[$i]->code);
         $extension->me_description = isset($xml->plugin[$i]->description) ? trim($xml->plugin[$i]->description) : "";
         $extension->me_description_etendue = trim($xml->plugin[$i]->author) ? trim($xml->plugin[$i]->author) : "";
         $extension->me_type = 'PL';
         $extension->me_menu = trim($xml->plugin[$i]->name);
         $extension->me_parameter = 'plugin_code=' . trim($xml->plugin[$i]->code);
         $a_extension[] = clone $extension;
     }
     return $a_extension;
 }