From f13e1f9e1f8d557f0893237bfbd01fb37fe84448 Mon Sep 17 00:00:00 2001 From: Imran Hussain <imranh@sucs.org> Date: Tue, 14 Apr 2015 15:58:23 +0000 Subject: [PATCH] Smarty 3 --- components/library.php | 7 +++---- components/members.php | 3 +-- components/mw.php | 2 +- htdocs/index.php | 11 ++++++----- lib/banana-admin.php | 12 ++++++------ 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/components/library.php b/components/library.php index 258596a..427e2f1 100644 --- a/components/library.php +++ b/components/library.php @@ -54,7 +54,7 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) { } else { $mode = "taglist"; $smarty->assign("tags", $DB->GetAll("SELECT name FROM bookcategories")); - } + } } elseif (isset($pathlist[$library_index + 1]) && is_numeric($pathlist[$library_index + 1])) { // We're displaying a specific book @@ -115,7 +115,7 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) { $msgbody .= " {$book['title']} by {$book['author']} from the library.\n\n"; $msgbody .= "Visit https://$preferred_hostname$path to process this request."; mail($librarian_mail, "Book Request", $msgbody); - + $smarty->assign("checkout_request", true); } @@ -123,7 +123,6 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) { $book['title'] = htmlentities2($book['title']); $book['author'] = htmlentities2($book['author']); $book['onloan'] = ($book['onloan'] == 't') ? true : false; - if (!isset($book['description'])) { // no book description in the database, try using Amazon data @@ -152,7 +151,7 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) { if ($session->loggedin) { $members = new Members; $smarty->assign("memberlist", $members->getMemberList()); - $secondary = $smarty->get_template_vars("secondary"); + $secondary = $smarty->getTemplateVars("secondary"); $secondary .= $smarty->fetch('library-loan.tpl'); $smarty->assign("secondary", $secondary); } diff --git a/components/members.php b/components/members.php index 5ec4c15..39529be 100644 --- a/components/members.php +++ b/components/members.php @@ -131,7 +131,7 @@ if ($session->loggedin) { } $smarty->assign("stats", $stats); - $secondary = $smarty->get_template_vars("secondary"); + $secondary = $smarty->getTemplateVars("secondary"); $secondary .= $smarty->fetch("banana-leaders.tpl"); $smarty->assign("secondary", $secondary); @@ -148,7 +148,6 @@ if ($session->loggedin) { $smarty->assign("public_members", $public_usernames); } - $smarty->assign('url', $component['path']); $smarty->assign('extra_styles', "/css/members.css"); $result = $smarty->fetch('members.tpl'); diff --git a/components/mw.php b/components/mw.php index cc6b754..0738614 100755 --- a/components/mw.php +++ b/components/mw.php @@ -128,7 +128,7 @@ if (!$session->loggedin) { } $folders = load_folders(); -$smarty->assign_by_ref("folders", $folders); +$smarty->assignByRef("folders", $folders); $smarty->assign("extra_styles", array("/css/forum/SUCS.css")); unset($mode); diff --git a/htdocs/index.php b/htdocs/index.php index 1754a4c..32ecc1e 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1,4 +1,5 @@ <?php +error_reporting(E_STRICT); // Display execution time? //$displaytime = TRUE; @@ -29,8 +30,8 @@ require("../lib/error.php"); // Include the Smarty templating engine define('SMARTY_DIR', '/usr/share/php/smarty3/'); -require("/usr/share/php/smarty3/SmartyBC.class.php"); -$smarty = new SmartyBC(); +require("/usr/share/php/smarty3/Smarty.class.php"); +$smarty = new Smarty(); $smarty->setTemplateDir($base."templates"); $smarty->setCompileDir($base."templates_c"); $smarty->addPluginsDir($base."plugins"); @@ -53,7 +54,7 @@ $sucsDB->SetFetchMode(ADODB_FETCH_ASSOC); // Include the session library require($base."lib/session.php"); $session = new Session; -$smarty->assign_by_ref("session", $session); +$smarty->assignByRef("session", $session); // include feedback form stuff @@ -115,7 +116,7 @@ if (isset($_SERVER['PATH_INFO'])) { // Determine which component to run $pathlist = explode('/', parse_url($pathinfo,PHP_URL_PATH)); while (end($pathlist) === "") array_pop($pathlist); -$smarty->assign_by_ref("pathlist", $pathlist); +$smarty->assignByRef("pathlist", $pathlist); $path = ''; $query = "select * from pagemap where path='/' "; $params = array(); @@ -130,7 +131,7 @@ foreach($pathlist as $item) { } // Determine the path of the request -$smarty->assign_by_ref("path", $path); +$smarty->assignByRef("path", $path); $query .= "order by depth desc"; $pagemap = $DB->GetAll($query, $params); diff --git a/lib/banana-admin.php b/lib/banana-admin.php index 1fec11d..9e8200d 100644 --- a/lib/banana-admin.php +++ b/lib/banana-admin.php @@ -26,8 +26,8 @@ if (isset($session->groups[$permission])) { if (trim ($_POST['why']) !== "") { $number = intval($_POST['number']); - $why = $_POST['why']; - + $why = $_POST['why']; + if ( abs($number) <= $maxbanana ){ $DB->Query("INSERT INTO awards (username, score, whn, who, why) VALUES (?,?,NOW(),?,?)", array($who, $number, $session->username, $why)); @@ -39,14 +39,14 @@ if (isset($session->groups[$permission])) { } else { trigger_error("No reason entered for the awarding of bananas.", E_USER_WARNING); - } + } } } elseif ($session->loggedin) { if ($_REQUEST['action'] == "award") { $number = intval($_POST['number']); - $why = $_POST['why']; + $why = $_POST['why']; - // Send a mail to someone about them bananas + // Send a mail to someone about them bananas $msgbody = $session->username." thinks $who deserves $number bananas:\r\n"; $msgbody .= "\"$why\"\r\n\r\nVisit https://sucs.org/Community/Members/$who if you want to make an award."; mail($contact, "Banana Award Nomination", $msgbody, $msgheaders); @@ -56,7 +56,7 @@ if (isset($session->groups[$permission])) { } -$secondary = $smarty->get_template_vars("secondary"); +$secondary = $smarty->getTemplateVars("secondary"); $secondary .= $smarty->fetch('banana-award.tpl'); $smarty->assign('secondary', $secondary); -- GitLab