예제 #1
0
 /**
  * トップページ
  *
  * @context integer $package_count パッケージ総数
  * @context $primary_tags primary がセットされているタグリスト(上限付き)
  * @context $recent_releases 最新 OpenpearRelease モデルの配列
  */
 public function index()
 {
     if (Store::has('index/package_count', 3600)) {
         $package_count = Store::get('index/package_count');
     } else {
         $package_count = C(OpenpearPackage)->find_count();
         Store::set('index/package_count', $package_count, 3600);
     }
     if (Store::has('index/primary_tags', 3600)) {
         $primary_tags = Store::get('index/primary_tags');
     } else {
         $primary_tags = OpenpearPackage::getActiveCategories(8);
         Store::set('index/primary_tags', $primary_tags, 3600);
     }
     if (Store::has('index/recent_releases', 3600)) {
         $recent_releases = Store::get('index/recent_releases');
     } else {
         $recent_releases = C(OpenpearPackage)->find_all(new Paginator(5), Q::neq('latest_release_id', null), Q::order('-released_at'));
         Store::set('index/recent_releases', $recent_releases, 3600);
     }
     if (Store::has('index/most_downloaded', 3600)) {
         $most_downloaded = Store::get('index/most_downloaded');
     } else {
         $most_downloaded = C(OpenpearPackage)->find_all(new Paginator(5), Q::order('-download_count'));
         Store::set('index/most_downloaded', $most_downloaded, 3600);
     }
     $this->vars('package_count', $package_count);
     $this->vars('primary_tags', $primary_tags);
     $this->vars('recent_releases', $recent_releases);
     $this->vars('most_downloaded', $most_downloaded);
 }
예제 #2
0
 public function package()
 {
     if ($this->package instanceof OpenpearPackage === false) {
         try {
             $this->package = OpenpearPackage::get_package($this->package_id());
         } catch (Exception $e) {
         }
     }
     return $this->package;
 }
예제 #3
0
 public function check_repo_exists()
 {
     $this->login_required();
     try {
         $package = OpenpearPackage::get_package($this->in_vars('package_id'));
         $info = Subversion::cmd('info', array(File::absolute(OpenpearConfig::svn_root(), implode('/', array($package->name(), 'trunk', $this->in_vars('dir', ''))))));
         if (isset($info['kind']) && $info['kind'] == 'dir') {
             echo 'ok';
         } else {
             throw new RuntimeException('directory is not found');
         }
     } catch (Exception $e) {
         Log::debug($e);
         echo 'ng';
     }
     exit;
 }
예제 #4
0
 /**
  * パッケージ作成
  */
 public function package_create()
 {
     // TODO 仕様の確認
     $user = $this->user();
     $package = new OpenpearPackage();
     if ($this->is_post() && $this->verify()) {
         try {
             $package->cp($this->vars());
             $package->author_id($user->id());
             $package->save();
             $package->add_maintainer($user);
             $this->redirect_by_map('package', $package->name());
         } catch (Exception $e) {
             C($package)->rollback();
             Log::debug($e);
         }
     }
     $this->cp($package);
 }
예제 #5
0
 public final function srcpath_link(OpenpearPackage $package, $path)
 {
     $ret = '';
     $parent = '';
     foreach (explode('/', $path) as $p) {
         $link = File::absolute(url(sprintf('package/%s/src/%s', $package->name())), implode('/', array($parent, $p)));
         $ret .= sprintf('<a href="%s">%s</a>', $link, $p);
         $parent .= $p;
     }
     return $ret;
 }