Beispiel #1
0
 /**
  * Processes mentions in a stream object
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function formatMentions(SocialStreamItem &$stream)
 {
     // Get the current view
     $view = JRequest::getCmd('view', '');
     // Get the stream's content
     $content = $stream->content;
     // Get tags for the stream
     $tags = isset($stream->tags) ? $stream->tags : array();
     // If there is no tags, just skip this and escape the content
     if (!$tags) {
         return FD::string()->escape($content);
     }
     // We need to store the changes in an array and replace it accordingly based on the counter.
     $items = array();
     // We need to merge the mentions and hashtags since we are based on the offset.
     $i = 0;
     foreach ($tags as $tag) {
         if ($tag->type == 'user') {
             $replace = '<a href="' . $tag->user->getPermalink() . '" data-popbox="module://easysocial/profile/popbox" data-popbox-position="top-left" data-user-id="' . $tag->user->id . '" class="mentions-user">' . $tag->user->getName() . '</a>';
         }
         if ($tag->type == 'hashtag') {
             // $alias = JFilterOutput::stringURLSafe($tag->title);
             $alias = $tag->title;
             $url = '';
             if ($view == 'groups') {
                 $clusterReg = FD::registry($stream->params);
                 $object = $clusterReg->get($stream->cluster_type);
                 switch ($stream->cluster_type) {
                     case SOCIAL_TYPE_GROUP:
                         // for now we assume all is group type.
                         $group = new SocialGroup();
                         $group->bind($object);
                         $url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'tag' => $alias));
                         break;
                     case SOCIAL_TYPE_EVENT:
                         $event = new SocialEvent();
                         $event->bind($object);
                         $url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'tag' => $alias));
                         break;
                     default:
                         FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias));
                         break;
                 }
             } else {
                 $url = FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias));
             }
             $replace = '<a href="' . $url . '" class="mentions-hashtag">#' . $tag->title . '</a>';
         }
         $links[$i] = $replace;
         $replace = '[si:mentions]' . $i . '[/si:mentions]';
         $content = JString::substr_replace($content, $replace, $tag->offset, $tag->length);
         $i++;
     }
     // Once we have the content, escape it
     $content = FD::string()->escape($content);
     if ($links) {
         for ($x = 0; $x < count($links); $x++) {
             $content = str_ireplace('[si:mentions]' . $x . '[/si:mentions]', $links[$x], $content);
         }
     }
     return $content;
 }
Beispiel #2
0
 public function prepareCreateMilestoneStream(SocialStreamItem $item, $includePrivacy = true)
 {
     $params = FD::registry($item->params);
     $milestone = FD::table('Milestone');
     $milestone->bind($params->get('milestone'));
     // Get the group data
     FD::load('group');
     $group = new SocialGroup();
     $group->bind($params->get('group'));
     // Get the actor
     $actor = $item->actor;
     // We need to get the task app for the group
     $app = Foundry::table('App');
     $app->load(array('element' => 'tasks', 'group' => 'group'));
     $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id));
     $this->set('permalink', $permalink);
     $this->set('milestone', $milestone);
     $this->set('actor', $actor);
     $this->set('group', $group);
     $item->title = parent::display('streams/tasks/create.milestone.title');
     $item->content = parent::display('streams/tasks/create.milestone.content');
 }
Beispiel #3
0
 private function prepareCreateStream(SocialStreamItem &$item)
 {
     $groupId = $item->contextId;
     $params = FD::registry($item->params);
     $obj = $params->get('group');
     $group = new SocialGroup();
     $group->bind($obj);
     if (!$group) {
         return;
     }
     // We don't want to display groups that are invitation only.
     if ($group->type == SOCIAL_GROUPS_INVITE_TYPE) {
         return;
     }
     $actor = $item->actor;
     $this->set('group', $group);
     $this->set('actor', $actor);
     $item->title = parent::display('streams/create.title');
     $item->content = parent::display('streams/create.content');
     $item->opengraph->addDescription(JText::sprintf('APP_GROUP_GROUPS_STREAM_CREATED_GROUP', $actor->getName(), $group->getName()));
 }
Beispiel #4
0
 /**
  * Prepares the upload avatar stream for a group
  *
  * @since	1.2
  * @access	public
  * @param	SocialStream
  * @return
  */
 public function prepareGroupUploadAvatarStream(&$item, $privacy, $includePrivacy = true)
 {
     $element = $item->context;
     $uid = $item->contextId;
     // Load the photo
     $photo = $this->getPhotoFromParams($item);
     // Get the data of the group
     $registry = Foundry::registry($item->params);
     $group = new SocialGroup();
     $group->bind($registry->get($item->cluster_type));
     $this->set('group', $group);
     $this->set('photo', $photo);
     $this->set('actor', $item->actor);
     $item->title = parent::display('streams/group/upload.avatar.title');
     $item->content = parent::display('streams/group/upload.avatar.content');
     if ($includePrivacy) {
         $item->privacy = $privacy->form($uid, $element, $item->actor->id, 'core.view', false, $item->uid);
     }
 }