function __invoke($error, $method, $path, \cms\Sphido $cms) { trigger(MissingPage::class . '_before', $error, $method, $path, $cms); if ($cms->page = Page::fromPath(\dir\content() . '/404', (array) \app\config()->meta)) { return $cms->render(); } trigger(MissingPage::class . '_default', $error, $method, $path, $cms); }
function __invoke($method, $path, $cms) { $this->cms = $cms = $this; // include prepend PHP file first is_file($php = \dir\content($path . '/index.php')) ? include_once $php : null || is_file($php = \dir\content($path . '.php')) ? include_once $php : null; // search page (html, md, latte, phtml) $this->page = Page::fromPath(\dir\content() . '/' . $path, (array) config()->meta); // include functions.php from $path and working directory is_file($php = \dir\content($path . '/functions.php')) ? include_once $php : null; is_file(getcwd() . '/functions.php') ? include_once getcwd() . '/functions.php' : null; print $this->page ? $this->render() : \route\error(404, $method, $path, $this); }
/** * @param $method * @param $path * @param $cms * @return mixed */ function __invoke($method, $path, $cms) { $this->cms = $cms = $this; // inclide prepend PHP file first is_file($php = \dir\content($path . '/index.php')) ? include_once $php : null || is_file($php = \dir\content($path . '.php')) ? include_once $php : null; // search page (html, md, latte, phtml) $this->page = Page::fromPath(\dir\content() . '/' . $path, (array) config()->meta); // include functions.php from $path and working directory is_file($php = \dir\content($path . '/function.php')) ? include_once $php : null; is_file(getcwd() . '/functions.php') ? include_once getcwd() . '/functions.php' : null; if ($this->page) { echo ensure('render.page', [$this, 'render'], $this); // render page } else { error(404, $method, $path, $this); // trigger router error } }
function menu() { return Pages::from(\dir\content(), ['404', \dir\content('example')])->toArraySorted(); }
<?php /** * @author Roman Ozana <*****@*****.**> */ namespace cms { /** @var \cms\Sphido $cms */ // Follow files are used in examples require_once __DIR__ . '/../vendor/sphido/json/src/json.php'; require_once __DIR__ . '/../vendor/sphido/http/src/http.php'; require_once __DIR__ . '/../vendor/sphido/download/src/download.php'; // get pages for menu $cms->pages = Pages::from(\dir\content(), ['404', \dir\content('example')])->toArraySorted(); // Custom default error handler... if 404.md missing in root on('render.default.error', function () { echo 'Page not found...'; }); } namespace { /** @var \cms\Sphido $cms */ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! return; // follow examples are disabled by default // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /** * Write {yolo()} for calling function from markdown or Latte template */ function yolo() { require_once __DIR__ . '/../vendor/sphido/http/src/http.php'; \http\redirect('http://www.omdesign.cz');
/** * @param null|string $src * @return string */ public function getUrl($src = null) { return url($this->getSlug($src ? $src : \dir\content())); }
/** * @param null|string $src * @return string */ public function getUrl($src = null) { return filter(self::class . '::' . __FUNCTION__, url($this->getSlug($src ? $src : \dir\content()))); }
<?php namespace cms; /** @var \cms\Sphido $this */ // add Follow line to public/functions.php $this->pages = Pages::from(\dir\content('/example'))->toArraySorted();