svn: /pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ ReleaseFileBrowser.php

[email protected] (Michael Gauthier)
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
gauthierm                                Fri, 09 Jul 2010 19:54:06 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=301141

Log:
Changes to SCF's file browser.

Changed paths:
    U   pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php

Modified: pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php	2010-07-09 19:41:41 UTC (rev 301140)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/ReleaseFileBrowser.php	2010-07-09 19:54:06 UTC (rev 301141)
@@ -4,28 +4,56 @@

 class ReleaseFileBrowser
 {
+    public $package;
+
     public $options;

-    public $release;
+    public $releaseFile;

-    public $internal_file;
+    public $file;

     public function __construct($options = array())
     {
+        $channel       = $options['frontend']::$channel;
+        $this->package = $channel->remotepackage[$options['package']];
+
+        if (isset($options['packageVersion'])) {
+            // try to set specified version
+            try {
+                $this->package->setRawVersion(
+                    null,
+                    array('release' => $options['packageVersion'])
+                );
+            } catch (\Exception $e) {
+                throw new UnregisteredViewException($e->getMessage());
+            }
+        } else {
+            // set lastest release version
+            $this->package->rewind();
+            $this->package->setRawVersion(
+                null,
+                array('release' => $this->package->key())
+            );
+        }
+
+        $releaseFile = $this->package->name . '-'
+            . $this->package->version['release'] . '.tgz';
+
+
         $root = rtrim(Main::$channel_path, DIRECTORY_SEPARATOR);
         $root = $root . DIRECTORY_SEPARATOR . 'get';
-        $file = $root . DIRECTORY_SEPARATOR . $options['release'];
+        $file = $root . DIRECTORY_SEPARATOR . $releaseFile;

         if (!file_exists($file) || dirname($file) != $root) {
             throw new \Exception('Cannot find the package ' . $file . '.');
         }

-        $this->release = new \PharData($file);
+        $this->releaseFile = new \PharData($file);

-        if (isset($options['internal'])) {
-            $file = 'phar://'.$file.'/'.$options['internal'];
+        if (isset($options['file'])) {
+            $file = 'phar://' . $file . '/' . $options['file'];
             if (file_exists($file)) {
-                $this->internal_file = new \SplFileObject($file);
+                $this->file = new \SplFileObject($file);
             }
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.