Example #1
0
 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);
 }
Example #2
0
File: cms.php Project: sphido/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);
 }
Example #3
0
 /**
  * @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
     }
 }
Example #4
0
 function menu()
 {
     return Pages::from(\dir\content(), ['404', \dir\content('example')])->toArraySorted();
 }
Example #5
0
<?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');
Example #6
0
 /**
  * @param null|string $src
  * @return string
  */
 public function getUrl($src = null)
 {
     return url($this->getSlug($src ? $src : \dir\content()));
 }
Example #7
0
File: Page.php Project: sphido/cms
 /**
  * @param null|string $src
  * @return string
  */
 public function getUrl($src = null)
 {
     return filter(self::class . '::' . __FUNCTION__, url($this->getSlug($src ? $src : \dir\content())));
 }
Example #8
0
<?php

namespace cms;

/** @var \cms\Sphido $this */
// add Follow line to public/functions.php
$this->pages = Pages::from(\dir\content('/example'))->toArraySorted();