Exemple #1
0
 /**
  *	Некий аналог XPath
  *
  * @param	array	$args	Результат работы регулярного выражния /((\.|\w+|)(\/|\[[^\]]+\]))/
  * @return	mixed	Значение результата поиска, или FALSE если указан неверный путь
  * @see	this::_parse_path()
  */
 private function _parse_XPath($args, $_data = FALSE)
 {
     if (!$_data) {
         $_data = $this->local_data;
     }
     $nodes = $args[1];
     $params = $args[2];
     $data = $_data;
     foreach ($nodes as $key => $name) {
         if ($name == '/') {
             $data = $this->root_data;
         } elseif ($name == '.') {
         } elseif ($name and $params[$key] == '') {
             $data = $this->_parse_path($name, $data, FALSE);
         } elseif ($name and ($params[$key] != '/' or $params[$key] != '') and preg_match('/^\\[((?:\\$|\\@|\\#)\\w+)\\]$/', $params[$key], $matches)) {
             $key = $this->_parse_path($matches[1]);
             $data = $this->_parse_path($name, $data, FALSE);
             $data = $this->_get_value($data, $key);
         } elseif ($name and ($params[$key] != '/' or $params[$key] != '') and preg_match('/^\\[(\\d+)\\]$/', $params[$key], $matches)) {
             $data = $this->_parse_path($name, $data, FALSE);
             $data = $this->_get_value($data, $matches[1]);
         } elseif ($name and ($params[$key] != '/' or $params[$key] != '') and $matches = $this->_parse_XPath_get_conditions($params[$key])) {
             if ($data = $this->_get_value($data, $name)) {
                 if (isset($data[0])) {
                     $x = $data;
                     $data = array();
                     foreach ($x as $y) {
                         if ($z = $this->_parse_XPath_check_conditions($matches, $y)) {
                             $data[] = $z;
                         }
                     }
                 } else {
                     $data = $this->_parse_XPath_check_conditions($matches, $data);
                 }
             }
         } else {
             dbg::show('Не определённый узел указателя "' . $name . '"!');
         }
     }
     return $data;
 }