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()
 {
     $perpageActivity = 4;
     $slug = $this->getRequest()->getParam('slug');
     $pageno = $this->getRequest()->getParam('page', 1);
     if (!$slug) {
         throw new Zend_Controller_Exception();
     }
     $mCompany = new Application_Model_Company();
     $company = $mCompany->getOneBySlug($slug);
     if (!$company) {
         throw new Zend_Controller_Exception();
     } else {
         // get activity info from db
         $tableActivity = new Application_Model_DbTable_Activity();
         $where = $tableActivity->getAdapter()->quoteInto('company_id=?', $company['id']);
         // do query
         $activity = $tableActivity->fetchAll($tableActivity->select()->from($tableActivity, '*')->where($where)->order('event_date desc')->limit($perpageActivity, ($pageno - 1) * $perpageActivity))->toArray();
         // get activity id
         foreach ($activity as $ak => $av) {
             $activityIds[] = $av['id'];
         }
         // get total of activity
         $rs = $tableActivity->fetchRow($tableActivity->select()->from($tableActivity, 'count(*) as total')->where($where))->toArray();
         $total = $rs['total'];
         //  get sub activity info from db
         $tableSubActivity = new Application_Model_DbTable_SubActivity();
         $where = $tableActivity->getAdapter()->quoteInto('activity_id in (?)', $activityIds);
         //			$where  .= $tableActivity->getAdapter()->quoteInto(' AND is_published=?');
         $subActivity = $tableSubActivity->fetchAll($tableSubActivity->select()->from($tableSubActivity)->where($where)->order('event_date desc'))->toArray();
         // format data
         $mAntique = new Application_Model_Antique();
         foreach ($activity as $k => $v) {
             $fullCount = 0;
             foreach ($subActivity as $sk => $sv) {
                 if ($v['id'] == $sv['activity_id']) {
                     $sv['antique_count'] = $mAntique->getCountBySubAcitivityId($sv['id']);
                     $activity[$k]['sub_activity'][] = $sv;
                     $fullCount += $sv['antique_count'];
                 }
             }
             $activity[$k]['antique_count'] = $fullCount;
         }
         $this->view->activity = $activity;
         $this->view->company = $company;
         // paginator
         $paginator = Zend_Paginator::factory(intval($total));
         $paginator->setDefaultItemCountPerPage($perpageActivity);
         $paginator->setCurrentPageNumber($pageno);
         $this->view->paginator = $paginator;
     }
 }
 /**
  * 
  * 
  * @throws Api_Model_Exception
  */
 public function showAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (!$id) {
         throw new Api_Model_Exception('', Api_Model_Exception::E_PARAM_REQUIRED);
     }
     $ids = explode(',', $id);
     $mAntique = new Application_Model_Antique();
     $mAntique->setWithActivity()->setWithPhoto();
     foreach ($ids as $id) {
         $rs[] = $mAntique->getOneById($id);
     }
     echo json_encode($rs);
 }
 /**
  * 详情页
  * 
  */
 public function showAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (!$id) {
         throw new Zend_Controller_Exception();
     }
     $mAntique = new Application_Model_Antique();
     $mAntique->setWithActivity()->setWithCompany()->setWithSubActivity()->setWithPhoto();
     $this->view->antique = $mAntique->getOneById($id);
     // random antiques
     $condition = array('activity_id' => $this->similarAntiqueActivityId);
     $rs = $mAntique->getSearch($condition, 4, 0, 'random');
     $this->view->antiquesRandom = $rs['data'];
 }