/*!
\static
Goes through all content nodes in \a $nodeList and extracts the \c 'path_string'.
\return An array with \c 'path_string' information.
486457
static function fetchNodePathString( $nodeList )
    {
        $pathList = array();
        foreach ( $nodeList as $node )
        {
            $pathList[] = $node->attribute( 'path_string' );
        }
        return $pathList;
    }
979246
public static function parsePath($path, $httpMethod)
    {
        $elements       = [];
        $elementStrings = explode('/', $path);
        foreach ($elementStrings as $elementString) {
            if (empty($elementString)) {
                continue;
            }
            $elements[] = new static($elementString, $httpMethod);
        }

        return $elements;
    }
393805
protected function parsePaths()
    {
        if (is_null($this->paths) === true) {
            // Server params
            $scriptName = $this->env->get('SCRIPT_NAME'); // <-- "/foo/index.php"
            $requestUri = $this->env->get('REQUEST_URI'); // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc"
            $queryString = $this->getQueryString(); // <-- "test=abc" or ""

            // Physical path
            if (strpos($requestUri, $scriptName) !== false) {
                $physicalPath = $scriptName; // <-- Without rewriting
            } else {
                $physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting
            }
            $scriptName = rtrim($physicalPath, '/'); // <-- Remove trailing slashes

            // Virtual path
            $pathInfo = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path
            $pathInfo = str_replace('?' . $queryString, '', $pathInfo); // <-- Remove query string
            $pathInfo = '/' . ltrim($pathInfo, '/'); // <-- Ensure leading slash

            $this->paths = array();
            $this->paths['physical'] = $scriptName;
            $this->paths['virtual'] = $pathInfo;
        }

        return $this->paths;
    }
1305834
static function contents($directory) {
        if (!self::exists($directory)) return null;

        $dircontents = [];

        $contents = scandir($directory);

        foreach ($contents as $content) {
            if ($content != '.' && $content != '..') {
                array_push($dircontents, $content);
            }
        }

        return $dircontents;
    }
648730
private function staticVariable() {
    $node = new StaticVariableNode();
    $this->mustMatch(T_VARIABLE, $node, 'name', TRUE);
    if ($this->tryMatch('=', $node)) {
      $node->addChild($this->staticScalar(), 'initialValue');
    }
    return $node;
  }
88916
private function parseFile()
    {
        $contents = file_get_contents($this->getPath());
        $lines = new Collection(explode("\n", $contents));
        $result = new Collection();

        $lines->filter(function ($value) {
            return $value;
        })->each(function ($value) use ($result) {
            preg_match('/([a-zA-Z_-]+)\=(.+)/', $value, $regexResult);

            array_shift($regexResult);
            $result->push(new Collection($regexResult));
        });

        return $result;
    }
1255802
function inputListXML( &$listNode, $currentSectionLevel, $listSectionLevel = null, $noParagraphs = true )
    {
        $output = '';
        $tagName = $listNode instanceof DOMNode ? $listNode->nodeName : '';

        switch ( $tagName )
        {
            case 'paragraph' :
            {
                $output .= $this->inputParagraphXML( $listNode,
                                                     $currentSectionLevel,
                                                     $listSectionLevel,
                                                     $noParagraphs );
            }break;

            case 'section' :
            {
                $listSectionLevel += 1;
                $output .= $this->inputSectionXML( $listNode, $currentSectionLevel, $listSectionLevel );
            }break;

            case '#text' :
            {
                //ignore whitespace
            }break;

            default :
            {
                eZDebug::writeError( "Unsupported tag at this level: $tagName", __METHOD__ );
            }break;
        }
        return $output;
    }
1148764
public function findXPath(string $xpath): NodeList {
        $results = $this->newNodeList();

        if ($this->isRemoved()) {
            return $results;
        }

        $domxpath = new \DOMXPath($this->document());

        foreach ($this->collection() as $node) {
            $results = $results->merge(
                $node->newNodeList($domxpath->query($xpath, $node))
            );
        }

        return $results;
    }
1081815
static public function getNodePath( $nodeId )
    {
        if ( !$nodeId or !is_numeric( $nodeId ) )
        {
            return false;
        }

        $node = eZContentObjectTreeNode::fetch( $nodeId );

        if ( !$node or !$node instanceof eZContentObjectTreeNode )
        {
            return false;
        }

        $parents = $node->attribute( 'path' );
        $path    = array( 'path' => array(), 'title_path' => array() );
        foreach ( $parents as $parent )
        {
            $path['path'][] = array( 'text' => $parent->attribute( 'name' ),
                             'url' => '/content/view/full/' . $parent->attribute( 'node_id' ),
                             'url_alias' => $parent->attribute( 'url_alias' ),
                             'node_id' => $parent->attribute( 'node_id' ) );
        }

        $path['title_path'] = $path['path'];
        $path['path'][] = array( 'text' => $node->attribute( 'name' ),
                         'url' => false,
                         'url_alias' => false,
                         'node_id' => $node->attribute( 'node_id' ) );

        $path['title_path'][] = array( 'text' => $node->attribute( 'name' ),
                              'url' => false,
                              'url_alias' => false );
        return $path;
    }
893269
public function parse($content)
    {
        // if there is no path it's not needed to try to get a clean one
        if (empty($content)) return [];

        $path = $this->getCleanPath($content);
        $pathParts = [$this->delimiter];
        // check if there is even a need for further checks
        if (mb_strpos($path, $this->delimiter) === false) {
            if (!$path) {
                return [$this->delimiter];
            }

            // set the root and the path
            $tmpPathParts = [
                $this->delimiter,
                $path
            ];

            return $tmpPathParts;
        }

        // if there's a deeper path it's time to walk through it and clean the empty parts etc
        $tmpPathParts = explode($this->delimiter, $path);


        // walk through the array and remove the empty entries
        for ($i = 0, $c = count($tmpPathParts); $i < $c; $i++) {
            if (!$tmpPathParts[$i]) unset($tmpPathParts[$i]);
        }

        // prepend the default delimiter
        $pathParts = array_merge($pathParts, $tmpPathParts);

        // path parts
        return $pathParts;
    }
151578
public function nodeString($indent = '', $isChild = false)
    {
        // non printable characters regex
        $nonPrintable = '#[^\x20-\x7E]#';

        //formatters
        $lt = '<';
        $gt = '>';
        $nl = "\n";
        if (!self::isCli()) {
            $lt = '&lt;';
            $gt = '&gt;';
            $nl = '<br />';
            $indent = str_replace(' ', '&nbsp;', $indent);
        }

        $ret = $indent.$lt.$this->tag;
        if ($this->attributeHash != null) {
            foreach ($this->attributeHash as $key => $value) {
                $ret .= ' '.$key.'="'.$value.'"';
            }
        }
        $ret .= $gt;
        if (strlen($this->data) > 0) {
            if (strlen($this->data) <= 1024) {
                //message
                if (preg_match($nonPrintable, $this->data)) {
                    $ret .= bin2hex($this->data);
                } else {
                    $ret .= $this->data;
                }
            } else {
                //raw data
                $ret .= ' '.strlen($this->data).' byte data';
            }
        }
        if ($this->children) {
            $ret .= $nl;
            $foo = [];
            foreach ($this->children as $child) {
                $foo[] = $child->nodeString($indent.'  ', true);
            }
            $ret .= implode($nl, $foo);
            $ret .= $nl.$indent;
        }
        $ret .= $lt.'/'.$this->tag.$gt;

        if (!$isChild) {
            $ret .= $nl;
            if (!self::isCli()) {
                $ret .= $nl;
            }
        }

        return $ret;
    }
90219
function path(){
      var nodeList = [];
      var weight = 0;
      var node = destination;
      while(p[node]){
        nodeList.push(node);
        weight += getEdgeWeight(p[node], node);
        node = p[node];
      }
      if (node !== source) {
        throw new Error("No path found");
      }
      nodeList.push(node);
      nodeList.reverse();
      nodeList.weight = weight;
      return nodeList;
    }
1128081
private String[] getPathElements(CmsXmlContent content, I_CmsXmlContentValue value) {

        List<String> pathElements = new ArrayList<String>();
        String[] paths = value.getPath().split("/");
        String path = "";
        for (int i = 0; i < paths.length; i++) {
            path += paths[i];
            I_CmsXmlContentValue ancestor = content.getValue(path, value.getLocale());
            int valueIndex = ancestor.getXmlIndex();
            if (ancestor.isChoiceOption()) {
                Element parent = ancestor.getElement().getParent();
                valueIndex = parent.indexOf(ancestor.getElement());
            }
            String pathElement = getAttributeName(ancestor);
            pathElements.add(pathElement + "[" + valueIndex + "]");
            if (ancestor.isChoiceType()) {
                pathElements.add("ATTRIBUTE_CHOICE");
            }
            path += "/";
        }
        return pathElements.toArray(new String[pathElements.size()]);
    }
512539
public function get_listing($path='', $page = '') {
        if (empty($path)) {
            $path = $this->build_node_path('root', get_string('pluginname', 'repository_onedrive'));
        }

        if ($this->disabled) {
            // Empty list of files for disabled repository.
            return ['dynload' => false, 'list' => [], 'nologin' => true];
        }

        // We analyse the path to extract what to browse.
        $trail = explode('/', $path);
        $uri = array_pop($trail);
        list($id, $name) = $this->explode_node_path($uri);

        // Handle the special keyword 'search', which we defined in self::search() so that
        // we could set up a breadcrumb in the search results. In any other case ID would be
        // 'root' which is a special keyword, or a parent (folder) ID.
        if ($id === 'search') {
            $q = $name;
            $id = 'root';

            // Append the active path for search.
            $str = get_string('searchfor', 'repository_onedrive', $searchtext);
            $path = $this->build_node_path('search', $str, $path);
        }

        // Query the Drive.
        $parent = $id;
        if ($parent != 'root') {
            $parent = 'items/' . $parent;
        }
        $q = '';
        $results = $this->query($q, $path, $parent);

        $ret = [];
        $ret['dynload'] = true;
        $ret['path'] = $this->build_breadcrumb($path);
        $ret['list'] = $results;
        $ret['manage'] = 'https://www.office.com/';
        return $ret;
    }
511081
function getNodePath(node) {
    var nodePaths = [];
    var nodeParent = node;
    while (nodeParent) {
        switch (nodeParent.nodeType) {
            case NodeType.ELEM:
                nodePaths.unshift(nodeParent.tagName);
                break;

            case NodeType.IF:
                nodePaths.unshift('if');
                break;

            case NodeType.FOR:
                nodePaths.unshift('for[' + nodeParent.anode.directives['for'].raw + ']'); // eslint-disable-line dot-notation
                break;

            case NodeType.SLOT:
                nodePaths.unshift('slot[' + (nodeParent.name || 'default') + ']');
                break;

            case NodeType.TPL:
                nodePaths.unshift('template');
                break;

            case NodeType.CMPT:
                nodePaths.unshift('component[' + (nodeParent.subTag || 'root') + ']');
                break;

            case NodeType.TEXT:
                nodePaths.unshift('text');
                break;
        }

        nodeParent = nodeParent.parent;
    }

    return nodePaths;
}
335042
public static function paths( $paths = null, $define = true )
	{
		if ( is_null( $paths ) )
		{
			return static::$paths;
		}
		
		foreach( $paths as $key => $path )
		{
			static::$paths[$key] = $path;
			
			if ( $define === true )
			{
				define( strtoupper( $key ).'PATH', $path );
			}
		}
	}
567631
protected function getPathFromContent()
    {
        $pathFromContent = str_replace($this->getPathToContent(), '', $this->getFile()->getRealPath());

        return trim($pathFromContent, DIRECTORY_SEPARATOR);
    }