Ejemplo n.º 1
0
 public function getWeightSchema(schema_ns\parser\element $element, $sMode, $sXMode, $bRoot = false)
 {
     $iResult = 0;
     if ($this->getMatch() || $bRoot) {
         if (!$this->getMatch()) {
             if ($bRoot && $sMode === $this->getMode() && $this->checkXMode($sXMode)) {
                 $iResult = self::WEIGHT_ELEMENT_ROOT;
                 if ($this->getXMode() && $this->getXMode() === $sXMode) {
                     $iResult += 1;
                 }
             }
         } else {
             if ($sMode === $this->getMode() && $this->checkXMode($sXMode)) {
                 $iElement = $this->getWeightName($element->getNamespace(), $element->getName());
                 if ($type = $element->getType()) {
                     $iType = $this->getWeightType($type);
                     $iResult = $iType > $iElement ? $iType : $iElement;
                     if ($this->getXMode() && $this->getXMode() === $sXMode) {
                         $iResult += 1;
                     }
                 } else {
                     $iResult = $iElement;
                 }
             }
         }
     }
     return $iResult;
 }
Ejemplo n.º 2
0
 public function setElement(schema\parser\element $el, $bDistinct = false)
 {
     $sName = $el->getName();
     $bAdd = true;
     if (array_key_exists($sName, $this->aKeyElements)) {
         if ($el === $this->aKeyElements[$sName]) {
             $bAdd = false;
         } else {
             $el->useAlias(true);
         }
     } else {
         $this->aKeyElements[$sName] = $el;
     }
     if ($bAdd) {
         $sName = $el->asAlias();
         if ($bDistinct) {
             $mContent = array('DISTINCT ', $sName);
             $this->setColumn($mContent, true);
         } else {
             $mContent = $sName;
             $this->setColumn($mContent);
         }
     }
     $this->aElements[] = $el;
 }
Ejemplo n.º 3
0
 public function lookupTemplate(schema\parser\element $element, $sContext, $sMode, $bRoot = false)
 {
     $result = null;
     $current = (object) array('template' => null, 'weight' => 0, 'key' => 0);
     $view = $this->getView();
     $sXMode = $view->getXMode();
     foreach ($this->getTemplates() as $iKey => $template) {
         if ($view->checkTemplate($template, $element->asToken(), false)) {
             continue;
         }
         $iWeight = $template->getWeightSchema($element, $sMode, $sXMode, $bRoot);
         if ($iWeight && $iWeight >= $current->weight) {
             $current->template = $template;
             $current->weight = $iWeight;
             $current->key = $iKey;
         }
     }
     if ($current->template) {
         $result = $this->loadTemplate($current->template, $current->key);
     }
     return $result;
 }
Ejemplo n.º 4
0
 public function addElement(parser\element $element, $iPosition = null)
 {
     if (!$element->getNamespace()) {
         $this->launchException('Element not valid, no namespace defined');
     }
     if (isset($this->aElements[$element->getNamespace()][$element->getName()])) {
         $this->launchException('Element ever registered', get_defined_vars());
     }
     $element->setPosition($iPosition);
     $element->setParticle($this);
     $this->aElements[$element->getNamespace()][$element->getName()] = $element;
     if (is_null($iPosition)) {
         $iPosition = count($this->aElementsIndexed);
     }
     $this->aElementsIndexed[$iPosition] = $element;
 }
Ejemplo n.º 5
0
 protected function addColumn(schema\parser\element $el)
 {
     $this->aColumns[$el->getName()] = $el;
 }
Ejemplo n.º 6
0
 protected function loadChild(schema\parser\element $child)
 {
     $child->setParent($this);
     $child->loadNamespace($this->getNamespace());
 }
Ejemplo n.º 7
0
 protected function addElement(parser\element $element)
 {
     $this->aElements[$element->getNamespace()][$element->getName()] = $element;
     return $element;
 }