public function generate() { $tmpl = new Template(); $tmpl->curr = $this->cur_page; $tmpl->menu = array( "display" => array( "Home", "Menu", "Pay", "Logout" ), "link" => array( "index.php", "order.php", "checkout.php", "login.php?logout=true" ) ); $css = $tmpl->build('header.css'); $html = $tmpl->build('header.html'); //$js = $tmpl->build('header.js'); $content = array('html' => $html, 'css' => $css, 'js' => $js); return $content; }
public function generate() { $tmpl = new Template(); $css = $tmpl->build('footer.css'); $html = $tmpl->build('footer.html'); //$js = $tmpl->build('footer.js'); $content = array('html' => $html, 'css' => array('code' => $css, 'link' => 'footer'), 'js' => $js); return $content; }
public function generate() { $tmpl = new Template(); $tmpl->ing_labels = $this->ing_labels; $css = $tmpl->build('ingredients.css'); $html = $tmpl->build('ingredients.html'); //$js = $tmpl->build('menubar.js'); // For any JS related to the menubar $content = array('html' => $html, 'css' => $css, 'js' => $js); return $content; }
public function generate($view) { $tmpl = new Template(); $tmpl->item_info = $this->item_info; $tmpl->view = $view; $tmpl->ing_labels = $this->ing_labels; $css = $tmpl->build('menuitem.css'); $html = $tmpl->build('menuitem.html'); //$js = $tmpl->build('menubar.js'); // For any JS related to the menubar $content = array('html' => $html, 'css' => $css, 'js' => $js); return $content; }
/** * @depends testInterface * @return null */ public function testBuild() { $data = array('foo' => 'bar', 'baz' => array(1, 2, 3)); $this->template->setStatus(3001, "Custom Message")->load($data); $expected = '{"code":3001,"message":"Custom Message",'; $expected .= '"data":{"foo":"bar","baz":[1,2,3]}}'; $this->assertEquals($expected, $this->template->build()); }
public function build($appContent){ $tmpl = new Template(); $tmpl->headerContent = $this->header->generate(); $tmpl->appContent = $appContent; $tmpl->footerContent = $this->footer->generate(); $tmpl->title = $this->page_title; $tmpl->id = $this->body_id; return $tmpl->build('page.html'); }
public function build($appContent) { $tmpl = new Template(); $tmpl->headerContent = $this->header->generate(); $tmpl->menuContent = $this->curr == 1 ? $this->menu->generate() : ""; $tmpl->menuItem = ($this->curr == 1) ? $this->menuItem->generate($this->curr) : ""; $tmpl->appContent = $appContent; $tmpl->title = $this->page_title; return $tmpl->build('page.html'); }
/** * general bypass for unhandled tag attributes * @param array $params * @return string */ protected function resolveParams(array $params) { $out = ''; foreach ($params as $key => $value) { // build dynamic tokens if (preg_match('/{{(.+?)}}/s', $value)) { $value = $this->template->build($value); } if (preg_match('/{{(.+?)}}/s', $key)) { $key = $this->template->build($key); } // inline token if (is_numeric($key)) { $out .= ' ' . $value; } elseif ($value == NULL) { $out .= ' ' . $key; } else { $out .= ' ' . $key . '="' . $value . '"'; } } return $out; }
/** * auto-append footer slot marker into <body> * @param $node * @return string */ public function _body($node) { $params = ''; if (isset($node['@attrib'])) { $params = $this->resolveAttr($node['@attrib']); unset($node['@attrib']); } $content = array(); // bypass inner content nodes foreach ($node as $el) { $content[] = $this->template->build($el); } return '<body' . $params . '>' . implode("\n", $content) . "\n" . $this->render('footer') . "\n" . '</body>'; }
public function build() { $pref = new Pref("system"); $this->setMainTemplate($pref->template); $tpl = new Template(PATH_TEMPLATES); if (!USER_ID && !$this->isAllowed()) { header("location: " . page("user", "login")); } if (!USER_ID && $this->isAllowed()) { $tpl->login = true; } else { $tpl->login = false; } $tpl->loadFile("template.php"); $tpl->data = $this->data; $tpl->build(); }
function template($tpl) { global $sys; $tpl_dir = ZH . "/tpl"; $cache_dir = ZH_TMP . "/tpl"; if (!file_exists("{$tpl_dir}/{$sys->theme}/{$tpl}.tpl.php")) { $theme = 'zh'; } else { $theme = $sys->theme; } $tplfile = "{$tpl_dir}/{$theme}/{$tpl}.tpl.php"; $objfile = "{$cache_dir}/{$theme}.{$tpl}.cache.php"; $langfile = "{$tpl_dir}/{$theme}/lang.ini.php"; if (!file_exists($objfile) || filemtime($objfile) < max(filemtime($tplfile), filemtime($langfile))) { $t = new Template(); $t->build($tplfile, $objfile); $t = null; } return $objfile; }
unset($img); //start a session and store a variable; setSession(0,'/'); // expires with browser session, the root is '/' setSessionVar('foo', 'bar'); //there's no retrieval function, so this is kind of stupid if( !isset($_SESSION['foo']) ){ throw new RedirectBrowserException("example.php"); } //Database calls /* $db = new Database("username", "password", "database name", "location of database", "type of database"); // currently only supports "mysql" $sql = "SELECT * FROM mytable WHERE myid=?"; $values = array(4); // myid $result = $db->qwv($sql, $values); // query with values, returns array of rows (can be empty) if( $db->stat() ) // <-- the boolean representing whether the last query was successful{ foreach( $result as $row ){ print $row['myid'] . "<br />"; } } $sql = "INSERT INTO mytable VALUES (4)"; $db->q($sql); // query (no values), returns array of rows (can be empty) Database.php is fully top-commented */ print $tmpl->build('example.html'); ?>
public function generate() { $tmpl = new Template(); $tmpl->curr = $this->cur_page; if( isset($_SESSION['umbrella']['tableid']) && !isset($_SESSION['userid']) ) { $this->setGuest($_SESSION['umbrella']['tableid']); } if( $_SERVER['QUERY_STRING'] != null ) { $qs = $_SERVER['QUERY_STRING']; $st = explode("&", $qs); $vals = array(); foreach($st as $string) { $pair = explode("=", $string); $vals[$pair[0]] = $pair[1]; } //array of available testing tables $tables = array(1); $tid = hexdec($vals['hor']) / 1000; if( in_array($tid, $tables) ) { $_SESSION['umbrella']['tableid'] = $tid; $this->setGuest($tid); header('Location: index.php'); } } if( $_SERVER['SCRIPT_NAME'] != '/error.php' ) { if( ($_SERVER['SCRIPT_NAME'] != '/login.php' && !isset($_SESSION['umbrella']['tableid'])) ) { if( $_SESSION['roleid'] > 2 ) { $loc = urlencode("login.php?code=11"); header('Location: login.php?action=logout&fwd='.$loc); } else { if( $_SERVER['SCRIPT_NAME'] != '/table.php' ) { header('Location: table.php?code=0'); } } } } if( $_SESSION['active'] ) { $tmpl->menu = Navigation::getByRole($_SESSION['roleid']); array_push($tmpl->menu, new Navigation( null, "Logout", "/login.php?action=logout", 'user', 4, 0 )); } else { $tmpl->menu = Navigation::getByRole(4); array_push($tmpl->menu, new Navigation( null, "Login", "/login.php", 'user', 4, 0 )); } $css = $tmpl->build('header.css'); $html = $tmpl->build('header.html'); $js = $tmpl->build('header.js'); $content = array('html' => $html, 'css' => array('code' => $css, 'link' => 'header'), 'js' => $js); return $content; }
break; case 13: $tmpl->message = "Adding item succeeded."; $tmpl->css = "okay"; break; case 14: $tmpl->message = "Updating item succeeded."; $tmpl->css = "okay"; break; default: break; } $page->run(); $html = $tmpl->build('item.html'); $css = $tmpl->build('item.css'); $js = $tmpl->build('item.js'); $appContent = array( 'html' => $html, 'css' => array( 'code' => $css, 'link' => 'item' ), 'js' => $js ); print $page->build($appContent); function checkLogin($roles) {
<?php set_include_path('backbone:components:content:scripts:styles:images:model:render'); require_once('Page.php'); require_once('Template.php'); $page = new Page(0, "OrderUp - improve your dining"); $tmpl = new Template(); $page->run(); $html = $tmpl->build('index.html'); $css = $tmpl->build('index.css'); //$js = $tmpl->build('index.js'); $appContent = array( 'html' => $html, 'css' => array( 'code' => $css, 'link' => 'index' ), 'js' => $js ); print $page->build($appContent); ?>
$mvrating = $movie->rating(); $photo_url = $movie->photo_localurl(); $db = new DB("torrents_imdb"); $db->setColPrefix("imdb_"); $db->torrent = $id; $db->genres = implode(", ", $gen); $db->plot = $plotoutline; $db->title = $movie->title(); $db->image = $photo_url; $db->rating = $mvrating; $db->insert(); } header("location: " . page("torrent", "details", "", "", "", "id=" . $id)); } else { $db = new DB("torrents"); $db->delete("torrent_id = {$id}"); throw new Exception("Could not upload torrent file. please contact staff."); } } catch (Exception $e) { echo error(_t($e->getMessage())) . "<br />"; } } try { if (!$acl->uploader) { throw new Exception("You are not an uploader. Access denied!"); } $tpl = new Template($this->path . "tpl/"); $tpl->build("upload.php"); } catch (Exception $e) { echo error(_t($e->getMessage())) . "<br />"; }
/** * 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 set_include_path('backbone:components:content:scripts:styles:images:model:render'); require_once('Page.php'); require_once('Template.php'); $page = new Page(0, "OrderUp - Error"); $tmpl = new Template(); $page->run(); $html = $tmpl->build('error.html'); //$css = $tmpl->build('error.css'); //$js = $tmpl->build('error.js'); $appContent = array( 'html' => $html, 'css' => array( 'code' => $css, 'link' => 'error' ), 'js' => $js ); print $page->build($appContent); ?>
$page->run(); $suggested_item_objects = array(); $suggested_items = isset($_GET['item']) ? Predict::similar(Item::getByName($_GET['item'])) : -1; $tmpl->suggested_items = $suggested_items; if($suggested_items != -1) { foreach($suggested_items as $si) { array_push($suggested_item_objects, array(Item::getByID(intval($si['itemid'])), $si['similarity'])); } } $tmpl->suggested_item_objects = $suggested_item_objects; $html = $tmpl->build('prediction_test.html'); $css = $tmpl->build('reporting.css'); $js = $tmpl->build('prediction_test.js'); $appContent = array( 'html' => $html, 'css' => array( 'code' => $css, 'link' => 'reporting' ), 'js' => $js ); print $page->build($appContent); ?>
$db->id = $id; $db->name = $username; $db->email = $email; $db->password = $password_hash; $db->password_secret = $password_secret; $db->status = 1; $db->ip = $_SERVER['REMOTE_ADDR']; $db->passkey = $passkey; $db->status = 1; $db->group = 1; $db->added = time(); $db->insert(); $email_body = "\n Click the link below to activate your account.<br />\n <a href='" . page("user", "confirm", "", "", "", "key=" . $password_secret) . "'>" . page("user", "confirm", "", "", "", "key=" . $password_secret) . "</a>\n "; sendEmail($email, "Account Confirmation", $email_body); echo notice(_t("an confirmation email has been sent to") . " " . $email, "Success!"); } catch (Exception $e) { echo error(_t($e->getMessage())); } } $pref = new Pref("system"); if (!$pref->registration) { throw new Exception("Registration is closed"); } if (SYSTEM_USERS >= $pref->max_users) { throw new Exception("We have reached the max amount of users. Try again later"); } $tpl = new Template($this->path . "tpl/"); $tpl->build("register.php"); } catch (Exception $e) { echo error(_t($e->getMessage())); }
?> </a></td> <td width="150px" class="" align="center"><?php echo $user->name; ?> </td> <td width="120px" class="stats" align="right"><?php echo $posts; ?> Replies</td> <td width="180px"class=""><?php echo $last_post; ?> </td> </tr> <?php } ?> </tbody> </table> <?php echo $pager->pager_bottom; ?> <?php $tpl = new Template(PATH_APPLICATIONS . "forums/tpl/"); $tpl->build("bottom-info.php"); } catch (Exception $e) { echo Error(_t($e->getMessage())); }
{ $active_items = $active_order_items; } } //get all inactive orders if(Order::getAllInactive()) { $inactive_order_objects = Order::getAllInactive(); } $tmpl->active_order_objects = $active_order_objects; $tmpl->inactive_order_objects = $inactive_order_objects; $tmpl->active_order_items = $active_order_items; $tmpl->active_items = $active_items; $page->run(); $html = $tmpl->build('orderlist.html'); $css = $tmpl->build('orderlist.css'); $js = $tmpl->build('orderlist.js'); $appContent = array( 'html' => $html, 'css' => array( 'code' => $css, 'link' => 'orderlist' ), 'js' => $js ); print $page->build($appContent); ?>
<?php set_include_path(".:../system:template:images:css"); require_once 'Template.php'; $pageName = "Home"; $tmpl1 = new Template(); $pageContent = $tmpl1->build('home.tmpl'); $tmpl2 = new Template(); $tmpl2->pageContent = $pageContent; $tmpl2->currentPage = $pageName; print $tmpl2->build('page.tmpl'); ?>
$page = new Page(0, "OrderUp - Past, Present, and Future Orders"); $tmpl = new Template(); $page->run(); $id = $_SESSION['userid']; $pending = Order::getForStatusesByUser($id, array(1)); $current = Order::getForStatusesByUser($id, array(2, 3, 4, 5, 7, 8, 9, 10)); $past = Order::getForStatusesByUser($id, array(6, 11)); $tmpl->pending = getOrderArray($pending); $tmpl->current = getOrderArray($current); $tmpl->past = $_SESSION['isAnon'] ? false : getOrderArray($past); $html = $tmpl->build('order.html'); $css = $tmpl->build('order.css'); $js = $tmpl->build('order.js'); $appContent = array( 'html' => $html, 'css' => array( 'code' => $css, 'link' => 'order' ), 'js' => $js ); print $page->build($appContent); function getOrderArray($orders) {
$tmpl->alert['message'] = "It appears that URL is broken.<br />Or the file got moved<br />Or something.<br />It appears the only course of action is to give up completely."; break; case 500: //Server Config or Script Crashed $tmpl->alert['type'] = "error"; $tmpl->alert['message'] = "Oh jeez. I'm so sorry. I don't even know what happened.<br />I swear this doesn't usually happen.<br />...<br />Um, the server is broken. Come back later."; break; case 200: default: //Server Config or Script Crashed $tmpl->alert['type'] = "okay"; $tmpl->alert['message'] = "Oh, you think you're SO sneaky. Move along, nothing to see here."; break; } $html = $tmpl->build('error.html'); $css = $tmpl->build('error.css'); $js = $tmpl->build('error.js'); $appContent = array( 'html' => $html, 'css' => array( 'code' => $css, 'link' => 'error' ), 'js' => array( 'code' => $js, 'link' => 'error' ) ); echo $page->build($appContent);
echo $spref->template; ?> /css/<?php echo $javascript; ?> " /> <?php } } ?> </head> <body class="full"> <?php if ($acl->Access("x")) { $toolbar = new Template(PATH_SITEADMIN . "templates/"); $toolbar->build("toolbar.php"); } ?> <div id="wrapper"> <div id="full_body_head"> <div id="full_body_head_left"> </div> <div id="full_body_head_right"> <?php echo $control->title; ?> </div> </div> <div id="full_content"> <div id="admin_menu_main"> <ul id="menu">
print "RECCOMMENDED? INGREDIENTS:<br/>"; foreach($ingredients as $ingredient) { print $ingredient['name']."<br/>"; print $ingredient['isVegetarian'] ? "Vegetarian" : ""; print $ingredient['isAllergenic'] ? "Allergy Warning" : ""; } */ } } //print total $table_data = $table_data."<td>Total: ".$total."</td></tr>"; } $tmpl->table_data = $table_data; $page->run(); $html = $tmpl->build('orderlist.html'); //$css = $tmpl->build('orderlist.css'); //$js = $tmpl->build('orderlist.js'); $appContent = array( 'html' => $html, 'css' => $css, 'js' => $js ); print $page->build($appContent); ?>
public function footer() { return \Template::build('footer.html'); }
if (!$acl->Access("z")) { throw new Exception("Access denied"); } $tpl = new Template(PATH_APPLICATIONS . "admin/tpl/translations/"); $action = isset($this->args["var_a"]) ? $this->args['var_a'] : ""; switch ($action) { default: $tpl->loadFile("main.php"); break; case 'edit': $tpl->lang_id = isset($this->args['var_b']) ? $this->args['var_b'] : 0; $tpl->loadFile("edit.php"); break; case 'import': $tpl->loadFile("import.php"); break; case 'export': $tpl->lang_id = isset($this->args['var_b']) ? $this->args['var_b'] : 0; $tpl->loadFile("export.php"); break; case 'delete': $tpl->loadFile("delete.php"); break; case 'create': $tpl->loadFile("create.php"); break; } $tpl->build(); } catch (Exception $e) { echo error(_t($e->getMessage())); }
try { if ($_POST['secure_input'] != $_SESSION['secure_token']) { throw new Exception("Wrong secured token"); } $email = $_POST['email']; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new Exception("Invalid email address"); } $db = new DB("users"); $db->select("user_email = '" . $db->escape($email) . "'"); if (!$db->numRows()) { throw new Exception("User not found"); } $db->nextRecord(); $username = $db->user_name; $secret = generatePassword(12); $password = generatePassword(); $password_hash = md5($secret . $password . $secret); $db = new DB("users"); $db->user_password_secret = $secret; $db->user_password = $password_hash; $db->update("user_email = '" . $db->escape($email) . "'"); $body = "Hey " . $username . "<br />Someone hopefully you have used the password recovery.<br />If you did not do this, please contact the staff as soon as possible.<br /><br /><b>New Password:</b> " . $password; sendEmail($email, "Password recovery", $body); } catch (Exception $e) { echo error(_t($e->getMessage())); } } else { $tpl = new Template($this->path . "tpl/"); $tpl->build("recover.php"); }