本文整理汇总了PHP中template::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP template::parse方法的具体用法?PHP template::parse怎么用?PHP template::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类template
的用法示例。
在下文中一共展示了template::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dok_box_ranked
function dok_box_ranked($display_module, $theme_path)
{
if (DOK_USE_CACHE) {
$fname = dok_c_box_filename('ranked', 'ignored');
$cache = dok_c_get($fname);
if ($cache) {
return $cache;
}
}
$res = mysql_query('select name, id from ' . dok_tn('song') . ' order by hits desc limit 10');
echo mysql_error();
if (!mysql_numrows($res)) {
return;
}
$t = new template($theme_path);
$t->set_file('page', 'box_default.tpl');
$t->set_var('BOXTITLE', MSG_TITLE_BOX_RANKED_SONG);
$t->set_block('page', 'boxlink', 'boxlinktag');
$t->set_var('boxlinktag', '');
if (!mysql_numrows($res)) {
$t->set_var('BOXCONTENT', '');
}
while ($row = mysql_fetch_array($res)) {
$t->set_var('LINK', $_SERVER['PHP_SELF'] . '?display=view_song&id=' . $row['id']);
$t->set_var('LABEL', $row['name']);
$t->parse('BOXCONTENT', 'boxlink', 'true');
}
$html = $t->parse('out', 'page');
if (DOK_USE_CACHE) {
dok_c_write($fname, $html);
}
return $html;
}
示例2: dok_list_users
function dok_list_users($VARS, $up, $theme_path)
{
$t = new template($theme_path);
$t->set_file('page', 'user_list.tpl');
$t->set_block('page', 'user', 'user_block');
$t->set_block('page', 'next_page', 'next_page_block');
if (!isset($VARS['alpha'])) {
$VARS['alpha'] = '-';
}
if (!strlen($VARS['offset']) || $VARS['offset'] < 0) {
$VARS['offset'] = '0';
}
$VARS['alpha'] = mysql_real_escape_string($VARS['alpha']);
$query = 'select id, name, editor, admin, disabled, creation, last_login from ' . dok_tn('user') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\' order by name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP;
$res = dok_oquery($query);
if ($res->numrows()) {
//$ids = $res->fetch_col_array('id');
//$n_res = dok_oquery('select album_id, count(*) as c from '.dok_tn('rel_song_album').' where album_id in('.implode(',',$ids).') group by album_id');
//$n_array = $n_res->fetch_col_array('c','album_id');
while ($user = $res->fetch_array()) {
if ($user['admin']) {
$admin = MSG_YES;
} else {
$admin = MSG_NO;
}
if ($user['editor']) {
$editor = MSG_YES;
} else {
$editor = MSG_NO;
}
if ($user['disabled']) {
$disabled = MSG_YES;
} else {
$disabled = MSG_NO;
}
if ($user['last_login'] == 0) {
$last_login = MSG_USER_NEVER_LOGGED;
} else {
$last_login = date($THEME_DATE, $user['last_login']);
}
$t->set_var('USER_LINK', $_SERVER['PHP_SELF'] . '?display=view_user&id=' . $user['id']);
$t->set_var(array('USER_NAME' => $user['name'], 'USER_DB_CREATION' => date($THEME_DATE, $user['creation']), 'USER_LAST_LOGIN' => $last_login, 'USER_ADMIN' => $admin, 'USER_EDITOR' => $editor, 'USER_DISABLED' => $disabled));
$t->parse('user_block', 'user', 'true');
}
$res = mysql_query('select count(*) as c from ' . dok_tn('user') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\'');
$total = mysql_result($res, 0, 'c');
if ($total > $VARS['offset'] + DOK_LIST_EPP) {
$t->set_var('NEXT_PAGE_LINK', $_SERVER['PHP_SELF'] . '?display=list_users&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP));
$t->parse('next_page_block', 'next_page');
} else {
$t->set_var('next_page_block', '');
}
} else {
$t->set_var('user_block', MSG_NO_USER);
$t->set_var('next_page_block', '');
}
return array($t, MSG_TITLE_LIST_USER);
}
示例3: index
/**
* Carga de mapa para emergencia
* @throws Exception
*/
public function index()
{
$this->load->helper(array("modulo/visor/visor", "modulo/marea_roja/permiso"));
$params = $this->uri->uri_to_assoc();
$emergencia = $this->_emergencia_model->getById($params["id"]);
$this->load->model('Permiso_Model', 'PermisoModel');
$this->load->model('Modulo_Model', 'ModuloModel');
if (!is_null($emergencia)) {
$this->layout_assets->addMapa();
//$this->layout_assets->addDatatable();
$this->layout_assets->addJs("mapa-visor.js");
$this->layout_assets->addJs("modulo/mapa/formulario.js");
$this->layout_assets->addJs("modulo/evento/form/nuevo.js");
$this->layout_assets->addJs("modulo/evento/form/editar.js");
$this->layout_assets->addJs("library/ckeditor-4.5.7/ckeditor.js");
$regiones_emergencia = $this->_emergencia_model->listarRegionesPorEmergencia($params["id"]);
$region_emergencia = $regiones_emergencia[0]['reg_ia_id'];
$regiones_usuario = explode(",", $this->session->userdata("session_regiones"));
$data = array("id" => $params["id"], "region_emergencia" => $region_emergencia, "regiones_usuario" => $regiones_usuario);
$this->layout_assets->addEditorTexto();
$this->template->parse("default", "pages/mapa/index", $data);
} else {
throw new Exception(__METHOD__ . " - La emergencia no existe");
}
}
示例4: dok_view_album
function dok_view_album($VARS, $update_module, $tpl_path)
{
global $THEME_DATE, $ARTIST_SONG_LINKS, $USER;
if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) {
$t = dok_error_template(MSG_ERR_ALBUM_DISPLAY);
return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, ''));
}
$res = mysql_query('select name, creation from ' . dok_tn('album') . ' where id = ' . $VARS['id']);
if (!mysql_numrows($res)) {
$t = dok_error_template(MSG_ERR_ALBUM_DISPLAY);
return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, ''));
}
$row = mysql_fetch_assoc($res);
$t = new template($tpl_path);
$t->set_file('page', 'album_display.tpl');
$t->set_block('page', 'if_albumeditor', 'editor_block');
$t->set_block('page', 'album_songs', 'songs_block');
$t->set_var(array('ALBUM_NAME' => $row['name'], 'ALBUM_DB_CREATION' => date($THEME_DATE, $row['creation'])));
if (DOK_ENABLE_USER && !$USER->editor && !$USER->admin) {
$t->set_var('editor_block', '');
} else {
$t->set_var('ALBUM_EDIT_LINK', $_SERVER['PHP_SELF'] . '?display=edit_album&id=' . $VARS['id']);
$t->parse('editor_block', 'if_albumeditor');
}
$query = 'select s.id, s.name, s.creation, s.length, s.release, s.comment, r.track from ' . dok_tn('rel_song_album') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where r.album_id = ' . $VARS['id'] . ' order by r.track';
$songs = dok_oquery($query);
$album_length = 0;
if (!$songs->numrows()) {
$t->set_var('songs_block', MSG_NO_SONG);
} else {
$pager_data = array('related' => 'album', 'related_id' => $VARS['id']);
while ($song = $songs->fetch_array()) {
$song_data = dok_song_format($song, $pager_data);
$song_data['SONG_ARTIST'] = preg_replace('/^' . $ARTIST_SONG_LINKS[0] . '/', '', $song_data['SONG_ARTIST']);
$t->set_var($song_data);
$t->set_var('SONG_TRACK', $song['track']);
$t->parse('songs_block', 'album_songs', 'true');
$album_length += $song['length'];
}
}
$t->set_var('ALBUM_LENGTH', dok_sec2str($album_length));
$t->set_var('ALBUM_SONGS', $songs->numrows());
return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, $row['name']));
}
示例5: render_cc_item
/**
* Renders an entry (icon) for the "Command and Control" center
*
* @param template $template template to use
* @param string $url URL the entry links to
* @param string $image URL of the icon
* @param string $label text to use under the icon
* @return void
*
*/
function render_cc_item(&$template, $url = '', $image = '', $label = '')
{
if (!empty($url)) {
$template->set_var('page_url', $url);
$template->set_var('page_image', $image);
$template->set_var('option_label', $label);
$template->set_var('cell_width', (int) (100 / ICONS_PER_ROW) . '%');
return $template->parse('cc_main_options', 'ccitem', false);
}
return '';
}
示例6: dok_ask_sound_artist
function dok_ask_sound_artist($VARS, $update, $theme_path)
{
if (!is_array($VARS['soundex']) || !sizeof($VARS['soundex'])) {
$t = dok_error_template(MSG_ERR_ARTIST_NOT_FOUND);
return array($t, MSG_TITLE_SOUNDEX_TEST);
}
$t = new template($theme_path);
$t->set_file('page', 'artist_soundex.tpl');
$t->set_block('page', 'artists', 'artists_block');
$t->set_var('NEW_ARTIST_NAME', $VARS['name']);
$t->set_var('ARTIST_CREATE_FORM', '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"><input type=hidden name="update" value="create_artist"><input type=hidden name="soundex_checked" value="1"><input type=hidden name="name" value="' . str_replace('"', '"', $VARS['name']) . '">');
foreach ($VARS['soundex'] as $id => $name) {
$t->set_var('ARTIST_NAME', $name);
$t->parse('artists_block', 'artists', 'true');
}
return array($t, MSG_TITLE_SOUNDEX_TEST);
}
示例7: dok_view_user
function dok_view_user($VARS, $update, $theme_path)
{
global $USER, $THEME_DATE;
if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) {
$t = dok_error_template(MSG_ERR_USER_DISPLAY);
return array($t, sprintf(MSG_TITLE_DISLAY_USER, ''));
}
$res = mysql_query('select * from ' . dok_tn('user') . ' where id = ' . $VARS['id']);
if (!mysql_numrows($res)) {
$t = dok_error_template(MSG_ERR_USER_DISPLAY);
return array($t, sprintf(MSG_TITLE_DISPLAY_USER, ''));
}
$user = mysql_fetch_array($res);
$t = new template($theme_path);
$t->set_file('page', 'user_display.tpl');
$t->set_block('page', 'if_could_edit', 'if_could_edit_block');
if (DOK_ENABLE_USER && ($USER->admin || $USER->id == $user['id']) || !DOK_ENABLE_USER) {
$t->parse('if_could_edit_block', 'if_could_edit');
} else {
$t->set_var('if_could_edit_block', '');
}
if ($user['admin']) {
$admin = MSG_YES;
} else {
$admin = MSG_NO;
}
if ($user['editor']) {
$editor = MSG_YES;
} else {
$editor = MSG_NO;
}
if ($user['disabled']) {
$disabled = MSG_YES;
} else {
$disabled = MSG_NO;
}
if ($user['last_login'] == 0) {
$last_login = MSG_USER_NEVER_LOGGED;
} else {
$last_login = date($THEME_DATE, $user['last_login']);
}
$t->set_var(array('USER_NAME' => $user['name'], 'USER_DB_CREATION' => date($THEME_DATE, $user['creation']), 'USER_LAST_LOGIN' => $last_login, 'USER_ADMIN' => $admin, 'USER_EDITOR' => $editor, 'USER_DISABLED' => $disabled, 'USER_EDIT_LINK' => $_SERVER['PHP_SELF'] . '?display=edit_user&id=' . $user['id']));
return array($t, sprintf(MSG_TITLE_DISPLAY_USER, $user['name']));
}
示例8: dok_edit_user
function dok_edit_user($VARS, $update_module, $theme_path)
{
global $USER;
if (!$VARS['id'] || !is_numeric($VARS['id']) || $VARS['id'] < 1) {
$t = dok_error_template(MSG_ERR_USER_NOT_FOUND);
return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN));
}
$res = mysql_query('select * from ' . dok_tn('user') . ' where id = ' . $VARS['id']);
if (!mysql_numrows($res)) {
$t = dok_error_template(MSG_ERR_USER_NOT_FOUND);
return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN));
}
$row = mysql_fetch_array($res);
if (DOK_ENABLE_USER && (!$USER->admin && $USER->id != $row['id'])) {
$t = dok_error_template(MSG_ERR_USER_EDITION_NOT_ALLOWED);
return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN));
}
$t = new template($theme_path);
$editor_cb = '<input type="checkbox" name="editor" value="1"';
if ($row['editor']) {
$editor_cb .= ' CHECKED';
}
$editor_cb .= '>';
$admin_cb = '<input type="checkbox" name="admin" value="1"';
if ($row['admin']) {
$admin_cb .= ' CHECKED';
}
$admin_cb .= '>';
$disabled_cb = '<input type="checkbox" name="disabled" value="1"';
if ($row['disabled']) {
$disabled_cb .= ' CHECKED';
}
$disabled_cb .= '>';
$t->set_file('page', 'user_edit.tpl');
$t->set_block('page', 'if_admin', 'if_admin_block');
if (!DOK_ENABLE_USER || $USER->admin) {
$t->parse('if_admin_block', 'if_admin');
} else {
$t->set_var('if_admin_block', '');
}
$t->set_var(array('USER_ID' => $row['id'], 'USER_NAME' => $row['name'], 'USER_NAME_TF' => str_replace('"', '"', $row['name']), 'USER_EDITOR_CB' => $editor_cb, 'USER_DISABLED_CB' => $disabled_cb, 'USER_ADMIN_CB' => $admin_cb));
return array($t, sprintf(MSG_TITLE_EDIT_USER, $row['name']));
}
示例9: error
function error($errno, $errmsg, $errfile, $errline)
{
if ($errno == 2 && preg_match("/500 Internal Server Error/", $errmsg)) {
throw new Exception("Error returned from bitcoin core");
}
// Get log file to write to
if ($errno == E_WARNING || $errno == E_USER_WARNING) {
$logfile = 'warning';
} elseif ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) {
$logfile = 'notice';
} elseif ($errno == E_STRICT) {
$logfile = 'strict';
} else {
$logfile = 'error';
}
// Save to logfile
$origin = $errno == E_USER_WARNING || $errno == E_USER_NOTICE || $errno == E_USER_ERROR || $errno == E_USER_DEPRECATED ? 'USER' : 'PHP';
$logline = $origin . ' - [' . date('Y-m-d H:i:s') . '] #' . $errno . ' ' . $errmsg . ' in (' . $errfile . ':' . $errline . ')';
file_put_contents(SITE_PATH . '/data/log/' . $logfile, "{$logline}\n", FILE_APPEND);
// Return, if not displaying error template
if ($logfile != 'error') {
return;
}
// Start template
$template = new template('500');
$template->assign('errno', $errno);
$template->assign('errmsg', $errmsg);
$template->assign('errfile', $errfile);
$template->assign('errline', $errline);
// Get theme
if (preg_match("/^admin/", $_GET['route'])) {
$template->theme = 'admin';
}
// Display template
$template->parse();
exit(0);
}
示例10: dok_list_full
function dok_list_full($VARS, $up, $theme_path)
{
global $THEME_FULL_LIST_COLUMN;
$t = new template($theme_path);
$t->set_file('page', 'full_list.tpl');
$t->set_block('page', 'element_letter', 'element_letter_block');
$t->set_block('page', 'element', 'element_block');
$t->set_block('page', 'next_block', 'next_block_block');
$t->set_var('element_letter_block', '');
$t->set_var('next_block_block', '');
if (!isset($VARS['element']) || !in_array($VARS['element'], array('artist', 'song', 'album', 'user'))) {
$VARS['element'] = 'song';
}
if ($VARS['element'] == 'album') {
$msg = MSG_NO_ALBUM;
$element_name = MSG_ALBUMS;
} elseif ($VARS['element'] == 'artist') {
$msg = MSG_NO_ARTIST;
$element_name = MSG_ARTISTS;
} elseif ($VARS['element'] == 'user') {
$msg = MSG_NO_USER;
$element_name = MSG_USERS;
} else {
$msg = MSG_NO_SONG;
$element_name = MSG_SONGS;
}
$t->set_var('LIST_ELEMENT_NAME', $element_name);
$where = '';
if (($VARS['element'] == 'album' || $VARS['element'] == 'song') && isset($VARS['artist_id']) && is_numeric($VARS['artist_id']) && $VARS['artist_id'] > 0) {
$res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist_id']);
if (mysql_numrows($res)) {
$row = mysql_fetch_array($res);
$t->set_var('ARTIST_NAME', $row['name']);
$t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_artist&id=' . $VARS['artist_id']);
if ($VARS['element'] == 'song') {
$where = 'left join ' . dok_tn('rel_song_artist') . ' as r on a.id=r.song_id where r.artist_id = ' . $VARS['artist_id'];
} else {
$where = 'left join ' . dok_tn('rel_song_album') . ' as r on a.id=r.album_id left join ' . dok_tn('rel_song_artist') . ' as r2 on r.song_id=r2.song_id where r2.artist_id = ' . $VARS['artist_id'] . ' group by a.id';
}
}
} else {
$t->set_var('ARTIST_NAME', '');
$t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF']);
}
$query = 'select a.id, a.name, substring(a.name from 1 for 1) as letter from ' . dok_tn($VARS['element']) . ' as a ' . $where . ' order by a.name';
//echo $query.'<BR>';
$res = dok_oquery($query);
//echo mysql_error();
if ($res->numrows()) {
$letter = false;
$count = -1;
$div = 1;
if ($res->numrows() <= reset($THEME_FULL_LIST_COLUMN)) {
$el_per_block = $res->numrows();
$div = 1;
} elseif ($res->numrows() >= end($THEME_FULL_LIST_COLUMN)) {
$div = key($THEME_FULL_LIST_COLUMN);
$el_per_block = ceil($res->numrows() / $div);
} else {
$ak = array_keys($THEME_FULL_LIST_COLUMN);
$i = 1;
foreach ($THEME_FULL_LIST_COLUMN as $key => $val) {
if ($res->numrows() >= $val && $res->numrows() <= $THEME_FULL_LIST_COLUMN[$ak[$i]]) {
$div = $key;
$el_per_block = ceil($res->numrows() / $key);
break;
}
$i++;
}
}
$t->set_var('BLOCK_PERCENT', (int) (100 / $div));
//if ( $res->numrows() < $THEME_FULL_LIST_COLUMN[0] && $res->numrows() < $THEME_FULL_LIST_COLUMN[0]
//$el_per_block = ceil($res->numrows() /3);
while ($row = $res->fetch_array()) {
$count++;
if ($count && !($count % $el_per_block)) {
$t->parse('element_block', 'next_block', 'true');
}
if (!$letter || $letter != $row['letter']) {
$letter = $row['letter'];
$t->set_var('LIST_LETTER', strtoupper($letter));
$t->parse('element_block', 'element_letter', 'true');
}
$t->set_var('LIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_' . $VARS['element'] . '&id=' . $row['id']);
$t->set_var('LIST_NAME', $row['name']);
$t->parse('element_block', 'element', 'true');
}
} else {
$t->set_var('element_block', $msg);
}
return array($t, $element_name . MSG_TITLE_LIST_FULL);
}
示例11: print_orders
function print_orders($sourceid)
{
/*
name:
print_orders($sourceid)
returns:
0 - no error
1 - no orders to be printed
2 - template parsing error
3 - error setting orders printed
other - mysql error number
*/
$sourceid = $_SESSION['sourceid'];
debug_msg(__FILE__, __LINE__, "BEGIN PRINTING");
$query = "SELECT * FROM `orders` WHERE `sourceid`='{$sourceid}' AND `printed` IS NULL AND `suspend`='0' ORDER BY dest_id ASC, priority ASC, associated_id ASC, id ASC";
$res = common_query($query, __FILE__, __LINE__);
if (!$res) {
return mysql_errno();
}
if (!mysql_num_rows($res)) {
return ERR_ORDER_NOT_FOUND;
}
$newassociated_id = "";
$tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $sourceid);
$tpl_print = new template();
$output['orders'] = '';
$msg = "";
while ($arr = mysql_fetch_array($res)) {
$oldassociated_id = $newassociated_id;
$newassociated_id = $arr['associated_id'];
if (isset($priority)) {
$oldpriority = $priority;
} else {
$oldpriority = 0;
}
$priority = $arr['priority'];
if ($oldassociated_id != "") {
$olddestid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $oldassociated_id));
$olddest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $olddestid);
$olddestname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $olddestid);
} else {
$olddestid = 0;
}
$destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id));
$dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid);
$destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid);
$dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
if ($destid != $olddestid || $priority != $oldpriority) {
if ($destid != $olddestid && $olddestid != "") {
$tpl_print->assign("date", printer_print_date());
$tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language));
$tpl_print->assign("page_cut", printer_print_cut());
// strips the last newline that has been put
$output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
if (table_is_takeaway($sourceid)) {
$print_tpl_file = 'ticket_takeaway';
} else {
$print_tpl_file = 'ticket';
}
if ($err = $tpl_print->set_print_template_file($olddestid, $print_tpl_file)) {
return $err;
}
if ($err = $tpl_print->parse()) {
$msg = "Error in " . __FUNCTION__ . " - ";
$msg .= 'error: ' . $err . "\n";
echo nl2br($msg) . "\n";
error_msg(__FILE__, __LINE__, $msg);
return ERR_PARSING_TEMPLATE;
}
$tpl_print->restore_curly();
$msg = $tpl_print->getOutput();
$tpl_print->reset_vars();
$output['orders'] = '';
$msg = str_replace("'", "", $msg);
if ($outerr = print_line($olddestid, $msg)) {
return $outerr;
}
} elseif ($priority != $oldpriority && $oldpriority != "") {
$tpl_print->assign("date", printer_print_date());
$tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language));
$tpl_print->assign("page_cut", printer_print_cut());
// strips the last newline that has been put
$output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
if (table_is_takeaway($sourceid)) {
$print_tpl_file = 'ticket_takeaway';
} else {
$print_tpl_file = 'ticket';
}
if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) {
return $err;
}
if ($err = $tpl_print->parse()) {
$msg = "Error in " . __FUNCTION__ . " - ";
$msg .= 'error: ' . $err . "\n";
error_msg(__FILE__, __LINE__, $msg);
echo nl2br($msg) . "\n";
return ERR_PARSING_TEMPLATE;
}
$tpl_print->restore_curly();
$msg = $tpl_print->getOutput();
//.........这里部分代码省略.........
示例12: dok_ask_dup_song
function dok_ask_dup_song($VARS, $update, $theme_path)
{
global $SONGS_LABELS;
if (!is_array($VARS['duplicates']) || !sizeof($VARS['duplicates'])) {
$t = dok_error_template(MSG_ERR_NO_DUP_SONG);
return array($t, sprintf(MSG_TITLE_DUP_SONG, ''));
}
if (!$VARS['label'] || $VARS['label'] == 0) {
$new_song_label = MSG_LABEL_NONE;
} else {
$new_song_label = $SONGS_LABELS[$VARS['label']]['label'];
}
if (!$VARS['track'] || $VARS['track'] == 0) {
$new_song_track = MSG_ALBUM_NEXT_TRACK;
} else {
$new_song_track = $VARS['track'];
}
/*
*find related songs
*
*/
//$res = dok_oquery('select * from '.dok_tn('rel_songs').' where song_id1 =
$t = new template($theme_path);
$t->set_file('page', 'song_dup.tpl');
$t->set_block('page', 'duplicate', 'dup_block');
$query = 'select * from ' . dok_tn('song') . ' where id in(' . implode(',', $VARS['duplicates']) . ')';
$res = mysql_query($query);
$relations = dok_songs_links_array();
while ($row = mysql_fetch_array($res)) {
$t->set_var(dok_song_format($row));
$relations_select = '<select name="link[' . $row['id'] . ']"><option value="" SELECTED>' . MSG_RELATION_NONE . '</option>' . "\n";
foreach ($relations as $key => $val) {
$relations_select .= '<option value="' . $key . '">' . $val . '</option>' . "\n";
}
$relations_select .= '</select>';
$t->set_var('SONG_RELATION_SELECT', $relations_select);
$t->parse('dup_block', 'duplicate', 'true');
}
if ($update == 'create_song') {
$res = mysql_query('select name from ' . dok_tn('album') . ' where id = ' . $VARS['album']);
if (!mysql_numrows($res)) {
$album = MSG_UNKNOWN;
} else {
$album = mysql_result($res, 0, 'name');
}
$res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist']);
if (!mysql_numrows($res)) {
$artist = MSG_UNKNOWN;
} else {
$artist = mysql_result($res, 0, 'name');
}
$t->set_var(array('NEW_SONG_NAME' => $VARS['name'], 'NEW_SONG_COMMENT' => dok_textarea_2_db($VARS['comment']), 'NEW_SONG_TRACK' => $new_song_track, 'NEW_SONG_LENGTH' => $VARS['length'], 'NEW_SONG_LABEL' => $new_song_label, 'NEW_SONG_ARTIST' => $artist, 'NEW_SONG_ALBUM' => $album, 'NEW_SONG_GENRE' => dok_genre_name($VARS['genre']), 'NEW_SONG_RELEASE' => dok_year2str($VARS['release'])));
} else {
$t->set_var(array('NEW_SONG_NAME' => $VARS['name'], 'NEW_SONG_COMMENT' => dok_textarea_2_db($VARS['comment']), 'NEW_SONG_TRACK' => $new_song_track, 'NEW_SONG_LENGTH' => dok_sec2str($VARS['length']), 'NEW_SONG_GENRE' => dok_genre_name($VARS['genre']), 'NEW_SONG_LABEL' => $new_song_label, 'NEW_SONG_ARTIST' => '', 'NEW_SONG_ALBUM' => '', 'NEW_SONG_RELEASE' => dok_year2str($VARS['release'])));
}
$yes_form = '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"><input type=hidden name="update" value="' . $update . '">';
$yes_form .= '<input type=hidden name="dup_checked" value="1">';
if ($update == 'update_song') {
$yes_form .= '<input type=hidden name="id" value="' . $VARS['id'] . '">';
}
$yes_form .= '<input type=hidden name="artist" value="' . $VARS['artist'] . '">';
$yes_form .= '<input type=hidden name="album" value="' . $VARS['album'] . '">';
$yes_form .= '<input type=hidden name="track" value="' . str_replace('"', '"', $VARS['track']) . '">';
$yes_form .= '<input type=hidden name="name" value="' . str_replace('"', '"', $VARS['name']) . '">';
$yes_form .= '<input type=hidden name="length" value="' . str_replace('"', '"', $VARS['length']) . '">';
$yes_form .= '<input type=hidden name="release" value="' . str_replace('"', '"', $VARS['release']) . '">';
$yes_form .= '<input type=hidden name="comment" value="' . str_replace('"', '"', $VARS['comment']) . '">';
$yes_form .= '<input type=hidden name="label" value="' . str_replace('"', '"', $VARS['label']) . '">';
$yes_form .= '<input type=hidden name="genre" value="' . $VARS['genre'] . '">';
$t->set_var('SONG_RECORD_FORM', $yes_form);
return array($t, MSG_TITLE_DUP_SONG);
}
示例13: numeric
function display_form($template = false)
{
global $CONFIG, $Sql, $LANG, $Session;
$note = !empty($_POST['note']) ? numeric($_POST['note']) : 0;
$path_redirect = $this->path . sprintf(str_replace('&', '&', $this->script_path), 0);
if ($this->_note_loaded()) {
if (!is_object($template) || strtolower(get_class($template)) != 'template') {
$template = new template('framework/note.tpl');
}
###########################Insertion##############################
if (!empty($_POST['valid_note'])) {
if (!empty($note)) {
$this->add($note);
}
redirect($path_redirect);
} else {
###########################Affichage##############################
$row_note = $Sql->query_array(PREFIX . $this->sql_table, 'users_note', 'nbrnote', 'note', "WHERE id = '" . $this->idprov . "'", __LINE__, __FILE__);
$select = '<option value="-1" selected="selected">' . $LANG['note'] . '</option>';
for ($i = 0; $i <= $this->notation_scale; $i++) {
$select .= '<option value="' . $i . '">' . $i . '</option>';
}
### Notation Ajax ###
$row_note['note'] = round($row_note['note'] / 0.25) * 0.25;
$l_note = ($this->options & NOTE_DISPLAY_NOTE) !== 0 ? '<strong>' . $LANG['note'] . ':</strong> ' : '';
$display = ($this->options & NOTE_DISPLAY_BLOCK) !== 0 ? 'block' : 'inline';
$width = ($this->options & NOTE_DISPLAY_BLOCK) !== 0 ? 'width:' . $this->notation_scale * 16 . 'px;margin:auto;' : '';
$ajax_note = '<div style="' . $width . 'display:none" id="note_stars' . $this->idprov . '" onmouseout="out_div(' . $this->idprov . ', array_note[' . $this->idprov . '])" onmouseover="over_div()">';
for ($i = 1; $i <= $this->notation_scale; $i++) {
$star_img = 'stars.png';
if ($row_note['note'] < $i) {
$decimal = $i - $row_note['note'];
if ($decimal >= 1) {
$star_img = 'stars0.png';
} elseif ($decimal >= 0.75) {
$star_img = 'stars1.png';
} elseif ($decimal >= 0.5) {
$star_img = 'stars2.png';
} else {
$star_img = 'stars3.png';
}
}
$ajax_note .= '<a href="javascript:send_note(' . $this->idprov . ', ' . $i . ', \'' . $Session->get_token() . '\')" onmouseover="select_stars(' . $this->idprov . ', ' . $i . ');"><img src="../templates/' . get_utheme() . '/images/' . $star_img . '" alt="" class="valign_middle" id="n' . $this->idprov . '_stars' . $i . '" /></a>';
}
if (($this->options & NOTE_NODISPLAY_NBRNOTES) !== 0) {
$ajax_note .= '</div> <span id="noteloading' . $this->idprov . '"></span>';
} else {
$ajax_note .= '</div> <span id="noteloading' . $this->idprov . '"></span> <div style="display:' . $display . '" id="nbrnote' . $this->idprov . '">(' . $row_note['nbrnote'] . ' ' . ($row_note['nbrnote'] > 1 ? strtolower($LANG['notes']) : strtolower($LANG['note'])) . ')</div>';
}
$template->assign_vars(array('C_JS_NOTE' => !defined('HANDLE_NOTE'), 'ID' => $this->idprov, 'NOTE_MAX' => $this->notation_scale, 'SELECT' => $select, 'NOTE' => $l_note . '<span id="note_value' . $this->idprov . '">' . ($row_note['nbrnote'] > 0 ? '<strong>' . $row_note['note'] . '</strong>' : '<em>' . $LANG['no_note'] . '</em>') . '</span>' . $ajax_note, 'ARRAY_NOTE' => 'array_note[' . $this->idprov . '] = \'' . $row_note['note'] . '\';', 'DISPLAY' => $display, 'L_AUTH_ERROR' => addslashes($LANG['e_auth']), 'L_ALERT_ALREADY_VOTE' => addslashes($LANG['already_vote']), 'L_ALREADY_VOTE' => '', 'L_NOTE' => addslashes($LANG['note']), 'L_NOTES' => addslashes($LANG['notes']), 'L_VALID_NOTE' => $LANG['valid_note']));
}
if (!defined('HANDLE_NOTE')) {
define('HANDLE_NOTE', true);
}
return $template->parse(TEMPLATE_STRING_MODE);
} else {
global $Errorh;
$Errorh->handler('e_unexist_page', E_USER_REDIRECT);
}
}
示例14: dok_list_songs
function dok_list_songs($VARS, $up, $theme_path)
{
$t = new template($theme_path);
$t->set_file('page', 'song_list.tpl');
$t->set_block('page', 'song', 'song_block');
$t->set_block('page', 'next_page', 'next_page_block');
$t->set_block('page', 'if_artist', 'if_artist_block');
if (!isset($VARS['alpha'])) {
$VARS['alpha'] = '-';
}
if (!strlen($VARS['offset']) || $VARS['offset'] < 0) {
$VARS['offset'] = '0';
}
$VARS['alpha'] = mysql_real_escape_string($VARS['alpha']);
if (isset($VARS['artist']) && is_numeric($VARS['artist']) && $VARS['artist'] > 0) {
$query = 'select s.* from ' . dok_tn('rel_song_artist') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where substring(s.name from 1 for 1) >= \'' . $VARS['alpha'] . '\' and r.artist_id = ' . $VARS['artist'] . ' order by s.name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP;
$total_query = 'select count(*) as c from ' . dok_tn('rel_song_artist') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where substring(s.name from 1 for 1) >= \'' . $VARS['alpha'] . '\' and r.artist_id = ' . $VARS['artist'];
$res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist']);
if (!mysql_numrows($res)) {
$t->set_var('ARTIST_NAME', '');
$t->set_var('ARTIST_LINK', '');
$t->set_var('ARTIST_ID', '');
} else {
$t->set_var('ARTIST_NAME', mysql_result($res, 0, 'name'));
$t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_artist&id=' . $VARS['artist']);
$t->set_var('ARTIST_ID', $VARS['artist']);
}
$t->parse('if_artist_block', 'if_artist');
$pager_infos = array('related' => 'artist', 'related_id' => $VARS['artist']);
} else {
$query = 'select * from ' . dok_tn('song') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\' order by name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP;
$total_query = 'select count(*) as c from ' . dok_tn('song') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\'';
$t->set_var('if_artist_block', '');
$t->set_var('ARTIST_ID', '');
$t->set_var('ARTIST_NAME', '');
$t->set_var('ARTIST_LINK', '');
$pager_infos = '';
}
$res = dok_oquery($query);
if ($res->numrows()) {
$ids = $res->fetch_col_array('id');
while ($row = $res->fetch_array()) {
$t->set_var(dok_song_format($row, $pager_infos));
$t->parse('song_block', 'song', 'true');
}
$res = mysql_query($total_query);
$total = mysql_result($res, 0, 'c');
if ($total > $VARS['offset'] + DOK_LIST_EPP) {
$lnk = $_SERVER['PHP_SELF'] . '?display=list_songs&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP);
if ($t->get_var('ARTIST_ID')) {
$lnk .= '&artist=' . $t->get_var('ARTIST_ID');
}
$t->set_var('NEXT_PAGE_LINK', $lnk);
$t->parse('next_page_block', 'next_page');
} else {
$t->set_var('next_page_block', '');
}
} else {
$t->set_var('song_block', MSG_NO_SONG);
$t->set_var('next_page_block', '');
}
return array($t, MSG_TITLE_LIST_SONG);
}
示例15: checkRender
public function checkRender($view_path, $check_view = '', $time = 0)
{
static $tplrefresh = null;
if (is_null($tplrefresh)) {
$tplrefresh = g('_config/view/tplrefresh');
}
$cache_file = $this->getCache($view_path);
$tpl_file = $this->getTpl($view_path);
$check_file = $check_view ? $this->getTpl($check_view) : 0;
if (!file_exists($cache_file) || $tplrefresh == 1 || $tplrefresh == 2 && filemtime($tpl_file) > filemtime($cache_file) || $check_file && filemtime($check_file) > $time) {
$this->checkCss();
$template = new template();
$content = $template->parse($tpl_file, $view_path, $this->_script_path);
$fp = fopen($cache_file, 'wb');
if ($fp) {
fwrite($fp, $content);
fclose($fp);
} else {
throw new error("{$view_path} template cache file can't write!");
}
//return $content;
} else {
//return file_get_contents($cache_file);
}
return $cache_file;
}