Example #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;
 }
Example #2
0
 public static function getActionMeta(\ApiParam $params)
 {
     //
     $category = \Category::loadByName($params->categoryEnglishName);
     $user = \Visitor::user();
     $mobile = $user ? $user->mobile : null;
     $metaData = array();
     $microControls = array();
     $isActive = false;
     return compact('isActive', 'metaData', 'user', 'microControls');
 }
Example #3
0
 public static function pailemai_categorylist(\ApiParam $params)
 {
     //拍了卖专用
     $mobileCategoryList = array();
     $coverImageList = \Config::item('app.categoryCoverImages');
     $blackCategoryList = array('huochepiao', 'shoujihaoma', 'cheliangqiugou', 'qiumai');
     foreach ($coverImageList as $categoryEnglishName => $imageUrl) {
         if (in_array($categoryEnglishName, $blackCategoryList)) {
             continue;
         }
         $category = \Category::loadByName($categoryEnglishName);
         if ($category->name) {
             $mobileCategoryList[] = array('name' => $category->name, 'queryUri' => 'categoryEnglishName:' . $categoryEnglishName, 'pic' => $imageUrl, 'categoryEnglishName' => $categoryEnglishName);
         }
     }
     return $mobileCategoryList;
 }
 public function syncToDatabase()
 {
     $guid = getGUID();
     $user_guid = $_SESSION['guid'];
     $name = $this->data['name'];
     $description = $this->data['description'];
     $allot_date = date("Y-m-d H:i:s", strtotime("+" . $this->data['days'] . " day", time()));
     //$allot_date = new DateTime();
     var_dump($allot_date);
     $isgone = 0;
     $sql1 = insert_sql("INSERT INTO product(guid, user_guid, allot_date, name, description, isgone) VALUES(?,?,?,?,?,?)", 'sssssi', array($guid, $user_guid, $allot_date, $name, $description, $isgone));
     if (!$sql1) {
         $this->message = "Er ging iets mis";
         return;
     }
     foreach ($this->data['categories'] as $category) {
         $c = new Category();
         $c->loadByName($category);
         insert_sql("INSERT INTO product_has_category(product_guid, category_guid) VALUES(?,?)", 'ss', array($guid, $c->guid));
     }
     foreach ($this->data['imgGUIDs'] as $img) {
         insert_sql("UPDATE pictures SET product_guid = ? WHERE guid = ?", 'ss', array($guid, $img));
     }
 }
Example #5
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);
 }
Example #6
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);
 }