本文整理汇总了PHP中tpl类的典型用法代码示例。如果您正苦于以下问题:PHP tpl类的具体用法?PHP tpl怎么用?PHP tpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tpl_function_include_clipcache
/**
* tpl {include_clipcache} function plugin
*
* Includes a template using private caching parameters. Must be registered as non-caching.
*
* @file function.include_clipcache.php
* @version 0.1.7 2006-May-11
* @since 2005-APR-08
*
* @author boots {jayboots ~ yahoo com}
* @copyright brainpower, boots, 2004-2006
* @license LGPL 2.1
* @link http://www.phpinsider.com/tpl-forum/viewtopic.php?p=19733#19733
*
* @param array $params
* @param tpl $tpl
*
* This function observes the following tag attributes (in $params):
*
* #param file required template file
* #param cache_id required specify cache build group
* #param cache_lifetime required time to live for template part/group
* #param ldelim optional specify the left delimiter to use for included content
* #param rdelim optional specify the right delimiter to use for included content
*/
function tpl_function_include_clipcache($params, &$tpl)
{
// validation
foreach (array('cache_id', 'file', 'cache_lifetime') as $required) {
if (!array_key_exists($required, $params)) {
$tpl->trigger_error("include_clipcache: '{$required}' param missing. Aborted.", E_USER_WARNING);
return;
}
}
// handle optional delimiters
foreach (array('rdelim' => $tpl->right_delimiter, 'ldelim' => $tpl->left_delimiter) as $optional => $default) {
${"_{$optional}"} = $default;
${$optional} = array_key_exists($optional, $params) ? $params[$optional] : $default;
}
$tpl->compile_check = false;
// save tpl environment as proposed by calling template
$_caching = $tpl->cache;
if (caching == 1) {
$tpl->cache = 2;
}
$_cache_lifetime = $tpl->cache_lifetime;
$tpl->cache_lifetime = $params['cache_lifetime'];
$tpl->left_delimiter = $ldelim;
$tpl->right_delimiter = $rdelim;
// run the requested clipcache template
$content = $tpl->fetch($params['file'], $params['cache_id']);
// restore tpl environment as proposed by calling template
$tpl->cache = $_caching;
$tpl->cache_lifetime = $_cache_lifetime;
$tpl->left_delimiter = $_ldelim;
$tpl->right_delimiter = $_rdelim;
return $content;
}
示例2: getItem
/**
* Возвращает шаблон,
* заполненный данными переданными в параметре
*
* @param tpl $tpl
* @param array $item
* @return tpl
*/
function getItem($tpl, $item)
{
$tplItem = $tpl->fetchBlock('BreadCrumbs');
$tplItem->assign($item);
$tpl->assign('BreadCrumbs', $tplItem);
$tplItem->reset();
return $tpl;
}
示例3: check_session
function check_session()
{
if (!isset($_SESSION['user_name'])) {
$tpl = new tpl();
$data = array('html_header' => $tpl->html_header, 'show_login' => $tpl->show_login);
echo $tpl->replace_vars($tpl->html_show_login, $data);
die;
}
}
示例4: showForm
/**
* Zeigt das Formular an, in dem User ihre Einträge machen können
*
* @param $text Vorbelegung für den text
* @param $mail Vorbelegung für die Emailadresse
* @param $page Vorbelegung für die Homepage
*/
function showForm($text = "", $mail = "", $page = "", $fehler = "")
{
global $allgAr;
$tpl = new tpl('gbook.htm');
$ar = array('uname' => $_SESSION['authname'], 'SMILIES' => getsmilies(), 'ANTISPAM' => get_antispam('gbook', 1), 'TXTL' => $allgAr['Gtxtl'], 'TEXT' => $text, 'PAGE' => $page, 'MAIL' => $mail, 'FEHLER' => $fehler);
$tpl->set_ar_out($ar, "formular_eintrag");
if (!isset($_SESSION['klicktime_gbook'])) {
$_SESSION['klicktime_gbook'] = 0;
}
}
示例5: update
function update($event_name, $data)
{
global $app, $conf;
// load the server configuration options
$app->uses("getconf");
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
if (substr($mail_config["homedir_path"], -1) == '/') {
$mail_config["homedir_path"] = substr($mail_config["homedir_path"], 0, -1);
}
if (isset($data["new"]["email"])) {
$email_parts = explode("@", $data["new"]["email"]);
} else {
$email_parts = explode("@", $data["old"]["email"]);
}
// Write the custom mailfilter script, if mailfilter recipe has changed
if ($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"] or $data["old"]["move_junk"] != $data["new"]["move_junk"] or $data["old"]["autoresponder_text"] != $data["new"]["autoresponder_text"] or $data["old"]["autoresponder"] != $data["new"]["autoresponder"] or isset($data["new"]["email"]) and $data["old"]["email"] != $data["new"]["email"] or $data["old"]["autoresponder_start_date"] != $data["new"]["autoresponder_start_date"] or $data["old"]["autoresponder_end_date"] != $data["new"]["autoresponder_end_date"] or $data["old"]["cc"] != $data["new"]["cc"]) {
$app->log("Mailfilter config has been changed", LOGLEVEL_DEBUG);
$sieve_file = $data["new"]["maildir"] . '/.sieve';
if (is_file($sieve_file)) {
unlink($sieve_file) or $app->log("Unable to delete file: {$sieve_file}", LOGLEVEL_WARN);
}
$app->load('tpl');
$tpl = new tpl();
$tpl->newTemplate("sieve_filter.master");
// cc Field
$tpl->setVar('cc', $data["new"]["cc"]);
// Custom filters
$tpl->setVar('custom_mailfilter', $data["new"]["custom_mailfilter"]);
// Move junk
$tpl->setVar('move_junk', $data["new"]["move_junk"]);
// Set autoresponder start date
$tpl->setVar('start_date', $data["new"]["autoresponder_start_date"]);
// Set autoresponder end date
$tpl->setVar('end_date', $data["new"]["autoresponder_end_date"]);
// Autoresponder
$tpl->setVar('autoresponder', $data["new"]["autoresponder"]);
$data["new"]["autoresponder_text"] = str_replace("\"", "'", $data["new"]["autoresponder_text"]);
$tpl->setVar('autoresponder_text', $data["new"]["autoresponder_text"]);
//* Set alias addresses for autoresponder
$sql = "SELECT * FROM mail_forwarding WHERE type = 'alias' AND destination = '" . $app->db->quote($data["new"]["email"]) . "'";
$records = $app->db->queryAllRecords($sql);
$addresses = '';
if (is_array($records) && count($records) > 0) {
$addresses .= ':addresses ["' . $data["new"]["email"] . '",';
foreach ($records as $rec) {
$addresses .= '"' . $rec['source'] . '",';
}
$addresses = substr($addresses, 0, -1);
$addresses .= ']';
}
$tpl->setVar('addresses', $addresses);
file_put_contents($sieve_file, $tpl->grab());
unset($tpl);
}
}
示例6: show_sitemap
function show_sitemap($q, $lv, $table, $menu, $where, $was)
{
$limit = 200;
$page = $menu->getA(2) == 'p' ? $menu->getE(2) : 1;
$MPL = db_make_sites($page, $where, $limit, '?sitemap-' . $menu->get(1), $table);
$anfang = ($page - 1) * $limit;
$q = db_query($q . " LIMIT " . $anfang . "," . $limit);
$tpl = new tpl('sitemap');
$l = '';
while ($r = db_fetch_row($q)) {
$l .= $tpl->list_get('links', array(str_replace('{id}', $r[0], $lv), $r[1]));
}
$tpl->set_ar_out(array('MPL' => $MPL, 'site' => $was, 'links' => $l), 1);
}
示例7: __construct
public function __construct($title, $hmenu, $was = 1, $file = null)
{
global $allgAr, $menu;
header('Content-Type: text/html;charset=UTF-8');
if (AJAXCALL) {
$this->ajax = true;
$this->json = array('title' => $title, 'hmenu' => $hmenu);
} else {
$this->ajax = false;
if (!is_null($file)) {
echo '<div style="display: block; background-color: #FFFFFF; border: 2px solid #ff0000;">!!Man konnte in einer PHP Datei eine spezielle Index angeben. Damit das Design fuer diese Datei anders aussieht. Diese Funktion wurde ersetzt. Weitere Informationen im Forum auf ilch.de ... Thema: <a href="http://www.ilch.de/forum-showposts-13758-p1.html#108812">http://www.ilch.de/forum-showposts-13758-p1.html#108812</a></div>';
}
$this->vars = array();
$this->file = $file;
// setzte das file standard 0 weil durch was definiert
$this->was = $was;
// 0 = smalindex, 1 = normal index , 2 = admin
$this->design = tpl::get_design();
$link = $this->htmlfile();
$this->headerAdds = '';
$this->bodyendAdds = '';
$tpl = new tpl($link, 2);
if ($tpl->list_exists('boxleft')) {
$tpl->set('boxleft', $this->get_boxes('l', $tpl));
}
if ($tpl->list_exists('boxright')) {
$tpl->set('boxright', $this->get_boxes('r', $tpl));
}
// ab 0.6 = ... menu listen moeglich
for ($i = 1; $i <= $allgAr['menu_anz']; $i++) {
if ($tpl->list_exists('menunr' . $i)) {
$tpl->set('menunr' . $i, $this->get_boxes($i, $tpl));
}
}
$ar = array('TITLE' => $this->escape_explode($title), 'HMENU' => '<span id="icHmenu">' . $this->escape_explode($hmenu) . '</span>', 'SITENAME' => $this->escape_explode($allgAr['title']), 'hmenuende' => '', 'vmenuende' => '', 'hmenubegi' => '', 'vmenubegi' => '', 'hmenupoint' => '', 'vmenupoint' => '', 'DESIGN' => $this->design);
$tpl->set_ar($ar);
$this->html = $tpl->get(0);
$this->html .= '{EXPLODE}';
$this->html .= $tpl->get(1);
unset($tpl);
$zsave0 = array();
preg_match_all("/\\{_boxes_([^\\{\\}]+)\\}/", $this->html, $zsave0);
$this->replace_boxes($zsave0[1]);
unset($zsave0);
$this->vars_replace();
unset($this->vars);
$this->html = explode('{EXPLODE}', $this->html);
}
}
示例8: test
function test($params, $content, &$smarty, &$repeat)
{
if (!$repeat) {
$v = tpl::get($smarty, 'ask');
return $params['ok'] . ":" . $content . $v;
}
}
示例9: show_online
/**
* Вывод списка online-пользователей
* @return null
*/
public function show_online()
{
$i = (int) config::o()->v('online_interval');
if (!$i) {
$i = 15;
}
$time = time() - $i;
$res = db::o()->p($time)->query('SELECT userdata FROM sessions
WHERE time > ? GROUP BY IF(uid>0,uid,ip)');
$res = db::o()->fetch2array($res);
tpl::o()->assign("res", $res);
$c = count($res);
$mo = stats::o()->read("max_online");
if (!intval($mo) || $mo < $c) {
$mo = $c;
stats::o()->write("max_online", $c);
stats::o()->write("max_online_time", time());
}
$mot = stats::o()->read("max_online_time");
tpl::o()->assign("record_total", $mo);
tpl::o()->assign("record_time", $mot);
/* @var $user user */
$user = plugins::o()->get_module("user");
lang::o()->get("profile");
tpl::o()->register_modifier("gau", array($user, "get_age"));
tpl::o()->assign("bdl", $this->bd_list());
tpl::o()->display("blocks/contents/online.tpl");
}
示例10: edit
/**
* Редактирование пользователя
* @param int $id ID пользователя
* @return null
*/
protected function edit($id)
{
$id = (int) $id;
lang::o()->get("registration");
lang::o()->get("usercp");
lang::o()->get('admin/groups');
/* @var $etc etc */
$etc = n("etc");
users::o()->set_tmpvars($etc->select_user($id));
if (users::o()->v('confirmed') != 3) {
tpl::o()->assign('unco', true);
}
tpl::o()->assign('inusercp', true);
/* @var $usercp usercp */
$usercp = plugins::o()->get_module('usercp');
/* @var $groups groups_man */
$groups = plugins::o()->get_module('groups', 1);
ob_start();
$group = users::o()->get_group(users::o()->v('old_group') ? users::o()->v('old_group') : users::o()->v('group'));
users::o()->alter_perms($group);
$groups->add($group, false, true);
$c = ob_get_contents();
ob_end_clean();
tpl::o()->assign('perms', $c);
$usercp->show_index();
users::o()->remove_tmpvars();
}
示例11: __construct
public function __construct()
{
$endpoint = $this;
if ($page = page('webmention') and kirby()->path() == $page->uri()) {
if (r::is('post')) {
try {
$endpoint->start();
header::status(202);
tpl::set('status', 'success');
tpl::set('alert', null);
} catch (Exception $e) {
header::status(400);
tpl::set('status', 'error');
tpl::set('alert', $e->getMessage());
}
} else {
tpl::set('status', 'idle');
}
} else {
kirby()->routes(array(array('pattern' => 'webmention', 'method' => 'GET|POST', 'action' => function () use($endpoint) {
try {
$endpoint->start();
echo response::success('Yay', 202);
} catch (Exception $e) {
echo response::error($e->getMessage());
}
})));
}
}
示例12: show
/**
* Функция отображения типов файлов
* @return null
*/
protected function show()
{
$r = db::o()->query('SELECT * FROM allowed_ft');
tpl::o()->assign('res', db::o()->fetch2array($r));
tpl::o()->register_modifier('aftbasic', array($this, 'is_basic'));
tpl::o()->display('admin/allowedft/index.tpl');
}
示例13: show
/**
* Функция отображения доп. полей
* @return null
*/
protected function show()
{
$r = db::o()->query('SELECT * FROM users_fields');
tpl::o()->assign('res', db::o()->fetch2array($r));
tpl::o()->register_modifier('cut_type_descr', array($this, 'cut_type_descr'));
tpl::o()->display('admin/userfields/index.tpl');
}
示例14: snippet
/**
* Embeds a snippet from the snippet folder
*
* @param string $file
* @param mixed $data array or object
* @param boolean $return
* @return string
*/
function snippet($file, $data = array(), $return = false)
{
if (is_object($data)) {
$data = array('item' => $data);
}
return tpl::load(c::get('root.snippets') . DS . $file . '.php', $data, $return);
}
示例15: render
/**
* Renders the snippet with the given data
*
* @param string $name
* @param array $data
* @param boolean $return
* @return string
*/
public function render($name, $data = [], $return = false)
{
if (is_object($data)) {
$data = ['item' => $data];
}
return tpl::load($this->kirby->registry->get('snippet', $name), $data, $return);
}