예제 #1
0
파일: actions.php 프로젝트: kzfk/emlauncher
 public function executeIndex()
 {
     static $pf = array('android' => Package::PF_ANDROID, 'ios' => Package::PF_IOS, 'all' => null);
     $platform = mfwRequest::param('pf');
     if (!in_array($platform, array('android', 'ios', 'all'))) {
         $ua = mfwRequest::userAgent();
         if ($ua->isAndroid()) {
             $platform = 'android';
         } elseif ($ua->isIOS()) {
             $platform = 'ios';
         } else {
             $platform = 'all';
         }
     }
     $tags = mfwRequest::param('tags') ? explode(' ', mfwRequest::param('tags')) : array();
     $current_page = mfwRequest::param('page', 1);
     $offset = ($current_page - 1) * self::LINE_IN_PAGE;
     $pkgs = PackageDb::selectByAppIdPfTagsWithLimit($this->app->getId(), $pf[$platform], $tags, $offset, self::LINE_IN_PAGE + 1);
     $has_next_page = false;
     if ($pkgs->count() > self::LINE_IN_PAGE) {
         $pkgs = $pkgs->slice(0, self::LINE_IN_PAGE);
         $has_next_page = true;
     }
     $comment_count = CommentDb::selectCountByAppId($this->app->getId());
     $top_comments = CommentDb::selectByAppId($this->app->getId(), 2);
     $commented_package = PackageDb::retrieveByPKs($top_comments->getColumnArray('package_id'));
     $params = array('pf' => $platform, 'is_owner' => $this->app->isOwner($this->login_user), 'packages' => $pkgs, 'active_tags' => $tags, 'current_page' => $current_page, 'has_next_page' => $has_next_page, 'filter_open' => mfwRequest::param('filter_open'), 'top_comments' => $top_comments, 'comment_count' => $comment_count, 'commented_package' => $commented_package);
     return $this->build($params);
 }
예제 #2
0
 public function executeComment()
 {
     $app_id = $this->app->getId();
     $comment_count = CommentDb::selectCountByAppId($app_id);
     $current_page = mfwRequest::param('page', 1);
     $max_page = ceil($comment_count / self::COMMENTS_IN_PAGE);
     $offset = max(0, min($current_page, $max_page) - 1) * self::COMMENTS_IN_PAGE;
     $comments = CommentDb::selectByAppId($app_id, self::COMMENTS_IN_PAGE, $offset);
     $commented_package = PackageDb::retrieveByPKs($comments->getColumnArray('package_id'));
     $install_packages = $this->login_user->getInstallPackages($app_id);
     $install_packages->sort(function ($a, $b) {
         return $a['id'] < $b['id'];
     });
     $params = array('comments_in_page' => self::COMMENTS_IN_PAGE, 'comment_count' => $comment_count, 'comments' => $comments, 'commented_package' => $commented_package, 'cur_page' => $current_page, 'max_page' => $max_page, 'install_packages' => $install_packages);
     return $this->build($params);
 }
예제 #3
0
파일: User.php 프로젝트: kzfk/emlauncher
 public function getInstallPackages($app_id)
 {
     $pkg_ids = InstallLog::getInstallPackageIds($this, $app_id);
     return PackageDb::retrieveByPKs($pkg_ids);
 }