From e6211c4c22eae51d78142056180f7b9e706179e4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 22 Jan 2009 17:29:10 +0100 Subject: Add a superclass for all sections --- lib/section.php | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 lib/section.php (limited to 'lib/section.php') diff --git a/lib/section.php b/lib/section.php new file mode 100644 index 000000000..d64095a3e --- /dev/null +++ b/lib/section.php @@ -0,0 +1,108 @@ +. + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/widget.php'; + +/** + * Base class for sections + * + * These are the widgets that show interesting data about a person + * group, or site. + * + * @category Widget + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class Section extends Widget +{ + /** + * Show the form + * + * Uses a recipe to output the form. + * + * @return void + * @see Widget::show() + */ + + function show() + { + $this->out->elementStart('div', + array('id' => $this->divId(), + 'class' => 'section')); + + $this->out->element('h2', null, + $this->title()); + + $have_more = $this->showContent(); + + if ($have_more) { + $this->elementStart('p'); + $this->element('a', array('href' => $this->moreUrl(), + 'class' => 'more'), + $this->moreTitle()); + $this->elementEnd('p'); + } + + $this->elementEnd('div'); + } + + function divId() + { + return 'generic_section'; + } + + function title() + { + return _('Untitled section'); + } + + function showContent() + { + $this->out->element('p', null, + _('(None)')); + return false; + } + + function moreUrl() + { + return null; + } + + function moreTitle() + { + return null; + } +} -- cgit v1.2.3-54-g00ecf