📄 category.php
字号:
if(file_exists(DIR_CACHE . 'cache_Cate.inc.php') && file_exists(DIR_CACHE . 'cache_Category.inc.php')){
include(DIR_CACHE . 'cache_Cate.inc.php');
include(DIR_CACHE . 'cache_Category.inc.php');
foreach($Cate as $key=>$category){
if($category[ParentID]=='-1'){
$CList[Title]=$category[Title];
$CList[CateID]=$category[CateID];
if(is_array($cachecates[$category[CateID]]))$CList[haveSon]='1';
$CateList[]=$CList;
}
}
}
$this->tpl->assign('CateList',$CateList);
$this->tpl->display('admin/tree_Cate_select.html');
}
function oncate_select_xml(){
include(DIR_CACHE . 'cache_Cate.inc.php');
include(DIR_CACHE . 'cache_Category.inc.php');
foreach($Cate as $key=>$category){
if($category[ParentID]==$this->in[CateID]){
$CList[Title]=$category[Title];
$CList[CateID]=$category[CateID];
if(is_array($cachecates[$category[CateID]]))$CList[haveSon]='1';
$CateList[]=$CList;
}
}
header("Content-type: text/xml");
echo'<?xml version="1.0" encoding="gb2312" ?'.'>'."\r\n";
$this->tpl->assign('CateList',$CateList);
$this->tpl->display('admin/Cate_select_xml.xml');
}
function onmove(){
if (function_exists("set_time_limit")==1 and get_cfg_var("safe_mode")==0) {
@set_time_limit(1200);
}
$data[ParentID]=$this->in[targetCateID];
$this->objDataSet->update($data, "CateID = '" . $this->in['CateID'] . "'", $this->category);
$subCate_array = explode(",",$this->getSub($this->in[CateID]));
$subCate_num = count($subCate_array);
for ($i=0;$i<$subCate_num;$i++) {
$this->updateparentlist($Cate_array[$i]);
}
$this->cachecates();
echo '<script>top.panelMenu.location= "index.php?module=category&act=menu";</script>';
}
function getparentCate($CateID){//取得列表
$Cates=$this->db->query("SELECT ParentID FROM ".$this->category." WHERE CateID='$CateID'");
while($Cate=$this->db->fetch_array($Cates)){
$CateID .=",";
$CateID .=$this->getparentCate($Cate[ParentID]);
}
return $CateID;
}
function updateparentlist($CateID) {//更新列表
$this->db->query("UPDATE ".$this->category." SET
ParentList='".$this->getparentCate($CateID)."'
WHERE CateID='$CateID'");
}
function getSub($CID, $sq = ',')
{
include DIR_CACHE . 'cache_Cate.inc.php';
$subcate = $CID;
foreach($Cate as $tmp) {
if ($tmp[ParentID] == $CID) {
$subcate .= $sq . $this->getSub($tmp[CateID]);
}
}
return $subcate;
}
function CreatTable($id,$cid)
{
include(DIR_CACHE . 'cache_contentmodel.inc.php');
$sql = 'CREATE TABLE `' . DBPREFIX . 'content_' . $cid . '` (';
$sql .= '`ContentID` int(10) unsigned NOT NULL auto_increment,`CateID` int(10) unsigned NOT NULL,';
// print_r($content_model_info[$id]);
foreach($content_model_info[$id][Model] as $key => $content) {
$sql .= "`" . $content[FieldName] . "` ";
if (!ereg('text', $content[FieldType])) {
if ($content[FieldSize] == '' && ereg('varchar', $content[FieldType])) {
$content[FieldSize] = '255';
} elseif ($content[FieldSize] == '' && ereg('int', $content[FieldType])) {
$content[FieldSize] = '20';
}
$sql .= $content[FieldType] . '(' . $content[FieldSize] . ') NOT NULL default \'' . $content[FieldDefaultValue] . '\',';
} else {
$sql .= $content[FieldType] . " NOT NULL,";
}
}
$sql .="`CreationDate` int(10) NOT NULL default '0',
`ModifiedDate` int(10) NOT NULL default '0',
`CreationUserID` int(8) NOT NULL default '0',
`LastModifiedUserID` int(8) NOT NULL default '0',
`ContributionUserID` int(8) NOT NULL default '0',
`ContributionID` int(8) NOT NULL default '0',
PRIMARY KEY (`ContentID`)
) TYPE=MyISAM PACK_KEYS=0;";
if ($this->db->query($sql)) {
$data[db_name] = DBPREFIX . 'content_' . $cid;
$this->objDataSet->insert($data, $this->db_set);
$this->dbprefix();
return ture;
} else {
return false;
}
}
function onfileformat()
{
$this->tpl->display('admin/PublishFileFormat.html');
}
// 刷新后台数据表缓存
function dbprefix()
{
$sql = "select * from " . DBPREFIX . "db_set order by `db_id`";
$this->db->query($sql);
$db_array = array();
while ($row = $this->db->fetch_array()) {
$db_array[] = $row;
}
$this->dbSet = $db_array;
$dbcache = var_export($db_array, true) . ';' . PHP_NEXTLINE . PHP_NEXTLINE;
if (@$fp = fopen(DIR_CACHE . 'cache_dbset.inc.php', 'w')) {
@fwrite($fp, "<?php" . PHP_NEXTLINE . "//SSMS cache file, DO NOT modify me!" .
PHP_NEXTLINE . "//Created on " . date("M j, Y,G:i") . PHP_NEXTLINE . PHP_NEXTLINE . "\$dbSet=" . $dbcache . PHP_CLOSE_TAG);
@fclose($fp);
} else {
exit('Can not write to cache file, please check cache directory.');
}
}
// 刷新后台频道缓存
function cachecates()
{
$sql = "SELECT * FROM " . $this->category . " ORDER BY ParentID ASC";
$this->db->query($sql);
$cachecates = array();
$cachecate = array();
while ($row = $this->db->fetch_array()) {
$cachecates[$row[ParentID]][$row[CateID]][CateID] = $row[CateID];
$cachecates[$row[ParentID]][$row[CateID]][Title] = $row[Title];
$cachecate[$row[CateID]] = $row;
}
$caches = var_export($cachecates, true) . ';' . PHP_NEXTLINE . PHP_NEXTLINE;
$cache = var_export($cachecate, true) . ';' . PHP_NEXTLINE . PHP_NEXTLINE;
if (@$fp = fopen(DIR_CACHE . 'cache_Category.inc.php', 'w')) {
@fwrite($fp, "<?php" . PHP_NEXTLINE . "//SSMS cache file, DO NOT modify me!" . PHP_NEXTLINE . "//Created on " . date("M j, Y,G:i") . PHP_NEXTLINE . PHP_NEXTLINE . "\$cachecates=" . $caches . PHP_CLOSE_TAG);
@fclose($fp);
} else {
exit('Can not write to cache file, please check cache directory.');
}
if (@$fp = fopen(DIR_CACHE . 'cache_Cate.inc.php', 'w')) {
@fwrite($fp, "<?php" . PHP_NEXTLINE . "//SSMS cache file, DO NOT modify me!" . PHP_NEXTLINE . "//Created on " . date("M j, Y,G:i") . PHP_NEXTLINE . PHP_NEXTLINE . "\$Cate=" . $cache . PHP_CLOSE_TAG);
@fclose($fp);
} else {
exit('Can not write to cache file, please check cache directory.');
}
}
// 获取内容模型列表
function getContentModel()
{
if(file_exists(DIR_CACHE . 'cache_contentmodel.inc.php')){
include(DIR_CACHE . 'cache_contentmodel.inc.php');
foreach($content_model_info as $key => $content) {
if ($this->content==$key) {
$list .= "<option value=\"$content[ContentModelID]\" selected>$content[ContentModelName]</option>\n";
} else {
$list .= "<option value=\"$content[ContentModelID]\" >$content[ContentModelName]</option>\n";
}
}
}
return $list;
}
function getcatelistbit($CateID = "-1", $level = 1)
{
if(file_exists(DIR_CACHE . 'cache_Category.inc.php')){
include(DIR_CACHE . 'cache_Category.inc.php');
if (isset($cachecates[$CateID])) {
foreach($cachecates[$CateID] AS $key => $cate) {
if ($level == 1)$this->css[$cate[CateID]] = 'option_cate';
$this->option[$cate[CateID]] = str_repeat("--", $level-1) . " $cate[Title]";
$this->getcatelistbit($cate[CateID], $level + 1);
}
}
}
}
function getcatelist()
{
$this->getcatelistbit();
if(is_array($this->option)){
foreach ($this->option AS $key => $value) {
if ($this->selected == $key) {
$list .= "<option value=\"$key\" selected class=\"{$this->css[$key]}\">$value</option>\n";
} else {
$list .= "<option value=\"$key\" class=\"{$this->css[$key]}\">$value</option>\n";
}
}
}
return $list;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -