/** * Merge a tag into the array * @see \PEAR2\Pyrus\XMLParser::mergeTag() * * @param array $arr The array representation of the XML * @param string $tag The tag name * @param array $attribs Associative array of attributes for this tag * @param string $name The tag name * @param int $depth The current depth within the XML document * * @return array */ protected function mergeTag($arr, $tag, $attribs, $name, $depth) { $arr = parent::mergeTag($arr, $tag, $attribs, $name, $depth); if ($this->_inContents) { if ($this->_inFile) { if ($depth < $this->_inFile) { $this->_inFile = 0; } } if ($name === 'dir') { while ($this->_lastDepth >= $depth) { $this->_path = dirname($this->_path); if ($this->_path == '.') { $this->_path = ''; } else { $this->_path .= '/'; } $this->_lastDepth--; } $this->_lastDepth = $depth; $this->_lastFileDepth = $depth + 1; $origpath = $path = $attribs['name']; if ($path === '/') { $path = ''; } else { $path .= '/'; } $this->_path .= $path; if (isset($attribs['baseinstalldir'])) { $this->_baseinstalldirs[$origpath] = $attribs['baseinstalldir']; } else { if (isset($this->_baseinstalldirs[dirname($path)])) { $this->_baseinstalldirs[$origpath] = $this->_baseinstalldirs[dirname($path)]; } } } elseif ($name === 'file') { while ($this->_lastFileDepth > $depth) { $this->_path = dirname($this->_path); if ($this->_path == '.') { $this->_path = ''; } else { $this->_path .= '/'; } $this->_lastFileDepth--; $this->_lastDepth--; } $path = $this->_path . $attribs['name']; if (isset($arr['file'][0])) { $newarr = $arr['file'][count($arr['file']) - 1]; } else { $newarr = $arr['file']; } $newarr['attribs']['name'] = $path; $this->_files[$path] = $newarr; $this->_curFile = $path; $this->_inFile = $depth; } elseif ($this->_inFile) { // add tasks $this->_files[$this->_curFile][$name] = $arr[$name]; } } elseif ($name === 'contents') { $this->_inContents = true; } return $arr; }