本文整理汇总了PHP中TemplateEngine::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateEngine::fetch方法的具体用法?PHP TemplateEngine::fetch怎么用?PHP TemplateEngine::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateEngine
的用法示例。
在下文中一共展示了TemplateEngine::fetch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addComment
/**
* handle add
*/
public function addComment($values)
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
$values['active'] = 1;
try {
$id = $this->insert($values);
$calendar = $this->plugin->getObject(Calendar::TYPE_DEFAULT);
$calendarDetail = $calendar->getDetail(array('id' => $values['cal_id']));
$url = new Url();
$url->setPath($this->director->tree->getPath($calendarDetail['tree_id']));
$url->setParameter('id', $calendarDetail['id']);
$url->setParameter($view->getUrlId(), Calendar::VIEW_DETAIL);
// notify insert
$ip = $request->getValue('REMOTE_ADDR', Request::SERVER);
$template = new TemplateEngine($this->getPath() . "templates/calendarcommentemail.tpl");
$template->setVariable($values);
$template->setVariable('calendarName', $calendarDetail['name']);
$template->setVariable('href_detail', $url->getUrl());
$template->setVariable('siteTitle', $this->director->tree->getTreeName());
$template->setVariable('domain', $request->getDomain());
$template->setVariable('protocol', $request->getProtocol());
$template->setVariable('ip', $ip);
$template->setVariable('host', gethostbyaddr($ip));
$template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER));
$this->director->systemUser->notify($calendarDetail['tree_id'], 'Comment added at ' . $request->getDomain(), $template->fetch());
} catch (Exception $e) {
$template = new TemplateEngine();
$template->setVariable('commentError', $e->getMessage(), false);
$template->setVariable('cmtValues', $values, false);
}
}
示例2: fetch_unassigned
/**
* Calls the template engine's fetch() method without pre-assigning template variables.
* Assumes that the template variables have already been set.
*
* @param string $template_name The name of the template to display
* @return string The content of the template
*/
public function fetch_unassigned($template_name)
{
return $this->template_engine->fetch($template_name);
}
示例3: notify
private function notify($record)
{
$request = Request::getInstance();
$template = new TemplateEngine($this->getPath() . "templates/intrusionemail.tpl");
$template->setVariable($record);
$template->setVariable('domain', $request->getDomain());
$template->setVariable('host', gethostbyaddr($record['ip']));
$template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER));
$this->director->systemUser->notify(NULL, 'Intrusion detected at ' . $request->getDomain(), $template->fetch());
}
示例4: sendMail
/**
* send email
*/
private function sendMail($mailto, $mailfrom, $subject, $settings, $link)
{
$recepients = explode(",", $mailto);
$template_content = new TemplateEngine($settings['content'], false);
$template_content->setVariable($settings);
$template_content->setVariable('password_url', $link);
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateEmail);
$template->setVariable('tpl_content', $template_content);
$template->setVariable('settings', $settings);
$request = Request::getInstance();
$ip = $request->getValue('REMOTE_ADDR', Request::SERVER);
$template->setVariable('ip', $ip);
$template->setVariable('host', gethostbyaddr($ip));
$template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER));
$mail = new PHPMailer();
$mail->From = $mailfrom;
$mail->FromName = $mailfrom;
foreach ($recepients as $email) {
$mail->AddAddress(trim($email));
}
$mail->WordWrap = 80;
$mail->Subject = $subject;
$mail->Body = $template->fetch();
if (!$mail->Send()) {
throw new Exception("Error sending message: " . $mail->ErrorInfo);
}
if (!$this->log->isInfoEnabled()) {
return;
}
$this->log->info("login info sent to {$mailto}");
}
示例5: render
/**
* A static function for invoking the smarty template engine given the
* template and the data variables.
*
* @param string $template
* @param string $data
*/
public static function render($template, $data)
{
$t = new TemplateEngine();
$t->assign($data);
return $t->fetch("file:/" . getcwd() . "/{$template}");
}
示例6: getUserList
/**
* Returns protected var $oberserver.
* @param string observer key
* @return array
*/
public function getUserList($search)
{
try {
if (!array_key_exists('tree_id', $search)) {
throw new Exception('Tree node not set');
}
if (!array_key_exists('tag', $search)) {
throw new Exception('Template tag not set');
}
if (!array_key_exists('date', $search)) {
throw new Exception('Date not set');
}
if (!array_key_exists('hour', $search)) {
throw new Exception('Hour not set');
}
$maxpage = 10;
$page = array_key_exists('page', $search) ? intval($search['page']) : 0;
$hour = $search['hour'];
$date = $search['date'] ? $search['date'] : date('Y-m-d');
$authentication = Authentication::getInstance();
$user = $authentication->getUserId();
$usr_id = $user['id'];
$canEdit = $authentication->canEdit($search['tree_id']);
$canView = $authentication->canView($search['tree_id']);
if (!$canEdit && !$canView) {
throw new Exception('Access denied');
}
$subObj = $this->getObject(self::TYPE_DEFAULT);
$settingObj = $this->getObject(self::TYPE_SETTINGS);
$settings = $settingObj->getSettings($search['tree_id'], $search['tag']);
// get linked users
$userLink = new ReservationUserLink();
$list = $userLink->getList(array('own_id' => $usr_id));
$userList = array($usr_id);
foreach ($list['data'] as $item) {
$userList[] = $item['usr_id'];
}
$vipCount = $subObj->getVipCount($search);
$legitimateUserList = $canEdit ? array() : $subObj->getLegitimateUserList($userList, $settings['max_subscribe']);
// check if there are any users that are allowed to make a reservation
if (!$legitimateUserList && !$canEdit) {
throw new Exception("Reservation count exceeded.");
}
// user is super user, let him be able to make reservations for his self
//if(!$legitimateUserList) $legitimateUserList = array($usr_id); // COMMENTED OUT BECAUSE SUPER USER CAN MAKE RESERVATIONS FOR ALL MEMBERS
$userSearch = array('id' => $legitimateUserList);
//if($vipCount >= $settings['vip_slots']) $userSearch['no_grp_id'] = $settings['vip_grp_id']; // vip_grp_id is not used anymore
// add search string for user
if (array_key_exists('user', $search) && $search['user']) {
$userSearch['search'] = $search['user'];
}
$userObj = $this->director->systemUser;
// backup pager url
$tmppagerUrl = $userObj->getPagerUrl();
$tmppagerKey = $userObj->getPagerKey();
$url = new JsUrl();
$url->setPath('javascript:userSearch');
$url->setParameter('date', "'{$date}'");
$url->setParameter('hour', $hour);
$url->setParameter('user', "'{$search['user']}'");
$userObj->setPagerUrl($url);
$users = $userObj->getList($userSearch, $maxpage, $page);
// restore pager url
$userObj->setPagerUrl($tmppagerUrl);
$userObj->setPagerKey($tmppagerKey);
$template = new TemplateEngine($this->getPath() . "templates/reservationuserselect.tpl");
$template->setVariable('users', $users);
$template->setVariable('date', $date);
$template->setVariable('hour', $hour);
$template->setVariable('htdocs_path', $this->getHtdocsPath(false));
$template->setVariable('include_vip', $vipCount < $settings['vip_slots']);
$template->setVariable('usersearch', array_key_exists('user', $search) ? $search['user'] : '');
return $template->fetch();
} catch (Exception $e) {
return $e->getMessage();
}
}
示例7: load
//.........这里部分代码省略.........
$controller_type = Controller::TYPE_REPORT;
break;
} else {
if ($redirected === true && file_exists(SOFTWARE_HOME . "{$redirect_path}/{$controller_path}/{$p}/{$baseClassName}Controller.php")) {
$controller_class_name = $baseClassName . "Controller";
$controller_name = $p;
$controller_path .= "/{$p}";
$controller_type = Controller::TYPE_MODULE;
$package_main .= $p;
add_include_path("{$redirect_path}/{$controller_path}/");
break;
} else {
$controller_path .= "/{$p}";
if ($redirected) {
$package_main .= "{$p}.";
}
}
}
}
}
}
}
}
}
}
// Check the type of controller and load it.
switch ($controller_type) {
case Controller::TYPE_MODULE:
// Load a module controller which would be a subclass of this
// class
if ($controller_class_name == "") {
require_once SOFTWARE_HOME . "app/modules{$controller_path}/{$controller_name}.php";
$controller = new $controller_name();
} else {
$controller_name = $controller_class_name;
$controller = new $controller_class_name();
$controller->redirected = $redirected;
$controller->redirectPath = $redirect_path;
$controller->redirectedPackage = $package_path;
$controller->mainRedirectedPackage = $package_main;
$controller->redirectedPackageName = $package_name;
}
break;
case Controller::TYPE_MODEL:
// Load the ModelController wrapper around an existing model class.
$model = substr(str_replace("/", ".", $controller_path), 1);
$controller_name = "ModelController";
$controller = new ModelController($model, $package_path);
break;
case Controller::TYPE_REPORT:
$controller = new XmlDefinedReportController($redirect_path . $controller_path . "/report.xml", $redirected);
$controller_name = "XmlDefinedReportController";
break;
default:
// Load a package controller for this folder
if (is_dir("app/modules{$controller_path}")) {
$controller = new PackageController($path);
$controller_name = "PackageController";
$get_contents = true;
$force_output = true;
} else {
if ($redirected === true && is_dir(SOFTWARE_HOME . "{$redirect_path}/{$controller_path}")) {
$controller = new PackageController($path);
$controller_name = "PackageController";
$get_contents = true;
$force_output = true;
} else {
$controller = new ErrorController();
$controller_name = "ErrorController";
}
}
}
// If the get contents flag has been set return all the contents of this
// controller.
$controller->path = $previousControllerPath . $controller_path;
if ($get_contents) {
if ($i == count($path) - 1 || $force_output) {
$ret = $controller->getContents();
} else {
if (method_exists($controller, $path[$i + 1])) {
$controller_class = new ReflectionClass($controller_name);
$method = $controller_class->GetMethod($path[$i + 1]);
$ret = $method->invoke($controller, array_slice($path, $i + 2));
} else {
$ret = "<h2>Error</h2> Method does not exist. [" . $path[$i + 1] . "]";
}
}
if (is_array($ret)) {
$t = new TemplateEngine();
$t->assign('controller_path', $controller_path);
$t->assign($ret["data"]);
$controller->content = $t->fetch(isset($ret["template"]) ? $ret["template"] : $path[$i + 1] . ".tpl");
} else {
if (is_string($ret)) {
$controller->content = $ret;
}
}
}
return $controller;
}
示例8: fetch
public function fetch()
{
$includeFile = is_file($this->getSource());
$template = new TemplateEngine($this->getSource(), $includeFile);
$template->setVariable($this->vars, null, false);
return $template->fetch();
}
示例9: render
/**
* Renders a given smarty template and returns the output as a string.
* The template passed to this function could either be a string or a file.
* The type of template is specified through the $proto parameter. If a
* protocol is not specified the render function reads in a file.
*
* @param string $template Template string or path to template
* @param array $data The data to render the template with.
* @param string $proto The type of template. 'file' for files and 'string' for strings.
*
* @return string
*/
public static function render($template, $data, $proto = 'file')
{
$t = new TemplateEngine();
$t->assign($data);
return @$t->fetch("{$proto}:" . ($proto === 'file' ? getcwd() . "/" : '') . "{$template}");
}
示例10: get
case 'galeria':
// $galerias = $db->select('pagina_galeria',"galeria_pagina_id=$pagina_id",'galeria_id,galeria_nombre,galeria_descripcion');
$galerias = $db->select_sql("SELECT galeria_id,galeria_nombre,galeria_descripcion,(SELECT imagen_url from pagina_galeria_imagen where imagen_galeria_id = galeria_id LIMIT 1) as foto FROM pagina_galeria WHERE galeria_pagina_id = {$pagina_id} ");
$tpl->galerias = $galerias;
$id = get('id');
// Si solo hay una galería... los mandamos a esa!
// Dejamos esto pendiente
if (count($galerias) == 1 && $id == '') {
$unica_galeria = $db->field("SELECT galeria_id from galeria WHERE galeria_pagina_id = {$pagina_id}");
// header('Location:'.$base_pagina."?p=galeria&id=".$unica_galeria);
}
if ($id != '') {
$imagenes = $db->select('pagina_galeria_imagen', "imagen_galeria_id = {$id}", 'imagen_url,imagen_titulo');
$tpl->imagenes = $imagenes;
}
$tpl->fetch('galeria.tpl');
break;
case 'publicacion':
$id = get('id');
if ($id != '') {
$db->query("UPDATE pagina_publicacion set publicacion_visitas = publicacion_visitas+1 WHERE publicacion_id = {$id}");
$publicacion = $db->select('pagina_publicacion', "publicacion_id={$id}", 'publicacion_id,publicacion_titulo,publicacion_contenido,publicacion_fecha,publicacion_video,publicacion_imagen');
$tpl->publicacion = $publicacion[0];
$tpl->meta_description = strip_tags(substr($publicacion[0]['publicacion_titulo'] . $publicacion[0]['publicacion_contenido'], 0, 140));
$publicaciones = $db->select_sql("SELECT publicacion_id, publicacion_titulo,LEFT(publicacion_contenido, 140) AS publicacion_resumen, publicacion_fecha,publicacion_imagen,publicacion_comentarios FROM pagina_publicacion WHERE publicacion_pagina_id = {$pagina_id} ORDER BY publicacion_fecha DESC LIMIT 5");
$tpl->publicaciones = $publicaciones;
$tpl->fetch('post.tpl');
}
break;
case 'blog':
$publicaciones = $db->select_sql("SELECT publicacion_id, publicacion_titulo,LEFT(publicacion_contenido, 140) AS publicacion_resumen, publicacion_fecha,publicacion_imagen FROM pagina_publicacion WHERE publicacion_pagina_id = {$pagina_id} ORDER BY publicacion_fecha DESC");