/** * @context OpenpearTemplf $ot フィルタ */ protected function __init__() { $this->add_module(new OpenpearAccountModule()); $this->vars('pear_domain', OpenpearConfig::pear_domain('openpear.org')); $this->vars('pear_alias', OpenpearConfig::pear_alias('openpear')); $this->vars('svn_url', OpenpearConfig::svn_url('http://svn.openpear.org')); $this->vars('ot', new OpenpearTemplf($this->user())); if ($this->is_login()) { $unread_messages_count = OpenpearMessage::unread_count($this->user()); if ($unread_messages_count > 0) { $this->vars('unread_messages_count', $unread_messages_count); } } }
/** * ????? * @const string $svn_url リポジトリのURL */ public function source_browse($package_name, $path = '') { if (empty($path)) { $this->redirect_method('source_browse', $package_name, '/trunk'); } // TODO 仕様の確認 // TODO SVNとの連携 $package = C(OpenpearPackage)->find_get(Q::eq('name', $package_name)); $path = rtrim(ltrim($path, ' /.'), '/'); $local_root = File::absolute(OpenpearConfig::svn_root(), $package->name()); $repo_path = File::absolute($local_root, $path); $info = Subversion::cmd('info', array($repo_path)); if ($info['kind'] === 'dir') { $this->vars('tree', self::format_tree(Subversion::cmd('list', array($info['url']), array('revision' => $this->in_vars('rev', 'HEAD'))))); } else { if ($info['kind'] === 'file') { $this->put_block('package/source_viewfile.html'); $p = explode('.', $info['path']); $ext = array_pop($p); if (in_array($ext, $this->allowed_ext)) { $source = Subversion::cmd('cat', array($info['url']), array('revision' => $this->in_vars('rev', 'HEAD'))); $this->vars('code', $source); try { $cache_key = array('syntax_highlight', md5($source)); if (Store::has($cache_key)) { $this->vars('code', Store::get($cache_key)); } else { include_once 'geshi/geshi.php'; $geshi = new Geshi($source, $ext); $code = $geshi->parse_code(); Store::set($cache_key, $code); $this->vars('code', $code); } $this->vars('geshi', true); } catch (Exception $e) { Log::debug($e); $this->vars('geshi', false); } } } else { $this->redirect_by_map('package', $package_name); } } $this->vars('path', $path); $this->vars('info', self::format_info($info)); $this->vars('package', $package); $this->vars('real_url', File::absolute(OpenpearConfig::svn_url(), implode('/', array($package->name(), $path)))); $this->vars('externals', Subversion::cmd('propget', array('svn:externals', $info['url']))); $this->add_vars_other_tree($package_name); }