public function __construct($settings = []) { $settings["helpers"] = array_merge(["acl" => "Lime\\Helper\\SimpleAcl", "assets" => "Lime\\Helper\\Assets", "fs" => "Lime\\Helper\\Filesystem", "image" => "Lime\\Helper\\Image", "i18n" => "Lime\\Helper\\I18n", "utils" => "Lime\\Helper\\Utils", "coockie" => "Lime\\Helper\\Cookie"], isset($settings["helpers"]) ? $settings["helpers"] : []); parent::__construct($settings); // renderer service $this->service('renderer', function () { $renderer = new \Lexy(); //register app helper functions $renderer->extend(function ($content) { $content = preg_replace('/(\\s*)@extend\\((.+?)\\)/', '$1<?php $extend($2); ?>', $content); $content = preg_replace('/(\\s*)@base\\((.+?)\\)/', '$1<?php $app->base($2); ?>', $content); $content = preg_replace('/(\\s*)@route\\((.+?)\\)/', '$1<?php $app->route($2); ?>', $content); $content = preg_replace('/(\\s*)@scripts\\((.+?)\\)/', '$1<?php echo $app->assets($2); ?>', $content); $content = preg_replace('/(\\s*)@render\\((.+?)\\)/', '$1<?php echo $app->view($2); ?>', $content); $content = preg_replace('/(\\s*)@trigger\\((.+?)\\)/', '$1<?php $app->trigger($2); ?>', $content); $content = preg_replace('/(\\s*)@lang\\((.+?)\\)/', '$1<?php echo $app("i18n")->get($2); ?>', $content); $content = preg_replace('/(\\s*)@start\\((.+?)\\)/', '$1<?php $app->start($2); ?>', $content); $content = preg_replace('/(\\s*)@end\\((.+?)\\)/', '$1<?php $app->end($2); ?>', $content); $content = preg_replace('/(\\s*)@block\\((.+?)\\)/', '$1<?php $app->block($2); ?>', $content); return $content; }); return $renderer; }); $this("session")->init(); }
/** * @param array $settings */ public function __construct($settings = []) { $settings["helpers"] = array_merge(["acl" => "Lime\\Helper\\SimpleAcl", "assets" => "Lime\\Helper\\Assets", "fs" => "Lime\\Helper\\Filesystem", "image" => "Lime\\Helper\\Image", "i18n" => "Lime\\Helper\\I18n", "utils" => "Lime\\Helper\\Utils", "coockie" => "Lime\\Helper\\Cookie", "yaml" => "Lime\\Helper\\YAML"], isset($settings["helpers"]) ? $settings["helpers"] : []); parent::__construct($settings); // renderer service $this->service('renderer', function () { $renderer = new \Lexy(); //register app helper functions $renderer->extend(function ($content) { $replace = ['extend' => '<?php $extend(expr); ?>', 'base' => '<?php $app->base(expr); ?>', 'route' => '<?php $app->route(expr); ?>', 'trigger' => '<?php $app->trigger(expr); ?>', 'assets' => '<?php echo $app->assets(expr); ?>', 'start' => '<?php $app->start(expr); ?>', 'end' => '<?php $app->end(expr); ?>', 'block' => '<?php $app->block(expr); ?>', 'url' => '<?php echo $app->pathToUrl(expr); ?>', 'view' => '<?php echo $app->view(expr); ?>', 'render' => '<?php echo $app->view(expr); ?>', 'include' => '<?php echo include($app->path(expr)); ?>', 'lang' => '<?php echo $app("i18n")->get(expr); ?>']; $content = preg_replace_callback('/\\B@(\\w+)([ \\t]*)(\\( ( (?>[^()]+) | (?3) )* \\))?/x', function ($match) use($replace) { if (isset($match[3]) && trim($match[1]) && isset($replace[$match[1]])) { return str_replace('(expr)', $match[3], $replace[$match[1]]); } return $match[0]; }, $content); return $content; }); return $renderer; }); $this("session")->init(); }
$site->path('types', CP_SITE_DIR . '/types'); $site->path('types', CP_SITE_DIR . '/theme/types'); # layouts $site->path('layouts', __DIR__ . '/layouts'); $site->path('layouts', CP_SITE_DIR . '/layouts'); $site->path('layouts', CP_SITE_DIR . '/theme/layouts'); # cockpit $site->path('cockpit', COCKPIT_DIR); # set cache path $site("cache")->setCachePath(CP_TMP_DIR); $site("yaml")->setCachePath(CP_TMP_DIR); /** * register view macros */ $site->service('renderer', function () use($site) { $renderer = new \Lexy(); $renderer->setCachePath(CP_TMP_DIR); $renderer->extend(function ($content) { $replace = ['extend' => '<?php $extend(expr); ?>', 'base' => '<?php $app->base(expr); ?>', 'route' => '<?php $app->route(expr); ?>', 'trigger' => '<?php $app->trigger(expr); ?>', 'assets' => '<?php echo $app->assets(expr); ?>', 'markdown' => '<?php echo $app->helper("markdown")->parse(expr); ?>', 'start' => '<?php $app->start(expr); ?>', 'end' => '<?php $app->end(expr); ?>', 'block' => '<?php $app->block(expr); ?>', 'url' => '<?php echo url_to(expr); ?>', 'render' => '<?php echo copi::view(expr); ?>', 'menu' => '<?php echo copi::menu(expr); ?>', 'snippet' => '<?php copi::snippet(expr); ?>', 'load' => '<?php copi::$meta->assets->append(expr); ?>', 'form' => '<?php echo cockpit("forms")->open(expr); ?>', 'region' => '<?php echo cockpit("regions")->render(expr); ?>']; $content = preg_replace_callback('/\\B@(\\w+)([ \\t]*)(\\( ( (?>[^()]+) | (?3) )* \\))?/x', function ($match) use($replace) { if (isset($match[3]) && trim($match[1]) && isset($replace[$match[1]])) { return str_replace('(expr)', $match[3], $replace[$match[1]]); } return $match[0]; }, $content); return $content; }); return $renderer; }); #shortcodes service $site->service('shortcodes', function () use($site) {
# data $copilot->path('data', CP_ROOT_DIR . '/storage/data'); # set cache path $copilot("cache")->setCachePath(CP_ROOT_DIR . '/storage/tmp'); $copilot("yaml")->setCachePath(CP_ROOT_DIR . '/storage/tmp'); /** * check for bootsraping Cockpit */ if ($copilot['cockpit']) { include_once $copilot->retrieve('cockpit/path', CP_ROOT_DIR . '/cockpit') . '/bootstrap.php'; } /** * register view macros */ $copilot->service('renderer', function () use($copilot) { $renderer = new \Lexy(); $renderer->setCachePath(CP_ROOT_DIR . '/storage/tmp'); $renderer->extend(function ($content) { $replace = ['extend' => '<?php $extend(expr); ?>', 'base' => '<?php $app->base(expr); ?>', 'route' => '<?php $app->route(expr); ?>', 'trigger' => '<?php $app->trigger(expr); ?>', 'assets' => '<?php echo $app->assets(expr); ?>', 'markdown' => '<?php echo $app->helper("markdown")->parse(expr); ?>', 'start' => '<?php $app->start(expr); ?>', 'end' => '<?php $app->end(expr); ?>', 'block' => '<?php $app->block(expr); ?>', 'url' => '<?php echo $app->pathToUrl(expr); ?>', 'render' => '<?php echo copi::view(expr); ?>', 'menu' => '<?php echo copi::menu(expr); ?>', 'snippet' => '<?php copi::snippet(expr); ?>', 'load' => '<?php copi::$meta->assets->append(expr); ?>']; // add macros for cockpit api if (function_exists('cockpit')) { $replace['form'] = '<?php cockpit()->module("forms")->form(expr); ?>'; $replace['region'] = '<?php echo cockpit()->module("regions")->render(expr); ?>'; } $content = preg_replace_callback('/\\B@(\\w+)([ \\t]*)(\\( ( (?>[^()]+) | (?3) )* \\))?/x', function ($match) use($replace) { if (isset($match[3]) && trim($match[1]) && isset($replace[$match[1]])) { return str_replace('(expr)', $match[3], $replace[$match[1]]); } return $match[0]; }, $content); return $content;