Exemple #1
0
 /**
  * Returns the rest resource of the stream regarding a stream a context-id and the parameters
  * stream-time, limit and offset (all in $this).
  *
  * @param BlubberStream $stream : the stream
  * @param $parameter : an array of context-parameter i.e. array('user_id' => $user_id)
  *
  * @return Array('collection' => array(...), 'pagination' => array())
  */
 private function getStreamBlubberRestResource($stream, $parameter)
 {
     $total = $stream->fetchNumberOfThreads();
     $threads = $stream->fetchThreads((int) $this->offset, (int) $this->limit ?: null, $this->stream_time ?: null);
     $json = array();
     foreach ($threads as $thread) {
         $url = $this->urlf('/blubber/posting/%s', array($thread->getId()));
         $json[$url] = $this->blubberPostingtoJSON($thread);
     }
     $this->etag(md5(serialize($json)));
     return $this->paginated($json, $total, $parameter);
 }
Exemple #2
0
 public function get_streams_threadnumber_action()
 {
     $stream = new BlubberStream();
     //Pool-rules
     $stream['pool_courses'] = Request::get("pool_courses_check") ? in_array("all", Request::getArray("pool_courses")) ? array("all") : Request::getArray("pool_courses") : null;
     $stream['pool_groups'] = Request::get("pool_groups_check") ? in_array("all", Request::getArray("pool_groups")) ? array("all") : Request::getArray("pool_groups") : null;
     $stream['pool_hashtags'] = Request::get("pool_hashtags_check") ? preg_split("/\\s+/", Request::get("pool_hashtags"), null, PREG_SPLIT_NO_EMPTY) : null;
     if (is_array($stream['pool_hashtags'])) {
         $stream['pool_hashtags'] = array_map(function ($tag) {
             while ($tag[0] === "#") {
                 $tag = substr($tag, 1);
             }
             return $tag;
         }, $stream['pool_hashtags']);
     }
     //Filter-rules
     $stream['filter_type'] = Request::get("filter_type_check") ? Request::getArray("filter_type") : null;
     $stream['filter_courses'] = Request::get("filter_courses_check") ? in_array("all", Request::getArray("filter_courses")) ? array("all") : Request::getArray("filter_courses") : null;
     $stream['filter_groups'] = Request::get("filter_groups_check") ? in_array("all", Request::getArray("filter_groups")) ? array("all") : Request::getArray("filter_groups") : null;
     $stream['filter_hashtags'] = Request::get("filter_hashtags_check") ? preg_split("/\\s+/", Request::get("filter_hashtags"), null, PREG_SPLIT_NO_EMPTY) : null;
     if (is_array($stream['filter_hashtags'])) {
         $stream['filter_hashtags'] = array_map(function ($tag) {
             while ($tag[0] === "#") {
                 $tag = substr($tag, 1);
             }
             return $tag;
         }, $stream['filter_hashtags']);
     }
     $stream['filter_nohashtags'] = Request::get("filter_nohashtags_check") ? preg_split("/\\s+/", Request::get("filter_nohashtags"), null, PREG_SPLIT_NO_EMPTY) : null;
     if (is_array($stream['filter_nohashtags'])) {
         $stream['filter_nohashtags'] = array_map(function ($tag) {
             while ($tag[0] === "#") {
                 $tag = substr($tag, 1);
             }
             return $tag;
         }, $stream['filter_nohashtags']);
     }
     $this->render_text($stream->fetchNumberOfThreads());
 }