コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function register(Engine $engine)
 {
     // Add app view data
     $engine->addData(['validation_errors' => [], 'base_js' => [], 'base_css' => []]);
     // Form helpers
     $engine->registerFunction('userPhoto', [$this, 'userPhoto']);
     $engine->registerFunction('requestBody', [$this, 'requestBody']);
     $engine->registerFunction('formFieldError', [$this, 'fieldError']);
     $engine->registerFunction('formInputSelect', [$this, 'inputSelect']);
     $engine->registerFunction('formInputMethod', [$this, 'inputMethod']);
     // Flash Message helpers
     $engine->registerFunction('flashMessages', [$this->flash, 'getMessages']);
     $engine->registerFunction('flashMessage', [$this->flash, 'getMessage']);
     // Register validation helpers
     $engine->registerFunction('validationErrors', function (array $errors = []) use($engine) {
         $engine->addData(['validation_errors' => $errors]);
     });
     // Register view js helpers
     $engine->registerFunction('appendJs', function (array $jsFiles = []) use($engine) {
         $engine->addData(['base_js' => $jsFiles]);
     });
     // Register view css helpers
     $engine->registerFunction('appendCss', function (array $cssFiles = []) use($engine) {
         $engine->addData(['base_css' => $cssFiles]);
     });
 }
 /**
  * Register extension functions.
  * @return null
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('fh_default_val', array($this, 'fhDefaultVal'));
     $engine->registerFunction('fh_input_select', array($this, 'fhInputSelect'));
     $engine->registerFunction('fh_error_css_class', array($this, 'fhErrorCssClass'));
     $engine->registerFunction('fh_show_errors', array($this, 'fhShowErrors'));
 }
コード例 #3
0
 public function register(Engine $engine)
 {
     $engine->registerFunction('asset', [$this, 'asset']);
     $engine->registerFunction('url', [$this, 'url']);
     $engine->registerFunction('formatDate', [$this, 'formatDate']);
     $engine->registerFunction('formatDatetime', [$this, 'formatDatetime']);
     $engine->registerFunction('formatRupiah', [$this, 'formatRupiah']);
 }
コード例 #4
0
ファイル: UrlHelpers.php プロジェクト: gluephp/glue-plates
 /**
  * @param  Engine $engine
  */
 public function register(Engine $engine)
 {
     // Load the built in URI extension
     $engine->loadExtension(new URI($this->request->getPathInfo()));
     // Custom methods
     $engine->registerFunction('route', [$this, 'route']);
     $engine->registerFunction('asset', [$this, 'asset']);
 }
コード例 #5
0
 /**
  * Register extension function.
  *
  * @param \League\Plates\Engine $engine Plates instance
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('baseUrl', [$this, 'baseUrl']);
     $engine->registerFunction('uriFull', [$this, 'uriFull']);
     $engine->registerFunction('pathFor', [$this->router, 'pathFor']);
     $engine->registerFunction('basePath', [$this->uri, 'getBasePath']);
     $engine->registerFunction('uriScheme', [$this->uri, 'getScheme']);
     $engine->registerFunction('uriHost', [$this->uri, 'getHost']);
     $engine->registerFunction('uriPort', [$this->uri, 'getPort']);
     $engine->registerFunction('uriPath', [$this->uri, 'getPath']);
     $engine->registerFunction('uriQuery', [$this->uri, 'getQuery']);
     $engine->registerFunction('uriFragment', [$this->uri, 'getFragment']);
 }
コード例 #6
0
 /**
  * Register extension functions.
  * @return null
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('uri_scheme', array($this, 'scheme'));
     $engine->registerFunction('uri_host', array($this, 'host'));
     $engine->registerFunction('uri_port', array($this, 'port'));
     $engine->registerFunction('uri_path', array($this, 'path'));
     $engine->registerFunction('uri_basepath', array($this, 'basePath'));
     $engine->registerFunction('uri_query', array($this, 'query'));
     $engine->registerFunction('uri_query_params', array($this, 'queryParams'));
     $engine->registerFunction('uri_match', array($this, 'runUri'));
     $engine->registerFunction('uri_path_for', array($this, 'pathFor'));
     $engine->registerFunction('uri_base_url', array($this, 'baseUrl'));
 }
コード例 #7
0
ファイル: HtmlExtension.php プロジェクト: mercury/framework
 public function register(Engine $po_engine)
 {
     $this->engine = $po_engine;
     $po_engine->registerFunction('styleselector', [$this, 'styleselector']);
     $po_engine->registerFunction('htmlinput', [$this, 'htmlinput']);
     $po_engine->registerFunction('postvalue', [$this, 'postvalue']);
     $po_engine->registerFunction('getvalue', [$this, 'getvalue']);
     $po_engine->registerFunction('debug', [$this, 'debug']);
     $po_engine->registerFunction('getflashmessage', [$this, 'getflashmessage']);
     $po_engine->registerFunction('setformerrors', [$this, 'setformerrors']);
     $po_engine->registerFunction('hasformerrors', [$this, 'hasformerrors']);
     $po_engine->registerFunction('validatefield', [$this, 'validatefield']);
     $po_engine->registerFunction('getfielderror', [$this, 'getfielderror']);
 }
コード例 #8
0
 protected function getTemplates()
 {
     if (!self::$templates) {
         // Create new Plates engine
         self::$templates = new Engine(__DIR__ . '/../../views', 'tpl');
         self::$templates->registerFunction('substr', function ($string, $start, $length) {
             return substr($string, $start, $length);
         });
         self::$templates->registerFunction('cleanWikiSyntax', function ($string) {
             return preg_replace("/\\[(wiki|url)\\=(?P<url>https?:\\/\\/[^\\]]*)\\](?P<text>[^\\[]*)\\[\\/(wiki|url)\\]/i", "\$3", $string);
         });
     }
     return self::$templates;
 }
コード例 #9
0
 /**
  * MY_Controller constructor.
  */
 public function __construct()
 {
     parent::__construct();
     // Profiler only development environment
     if (ENVIRONMENT === 'development' and $this->config->item('profiler') === TRUE) {
         $this->load->add_package_path(APPPATH . 'packages/codeigniter-forensics');
         $this->output->enable_profiler(TRUE);
     }
     // Templates
     $this->template = new League\Plates\Engine(APPPATH . 'views');
     $this->template->registerFunction('CI', function () {
         return $this;
     });
     $this->template->loadExtension(new League\Plates\Extension\Asset(FCPATH));
 }
コード例 #10
0
ファイル: ServiceProvider.php プロジェクト: ezimuel/tonis
 /**
  * {@inheritDoc}
  */
 public function register()
 {
     $container = $this->getContainer();
     // route map which contains routes for lookup
     $container->singleton(Router\RouteMap::class, function () {
         return new Router\RouteMap();
     });
     // handles errors in the life-cycle
     $container->singleton(Handler\ErrorInterface::class, function () {
         return new Handler\Error();
     });
     // handles not found errors in the life-cycle
     $container->singleton(Handler\NotFoundInterface::class, function () {
         return new Handler\NotFound();
     });
     // plates engine
     $container->singleton(Engine::class, function () use($container) {
         $engine = new Engine(__DIR__ . '/../view');
         $engine->registerFunction('url', new View\Plates\UrlFunction($container->get(Router\RouteMap::class)));
         return $engine;
     });
     // view manager
     $container->singleton(View\Manager::class, function () use($container) {
         return new View\Manager(new View\PlatesStrategy($container->get(Engine::class)));
     });
     // router
     $container->add(Router\Router::class, function () use($container) {
         return new Router\Router($container->get(Router\RouteMap::class));
     });
 }
コード例 #11
0
ファイル: Templates.php プロジェクト: oscarotero/folk
 public function register(Fol $app)
 {
     $app['templates'] = function ($app) {
         $root = dirname(dirname(__DIR__));
         $templates = new Engine($root . '/templates');
         $icons = new Collection(new MaterialDesignIcons($root . '/assets/icons'));
         $templates->addData(['app' => $app]);
         $templates->registerFunction('icon', function ($name) use($icons) {
             return $icons->get($name);
         });
         return $templates;
     };
 }
コード例 #12
0
ファイル: FlashBagExtension.php プロジェクト: jirro/jirro
 public function register(View $view)
 {
     $view->registerFunction('flashBag', [$this, 'flashBag']);
 }
コード例 #13
0
ファイル: BaseUrlExtension.php プロジェクト: jirro/jirro
 public function register(View $view)
 {
     $view->registerFunction('baseUrl', [$this, 'baseUrl']);
 }
コード例 #14
0
 /**
  * Register functions with the Plates engine.
  *
  * Registers:
  *
  * - url($route = null, array $params = []) : string
  * - serverurl($path = null) : string
  *
  * @param Engine $engine
  * @return void
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('url', [$this, 'generateUrl']);
     $engine->registerFunction('serverurl', [$this, 'generateServerUrl']);
 }
コード例 #15
0
ファイル: URI.php プロジェクト: jezqhiel/cms-packages
 /**
  * Register extension functions.
  * @param Engine $engine
  * @return null
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('uri', array($this, 'runUri'));
 }
コード例 #16
0
 /**
  * setup the template engine and sends the parsed content to the engine
  *
  * @uses    \League\Plates\Extension\Asset
  * @uses    \League\Plates\Engine
  * @uses    url
  * @since   1.0
  */
 public function setup()
 {
     $engine = new Engine($this->relativePath . "include" . DS . "styles" . DS . config::init()->style);
     $engine->loadExtension(new Asset($this->relativePath . "include" . DS . "styles" . DS . config::init()->style . DS . "assets", true));
     // add infos for theme
     $this->setStyleParameter("isZipEnabled", false);
     $this->setStyleParameter("showWarnings", false);
     $breadcrumbs = $this->generateBreadcrumbs(url::GET("dir"));
     $this->setStyleParameter("breadcrumbs", $breadcrumbs);
     $this->setStyleParameter("assetspath", common::getRelativePath(getcwd(), dirname(__FILE__)) . DS . "styles" . DS . config::init()->style . DS . "assets");
     $this->setStyleParameter("title", "SimpleDirLister | " . common::fixPaths(implode(DS, array_keys($breadcrumbs))));
     $this->setStyleParameter("path", common::fixPaths(implode(DS, array_keys($breadcrumbs))));
     $this->setStyleParameter("header", config::init()->header ? file::init(config::init()->header)->getFilename() : false);
     $this->setStyleParameter("footer", config::init()->footer ? file::init(config::init()->footer)->getFilename() : false);
     $engine->addFolder('static', $this->getBasePath() . DS . config::init()->headerFooterDir);
     try {
         $files = $this->getRawPaths();
         $files = $this->cleanArray($files);
         if (config::init()->showReadme) {
             $readmeContent = [];
             foreach (config::init()->readme as $readme) {
                 if (isset($files[$readme])) {
                     $c = file_get_contents($files[$readme]["path"]);
                     $ext = pathinfo($files[$readme]["path"], PATHINFO_EXTENSION);
                     if ($ext == "md") {
                         $md = new Parsedown();
                         $readmeContent[] = '<div class="md">' . $md->text($c) . '</div>';
                     } elseif ($ext == "php") {
                         $readmeContent[] = (require $files[$readme]["path"]);
                     } else {
                         $readmeContent[] = $c;
                     }
                     if (config::init()->removeReadme) {
                         unset($files[$readme]);
                     }
                 }
             }
             $this->setStyleParameter("readme", $readmeContent);
         }
     } catch (\Exception $e) {
         $this->setStyleParameter("showWarnings", true);
         $this->setStyleParameter("warnings", [["message" => "dir not found", "type" => "danger"]]);
         $files = [];
     } finally {
         $this->setStyleParameter("files", $files);
     }
     $engine->registerFunction('fileicon', [&$this, "getIconFromSet"]);
     $this->setStyleParameter("search", url::GET("s"));
     $engine->addData($this->styleParameter);
     if (!empty(url::GET("s"))) {
         echo $engine->render("search", $this->styleParameter);
     } else {
         echo $engine->render("index", $this->styleParameter);
     }
 }
コード例 #17
0
 /**
  * {@inheritdoc}
  */
 public function registerFunction($name, $callable) : EngineInterface
 {
     $this->engine->registerFunction($name, $callable);
     return $this;
 }
コード例 #18
0
ファイル: URL.php プロジェクト: sqrt-pro/kernel
 public function register(Engine $engine)
 {
     $engine->registerFunction('url', array($this, 'getURL'));
 }
コード例 #19
0
 public function register(Engine $engine)
 {
     $engine->registerFunction('mailto', array($this, 'generateMailtoLink'));
 }
コード例 #20
0
ファイル: RequestExtension.php プロジェクト: jirro/jirro
 public function register(View $view)
 {
     $view->registerFunction('request', [$this, 'request']);
 }
コード例 #21
0
ファイル: DebugBarExtension.php プロジェクト: jirro/jirro
 public function register(View $view)
 {
     $view->registerFunction('debugBar', [$this, 'debugBar']);
 }
コード例 #22
0
ファイル: AssetUrlExtension.php プロジェクト: jirro/jirro
 public function register(View $view)
 {
     $view->registerFunction('assetUrl', [$this, 'assetUrl']);
 }
コード例 #23
0
 public function register(Engine $engine)
 {
     $engine->registerFunction('asset', [$this, 'getAsset']);
     $engine->registerFunction('favicon', [$this, 'getFavicon']);
 }
コード例 #24
0
 public function register(Engine $engine)
 {
     $engine->registerFunction('route', [$this, 'getRoute']);
 }
コード例 #25
0
 /**
  * Register extension function.
  * @return null
  */
 public function register(Engine $engine)
 {
     $this->engine = $engine;
     $engine->registerFunction('assetJs', array($this, 'assetJs'));
     $engine->registerFunction('assetCss', array($this, 'assetCss'));
 }
コード例 #26
0
ファイル: Asset.php プロジェクト: jothamhernandez/PT_HIFI
 /**
  * Register extension function.
  * @return null
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('asset', array($this, 'cachedAssetUrl'));
 }
コード例 #27
0
 /**
  * Register functions with the Plates engine.
  *
  * @param \League\Plates\Engine $engine The Plates Engine instance.
  * @return void
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('slim', array($this, 'getObject'));
 }
コード例 #28
0
 public function register(Engine $engine)
 {
     $engine->registerFunction('userSession', [$this, 'getUser']);
 }
コード例 #29
0
ファイル: PlatesExtensions.php プロジェクト: nadiadev/W
 /**
  * Enregistre les nouvelles fonctions dans Plates
  */
 public function register(Engine $engine)
 {
     $engine->registerFunction('assetUrl', [$this, 'assetUrl']);
     $engine->registerFunction('url', [$this, 'generateUrl']);
 }
コード例 #30
0
 public function register(Engine $engine)
 {
     $engine->registerFunction('utils', [$this, 'getObject']);
 }