* 负责处理新发表文章的逻辑 * Createed By C860 at 2014-1-19 */ if (!class_exists('sys')) { include_once '../conf/config.php'; } //需要登录 sys::needLog('../login.php'); //检测数据合法性 if (isset($_POST['title']) && !empty($_POST['title']) && isset($_POST['content']) && !empty($_POST['content']) && isset($_POST['tags']) && !empty($_POST['tags'])) { //引入相关模型类 include_once '../Models/article.php'; include_once '../Models/tag_relate_article.php'; include_once '../Models/user_info.php'; $currentTime = date('Y-m-d H:i:s'); //新增文章 if (article::add($_POST['title'], $_POST['content'], $currentTime, $_SESSION['userId'])) { $ID = article::getId($_POST['title'], $_SESSION['userId'], $currentTime); $tags = explode('|', $_POST['tags']); foreach ($tags as $tag) { tag_relate_article::add($tag, $ID); } user_info::increaseArticleCount($_SESSION['userId']); sys::alert('发表成功!'); sys::redirect('../index.php'); } } else { //引入相关模型类 include_once 'Models/tag.php'; $taglist = tag::getAllTags(); }
function showArticleAdministration() { require_once ROOT . "includes/items.php"; require_once ROOT . "DBInterface/articleDB.php"; require_once ROOT . "DBInterface/languageDB.php"; require_once ROOT . "DBInterface/articleTranslationDB.php"; if (isset($_POST['action'])) { if ($_POST['action'] == 'add') { $articleDB = new ArticleDB(); $res = $articleDB->addArticle($_POST['artSystemName'], $_POST['artSystemDescription'], $_POST['artPrice'], $_POST['artImagePath']); $resID = $res->fetch_object(); $artID = $resID->Article_ID; saveCategory($artID); saveLanguages($artID); } else { if ($_POST['action'] == 'update') { $articleDB = new ArticleDB(); $artID = $_POST['artId']; $res = $articleDB->updateArticle($_POST['artId'], $_POST['artSystemName'], $_POST['artSystemDescription'], $_POST['artPrice'], $_POST['artImagePath']); saveCategory($artID); saveLanguages($artID); } else { if ($_POST['action'] == 'delete') { $artID = $_POST['artId']; deleteArticle($artID); } } } } $lang = $_COOKIE["lang"]; include ROOT . "resources/{$lang}.php"; $items = array(); $article = null; $articleDB = new ArticleDB(); echo "<table class=\"basket-table\" border=\"1px\">"; echo "<thead>"; echo "<tr>"; echo "<th>{$adminArticleId}</th>"; echo "<th>{$adminArticleName}</th>"; echo "<th>{$adminArticleDescription}</th>"; echo "<th>{$adminArticlePrice}</th>"; echo "<th>{$adminArticleImage}</th>"; echo "<th> </th>"; echo "<th> </th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; $res = $articleDB->getAllArticles(); while ($items = $res->fetch_object()) { $articleId = $items->Article_ID; $articleName = $items->ArticleName; $articleDescription = $items->ArticleDescription; $articlePrice = $items->ArticlePrice; $articleImage = $items->ArticleImage; $article = new article($articleId, $articleName, $articlePrice, $articleDescription, $articleImage, null); echo "<tr>"; echo "<td>" . $article->getId() . "</td>"; echo "<td>" . $article->getName() . "</td>"; echo "<td>" . $article->getDescription() . "</td>"; echo "<td>" . $article->getPrice() . "</td>"; echo "<td>" . $article->getImage() . "</td>"; echo "<form action=\"index.php?site=changeArticle\" method=\"get\">"; echo "<input type=\"hidden\" name=\"artId\" value=\"" . $article->getId() . "\" /input>"; echo "<input type=\"hidden\" name=\"site\" value=\"changeArticle\" /input>"; echo "<input type=\"hidden\" name=\"origin\" value=\"update\" /input>"; echo "<td> <input class=\"basket-update-button\" type=\"submit\" value=\"{$adminArticleUpdateLabel}\"/></td>"; echo "</form>"; echo "<form action=\"index.php?" . $_SERVER['QUERY_STRING'] . "\" method=\"post\">"; echo "<input type=\"hidden\" name=\"artId\" value=\"" . $article->getId() . "\" /input>"; echo "<input type=\"hidden\" name=\"action\" value=\"delete\" /input>"; echo "<td> <input class=\"basket-delete-button\" name=\"delete\" type=\"submit\" value=\"{$adminArticleDeleteLabel}\"/></td>"; echo "</form>"; echo "</tr>"; echo "</form>"; } // last line to add a new article echo "<form action=\"index.php?site=changeArticle\" method=\"get\">"; // echo "<input type=\"hidden\" name=\"articleId\" value=\"" . $articleId . "\" /input>"; echo "<tr>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<input type=\"hidden\" name=\"site\" value=\"changeArticle\" /input>"; echo "<input type=\"hidden\" name=\"origin\" value=\"add\" /input>"; echo "<td> <input class=\"basket-update-button\" type=\"submit\" value=\"{$adminArticleAddLabel}\"/></td>"; echo "</tr>"; echo "</form>"; echo "</tbody>"; echo "</table>"; }