Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

ModuleInfoXml.class.php

Go to the documentation of this file.
00001 <?php
00009 include_once("core/utils/XmlParser.class.php");
00010 include_once("core/modules/moduleinformation/IModuleInfo.class.php");
00011 include_once("core/modules/moduleinformation/backends/ModuleInfoXmlPermission.class.php");
00012 include_once("core/modules/moduleinformation/backends/ModuleInfoXmlConfig.class.php");
00013 
00014 define("ERROR_OPEN", 1);
00015 define("ERROR_NO_NAME", 2);
00016 define("ERROR_NOT_VALID", 3);
00017 
00024 class ModuleInfoXml extends IModuleInfo
00025 {
00026         var $filename;          
00027         
00028         var $parser;            
00029         
00030         var $name;                      
00031         var $version;           
00032         var $screenname;        
00033         var $permissions;       
00034         var $config;            
00035         var $what_implements;   
00036         var $what_requires;             
00037         var $sql;                       
00038         
00044         function ModuleInfoXml($name)
00045         {
00046                 $this->filename = $name;
00047 
00048                 $this->parser = new XmlParser($this->filename);
00049                 
00050                 $error = $this->_ProcessXml();
00051                 
00052                 if (JSystem::IsError($error))
00053                         $this->RaiseConstructorError($error);           
00054         }
00055         
00060         function _ProcessXml()
00061         {
00062                 $tree =& $this->parser->getTree();
00063                 
00064                 // Getting attributes
00065                 $this->name = $tree["attributes"]["name"];
00066                 if (! $this->name)
00067                         return $this->RaiseError(ERROR_NO_NAME, "The module has no name");
00068                 $this->version = $tree["attributes"]["version"];
00069                 
00070                 // Processing the children
00071                 $this->_ProcessXmlChildren($tree["children"]);
00072         }
00073         
00078         function _ProcessXmlChildren($tree)
00079         {
00080                 foreach ($tree as $childtree)
00081                 {
00082                         switch($childtree["tag"])
00083                         {
00084                                 case "screenname":
00085                                         $lang = $childtree["attributes"]["lang"];
00086                                         if (!$childtree["attributes"]["lang"])
00087                                                 $lang = "default";
00088                                         $this->screenname[$lang] = $childtree["value"];
00089                                         break;
00090                                         
00091                                 case "permissions":
00092                                         $this->_ProcessXmlPermissions($childtree);
00093                                         break;
00094                                 
00095                                 case "config":
00096                                         $this->_ProcessXmlConfig($children);
00097                                         break;
00098                                         
00099                                 case "implements":
00100                                         $this->what_implements[] = $childtree["value"];
00101                                         break;
00102                                 
00103                                 case "requires":
00104                                         $this->what_requires[] = $childtree["value"];
00105                                         break;
00106                                         
00107                                 case "sql":
00108                                         $this->sql[] = $childtree["value"];
00109                                         break;
00110                         }
00111                 }
00112         }
00113         
00118         function _ProcessXmlPermissions($tree)
00119         {
00120                 if(count($tree["children"]) > 0)
00121                 {
00122                         foreach($tree["children"] as $perm)
00123                         {
00124                                 $mixperm = new ModuleInfoXmlPermission($perm);
00125                                 $this->permissions[$mixperm->getName()] = $mixperm;
00126                         }
00127                 }
00128         }
00129         
00134         function _ProcessXmlConfig($tree)
00135         {
00136                 if (count($tree["children"]) > 0)
00137                 {
00138                         foreach($tree["children"] as $conf)
00139                         {
00140                                 $mixconf = new ModuleInfoXmlConfig($conf);
00141                                 $this->config[$mixconf->getName()] = $mixconf;
00142                         }
00143                 }
00144         }
00145         
00150         function getName()
00151         {
00152                 return $this->name;
00153         }
00154         
00159         function getVersion()
00160         {
00161                 return $this->version;
00162         }
00163         
00169         function getScreenNames()
00170         {
00171                 return $this->screenname;
00172         } 
00173         
00178         function getPermissions()
00179         {
00180                 return $this->permissions;
00181         }
00182         
00187         function getConfig()
00188         {
00189                 return $this->config;
00190         }
00191         
00196         function getImplements()
00197         {
00198                 return $this->what_implements;
00199         }
00200         
00206         function Implements($string)
00207         {
00208                 return in_array($string, $this->what_implements);
00209         }
00210         
00215         function getRequires()
00216         {
00217                 return $this->what_requires;
00218         }
00219         
00225         function Requires($string)
00226         {
00227                 return in_array($string, $this->what_requires);
00228         }
00229         
00234         function getSql()
00235         {
00236                 return $this->sql;
00237         }
00238 }
00239 ?>

Generated on Wed Nov 19 20:29:35 2003 for James by doxygen 1.3.4