예제 #1
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;
 }
예제 #2
0
 public function getOneBySubIdLot($subId, $lot)
 {
     if (empty($subId) || empty($lot)) {
         return array();
     }
     $table =& $this->dbTable;
     $where = $table->getAdapter()->quoteInto('sub_id=?', $subId);
     $where .= ' AND ' . $table->getAdapter()->quoteInto('lot=?', $lot);
     $antique = $table->fetchAll($table->select()->from($table, '*')->where($where))->toArray();
     $antique = $antique[0];
     if (!empty($antique)) {
         if ($this->withActivity) {
             $tableActivity = new Application_Model_DbTable_Activity();
             $activity = $tableActivity->find($antique['activity_id'])->toArray();
             $antique['activity'] = $activity[0];
         }
         if ($this->withSubActivity) {
             $tableSubActivity = new Application_Model_DbTable_SubActivity();
             $subActivity = $tableSubActivity->find($antique['sub_id'])->toArray();
             $antique['sub'] = $subActivity[0];
         }
         if ($this->withCompany) {
             $tableCompany = new Application_Model_DbTable_Company();
             $company = $tableCompany->find($antique['activity']['company_id'])->toArray();
             $antique['company'] = $company[0];
         }
         if ($this->withPhoto) {
             $modelPhoto = new Application_Model_Photo();
             $photo = $modelPhoto->getByAntiqueIds($id);
             $antique['photo'] = $photo;
         }
     }
     return $antique;
 }