コード例 #1
0
 /**
  * Suggest a list of friend names for a user.
  *
  * @since	1.0
  * @access	public
  * @param	null
  *
  */
 public function filter()
 {
     // Check for valid tokens.
     FD::checkToken();
     // Check for valid user.
     FD::requireLogin();
     // Load friends model.
     $model = FD::model('Followers');
     $limit = FD::themes()->getConfig()->get('followersLimit', 20);
     // Load the view.
     $view = $this->getCurrentView();
     // Get the filter types.
     $type = JRequest::getVar('type');
     // Get the user id that we should load for.
     $userId = JRequest::getInt('id');
     if (!$userId) {
         $userId = null;
     }
     // Try to load the target user.
     $user = FD::user($userId);
     $users = array();
     if ($type == 'followers') {
         $users = $model->getFollowers($userId, array('limit' => $limit));
     }
     if ($type == 'following') {
         $users = $model->getFollowing($userId, array('limit' => $limit));
     }
     if ($type == 'suggest') {
         $users = $model->getSuggestions($user->id);
     }
     $pagination = $model->getPagination();
     // Define those query strings here
     $pagination->setVar('Itemid', FRoute::getItemId('followers'));
     $pagination->setVar('view', 'followers');
     $pagination->setVar('filter', $type);
     if (FD::user()->id != $userId) {
         $pagination->setVar('userid', $user->getAlias());
     }
     return $view->call(__FUNCTION__, $type, $users, $userId, $pagination);
 }
コード例 #2
0
ファイル: users.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Retrieves the list of users on the site.
  *
  * @since	1.0
  * @access	public
  */
 public function getUsers()
 {
     // Check for request forgeries
     FD::checkToken();
     // Get the current filter
     $filter = $this->input->get('filter', 'all', 'word');
     // Get the current sorting
     $sort = $this->input->get('sort', $this->config->get('users.listings.sorting'), 'word');
     $isSort = $this->input->get('isSort', false, 'bool');
     $showPagination = $this->input->get('showpagination', 0, 'default');
     $model = FD::model('Users');
     $options = array('exclusion' => $this->my->id);
     if ($sort == 'alphabetical') {
         $nameField = $this->config->get('users.displayName') == 'username' ? 'a.username' : 'a.name';
         $options['ordering'] = $nameField;
         $options['direction'] = 'ASC';
     } elseif ($sort == 'latest') {
         $options['ordering'] = 'a.id';
         $options['direction'] = 'DESC';
     } elseif ($sort == 'lastlogin') {
         $options['ordering'] = 'a.lastvisitDate';
         $options['direction'] = 'DESC';
     }
     if ($filter == 'online') {
         $options['login'] = true;
     }
     if ($filter == 'photos') {
         $options['picture'] = true;
     }
     // setup the limit
     $limit = FD::themes()->getConfig()->get('userslimit');
     $options['limit'] = $limit;
     // Determine if we should display admins
     $admin = $this->config->get('users.listings.admin') ? true : false;
     $options['includeAdmin'] = $admin;
     // we only want published user.
     $options['published'] = 1;
     // exclude users who blocked the current logged in user.
     $options['excludeblocked'] = 1;
     $result = $model->getUsers($options);
     $pagination = null;
     if ($showPagination) {
         $pagination = $model->getPagination();
         // Define those query strings here
         $pagination->setVar('Itemid', FRoute::getItemId('users'));
         $pagination->setVar('view', 'users');
         $pagination->setVar('filter', $filter);
         $pagination->setVar('sort', $sort);
     }
     $users = array();
     // preload users.
     $arrIds = array();
     foreach ($result as $obj) {
         $arrIds[] = FD::user($obj->id);
     }
     if ($arrIds) {
         FD::user($arrIds);
     }
     foreach ($result as $obj) {
         $users[] = FD::user($obj->id);
     }
     return $this->view->call(__FUNCTION__, $users, $isSort, $pagination);
 }
コード例 #3
0
ファイル: default.php プロジェクト: BetterBetterBetter/B3App
			<?php 
if ($search) {
    ?>
			<div class="fd-navbar-search pull-right" data-nav-search>
				<form action="<?php 
    echo JRoute::_('index.php');
    ?>
" method="post">
					<i class="ies-search"></i>
					<input type="text" name="q" class="search-query" autocomplete="off" data-nav-search-input placeholder="<?php 
    echo JText::_('COM_EASYSOCIAL_TOOLBAR_SEARCH', true);
    ?>
" />

					<?php 
    echo $this->html('form.itemid', FRoute::getItemId('search'));
    ?>
					<input type="hidden" name="view" value="search" />
					<input type="hidden" name="option" value="com_easysocial" />
				</form>
			</div>
			<?php 
}
?>

			<ul class="fd-nav pull-right">
				<?php 
if ($this->my->guest && $login) {
    ?>
				<li class="dropdown_">
					<?php 
コード例 #4
0
 /**
  * Suggest a list of friend names for a user.
  *
  * @since	1.0
  * @access	public
  * @param	null
  *
  */
 public function filter()
 {
     // Check for valid tokens.
     FD::checkToken();
     // Check for valid user.
     FD::requireLogin();
     // Load friends model.
     $model = FD::model('Friends');
     // Load the view.
     $view = $this->getCurrentView();
     // Get the filter types.
     $type = $this->input->get('filter', 'all', 'cmd');
     $userId = $this->input->get('userid', null, 'int');
     $user = FD::user($userId);
     $my = FD::user();
     $friends = array();
     $limit = FD::themes()->getConfig()->get('friendslimit', 20);
     $options = array('limit' => $limit);
     $userAlias = $user->getAlias();
     if ($type == 'pending') {
         $options['state'] = SOCIAL_FRIENDS_STATE_PENDING;
         $friends = $model->getFriends($user->id, $options);
     }
     if ($type == 'all') {
         $options['state'] = SOCIAL_FRIENDS_STATE_FRIENDS;
         $friends = $model->getFriends($user->id, $options);
     }
     if ($type == 'mutual') {
         $friends = $model->getMutualFriends($my->id, $user->id, $limit);
     }
     if ($type == 'suggest') {
         $friends = $model->getSuggestedFriends($my->id, $limit);
         $userAlias = $my->getAlias();
     }
     if ($type == 'request') {
         $options['state'] = SOCIAL_FRIENDS_STATE_PENDING;
         $options['isRequest'] = true;
         $friends = $model->getFriends($user->id, $options);
     }
     if ($type == 'invites') {
         $friends = $model->getInvitedUsers($user->id);
     }
     // Get the pagination
     $pagination = $model->getPagination();
     // Set additional vars for the pagination
     $pagination->setVar('Itemid', FRoute::getItemId('friends'));
     $pagination->setVar('view', 'friends');
     if ($type != 'suggest') {
         $pagination->setVar('userid', $userAlias);
     }
     $pagination->setVar('filter', $type);
     return $view->call(__FUNCTION__, $type, $friends, $pagination);
 }
コード例 #5
0
 public function buildPaginationParams()
 {
     $params = '';
     $view = JRequest::getVar('view', 'dashboard');
     if ($view) {
         $params .= '&view=' . $view;
     }
     if (JRequest::getVar('layout')) {
         $params .= '&layout=' . JRequest::getVar('layout');
     } else {
         if ($view == 'groups') {
             $params .= '&layout=item';
         }
         if ($view == 'events') {
             $params .= '&layout=item';
         }
         if ($view == 'profile') {
             $params .= '&layout=timeline';
         }
     }
     $type = '';
     // Define those query strings here
     if (JRequest::getVar('type', '') != '') {
         $type = JRequest::getVar('type');
         if ($type == 'custom') {
             $type = 'filter';
         }
     }
     if (FD::config()->get('stream.pagination.style') == 'loadmore') {
         $params .= '&type=' . $type;
         if (JRequest::getVar('filterid', '')) {
             $params .= '&filterid=' . JRequest::getVar('filterid');
         }
         if (JRequest::getVar('id', '')) {
             if ($view == 'profile' || $view == 'profiles' || $view == 'groups' || $view == 'events') {
                 $params .= '&id=' . JRequest::getVar('id');
             } else {
                 if ($type == 'group') {
                     $params .= '&groupId=' . JRequest::getVar('id');
                 } else {
                     if ($type == 'event') {
                         $params .= '&eventId=' . JRequest::getVar('id');
                     } else {
                         $params .= '&filterid=' . JRequest::getVar('id');
                     }
                 }
             }
         }
     } else {
         // normal pagination.
         if ($type == 'hashtag') {
             $params .= '&filterId=' . JRequest::getVar('id');
         } else {
             if ($type == 'apps') {
                 $params .= '&app=' . JRequest::getVar('id');
             } else {
                 if ($type == 'event') {
                     $params .= '&type=' . $type;
                 } else {
                     if ($type == 'group') {
                         $params .= '&type=' . $type;
                     } else {
                         $params .= '&type=' . $type;
                     }
                 }
             }
         }
         // if($type == 'event' && JRequest::getVar('id', '')) {
         // 	$params .= '&eventId=' . JRequest::getVar('id');
         // }
         // if($type == 'group' && JRequest::getVar('id', '')) {
         // 	$params .= '&groupId=' . JRequest::getVar('id');
         // }
         if ($view == 'dashboard') {
             if (JRequest::getVar('eventId', '')) {
                 $params .= '&eventId=' . JRequest::getVar('eventId');
             }
             if (JRequest::getVar('groupId', '')) {
                 $params .= '&groupId=' . JRequest::getVar('groupId');
             }
         }
         if (JRequest::getVar('id', '')) {
             if ($view == 'profile' || $view == 'profiles' || $view == 'groups' || $view == 'events') {
                 if ($view == 'events' && JRequest::getVar('eventId', '')) {
                     $params .= '&id=' . JRequest::getVar('eventId');
                 } else {
                     $params .= '&id=' . JRequest::getVar('id');
                 }
             } else {
                 if ($type == 'group') {
                     $params .= '&groupId=' . JRequest::getVar('id');
                 } else {
                     if ($type == 'event') {
                         $params .= '&eventId=' . JRequest::getVar('id');
                     } else {
                         if ($type == 'list') {
                             $params .= '&listId=' . JRequest::getVar('id');
                         } else {
                             $params .= '&filterid=' . JRequest::getVar('id');
                         }
                     }
                 }
             }
         } else {
             if (JRequest::getVar('filterid', '') && $type != 'filter') {
                 $params .= '&id=' . JRequest::getVar('filterid');
             }
         }
     }
     if (JRequest::getVar('filter', '')) {
         $params .= '&filter=' . JRequest::getVar('filter');
     }
     if (JRequest::getVar('filterId', '')) {
         $params .= '&filterId=' . JRequest::getVar('filterId');
     }
     if (JRequest::getVar('tag', '')) {
         $params .= '&tag=' . JRequest::getVar('tag');
     }
     if (JRequest::getVar('app', '')) {
         $params .= '&app=' . JRequest::getVar('app');
     }
     if (!JRequest::getInt('Itemid')) {
         $Itemid = FRoute::getItemId($view);
         $params .= '&Itemid=' . $Itemid;
     }
     return $params;
 }
コード例 #6
0
ファイル: groups.php プロジェクト: ppantilla/bbninja
 /**
  * Allows caller to retrieve groups
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function getGroups()
 {
     // Check for request forgeries
     FD::checkToken();
     // Get the current view
     $view = $this->getCurrentView();
     // Check if the caller passed us a category id.
     $categoryId = $this->input->get('categoryId', 0, 'int');
     // Load up the model
     $model = FD::model('Groups');
     // Filter
     $filter = $this->input->get('filter', '', 'cmd');
     // Options
     $options = array('state' => SOCIAL_CLUSTER_PUBLISHED);
     // Default values
     $groups = array();
     $featuredGroups = array();
     if ($filter == 'featured') {
         // Get a list of featured groups
         $options['featured'] = true;
         $featuredGroups = $model->getGroups($options);
     } else {
         // Determine the pagination limit
         $limit = FD::themes()->getConfig()->get('groups_limit', 20);
         $options['limit'] = $limit;
         if ($filter == 'mine') {
             $options['uid'] = FD::user()->id;
             $options['types'] = 'all';
         }
         if ($filter == 'invited') {
             $options['invited'] = FD::user()->id;
             $options['types'] = 'all';
         }
         if ($categoryId) {
             $options['category'] = $categoryId;
         }
         // Get the groups
         $groups = $model->getGroups($options);
     }
     // Get the pagination
     $pagination = $model->getPagination();
     // Define those query strings here
     $pagination->setVar('Itemid', FRoute::getItemId('groups'));
     $pagination->setVar('view', 'groups');
     $pagination->setVar('filter', $filter);
     if (isset($options['category'])) {
         $groupCat = FD::table('GroupCategory');
         $groupCat->load($options['category']);
         $pagination->setVar('categoryid', $groupCat->getAlias());
     }
     return $view->call(__FUNCTION__, $groups, $pagination, $featuredGroups);
 }
コード例 #7
0
ファイル: default.php プロジェクト: ppantilla/bbninja
		<div class="es-widget">

			<div class="es-navbar-search" data-mod-search>
				<form action="<?php 
echo JRoute::_('index.php');
?>
" method="post">
					<input type="text" name="q" class="form-control input-sm" autocomplete="off" data-nav-search-input placeholder="<?php 
echo JText::_('MOD_EASYSOCIAL_SEARCH_PHASE', true);
?>
" />

					<input type="hidden" name="view" value="search" />
					<input type="hidden" name="option" value="com_easysocial" />
					<input type="hidden" name="Itemid" value="<?php 
echo FRoute::getItemId('search');
?>
" />
					<?php 
echo $modules->html('form.token');
?>
				</form>
			</div>
			<div class="mt-5 mr-10 fd-cf">
				<a class="pull-right fd-small" href="<?php 
echo FRoute::search(array('layout' => 'advanced'));
?>
"><?php 
echo JText::_('MOD_EASYSOCIAL_SEARCH_ADVANCED_SEARCH');
?>
</a>
コード例 #8
0
ファイル: view.html.php プロジェクト: ppantilla/bbninja
 /**
  * Displays a list of users on the site from dating search module
  *
  * @access	public
  * @param	string	The name of the template file to parse; automatically searches through the template paths.
  * @return	null
  */
 public function search($tpl = null)
 {
     // Check for user profile completeness
     FD::checkCompleteProfile();
     // Retrieve the users model
     $model = FD::model('Users');
     $my = FD::user();
     $config = FD::config();
     $admin = $config->get('users.listings.admin') ? true : false;
     $options = array('includeAdmin' => $admin);
     $limit = FD::themes()->getConfig()->get('userslimit');
     $options['limit'] = $limit;
     // Default title
     $title = JText::_('COM_EASYSOCIAL_PAGE_TITLE_USERS');
     $post = JRequest::get('POSTS');
     // echo '<pre>';print_r( $post );echo '</pre>';
     // Get values from posted data
     $values = array();
     $values['criterias'] = JRequest::getVar('criterias');
     $values['datakeys'] = JRequest::getVar('datakeys');
     $values['operators'] = JRequest::getVar('operators');
     $values['conditions'] = JRequest::getVar('conditions');
     // echo '<pre>';print_r( $values );echo '</pre>';
     $searchOptions = array();
     // lets do some clean up here.
     for ($i = 0; $i < count($values['criterias']); $i++) {
         $criteria = $values['criterias'][$i];
         $condition = $values['conditions'][$i];
         $datakey = $values['datakeys'][$i];
         $operator = $values['operators'][$i];
         if (trim($condition)) {
             $searchOptions['criterias'][] = $criteria;
             $searchOptions['datakeys'][] = $datakey;
             $searchOptions['operators'][] = $operator;
             $field = explode('|', $criteria);
             $fieldCode = $field[0];
             $fieldType = $field[1];
             if ($fieldType == 'birthday') {
                 // currently the value from form is in age format. we need to convert it into date time.
                 $ages = explode('|', $condition);
                 if (!isset($ages[1])) {
                     // this happen when start has value and end has no value
                     $ages[1] = $ages[0];
                 }
                 if ($ages[1] && !$ages[0]) {
                     //this happen when start is empty and end has value
                     $ages[0] = $ages[1];
                 }
                 $startdate = '';
                 $enddate = '';
                 $currentTimeStamp = FD::date()->toUnix();
                 if ($ages[0] == $ages[1]) {
                     $start = strtotime('-' . $ages[0] . ' years', $currentTimeStamp);
                     $year = FD::date($start)->toFormat('Y');
                     $startdate = $year . '-01-01 00:00:01';
                     $enddate = FD::date($start)->toFormat('Y-m-d') . ' 23:59:59';
                 } else {
                     if ($ages[0]) {
                         $start = strtotime('-' . $ages[0] . ' years', $currentTimeStamp);
                         $year = FD::date($start)->toFormat('Y');
                         $enddate = $year . '-12-31 23:59:59';
                     }
                     if ($ages[1]) {
                         $end = strtotime('-' . $ages[1] . ' years', $currentTimeStamp);
                         $year = FD::date($end)->toFormat('Y');
                         $startdate = $year . '-01-01 00:00:01';
                     }
                 }
                 $condition = $startdate . '|' . $enddate;
             }
             $searchOptions['conditions'][] = $condition;
         }
     }
     $pagination = null;
     $result = null;
     $users = array();
     if ($searchOptions) {
         $searchOptions['match'] = 'all';
         $searchOptions['avatarOnly'] = false;
         // Retrieve the users
         $result = $model->getUsersByFilter('0', $options, $searchOptions);
         // $result		= array();
         $pagination = $model->getPagination();
         $pagination->setVar('Itemid', FRoute::getItemId('users'));
         $pagination->setVar('view', 'users');
         $pagination->setVar('layout', 'search');
         $pagination->setVar('filter', 'search');
         for ($i = 0; $i < count($values['criterias']); $i++) {
             $criteria = $values['criterias'][$i];
             $condition = $values['conditions'][$i];
             $datakey = $values['datakeys'][$i];
             $operator = $values['operators'][$i];
             $field = explode('|', $criteria);
             $fieldCode = $field[0];
             $fieldType = $field[1];
             $pagination->setVar('criterias[' . $i . ']', $criteria);
             $pagination->setVar('datakeys[' . $i . ']', $datakey);
             $pagination->setVar('operators[' . $i . ']', $operator);
             $pagination->setVar('conditions[' . $i . ']', $condition);
         }
         if ($result) {
             foreach ($result as $obj) {
                 $users[] = FD::user($obj->id);
             }
         }
     }
     // Set the page title
     FD::page()->title($title);
     // Set the page breadcrumb
     FD::page()->breadcrumb($title);
     $filter = 'search';
     $sort = '';
     $this->set('issearch', true);
     $this->set('profiles', '');
     $this->set('activeProfile', '');
     $this->set('profile', '');
     $this->set('activeTitle', $title);
     $this->set('pagination', $pagination);
     $this->set('filter', $filter);
     $this->set('sort', $sort);
     $this->set('users', $users);
     $this->set('fid', '');
     $this->set('searchFilters', '');
     $this->set('searchFilter', '');
     echo parent::display('site/users/default');
 }
コード例 #9
0
ファイル: events.php プロジェクト: knigherrant/decopatio
 /**
  * Retrieves a list of events from the site
  *
  * @since   1.3
  * @access  public
  * @param   string
  * @return
  */
 public function getEvents()
 {
     // Check for request forgeries
     FD::checkToken();
     // Load up the model
     $model = FD::model('Events');
     // Ge the current filter from the request
     $filter = $this->input->get('filter', 'all', 'string');
     // There is a possibility to filter events by category
     $categoryid = $this->input->get('categoryid', 0, 'int');
     // Get the ordering
     $ordering = $this->input->get('ordering', 'start', 'word');
     // See if past should be included
     $includePast = $this->input->getInt('includePast', 0);
     $options = array('state' => SOCIAL_STATE_PUBLISHED, 'ordering' => $ordering, 'type' => $this->my->isSiteAdmin() ? 'all' : 'user', 'featured' => FD::config()->get('events.listing.includefeatured') ? 'all' : false);
     $options['limit'] = $this->input->getInt('limit', FD::themes()->getConfig()->get('events_limit', 20));
     $options['limitstart'] = $this->input->getInt('limitstart', 0);
     $featuredEvents = false;
     $activeCategory = false;
     // Support for group id
     $groupid = $this->input->getInt('group');
     if (!empty($groupid)) {
         $options['group_id'] = $groupid;
     }
     if ($filter === 'category') {
         $category = FD::table('EventCategory');
         $category->load($categoryid);
         $activeCategory = $category;
         $options['category'] = $category->id;
         $filter = 'all';
     }
     if ($filter === 'all') {
         // Need to get featured events separately here
         $featuredOptions = array('featured' => true, 'type' => array(SOCIAL_EVENT_TYPE_PUBLIC, SOCIAL_EVENT_TYPE_PRIVATE));
         if ($activeCategory) {
             $featuredOptions['category'] = $category->id;
         }
         $featuredEvents = $model->getEvents($featuredOptions);
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'past') {
         $options['start-before'] = FD::date()->toSql();
         $options['ordering'] = 'created';
         $options['direction'] = 'desc';
     }
     if ($filter === 'featured') {
         $options['featured'] = true;
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'mine') {
         $options['creator_uid'] = $this->my->id;
         $options['creator_type'] = SOCIAL_TYPE_USER;
         $options['type'] = 'all';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'participated') {
         $options['guestuid'] = $this->my->id;
         $options['type'] = 'all';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'invited') {
         $options['gueststate'] = SOCIAL_EVENT_GUEST_INVITED;
         $options['guestuid'] = $this->my->id;
         $options['type'] = 'all';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'going') {
         $options['gueststate'] = SOCIAL_EVENT_GUEST_GOING;
         $options['guestuid'] = $this->my->id;
         $options['type'] = 'all';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'pending') {
         $options['gueststate'] = SOCIAL_EVENT_GUEST_PENDING;
         $options['guestuid'] = $this->my->id;
         $options['type'] = 'all';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'maybe') {
         $options['gueststate'] = SOCIAL_EVENT_GUEST_MAYBE;
         $options['guestuid'] = $this->my->id;
         $options['type'] = 'all';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'notgoing') {
         $options['gueststate'] = SOCIAL_EVENT_GUEST_NOTGOING;
         $options['guestuid'] = $this->my->id;
         $options['type'] = 'all';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
     }
     if ($filter === 'tomorrow') {
         $filter = 'date';
         $this->input->set('date', FD::date()->modify('+1 day')->format('Y-m-d', true));
     }
     if ($filter === 'month') {
         $filter = 'date';
         $this->input->set('date', FD::date()->format('Y-m', true));
     }
     if ($filter === 'year') {
         $filter = 'date';
         $this->input->set('date', FD::date()->format('Y', true));
     }
     if ($filter === 'date') {
         // Depending on the input format.
         // Could be by year, year-month or year-month-day
         $now = FD::date();
         list($nowYMD, $nowHMS) = explode(' ', $now->toSql(true));
         $input = $this->input->getString('date');
         // We need segments to be populated. If no input is passed, then it is today, and we use today as YMD then
         if (empty($input)) {
             $input = $nowYMD;
         }
         $segments = explode('-', $input);
         $start = $nowYMD;
         $end = $nowYMD;
         // Depending on the amount of segments
         // 1 = filter by year
         // 2 = filter by month
         // 3 = filter by day
         $mode = count($segments);
         switch ($mode) {
             case 1:
                 $start = $segments[0] . '-01-01';
                 $end = $segments[0] . '-12-31';
                 break;
             case 2:
                 $start = $segments[0] . '-' . $segments[1] . '-01';
                 // Need to get the month's maximum day
                 $monthDate = FD::date($start);
                 $maxDay = $monthDate->format('t');
                 $end = $segments[0] . '-' . $segments[1] . '-' . str_pad($maxDay, 2, '0', STR_PAD_LEFT);
                 break;
             default:
             case 3:
                 $start = $segments[0] . '-' . $segments[1] . '-' . $segments[2];
                 $end = $segments[0] . '-' . $segments[1] . '-' . $segments[2];
                 break;
         }
         $options['start-after'] = $start . ' 00:00:00';
         $options['start-before'] = $end . ' 23:59:59';
     }
     if ($filter === 'week1') {
         $now = FD::date();
         $week1 = FD::date($now->toUnix() + 60 * 60 * 24 * 7);
         $options['start-after'] = $now->toSql();
         $options['start-before'] = $week1->toSql();
     }
     if ($filter === 'week2') {
         $now = FD::date();
         $week2 = FD::date($now->toUnix() + 60 * 60 * 24 * 14);
         $options['start-after'] = $now->toSql();
         $options['start-before'] = $week2->toSql();
     }
     if ($filter === 'nearby') {
         $distance = $this->input->getString('distance');
         if (empty($distance)) {
             $distance = 10;
         }
         $options['location'] = true;
         $options['distance'] = $distance;
         $options['latitude'] = $this->input->getString('latitude');
         $options['longitude'] = $this->input->getString('longitude');
         $options['range'] = '<=';
         // We do not want to include past events here
         if (!$includePast) {
             $options['ongoing'] = true;
             $options['upcoming'] = true;
         }
         $session = JFactory::getSession();
         $userLocation = $session->get('events.userlocation', array(), SOCIAL_SESSION_NAMESPACE);
         $hasLocation = !empty($userLocation) && !empty($userLocation['latitude']) && !empty($userLocation['longitude']);
         if (!$hasLocation) {
             $userLocation['latitude'] = $options['latitude'];
             $userLocation['longitude'] = $options['longitude'];
             $session->set('events.userlocation', $userLocation, SOCIAL_SESSION_NAMESPACE);
         }
     }
     $events = $model->getEvents($options);
     // Load up the pagination
     $pagination = $model->getPagination();
     $pagination->setVar('Itemid', FRoute::getItemId('events'));
     $pagination->setVar('view', 'events');
     $pagination->setVar('filter', $filter);
     if ($includePast) {
         $pagination->setVar('includePast', $includePast);
     }
     if ($ordering != 'start') {
         $pagination->setVar('ordering', $ordering);
     }
     if ($activeCategory) {
         $pagination->setVar('categoryid', $activeCategory->id);
     }
     $dateInput = $this->input->getString('date');
     if (!empty($dateInput)) {
         $pagination->setVar('date', $dateInput);
     }
     $distanceInput = $this->input->getString('distance');
     if (!empty($distanceInput)) {
         $pagination->setVar('distance', $distanceInput);
     }
     return $this->view->call(__FUNCTION__, $filter, $events, $pagination, $activeCategory, $featuredEvents);
 }
コード例 #10
0
ファイル: router.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Builds the URLs for apps view
  *
  * @since   1.0
  * @access  public
  * @param   array   An array of request arguments
  * @param   bool    Determines if the url should be xhtml compliant
  * @return  url     The string of the URL
  */
 public function route($options = array(), $xhtml = true)
 {
     $url = self::$base . '&view=' . $this->name;
     // Custom options
     $ssl = $options['ssl'];
     $tokenize = $options['tokenize'];
     $external = $options['external'];
     $tmpl = $options['tmpl'];
     $sef = $options['sef'];
     $layout = isset($options['layout']) ? $options['layout'] : '';
     // check if the current request is from feed page or not.
     // if yes, let set the external to always true.
     $pageFormat = FD::input()->get('format', '', 'var');
     if (!$external && $pageFormat == 'feed') {
         $external = true;
     }
     // Determines if this is a request to the controller
     $controller = $options['controller'];
     $data = array();
     unset($options['ssl'], $options['tokenize'], $options['external'], $options['tmpl'], $options['controller'], $options['sef']);
     if ($options) {
         foreach ($options as $key => $value) {
             $data[] = $key . '=' . $value;
         }
     }
     $query = $options;
     $options = implode('&', $data);
     $join = !empty($options) ? '&' : '';
     $url = $url . $join . $options;
     // Try to get the url from the adapter
     $overrideUrl = '';
     // Set temporary data
     $query['view'] = $this->name;
     $query['option'] = 'com_easysocial';
     // Ensure that all query values are lowercased
     $query = array_map(array('JString', 'strtolower'), $query);
     // Let's find for a suitable menu
     $view = $this->name;
     $layout = isset($query['layout']) ? $query['layout'] : '';
     $id = isset($query['id']) ? (int) $query['id'] : '';
     // For photos and albums, we want to fetch menu from "All Albums"
     if ($view == 'photos' || $view == 'albums') {
         $view = 'albums';
         $layout = 'all';
         $id = '';
     }
     $menuId = FRoute::getItemId($view, $layout, $id);
     if ($menuId) {
         $menu = JFactory::getApplication()->getMenu()->getItem($menuId);
         if ($menu) {
             $current = $menu->query;
             if (isset($current['id']) && !empty($current['id'])) {
                 $current['id'] = (int) $current['id'];
             }
             if (isset($query['id'])) {
                 $query['id'] = (int) $query['id'];
             }
             $hasDiff = array_diff($query, $current);
             // // If there's no difference in both sets of query, we can safely assume that there's already
             // // a menu for this link
             if (empty($hasDiff)) {
                 $overrideUrl = 'index.php?Itemid=' . $menuId;
             }
             //$overrideUrl    = 'index.php?Itemid=' . $menuId;
         }
     }
     // If there are no overriden url's, we append our own item id.
     if ($overrideUrl) {
         $url = $overrideUrl;
     } else {
         // If there is no getUrl method, we want to get the default item id.
         if ($menuId) {
             $url .= '&Itemid=' . $menuId;
         } else {
             $url .= '&Itemid=' . FRoute::getItemId($view, $layout);
         }
     }
     return FRoute::_($url, $xhtml, array(), $ssl, $tokenize, $external, $tmpl, $controller, $sef);
 }