]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/action.php
Merge branch 'master' of evan@dev.controlyourself.ca:/var/www/trunk into 0.7.x
[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('css/ie'.$ver.'.css', 'base'))) {
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         $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
173                        'href="'.theme_path('css/ie.css', null).'?version='.LACONICA_VERSION.'" /><![endif]');
174     }
175
176     /**
177      * Show javascript headers
178      *
179      * @return nothing
180      */
181     function showScripts()
182     {
183         $this->element('script', array('type' => 'text/javascript',
184                                        'src' => common_path('js/jquery.min.js')),
185                        ' ');
186         $this->element('script', array('type' => 'text/javascript',
187                                        'src' => common_path('js/jquery.form.js')),
188                        ' ');
189         $this->element('script', array('type' => 'text/javascript',
190                                        'src' => common_path('js/xbImportNode.js')),
191                        ' ');
192         $this->element('script', array('type' => 'text/javascript',
193                                        'src' => common_path('js/util.js?version='.LACONICA_VERSION)),
194                        ' ');
195     }
196
197     /**
198      * Show OpenSearch headers
199      *
200      * @return nothing
201      */
202     function showOpenSearch()
203     {
204         $this->element('link', array('rel' => 'search',
205                                      'type' => 'application/opensearchdescription+xml',
206                                      'href' =>  common_local_url('opensearch', array('type' => 'people')),
207                                      'title' => common_config('site', 'name').' People Search'));
208         $this->element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml',
209                                      'href' =>  common_local_url('opensearch', array('type' => 'notice')),
210                                      'title' => common_config('site', 'name').' Notice Search'));
211     }
212
213     /**
214      * Show feed headers
215      *
216      * MAY overload
217      *
218      * @return nothing
219      */
220     function showFeeds()
221     {
222         // does nothing by default
223     }
224
225     /**
226      * Show description.
227      *
228      * SHOULD overload
229      *
230      * @return nothing
231      */
232     function showDescription()
233     {
234         // does nothing by default
235     }
236
237     /**
238      * Show extra stuff in <head>.
239      *
240      * MAY overload
241      *
242      * @return nothing
243      */
244     function extraHead()
245     {
246         // does nothing by default
247     }
248
249     
250     /**
251      * Show body.
252      *
253      * Calls template methods
254      *
255      * @return nothing
256      */
257     function showBody()
258     {
259         $this->elementStart('body', array('id' => $this->trimmed('action')));
260         $this->elementStart('div', array('id' => 'wrap'));
261         $this->showHeader();
262         $this->showCore();
263         $this->showFooter();
264         $this->elementEnd('div');
265         $this->elementEnd('body');
266     }
267
268     /**
269      * Show header of the page.
270      *
271      * Calls template methods
272      *
273      * @return nothing
274      */
275     function showHeader()
276     {
277         $this->elementStart('div', array('id' => 'header'));
278         $this->showLogo();
279         $this->showPrimaryNav();
280         $this->showSiteNotice();
281         if (common_logged_in()) {
282             $this->showNoticeForm();
283         } else {
284             $this->showAnonymousMessage();
285         }
286         $this->elementEnd('div');
287     }
288
289     /**
290      * Show configured logo.
291      *
292      * @return nothing
293      */
294     function showLogo()
295     {
296         $this->elementStart('address', array('id' => 'site_contact',
297                                              'class' => 'vcard'));
298         $this->elementStart('a', array('class' => 'url home bookmark',
299                                        'href' => common_local_url('public')));
300         if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) {
301             $this->element('img', array('class' => 'logo photo',
302                                         'src' => (common_config('site', 'logo')) ? common_config('site', 'logo') : theme_path('logo.png'),
303                                         'alt' => common_config('site', 'name')));
304         }
305         $this->element('span', array('class' => 'fn org'), common_config('site', 'name'));
306         $this->elementEnd('a');
307         $this->elementEnd('address');
308     }
309
310     /**
311      * Show primary navigation.
312      *
313      * @return nothing
314      */
315     function showPrimaryNav()
316     {
317         $this->elementStart('dl', array('id' => 'site_nav_global_primary'));
318         $this->element('dt', null, _('Primary site navigation'));
319         $this->elementStart('dd');
320         $user = common_current_user();
321         $this->elementStart('ul', array('class' => 'nav'));
322         if ($user) {
323             $this->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
324                             _('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
325         }
326         $this->menuItem(common_local_url('peoplesearch'),
327                         _('Search'), _('Search for people or text'), false, 'nav_search');
328         if ($user) {
329             $this->menuItem(common_local_url('profilesettings'),
330                             _('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account');
331
332             if (common_config('xmpp', 'enabled')) {
333                 $this->menuItem(common_local_url('imsettings'),
334                             _('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect');
335             } else {
336                 $this->menuItem(common_local_url('smssettings'),
337                             _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
338             }
339             $this->menuItem(common_local_url('logout'),
340                             _('Logout'), _('Logout from the site'), false, 'nav_logout');
341         } else {
342             $this->menuItem(common_local_url('login'),
343                             _('Login'), _('Login to the site'), false, 'nav_login');
344             if (!common_config('site', 'closed')) {
345                 $this->menuItem(common_local_url('register'),
346                                 _('Register'), _('Create an account'), false, 'nav_register');
347             }
348             $this->menuItem(common_local_url('openidlogin'),
349                             _('OpenID'), _('Login with OpenID'), false, 'nav_openid');
350         }
351         $this->menuItem(common_local_url('doc', array('title' => 'help')),
352                         _('Help'), _('Help me!'), false, 'nav_help');
353         $this->elementEnd('ul');
354         $this->elementEnd('dd');
355         $this->elementEnd('dl');
356     }
357     
358     /**
359      * Show site notice.
360      *
361      * @return nothing
362      */
363     function showSiteNotice()
364     {
365         // Revist. Should probably do an hAtom pattern here
366         $text = common_config('site', 'notice');
367         if ($text) {
368             $this->elementStart('dl', array('id' => 'site_notice',
369                                             'class' => 'system_notice'));
370             $this->element('dt', null, _('Site notice'));
371             $this->element('dd', null, $text);
372             $this->elementEnd('dl');
373         }
374     }
375
376     /**
377      * Show notice form.
378      *
379      * MAY overload if no notice form needed... or direct message box????
380      *
381      * @return nothing
382      */
383     function showNoticeForm()
384     {
385         $notice_form = new NoticeForm($this);
386         $notice_form->show();
387     }
388     
389     /**
390      * Show anonymous message.
391      *
392      * SHOULD overload
393      *
394      * @return nothing
395      */
396     function showAnonymousMessage()
397     {
398         // needs to be defined by the class
399     }
400
401     /**
402      * Show core.
403      *
404      * Shows local navigation, content block and aside.
405      *
406      * @return nothing
407      */
408     function showCore()
409     {
410         $this->elementStart('div', array('id' => 'core'));
411         $this->showLocalNavBlock();
412         $this->showContentBlock();
413         $this->showAside();
414         $this->elementEnd('div');
415     }
416
417     /**
418      * Show local navigation block.
419      *
420      * @return nothing
421      */
422     function showLocalNavBlock()
423     {
424         $this->elementStart('dl', array('id' => 'site_nav_local_views'));
425         $this->element('dt', null, _('Local views'));
426         $this->elementStart('dd');
427         $this->showLocalNav();
428         $this->elementEnd('dd');
429         $this->elementEnd('dl');
430     }
431
432     /**
433      * Show local navigation.
434      *
435      * SHOULD overload
436      *
437      * @return nothing
438      */
439     function showLocalNav()
440     {
441         // does nothing by default
442     }
443
444     /**
445      * Show content block.
446      *
447      * @return nothing
448      */
449     function showContentBlock()
450     {
451         $this->elementStart('div', array('id' => 'content'));
452         $this->showPageTitle();
453         $this->showPageNoticeBlock();
454         $this->elementStart('div', array('id' => 'content_inner'));
455         // show the actual content (forms, lists, whatever)
456         $this->showContent();
457         $this->elementEnd('div');
458         $this->elementEnd('div');
459     }
460
461     /**
462      * Show page title.
463      *
464      * @return nothing
465      */
466     function showPageTitle()
467     {
468         $this->element('h1', null, $this->title());
469     }
470
471     /**
472      * Show page notice block.
473      *
474      * @return nothing
475      */
476     function showPageNoticeBlock()
477     {
478         $this->elementStart('dl', array('id' => 'page_notice',
479                                         'class' => 'system_notice'));
480         $this->element('dt', null, _('Page notice'));
481         $this->elementStart('dd');
482         $this->showPageNotice();
483         $this->elementEnd('dd');
484         $this->elementEnd('dl');
485     }
486
487     /**
488      * Show page notice.
489      *
490      * SHOULD overload (unless there's not a notice)
491      *
492      * @return nothing
493      */
494     function showPageNotice()
495     {
496     }
497
498     /**
499      * Show content.
500      *
501      * MUST overload (unless there's not a notice)
502      *
503      * @return nothing
504      */
505     function showContent()
506     {
507     }
508
509     /**
510      * Show Aside.
511      *
512      * @return nothing
513      */
514     function showAside()
515     {
516         $this->elementStart('div', array('id' => 'aside_primary',
517                                          'class' => 'aside'));
518         $this->showExportData();
519         $this->showSections();
520         $this->elementEnd('div');
521     }
522
523     /**
524      * Show export data feeds.
525      *
526      * MAY overload if there are feeds
527      *
528      * @return nothing
529      */
530     function showExportData()
531     {
532         // is there structure to this?
533         // list of (visible!) feed links
534         // can we reuse list of feeds from showFeeds() ?
535     }
536
537     /**
538      * Show sections.
539      *
540      * SHOULD overload
541      *
542      * @return nothing
543      */
544     function showSections()
545     {
546         // for each section, show it
547     }
548
549     /**
550      * Show footer.
551      *
552      * @return nothing
553      */
554     function showFooter()
555     {
556         $this->elementStart('div', array('id' => 'footer'));
557         $this->showSecondaryNav();
558         $this->showLicenses();
559         $this->elementEnd('div');
560     }
561
562     /**
563      * Show secondary navigation.
564      *
565      * @return nothing
566      */
567     function showSecondaryNav()
568     {
569         $this->elementStart('dl', array('id' => 'site_nav_global_secondary'));
570         $this->element('dt', null, _('Secondary site navigation'));
571         $this->elementStart('dd', null);
572         $this->elementStart('ul', array('class' => 'nav'));
573         $this->menuItem(common_local_url('doc', array('title' => 'help')),
574                         _('Help'));
575         $this->menuItem(common_local_url('doc', array('title' => 'about')),
576                         _('About'));
577         $this->menuItem(common_local_url('doc', array('title' => 'faq')),
578                         _('FAQ'));
579         $this->menuItem(common_local_url('doc', array('title' => 'privacy')),
580                         _('Privacy'));
581         $this->menuItem(common_local_url('doc', array('title' => 'source')),
582                         _('Source'));
583         $this->menuItem(common_local_url('doc', array('title' => 'contact')),
584                         _('Contact'));
585         $this->elementEnd('ul');
586         $this->elementEnd('dd');
587         $this->elementEnd('dl');
588     }
589
590     /**
591      * Show licenses.
592      *
593      * @return nothing
594      */
595     function showLicenses()
596     {
597         $this->elementStart('dl', array('id' => 'licenses'));
598         $this->showLaconicaLicense();
599         $this->showContentLicense();
600         $this->elementEnd('dl');
601     }
602
603     /**
604      * Show Laconica license.
605      *
606      * @return nothing
607      */
608     function showLaconicaLicense()
609     {
610         $this->element('dt', array('id' => 'site_laconica_license'), _('Laconica software license'));
611         $this->elementStart('dd', null);
612         if (common_config('site', 'broughtby')) {
613             $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
614         } else {
615             $instr = _('**%%site.name%%** is a microblogging service. ');
616         }
617         $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);
618         $output = common_markup_to_html($instr);
619         $this->raw($output);
620         $this->elementEnd('dd');
621         // do it
622     }
623
624     /**
625      * Show content license.
626      *
627      * @return nothing
628      */
629     function showContentLicense()
630     {
631         $this->element('dt', array('id' => 'site_content_license'), _('Laconica software license'));
632         $this->elementStart('dd', array('id' => 'site_content_license_cc'));
633         $this->elementStart('p');
634         $this->element('img', array('id' => 'license_cc',
635                                     'src' => common_config('license', 'image'),
636                                     'alt' => common_config('license', 'title')));
637         //TODO: This is dirty: i18n
638         $this->text(_('All '.common_config('site', 'name').' content and data are available under the '));
639         $this->element('a', array('class' => 'license',
640                                   'rel' => 'external license',
641                                   'href' => common_config('license', 'url')),
642                        common_config('license', 'title'));
643         $this->text(_('license.'));
644         $this->elementEnd('p');
645         $this->elementEnd('dd');
646     }
647
648     /**
649      * Return last modified, if applicable.
650      *
651      * MAY override
652      *
653      * @return string last modified http header
654      */
655     function lastModified()
656     {
657         // For comparison with If-Last-Modified
658         // If not applicable, return null
659         return null;
660     }
661
662     /**
663      * Return etag, if applicable.
664      *
665      * MAY override
666      *
667      * @return string etag http header
668      */
669     function etag()
670     {
671         return null;
672     }
673
674     /**
675      * Return true if read only.
676      *
677      * MAY override
678      *
679      * @return boolean is read only action?
680      */
681     function isReadOnly()
682     {
683         return false;
684     }
685
686     /**
687      * Returns query argument or default value if not found
688      *
689      * @param string $key requested argument
690      * @param string $def default value to return if $key is not provided
691      *
692      * @return boolean is read only action?
693      */
694     function arg($key, $def=null)
695     {
696         if (array_key_exists($key, $this->args)) {
697             return $this->args[$key];
698         } else {
699             return $def;
700         }
701     }
702
703     /**
704      * Returns trimmed query argument or default value if not found
705      *
706      * @param string $key requested argument
707      * @param string $def default value to return if $key is not provided
708      *
709      * @return boolean is read only action?
710      */
711     function trimmed($key, $def=null)
712     {
713         $arg = $this->arg($key, $def);
714         return is_string($arg) ? trim($arg) : $arg;
715     }
716
717     /**
718      * Handler method
719      *
720      * @param array $argarray is ignored since it's now passed in in prepare()
721      *
722      * @return boolean is read only action?
723      */
724     function handle($argarray=null)
725     {
726         $lm   = $this->lastModified();
727         $etag = $this->etag();
728         if ($etag) {
729             header('ETag: ' . $etag);
730         }
731         if ($lm) {
732             header('Last-Modified: ' . date(DATE_RFC1123, $lm));
733             $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
734             if ($if_modified_since) {
735                 $ims = strtotime($if_modified_since);
736                 if ($lm <= $ims) {
737                     if (!$etag ||
738                         $this->_hasEtag($etag, $_SERVER['HTTP_IF_NONE_MATCH'])) {
739                         header('HTTP/1.1 304 Not Modified');
740                         // Better way to do this?
741                         exit(0);
742                     }
743                 }
744             }
745         }
746     }
747
748     /**
749      * HasĀ etag? (private)
750      *
751      * @param string $etag          etag http header
752      * @param string $if_none_match ifNoneMatch http header
753      *
754      * @return boolean
755      */
756     function _hasEtag($etag, $if_none_match)
757     {
758         return ($if_none_match) && in_array($etag, explode(',', $if_none_match));
759     }
760
761     /**
762      * Boolean understands english (yes, no, true, false)
763      *
764      * @param string $key query key we're interested in 
765      * @param string $def default value
766      *
767      * @return boolean interprets yes/no strings as boolean
768      */
769     function boolean($key, $def=false)
770     {
771         $arg = strtolower($this->trimmed($key));
772
773         if (is_null($arg)) {
774             return $def;
775         } else if (in_array($arg, array('true', 'yes', '1'))) {
776             return true;
777         } else if (in_array($arg, array('false', 'no', '0'))) {
778             return false;
779         } else {
780             return $def;
781         }
782     }
783
784     /**
785      * Server error
786      *
787      * @param string  $msg  error message to display
788      * @param integer $code http error code, 500 by default
789      *
790      * @return nothing
791      */
792     function serverError($msg, $code=500)
793     {
794         $action = $this->trimmed('action');
795         common_debug("Server error '$code' on '$action': $msg", __FILE__);
796         common_server_error($msg, $code);
797     }
798
799     /**
800      * Client error
801      *
802      * @param string  $msg  error message to display
803      * @param integer $code http error code, 400 by default
804      *
805      * @return nothing
806      */
807     function clientError($msg, $code=400)
808     {
809         $action = $this->trimmed('action');
810         common_debug("User error '$code' on '$action': $msg", __FILE__);
811         common_user_error($msg, $code);
812     }
813
814     /**
815      * Returns the current URL
816      *
817      * @return string current URL
818      */
819     function selfUrl()
820     {
821         $action = $this->trimmed('action');
822         $args   = $this->args;
823         unset($args['action']);
824         foreach (array_keys($_COOKIE) as $cookie) {
825             unset($args[$cookie]);
826         }
827         return common_local_url($action, $args);
828     }
829
830     /**
831      * Generate a menu item
832      *
833      * @param string  $url         menu URL
834      * @param string  $text        menu name
835      * @param string  $title       title attribute, null by default
836      * @param boolean $is_selected current menu item, false by default
837      * @param string  $id          element id, null by default
838      *
839      * @return nothing
840      */
841     function menuItem($url, $text, $title=null, $is_selected=false, $id=null)
842     {
843         // Added @id to li for some control.
844         // XXX: We might want to move this to htmloutputter.php
845         $lattrs = array();
846         if ($is_selected) {
847             $lattrs['class'] = 'current';
848         }
849
850         (is_null($id)) ? $lattrs : $lattrs['id'] = $id;
851
852         $this->elementStart('li', $lattrs);
853         $attrs['href'] = $url;
854         if ($title) {
855             $attrs['title'] = $title;
856         }
857         $this->element('a', $attrs, $text);
858         $this->elementEnd('li');
859     }
860
861     /**
862      * Generate pagination links
863      *
864      * @param boolean $have_before is there something before?
865      * @param boolean $have_after  is there something after?
866      * @param integer $page        current page
867      * @param string  $action      current action
868      * @param array   $args        rest of query arguments
869      *
870      * @return nothing
871      */
872     function pagination($have_before, $have_after, $page, $action, $args=null)
873     {
874         // Does a little before-after block for next/prev page
875         if ($have_before || $have_after) {
876             $this->elementStart('div', array('class' => 'pagination'));
877             $this->elementStart('dl', null);
878             $this->element('dt', null, _('Pagination'));
879             $this->elementStart('dd', null);
880             $this->elementStart('ul', array('class' => 'nav'));
881         }
882         if ($have_before) {
883             $pargs   = array('page' => $page-1);
884             $newargs = $args ? array_merge($args, $pargs) : $pargs;
885             $this->elementStart('li', array('class' => 'nav_prev'));
886             $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'prev'),
887                            _('After'));
888             $this->elementEnd('li');
889         }
890         if ($have_after) {
891             $pargs   = array('page' => $page+1);
892             $newargs = $args ? array_merge($args, $pargs) : $pargs;
893             $this->elementStart('li', array('class' => 'nav_next'));
894             $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'next'),
895                            _('Before'));
896             $this->elementEnd('li');
897         }
898         if ($have_before || $have_after) {
899             $this->elementEnd('ul');
900             $this->elementEnd('dd');
901             $this->elementEnd('dl');
902             $this->elementEnd('div');
903         }
904     }
905 }