本文整理汇总了PHP中Typeframe::SetPageTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Typeframe::SetPageTemplate方法的具体用法?PHP Typeframe::SetPageTemplate怎么用?PHP Typeframe::SetPageTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typeframe
的用法示例。
在下文中一共展示了Typeframe::SetPageTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
<?php
$file = isset($_REQUEST['file']) ? $_REQUEST['file'] : '';
if ($file && file_exists(TYPEF_DIR . $file) && is_file(TYPEF_DIR . $file)) {
header('Content-type: text/css');
$dir = dirname($file);
$md5 = md5($file) . '.css';
$dst = TYPEF_DIR . '/files/cache/lessphp/' . $md5;
lessc::ccompile(TYPEF_DIR . $file, $dst);
$css = SimpleCss::LoadFile($dst, TYPEF_WEB_DIR . $dir);
$code = $css->toString();
preg_match_all('/url\\(\\"([\\w\\W\\s\\S]*?)"\\)/', $code, $matches);
if (isset($matches[1])) {
foreach ($matches[1] as $url) {
$url = Typeframe_Attribute_Url::ConvertShortUrlToExpression($url);
$url = Typeframe::Pagemill()->data()->parseVariables($url);
$code = str_replace($matches[1], $url, $code);
}
}
echo $code;
exit;
} else {
http_response_code(404);
Typeframe::SetPageTemplate('/404.html');
Typeframe::CurrentPage()->stop();
}
示例2: array
<?php
$db = Typeframe::Database();
$pm = Typeframe::Pagemill();
Typeframe::SetPageTemplate('/admin/applications/index.html');
foreach (Typeframe::Registry()->applications() as $a) {
$app = array('name' => $a->name(), 'title' => $a->title(), 'map' => $a->map());
$pm->addLoop('applications', $app);
if ($a->map() == 'hard') {
$pm->addLoop('applications', 'pages', array('uri' => TYPEF_WEB_DIR . $a->base()));
} else {
// TODO: Figure out what to do about soft-mapped pages
/*
foreach (Typeframe::Registry()->getApplicationPagesByName($a->name()) as $p) {
$pm->addLoop('applications', 'pages', array('uri' => $p->uri()));
}
*/
}
}
$pm->sortLoop('applications', 'name');
示例3: Ftp
<?php
$db = Typeframe::Database();
$pm = Typeframe::Pagemill();
if (empty($_SESSION['typef_ftp_user']) || empty($_SESSION['typef_ftp_pass'])) {
if (defined('TYPEF_FTP_USER') && defined('TYPEF_FTP_PASS') && TYPEF_FTP_USER != '') {
// Test the provided credentials
$ftp = new Ftp();
$ftp->connect(TYPEF_FTP_HOST) or die('Invalid FTP host.');
if ($ftp->login(TYPEF_FTP_USER, TYPEF_FTP_PASS)) {
$_SESSION['typef_ftp_user'] = TYPEF_FTP_USER;
$_SESSION['typef_ftp_pass'] = TYPEF_FTP_PASS;
$ftp->close();
return;
}
}
$pm->setVariable('redirect', $_SERVER['REQUEST_URI']);
Typeframe::SetPageTemplate('/admin/ftp/login.html');
Typeframe::CurrentPage()->stop();
}
示例4: randomID
$userid = $user->get('userid');
$resetkey = randomID();
$expire = date('Y-m-d H:i:s', time() + 86400);
// create an entry in the password reset table
$reset = Model_UserReset::Create();
$reset->set('userid', $userid);
$reset->set('resetkey', $resetkey);
$reset->set('expire', $expire);
$reset->save();
// construct e-mail body
$mm = new Pagemill($pm->root()->fork());
$mm->setVariable('username', $user->get('username'));
$mm->setVariable('reseturl', sprintf('http://%s%s/password?userid=%d&resetkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $resetkey));
$body = str_replace('&', '&', $mm->writeString('<pm:include template="/users/reset.eml" />', true));
// e-mail the user so they can reset their password
$mailer = new Mailer();
$mailer->Configure();
$mailer->IsHTML(true);
$mailer->AddAddress($_POST['email']);
$mailer->Subject = 'Request to Reset Password for ' . TYPEF_TITLE;
$mailer->Body = $body;
$mailer->Send();
$pm->setVariable('reset_email_sent', true);
Typeframe::Log('Request to reset password for ' . $_POST['email']);
} else {
$pm->setVariable('reset_email_failed', true);
}
}
// set template (controller is at root, but template lives in users directory
Typeframe::SetPageTemplate('/users/password-reset.html');
示例5: array
if (isset($_POST['action']) && 'Cancel' != $_POST['action']) {
$content = array();
foreach ($group['members'] as $member) {
$key = $member['name'];
if ('image' == $member['type']) {
$value = basename(FileManager::GetPostedOrUploadedFile($key, TYPEF_DIR . '/files/public/content'));
} elseif (isset($_POST[$key])) {
$value = $_POST[$key];
} else {
$value = null;
}
$content[$key] = $value;
}
$pm->setVariable('row', $content);
$pm->setVariable('group', $group);
}
Typeframe::SetPageTemplate('/admin/content/groups/form-post.html');
}
$pm->setVariable('action', $_SERVER['REQUEST_URI']);
$pm->setVariable('group', $group);
$pm->setVariable('template', $_REQUEST['template']);
$pm->setVariable('base', $_REQUEST['base']);
if (!empty($_REQUEST['pageid'])) {
$pm->setVariable('group_url', TYPEF_WEB_DIR . '/admin/content/groups/form?pageid=' . $_REQUEST['pageid']);
} else {
$pm->setVariable('group_url', TYPEF_WEB_DIR . '/admin/content/groups/form?plugid=' . $_REQUEST['plugid']);
}
} else {
Typeframe::Redirect('Invalid base.', $typef_app_dir, -1);
return;
}
示例6: redirect
/**
* Redirect the request to a new URL.
* @param string $message Message to display.
* @param string $url The URL where the request will be redirected.
* @param int $sec Seconds to pause (0 for instant, -1 to wait for user interaction)
* @param bool $addHeader True to add a Location header to the response
* @param int $responseCode The HTTP response code (0 to use existing code, usu. 200)
* @param string $postOverride The name of a POST variable that can override the $url parameter
*/
public function redirect($message, $url, $sec = TYPEF_DEFAULT_REDIRECT_TIME, $addHeader = false, $responseCode = 0, $postOverride = 'post_redir')
{
if ($postOverride && !empty($_POST[$postOverride])) {
// TODO: This is weird. Why isn't this value decoded already?
$url = urldecode($_POST[$postOverride]);
}
if (substr($url, 0, 7) != "http://" && substr($url, 0, 8) != "https://") {
if ($_SERVER['SERVER_PORT'] != '443') {
$url = "http://" . $_SERVER["SERVER_NAME"] . $url;
} else {
$url = "https://" . $_SERVER["SERVER_NAME"] . $url;
}
}
if ($sec == 0 || $addHeader == true) {
// Include a Location redirect in the HTML headers
$this->_redirectHeader = true;
} else {
$this->_redirectHeader = false;
}
$this->_redirectLocation = $url;
$this->_redirectResponseCode = $responseCode ? $responseCode : 302;
Typeframe::Pagemill()->setVariable("message", $message);
Typeframe::Pagemill()->setVariable("url", $url);
Typeframe::Pagemill()->setVariable("time", $sec);
Typeframe::SetPageTemplate('/redirect.html');
// TODO: This might be a bad place for this line. Technically, I'm not sure that
// HTMLTag should be a required part of the kernel.
//Pagemill_Tag_Stylesheets::AddStylesheet('/redirect.css');
}
示例7: Exception
}
$mail->Subject = $mailform['subject'] ? $mailform['subject'] : 'Mailform Submission';
$mail->Body = $body;
if (!$mail->Send()) {
throw new Exception($mail->ErrorInfo);
}
}
$pm->setVariable('response', $mailform['response']);
$pm->setVariable('referer', @$_SERVER['HTTP_REFERER']);
if ($mailform['redirect']) {
if (requestIsAjax()) {
header('Content-Type: text/json');
$response = array('status' => 'ok', 'redirect' => $pm->data()->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($mailform['redirect'])));
echo json_encode($response);
exit;
} else {
Typeframe::Redirect('Submission received.', $pm->data()->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($mailform['redirect'])));
}
} else {
Typeframe::SetPageTemplate('/mailform/completed.html');
}
} else {
$pm->setVariable('errors', $formHandler->errors());
if (requestIsAjax()) {
header('Content-Type: text/json');
$response = array('status' => 'error', 'errors' => $formHandler->errors());
echo json_encode($response);
exit;
}
}
}
示例8: foreach
<?php
//include_once(TYPEF_SOURCE_DIR . '/classes/sitemap.class.php');
//$sm = new Sitemap();
//$pm->setVariable('pages', $sm->getAsArray());
$host = $_SERVER['SERVER_NAME'];
foreach (Typeframe::Registry()->pages() as $page) {
if ($page->pageid()) {
$pm->addLoop('pages', array('page' => 'https://' . $host . $page->uri(), 'uri' => $page->uri(), 'name' => $page->title(), 'application' => $page->application()->name()));
if (file_exists(TYPEF_SOURCE_DIR . '/scripts' . $page->application()->base() . '/sitemap.php')) {
include TYPEF_SOURCE_DIR . '/scripts' . $page->application()->base() . '/sitemap.php';
}
}
}
Typeframe::SetPageTemplate('/sitemap.html');
示例9:
<?php
Typeframe::SetPageTemplate('/mailform/validator.js');
header('Content-Type: text/javascript; charset=utf-8');
示例10: Pagemill
// create an entry in the user confirmation table
$user_confirm = Model_UserConfirm::Create();
$user_confirm->set('confirmkey', $confirmkey);
$user_confirm->set('userid', $userid);
$user_confirm->set('expire', $expire);
$user_confirm->save();
// construct e-mail body
$mm = new Pagemill($pm->root()->fork());
$mm->setVariable('username', $user->get('username'));
$mm->setVariable('confirmurl', sprintf('http://%s%s/confirm?userid=%d&confirmkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $confirmkey));
$body = str_replace('&', '&', $mm->writeString('<pm:include template="/users/register/confirmation.eml" />', true));
// e-mail the user so they can confirm their registration
$mailer = new Mailer();
$mailer->Configure();
$mailer->IsHTML(true);
$mailer->AddAddress($_POST['email']);
$mailer->Subject = 'Your Account Confirmation from ' . TYPEF_TITLE;
$mailer->Body = $body;
$mailer->Send();
} else {
// if confirmation is not required, log the user in immediately
Typeframe::User()->login($_POST['username'], $_POST['password']);
Typeframe::Redirect('Registration complete. Welcome!', TYPEF_WEB_DIR . '/', 1);
return;
}
// registratino is complete
Typeframe::SetPageTemplate('/users/register/complete.html');
}
}
// populate form fields
$pm->setVariable('fields', $form->fields());
示例11: header
<?php
/**
* Typeframe News application
*
* client-side rss controller
*/
// set the appropriate content type
header('Content-Type: application/rss+xml');
// set the template
Typeframe::SetPageTemplate('/news/rss.xml');
// add title, description, link, and lastbuild date to template
$pm->setVariable('title', TYPEF_TITLE);
$pm->setVariable('description', TYPEF_TITLE . ' News');
$pm->setVariable('link', 'http://' . $_SERVER['HTTP_HOST']);
$pm->setVariable('lastbuild', date('D, d M Y H:i:s T'));
// get articles; limit to published if non-admin
$articles = new Model_News_Article();
$articles->where('pubdate <= ?', Typeframe::Now());
$articles->limit('0, 10');
// add articles to template
$pm->setVariable('items', $articles);
示例12:
<?php
$db = Typeframe::Database();
$pm = Typeframe::Pagemill();
Typeframe::SetPageTemplate('/index.html');
示例13:
<?php
Typeframe::SetPageTemplate('/admin/users/update.html');
$usergroups = new Model_Usergroup();
$pm->setVariable('usergroups', $usergroups);
if (defined('TYPEF_HOST')) {
$sites = new Model_Site();
$pm->setVariable('sites', $sites);
}
示例14: unlink
<?php
$db = Typeframe::Database();
$pm = Typeframe::Pagemill();
Typeframe::SetPageTemplate('.');
if (isset($_POST['cmd']) && $_POST['cmd'] == 'backup-delete') {
$rs = $db->prepare('SELECT * FROM #__backup WHERE backupid = ?');
if ($row = $rs->execute_fetch($_REQUEST['backupid'])) {
if (file_exists(TYPEF_DIR . '/files/secure/backups/' . $row['filename'])) {
unlink(TYPEF_DIR . '/files/secure/backups/' . $row['filename']);
}
$rs = $db->prepare('DELETE FROM #__backup WHERE backupid = ?');
$rs->execute($_REQUEST['backupid']);
Typeframe::Redirect('Backup deleted.', Typeframe::CurrentPage()->applicationUri());
return;
} else {
Typeframe::Redirect('Invalid backup specified.', Typeframe::CurrentPage()->applicationUri(), 1);
return;
}
}
$rs = $db->prepare('SELECT * FROM #__backup ORDER BY datecreated DESC');
$rs->execute();
while ($row = $rs->fetch_array()) {
$pm->addLoop('backups', $row);
}
示例15:
<?php
/**
* User logout controller.
*
* Provides a logout form and logs the user out.
*
* @package User
*/
// process form
if ('POST' == $_SERVER['REQUEST_METHOD']) {
Typeframe::User()->logout();
Typeframe::Redirect('Logout complete.', TYPEF_WEB_DIR . '/');
return;
}
// set template (controller is at root, but template lives in users directory
Typeframe::SetPageTemplate('/users/logout.html');