本文整理汇总了PHP中updatediytemplate函数的典型用法代码示例。如果您正苦于以下问题:PHP updatediytemplate函数的具体用法?PHP updatediytemplate怎么用?PHP updatediytemplate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了updatediytemplate函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: updatetopic
function updatetopic($topic = '')
{
global $_G;
$topicid = empty($topic) ? '' : $topic['topicid'];
include_once libfile('function/home');
$_POST['title'] = getstr(trim($_POST['title']), 255);
$_POST['name'] = getstr(trim($_POST['name']), 255);
$_POST['domain'] = getstr(trim($_POST['domain']), 255);
if (empty($_POST['title'])) {
return 'topic_title_cannot_be_empty';
}
if (empty($_POST['name'])) {
$_POST['name'] = $_POST['title'];
}
if (!$topicid || $_POST['name'] != $topic['name']) {
if ($value = C::t('portal_topic')->fetch_by_name($_POST['name'])) {
return 'topic_name_duplicated';
}
}
if ($topicid && !empty($topic['domain'])) {
require_once libfile('function/delete');
deletedomain($topicid, 'topic');
}
if (!empty($_POST['domain'])) {
require_once libfile('function/domain');
domaincheck($_POST['domain'], $_G['setting']['domain']['root']['topic'], 1);
}
$setarr = array('title' => $_POST['title'], 'name' => $_POST['name'], 'domain' => $_POST['domain'], 'summary' => getstr($_POST['summary']), 'keyword' => getstr($_POST['keyword']), 'useheader' => $_POST['useheader'] ? '1' : '0', 'usefooter' => $_POST['usefooter'] ? '1' : '0', 'allowcomment' => $_POST['allowcomment'] ? 1 : 0, 'closed' => $_POST['closed'] ? 0 : 1);
if ($_POST['deletecover'] && $topic['cover']) {
if ($topic['picflag'] != '0') {
pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
}
$setarr['cover'] = '';
} else {
if ($_FILES['cover']['tmp_name']) {
if ($topic['cover'] && $topic['picflag'] != '0') {
pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
}
$pic = pic_upload($_FILES['cover'], 'portal');
if ($pic) {
$setarr['cover'] = 'portal/' . $pic['pic'];
$setarr['picflag'] = $pic['remote'] ? '2' : '1';
}
} else {
if (!empty($_POST['cover']) && $_POST['cover'] != $topic['cover']) {
if ($topic['cover'] && $topic['picflag'] != '0') {
pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
}
$setarr['cover'] = $_POST['cover'];
$setarr['picflag'] = '0';
}
}
}
$primaltplname = '';
if (empty($topicid) || empty($topic['primaltplname']) || $topic['primaltplname'] && $topic['primaltplname'] != $_POST['primaltplname']) {
$primaltplname = $_POST['primaltplname'];
if (!isset($_POST['signs'][dsign($primaltplname)])) {
return 'diy_sign_invalid';
}
$checktpl = checkprimaltpl($primaltplname);
if ($checktpl !== true) {
return $checktpl;
}
$setarr['primaltplname'] = $primaltplname;
}
if ($topicid) {
C::t('portal_topic')->update($topicid, $setarr);
C::t('common_diy_data')->update('portal/portal_topic_content_' . $topicid, getdiydirectory($topic['primaltplname']), array('name' => $setarr['title']));
} else {
$setarr['uid'] = $_G['uid'];
$setarr['username'] = $_G['username'];
$setarr['dateline'] = $_G['timestamp'];
$setarr['closed'] = '1';
$topicid = addtopic($setarr);
if (!$topicid) {
return 'topic_created_failed';
}
}
if (!empty($_POST['domain'])) {
C::t('common_domain')->insert(array('domain' => $_POST['domain'], 'domainroot' => $_G['setting']['domain']['root']['topic'], 'id' => $topicid, 'idtype' => 'topic'));
}
$tpldirectory = '';
if ($primaltplname && $topic['primaltplname'] != $primaltplname) {
$targettplname = 'portal/portal_topic_content_' . $topicid;
if (strpos($primaltplname, ':') !== false) {
list($tpldirectory, $primaltplname) = explode(':', $primaltplname);
}
C::t('common_diy_data')->update($targettplname, getdiydirectory($topic['primaltplname']), array('primaltplname' => $primaltplname, 'tpldirectory' => $tpldirectory));
updatediytemplate($targettplname);
}
if ($primaltplname && empty($topic['primaltplname'])) {
$tpldirectory = $tpldirectory ? $tpldirectory : $_G['cache']['style_default']['tpldir'];
$content = file_get_contents(DISCUZ_ROOT . $tpldirectory . '/' . $primaltplname . '.htm');
$tplfile = DISCUZ_ROOT . './data/diy/' . $tpldirectory . '/portal/portal_topic_content_' . $topicid . '.htm';
$tplpath = dirname($tplfile);
if (!is_dir($tplpath)) {
dmkdir($tplpath);
}
file_put_contents($tplfile, $content);
}
//.........这里部分代码省略.........
开发者ID:softhui,项目名称:discuz,代码行数:101,代码来源:function_portalcp.php
示例2: remakediytemplate
function remakediytemplate($primaltplname, $targettplname, $diytplname, $olddirectory)
{
global $_G;
if (empty($targettplname)) {
return false;
}
$tpldirectory = '';
if (strpos($primaltplname, ':') !== false) {
list($tpldirectory, $primaltplname) = explode(':', $primaltplname);
}
$tpldirectory = $tpldirectory ? $tpldirectory : $_G['cache']['style_default']['tpldir'];
$newdiydata = C::t('common_diy_data')->fetch($targettplname, $tpldirectory);
if ($newdiydata) {
return false;
}
$diydata = C::t('common_diy_data')->fetch($targettplname, $olddirectory);
$diycontent = empty($diydata['diycontent']) ? '' : $diydata['diycontent'];
if ($diydata) {
C::t('common_diy_data')->update($targettplname, $olddirectory, array('primaltplname' => $primaltplname, 'tpldirectory' => $tpldirectory));
} else {
$diycontent = '';
if (in_array($primaltplname, array('portal/list', 'portal/view'))) {
$diydata = C::t('common_diy_data')->fetch($targettplname, $olddirectory);
$diycontent = empty($diydata['diycontent']) ? '' : $diydata['diycontent'];
}
$diyarr = array('targettplname' => $targettplname, 'tpldirectory' => $tpldirectory, 'primaltplname' => $primaltplname, 'diycontent' => $diycontent, 'name' => $diytplname, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => TIMESTAMP);
C::t('common_diy_data')->insert($diyarr);
}
if (empty($diycontent)) {
$file = $tpldirectory . '/' . $primaltplname . '.htm';
if (!file_exists($file)) {
$file = './template/default/' . $primaltplname . '.htm';
}
$content = @file_get_contents(DISCUZ_ROOT . $file);
if (!$content) {
$content = '';
}
$content = preg_replace("/\\<\\!\\-\\-\\[name\\](.+?)\\[\\/name\\]\\-\\-\\>/i", '', $content);
file_put_contents(DISCUZ_ROOT . './data/diy/' . $tpldirectory . '/' . $targettplname . '.htm', $content);
} else {
updatediytemplate($targettplname, $tpldirectory);
}
return true;
}
开发者ID:renning,项目名称:html,代码行数:44,代码来源:admincp_yuexiamen.php
示例3: template
function template($file, $templateid = 0, $tpldir = '', $gettplfile = 0, $primaltpl = '')
{
global $_G;
static $_init_style = false;
if ($_init_style === false) {
C::app()->_init_style();
$_init_style = true;
}
$oldfile = $file;
if (strpos($file, ':') !== false) {
$clonefile = '';
list($templateid, $file, $clonefile) = explode(':', $file);
$oldfile = $file;
$file = empty($clonefile) ? $file : $file . '_' . $clonefile;
if ($templateid == 'diy') {
$indiy = false;
$_G['style']['tpldirectory'] = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$_G['style']['prefile'] = '';
$diypath = DISCUZ_ROOT . './data/diy/' . $_G['style']['tpldirectory'] . '/';
//DIY模板文件目录
$preend = '_diy_preview';
$_GET['preview'] = !empty($_GET['preview']) ? $_GET['preview'] : '';
$curtplname = $oldfile;
$basescript = $_G['mod'] == 'viewthread' && !empty($_G['thread']) ? 'forum' : $_G['basescript'];
if (isset($_G['cache']['diytemplatename' . $basescript])) {
$diytemplatename =& $_G['cache']['diytemplatename' . $basescript];
} else {
if (!isset($_G['cache']['diytemplatename'])) {
loadcache('diytemplatename');
}
$diytemplatename =& $_G['cache']['diytemplatename'];
}
$tplsavemod = 0;
if (isset($diytemplatename[$file]) && file_exists($diypath . $file . '.htm') && ($tplsavemod = 1) || empty($_G['forum']['styleid']) && ($file = $primaltpl ? $primaltpl : $oldfile) && isset($diytemplatename[$file]) && file_exists($diypath . $file . '.htm')) {
$tpldir = 'data/diy/' . $_G['style']['tpldirectory'] . '/';
!$gettplfile && ($_G['style']['tplsavemod'] = $tplsavemod);
$curtplname = $file;
if (isset($_GET['diy']) && $_GET['diy'] == 'yes' || isset($_GET['diy']) && $_GET['preview'] == 'yes') {
//DIY模式或预览模式下做以下判断
$flag = file_exists($diypath . $file . $preend . '.htm');
if ($_GET['preview'] == 'yes') {
$file .= $flag ? $preend : '';
} else {
$_G['style']['prefile'] = $flag ? 1 : '';
}
}
$indiy = true;
} else {
$file = $primaltpl ? $primaltpl : $oldfile;
}
$tplrefresh = $_G['config']['output']['tplrefresh'];
if ($indiy && ($tplrefresh == 1 || $tplrefresh > 1 && !($_G['timestamp'] % $tplrefresh)) && filemtime($diypath . $file . '.htm') < filemtime(DISCUZ_ROOT . $_G['style']['tpldirectory'] . '/' . ($primaltpl ? $primaltpl : $oldfile) . '.htm')) {
if (!updatediytemplate($file, $_G['style']['tpldirectory'])) {
unlink($diypath . $file . '.htm');
$tpldir = '';
}
}
if (!$gettplfile && empty($_G['style']['tplfile'])) {
$_G['style']['tplfile'] = empty($clonefile) ? $curtplname : $oldfile . ':' . $clonefile;
}
$_G['style']['prefile'] = !empty($_GET['preview']) && $_GET['preview'] == 'yes' ? '' : $_G['style']['prefile'];
} else {
$tpldir = './source/plugin/' . $templateid . '/template';
}
}
$file .= !empty($_G['inajax']) && ($file == 'common/header' || $file == 'common/footer') ? '_ajax' : '';
$tpldir = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$templateid = $templateid ? $templateid : (defined('TEMPLATEID') ? TEMPLATEID : '');
$filebak = $file;
if (defined('IN_MOBILE') && !defined('TPL_DEFAULT') && strpos($file, 'mobile/') === false || isset($_G['forcemobilemessage']) && $_G['forcemobilemessage']) {
$file = 'mobile/' . $oldfile;
}
if (!$tpldir) {
$tpldir = './template/default';
}
$tplfile = $tpldir . '/' . $file . '.htm';
$file == 'common/header' && defined('CURMODULE') && CURMODULE && ($file = 'common/header_' . $_G['basescript'] . '_' . CURMODULE);
if (defined('IN_MOBILE') && !defined('TPL_DEFAULT')) {
if (strpos($tpldir, 'plugin')) {
if (!file_exists(DISCUZ_ROOT . $tpldir . '/' . $file . '.htm') && !file_exists(DISCUZ_ROOT . $tpldir . '/' . $file . '.php')) {
discuz_error::template_error('template_notfound', $tpldir . '/' . $file . '.htm');
} else {
$mobiletplfile = $tpldir . '/' . $file . '.htm';
}
}
!$mobiletplfile && ($mobiletplfile = $file . '.htm');
if (strpos($tpldir, 'plugin') && (file_exists(DISCUZ_ROOT . $mobiletplfile) || file_exists(substr(DISCUZ_ROOT . $mobiletplfile, 0, -4) . '.php'))) {
$tplfile = $mobiletplfile;
} elseif (!file_exists(DISCUZ_ROOT . TPLDIR . '/' . $mobiletplfile) && !file_exists(substr(DISCUZ_ROOT . TPLDIR . '/' . $mobiletplfile, 0, -4) . '.php')) {
$mobiletplfile = './template/default/' . $mobiletplfile;
if (!file_exists(DISCUZ_ROOT . $mobiletplfile) && !$_G['forcemobilemessage']) {
$tplfile = str_replace('mobile/', '', $tplfile);
$file = str_replace('mobile/', '', $file);
define('TPL_DEFAULT', true);
} else {
$tplfile = $mobiletplfile;
}
} else {
$tplfile = TPLDIR . '/' . $mobiletplfile;
}
//.........这里部分代码省略.........
开发者ID:dalinhuang,项目名称:healthshop,代码行数:101,代码来源:function_core.php
示例4: updatetopic
function updatetopic($topic = '')
{
global $_G;
$topicid = empty($topic) ? '' : $topic['topicid'];
include_once libfile('function/home');
$_POST['title'] = getstr(trim($_POST['title']), 255, 1, 1);
$_POST['name'] = getstr(trim($_POST['name']), 255, 1, 1);
$_POST['domain'] = getstr(trim($_POST['domain']), 255, 1, 1);
if (empty($_POST['title'])) {
return 'topic_title_cannot_be_empty';
}
if (empty($_POST['name'])) {
$_POST['name'] = $_POST['title'];
}
if (!$topicid || $_POST['name'] != $topic['name']) {
$value = DB::fetch_first('SELECT * FROM ' . DB::table('portal_topic') . " WHERE name = '{$_POST['name']}' LIMIT 1");
if ($value) {
return 'topic_name_duplicated';
}
}
if ($topicid && !empty($topic['domain'])) {
require_once libfile('function/delete');
deletedomain($topicid, 'topic');
}
if (!empty($_POST['domain'])) {
require_once libfile('function/domain');
domaincheck($_POST['domain'], $_G['setting']['domain']['root']['topic'], 1);
}
$setarr = array('title' => $_POST['title'], 'name' => $_POST['name'], 'domain' => $_POST['domain'], 'summary' => getstr($_POST['summary'], '', 1, 1), 'keyword' => getstr($_POST['keyword'], '', 1, 1), 'useheader' => $_POST['useheader'] ? '1' : '0', 'usefooter' => $_POST['usefooter'] ? '1' : '0', 'allowcomment' => $_POST['allowcomment'] ? 1 : 0, 'closed' => $_POST['closed'] ? 0 : 1);
if ($_POST['deletecover'] && $topic['cover']) {
if ($topic['picflag'] != '0') {
pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
}
$setarr['cover'] = '';
} else {
if ($_FILES['cover']['tmp_name']) {
if ($topic['cover'] && $topic['picflag'] != '0') {
pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
}
$pic = pic_upload($_FILES['cover'], 'portal');
if ($pic) {
$setarr['cover'] = 'portal/' . $pic['pic'];
$setarr['picflag'] = $pic['remote'] ? '2' : '1';
}
} else {
if (!empty($_POST['cover']) && $_POST['cover'] != $topic['cover']) {
if ($topic['cover'] && $topic['picflag'] != '0') {
pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0');
}
$setarr['cover'] = $_POST['cover'];
$setarr['picflag'] = '0';
}
}
}
$primaltplname = '';
if (empty($topicid) || empty($topic['primaltplname']) || $topic['primaltplname'] && $topic['primaltplname'] != 'portal/' . $_POST['primaltplname']) {
$primaltplname = 'portal/' . $_POST['primaltplname'];
$checktpl = checkprimaltpl($primaltplname);
if ($checktpl !== true) {
return $checktpl;
}
$setarr['primaltplname'] = $primaltplname;
}
if ($topicid) {
DB::update('portal_topic', $setarr, array('topicid' => $topicid));
DB::update('common_diy_data', array('name' => $setarr['title']), array('targettplname' => 'portal/portal_topic_content_' . $topicid));
} else {
$setarr['uid'] = $_G['uid'];
$setarr['username'] = $_G['username'];
$setarr['dateline'] = $_G['timestamp'];
$setarr['closed'] = '1';
$topicid = addtopic($setarr);
if (!$topicid) {
return 'topic_created_failed';
}
}
if (!empty($_POST['domain'])) {
DB::insert('common_domain', array('domain' => $_POST['domain'], 'domainroot' => addslashes($_G['setting']['domain']['root']['topic']), 'id' => $topicid, 'idtype' => 'topic'));
}
if ($topic['primaltplname'] != $primaltplname) {
$targettplname = 'portal/portal_topic_content_' . $topicid;
DB::update('common_diy_data', array('primaltplname' => $primaltplname), array('targettplname' => $targettplname));
updatediytemplate($targettplname);
}
if ($primaltplname && empty($topic['primaltplname'])) {
$content = file_get_contents(DISCUZ_ROOT . './template/default/' . $primaltplname . '.htm');
$tplfile = DISCUZ_ROOT . './data/diy/portal/portal_topic_content_' . $topicid . '.htm';
$tplpath = dirname($tplfile);
if (!is_dir($tplpath)) {
dmkdir($tplpath);
}
file_put_contents($tplfile, $content);
}
include_once libfile('function/cache');
updatecache(array('diytemplatename', 'setting'));
return $topicid;
}
开发者ID:pan289091315,项目名称:Discuz,代码行数:97,代码来源:function_portalcp.php
示例5: build_cache_updatediytemplate
function build_cache_updatediytemplate()
{
updatediytemplate();
}
开发者ID:softhui,项目名称:discuz,代码行数:4,代码来源:cache_updatediytemplate.php
示例6: template
function template($file, $templateid = 0, $tpldir = '', $gettplfile = 0)
{
global $_G;
if (strexists($file, ':')) {
list($templateid, $file, $clonefile) = explode(':', $file);
$oldfile = $file;
$file = empty($clonefile) || STYLEID != $_G['cache']['style_default']['styleid'] ? $file : $file . '_' . $clonefile;
if ($templateid == 'diy' && STYLEID == $_G['cache']['style_default']['styleid']) {
$_G['style']['prefile'] = '';
$diypath = DISCUZ_ROOT . './data/diy/';
$preend = '_diy_preview';
$previewname = $diypath . $file . $preend . '.htm';
$curtplname = $oldfile;
if (file_exists($diypath . $file . '.htm')) {
$tpldir = 'data/diy';
!$gettplfile && ($_G['style']['tplsavemod'] = 1);
$curtplname = $file;
$flag = file_exists($previewname);
if ($_G['gp_preview'] == 'yes') {
$file .= $flag ? $preend : '';
} else {
$_G['style']['prefile'] = $flag ? 1 : '';
}
} elseif (file_exists($diypath . $oldfile . '.htm')) {
$file = $oldfile;
$tpldir = 'data/diy';
!$gettplfile && ($_G['style']['tplsavemod'] = 0);
$curtplname = $file;
$flag = file_exists($previewname);
if ($_G['gp_preview'] == 'yes') {
$file .= $flag ? $preend : '';
} else {
$_G['style']['prefile'] = $flag ? 1 : '';
}
} else {
$file = $oldfile;
}
$tplrefresh = $_G['config']['output']['tplrefresh'];
if ($tpldir == 'data/diy' && ($tplrefresh == 1 || $tplrefresh > 1 && !($_G['timestamp'] % $tplrefresh)) && @filemtime($diypath . $file . '.htm') && @filemtime($diypath . $file . '.htm') < @filemtime(DISCUZ_ROOT . TPLDIR . '/' . $oldfile . '.htm')) {
if (!updatediytemplate($file)) {
@unlink($diypath . $file . '.htm');
$tpldir = '';
}
}
if (!$gettplfile && empty($_G['style']['tplfile'])) {
$_G['style']['tplfile'] = empty($clonefile) ? $curtplname : $oldfile . ':' . $clonefile;
}
$_G['style']['prefile'] = $_G['gp_preview'] == 'yes' && $_G['gp_preview'] == 'yes' ? '' : $_G['style']['prefile'];
} else {
$tpldir = './source/plugin/' . $templateid . '/template';
}
}
$file .= !empty($_G['inajax']) && ($file == 'common/header' || $file == 'common/footer') ? '_ajax' : '';
$tpldir = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$templateid = $templateid ? $templateid : (defined('TEMPLATEID') ? TEMPLATEID : '');
$tplfile = ($tpldir ? $tpldir . '/' : './template/') . $file . '.htm';
$filebak = $file;
$file == 'common/header' && defined('CURMODULE') && CURMODULE && ($file = 'common/header_' . CURMODULE);
$cachefile = './data/template/' . (defined('STYLEID') ? STYLEID . '_' : '_') . $templateid . '_' . str_replace('/', '_', $file) . '.tpl.php';
if ($templateid != 1 && !file_exists(DISCUZ_ROOT . $tplfile)) {
$tplfile = './template/default/' . $filebak . '.htm';
}
if ($gettplfile) {
return $tplfile;
}
checktplrefresh($tplfile, $tplfile, @filemtime($cachefile), $templateid, $cachefile, $tpldir, $file);
return $cachefile;
}
开发者ID:Kingson4Wu,项目名称:php_demo,代码行数:68,代码来源:function_core.php
示例7: remakediytemplate
function remakediytemplate($primaltplname, $targettplname, $diytplname)
{
global $_G;
if (empty($targettplname)) {
return false;
}
$diydata = DB::fetch_first("SELECT diycontent FROM " . DB::table('common_diy_data') . " WHERE targettplname='{$targettplname}'");
$diycontent = empty($diydata['diycontent']) ? '' : $diydata['diycontent'];
if ($diydata) {
DB::update('common_diy_data', array('primaltplname' => $primaltplname), array('targettplname' => $targettplname));
} else {
$diycontent = '';
if (in_array($primaltplname, array('portal/list', 'portal/view'))) {
$diydata = DB::fetch_first("SELECT diycontent FROM " . DB::table('common_diy_data') . " WHERE targettplname='{$primaltplname}'");
$diycontent = empty($diydata['diycontent']) ? '' : $diydata['diycontent'];
}
$diyarr = array('primaltplname' => $primaltplname, 'targettplname' => $targettplname, 'diycontent' => addslashes($diycontent), 'name' => addslashes($diytplname), 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => TIMESTAMP);
DB::insert('common_diy_data', $diyarr);
}
if (empty($diycontent)) {
$file = ($_G['cache']['style_default']['tpldir'] ? $_G['cache']['style_default']['tpldir'] : './template/default') . '/' . $primaltplname . '.htm';
if (!file_exists($file)) {
$file = './template/default/' . $primaltplname . '.htm';
}
$content = @file_get_contents(DISCUZ_ROOT . $file);
if (!$content) {
$content = '';
}
$content = preg_replace("/\\<\\!\\-\\-\\[name\\](.+?)\\[\\/name\\]\\-\\-\\>/i", '', $content);
file_put_contents(DISCUZ_ROOT . './data/diy/' . $targettplname . '.htm', $content);
} else {
updatediytemplate($targettplname);
}
return true;
}
开发者ID:pan289091315,项目名称:Discuz,代码行数:35,代码来源:admincp_portalcategory.php
示例8: template
function template($file, $templateid = 0, $tpldir = '', $gettplfile = 0, $primaltpl = '')
{
global $_G;
static $_init_style = false;
if ($_init_style === false) {
$discuz =& discuz_core::instance();
$discuz->_init_style();
$_init_style = true;
}
$oldfile = $file;
if (strpos($file, ':') !== false) {
$clonefile = '';
list($templateid, $file, $clonefile) = explode(':', $file);
$oldfile = $file;
$file = empty($clonefile) || STYLEID != $_G['cache']['style_default']['styleid'] ? $file : $file . '_' . $clonefile;
if ($templateid == 'diy' && STYLEID == $_G['cache']['style_default']['styleid']) {
$_G['style']['prefile'] = '';
/*vot*/
$diypath = DISCUZ_ROOT . './data/diy/';
//DIY template file directory
$preend = '_diy_preview';
$_G['gp_preview'] = !empty($_G['gp_preview']) ? $_G['gp_preview'] : '';
$curtplname = $oldfile;
if (isset($_G['cache']['diytemplatename' . $_G['basescript']])) {
$diytemplatename =& $_G['cache']['diytemplatename' . $_G['basescript']];
} else {
$diytemplatename =& $_G['cache']['diytemplatename'];
}
$tplsavemod = 0;
if (isset($diytemplatename[$file]) && file_exists($diypath . $file . '.htm') && ($tplsavemod = 1) || ($file = $primaltpl ? $primaltpl : $oldfile) && isset($diytemplatename[$file]) && file_exists($diypath . $file . '.htm')) {
$tpldir = 'data/diy';
!$gettplfile && ($_G['style']['tplsavemod'] = $tplsavemod);
$curtplname = $file;
/*vot*/
if ($_G['gp_diy'] == 'yes' || $_G['gp_preview'] == 'yes') {
//DIY mode or preview mode, do the following judge
$flag = file_exists($diypath . $file . $preend . '.htm');
if ($_G['gp_preview'] == 'yes') {
$file .= $flag ? $preend : '';
} else {
$_G['style']['prefile'] = $flag ? 1 : '';
}
}
} else {
$file = $primaltpl ? $primaltpl : $oldfile;
}
$tplrefresh = $_G['config']['output']['tplrefresh'];
if ($tpldir == 'data/diy' && ($tplrefresh == 1 || $tplrefresh > 1 && !($_G['timestamp'] % $tplrefresh)) && filemtime($diypath . $file . '.htm') < filemtime(DISCUZ_ROOT . TPLDIR . '/' . ($primaltpl ? $primaltpl : $oldfile) . '.htm')) {
if (!updatediytemplate($file)) {
unlink($diypath . $file . '.htm');
$tpldir = '';
}
}
if (!$gettplfile && empty($_G['style']['tplfile'])) {
$_G['style']['tplfile'] = empty($clonefile) ? $curtplname : $oldfile . ':' . $clonefile;
}
$_G['style']['prefile'] = !empty($_G['gp_preview']) && $_G['gp_preview'] == 'yes' ? '' : $_G['style']['prefile'];
} else {
$tpldir = './source/plugin/' . $templateid . '/template';
}
}
$file .= !empty($_G['inajax']) && ($file == 'common/header' || $file == 'common/footer') ? '_ajax' : '';
$tpldir = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$templateid = $templateid ? $templateid : (defined('TEMPLATEID') ? TEMPLATEID : '');
$filebak = $file;
if (defined('IN_MOBILE') && !defined('TPL_DEFAULT') && strpos($file, 'mobile/') === false || $_G['forcemobilemessage']) {
$file = 'mobile/' . $oldfile;
}
$tplfile = ($tpldir ? $tpldir . '/' : './template/') . $file . '.htm';
$file == 'common/header' && defined('CURMODULE') && CURMODULE && ($file = 'common/header_' . $_G['basescript'] . '_' . CURMODULE);
if (defined('IN_MOBILE') && !defined('TPL_DEFAULT')) {
if (strpos($tpldir, 'plugin')) {
if (!file_exists(DISCUZ_ROOT . $tpldir . '/' . $file . '.htm')) {
require_once libfile('class/error');
discuz_error::template_error('template_notfound', $tpldir . '/' . $file . '.htm');
} else {
$mobiletplfile = $tpldir . '/' . $file . '.htm';
}
}
!$mobiletplfile && ($mobiletplfile = $file . '.htm');
if (strpos($tpldir, 'plugin') && file_exists(DISCUZ_ROOT . $mobiletplfile)) {
$tplfile = $mobiletplfile;
} elseif (!file_exists(DISCUZ_ROOT . TPLDIR . '/' . $mobiletplfile)) {
$mobiletplfile = './template/default/' . $mobiletplfile;
if (!file_exists(DISCUZ_ROOT . $mobiletplfile) && !$_G['forcemobilemessage']) {
$tplfile = str_replace('mobile/', '', $tplfile);
$file = str_replace('mobile/', '', $file);
define('TPL_DEFAULT', true);
} else {
$tplfile = $mobiletplfile;
}
} else {
$tplfile = TPLDIR . '/' . $mobiletplfile;
}
}
$cachefile = './data/template/' . (defined('STYLEID') ? STYLEID . '_' : '_') . $templateid . '_' . str_replace('/', '_', $file) . '.tpl.php';
if ($templateid != 1 && !file_exists(DISCUZ_ROOT . $tplfile)) {
$tplfile = './template/default/' . $filebak . '.htm';
}
if ($gettplfile) {
//.........这里部分代码省略.........
开发者ID:v998,项目名称:discuzx-en,代码行数:101,代码来源:function_core.php
示例9: template
/**
* 解析模板
* @return 返回域名
*/
function template($file, $templateid = 0, $tpldir = '', $gettplfile = 0, $primaltpl = '')
{
global $_G;
static $_init_style = false;
if ($_init_style === false) {
C::app()->_init_style();
$_init_style = true;
}
$oldfile = $file;
//原模板
if (strpos($file, ':') !== false) {
$clonefile = '';
list($templateid, $file, $clonefile) = explode(':', $file);
$oldfile = $file;
$file = empty($clonefile) ? $file : $file . '_' . $clonefile;
if ($templateid == 'diy') {
$indiy = false;
//是否存在DIY
$_G['style']['tpldirectory'] = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
//模板文件所在的目录,DIY保存时使用
$_G['style']['prefile'] = '';
//非预览环境标记预览文件是否存在
$diypath = DISCUZ_ROOT . './data/diy/' . $_G['style']['tpldirectory'] . '/';
//DIY模板文件目录
$preend = '_diy_preview';
//预览文件后缀
$_GET['preview'] = !empty($_GET['preview']) ? $_GET['preview'] : '';
//是否预览
$curtplname = $oldfile;
//当前模板名
$basescript = $_G['mod'] == 'viewthread' && !empty($_G['thread']) ? 'forum' : $_G['basescript'];
//帖子查看页归到froum中
if (isset($_G['cache']['diytemplatename' . $basescript])) {
$diytemplatename =& $_G['cache']['diytemplatename' . $basescript];
//当前应用的DIY文件缓存
} else {
if (!isset($_G['cache']['diytemplatename'])) {
loadcache('diytemplatename');
}
$diytemplatename =& $_G['cache']['diytemplatename'];
//所有DIY文件缓存
}
$tplsavemod = 0;
//公共DIY页面标记
//独立DIY页面 || 分区或版块没有指定模板 && 公共DIY页面
if (isset($diytemplatename[$file]) && file_exists($diypath . $file . '.htm') && ($tplsavemod = 1) || empty($_G['forum']['styleid']) && ($file = $primaltpl ? $primaltpl : $oldfile) && isset($diytemplatename[$file]) && file_exists($diypath . $file . '.htm')) {
$tpldir = 'data/diy/' . $_G['style']['tpldirectory'] . '/';
//文件目录
!$gettplfile && ($_G['style']['tplsavemod'] = $tplsavemod);
//独立DIY页面标记:1,公共DIY页面标记:0
$curtplname = $file;
//当前模板名
if (isset($_GET['diy']) && $_GET['diy'] == 'yes' || isset($_GET['diy']) && $_GET['preview'] == 'yes') {
//DIY模式或预览模式下做以下判断
$flag = file_exists($diypath . $file . $preend . '.htm');
//预览文件是否存在
if ($_GET['preview'] == 'yes') {
//预览环境
$file .= $flag ? $preend : '';
//使用预览模板文件
} else {
$_G['style']['prefile'] = $flag ? 1 : '';
//非预览环境标记预览文件是否存在
}
}
$indiy = true;
} else {
$file = $primaltpl ? $primaltpl : $oldfile;
//无DIY页面则使用原模板
}
//根据模板自动刷新开关$tplrefresh 更新DIY模板
$tplrefresh = $_G['config']['output']['tplrefresh'];
//在有DIY生成模板文件时 && 自动刷新开启 && DIY生成模板文件修改时间 < 原模板修改修改
if ($indiy && ($tplrefresh == 1 || $tplrefresh > 1 && !($_G['timestamp'] % $tplrefresh)) && filemtime($diypath . $file . '.htm') < filemtime(DISCUZ_ROOT . $_G['style']['tpldirectory'] . '/' . ($primaltpl ? $primaltpl : $oldfile) . '.htm')) {
//原模板更改则更新DIY模板,如果更新失败则删除DIY模板
if (!updatediytemplate($file, $_G['style']['tpldirectory'])) {
unlink($diypath . $file . '.htm');
$tpldir = '';
}
}
//保存当前模板名
if (!$gettplfile && empty($_G['style']['tplfile'])) {
$_G['style']['tplfile'] = empty($clonefile) ? $curtplname : $oldfile . ':' . $clonefile;
}
//是否显示继续DIY
$_G['style']['prefile'] = !empty($_GET['preview']) && $_GET['preview'] == 'yes' ? '' : $_G['style']['prefile'];
} else {
$tpldir = './source/plugin/' . $templateid . '/template';
}
}
$file .= !empty($_G['inajax']) && ($file == 'common/header' || $file == 'common/footer') ? '_ajax' : '';
$tpldir = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$templateid = $templateid ? $templateid : (defined('TEMPLATEID') ? TEMPLATEID : '');
$filebak = $file;
//X 将页面模板加一层Mobile目录,用以定位手机模板页面(IN_MOBILE)
if (defined('IN_MOBILE') && !defined('TPL_DEFAULT') && strpos($file, $_G['mobiletpl'][IN_MOBILE] . '/') === false || isset($_G['forcemobilemessage']) && $_G['forcemobilemessage']) {
//.........这里部分代码省略.........
开发者ID:vanloswang,项目名称:discuzx-1,代码行数:101,代码来源:function_core.php
示例10: templateEx
function templateEx($file, $templateid = 0, $tpldir = '', $gettplfile = 0, $primaltpl = '')
{
global $_G, $brandresult;
$m = md5($file);
if (empty($_G[$m])) {
hookscript('sanreebrandtemplatefile', 'global', 'funcs', array('file' => &$file, 'templateid' => &$templateid, 'tpldir' => &$tpldir, 'gettplfile' => &$gettplfile, 'primaltpl' => &$primaltpl), 'sanreebrandtemplatefile');
$_G[$m] = true;
}
$appVer = $_G['setting']['version'];
$debartemplate = array('srhead', 'srfoot', 'header_one_' . $appVer);
list($plugin, $temp) = explode(':', $file);
list($template, $birdfile) = explode('/', $temp);
if ($_G['cache']['plugin']['sanree_brand']['isbird'] && !in_array($birdfile, $debartemplate)) {
$birdtemplate = array('index', 'hello', 'christmas', 'newyear', 'springfestival', 'item', 'detail', 'albumlist', 'albumshow');
if ($_G['item_detail'] == 'detail') {
$birdfile = $_G['item_detail'];
}
$fulltemplate = array('item', 'detail', 'albumlist', 'albumshow');
$fullflag = array('item' => 'index', 'detail' => 'detail', 'albumlist' => 'myalbum', 'albumshow' => 'myalbum');
if (in_array($birdfile, $fulltemplate)) {
require_once libfile('class/' . $plugin . '_newmenu', 'plugin/' . $plugin);
new sanree_brand_newmenu($fullflag[$birdfile], $brandresult, $birdfile);
}
if ($plugin == 'sanree_brand' && in_array($birdfile, $birdtemplate)) {
$template = 'bird';
define('BIRD_IMG', 'source/plugin/' . $plugin . '/tpl/' . $template . '/images/');
define('BIRD_JS', 'source/plugin/' . $plugin . '/tpl/' . $template . '/js/');
define('BIRD_CSS', 'source/plugin/' . $plugin . '/tpl/' . $template . '/');
$birdindex = array('index', 'hello', 'christmas', 'newyear', 'springfestival');
if (in_array($birdfile, $birdindex)) {
$file = $plugin . ':' . $template . '/' . $birdtemplate[0];
} elseif ($birdfile == $fulltemplate[0]) {
$file = $plugin . ':' . $template . '/' . $birdfile . '_' . $fullflag[$birdfile];
} elseif ($birdfile == $fulltemplate[1]) {
$file = $plugin . ':' . $template . '/' . $fulltemplate[0] . '_' . $birdfile;
} elseif ($birdfile == $fulltemplate[2]) {
$file = $plugin . ':' . $template . '/' . $birdfile;
} elseif ($birdfile == $fulltemplate[3]) {
$file = $plugin . ':' . $template . '/' . $birdfile;
}
}
}
if ($_G['setting']['version'] == 'X2.5' || $_G['setting']['version'] == 'X3' || $_G['setting']['version'] == 'X3.1' || $_G['setting']['version'] == 'X3.2') {
static $_init_style = false;
if ($_init_style === false) {
C::app()->_init_style();
$_init_style = true;
}
} else {
if (!defined('STYLEID')) {
define('STYLEID', 1);
}
}
$oldfile = $file;
if (strpos($file, ':') !== false) {
$clonefile = '';
list($templateid, $file, $clonefile) = explode(':', $file);
$oldfile = $file;
$file = empty($clonefile) ? $file : $file . '_' . $clonefile;
if ($templateid == 'diy') {
$indiy = false;
$_G['style']['tpldirectory'] = $tpldir ? $tpldir : (defined('TPLDIR') ? TPLDIR : '');
$_G['style']['prefile'] = '';
$diypath = DISCUZ_ROOT . './data/diy/' . $_G['style']['tpldirectory'] . '/';
//DIY模板文件目录
$preend = '_diy_preview';
$_GET['preview'] = !empty($_GET['preview']) ? $_GET['preview'] : '';
$curtplname = $oldfile;
$basescript = $_G['mod'] == 'viewthread' && !empty($_G['thread']) ? 'forum' : $_G['basescript'];
if (isset($_G['cache']['diytemplatename' . $basescript])) {
$diytemplatename =& $_G['cache']['diytemplatename' . $basescript];
} else {
if (!isset($_G['cache']['diytemplatename'])) {
loadcache('diytemplatename');
}
$diytemplatename =& $_G['cache']['diytemplatename'];
}
$tplsavemod = 0;
if (isset($diytemplatename[$file]) && file_exists($diypath . $file . '.php') && ($tplsavemod = 1) || empty($_G['forum']['styleid']) && ($file = $primaltpl ? $primaltpl : $oldfile) && isset($diytemplatename[$file]) && file_exists($diypath . $file . '.php')) {
$tpldir = 'data/diy/' . $_G['style']['tpldirectory'] . '/';
!$gettplfile && ($_G['style']['tplsavemod'] = $tplsavemod);
$curtplname = $file;
if (isset($_GET['diy']) && $_GET['diy'] == 'yes' || isset($_GET['diy']) && $_GET['preview'] == 'yes') {
//DIY模式或预览模式下做以下判断
$flag = file_exists($diypath . $file . $preend . '.php');
if ($_GET['preview'] == 'yes') {
$file .= $flag ? $preend : '';
} else {
$_G['style']['prefile'] = $flag ? 1 : '';
}
}
$indiy = true;
} else {
$file = $primaltpl ? $primaltpl : $oldfile;
}
$tplrefresh = $_G['config']['output']['tplrefresh'];
if ($indiy && ($tplrefresh == 1 || $tplrefresh > 1 && !($_G['timestamp'] % $tplrefresh)) && filemtime($diypath . $file . '.php') < filemtime(DISCUZ_ROOT . $_G['style']['tpldirectory'] . '/' . ($primaltpl ? $primaltpl : $oldfile) . '.php')) {
if (!updatediytemplate($file, $_G['style']['tpldirectory'])) {
unlink($diypath . $file . '.php');
$tpldir = '';
//.........这里部分代码省略.........
开发者ID:herosrx,项目名称:shops,代码行数:101,代码来源:function_core.php
示例11: array
$diyarr = array('primaltplname' => $primaltplname, 'targettplname' => $targettplname, 'diycontent' => addslashes($diycontent), 'name' => $_G['gp_catname'], 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => TIMESTAMP);
DB::insert('common_diy_data', $diyarr);
}
if (empty($diycontent)) {
$file = ($_G['cache']['style_default']['tpldir'] ? $_G['cache']['style_default']['tpldir'] : './template/default') . '/' . $primaltplname . '.htm';
if (!file_exists($file)) {
$file = './template/default/' . $primaltplname . '.htm';
}
$content = @file_get_contents(DISCUZ_ROOT . $file);
if (!$content) {
$content = '';
}
$content = preg_replace("/\\<\\!\\-\\-\\[name\\](.+?)\\[\\/name\\]\\-\\-\\>/i", '', $content);
file_put_contents(DISCUZ_ROOT . './data/diy/' . $targettplname . '.htm', $content);
} else {
updatediytemplate($targettplname);
}
}
include_once libfile('function/cache');
updatecache('portalcategory');
loadcache('portalcategory', true);
$portalcategory = $_G['cache']['portalcategory'];
if (!empty($updatecategoryfile)) {
remakecategoryfile($updatecategoryfile);
}
if ($dir) {
if (!makecategoryfile($dir, $_G['gp_catid'], $domain)) {
cpmsg(cplang('portalcategory_filewrite_error') . ',' . cplang('return'), NULL, 'error');
}
remakecategoryfile($portalcategory[$_G['gp_catid']]['children']);
}
开发者ID:v998,项目名称:discuzx-en,代码行数:31,代码来源:admincp_portalcategory.php
注:本文中的updatediytemplate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论