protected function actionEdit() { $model = new ArticleClass(); $view = new View(); $view->news = $model->getAll(); if (isset($_GET['id'])) { $id = $_GET['id']; $view->new_article = $model->getOne($id); } if (isset($_POST['edit'])) { if (!empty($_POST['title']) and !empty($_POST['text'])) { $title = $_POST['title']; $text = $_POST['text']; $id = $_POST['id']; $model->updateArticle($title, $text, $id); $view->msg = 'Статья изменена'; $view->title = $title; $view->text = $text; $view->new_article = $model->getOne($id); } else { $view->new_article = $model->getOne($id); $view->msg = 'Заполните все графы'; } } if (isset($_POST['no_edit'])) { header("Location: ./editor.php"); } $view->display('../view/edit.php'); }
<section> <?php // BUILD OUR PAGE CONTENT // obtain/receive all content areas ($areaArray) // get them in ORDER // every page gets all content areas (they may be empty) // so I do not need to tie to current page $areaArray = ContentAreaClass::retrieveDivs(); foreach ($areaArray as $area) { // all of our content areas are DIVs echo "<div id='" . $area->getDivName() . "'>"; // obtain/receive all articles ($articleArray) // for the current page (or for all pages) // and for the current area // in REVERSE ORDER of creation date $articleArray = ArticleClass::getAreaArticles($_GET['page'], $area->getId()); foreach ($articleArray as $article) { echo "<article id='" . $article->getTitle() . "'>"; // echo "<article id='$article->getAlias()'>"; echo $article->getTitle(); echo "<p>"; echo $article->getContent(); echo "</p>"; echo "</article>"; } echo "</div>"; } ?> </section> </body> </html>
/** * 产品显示页面 * */ private function product() { require_once "shopGoods.class.php"; $obj_shop_goods = new ShopGoodsClass(); /*当前产品信息*/ $condition['goods_id'] = intval($this->_input['id']); if ($condition['goods_id'] == 0) { header("Location:index.php"); exit; } $condition['no_state'] = 1; $product_array = $this->obj_product->getProductInfo($condition); /*产品颜色,产品规格*/ $c_array = @explode('|', $product_array['goods_color']); $s_array = @explode('|', $product_array['goods_size']); $color_select = $product_array['goods_color'] != '' ? Common::Select('goods_color', array_combine($c_array, $c_array)) : ''; $size_select = $product_array['goods_size'] != '' ? Common::Select('goods_size', array_combine($s_array, $s_array)) : ''; $this->output('color_select', $color_select); //颜色输出 $this->output('size_select', $size_select); //规格输出 /*产品多图*/ require_once 'goods.class.php'; $goods = new GoodsClass(); if ($product_array['shop_goods_id'] != '') { $product_array['more_image'] = $goods->getGoodsImage($product_array['shop_goods_id']); } else { $product_array['more_image'] = $goods->getGoodsImage($product_array['goods_id']); } $this->output('more_image_num', count($product_array['more_image']) + 1); $this->output('product_array', $product_array); /*浏览量*/ $goods_click = intval($product_array['goods_click']) + 1; $this->obj_goods->modifyGoods($goods_click, $condition['goods_id'], "goods_click"); /*推荐产品*/ $commend_array = $this->obj_product->getProductSpecific(array('goods_commend' => 1, 'goods_state' => 1)); $this->output('commend_array', $commend_array); /*产品属性*/ $goods_attr_body = @unserialize($product_array['goods_attr_body']); //商品内的属性 include 'goodsClass.class.php'; //载入产品分类文件 $goods_class = new GoodsClassClass(); $goods_type_id = $goods_class->getGoodsClassInfo(array('class_id' => $product_array['class_id']), 'goods_type_id,class_other_attr'); if ($goods_type_id[0] != '') { include 'goodsType.class.php'; $goods_type = new GoodsTypeClass(); $type_array = $goods_type->getTypeInfo(array('goods_type_id' => $goods_type_id[0])); /*判断商品类型状态,如果关闭则不执行*/ if ($type_array['goods_type_state'] == 1) { $attr_array = $goods_type->goodsAttrArray(array('txt_goods_type_id' => $type_array['goods_type_id'])); $goods_attr = array(); $i = 0; foreach ($attr_array as $val) { if (!empty($goods_attr_body['class_attr'][$val['attribute_id']])) { $goods_attr[$i]['title'] = $val['attribute_name']; $goods_attr[$i]['vaule'] = $goods_attr_body['class_attr'][$val['attribute_id']]; $i++; } } $this->output('goods_attr', $goods_attr); } } /*产品所在分类独有属性*/ if (is_array($goods_type_id['class_other_attr']) and count($goods_type_id['class_other_attr']) > 0) { $goods_other_attr = array(); foreach ($goods_type_id['class_other_attr'] as $key => $value) { if (!empty($goods_attr_body['class_other_attr'][$key])) { $goods_other_attr[] = array('attr_name' => $value, 'attr_value' => $goods_attr_body['class_other_attr'][$key]); } } } $this->output('goods_other_attr', $goods_other_attr); /*相关商品*/ if ($product_array['goods_link_goods'] != '') { if (intval($product_array['shop_goods_id']) == 0) { $goods_link_goods = $this->obj_goods->ajaxGoodsSearch(array('goods_id_str' => $product_array['goods_link_goods'], 'other_action' => 'modify_link'), '*'); } $this->output('goods_link_goods', $goods_link_goods); } /*相关文章*/ if ($product_array['goods_link_article'] != '') { include 'article.class.php'; $article = new ArticleClass(); $goods_link_article = $article->ajaxArticleSearch(array('article_id_str' => $product_array['goods_link_article'], 'other_action' => 'modify_link')); $this->output('goods_link_article', $goods_link_article); } /*产品导航条*/ include BasePath . "/share/" . NC_SHOP_DIR . "goods_class_show.php"; $array = array(); foreach ($node_cache as $k => $v) { if ($v[0] == intval($product_array['class_id'])) { $array['class_id'] = $v[0]; $array['class_top_id'] = $v[1]; $array['key_id'] = $k; break; } } $class_menu = $this->obj_product_class->prductClassMenu($array); $this->output('class_menu', $class_menu); /*评论列表*/ require_once "commonpage.class.php"; $obj_page = new CommonPage(); $obj_page->pagebarnum(10); $conditon_array = array('goods_id' => $condition['goods_id']); $comment_array = $this->obj_comment->getGoodsCommentList($conditon_array, $obj_page); $show_page = $obj_page->show(3); $this->output('comment_array', $comment_array); $this->output('show_page', $show_page); /*侧边商品分类显示*/ $class_array = $goods_class->getClassSort(); $this->output('class_array', $class_array); /*商品品牌*/ $brand_array = $this->obj_brand->getBrandList(array('show_type' => 'class_show')); $this->output('brand_array', $brand_array); /*当前类热卖商品*/ $hot_array = $this->obj_product_class->productClassList($array, '', 'goods.goods_name,goods.goods_id,goods.shop_goods_id', '', ' order by goods.goods_click desc', 8); $this->output('hot_array', $hot_array); /*浏览过的商品*/ if ($this->getCookies('c_product_viewed') != '') { $view_goods_array = $this->obj_product_class->productClassList(array('c_product_viewed' => $this->getCookies('c_product_viewed')), '', 'goods.goods_name,goods.goods_id,goods.goods_small_image,shop_goods_id'); $this->output('view_goods_array', $view_goods_array); } /*添加该商品到cookie,浏览商品*/ $this->setReviewed(intval($this->_input['id'])); $this->showpage("product"); }
<thead> <tr> <td>Article Id</td> <td>Article Name</td> <td colspan="2"> <form action="editorPortal.php" method="post"> <input type="Submit" id="addArticle" name="addArticle" value="Add Article" /> </form> </td> </tr> </thead> <tbody> <?php require "../Business/ArticleClass.php"; $arrayOfArticles = ArticleClass::retrieveArticles(); foreach ($arrayOfArticles as $article) { ?> <tr> <td><?php echo $article->getId(); ?> </td> <td><?php echo $article->getTitle(); ?> </td> <td> <form action="editorPortal.php" method="post"> <input type="text" id="editArticleId" name="editArticleId" value="<?php echo $article->getID();
} elseif (isset($_POST['editArticle'])) { //load pre-populated form + pointer to update routine include_once 'tables/article/article.php'; } elseif (isset($_POST['delArticle'])) { //load delete confirmation page include_once 'tables/article/deleteArticle.php'; } elseif (isset($_POST['addedArticle'])) { //load insert routine + success/fail message include_once 'tables/article/addArticle.php'; } elseif (isset($_POST['editedArticle'])) { //load update routine + success/fail message include_once 'tables/article/editArticle.php'; } elseif (isset($_POST['deletedArticle'])) { //delete selected article require_once '../Business/ArticleClass.php'; $currentArticle = ArticleClass::getSingleArticle($_POST['delArticleId']); $result = $currentArticle->deleteArticle(); echo $result; } ////////////////////////////////////////// // Div MGMT Block // //////////////////////////////////////// if (isset($_POST['divMgmtBtn'])) { //load the divs management table\ include_once 'tables/divMgmt.php'; } elseif (isset($_POST['editDiv'])) { //load the divs management table\ include_once 'tables/div/div.php'; } elseif (isset($_POST['addDiv'])) { //load the divs management table\ include_once 'tables/div/div.php';
<?php require '../Business/ArticleClass.php'; //build new article business object $newArticle = new ArticleClass($_POST['aWebName'], $_POST['aTitle'], $_POST['aContent']); $newArticle->setDesc($_POST['aDesc']); $newArticle->setDivContainer($_POST['aDivIn']); if ($_POST[aPageOn] == "all_pages") { $newArticle->setAllPagesBool(1); } else { $newArticle->setAllPagesBool(0); $newArticle->setPageOn($_POST['aPageOn']); } $result = $newArticle->saveArticle(); //report success/failure echo $result; ?>
<?php require '../Business/ArticleClass.php'; //build new article business object $newArticle = new ArticleClass($_POST['aWebName'], $_POST['aTitle'], $_POST['aContent']); $newArticle->setId($_POST['editArticleId']); $newArticle->setDesc($_POST['aDesc']); $newArticle->setDivContainer($_POST['aDivIn']); if ($_POST[aPageOn] == "all_pages") { $newArticle->setAllPagesBool(1); } else { $newArticle->setAllPagesBool(0); $newArticle->setPageOn($_POST['aPageOn']); } $result = $newArticle->updateArticle(); //report success/failure echo $result; ?>