/** * replace twig like variables in page content * * @param Page $page * @param array $vars */ protected function insertVars(Page $page, array $vars) { $content = $page->getRawContent(); foreach ($vars as $key => $value) { $regex = '/\\{\\{(\\s*?)' . $key . '(\\s*?)\\}\\}/'; $content = preg_replace($regex, $value, $content); } $page->setContent($content); }
/** * return page at offset from $page in applied search order * * @param \Phile\Model\Page $page * @param int $offset * @return null|\Phile\Model\Page */ public function getPageOffset(\Phile\Model\Page $page, $offset = 0) { $pages = $this->findAll(); $order = array(); foreach ($pages as $p) { $order[] = $p->getFilePath(); } $key = array_search($page->getFilePath(), $order) + $offset; if (!isset($order[$key])) { return null; } return $this->getPage($order[$key]); }
public function getContentFolderRelativePath() { return str_replace($this->getContentFolder(), '', $this->page->getFilePath()); }