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