Пример #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;
 }
Пример #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');
 }