本文整理汇总了PHP中Template::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::add方法的具体用法?PHP Template::add怎么用?PHP Template::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: showResults
public function showResults($electionId)
{
\Layout::addStyle('election', 'Admin/Report/style.css');
$singleResults = Factory::getSingleResults($electionId);
$multipleResults = Factory::getMultipleResults($electionId);
$referendumResults = Factory::getReferendumResults($electionId);
$template = new \Template();
$template->add('single', $singleResults);
$template->add('multiple', $multipleResults);
$template->add('referendum', $referendumResults);
$template->setModuleTemplate('election', 'Admin/Report/Results.html');
return $template->get();
}
示例3: printFile
public function printFile($id)
{
$db = \Database::newDB();
$t = $db->addTable('documents');
$t->addFieldConditional('id', (int) $id);
$row = $db->selectOneRow();
if (empty($row)) {
return null;
}
$template = new \Template();
$template->setModuleTemplate('filecabinet', 'FC_Forms/document_view.html');
$template->add('title', $row['title']);
$template->add('filepath', './filecabinet/' . $row['id']);
return $template->get();
}
示例4: printFile
public function printFile($id)
{
$db = \Database::newDB();
$t = $db->addTable('images');
$t->addFieldConditional('id', (int) $id);
$row = $db->selectOneRow();
if (empty($row)) {
return null;
}
$template = new \Template();
$template->setModuleTemplate('filecabinet', 'FC_Forms/image_view.html');
$template->add('title', $row['title']);
$template->add('alt', $row['alt']);
$template->add('filepath', $row['file_directory'] . $row['file_name']);
return $template->get();
}
示例5: render
public function render()
{
$items = $this->products->get_latest_products($this->count);
$html = new \Template('partials/sidebar/products.html.php');
$html->add('products', $items);
return $html;
}
示例6: populateTemplate
public function populateTemplate()
{
if (empty($this->template)) {
throw new \Exception(t('Template not set'));
}
$this->template->add('pager_id', $this->getId());
$this->template->add('pager_javascript', $this->getJavascript());
}
示例7: access_denied
/**
* Returns an access denied page.
*/
function access_denied()
{
$tpl = new Template();
$tpl->add('main', 'common/503');
// FIXME: Does it exist?.
$tpl->setTPL('page');
// FIXME: What about TTLs.
return $tpl->render();
}
示例8: controller
function controller($args)
{
$ucard = random_card();
$card_name = t(ucard2words($ucard));
$card_icon = ucard2html($ucard);
$card_suit = ucard2suit($ucard);
page_set_title("{$card_icon} {$card_name}");
$tpl_params = ['card_name' => $card_name, 'card_icon' => $card_icon, 'card_suit' => $card_suit];
$tpl = new Template();
$tpl->add('main', 'blocks/speedcard', $tpl_params);
$tpl->setTPL('page');
return $tpl->render();
}
示例9: pager
private function pager(\Request $request)
{
\Pager::prepare();
$template = new \Template();
$template->setModuleTemplate('pulse', 'pager.html');
if (\Settings::get('pulse', 'allow_web_access')) {
$template->add('button_class', 'btn-success');
$template->add('button_status', 'Web Access Allowed');
$template->add('button_icon', 'fa-check');
$template->add('button_title', 'Pulse will process schedules via the web.');
} else {
$template->add('button_class', 'btn-danger');
$template->add('button_status', 'Web Access Denied');
$template->add('button_icon', 'fa-ban');
$template->add('button_title', 'Pulse will not allow access via the web.');
}
return $template;
}
示例10: emailStudent
private static function emailStudent(\election\Resource\Student $student, array $election)
{
if (STUDENT_DATA_TEST) {
$email_address = TEST_STUDENT_EMAIL;
} else {
$email_address = $student->getEmail();
}
$transport = \Swift_MailTransport::newInstance();
$template = new \Template();
$template->setModuleTemplate('election', 'Admin/VoteSuccess.html');
$template->add('title', $election['title']);
$content = $template->get();
$message = \Swift_Message::newInstance();
$message->setSubject('Vote complete');
$message->setFrom(\PHPWS_Settings::get('election', 'fromAddress'));
$message->setTo($email_address);
$message->setBody($content, 'text/html');
$mailer = \Swift_Mailer::newInstance($transport);
$mailer->send($message);
}
示例11: parse
/**
* Parses the specified file $filename with an array $data.
* Useful for parsing piece of code.
*
* @param string $filename
* @param array $data
* @return string
*/
function parse($filename, $data)
{
$tpl = new Template();
foreach ($data as $k => $v) {
$tpl->add($k, $v);
}
return $tpl->fetch($filename);
}
示例12: welcomeScreen
public static function welcomeScreen()
{
\Layout::addStyle('election', 'User/style.css');
$template = new \Template();
$template->setModuleTemplate('election', 'User/welcome.html');
if (!\Current_User::isLogged()) {
$template->add('color', 'primary');
$template->add('label', '<i class="fa fa-check-square-o"></i> Sign in to Vote');
$template->add('url', ELECTION_LOGIN_DIRECTORY);
} else {
$template->add('color', 'success');
$template->add('label', '<i class="fa fa-check-square-o"></i> Get started voting!');
$template->add('url', 'election/');
}
$template->add('image', PHPWS_SOURCE_HTTP . 'mod/election/img/background1.jpg');
\Layout::add($template->get());
}
示例13: getMultipleResults
public static function getMultipleResults($electionId)
{
$total_votes = Election::getTotalVotes($electionId);
$multiples = Multiple::getListWithCandidates($electionId);
if (empty($multiples)) {
return null;
}
$votes = Vote::getMultipleVotes($electionId);
if (empty($votes)) {
return 'No multiple chair votes recorded.';
}
$total_cast_votes = array();
foreach ($votes as $v) {
$key = $v['multipleId'];
if (!isset($total_cast_votes[$key])) {
$total_cast_votes[$key] = 0;
}
$total_cast_votes[$key] += $v['votes'];
$sorted_votes[$key][$v['candidateId']] = $v['votes'];
}
foreach ($multiples as $ballot) {
$ballot_row['title'] = $ballot['title'];
$ballot_row['seats'] = $ballot['seatNumber'];
$candidates = array();
foreach ($ballot['candidates'] as $c) {
if (isset($sorted_votes[$ballot['id']][$c['id']])) {
$vote = $sorted_votes[$ballot['id']][$c['id']];
$template = new \Template();
$template->setModuleTemplate('election', 'Admin/Report/Candidate.html');
$template->add('name', $c['firstName'] . ' ' . $c['lastName']);
$percentage = round($vote / $total_cast_votes[$ballot['id']] * 100, 1);
$template->add('vote', "{$vote} ({$percentage}%)");
$template->add('picture', $c['picture']);
$candidates[$vote . '.' . $c['id']] = $template->get();
}
}
if (!empty($candidates)) {
krsort($candidates);
$ballot_row['candidates'] = implode("\n", $candidates);
} else {
$ballot_row['candidates'] = self::noCandidateVotes();
}
$tpl['ballots'][] = $ballot_row;
}
$template = new \Template();
$template->addVariables($tpl);
$template->setModuleTemplate('election', 'Admin/Report/Multiple.html');
return $template->get();
}
示例14: autoloader
//require_once("libs/lib_template.php");
//require_once("libs/lib_item.php");
//require_once("libs/lib_game.php");
function autoloader($classname)
{
if (file_exists("libs/" . strtolower($classname) . ".class.php")) {
require_once "libs/" . strtolower($classname) . ".class.php";
}
}
spl_autoload_register("autoloader");
$controler = GET('action', GET('a'));
if ($controler == "") {
$controler = "index";
}
$run = GET('subaction', GET('s'));
if ($run == "") {
$run = "run";
}
if (!file_exists('controler/' . $controler . '.controler.php')) {
$controler = 'error';
}
include 'controler/' . $controler . '.controler.php';
$controler = $controler . "_controler";
$c = new $controler();
$templ = new Template();
$templ->add("title", $CONFIG['Title']);
if (!is_callable(array($controler, $run))) {
$run = "run";
}
$c->{$run}($templ);
$templ->run();
示例15: confirmWinner
private function confirmWinner()
{
$game = \tailgate\Factory\Game::getCurrent();
$hash = filter_input(INPUT_GET, 'hash', FILTER_SANITIZE_STRING);
$template = new \Template();
$factory = new Factory();
$template->setModuleTemplate('tailgate', 'User/confirmation.html');
$template->add('button_color', 'primary');
if ($game->getPickupDeadline() < time()) {
$template->add('message_color', 'danger');
$template->add('message', 'Sorry, the confirmation deadline for this lottery has passed.');
$template->add('url', \Server::getSiteUrl());
$template->add('label', 'Go back to home page');
$content = $template->get();
return $content;
}
$confirm = $factory->confirm($hash);
if ($confirm) {
$template->add('message_color', 'success');
$template->add('message', 'Lottery win confirmed!');
if (!\Current_User::isLogged()) {
$template->add('url', \Server::getSiteUrl() . 'admin/');
$template->add('label', 'Log in to pick your lot');
} else {
$template->add('url', \Server::getSiteUrl() . 'tailgate/');
$template->add('label', 'Go to your status page and pick a spot');
}
} else {
$template->add('message_color', 'danger');
$template->add('message', 'Sorry, could not confirm your lottery win. Contact us if you are having trouble.');
$template->add('url', \Server::getSiteUrl());
$template->add('label', 'Go back to home page');
}
$content = $template->get();
return $content;
}