svn: /pear2/sandbox/SimpleChannelFrontend/trunk/ src/SimpleChannelFrontend/Main.php src/SimpleChannelFrontend/ReleaseFileBrowser.php www/templates/html/ReleaseFileBrowser.tpl.php
[email protected] (Brett Bieber)
| Newsgroups | php.pear.cvs,php.pear.core |
|---|---|
| Message-ID | <[email protected]> |
saltybeagle Mon, 28 Jun 2010 20:45:37 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=300828
Log:
Add primitive release file browser.
Changed paths:
U pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php
A pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php
A pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/html/ReleaseFileBrowser.tpl.php
Modified: pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php 2010-06-28 20:38:04 UTC (rev 300827)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php 2010-06-28 20:45:37 UTC (rev 300828)
@@ -32,12 +32,14 @@
*/
public static $channel;
+ static public $channel_path;
+
public $page_title = '{page_title}';
public $page_content;
public $options = array('view' => 'news',
- 'format' => 'html');
+ 'format' => 'html');
protected static $view_map = array('news' => 'PEAR2\SimpleChannelFrontend\News',
'packages' => 'PEAR2\SimpleChannelFrontend\PackageList',
@@ -47,7 +49,9 @@
'categories' => 'PEAR2\SimpleChannelFrontend\Categories',
'category' => 'PEAR2\SimpleChannelFrontend\Category',
'support' => 'PEAR2\SimpleChannelFrontend\Support',
- 'search' => 'PEAR2\SimpleChannelFrontend\Search');
+ 'search' => 'PEAR2\SimpleChannelFrontend\Search',
+ 'filebrowser' => 'PEAR2\SimpleChannelFrontend\ReleaseFileBrowser',
+ );
public static $url = '';
@@ -102,15 +106,15 @@
\PEAR2\Pyrus\Config::current()->cache_dir = '/tmp';
static::$channel = \PEAR2\Pyrus\Config::current()->channelregistry['pear2.php.net'];
- $base_directory = dirname($channel->path);
-
+ static::$channel_path = dirname($channel->path);
+
$rest = str_replace('http://' . $channel->name,
'',
$channel->protocols->rest['REST1.0']->baseurl);
- Internet::addDirectory($base_directory . '/get',
+ Internet::addDirectory(static::$channel_path . '/get',
'http://' . $channel->name . '/get/');
- Internet::addDirectory($base_directory . $rest,
+ Internet::addDirectory(static::$channel_path . $rest,
$channel->protocols->rest['REST1.0']->baseurl);
static::$channel->fromArray($channel->getArray());
Added: pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php (rev 0)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php 2010-06-28 20:45:37 UTC (rev 300828)
@@ -0,0 +1,32 @@
+<?php
+namespace PEAR2\SimpleChannelFrontend;
+class ReleaseFileBrowser
+{
+ public $options;
+
+ public $release;
+
+ public $internal_file;
+
+ function __construct($options = array())
+ {
+ $file = Main::$channel_path.'/get/'.$options['release'];
+ if (!file_exists($file)
+ || dirname($file) != Main::$channel_path.'/get') {
+ throw new \Exception('Cannot find the package. '.$file);
+ }
+
+ $this->release = new \PharData($file);
+
+ if (isset($options['internal'])) {
+ $file = 'phar://'.$file.'/'.$options['internal'];
+ if (file_exists($file)) {
+ $this->internal_file = new \SplFileObject($file);
+ }
+ }
+
+ $this->options = $options;
+
+ }
+
+}
\ No newline at end of file
Added: pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/html/ReleaseFileBrowser.tpl.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/html/ReleaseFileBrowser.tpl.php (rev 0)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/html/ReleaseFileBrowser.tpl.php 2010-06-28 20:45:37 UTC (rev 300828)
@@ -0,0 +1,19 @@
+<ul style="width:250px; float:left;">
+<?php
+foreach (new RecursiveIteratorIterator($context->getRaw('release')) as $file) {
+ $filename = substr($file, strpos($file, $context->options['release'])+strlen($context->options['release'])+1);
+ echo '<li><a href="?view=filebrowser&release='.$context->options['release'].'&internal='.$filename.'">'.$filename.'</a></li>';
+}
+?>
+</ul>
+<div class="source_browser">
+<?php
+if (isset($context->internal_file)) {
+ echo '<ol>';
+ foreach ($context->internal_file as $line) {
+ echo '<li>'.$line.'</li>';
+ }
+ echo '</ol>';
+}
+?>
+</div>
\ No newline at end of file