]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/action.php
Merge branch '0.7.x' into 0.8.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      * For initializing members of the class.
78      *
79      * @param array $argarray misc. arguments
80      *
81      * @return boolean true
82      */
83     function prepare($argarray)
84     {
85         $this->args =& common_copy_args($argarray);
86         return true;
87     }
88
89     /**
90      * Show page, a template method.
91      *
92      * @return nothing
93      */
94     function showPage()
95     {
96         $this->startHTML();
97         $this->showHead();
98         $this->showBody();
99         $this->endHTML();
100     }
101
102     /**
103      * Show head, a template method.
104      *
105      * @return nothing
106      */
107     function showHead()
108     {
109         // XXX: attributes (profile?)
110         $this->elementStart('head');
111         $this->showTitle();
112         $this->showStylesheets();
113         $this->showScripts();
114         $this->showOpenSearch();
115         $this->showFeeds();
116         $this->showDescription();
117         $this->extraHead();
118         $this->elementEnd('head');
119     }
120
121     /**
122      * Show title, a template method.
123      *
124      * @return nothing
125      */
126     function showTitle()
127     {
128         $this->element('title', null,
129                        sprintf(_("%s - %s"),
130                                $this->title(),
131                                common_config('site', 'name')));
132     }
133
134     /**
135      * Returns the page title
136      *
137      * SHOULD overload
138      *
139      * @return string page title
140      */
141
142     function title()
143     {
144         return _("Untitled page");
145     }
146
147     /**
148      * Show stylesheets
149      *
150      * @return nothing
151      */
152     function showStylesheets()
153     {
154         $this->element('link', array('rel' => 'stylesheet',
155                                      'type' => 'text/css',
156                                      'href' => theme_path('css/display.css', 'base') . '?version=' . LACONICA_VERSION,
157                                      'media' => 'screen, projection, tv'));
158         $this->element('link', array('rel' => 'stylesheet',
159                                      'type' => 'text/css',
160                                      'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION,
161                                      'media' => 'screen, projection, tv'));
162         $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
163                        'href="'.theme_path('css/ie.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
164         foreach (array(6,7) as $ver) {
165             if (file_exists(theme_file('css/ie'.$ver.'.css', 'base'))) {
166                 // Yes, IE people should be put in jail.
167                 $this->comment('[if lte IE '.$ver.']><link rel="stylesheet" type="text/css" '.
168                                'href="'.theme_path('css/ie'.$ver.'.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
169             }
170         }
171         $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
172                        'href="'.theme_path('css/ie.css', null).'?version='.LACONICA_VERSION.'" /><![endif]');
173     }
174
175     /**
176      * Show javascript headers
177      *
178      * @return nothing
179      */
180     function showScripts()
181     {
182         $this->element('script', array('type' => 'text/javascript',
183                                        'src' => common_path('js/jquery.min.js')),
184                        ' ');
185         $this->element('script', array('type' => 'text/javascript',
186                                        'src' => common_path('js/jquery.form.js')),
187                        ' ');
188         $this->element('script', array('type' => 'text/javascript',
189                                        'src' => common_path('js/xbImportNode.js')),
190                        ' ');
191         $this->element('script', array('type' => 'text/javascript',
192                                        'src' => common_path('js/util.js?version='.LACONICA_VERSION)),
193                        ' ');
194     }
195
196     /**
197      * Show OpenSearch headers
198      *
199      * @return nothing
200      */
201     function showOpenSearch()
202     {
203         $this->element('link', array('rel' => 'search',
204                                      'type' => 'application/opensearchdescription+xml',
205                                      'href' =>  common_local_url('opensearch', array('type' => 'people')),
206                                      'title' => common_config('site', 'name').' People Search'));
207         $this->element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml',
208                                      'href' =>  common_local_url('opensearch', array('type' => 'notice')),
209                                      'title' => common_config('site', 'name').' Notice Search'));
210     }
211
212     /**
213      * Show feed headers
214      *
215      * MAY overload
216      *
217      * @return nothing
218      */
219     function showFeeds()
220     {
221         // does nothing by default
222     }
223
224     /**
225      * Show description.
226      *
227      * SHOULD overload
228      *
229      * @return nothing
230      */
231     function showDescription()
232     {
233         // does nothing by default
234     }
235
236     /**
237      * Show extra stuff in <head>.
238      *
239      * MAY overload
240      *
241      * @return nothing
242      */
243     function extraHead()
244     {
245         // does nothing by default
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', array('id' => '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->elementStart('dd', null);
370             $this->raw($text);
371             $this->elementEnd('dd');
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 }