]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/action.php
Merge branch 'master' of /var/www/trunk
[quix0rs-gnu-social.git] / lib / action.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Base class for all actions (~views)
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Action
23  * @package   Laconica
24  * @author    Evan Prodromou <evan@controlyourself.ca>
25  * @author    Sarven Capadisli <csarven@controlyourself.ca>
26  * @copyright 2008 Control Yourself, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://laconi.ca/
29  */
30
31 if (!defined('LACONICA')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/noticeform.php';
36 require_once INSTALLDIR.'/lib/htmloutputter.php';
37
38 /**
39  * Base class for all actions
40  *
41  * This is the base class for all actions in the package. An action is
42  * more or less a "view" in an MVC framework.
43  *
44  * Actions are responsible for extracting and validating parameters; using
45  * model classes to read and write to the database; and doing ouput.
46  *
47  * @category Output
48  * @package  Laconica
49  * @author   Evan Prodromou <evan@controlyourself.ca>
50  * @author   Sarven Capadisli <csarven@controlyourself.ca>
51  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
52  * @link     http://laconi.ca/
53  *
54  * @see      HTMLOutputter
55  */
56 class Action extends HTMLOutputter // lawsuit
57 {
58     var $args;
59
60     /**
61      * Constructor
62      *
63      * Just wraps the HTMLOutputter constructor.
64      *
65      * @param string  $output URI to output to, default = stdout
66      * @param boolean $indent Whether to indent output, default true
67      *
68      * @see XMLOutputter::__construct
69      * @see HTMLOutputter::__construct
70      */
71     function __construct($output='php://output', $indent=true)
72     {
73         parent::__construct($output, $indent);
74     }
75
76
77     /**
78      * For initializing members of the class.
79      *
80      * @param array $argarray misc. arguments
81      *
82      * @return boolean true
83      */
84     function prepare($argarray)
85     {
86         $this->args =& common_copy_args($argarray);
87         return true;
88     }
89
90     /**
91      * Show page, a template method.
92      *
93      * @return nothing
94      */
95     function showPage()
96     {
97         $this->startHTML();
98         $this->showHead();
99         $this->showBody();
100         $this->endHTML();
101     }
102
103     /**
104      * Show head, a template method.
105      *
106      * @return nothing
107      */
108     function showHead()
109     {
110         // XXX: attributes (profile?)
111         $this->elementStart('head');
112         $this->showTitle();
113         $this->showStylesheets();
114         $this->showScripts();
115         $this->showOpenSearch();
116         $this->showFeeds();
117         $this->showDescription();
118         $this->extraHead();
119         $this->elementEnd('head');
120     }
121
122     /**
123      * Show title, a template method.
124      *
125      * @return nothing
126      */
127     function showTitle()
128     {
129         $this->element('title', null,
130                        sprintf(_("%s - %s"),
131                                $this->title(),
132                                common_config('site', 'name')));
133     }
134
135     /**
136      * Returns the page title
137      *
138      * SHOULD overload
139      *
140      * @return string page title
141      */
142
143     function title()
144     {
145         return _("Untitled page");
146     }
147
148     /**
149      * Show stylesheets
150      *
151      * @return nothing
152      */
153     function showStylesheets()
154     {
155         $this->element('link', array('rel' => 'stylesheet',
156                                      'type' => 'text/css',
157                                      'href' => theme_path('css/display.css', 'base') . '?version=' . LACONICA_VERSION,
158                                      'media' => 'screen, projection, tv'));
159         $this->element('link', array('rel' => 'stylesheet',
160                                      'type' => 'text/css',
161                                      'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION,
162                                      'media' => 'screen, projection, tv'));
163         $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
164                        'href="'.theme_path('css/ie.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
165         foreach (array(6,7) as $ver) {
166             if (file_exists(theme_file('ie'.$ver.'.css'))) {
167                 // Yes, IE people should be put in jail.
168                 $this->comment('[if lte IE '.$ver.']><link rel="stylesheet" type="text/css" '.
169                                'href="'.theme_path('css/ie'.$ver.'.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
170             }
171         }
172     }
173
174     /**
175      * Show javascript headers
176      *
177      * @return nothing
178      */
179     function showScripts()
180     {
181         $this->element('script', array('type' => 'text/javascript',
182                                        'src' => common_path('js/jquery.min.js')),
183                        ' ');
184         $this->element('script', array('type' => 'text/javascript',
185                                        'src' => common_path('js/jquery.form.js')),
186                        ' ');
187         $this->element('script', array('type' => 'text/javascript',
188                                        'src' => common_path('js/xbImportNode.js')),
189                        ' ');
190         $this->element('script', array('type' => 'text/javascript',
191                                        'src' => common_path('js/util.js?version='.LACONICA_VERSION)),
192                        ' ');
193     }
194
195     /**
196      * Show OpenSearch headers
197      *
198      * @return nothing
199      */
200     function showOpenSearch()
201     {
202         $this->element('link', array('rel' => 'search',
203                                      'type' => 'application/opensearchdescription+xml',
204                                      'href' =>  common_local_url('opensearch', array('type' => 'people')),
205                                      'title' => common_config('site', 'name').' People Search'));
206         $this->element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml',
207                                      'href' =>  common_local_url('opensearch', array('type' => 'notice')),
208                                      'title' => common_config('site', 'name').' Notice Search'));
209     }
210
211     /**
212      * Show feed headers
213      *
214      * MAY overload
215      *
216      * @return nothing
217      */
218     function showFeeds()
219     {
220         // does nothing by default
221     }
222
223     /**
224      * Show description.
225      *
226      * SHOULD overload
227      *
228      * @return nothing
229      */
230     function showDescription()
231     {
232         // does nothing by default
233     }
234
235     /**
236      * Show extra stuff in <head>.
237      *
238      * MAY overload
239      *
240      * @return nothing
241      */
242     function extraHead()
243     {
244         // does nothing by default
245     }
246
247     
248     /**
249      * Show body.
250      *
251      * Calls template methods
252      *
253      * @return nothing
254      */
255     function showBody()
256     {
257         $this->elementStart('body', array('id' => $this->trimmed('action')));
258         $this->elementStart('div', 'wrap');
259         $this->showHeader();
260         $this->showCore();
261         $this->showFooter();
262         $this->elementEnd('div');
263         $this->elementEnd('body');
264     }
265
266     /**
267      * Show header of the page.
268      *
269      * Calls template methods
270      *
271      * @return nothing
272      */
273     function showHeader()
274     {
275         $this->elementStart('div', array('id' => 'header'));
276         $this->showLogo();
277         $this->showPrimaryNav();
278         $this->showSiteNotice();
279         if (common_logged_in()) {
280             $this->showNoticeForm();
281         } else {
282             $this->showAnonymousMessage();
283         }
284         $this->elementEnd('div');
285     }
286
287     /**
288      * Show configured logo.
289      *
290      * @return nothing
291      */
292     function showLogo()
293     {
294         $this->elementStart('address', array('id' => 'site_contact',
295                                              'class' => 'vcard'));
296         $this->elementStart('a', array('class' => 'url home bookmark',
297                                        'href' => common_local_url('public')));
298         if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) {
299             $this->element('img', array('class' => 'logo photo',
300                                         'src' => (common_config('site', 'logo')) ? common_config('site', 'logo') : theme_path('logo.png'),
301                                         'alt' => common_config('site', 'name')));
302         }
303         $this->element('span', array('class' => 'fn org'), common_config('site', 'name'));
304         $this->elementEnd('a');
305         $this->elementEnd('address');
306     }
307
308     /**
309      * Show primary navigation.
310      *
311      * @return nothing
312      */
313     function showPrimaryNav()
314     {
315         $this->elementStart('dl', array('id' => 'site_nav_global_primary'));
316         $this->element('dt', null, _('Primary site navigation'));
317         $this->elementStart('dd');
318         $user = common_current_user();
319         $this->elementStart('ul', array('class' => 'nav'));
320         if ($user) {
321             $this->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
322                             _('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
323         }
324         $this->menuItem(common_local_url('peoplesearch'),
325                         _('Search'), _('Search for people or text'), false, 'nav_search');
326         if ($user) {
327             $this->menuItem(common_local_url('profilesettings'),
328                             _('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account');
329             $this->menuItem(common_local_url('imsettings'),
330                             _('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect');
331             $this->menuItem(common_local_url('logout'),
332                             _('Logout'), _('Logout from the site'), false, 'nav_logout');
333         } else {
334             $this->menuItem(common_local_url('login'),
335                             _('Login'), _('Login to the site'), false, 'nav_login');
336             if (!common_config('site', 'closed')) {
337                 $this->menuItem(common_local_url('register'),
338                                 _('Register'), _('Create an account'), false, 'nav_register');
339             }
340             $this->menuItem(common_local_url('openidlogin'),
341                             _('OpenID'), _('Login with OpenID'), false, 'nav_openid');
342         }
343         $this->menuItem(common_local_url('doc', array('title' => 'help')),
344                         _('Help'), _('Help me!'), false, 'nav_help');
345         $this->elementEnd('ul');
346         $this->elementEnd('dd');
347         $this->elementEnd('dl');
348     }
349     
350     /**
351      * Show site notice.
352      *
353      * @return nothing
354      */
355     function showSiteNotice()
356     {
357         // Revist. Should probably do an hAtom pattern here
358         $text = common_config('site', 'notice');
359         if ($text) {
360             $this->elementStart('dl', array('id' => 'site_notice',
361                                             'class' => 'system_notice'));
362             $this->element('dt', null, _('Site notice'));
363             $this->element('dd', null, $text);
364             $this->elementEnd('dl');
365         }
366     }
367
368     /**
369      * Show notice form.
370      *
371      * MAY overload if no notice form needed... or direct message box????
372      *
373      * @return nothing
374      */
375     function showNoticeForm()
376     {
377         $notice_form = new NoticeForm($this);
378         $notice_form->show();
379     }
380     
381     /**
382      * Show anonymous message.
383      *
384      * SHOULD overload
385      *
386      * @return nothing
387      */
388     function showAnonymousMessage()
389     {
390         // needs to be defined by the class
391     }
392
393     /**
394      * Show core.
395      *
396      * Shows local navigation, content block and aside.
397      *
398      * @return nothing
399      */
400     function showCore()
401     {
402         $this->elementStart('div', array('id' => 'core'));
403         $this->showLocalNavBlock();
404         $this->showContentBlock();
405         $this->showAside();
406         $this->elementEnd('div');
407     }
408
409     /**
410      * Show local navigation block.
411      *
412      * @return nothing
413      */
414     function showLocalNavBlock()
415     {
416         $this->elementStart('dl', array('id' => 'site_nav_local_views'));
417         $this->element('dt', null, _('Local views'));
418         $this->elementStart('dd');
419         $this->showLocalNav();
420         $this->elementEnd('dd');
421         $this->elementEnd('dl');
422     }
423
424     /**
425      * Show local navigation.
426      *
427      * SHOULD overload
428      *
429      * @return nothing
430      */
431     function showLocalNav()
432     {
433         // does nothing by default
434     }
435
436     /**
437      * Show content block.
438      *
439      * @return nothing
440      */
441     function showContentBlock()
442     {
443         $this->elementStart('div', array('id' => 'content'));
444         $this->showPageTitle();
445         $this->showPageNoticeBlock();
446         $this->elementStart('div', array('id' => 'content_inner'));
447         // show the actual content (forms, lists, whatever)
448         $this->showContent();
449         $this->elementEnd('div');
450         $this->elementEnd('div');
451     }
452
453     /**
454      * Show page title.
455      *
456      * @return nothing
457      */
458     function showPageTitle()
459     {
460         $this->element('h1', null, $this->title());
461     }
462
463     /**
464      * Show page notice block.
465      *
466      * @return nothing
467      */
468     function showPageNoticeBlock()
469     {
470         $this->elementStart('dl', array('id' => 'page_notice',
471                                         'class' => 'system_notice'));
472         $this->element('dt', null, _('Page notice'));
473         $this->elementStart('dd');
474         $this->showPageNotice();
475         $this->elementEnd('dd');
476         $this->elementEnd('dl');
477     }
478
479     /**
480      * Show page notice.
481      *
482      * SHOULD overload (unless there's not a notice)
483      *
484      * @return nothing
485      */
486     function showPageNotice()
487     {
488     }
489
490     /**
491      * Show content.
492      *
493      * MUST overload (unless there's not a notice)
494      *
495      * @return nothing
496      */
497     function showContent()
498     {
499     }
500
501     /**
502      * Show Aside.
503      *
504      * @return nothing
505      */
506     function showAside()
507     {
508         $this->elementStart('div', array('id' => 'aside_primary',
509                                          'class' => 'aside'));
510         $this->showExportData();
511         $this->showSections();
512         $this->elementEnd('div');
513     }
514
515     /**
516      * Show export data feeds.
517      *
518      * MAY overload if there are feeds
519      *
520      * @return nothing
521      */
522     function showExportData()
523     {
524         // is there structure to this?
525         // list of (visible!) feed links
526         // can we reuse list of feeds from showFeeds() ?
527     }
528
529     /**
530      * Show sections.
531      *
532      * SHOULD overload
533      *
534      * @return nothing
535      */
536     function showSections()
537     {
538         // for each section, show it
539     }
540
541     /**
542      * Show footer.
543      *
544      * @return nothing
545      */
546     function showFooter()
547     {
548         $this->elementStart('div', array('id' => 'footer'));
549         $this->showSecondaryNav();
550         $this->showLicenses();
551         $this->elementEnd('div');
552     }
553
554     /**
555      * Show secondary navigation.
556      *
557      * @return nothing
558      */
559     function showSecondaryNav()
560     {
561         $this->elementStart('dl', array('id' => 'site_nav_global_secondary'));
562         $this->element('dt', null, _('Secondary site navigation'));
563         $this->elementStart('dd', null);
564         $this->elementStart('ul', array('class' => 'nav'));
565         $this->menuItem(common_local_url('doc', array('title' => 'help')),
566                         _('Help'));
567         $this->menuItem(common_local_url('doc', array('title' => 'about')),
568                         _('About'));
569         $this->menuItem(common_local_url('doc', array('title' => 'faq')),
570                         _('FAQ'));
571         $this->menuItem(common_local_url('doc', array('title' => 'privacy')),
572                         _('Privacy'));
573         $this->menuItem(common_local_url('doc', array('title' => 'source')),
574                         _('Source'));
575         $this->menuItem(common_local_url('doc', array('title' => 'contact')),
576                         _('Contact'));
577         $this->elementEnd('ul');
578         $this->elementEnd('dd');
579         $this->elementEnd('dl');
580     }
581
582     /**
583      * Show licenses.
584      *
585      * @return nothing
586      */
587     function showLicenses()
588     {
589         $this->elementStart('dl', array('id' => 'licenses'));
590         $this->showLaconicaLicense();
591         $this->showContentLicense();
592         $this->elementEnd('dl');
593     }
594
595     /**
596      * Show Laconica license.
597      *
598      * @return nothing
599      */
600     function showLaconicaLicense()
601     {
602         $this->element('dt', array('id' => 'site_laconica_license'), _('Laconica software license'));
603         $this->elementStart('dd', null);
604         if (common_config('site', 'broughtby')) {
605             $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
606         } else {
607             $instr = _('**%%site.name%%** is a microblogging service. ');
608         }
609         $instr .= sprintf(_('It runs the [Laconica](http://laconi.ca/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), LACONICA_VERSION);
610         $output = common_markup_to_html($instr);
611         $this->raw($output);
612         $this->elementEnd('dd');
613         // do it
614     }
615
616     /**
617      * Show content license.
618      *
619      * @return nothing
620      */
621     function showContentLicense()
622     {
623         $this->element('dt', array('id' => 'site_content_license'), _('Laconica software license'));
624         $this->elementStart('dd', array('id' => 'site_content_license_cc'));
625         $this->elementStart('p');
626         $this->element('img', array('id' => 'license_cc',
627                                     'src' => common_config('license', 'image'),
628                                     'alt' => common_config('license', 'title')));
629         //TODO: This is dirty: i18n
630         $this->text(_('All '.common_config('site', 'name').' content and data are available under the '));
631         $this->element('a', array('class' => 'license',
632                                   'rel' => 'external license',
633                                   'href' => common_config('license', 'url')),
634                        common_config('license', 'title'));
635         $this->text(_('license.'));
636         $this->elementEnd('p');
637         $this->elementEnd('dd');
638     }
639
640     /**
641      * Return last modified, if applicable.
642      *
643      * MAY override
644      *
645      * @return string last modified http header
646      */
647     function lastModified()
648     {
649         // For comparison with If-Last-Modified
650         // If not applicable, return null
651         return null;
652     }
653
654     /**
655      * Return etag, if applicable.
656      *
657      * MAY override
658      *
659      * @return string etag http header
660      */
661     function etag()
662     {
663         return null;
664     }
665
666     /**
667      * Return true if read only.
668      *
669      * MAY override
670      *
671      * @return boolean is read only action?
672      */
673     function isReadOnly()
674     {
675         return false;
676     }
677
678     /**
679      * Returns query argument or default value if not found
680      *
681      * @param string $key requested argument
682      * @param string $def default value to return if $key is not provided
683      *
684      * @return boolean is read only action?
685      */
686     function arg($key, $def=null)
687     {
688         if (array_key_exists($key, $this->args)) {
689             return $this->args[$key];
690         } else {
691             return $def;
692         }
693     }
694
695     /**
696      * Returns trimmed query argument or default value if not found
697      *
698      * @param string $key requested argument
699      * @param string $def default value to return if $key is not provided
700      *
701      * @return boolean is read only action?
702      */
703     function trimmed($key, $def=null)
704     {
705         $arg = $this->arg($key, $def);
706         return is_string($arg) ? trim($arg) : $arg;
707     }
708
709     /**
710      * Handler method
711      *
712      * @param array $argarray is ignored since it's now passed in in prepare()
713      *
714      * @return boolean is read only action?
715      */
716     function handle($argarray=null)
717     {
718         $lm   = $this->lastModified();
719         $etag = $this->etag();
720         if ($etag) {
721             header('ETag: ' . $etag);
722         }
723         if ($lm) {
724             header('Last-Modified: ' . date(DATE_RFC1123, $lm));
725             $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
726             if ($if_modified_since) {
727                 $ims = strtotime($if_modified_since);
728                 if ($lm <= $ims) {
729                     if (!$etag ||
730                         $this->_hasEtag($etag, $_SERVER['HTTP_IF_NONE_MATCH'])) {
731                         header('HTTP/1.1 304 Not Modified');
732                         // Better way to do this?
733                         exit(0);
734                     }
735                 }
736             }
737         }
738     }
739
740     /**
741      * HasĀ etag? (private)
742      *
743      * @param string $etag          etag http header
744      * @param string $if_none_match ifNoneMatch http header
745      *
746      * @return boolean
747      */
748     function _hasEtag($etag, $if_none_match)
749     {
750         return ($if_none_match) && in_array($etag, explode(',', $if_none_match));
751     }
752
753     /**
754      * Boolean understands english (yes, no, true, false)
755      *
756      * @param string $key query key we're interested in 
757      * @param string $def default value
758      *
759      * @return boolean interprets yes/no strings as boolean
760      */
761     function boolean($key, $def=false)
762     {
763         $arg = strtolower($this->trimmed($key));
764
765         if (is_null($arg)) {
766             return $def;
767         } else if (in_array($arg, array('true', 'yes', '1'))) {
768             return true;
769         } else if (in_array($arg, array('false', 'no', '0'))) {
770             return false;
771         } else {
772             return $def;
773         }
774     }
775
776     /**
777      * Server error
778      *
779      * @param string  $msg  error message to display
780      * @param integer $code http error code, 500 by default
781      *
782      * @return nothing
783      */
784     function serverError($msg, $code=500)
785     {
786         $action = $this->trimmed('action');
787         common_debug("Server error '$code' on '$action': $msg", __FILE__);
788         common_server_error($msg, $code);
789     }
790
791     /**
792      * Client error
793      *
794      * @param string  $msg  error message to display
795      * @param integer $code http error code, 400 by default
796      *
797      * @return nothing
798      */
799     function clientError($msg, $code=400)
800     {
801         $action = $this->trimmed('action');
802         common_debug("User error '$code' on '$action': $msg", __FILE__);
803         common_user_error($msg, $code);
804     }
805
806     /**
807      * Returns the current URL
808      *
809      * @return string current URL
810      */
811     function selfUrl()
812     {
813         $action = $this->trimmed('action');
814         $args   = $this->args;
815         unset($args['action']);
816         foreach (array_keys($_COOKIE) as $cookie) {
817             unset($args[$cookie]);
818         }
819         return common_local_url($action, $args);
820     }
821
822     /**
823      * Generate a menu item
824      *
825      * @param string  $url         menu URL
826      * @param string  $text        menu name
827      * @param string  $title       title attribute, null by default
828      * @param boolean $is_selected current menu item, false by default
829      * @param string  $id          element id, null by default
830      *
831      * @return nothing
832      */
833     function menuItem($url, $text, $title=null, $is_selected=false, $id=null)
834     {
835         // Added @id to li for some control.
836         // XXX: We might want to move this to htmloutputter.php
837         $lattrs = array();
838         if ($is_selected) {
839             $lattrs['class'] = 'current';
840         }
841
842         (is_null($id)) ? $lattrs : $lattrs['id'] = $id;
843
844         $this->elementStart('li', $lattrs);
845         $attrs['href'] = $url;
846         if ($title) {
847             $attrs['title'] = $title;
848         }
849         $this->element('a', $attrs, $text);
850         $this->elementEnd('li');
851     }
852
853     /**
854      * Generate pagination links
855      *
856      * @param boolean $have_before is there something before?
857      * @param boolean $have_after  is there something after?
858      * @param integer $page        current page
859      * @param string  $action      current action
860      * @param array   $args        rest of query arguments
861      *
862      * @return nothing
863      */
864     function pagination($have_before, $have_after, $page, $action, $args=null)
865     {
866         // Does a little before-after block for next/prev page
867         if ($have_before || $have_after) {
868             $this->elementStart('div', array('class' => 'pagination'));
869             $this->elementStart('dl', null);
870             $this->element('dt', null, _('Pagination'));
871             $this->elementStart('dd', null);
872             $this->elementStart('ul', array('class' => 'nav'));
873         }
874         if ($have_before) {
875             $pargs   = array('page' => $page-1);
876             $newargs = $args ? array_merge($args, $pargs) : $pargs;
877             $this->elementStart('li', array('class' => 'nav_prev'));
878             $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'prev'),
879                            _('After'));
880             $this->elementEnd('li');
881         }
882         if ($have_after) {
883             $pargs   = array('page' => $page+1);
884             $newargs = $args ? array_merge($args, $pargs) : $pargs;
885             $this->elementStart('li', array('class' => 'nav_next'));
886             $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'next'),
887                            _('Before'));
888             $this->elementEnd('li');
889         }
890         if ($have_before || $have_after) {
891             $this->elementEnd('ul');
892             $this->elementEnd('dd');
893             $this->elementEnd('dl');
894             $this->elementEnd('div');
895         }
896     }
897 }