本文整理汇总了PHP中Template::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::getCode方法的具体用法?PHP Template::getCode怎么用?PHP Template::getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template::getCode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCode
/**
*
* @return string
*/
public function getCode()
{
if (isset($_POST['save'])) {
foreach ($_POST as $property => $value) {
if ($property != "save" && $property != "roles") {
$settings = Settings::getRootInstance()->specify($this->areaType, $this->area);
if ($this->dir != "" && $this->dir != "/") {
$settings = $settings->dir($this->dir);
}
$settings->set($property, $value, $this->role);
}
}
Settings::forceReload();
Cache::clear();
Language::GetGlobal()->ClearCache();
if (@header("Location:" . str_replace("&save_settings=1", "", $_SERVER['REQUEST_URI']))) {
exit;
} else {
die("<script>window.location.href = '" . str_replace("&save_settings=1", "", $_SERVER['REQUEST_URI']) . "';</script>");
}
$changed = true;
}
$template = new Template();
$template->load($this->template);
if ($this->area != "global" || $this->areaType != "global") {
$roleselector = "<select name=\"roles\" onchange=\"document.location.href='" . $this->url . $this->getQuerySeperator() . "areatype=" . urlencode($this->areaType) . "&area=" . urlencode($this->area) . "&role=' + this.options[this.selectedIndex].value + '&save_settings=1';\">";
} else {
$roleselector = "<select name=\"roles\" onchange=\"document.location.href='" . $this->url . $this->getQuerySeperator() . "role=' + this.options[this.selectedIndex].value + '&save_settings=1';\">";
}
$roles = DataBase::Current()->ReadRows("SELECT * FROM {'dbprefix'}roles ORDER BY name");
if ($roles) {
foreach ($roles as $role) {
if ($this->role == $role->id) {
$roleselector .= "<option value=\"" . $role->id . "\" selected=\"selected\">" . htmlentities($role->name) . "</option>";
} else {
$roleselector .= "<option value=\"" . $role->id . "\">" . $role->name . "</option>";
}
}
}
$roleselector .= "</select>";
$template->assign_var("ROLES", $roleselector);
if ($this->area != "global" || $this->areaType != "global") {
$template->assign_var("URL", $this->url . $this->getQuerySeperator() . "areatype=" . urlencode($this->areaType) . "&area=" . urlencode($this->area) . "&role=" . $this->role . "&save_settings=1");
} else {
$template->assign_var("URL", $this->url . $this->getQuerySeperator() . "role=" . $this->role . "&save_settings=1");
}
$rows = Settings::getRootInstance()->specify($this->areaType, $this->area)->dir($this->dir)->getRows($this->role);
if ($rows) {
foreach ($rows as $row) {
$index = $template->add_loop_item("SETTINGS");
$template->assign_loop_var("SETTINGS", $index, "PROPERTY", $row['name']);
$template->assign_loop_var("SETTINGS", $index, "DESCRIPTION", htmlentities($row['description']));
$control = new $row['type']();
$control->name = $row['name'];
$control->value = $row['value'];
$template->assign_loop_var("SETTINGS", $index, "CONTROL", $control->getCode());
}
}
return $template->getCode();
}
示例2: display
public function display()
{
$template = new Template();
$template->load("plugin_contactform_contactform");
$template->show_if('SHOWFORM', true);
$template->show_if('SHOWMESSAGE', false);
if (isset($_POST["contactformsubmit"]) && $_POST["url"] == "" && $_POST["inputspamcontrol"] == $_SESSION["plugin_contactform_result"]) {
$settings = Settings::getRootInstance()->specify("plugin", "contactform");
$plugin_contactform_receiver = $settings->get("contactform_mail");
$plugin_contactform_sendername = $_POST['inputname'];
$plugin_contactform_sendermail = $_POST['inputmail'];
$plugin_contactform_text = $_POST['inputtext'];
$plugin_contactform_subject = Language::DirectTranslate("plugin_contactform_pagetypetitle") . " " . Settings::getInstance()->get("title");
mail($plugin_contactform_receiver, $plugin_contactform_subject, $plugin_contactform_text, "From: {$plugin_contactform_sendername} <{$plugin_contactform_sendermail}>");
$_SESSION['plugin_contactform_result'] = "";
$template->show_if('SHOWFORM', false);
$template->show_if('SHOWMESSAGE', true);
$template->assign_var("SUCCESSMESSAGE", $settings->get("contactform_successmessage"));
}
$plugin_contactform_numberone = rand(1, 10);
$plugin_contactform_numbertwo = rand(1, 10);
$_SESSION['plugin_contactform_result'] = $plugin_contactform_numberone + $plugin_contactform_numbertwo;
$template->assign_var('FORMURL', UrlRewriting::GetUrlByAlias($this->page->alias));
$template->assign_var('NUMBER1', $plugin_contactform_numberone);
$template->assign_var('NUMBER2', $plugin_contactform_numbertwo);
Cache::clear();
echo $template->getCode();
}
示例3: load
public function load()
{
$this->headline = Language::DirectTranslate("plugin_menulistwidget_menus");
if (Cache::contains("menu", "widget_" . $_GET['dir'])) {
$this->content = Cache::getData("menu", "widget_" . $_GET['dir']);
} else {
if (!isset($_GET['dir']) || substr($_GET['dir'], 0, 1) == '.') {
$_GET['dir'] = "";
}
$template = new Template();
$template->load("plugin_menulistwidget_menulist");
$newmenuurl = UrlRewriting::GetUrlByAlias("admin/newmenu");
$template->assign_var("NEWMENUURL", $newmenuurl);
$menus = sys::getMenues($_GET['dir']);
foreach ($menus as $menu) {
$index = $template->add_loop_item("MENUS");
$template->assign_loop_var("MENUS", $index, "ID", $menu->id);
$template->assign_loop_var("MENUS", $index, "TITLE", $menu->name);
$template->assign_loop_var("MENUS", $index, "PAGES", $menu->count);
$editurl = UrlRewriting::GetUrlByAlias("admin/editmenu", "menu=" . $menu->id);
$template->assign_loop_var("MENUS", $index, "EDITURL", $editurl);
$deleteurl = UrlRewriting::GetUrlByAlias("admin/deletemenu", "menu=" . $menu->id);
$template->assign_loop_var("MENUS", $index, "DELETEURL", $deleteurl);
}
if (!$menus) {
$template->assign_var("NOMENUS", Language::DirectTranslate("plugin_menulistwidget_no_menus"));
} else {
$template->assign_var("NOMENUS", "");
}
$this->content = $template->getCode();
Cache::setData("menu", "widget_" . $_GET['dir'], $this->content);
}
}
示例4: getCode
/**
* Just loads the code which is received when all templates are put together
* without any replacement of objects or language strings.
*
* @return mixed false on failure, otherwise the code will be returned as string
*/
public function getCode()
{
//include all templates
preg_match_all("/\\{\\%(.*?)\\%\\}/mis", $this->template, $matches, PREG_PATTERN_ORDER);
for ($x = 0; $x < sizeof($matches[0]); $x++) {
$command = explode("->", $matches[1][$x]);
//just the command
$replace = $matches[0][$x];
//whole part which will be replaced
if (sizeof($command) != 2) {
return false;
}
switch ($command[0]) {
case "TEMPLATE":
$tmp = new Template($command[1]);
if ($tmp === false) {
return false;
}
$render = $tmp->getCode();
if ($render === false) {
return false;
}
$this->template = str_replace($replace, $render, $this->template);
break;
default:
return false;
break;
}
}
return $this->template;
}
示例5: display
public function display()
{
$template = new Template();
$template->load("plugin_changepassword_changepassword");
$template->show_if('PASSWORD_WRONG', false);
$template->show_if('SUCCESSFUL', false);
$template->show_if('OLD_PASSWORD_WRONG', false);
if (isset($_REQUEST['old_password']) && !empty($_REQUEST['old_password']) && is_string($_REQUEST['old_password']) && isset($_REQUEST['new_password']) && !empty($_REQUEST['new_password']) && is_string($_REQUEST['new_password']) && isset($_REQUEST['confirm_password']) && !empty($_REQUEST['confirm_password']) && is_string($_REQUEST['confirm_password'])) {
$old_password = DataBase::Current()->EscapeString($_REQUEST['old_password']);
$new_password = DataBase::Current()->EscapeString($_REQUEST['new_password']);
$confirm_password = DataBase::Current()->EscapeString($_REQUEST['confirm_password']);
if ($new_password != $confirm_password) {
$template->show_if('PASSWORD_WRONG', true);
} else {
$password = DataBase::Current()->EscapeString(md5($new_password . Settings::getInstance()->get("salt")));
$old_password = DataBase::Current()->EscapeString(md5($old_password . Settings::getInstance()->get("salt")));
$db_password = DataBase::Current()->ReadField("SELECT `password` FROM `{'dbprefix'}user` WHERE `id` = '" . User::Current()->id . "'; ");
if ($db_password && $db_password != null) {
if ($db_password != $old_password) {
$template->show_if('OLD_PASSWORD_WRONG', true);
} else {
DataBase::Current()->Execute("UPDATE `{'dbprefix'}user` SET `password` = '" . $password . "' WHERE `id` = '" . User::Current()->id . "'; ");
$template->show_if('SUCCESSFUL', true);
EventManager::raiseEvent("plugin_changepassword_change", array('old_password' => $old_password, 'new_password' => $password, 'userid' => User::Current()->id));
Cache::clear("tables", "userlist");
}
} else {
//Der User ist nicht in der Datenbank aufgeführt.
}
}
}
$template->assign_var('ACTION', UrlRewriting::GetUrlByAlias($this->page->alias));
echo $template->getCode();
}
示例6: getEditableCode
/**
*
* @return string
*/
public function getEditableCode()
{
$template = new Template();
$template->load("control_wysiwyg");
$template->assign_var("CONTENT", $this->page->getEditorContent($this));
$template->assign_var("HOST", Settings::getInstance()->get("host"));
$template->assign_var("ALIAS", $this->page->alias);
$template->assign_var("URL", UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $this->page->alias));
$template->assign_var("LANG", strtolower(Settings::getInstance()->get("language")));
$template->assign_var("PREVIEWURL", $this->page->GetUrl());
return $template->getCode();
}
示例7: load
public function load()
{
$dir = '';
if (isset($_GET['dir']) && substr($_GET['dir'], 0, 1) != '.') {
$dir = $_GET['dir'];
}
$this->headline = Language::DirectTranslate("plugin_pagelistwidget_pages");
if (Cache::contains("page", "widget_" . $dir)) {
$this->content = Cache::getData("page", "widget_" . $dir);
} else {
$template = new Template();
$template->load("plugin_pagelistwidget_pagelist");
$pages = Page::getPagesByDir($dir);
if (substr($dir, 0, 1) == "/") {
$shortdir = substr($dir, 1);
} else {
$shortdir = $dir;
}
if ($pages) {
foreach ($pages as $page) {
$shortalias = substr($page->alias, strlen($shortdir));
if (substr($shortalias, 0, 1) == "/") {
$shortalias = substr($shortalias, 1);
} else {
$shortalias = $shortalias;
}
if (!strpos($shortalias, "/")) {
$host = Settings::getInstance()->get("host");
$index = $template->add_loop_item("PAGES");
$template->assign_loop_var("PAGES", $index, "TITLE", $page->title);
$template->assign_loop_var("PAGES", $index, "ALIAS", $shortalias);
$editurl = UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $page->alias);
$template->assign_loop_var("PAGES", $index, "EDITURL", $editurl);
$deleteurl = UrlRewriting::GetUrlByAlias("admin/pagedelete", "site=" . $page->alias);
$template->assign_loop_var("PAGES", $index, "DELETEURL", $deleteurl);
$showurl = UrlRewriting::GetUrlByAlias($page->alias);
$template->assign_loop_var("PAGES", $index, "SHOWURL", $showurl);
}
}
$template->assign_var("NOPAGES", "");
} else {
$template->assign_var("NOPAGES", Language::DirectTranslate("plugin_pagelistwidget_no_pages"));
}
$this->content = $template->getCode();
if (isset($_GET['dir'])) {
Cache::setData("page", "widget_" . $_GET['dir'], $this->content);
}
}
}
示例8: testSaveCustomFile
public function testSaveCustomFile()
{
// create custom file first
$this->request->set('file', 'theme/sometheme/test.tpl');
$this->request->set('code', 'test code');
$response = $this->controller->save();
// edit the file
$this->request->set('file', 'theme/sometheme/test.tpl');
$this->request->set('code', 'test code');
$response = $this->controller->save();
$template = new Template('test.tpl', 'sometheme');
$this->assertEquals($template->getCode(), 'test code');
$this->assertEquals($template->getFileName(), 'theme/sometheme/test.tpl');
$template->restoreOriginal();
}
示例9: getCode
/**
*
* @return string
*/
public function getCode()
{
$template = new Template();
$template->load("widget_" . $this->displayType);
$template->assign_var("HEADLINE", $this->headline);
$template->assign_var("CONTENT", $this->content);
$template->assign_var("MINWIDTH", $this->minwidth);
$template->show_if("HASMINWIDTH", $this->minwidth != -1);
$template->assign_var("MAXWIDTH", $this->maxwidth);
$template->show_if("HASMAXWIDTH", $this->maxwidth != -1);
$template->assign_var("MINHEIGHT", $this->minheight);
$template->show_if("HASMINHEIGHT", $this->minheight != -1);
$template->assign_var("MAXHEIGHT", $this->maxheight);
$template->show_if("HASMAXHEIGHT", $this->maxheight != -1);
return $template->getCode();
}
示例10: getEditableCode
/**
*
* @return string
*/
public function getEditableCode()
{
$template = new Template();
$template->load("listpage");
if ($list = unserialize($this->page->getEditorContent($this))) {
$template->assign_var("SELECT", str_replace('\\\'', '\'', $list->fillSelect));
$template->assign_var("TEMPLATE", $list->template);
} else {
$template->assign_var("SELECT", "");
$template->assign_var("TEMPLATE", "");
}
$template->assign_var("HOST", Settings::getInstance()->get("host"));
$template->assign_var("ALIAS", $this->page->alias);
$url = UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $this->page->alias);
$template->assign_var("URL", $url);
$template->assign_var("LANG", Settings::getInstance()->get("language"));
return $template->getCode();
}
示例11: getCode
/**
*
* @return string
*/
public function getCode()
{
$template = new Template();
$template->load("control_skinselector");
$template->assign_var("NAME", $this->name);
$template->assign_var("SELECTORNAME", $this->type);
$template->assign_var("VALUE", $this->value);
$template->assign_var("HOST", Settings::getValue("host"));
$template->assign_var("CURRENTSKINNAME", SkinController::getSkinName($this->value));
$i = 0;
foreach (SkinController::getInstalledSkins() as $skin) {
$index = $template->add_loop_item("SKINS");
$template->assign_loop_var("SKINS", $index, "SELECTORNAME", $this->type);
$template->assign_loop_var("SKINS", $index, "INDEX", $i);
$template->assign_loop_var("SKINS", $index, "SKINID", $skin->id);
$template->assign_loop_var("SKINS", $index, "SKINNAME", $skin->name);
$i++;
}
return $template->getCode();
}
示例12: getCode
/**
*
* @return string
*/
public function getCode()
{
$outerTemplate = new Template();
$outerTemplate->load("list");
$outerTemplate->assign_var("NAME", $this->name);
$outerTemplate->assign_var("STYLE", $this->getListStyle());
if ($rows = DataBase::Current()->ReadRows($this->fillSelect)) {
foreach ($rows as $row) {
$index = $outerTemplate->add_loop_item("ITEMS");
$innerTemplate = new Template();
$innerTemplate->load($this->template);
$vars = get_object_vars($row);
foreach ($vars as $key => $value) {
$innerTemplate->assign_var(strtoupper($key), $value);
}
$outerTemplate->assign_loop_var("ITEMS", $index, "ITEM", $innerTemplate->getCode($this->escape));
}
}
$res = $outerTemplate->getCode();
return $res;
}
示例13: load
public function load()
{
$this->headline = Language::DirectTranslate("plugin_formlistwidget_forms");
if (isset($_POST['plugin_formlistwidget_deleteid'])) {
$form = new Form($_POST['plugin_formlistwidget_deleteid']);
$form->Delete();
}
$template = new Template();
$template->load("plugin_formlistwidget_formlist");
$forms = Form::getByDir($_GET['dir']);
if ($forms) {
foreach ($forms as $form) {
$index = $template->add_loop_item("FORMS");
$template->assign_loop_var("FORMS", $index, "NAME", $form->name);
$template->assign_loop_var("FORMS", $index, "EDITURL", UrlRewriting::GetUrlByAlias("admin/formedit", "form=" . $form->id));
$template->assign_loop_var("FORMS", $index, "ID", $form->id);
}
$template->assign_var("NOFORMS", "");
} else {
$template->assign_var("NOFORMS", Language::DirectTranslate("plugin_formlistwidget_no_forms"));
}
$this->content = $template->getCode();
}
示例14: getEditableCode
/**
*
* @param Actionlist $actions
* @return string
*/
public function getEditableCode(Actionlist $actions)
{
$template = new Template();
$template->load("menuentry_editable");
$template->assign_var("ID", $this->id);
$template->assign_var("TITLE", $this->title);
if ($this->type == 0) {
$template->assign_var("SELECTEDINTERNAL", " selected=\"1\"");
$selector = new PageSelector();
$selector->name = $this->id . '_href';
$selector->value = $this->href;
$template->assign_var("VALUECONTROL", $selector->getCode());
$template->assign_var("SELECTEDEXTERNAL", "");
$template->assign_var("SELECTEDSUBMENU", "");
} else {
if ($this->type == 1) {
$template->assign_var("SELECTEDEXTERNAL", " selected=\"1\"");
$template->assign_var("SELECTEDINTERNAL", "");
$template->assign_var("SELECTEDSUBMENU", "");
$template->assign_var("VALUECONTROL", "<input name=\"" . $this->id . "_href\" value=\"" . $this->href . "\" />");
} else {
if ($this->type == 2) {
$template->assign_var("SELECTEDSUBMENU", " selected=\"1\"");
$template->assign_var("SELECTEDINTERNAL", "");
$template->assign_var("SELECTEDEXTERNAL", "");
$selector = new MenueSelector();
$selector->name = $this->id . '_href';
$selector->value = $this->href;
$template->assign_var("VALUECONTROL", $selector->getCode());
}
}
}
$params = array();
$params['menu'] = $this->menu;
$params['ID'] = $this->id;
$template->assign_var("ACTIONS", $actions->getCode($params));
return $template->getCode();
}