logo       
Google Custom Search
    AddThis Social Bookmark Button

CVS: phpwiki/lib/plugin ListPages.php,1.5,1.6: msg#00033

Subject: CVS: phpwiki/lib/plugin ListPages.php,1.5,1.6
Update of /cvsroot/phpwiki/phpwiki/lib/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24821/plugin

Modified Files:
        ListPages.php 
Log Message:
simplify exclude, add numbacklinks+numpagelinks

Index: ListPages.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/ListPages.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -2 -b -p -d -r1.5 -r1.6
--- ListPages.php       6 Sep 2004 08:37:31 -0000       1.5
+++ ListPages.php       14 Sep 2004 10:33:39 -0000      1.6
@@ -27,5 +27,6 @@ require_once('lib/PageList.php');
  *
  * Mainly used to see some ratings and recommendations.
- * But also possible to list some Categories or Users.
+ * But also possible to list some Categories or Users, or as generic 
+ * frontend for plugin-list page lists.
  *
  * @author: Dan Frankowski
@@ -57,11 +58,18 @@ extends WikiPlugin
     // info arg allows multiple columns
     // info=mtime,hits,summary,version,author,locked,minor
+    // additional info args: 
+    //   top3recs      : recommendations
+    //   numbacklinks  : number of backlinks (links to the given page)
+    //   numpagelinks  : number of forward links (links at the given page)
 
     function run($dbi, $argstr, &$request, $basepage) {
         $args = $this->getArgs($argstr, $request);
         extract($args);
+        if ($info)
+            $info = split(',', $info);
+        else
+            $info = array();
 
-        if (in_array('top3recs', split(',', $info))) {
-
+        if (in_array('top3recs', $info)) {
             require_once('lib/wikilens/Buddy.php');
             require_once('lib/wikilens/PageListColumns.php');
@@ -94,30 +102,26 @@ extends WikiPlugin
                 unset($user);
             }
-            //DONE:
-            //What we really want is passing the pagelist object to the column
-            //$top3 = new _PageList_Column_top3recs('top3recs', _("Top 
Recommendations"), 
-            //                                      'left', 0, $allowed_users);
             $options = array('dimension' => $dimension, 
                              'users' => $allowed_users);
-        } else {
-            $options = array();
+            $args = array_merge($options, $args);
         }
-
-        if (empty($pages))
+        if (empty($pages) and $pages != '0')
             return '';
 
-        $pagelist = new PageList($info, false, $options);
-        // FIXME: This should be not neccessary with the new custom pagelist 
columns
-        /*
-        if (!empty($options)) {
-            $pagelist->addColumnObject(new 
_PageList_Column_top3recs('custom:top3recs', _("Top Recommendations"), 
-                                                                     'left', 
$pagelist));
+        if (in_array('numbacklinks', $info)) {
+            $args['types']['numbacklinks'] = new 
_PageList_Column_ListPages_count('numbacklinks', _("#"), true);
         }
-        */
+        if (in_array('numpagelinks', $info)) {
+            $args['types']['numpagelinks'] = new 
_PageList_Column_ListPages_count('numpagelinks', _("#"));
+        }
+
+        $pagelist = new PageList($info, $exclude, $args);
+        $pages_array = is_string($pages) ? explodePageList($pages) : 
(is_array($pages) ? $pages : array());
+        $pagelist->addPageList($pages_array);
+        /*
         if (is_string($exclude) and !empty($exclude)) {
             $exclude = explodePageList($exclude);
             // $argstr = preg_replace("/exclude=\S*\s/", "", $argstr);
         }
-
         $pages_array = is_string($pages) ? explodePageList($pages) : 
(is_array($pages) ? $pages : array());
         foreach ($pages_array as $pagename) {
@@ -127,10 +131,26 @@ extends WikiPlugin
             }
         }
-
+        */
         return $pagelist;
     }
 };
 
+// how many back-/forwardlinks for this page
+class _PageList_Column_ListPages_count extends _PageList_Column {
+    function _PageList_Column_ListPages_count($field, $display, $backwards = 
false) {
+        $this->_direction = $backwards;
+        return $this->_PageList_Column($field, $display, 'center');
+    }
+    function _getValue($page, &$revision_handle) {
+        $iter = $page->getLinks($this->_direction);
+        $count = $iter->count();
+        return $count;
+    }
+}
+
 // $Log$
+// Revision 1.6  2004/09/14 10:33:39  rurban
+// simplify exclude, add numbacklinks+numpagelinks
+//
 // Revision 1.5  2004/09/06 08:37:31  rurban
 // plugin-list support for pages and exclude args



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>