|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- <?php
- if (!defined('DEDEINC')) exit('dedebiz');
-
- require_once(DEDEINC."/channelunit.func.php");
-
-
- class TypeLink
- {
- var $typeDir;
- var $dsql;
- var $TypeID;
- var $baseDir;
- var $modDir;
- var $indexUrl;
- var $indexName;
- var $TypeInfos;
- var $SplitSymbol;
- var $valuePosition;
- var $valuePositionName;
- var $OptionArrayList;
-
-
-
- function __construct($typeid)
- {
- $this->indexUrl = $GLOBALS['cfg_basehost'].$GLOBALS['cfg_indexurl'];
- $this->indexName = $GLOBALS['cfg_indexname'];
- $this->baseDir = $GLOBALS['cfg_basedir'];
- $this->modDir = $GLOBALS['cfg_templets_dir'];
- $this->SplitSymbol = $GLOBALS['cfg_list_symbol'] === " > " ? "" : $GLOBALS['cfg_list_symbol'];
- $this->dsql = $GLOBALS['dsql'];
- $this->TypeID = $typeid;
- $this->valuePosition = '';
- $this->valuePositionName = '';
- $this->typeDir = '';
- $this->OptionArrayList = '';
-
-
- $query = "SELECT tp.*,ch.typename as ctypename,ch.addtable,ch.issystem FROM `#@__arctype` tp left join `#@__channeltype` ch
- on ch.id=tp.channeltype WHERE tp.id='$typeid' ";
- if ($typeid > 0) {
- $this->TypeInfos = $this->dsql->GetOne($query);
- if (is_array($this->TypeInfos)) {
- $this->TypeInfos['tempindex'] = MfTemplet($this->TypeInfos['tempindex']);
- $this->TypeInfos['templist'] = MfTemplet($this->TypeInfos['templist']);
- $this->TypeInfos['temparticle'] = MfTemplet($this->TypeInfos['temparticle']);
- }
- }
- }
-
-
-
- function TypeLink($typeid)
- {
- $this->__construct($typeid);
- }
-
-
- function Close()
- {
- }
-
-
- function SetTypeID($typeid)
- {
- $this->TypeID = $typeid;
- $this->valuePosition = "";
- $this->valuePositionName = "";
- $this->typeDir = "";
- $this->OptionArrayList = "";
-
-
- $query = "
- SELECT #@__arctype.*,#@__channeltype.typename as ctypename
- FROM #@__arctype left join #@__channeltype
- on #@__channeltype.id=#@__arctype.channeltype WHERE #@__arctype.id='$typeid' ";
- $this->dsql->SetQuery($query);
- $this->TypeInfos = $this->dsql->GetOne();
- }
-
-
- function GetTypeDir()
- {
- if (empty($this->TypeInfos['typedir'])) {
- return $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir'];
- } else {
- return $this->TypeInfos['typedir'];
- }
- }
-
-
-
- function GetPositionLink($islink = true)
- {
- if (defined('DEDEMOB')) {
- $indexpage = "<li class='breadcrumb-item'><a href='index.php'>".$this->indexName."</a></li>";
- } else {
- $indexpage = "<li class='breadcrumb-item'><a href='".$this->indexUrl."'>".$this->indexName."</a></li>";
- }
-
- if ($this->valuePosition != "" && $islink) {
- return $this->valuePosition;
- } else if ($this->valuePositionName != "" && !$islink) {
- return $this->valuePositionName;
- } else if ($this->TypeID == 0) {
- if ($islink) {
- return $indexpage;
- } else {
- return "没指定分类";
- }
- } else {
- if ($islink) {
- $this->valuePosition = $this->GetOneTypeLink($this->TypeInfos);
- if ($this->TypeInfos['reid'] != 0) {
-
- $this->LogicGetPosition($this->TypeInfos['reid'], true);
- }
- $this->valuePosition = $indexpage.$this->SplitSymbol.$this->valuePosition;
- return $this->valuePosition.$this->SplitSymbol;
- } else {
- $this->valuePositionName = $this->TypeInfos['typename'];
- if ($this->TypeInfos['reid'] != 0) {
-
- $this->LogicGetPosition($this->TypeInfos['reid'], false);
- }
- return $this->valuePositionName;
- }
- }
- }
-
-
- function GetPositionName()
- {
- return $this->GetPositionLink(false);
- }
-
-
- function LogicGetPosition($id, $islink)
- {
- $this->dsql->SetQuery("SELECT id,reid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE id='".$id."'");
- $tinfos = $this->dsql->GetOne();
- if ($islink) {
- $this->valuePosition = $this->GetOneTypeLink($tinfos).$this->SplitSymbol.$this->valuePosition;
- } else {
- $this->valuePositionName = $tinfos['typename'].$this->SplitSymbol.$this->valuePositionName;
- }
- if ($tinfos['reid'] > 0) {
- $this->LogicGetPosition($tinfos['reid'], $islink);
- } else {
- return 0;
- }
- }
-
-
- function GetOneTypeLink($typeinfos)
- {
- $typepage = $this->GetOneTypeUrl($typeinfos);
- $typelink = "<li class='breadcrumb-item'><a href='".$typepage."'>".$typeinfos['typename']."</a></li>";
- return $typelink;
- }
-
-
- function GetOneTypeUrl($typeinfos)
- {
- if (defined('DEDEMOB')) {
- return 'list.php?tid='.$typeinfos['id'];
- } else {
- return GetTypeUrl(
- $typeinfos['id'],
- MfTypedir($typeinfos['typedir']),
- $typeinfos['isdefault'],
- $typeinfos['defaultname'],
- $typeinfos['ispart'],
- $typeinfos['namerule2'],
- $typeinfos['moresite'],
- $typeinfos['siteurl'],
- $typeinfos['sitepath']
- );
- }
- }
-
-
-
-
-
- function GetOptionArray($hid = 0, $oper = 0, $channeltype = 0, $usersg = 0)
- {
- return $this->GetOptionList($hid, $oper, $channeltype, $usersg);
- }
-
- function GetOptionList($hid = 0, $oper = 0, $channeltype = 0, $usersg = 0)
- {
- global $cfg_admin_channel;
- if (empty($cfg_admin_channel)) $cfg_admin_channel = 'all';
-
- if (!$this->dsql) $this->dsql = $GLOBALS['dsql'];
- $this->OptionArrayList = '';
-
- if ($hid > 0) {
- $row = $this->dsql->GetOne("SELECT id,typename,ispart,channeltype FROM `#@__arctype` WHERE id='$hid'");
- $channeltype = $row['channeltype'];
- if ($row['ispart'] == 1) {
- $this->OptionArrayList .= "<option value='".$row['id']."' style='background-color:#DFDFDB;color:#888888' selected>".$row['typename']."</option>\r\n";
- } else {
- $this->OptionArrayList .= "<option value='".$row['id']."' selected>".$row['typename']."</option>\r\n";
- }
- }
-
- if ($channeltype == 0) $ctsql = '';
- else $ctsql = " AND channeltype='$channeltype' ";
-
-
- if (is_array($oper) && $cfg_admin_channel != 'all') {
- if (count($oper) == 0) {
- $query = "SELECT id,typename,ispart FROM `#@__arctype` WHERE 1=2 ";
- } else {
- $admin_catalog_tmp = $admin_catalog = join(',', $oper);
- $this->dsql->SetQuery("SELECT reid FROM `#@__arctype` WHERE id in($admin_catalog) GROUP BY reid ");
- $this->dsql->Execute();
- $topidstr = '';
- while ($row = $this->dsql->GetObject()) {
- if ($row->reid == 0) continue;
- $topidstr .= ($topidstr == '' ? $row->reid : ','.$row->reid);
- }
- $admin_catalog .= ','.$topidstr;
- $admin_catalogs = explode(',', $admin_catalog);
- $admin_catalogs = array_unique($admin_catalogs);
- $admin_catalog = join(',', $admin_catalogs);
- $admin_catalog = preg_replace("/,$/", '', $admin_catalog);
- $query = "SELECT id,typename,ispart FROM `#@__arctype` WHERE id in({$admin_catalog}) AND reid=0 $ctsql";
- }
- } else {
- $query = "SELECT id,typename,ispart FROM `#@__arctype` WHERE reid=0 $ctsql ORDER BY sortrank ASC";
- }
-
- $this->dsql->SetQuery($query);
- $this->dsql->Execute();
- while ($row = $this->dsql->GetObject()) {
- if ($row->id != $hid) {
- if ($row->ispart == 1) {
- $this->OptionArrayList .= "<option value='".$row->id."' style='background-color:#EFEFEF;color:#666666'>".$row->typename."</option>\r\n";
- } else {
- $this->OptionArrayList .= "<option value='".$row->id."'>".$row->typename."</option>\r\n";
- }
- }
- $this->LogicGetOptionArray($row->id, "─", $oper);
- }
- return $this->OptionArrayList;
- }
-
-
-
- function LogicGetOptionArray($id, $step, $oper = 0)
- {
- global $cfg_admin_channel;
- if (empty($cfg_admin_channel)) $cfg_admin_channel = 'all';
-
- $this->dsql->SetQuery("SELECT id,typename,ispart FROM `#@__arctype` WHERE reid='".$id."' AND ispart<>2 ORDER BY sortrank ASC");
- $this->dsql->Execute($id);
- while ($row = $this->dsql->GetObject($id)) {
- if (is_array($oper) && $cfg_admin_channel != 'all') {
- if (!in_array($row->id, $oper)) continue;
- }
- if ($row->ispart == 1) {
- $this->OptionArrayList .= "<option value='".$row->id."' style='background-color:#EFEFEF;color:#666666'>$step".$row->typename."</option>\r\n";
- } else {
- $this->OptionArrayList .= "<option value='".$row->id."'>$step".$row->typename."</option>\r\n";
- }
- $this->LogicGetOptionArray($row->id, $step."─", $oper);
- }
- }
-
-
-
- function GetChannelList(
- $typeid = 0,
- $reid = 0,
- $row = 8,
- $typetype = 'sun',
- $innertext = '',
- $col = 1,
- $tablewidth = 100,
- $myinnertext = ''
- ) {
- if ($typeid == 0) $typeid = $this->TypeID;
- if ($row == "") $row = 8;
- if ($reid == "") $reid = 0;
- if ($col == "") $col = 1;
-
- $tablewidth = str_replace("%", "", $tablewidth);
- if ($tablewidth == "") $tablewidth = 100;
- if ($col == "") $col = 1;
-
- $colWidth = ceil(100 / $col);
- $tablewidth = $tablewidth."%";
- $colWidth = $colWidth."%";
- if ($typetype == "") $typetype = "sun";
-
- if ($innertext == "") $innertext = GetSysTemplets("channel_list.htm");
-
- if ($reid == 0 && $typeid > 0) {
- $dbrow = $this->dsql->GetOne("SELECT reid FROM `#@__arctype` WHERE id='$typeid' ");
- if (is_array($dbrow)) {
- $reid = $dbrow['reid'];
- }
- }
- $likeType = "";
- if ($typetype == "top") {
- $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl
- FROM `#@__arctype` WHERE reid=0 AND ishidden<>1 ORDER BY sortrank ASC limit 0,$row";
- } else if ($typetype == "sun" || $typetype == "son") {
- $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl
- FROM `#@__arctype` WHERE reid='$typeid' AND ishidden<>1 ORDER BY sortrank ASC limit 0,$row";
- } else if ($typetype == "self") {
- $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl
- FROM `#@__arctype` WHERE reid='$reid' AND ishidden<>1 ORDER BY sortrank ASC limit 0,$row";
- }
-
-
- $dtp2 = new DedeTagParse();
- $dtp2->SetNameSpace("field", "[", "]");
- $dtp2->LoadSource($innertext);
- $this->dsql->SetQuery($sql);
- $this->dsql->Execute();
- $line = $row;
- $GLOBALS['autoindex'] = 0;
- if ($col > 1) {
- $likeType = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
- }
- for ($i = 0; $i < $line; $i++) {
- if ($col > 1) {
- $likeType .= "<tr>\r\n";
- }
- for ($j = 0; $j < $col; $j++) {
- if ($col > 1) $likeType .= " <td width='$colWidth'>\r\n";
- if ($row = $this->dsql->GetArray()) {
-
- if ($row['id'] == "$typeid" && $myinnertext != '') {
- $linkOkstr = $myinnertext;
- $row['typelink'] = $this->GetOneTypeUrl($row);
- $linkOkstr = str_replace("~typelink~", $row['typelink'], $linkOkstr);
- $linkOkstr = str_replace("~typename~", $row['typename'], $linkOkstr);
- $likeType .= $linkOkstr;
- } else {
-
- $row['typelink'] = $this->GetOneTypeUrl($row);
- if (is_array($dtp2->CTags)) {
- foreach ($dtp2->CTags as $tagid => $ctag) {
- if (isset($row[$ctag->GetName()])) {
- $dtp2->Assign($tagid, $row[$ctag->GetName()]);
- }
- }
- }
- $likeType .= $dtp2->GetResult();
- }
- }
- if ($col > 1) {
- $likeType .= " </td>\r\n";
- }
- $GLOBALS['autoindex']++;
- }
-
- if ($col > 1) {
- $i += $col - 1;
- }
- if ($col > 1) {
- $likeType .= " </tr>\r\n";
- }
- }
-
- if ($col > 1) {
- $likeType .= " </table>\r\n";
- }
- $this->dsql->FreeResult();
- return $likeType;
- }
-
- }
|