Exemplo n.º 1
0
 /**
  * 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', '');
 }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 5
0
 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'));
 }
Exemplo n.º 6
0
 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');
 }
Exemplo n.º 7
0
Arquivo: Form.php Projeto: ntentan/wyf
 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());
 }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
Arquivo: Wyf.php Projeto: ntentan/wyf
 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);
 }
Exemplo n.º 10
0
 public function __construct()
 {
     parent::__construct();
     $this->temp = TemplateEngine::getTempDirectory();
     $this->setCompileDir("{$this->temp}/smarty_compiled_templates");
 }
Exemplo n.º 11
0
 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]);
 }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
0
 public static function tearDownAfterClass()
 {
     TemplateEngine::reset();
 }
Exemplo n.º 14
0
 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));
 }
Exemplo n.º 15
0
 public function writeFile($templateFile, $data, $destination)
 {
     $output = \ntentan\honam\TemplateEngine::renderString(Filesystem::get($templateFile)->getContents(), 'mustache', $data);
     Filesystem::get($destination)->putContents($output);
 }
Exemplo n.º 16
0
 public function renderFoot()
 {
     return \ntentan\honam\TemplateEngine::render('fieldset_foot.tpl.php', array('element' => $this));
 }
Exemplo n.º 17
0
 public function __toString()
 {
     return TemplateEngine::render(FormHelper::getLayout() . "_layout_element.tpl.php", array('element' => $this));
 }
Exemplo n.º 18
0
 public function renderFoot()
 {
     return TemplateEngine::render('form_foot.tpl.php', array('show_submit' => $this->showSubmit, 'submit_values' => $this->submitValues));
 }
Exemplo n.º 19
0
 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));
 }
Exemplo n.º 20
0
 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));
 }
Exemplo n.º 21
0
 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());
 }
Exemplo n.º 22
0
 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);
 }
Exemplo n.º 23
0
function t($template, $templateData = array())
{
    return TemplateEngine::render($template, $templateData);
}
Exemplo n.º 24
0
 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));
 }
Exemplo n.º 25
0
 public function __construct()
 {
     \ntentan\honam\TemplateEngine::appendPath(__DIR__ . "/../../templates/forms");
 }
Exemplo n.º 26
0
 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 = "&lt;div&gt;Number one&lt;/div&gt; <div>Number one</div> first \n&lt;b&gt;Number two&lt;/b&gt; <b>Number two</b> second \n&lt;span&gt;Number three&lt;/span&gt; <span>Number three</span> third \n&lt;div&gt;Number one&lt;/div&gt; <div>Number one</div> \nsecond found\n&lt;p&gt;A new paragraph&lt;/p&gt; <p>A new paragraph</p> \n&lt;p&gt;A zero paragraph&lt;/p&gt; <p>A zero paragraph</p> \n\n";
     $this->assertEquals($expected, $output);
 }
Exemplo n.º 27
0
 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();
     }
 }
Exemplo n.º 28
0
 public function testLoading()
 {
     TemplateEngine::appendPath("tests/files/views/no_engine");
     TemplateEngine::render("no_engine", array());
 }
Exemplo n.º 29
0
 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')));
 }