diff --git a/actions/all.php b/actions/all.php index 2a3c0ef0b6..5933d00946 100644 --- a/actions/all.php +++ b/actions/all.php @@ -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(); } diff --git a/actions/public.php b/actions/public.php index 6ecdf2e50a..5e07a893ff 100644 --- a/actions/public.php +++ b/actions/public.php @@ -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(); diff --git a/lib/action.php b/lib/action.php index 518ab3fe8a..360d342b22 100644 --- a/lib/action.php +++ b/lib/action.php @@ -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. * diff --git a/lib/publicgroupnav.php b/lib/publicgroupnav.php index e7c61000f3..69347bc0d4 100644 --- a/lib/publicgroupnav.php +++ b/lib/publicgroupnav.php @@ -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 diff --git a/lib/uapplugin.php b/lib/uapplugin.php index 9a6aeab662..dd72c8723d 100644 --- a/lib/uapplugin.php +++ b/lib/uapplugin.php @@ -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', diff --git a/plugins/Favorite/FavoritePlugin.php b/plugins/Favorite/FavoritePlugin.php index 117f6cb46d..09a3f8641c 100644 --- a/plugins/Favorite/FavoritePlugin.php +++ b/plugins/Favorite/FavoritePlugin.php @@ -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', diff --git a/plugins/Favorite/actions/favorited.php b/plugins/Favorite/actions/favorited.php index ff4a99cd60..849a1c8b07 100644 --- a/plugins/Favorite/actions/favorited.php +++ b/plugins/Favorite/actions/favorited.php @@ -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 diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php index 2dcb30d676..e2551de184 100644 --- a/plugins/Mapstraction/MapstractionPlugin.php +++ b/plugins/Mapstraction/MapstractionPlugin.php @@ -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 diff --git a/plugins/ModLog/ModLogPlugin.php b/plugins/ModLog/ModLogPlugin.php index f5373aa947..bbf283f8c4 100644 --- a/plugins/ModLog/ModLogPlugin.php +++ b/plugins/ModLog/ModLogPlugin.php @@ -116,7 +116,7 @@ class ModLogPlugin extends Plugin return true; } - function onEndShowSections($action) + function onEndShowSections(Action $action) { if ($action->arg('action') != 'showstream') { return true; diff --git a/plugins/SiteNoticeInSidebar/SiteNoticeInSidebarPlugin.php b/plugins/SiteNoticeInSidebar/SiteNoticeInSidebarPlugin.php index b487d86720..3131847349 100644 --- a/plugins/SiteNoticeInSidebar/SiteNoticeInSidebarPlugin.php +++ b/plugins/SiteNoticeInSidebar/SiteNoticeInSidebarPlugin.php @@ -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)) { diff --git a/plugins/WikiHashtags/WikiHashtagsPlugin.php b/plugins/WikiHashtags/WikiHashtagsPlugin.php index 52925d113a..f0baa597ce 100644 --- a/plugins/WikiHashtags/WikiHashtagsPlugin.php +++ b/plugins/WikiHashtags/WikiHashtagsPlugin.php @@ -51,7 +51,7 @@ class WikiHashtagsPlugin extends Plugin parent::__construct(); } - function onStartShowSections($action) + function onStartShowSections(Action $action) { $name = $action->trimmed('action');