svn: /pear2/sandbox/pear2.php.net/trunk/ src/PEAR2Web/Menu.php src/PEAR2Web/MenuDisplayer.php www/css/main.css www/index.php www/templates/pear2/html/Categories.tpl.php www/templates/pear2/html/LatestReleases.tpl.php www/templates/pear2/html/Main.tpl.php www/templates/pear2/html/MenuFoot.tpl.php www/templates/pear2/html/MenuHead.tpl.php www/templates/pear2/html/Package.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 13:58:40 +0000

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

Log:
Various cleanups and improvements to PEAR2Web:
- make menu render using Savant
- remove unnecessary double-escaping of special chars
- clean up clearfixes so extra markup is not needed
- add maintainers to package details

Changed paths:
    U   pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Menu.php
    D   pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/MenuDisplayer.php
    U   pear2/sandbox/pear2.php.net/trunk/www/css/main.css
    U   pear2/sandbox/pear2.php.net/trunk/www/index.php
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Categories.tpl.php
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/LatestReleases.tpl.php
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Main.tpl.php
    A   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuFoot.tpl.php
    A   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuHead.tpl.php
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Package.tpl.php
    U   pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageDetails.tpl.php
svn-diffs-300518.txt (text/x-diff, 15.4 KB)
Modified: pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Menu.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Menu.php	2010-06-17 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/Menu.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -4,7 +4,7 @@

 class Menu
 {
-    public static $data = array(
+    public $data = array(

         'packages'      => array(
             'title'     => 'Packages',

Deleted: pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/MenuDisplayer.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/MenuDisplayer.php	2010-06-17 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/src/PEAR2Web/MenuDisplayer.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -1,114 +0,0 @@
-<?php
-
-namespace PEAR2Web;
-
-class MenuDisplayer
-{
-    public static function display($base, array $menu, $selected = null)
-    {
-        echo "\t" . '<h1>';
-
-        if ($selected !== 'news') {
-            echo '<a href="' . $base . '">';
-        }
-
-        echo '<img src="' . $base . 'img/logo.png" alt="Pear" />';
-        echo '<span>PHP Extension and Application Repository</span>';
-
-        if ($selected) {
-            echo '</a>';
-        }
-
-        echo '</h1>' ."\n";
-
-        echo "\t\t\t" . '<div id="nav">' ."\n";
-        echo "\t\t\t" . '<ul id="navbar">' ."\n";
-
-        foreach ($menu as $id => $item) {
-            echo "\t\t\t\t";
-
-            if ($selected == $id) {
-                echo '<li class="selected">';
-            } else {
-                echo '<li>';
-            }
-
-            if ($selected != $id) {
-                echo '<a href="' . $base . $item['link'] . '">';
-            }
-
-            echo $item['title'];
-
-            if ($selected != $id) {
-                echo '</a>';
-            }
-
-            echo '</li>';
-            echo "\n";
-        }
-
-        echo "\t\t\t" . '</ul>' . "\n";
-
-        if (   $selected
-            && isset($menu[$selected])
-            && isset($menu[$selected]['menu'])
-            && is_array($menu[$selected]['menu'])
-            && count($menu[$selected]['menu']) > 0
-        ) {
-            echo "\t\t\t" . '<div id="subnav">' . "\n";
-            echo "\t\t\t\t" . '<div id="subnavcontainer">' . "\n";
-            echo "\t\t\t\t\t" . '<ul id="subnavbar">' . "\n";
-
-            foreach ($menu[$selected]['menu'] as $id => $item) {
-                echo "\t\t\t\t\t\t" . '<li>';
-
-                echo '<a href="' . $base . $item['link'] . '">';
-                echo $item['title'];
-                echo '</a>';
-
-                echo '</li>' . "\n";
-            }
-
-            echo "\t\t\t\t\t" . '</ul>' . "\n";
-            echo "\t\t\t\t" . '</div>' . "\n";
-            echo "\t\t\t" . '</div>' . "\n";
-        }
-
-        echo "\t\t\t" . '</div>' . "\n";
-        echo "\t\t\t" . '<div class="clearfix"></div>' . "\n";
-    }
-
-    public static function displayFooter($base, array $menu)
-    {
-        $last = end(array_keys($menu));
-
-        foreach ($menu as $id => $item) {
-            echo "\t\t\t";
-
-            if ($id == $last) {
-                echo '<ul class="footer-menu footer-menu-last">' . "\n";
-            } else {
-                echo '<ul class="footer-menu">' . "\n";
-            }
-
-            echo "\t\t\t\t" . '<li class="header">';
-            echo '<a href="' . $base . $item['link'] . '">';
-            echo $item['title'];
-            echo '</a>';
-            echo '</li>' . "\n";
-
-            if (isset($item['menu']) && is_array($item['menu'])) {
-                foreach ($item['menu'] as $subId => $subItem) {
-                    echo "\t\t\t\t";
-                    echo '<li><a href="' . $subItem['link'] . '">';
-                    echo $subItem['title'];
-                    echo '</a></li>' . "\n";
-                }
-            }
-
-            echo "\t\t\t" . '</ul>' . "\n";
-        }
-
-        echo "\t\t\t" . '<div class="clearfix"></div>' . "\n";
-    }
-}

Modified: pear2/sandbox/pear2.php.net/trunk/www/css/main.css
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/css/main.css	2010-06-17 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/www/css/main.css	2010-06-17 13:58:40 UTC (rev 300518)
@@ -44,7 +44,11 @@
 	font-weight: bold;
 }

-.clearfix {
+.clearfix::after {
+	display: block;
+	content: '.';
+	visibility: hidden;
+	height: 0;
 	clear: both;
 }


Modified: pear2/sandbox/pear2.php.net/trunk/www/index.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/index.php	2010-06-17 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/www/index.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -4,7 +4,6 @@
 require_once dirname(__FILE__).'/../src/PEAR2Web/Router.php';
 require_once dirname(__FILE__).'/../src/PEAR2Web/License.php';
 require_once dirname(__FILE__).'/../src/PEAR2Web/Menu.php';
-require_once dirname(__FILE__).'/../src/PEAR2Web/MenuDisplayer.php';

 $channel = new \PEAR2\Pyrus\ChannelFile(__DIR__ . '/channel.xml');


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 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Categories.tpl.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -12,7 +12,7 @@
                 <h2>Packages</h2>
                 <?php echo $savant->render(null, 'SearchForm.tpl.php'); ?>
             </div>
-            <div class="pearbox-content">
+            <div class="pearbox-content clearfix">

                 <ul class="categories">
 <?php
@@ -23,13 +23,12 @@
         'category category-clear' : 'category';

     $packageCount = count($category);
-    $categoryName = htmlspecialchars($category->name);

     echo '<li class="' . $class . '">';

     echo '<h3>';
     echo '<a href="#">';
-    echo '<span class="category-title">' . $categoryName . '</span> ';
+    echo '<span class="category-title">' . $category->name . '</span> ';
     echo '<span class="category-count">' . $packageCount . '</span>';
     echo '</a>';
     echo '</h3>';
@@ -50,11 +49,9 @@
                 break;
             } else {
                 $packageHref = PEAR2\SimpleChannelFrontend\Main::getURL()
-                    . htmlspecialchars($package->name);
+                    . $package->name;

-                $packageName = htmlspecialchars($package->name);
-
-                echo '<a href="' . $packageHref . '">' . $packageName . '</a>';
+                echo '<a href="' . $packageHref . '">' . $package->name . '</a>';
             }

             echo '</li>';
@@ -71,8 +68,6 @@
 ?>
                 </ul>

-                <div class="clearfix"></div>
-
             </div>
         </div>
         <h3>Don't see what you need?</h3>

Modified: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/LatestReleases.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/LatestReleases.tpl.php	2010-06-17 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/LatestReleases.tpl.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -14,10 +14,7 @@
     $packageURL = PEAR2\SimpleChannelFrontend\Main::getURL()
         . $package->name;

-    $packageTitle = htmlspecialchars(
-        str_replace('PEAR2_', '', $package->name)
-    );
-
+    $packageTitle  = str_replace('PEAR2_', '', $package->name);
     $packageTitle .= '-' . $package->version['release'];

     $releaseDate = date('F j', strtotime($date));

Modified: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Main.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Main.tpl.php	2010-06-17 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Main.tpl.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -23,14 +23,10 @@
 <div id="header">

     <div id="top">
-        <div class="content">
+        <div class="content clearfix">
 <?php

-PEAR2Web\MenuDisplayer::display(
-    PEAR2\SimpleChannelFrontend\Main::getURL(),
-    PEAR2Web\Menu::$data,
-    $context->options['view']
-);
+echo $savant->render(new PEAR2Web\Menu(), 'MenuHead.tpl.php');

 ?>
         </div>
@@ -39,7 +35,7 @@
     <?php if ($context->options['view'] == 'news'): ?>

     <div id="mid">
-        <div class="content">
+        <div class="content clearfix">

             <div class="left">
                 <h2>What is PEAR?</h2>
@@ -54,8 +50,6 @@
                 </div>
             </div>

-            <div class="clearfix"></div>
-
         </div>
     </div>

@@ -92,10 +86,7 @@

 <?php

-PEAR2Web\MenuDisplayer::displayFooter(
-    PEAR2\SimpleChannelFrontend\Main::getURL(),
-    PEAR2Web\Menu::$data
-);
+echo $savant->render(new PEAR2Web\Menu(), 'MenuFoot.tpl.php');

 ?>


Added: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuFoot.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuFoot.tpl.php	                        (rev 0)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuFoot.tpl.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -0,0 +1,37 @@
+<?php
+
+$base = PEAR2\SimpleChannelFrontend\Main::getURL();
+$last = end(array_keys($context->data));
+
+echo '            <div class="footer-menu-container clearfix">' . "\n";
+
+foreach ($context->data as $id => $item) {
+    echo '                ';
+
+    if ($id == $last) {
+        echo '<ul class="footer-menu footer-menu-last">' . "\n";
+    } else {
+        echo '<ul class="footer-menu">' . "\n";
+    }
+
+    echo '                    <li class="header">';
+    echo '<a href="' . $base . $item['link'] . '">';
+    echo $item['title'];
+    echo '</a>';
+    echo '</li>' . "\n";
+
+    if (isset($item['menu']) && is_array($item['menu'])) {
+        foreach ($item['menu'] as $subId => $subItem) {
+            echo '                    ';
+            echo '<li><a href="' . $subItem['link'] . '">';
+            echo $subItem['title'];
+            echo '</a></li>' . "\n";
+        }
+    }
+
+    echo '                </ul>' . "\n";
+}
+
+echo '            </div>' . "\n";
+
+?>


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

Added: pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuHead.tpl.php
===================================================================
--- pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuHead.tpl.php	                        (rev 0)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/MenuHead.tpl.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -0,0 +1,77 @@
+<?php
+
+$base     = PEAR2\SimpleChannelFrontend\Main::getURL();
+$selected = ($parent->context->options['view'] === 'news') ?
+            null : $parent->context->options['view'];
+
+echo '            <h1>';
+
+if ($selected) {
+    echo '<a href="' . $base . '">';
+}
+
+echo '<img src="' . $base . 'img/logo.png" alt="PEAR" />';
+echo '<span>PHP Extension and Application Repository</span>';
+
+if ($selected) {
+    echo '</a>';
+}
+
+echo '</h1>' . "\n";
+
+echo '            <div id="nav">' . "\n";
+echo '            <ul id="navbar">' . "\n";
+
+foreach ($context->data as $id => $item) {
+    echo '                ';
+
+    if ($selected == $id) {
+        echo '<li class="selected">';
+    } else {
+        echo '<li>';
+    }
+
+    if ($selected != $id) {
+        echo '<a href="' . $base . $item['link'] . '">';
+    }
+
+    echo $item['title'];
+
+    if ($selected != $id) {
+        echo '</a>';
+    }
+
+    echo '</li>';
+    echo "\n";
+}
+
+echo '            </ul>' . "\n";
+
+if (   $selected
+    && isset($context->data[$selected])
+    && isset($context->data[$selected]['menu'])
+    && is_array($context->data[$selected]['menu'])
+    && count($context->data[$selected]['menu']) > 0
+) {
+    echo '            <div id="subnav">' . "\n";
+    echo '                <div id="subnavcontainer">' . "\n";
+    echo '                    <ul id="subnavbar">' . "\n";
+
+    foreach ($context->data[$selected]['menu'] as $id => $item) {
+        echo '                        <li>';
+
+        echo '<a href="' . $base . $item['link'] . '">';
+        echo $item['title'];
+        echo '</a>';
+
+        echo '</li>' . "\n";
+    }
+
+    echo '                    </ul>' . "\n";
+    echo '                </div>' . "\n";
+    echo '            </div>' . "\n";
+}
+
+echo '            </div>' . "\n";
+
+?>


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

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-06-17 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/Package.tpl.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -47,10 +47,7 @@

 <?php

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

 ?>


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 12:31:57 UTC (rev 300517)
+++ pear2/sandbox/pear2.php.net/trunk/www/templates/pear2/html/PackageDetails.tpl.php	2010-06-17 13:58:40 UTC (rev 300518)
@@ -15,7 +15,6 @@
 $releaseDateISO = $context->date . 'T' . $context->time;
 $releaseDate    = date('F j, Y', strtotime($releaseDateISO));

-$licenseName  = htmlspecialchars($context->license['name']);
 $licenseURI   = \PEAR2Web\License::getLink($context->license['name']);
 $licenseClass = \PEAR2Web\License::isValid($context->license['name']) ?
     'package-license-good' : 'package-license-bad';
@@ -38,11 +37,12 @@
 <?php

 if ($licenseURI) {
+    echo '                ';
     echo '<a href="' . $licenseURI . '" class="' . $licenseClass . '">';
 }
-echo $licenseName;
+echo $context->license['name'];
 if ($licenseURI) {
-    echo '</a>';
+    echo '</a>' . "\n";
 }

 ?>
@@ -52,9 +52,26 @@
             <th>Bugs:</th>
             <td></td>
         </tr -->
-        <!-- tr>
+        <tr>
             <th>Maintainers:</th>
-            <td></td>
-        </tr -->
+            <td>
+<?php
+
+if (count($context->maintainer) === 0) {
+    echo '<span class="package-unmaintained">none</span>';
+} else {
+    echo '                <ul class="package-maintainers">' . "\n";
+    foreach ($context->maintainer as $maintainer) {
+        echo '                    <li>';
+        echo '<a href="#">' . $maintainer->name . '</a>';
+        echo ' (' . $maintainer->role . ')';
+        echo '</li>' . "\n";
+    }
+    echo '                </ul>' . "\n";
+}
+
+?>
+            </td>
+        </tr>
     </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.