Example #1
0
 /**
  * @return Feed\Object|Feed\Object[]
  */
 public function get($params = null)
 {
     $this->auth();
     $feeds = [];
     $isSingle = false;
     if (is_numeric($params)) {
         $id = (int) $params;
         $params = [];
         $params['id'] = $id;
         $isSingle = true;
     } else {
         if (is_string($params)) {
             $type = $params;
             $params = [];
             $params['type_id'] = $type;
         }
     }
     if (isset($_GET['page'])) {
         $params['page'] = $_GET['page'];
     }
     if (isset($_GET['limit'])) {
         $params['limit'] = $_GET['limit'];
     }
     $params['is_api'] = true;
     $rows = \Feed_Service_Feed::instance()->get($params);
     // d($rows); exit;
     foreach ($rows as $row) {
         $object = ['id' => (int) $row['feed_id'], 'content' => $row['content'], 'total_likes' => (int) $row['feed_total_like'], 'total_comments' => (int) (isset($row['total_comment']) ? $row['total_comment'] : 0), 'user' => $row];
         if ($row['type_id'] != 'app') {
             $object['custom'] = ['item_id' => $row['item_id'], 'url' => $row['feed_link'], 'external_url' => isset($row['feed_link_actual']) ? $row['feed_link_actual'] : '', 'title' => $row['feed_title'], 'description' => isset($row['feed_content']) ? $row['feed_content'] : null, 'time_stamp' => $row['feed_time_stamp'], 'image' => isset($row['feed_image']) ? $row['feed_image'] : null, 'type' => $row['type_id'], 'privacy' => $row['privacy'], 'likes' => $row['feed_total_like'], 'is_liked' => $row['feed_is_liked'], 'comments' => isset($row['total_comment']) ? $row['total_comment'] : 0];
         }
         $feeds[] = new Feed\Object($object);
     }
     if ($isSingle) {
         if (!isset($feeds[0])) {
             throw new \Exception('Unable to find this feed.');
         }
         $feed = $feeds[0];
         if (!$this->isApi() && $feed instanceof Feed\Object) {
             \Phpfox_Component::setPublicParam('aFeed', ['comment_type_id' => 'app', 'privacy' => $feed->custom->privacy, 'comment_privacy' => $feed->custom->privacy, 'like_type_id' => 'app', 'feed_is_liked' => $feed->custom->is_liked, 'item_id' => $feed->custom->item_id, 'user_id' => $feed->user->id, 'total_comment' => $feed->custom->comments, 'total_like' => $feed->custom->likes, 'feed_link' => $feed->custom->url, 'feed_title' => $feed->custom->title, 'feed_display' => 'view', 'feed_total_like' => $feed->custom->likes, 'report_module' => $feed->custom->type, 'report_phrase' => 'Report', 'time_stamp' => $feed->custom->time_stamp]);
         }
         return $feed;
     }
     return $feeds;
 }
Example #2
0
 /**
  * Set the menu name for the current page we are on.
  *
  * @param string $sMenuName Unique menu name.
  */
 protected function _setMenuName($sMenuName)
 {
     self::$_sMenuName = $sMenuName;
 }
Example #3
0
 private function _loadLikeBlock($iPage)
 {
     $aPage = Phpfox::getService('pages')->getForView($iPage);
     $oAjax = Phpfox_Ajax::instance();
     Phpfox_Template::instance()->assign('aPage', $aPage);
     Phpfox_Component::setPublicParam('aPage', $aPage);
     Phpfox::getBlock('pages.like');
     $oAjax->html('#js_pages_like_join_holder', $oAjax->getContent(false));
 }
Example #4
0
 private function _loadLikeBlock($iPage)
 {
     $aPage = Phpfox::getService('organization')->getForView($iPage);
     $oAjax = Phpfox::getLib('ajax');
     Phpfox::getLib('template')->assign('aPage', $aPage);
     Phpfox_Component::setPublicParam('aPage', $aPage);
     Phpfox::getBlock('organization.like');
     $oAjax->html('#js_organization_like_join_holder', $oAjax->getContent(false));
 }