本文整理汇总了PHP中Dwoo类的典型用法代码示例。如果您正苦于以下问题:PHP Dwoo类的具体用法?PHP Dwoo怎么用?PHP Dwoo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dwoo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Dwoo_Plugin_fetch
/**
* Reads a file
* <pre>
* * file : path or URI of the file to read (however reading from another website is not recommended for performance reasons)
* * assign : if set, the file 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 <j.boggiano@seld.be>
* @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_fetch(Dwoo $dwoo, $file, $assign = null)
{
if ($file === '') {
return;
}
if ($policy = $dwoo->getSecurityPolicy()) {
while (true) {
if (preg_match('{^([a-z]+?)://}i', $file)) {
return $dwoo->triggerError('The security policy prevents you to read files from external sources.', E_USER_WARNING);
}
$file = realpath($file);
$dirs = $policy->getAllowedDirectories();
foreach ($dirs as $dir => $dummy) {
if (strpos($file, $dir) === 0) {
break 2;
}
}
return $dwoo->triggerError('The security policy prevents you to read <em>' . $file . '</em>', E_USER_WARNING);
}
}
$file = str_replace(array("\t", "\n", "\r"), array('\\t', '\\n', '\\r'), $file);
$out = file_get_contents($file);
if ($assign === null) {
return $out;
}
$dwoo->assignInScope($out, $assign);
}
示例2: main
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;
}
示例3: Dwoo_Plugin_str
/**
* Dwoo {str} function plugin
*
* Type: function<br>
* Name: str<br>
* Date: June 22, 2006<br>
* Purpose: Fetch internationalized strings
* @author Catalyst IT Ltd
* @version 1.0
* @return Internationalized string
*/
function Dwoo_Plugin_str(Dwoo $dwoo, $tag, $section = 'mahara', $args = null, $arg1 = null, $arg2 = null, $arg3 = null, $assign = null)
{
static $dictionary;
$params = array($tag, $section);
if ($args) {
if (!is_array($args)) {
$args = array($args);
}
$params = array_merge($params, $args);
} else {
if (isset($arg1)) {
foreach (array('arg1', 'arg2', 'arg3') as $k) {
if (isset(${$k})) {
$params[] = ${$k};
}
}
}
}
$ret = call_user_func_array('get_string', $params);
// If there is an 'assign' parameter, place it into that instead.
if (!empty($assign)) {
$dwoo->assignInScope($ret, $assign);
return;
}
return $ret;
}
示例4: render
/**
* {@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;
}
示例5: main
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;
}
}
示例6: getData
public function getData()
{
$this->check_permission();
//get global_lib Singelton
$mainlib = global_lib::getInstance();
//Create path of Controller Files => controller/FILENAME.php
$path = $mainlib->joinPaths("controller/", $this->meta_data["main_file"] . ".php");
try {
//Include Controller File
include_once $path;
} catch (Exception $e) {
//Exception
var_dump($e);
}
try {
//Call Class from Controller File
$web_call = new $this->meta_data["main_class"]($this->request);
//Request Type (Method) to Lowercase
$method_call = strtolower($this->request->method);
//Rufe die methode im Class File auf
$web_call->{$method_call}();
// Generiere Variablen für die Template Engine
$template_engine_var = $web_call->get_context();
// Generiere für das Template den Pfad
$template_path = $mainlib->joinPaths("view/", $web_call->template . ".html");
// Lade Dwoo Template Engine
$dwoo = new Dwoo();
// Compare get_context and template
$dwoo->output($template_path, $template_engine_var);
} catch (Exception $e) {
var_dump($e);
}
}
示例7: Dwoo_Plugin_contextualhelp
/**
* Dwoo {contextualhelp} function plugin
*
* Type: function<br>
* Date: June 22, 2006<br>
* Purpose: Provide inline contextual help for arbitrary sections
* @author Catalyst IT Ltd
* @version 1.0
* @return HTML snippet for help icon
*/
function Dwoo_Plugin_contextualhelp(Dwoo $dwoo, $plugintype, $pluginname, $form = null, $element = null, $section = null, $assign = null)
{
$ret = call_user_func_array('get_help_icon', array($plugintype, $pluginname, $form, $element, null, $section));
// If there is an 'assign' parameter, place it into that instead.
if ($assign) {
$dwoo->assignInScope($ret, $assign);
return;
}
return $ret;
}
示例8: main
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;
}
示例9: GenerateModLogRSS
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;
}
示例10: testRebuildClassPath
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');
}
示例11: main
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;
}
示例12: Dwoo_Plugin_eval
/**
* 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 <j.boggiano@seld.be>
* @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;
}
}
示例13: go
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"] = "resetpassword@" . $_SERVER["HTTP_HOST"];
$output = $dwoo->get($tpl, $markerArray);
print $output;
return 0;
}
示例14: main
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;
}
}
示例15: main
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;
}