本文整理汇总了PHP中PHPTAL::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPTAL::execute方法的具体用法?PHP PHPTAL::execute怎么用?PHP PHPTAL::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPTAL
的用法示例。
在下文中一共展示了PHPTAL::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Use PHPTAL to generate some XHTML
* @return string
*/
public function execute()
{
try {
$this->phptal->setTemplate($this->template);
return $this->phptal->execute();
} catch (Exception $e) {
$ex = new FrameEx($e->getMessage());
$ex->backtrace = $e->getTrace();
throw $ex;
}
}
示例2: getContent
public function getContent()
{
global $sql;
//Lang::load('blocks/shoutbox/lang.*.php');
$err = new Error();
$note = new Notifier('note-shoutbox');
$form['author'] = LOGGED ? User::$nickname : '';
$form['message'] = '';
if (isset($_POST['reply-shoutbox'])) {
$form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
$form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
$err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
$err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
$err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
// No errors
if ($err->noErrors()) {
$sql->exec('
INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
VALUES (
' . TIMESTAMP . ',
"' . $form['author'] . '",
"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
' . UID . ',
"' . IP . '")');
$sql->clearCache('shoutbox');
$note->success(t('Entry was added successfully.'));
redirect(HREF . PATH . '#shoutbox');
} else {
$note->error($err->toArray());
}
}
// If cache for shoutbox doesn't exists
if (!($entries = $sql->getCache('shoutbox'))) {
$query = $sql->query('
SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
FROM ' . DB_PREFIX . 'shoutbox s
LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
ORDER BY s.id DESC
LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
while ($row = $query->fetch()) {
if ($row['author_id']) {
$row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
$row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
}
$entries[] = $row;
}
$sql->putCacheContent('shoutbox', $entries);
}
try {
$tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
$tpl->entries = $entries;
$tpl->err = $err->toArray();
$tpl->form = $form;
$tpl->note = $note;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e->getMessage());
//echo Note::error($e->getMessage());
}
}
示例3: execute
function execute()
{
// Variablen an Template zuweisen
$this->__set('javascriptContent', $this->_javascript);
$this->__set('messages', $this->_messages);
parent::execute();
}
示例4: echoExecute
private function echoExecute(PHPTAL $tpl)
{
try {
ob_start();
$this->assertEquals(0, strlen($tpl->echoExecute()));
$res = ob_get_clean();
} catch (Exception $e) {
ob_end_clean();
throw $e;
}
$res2 = $tpl->execute();
$res3 = $tpl->execute();
$this->assertEquals($res2, $res3, "Multiple runs should give same result");
$this->assertEquals($res2, $res, "Execution with and without buffering should give same result");
return normalize_html($res);
}
示例5: processViewData
/**
* This method is used to process the data into the view and than return it to the main method that will handle what to do.
* It also uses buffer to handle that content.
*
* @author Klederson Bueno <klederson@klederson.com>
* @version 0.1a
*
* @param String $___phpBurnFilePath
* @param Array $__phpBurnData
* @return String
*/
public function processViewData($___phpBurnFilePath, $__phpBurnData)
{
$tpl = new PHPTAL($___phpBurnFilePath);
$tpl->setOutputMode(PHPTAL::HTML5);
$tr = new PHPTAL_GetTextTranslator();
// set language to use for this session (first valid language will
// be used)
$tr->setLanguage('pt_BR.utf8', 'pt_BR');
// register gettext domain to use
$tr->addDomain('system', SYS_BASE_PATH . 'locale');
// specify current domain
$tr->useDomain('system');
// tell PHPTAL to use our translator
$tpl->setTranslator($tr);
foreach ($__phpBurnData as $index => $value) {
if (is_string($value)) {
$value = PhpBURN_Views::lazyTranslate($value, $_SESSION['lang']);
}
$tpl->{$index} = $value;
}
ob_start();
try {
echo $tpl->execute();
} catch (Exception $e) {
echo $e;
}
$___phpBurnBufferStored = ob_get_contents();
//
// //Cleaning the buffer for new sessions
ob_clean();
return $___phpBurnBufferStored;
}
示例6: getForm
public static function getForm($errors = array())
{
global $cfg;
if (LOGGED) {
redirect(REFERER);
}
$note = new Notifier();
$err = new Error();
if ($errors) {
$note->error($errors);
}
if ($_POST['login'] && $_POST['module']) {
$form = array('logname' => $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '', 'password' => $_POST['password-session'] ? filter($_POST['password-session'], 100) : '');
$err->setError('empty_logname', t('Logname field is required.'))->condition(!$form['logname']);
$err->setError('logname_not_exists', t('The logname you used isn't registered.'))->condition($form['logname'] && !User::loginNameRegistered($form['logname']));
$err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
$err->setError('password_invalid', t('Password is invalid.'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
$err->noErrors() ? redirect(REFERER) : $note->restore()->error($err->toArray());
}
$tpl = new PHPTAL('modules/login/form.html');
$tpl->form = $form;
$tpl->err = $err->toArray();
$tpl->note = $note;
echo $tpl->execute();
}
示例7: finalize
/**
* Return the content in the right format, it tell to the child class to execute template vars inflating
*
* @see controller::finalize
*
* @return mixed|void
*/
public function finalize()
{
/**
* Call child for template vars fill
*
*/
$this->setTemplateVars();
try {
$buffer = ob_get_contents();
ob_get_clean();
ob_start("ob_gzhandler");
// compress page before sending
$this->nocache();
header('Content-Type: text/html; charset=utf-8');
/**
* Execute Template Rendering
*/
echo $this->template->execute();
} catch (Exception $e) {
echo "<pre>";
print_r($e);
echo "\n\n\n";
echo "</pre>";
exit;
}
}
示例8: getContent
public function getContent()
{
// User is logged in
if (LOGGED) {
$this->subcodename = 'logged';
$tpl = new PHPTAL('blocks/user_panel/logged.html');
$tpl->user = User::format(User::$id, User::$nickname, User::$groupId);
$pm_item = User::$pmNew ? array(t('Messages <strong>(New: %new)</strong>', array('%new' => $user->pm_new)), 'pm/inbox') : array(t('Messages'), 'pm');
$tpl->items = items(array($pm_item[0] => HREF . $pm_item[1], t('Administration') => HREF . 'admin', t('Edit profile') => HREF . 'edit_profile', t('Log out') => HREF . 'logout'));
return $tpl->execute();
} else {
$err = new Error();
$note = new Notifier('note-user_panel');
$this->subcodename = 'not_logged';
$form = array('logname' => null, 'password' => null);
if ($_POST['login'] && $_POST['user_panel']) {
$form['logname'] = $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '';
$form['password'] = $_POST['password-session'] ? $_POST['password-session'] : '';
$err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']);
$err->setError('logname_not_exists', t('Entered logname is not registered.'))->condition(!User::loginNameRegistered($form['logname']));
$err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
$err->setError('password_incorrect', t('ERROR_PASS_INCORRECT'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
if ($err->noErrors()) {
redirect('./');
} else {
$note->error($err->toArray());
}
}
$tpl = new PHPTAL('blocks/user_panel/not_logged.html');
$tpl->note = $note;
$tpl->form = $form;
$tpl->err = $err->toArray();
return $tpl->execute();
}
}
示例9: render
public function render(&$toolbar)
{
if (!class_exists('PHPTAL')) {
require 'PHPTAL.php';
}
$tal = new PHPTAL();
$tal->toolbar = $toolbar;
$tal->setSource($this->template);
$html = $tal->execute();
return $html;
}
示例10: parse
public function parse($tplDir, $tplFile, $args)
{
if (!$this->is_included) {
$this->include_php_tal_file();
}
/**
* @var PHPTAL
*/
$tpl = new PHPTAL($tplDir . "/" . $tplFile);
$tpl->doc = $args;
return $tpl->execute();
}
示例11: getContent
public function getContent()
{
global $sql;
$note = new Notifier('note-poll');
$stmt = $sql->setCache('poll_topic')->query('
SELECT id, title, votes
FROM ' . DB_PREFIX . 'poll_topics
WHERE active = 1');
$topic = $stmt->fetch(PDO::FETCH_ASSOC);
if ($topic) {
$vote_id = $sql->query('
SELECT option_id
FROM ' . DB_PREFIX . 'poll_votes
WHERE topic_id = ' . $topic['id'] . ' AND voter_ip = "' . IP . '"')->fetchColumn();
$stmt = $sql->setCache('poll_options')->query('
SELECT id, title, votes
FROM ' . DB_PREFIX . 'poll_options
WHERE topic_id = ' . $topic['id'] . ' ORDER BY votes DESC');
// User already voted
if ($vote_id) {
$options = array();
$block->subcodename = 'results';
foreach ($stmt as $row) {
$row['percent'] = @round(100 * ($row['votes'] / $topic['votes']), 1);
$options[] = $row;
}
$tpl = new PHPTAL('blocks/poll/results.html');
$tpl->vote_id = $vote_id;
} else {
if ($_POST['vote-poll'] && $_POST['option-poll']) {
$option_id = (int) $_POST['option-poll'];
$sql->clearCacheGroup('poll_*')->exec('
UPDATE ' . DB_PREFIX . 'poll_options o, ' . DB_PREFIX . 'poll_topics t
SET o.votes = o.votes + 1, t.votes = t.votes + 1
WHERE o.topic_id = ' . $topic['id'] . ' AND o.id = ' . $option_id . ' AND t.id = ' . $topic['id'] . ';
INSERT INTO ' . DB_PREFIX . 'poll_votes (topic_id, option_id, voter_id, voter_ip, voted)
VALUES (' . $topic['id'] . ', ' . $option_id . ', ' . $user->id . ', "' . IP . '", ' . TIMESTAMP . ')');
redirect(PATH . '#poll');
} else {
$block->subcodename = 'voting';
$options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$tpl = new PHPTAL('blocks/poll/voting.html');
}
}
$stmt->closeCursor();
$tpl->topic = $topic;
$tpl->options = $options;
$tpl->note = $note;
return $tpl->execute();
} else {
return t('There is no content to display.');
}
}
示例12: getContent
public function getContent()
{
global $sql;
// $kio->disableRegion('left');
if (u1 || LOGGED) {
// TODO: Zamiast zapytania dla własnego konta dać User::toArray()
$profile = $sql->query('
SELECT u.*
FROM ' . DB_PREFIX . 'users u
WHERE u.id = ' . (ctype_digit(u1) ? u1 : UID))->fetch();
}
if ($profile) {
Kio::addTitle(t('Users'));
Kio::addBreadcrumb(t('Users'), 'users');
Kio::addTitle($profile['nickname']);
Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1 . '/' . clean_url($profile['nickname']));
Kio::setDescription(t('%nickname's profile', array('%nickname' => $profile['nickname'])) . ($profile['title'] ? ' - ' . $profile['title'] : ''));
Kio::addTabs(array(t('Edit profile') => 'edit_profile/' . u1));
if ($profile['birthdate']) {
$profile['bd'] = $profile['birthdate'] ? explode('-', $profile['birthdate']) : '';
// DD Month YYYY (Remaining days to next birthday)
$profile['birthdate'] = $profile['bd'][2] . ' ' . Kio::$months[$profile['bd'][1]] . ' ' . $profile['bd'][0] . ' (' . day_diff(mktime(0, 0, 0, $profile['bd'][1], $profile['bd'][2] + 1, date('y')), t('%d days remaining')) . ')';
$profile['age'] = get_age($profile['bd'][2], $profile['bd'][1], $profile['bd'][0]);
if (Plugin::exists('zodiac')) {
require_once ROOT . 'plugins/zodiac/zodiac.plugin.php';
$profile['zodiac'] = Zodiac::get($profile['bd'][2], $profile['bd'][1]);
}
}
if ($profile['http_agent'] && Plugin::exists('user_agent')) {
require_once ROOT . 'plugins/user_agent/user_agent.plugin.php';
$profile['os'] = User_Agent::getOS($profile['http_agent']);
$profile['browser'] = User_Agent::getBrowser($profile['http_agent']);
}
$group = Kio::getGroup($profile['group_id']);
$profile['group'] = $group['name'] ? $group['inline'] ? sprintf($group['inline'], $group['name']) : $group['name'] : '';
if ($profile['gender']) {
$profile['gender'] = $profile['gender'] == 1 ? t('Male') : t('Female');
}
try {
// TODO: Zrobić modyfikator dla funkcji o wielu parametrach (teraz jest tylko jeden możliwy)
$tpl = new PHPTAL('modules/profile/profile.tpl.html');
$tpl->profile = $profile;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e);
}
} else {
return not_found(t('Selected user doesn't exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
}
}
示例13: getContent
public function getContent()
{
//Lang::load('blocks/calendar/lang.*.php');
$today = date('j');
$month = date('n');
$year = date('Y');
if ($month < 8 && $month % 2 == 1 || $month > 7 && $month % 2 == 0) {
$total_days = 31;
} else {
$total_days = $month == 2 ? date('L') ? 29 : 28 : 30;
}
$first_day = date('w', mktime(1, 1, 1, $month, 0, $year));
$last_day = date('w', mktime(1, 1, 1, $month, $total_days - 1, $year));
if ($first_day != 0) {
$colspan = $first_day;
}
if (6 - $last_day != 0) {
$colspan2 = 6 - $last_day;
}
$days = null;
for ($day = 1; $day <= $total_days; ++$day) {
$day_of_week = date('w', mktime(1, 1, 1, $month, $day - 1, $year));
if ($day == 1 || $day_of_week == 0) {
$days .= '<tr class="border-1-parent" title="' . t('Week: %week', array('%week' => date('W', mktime(1, 1, 1, $month, $day, $year)))) . '">';
if ($colspan > 0 && $day == 1) {
$days .= '<td colspan="' . $colspan . '" class="empty"> </td>';
}
}
$days .= '<td><a';
if ($day == $today) {
$days .= ' class="today border-2"';
}
$days .= ' href="#' . $day . '.' . $month . '.' . $year . '">' . $day . '</a></td>';
if ($day == $total_days && $colspan2 > 0) {
$days .= '<td colspan="' . $colspan2 . '" class="empty"> </td>';
}
if ($day_of_week == 6 || $day == $total_days) {
$days .= '</tr>';
}
}
try {
$tpl = new PHPTAL('blocks/calendar/month_view.html');
$tpl->days = $days;
$tpl->month_year = date('m') . '/' . $year;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e->getMessage());
}
}
示例14: getContent
public function getContent()
{
global $sql;
$pager = new Pager('users', Kio::getStat('total', 'users'), Kio::getConfig('limit', 'users'));
$pager->sort(array(t('Nickname') => 'nickname', t('Group') => 'g_name', t('Gender') => 'gender', t('Title') => 'title', t('Location') => 'locality', t('Country') => 'country', t('Registered') => 'registered'), 'registered', 'asc');
$query = $sql->query('
SELECT id, name, inline, members
FROM ' . DB_PREFIX . 'groups
ORDER BY display_order');
while ($row = $query->fetch()) {
if ($row['inline']) {
$row['name'] = sprintf($row['inline'], $row['name']);
}
$groups[] = $row;
}
$query = $sql->query('
SELECT u.id, u.nickname, u.email, u.registered, u.group_id, u.gender, u.locality, u.country, u.communicator, u.title, g.name g_name
FROM ' . DB_PREFIX . 'users u
LEFT JOIN ' . DB_PREFIX . 'groups g ON g.id = u.group_id
ORDER BY ' . $pager->orderBy . '
LIMIT ' . $pager->limit . '
OFFSET ' . $pager->offset);
while ($row = $query->fetch()) {
$row['nickname'] = User::format($row['id'], $row['nickname'], $row['group_id']);
switch ($row['gender']) {
case 1:
$row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/male.png" alt="' . t('Male') . '" title="' . t('Male') . '" />';
break;
case 2:
$row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/female.png" alt="' . t('Female') . '" title="' . t('Female') . '" />';
break;
default:
$row['gender'] = '';
}
$users[] = $row;
}
try {
$tpl = new PHPTAL('modules/users/users.tpl.html');
$tpl->sort = $pager->sorters;
$tpl->users = $users;
$tpl->groups = $groups;
$tpl->pagination = $pager->getLinks();
return $tpl->execute();
} catch (Exception $e) {
return template_error($e);
}
}
示例15: execute
public function execute($view)
{
parent::execute($view);
return $view->render();
$context = Joy_Context::getInstance();
$resource = $view->getResourceList();
$context->response->addScript($resource["javascripts"]);
$context->response->addStyle($resource["stylesheets"]);
$application = $context->config->application->get("application");
$application["i18n"] = $view->getLocale();
$tpl = new PHPTAL();
$tpl->setSource($view->getTemplate());
$tpl->import = new Joy_Render_Template_Importer($view);
$tpl->application = $application;
$tpl->get = (array) $view->assignAll();
return $tpl->execute();
}