예제 #1
0
 public function listAction()
 {
     $p = $_REQUEST;
     $pCateid = empty($p['cateid']) ? 0 : intval($p['cateid']);
     $pAid = empty($p['aid']) ? 0 : intval($p['aid']);
     $pOpt = empty($p['opt']) ? '' : trim($p['opt']);
     $tOptarr = array('up', 'down');
     $pSize = empty($p['size']) ? 5 : intval(trim($p['size']));
     $tTime = time();
     if (!in_array($pOpt, $tOptarr)) {
         Tool_Fnc::appMsg('操作类型错误');
     }
     if (empty($pCateid)) {
         Tool_Fnc::ajaxMsg('分类id不正确');
     }
     $tWhere = '';
     $tOrder = '';
     if ($pOpt == 'up') {
         $tWhere = ' and id < ' . $pAid;
         $tOrder = 'id desc';
     } else {
         $tWhere = ' and id > ' . $pAid;
         $tOrder = 'id asc';
     }
     if (empty($pAid)) {
         $tWhere = '';
         $tOrder = 'id desc';
     }
     #特殊情况
     $tMO = new ArticleModel();
     $tImgUrl = Yaf_Registry::get("config")->web->url->img;
     $tDatas = $tMO->field('id aid, concat(\'' . $tImgUrl . '\', head_img)  head_img,(view+initview) viewtotal,title,description,created')->where('cate_id = ' . $pCateid . $tWhere)->order($tOrder)->limit('0,' . $pSize)->fList();
     Tool_Fnc::ajaxMsg('', 1, $tDatas);
 }
예제 #2
0
 public function listAction()
 {
     $p = $_REQUEST;
     $pCateid = empty($p['cateid']) ? 0 : intval($p['cateid']);
     $pFid = empty($p['fid']) ? 0 : intval($p['fid']);
     $pOpt = empty($p['opt']) ? '' : trim($p['opt']);
     $tOptarr = array('up', 'down');
     $pSize = empty($p['size']) ? 5 : intval(trim($p['size']));
     $tTime = time();
     if (!in_array($pOpt, $tOptarr)) {
         Tool_Fnc::appMsg('操作类型错误');
     }
     if (empty($pCateid)) {
         Tool_Fnc::ajaxMsg('分类id不正确');
     }
     $tWhere = '';
     $tOrder = '';
     if ($pOpt == 'up') {
         $tWhere = ' and id > ' . $pFid;
         $tOrder = 'id asc';
     } else {
         $tWhere = ' and id < ' . $pFid;
         $tOrder = 'id desc';
     }
     if (empty($pFid)) {
         $tWhere = '';
         $tOrder = 'id asc';
     }
     #特殊情况
     $tMO = new FoodModel();
     $tImgUrl = Yaf_Registry::get("config")->web->url->img;
     #$tDatas = $tMO->field('id fid,title,c_id cateid,c_title cate_title, concat(\''.$tImgUrl.'\',thumb_img) thumb_img , concat(\''.$tImgUrl.'\',large_img) large_img,tag,calcium,vitamin_a,zinc,magnesium,vitamin_c,fiber_dietary,selenium,copper,carbohydrate,phosphor,fat,niacin,vitamin_e,manganese,cholesterol,iron,kalium,natrium,thiamine,protein,lactoflavin,calory,carotene')->where('c_id = ' . $pCateid .$tWhere)->order($tOrder)->limit('0,'.$pSize)->fList();
     $tDatas = $tMO->field('id fid,title,c_id cateid,c_title cate_title, concat(\'' . $tImgUrl . '\',thumb_img) thumb_img ,tag,protein')->where('c_id = ' . $pCateid . $tWhere)->order($tOrder)->limit('0,' . $pSize)->fList();
     $tFUMO = new FoodunitsModel();
     foreach ($tDatas as $tKey => $tRow) {
         $tUnits = $tFUMO->field('amount,unit,weight')->where('fid  = ' . $tRow['fid'])->fList();
         $tDatas[$tKey]['units'] = $tUnits;
     }
     Tool_Fnc::ajaxMsg('', 1, $tDatas);
 }