function onEndShowAccountProfileBlock(HTMLOutputter $out, Profile $profile)
 {
     $user = User::getKV('id', $profile->id);
     if ($user) {
         $url = common_local_url('profiledetail', array('nickname' => $user->nickname));
         // TRANS: Link text on user profile page leading to extended profile page.
         $out->element('a', array('href' => $url, 'class' => 'profiledetail'), _m('More details...'));
     }
 }
 /**
  * Build common remote-profile options structure.
  * Currently only adds output for remote profiles, nothing for local users.
  *
  * @param HTMLOutputter $out
  * @param Profile $profile
  */
 protected function showProfileOptions(HTMLOutputter $out, Profile $profile)
 {
     if (!$profile->isGroup() && !$profile->isLocal()) {
         $target = common_local_url('userbyid', array('id' => $profile->getID()));
         // TRANS: Label for access to remote profile options.
         $label = _m('Remote profile options...');
         $out->elementStart('div', 'remote-profile-options');
         $out->element('a', array('href' => $target), $label);
         $out->elementEnd('div');
     }
 }
 private function showShareTarget(HTMLOutputter $out, NoticeShareTarget $target)
 {
     $class = $target->getClass();
     $text = $target->getText();
     $url = $target->targetUrl();
     $out->elementStart('li', array('class' => 'notice-share-' . $class));
     $out->elementStart('a', array('href' => $url, 'title' => $text, 'target' => '_blank'));
     $out->element('span', array(), $text);
     $out->elementEnd('a');
     $out->elementEnd('li');
 }
Exemple #4
0
 /**
  * Constructor
  *
  * Just wraps the HTMLOutputter constructor.
  *
  * @param string  $output URI to output to, default = stdout
  * @param boolean $indent Whether to indent output, default true
  *
  * @see XMLOutputter::__construct
  * @see HTMLOutputter::__construct
  */
 function __construct($output = 'php://output', $indent = null)
 {
     parent::__construct($output, $indent);
 }
Exemple #5
0
 function endHTML()
 {
     global $_startTime;
     if (isset($_startTime)) {
         $endTime = microtime(true);
         $diff = round(($endTime - $_startTime) * 1000);
         $this->raw("<!-- {$diff}ms -->");
     }
     return parent::endHTML();
 }
Exemple #6
0
 protected function showRSVP(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $rsvp = RSVP::fromNotice($stored);
     if (empty($rsvp)) {
         // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond").
         $out->element('p', null, _m('Deleted.'));
         return;
     }
     $out->elementStart('div', 'rsvp');
     $out->raw($rsvp->asHTML());
     $out->elementEnd('div');
 }
 /**
  * Layout stuff
  */
 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $out->raw($stored->getRendered());
 }
Exemple #8
0
 /**
  * Handle a POST user credential check in apioauthauthorization.
  * If given an OpenID URL, we'll pass us over to the regular things
  * and then redirect back here on completion.
  *
  * @fixme merge with common code for main OpenID login form
  * @param HTMLOutputter $action
  */
 function onStartOAuthLoginCheck($action, &$user)
 {
     $provider = common_config('openid', 'trusted_provider');
     if ($provider) {
         $openid_url = $provider;
         if (common_config('openid', 'append_username')) {
             $openid_url .= $action->trimmed('openid_username');
         }
     } else {
         $openid_url = $action->trimmed('openid_url');
     }
     if ($openid_url) {
         require_once dirname(__FILE__) . '/openid.php';
         oid_assert_allowed($openid_url);
         $returnto = common_local_url('ApiOauthAuthorize', array(), array('oauth_token' => $action->arg('oauth_token'), 'mode' => $action->arg('mode')));
         common_set_returnto($returnto);
         // This will redirect if functional...
         $result = oid_authenticate($openid_url, 'finishopenidlogin');
         if (is_string($result)) {
             # error message
             throw new ServerException($result);
         } else {
             exit(0);
         }
     }
     return true;
 }
 function onEndProfilePageProfileElements(HTMLOutputter $out, Profile $profile)
 {
     $user = User::staticGet('id', $profile->id);
     if ($user) {
         $url = common_local_url('profiledetail', array('nickname' => $user->nickname));
         $out->element('a', array('href' => $url), _m('More details...'));
     }
     return;
 }
Exemple #10
0
 public function onStartShowAttachmentRepresentation(HTMLOutputter $out, File $file)
 {
     $oembed = File_oembed::getKV('file_id', $file->id);
     if (empty($oembed->type)) {
         return true;
     }
     switch ($oembed->type) {
         case 'rich':
         case 'video':
         case 'link':
             if (!empty($oembed->html) && (GNUsocial::isAjax() || common_config('attachments', 'show_html'))) {
                 require_once INSTALLDIR . '/extlib/htmLawed/htmLawed.php';
                 $config = array('safe' => 1, 'elements' => '*+object+embed');
                 $out->raw(htmLawed($oembed->html, $config));
             }
             break;
         case 'photo':
             $out->element('img', array('src' => $oembed->url, 'width' => $oembed->width, 'height' => $oembed->height, 'alt' => 'alt'));
             break;
         default:
             Event::handle('ShowUnsupportedAttachmentRepresentation', array($out, $file));
     }
 }
 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $nb = Bookmark::getByNotice($stored);
     if (empty($nb)) {
         common_log(LOG_ERR, "No bookmark for notice {$stored->id}");
         parent::showContent();
         return;
     } else {
         if (empty($nb->url)) {
             common_log(LOG_ERR, "No url for bookmark {$nb->id} for notice {$stored->id}");
             parent::showContent();
             return;
         }
     }
     $profile = $stored->getProfile();
     // Whether to nofollow
     $attrs = array('href' => $nb->url, 'class' => 'bookmark-title');
     $nf = common_config('nofollow', 'external');
     if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
         $attrs['rel'] = 'external';
     } else {
         $attrs['rel'] = 'nofollow external';
     }
     $out->elementStart('h3');
     $out->element('a', $attrs, $nb->title);
     $out->elementEnd('h3');
     // Replies look like "for:" tags
     $replies = $stored->getReplies();
     $tags = $stored->getTags();
     if (!empty($nb->description)) {
         $out->element('p', array('class' => 'bookmark-description'), $nb->description);
     }
     if (!empty($replies) || !empty($tags)) {
         $out->elementStart('ul', array('class' => 'bookmark-tags'));
         foreach ($replies as $reply) {
             $other = Profile::getKV('id', $reply);
             if (!empty($other)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => $other->profileurl, 'title' => $other->getBestName()), sprintf('for:%s', $other->nickname));
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         foreach ($tags as $tag) {
             $tag = trim($tag);
             if (!empty($tag)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         $out->elementEnd('ul');
     }
 }
 public function onEndProfilePageActionsElements(HTMLOutputter $out, Profile $profile)
 {
     $scoped = Profile::current();
     if (!$scoped instanceof Profile) {
         return true;
     }
     if ($profile->isLocal() && $scoped->mutuallySubscribed($profile)) {
         $out->elementStart('li', 'entity_send-a-message');
         $out->element('a', array('href' => common_local_url('newmessage', array('to' => $profile->id)), 'title' => _('Send a direct message to this user.')), _m('BUTTON', 'Message'));
         $out->elementEnd('li');
     }
     return true;
 }
 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $nb = Bookmark::fromStored($stored);
     // Whether to nofollow
     $attrs = array('href' => $nb->getUrl(), 'class' => 'bookmark-title');
     $nf = common_config('nofollow', 'external');
     if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
         $attrs['rel'] = 'external';
     } else {
         $attrs['rel'] = 'nofollow external';
     }
     $out->elementStart('h3');
     $out->element('a', $attrs, $nb->getTitle());
     $out->elementEnd('h3');
     // Replies look like "for:" tags
     $replies = $stored->getReplies();
     $tags = $stored->getTags();
     if (!empty($nb->description)) {
         $out->element('p', array('class' => 'bookmark-description'), $nb->description);
     }
     if (!empty($replies) || !empty($tags)) {
         $out->elementStart('ul', array('class' => 'bookmark-tags'));
         foreach ($replies as $reply) {
             $other = Profile::getByPK($reply);
             $out->elementStart('li');
             $out->element('a', array('rel' => 'tag', 'href' => $other->getUrl(), 'title' => $other->getBestName()), sprintf('for:%s', $other->getNickname()));
             $out->elementEnd('li');
             $out->text(' ');
         }
         foreach ($tags as $tag) {
             $tag = trim($tag);
             if (!empty($tag)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         $out->elementEnd('ul');
     }
 }
 function showNotice(Notice $notice, HTMLOutputter $out)
 {
     $vid = Video::getByNotice($notice);
     if ($vid) {
         $out->element('video', array('src' => $vid->url, 'width' => '100%', 'controls' => 'controls'));
     }
 }
Exemple #15
0
 /**
  * Build common remote-profile options structure.
  * Currently only adds output for remote profiles, nothing for local users.
  *
  * @param HTMLOutputter $out
  * @param Profile $profile (may also be an ArrayWrapper... sigh)
  */
 protected function showProfileOptions(HTMLOutputter $out, $profile)
 {
     $isRemote = !User::staticGet('id', $profile->id);
     if ($isRemote) {
         $target = common_local_url('remoteprofile', array('id' => $profile->id));
         // TRANS: Label for access to remote profile options.
         $label = _m('Remote profile options...');
         $out->elementStart('div', 'remote-profile-options');
         $out->element('a', array('href' => $target), $label);
         $out->elementEnd('div');
     }
 }
 function showNoticeContent(Notice $notice, HTMLOutputter $out)
 {
     $photo = Photo::getByNotice($notice);
     if ($photo) {
         if ($photo->title) {
             // TODO: ugly. feel like we should have a more abstract way
             // of choosing the h-level.
             $out->element('h3', array(), $title);
         }
         $out->element('img', array('src' => $photo->photo_uri, 'width' => '100%'));
         // TODO: add description
     }
 }
 public function onShowUnsupportedAttachmentRepresentation(HTMLOutputter $out, File $file)
 {
     try {
         $oembed = File_oembed::getByFile($file);
     } catch (NoResultException $e) {
         return true;
     }
     // the 'photo' type is shown through ordinary means, using StartShowAttachmentRepresentation!
     switch ($oembed->type) {
         case 'rich':
         case 'video':
         case 'link':
             if (!empty($oembed->html) && (GNUsocial::isAjax() || common_config('attachments', 'show_html'))) {
                 require_once INSTALLDIR . '/extlib/htmLawed/htmLawed.php';
                 $config = array('safe' => 1, 'elements' => '*+object+embed');
                 $out->raw(htmLawed($oembed->html, $config));
             }
             return false;
             break;
     }
     return true;
 }