本文整理汇总了PHP中XTemplate::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP XTemplate::parse方法的具体用法?PHP XTemplate::parse怎么用?PHP XTemplate::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XTemplate
的用法示例。
在下文中一共展示了XTemplate::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: XTemplate
function display_page($p)
{
$page = $this->db->quick_query('SELECT * FROM %ppages WHERE page_id=%d', $p);
if (!$page) {
return $this->error('The page you are looking for does not exist. It may have been deleted or the URL is incorrect.', 404);
}
$xtpl = new XTemplate('./skins/' . $this->skin . '/page.xtpl');
$this->title($page['page_title']);
$this->meta_description($page['page_meta']);
$sidebar = null;
$content = $this->format($page['page_content'], $page['page_flags']);
if ($page['page_flags'] & POST_HTML && $page['page_flags'] & POST_BBCODE) {
$content = html_entity_decode($content, ENT_COMPAT, 'UTF-8');
}
$xtpl->assign('content', $content);
if ($page['page_flags'] & POST_SIDEBAR) {
$SideBar = new sidebar($this);
$sidebar = $SideBar->build_sidebar();
$xtpl->parse('Page.HasSidebar');
} else {
$xtpl->parse('Page.NoSidebar');
}
$xtpl->assign('sidebar', $sidebar);
$xtpl->parse('Page');
return $xtpl->text('Page');
}
示例2: XTemplate
function nv_block_archives_search()
{
global $lang_module, $module_name, $module_data, $module_file, $module_config, $module_info, $global_archives_cat, $nv_Request, $array_op;
$q = $nv_Request->get_string('q', 'get', '');
$oid = $nv_Request->get_int('catid', 'get', 0);
if (!empty($global_archives_cat)) {
$xtpl = new XTemplate("block_search.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . "/modules/" . $module_file);
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
$xtpl->assign('SEARCH', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=search");
$xtpl->assign('LANG', $lang_module);
foreach ($global_archives_cat as $catid => $catinfo) {
if ($catinfo['parentid'] == '0') {
$xtpl->assign('ROW', $catinfo);
$xtpl->parse('main.loop');
}
$xtitle = "";
if ($catinfo['lev'] > 0) {
for ($i = 1; $i <= $catinfo['lev']; $i++) {
$xtitle .= " ";
}
}
$catinfo['xtitle'] = $xtitle . $catinfo['title'];
$catinfo['select'] = $catinfo['catid'] == $oid ? "selected=\"selected\"" : "";
$xtpl->assign('PAR', $catinfo);
$xtpl->parse('main.parent_loop');
}
$xtpl->assign('text_search', $q);
$xtpl->parse('main');
return $xtpl->text('main');
}
return "";
}
示例3: elseif
/**
* nv_page_list()
*
* @return
*/
function nv_page_list($block_config)
{
global $global_config, $site_mods, $db, $module_name;
$module = $block_config['module'];
if (!isset($site_mods[$module])) {
return '';
}
$db->sqlreset()->select('id, title, alias')->from(NV_PREFIXLANG . '_' . $site_mods[$module]['module_data'])->where('status = 1')->order('weight ASC')->limit($block_config['numrow']);
$list = nv_db_cache($db->sql(), 'id', $module);
if (!empty($list)) {
if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/page/block.page_list.tpl')) {
$block_theme = $global_config['module_theme'];
} elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/modules/page/block.page_list.tpl')) {
$block_theme = $global_config['site_theme'];
} else {
$block_theme = 'default';
}
$xtpl = new XTemplate('block.page_list.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/page');
foreach ($list as $l) {
$l['title_clean60'] = nv_clean60($l['title'], $block_config['title_length']);
$l['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module . '&' . NV_OP_VARIABLE . '=' . $l['alias'] . $global_config['rewrite_exturl'];
$xtpl->assign('ROW', $l);
$xtpl->parse('main.loop');
}
$xtpl->parse('main');
return $xtpl->text('main');
} else {
return '';
}
}
示例4: nv_theme_event_detail
/**
* nv_theme_event_detail()
*
* @param mixed $array_data
* @return
*/
function nv_theme_event_detail($array_data)
{
global $global_config, $module_name, $module_file, $lang_module, $module_config, $module_info, $op, $global_array_event_cat;
if (NV_CURRENTTIME >= $array_data['start_time'] and NV_CURRENTTIME <= $array_data['end_time']) {
$array_data['status_str'] = $lang_module['status_2'];
} elseif (NV_CURRENTTIME < $array_data['start_time']) {
$array_data['status_str'] = $lang_module['status_1'];
} else {
$array_data['status_str'] = $lang_module['status_0'];
}
$array_data['start_date'] = nv_date('d/m/Y', $array_data['start_time']);
$array_data['start_time'] = nv_date('H:i', $array_data['start_time']);
$array_data['end_date'] = nv_date('d/m/Y', $array_data['end_time']);
$array_data['end_time'] = nv_date('H:i', $array_data['end_time']);
$array_data['title_cat'] = $global_array_event_cat[$array_data['catid']]['title'];
$array_data['url_cat'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_event_cat[$array_data['catid']]['alias'];
$xtpl = new XTemplate($op . '.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('DATA', $array_data);
if ($array_data['start_date'] == $array_data['end_date']) {
$xtpl->parse('main.day');
} else {
$xtpl->parse('main.longday');
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例5: main_theme
/**
* main_theme()
*
* @param mixed $contents
* @return
*/
function main_theme($contents)
{
if (empty($contents)) {
return '';
}
global $global_config, $module_file;
$xtpl = new XTemplate('cronjobs_list.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
foreach ($contents as $id => $values) {
$xtpl->assign('DATA', array('caption' => $values['caption'], 'edit' => empty($values['edit']) ? array() : $values['edit'], 'disable' => empty($values['disable']) ? array() : $values['disable'], 'delete' => empty($values['delete']) ? array() : $values['delete'], 'id' => $id));
if (!empty($values['edit'][0])) {
$xtpl->parse('main.edit');
}
if (!empty($values['disable'][0])) {
$xtpl->parse('main.disable');
}
if (!empty($values['delete'][0])) {
$xtpl->parse('main.delete');
}
$a = 0;
foreach ($values['detail'] as $key => $value) {
$xtpl->assign('ROW', array('key' => $key, 'value' => $value));
$xtpl->parse('main.loop');
}
$xtpl->parse('main');
}
return $xtpl->text('main');
}
示例6: nv_show_sources_list
/**
* nv_show_sources_list()
*
* @return
*
*/
function nv_show_sources_list()
{
global $db, $lang_module, $lang_global, $module_name, $module_data, $nv_Request, $module_file, $global_config;
$num = $db->query('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_sources')->fetchColumn();
$base_url = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_data . '&' . NV_OP_VARIABLE . '=sources';
$num_items = $num > 1 ? $num : 1;
$per_page = 15;
$page = $nv_Request->get_int('page', 'get', 1);
$xtpl = new XTemplate('sources_list.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('GLANG', $lang_global);
if ($num > 0) {
$db->sqlreset()->select('*')->from(NV_PREFIXLANG . '_' . $module_data . '_sources')->order('weight')->limit($per_page)->offset(($page - 1) * $per_page);
$result = $db->query($db->sql());
while ($row = $result->fetch()) {
$xtpl->assign('ROW', array('sourceid' => $row['sourceid'], 'title' => $row['title'], 'link' => $row['link'], 'url_edit' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=sources&sourceid=' . $row['sourceid'] . '#edit'));
for ($i = 1; $i <= $num; ++$i) {
$xtpl->assign('WEIGHT', array('key' => $i, 'title' => $i, 'selected' => $i == $row['weight'] ? ' selected="selected"' : ''));
$xtpl->parse('main.loop.weight');
}
$xtpl->parse('main.loop');
}
$result->closeCursor();
$generate_page = nv_generate_page($base_url, $num_items, $per_page, $page);
if (!empty($generate_page)) {
$xtpl->assign('GENERATE_PAGE', $generate_page);
$xtpl->parse('main.generate_page');
}
$xtpl->parse('main');
$contents = $xtpl->text('main');
} else {
$contents = ' ';
}
return $contents;
}
示例7: getEditor
function getEditor()
{
$xtpl = new XTemplate(dirname(__FILE__) . '/editor.xtpl');
$xtpl->parse('main.menu_item_list');
$xtpl->parse('main');
return $xtpl->text('main');
}
示例8: viewdirtree
/**
* viewdirtree()
*
* @param mixed $dir
* @param mixed $currentpath
* @return
*/
function viewdirtree($dir, $currentpath)
{
global $array_dirname, $global_config, $module_file;
$pattern = !empty($dir) ? '/^(' . nv_preg_quote($dir) . ')\\/([^\\/]+)$/' : '/^([^\\/]+)$/';
$_dirlist = preg_grep($pattern, array_keys($array_dirname));
$content = '';
foreach ($_dirlist as $_dir) {
$check_allow_upload_dir = nv_check_allow_upload_dir($_dir);
if (!empty($check_allow_upload_dir)) {
$class_li = ($_dir == $currentpath or strpos($currentpath, $_dir . '/') !== false) ? 'open collapsable' : 'expandable';
$style_color = $_dir == $currentpath ? ' style="color:red"' : '';
$tree = array();
$tree['class1'] = $class_li;
$tree['class2'] = nv_set_dir_class($check_allow_upload_dir) . ' pos' . nv_string_to_filename($dir);
$tree['style'] = $style_color;
$tree['title'] = $_dir;
$tree['titlepath'] = basename($_dir);
$content2 = viewdirtree($_dir, $currentpath);
$xtpl = new XTemplate('foldlist.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
$xtpl->assign('DIRTREE', $tree);
if (empty($content2)) {
$content2 = '<li class="hide"> </li>';
}
if (!empty($content2)) {
$xtpl->assign('TREE_CONTENT', $content2);
$xtpl->parse('tree.tree_content');
}
$xtpl->parse('tree');
$content .= $xtpl->text('tree');
}
}
return $content;
}
示例9: elseif
function nv_block_language($block_config)
{
global $global_config, $site_mods, $lang_global, $language_array;
if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/blocks/global.block_language.tpl')) {
$block_theme = $global_config['module_theme'];
} elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/blocks/global.block_language.tpl')) {
$block_theme = $global_config['site_theme'];
} else {
$block_theme = 'default';
}
$xtpl = new XTemplate('global.block_language.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/blocks');
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
$xtpl->assign('BLOCK_THEME', $block_theme);
$xtpl->assign('SELECT_LANGUAGE', $lang_global['langsite']);
// Multiple languages
if ($global_config['lang_multi'] and sizeof($global_config['allow_sitelangs']) > 1) {
foreach ($global_config['allow_sitelangs'] as $lang_i) {
$xtpl->assign('LANGSITENAME', $language_array[$lang_i]['name']);
$xtpl->assign('LANGSITEURL', NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . $lang_i);
if (NV_LANG_DATA != $lang_i) {
$xtpl->parse('main.language.langitem');
} else {
$xtpl->parse('main.language.langcuritem');
}
}
$xtpl->parse('main.language');
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例10: array
function nv_weather_blocks($block_config)
{
global $global_config, $site_mods, $db, $module_name;
$module = $block_config['module'];
$array_th = array();
$sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_weather WHERE status = 1 ORDER BY weight ASC';
$list = nv_db_cache($sql, '', $module);
if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/weather/block.weather.tpl')) {
$block_theme = $global_config['module_theme'];
} elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/modules/weather/block.weather.tpl')) {
$block_theme = $global_config['site_theme'];
} else {
$block_theme = 'default';
}
$xtpl = new XTemplate('block.weather.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/weather');
$xtpl->assign('TEMPLATE', $block_theme);
$xtpl->assign('CODE', $block_config['location']);
$xtpl->assign('NUM_DAY', $block_config['numday']);
foreach ($list as $row) {
$block_config['location'] == $row['location_code'] ? $row['selected'] = ' selected="selected"' : ($row['selected'] = '');
$xtpl->assign('ROW', $row);
$xtpl->parse('main.loop');
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例11: elseif
/**
* nv_menu_theme_default_footer()
*
* @param mixed $block_config
* @return
*
*/
function nv_menu_theme_default_footer($block_config)
{
global $global_config, $site_mods, $lang_global, $module_name, $home;
if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/blocks/global.menu_footer.tpl')) {
$block_theme = $global_config['module_theme'];
} elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/blocks/global.menu_footer.tpl')) {
$block_theme = $global_config['site_theme'];
} else {
$block_theme = 'default';
}
$xtpl = new XTemplate('global.menu_footer.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/blocks');
$xtpl->assign('LANG', $lang_global);
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
$xtpl->assign('BLOCK_THEME', $block_theme);
$xtpl->assign('THEME_SITE_HREF', NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA);
$a = 0;
foreach ($site_mods as $modname => $modvalues) {
if (in_array($modname, $block_config['module_in_menu']) and !empty($modvalues['funcs'])) {
$_array_menu = array('title' => $modvalues['custom_title'], 'link' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $modname);
$xtpl->assign('FOOTER_MENU', $_array_menu);
$xtpl->parse('main.footer_menu');
++$a;
}
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例12: elseif
/**
* nv_page_list()
*
* @return
*/
function nv_page_list($block_config)
{
global $global_config, $site_mods, $db, $module_name;
$module = $block_config['module'];
if (!isset($site_mods[$module])) {
return '';
}
$db->sqlreset()->select('id, title, phone,phone1,image')->from(NV_PREFIXLANG . '_' . $site_mods[$module]['module_data'])->where('status = 1')->order('weight ASC')->limit($block_config['numrow']);
$list = nv_db_cache($db->sql(), 'id', $module);
if (!empty($list)) {
if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/nhan-vien/block.nhanvien.tpl')) {
$block_theme = $global_config['module_theme'];
} elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/modules/nhan-vien/block.nhanvien.tpl')) {
$block_theme = $global_config['site_theme'];
} else {
$block_theme = 'default';
}
$xtpl = new XTemplate('block.nhanvien.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/nhan-vien');
foreach ($list as $l) {
$l['img'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $l['image'];
$xtpl->assign('ROW', $l);
$xtpl->parse('main.loop');
}
$xtpl->parse('main');
return $xtpl->text('main');
} else {
return '';
}
}
示例13: viewdirtree
/**
* viewdirtree()
*
* @param mixed $dir
* @param mixed $currentpath
* @return
*/
function viewdirtree($dir, $currentpath)
{
global $dirlist, $global_config, $module_file;
$pattern = !empty($dir) ? "/^(" . nv_preg_quote($dir) . ")\\/([^\\/]+)\$/" : "/^([^\\/]+)\$/";
$_dirlist = preg_grep($pattern, $dirlist);
$content = "";
foreach ($_dirlist as $_dir) {
$check_allow_upload_dir = nv_check_allow_upload_dir($_dir);
if (!empty($check_allow_upload_dir)) {
$class_li = ($_dir == $currentpath or strpos($currentpath, $_dir . '/') !== false) ? "open collapsable" : "expandable";
$style_color = $_dir == $currentpath ? ' style="color:red"' : '';
$tree = array();
$tree['class1'] = $class_li;
$tree['class2'] = nv_set_dir_class($check_allow_upload_dir) . " pos" . nv_string_to_filename($dir);
$tree['style'] = $style_color;
$tree['title'] = $_dir;
$tree['titlepath'] = basename($_dir);
$content2 = viewdirtree($_dir, $currentpath);
$xtpl = new XTemplate("foldlist.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file);
$xtpl->assign("DIRTREE", $tree);
if (!empty($content2)) {
$xtpl->assign("TREE_CONTENT", $content2);
$xtpl->parse('tree.tree_content');
}
$xtpl->parse('tree');
$content .= $xtpl->text('tree');
}
}
return $content;
}
示例14: nv_page_main_list
/**
* nv_page_main_list()
*
* @param mixed $array_data
* @return
*/
function nv_page_main_list($array_data, $generate_page)
{
global $module_file, $lang_module, $module_upload, $module_info, $meta_property, $my_head, $client_info, $page_config, $module_name;
$template = file_exists(NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file . '/main_list.tpl') ? $module_info['template'] : 'default';
$xtpl = new XTemplate('main_list.tpl', NV_ROOTDIR . '/themes/' . $template . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
if (!empty($array_data)) {
foreach ($array_data as $data) {
if (!empty($data['image'])) {
$data['image'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $data['image'];
$data['imagealt'] = !empty($data['imagealt']) ? $data['imagealt'] : $data['title'];
}
$xtpl->assign('DATA', $data);
if (!empty($data['image'])) {
$xtpl->parse('main.loop.image');
}
$xtpl->parse('main.loop');
}
if ($generate_page != '') {
$xtpl->assign('GENERATE_PAGE', $generate_page);
}
}
$xtpl->parse('main');
return $xtpl->text('main');
}
示例15: mainAction
/**
* main action
*/
public function mainAction()
{
$template['file'] = ONXSHOP_DIR . "templates/{$this->GET['template']}";
$tpl = new XTemplate($template['file']);
$tpl->parse('title');
$tpl->parse('description');
$tpl->parse('keywords');
$tpl->parse('head');
$template['title'] = $tpl->text('title');
$template['description'] = $tpl->text('description');
$template['keywords'] = $tpl->text('keywords');
$template['head'] = $tpl->text('head');
if (file_exists($template['file'])) {
$file_content = file($template['file']);
foreach ($file_content as $file_line) {
$proc = 1;
if (preg_match('/<\\!-- BEGIN: content -->/', $file_line)) {
$add = 1;
$proc = 0;
} else {
if (preg_match('/<\\!-- END: content -->/', $file_line)) {
$add = 0;
}
}
if ($add == 1 && $proc == 1) {
$template['content'] = $template['content'] . $file_line;
}
}
} else {
msg("template {$template['file']} does not exists!", 'error', 1);
}
$this->tpl->assign('template', $template);
return true;
}