public function showAction()
 {
     $perpage = 20;
     $pageno = $this->getRequest()->getParam('page', 1);
     $id = $this->getRequest()->getParam('id');
     if (!$id) {
         throw new Zend_Controller_Exception();
     }
     // get sub-activity info
     $mSubActivity = new Application_Model_SubActivity();
     $subActivity = $mSubActivity->getOneById($id);
     if (!$subActivity) {
         throw new Zend_Controller_Exception();
     } else {
         // get antique
         $condition = array('sub_id' => $id);
         $mAntique = new Application_Model_Antique();
         $mAntique->setWithPhoto()->setWithActivity()->setWithCompany();
         $rs = $mAntique->getSearch($condition, $perpage, ($pageno - 1) * $perpage, 'lotup');
         $this->view->antiques = $antiques = $rs['data'];
         $total = $rs['total'];
         // get activity
         $subActivity['activity'] = $antiques[0]['activity'];
         // get company
         $subActivity['company'] = $antiques[0]['company'];
     }
     $this->view->subActivity = $subActivity;
     $paginator = Zend_Paginator::factory(intval($total));
     $paginator->setDefaultItemCountPerPage($perpage);
     $paginator->setCurrentPageNumber($pageno);
     $this->view->paginator = $paginator;
 }
 public function showAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (!$id) {
         throw new Api_Model_Exception('', Api_Model_Exception::E_PARAM_REQUIRED);
     }
     $ids = explode(',', $id);
     $mSub = new Application_Model_SubActivity();
     $rs = $mSub->getByIds($ids);
     echo json_encode($rs);
 }
Exemplo n.º 3
0
 public function get()
 {
     $table =& $this->dbTable;
     $where = $table->getAdapter()->quoteInto('is_published=?', Application_Model_DbTable_Link::IS_PUBLISHED_YES);
     $select = $table->select()->from($table, '*')->where($where)->order('sort_order');
     $links = $table->fetchAll($select)->toArray();
     foreach ($links as $l) {
         $subIds[] = $l['sub_id'];
     }
     $mSub = new Application_Model_SubActivity();
     $subs = $mSub->getByIds($subIds);
     $mPhoto = new Application_Model_Photo();
     $mAntique = new Application_Model_Antique();
     //
     foreach ($links as $k => &$link) {
         foreach ($subs as $sk => &$sub) {
             if ($link['sub_id'] == $sub['id']) {
                 // 如果不为空则使用name作为首页显示名,为空直接使用对应专场自己的名字
                 if (empty($link['name'])) {
                     $link['name'] = $sub['label'];
                 }
                 // 如果存在则作为此专场的缩略图显示于首页
                 if ($link['image']) {
                     if (strpos($link['image'], 'http://') === false) {
                         $link['image'] = $mPhoto->getPhotoUrl($link['image'], 160);
                     }
                 } else {
                     if (empty($link['image']) && $sub['cover']) {
                         $link['image'] = $mPhoto->getPhotoUrl($sub['cover'], 160);
                     } else {
                         $photo = $mPhoto->getBySubIdLot($link['sub_id'], $link['lot']);
                         $link['image'] = $photo[0]['url_thumb_160'];
                     }
                 }
             }
         }
         $res[$link['company_id']][] = $link;
     }
     return $links;
     // return $res;
 }