本文整理汇总了PHP中Template类的典型用法代码示例。如果您正苦于以下问题:PHP Template类的具体用法?PHP Template怎么用?PHP Template使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Template类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_linkpopup
function action_linkpopup($args)
{
global $config, $manager, $tree, $user, $lang;
$tpl = new Template($this->getTemplate('main.template'));
if ($config->get('multiLanguageSupport')) {
@(include _BASE_LIBRARIES_ . 'resources/iso639to3166.php');
$languages = array();
$list = new languages(_DEFAULT_SITE_);
while (list(, $language) = each($list->nodes)) {
if ($language->public) {
$languages[] = array('id' => $language->id, 'name' => $language->name, 'flag' => strtolower($iso639to3166[$language->id]));
}
}
$tpl->set('languages', $languages);
}
// Call the RetrieveObjects functions of each plugin
if (count($args)) {
$id = array_shift($args);
$result = array();
$files = array();
$data = array('id' => intval($id), 'result' => &$result);
$manager->handleEvent('RetrieveObjects', $data);
while (list(, $entries) = each($result)) {
$files = array_merge($files, $entries);
}
$tpl->set('files', $files);
}
echo $tpl->fetch();
exit;
}
示例2: disp
function disp()
{
$t = new Template(WEB_ADMIN_TMPPATH);
$dispObj = new DispAttachRule(&$this->dbObj, $this->getUid());
$t->set_file('f', 'pageconfig.html');
$t->set_block('f', 'row', 'r');
$p = $_GET['pageid'] + 0;
$sql = "\r\n\t\t\tSELECT c.configvalue AS userdefalut,o.* FROM " . WEB_ADMIN_TABPOX . "otherrule o \r\n\t\t\t\tLEFT OUTER JOIN " . WEB_ADMIN_TABPOX . "config c ON ( (o.otherruleid = c.otherruleid) AND (c.userid = " . $this->getUid() . ") ) \r\n\t\t\tWHERE (o.isrule = 0) AND (o.issystemvar = 0) AND (o.ruleid = {$p})\r\n\t\t";
$rs = $this->dbObj->GetArray($sql);
foreach ($rs as $v) {
$t->set_var($dispObj->disp($v, $v['userdefalut']));
$t->parse('r', 'row', true);
}
$r = '';
$m = new Menu(&$this->dbObj);
$s = $m->getRelating($p);
for ($i = 0; $i < count($s); $i++) {
if ($i == 0) {
$r = $s[$i]['rulename'];
} else {
$r .= ' > ' . $s[$i]['rulename'];
}
}
$t->set_var('updid', $p);
$t->set_var('address', $r);
$t->set_var('path', WEB_ADMIN_HTTPPATH . '/common/');
$t->parse('out', 'f');
$t->p('out');
}
示例3: 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();
}
示例4: event_ExecuteEditor
function event_ExecuteEditor(&$data)
{
global $lang, $manager, $user;
if (isset($manager->types[$data['type']]['content']['story']) && $data['sheet'] == 'contents') {
// Retrieve story
$res = sql::query("\n\t\t\t\t\tSELECT \n\t\t\t\t\t\t*\n\t\t\t\t\tFROM \n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_story \n\t\t\t\t\tWHERE \n\t\t\t\t\t\t`ID` = '" . $data['params']['id'] . "' AND\n\t\t\t\t\t\t`revision` = '" . $data['params']['revision'] . "'\n\t\t\t\t");
if ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$story = $row;
} else {
$story = array('text' => '');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$_POST['text'] = filter::images($_POST['text']);
$_POST['text'] = filter::html($_POST['text']);
$res = sql::query("\n\t\t\t\t\t\tREPLACE INTO \n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_story \n\t\t\t\t\t\tSET \n\t\t\t\t\t\t\tID='" . $data['params']['id'] . "', \n\t\t\t\t\t\t\trevision='" . $data['params']['revision'] . "',\n\t\t\t\t\t\t\ttext='" . addslashes($_POST['text']) . "'\n\t\t\t\t\t");
// Mark this action as a modification
revisions::updateModificationDate($data['params']['id'], $data['params']['revision']);
header("Location: " . url::item($data['params']['id'], 'edit') . "/contents?revision=" . $data['params']['revision']);
exit;
}
$tpl = new Template($this->getTemplate('editor.template'));
$tpl->set('story', $story);
$tpl->set('id', $data['params']['id']);
$tpl->set('revision', $data['params']['revision']);
$data['template']->append('content', $tpl->fetch());
}
}
示例5: applyCommonVariables
/**
* Apply common variables to the header template
* Common variables include:
* * pageStylesheets
* * pageJavascripts
* * urlbase
*
* @access protected
* @return void
* @param Template $tpl
* @param boolean $options
*/
protected function applyCommonVariables($tpl, $options = false)
{
$config = $this->sl->get('aetherConfig');
if (!$options) {
$options = $config->getOptions();
}
$tpl->set('urlbase', $config->getBase());
// Stylesheets. Read from config and code
$styles = array();
if (array_key_exists('styles', $options)) {
$styles = explode(';', $options['styles']);
}
foreach ($this->sl->getVector('styles') as $style) {
$styles[] = $style;
}
$styles = array_map('trim', $styles);
$styles = array_unique($styles);
$tpl->set('pageStylesheets', $styles);
// Scripts
$scripts = array();
if (array_key_exists('javascripts', $options)) {
$scripts = explode(';', $options['javascripts']);
}
foreach ($this->sl->getVector('javascripts') as $script) {
$scripts[] = $script;
}
$scripts = array_map('trim', $scripts);
$scripts = array_unique($scripts);
$tpl->set('pageJavascripts', $scripts);
}
示例6: service_genButton_paypal
/**
* Create the payment buttons for an external item.
* Creates the requested buy_now button type and, if requested,
* an add_cart button.
*
* All gateways that have the 'external' service enabled as well as the
* requested button type will provide a button.
*
* $args['btn_type'] can be empty or not set, to create only an Add to Cart
* button. $args['add_cart'] must still be set in this case. If neither
* button type is requested, an empty array is returned.
*
* Provided $args should include at least:
* 'item_number', 'item_name', 'price', 'quantity', and 'item_type'
* $args['btn_type'] should reflect the type of immediate-purchase button
* desired. $args['add_cart'] simply needs to be set to get an add-to-cart
* button.
*
* @uses PaymentGw::ExternalButton()
* @param array $args Array of item information
* @param array &$output Pointer to output array
* @param array &$svc_msg Unused
* @return integer Status code
*/
function service_genButton_paypal($args, &$output, &$svc_msg)
{
global $_CONF, $_PP_CONF;
$btn_type = isset($args['btn_type']) ? $args['btn_type'] : '';
$output = array();
// Create the immediate purchase button, if requested. As soon as a
// gateway supplies the requested button type, break from the loop.
if (!empty($btn_type)) {
PAYPAL_loadGateways();
// load all gateways
if (!empty($_PP_CONF['gateways'])) {
// Should be at least one
// Get the first gateway that supports the button type
foreach ($_PP_CONF['gateways'] as $gw_info) {
if (PaymentGw::Supports($btn_type, $gw_info) && PaymentGw::Supports('external', $gw_info) && class_exists($gw_info['id'])) {
$gw = new $gw_info['id']();
$output[] = $gw->ExternalButton($args, $btn_type);
}
}
}
}
// Now create an add-to-cart button, if requested.
if (isset($args['add_cart']) && $_PP_CONF['ena_cart'] == 1) {
if (!isset($args['item_type'])) {
$args['item_type'] = PP_PROD_VIRTUAL;
}
$T = new Template(PAYPAL_PI_PATH . '/templates');
$T->set_file('cart', 'buttons/btn_add_cart.thtml');
$T->set_var(array('item_name' => $args['item_name'], 'item_number' => $args['item_number'], 'short_description' => $args['short_description'], 'amount' => $args['amount'], 'pi_url' => PAYPAL_URL, 'item_type' => $args['item_type'], 'have_tax' => isset($args['tax']) ? 'true' : '', 'tax' => isset($args['tax']) ? $args['tax'] : 0, 'quantity' => isset($args['quantity']) ? $args['quantity'] : '', '_ret_url' => isset($args['_ret_url']) ? $args['_ret_url'] : ''));
$output['add_cart'] = $T->parse('', 'cart');
}
return PLG_RET_OK;
}
示例7: generatePage
public static function generatePage(&$tpl, &$session, &$account, &$mj)
{
$dbMgr = DbManager::getInstance();
//Instancier le gestionnaire
$db = $dbMgr->getConn('game');
//Demander la connexion existante
$maxMsg = 50;
$nbrMsg = isset($_GET['hepage']) ? $maxMsg * ($_GET['hepage'] - 1) : 0;
//Charger le perso
$query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE id=:id' . ' LIMIT 1;';
$prep = $db->prepare($query);
$prep->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
$prep->executePlus($db, __FILE__, __LINE__);
$arr = $prep->fetch();
$prep->closeCursor();
$prep = NULL;
$perso = new Member_Perso($arr);
//Lister les messages du HE
$heMsg = self::listMessages($nbrMsg, $maxMsg, $_GET['id']);
$code = '';
while ($msg = array_shift($heMsg)) {
$tpl2 = new Template($account);
$tpl2->set('MSG', $msg);
$tpl2->set('SKIN_VIRTUAL_PATH', SITE_VIRTUAL_PATH);
$code .= $tpl2->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Perso/He_item.htm');
unset($tpl2);
}
$tpl->set('HE_MESSAGES', $code);
//Trouver les sur la taille du HE
$heSize = self::calculateHeSize((int) $_GET['id']);
$tpl->set('HE_SIZE', $heSize);
$tpl->set('HE_MSGPERPAGE', $maxMsg);
$tpl->set('HE_PAGE', isset($_GET['hepage']) ? (int) $_GET['hepage'] : 1);
return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Perso/He.htm');
}
示例8: disp
function disp()
{
//定义模板
$t = new Template('../template/basic');
$t->set_file('f', 'upmorefile.html');
$t->unknowns = "remove";
$t->left_delimiter = "[#";
//修改左边界符为[#
$t->right_delimiter = "#]";
//修改右边界符#]
$t->set_block('f', 'mainlist', 'ml');
//设置分类
$t->set_var('ml');
$inrs =& $this->dbObj->Execute('select * from ' . WEB_ADMIN_TABPOX . 'apparatus where agencyid =' . $_SESSION["currentorgan"]);
//echo 'select * from '.WEB_ADMIN_TABPOX.'roomgroup where agencyid ='.$_SESSION["currentorgan"];
while ($inrrs =& $inrs->FetchRow()) {
$t->set_var($inrrs);
$t->parse('ml', 'mainlist', true);
}
$inrs->Close();
$t->set_var('add', $this->getAddStr('img'));
$t->set_var('path', WEB_ADMIN_HTTPPATH . '/common/');
$t->parse('out', 'f');
$t->p('out');
}
示例9: displayError
public function displayError()
{
if (!ini_get('display_errors')) {
return;
}
$messages = explode("\n", $this->message);
$messages = array_map('trim', $messages);
$messages = array_filter($messages, 'strlen');
$messages = array_values($messages);
$param = array("code" => $this->code, "messages" => $messages, "file" => $this->file, "line" => $this->line, "trace" => debug_backtrace());
$template = new Template();
// set template
$template->assign_vars($param);
// load template
if (!self::$template_filename) {
self::$template_filename = dirname(__FILE__) . '/../../component/view/Exception.tpl';
}
if ($template->load(self::$template_filename)) {
$html = $template->get_display_template(true);
} else {
throw new PMPException('Sysmtem Error ' . __CLASS__ . ' ' . __LINE__);
}
print $html;
exit;
}
示例10: html
public function html()
{
$content = null;
if (!$this->totalItems) {
return $content;
}
$numberOfPages = ceil($this->totalItems / $this->itemsPerPage);
if ($numberOfPages == 1) {
return $content;
}
$onFirstPage = $this->currentPage == 1;
$onLastPage = $this->currentPage == $numberOfPages;
$pageLinks = array();
if (!$onFirstPage) {
$pageLinks[] = array('id' => $this->currentPage - 1, 'title' => _('Previous'));
}
for ($i = 1; $i <= $numberOfPages; ++$i) {
$isCurrentPage = (int) ($i == $this->currentPage);
$pageLinks[] = array('id' => $i, 'title' => $i, 'active' => $isCurrentPage);
}
if (!$onLastPage) {
$pageLinks[] = array('id' => $this->currentPage + 1, 'title' => _('Next'));
}
$template = new Template('parts/paging');
$template->assign('pageLinks', $pageLinks);
return $template->fetch();
}
示例11: loadTemplate
protected function loadTemplate()
{
$modal = new \Modal('edit-file-form');
$this->template = new \Template();
$this->template->setModuleTemplate('filecabinet', 'FC_Forms/folders.html');
$this->template->add('modal', $modal->get());
}
示例12: lateral_menu
function lateral_menu()
{
global $LANG, $CONFIG;
$tpl = new Template('admin/menus/panel.tpl');
$tpl->assign_vars(array('L_MENUS_MANAGEMENT' => $LANG['menus_management'], 'L_ADD_CONTENT_MENUS' => $LANG['menus_content_add'], 'L_ADD_LINKS_MENUS' => $LANG['menus_links_add'], 'L_ADD_FEED_MENUS' => $LANG['menus_feed_add'], 'L_MANAGE_THEME_COLUMNS' => $LANG['manage_theme_columns'], 'THEME_NAME' => get_utheme()));
$tpl->parse();
}
示例13: formAction
/**
* Handle form action
*/
protected function formAction()
{
switch ($this->s->action) {
case 'reload':
// element: submenu
$this->s->resetParams('form');
$module = $this->s->loadModule($this->s->controller);
$tpl = new Template('system');
$tpl->assign('subnav', $this->generateNav($module->getSection()));
$tpl->display('submenu.html');
return true;
break;
case 'submenu':
if ($this->s->element == '') {
Error::addWarning('Fehler: ID des Untermenüs ist nicht definiert!');
return false;
}
$section = str_replace('nav_', '', $this->s->element);
$this->s->resetParams();
$tpl = new Template('system');
$tpl->assign('subnav', $this->generateNav($section));
$tpl->display('submenu.html');
return true;
break;
case 'cleanlog':
if ($this->s->element == 'error') {
$file = fopen("logs/error.log", "w+");
fclose($file);
}
return true;
break;
}
}
示例14: jkbanners_display_banners
function jkbanners_display_banners($atts)
{
$a = shortcode_atts(array('id' => false, 'filter_menu_order' => false, 'template' => 'list'), $atts);
$output = array();
//
$banners = array();
$banners = Banner::getAll();
if ($a['filter_menu_order']) {
foreach ($banners as $bk => $banner) {
if ($banner->post->menu_order != $a['filter_menu_order']) {
unset($banners[$bk]);
}
}
}
//
$bannerTemplate = new Template();
//One random banner
if ($a['template'] == 'random-single') {
//get a random item
$banner = $banners[array_rand($banners)];
//show single banner
$bannerTemplateResponse = $bannerTemplate->get(__DIR__ . '/templates/single.php', array('banner' => $banner));
$output[] = $bannerTemplateResponse;
}
//List all banners
if ($a['template'] == 'list') {
$bannerTemplateResponse = $bannerTemplate->get(__DIR__ . '/templates/list.php', array('banners' => $banners));
$output[] = $bannerTemplateResponse;
}
//
$output = implode("\n", $output);
return $output;
}
示例15: smarty_function_render
/**
* Campsite render function plugin
*
* Type: function
* Name: render
* Purpose: template rendering
*
* @param array
* $p_params
* @param object
* $p_smarty The Smarty object
*
* @return
* rendered content
*/
function smarty_function_render($p_params, &$p_smarty)
{
if (empty($p_params['file'])) {
return null;
}
$smarty = clone $p_smarty;
if (SystemPref::Get('TemplateCacheHandler')) {
$campsiteVector = $smarty->campsiteVector;
foreach ($campsiteVector as $key => $value) {
if (isset($p_params[$key])) {
if (empty($p_params[$key])) {
$campsiteVector[$key] = null;
}
if (is_int($p_params[$key])) {
$campsiteVector[$key] = $p_params[$key];
}
}
}
if (isset($p_params['params'])) {
$campsiteVector['params'] = $p_params['params'];
}
$smarty->campsiteVector = $campsiteVector;
if (empty($p_params['cache'])) {
$template = new Template($p_params['file']);
$smarty->cache_lifetime = (int)$template->getCacheLifetime();
} else {
$smarty->cache_lifetime = (int)$p_params['cache'];
}
}
return $smarty->display($p_params['file']);
} // fn smarty_function_render