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