Esempio n. 1
0
 /**
  * Test to see if a page passes the condition
  *
  * @param CMS_page $page The parsed page : the one which contains the linx tag
  * @param CMS_page $page The page to test
  * @param boolean $publicTree Is the test conducted inside the public or edited tree ?
  * @param integer $rank The rank of the page in the pre-condition targets
  * @return boolean true if the page passes the condition, false otherwise
  * @access public
  */
 function pagePasses(&$parsedPage, &$page, $publicTree, $rank)
 {
     //set the condition value
     if ($this->_valueIsScalar) {
         $condition_value = $this->_valueScalar;
     } else {
         $condition_target = $this->_valueNodespec->getTarget($parsedPage, $publicTree);
         $condition_value = $this->_getPageProperty($condition_target, $this->_valueNodespecProperty, $publicTree);
     }
     if (is_null($condition_value)) {
         return false;
     }
     //build the body of the test function
     if ($this->_pageProperty == "rank") {
         $func_body = sprintf('return (\'%s\' %s \'%s\');', $rank, $this->_operator, $condition_value);
     } else {
         $page_value = $this->_getPageProperty($page, $this->_pageProperty, $publicTree);
         if (is_null($page_value)) {
             return false;
         }
         $func_body = sprintf('return (\'%s\' %s \'%s\');', $page_value, $this->_operator, $condition_value);
     }
     $func = @create_function('', $func_body);
     if (!$func) {
         return false;
     }
     return @$func();
 }