/** * Selects the targets : apply the selection to the builded targets * * @param array(CMS_page) $targets The build targets of which we want the selection * @return boolean true on success, false on failure * @access private */ protected function _selectTargets($targets) { $public_targets = array(); if (is_array($targets)) { foreach ($targets as $target) { if (!$this->_publicTree || $this->_publicTree && $target->isUseable() && $target->getPublication() == RESOURCE_PUBLICATION_PUBLIC) { $public_targets[] = $target; } } } $targets = $public_targets; if (!$targets || !$this->_selectionCondition) { return $targets; } $selected_targets = array(); $sizeofTargets = sizeof($targets); for ($i = 0; $i < $sizeofTargets; $i++) { $current_target = $targets[$i]; $pass = $this->_selectionCondition->pagePasses($this->_page, $current_target, $this->_publicTree, $i + 1); if ($pass) { $selected_targets[] = $current_target; } } return $selected_targets; }
/** * Constructor. * initializes the linxDisplay. * * @param string $tagContent The tag content. * @return void * @access public */ function __construct($tag) { $conditions = $tag->getElementsByTagName('condition'); $htmltemplates = $tag->getElementsByTagName('htmltemplate'); $modes = $tag->getElementsByTagName('mode'); $subleveltemplates = $tag->getElementsByTagName('subleveltemplate'); $root = $tag->getElementsByTagName('root'); //conditions if ($conditions->length > 0) { foreach ($conditions as $condition) { $this->_conditions[] = CMS_linxCondition::createCondition($condition); } } //htmltemplate if ($htmltemplates->length > 0) { $this->_htmlTemplate = CMS_DOMDocument::DOMElementToString($htmltemplates->item(0), true); } //mode if ($modes->length > 0) { $this->_mode = trim(CMS_DOMDocument::DOMElementToString($modes->item(0), true)); } else { if ($tag->getAttribute('mode')) { $this->_mode = trim($tag->getAttribute('mode')); } } //root if ($root->length > 0) { $attribute = trim(CMS_DOMDocument::DOMElementToString($root->item(0), true)); $this->_root = $attribute === "0" || $attribute === "false" || !$attribute ? false : true; } else { if ($tag->hasAttribute('root')) { $attribute = trim($tag->getAttribute('root')); $this->_root = $attribute === "0" || $attribute === "false" || !$attribute ? false : true; } else { $this->_root = true; } } //subleveltemplate if ($subleveltemplates->length > 0) { $this->_subleveltemplate = CMS_DOMDocument::DOMElementToString($subleveltemplates->item(0), true); } }