public function start($formName) { $array = array("class" => "form-horizontal", "role" => "form", "enctype" => "multipart/form-data"); $this->init($formName, '/index.php?m=admin&c=article&a=save', '', $array); $array = array("class" => "form-control", "placeholder" => "NAME"); $this->setText("title", "", $array, array('datatype' => '*2-24')); $this->setText("id", "", $array, array('datatype' => 'n1-8'), "hidden"); $array = array("class" => "form-control", "placeholder" => date("Y-m-d H:i:s"), "disabled" => "disabled"); $this->setText("time", "", $array, array(), "text", 0, 3); $array = array("class" => "form-control"); $this->setUeditor("content", "", $array); $array = array("class" => "form-control", "id" => "tags", "placeholder" => "日志标签,逗号或空格分隔"); $this->setText("tag", "", $array, array('datatype' => '*0-256'), "text", 0, 6); $array = array("class" => "form-control"); $menu = new \Admin\Model\articleModel(); $data = $menu->getCategory(); $this->setSelect("category", "", $array, $data, 3, 3); $array = array("class" => "form-control", "style" => "height:200px"); $this->setUeditor("excerpt", "", $array); $array = array("class" => "form-control"); $this->setText("password", "访问密码", $array, array('datatype' => '*0-24'), "text", 1, 3); $array = array("class" => "form-control"); $this->setText("thumbnail", "", $array, array(), "file", 1, 3); $array = array("class" => "make-switch", "data-on-color" => "primary", "data-off-color" => "info"); $this->setBsCheckBox("istop", "是否置顶", $array); $this->setBsCheckBox("allow_comment", "允许评论", $array); }
/** * 显示博文 */ public function showAction() { $id = get("id", "int"); $where['status'] = \Admin\Article\Type\Status::STATUS_ENABLE; $where['member_id'] = 1; $where['id'] = $id; $row = db()->Table('article')->getRow($where)->limit(0, 1)->done(); if (!empty($row['password'])) { $cookiePassword = addslashes(trim(cookie('xtt_logpwd_' . $row['id']))); if ($cookiePassword != $row['password']) { $this->getView()->assign(array('id' => $id, 'msg' => "")); return $this->getView()->display("checkpwd"); } } $config = new \Admin\Model\webConfigModel(); $webConfig = $config->getConfig(); if ($webConfig['ischkcomment']) { new \Common\Security\CommentVerSession(); } $model = new \Home\Model\homeModel(); $row['category'] = $model->getArticleCategory($row['category']); $tag = new \Admin\Model\articleModel(); //获取该文章标签 $tags = $tag->getTags($row['id'], true); if ($tags) { $row['tags'] = explode(",", $tags); } $row['author'] = member($row['member_id']); $row['content'] = stripslashes($row['content']); //加载评论 $commentWhere['status'] = \Admin\Comment\Type\Status::STATUS_ENABLE; $commentWhere['type'] = \Admin\Comment\Type\Type::TYPE_ARTICLE; $commentWhere['data'] = $id; $comments = db()->Table('comment')->getAll($commentWhere)->order("id " . $webConfig['comment_order'])->done(); //生成序列树 $comments = $this->sortOut($comments); $this->getView()->assign(array('blog' => $row, "comments" => $comments)); return $this->getView()->display(); }
/** * 日志编辑 */ public function editAction() { $id = get('id', 'int'); $row = db()->Table('article')->getRow(array('id' => $id))->done(); //getRow if (!$row) { return $this->link()->error("参数错误"); } $row['title'] = htmlspecialchars($row['title']); $row['content'] = htmlspecialchars($row['content']); $row['excerpt'] = htmlspecialchars($row['excerpt']); $form = new \Admin\Article\Form\editForm(); //获取表单 $form->bind($row); //绑定Row $form->start('articleEdit'); //开始渲染 $this->getView()->assign(array('form' => $form)); $tag = new \Admin\Model\articleModel(); //获取该文章标签 $tTags = $tag->getTags($id, true); //获取已有全部标签 $tags = $tag->getTags("", true); $this->getView()->assign(array('tags' => $tags, 'tTags' => $tTags, 'data' => $row)); $this->getView()->display(); }