Esempio n. 1
0
        $plugins->trigger('404', [&$page, $body]);
        if (false === $page) {
            // If no 404 page is found
            return $res->write('404 - Page ' . htmlspecialchars($page) . ' not found');
        }
    }
    $plugins->trigger('page', [&$page, $body]);
    // Page layout
    if ($theme->hasLayout($page->get('layout'))) {
        $layout = $theme->getLayout($page->layout);
    } else {
        $layout = $theme->getLayout();
        // Default layout
    }
    // Assign some useful variables
    $view->addData(['baseUrl' => Parvula::getRelativeURIToRoot(), 'themeUrl' => Parvula::getRelativeURIToRoot($theme->getPath()), 'pagesArr' => function ($listHidden = false, $pagesPath = '') use($pages, $config) {
        return $pages->all($pagesPath)->visibility(!$listHidden)->order($config->get('typeOfSort'), $config->get('sortField'))->toArray();
    }, 'pages' => $pages->order($config->get('typeOfSort'), $config->get('sortField')), 'plugin' => function ($name) use($plugins) {
        return $plugins->getPlugin($name);
    }, 'site' => $config->toObject(), 'page' => $page, 'theme' => $theme, 'config' => $app['fileParser']->read(_CONFIG_ . 'user.yml'), '__time__' => function () use($config) {
        // useful to benchmark
        return sprintf('%.4f', $config->get('__time__') + microtime(true));
    }, 'content' => $page->content]);
    $plugins->trigger('preRender', [&$layout]);
    $out = $view->render($layout);
    $plugins->trigger('postRender', [&$out]);
    return $res->write($out);
});
// Files handler (media or uploads) (must have an extension)
$router->get('/{file:.+\\.[^.]{2,10}}', function ($req, $res, $args) use($app) {
    $filePath = str_replace(['..', ""], '', $args['file']);
Esempio n. 2
0
<?php

use Parvula\Parvula;
use Parvula\Parvula\Core\Config;
use Parvula\Parvula\Core\Models\Pages;
$templates = new League\Plates\Engine(__DIR__ . '/view', 'html');
$templates->addData(['baseUrl' => Parvula::getRelativeURIToRoot(), 'pluginUrl' => Parvula::getRelativeURIToRoot($that->getPluginPath()), 'templateUrl' => Parvula::getRelativeURIToRoot(_THEMES_ . $that->app['config']->get('theme'))]);
$pages = $that->app['pages'];
$pagesList = $pages->index(true);
$templates->addData(['pagesList' => $pagesList, '_page' => 'admin']);
return $templates->render('base');
Esempio n. 3
0
 /**
  * Get the current plugin URI, useful for the client part
  *
  * @param string $suffix optional Suffix
  * @return string the current URI path
  */
 protected function getUri($suffix = '')
 {
     return Parvula::getRelativeURIToRoot($this->getPluginPath() . $suffix);
 }