Esempio n. 1
0
 public static function category_meta(\ApiParam $params)
 {
     $metaConfig = array();
     $category = \Category::loadByName($params->categoryEnglishName);
     $category->clientType = \Category::CLIENT_API;
     $city = \City::loadByName($params->cityEnglishName ?: 'shanghai');
     if (!isset(\Page::$context['city'])) {
         \Page::$context['city'] = $city;
     }
     if (!isset(\Page::$context['category'])) {
         \Page::$context['category'] = $category;
     }
     if (!isset($metaConfig['wanted']) && $category->get('wanted')) {
         $meta = \Meta::factory('Radio', $category)->set('name', "wanted")->set('displayName', '供求')->set('controlView', 'radio')->set('style', 'required')->set('values', '1,0')->set('labels', explode('|', $category->get('wanted')));
         $metaConfig['wanted'] = self::metaConfig($meta, $city, $category, $params);
     }
     foreach ($category->metas() as $meta) {
         if (empty($meta->name)) {
             continue;
         }
         $metaConfig[$meta->name] = self::metaConfig($meta, $city, $category, $params);
     }
     //todo 暂时兼容
     if (!isset($metaConfig['images'])) {
         $meta = \Meta::factory('Input', $category)->set('name', "images")->set('displayName', '照片')->set('controlView', 'image')->set('style', '');
         $metaConfig['images'] = self::metaConfig($meta, $city, $category, $params);
     }
     return $metaConfig;
 }
Esempio n. 2
0
 public static function city_loadByName(\ApiParam $params)
 {
     if ($city = \City::loadByName($params->cityEnglishName)) {
         $data = self::cityFilter($city, $params);
     } else {
         $data = null;
     }
     return compact('data');
 }
Esempio n. 3
0
 private static function searchOption(\ApiParam $params, $sort = null)
 {
     $params->query = $params->query ? trim($params->query) : null;
     $query = $params->query ? new \RawQuery($params->query) : new \TrueQuery();
     if (isset($params['keyword']) && strlen(trim($params['keyword'])) > 0) {
         $keyword = trim($params['keyword']);
         $query = new \AndQuery($query, new \Query('title', $keyword));
     }
     $options = array();
     if ($params->cache) {
         $options['cache'] = 1;
     }
     $rows = intval($params->rows);
     $options['rows'] = $rows && $rows <= 1000 && $rows >= 0 ? $rows : '10';
     $start = $params->start;
     $options['start'] = $start && $start <= 100000 && $start >= 0 ? $start : '0';
     if ($sort) {
         $options['sort'] = $sort;
     }
     if ($params->d) {
         $options['d'] = $params->d;
     }
     $category = $params->categoryEnglishName ? \Category::loadByName($params->categoryEnglishName) : null;
     $city = $params->cityEnglishName ? \City::loadByName($params->cityEnglishName) : null;
     return array($query, $category, $city, $params->wanted, $options, $params->rt);
 }
Esempio n. 4
0
 public static function mobile_get_quota_info(\ApiParam $params)
 {
     $user = new \User();
     $user->load($params->userId);
     $city = \City::loadByName($params->cityEnglishName);
     $category = \Category::loadByName($params->categoryEnglishName);
     if (!$user || !$city || !$category) {
         throw new \Exception('参数错误', 777);
     }
     $quotaInfo = \Fabu_Logic::quotaInfo($user, $city, $category);
     $quotaInfo['message'] = strip_tags($quotaInfo['message']);
     $result = array('quota' => $quotaInfo);
     return self::composeResponse(0, 'succeed', $result);
 }