Example #1
0
 public function loadXmlFile($filename)
 {
     if (!file_exists($filename)) {
         throw new RuntimeException("Project file does not exist: " . $filename);
     }
     $xml = @simplexml_load_file($filename);
     if (!$xml) {
         throw new RuntimeException("Incorrectly formatted XML in " . $filename);
     }
     $this->basepath = dirname(realpath($filename));
     echo "project.basepath:" . $this->basepath . "\n";
     $this->scope = new Scope();
     // parse topics, recursively
     foreach ($xml->topic as $node) {
         $this->parseXmlNode($node, 0);
     }
     // load project-level variables
     foreach ($xml->variable as $variable) {
         $this->scope->define((string) $variable['key'], (string) $variable);
     }
     // load languages
     foreach ($xml->language as $languageNode) {
         $language = new Language($this);
         $language->setName((string) $languageNode['name']);
         // load language-level variables
         foreach ($languageNode->variable as $variable) {
             $language->getScope()->define((string) $variable['key'], (string) $variable);
         }
         // load targets per language
         foreach ($languageNode->target as $targetNode) {
             $class = (string) $targetNode['class'];
             if ($class == '') {
                 $class = 'Doxedo\\Core\\Target\\SinglePage';
             }
             $target = new $class($language);
             $target->setName((string) $targetNode['name']);
             // load target-level variables
             foreach ($targetNode->variable as $variable) {
                 $target->getScope()->define((string) $variable['key'], (string) $variable);
             }
             $language->addTarget($target);
         }
         $this->addLanguage($language);
     }
 }
Example #2
0
 public function __construct(Language $language)
 {
     $this->language = $language;
     $this->scope = new Scope();
     $this->scope->setParent($language->getScope());
 }