section control over their notice lists + HTML id stuff
This commit is contained in:
parent
7ed1ef081b
commit
51f97c7e84
|
@ -70,6 +70,6 @@ class AttachmentNoticeSection extends NoticeSection
|
|||
|
||||
function divId()
|
||||
{
|
||||
return 'popular_notices';
|
||||
return 'attachment_section';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,11 @@ class InviteButtonSection extends Section
|
|||
return false;
|
||||
}
|
||||
|
||||
function divId()
|
||||
{
|
||||
return 'invite_button';
|
||||
}
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$this->out->element(
|
||||
|
|
|
@ -55,6 +55,7 @@ class NoticeList extends Widget
|
|||
|
||||
protected $addressees = true;
|
||||
protected $attachments = true;
|
||||
protected $id_prefix = null;
|
||||
protected $maxchars = 0;
|
||||
protected $options = true;
|
||||
protected $show_n = NOTICES_PER_PAGE;
|
||||
|
@ -81,7 +82,12 @@ class NoticeList extends Widget
|
|||
$this->$key = (bool)$prefs[$key];
|
||||
}
|
||||
}
|
||||
|
||||
// string preferences
|
||||
foreach(array('id_prefix') as $key) {
|
||||
if (array_key_exists($key, $prefs)) {
|
||||
$this->$key = $prefs[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,6 +140,7 @@ class NoticeList extends Widget
|
|||
{
|
||||
$prefs = array('addressees' => $this->addressees,
|
||||
'attachments' => $this->attachments,
|
||||
'id_prefix' => $this->id_prefix,
|
||||
'maxchars' => $this->maxchars,
|
||||
'options' => $this->options);
|
||||
return new NoticeListItem($notice, $this->out, $prefs);
|
||||
|
|
|
@ -60,6 +60,7 @@ class NoticeListItem extends Widget
|
|||
|
||||
protected $addressees = true;
|
||||
protected $attachments = true;
|
||||
protected $id_prefix = null;
|
||||
protected $options = true;
|
||||
protected $maxchars = 0; // if <= 0 it means use full posts
|
||||
|
||||
|
@ -99,6 +100,12 @@ class NoticeListItem extends Widget
|
|||
$this->$key = (bool)$prefs[$key];
|
||||
}
|
||||
}
|
||||
// string preferences
|
||||
foreach(array('id_prefix') as $key) {
|
||||
if (array_key_exists($key, $prefs)) {
|
||||
$this->$key = $prefs[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,8 +218,9 @@ class NoticeListItem extends Widget
|
|||
if (!empty($this->notice->source)) {
|
||||
$class .= ' notice-source-'.$this->notice->source;
|
||||
}
|
||||
$id_prefix = (strlen($this->id_prefix) ? $this->id_prefix . '-' : '');
|
||||
$this->out->elementStart('li', array('class' => $class,
|
||||
'id' => 'notice-' . $id));
|
||||
'id' => "${id_prefix}notice-${id}"));
|
||||
Event::handle('EndOpenNoticeListItemElement', array($this));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,14 +46,26 @@ define('NOTICES_PER_SECTION', 6);
|
|||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class NoticeSection extends Section
|
||||
abstract class NoticeSection extends Section
|
||||
{
|
||||
protected $addressees = false;
|
||||
protected $attachments = false;
|
||||
protected $maxchars = 140;
|
||||
protected $options = false;
|
||||
protected $show_n = NOTICES_PER_SECTION;
|
||||
|
||||
function showContent()
|
||||
{
|
||||
// args: notice object, html outputter, preference array for list and items
|
||||
$list = new SectionNoticeList($this->getNotices(), $this->out);
|
||||
$prefs = array();
|
||||
foreach (array('addressees', 'attachments', 'maxchars', 'options', 'show_n') as $key) {
|
||||
$prefs[$key] = $this->$key;
|
||||
}
|
||||
$prefs['id_prefix'] = $this->divId();
|
||||
|
||||
// args: notice object, html outputter, preference array for notice lists and their items
|
||||
$list = new NoticeList($this->getNotices(), $this->out, $prefs);
|
||||
$total = $list->show(); // returns total amount of notices available
|
||||
return ($total > NOTICES_PER_SECTION); // do we have more to show?
|
||||
return ($total > $this->show_n); // do we have more to show?
|
||||
}
|
||||
|
||||
function getNotices()
|
||||
|
|
|
@ -46,7 +46,7 @@ define('PROFILES_PER_SECTION', 6);
|
|||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ProfileSection extends Section
|
||||
abstract class ProfileSection extends Section
|
||||
{
|
||||
function showContent()
|
||||
{
|
||||
|
|
|
@ -27,11 +27,7 @@
|
|||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR.'/lib/widget.php';
|
||||
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Base class for sections
|
||||
|
@ -45,7 +41,7 @@ require_once INSTALLDIR.'/lib/widget.php';
|
|||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class Section extends Widget
|
||||
abstract class Section extends Widget
|
||||
{
|
||||
/**
|
||||
* Show the form
|
||||
|
@ -94,10 +90,7 @@ class Section extends Widget
|
|||
$this->out->elementEnd('p');
|
||||
}
|
||||
|
||||
function divId()
|
||||
{
|
||||
return 'generic_section';
|
||||
}
|
||||
abstract public function divId();
|
||||
|
||||
function title()
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ class PopularNoticeSection extends NoticeSection
|
|||
{
|
||||
protected $viewer;
|
||||
|
||||
function __construct($out, $viewer)
|
||||
function __construct($out, Profile $viewer=null)
|
||||
{
|
||||
parent::__construct($out);
|
||||
$this->viewer = $viewer;
|
||||
|
@ -67,7 +67,7 @@ class PopularNoticeSection extends NoticeSection
|
|||
|
||||
function divId()
|
||||
{
|
||||
return 'popular_notices';
|
||||
return 'popular_section';
|
||||
}
|
||||
|
||||
function moreUrl()
|
||||
|
|
Loading…
Reference in New Issue
Block a user