Пример #1
0
 public static function action_get($args, &$returncode, &$profile, &$auth = false, $format = false)
 {
     if ($auth) {
         $returncode = ResponseCode::BAD_REQUEST;
         return false;
     }
     if (!$profile->perm_screenshot_get) {
         $returncode = ResponseCode::ACTION_NOT_ALLOWED;
         return false;
     }
     if (!isset($args->app_id)) {
         $returncode = ResponseCode::BAD_REQUEST;
         return false;
     }
     $sm = ScreenshotModel::getInstance();
     $shots = $sm->getByAppIDCached($args->app_id);
     if (!$shots) {
         $returncode = ResponseCode::RESOURCE_NOT_FOUND;
         return false;
     }
     $data = array('screenshots' => array());
     foreach ($shots as $shot) {
         $i = count($data['screenshots']);
         $data['screenshots'][$i] = array('is_horiz' => $shot->is_horiz, 'url' => $shot->shot_url);
     }
     $returncode = ResponseCode::OK;
     return $data;
 }
Пример #2
0
 case 'requirements':
     $jsonApp['requirements'] = $app->requirements;
     break;
 case 'icon100':
     $jsonApp['icon100'] = $app->bigicon_url;
     break;
 case 'icon57':
     $jsonApp['icon57'] = $app->smallicon_url;
     break;
 case 'latestcracker':
     $jsonApp['latestcracker'] = $app->latest_version_first_cracker;
     break;
 case 'screenshots':
     if (count($apps) == 1) {
         $jsonShots = array();
         $sm = ScreenshotModel::getInstance();
         $shots = $sm->getByAppIDCached($app->id);
         foreach ($shots as $shot) {
             $jsonShot = array();
             $jsonShot['url'] = $shot->shot_url;
             $jsonShot['is_horiz'] = $shot->is_horiz ? 1 : 0;
             $jsonShots[] = $jsonShot;
         }
         $jsonApp['screenshots'] = $jsonShots;
     }
     break;
 case 'links':
     if (count($apps) == 1) {
         $alm = AppLinkModel::getInstance();
         $links = $alm->getByAppIDCached($app->id);
         $jsonLinks = array();
Пример #3
0
 public function createFromITunesScraper($appinfo, $iconsPreSaved = false)
 {
     $bean = new ApplicationBean();
     $bean->itunes_id = $appinfo->getITunesID();
     $bean->name = $appinfo->getName();
     $bean->releasedate = $appinfo->getReleaseDate();
     $bean->seller = $appinfo->getSeller();
     $bean->company = $appinfo->getCompany() ?: $bean->seller;
     $bean->size = $appinfo->getSize();
     $bean->price = $appinfo->getPrice();
     $bean->description = $appinfo->getDescription();
     $bean->languages = $appinfo->getLanguages();
     $bean->requirements = $appinfo->getRequirements();
     $smallicon = $appinfo->getITunesID() . 'icon-57x57.png';
     $bigicon = $appinfo->getITunesID() . 'icon-100x100.png';
     if ($iconsPreSaved || $this->saveIconsLocally($appinfo->getIconUrlPNG(), $smallicon, $bigicon)) {
         $bean->smallicon_url = '%BASE_URL%/appimages/icons/' . $smallicon;
         $bean->bigicon_url = '%BASE_URL%/appimages/icons/' . $bigicon;
     }
     $bean->set('date_added', 'NOW()', true);
     $bean->set('last_updated', 'NOW()', true);
     $catname = $appinfo->getCategory() ?: 'Unknown';
     $acm = AppCategoryModel::getInstance();
     $cat = $acm->getByName($catname);
     if (!$cat) {
         $acm->create($catname);
         if (!($cat = $acm->getByName($catname))) {
             return false;
         }
     }
     $bean->category_id = $cat->id;
     try {
         $bean->insert();
     } catch (QueryFailedException $e) {
         return false;
     }
     $shots = $appinfo->getScreenshots();
     if ($shots) {
         if (!($bean = $this->getDetailsByITunesID($appinfo->getITunesID(), false))) {
             return false;
         }
         $sm = ScreenshotModel::getInstance();
         $sm->setScreenshots($bean->id, $bean->itunes_id, $shots);
     }
     $this->indexName($bean->name, $bean->id);
     $this->cm->clearGroup('applist');
     return true;
 }