Exemplo n.º 1
0
 /**
  * Process parameters section.
  *
  * @return EcrProjectManifest
  */
 private function processParameters()
 {
     if ($this->project->isNew) {
         //-- No parameters for new projects
         if ('template' != $this->project->type) {
             return $this;
         }
         //-- Except for templates :(
         $path = $this->project->buildPath;
         $path .= '/site';
         //@todo admin templates ?
         $fileName = $path . '/templateDetails.xml';
         if (false == JFile::exists($fileName)) {
             return $this;
         }
         $refXml = EcrProjectHelper::getXML($fileName);
         $params = $this->manifest->addChild('params');
         $this->appendXML($params, $refXml->params);
         $config = $this->manifest->addChild('config');
         $this->appendXML($config, $refXml->config);
         $positions = $this->manifest->addChild('positions');
         $this->appendXML($positions, $refXml->positions);
         return $this;
     }
     //-- Search if there is a config.xml
     $fileName = EcrProjectHelper::findConfigXML($this->project->type, $this->project->comName);
     if ($fileName) {
         $cfgXml = EcrProjectHelper::getXML($fileName);
         if (!$cfgXml || !$cfgXml->params) {
             return $this;
         }
         $paramsElement = $this->manifest->addChild('params');
         foreach ($cfgXml->params as $cfgParams) {
             /* @var SimpleXMLElement $cfgParam */
             foreach ($cfgParams->param as $cfgParam) {
                 if ($cfgParam->attributes()->type == 'spacer' || $cfgParam->attributes()->type == 'easyspacer') {
                     continue;
                 }
                 if ($cfgParam->attributes()->default && $cfgParam->attributes()->default != '0') {
                     $p = $paramsElement->addChild('param');
                     $p->addAttribute('name', $cfgParam->attributes()->name);
                     $p->addAttribute('type', $cfgParam->attributes()->type);
                     $p->addAttribute('label', $cfgParam->attributes()->label);
                     $p->addAttribute('default', $cfgParam->attributes()->default);
                 }
             }
         }
     } else {
         if (JFile::exists(JPath::clean(JPATH_ROOT . DS . EcrProjectHelper::findManifest($this->project)))) {
             $refXml = EcrProjectHelper::getXML(JPath::clean(JPATH_ROOT . DS . EcrProjectHelper::findManifest($this->project)));
             $params = $this->manifest->addChild('params');
             $this->appendXML($params, $refXml->params);
             $config = $this->manifest->addChild('config');
             $this->appendXML($config, $refXml->config);
             if ('template' == $this->project->type) {
                 $positions = $this->manifest->addChild('positions');
                 $this->appendXML($positions, $refXml->positions);
             }
         }
     }
     return $this;
 }