📄 category.php
字号:
<?php
class CPage extends Page {
function CPage(&$app)
{
$this->Page($app);
$this->selected = $this->in['_GET']['ParentID'];
}
function page_load()
{
$this->objDataSet->setTable($this->category);
if (empty($this->in['act'])) $this->onList();
}
function onInsert()
{
if ($this->in['_POST']['do']) {
include DIR_CACHE . 'cache_contentmodel.inc.php';
if (trim($this->in['_POST']['data_Title']) == '') {
$this->err->catchErr($this->app->getSysMsg('isempty', "title"));
$this->page_err();
}
$this->in['_POST'][PerPage] = intval($this->in['_POST']['data'][PerPage]);
if ($this->in['_POST']['data'][PerPage] < 10) {
$this->in['_POST']['data'][PerPage] = 10;
}
$Model=$this->in['_POST']['data_ContentModel'];
$TableID=$content_model_info[$Model][TableID];
// `CateID` , `Title` , `Description` , `Displayorder` , `ParentID` , `Img` , `ParentList` , `PerPage` , `StyleID` , `DoHtml` , `HotNum` , `ListFileName` , `ContentFileName` , `CateDir` , `CateUrl` , `MaxPage`
$data = array(Title => addslashes($this->in['_POST']['data_Title']),
Description => addslashes($this->in['_POST']['data_Description']),
Displayorder => intval($this->in['_POST']['data_Displayorder']),
ParentID => intval($this->in['_POST']['data_ParentID']),
Img => addslashes($this->in['_POST']['data_Img']),
ContentModel => intval($this->in['_POST']['data_ContentModel']),
TableID=>$TableID,
PerPage => intval($this->in['_POST']['data_PerPage']),
IndexTpl => addslashes($this->in['_POST']['data_IndexTpl']),
ContentTpl => addslashes($this->in['_POST']['data_ContentTpl']),
ImageTpl => addslashes($this->in['_POST']['data_ImageTpl']),
DoHtml => intval($this->in['_POST']['data_DoHtml']),
HotNum => intval($this->in['_POST']['data_HotNum']),
ListFileName => addslashes($this->in['_POST']['data_ListFileName']),
ContentFileName => addslashes($this->in['_POST']['data_ContentFileName']),
ResourcePSN=> addslashes($this->in['_POST']['data_ResourcePSN']),
ResourceURL => addslashes($this->in['_POST']['data_ResourceURL']),
SubDir => addslashes($this->in['_POST']['data_SubDir']),
MaxPage => intval($this->in['_POST']['data_MaxPage']));
$CateID = $this->objDataSet->insert($data, $this->category);
$this->page_err();
$sql='SELECT * FROM '.DBPREFIX . 'content_'. $TableID.' LIMIT 0,1';
if(!$this->db->query($sql)) $this->CreatTable($this->in['_POST']['data_ContentModel'], $TableID);
$this->updateparentlist($CateID);
$this->cachecates();
$this->tpl->assign('javascript', '<script>top.panelMenu.location= "index.php?module=category&act=menu";</script>');
}
!empty($this->in['_GET']['ParentID'])?$updateData[ParentID]= $this->in['_GET']['ParentID']:$updateData[ParentID]='-1';
$this->tpl->assign('act', 'Insert');
$this->tpl->assign('updateData', $updateData);
$this->content = $updateData[ContentModel];
$this->tpl->assign('ContentModel', $this->getContentModel());
$this->tpl->assign('list', $this->getcatelist());
$this->tpl->assign("title", $this->app->getSysMsg('addcate'));
$this->tpl->display( "admin/category_insert.htm");
}
function onupdate()
{
if ($this->in['_POST']['do']) {
if (trim($this->in['_POST']['data_Title']) == '') {
$this->err->catchErr($this->app->getSysMsg('isempty', "title"));
$this->page_err();
}
$this->in['_POST']['data'][PerPage] = intval($this->in['_POST']['data'][PerPage]);
if ($this->in['_POST']['data'][PerPage] < 10) {
$this->in['_POST']['data'][PerPage] = 10;
}
$this->in['_POST']['data_ContentModel'] = $cate['ContentModel'];
$data = array(Title => addslashes($this->in['_POST']['data_Title']),
Description => addslashes($this->in['_POST']['data_Description']),
Displayorder => intval($this->in['_POST']['data_Displayorder']),
ParentID => intval($this->in['_POST']['data_ParentID']),
Img => addslashes($this->in['_POST']['data_Img']),
PerPage => intval($this->in['_POST']['data_PerPage']),
IndexTpl => addslashes($this->in['_POST']['data_IndexTpl']),
ContentTpl => addslashes($this->in['_POST']['data_ContentTpl']),
ImageTpl => addslashes($this->in['_POST']['data_ImageTpl']),
DoHtml => intval($this->in['_POST']['data_DoHtml']),
HotNum => intval($this->in['_POST']['data_HotNum']),
ListFileName => addslashes($this->in['_POST']['data_ListFileName']),
ContentFileName => addslashes($this->in['_POST']['data_ContentFileName']),
ResourcePSN=> addslashes($this->in['_POST']['data_ResourcePSN']),
ResourceURL => addslashes($this->in['_POST']['data_ResourceURL']),
SubDir => addslashes($this->in['_POST']['data_SubDir']),
MaxPage => intval($this->in['_POST']['data_MaxPage']));
$this->objDataSet->update($data, "CateID = '" . $this->in['_POST']['CateID'] . "'", $this->category); $subCate_array = explode(",",$this->getSub($CateID));
$subCate_num = count($subCate_array);
for ($i=0;$i<$subCate_num;$i++) {
$this->updateparentlist($Cate_array[$i]);
}
$this->page_err();
$this->cachecates();
header("location:index.php?module=category&action=list");
echo '<script>top.panelMenu.location= "index.php?module=category&act=menu";</script>';
}
$this->tpl->assign('act', 'update');
$updateData = $this->objDataSet->getDataById($this->in['_GET']['CateID'], "CateID", $this->category);
if($this->selected=='')$this->selected=$updateData[ParentID];
$this->tpl->assign('updateData', $updateData);
$this->content = $updateData[ContentModel];
$this->tpl->assign('ContentModel', $this->getContentModel());
$this->tpl->assign('list', $this->getcatelist());
$this->tpl->assign("title", $this->app->getSysMsg('addcate'));
$this->tpl->display( "admin/category_insert.htm");
}
function onDelete()
{
$in = & $this->in;
$dataSet = & $this->objDataSet;
if (isset($in['row_select']))
{
$ids = "'".implode("','",$in['row_select'])."'";
}
else $ids = "'".$in['id']."'";
$dataSet->delete("CateID in ($ids)",$this->category);
$this->cachecates();
$this->page_err();
header("location:".preg_replace("/totalnum=[^&]*&?/","",$this->fromUrl));
}
function onList()
{
$in = &$this->in;
$tpl = &$this->tpl;
$objDataSet = &$this->objDataSet;
$objServer = &$this->objServer;
$orderfield = $in['orderfield'] ? $in['orderfield'] : "c.CateID";
$ordermode = $in['ordermode'] ? $in['ordermode'] : "desc";
$loop_data = $objDataSet->getList("select c.* , m.* from " . $this->category . " as c left join " . $this->content_model . " as m on c.ContentModel=m.ContentModelID order by $orderfield $ordermode", 20);
$tpl->assign("total", $loop_data->total());
$tpl->assign("fromto", $loop_data->fromto());
$loop_data->navchar = array($this->app->getSysMsg('firstpage'), '[<]', '[>]', $this->app->getSysMsg('endpage'));
$tpl->assign("navbar", $loop_data->navbar(10));
$tpl->assign("fieldsdata", $loop_data->field);
$tpl->assign($in['_GET']);
$column_id = $this->getColumnStr($this->app->getSysMsg('id'), "CateID", (!$in['ordermode'] ? "↓" : "")) ;
$category_name = $this->getColumnStr($this->app->getSysMsg('category_name'), "Title") ;
$ContentModelName = $this->getColumnStr($this->app->getSysMsg('ContentModelName'), "ContentModelName") ;
$tpl->assign(array('column_id' => $column_id,
'category_name' => $category_name,
'ContentModelName' => $ContentModelName)) ;
$tpl->assign("title", $this->app->getSysMsg('list_category'));
$tpl->display( "admin/category_list.htm");
}
function onMenu(){
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_Category.html');
}
function oncategory_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/Category_xml.xml');
}
function ontargetCateWindow(){
$this->tpl->display('admin/select_Cate.html');
}
function onCate_select(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -