function onStartShowSections(Action $action)
 {
     $name = $action->trimmed('action');
     if ($name == 'tag') {
         $taginput = $action->trimmed('tag');
         $tag = common_canonical_tag($taginput);
         if (!empty($tag)) {
             $url = sprintf('http://hashtags.wikia.com/index.php?title=%s&action=render', urlencode($tag));
             $editurl = sprintf('http://hashtags.wikia.com/index.php?title=%s&action=edit', urlencode($tag));
             $request = HTTPClient::start();
             $response = $request->get($url);
             $html = $response->getBody();
             $action->elementStart('div', array('id' => 'wikihashtags', 'class' => 'section'));
             if ($response->isOk() && !empty($html)) {
                 $action->element('style', null, "span.editsection { display: none }\n" . "table.toc { display: none }");
                 $action->raw($html);
                 $action->elementStart('p');
                 $action->element('a', array('href' => $editurl, 'title' => sprintf(_m('Edit the article for #%s on WikiHashtags'), $tag)), _m('Edit'));
                 $action->element('a', array('href' => 'http://www.gnu.org/copyleft/fdl.html', 'title' => _m('Shared under the terms of the GNU Free Documentation License'), 'rel' => 'license'), _m('GNU FDL'));
                 $action->elementEnd('p');
             } else {
                 $action->element('a', array('href' => $editurl), sprintf(_m('Start the article for #%s on WikiHashtags'), $tag));
             }
             $action->elementEnd('div');
         }
     }
     return true;
 }
Пример #2
0
 public function onEndShowHeadElements(Action $action)
 {
     switch ($action->getActionName()) {
         case 'attachment':
             $action->element('link', array('rel' => 'alternate', 'type' => 'application/json+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'json', 'url' => common_local_url('attachment', array('attachment' => $action->attachment->id)))), 'title' => 'oEmbed'), null);
             $action->element('link', array('rel' => 'alternate', 'type' => 'text/xml+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'xml', 'url' => common_local_url('attachment', array('attachment' => $action->attachment->id)))), 'title' => 'oEmbed'), null);
             break;
         case 'shownotice':
             try {
                 $action->element('link', array('rel' => 'alternate', 'type' => 'application/json+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'json', 'url' => $action->notice->getUrl())), 'title' => 'oEmbed'), null);
                 $action->element('link', array('rel' => 'alternate', 'type' => 'text/xml+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'xml', 'url' => $action->notice->getUrl())), 'title' => 'oEmbed'), null);
             } catch (InvalidUrlException $e) {
                 // The notice is probably a share or similar, which don't
                 // have a representational URL of their own.
             }
             break;
     }
     return true;
 }
Пример #3
0
 /**
  * Add extra <meta> headers for certain pages that geourl.org understands
  *
  * @param Action $action page being shown
  *
  * @return boolean event handler flag
  */
 function onEndShowHeadElements($action)
 {
     $name = $action->trimmed('action');
     $location = null;
     if ($name == 'showstream') {
         $profile = $action->profile;
         if (!empty($profile) && !empty($profile->lat) && !empty($profile->lon)) {
             $location = $profile->lat . ', ' . $profile->lon;
         }
     } else {
         if ($name == 'shownotice') {
             $notice = $action->profile;
             if (!empty($notice) && !empty($notice->lat) && !empty($notice->lon)) {
                 $location = $notice->lat . ', ' . $notice->lon;
             }
         }
     }
     if (!empty($location)) {
         $action->element('meta', array('name' => 'ICBM', 'content' => $location));
         $action->element('meta', array('name' => 'DC.title', 'content' => $action->title()));
     }
     return true;
 }
Пример #4
0
 /**
  * Add extra <meta> headers for certain pages that geourl.org understands
  *
  * @param Action $action page being shown
  *
  * @return boolean event handler flag
  */
 function onEndShowHeadElements(Action $action)
 {
     $name = $action->trimmed('action');
     $location = null;
     if ($action instanceof ShowstreamAction) {
         $profile = $action->getTarget();
         if (!empty($profile->lat) && !empty($profile->lon)) {
             $location = $profile->lat . ', ' . $profile->lon;
         }
     } elseif ($action instanceof ShownoticeAction) {
         // FIXME: getNotice in ShownoticeAction will do a new lookup, we should fix those classes
         // so they can reliably just get a pre-stored notice object which was fetched in Shownotice prepare()...
         $notice = $action->notice;
         if ($notice instanceof Notice && !empty($notice->lat) && !empty($notice->lon)) {
             $location = $notice->lat . ', ' . $notice->lon;
         }
     }
     if (!is_null($location)) {
         $action->element('meta', array('name' => 'ICBM', 'content' => $location));
         $action->element('meta', array('name' => 'DC.title', 'content' => $action->title()));
     }
     return true;
 }
Пример #5
0
 /**
  * Show a leaderboard ad
  *
  * @param Action $action Action being shown
  *
  * @return void
  */
 protected function showLeaderboard($action)
 {
     $action->element('img', array('width' => 728, 'height' => 90, 'src' => common_path('plugins/BlankAd/redpixel.png')), '');
 }
Пример #6
0
 /**
  * We include a <meta> element linking to the webfinger resource page,
  * for OpenID client-side authentication.
  *
  * @param Action $action Action being shown
  *
  * @return void
  */
 function onEndShowHeadElements(Action $action)
 {
     if ($action instanceof ShowstreamAction) {
         $action->element('link', array('rel' => 'openid2.provider', 'href' => common_local_url('openidserver')));
         $action->element('link', array('rel' => 'openid2.local_id', 'href' => $action->getTarget()->getUrl()));
         $action->element('link', array('rel' => 'openid.server', 'href' => common_local_url('openidserver')));
         $action->element('link', array('rel' => 'openid.delegate', 'href' => $action->getTarget()->getUrl()));
     }
     if ($action instanceof SitestreamAction) {
         $action->element('meta', array('http-equiv' => 'X-XRDS-Location', 'content' => common_local_url('publicxrds')));
     }
     return true;
 }
Пример #7
0
 /**
  * If a notice has a title, show it in the <title> element
  *
  * @param Action $action Action being executed
  *
  * @return boolean hook value
  */
 function onStartShowHeadTitle($action)
 {
     $actionName = $action->trimmed('action');
     if ($actionName == 'shownotice') {
         $title = Notice_title::fromNotice($action->notice);
         if (!empty($title)) {
             $action->element('title', null, sprintf(_m("%1\$s - %2\$s"), $title, common_config('site', 'name')));
         }
     }
     return true;
 }
 /**
  * SN plugin API, here we will add css needed for modifiyed rendered
  *
  * @param Action $xml
  */
 public function onEndShowStatusNetStyles($xml)
 {
     $xml->element('style', array('type' => 'text/css'), 'span.rtl {display:block;direction:rtl;text-align:right;float:right;} .notice .author {float:left}');
 }
 function onEndShowSections(Action $action)
 {
     $actionName = $action->trimmed('action');
     // These are the ones that have maps on 'em
     if (!in_array($actionName, array('showstream', 'all'))) {
         return true;
     }
     $action->elementStart('div', array('id' => 'entity_map', 'class' => 'section'));
     // TRANS: Header for Map widget that displays a map with geodata for notices.
     $action->element('h2', null, _m('Map'));
     $action->element('div', array('id' => 'map_canvas', 'class' => 'gray smallmap', 'style' => "width: 100%; height: 240px"));
     $mapAct = $actionName == 'showstream' ? 'usermap' : 'allmap';
     $mapUrl = common_local_url($mapAct, array('nickname' => $action->trimmed('nickname')));
     $action->element('a', array('href' => $mapUrl), _m('Full size'));
     $action->elementEnd('div');
 }
Пример #10
0
 /**
  * Meta tags for "claiming" a site
  *
  * We add extra meta tags that search engines like Yahoo!, Google, and Bing
  * require to let you claim your site.
  *
  * @param Action $action Action being executed
  *
  * @return boolean hook value.
  */
 function onStartShowHeadElements($action)
 {
     $actionName = $action->trimmed('action');
     $singleUser = common_config('singleuser', 'enabled');
     // Different "top" pages if it's single user or not
     if ($singleUser && $actionName == 'showstream' || !$singleUser && $actionName == 'public') {
         $keys = array('googlekey' => 'google-site-verification', 'yahookey' => 'y_key', 'bingkey' => 'msvalidate.01');
         // XXX: is this the same for all sites?
         foreach ($keys as $config => $metaname) {
             $content = common_config('sitemap', $config);
             if (!empty($content)) {
                 $action->element('meta', array('name' => $metaname, 'content' => $content));
             }
         }
     }
     return true;
 }
 /**
  * Show an indicator that the group is (essentially) private on the group page
  *
  * @param Action     $action The action being shown
  * @param User_group $group  The group being shown
  *
  * @return boolean hook value
  */
 function onEndGroupProfileElements($action, $group)
 {
     $gps = Group_privacy_settings::forGroup($group);
     if ($gps->allow_privacy == Group_privacy_settings::ALWAYS) {
         $action->element('p', 'privategroupindicator', _('Private'));
     }
     return true;
 }
Пример #12
0
 function onEndShowSections(Action $action)
 {
     if (!$action instanceof ShowstreamAction) {
         // early return for actions we're not interested in
         return true;
     }
     $scoped = $action->getScoped();
     if (!$scoped instanceof Profile || !$scoped->hasRight(self::VIEWMODLOG)) {
         // only continue if we are allowed to VIEWMODLOG
         return true;
     }
     $profile = $action->getTarget();
     $ml = new ModLog();
     $ml->profile_id = $profile->getID();
     $ml->orderBy("created");
     $cnt = $ml->find();
     if ($cnt > 0) {
         $action->elementStart('div', array('id' => 'entity_mod_log', 'class' => 'section'));
         $action->element('h2', null, _('Moderation'));
         $action->elementStart('table');
         while ($ml->fetch()) {
             $action->elementStart('tr');
             $action->element('td', null, strftime('%y-%m-%d', strtotime($ml->created)));
             $action->element('td', null, sprintf($ml->is_grant ? _('+%s') : _('-%s'), $ml->role));
             $action->elementStart('td');
             if ($ml->moderator_id) {
                 $mod = Profile::getByID($ml->moderator_id);
                 if (empty($mod)) {
                     $action->text(_('[unknown]'));
                 } else {
                     $action->element('a', array('href' => $mod->getUrl(), 'title' => $mod->getFullname()), $mod->getNickname());
                 }
             } else {
                 $action->text(_('[unknown]'));
             }
             $action->elementEnd('td');
             $action->elementEnd('tr');
         }
         $action->elementEnd('table');
         $action->elementEnd('div');
     }
 }
Пример #13
0
 /**
  * Show an indicator that the group is (essentially) private on the group page
  *
  * @param Action     $action The action being shown
  * @param User_group $group  The group being shown
  *
  * @return boolean hook value
  */
 function onEndGroupProfileElements($action, $group)
 {
     $gps = Group_privacy_settings::forGroup($group);
     if ($gps->allow_privacy == Group_privacy_settings::ALWAYS) {
         // TRANS: Indicator on the group page that the group is (essentially) private.
         $action->element('p', 'privategroupindicator', _m('Private'));
     }
     return true;
 }
 public function onEndShowHeadElements(Action $action)
 {
     if ($action instanceof ShowNoticeAction) {
         // Showing a notice
         $notice = Notice::getKV('id', $action->arg('notice'));
         try {
             $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE);
             $fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE);
         } catch (NoResultException $e) {
             return true;
         }
         $statusId = twitter_status_id($notice);
         if ($notice instanceof Notice && $notice->isLocal() && $statusId) {
             $tweetUrl = 'https://twitter.com/' . $fuser->nickname . '/status/' . $statusId;
             $action->element('link', array('rel' => 'syndication', 'href' => $tweetUrl));
         }
     }
     if (!$action instanceof AttachmentAction) {
         return true;
     }
     /* Twitter card support. See https://dev.twitter.com/docs/cards */
     /* @fixme: should we display twitter cards only for attachments posted
      *         by local users ? Seems mandatory to display twitter:creator
      *
      * Author: jbfavre
      */
     switch ($action->attachment->mimetype) {
         case 'image/pjpeg':
         case 'image/jpeg':
         case 'image/jpg':
         case 'image/png':
         case 'image/gif':
             $action->element('meta', array('name' => 'twitter:card', 'content' => 'photo'), null);
             $action->element('meta', array('name' => 'twitter:url', 'content' => common_local_url('attachment', array('attachment' => $action->attachment->id))), null);
             $action->element('meta', array('name' => 'twitter:image', 'content' => $action->attachment->url));
             $action->element('meta', array('name' => 'twitter:title', 'content' => $action->attachment->title));
             $ns = new AttachmentNoticeSection($action);
             $notices = $ns->getNotices();
             $noticeArray = $notices->fetchAll();
             // Should not have more than 1 notice for this attachment.
             if (count($noticeArray) != 1) {
                 break;
             }
             $post = $noticeArray[0];
             try {
                 $flink = Foreign_link::getByUserID($post->profile_id, TWITTER_SERVICE);
                 $fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE);
                 $action->element('meta', array('name' => 'twitter:creator', 'content' => '@' . $fuser->nickname));
             } catch (NoResultException $e) {
                 // no foreign link and/or user for Twitter on this profile ID
             }
             break;
         default:
             break;
     }
     return true;
 }
 public function onEndShowInsideFooter(Action $action)
 {
     if ($this->serveMobile) {
         // TRANS: Link to switch site layout from mobile to desktop mode. Appears at very bottom of page.
         $linkText = _m('Switch to desktop site layout.');
         $key = 'mobile-toggle-disable';
     } else {
         // TRANS: Link to switch site layout from desktop to mobile mode. Appears at very bottom of page.
         $linkText = _m('Switch to mobile site layout.');
         $key = 'mobile-toggle-enable';
     }
     $action->elementStart('p');
     $action->element('a', array('href' => '#', 'id' => $key), $linkText);
     $action->elementEnd('p');
     return true;
 }
Пример #16
0
 function onEndShowSections(Action $action)
 {
     if ($action->arg('action') != 'showstream') {
         return true;
     }
     $cur = common_current_user();
     if (empty($cur) || !$cur->hasRight(self::VIEWMODLOG)) {
         return true;
     }
     $profile = $action->profile;
     $ml = new ModLog();
     $ml->profile_id = $profile->id;
     $ml->orderBy("created");
     $cnt = $ml->find();
     if ($cnt > 0) {
         $action->elementStart('div', array('id' => 'entity_mod_log', 'class' => 'section'));
         $action->element('h2', null, _('Moderation'));
         $action->elementStart('table');
         while ($ml->fetch()) {
             $action->elementStart('tr');
             $action->element('td', null, strftime('%y-%m-%d', strtotime($ml->created)));
             $action->element('td', null, sprintf($ml->is_grant ? _('+%s') : _('-%s'), $ml->role));
             $action->elementStart('td');
             if ($ml->moderator_id) {
                 $mod = Profile::getKV('id', $ml->moderator_id);
                 if (empty($mod)) {
                     $action->text(_('[unknown]'));
                 } else {
                     $action->element('a', array('href' => $mod->profileurl, 'title' => $mod->fullname), $mod->nickname);
                 }
             } else {
                 $action->text(_('[unknown]'));
             }
             $action->elementEnd('td');
             $action->elementEnd('tr');
         }
         $action->elementEnd('table');
         $action->elementEnd('div');
     }
 }
Пример #17
0
 /**
  * Actually output a flag button. If the target profile has already been
  * flagged by the current user, a null-action faux button is shown.
  *
  * @param Action $action
  * @param Profile $profile
  * @param array $returnToArgs
  */
 protected function showFlagButton($action, $profile, $returnToArgs)
 {
     $user = common_current_user();
     if (!empty($user) && $user->id != $profile->id) {
         $action->elementStart('li', 'entity_flag');
         if (User_flag_profile::exists($profile->id, $user->id)) {
             // @todo FIXME: Add a title explaining what 'flagged' means?
             // TRANS: Message added to a profile if it has been flagged for review.
             $action->element('p', 'flagged', _m('Flagged'));
         } else {
             $form = new FlagProfileForm($action, $profile, $returnToArgs);
             $form->show();
         }
         $action->elementEnd('li');
     }
 }
Пример #18
0
 /**
  * Add in a Facebook Connect avatar to the primary nav menu
  *
  * @param Action $action the current action
  *
  * @return void
  *
  */
 function onStartPrimaryNav($action)
 {
     if (self::hasKeys()) {
         $user = common_current_user();
         if (!empty($user)) {
             $fbuid = $this->loggedIn();
             if (!empty($fbuid)) {
                 /* Default FB silhouette pic for FB users who haven't
                    uploaded a profile pic yet. */
                 $silhouetteUrl = 'http://static.ak.fbcdn.net/pics/q_silhouette.gif';
                 $url = $this->getProfilePicURL($fbuid);
                 $action->elementStart('li', array('id' => 'nav_fb'));
                 $action->element('img', array('id' => 'fbc_profile-pic', 'src' => !empty($url) ? $url : $silhouetteUrl, 'alt' => 'Facebook Connect User', 'width' => '16'), '');
                 $iconurl = common_path('plugins/Facebook/fbfavicon.ico');
                 $action->element('img', array('id' => 'fb_favicon', 'src' => $iconurl));
                 $action->elementEnd('li');
             }
         }
     }
     return true;
 }
Пример #19
0
 /**
  * If a notice has a title, show it in the <h1> element
  *
  * @param Action $action Action being executed
  *
  * @return boolean hook value
  */
 function onStartShowPageTitle($action)
 {
     $actionName = $action->trimmed('action');
     if ($actionName == 'shownotice') {
         $title = Notice_title::fromNotice($action->notice);
         if (!empty($title)) {
             $action->element('h1', null, $title);
             return false;
         }
     }
     return true;
 }
Пример #20
0
 /**
  * Show a leaderboard ad
  *
  * @param Action $action Action being shown
  *
  * @return void
  */
 protected function showLeaderboard($action)
 {
     $action->element('img', array('width' => 728, 'height' => 90, 'src' => $this->path('redpixel.png')), '');
 }
Пример #21
0
 public function onEndShowHeadElements(Action $action)
 {
     if (!$action instanceof AttachmentAction) {
         return true;
     }
     /* Twitter card support. See https://dev.twitter.com/docs/cards */
     /* @fixme: should we display twitter cards only for attachments posted
      *         by local users ? Seems mandatory to display twitter:creator
      *
      * Author: jbfavre
      */
     switch ($action->attachment->mimetype) {
         case 'image/pjpeg':
         case 'image/jpeg':
         case 'image/jpg':
         case 'image/png':
         case 'image/gif':
             $action->element('meta', array('name' => 'twitter:card', 'content' => 'photo'), null);
             $action->element('meta', array('name' => 'twitter:url', 'content' => common_local_url('attachment', array('attachment' => $action->attachment->id))), null);
             $action->element('meta', array('name' => 'twitter:image', 'content' => $action->attachment->url));
             $action->element('meta', array('name' => 'twitter:title', 'content' => $action->attachment->title));
             $ns = new AttachmentNoticeSection($action);
             $notices = $ns->getNotices();
             $noticeArray = $notices->fetchAll();
             // Should not have more than 1 notice for this attachment.
             if (count($noticeArray) != 1) {
                 break;
             }
             $post = $noticeArray[0];
             $flink = Foreign_link::getByUserID($post->profile_id, TWITTER_SERVICE);
             if ($flink) {
                 // Our local user has registered Twitter Gateway
                 $fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE);
                 if ($fuser) {
                     // Got nickname for local user's Twitter account
                     $action->element('meta', array('name' => 'twitter:creator', 'content' => '@' . $fuser->nickname));
                 }
             }
             break;
         default:
             break;
     }
     return true;
 }
Пример #22
0
 /**
  * Show a link to our delicious import page on profile settings form
  *
  * @param Action $action Profile settings action being shown
  *
  * @return boolean hook value
  */
 function onEndProfileSettingsActions($action)
 {
     $user = common_current_user();
     if (!empty($user) && $user->hasRight(self::IMPORTDELICIOUS)) {
         $action->elementStart('li');
         $action->element('a', array('href' => common_local_url('importdelicious')), _m('Import del.icio.us bookmarks'));
         $action->elementEnd('li');
     }
     return true;
 }
 /**
  * We include a <meta> element linking to the userxrds page, for OpenID
  * client-side authentication.
  *
  * @param Action $action Action being shown
  *
  * @return void
  */
 function onEndShowHeadElements($action)
 {
     if ($action instanceof ShowstreamAction) {
         $action->element('link', array('rel' => 'openid2.provider', 'href' => common_local_url('openidserver')));
         $action->element('link', array('rel' => 'openid2.local_id', 'href' => $action->profile->profileurl));
         $action->element('link', array('rel' => 'openid.server', 'href' => common_local_url('openidserver')));
         $action->element('link', array('rel' => 'openid.delegate', 'href' => $action->profile->profileurl));
     }
     return true;
 }
Пример #24
0
    /**
     * Called when all scripts have been shown
     *
     * @param Action $action Current action
     *
     * @return boolean ignored
     */
    function onEndShowScripts($action)
    {
        // Slight modification to the default code.
        // Loading the piwik.js file from a <script> created in a document.write
        // meant that the browser had no way to preload it, ensuring that its
        // loading will be synchronous, blocking further page rendering.
        //
        // User-agents understand protocol-relative links, so instead of the
        // URL produced in JS we can just give a universal one. Since it's
        // sitting there in the DOM ready to go, the browser can preload the
        // file for us and we're less likely to have to wait for it.
        $piwikUrl = '//' . $this->piwikroot . 'piwik.js';
        $piwikCode = <<<ENDOFPIWIK
try {
var pkBaseURL = (("https:" == document.location.protocol) ? "https://{$this->piwikroot}" : "http://{$this->piwikroot}");
    var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$this->piwikId});
    piwikTracker.trackPageView();
    piwikTracker.enableLinkTracking();
} catch( err ) {}
ENDOFPIWIK;
        // Don't use $action->script() here; it'll try to preface the URL.
        $action->element('script', array('type' => 'text/javascript', 'src' => $piwikUrl), ' ');
        $action->inlineScript($piwikCode);
        return true;
    }
Пример #25
0
 /**
  * Overrides XMLOutputter::element to write booleans as strings (true|false).
  * See that method's documentation for more info.
  *
  * @param string $tag     Element type or tagname
  * @param array  $attrs   Array of element attributes, as
  *                        key-value pairs
  * @param string $content string content of the element
  *
  * @return void
  */
 function element($tag, $attrs = null, $content = null)
 {
     if (is_bool($content)) {
         $content = $content ? 'true' : 'false';
     }
     return parent::element($tag, $attrs, $content);
 }
 /**
  * Show an error message about validating user email before posting
  *
  * @param string $tag    Current tab tag value
  * @param Action $action action being shown
  * @param Form   $form   object producing the form
  *
  * @return boolean hook value
  */
 function onStartMakeEntryForm($tag, $action, &$form)
 {
     $user = common_current_user();
     if (!empty($user)) {
         if (!$this->validated($user)) {
             $action->element('div', array('class' => 'error'), _m('You must validate an email address before posting!'));
         }
     }
     return true;
 }