function main($itsp) { $itsp->bLang->setLanguage($_GET["lang"]); include_once "dwoo/dwooAutoload.php"; $params = array(); $params["lang"] = "dk"; $params["screen"] = "newUser"; $newUserUrl = $itsp->bUrl->newUrl("newuser", $params, 0, 0); $params = array(); $screenshoturl = $itsp->bUrl->newUrl("screenshots", $params, 0, 0); $params = array(); $loginUrl = $itsp->bUrl->newUrl("home", $params); $tpl = new Dwoo_Template_File('templates/frontpage.tpl'); $dwoo = new Dwoo(); $jsfiles = array(); $jsfiles[] = array('jsfile' => 'js/newuser.js'); $markerArray = templateArray(); $markerArray["headertitle"] = $itsp->bLang->getLL("title") . " frontpage"; $markerArray["username"] = $itsp->bLang->getLL("username"); $markerArray["password"] = $itsp->bLang->getLL("password"); $markerArray["title"] = "myTasks frontpage"; $markerArray["loginbtn"] = "Login"; $markerArray["createNewUser"] = $itsp->bLang->getLL("createNewUser"); $markerArray["url"] = $newUserUrl; $markerArray["loginUrl"] = $loginUrl; $markerArray["js_list"] = $jsfiles; $markerArray["screenshoturl"] = $screenshoturl; $output = $dwoo->get($tpl, $markerArray); print $output; }
/** * {@inheritdoc} */ public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true) { Profile::start('Renderer', 'Generate HTML'); $templateName = $viewName . '.' . static::$templateFileExtension; $dwoo = new Dwoo($this->compiledPath, $this->cachePath); $dwoo->getLoader()->addDirectory($this->functionsPath); Profile::start('Renderer', 'Create template file.'); $template = new Dwoo_Template_File($templateName); $template->setIncludePath($this->getTemplatesPath()); Profile::stop(); Profile::start('Renderer', 'Render'); $dwooData = new Dwoo_Data(); $dwooData->setData($model->getData()); $dwooData->assign('errorMessages', $notificationCenter->getErrors()); $dwooData->assign('successMessages', $notificationCenter->getSuccesses()); $this->setHeader('Content-type: text/html', $output); // I do never output directly from dwoo to have the possibility to show an error page if there was a render error. $result = $rendered = $dwoo->get($template, $dwooData, null, false); if ($output) { echo $result; } Profile::stop(); Profile::stop(); return $output ? null : $rendered; }
function main($itsp) { include_once "dwoo/dwooAutoload.php"; $displayNewUserForm = 1; $emailsent = ""; $reset = $itsp->bUrl->getGP("s"); $username = $itsp->bUrl->getGP("u"); $showform = 1; $errormsg = ""; if ($_POST["reset"]) { include_once "user_backend.php"; $user = new user_backend("reset"); if ($user->setNewPassword($_POST["reset"], $_POST["password"])) { $showform = 0; $tpl = new Dwoo_Template_File('templates/setnewpassword1.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $output = $dwoo->get($tpl, $markerArray); print $output; exit; } else { $errormsg = "Please enter a valid password"; } } if ($reset != "" && $username != "" && $showform) { $tpl = new Dwoo_Template_File('templates/setnewpassword.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["url"] = $_SERVER["REQUEST_URI"]; $markerArray["reset"] = $reset; $markerArray["errormsg"] = $errormsg; $output = $dwoo->get($tpl, $markerArray); print $output; } }
/** * Renders a view file. * This method is required by {@link IViewRenderer}. * @param CBaseController the controller or widget who is rendering the view file. * @param string the view file path * @param mixed the data to be passed to the view * @param boolean whether the rendering result should be returned * @return mixed the rendering result, or null if the rendering result is not needed. */ public function renderFile($context, $sourceFile, $data, $return) { // current controller properties will be accessible as {this.property} $data['this'] = $context; $data['Yii'] = Yii::app(); $data["TIME"] = sprintf('%0.5f', Yii::getLogger()->getExecutionTime()); $data["MEMORY"] = round(Yii::getLogger()->getMemoryUsage() / (1024 * 1024), 2) . " MB"; // check if view file exists if (!is_file($sourceFile) || ($file = realpath($sourceFile)) === false) { throw new CException(Yii::t('yiiext', 'View file "{file}" does not exist.', array('{file}' => $sourceFile))); } //render or return if ($return) { return $this->dwoo->get($sourceFile, $data); } else { $this->dwoo->get($sourceFile, $data, null, true); } }
function main($itsp) { include "dwoo/dwooAutoload.php"; $tpl = new Dwoo_Template_File('templates/screenshots.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["title"] = "screenshots"; $output = $dwoo->get($tpl, $markerArray); print $output; }
function GenerateModLogRSS() { global $tc_db; require_once KU_ROOTDIR . 'lib/dwoo.php'; $dwoo = new Dwoo(); $dwoo_data = new Dwoo_Data(); $entries = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "modlog` ORDER BY `timestamp` DESC LIMIT 15"); $dwoo_data->assign('entries', $entries); $rss = $dwoo->get(KU_TEMPLATEDIR . '/rss_mod.tpl', $dwoo_data); return $rss; }
function main($itsp) { include "dwoo/dwooAutoload.php"; $tpl = new Dwoo_Template_File('templates/error.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["title"] = $itsp->bLang->getLL("page.error.title"); $markerArray["pagenotfound"] = $itsp->bLang->getLL("page.error.pagenotfound"); $markerArray["goback"] = $itsp->bLang->getLL("page.error.goback"); $output = $dwoo->get($tpl, $markerArray); print $output; }
public function testRebuildClassPath() { $dwoo = new Dwoo(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); $loader = new Dwoo_Loader(TEST_DIRECTORY . '/temp/cache'); $dwoo->setLoader($loader); $loader->addDirectory(TEST_DIRECTORY . '/resources/plugins'); file_put_contents(TEST_DIRECTORY . '/resources/plugins/loaderTest2.php', '<?php function Dwoo_Plugin_loaderTest2(Dwoo $dwoo) { return "It works!"; }'); $tpl = new Dwoo_Template_String('{loaderTest2}'); $tpl->forceCompilation(); $this->assertEquals('It works!', $dwoo->get($tpl, array(), $this->compiler)); unlink(TEST_DIRECTORY . '/resources/plugins/loaderTest2.php'); }
/** * Evaluates the given string as if it was a template * * Although this plugin is kind of optimized and will * not recompile your string each time, it is still not * a good practice to use it. If you want to have templates * stored in a database or something you should probably use * the Dwoo_Template_String class or make another class that * extends it * <pre> * * var : the string to use as a template * * assign : if set, the output of the template will be saved in this variable instead of being output * </pre> * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the use of this software. * * @author Jordi Boggiano <*****@*****.**> * @copyright Copyright (c) 2008, Jordi Boggiano * @license http://dwoo.org/LICENSE Modified BSD License * @link http://dwoo.org/ * @version 1.0.0 * @date 2008-10-23 * @package Dwoo */ function Dwoo_Plugin_eval(Dwoo $dwoo, $var, $assign = null) { if ($var == '') { return; } $tpl = new Dwoo_Template_String($var); $out = $dwoo->get($tpl, $dwoo->readVar('_parent')); if ($assign !== null) { $dwoo->assignInScope($out, $assign); } else { return $out; } }
function go() { include_once "dwoo/dwooAutoload.php"; if ($_POST) { $tpl = new Dwoo_Template_File('templates/config.php.tpl'); $dwoo = new Dwoo(); $hostname = str_replace("http:", "", $_POST["hostname"]); $hostname = str_replace("/", "", $hostname); $markerArray = array(); $markerArray["dbusername"] = $_POST["mysqlusername"]; $markerArray["dbpassword"] = $_POST["mysqlpassword"]; $markerArray["dbhostname"] = $_POST["mysqlhostname"]; $markerArray["dbtable"] = $_POST["mysqldatabase"]; $markerArray["installpath"] = $_POST["installpath"]; $markerArray["basehref"] = "http://" . $hostname . "/" . $_POST["installpath"]; $markerArray["prefix"] = $_POST["mysqlprefix"]; $markerArray["prettyurls"] = $_POST["prettyurls"] ? 1 : 0; $markerArray["hostname"] = $hostname; $markerArray["newuseremail"] = $_POST["newuseremail"]; $markerArray["resetpasswordemail"] = $_POST["resetpassword"]; $output = "<?\n"; $output .= $dwoo->get($tpl, $markerArray); $output .= "?>"; $fp = fopen('config.php', 'w'); fwrite($fp, $output); fclose($fp); include_once "config.php"; include_once "database_backend.php"; $db = new database_backend(); $db->connect(); $handle = fopen("database.sql", "rb"); $databasesql = stream_get_contents($handle); fclose($handle); $databasesql = str_replace("itsp_", $_POST["mysqlprefix"], $databasesql); $sql_cmds = explode(";", $databasesql); for ($i = 0; $i < count($sql_cmds); $i++) { mysql_query($sql_cmds[$i]); } return 1; } $tpl = new Dwoo_Template_File('templates/wizard.tpl'); $dwoo = new Dwoo(); $markerArray = array(); $markerArray["hostname"] = "http://" . $_SERVER["HTTP_HOST"] . "/"; $markerArray["installpath"] = substr($_SERVER["REQUEST_URI"], 1); $markerArray["newuseremail"] = "newuser@" . $_SERVER["HTTP_HOST"]; $markerArray["resetpassword"] = "******" . $_SERVER["HTTP_HOST"]; $output = $dwoo->get($tpl, $markerArray); print $output; return 0; }
function main($itsp) { include "dwoo/dwooAutoload.php"; $displayNewUserForm = 1; $emailsent = ""; if ($_POST["username"]) { include_once "user_backend.php"; $bUser = new user_backend("newuser"); $sess = $bUser->resetPassword($_POST["username"]); if ($sess) { $tpl = new Dwoo_Template_File('templates/forgotpasswordemail.tpl'); $dwoo = new Dwoo(); $params = array(); $params["s"] = $sess["reset"]; $params["u"] = $sess["username"]; $setnewpasswordUrl = $itsp->bUrl->newUrl("setnewpassword", $params, 1); $markerArray = array(); $markerArray["emailForgotpasswordHello"] = $itsp->bLang->getLL("email.forgotpassword.hello"); $markerArray["username"] = $sess["username"]; $markerArray["emailForgotpasswordHostname"] = config::hostname; $markerArray["emailForgotpasswordMsg1"] = $itsp->bLang->getLL("email.forgotpassword.msg1"); $markerArray["emailForgotpasswordMsg2"] = $itsp->bLang->getLL("email.forgotpassword.msg2"); $markerArray["emailForgotpasswordMsg3"] = $itsp->bLang->getLL("email.forgotpassword.msg3"); $markerArray["emailForgotpasswordMsg4"] = $itsp->bLang->getLL("email.forgotpassword.msg4"); $markerArray["emailForgotpasswordMsg5"] = $itsp->bLang->getLL("email.forgotpassword.msg5"); $markerArray["emailForgotpasswordMsg6"] = $itsp->bLang->getLL("email.forgotpassword.msg6"); $markerArray["emailForgotpasswordURL"] = $setnewpasswordUrl; $markerArray["emailForgotpasswordSignature"] = $itsp->bLang->getLL("email.forgotpassword.signature"); $forgotemail = $dwoo->get($tpl, $markerArray); $emailto = $sess["email"]; $emailsubject = $itsp->bLang->getLL("email.forgotpassword.subject"); $emailheaders = "From: " . config::resetpasswordFromEmail . "\r\n"; mail($emailto, $emailsubject, $forgotemail, $emailheaders); $emailsent = "Email sent"; } } if ($displayNewUserForm) { $tpl = new Dwoo_Template_File('templates/forgotpassword.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["url"] = $_SERVER["REQUEST_URI"]; $markerArray["username"] = $itsp->bLang->getLL("username"); $markerArray["password"] = $itsp->bLang->getLL("password"); $markerArray["headertitle"] = $itsp->bLang->getLL("page.forgotpassword.title"); $markerArray["loginbtn"] = $itsp->bLang->getLL("login"); $markerArray["sendit"] = $itsp->bLang->getLL("sendit"); $markerArray["emailsent"] = $emailsent; $createnewuser = $dwoo->get($tpl, $markerArray); print $createnewuser; } }
/** * @param $eventData * @return void */ public function notify() { $iso = $this->_getLocale(); $message = $this->_emailNotification->{$iso}; if ($message == null) { return; } $dwoo = new Dwoo(); $template = new Dwoo_Template_String($message); $data = new Dwoo_Data(); $data = $this->_assign($data); $parsedMessage = $dwoo->get($template, $data); return $this->_send($parsedMessage); }
function main($itsp) { $itsp->bLang->setLanguage($_GET["lang"]); include "dwoo/dwooAutoload.php"; $tpl = new Dwoo_Template_File('templates/login.tpl'); $dwoo = new Dwoo(); $markerArray = array(); $markerArray["headertitle"] = $itsp->bLang->getLL("title"); $markerArray["username"] = $itsp->bLang->getLL("username"); $markerArray["password"] = $itsp->bLang->getLL("password"); $markerArray["loginbtn"] = "Login"; $settings = $dwoo->get($tpl, $markerArray); print $settings; }
function main($itsp) { include "dwoo/dwooAutoload.php"; if ($itsp->bUrl->getGP("s")) { user_backend::verifyUser($itsp->bUrl->getGP("s"), $itsp->bUrl->getGP("u"), 9); $tpl = new Dwoo_Template_File('templates/rejectuser.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["pageRejectedMsg1"] = $itsp->bLang->getLL("page.rejecteduser.msg1"); $output = $dwoo->get($tpl, $markerArray); print $output; } else { print "access denied"; } }
/** * Inserts another template into the current one * <pre> * * file : the resource name of the template * * cache_time : cache length in seconds * * cache_id : cache identifier for the included template * * compile_id : compilation identifier for the included template * * data : data to feed into the included template, it can be any array and will default to $_root (the current data) * * assign : if set, the output of the included template will be saved in this variable instead of being output * * rest : any additional parameter/value provided will be added to the data array * </pre> * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the use of this software. * * @author Jordi Boggiano <*****@*****.**> * @copyright Copyright (c) 2008, Jordi Boggiano * @license http://dwoo.org/LICENSE Modified BSD License * @link http://dwoo.org/ * @version 1.1.0 * @date 2009-07-18 * @package Dwoo */ function Dwoo_Plugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array()) { if ($file === '') { return; } if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) { // resource:identifier given, extract them $resource = $m[1]; $identifier = $m[2]; } else { // get the current template's resource $resource = $dwoo->getTemplate()->getResourceName(); $identifier = $file; } try { if (!is_numeric($cache_time)) { $cache_time = null; } $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); } catch (Dwoo_Security_Exception $e) { return $dwoo->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING); } catch (Dwoo_Exception $e) { return $dwoo->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING); } if ($include === null) { return $dwoo->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.', E_USER_WARNING); } elseif ($include === false) { return $dwoo->triggerError('Include : Resource "' . $resource . '" does not support includes.', E_USER_WARNING); } if ($dwoo->isArray($data)) { $vars = $data; } elseif ($dwoo->isArray($cache_time)) { $vars = $cache_time; } else { $vars = $dwoo->readVar($data); } if (count($rest)) { $vars = $rest + $vars; } $out = $dwoo->get($include, $vars); if ($assign !== null) { $dwoo->assignInScope($out, $assign); } else { return $out; } }
function main($itsp) { $itsp->bLang->setLanguage($_GET["lang"]); include_once "dwoo/dwooAutoload.php"; $valid = isValidUser(); if ($valid) { $tpl = new Dwoo_Template_File('templates/home.tpl'); $dwoo = new Dwoo(); $markerArray = loggedInArray(); $output = $dwoo->get($tpl, $markerArray); print $output; } else { $tpl = new Dwoo_Template_File('templates/frontpage.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["loginerror"] = "Failed to login"; $output = $dwoo->get($tpl, $markerArray); print $output; } }
public function testHtmlFormat() { $tpl = new Dwoo_Template_String("<html><body><div><p>a<em>b</em>c<hr /></p><textarea>a\n b</textarea></div></body><html>"); $tpl->forceCompilation(); $dwoo = new Dwoo(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); $dwoo->addFilter('html_format', true); $this->assertEquals(str_replace("\r", '', <<<SNIPPET <html> <body> \t<div> \t\t<p> \t\t\ta<em>b</em>c \t\t\t<hr /> \t\t</p><textarea>a b</textarea> \t</div> </body> <html> SNIPPET ), $dwoo->get($tpl, array(), $this->compiler)); }
function main($itsp) { include "dwoo/dwooAutoload.php"; if ($itsp->bUrl->getGP("s")) { user_backend::verifyUser($itsp->bUrl->getGP("s"), $itsp->bUrl->getGP("u"), 1); } $valid = isValidUser(); if ($valid) { $tpl = new Dwoo_Template_File('templates/verifieduser.tpl'); $dwoo = new Dwoo(); $params = array(); $homeurl = "/" . config::installpath . "" . $itsp->bUrl->newUrl("tasks", $params); $markerArray = loggedInArray(); $markerArray["pageVerifiedUserAccepted"] = $itsp->bLang->getLL("page.verifieduser.useraccepted"); $markerArray["pageVerifiedUserHomeUrl"] = $itsp->bLang->getLL("page.verifieduser.homeurl"); $markerArray["homeUrl"] = $homeurl; $output = $dwoo->get($tpl, $markerArray); print $output; } else { print "access denied"; } }
/** * Processes a view script and outputs it. Output is then * passed through filters. * * @param string $name The script script name to process. * @return string The script output. */ public function _run() { $template = new Dwoo_Template_File(func_get_arg(0)); echo $this->_engine->get($template, $this->getDataProvider(), $this->getCompiler()); }
public function testCustomClassPluginInstanceAsModifier() { $dwoo = new Dwoo(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); $dwoo->addPlugin('CustomClassPlugin', array(new custom_class_plugin_obj(), 'call')); $tpl = new Dwoo_Template_String('{$foo=4}{$foo|CustomClassPlugin:5}'); $tpl->forceCompilation(); $this->assertEquals('20', $dwoo->get($tpl, array(), $this->compiler)); }
/** * Method that parsed invoice template and returns string * * All variable that parsed into invoice.pthml template * $reservation: * $reservation.id * $reservation.user_id * $reservation.confirmed (Yes, No - translated) * $reservation.is_read (Yes, No - translated) * $reservation.creation_datetime (In MySQL format: Y-m-d H:m:s) * $reservation.modified_datetime (In MySQL format: Y-m-d H:m:s) * $reservation.notes * $reservation.tax * $reservation.paid * $reservation.due * * $customer: * $customer.id * $customer.title (Translated) * $customer.first_name * $customer.last_name * $customer.address1 * $customer.address2 * $customer.state * $customer.city * $customer.postcode * $customer.country * $customer.telephone * $customer.mobile * $customer.email * $customer.username * * $details each detail is an $element: * $element.reservation_id * $element.unit_id * $element.start_datetime (In MySQL format: Y-m-d H:m:s) * $element.end_datetime (In MySQL format: Y-m-d H:m:s) * $element.total_price * $element.unit.id * $element.unit.rating (number) * $element.unit.published (Yes, No - translated) * $element.unit.color (hex color) * $element.unit.(all language db field names that are belong to unit type, for example: name, summary, description) * * $text: all text constants in section 'Admin.Invoice' in languages file, for example $text.BookingReference * * @param RM_Reservation_Row $reservation * @return <type> */ public static function getInvoice(RM_Reservation_Row $reservation) { $translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN); $data = new Dwoo_Data(); $data->assign('invoice', array('date' => date('d/m/Y'))); $config = new RM_Config(); $data->assign('currencysymbol', $config->getCurrencySymbol()); //TODO: resmania - we need to add discounts and coupons here $reservationArray = $reservation->toArray(); $billing = new RM_Billing(); $priceCharges = $billing->getPrice($reservation->id); $reservationArray['tax'] = $priceCharges->tax; $reservationArray['paid'] = $billing->getPaymentsTotal($reservation); $reservationArray['due'] = abs($priceCharges->total - $billing->getPaymentsTotal($reservation)); $reservationArray['total'] = $priceCharges->total; $reservationArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo'); $reservationArray['is_read'] = $reservation->is_read ? $translate->_('MessageYes') : $translate->_('MessageNo'); $data->assign('reservation', $reservationArray); $text = $translate->getSectionMessages('Common.Invoice'); $data->assign('text', $text); $userModel = new RM_Users(); $user = $userModel->getByReservation($reservation); if ($user == null) { $userArray = array(); } else { $userArray = $user->toArray(); $userArray['title'] = $user->getTitle(); } $data->assign('customer', $userArray); $reservationDetailsModel = new RM_ReservationDetails(); $summaryModel = new RM_ReservationSummary(); $details = $reservationDetailsModel->getAllByReservation($reservation); $arrayDetails = array(); foreach ($details as $detail) { $arrayDetail = $detail->toArray(); $unit = $detail->findUnit(); $unitArray = $unit->toArray(); $unitArray['id'] = $unit->getId(); $unitArray['published'] = $unitArray->published ? $translate->_('MessageYes') : $translate->_('MessageNo'); // format the start/end dates $arrayDetail['start_datetime'] = $config->convertDates($arrayDetail['start_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT); $arrayDetail['end_datetime'] = $config->convertDates($arrayDetail['end_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT); // extras $reservationDetailsExtra = $summaryModel->fetchByReservationDetail($detail)->toArray(); foreach ($reservationDetailsExtra as $extra) { if ($extra['value'] == 0) { $extra['value'] = ""; } $unitArray['extras'][] = array("name" => $extra['name'], "value" => $extra['value'], "total_amount" => $extra['total_amount']); } $arrayDetail['unit'] = $unitArray; $arrayDetails[] = $arrayDetail; } $data->assign('details', $arrayDetails); $templateFile = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'views', 'admin', 'scripts', 'templates', 'invoice.phtml')); $template = new Dwoo_Template_File($templateFile); $dwoo = new Dwoo(); return $dwoo->get($template, $data); }
public function testCallingMethodOnPropery() { $tpl = new Dwoo_Template_String('{getobj()->instance->Bar("hoy")}'); $tpl->forceCompilation(); $dwoo = new Dwoo(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); $dwoo->addPlugin('getobj', array(new PluginHelper(), 'call')); $this->assertEquals('HOY', $dwoo->get($tpl, array(), $this->compiler)); }
/** * this overrides and extends the original get() method Dwoo provides: * - use the template search and fallback paths * * @access public * @param see original Dwoo docs * @return see original Dwoo docs * **/ public function get($_tpl, $data = array(), $_compiler = null, $_output = false) { // add globals to $data array if (is_array(self::$_globals) && count(self::$_globals) && is_array($data)) { $this->logger->LogDebug('Adding globals to data:', self::$_globals); $data = array_merge(self::$_globals, $data); } if (!is_object($_tpl)) { if (!file_exists($_tpl) || is_dir($_tpl)) { global $parser; $file = $parser->findTemplate($_tpl); $this->logger->LogDebug(sprintf('Template file [%s]', $file)); if ($file) { return parent::get(realpath($file), $data, $_compiler, $_output); } else { $this->logger->LogCrit('No template file!'); } } else { return parent::get($_tpl, $data, $_compiler, $_output); } } else { return parent::get($_tpl, $data, $_compiler, $_output); } }
function main($itsp) { include_once "dwoo/dwooAutoload.php"; $valid = isValidUser(); if ($valid) { include_once "user_backend.php"; $userb = new user_backend(); if ($_POST) { $errormsg = ""; $errors = 0; $passwordok = 0; if ($_POST["username"]) { include_once "user_backend.php"; $userb = new user_backend(); if (!$userb->isUsernameAvail($_POST["username"])) { if ($errormsg != "") { $errormsg .= "<br />"; } $errormsg .= $itsp->bLang->getLL("page.myinfo.usernamenotavailable"); $errors++; } } if ($_POST["password"] != $_POST["repeatpassword"]) { if ($errormsg != "") { $errormsg .= "<br />"; } $errormsg .= $itsp->bLang->getLL("page.myinfo.notidenticalpasswords"); $errors++; } else { if ($_POST["password"] != "itsplanned") { $passwordok = 1; } } if (!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+$/', $_POST["email"])) { if ($errormsg != "") { $errormsg .= "<br />"; } $errormsg .= $itsp->bLang->getLL("page.myinfo.novalidemail"); $errors++; } if ($errors == 0) { $userb->setUserInfo("realname", $_POST["realname"]); $userb->setUserInfo("username", $_POST["username"]); $userb->setUserInfo("email", $_POST["email"]); if ($passwordok) { $userb->setUserInfo("password", md5($_POST["password"])); } $userb->setUserSetting("layoutlanguage", $_POST["language"]); $itsp->bLang->setLanguage($_POST["language"]); } } $tpl = new Dwoo_Template_File('templates/myinfo.tpl'); $dwoo = new Dwoo(); $language = $userb->getUserSetting("layoutlanguage"); $markerArray = loggedInArray(); $markerArray["pageMyinfoUsername"] = $itsp->bLang->getLL("page.myinfo.username"); $markerArray["pageMyinfoNewPassword"] = $itsp->bLang->getLL("page.myinfo.newpassword"); $markerArray["pageMyinfoNewPasswordRepeat"] = $itsp->bLang->getLL("page.myinfo.newpasswordrepeat"); $markerArray["pageMyinfoRealname"] = $itsp->bLang->getLL("page.myinfo.realname"); $markerArray["pageMyinfoEmail"] = $itsp->bLang->getLL("page.myinfo.email"); $markerArray["pageMyinfoUpdate"] = $itsp->bLang->getLL("page.myinfo.update"); $markerArray["pageMyinfoLayoutLanguage"] = $itsp->bLang->getLL("page.myinfo.layoutlanguage"); $markerArray["pageMyinfoErrorMsg"] = $errormsg; $markerArray["password"] = "******"; $markerArray["email"] = $userb->getUserInfo("email"); $markerArray["realname"] = $userb->getUserInfo("realname"); $markerArray["languageset" . $language] = " selected=selected "; $markerArray["headertitle"] = $itsp->bLang->getLL("page.myinfo.title"); $page = $dwoo->get($tpl, $markerArray); print $page; } else { print "access denied"; } }
function template($name = "", $varname1 = "", $varval1 = "", $varname2 = "", $varval2 = "", $varname3 = "", $varval3 = "") { if (!$name) { $name = $GLOBALS['def_template']; } $php_template = $name . ".php.html"; if (!file_exists($php_template)) { $php_template = "uses/" . $name . ".php.html"; } if (!file_exists($php_template)) { $php_template = "views/" . $name . ".php.html"; } if (file_exists($php_template)) { ob_start(); foreach ($GLOBALS as $key => $value) { ${$key} = $value; } require $php_template; $contents = ob_get_contents(); ob_end_clean(); return $contents; } $dwoo_template = "uses/" . $name . ".dwoo.html"; if (file_exists($dwoo_template)) { require_once "uses/dwoo/dwooAutoload.php"; $dwoo = new Dwoo(); $data = new Dwoo_Data(); foreach ($GLOBALS as $key => $value) { $data->assign($key, $value); } $html = $dwoo->get($dwoo_template, $data); return $html; } $fname = "uses/" . $name . ".tmpl.html"; if (!file_exists($fname)) { $fname = "uses/" . $name . ".html"; } if (file_exists($fname)) { $html = file_get_contents($fname); template_set($html, $varname1, $varval1, $varname2, $varval2, $varname3, $varval3); replace_files($html); replace_my_tags($html); replace_globals($html); return $html; } else { die("template: {$name} not found"); } }
/** * Replace all placeholders with information from current made reservations * * @param RM_Reservation_Manager $manager * @param string $template * @return */ private function _parseCompleteTemplate(RM_Reservation_Manager $manager, $template) { $data = new Dwoo_Data(); $reservationModel = new RM_Reservations(); $reservation = $reservationModel->find($manager->getReservationID())->current(); $summaryModel = new RM_ReservationSummary(); $unitModel = new RM_Units(); $details = $reservation->getDetails(); $arrayDetails = array(); foreach ($details as $detailRow) { $detail = $detailRow->transform(); $unitArray = $detail->getUnit()->toArray(); $periodArray = $detail->getPeriod()->toArray(); $periodArrayWithTime = $detail->getPeriod()->toArray(true); $personsArray = $detailRow->getPersons(); //$unitID = $detail->getUnit()->getId(); $unitID = $unitArray['id']; $unit = $unitModel->get($unitID); $locationModel = new RM_Locations(); $location = $locationModel->fetchByUnit($unitID)->current(); $arrayDetails[] = array('unit' => $unit->toArray(), 'period' => $periodArray, 'periodtime' => $periodArrayWithTime, 'persons' => $personsArray, 'summary' => $summaryModel->fetchByReservationDetail($detailRow)->toArray(), 'location' => $location !== null ? $location->toArray() : $locationModel->createRow()->toArray()); } $data->assign('details', $arrayDetails); $data->assign('user', $manager->getUser()->toArray()); $reservationArray = $reservation->toArray(); $reservationArray['confirmed'] = $reservation->isPaid() ? $this->_translate->_('MessageYes') : $this->_translate->_('MessageNo'); $reservationArray['total'] = $reservation->getTotalPrice(); $reservationArray['paid'] = $reservation->getTotalPaid(); $reservationArray['due'] = $reservationArray['total'] - $reservationArray['paid']; $data->assign('reservation', $reservationArray); $dwooTemplate = new Dwoo_Template_String($template); $dwoo = new Dwoo(); return $dwoo->get($dwooTemplate, $data); }
public function purerecipe($atts) { extract(shortcode_atts(array('id' => ''), $atts)); global $post; $shortname = 'cookingpress'; $recipedata = array(); if (empty($id)) { $id = get_the_id(); } $ingredients = get_post_meta($id, $shortname . 'ingridients', true); if (!empty($ingredients)) { if (!empty($ingredients[0]['name'])) { $gettitle = get_post_meta($id, $shortname . 'title', true); $title = empty($gettitle) ? get_the_title($id) : $gettitle; $recipedata['title'] = $title; $desc = get_post_meta($id, $shortname . 'summary', true); if (!empty($desc)) { $recipedata['desc'] = wpautop(do_shortcode($desc)); } $recipeoptions = get_post_meta($id, $shortname . 'recipeoptions', true); if (!empty($recipeoptions)) { $preptime = $recipeoptions[0]; if (!empty($preptime)) { $recipedata['preptime'] = $this->convert_minutes($preptime); $recipedata['preptimept'] = $this->convert_minutes_to_pt($preptime); } $cooktime = $recipeoptions[1]; if (!empty($cooktime)) { $recipedata['cooktime'] = $this->convert_minutes($cooktime); $recipedata['cooktimept'] = $this->convert_minutes_to_pt($cooktime); } $yield = $recipeoptions[2]; if (!empty($yield)) { $recipedata['yield'] = $yield; } } $nutrtion_facts = get_post_meta($id, $shortname . 'ntfacts', true); if (!empty($nutrtion_facts)) { $rennutrtion_facts = array(); $translatednutritions = $this->nutritions; foreach ($nutrtion_facts as $key => $value) { if (!empty($value)) { $formattedkey = ucfirst(str_replace('Content', '', $key)); if (is_numeric($key)) { $formattedkeyspace = preg_replace('/(?<!\\ )[A-Z]/', ' $0', $formattedkey); } else { $formattedkeyspace = $translatednutritions[$key]; } $rennutrtion_facts[] = array('nutr' => $key, 'formnutr' => $formattedkeyspace, 'fact' => $value); } } $recipedata['nutrtion_facts'] = $rennutrtion_facts; } $reviews = $this->get_average_post_rating(""); if (!empty($reviews)) { $recipedata['rating'] = $reviews['rating']; $recipedata['rating_nr'] = $reviews['reviews']; } //if(function_exists('the_ratings')) $ingredients_arr = array(); foreach ($ingredients as $ingredient) { //$tag = get_term_by('name',); $tagurl = get_term_link($ingredient['name'], 'ingredients'); if (is_wp_error($tagurl)) { $tagurl = ''; } $ingredients_arr[] = array('name' => $ingredient['name'], 'note' => $ingredient['note'], 'url' => $tagurl); } $recipedata['ingredients'] = $ingredients_arr; $instructions = get_post_meta($id, 'cookingpressinstructions', true); if (!empty($instructions)) { $recipedata['instructions'] = wpautop(do_shortcode($instructions)); } else { $recipedata['instructions'] = ''; } $author = get_the_author(); if (!empty($author)) { $recipedata['author'] = $author; $recipedata['authorurl'] = get_author_posts_url(get_the_author_meta('ID')); } $allergens = get_the_term_list($id, 'allergen', ' ', ', ', ' '); if (!empty($allergens)) { $recipedata['allergens'] = $allergens; } $level = get_the_term_list($id, 'level', ' ', ', ', ' '); if (!empty($level)) { $recipedata['level'] = $level; } $serving = get_the_term_list($id, 'serving', ' ', ', ', ' '); if (!empty($serving)) { $recipedata['serving'] = $serving; } $cpthumb = get_post_meta($id, $shortname . 'photo', true); if (!empty($cpthumb)) { $large_image_url = wp_get_attachment_image_src($cpthumb, 'large'); $photo = $large_image_url[0]; $thumb_url = wp_get_attachment_image_src($cpthumb, 'thumbnail'); $thumb = $thumb_url[0]; $recipedata['photo'] = $photo; $recipedata['thumb'] = $thumb; } elseif (has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'large'); $photo = $large_image_url[0]; $thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'thumbnail'); $thumb = $thumb_url[0]; $recipedata['photo'] = $photo; $recipedata['thumb'] = $thumb; } else { $recipedata['photo'] = ''; $recipedata['thumb'] = ''; } $recipedata['lang'] = array('by' => __('By', 'foodiepress'), 'preptime' => __('Prep Time', 'foodiepress'), 'cooktime' => __('Cook Time', 'foodiepress'), 'yield' => __('Yield', 'foodiepress'), 'serving' => __('Serving', 'foodiepress'), 'allergens' => __('Allergens', 'foodiepress'), 'ntfacts' => __('Nutrition facts <span>(per portion)</span>', 'foodiepress'), 'ingredients' => __('Ingredients', 'foodiepress'), 'instructions' => __('Instructions', 'foodiepress'), 'rating' => __('Rating', 'foodiepress'), 'stars' => __('stars - based on', 'foodiepress'), 'review' => __(' review(s)', 'foodiepress')); $recipedata['date'] = get_the_date(); $recipedata['dateformated'] = get_the_date('Y-m-d'); $recipedata['style'] = get_post_meta($id, $shortname . 'recipetheme', true); $recipestyle = $recipedata['style']; if (empty($recipestyle)) { $recipestyle = 'recipe1'; } $options = get_option('chow_option', array()); if (is_array($options) && !empty($options['print'])) { $recipedata['print'] = '<a href="#" class="print print-simple"><i class="fa fa-print"></i>' . __('Print', 'foodiepress') . '</a>'; } else { $recipedata['print'] = '<a href="http://www.printfriendly.com/print?url=' . esc_url(get_permalink()) . '" rel="nofollow" onclick="window.print(); return false;" class="print print-friendly"> <i class="fa fa-print"></i> ' . __('Print', 'foodiepress') . '</a>'; } $recipethemes = apply_filters('foodiepress_themes', array()); $origin = $recipethemes[$recipestyle]['origin']; if (empty($origin)) { $origin = 'core'; } //echo "<pre>";print_r($recipedata); echo "</pre>";die(); $dwoo = new Dwoo(); if ($origin == 'core') { $tpl = new Dwoo_Template_File(dirname(__FILE__) . '/templates/' . $recipestyle . '/index.tpl'); } else { $upload_dir = wp_upload_dir(); $tpl = new Dwoo_Template_File($upload_dir['basedir'] . '/foodiepress/' . $recipestyle . '/index.tpl'); } return $dwoo->get($tpl, $recipedata); } } }
public function testClearCacheOnTemplateClass() { $dwoo = new Dwoo(DWOO_COMPILE_DIR, DWOO_CACHE_DIR); $dwoo->setCacheTime(10); $tpl = new Dwoo_Template_String('foo{$foo}bar', null, 'cachetest2'); $tpl->forceCompilation(); $this->assertEquals("foo1bar", $dwoo->get($tpl, array('foo' => 1))); $this->assertEquals(true, $dwoo->isCached($tpl)); $this->assertEquals("foo1bar", $dwoo->get($tpl, array('foo' => 1))); $this->assertEquals(false, $tpl->clearCache($dwoo, 10)); $this->assertEquals(true, $tpl->clearCache($dwoo, -1)); $this->assertEquals(false, $dwoo->isCached($tpl)); }
/** * Processes a view script and outputs it. Output is then * passed through filters. * * @param string $name The script script name to process. * @return string The script output. */ public function _run() { echo $this->_engine->get($this->getTemplateFile(func_get_arg(0)), $this->getDataProvider(), $this->getCompiler()); }
function main($itsp) { $itsp->bLang->setLanguage($_GET["lang"]); include "dwoo/dwooAutoload.php"; $displayNewUserForm = 1; $errormsg = ""; if ($_POST["username"] && $_POST["password"]) { include_once "user_backend.php"; $bUser = new user_backend("newuser"); try { $errormsg = ""; $errors = 0; $passwordok = 0; if ($_POST["username"]) { include_once "user_backend.php"; if (!$bUser->isUsernameAvail($_POST["username"])) { if ($errormsg != "") { $errormsg .= "<br />"; } $errormsg .= $itsp->bLang->getLL("page.myinfo.usernamenotavailable"); $errors++; } } if ($_POST["password"] != $_POST["repeatpassword"]) { if ($errormsg != "") { $errormsg .= "<br />"; } $errormsg .= $itsp->bLang->getLL("page.myinfo.notidenticalpasswords"); $errors++; } else { if ($_POST["password"] != "itsplanned") { $passwordok = 1; } } if (!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+$/', $_POST["email"])) { if ($errormsg != "") { $errormsg .= "<br />"; } $errormsg .= $itsp->bLang->getLL("page.myinfo.novalidemail"); $errors++; } if ($errors == 0) { $bUser->createNew($_POST["username"], $_POST["password"]); isValidUser("create"); $bUser->setUserInfo("realname", $_POST["realname"]); $bUser->setUserInfo("email", $_POST["email"]); $bUser->setUserInfo("verified", '0'); $tpl = new Dwoo_Template_File('templates/newuseremail.tpl'); $dwoo = new Dwoo(); $params = array(); $params["s"] = session_id(); $params["u"] = $_POST["username"]; $verifyuserUrl = $itsp->bUrl->newUrl("verifyuser", $params, 1); $rejectuserUrl = $itsp->bUrl->newUrl("rejectuser", $params, 1); $markerArray = array(); $markerArray["emailNewuserHello"] = $itsp->bLang->getLL("email.newuser.hello"); $markerArray["username"] = $_POST["username"]; $markerArray["emailNewuserHostname"] = config::hostname; $markerArray["emailNewuserMsg1"] = $itsp->bLang->getLL("email.newuser.msg1"); $markerArray["emailNewuserMsg2"] = $itsp->bLang->getLL("email.newuser.msg2"); $markerArray["emailNewuserMsg3"] = $itsp->bLang->getLL("email.newuser.msg3"); $markerArray["emailNewuserMsg4"] = $itsp->bLang->getLL("email.newuser.msg4"); $markerArray["emailNewuserMsg5"] = $itsp->bLang->getLL("email.newuser.msg5"); $markerArray["emailNewuserMsg6"] = $itsp->bLang->getLL("email.newuser.msg6"); $markerArray["emailNewuserVerifyURL"] = $verifyuserUrl; $markerArray["emailNewuserRejectURL"] = $rejectuserUrl; $markerArray["emailNewuserSignature"] = $itsp->bLang->getLL("email.newuser.signature"); $newuseremail = $dwoo->get($tpl, $markerArray); $emailto = $_POST["email"]; $emailsubject = $itsp->bLang->getLL("email.newuser.subject"); $emailheaders = "From: " . config::newuserFromEmail . "\r\n"; mail($emailto, $emailsubject, $newuseremail, $emailheaders); $tpl = new Dwoo_Template_File('templates/userverification.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["pageUserverificationMsg1"] = $itsp->bLang->getLL("page.userverification.msg1"); $output = $dwoo->get($tpl, $markerArray); print $output; exit; } } catch (Exception $e) { if ($e->getMessage() == "UserExist") { $errormsg = "Username is already taken"; } } } if ($displayNewUserForm) { $tpl = new Dwoo_Template_File('templates/myinfonew.tpl'); $dwoo = new Dwoo(); $markerArray = templateArray(); $markerArray["url"] = $_SERVER["REQUEST_URI"]; $markerArray["pageMyinfoErrorMsg"] = $errormsg; $markerArray["username"] = $itsp->bLang->getLL("username"); $markerArray["password"] = $itsp->bLang->getLL("password"); $markerArray["pageMyinfoUsername"] = $itsp->bLang->getLL("page.myinfo.username"); $markerArray["pageMyinfoNewPassword"] = $itsp->bLang->getLL("page.myinfo.newpassword"); $markerArray["pageMyinfoNewPasswordRepeat"] = $itsp->bLang->getLL("page.myinfo.newpasswordrepeat"); $markerArray["pageMyinfoRealname"] = $itsp->bLang->getLL("page.myinfo.realname"); $markerArray["pageMyinfoEmail"] = $itsp->bLang->getLL("page.myinfo.email"); $markerArray["pageMyinfoUpdate"] = $itsp->bLang->getLL("page.myinfo.create"); $markerArray["pageMyinfoLayoutLanguage"] = $itsp->bLang->getLL("page.myinfo.layoutlanguage"); $markerArray["usernamefield"] = $_POST["username"]; $markerArray["email"] = $_POST["email"]; $markerArray["realname"] = $_POST["realname"]; $markerArray["headertitle"] = $itsp->bLang->getLL("page.myinfo.newusertitle"); $markerArray["loginbtn"] = $itsp->bLang->getLL("login"); $createnewuser = $dwoo->get($tpl, $markerArray); print $createnewuser; } }