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