本文整理汇总了PHP中Template::fromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::fromFile方法的具体用法?PHP Template::fromFile怎么用?PHP Template::fromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template::fromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Sends an E-Mail to the offerer of the book.
*
* Known usages:
* - add.php
* - book.php - "Anfrage: "
* - Cleaner.php - "Erneuern: "
*
* @param int $bookId database id of th book, this mail is about
* @param string $subjectStart beginning of the subject, the title will
* follow
* @param string $message some text for the user, greeting will be added
* @param string $replyTo mail address for the Reply-To field (optional)
* @return bool false on failure
*/
public static function send($bookId, $subjectStart, $message, $replyTo = null)
{
include_once 'mysql_conn.php';
$query = 'select mail, id, author, title, price, year, isbn,' . ' description, auth_key from books where id="' . $bookId . '"';
$result = mysql_query($query);
if (mysql_num_rows($result) != 1) {
return false;
}
$book = Book::fromMySql($result);
$subject = $subjectStart . $book->get('title');
$tmpl = Template::fromFile('view/mail.txt');
$tmpl->assign('message', $message);
$tmpl->assign('bookText', $book->asText());
if ($replyTo == null || $replyTo == $book->get('mail')) {
$subTmpl = $tmpl->addSubtemplate('editBook');
$link = self::editLink($book->get('id'), $book->get('auth_key'));
$subTmpl->assign('editLink', $link);
$books = new UsersBooks($book->get('mail'));
$subTmpl->assign('usersBooks', $books->toString());
} else {
$subTmpl = $tmpl->addSubtemplate('viewBook');
$link = self::bookLink($book->get('id'));
$subTmpl->assign('bookLink', $link);
}
$content = $tmpl->result();
return self::mail($book->get('mail'), $subject, $content, $replyTo);
}
示例2: __construct
public function __construct($bookId, $output)
{
$this->bookId = $bookId;
$this->output = $output;
$this->tmpl = Template::fromFile('view/book.html');
$this->book = $this->selectBook($bookId);
$this->tmpl->assign('id', $bookId);
}
示例3: __construct
public function __construct()
{
$this->selectableCategories = new SelectableCategories();
$this->output = new Output();
$this->output->setExpires('43200');
$this->output->addNavigationLink('first', 'Erste', 'add.php');
$this->addForm = Template::fromFile('view/add_form.html');
}
示例4: asText
public function asText()
{
$tmpl = Template::fromFile('view/book.txt');
foreach ($this->data as $k => $v) {
$tmpl->assign($k, $v);
}
return $tmpl->result();
}
示例5: testFromFileFailing
function testFromFileFailing()
{
try {
Template::fromFile('/');
} catch (Exception $expected) {
// This should happen
return;
}
$this->fail('Exception expected.');
}
示例6: Output
}
if (isset($_GET['activate'])) {
ExternalServer::activate($_GET['activate']);
}
if (isset($_GET['delete'])) {
ExternalServer::delete($_GET['delete']);
}
}
if (sizeof($_GET)) {
AdminServers::reload();
}
if (sizeof($_POST)) {
AdminServers::reload();
}
$output = new Output();
$template = Template::fromFile('view/admin_servers.html');
$template->assign('localServerName', $localServer->name());
if ($localServer->isEmpty() || AdminServers::$editName) {
$template->addSubtemplate('defineName');
} else {
$sub = $template->addSubtemplate('listServers');
if ($localServer->rememberNewServers()) {
$sub->addSubtemplate('rememberingServers');
} else {
$sub->addSubtemplate('notRememberingServers');
}
if ($localServer->acceptSuggestedServers()) {
$sub->addSubtemplate('acceptingSuggestedServers');
} else {
$sub->addSubtemplate('notAcceptingSuggestedServers');
}
示例7: __construct
public function __construct()
{
$this->output = new Output();
$this->tmpl = Template::fromFile('view/index.html');
$this->basicOutput();
}
示例8: array
$indices = array('author', 'title', 'price', 'year', 'isbn', 'description');
$bookString = trim($bookString);
$bookLines = split("\n", $bookString, sizeof($labels));
for ($i = 0; $i < sizeof($labels); $i++) {
list($label, $value) = split(':', $bookLines[$i], 2);
if (trim($label) != $labels[$i]) {
$value = '';
}
$value = Parser::text2html(stripslashes(trim($value)));
$tmpl->assign($indices[$i], $value);
}
}
$usermail = Parser::text2html(stripslashes(Mailer::mailFromUser('mail')));
if (isset($_POST['book_data'])) {
$tmpl = Template::fromFile('view/add_form.html');
import_book($_POST['book_data'], $tmpl);
if (isset($_POST['mail'])) {
$tmpl->assign('mail', $usermail);
}
$selectableCategories = new SelectableCategories();
$categoryString = implode(' ', $selectableCategories->createSelectArray());
$tmpl->assign('categories', $categoryString);
} else {
$tmpl = Template::fromFile('view/import.html');
if (isset($_GET['mail'])) {
$mailTmpl = $tmpl->addSubtemplate('mail');
$mailTmpl->assign('mail', $usermail);
}
}
$output = new Output();
$output->send($tmpl->result());
示例9: Output
<?php
/*
* This file is part of uBook - a website to buy and sell books.
* Copyright © 2010 Maikel Linke
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'tools/Output.php';
require_once 'text/Template.php';
$helpTpl = Template::fromFile('view/help.html');
$output = new Output();
$output->setExpires(43200);
$output->unlinkMenuEntry('Tipps');
$output->send($helpTpl->result());
示例10: sendNotFound
public function sendNotFound($content = null)
{
header('HTTP/1.0 404 Not Found');
if ($content === null) {
$tmpl = Template::fromFile('view/NotFound.html');
$content = $tmpl->result();
}
$this->send($content);
}
示例11:
<?php
/*
* This file is part of uBook - a website to buy and sell books.
* Copyright © 2010 Maikel Linke
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'text/Template.php';
require_once 'tools/WEBDIR.php';
$tmpl = Template::fromFile('view/openSearch.xml');
$tmpl->assign('siteurl', WEBDIR);
header('Content-Type: application/opensearchdescription+xml;charset=utf-8');
//header('Content-Type: text/xml;charset=utf-8');
echo $tmpl->result();
示例12: Output
* This file is part of uBook - a website to buy and sell books.
* Copyright © 2010 Maikel Linke
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'update/Updater.php';
require_once 'tools/Output.php';
require_once 'text/Template.php';
$output = new Output();
$tmpl = Template::fromFile('view/update.html');
$updater = new Updater();
if ($updater->hasWork()) {
$updater->update();
$sub = $tmpl->addSubtemplate('working');
$sub->assign('version', $updater->getNextVersion());
$output->addRefreshLink('./admin_update.php');
} else {
$tmpl->addSubtemplate('noWork');
}
$output->send($tmpl->result());
示例13: mysql_query
if (!isset($_GET['id'])) {
exit;
}
if (!isset($_GET['key'])) {
exit;
}
$id = (int) $_GET['id'];
$key = $_GET['key'];
$query = 'select id from books where id="' . $id . '" and auth_key="' . $key . '";';
$result = mysql_query($query);
if (mysql_num_rows($result) != 1) {
exit;
}
// now we have valid access
$output = new Output();
$tmpl = Template::fromFile('view/upload.html');
$tmpl->assign('id', $id);
$tmpl->assign('key', $key);
if (isset($_GET['upload'])) {
if (Image::wasUploaded()) {
if (Image::isStorable()) {
$image = new Image($id);
if ($image->moveUploaded()) {
header('Location: book.php?id=' . $id . '&key=' . $key . '&uploaded=true');
} else {
$tmpl->addSubtemplate('processingError');
}
} else {
$tmpl->addSubtemplate('notStorable');
}
} else {
示例14: Statistics
/*
* This file is part of uBook - a website to buy and sell books.
* Copyright © 2010 Maikel Linke
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'tools/Output.php';
require_once 'tools/Statistics.php';
require_once 'text/Template.php';
$stat = new Statistics();
$statTpl = Template::fromFile('view/statistics.html');
if (file_exists(Statistics::STATS_FILE)) {
$statTpl->addSubtemplate('stats');
$stat->fillTemplate($statTpl);
} else {
$statTpl->addSubtemplate('noStats');
}
$output = new Output();
$output->setExpires(43200);
$output->send($statTpl->result());
示例15: SelectableCategories
$error = 'not found';
} else {
/* we have valid access to this book */
$selectableCategories = new SelectableCategories($id);
if (isset($_POST['author'])) {
/* update base book data */
$query = 'update books set
author = "' . $_POST['author'] . '",
title = "' . $_POST['title'] . '",
year = "' . $_POST['year'] . '",
isbn = "' . $_POST['isbn'] . '",
price = "' . str_replace(',', '.', $_POST['price']) . '",
description = "' . $_POST['desc'] . '"
where id="' . $id . '" and auth_key="' . $key . '"';
mysql_query($query);
/* update category relations */
$selectableCategories->update();
/* update expire date and look at the book */
require 'renew.php';
}
$book = Book::fromMySql($result);
require_once 'tools/Output.php';
require_once 'text/Template.php';
$tmpl = Template::fromFile('view/edit.html');
$book->assignHtmlToTemplate($tmpl);
assignSelectableCategories($selectableCategories, $tmpl);
$tmpl->assign('id', $_GET['id']);
$tmpl->assign('key', $_GET['key']);
$output = new Output();
$output->send($tmpl->result());
}