Update doc for PlSet to explain 'arg' functions
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 16 Aug 2010 22:11:19 +0000 (00:11 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 16 Aug 2010 22:11:19 +0000 (00:11 +0200)
Rename the Smarty part of these for consistency.

Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/plset.php
templates/plset.tpl
templates/plview.multipage.tpl

index 41e73da..106c18a 100644 (file)
@@ -137,7 +137,9 @@ abstract class PlSet
         return $it;
     }
 
-    /** XXX ??
+    /** Return an array containing all pertinent parameters for this page
+     * Generated from $_GET, after some cleanup (remove 'n' (plat/al field
+     * for the handler path)
      */
     public function args()
     {
@@ -146,7 +148,9 @@ abstract class PlSet
         return $get;
     }
 
-    /** XXX?
+    /** Convert an array into an URL query (?foo=bar)
+     * @param $args An associative array to convert to a query string
+     * @param $encode Whether to url-encode the string
      */
     protected function encodeArgs(array $args, $encode = false)
     {
@@ -204,15 +208,12 @@ abstract class PlSet
             return false;
         }
         $args = $view->args();
-        if (!isset($args['rechercher'])) {
-            $args['rechercher'] = 'Chercher';
-        }
         $page->coreTpl('plset.tpl');
         $page->assign('plset_base', $baseurl);
         $page->assign('plset_mods', $this->mods);
         $page->assign('plset_mod', $this->mod);
-        $page->assign('plset_search', $this->encodeArgs($args));
-        $page->assign('plset_search_enc', $this->encodeArgs($args, true));
+        $page->assign('plset_args', $this->encodeArgs($args));
+        $page->assign('plset_args_enc', $this->encodeArgs($args, true));
         foreach ($this->modParams[$this->mod] as $param=>$value) {
             $page->assign($this->mod . '_' . $param, $value);
         }
@@ -238,7 +239,8 @@ interface PlView
      */
     public function apply(PlPage &$page);
 
-    /** XXX?
+    /** As PlSet->args(), returns the ?foo=bar part of the URL for generating
+     * this PlSet, after adding the necessary components and removing useless ones.
      */
     public function args();
 }
@@ -393,6 +395,9 @@ abstract class MultipageView implements PlView
         return PlPage::getCoreTpl('plview.multipage.tpl');
     }
 
+    /** Arguments are those needed by the set, minus 'page' and 'order' which
+     * will be set to new values in the html links.
+     */
     public function args()
     {
         $list = $this->set->args();
index 4f13ada..08a3261 100644 (file)
@@ -28,7 +28,7 @@
   {foreach from=$plset_mods key=mod item=desc name=mods}
     {if $mod neq $plset_mod}
     {if $has_prev}| {/if}
-    <a href="{$platal->ns}{$plset_base}/{$mod}{$plset_search}#pl_set_top">{$desc}</a>
+    <a href="{$platal->ns}{$plset_base}/{$mod}{$plset_args}#pl_set_top">{$desc}</a>
     {assign var=has_prev value=true}
     {/if}
   {/foreach}
index a03c7fc..49e6ae9 100644 (file)
@@ -25,8 +25,8 @@
   {if $show_bounds}<div style="float: right"><small><strong>[{$first} - {$last}]&nbsp;</strong></small></div>{/if}
 <div class="center pages" style="float: left">
   {if $plview->page neq 1}
-  <a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page=1#pl_set_top">{icon name=resultset_first title="Première page"}</a>{*
-  *}<a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$plview->page-1}#pl_set_top">{icon name=resultset_previous title="Page précédente"}</a>
+  <a href="{$platal->pl_self()}{$plset_args}order={$order}&amp;page=1#pl_set_top">{icon name=resultset_first title="Première page"}</a>{*
+  *}<a href="{$platal->pl_self()}{$plset_args}order={$order}&amp;page={$plview->page-1}#pl_set_top">{icon name=resultset_previous title="Page précédente"}</a>
   {else}
   {icon name=null title=""}{icon name=null title=""}
   {/if}
   {if $smarty.section.page.index eq $plview->page}
   <span style="color: red">{$plview->page}</span>
   {else}
-  <a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$smarty.section.page.index}#pl_set_top">{$smarty.section.page.index}</a>
+  <a href="{$platal->pl_self()}{$plset_args}order={$order}&amp;page={$smarty.section.page.index}#pl_set_top">{$smarty.section.page.index}</a>
   {/if}
   {/section}
   {if $plview->page neq $plview->pages}
-  <a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$plview->page+1}#pl_set_top">{icon name=resultset_next title="Page suivante"}</a>{*
-  *}<a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$plview->pages}#pl_set_top">{icon name=resultset_last title="Dernière page"}</a>
+  <a href="{$platal->pl_self()}{$plset_args}order={$order}&amp;page={$plview->page+1}#pl_set_top">{icon name=resultset_next title="Page suivante"}</a>{*
+  *}<a href="{$platal->pl_self()}{$plset_args}order={$order}&amp;page={$plview->pages}#pl_set_top">{icon name=resultset_last title="Dernière page"}</a>
   {else}
   {icon name=null title=""}{icon name=null title=""}
   {/if}
   [
   {if $name eq $order}
   <img src='images/dn.png' alt='tri ascendant' />
-  <a href="{$platal->pl_self()}{$plset_search}order=-{$name}#pl_set_top">{$sort->displaytext}</a>
+  <a href="{$platal->pl_self()}{$plset_args}order=-{$name}#pl_set_top">{$sort->displaytext}</a>
   {elseif $order eq "-$name"}
   <img src='images/up.png' alt='tri ascendant' />
-  <a href="{$platal->pl_self()}{$plset_search}order={$name}#pl_set_top">{$sort->displaytext}</a>
+  <a href="{$platal->pl_self()}{$plset_args}order={$name}#pl_set_top">{$sort->displaytext}</a>
   {else}
-  <a href="{$platal->pl_self()}{$plset_search}order={$name}#pl_set_top">{$sort->displaytext}</a>
+  <a href="{$platal->pl_self()}{$plset_args}order={$name}#pl_set_top">{$sort->displaytext}</a>
   {/if}
   ]&nbsp;
   {/foreach}