default: throw new Exception("unkown action: {$action}"); break; } } $types = Product::types(); switch ($target) { case '': list($name, $no, $type, $sort1, $sort2) = _get('name', 'no', 'type', 'sort1', 'sort2'); $sort = $sort1 ? $sort1 . ' ' . $sort2 : ''; $p = _get('p') ?: 1; $per_page = 50; $total = Product::count(array('name' => $name, 'no' => $no, 'type' => $type)); $paging = new Paginate($per_page, $total); $paging->setCurPage($p); $products = Product::listProduct(array('limit' => $per_page, 'offset' => $paging->offset(), 'name' => $name, 'no' => $no, 'type' => $type, 'sort' => $sort)); break; case 'post': $types = Product::types(); list($name, $no, $type, $material, $weight, $rabbet_start, $rabbet_end, $small_stone, $st_weight, $remark) = _post('name', 'no', 'type', 'material', 'weight', 'rabbet_start', 'rabbet_end', 'small_stone', 'st_weight', 'remark'); $image1 = _post('image1'); $image1_400 = _post('image1_400'); $image1_thumb = _post('image1_thumb'); $image2 = _post('image2'); $image2_400 = _post('image2_400'); $image2_thumb = _post('image2_thumb'); $image3 = _post('image3'); $image3_400 = _post('image3_400'); $image3_thumb = _post('image3_thumb'); $material = _post('material'); if ($material) {