예제 #1
0
 /**
  * Parse a "selection" XML tag searching for start and stop nodespecs
  * This will fill the _selectionStartPageTags and _selectionStopPageTag attributes
  *
  * @param CMS_XMLTag $selectionTag The selection tag to parse
  * @return boolean true on success, false on failure
  * @access private
  */
 protected function _parseSelection($selectionTag)
 {
     if (is_a($selectionTag, "DOMElement")) {
         //set error level on selection attribute
         if ($selectionTag->hasAttribute('noerror') && ($selectionTag->getAttribute('noerror') == 'true' || $selectionTag->getAttribute('noerror') == '1')) {
             $this->_noerror = true;
         }
         //set cross website status on selection attribute
         if ($selectionTag->hasAttribute('crosswebsite') && $selectionTag->getAttribute('crosswebsite') == 'true' || $selectionTag->getAttribute('crosswebsite') == '1') {
             $this->_crosswebsite = true;
         }
         $starts = $selectionTag->getElementsByTagName('start');
         $stops = $selectionTag->getElementsByTagName('stop');
         $conditions = $selectionTag->getElementsByTagName('condition');
         if ($conditions->length > 0) {
             $this->_selectionCondition = CMS_linxCondition::createCondition($conditions->item(0));
         }
         //parse the start tag(s)
         foreach ($starts as $start) {
             $nodespecs = $start->getElementsByTagName('nodespec');
             if ($nodespecs->length > 0) {
                 $nodespec = $nodespecs->item(0);
                 $nodespec = CMS_linxNodespec::createNodespec($nodespec, $this->_crosswebsite);
             }
             $pages = $nodespec->getTarget($this->_page, $this->_publicTree);
             if ($pages) {
                 if (!is_array($pages)) {
                     $pages = array($pages);
                 }
                 foreach ($pages as $pg) {
                     $this->_selectionStartPages[] = $pg;
                     //if nodespec type is relative and relative type is father OR the linx type is sublinks,
                     //store the representation ID in the _fatherWatch array
                     if ($nodespec->getRelativeType() == "brother" || $this->_type == "sublinks" || $this->_type == "recursivelinks") {
                         $this->_fatherWatches[] = $pg->getID();
                     }
                 }
             }
         }
         if ($stops->length > 0) {
             $stop = $stops->item(0);
             $nodespecs = $stop->getElementsByTagName('nodespec');
             if ($nodespecs->length > 0) {
                 $nodespec = $nodespecs->item(0);
                 $nodespec = CMS_linxNodespec::createNodespec($nodespec);
                 $pg = $nodespec->getTarget($this->_page, $this->_publicTree);
                 if ($pg) {
                     $this->_selectionStopPage = $pg;
                 }
             }
         }
     } else {
         $this->raiseError('SelectionTag is not a DOMElement instance');
         return false;
     }
     return true;
 }
예제 #2
0
 /**
  * Constructor.
  * initializes the linxCondition.
  *
  * @param string $property The page property we're gonna test. Only a set of these are available here.
  * @param string $operator The comparison operator serving to test the condition.
  * @param string $tagContent The tag content.
  * @return void
  * @access public
  */
 function __construct($tag)
 {
     $authorized_properties = array("rank", "title", "id", "lvl", "father", "website", "codename");
     $property = $tag->getAttribute('property');
     $operator = $tag->getAttribute('operator');
     if (SensitiveIO::isInSet($property, $authorized_properties)) {
         $this->_pageProperty = $property;
         $this->_operator = io::decodeEntities(io::decodeEntities(io::decodeEntities($operator)));
         $values = $tag->getElementsByTagName('value');
         if ($values->length > 0) {
             $value = $values->item(0);
             //if value type is "nodeproperty", we must parse the inner content to find a nodespec tag
             if ($value->hasAttribute("type") && $value->getAttribute("type") == "nodeproperty") {
                 $this->_valueIsScalar = false;
                 $this->_valueNodespecProperty = $value->getAttribute("property");
                 $nodespecs = $value->getElementsByTagName('nodespec');
                 if ($nodespecs->length > 0) {
                     $nodespec = $nodespecs->item(0);
                     $this->_valueNodespec = CMS_linxNodespec::createNodespec($nodespec);
                 }
             } else {
                 $this->_valueScalar = $value->nodeValue;
             }
         } else {
             $this->raiseError("Malformed innerContent");
             return;
         }
     } else {
         $this->raiseError("Unknown property : " . $property);
     }
 }