本文整理汇总了PHP中Template::assign_by_ref方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::assign_by_ref方法的具体用法?PHP Template::assign_by_ref怎么用?PHP Template::assign_by_ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template::assign_by_ref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BulkMail
function BulkMail()
{
global $C, $DB;
$message = GetValue('bulk_email');
$t = new Template();
$t->assign_by_ref('config', $C);
$result = $DB->Query('SELECT * FROM `tlx_accounts` JOIN `tlx_account_fields` USING (`username`)');
while ($account = $DB->NextRow($result)) {
if ($account['status'] == STATUS_ACTIVE) {
$t->assign_by_ref('account', $account);
SendMail($account['email'], $message, $t, FALSE);
}
}
$DB->Free($result);
DeleteValue('bulk_email');
}
示例2: txShReportAdd
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// If you are using this script on one of the domains you have defined in the
// Manage Domains interface, uncomment the following line and set the directory
// path to your TGPX Server Edition installation
//chdir('/full/path/to/tgpxse/install');
require_once 'includes/common.php';
require_once "{$GLOBALS['BASE_DIR']}/includes/template.class.php";
require_once "{$GLOBALS['BASE_DIR']}/includes/mysql.class.php";
require_once "{$GLOBALS['BASE_DIR']}/includes/validator.class.php";
SetupRequest();
$t = new Template();
$t->assign_by_ref('config', $C);
$DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']);
$DB->Connect();
$domain = $DB->Row('SELECT * FROM `tx_domains` WHERE `domain`=?', array(preg_replace('~^www\\.~i', '', strtolower($_SERVER['HTTP_HOST']))));
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
txReportAdd();
} else {
txShReportAdd();
}
$DB->Disconnect();
function txShReportAdd($errors = null)
{
global $DB, $C, $L, $t, $domain;
$gallery = $DB->Row('SELECT * FROM `tx_galleries` WHERE `gallery_id`=?', array($_REQUEST['id']));
if (!$gallery) {
$t->assign('error', $L['BAD_GALLERY_ID']);
示例3: DisplayCategory
function DisplayCategory()
{
global $C, $DB;
$t = new Template();
$t->caching = TRUE;
$t->cache_lifetime = $C['cache_category'];
$custom_sort = isset($_GET['s']);
$from_path = FALSE;
$template = 'directory-category.tpl';
if ($custom_sort) {
$t->caching = FALSE;
}
if ($C['mod_rewrite'] && !is_numeric($_GET['c'])) {
$_GET['c'] = preg_replace('~^/|/$~', '', $_GET['c']);
if (preg_match("~(.*?)/(\\d+)\\.{$C['extension']}\$~", $_GET['c'], $matches)) {
$_GET['c'] = $matches[1];
$_GET['p'] = $matches[2];
}
$from_path = TRUE;
}
$_GET['p'] = isset($_GET['p']) ? $_GET['p'] : 1;
$cache_id = md5($_GET['c'] . '-' . $_GET['p']);
if ($custom_sort || $C['custom_categories'] || !$t->is_cached($template, $cache_id)) {
$DB->Connect();
// Get the category
if ($from_path) {
$category = $DB->Row('SELECT * FROM lx_categories WHERE path_hash=?', array(md5($_GET['c'])));
} else {
$category = $DB->Row('SELECT * FROM lx_categories WHERE category_id=?', array($_GET['c']));
}
if ($category['template']) {
$template = $category['template'];
}
if (!$category) {
require_once 'includes/language.php';
$t->caching = FALSE;
$t->assign('error', $L['NO_SUCH_PAGE']);
$t->assign_by_ref('config', $C);
$t->display('error-nice.tpl');
return;
}
}
if ($custom_sort || !$t->is_cached($template, $cache_id)) {
$category['path_parts'] = unserialize($category['path_parts']);
$t->assign_by_ref('this_category', $category);
$t->assign_by_ref('config', $C);
$t->assign('page_num', $_GET['p']);
$t->assign('get_c', $_GET['c']);
$t->assign('template', $template);
$t->assign_by_ref('request', $_GET);
}
$t->display($template, $cache_id);
}
示例4: txGalleryReject
function txGalleryReject()
{
global $DB, $json, $C;
VerifyPrivileges(P_GALLERY_MODIFY, TRUE);
$reject_cache = array();
$t = new Template();
$t->assign_by_ref('config', $C);
$result = GetWhichGalleries();
$amount = 0;
while ($gallery = $DB->NextRow($result)) {
if ($gallery['status'] == 'pending' || $gallery['status'] == 'unconfirmed') {
DeleteGallery($gallery['gallery_id'], $gallery);
// Send rejection e-mail if selected
if (is_numeric($_REQUEST['multi_email'])) {
if (!isset($reject_cache[$_REQUEST['multi_email']])) {
$rejection = $DB->Row('SELECT * FROM `tx_rejections` WHERE `email_id`=?', array($_REQUEST['multi_email']));
$reject_cache[$_REQUEST['multi_email']] = $rejection;
}
$t->assign_by_ref('gallery', $gallery);
SendMail($gallery['email'], $reject_cache[$_REQUEST['multi_email']]['plain'], $t, FALSE);
}
$amount++;
}
}
$DB->Free($result);
// Update administrator count of galleries rejected
$DB->Update('UPDATE `tx_administrators` SET `rejected`=`rejected`+? WHERE `username`=?', array($amount, $_SERVER['REMOTE_USER']));
echo $json->encode(array('status' => JSON_SUCCESS, 'message' => "{$amount} galler" . ($amount == 1 ? 'y has' : 'ies have') . " been rejected"));
}
示例5: tlxAccountProcess
function tlxAccountProcess()
{
global $DB, $json, $C, $L;
VerifyPrivileges(P_ACCOUNT_MODIFY, TRUE);
if (!is_array($_REQUEST['username'])) {
$_REQUEST['username'] = array($_REQUEST['username']);
}
$t = new Template();
$t->assign_by_ref('config', $C);
if ($_REQUEST['w'] == 'reject') {
$action = 'rejected';
$rejections =& $DB->FetchAll('SELECT * FROM `tlx_rejections`', null, 'email_id');
foreach ($_REQUEST['username'] as $username) {
$account = $DB->Row('SELECT * FROM `tlx_accounts` WHERE `username`=?', array($username));
DeleteAccount($account['username'], $account);
// Send rejection e-mail
if (isset($rejections[$_REQUEST['reject'][$username]])) {
$t->assign_by_ref('account', $account);
SendMail($account['email'], $rejections[$_REQUEST['reject'][$username]]['compiled'], $t, FALSE);
}
}
} else {
if ($_REQUEST['w'] == 'approve') {
$action = 'approved';
foreach ($_REQUEST['username'] as $username) {
$DB->Update('UPDATE `tlx_accounts` SET `status`=?,`date_activated`=? WHERE `username`=?', array(STATUS_ACTIVE, MYSQL_NOW, $username));
$account = $DB->Row('SELECT * FROM `tlx_accounts` WHERE `username`=?', array($username));
if ($C['email_new_accounts']) {
$account['password'] = $L['ENCRYPTED_PASSWORD'];
$t->assign_by_ref('account', $account);
SendMail($account['email'], 'email-account-added.tpl', $t);
}
}
}
}
echo $json->encode(array('status' => JSON_SUCCESS));
}
示例6: DailyPartnerMaintenance
function DailyPartnerMaintenance()
{
global $DB, $C;
$args = ParseCommandLine();
// Remove inactive partner accounts
if (isset($args['remove-inactive']) && is_numeric($args['remove-inactive'])) {
$min_last_submit = gmdate(DF_DATETIME, TimeWithTz() - $args['remove-inactive'] * 86400);
$result = $DB->Query('SELECT * FROM `tx_partners` WHERE `date_last_submit` <= ? OR (`date_last_submit` IS NULL AND `date_added` <= ?)', array($min_last_submit, $min_last_submit));
while ($partner = $DB->NextRow($result)) {
DeletePartner($partner['username'], $partner);
}
$DB->Free($result);
}
// Send an e-mail message to partner accounts that are inactive
if (isset($args['email-inactive']) && is_numeric($args['email-inactive'])) {
// Prepare the template
$t = new Template();
$t->assign_by_ref('config', $C);
$t->assign('inactive', $args['email-inactive']);
// Determine the time range to select
$start = gmdate(DF_DATE, strtotime('-' . $args['email-inactive'] . ' day', TimeWithTz())) . ' 00:00:00';
$end = gmdate(DF_DATE, strtotime('-' . $args['email-inactive'] . ' day', TimeWithTz())) . ' 23:59:59';
// Find matching partners
$result = $DB->Query('SELECT * FROM `tx_partners` WHERE `date_last_submit` BETWEEN ? AND ? OR (`date_last_submit` IS NULL AND `date_added` BETWEEN ? AND ?)', array($start, $end, $start, $end));
while ($partner = $DB->NextRow($result)) {
$t->assign_by_ref('partner', $partner);
SendMail($partner['email'], 'email-partner-inactive.tpl', $t);
}
$DB->Free($result);
}
// Send an e-mail message to partner accounts that are expiring soon
if (isset($args['email-expiring']) && is_numeric($args['email-expiring'])) {
// Prepare the template
$t = new Template();
$t->assign_by_ref('config', $C);
// Determine the time range to select
$start = gmdate(DF_DATE, strtotime('+' . $args['email-expiring'] . ' day', TimeWithTz())) . ' 00:00:00';
$end = gmdate(DF_DATE, strtotime('+' . $args['email-expiring'] . ' day', TimeWithTz())) . ' 23:59:59';
// Find matching partners
$result = $DB->Query('SELECT * FROM `tx_partners` WHERE `date_end` BETWEEN ? AND ?', array($start, $end));
while ($partner = $DB->NextRow($result)) {
$partner['date_end'] = strtotime($partner['date_end']);
$t->assign_by_ref('partner', $partner);
SendMail($partner['email'], 'email-partner-expiring.tpl', $t);
}
$DB->Free($result);
}
}
示例7: lxMailUser
function lxMailUser()
{
global $DB, $C, $t;
VerifyPrivileges(P_USER);
UnixFormat($_REQUEST['plain']);
UnixFormat($_REQUEST['html']);
$message = "=>[subject]\n" . $_REQUEST['subject'] . "\n" . "=>[plain]\n" . trim($_REQUEST['plain']) . "\n" . "=>[html]\n" . trim($_REQUEST['html']);
$t = new Template();
$t->assign_by_ref('config', $C);
foreach (explode(',', $_REQUEST['to']) as $to_account) {
$account = $DB->Row('SELECT * FROM lx_users JOIN lx_user_fields USING (username) WHERE lx_users.username=?', array($to_account));
if ($account) {
$t->assign_by_ref('account', $account);
SendMail($account['email'], $message, $t, FALSE);
}
}
$message = 'The selected user accounts have been e-mailed';
include_once 'includes/message.php';
}
示例8: DB
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
require_once 'includes/common.php';
require_once "{$GLOBALS['BASE_DIR']}/includes/template.class.php";
require_once "{$GLOBALS['BASE_DIR']}/includes/mysql.class.php";
require_once "{$GLOBALS['BASE_DIR']}/includes/validator.class.php";
SetupRequest();
$DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']);
$DB->Connect();
$t = new Template();
$t->assign_by_ref('config', $C);
$v = new Validator();
$v->Register($_REQUEST['email'], V_EMAIL, $L['INVALID_EMAIL']);
$v->Register($_REQUEST['name'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['NAME']}");
$v->Register($_REQUEST['comment'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['COMMENT']}");
$v->Register($_REQUEST['comment'], V_LENGTH, sprintf($L['COMMENT_LENGTH'], $C['min_comment_length'], $C['max_comment_length']), "{$C['min_comment_length']},{$C['max_comment_length']}");
// Verify captcha code
if ($C['comments_captcha']) {
VerifyCaptcha($v, 'linkxcaptcha_comment');
}
$account = ValidUserLogin();
if ($C['user_for_comments']) {
if ($account === FALSE || $account['status'] != 'active') {
if ($account === FALSE) {
$v->SetError($L['INVALID_LOGIN']);
} else {
示例9: Template
<?php
require LIBPATH . '/system/Template.php';
$tpl = new Template();
global $php;
$tpl->assign_by_ref('php_genv', $php->genv);
$tpl->assign_by_ref('php', $php->env);
if (defined('TPL_DIR')) {
$tpl->template_dir = TPL_DIR;
} elseif (is_dir(Swoole::$app_path . '/templates')) {
$tpl->template_dir = Swoole::$app_path . '/templates';
} else {
$tpl->template_dir = WEBPATH . "/templates";
}
if (DEBUG == 'on') {
$tpl->compile_check = true;
} else {
$tpl->compile_check = false;
}
示例10: assign_by_ref
/**
* Assign var by reference
* @param string $tpl_var
* @param mixed $value
* @return View
*/
public function assign_by_ref($tpl_var, &$value)
{
$this->tpl->assign_by_ref($tpl_var, $value);
return $this;
}
示例11: astripslashes
astripslashes($_POST);
}
$_POST['s'] = trim($_POST['s']);
$page = !empty($_POST['p']) ? $_POST['p'] : 1;
$per_page = !empty($_POST['pp']) ? $_POST['pp'] : 20;
$too_short = strlen($_POST['s']) < 4;
$search_id = sha1("{$_POST['s']}-{$_POST['c']}-{$page}");
$t = new Template();
$t->caching = TRUE;
$t->cache_lifetime = 3600;
$t->assign('search_term', $_POST['s']);
$t->assign('search_category', $_POST['c']);
$t->assign('page', $page);
$t->assign('per_page', $per_page);
$t->assign('search_too_short', $too_short);
$t->assign_by_ref('config', $C);
if (!$too_short && !$t->is_cached('search-results.tpl', $search_id)) {
$DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']);
$DB->Connect();
$accounts = array();
$result = $DB->QueryWithPagination('SELECT * FROM `tlx_accounts` JOIN `tlx_account_hourly_stats` USING (`username`) WHERE ' . 'MATCH(`title`,`description`,`keywords`) AGAINST(? IN BOOLEAN MODE) AND ' . '`status`=? AND ' . '`disabled`=0 ' . (!empty($_POST['c']) && is_numeric($_POST['c']) ? ' AND `category_id`=' . $DB->Escape($_POST['c']) . ' ' : '') . 'ORDER BY `unique_in_total` DESC', array($_POST['s'], 'active'), $page, $per_page);
if ($result['result']) {
while ($account = $DB->NextRow($result['result'])) {
$accounts[] = array_merge($account, $DB->Row('SELECT * FROM `tlx_account_fields` WHERE `username`=?', array($account['username'])));
}
$DB->Free($result['result']);
unset($result['result']);
}
$categories = $DB->FetchAll('SELECT * FROM `tlx_categories` ORDER BY `name`');
if (!$categories) {
$categories = array();
示例12: Template
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
require_once 'includes/common.php';
require_once "{$GLOBALS['BASE_DIR']}/includes/template.class.php";
require_once "{$GLOBALS['BASE_DIR']}/includes/mysql.class.php";
require_once "{$GLOBALS['BASE_DIR']}/includes/validator.class.php";
SetupRequest();
$t = new Template();
$t->assign_by_ref('config', $C);
$DB = new DB($C['db_hostname'], $C['db_username'], $C['db_password'], $C['db_name']);
$DB->Connect();
$account = $DB->Row('SELECT * FROM `tlx_accounts` WHERE `username`=?', array($_REQUEST['id']));
if ($account) {
$page = isset($_REQUEST['p']) ? $_REQUEST['p'] : 1;
$per_page = isset($_REQUEST['pp']) ? $_REQUEST['pp'] : 20;
$result = $DB->QueryWithPagination('SELECT * FROM `tlx_account_comments` WHERE `status`=? AND `username`=? ORDER BY `date_submitted` DESC', array('approved', $_REQUEST['id']), $page, $per_page);
if ($result['result']) {
while ($comment = $DB->NextRow($result['result'])) {
$comment['date'] = strtotime($comment['date_submitted']);
$comments[] = $comment;
}
$DB->Free($result['result']);
unset($result['result']);
}
示例13: txAdministratorMail
function txAdministratorMail()
{
global $DB, $C, $t;
VerifyAdministrator();
$message = PrepareMessage();
$t = new Template();
$t->assign_by_ref('config', $C);
foreach (explode(',', $_REQUEST['to']) as $to_account) {
$account = $DB->Row('SELECT * FROM `tx_administrators` WHERE `username`=?', array($to_account));
if ($account) {
$t->assign_by_ref('account', $account);
SendMail($account['email'], $message, $t, FALSE);
}
}
$message = 'The selected administrator accounts have been e-mailed';
include_once 'includes/message.php';
}
示例14: array
}
}
$temp_categories = array();
foreach (explode(' ', $gallery['categories']) as $category_tag) {
if ($categories[$category_tag]) {
$temp_categories[] = $categories[$category_tag];
}
}
$gallery['categories'] = $temp_categories;
$gallery['category'] = $gallery['categories'][0]['name'];
$galleries[] = $gallery;
}
$DB->Free($result['result']);
unset($result['result']);
}
$t->assign_by_ref('search_categories', $categories);
$t->assign_by_ref('pagination', $result);
$t->assign_by_ref('results', $galleries);
}
if (!$too_short && $page == 1 && $C['log_searches']) {
if ($_COOKIE['txsearch'] != $_GET['s']) {
logsearch();
}
setcookie('txsearch', $_GET['s'], time() + 86400, '/', $C['cookie_domain']);
}
$t->assign_by_ref('config', $C);
$t->assign('search_term', $_GET['s']);
$t->assign('search_category', $_GET['c']);
$t->assign('search_format', $_GET['f']);
$t->assign('search_too_short', $too_short);
$t->assign('page', $page);
示例15: lxNewUser
/**
* Process new user accounts (approve/reject)
*/
function lxNewUser()
{
global $json, $DB, $C;
$t = new Template();
$t->assign_by_ref('config', $C);
VerifyPrivileges(P_USER_MODIFY, TRUE);
if (!is_array($_REQUEST['username'])) {
$_REQUEST['username'] = array($_REQUEST['username']);
}
foreach ($_REQUEST['username'] as $username) {
$account = $DB->Row('SELECT * FROM lx_users JOIN lx_user_fields USING (username) WHERE lx_users.username=?', array($username));
$t->assign_by_ref('account', $account);
if ($_REQUEST['w'] == 'approve') {
$account['status'] = 'active';
$DB->Update('UPDATE lx_users SET status=? WHERE username=?', array('active', $username));
// Send approval e-mail, if selected
if ($_REQUEST['email'] == 'approval') {
SendMail($account['email'], 'email-account-added.tpl', $t);
}
} else {
if ($_REQUEST['w'] == 'reject') {
// Remove this user's links
$result = $DB->Query('SELECT * FROM lx_links WHERE username=?', array($username));
while ($link = $DB->NextRow($result)) {
DeleteLink($link['link_id'], TRUE, $link);
}
$DB->Free($result);
// Remove this user's comments
$DB->Update('DELETE FROM lx_link_comments WHERE username=?', array($username));
// Remove this user
$DB->Update('DELETE FROM lx_user_fields WHERE username=?', array($username));
$DB->Update('DELETE FROM lx_user_confirms WHERE username=?', array($username));
$DB->Update('DELETE FROM lx_users WHERE username=?', array($username));
// Send rejection e-mail, if selected
if (!empty($_REQUEST['email']) && $_REQUEST['email'] != 'approval') {
$rejection = $DB->Row('SELECT * FROM lx_rejections WHERE email_id=?', array($_REQUEST['email']));
if ($rejection) {
SendMail($account['email'], $rejection['plain'], $t, FALSE);
}
}
}
}
}
echo $json->encode(array('status' => JSON_SUCCESS));
}