/**
  * Strategy pattern: Initialize the configuration.
  *
  * Change the script tags that are linked to a file used in the web page
  * according the configuration pararmeters
  *
  * See {@link \Zend_View}
  * See {@link \Zend_View_Helper_HeadScript}
  *
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function init(\Zend_Controller_Request_Abstract $request)
 {
     $this->_headScript = $this->_getView()->headScript();
     foreach ($this->_options as $scriptFileId => $options) {
         if (!isset($options['src'])) {
             require_once 'Exception.php';
             throw new Exception('The definition of a script file element require at least
                         one minimum option parameter:\\"src\\"');
         }
         if (!isset($options['type'])) {
             $type = 'text/javascript';
         } else {
             $type = $options['type'];
         }
         if (isset($options['allowArbitraryAttributes'])) {
             $this->_headScript->setAllowArbitraryAttributes($options['allowArbitraryAttributes']);
         }
         if (!isset($options['attributes'])) {
             $options['attributes'] = array();
         }
         if (!isset($options['placement']) || strcasecmp('APPEND', $options['placement']) == 0) {
             $this->_headScript->appendFile($options['src'], $type, $options['attributes']);
         } else {
             if (strcasecmp('SET', $options['placement']) == 0) {
                 $this->_headScript->setFile($options['src'], $type, $options['attributes']);
             } else {
                 if (strcasecmp('PREPEND', $options['placement']) == 0) {
                     $this->_headScript->prependFile($options['src'], $type, $options['attributes']);
                 } else {
                     $this->_headScript->offsetSetFile(intval($options['placement']), $options['src'], $type, $options['attributes']);
                 }
             }
         }
     }
 }
 /**
  * @group ZF-12287
  */
 public function testConditionalWithAllowArbitraryAttributesDoesNotIncludeConditionalScript()
 {
     $this->helper->setAllowArbitraryAttributes(true);
     $this->helper->appendFile('/js/foo.js', 'text/javascript', array('conditional' => 'lt IE 7'));
     $test = $this->helper->toString();
     $this->assertNotContains('conditional', $test);
 }
Пример #3
0
 public function __construct($application)
 {
     parent::__construct($application);
     $this->initViewHelperPath();
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile(Zend_Registry::get('StaticBaseUrl') . 'application/modules/Activity/externals/scripts/core.js');
 }
Пример #4
0
 public function appendFile($item)
 {
     if (!preg_match('/^http/i', $item)) {
         $item .= '?v=' . $this->_appversion;
     }
     parent::appendFile($item);
 }
 /**
  * @group GH-515
  */
 public function testConditionalScriptNoIE()
 {
     $this->helper->setAllowArbitraryAttributes(true);
     $this->helper->appendFile('/js/foo.js', 'text/javascript', array('conditional' => '!IE'));
     $test = $this->helper->toString();
     $this->assertContains('<!--[if !IE]><!--><', $test);
     $this->assertContains('<!--<![endif]-->', $test);
 }
Пример #6
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynblog/externals/scripts/jquery-1.5.1.min.js');
     $headScript->appendFile('application/modules/Ynblog/externals/scripts/jquery.divslideshow-1.2-min.js');
     // Number of blog display
     if ($this->_getParam('max') != '' && $this->_getParam('max') >= 0) {
         $limitFblog = $this->_getParam('max');
     } else {
         $limitFblog = 6;
     }
     // Get featured blogs
     $btable = Engine_Api::_()->getItemTable('blog');
     $select = $btable->select()->where("search = 1")->where("draft = 0")->where("is_approved = 1")->where("is_featured = 1")->order('RAND()')->limit($limitFblog);
     $this->view->blogs = $btable->fetchAll($select);
     $this->view->limit = $limitFblog;
 }
Пример #7
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynevent/externals/scripts/YneventTabContent.js');
     $params = $this->_getAllParams();
     $tab_past = $tab_week = $tab_month = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_past'])) {
         $tab_past = $params['tab_past'];
     }
     if ($tab_past) {
         $tab_enabled[] = 'past';
     }
     if (isset($params['tab_week'])) {
         $tab_week = $params['tab_week'];
     }
     if ($tab_week) {
         $tab_enabled[] = 'week';
     }
     if (isset($params['tab_month'])) {
         $tab_month = $params['tab_month'];
     }
     if ($tab_month) {
         $tab_enabled[] = 'month';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "ynevent_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "ynevent_grid-view";
             break;
         case 'map':
             $class_mode = "ynevent_map-view";
             break;
         default:
             $class_mode = "ynevent_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     $table = Engine_Api::_()->getItemTable('event');
     $viewer = Engine_Api::_()->user()->getViewer();
     $oldTz = date_default_timezone_get();
     if ($viewer->getIdentity()) {
         date_default_timezone_set($viewer->timezone);
     }
     $date = date('Y-m-d H:i:s');
     date_default_timezone_set($oldTz);
     $time = strtotime($date);
     $sub = $time - time();
     //past event
     $select = $table->select()->where("endtime < FROM_UNIXTIME(?)", time())->order("starttime ASC")->limit($itemCount);
     $this->view->events_pastevent = $events_pastevent = $table->fetchAll($select);
     $week = (int) date('W', strtotime(date('Y-m-d H:i:s')));
     $subyear = 0;
     if ($week == 1) {
         $subyear = 1;
     }
     // last week
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}') - ?", $subyear)->where("WEEK(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = WEEK(date_sub('{$date}', INTERVAL 7 day))")->order("starttime ASC")->limit($itemCount);
     $this->view->events_preweek = $events_preweek = $table->fetchAll($select);
     //last month
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}') - ?", $subyear)->where("MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = MONTH(date_sub('{$date}', INTERVAL 1 MONTH))")->order("starttime ASC")->limit($itemCount);
     $this->view->events_premonth = $events_premonth = $table->fetchAll($select);
     $eventIds = array();
     foreach ($events_pastevent as $e) {
         $eventIdsPast[] = $e->getIdentity();
     }
     foreach ($events_preweek as $e) {
         $eventIdsPreweek[] = $e->getIdentity();
     }
     foreach ($events_premonth as $e) {
         $eventIdsPremonth[] = $e->getIdentity();
     }
     $this->view->eventIdsPast = implode("_", $eventIdsPast);
     $this->view->eventIdsPreweek = implode("_", $eventIdsPreweek);
     $this->view->eventIdsPremonth = implode("_", $eventIdsPremonth);
 }
Пример #8
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynevent/externals/scripts/YneventTabContent.js');
     $params = $this->_getAllParams();
     $tab_popular = $tab_attending = $tab_liked = $tab_rated = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_popular'])) {
         $tab_popular = $params['tab_popular'];
     }
     if ($tab_popular) {
         $tab_enabled[] = 'popular';
     }
     if (isset($params['tab_attending'])) {
         $tab_attending = $params['tab_attending'];
     }
     if ($tab_attending) {
         $tab_enabled[] = 'attending';
     }
     if (isset($params['tab_liked'])) {
         $tab_liked = $params['tab_liked'];
     }
     if ($tab_liked) {
         $tab_enabled[] = 'liked';
     }
     if (isset($params['tab_rated'])) {
         $tab_rated = $params['tab_rated'];
     }
     if ($tab_rated) {
         $tab_enabled[] = 'rated';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "ynevent_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "ynevent_grid-view";
             break;
         case 'map':
             $class_mode = "ynevent_map-view";
             break;
         default:
             $class_mode = "ynevent_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     $table = Engine_Api::_()->getItemTable('event');
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $filter = $request->getParam('filter', 'future');
     if ($filter == 'future') {
         $filter = ">";
     } else {
         $filter = "<";
     }
     //popular event
     $select = $table->select()->where('search = ?', 1)->where("endtime {$filter} FROM_UNIXTIME(?)", time())->order('view_count')->limit($itemCount);
     $this->view->events_popular = $events_popular = $table->fetchAll($select);
     // most attending
     $tableEventName = $table->info('name');
     $select = $table->select()->limit($itemCount);
     $tableMembership = Engine_Api::_()->getDbTable('membership', 'ynevent');
     $tableMembershipName = $tableMembership->info('name');
     $select->setIntegrityCheck(false)->from($tableEventName, array("{$tableEventName}.*", "count({$tableMembershipName}.resource_id)as member_attending"))->join($tableMembershipName, "{$tableMembershipName}.resource_id={$tableEventName}.event_id", '')->where("{$tableMembershipName}.rsvp = ?", 2)->group("{$tableMembershipName}.resource_id")->where("endtime {$filter} FROM_UNIXTIME(?)", time())->order("count({$tableMembershipName}.resource_id) DESC")->limit($itemCount);
     $this->view->events_attending = $events_attending = $table->fetchAll($select);
     //most liked
     $ltable = Engine_Api::_()->getDbtable('likes', 'core');
     $Name = $table->info('name');
     $lName = $ltable->info('name');
     $select = $table->select()->from($Name, "{$Name}.*,count({$lName}.like_id)as liked_count");
     $select->joinLeft($lName, "resource_id = {$Name}.event_id AND resource_type LIKE 'event'", '')->group("{$Name}.event_id")->order("Count({$lName}.like_id) DESC");
     $select->where("search = ?", "1")->where("endtime {$filter} FROM_UNIXTIME(?)", time());
     $events = $table->fetchAll($select);
     $this->view->events_liked = $events_liked = Ynevent_Plugin_Utilities::getListOfEvents($events, $itemCount);
     //most rated
     $select = $table->select();
     $tableEventName = $table->info('name');
     $tableRating = Engine_Api::_()->getDbTable('ratings', 'ynevent');
     $tableRatingName = $tableRating->info('name');
     $select->setIntegrityCheck(false)->from($tableEventName, array("{$tableEventName}.*", "count({$tableRatingName}.event_id)as rating_count"))->join($tableRatingName, "{$tableRatingName}.event_id={$tableEventName}.event_id", '')->where("{$tableEventName}.search = ?", 1)->group("{$tableRatingName}.event_id")->where("endtime {$filter} FROM_UNIXTIME(?)", time())->order("{$tableEventName}.rating DESC");
     $this->view->events_rated = $events_rated = Zend_Paginator::factory($select);
     $eventIdsPopular = $eventIdsAttending = $eventIdsLiked = $eventIdsRated = array();
     foreach ($events_popular as $e) {
         $eventIdsPopular[] = $e->getIdentity();
     }
     foreach ($events_attending as $e) {
         $eventIdsAttending[] = $e->getIdentity();
     }
     foreach ($events_liked as $e) {
         $eventIdsLiked[] = $e->getIdentity();
     }
     foreach ($events_rated as $e) {
         $eventIdsRated[] = $e->getIdentity();
     }
     $this->view->eventIdsPopular = implode("_", $eventIdsPopular);
     $this->view->eventIdsAttending = implode("_", $eventIdsAttending);
     $this->view->eventIdsLiked = implode("_", $eventIdsLiked);
     $this->view->eventIdsRated = implode("_", $eventIdsRated);
 }
Пример #9
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynevent/externals/scripts/YneventTabContent.js');
     $params = $this->_getAllParams();
     $tab_upcoming = $tab_today = $tab_week = $tab_month = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_upcoming'])) {
         $tab_upcoming = $params['tab_upcoming'];
     }
     if ($tab_upcoming) {
         $tab_enabled[] = 'upcoming';
     }
     if (isset($params['tab_today'])) {
         $tab_today = $params['tab_today'];
     }
     if ($tab_today) {
         $tab_enabled[] = 'today';
     }
     if (isset($params['tab_week'])) {
         $tab_week = $params['tab_week'];
     }
     if ($tab_week) {
         $tab_enabled[] = 'week';
     }
     if (isset($params['tab_month'])) {
         $tab_month = $params['tab_month'];
     }
     if ($tab_month) {
         $tab_enabled[] = 'month';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "ynevent_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "ynevent_grid-view";
             break;
         case 'map':
             $class_mode = "ynevent_map-view";
             break;
         default:
             $class_mode = "ynevent_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     $table = Engine_Api::_()->getItemTable('event');
     $tableName = $table->info('name');
     $viewer = Engine_Api::_()->user()->getViewer();
     $oldTz = date_default_timezone_get();
     if ($viewer->getIdentity()) {
         date_default_timezone_set($viewer->timezone);
     }
     $date = date('Y-m-d H:i:s');
     date_default_timezone_set($oldTz);
     $time = strtotime($date);
     $sub = $time - time();
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     //upcoming event
     // membership
     $membershipTb = Engine_Api::_()->getDbtable('membership', 'ynevent');
     $membershipName = $membershipTb->info('name');
     $select = $membershipTb->getMembershipsOfSelect($viewer);
     $select->where("{$tableName}.endtime > FROM_UNIXTIME(?)", $time)->order("{$membershipName}.rsvp DESC")->order("{$tableName}.starttime ASC")->limit($itemCount);
     $events_upcoming = $table->fetchAll($select);
     if (count($events_upcoming) < $itemCount) {
         $select = $table->select();
         $select->where("{$tableName}.endtime > FROM_UNIXTIME(?)", $time)->order("{$tableName}.starttime ASC")->limit($itemCount - count($events_upcoming));
         $otherEvents = $table->fetchAll($select);
         foreach ($otherEvents as $otherEvent) {
             $events_upcoming[] = $otherEvent;
         }
     }
     $this->view->events_upcoming = $events_upcoming;
     // today
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}')")->where("MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = MONTH('{$date}')")->where("DAY(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = DAY('{$date}')")->order("starttime ASC")->limit($itemCount);
     $this->view->events_today = $events_today = $table->fetchAll($select);
     // this week
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}')")->where("WEEK(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = WEEK('{$date}')")->order("starttime ASC")->limit($itemCount);
     $this->view->events_week = $events_week = $table->fetchAll($select);
     //this month
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}')")->where("MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = MONTH('{$date}')")->order("starttime ASC")->limit($itemCount);
     $this->view->events_month = $events_month = $table->fetchAll($select);
     $eventIdsUpcoming = $eventIdsToday = $eventIdsWeek = $eventIdsMonth = array();
     foreach ($events_upcoming as $e) {
         $eventIdsUpcoming[] = $e->getIdentity();
     }
     foreach ($events_today as $e) {
         $eventIdsToday[] = $e->getIdentity();
     }
     foreach ($events_week as $e) {
         $eventIdsWeek[] = $e->getIdentity();
     }
     foreach ($events_month as $e) {
         $eventIdsMonth[] = $e->getIdentity();
     }
     $this->view->eventIdsUpcoming = implode("_", $eventIdsUpcoming);
     $this->view->eventIdsToday = implode("_", $eventIdsToday);
     $this->view->eventIdsWeek = implode("_", $eventIdsWeek);
     $this->view->eventIdsMonth = implode("_", $eventIdsMonth);
 }
Пример #10
0
 protected function _triggerMethodAsset()
 {
     // Get url
     $path = Zend_Controller_Front::getInstance()->getRouter()->assemble(array('controller' => 'utility', 'action' => 'tasks'), 'default', true) . '?notrigger=1' . '&pid=' . $this->_pid . '&mode=' . 'js';
     $url = $path;
     // Add to headScript
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile($url);
 }
Пример #11
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $viewer = Engine_Api::_()->user()->getViewer();
     $this->view->viewer_id = $viewer_id = $viewer->getIdentity();
     $subject = null;
     if (Engine_Api::_()->core()->hasSubject()) {
         // Get subject
         $subject = Engine_Api::_()->core()->getSubject();
         if (!$subject->authorization()->isAllowed($viewer, 'view')) {
             return $this->setNoRender();
         }
     }
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $actionTable = Engine_Api::_()->getDbtable('actions', 'ynfeed');
     $this->view->friendUsers = $friendUsers = Engine_Api::_()->ynfeed()->getViewerFriends($viewer);
     // Get some settings from Ynfeed settings
     $settings = Engine_Api::_()->getApi('settings', 'core');
     $this->view->autoUpdate = $settings->getSetting('ynfeed.autoupdate', true);
     $liveUpdateValue = $settings->getSetting('ynfeed.liveupdatevalue', 2);
     $liveUpdatePeriod = $settings->getSetting('ynfeed.liveupdateperiod', 'm');
     $updateSettings = 0;
     if ($liveUpdateValue) {
         switch ($liveUpdatePeriod) {
             case 'm':
                 $updateSettings = $liveUpdateValue * 60000;
                 break;
             case 'h':
                 $updateSettings = $liveUpdateValue * 60 * 60000;
                 break;
         }
     }
     $this->view->updateSettings = $updateSettings;
     $this->view->autoLoadMore = $autoLoadMore = $settings->getSetting('ynfeed.autoloadfeed', true);
     // Get some options
     $countAutoload = $request->getParam('countAutoload', 0);
     $this->view->countAutoload = $countAutoload + 1;
     $this->view->feedOnly = $feedOnly = $request->getParam('feedOnly', false);
     $this->view->length = $length = $request->getParam('limit', $settings->getSetting('activity.length', 15));
     if ($autoLoadMore) {
         $this->view->max_times = $settings->getSetting('ynfeed.length', 5);
     }
     $this->view->itemActionLimit = $itemActionLimit = $settings->getSetting('activity.userlength', 5);
     $this->view->viewAllLikes = $request->getParam('viewAllLikes', $request->getParam('show_likes', false));
     $this->view->viewAllComments = $request->getParam('viewAllComments', $request->getParam('show_comments', false));
     $this->view->getUpdate = $request->getParam('getUpdate');
     $this->view->checkUpdate = $request->getParam('checkUpdate');
     $this->view->action_id = $action_id = (int) $request->getParam('action_id');
     $this->view->post_failed = (int) $request->getParam('pf');
     // Open comment hidden
     $this->view->openHide = $openHide = $request->getParam('openHide', 0);
     if ($feedOnly) {
         $this->getElement()->removeDecorator('Title');
         $this->getElement()->removeDecorator('Container');
     }
     if ($length > 50) {
         $this->view->length = $length = 50;
     }
     $default_firstid = null;
     $listTypeFilter = array();
     $this->view->enableContentTabs = true;
     $this->view->actionFilter = $actionFilter = $request->getParam('actionFilter', 'all');
     $this->view->isFromTab = $request->getParam('isFromTab', false);
     $this->view->filterValue = $filterValue = $request->getParam('filterValue', '');
     if (!$feedOnly && empty($subject)) {
         // Start filter tabs
         $this->view->contentTabMax = $settings->getSetting('ynfeed.defaultvisible', 7);
         $enableContentTabs = 0;
         $contentTabs = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContentList(array('show' => 1, 'content_tab' => 1));
         $defaultcontentTab = $request->getParam('actionFilter');
         $i = 0;
         $friendListIcon = $networkIcon = $customIcon = "";
         $friendContent = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContents(array('filter_type' => 'member_list'));
         if ($friendContent) {
             $friendListIcon = $friendContent->getPhotoUrl();
         }
         $networkContent = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContents(array('filter_type' => 'only_network'));
         if ($networkContent) {
             $networkIcon = $networkContent->getPhotoUrl();
         }
         $customContent = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContents(array('filter_type' => 'custom_list'));
         if ($customContent) {
             $customIcon = $customContent->getPhotoUrl();
         }
         foreach ($contentTabs as $value) {
             if (empty($viewer_id) && in_array($value->filter_type, array('membership', 'user_saved', 'user_follow'))) {
                 continue;
             }
             $filterTabs[$i]['filter_type'] = $value->filter_type;
             $filterTabs[$i]['tab_title'] = $this->view->translate($value->resource_title);
             $filterTabs[$i]['list_id'] = $value->content_id;
             $icon_url = $value->getPhotoUrl();
             $filterTabs[$i]['icon_url'] = $icon_url;
             $i++;
             if (empty($defaultcontentTab)) {
                 $defaultcontentTab = $value->filter_type;
             }
         }
         if ($defaultcontentTab) {
             $this->view->actionFilter = $defaultcontentTab;
             if ($defaultcontentTab != 'all') {
                 $default_firstid = $actionTable->select()->from($actionTable, 'action_id')->order('action_id DESC')->limit(1)->query()->fetchColumn();
             }
         }
         // Filter by networks
         $enableNetworkListFilter = $settings->getSetting('ynfeed.networklist.filtering', 0);
         if ($viewer_id && $enableNetworkListFilter) {
             $networkLists = Engine_Api::_()->ynfeed()->getNetworks($enableNetworkListFilter, $viewer);
             $countNetworkLists = count($networkLists);
             if ($countNetworkLists) {
                 if (count($filterTabs) > $this->view->contentTabMax) {
                     $filterTabs[$i]['filter_type'] = "separator";
                 }
                 $i++;
                 foreach ($networkLists as $value) {
                     $filterTabs[$i]['filter_type'] = "network_list";
                     $filterTabs[$i]['tab_title'] = $value->getTitle();
                     $filterTabs[$i]['list_id'] = $value->getIdentity();
                     $filterTabs[$i]['icon_url'] = $networkIcon;
                     $i++;
                 }
             }
         }
         // Filter by friend list
         $userFriendListEnable = $settings->getSetting('user.friends.lists');
         $enableFriendListFilter = $userFriendListEnable && $settings->getSetting('ynfeed.friendlist.filtering', 1);
         if ($enableFriendListFilter) {
             $listTable = Engine_Api::_()->getItemTable('user_list');
             $lists = $listTable->fetchAll($listTable->select()->where('owner_id = ?', $viewer->getIdentity()));
             $countlistsLists = count($lists);
             if ($countlistsLists) {
                 if (count($filterTabs) > $this->view->contentTabMax) {
                     $filterTabs[$i]['filter_type'] = "separator";
                 }
                 $i++;
                 foreach ($lists as $value) {
                     $filterTabs[$i]['filter_type'] = "member_list";
                     $filterTabs[$i]['tab_title'] = $value->title;
                     $filterTabs[$i]['list_id'] = $value->list_id;
                     $filterTabs[$i]['icon_url'] = $friendListIcon;
                     $i++;
                 }
             }
         }
         // Filter by custom list
         $this->view->canCreateCustomList = 0;
         if ($viewer_id) {
             $this->view->canCreateCustomList = $settings->getSetting('ynfeed.customlist.filtering', 1);
             $customTypeLists = Engine_Api::_()->getDbtable('customtypes', 'ynfeed')->getCustomTypeList(array('enabled' => 1));
             $count = count($customTypeLists);
             if (empty($count)) {
                 $this->view->canCreateCustomList = 0;
             }
             if ($this->view->canCreateCustomList) {
                 $customLists = Engine_Api::_()->getDbtable('lists', 'ynfeed')->getMemberOfList($viewer, 'default');
                 $countCustomLists = count($customLists);
                 if ($countCustomLists) {
                     if (count($filterTabs) > $this->view->contentTabMax) {
                         $filterTabs[$i]['filter_type'] = "separator";
                         $i++;
                     }
                     foreach ($customLists as $value) {
                         $filterTabs[$i]['filter_type'] = "custom_list";
                         $filterTabs[$i]['tab_title'] = $value->title;
                         $filterTabs[$i]['list_id'] = $value->list_id;
                         $filterTabs[$i]['icon_url'] = $customIcon;
                         $i++;
                     }
                 }
             }
         }
         $this->view->filterTabs = $filterTabs;
         // End filter tabs
     }
     $actionTypeFilters = array();
     if ($actionFilter && !in_array($actionFilter, array('membership', 'owner', 'all', 'network_list', 'member_list', 'custom_list'))) {
         $actionTypesTable = Engine_Api::_()->getDbtable('actionTypes', 'ynfeed');
         $groupedActionTypes = $actionTypesTable->getEnabledGroupedActionTypes($actionFilter);
         if (isset($groupedActionTypes[$actionFilter])) {
             $actionTypeFilters = $groupedActionTypes[$actionFilter];
         }
     } elseif (in_array($actionFilter, array('member_list', 'custom_list')) && $filterValue != null) {
         $listTypeFilter = Engine_Api::_()->ynfeed()->getListBaseContent($actionFilter, array('filterValue' => $filterValue));
     } else {
         if ($actionFilter == 'network_list' && $filterValue != null) {
             $listTypeFilter = array($filterValue);
         }
     }
     // Get config options for activity
     $config = array('action_id' => $action_id, 'max_id' => (int) $request->getParam('maxid'), 'min_id' => (int) $request->getParam('minid'), 'limit' => (int) $length, 'showTypes' => $actionTypeFilters, 'actionFilter' => $actionFilter, 'filterValue' => $filterValue, 'listTypeFilter' => $listTypeFilter);
     // Pre-process feed items
     $selectCount = 0;
     $nextid = null;
     $firstid = null;
     $tmpConfig = $config;
     $activity = array();
     $endOfFeed = false;
     $friendRequests = array();
     $itemActionCounts = array();
     $enabledModules = Engine_Api::_()->getDbtable('modules', 'core')->getEnabledModuleNames();
     $hideItems = array();
     if ($viewer->getIdentity()) {
         $hideItems = Engine_Api::_()->getDbtable('hide', 'ynfeed')->getHideItemByMember($viewer);
     }
     if ($default_firstid) {
         $firstid = $default_firstid;
     }
     $tmpConfig['showTypes'] = array('advgroup_video_create');
     do {
         // Get current batch
         $actions = null;
         // Where the Activity Feed is Fetched
         if (!empty($subject)) {
             $actions = $actionTable->getActivityAbout($subject, $viewer, $tmpConfig);
         } else {
             $actions = $actionTable->getActivity($viewer, $tmpConfig);
         }
         $selectCount++;
         // Are we at the end?
         if (count($actions) < $length || count($actions) <= 0) {
             $endOfFeed = true;
         }
         // Pre-process
         if (count($actions) > 0) {
             foreach ($actions as $action) {
                 // get next id
                 if (null === $nextid || $action->action_id <= $nextid) {
                     $nextid = $action->action_id - 1;
                 }
                 // get first id
                 if (null === $firstid || $action->action_id > $firstid) {
                     $firstid = $action->action_id;
                 }
                 // skip disabled actions
                 if (!$action->getTypeInfo() || !@$action->getTypeInfo()->enabled) {
                     continue;
                 }
                 // skip items with missing items
                 if (@$action->subject_type == 'ynbusinesspages_business' && !Engine_Api::_()->hasModuleBootstrap('ynbusinesspages')) {
                     continue;
                 }
                 if (!@$action->getSubject() || !@$action->getSubject()->getIdentity()) {
                     continue;
                 }
                 if (!@$action->getObject() || !@$action->getObject()->getIdentity()) {
                     continue;
                 }
                 // skip the hide actions and content
                 if (!empty($hideItems) && !$action_id) {
                     if (isset($hideItems[$action->getType()]) && in_array($action->getIdentity(), $hideItems[$action->getType()])) {
                         continue;
                     }
                     if ($action->getSubject()->getType() == 'user' && isset($hideItems[$action->getSubject()->getType()]) && in_array($action->getSubject()->getIdentity(), $hideItems[$action->getSubject()->getType()])) {
                         continue;
                     }
                     if ($action->getSubject()->getType() == 'ynbusinesspages_business' && isset($hideItems[$action->getSubject()->getType()]) && in_array($action->getSubject()->getIdentity(), $hideItems[$action->getSubject()->getType()])) {
                         continue;
                     }
                 }
                 // track/remove users who do too much (but only in the main feed)
                 if (empty($subject)) {
                     $actionSubject = $action->getSubject();
                     $actionObject = $action->getObject();
                     if (!isset($itemActionCounts[$actionSubject->getGuid()])) {
                         $itemActionCounts[$actionSubject->getGuid()] = 1;
                     } else {
                         if ($itemActionCounts[$actionSubject->getGuid()] >= $itemActionLimit) {
                             continue;
                         } else {
                             $itemActionCounts[$actionSubject->getGuid()]++;
                         }
                     }
                 }
                 // remove duplicate friend requests
                 if ($action->type == 'friends') {
                     $id = $action->subject_id . '_' . $action->object_id;
                     $rev_id = $action->object_id . '_' . $action->subject_id;
                     if (in_array($id, $friendRequests) || in_array($rev_id, $friendRequests)) {
                         continue;
                     } else {
                         $friendRequests[] = $id;
                         $friendRequests[] = $rev_id;
                     }
                 }
                 // remove items with disabled module attachments
                 try {
                     $attachments = $action->getAttachments();
                 } catch (Exception $e) {
                     // if a module is disabled, getAttachments() will throw an Engine_Api_Exception; catch and continue
                     continue;
                 }
                 // add to list
                 if (count($activity) < $length) {
                     $activity[] = $action;
                     if (count($activity) == $length) {
                         $actions = array();
                     }
                 }
             }
         }
         // Set next tmp max_id
         if ($nextid) {
             $tmpConfig['max_id'] = $nextid;
         }
         if (!empty($tmpConfig['action_id'])) {
             $actions = array();
         }
     } while (count($activity) < $length && $selectCount <= 3 && !$endOfFeed);
     if (count($activity) == 0) {
         $this->view->endOfFeed = true;
         $this->view->noFeed = true;
     } else {
         $this->view->noFeed = false;
     }
     $this->view->activity = $activity;
     $this->view->activityCount = count($activity);
     $this->view->nextid = $nextid;
     $this->view->firstid = $firstid;
     $this->view->endOfFeed = $endOfFeed;
     // Get some other info
     if (!empty($subject)) {
         $this->view->subjectGuid = $subject->getGuid(false);
     }
     $this->view->enableComposer = false;
     if ($viewer->getIdentity()) {
         if (!$subject || $subject instanceof Core_Model_Item_Abstract && $subject->isSelf($viewer)) {
             if (Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'user', 'status')) {
                 $this->view->enableComposer = true;
             }
         } else {
             if ($subject) {
                 if (Engine_Api::_()->authorization()->isAllowed($subject, $viewer, 'comment')) {
                     $this->view->enableComposer = true;
                 }
             }
         }
     }
     $this->view->enableComposer = false;
     // Assign the composing values
     $composePartials = array();
     foreach (Zend_Registry::get('Engine_Manifest') as $data) {
         if (empty($data['composer'])) {
             continue;
         }
         foreach ($data['composer'] as $type => $config) {
             if (!empty($config['auth']) && !Engine_Api::_()->authorization()->isAllowed($config['auth'][0], null, $config['auth'][1])) {
                 continue;
             }
             $composePartials[] = $config['script'];
         }
     }
     $this->view->composePartials = $composePartials;
     // Add javascript
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/core.js');
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/yncomposer.js');
     //update to support Video 487
     $headScript->appendFile('externals/mdetect/mdetect' . (APPLICATION_ENV != 'development' ? '.min' : '') . '.js');
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynfeed.js');
     if ($viewer->getIdentity()) {
         // Support tags
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/yntag.js');
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynaddfriend.js');
         $this->view->hasTag = true;
         // Checkin JS
         $headScript->appendFile('//maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&libraries=places');
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/yncheckin.js');
     }
     // Auto scroll
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/scrollspy.1.2.js');
     if ($viewer && ($subject && $viewer->isSelf($subject) || !$subject || $subject && in_array($subject->getType(), array('event', 'group', 'ynbusinesspages_business')))) {
         // Add privacy
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynaddprivacies.js');
         $this->view->hasPrivacy = true;
     }
     if (Engine_Api::_()->hasModuleBootstrap('ynbusinesspages')) {
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynaddbusiness.js');
     }
     // Form token
     $session = new Zend_Session_Namespace('ActivityFormToken');
     if (empty($session->token)) {
         $this->view->formToken = $session->token = md5(time() . $viewer->getIdentity() . get_class($this));
     } else {
         $this->view->formToken = $session->token;
     }
     //Fix for Vincent
     $actionTable = Engine_Api::_()->getDbtable('actions', 'ynfeed');
     $Name = $actionTable->info('name');
     $select = $actionTable->select()->from($Name, array('action_id'))->order('action_id DESC')->limit(1);
     $result = $actionTable->fetchRow($select);
     $this->view->last_id_pva = $result->action_id;
     $this->view->firstid = $result->action_id;
 }
Пример #12
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Advgroup/externals/scripts/AdvgroupTabContent.js');
     $params = $this->_getAllParams();
     $tab_recent = $tab_popular = $tab_active = $tab_directory = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_popular'])) {
         $tab_popular = $params['tab_popular'];
     }
     if ($tab_popular) {
         $tab_enabled[] = 'popular';
     }
     if (isset($params['tab_recent'])) {
         $tab_recent = $params['tab_recent'];
     }
     if ($tab_recent) {
         $tab_enabled[] = 'recent';
     }
     if (isset($params['tab_active'])) {
         $tab_active = $params['tab_active'];
     }
     if ($tab_active) {
         $tab_enabled[] = 'active';
     }
     if (isset($params['tab_directory'])) {
         $tab_directory = $params['tab_directory'];
     }
     if ($tab_directory) {
         $tab_enabled[] = 'directory';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "advgroup_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "advgroup_grid-view";
             break;
         case 'map':
             $class_mode = "advgroup_map-view";
             break;
         default:
             $class_mode = "advgroup_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     $table = Engine_Api::_()->getItemTable('group');
     $request = Zend_Controller_Front::getInstance()->getRequest();
     // recent groups
     $count = $this->_getParam('itemCountPerPage');
     if (!is_numeric($count) | $count <= 0) {
         $count = 6;
     }
     $recentType = $this->_getParam('recentType', 'creation');
     if (!in_array($recentType, array('creation', 'modified'))) {
         $recentType = 'creation';
     }
     $this->view->recentType = $recentType;
     $this->view->recentCol = $recentCol = $recentType . '_date';
     // Get paginator
     $table = Engine_Api::_()->getItemTable('group');
     $select = $table->select()->where('search = ?', 1)->where("is_subgroup = ?", 0)->limit($count);
     if ($recentType == 'creation') {
         // using primary should be much faster, so use that for creation
         $select->order('group_id DESC');
     } else {
         $select->order($recentCol . ' DESC');
     }
     $this->view->recentgroups = $groups = $table->fetchAll($select);
     $this->view->limit = $count;
     // Hide if nothing to show
     if (count($groups) <= 0) {
         //return $this->setNoRender();
     }
     //most popular groups
     $count = $this->_getParam('itemCountPerPage');
     if (!is_numeric($count) | $count <= 0) {
         $count = 6;
     }
     $popularType = $this->_getParam('popularType', 'member');
     if (!in_array($popularType, array('view', 'member'))) {
         $popularType = 'member';
     }
     $this->view->popularType = $popularType;
     $this->view->popularCol = $popularCol = $popularType . '_count';
     // Get paginator
     $table = Engine_Api::_()->getItemTable('group');
     $select = $table->select()->where('search = ?', 1)->where("is_subgroup = ?", 0)->order($popularCol . ' DESC')->limit($count);
     $this->view->populargroups = $groups = $table->fetchAll($select);
     $this->view->limit = $count;
     // Hide if nothing to show
     if (count($groups) <= 0) {
         //return $this->setNoRender();
     }
     //most active group
     $count = $this->_getParam('itemCountPerPage');
     if (!is_numeric($count) | $count <= 0) {
         $count = 6;
     }
     $time = $this->_getParam('time', 1);
     if (!in_array($time, array(1, 2, 3))) {
         $time = 1;
     }
     $date = date('Y-m-d H:i:s');
     switch ($time) {
         case 1:
             $newdate = strtotime('-30 day', strtotime($date));
             break;
         case 2:
             $newdate = strtotime('-60 day', strtotime($date));
             break;
         case 3:
             $newdate = strtotime('-90 day', strtotime($date));
     }
     $newdate = date('Y-m-d H:i:s', $newdate);
     $topicTable = Engine_Api::_()->getItemTable('advgroup_topic');
     $topicName = $topicTable->info('name');
     $groupTable = Engine_Api::_()->getItemTable('group');
     $groupName = $groupTable->info('name');
     $select = $groupTable->select()->from($groupName, array("{$groupName}.*", "COUNT('topic_id') AS topic_count"))->setIntegrityCheck(false)->joinRight($topicName, "{$topicName}.group_id = {$groupName}.group_id", "{$topicName}.topic_id")->where("{$groupName}.search = ?", 1)->where("{$groupName}.is_subgroup = ?", 0)->where("{$topicName}.creation_date > ?", $newdate)->group("{$groupName}.group_id")->order("COUNT('topic_id') DESC")->limit($count);
     $this->view->activegroups = $groups = $groupTable->fetchAll($select);
     $this->view->limit = $count;
     if (count($groups) <= 0) {
         //return $this->setNoRender();
     }
     //group directory
     $request = Zend_Controller_Front::getInstance()->getRequest();
     // clear title of widget
     if ($request->isPost()) {
         $this->getElement()->setTitle('');
         $element = $this->getElement();
     }
     $table = Engine_Api::_()->getItemTable('group');
     $select = $table->select()->where('search = ?', 1)->where('is_subgroup = ?', 0)->order('title ASC');
     $this->view->directory = $paginator = Zend_Paginator::factory($select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 12));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     if (count($paginator) <= 0) {
         //return $this->setNoRender();
     }
 }