]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/action.php
trac #1099: main menu should not lead to IM settings when IM is disabled
[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
330             if (common_config('xmpp', 'enabled')) {
331                 $this->menuItem(common_local_url('imsettings'),
332                             _('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect');
333             } else {
334                 $this->menuItem(common_local_url('smssettings'),
335                             _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
336             }
337             $this->menuItem(common_local_url('logout'),
338                             _('Logout'), _('Logout from the site'), false, 'nav_logout');
339         } else {
340             $this->menuItem(common_local_url('login'),
341                             _('Login'), _('Login to the site'), false, 'nav_login');
342             if (!common_config('site', 'closed')) {
343                 $this->menuItem(common_local_url('register'),
344                                 _('Register'), _('Create an account'), false, 'nav_register');
345             }
346             $this->menuItem(common_local_url('openidlogin'),
347                             _('OpenID'), _('Login with OpenID'), false, 'nav_openid');
348         }
349         $this->menuItem(common_local_url('doc', array('title' => 'help')),
350                         _('Help'), _('Help me!'), false, 'nav_help');
351         $this->elementEnd('ul');
352         $this->elementEnd('dd');
353         $this->elementEnd('dl');
354     }
355     
356     /**
357      * Show site notice.
358      *
359      * @return nothing
360      */
361     function showSiteNotice()
362     {
363         // Revist. Should probably do an hAtom pattern here
364         $text = common_config('site', 'notice');
365         if ($text) {
366             $this->elementStart('dl', array('id' => 'site_notice',
367                                             'class' => 'system_notice'));
368             $this->element('dt', null, _('Site notice'));
369             $this->element('dd', null, $text);
370             $this->elementEnd('dl');
371         }
372     }
373
374     /**
375      * Show notice form.
376      *
377      * MAY overload if no notice form needed... or direct message box????
378      *
379      * @return nothing
380      */
381     function showNoticeForm()
382     {
383         $notice_form = new NoticeForm($this);
384         $notice_form->show();
385     }
386     
387     /**
388      * Show anonymous message.
389      *
390      * SHOULD overload
391      *
392      * @return nothing
393      */
394     function showAnonymousMessage()
395     {
396         // needs to be defined by the class
397     }
398
399     /**
400      * Show core.
401      *
402      * Shows local navigation, content block and aside.
403      *
404      * @return nothing
405      */
406     function showCore()
407     {
408         $this->elementStart('div', array('id' => 'core'));
409         $this->showLocalNavBlock();
410         $this->showContentBlock();
411         $this->showAside();
412         $this->elementEnd('div');
413     }
414
415     /**
416      * Show local navigation block.
417      *
418      * @return nothing
419      */
420     function showLocalNavBlock()
421     {
422         $this->elementStart('dl', array('id' => 'site_nav_local_views'));
423         $this->element('dt', null, _('Local views'));
424         $this->elementStart('dd');
425         $this->showLocalNav();
426         $this->elementEnd('dd');
427         $this->elementEnd('dl');
428     }
429
430     /**
431      * Show local navigation.
432      *
433      * SHOULD overload
434      *
435      * @return nothing
436      */
437     function showLocalNav()
438     {
439         // does nothing by default
440     }
441
442     /**
443      * Show content block.
444      *
445      * @return nothing
446      */
447     function showContentBlock()
448     {
449         $this->elementStart('div', array('id' => 'content'));
450         $this->showPageTitle();
451         $this->showPageNoticeBlock();
452         $this->elementStart('div', array('id' => 'content_inner'));
453         // show the actual content (forms, lists, whatever)
454         $this->showContent();
455         $this->elementEnd('div');
456         $this->elementEnd('div');
457     }
458
459     /**
460      * Show page title.
461      *
462      * @return nothing
463      */
464     function showPageTitle()
465     {
466         $this->element('h1', null, $this->title());
467     }
468
469     /**
470      * Show page notice block.
471      *
472      * @return nothing
473      */
474     function showPageNoticeBlock()
475     {
476         $this->elementStart('dl', array('id' => 'page_notice',
477                                         'class' => 'system_notice'));
478         $this->element('dt', null, _('Page notice'));
479         $this->elementStart('dd');
480         $this->showPageNotice();
481         $this->elementEnd('dd');
482         $this->elementEnd('dl');
483     }
484
485     /**
486      * Show page notice.
487      *
488      * SHOULD overload (unless there's not a notice)
489      *
490      * @return nothing
491      */
492     function showPageNotice()
493     {
494     }
495
496     /**
497      * Show content.
498      *
499      * MUST overload (unless there's not a notice)
500      *
501      * @return nothing
502      */
503     function showContent()
504     {
505     }
506
507     /**
508      * Show Aside.
509      *
510      * @return nothing
511      */
512     function showAside()
513     {
514         $this->elementStart('div', array('id' => 'aside_primary',
515                                          'class' => 'aside'));
516         $this->showExportData();
517         $this->showSections();
518         $this->elementEnd('div');
519     }
520
521     /**
522      * Show export data feeds.
523      *
524      * MAY overload if there are feeds
525      *
526      * @return nothing
527      */
528     function showExportData()
529     {
530         // is there structure to this?
531         // list of (visible!) feed links
532         // can we reuse list of feeds from showFeeds() ?
533     }
534
535     /**
536      * Show sections.
537      *
538      * SHOULD overload
539      *
540      * @return nothing
541      */
542     function showSections()
543     {
544         // for each section, show it
545     }
546
547     /**
548      * Show footer.
549      *
550      * @return nothing
551      */
552     function showFooter()
553     {
554         $this->elementStart('div', array('id' => 'footer'));
555         $this->showSecondaryNav();
556         $this->showLicenses();
557         $this->elementEnd('div');
558     }
559
560     /**
561      * Show secondary navigation.
562      *
563      * @return nothing
564      */
565     function showSecondaryNav()
566     {
567         $this->elementStart('dl', array('id' => 'site_nav_global_secondary'));
568         $this->element('dt', null, _('Secondary site navigation'));
569         $this->elementStart('dd', null);
570         $this->elementStart('ul', array('class' => 'nav'));
571         $this->menuItem(common_local_url('doc', array('title' => 'help')),
572                         _('Help'));
573         $this->menuItem(common_local_url('doc', array('title' => 'about')),
574                         _('About'));
575         $this->menuItem(common_local_url('doc', array('title' => 'faq')),
576                         _('FAQ'));
577         $this->menuItem(common_local_url('doc', array('title' => 'privacy')),
578                         _('Privacy'));
579         $this->menuItem(common_local_url('doc', array('title' => 'source')),
580                         _('Source'));
581         $this->menuItem(common_local_url('doc', array('title' => 'contact')),
582                         _('Contact'));
583         $this->elementEnd('ul');
584         $this->elementEnd('dd');
585         $this->elementEnd('dl');
586     }
587
588     /**
589      * Show licenses.
590      *
591      * @return nothing
592      */
593     function showLicenses()
594     {
595         $this->elementStart('dl', array('id' => 'licenses'));
596         $this->showLaconicaLicense();
597         $this->showContentLicense();
598         $this->elementEnd('dl');
599     }
600
601     /**
602      * Show Laconica license.
603      *
604      * @return nothing
605      */
606     function showLaconicaLicense()
607     {
608         $this->element('dt', array('id' => 'site_laconica_license'), _('Laconica software license'));
609         $this->elementStart('dd', null);
610         if (common_config('site', 'broughtby')) {
611             $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
612         } else {
613             $instr = _('**%%site.name%%** is a microblogging service. ');
614         }
615         $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);
616         $output = common_markup_to_html($instr);
617         $this->raw($output);
618         $this->elementEnd('dd');
619         // do it
620     }
621
622     /**
623      * Show content license.
624      *
625      * @return nothing
626      */
627     function showContentLicense()
628     {
629         $this->element('dt', array('id' => 'site_content_license'), _('Laconica software license'));
630         $this->elementStart('dd', array('id' => 'site_content_license_cc'));
631         $this->elementStart('p');
632         $this->element('img', array('id' => 'license_cc',
633                                     'src' => common_config('license', 'image'),
634                                     'alt' => common_config('license', 'title')));
635         //TODO: This is dirty: i18n
636         $this->text(_('All '.common_config('site', 'name').' content and data are available under the '));
637         $this->element('a', array('class' => 'license',
638                                   'rel' => 'external license',
639                                   'href' => common_config('license', 'url')),
640                        common_config('license', 'title'));
641         $this->text(_('license.'));
642         $this->elementEnd('p');
643         $this->elementEnd('dd');
644     }
645
646     /**
647      * Return last modified, if applicable.
648      *
649      * MAY override
650      *
651      * @return string last modified http header
652      */
653     function lastModified()
654     {
655         // For comparison with If-Last-Modified
656         // If not applicable, return null
657         return null;
658     }
659
660     /**
661      * Return etag, if applicable.
662      *
663      * MAY override
664      *
665      * @return string etag http header
666      */
667     function etag()
668     {
669         return null;
670     }
671
672     /**
673      * Return true if read only.
674      *
675      * MAY override
676      *
677      * @return boolean is read only action?
678      */
679     function isReadOnly()
680     {
681         return false;
682     }
683
684     /**
685      * Returns query argument or default value if not found
686      *
687      * @param string $key requested argument
688      * @param string $def default value to return if $key is not provided
689      *
690      * @return boolean is read only action?
691      */
692     function arg($key, $def=null)
693     {
694         if (array_key_exists($key, $this->args)) {
695             return $this->args[$key];
696         } else {
697             return $def;
698         }
699     }
700
701     /**
702      * Returns trimmed query argument or default value if not found
703      *
704      * @param string $key requested argument
705      * @param string $def default value to return if $key is not provided
706      *
707      * @return boolean is read only action?
708      */
709     function trimmed($key, $def=null)
710     {
711         $arg = $this->arg($key, $def);
712         return is_string($arg) ? trim($arg) : $arg;
713     }
714
715     /**
716      * Handler method
717      *
718      * @param array $argarray is ignored since it's now passed in in prepare()
719      *
720      * @return boolean is read only action?
721      */
722     function handle($argarray=null)
723     {
724         $lm   = $this->lastModified();
725         $etag = $this->etag();
726         if ($etag) {
727             header('ETag: ' . $etag);
728         }
729         if ($lm) {
730             header('Last-Modified: ' . date(DATE_RFC1123, $lm));
731             $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
732             if ($if_modified_since) {
733                 $ims = strtotime($if_modified_since);
734                 if ($lm <= $ims) {
735                     if (!$etag ||
736                         $this->_hasEtag($etag, $_SERVER['HTTP_IF_NONE_MATCH'])) {
737                         header('HTTP/1.1 304 Not Modified');
738                         // Better way to do this?
739                         exit(0);
740                     }
741                 }
742             }
743         }
744     }
745
746     /**
747      * HasĀ etag? (private)
748      *
749      * @param string $etag          etag http header
750      * @param string $if_none_match ifNoneMatch http header
751      *
752      * @return boolean
753      */
754     function _hasEtag($etag, $if_none_match)
755     {
756         return ($if_none_match) && in_array($etag, explode(',', $if_none_match));
757     }
758
759     /**
760      * Boolean understands english (yes, no, true, false)
761      *
762      * @param string $key query key we're interested in 
763      * @param string $def default value
764      *
765      * @return boolean interprets yes/no strings as boolean
766      */
767     function boolean($key, $def=false)
768     {
769         $arg = strtolower($this->trimmed($key));
770
771         if (is_null($arg)) {
772             return $def;
773         } else if (in_array($arg, array('true', 'yes', '1'))) {
774             return true;
775         } else if (in_array($arg, array('false', 'no', '0'))) {
776             return false;
777         } else {
778             return $def;
779         }
780     }
781
782     /**
783      * Server error
784      *
785      * @param string  $msg  error message to display
786      * @param integer $code http error code, 500 by default
787      *
788      * @return nothing
789      */
790     function serverError($msg, $code=500)
791     {
792         $action = $this->trimmed('action');
793         common_debug("Server error '$code' on '$action': $msg", __FILE__);
794         common_server_error($msg, $code);
795     }
796
797     /**
798      * Client error
799      *
800      * @param string  $msg  error message to display
801      * @param integer $code http error code, 400 by default
802      *
803      * @return nothing
804      */
805     function clientError($msg, $code=400)
806     {
807         $action = $this->trimmed('action');
808         common_debug("User error '$code' on '$action': $msg", __FILE__);
809         common_user_error($msg, $code);
810     }
811
812     /**
813      * Returns the current URL
814      *
815      * @return string current URL
816      */
817     function selfUrl()
818     {
819         $action = $this->trimmed('action');
820         $args   = $this->args;
821         unset($args['action']);
822         foreach (array_keys($_COOKIE) as $cookie) {
823             unset($args[$cookie]);
824         }
825         return common_local_url($action, $args);
826     }
827
828     /**
829      * Generate a menu item
830      *
831      * @param string  $url         menu URL
832      * @param string  $text        menu name
833      * @param string  $title       title attribute, null by default
834      * @param boolean $is_selected current menu item, false by default
835      * @param string  $id          element id, null by default
836      *
837      * @return nothing
838      */
839     function menuItem($url, $text, $title=null, $is_selected=false, $id=null)
840     {
841         // Added @id to li for some control.
842         // XXX: We might want to move this to htmloutputter.php
843         $lattrs = array();
844         if ($is_selected) {
845             $lattrs['class'] = 'current';
846         }
847
848         (is_null($id)) ? $lattrs : $lattrs['id'] = $id;
849
850         $this->elementStart('li', $lattrs);
851         $attrs['href'] = $url;
852         if ($title) {
853             $attrs['title'] = $title;
854         }
855         $this->element('a', $attrs, $text);
856         $this->elementEnd('li');
857     }
858
859     /**
860      * Generate pagination links
861      *
862      * @param boolean $have_before is there something before?
863      * @param boolean $have_after  is there something after?
864      * @param integer $page        current page
865      * @param string  $action      current action
866      * @param array   $args        rest of query arguments
867      *
868      * @return nothing
869      */
870     function pagination($have_before, $have_after, $page, $action, $args=null)
871     {
872         // Does a little before-after block for next/prev page
873         if ($have_before || $have_after) {
874             $this->elementStart('div', array('class' => 'pagination'));
875             $this->elementStart('dl', null);
876             $this->element('dt', null, _('Pagination'));
877             $this->elementStart('dd', null);
878             $this->elementStart('ul', array('class' => 'nav'));
879         }
880         if ($have_before) {
881             $pargs   = array('page' => $page-1);
882             $newargs = $args ? array_merge($args, $pargs) : $pargs;
883             $this->elementStart('li', array('class' => 'nav_prev'));
884             $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'prev'),
885                            _('After'));
886             $this->elementEnd('li');
887         }
888         if ($have_after) {
889             $pargs   = array('page' => $page+1);
890             $newargs = $args ? array_merge($args, $pargs) : $pargs;
891             $this->elementStart('li', array('class' => 'nav_next'));
892             $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'next'),
893                            _('Before'));
894             $this->elementEnd('li');
895         }
896         if ($have_before || $have_after) {
897             $this->elementEnd('ul');
898             $this->elementEnd('dd');
899             $this->elementEnd('dl');
900             $this->elementEnd('div');
901         }
902     }
903 }