<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id addnew.inc.php 1 2008-08-24 10:25 $
*/
(!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied');

if($dosubmit) {

    (empty($articleid) || $articleid < 0) && cpmsg("无效的文章ID。", 'stop');
    empty($article['subject']) && cpmsg('标题未填写，请返回填写。');
    empty($article['classid']) && cpmsg('分类为选择，请返回选择。');
    empty($article['content']) && cpmsg('内容未填写，请返回填写。');

    $article['introduce'] = nl2br(unite_textarea($article['introduce']));
    if($newdateline) $article['dateline'] = $timestamp;

    article_edit($articleid, $article);
    cpmsg('文章更新完毕！', 'admincp.php?action=article&file=list');

} else {

    // 分类缓存
    $articleclass = read_cache_articleclass();
    if(empty($articleclass)) {
        cpmsg('请先添加文章分类。', 'admincp.php?action=article&file=class');
    }
    $article = $db->get_one("SELECT * FROM {$dbpre}articles a LEFT JOIN {$dbpre}articledata ad ON(a.articleid=ad.articleid) WHERE a.articleid='$articleid'");
    empty($article) && cpmsg("文章记录不存在或已删除。", 'stop');
    // 还原换行
    $article['introduce'] = str_replace("<br />", "\r\n", $article['introduce']);
    // 加载 FCK 编辑器
    require_once(MUDDER_ROOT.'./include/editor/fckeditor.php');
    $fck = new FCKeditor('article[content]');
    $fck->ToolbarSet = 'Admin';
    $fck->Value = $article['content'];
    $fckhtml = $fck->CreateHtml();
    
    include cptpl('artcile_edit', MOD_ROOT.'./admin/templates/');
}
?>