public function handle($e) { $app = App::getInstance(); while (ob_get_level() > 0) { ob_end_clean(); } // header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); if ($app->config('bono.debug') !== true) { if (isset($app->response)) { $app->response->setStatus(500); } if (isset($app->theme)) { $view = $app->theme->getView(); $errorTemplate = 'error'; } else { $view = new View(); $errorTemplate = '../templates/error.php'; if (is_readable($errorTemplate)) { $view->setTemplatesDirectory('.'); } } return $view->display($errorTemplate, array('error' => $e), 500); } return call_user_func_array(array($app->whoops, Run::EXCEPTION_HANDLER), func_get_args()); }
public function __invoke() { $user = $this->userRepository->authenticate($this->username, $this->password); if (false !== $user) { $this->session->set(LoginContext::LOGIN_VAR, $user->id()); $this->redir->redirect(303, '/games'); return; } $this->view->display('home.html', ['msg' => 'Invalid login']); }
public function __invoke() { $games = $this->gameRepository->findAll(); $viewGames = []; /** @var Game $game */ foreach ($games as $game) { $viewGames[$game->owner()->displayName()][] = $game->title(); } $viewData['gamesList'] = $viewGames; $this->view->display('games.html', $viewData); }
/** * Render markdown input * * @param string $markDownSyntax Markdown syntax to put inside textarea * @param string $template Template name * @return string HTML string */ public function renderInput($markdownSyntax = '', $template = '_markdown/form') { $this->view->set('app', $this->app); $this->view->set('id', $this->random()); $this->view->set('markdown', $markdownSyntax); $counter = count(explode('.php', $template)); $bladeCounter = count(explode('.blade.php', $template)); if ($counter == 1 and $bladeCounter == 1) { $template .= '.php'; } return $this->view->fetch($template); }
/** * Render template * @var string Template to be rendered (optional) */ public function render($template = '') { $template = is_string($template) ? $template . '.php' : null; if ($template) { $this->appendData(array('global' => $this->global)); $content = parent::render($template); } else { $content = ''; } // make sure buffers flushed ob_end_flush(); if (ob_get_length() !== false) { ob_flush(); } ob_start(); extract(array('content' => $content, 'global' => $this->global)); if ($this->layout) { $layoutPath = $this->getTemplatesDirectory() . '/' . ltrim($this->layout, '/'); if (!is_readable($layoutPath)) { throw new RuntimeException('View cannot render layout `' . $layoutPath); } require $layoutPath; } else { echo $content; } return ob_get_clean(); }
/** * @param array [$options] * @return void */ public function __construct($options = array()) { parent::__construct(); foreach (array_intersect_key($options, array_flip($this->allowedOptions)) as $key => $value) { $this->{$key} = $value; } }
public function fetch($template, $data = null) { $data = is_array($data) ? $data : []; $data['css_files'] = $this->cssFiles; $data['js_files'] = $this->jsFiles; return parent::fetch($template, $data); }
public function render($template = [], $data = null) { if (is_string($template)) { return parent::render($template, $data); } return json_encode($this->data[0]); }
/** * [fetch description] * * @param [type] $template [description] * * @return [type] [description] */ public function fetch($template) { $app = App::getInstance(); if (empty($template)) { return $this->data['body']; } else { if ($app->theme) { $template = $app->theme->resolve($template, $this) ?: $template; } $html = parent::fetch($template); $layoutTemplate = null; if ($this->layout) { if ($app->theme) { $layoutTemplate = $app->theme->resolve($this->layout, $this->layoutView); } else { $layoutTemplate = $this->layout; } } if ($layoutTemplate) { $this->layoutView->replace($this->all()); $this->layoutView->set('body', $html); return $this->layoutView->render($layoutTemplate); } else { return $html; } } }
public function __construct($path) { $this->loader = new \Twig_Loader_Filesystem($path); $this->twig = new \Twig_Environment($this->loader); $this->twig->addExtension(new \Twig_Extensions_Extension_I18n()); parent::__construct(); }
/** * Constructor * * @param string $template_dir The base template directory * @param string $compile_dir The directory in which to compile the templates * @param string $cache_dir The directory in which to cache the compiled templates * @param string $plugin_dir The directory containing Smarty plugins */ public function __construct($template_dir, $compile_dir, $cache_dir, $plugin_dir = '') { parent::__construct(); $this->template_dir = $template_dir; $this->compile_dir = $compile_dir; $this->cache_dir = $cache_dir; $this->plugin_dir = $plugin_dir; }
public function __construct(array $options = array()) { parent::__construct(); $this->options = array_merge($this->options, $options); if (!empty($this->options['overwrite'])) { $this->options['auto_reload'] = true; } }
/** * Render a template * * Call this method within a GET, POST, PUT, DELETE, NOT FOUND, or ERROR * callable to render a template whose output is appended to the * current HTTP response body. How the template is rendered is * delegated to the current View. * * @param string $template The name of the template passed into the view's render() method * @param array $data Associative array of data made available to the view * @param int $status The HTTP response status code to use (optional) */ public function render($template, $data = array(), $status = null) { if (!is_null($status)) { $this->response->status($status); } $this->view->appendData($data); $this->view->display($template); }
public function __construct() { parent::__construct(); $this->context = new SplStack(); $this->yield_blocks = array(); $this->helpers = new \Slim\Helper\Set($this->getHelpers()); $this->block_helpers = new \Slim\Helper\Set($this->getBlockHelpers()); }
/** * Configure view behavior. * * @param \Slim\View $view Default view */ protected function configureView(\Slim\View $view) { $view->parserOptions = ['charset' => 'utf-8', 'cache' => $this->slim->config('view.cache'), 'debug' => $this->slim->config('debug'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true]; // Install twig parser extensions $view->parserExtensions = [new \Slim\Views\TwigExtension(), new TwigExtension($this->slim->parsoid), new \Wikimedia\SimpleI18n\TwigExtension($this->slim->i18nContext), new \Twig_Extension_Debug(), new LinkifyExtension(['/(?<=^|\\s)\\b(I[0-9a-f]{6,})\\b(?=\\s|:|,|$)/' => ['https://gerrit.wikimedia.org/r/#/q/$1,n,z', '$1'], '/(?<=^|\\s|\\(|\\[)\\b([0-9a-f]{7,})\\b(?=\\s|:|,|\\)|\\]|$)/' => ['https://gerrit.wikimedia.org/r/#/q/$1,n,z', '$1'], '/\\b([Gg]errit[:|](\\d+))\\b/' => ['https://gerrit.wikimedia.org/r/#/c/$2', '$1'], '#(?<!/)\\b(T\\d+)\\b#' => ['https://phabricator.wikimedia.org/$1', '$1'], '/\\b([Bb]ugzilla[:|](\\d+))\\b/' => ['https://bugzilla.wikimedia.org/show_bug.cgi?id=$2', '$1'], '/(?<=^|\\s)\\br(\\d+)\\b(?=\\s|:|,|$)/' => ['https://www.mediawiki.org/wiki/Special:Code/MediaWiki/$1', '$0'], '#(?<=^|\\s)<?(https?://\\S+)>?(?=\\s|$)#' => ['$1', '$0']])]; // Set default view data $view->replace(['app' => $this->slim, 'i18nCtx' => $this->slim->i18nContext]); }
protected function render($template, $data = null) { $contents = parent::render($template, $data); if (is_null($this->layoutFile)) { return $contents; } else { return parent::render('layout.php', array('contents' => $contents, 'title' => $this->htmlTitle)); } }
public function __construct($options) { parent::__construct(); // Smarty対応 self::$smartyDirectory = $options['smartyDirectory']; self::$smartyCompileDirectory = $options['smartyCompileDirectory']; self::$smartyCacheDirectory = $options['smartyCacheDirectory']; self::$smartyTemplatesDirectory = $options['smartyTemplatesDirectory']; }
/** * Render a template * * Call this method within a GET, POST, PUT, DELETE, NOT FOUND, or ERROR * callable to render a template whose output is appended to the * current HTTP response body. How the template is rendered is * delegated to the current View. * * @param string $template The name of the template passed into the view's render() method * @param array $data Associative array of data made available to the view * @param int $status The HTTP response status code to use (optional) */ public function render($template, $data = array(), $status = null) { if (!is_null($status)) { $this->response->status($status); } $this->view->setTemplatesDirectory($this->config('templates.path')); $this->view->appendData($data); $this->view->display($template); }
public function render($template, $data = NULL) { if ($this->layout) { $_html = parent::render($template); $this->set('_html', $_html); $template = $this->layout; $this->layout = null; } return parent::render($template); }
public function handle() { $app = App::getInstance(); if ($app->config('bono.debug') !== true) { if (isset($app->response)) { $app->response->setStatus(404); } if (isset($app->theme)) { $view = $app->theme->getView(); $errorTemplate = 'notFound'; } else { $view = new View(); $errorTemplate = '../templates/notFound.php'; if (is_readable($errorTemplate)) { $view->setTemplatesDirectory('.'); } } return $view->display($errorTemplate, array(), 404); } $app->whoops->sendHttpCode(404); return call_user_func(array($app->whoops, Run::EXCEPTION_HANDLER), new RuntimeException("404 Resource not found")); }
public function render($template, $data = null) { if (!is_array($data)) { $data = (array) $data; } if (isset($data['noWrapper'])) { return parent::render($template, $data); } else { $data['view'] = $this; $data['template'] = $template; return parent::render("decorator/decorator.phtml", $data); } }
/** * Our (marginally) smarter render function. The layout can be changed by * setting a "_layout" data key to the new layout file, or boolean false to * disable layout. * * @param string $template template name * @return string rendered template */ public function render($template) { $env = \Slim\Environment::getInstance(); $this->setData('_base', $env['SCRIPT_NAME']); $data = $this->getData(); if (isset($data['_layout'])) { $layout = $data['_layout']; } else { $layout = $this->layout; } $content = parent::render($template); if ($layout !== false) { $this->setData($data); $this->setData('content', $content); $content = parent::render($layout); } return $content; }
/** * Render template * @var string $template Template to be rendered */ public function render($template = '', $data = null) { $template = is_string($template) ? $template . '.php' : null; if ($template) { $this->appendData(array('global' => $this->global)); $content = parent::render($template); } else { $content = ''; } extract(array('content' => $content, 'global' => $this->global)); if ($this->layout) { $layoutPath = $this->getTemplatesDirectory() . DIRECTORY_SEPARATOR . ltrim($this->layout, '/'); if (!is_readable($layoutPath)) { throw new \RuntimeException('View cannot render layout `' . $layoutPath); } require $layoutPath; } else { echo $content; } }
/** * Initalizer a.k.a the class constructor * Leave the third arguments empty if you won't use any layout * * @param array $options Options for BladeView * * @return KrisanAlfa\Blade\BladeView */ public function __construct(array $options) { parent::__construct(); $this->app = App::getInstance(); $this->container = new Container(); $viewPaths = $this->resolvePath($options['viewPaths']); $this->container->singleton('view.paths', function () use($viewPaths) { return $viewPaths; }); $cachePath = $options['cachePath']; $this->container->singleton('cache.path', function () use($cachePath) { return $cachePath; }); $this->registerFilesystem(); $this->registerEvents(); $this->registerEngineResolver(); $this->registerViewFinder(); $this->registerFactory(); $this->instance = $this->container->make('view'); }
function __construct() { parent::__construct(); require_once __DIR__ . '/../../Twig/lib/Twig/Autoloader.php'; Twig_Autoloader::register(); $loader = new \Twig_Loader_Filesystem(); $locations = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getOptions(); $templates = $locations['location']; foreach ($templates as $key => $value) { if (!file_exists($value . '/Views')) { mkdir($value . '/Views'); } $loader->addPath($value . '/Views', $key); } // if (\Raptor\Raptor::getInstance()->getMode() == 'development') { if (\Raptor\Raptor::getInstance()->config('debug')) { $this->twig = new Twig_Environment($loader, array()); } else { $this->twig = new Twig_Environment($loader, array('cache' => \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE) . '/7u136')); } $this->register(); }
public function __construct(AssetManager $asset_manager) { parent::__construct(); $this->_assetManager = $asset_manager; $app = App::i(); $this->documentMeta = new \ArrayObject(); $this->bodyClasses = new \ArrayObject(); $this->bodyProperties = new \ArrayObject(); $this->jsObject = new \ArrayObject(); $this->jsObject['baseURL'] = $app->baseUrl; $this->jsObject['assetURL'] = $app->assetUrl; $this->jsObject['maxUploadSize'] = $app->getMaxUploadSize($useSuffix = false); $this->jsObject['maxUploadSizeFormatted'] = $app->getMaxUploadSize(); $folders = []; $class = get_called_class(); while ($class !== __CLASS__) { if (!method_exists($class, 'getThemeFolder')) { throw new \Exception("getThemeFolder method is required for theme classes and is not present in {$class} class"); } $folders[] = $class::getThemeFolder() . '/'; $class = get_parent_class($class); } $this->path = new \ArrayObject(array_reverse($folders)); }
function getOutput($template, $data = array()) { $this->setData($data); return parent::render($template); }
protected function render($template, $data = null) { return parent::render($template . '.php', $data); }
public function __construct(Slim $app) { parent::__construct(); $this->app = $app; $this->setTemplatesDirectory(__DIR__ . '/../Responder/html'); }
/** * コンストラクタ * * @param Array $options */ public function __construct($options) { parent::__construct(); self::$twigOptions = $options; }