public function searchAction($path) { $this->setPath($path); $search = $this->docbook->getRequest()->getArgument('s'); if (empty($search)) { return $this->indexAction($path); } $_s = Helper::processDocBookSearch($search, $this->getPath()); $title = _T('Search for "%search_str%"', array('search_str' => $search)); $breadcrumbs = Helper::getBreadcrumbs($this->getPath()); $breadcrumbs[] = $title; $dbfile = new DocBookFile($this->getpath()); $page = $dbfile->getDocBookStack(); $page['type'] = 'search'; $tpl_params = array('page' => $page, 'breadcrumbs' => $breadcrumbs, 'title' => $title); $search_content = $this->docbook->display($_s, 'search', array('search_str' => $search, 'path' => Helper::buildPageTitle($this->getPath()))); return array('default', $search_content, $tpl_params); }
/** * Find previous file in current chapter * * @return array */ public function findPrevious() { if (!isset($this->cache['docbook_previous'])) { $this->cache['docbook_previous'] = null; $filepath = $this->getPathname(); if ($this->isLink() || $this->isRootLink()) { $filepath = DirectoryHelper::slashDirname($this->getWebPath()) . $this->getFilename(); } $dir_realpath = dirname(realpath($filepath)); $dir_targetpath = dirname($filepath); if (empty($dir_realpath)) { $dir_realpath = $dir_targetpath; } $dir = new FilesystemIterator($dir_realpath, FilesystemIterator::CURRENT_AS_PATHNAME); $dir_table = iterator_to_array($dir, false); $i = array_search($this->getRealPath(), $dir_table); if (false !== $i) { $j = $i - 1; while ($j >= 0 && array_key_exists($j, $dir_table) && (is_dir($dir_table[$j]) && !Helper::isDirValid($dir_table[$j]) || !Helper::isFileValid($dir_table[$j]) || DirectoryHelper::isDotPath($dir_table[$j]) || Helper::isTranslationFile($dir_table[$j]))) { $j = $j - 1; } if ($j >= 0 && array_key_exists($j, $dir_table) && (is_dir($dir_table[$j]) && Helper::isDirValid($dir_table[$j]) || !is_dir($dir_table[$j]) && Helper::isFileValid($dir_table[$j]) && !Helper::isTranslationFile($dir_table[$j])) && !DirectoryHelper::isDotPath($dir_table[$j])) { $previous = new DocBookFile($dir_table[$j]); $this->cache['docbook_previous'] = $previous->getDocBookStack(); } } } return $this->cache['docbook_previous']; }