svn: /pear2/sandbox/pear2.php.net/trunk/www/ css/main.css css/package.css templates/pear2/html/Package.tpl.php templates/pear2/html/PackageFileInfo.tpl.php

[email protected] (Michael Gauthier)
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
gauthierm                                Thu, 15 Jul 2010 17:47:17 +0000

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

Log:
Add link to file browser on the package details page.

Changed paths:
    U   pear2/sandbox/pear2.php.net/trunk/www/css/main.css
    U   pear2/sandbox/pear2.php.net/trunk/www/css/package.css
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Package.tpl.php
    A   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageFileInfo.tpl.php

Modified: pear2/sandbox/pear2.php.net/trunk/www/css/main.css
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/css/main.css	2010-07-15 16:57:14 UTC (rev 301293)
+++ pear2/sandbox/pear2.php.net/trunk/www/css/main.css	2010-07-15 17:47:17 UTC (rev 301294)
@@ -131,6 +131,7 @@
 	padding: 2px 12px;
 }

+a.button:hover,
 a.button-small:hover {
 	text-decoration: none;
 	cursor: default;

Modified: pear2/sandbox/pear2.php.net/trunk/www/css/package.css
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/css/package.css	2010-07-15 16:57:14 UTC (rev 301293)
+++ pear2/sandbox/pear2.php.net/trunk/www/css/package.css	2010-07-15 17:47:17 UTC (rev 301294)
@@ -178,8 +178,26 @@
 }

 /* }}} */
+/* {{{ Browse files */
+
+.package-files {
+	margin: 15px 0 5px 1.8em;
+}
+
+.package-files h3 {
+	font-size: 13px;
+	display: inline;
+	margin: 0 0.5em 0 0;
+}
+
+/* }}} */
 /* {{{ Package releases */

+.package-releases h3 {
+	/* TODO: remove this when the documentation section goes live */
+	margin-top: 0;
+}
+
 .package-releases table {
 	margin: 0;
 	width: 100%;

Modified: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Package.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Package.tpl.php	2010-07-15 16:57:14 UTC (rev 301293)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Package.tpl.php	2010-07-15 17:47:17 UTC (rev 301294)
@@ -42,7 +42,13 @@
 echo $savant->render($context, 'PackageDetails.tpl.php');

 ?>
+<?php

+$filesURL = PEAR2\SimpleChannelFrontend\Main::getURL()
+    . $context->name . '/files';
+
+?>
+
     <div class="package-releases">
         <h3>Release History</h3>
         <table>
@@ -94,11 +100,20 @@
     $count++;
 }

+// TODO: should iteration really modify the object?
+$context->rewind();
+$context->setRawVersion(null, array('release' => $context->key()));
+
 ?>
             </tbody>
         </table>
     </div>

+    <div class="package-files">
+        <h3><a class="button" href="<?php echo $filesURL; ?>">Browse Files</a></h3>
+        <span class="package-files-info"><?php echo $savant->render($context, 'PackageFileInfo.tpl.php'); ?>
+    </div>
+
 <?php

 echo $savant->render($context, 'PackageDependencies.tpl.php');

Added: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageFileInfo.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageFileInfo.tpl.php	                        (rev 0)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageFileInfo.tpl.php	2010-07-15 17:47:17 UTC (rev 301294)
@@ -0,0 +1,41 @@
+<?php
+
+$releaseFile = $context->name . '-' . $context->version['release'] . '.tgz';
+
+$root = rtrim(
+    \PEAR2\SimpleChannelFrontend\Main::$channel_path,
+    DIRECTORY_SEPARATOR
+);
+$root        = $root . DIRECTORY_SEPARATOR . 'get';
+$releaseFile = $root . DIRECTORY_SEPARATOR . $releaseFile;
+
+if (!file_exists($releaseFile) || dirname($releaseFile) != $root) {
+    throw new \Exception('Cannot find the package ' . $releaseFile . '.');
+}
+
+$releaseFile = new \PharData($releaseFile);
+
+$fileCount      = 0;
+$directoryCount = 0;
+
+$traverseFiles = function(
+    \RecursiveIterator $node
+) use (
+    &$traverseFiles,
+    &$fileCount,
+    &$directoryCount
+) {
+    foreach ($node as $file) {
+        if ($node->hasChildren()) {
+            $directoryCount++;
+            $traverseFiles($node->getChildren());
+        } else {
+            $fileCount++;
+        }
+
+    }
+};
+
+$traverseFiles($releaseFile);
+
+?><strong><?php echo $fileCount; ?></strong> files in <strong><?php echo $directoryCount; ?></strong> directories.


Property changes on: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageFileInfo.tpl.php
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native
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.