?? html.php
字號(hào):
<?php
include DIR_INCLUDES . 'cms_function.inc.php';
class CPage extends Page {
var $CateID;
var $ContentID;
var $TableID;
var $ContentTpl;
var $RPSN;
var $URL;
var $SubDir;
var $PublisDate;
var $IndexID;
var $Model;
function CPage(&$app)
{
$this->Page($app);
$this->userid = userid;
$this->user_username = username;
$this->app->includeClass("Files");
$this->Files = new Files;
}
function page_load()
{
if (empty($this->in['act'])) $this->onMake();
}
function onMake()
{
include DIR_CACHE . 'cache_Cate.inc.php';
include DIR_CACHE . 'cache_Category.inc.php';
$ContentID = intval($this->in['ContentID']); //獲取當(dāng)前內(nèi)容ID(內(nèi)容表內(nèi))
$CateID = intval($this->in['CateID']); //內(nèi)容的分類(lèi)ID
$IndexID = intval($this->in['IndexID']); //文章的索引ID
if (empty($IndexID)) {
// 下面兩行用來(lái)獲取當(dāng)前文章在系統(tǒng)文章庫(kù)中的索引號(hào)碼
$sql = "SELECT * FROM " . $this->content_index . " WHERE ContentID=" . $ContentID . " AND CateID=" . $CateID;
} else $sql = "SELECT * FROM " . $this->content_index . " WHERE IndexID=" . $IndexID;
$query = $this->db->query($sql);
$contentIndex = $this->db->fetch_array($query);
$this->CateID = $contentIndex[CateID];
$this->TableID = $Cate[$this->CateID][TableID];
$contentIndex['SelfTemplate'] == ''?$this->ContentTpl = $Cate[$CateID]['ContentTpl']:$this->ContentTpl = $contentIndex['SelfTemplate'];
$contentIndex['SelfPSN'] == ''?$this->RPSN = $Cate[$CateID]['ResourcePSN']:$this->RPSN = $contentIndex['SelfPSN'];
$contentIndex['SelfPSNURL'] == ''?$this->URL = $Cate[$CateID]['ResourceURL']:$this->URL = $contentIndex['SelfPSNURL'];
$contentIndex['SelfPublishFileName'] == ''?$this->fntype = $Cate[$CateID]['ContentFileName']:$this->fntype = $contentIndex['SelfPublishFileName'];
$this->ContentID = $contentIndex[ContentID];
$this->PublishDate = $contentIndex[PublishDate];
$this->SubDir = $Cate[$this->CateID]['SubDir'];
// $this->PublisDate = $contentIndex['PublishDate'];
$this->IndexID = $contentIndex['IndexID'];
$this->Model = $Cate[$this->CateID][ContentModel];
$msg = $this->MakeContent();
$this->tpl->assign('msg', $msg);
$this->tpl->display('admin/msg.html');
}
function MakeContent()
{
include DIR_CACHE . 'cache_PSN.inc.php';
include DIR_CACHE . 'cache_contentmodel.inc.php';
// 獲取當(dāng)前分類(lèi)的內(nèi)容模板名稱(chēng)
if ($this->ContentTpl == '')$this->ContentTpl = 'default/content.html';
// 開(kāi)始獲取文章內(nèi)容等字段
$value = $this->objDataSet->getDataById($this->ContentID, "ContentID", $this-> {
'content_' . $this->TableID}
);
// 開(kāi)始計(jì)算文件名的定義,并分離出主文件名和擴(kuò)展文件名(分離是為了生成分頁(yè)文件)
$fntype = str_replace("{ContentID}", $this->ContentID, $this->fntype);
$fntype = str_replace("{CateID}", $this->CateID, $fntype);
$fntype = str_replace("{TimeStamp}", $this->PublishDate, $fntype);
$fntype = str_replace("{IndexID}", $this->IndexID, $fntype);
$this->tpl->assign('IndexID',$this->IndexID);
$this->tpl->assign('PublishDate',$this->PublishDate);
$apos = strpos($fntype, ".");
if (!$apos) {
$filename = $fntype;
$ext = ".html";
} else {
$filename = substr($fntype, 0, $apos);
$ext = substr($fntype, $apos);
}
// 計(jì)算文件名的定義結(jié)束。
// 下面用來(lái)獲取當(dāng)前文章的發(fā)布人,如果不需要顯示的話,可以將
$userid = userid;
$users = $this->objDataSet->getDataById($value['CreationUserID'], $userid, $this->user);
// 以下開(kāi)始計(jì)算當(dāng)前分類(lèi)內(nèi)容頁(yè)面保存的位置
preg_match("/{PSN:(\d)}(.*)/is", $this->RPSN, $p);
$RPSN = $PSN_cache[$p[1]]['PSN'];
$RPSN = ltrim(rtrim(str_replace("Local::", "", $RPSN)));
$RPSN .= $p[2];
$RPSN .= "/";
if ($this->SubDir) {
$subdir = date($this->SubDir, $value[CreationDate]);
}
if ($subdir)$RPSN .= $subdir . "/";
$RPSN = str_replace("//", "/", $RPSN);
preg_match("/{PSN-URL:(\d)}(.*)/is", $this->URL, $p);
$RPSNURL = $PSN_cache[$p[1]]['URL'];
$RPSNURL .= $p[2];
$RPSNURL .= "/";
if ($this->SubDir)$RPSNURL .= $subdir . "/";
if (!is_dir($RPSN)) {
$this->Files->mDir($RPSN);
}
// echo $this->makenavbar($CateID);
// 合并生成文件夾和主文件名
$Pfilename = $RPSN . $filename;
$url = $RPSNURL . $filename;
// $this->tpl->assign('CreationDate', $value['CreationDate']);
$this->tpl->assign('PUBLISH_URL', HTTP_SERVER);
// $this->tpl->assign('Title',$value[Title]);
$this->tpl->assign($value);
$this->tpl->assign('Navigation', $this->MakeNavigation($this->CateID));
foreach($content_model_info[$this->Model][Model] as $k => $val) {
$FieldName = $val['FieldName'];
$FieldText = $value[$val['FieldName']];
if ($val['IsMainField'] == '1') {
$Content = stripslashes($value[$val['FieldName']]);
} elseif ($val['IsTitleField'] == '1') {
$Title = $value[$val['FieldName']];
}
}
$page = $this->page_chunk($Content, $Title);
$this->tpl->assign('Editor', $users['user_username']);
if (count($page) <= '1') {
$this->tpl->assign('PageTitle', $Title);
$this->tpl->assign('Content', $Content);
$msg = "MakeHtml==><a href=" . $url . $ext . ">" . $Pfilename . $ext . "</a><br>";
$string = $this->tpl->display($this->ContentTpl, 1);
$this->Files->write($Pfilename . $ext, $string);
} else {
unset($pages);
if (count($page) != '1') {
for($i = 0;$i < count($page);$i++) {
if (!$i) {
$fn = $Pfilename . $ext;
$fnurl = $url . $ext;
} else {
$fn = $Pfilename . "_" . $i . $ext;
$fnurl = $url . "_" . $i . $ext;
}
$j = $i + 1;
$pages[$j][URL] = $fnurl;
$pages[$j][Title] = $page[$i][Title];
}
}
$msg = '';
for($i = 0;$i < count($page);$i++) {
if (!$i) {
$fn = $Pfilename . $ext;
$fnurl = $url . $ext;
} else {
$fn = $Pfilename . "_" . $i . $ext;
$fnurl = $url . "_" . $i . $ext;
}
$msg .= "MakeHtml==><a href=" . $fnurl . ">" . $fn . "</a><br>";
$this->tpl->assign('PageNav', $pages);
$this->tpl->assign('PageTitle', $page[$i][Title]);
$this->tpl->assign('Content', $page[$i][Content]);
$string = $this->tpl->display($this->ContentTpl, 1);
$this->tpl->uassign('PageNav'); //刪除模板變量PageNav;否則他將一直存在直到下一次被相同的變量所覆蓋!
$this->Files->write($fn, $string);
}
}
return $msg;
}
function page_chunk($str, $first = '', $regexp = "#\[page:([^\]]+)\]#i") // $first???????
{
$match = array();
preg_match_all($regexp, $str, $match);
$page_title_list = $match[1];
$page_content_list = preg_split($regexp, $str);
array_unshift($page_title_list, $first);
for($ii = 0; $ii < count($page_title_list); $ii++) {
if (trim($page_content_list[$ii]) == '')continue;
$pages['Title'] = $page_title_list[$ii];
$pages['Content'] = $page_content_list[$ii];
$page[] = $pages;
}
Return $page;
}
function onrefreshIndex()
{
include DIR_CACHE . 'cache_Cate.inc.php';
$CateID = $this->in[CateID];
echo "<script language='JavaScript'>top.TaskInfoFrame.addInfo('Updating index.html at " . $Cate[$CateID][Title] . " failed.', 'refreshIndex" . $CateID . "')</script><script language='JavaScript'>parent.endThread('refreshIndex" . $CateID . "');</script>";
}
function onsiteRefresh()
{
$this->tpl->display('admin/siteRefresh.html');
}
function CateRefresh()
{
include DIR_CACHE . 'cache_Cate.inc.php';
$this->objDataSet->html = '1';
$this->objDataSet->filename = 'index';
$this->objDataSet->ext = 'html';
$this->objDataSet->pagenum = $this->in[page];
if ($this->CateID == '0')$this->CateID = '1';
$this->CateID != ''?$where = ' where CateID=' . $this->CateID:'';
$loop_data = $this->objDataSet->getList("select * from " . $this->content_index . $where . " order by IndexID", $this->content_num);
if (is_array($loop_data->field)) {
foreach($loop_data->field as $contentIndex) {
$this->CateID = $contentIndex[CateID];
$this->TableID = $Cate[$this->CateID][TableID];
$contentIndex['SelfTemplate'] == ''?$this->ContentTpl = $Cate[$this->CateID]['ContentTpl']:$this->ContentTpl = $contentIndex['SelfTemplate'];
$contentIndex['SelfPSN'] == ''?$this->RPSN = $Cate[$this->CateID]['ResourcePSN']:$this->RPSN = $contentIndex['SelfPSN'];
$contentIndex['SelfPSNURL'] == ''?$this->URL = $Cate[$this->CateID]['ResourceURL']:$this->URL = $contentIndex['SelfPSNURL'];
$contentIndex['SelfPublishFileName'] == ''?$this->fntype = $Cate[$this->CateID]['ContentFileName']:$this->fntype = $contentIndex['SelfPublishFileName'];
$this->ContentID = $contentIndex[ContentID];
$this->SubDir = $Cate[$this->CateID]['SubDir'];
$this->PublishDate = $contentIndex[PublishDate];
$this->IndexID = $contentIndex['IndexID'];
$this->Model = $Cate[$this->CateID][ContentModel];
$msg .= $this->MakeContent();
}
$this->tpl->assign('msg', $msg);
$this->in[page]?$page = $this->in[page]:$page = '1';
$page++;
echo "<script language='JavaScript'>top.TaskInfoFrame.addInfo('Updating content Cate" . $CateID . " (" . $loop_data->startnum . "," . $loop_data->endnum . ")', 'refreshcontent " . $CateID . "')</script>";
if ($page <= $loop_data->totalpage) {
return $page;
}
}
}
function onrefreshSite()
{
include DIR_CACHE . 'cache_Cate.inc.php';
$this->app->includeClass("Files");
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -