Exemple #1
0
 public static function getInstance($path, $params)
 {
     if (!count($path)) {
         self::redirectTo('home');
         exit;
     }
     $pname = $path[0];
     $path = self::nextPath($path);
     switch ($pname) {
         case 'home':
             $page = HomePage::getInstance($path, $params);
             break;
         case 'register':
             $page = RegistrationPage::getInstance($path, $params);
             break;
         case 'login':
             $page = LoginPage::getInstance($path, $params);
             break;
         case 'logout':
             $page = LogoutPage::getInstance($path, $params);
             break;
         case 'switch-user':
             $page = SwitchUserPage::getInstance($path, $params);
             break;
         case 'links':
             $page = LinksPage::getInstance($path, $params);
             break;
         case 'users':
             $page = UsersPage::getInstance($path, $params);
             break;
         case 'groups':
             $page = GroupsPage::getInstance($path, $params);
             break;
         case 'settings':
             $page = SettingsPage::getInstance($path, $params);
             break;
         case 'tools':
             $page = ToolsPage::getInstance($path, $params);
             break;
         case 'installation':
             $page = InstallationPage::getInstance($path, $params);
             break;
         default:
             $page = NotFoundPage::getInstance($path, $params);
     }
     return $page;
 }
Exemple #2
0
// 本周新品
$newlist = $mg->select(array('goods_id', 'goods_name', 'goods_price', 'goods_img'), 'is_new order by sale_total desc limit 0,3');
// 或的该栏目下的所有商品
$allCateId = ToolsInfClassify::ChildrenId($ALLCATE, $cate_id);
array_unshift($allCateId, $cate_id);
// 分页显示
$list_per_page = 16;
// 每页显示的条数
$sql = 'select count(*) from bl_goods where cate_id in (' . implode(',', $allCateId) . ')';
$list_total = $mg->getOne($sql);
// 显示的总条数
$page_total = ceil($list_total / $list_per_page);
// 总页数
// 获得当前显示的页
if (!isset($_GET['page']) || intval($_GET['page']) < 1) {
    $page = 1;
} else {
    if (intval($_GET['page']) > $page_total) {
        $page = $page_total;
    } else {
        $page = intval($_GET['page']);
    }
}
// 获得要显示的页码数组
$result = ToolsPage::DividePage($list_per_page, $list_total, $page, 'cate.php?cate_id=' . $cate_id);
$pages = $result['pages'];
$html = $result['html'];
$sql = "select g.goods_id,g.goods_name,g.cate_id,g.goods_price,g.goods_img from bl_goods as g where g.cate_id in (" . implode(',', $allCateId) . ') limit ' . ($page - 1) * $list_per_page . ',' . $list_per_page;
$goodslist = $mg->getAll($sql);
//print_r($goodslist);die();
require ROOT . 'view/front/cate.html';