X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FTagSub%2FTagSubPlugin.php;h=ed65665ecc6c3f7dc0d6b4fbc6fd660c9dc763e4;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=8fbb1133627856bafee58a3108dde4f4870d3578;hpb=1459443b2110039a085103ee33522c79840288d5;p=quix0rs-gnu-social.git diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index 8fbb113362..ed65665ecc 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -60,43 +60,14 @@ class TagSubPlugin extends Plugin return true; } - /** - * Load related modules when needed - * - * @param string $cls Name of the class to be loaded - * - * @return boolean hook value; true means continue processing, false means stop. - */ - function onAutoload($cls) - { - $dir = dirname(__FILE__); - - switch ($cls) - { - case 'TagSub': - include_once $dir.'/'.$cls.'.php'; - return false; - case 'TagsubAction': - case 'TagunsubAction': - case 'TagsubsAction': - case 'TagSubForm': - case 'TagSubMenu': - case 'TagUnsubForm': - include_once $dir.'/'.strtolower($cls).'.php'; - return false; - default: - return true; - } - } - /** * Map URLs to actions * - * @param Net_URL_Mapper $m path-to-action mapper + * @param URLMapper $m path-to-action mapper * * @return boolean hook value; true means continue processing, false means stop. */ - function onRouterInitialized($m) + public function onRouterInitialized(URLMapper $m) { $m->connect('tag/:tag/subscribe', array('action' => 'tagsub'), @@ -118,7 +89,7 @@ class TagSubPlugin extends Plugin * * @return value */ - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'TagSub', 'version' => self::VERSION, @@ -165,7 +136,8 @@ class TagSubPlugin extends Plugin function onStartTagShowContent(TagAction $action) { $user = common_current_user(); - if ($user) { + + if ($user instanceof User) { $tag = $action->trimmed('tag'); $tagsub = TagSub::pkeyGet(array('tag' => $tag, 'profile_id' => $user->id)); @@ -182,6 +154,7 @@ class TagSubPlugin extends Plugin $action->elementEnd('ul'); $action->elementEnd('div'); } + return true; } @@ -192,7 +165,6 @@ class TagSubPlugin extends Plugin * * @return boolean hook return */ - function onEndSubGroupNav($widget) { $action = $widget->out; @@ -208,51 +180,21 @@ class TagSubPlugin extends Plugin return true; } - /** - * Add a count of mirrored feeds into a user's profile sidebar stats. - * - * @param Profile $profile - * @param array $stats - * @return boolean hook return value - */ - function onProfileStats($profile, &$stats) - { - $cur = common_current_user(); - if (!empty($cur) && $cur->id == $profile->id) { - $tagsub = new TagSub(); - $tagsub->profile_id = $profile->id; - $entry = array( - 'id' => 'tagsubs', - 'label' => _m('Tag subscriptions'), - 'link' => common_local_url('tagsubs', array('nickname' => $profile->nickname)), - 'value' => $tagsub->count(), - ); - - $insertAt = count($stats); - foreach ($stats as $i => $row) { - if ($row['id'] == 'groups') { - // Slip us in after them. - $insertAt = $i + 1; - break; - } - } - array_splice($stats, $insertAt, 0, array($entry)); - } - return true; - } - function onEndDefaultLocalNav($menu, $user) { $user = common_current_user(); - $tags = TagSub::forProfile($user->getProfile()); + if (!empty($user)) { - if (!empty($tags)) { - $tagSubMenu = new TagSubMenu($menu->out, $user, $tags); - $menu->submenu(_m('Tags'), $tagSubMenu); + $tags = TagSub::forProfile($user->getProfile()); + + if (!empty($tags) && count($tags) > 0) { + $tagSubMenu = new TagSubMenu($menu->out, $user, $tags); + // TRANS: Menu item text for tags submenu. + $menu->submenu(_m('Tags'), $tagSubMenu); + } } return true; } - }