/** * Initialize the component. * * @see ntentan\controllers.Controller::init() */ public function init() { parent::init(); // Setup the template engine and set params TemplateEngine::appendPath(realpath(__DIR__ . "/../../views/signin")); View::set('app', Config::get('ntentan:app.name')); View::set('social_signin_base_url', ''); }
public function render() { $this->setAttribute('rows', 10); $this->setAttribute('cols', 80); $this->setAttribute('class', "textarea {$this->getCSSClasses()}"); $this->setAttribute('name', $this->getName()); return \ntentan\honam\TemplateEngine::render("textarea_element.tpl.php", array('element' => $this)); }
public function login() { TemplateEngine::appendPath(__DIR__ . '/../../../../views/auth'); if (Input::exists(Input::POST, $this->usersFields['username']) && Input::exists(Input::POST, $this->usersFields['password'])) { return $this->authLocalPassword(Input::post($this->usersFields['username']), Input::post($this->usersFields['password'])); } else { return false; } }
public function render() { if ($this->getCheckedValue() == (string) $this->getValue()) { $this->setAttribute('checked', 'checked'); } $this->setAttribute("name", $this->getName()); $this->setAttribute("class", "{$this->getAttribute('type')} {$this->getCSSClasses()}"); $this->setValue($this->getCheckedValue()); return TemplateEngine::render('input_checkable_element.tpl.php', array('element' => $this)); }
public function testAssetLoading() { vfsStream::setup('public'); AssetsLoader::appendSourceDir('tests/files/assets'); AssetsLoader::setDestinationDir(vfsStream::url('public')); touch(vfsStream::url('public/existing.css')); $output = TemplateEngine::render('assets.tpl.php', array()); $this->assertEquals("vfs://public/some.css\nvfs://public/another.css\nvfs://public/existing.css", $output); $this->assertFileExists(vfsStream::url('public/some.css')); $this->assertFileExists(vfsStream::url('public/another.css')); }
public function __construct() { parent::__construct(); $this->addOperation('edit'); $this->addOperation('delete'); TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/crud')); TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/forms')); View::set('entities', $this->getWyfName()); View::set('entity', Text::singularize($this->getWyfName())); View::set('has_add_operation', true); View::set('form_template', str_replace('.', '_', $this->getWyfPackage()) . '_form'); }
public function __toString() { foreach ($this->elements as $element) { if (is_a($element, "\\ntentan\\plugins\\wyf\\helpers\\inputs\\forms\\Container")) { $element->setData($this->data); $element->setErrors($this->errors); } else { $name = $element->getName(); $element->setData($this->data[$name]); $element->setErrors($this->errors[$name]); } } return TemplateEngine::render('wyf_forms_form', $this->getTemplateVariables()); }
public function __construct() { $this->addComponent('auth', array('users_model' => 'system.users', 'on_success' => 'call_function', 'login_route' => 'auth/login', 'success_function' => AuthController::class . '::postLogin')); TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/default')); TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/menus')); View::set('route_breakdown', explode('/', Router::getRoute())); View::set('wyf_title', Config::get('ntentan:app.name')); $class = get_class($this); $namespace = Ntentan::getNamespace(); if (preg_match("/{$namespace}\\\\app\\\\(?<base>.*)\\\\controllers\\\\(?<name>.*)Controller/", $class, $matches)) { $this->package = strtolower(str_replace("\\", ".", $matches['base']) . "." . $matches['name']); $this->name = str_replace(".", " ", $this->package); $this->path = str_replace(' ', '/', $this->name); } }
public static function init($parameters = []) { Router::mapRoute('wyf_auth', 'auth/{action}', ['default' => ['controller' => controllers\AuthController::class]]); Router::mapRoute('wyf_api', 'api/{*path}', ['default' => ['controller' => controllers\ApiController::class, 'action' => 'rest']]); Router::mapRoute('wyf_main', function ($route) { $routeArray = explode('/', $route); $routeDetails = self::getController($routeArray, realpath(__DIR__ . '/../../../../src/app/'), \ntentan\Ntentan::getNamespace() . '\\app'); return $routeDetails; }, ['default' => ['action' => 'index']]); TemplateEngine::appendPath(realpath(__DIR__ . '/../views/layouts')); TemplateEngine::appendPath(realpath(__DIR__ . '/../views')); AssetsLoader::appendSourceDir(realpath(__DIR__ . '/../assets')); View::set('wyf_app_name', $parameters['short_name']); InjectionContainer::bind(ModelClassResolver::class)->to(ClassNameResolver::class); InjectionContainer::bind(ControllerClassResolver::class)->to(ClassNameResolver::class); }
public function __construct() { parent::__construct(); $this->temp = TemplateEngine::getTempDirectory(); $this->setCompileDir("{$this->temp}/smarty_compiled_templates"); }
public function __toString() { $menuItems = array(); foreach ($this->items as $index => $item) { if (is_string($item) || is_numeric($item)) { $item = array('label' => $item, 'url' => $this->makeFullUrl(strtolower(str_replace(' ', '_', $item))), 'default' => null); } $item['selected'] = $item['url'] == substr($this->currentUrl, 0, strlen($item['url'])); $item['fully_matched'] = $item['url'] == $this->currentUrl; $menuItems[$index] = $item; } return \ntentan\honam\TemplateEngine::render("{$this->alias}_menu.tpl.php", ['items' => $menuItems, 'css_classes' => $this->cssClasses, 'has_links' => $this->hasLinks, 'alias' => $this->alias]); }
public function __toString() { $this->parameters['row_template'] = $this->parameters['row_template'] == null ? 'row.tpl.php' : $this->parameters['row_template']; $this->parameters['default_cell_template'] = $this->parameters['default_cell_template'] == null ? 'default_cell.tpl.php' : $this->parameters['default_cell_template']; return TemplateEngine::render('list.tpl.php', $this->parameters); }
public static function tearDownAfterClass() { TemplateEngine::reset(); }
public function render() { $keys = array_keys($this->options); array_unshift($keys, ''); array_unshift($this->options, $this->default); $this->options = array_combine($keys, $this->options); $this->setAttribute('name', $this->name); if ($this->multiple) { $this->setAttribute('multiple', 'multiple'); } $this->setAttribute('class', "select {$this->getCSSClasses()}"); return \ntentan\honam\TemplateEngine::render('select_element.tpl.php', array('element' => $this)); }
public function writeFile($templateFile, $data, $destination) { $output = \ntentan\honam\TemplateEngine::renderString(Filesystem::get($templateFile)->getContents(), 'mustache', $data); Filesystem::get($destination)->putContents($output); }
public function renderFoot() { return \ntentan\honam\TemplateEngine::render('fieldset_foot.tpl.php', array('element' => $this)); }
public function __toString() { return TemplateEngine::render(FormHelper::getLayout() . "_layout_element.tpl.php", array('element' => $this)); }
public function renderFoot() { return TemplateEngine::render('form_foot.tpl.php', array('show_submit' => $this->showSubmit, 'submit_values' => $this->submitValues)); }
public function render() { $this->setAttribute("class", "{$this->getAttribute('type')} {$this->getCSSClasses()}"); $this->setAttribute("name", $this->getName()); return TemplateEngine::render("input_element.tpl.php", array('element' => $this)); }
public function __toString() { $pagingLinks = array(); if ($this->parameters['page_number'] > 1) { $pagingLinks[] = array("link" => $this->getLink($this->parameters['page_number'] - 1), "label" => "< Prev", "selected" => false); } if ($this->parameters['number_of_pages'] <= $this->parameters['number_of_links'] || $this->parameters['page_number'] < $this->halfNumberOfLinks) { for ($i = 1; $i <= ($this->parameters['number_of_pages'] > $this->parameters['number_of_links'] ? $this->parameters['number_of_links'] : $this->parameters['number_of_pages']); $i++) { $pagingLinks[] = array("link" => $this->getLink($i), "label" => "{$i}", "selected" => $this->parameters['page_number'] == $i); } } else { if ($this->parameters['number_of_pages'] - $this->parameters['page_number'] < $this->halfNumberOfLinks) { $startOffset = $this->parameters['page_number'] - ($this->parameters['number_of_links'] - 1 - ($this->parameters['number_of_pages'] - $this->parameters['page_number'])); $endOffset = $this->parameters['page_number'] + ($this->parameters['number_of_pages'] - $this->parameters['page_number']); } else { $startOffset = $this->parameters['page_number'] - ($this->halfNumberOfLinks - 1); $endOffset = $this->parameters['page_number'] + ($this->halfNumberOfLinks - 1); } for ($i = $startOffset; $i <= $endOffset; $i++) { $pagingLinks[] = array("link" => $this->getLink($i), "label" => "{$i}", "selected" => $this->parameters['page_number'] == $i); } } if ($this->parameters['page_number'] < $this->parameters['number_of_pages']) { $pagingLinks[] = array("link" => $this->getLink($this->parameters['page_number'] + 1), "label" => "Next >", "selected" => false); } return TemplateEngine::render("links.tpl.php", array('links' => $pagingLinks)); }
public function __toString() { $type = $this->renderWithType == '' ? \ntentan\utils\Text::deCamelize($this->getType()) : $this->renderWithType; return TemplateEngine::render("wyf_inputs_forms_{$type}.tpl.php", $this->getTemplateVariables()); }
public function executeControllerAction($action, $params) { $name = $this->getName(); $path = Text::camelize($action); $return = null; $invokeParameters = []; if ($methodDetails = $this->getMethod($path)) { panie\InjectionContainer::bind(controllers\ModelBinderInterface::class)->to($methodDetails['binder']); $method = new \ReflectionMethod($this, $methodDetails['name']); honam\TemplateEngine::prependPath("views/{$name}"); if (View::getTemplate() == null) { View::setTemplate("{$name}_{$action}" . '.tpl.php'); } $methodParameters = $method->getParameters(); foreach ($methodParameters as $methodParameter) { $this->bindParameter($invokeParameters, $methodParameter, $params); } $method->invokeArgs($this, $invokeParameters); $return = View::out(); echo $return; return; } else { foreach ($this->loadedComponents as $component) { //@todo Look at how to prevent this from running several times if ($component->hasMethod($path)) { $component->executeControllerAction($path, $params); return; } } } throw new exceptions\ControllerActionNotFoundException($this, $path); }
function t($template, $templateData = array()) { return TemplateEngine::render($template, $templateData); }
public static function run() { Session::start(); honam\TemplateEngine::prependPath('views/shared'); honam\TemplateEngine::prependPath('views/layouts'); honam\AssetsLoader::setSiteUrl(Url::path('public')); honam\AssetsLoader::appendSourceDir('assets'); honam\AssetsLoader::setDestinationDir('public'); honam\Helper::setBaseUrl(Url::path('')); self::getRouter()->execute(substr(utils\Input::server('REQUEST_URI'), 1)); }
public function __construct() { \ntentan\honam\TemplateEngine::appendPath(__DIR__ . "/../../templates/forms"); }
public function testArrayVariable() { $output = TemplateEngine::render('phptest_array.tpl.php', array('array' => array('first' => '<div>Number one</div>', 'second' => '<b>Number two</b>', 'third' => '<span>Number three</span>'))); $expected = "<div>Number one</div> <div>Number one</div> first \n<b>Number two</b> <b>Number two</b> second \n<span>Number three</span> <span>Number three</span> third \n<div>Number one</div> <div>Number one</div> \nsecond found\n<p>A new paragraph</p> <p>A new paragraph</p> \n<p>A zero paragraph</p> <p>A zero paragraph</p> \n\n"; $this->assertEquals($expected, $output); }
public function render() { switch ($this->rendererMode) { case 'head': return $this->renderHead(); case 'foot': return $this->renderFoot(); default: return $this->renderHead() . TemplateEngine::render('elements.tpl.php', array('elements' => $this->getElements())) . $this->renderFoot(); } }
public function testLoading() { TemplateEngine::appendPath("tests/files/views/no_engine"); TemplateEngine::render("no_engine", array()); }
public function testInvocation() { $this->assertEquals('Hello James Ainooson<form method="POST" class="fapi-form"><div class="form-submit-area"><input class="form-submit" type="submit" value="Submit" /></div></form>', TemplateEngine::render("test.smarty", array('firstname' => 'James', 'lastname' => 'Ainooson'))); }