<?php
/**
 * 設置某頻道為默認發佈
 *
 * @version        $Id: public_guide.php 1 15:46 2010年7月20日Z tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__)."/config.php");
require_once(DEDEINC."/oxwindow.class.php");
if(empty($action)) $action = '';

/*--------------------
function __SetDefault();
----------------------*/
if($action=='setdefault')
{
    CheckPurview('sys_Edit');
    $dsql->ExecuteNoneQuery("UPDATE `#@__channeltype` SET isdefault=0 WHERE id<>'$cid'");
    if($cid != 0)
    {
        $dsql->ExecuteNoneQuery("UPDATE `#@__channeltype` SET isdefault=1 WHERE id='$cid'");
    }
    $win = new OxWindow();
    $win->Init();
    $win->mainTitle = "內容發佈嚮導";
    $wecome_info = "<a href='public_guide.php?action=edit'>內容發佈嚮導</a>";
    $win->AddTitle("<a href='public_guide.php?action=edit'>內容發佈嚮導</a> &gt;&gt; 設置默認發佈表單");
    if($cid==0)
    {
        $msg = "
         成功取消默認發佈表單！
           <hr style='width:90%' size='1' />
           你目前想要進行的操作： <a href='public_guide.php?action=edit'>返回發佈嚮導頁</a>
      ";
    }
    else
    {
        $msg = "
        成功保存默認發佈表單，以後點擊「內容發佈」面板將直接跳轉到你選擇的內容發佈頁！
        <hr style='width:90%' size='1' />
           你目前想要進行的操作： <a href='public_guide.php'>轉到默認發佈表單</a> &nbsp; <a href='public_guide.php?action=edit'>返回發佈嚮導頁</a>
      ";
    }
    $win->AddMsgItem("<div style='padding-left:20px;line-height:150%'>$msg</div>");
    $winform = $win->GetWindow("hand");
    $win->Display();
    exit();
}

//以下為正常瀏覽的內容
/*--------------------
function __PageShow();
----------------------*/
$row = $dsql->GetOne("SELECT id,addcon FROM `#@__channeltype` WHERE isdefault='1' ");

//已經設置了默認發佈表單
if(is_array($row) && $action!='edit')
{
    $addcon = $row['addcon'];
    if($addcon=='')
    {
        $addcon='archives_add.php';
    }
    $channelid = $row['id'];
    $cid = 0;
    require_once(DEDEADMIN.'/'.$addcon);
    exit();
}

//沒有設置默認發佈表單
else
{
    $dsql->SetQuery("SELECT id,typename,mancon,isdefault,addtable FROM `#@__channeltype` WHERE id<>-1 And isshow=1 ");
    $dsql->Execute();
}
include DedeInclude('templets/public_guide.htm');

//獲取頻道欄目數
function GetCatalogs(&$dsql,$cid)
{
    $row = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__arctype` WHERE channeltype='$cid' ");
    return (!is_array($row) ? '0' : $row['dd']);
}