Favorite "aside"-sections moved, also small fixes left from before

Action now has 'isAction' which compares the loaded Action with names
of classes in an array (added without the 'Action') to its own type.
This commit is contained in:
Mikael Nordfeldth 2014-06-28 16:09:46 +02:00
parent 7e597ea7cc
commit 138d26d488
11 changed files with 42 additions and 30 deletions

View File

@ -196,8 +196,6 @@ class AllAction extends ProfileAction
// XXX: make this a little more convenient
if (!common_config('performance', 'high')) {
$pop = new PopularNoticeSection($this, $this->scoped);
$pop->show();
$pop = new InboxTagCloudSection($this, $this->target);
$pop->show();
}

View File

@ -27,13 +27,7 @@
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/publicgroupnav.php';
require_once INSTALLDIR.'/lib/noticelist.php';
require_once INSTALLDIR.'/lib/feedlist.php';
if (!defined('GNUSOCIAL')) { exit(1); }
// Farther than any human will go
@ -261,8 +255,6 @@ class PublicAction extends Action
$p = Profile::current();
$pop = new PopularNoticeSection($this, $p);
$pop->show();
if (!common_config('performance', 'high')) {
$cloud = new PublicTagCloudSection($this);
$cloud->show();

View File

@ -169,17 +169,36 @@ class Action extends HTMLOutputter // lawsuit
return true;
}
function updateScopedProfile() {
public function updateScopedProfile()
{
$this->scoped = Profile::current();
return $this->scoped;
}
public function getScoped()
{
return ($this->scoped instanceof Profile) ? $this-scoped : null;
}
// Must be run _after_ prepare
public function getActionName()
{
return $this->action;
}
public function isAction(array $names)
{
foreach ($names as $class) {
// PHP is case insensitive, and we have stuff like ApiUpperCaseAction,
// but we at least make a point out of wanting to do stuff case-sensitive.
$class = ucfirst($class) . 'Action';
if ($this instanceof $class) {
return true;
}
}
return false;
}
/**
* Show page, a template method.
*

View File

@ -27,11 +27,7 @@
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/widget.php';
if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Menu for public group of actions

View File

@ -79,7 +79,7 @@ abstract class UAPPlugin extends Plugin
*
* @return boolean hook flag
*/
function onStartShowAside($action)
function onStartShowAside(Action $action)
{
if (!is_null($this->mediumRectangle)) {
@ -141,7 +141,7 @@ abstract class UAPPlugin extends Plugin
*
* @return boolean hook flag
*/
function onStartShowSections($action)
function onStartShowSections(Action $action)
{
if (!is_null($this->rectangle)) {
$action->elementStart('div',
@ -161,7 +161,7 @@ abstract class UAPPlugin extends Plugin
*
* @return boolean hook flag
*/
function onEndShowAside($action)
function onEndShowAside(Action $action)
{
if (!is_null($this->wideSkyscraper)) {
$action->elementStart('div',

View File

@ -338,6 +338,18 @@ class FavoritePlugin extends ActivityHandlerPlugin
}
}
public function onEndShowSections(Action $action)
{
if (!$action->isAction(array('all', 'public'))) {
return true;
}
if (!common_config('performance', 'high')) {
$section = new PopularNoticeSection($action, $action->getScoped());
$section->show();
}
}
public function onPluginVersion(array &$versions)
{
$versions[] = array('name' => 'Favorite',

View File

@ -28,12 +28,7 @@
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/publicgroupnav.php';
require_once INSTALLDIR.'/lib/noticelist.php';
if (!defined('GNUSOCIAL')) { exit(1); }
/**
* List of popular notices

View File

@ -139,7 +139,7 @@ class MapstractionPlugin extends Plugin
return true;
}
function onEndShowSections($action)
function onEndShowSections(Action $action)
{
$actionName = $action->trimmed('action');
// These are the ones that have maps on 'em

View File

@ -116,7 +116,7 @@ class ModLogPlugin extends Plugin
return true;
}
function onEndShowSections($action)
function onEndShowSections(Action $action)
{
if ($action->arg('action') != 'showstream') {
return true;

View File

@ -60,7 +60,7 @@ class SiteNoticeInSidebarPlugin extends Plugin
return false;
}
function onStartShowSections($action)
function onStartShowSections(Action $action)
{
$text = common_config('site', 'notice');
if (!empty($text)) {

View File

@ -51,7 +51,7 @@ class WikiHashtagsPlugin extends Plugin
parent::__construct();
}
function onStartShowSections($action)
function onStartShowSections(Action $action)
{
$name = $action->trimmed('action');