/** * The magic method __call() allows us to treat any method that is called as the intented * html element to be created. * * If $args[0] is an Array then $args[0] will be treated as properties to be included on the element * containing content specified in $args[1]. Otherwise $args[0] will be treated as the content of the element. * * * @param string $method The method name called and also the intented html element to return. * @param Array $args The arguements passed to $method. * * @return string */ public function __call($method, $args) { $ele = $method; $props = ''; if (is_array($args[0])) { foreach ($args[0] as $k => $v) { $props .= sprintf($this->prop, $k, $v); } //foreach $props = rtrim($props); if (!isset($args[1]) && in_array($method, $this->noClose)) { $out = sprintf($this->noCloseBase, $method . ' ' . $props); if ($this->stack) { \View::html($out); $this->stack = false; } else { return $out; } //el } //if $method .= ' ' . $props; $html = ''; if (isset($args[1])) { $html = $args[1]; } //if } else { $html = $args[0]; } //el $out = sprintf($this->base, $method, $html, $ele); if ($this->stack) { \View::html($out); $this->stack = false; } else { return $out; } //el }
public function testPageOutput() { View::instance()->html = array(); ob_start(); View::lang('en'); View::title('Test Title'); View::desc('Test Desc'); View::html('Content'); View::styleSrc('/css/css.css'); View::scriptSrc('/js/js.js'); View::script('alert("Hi");'); View::printPage(); $c = ob_get_contents(); ob_end_clean(); $this->assertContains("<html lang='en'", $c); $this->assertContains('<title>Test Title</title>', $c); $this->assertContains("<meta name='description' content=\"Test Desc\">", $c); $this->assertContains('Content', $c); $this->assertContains('<link rel="stylesheet" type="text/css" href="/css/css.css"/>', $c); $this->assertContains('<script type="text/javascript" src="/js/js.js"></script>', $c); $this->assertContains('<script type="text/javascript">alert("Hi");</script>', $c); }
/** * Add HTML to the view. * * @param string $html HTML to load into the view. */ public function html($html) { \View::html($template); \View::serve(); }
/** * Print page breadcrumbs. * * * @param array $data The crumbs. * * @return string */ public function printBreadCrumbs($data) { $html = ''; foreach ($data as $k => $v) { $html .= \Template::build('wordpress/breadcrumb', array('path' => $this->path, 'slug' => $v, 'name' => $k)); } //foreach $crumbs = \Template::build('wordpress/breadcrumb-container', array('crumbs' => $html, 'path' => $this->path)); if ($this->settings['inject_feed']) { \View::html($crumbs); } else { return $crumbs; } //el }
<?php return function () { \View::html(' <div class="container center-align"> <h1 class="header">404 :[</h1> <p>Pstt: This is being served from <span class="chip">app/error/404.php</span>. You should custmoize it and make it unique!</p> </div> '); };
<?php return function () { \View::html(' <div class="container center-align"> <h1 class="header">Oops we messed up and couldn\'t process your request</h1> <p>AKA <i>Internal Server Error</i></p> <p>Pstt: This is being served from <span class="chip">app/error/500.php</span>.</p> </div> '); };
<?php return function () { View::html('Our site is currently undering going routine maintanance it should be back up soon'); };
$c['Author'] = 'author/'; $c[$author] = 'author/' . $author; WP::printBreadCrumbs($c); WP::author($author); })->where('author', 'alpha_numeric'); Router::get(WP::path() . 'author/{author}/page/{currentPage}', function ($author, $currentPage) { $c = array(); $c['Author'] = 'author/'; $c[$author] = 'author/' . $author; WP::printBreadCrumbs($c); Data::get()->set('current-page', $currentPage); WP::author($author); })->where(array('author' => 'alpha_numeric', 'currentPage' => 'integer')); Router::get(WP::path() . 'tag/', function () { $c = array(); $c['Tag'] = 'tag/'; WP::printBreadCrumbs($c); WP::template('tag-list', '<a class="wp-tag-list" href="{{$path}}tag/{{$slug}}">{{$name}} - {{$count}}</a>'); $tags = WP::topTags(1000); View::html("<div class='clearfix'>{$tags}</div>"); WP::clearTemplate('tag-list'); }); Router::get(WP::path() . '{slug}', function ($slug) { WP::printBreadCrumbs(array(str_replace('-', ' ', $slug) => $slug)); WP::post($slug); })->where('slug', 'alpha_numeric'); Router::get(WP::path() . 'page/{currentPage}', function ($currentPage) { WP::printBreadCrumbs(array('Page ' . $currentPage => 'page/' . $currentPage)); Data::get()->set('current-page', $currentPage); WP::index(); })->where('currentPage', 'integer');