svn: /pear2/sandbox/pear2.php.net/trunk/ src/PEAR2Web/Router.php www/index.php www/templates/pear2/html/Categories.tpl.php www/templates/pear2/html/Category.tpl.php www/templates/pear2/html/PackageDetails.tpl.php

[email protected] (Michael Gauthier)
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
gauthierm                                Thu, 17 Jun 2010 21:44:51 +0000

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

Log:
Add category page. Still needs CSS work.

Changed paths:
    U   pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Router.php
    U   pear2/sandbox/pear2.php.net/trunk/www/index.php
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Categories.tpl.php
    A   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Category.tpl.php
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageDetails.tpl.php

Modified: pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Router.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Router.php	2010-06-17 21:24:06 UTC (rev 300547)
+++ pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Router.php	2010-06-17 21:44:51 UTC (rev 300548)
@@ -20,14 +20,21 @@
         $quotedBase = preg_quote($base, '/');
         $packageExp = "/"
             . "^\n"
-            . $quotedBase . "            # base\n"
-            . "(?<package>[0-9a-z_]+)    # package name\n"
-            . "(-                        # dash separator\n"
-            . "    (?<version>[0-9ab.]+) # version\n"
-            . ")?                        # ... is optional\n"
+            . $quotedBase . "             # base\n"
+            . "(?<package>[0-9a-z_]+)     # package name\n"
+            . "(-                         # dash separator\n"
+            . "    (?<version>[0-9ab.]+)  # version\n"
+            . ")?                         # ... is optional\n"
             . "$\n"
             . "/xi";

+        $categoryExp = "/"
+            . "^\n"
+            . $quotedBase . "categories\/ # base\n"
+            . "(?<category>[0-9a-z_\ -]+) # category name\n"
+            . "$\n"
+            . "/xi";
+
         if ($requestURI === $base) {
             $options['view'] = 'news';
         } elseif ($requestURI === $base . 'categories/') {
@@ -36,6 +43,12 @@
             $options['view'] = 'packages';
         } elseif ($requestURI === $base . 'support/') {
             $options['view'] = 'support';
+        } elseif (preg_match($categoryExp, $requestURI, $matches) === 1) {
+
+            // Viewing an individual category
+            $options['view']     = 'category';
+            $options['category'] = $matches['category'];
+
         } elseif (preg_match($packageExp, $requestURI, $matches) === 1) {

             // Viewing an individual package

Modified: pear2/sandbox/pear2.php.net/trunk/www/index.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/index.php	2010-06-17 21:24:06 UTC (rev 300547)
+++ pear2/sandbox/pear2.php.net/trunk/www/index.php	2010-06-17 21:44:51 UTC (rev 300548)
@@ -20,7 +20,7 @@
 );
 $savant->setTemplatePath(
     array(
-        __DIR__ . '/templates/default/html',
+//        __DIR__ . '/templates/default/html',
         __DIR__ . '/templates/pear2/html'
     )
 );

Modified: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Categories.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Categories.tpl.php	2010-06-17 21:24:06 UTC (rev 300547)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Categories.tpl.php	2010-06-17 21:44:51 UTC (rev 300548)
@@ -19,6 +19,7 @@

 $categoryCount = 0;
 foreach ($context as $category) {
+
     $class = ($categoryCount % $categoriesPerRow === 0) ?
         'category category-clear' : 'category';

@@ -27,7 +28,7 @@
     echo '<li class="' . $class . '">';

     echo '<h3>';
-    echo '<a href="#">';
+    echo '<a href="' . PEAR2\SimpleChannelFrontend\Main::getURL() . 'categories/' . $category->name . '">';
     echo '<span class="category-title">' . $category->name . '</span> ';
     echo '<span class="category-count">' . $packageCount . '</span>';
     echo '</a>';

Added: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Category.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Category.tpl.php	                        (rev 0)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Category.tpl.php	2010-06-17 21:44:51 UTC (rev 300548)
@@ -0,0 +1,47 @@
+<?php
+
+// Set the page title
+$parent->context->page_title = $context->name . ' | Categories | ' . PEAR2\SimpleChannelFrontend\Main::$channel->name;
+
+?>
+
+        <div id="categories" class="pearbox">
+            <div class="pearbox-header">
+                <h2>
+                    <a href="<?php echo PEAR2\SimpleChannelFrontend\Main::getURL(); ?>categories/">Packages</a>
+                    ›
+                    <?php echo $context->name; ?> <span><?php echo count($context); ?></span>
+                </h2>
+            </div>
+            <div class="pearbox-content clearfix">
+
+<?php
+
+foreach ($context as $key => $package) {
+    echo '<div class="package">';
+
+    echo '<div class="package-info">';
+
+    echo '<div class="package-title">';
+    echo '<a href="' . PEAR2\SimpleChannelFrontend\Main::getURL()
+        . $package->name . '">' . $package->name . '</a>';
+
+    echo '</div>';
+    echo '<div class="package-description">';
+    echo '<p>' . $package->summary . '</p>';
+    echo '</div>';
+
+    echo '</div>';
+    echo '<div class="package-more-info">';
+
+    echo $savant->render($package, 'PackageDetails.tpl.php');
+
+    echo '</div>';
+
+    echo '</div>';
+}
+
+?>
+
+            </div>
+        </div>


Property changes on: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Category.tpl.php
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageDetails.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageDetails.tpl.php	2010-06-17 21:24:06 UTC (rev 300547)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageDetails.tpl.php	2010-06-17 21:44:51 UTC (rev 300548)
@@ -52,6 +52,8 @@
             <th>Bugs:</th>
             <td></td>
         </tr -->
+
+<?php if ($parent->parent->context->options['view'] === 'package') { ?>
         <tr>
             <th>Maintainers:</th>
             <td>
@@ -73,5 +75,22 @@
 ?>
             </td>
         </tr>
+<?php } else { ?>
+        <tr>
+            <th>Maintained:</th>
+            <td>
+<?php
+
+if (count($context->maintainer) === 0) {
+    echo '<span class="package-unmaintained">no</span>';
+} else {
+    echo '<span class="package-maintained">yes</span>';
+}
+
+?>
+            </td>
+        </tr>
+<?php } ?>
+
     </tbody>
 </table>
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.