public function actionCat()
 {
     //Безопасность для $_GET и дополнительная проверка параметра cat
     $varCat = intval($_GET['cat']);
     $objCatMod = new CatModel();
     $varMaxValCat = $objCatMod->getMaxValCat();
     $objCatSup = new SupportingLib();
     $varCat = $objCatSup->getRightVal($varMaxValCat[0]['id'], $varCat, 0, 1);
     $varPage = intval($_GET['page']);
     //Подсчёт количества видео в категории для ПН(постраничная навигация):
     $varSumVid = $objCatMod->getSumVid($varCat);
     //Дополнительные операции для ПН:
     $varAdditSup = $objCatSup->actPageNav($varPage, $varSumVid[0]["COUNT(*)"]);
     //Выборка видеo по категории:
     $varVidCat = $objCatMod->getCatVid($varCat, $varAdditSup[0]);
     $view = new View();
     //Создание свойства для видео по категории
     $view->varShortInf = $varVidCat;
     //Создание свойств для ПН
     $view->cat = $varCat;
     $view->page = $varAdditSup[1];
     $view->sumVid = +$varSumVid[0]["COUNT(*)"];
     $view->ctrl = 'Video';
     $view->act = 'Cat';
     //Создание свойства для информации по категории
     $view->getInfoCat = static::getCatInfo($varCat);
     //Создание свойств для навигационного меню и футера
     $view->sqlNav = static::sqlNav();
     $view->sqlFoot = static::sqlFoot();
     //Подключение страницы вывода
     $view->display('ViewCat.php');
 }
Esempio n. 2
0
 /**
  * 取出指定栏目的商品
  * @param $cat_id
  * @return array $sons
  */
 public function getGoodsByCat($cat_id)
 {
     $category = new CatModel();
     $cats = $category->getList();
     $sons = $category->getListTree($cats, $cat_id);
     $sub = array($cat_id);
     if (!empty($sons)) {
         foreach ($sons as $v) {
             $sub[] = $v['cat_id'];
         }
     }
     $in = implode(',', $sub);
     $sql = 'select goods_id,goods_name,shop_price,market_price,thumb_img from ' . $this->table . ' where cat_id in (' . $in . ') order by add_time';
     return $this->db->getAll($sql);
 }
Esempio n. 3
0
 public function catGoodsCount($cat_id)
 {
     $category = new CatModel();
     $cats = $category->select();
     // 取出所有的栏目来
     $sons = $category->getCatTree($cats, $cat_id);
     // 取出给定栏目的子孙栏目
     $sub = array($cat_id);
     if (!empty($sons)) {
         // 没有子孙栏目
         foreach ($sons as $v) {
             $sub[] = $v['cat_id'];
         }
     }
     $in = implode(',', $sub);
     $sql = 'select count(*) from goods where cat_id in (' . $in . ')';
     return $this->db->getOne($sql);
 }
Esempio n. 4
0
	public function catGoods($cat_id){
		$category = new CatModel();
		$cats = $category->select(); //取出所有的栏目来
		$sons = $category->getCatTree($cats, $cat_id); //取出给定栏目的子孙栏目

		$sub = array($cat_id);


		if(!empty($sons)){ //没有子孙栏目

			foreach($sons as $v){
				$sub[] = $v['cat_id'];
			}

		}

		$in = implode(',', $sub);

	   $sql = 'select goods_id,goods_name,shop_price,market_price,thumb_img from ' . $this->table . ' where cat_id in (' . $in . ') order by add_time limit 5';

		return $this->db->getAll($sql);


	}
Esempio n. 5
0
<?php

/**
*catedit.php
*作用: 编辑栏目
*
*思路:
*接收cat_id
*
*实例化model
*调用model取出栏目信息
*
*展示到表单
**/
define('ACC', true);
require '../include/init.php';
$cat_id = $_GET['cat_id'] + 0;
$cat = new CatModel();
$catinfo = $cat->find($cat_id);
$catlist = $cat->select();
$catlist = $cat->getCatTree($catlist);
//print_r($catinfo);
include ROOT . 'view/admin/templates/catedit.html';
Esempio n. 6
0
调用model

删除cat_id
**/
define('ACC', true);
require '../include/init.php';
$cat_id = $_GET['cat_id'] + 0;
/*
判断该栏目是否有子栏目
如果有子栏目,则该栏目不允许删除

思路:
无限级分类有3个基本应用
1:查子栏目
2:查子孙栏目
3:查家谱树


我们可以在model写一个方法,专门查子栏目.
调用一下,并判断
*/
$cat = new CatModel();
$sons = $cat->getSon($cat_id);
if (!empty($sons)) {
    exit('有子栏目,不允许删除');
}
if ($cat->delete($cat_id)) {
    echo '删除成功';
} else {
    echo '删除失败';
}
Esempio n. 7
0
<?php

define('ACC', true);
require '../include/init.php';
/***
 * file catelist.php
 * 目录列表显示页面控制器
 * @author zhangyang
 */
$cat = new CatModel();
$catelist = $cat->getList();
$catelist = $cat->getListTree($catelist, 0);
include ROOT . 'view/admin/templates/catelist.html';
Esempio n. 8
0
<?php

define('ACC', true);
/**
 * Created by PhpStorm.
 * User: 洋
 * Date: 2015/8/19 0019
 * Time: 16:25
 */
require './include/init.php';
$cat = new CatModel();
$catList = $cat->getList();
$catList = $cat->getListTree($catList, 0);
$goods = new GoodsModel();
if (isset($_GET['cat_id'])) {
    $goodsList = $goods->getGoodsByCat($_GET['cat_id']);
    $catFamily = $cat->getFamilyTree($_GET['cat_id']);
    $catFamily = array_reverse($catFamily);
} else {
    $goodsList = $goods->getGoodsByCat(0);
}
include ROOT . 'view/front/lanmu.html';
Esempio n. 9
0
/*
@Describe:栏目页面
@Author:GongBiao
@Date:2015/07/04
*/
header('Content-Type:text/html; charset=utf-8');

define('ACC', true);
require('./include/init.php');
//session_start();  //写到了init里面初始化开启session_start();

//接收传过来的栏目ID
$cat_id = isset($_GET['cat_id'])?$_GET['cat_id'] + 0 : 0;

//查找栏目
$cat = new CatModel();
$category = $cat->find($cat_id);


if(empty($category)){
	header('location: index.php');
	exit;
}

//取出树状导航

$cats = $cat->select(); //取出所有栏目

$sort = $cat->getCatTree($cats, 0, 1); //把取出的栏目排序

//取出面包屑导航
Esempio n. 10
0
<?php

define('ACC', true);
require '../include/init.php';
/***
 * file catedit.php
 * 栏目编辑页面控制器
 * 
 * 接收cat_id
 * 实例化model
 * 调用model取出栏目信息
 * 展示到表单
 * @author zhangyang
 */
$cat_id = $_GET['cat_id'] + 0;
$cat = new CatModel();
$catinfo = $cat->find($cat_id);
$catlist = $cat->getList();
$catlist = $cat->getListTree($catlist);
//print_r($catinfo);
include ROOT . 'view/admin/templates/catedit.html';
Esempio n. 11
0
File: goods.php Progetto: wyjie/bool
<?php

define('ACC', true);
require './include/init.php';
$goods_id = isset($_GET['goods_id']) ? $_GET['goods_id'] + 0 : 0;
// 先查询这个商品信息
$goods = new GoodsModel();
$g = $goods->find($goods_id);
if (empty($g)) {
    header('location: index.php');
    exit;
}
$cat = new CatModel();
$nav = $cat->getTree($g['cat_id']);
include ROOT . 'view/front/shangpin.html';
Esempio n. 12
0
<?php
header('Content-Type:text/html; charset=utf-8');
define('ACC', true);
require('../include/init.php');
//调用model
$cat = new CatModel();
$catlist = $cat->select();

$catlist = $cat->getCatTree($catlist, 0); //目标无限级分类格式化

/*
echo '<pre>';
print_r($catlist);
echo '</pre>';
*/
include(ROOT.'view/admin/templates/catelist.html');

?>
 public function getCatInfo($cat)
 {
     //Запрос информации о категории из базы
     $catObj = new CatModel();
     return $catObj->getInfoCat($cat);
 }
Esempio n. 14
0
$cat_id = isset($_GET['cat_id']) ? $_GET['cat_id'] + 0 : 0;
$page = isset($_GET['page']) ? $_GET['page'] + 0 : 1;
if ($page < 1) {
    $page = 1;
}
$goodsModel = new GoodsModel();
$total = $goodsModel->catGoodsCount($cat_id);
// 每页取2条
$perpage = 2;
if ($page > ceil($total / $perpage)) {
    $page = 1;
}
$offset = ($page - 1) * $perpage;
$pagetool = new PageTool($total, $page, $perpage);
$pagecode = $pagetool->show();
$cat = new CatModel();
$category = $cat->find($cat_id);
if (empty($category)) {
    header('location: index.php');
    exit;
}
// 取出树状导航
$cats = $cat->select();
// 获取所有的栏目
$sort = $cat->getCatTree($cats, 0, 1);
// 取出面包屑导航
$nav = $cat->getTree($cat_id);
// 取出栏目下的商品
$goods = new GoodsModel();
$goodslist = $goods->catGoods($cat_id, $offset, $perpage);
include ROOT . 'view/front/lanmu.html';
Esempio n. 15
0
<?php
//栏目编辑Control
define('ACC', true);
require('../include/init.php');
$cat_id = $_GET['cat_id'] + 0;

$cat = new CatModel();
$catinfo = $cat->find($cat_id); //取出要找的一行数据

$catlist = $cat->select(); //取出数据
$catlist = $cat->getCatTree($catlist); //无限级分类

/*
echo '<pre>';
print_r($catlist);
echo '</pre>';
*/

require(ROOT.'view/admin/templates/catedit.html');
?>
Esempio n. 16
0
<?php

define('ACC', true);
require '../include/init.php';
$cat = new CatModel();
$catlist = $cat->select();
$catlist = $cat->getCatTree($catlist);
include ROOT . 'view/admin/templates/cateadd.html';
Esempio n. 17
0
/*
判断该栏目是否有子栏目
如果有子栏目,则该栏目不允许删除

思路:
无限级分类有3个基本应用
1:查子栏目
2:查子孙栏目
3:查家谱树

我们可以在model写一个方法,专门查子栏目
*/



$cat = new CatModel();

$sons = $cat->getSon($cat_id); //判断有没有子栏目,有子栏目不允许删除
if(!empty($sons)){
	exit('有子栏目,不允许删除');
}

if($cat->delete($cat_id)){
	echo '删除成功';
}else{
	echo '删除失败';
}



?>
Esempio n. 18
0
echo '</pre>';
*/

//第二步,检验数据
$data = array();
if(empty($_POST['cat_name'])){
	exit('栏目名不能为空');	
}
$data['cat_name'] = $_POST['cat_name'];

//同理判断intro及父栏目id是否合法

$data['parent_id'] = $_POST['parent_id'];
$data['intro'] = $_POST['intro'];


//第三眇,实例化model
//并调用model类相关方法

$cat = new CatModel();

if($cat->add($data)){
	echo '栏目添加成功';
}else{
	echo '栏目添加失败';
	exit;
}



?>
Esempio n. 19
0
$data['intro'] = $_POST['intro'];
$cat_id = $_POST['cat_id'] + 0;
/*
一个栏目A,不能修改成为A的子孙栏目的子栏目.

思考: 如果B是A的后代,则A不能成为B的子栏目.
反之, B是A的后代,则A是B的祖先


因此,我们为A设定一个新的父栏目时,设为N
我们可以先查N的 家谱树,N的家谱树里,如果有A

则子孙差辈了. 
*/
// 调用model 来更改
$cat = new CatModel();
// 查找新父栏目的家谱树
$trees = $cat->getTree($data['parent_id']);
// 判断自身是否在新父栏目的家谱树里面
$flag = true;
foreach ($trees as $v) {
    if ($v['cat_id'] == $cat_id) {
        $flag = false;
        break;
    }
}
if (!$flag) {
    echo '父栏目选取错误';
    exit;
}
if ($cat->update($data, $cat_id)) {
Esempio n. 20
0
<?php

define('ACC', true);
require './include/init.php';
/**
 * Created by PhpStorm.
 * User: 洋
 * Date: 2015/8/20 0020
 * Time: 14:36
 */
$goods = new GoodsModel();
$cat = new CatModel();
if (isset($_GET['goods_id'])) {
    $goods_info = $goods->getOne($_GET['goods_id']);
    $catFamily = $cat->getFamilyTree($goods_info['cat_id']);
    $catFamily = array_reverse($catFamily);
    include ROOT . 'view/front/shangpin.html';
} else {
    $msg = "啊哦出错了!";
    include ROOT . 'view/front/msg.html';
}