public function getStatsData($grouping, $defaultStart) { $tz = new DateTimeZone('GMT'); if (!($start = $this->_input->filterSingle('start', XenForo_Input::DATE_TIME, array('timeZone' => $tz)))) { $start = $defaultStart; } if (!($end = $this->_input->filterSingle('end', XenForo_Input::DATE_TIME, array('dayEnd' => true, 'timeZone' => $tz)))) { $end = XenForo_Application::$time; } if (!($statsTypes = $this->_input->filterSingle('statsTypes', XenForo_Input::ARRAY_SIMPLE))) { $statsTypes = array('post', 'post_like'); } $statsModel = $this->_getStatsModel(); $groupings = array('daily' => array('printDateFormat' => 'absolute', 'xAxisTime' => true), 'monthly' => array('printDateFormat' => 'M Y', 'groupDateFormat' => 'Ym'), 'weekly' => array('printDateFormat' => '\\WW Y', 'groupDateFormat' => 'YW')); if (!isset($groupings[$grouping])) { $grouping = 'daily'; } $groupingConfig = $groupings[$grouping]; $plots = $statsModel->getStatsData($start, $end, $statsTypes, $grouping); $dateMap = array(); foreach ($plots as $type => $plot) { $output = $statsModel->prepareGraphData($plot, $grouping); $plots[$type] = $output['plot']; $dateMap[$type] = $output['dateMap']; } if (empty($groupingConfig['xAxisTime'])) { $output = $statsModel->filterGraphDataDates($plots, $dateMap); $plots = $output['plots']; $dateMap = $output['dateMap']; } $viewParams = array('plots' => $plots, 'dateMap' => $dateMap, 'start' => $start, 'end' => $end, 'endDisplay' => $end >= XenForo_Application::$time ? 0 : $end, 'statsTypeOptions' => $statsModel->getStatsTypeOptions($statsTypes), 'statsTypePhrases' => $statsModel->getStatsTypePhrases($statsTypes), 'datePresets' => XenForo_Helper_Date::getDatePresets(), 'grouping' => $grouping, 'groupingConfig' => $groupingConfig); return $viewParams; }
public function actionForum() { $response = parent::actionForum(); if (!empty($response->params['forum']['node_id'])) { list($locations, $statuses, $demands, $priceSteps) = $this->_getListClassifieds(); $visitor = XenForo_Visitor::getInstance(); $params = array('BRTC_locations' => $locations, 'BRTC_statuses' => $statuses, 'BRTC_demands' => $demands, 'BRTC_priceSteps' => $priceSteps, 'datePresets' => XenForo_Helper_Date::getDatePresets(), 'threadClassifieds' => XenForo_Application::get('session')->get('brtcThreadClassifieds'), 'brtcLocation' => !empty($visitor['location']) ? $visitor['location'] : ''); $response->params += $params; } return $response; }
public function actionIndex() { if ($this->_input->inRequest('delete_selected')) { return $this->responseReroute(__CLASS__, 'delete'); } $input = $this->_getFilterParams(); $dateInput = $this->_input->filter(array('start' => XenForo_Input::DATE_TIME, 'end' => array(XenForo_Input::DATE_TIME, 'dayEnd' => true))); $attachmentModel = $this->_getAttachmentModel(); $page = $this->_input->filterSingle('page', XenForo_Input::UINT); $perPage = 50; $pageParams = array(); if ($input['mode']) { $pageParams['mode'] = $input['mode']; } if ($input['start']) { $pageParams['start'] = $input['start']; } if ($input['end']) { $pageParams['end'] = $input['end']; } if ($input['content_type']) { $pageParams['content_type'] = $input['content_type']; } $userId = 0; if ($input['username']) { if ($user = $this->getModelFromCache('XenForo_Model_User')->getUserByName($input['username'])) { $userId = $user['user_id']; $pageParams['username'] = $input['username']; } else { $input['username'] = ''; } } $conditions = array('content_type' => $input['content_type'], 'user_id' => $userId, 'start' => $dateInput['start'], 'end' => $dateInput['end']); $fetchOptions = array('page' => $page, 'perPage' => $perPage, 'join' => XenForo_Model_Attachment::FETCH_USER); switch ($input['mode']) { case 'size': $fetchOptions['order'] = 'size'; break; case 'recent': default: $input['mode'] = 'recent'; $fetchOptions['order'] = 'recent'; break; } $attachments = $attachmentModel->getAttachments($conditions, $fetchOptions); $viewParams = array('contentTypes' => $attachmentModel->getAttachmentHandlerContentTypeNames(), 'attachments' => $attachmentModel->prepareAttachments($attachments, true), 'mode' => $input['mode'], 'contentType' => $input['content_type'], 'username' => $input['username'], 'start' => $input['start'], 'end' => $input['end'], 'datePresets' => XenForo_Helper_Date::getDatePresets(), 'page' => $page, 'perPage' => $perPage, 'pageParams' => $pageParams, 'total' => $attachmentModel->countAttachments($conditions)); return $this->responseView('XenForo_ControllerAdmin_Attachment_List', 'attachment_list', $viewParams); }
public function actionIndex() { $forum = array('node_id' => 0, 'title' => ''); $forumId = 0; $visitor = XenForo_Visitor::getInstance(); $threadModel = $this->_getThreadModel(); $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT)); $threadsPerPage = XenForo_Application::get('options')->discussionsPerPage; $defaultOrder = 'last_post_date'; $defaultOrderDirection = 'desc'; $order = $this->_input->filterSingle('order', XenForo_Input::STRING, array('default' => $defaultOrder)); $orderDirection = $this->_input->filterSingle('direction', XenForo_Input::STRING, array('default' => $defaultOrderDirection)); $displayConditions = $this->_getDisplayConditions($forum); $fetchElements = $this->_getThreadFetchElements($forum, $displayConditions); $threadFetchConditions = $fetchElements['conditions']; $threadFetchOptions = $fetchElements['options'] + array('perPage' => $threadsPerPage, 'page' => $page, 'order' => $order, 'orderDirection' => $orderDirection); unset($fetchElements); $viewableNodes = $this->_getViewAbleNode(); $nodeIds = array_keys($viewableNodes); $threadFetchConditions['node_id'] = $nodeIds; $totalThreads = $threadModel->countThreadsInForum($forumId, $threadFetchConditions); $this->canonicalizePageNumber($page, $threadsPerPage, $totalThreads, 'forums', $forum); $threads = $threadModel->getThreads($threadFetchConditions, $threadFetchOptions); //$threads = $threadModel->getThreadsInForum($forumId, $threadFetchConditions, $threadFetchOptions); if ($page == 1) { $stickyThreadFetchOptions = $threadFetchOptions; unset($stickyThreadFetchOptions['perPage'], $stickyThreadFetchOptions['page']); $threadFetchConditions['sticky'] = 1; $stickyThreads = $threadModel->getThreads($threadFetchConditions, $stickyThreadFetchOptions); } else { $stickyThreads = array(); } $threads = $threadModel->classifiedPrepareThreads($threads); $stickyThreads = $threadModel->classifiedPrepareThreads($stickyThreads); // if we've read everything on the first page of a normal sort order, probably need to mark as read if ($visitor['user_id'] && $page == 1 && !$displayConditions && $order == 'last_post_date' && $orderDirection == 'desc') { $hasNew = false; foreach ($threads as $thread) { if ($thread['isNew'] && !$thread['isIgnored']) { $hasNew = true; break; } } } // get the ordering params set for the header links $orderParams = array(); foreach ($this->_getThreadSortFields($forum) as $field) { $orderParams[$field] = $displayConditions; $orderParams[$field]['order'] = $field != $defaultOrder ? $field : false; if ($order == $field) { $orderParams[$field]['direction'] = $orderDirection == 'desc' ? 'asc' : 'desc'; } } $pageNavParams = $displayConditions; $pageNavParams['order'] = $order != $defaultOrder ? $order : false; $pageNavParams['direction'] = $orderDirection != $defaultOrderDirection ? $orderDirection : false; list($locations, $statuses, $priceSteps) = $this->_getListClassifieds(); $visitor = XenForo_Visitor::getInstance(); $viewParams = array('BRTC_locations' => $locations, 'BRTC_statuses' => $statuses, 'BRTC_priceSteps' => $priceSteps, 'datePresets' => XenForo_Helper_Date::getDatePresets(), 'threadClassifieds' => XenForo_Application::get('session')->get('brtcThreadClassifieds'), 'brtcLocation' => !empty($visitor['brtc_location']) ? $visitor['brtc_location'] : '', 'threads' => $threads, 'stickyThreads' => $stickyThreads, 'ignoredNames' => $this->_getIgnoredContentUserNames($threads) + $this->_getIgnoredContentUserNames($stickyThreads), 'order' => $order, 'orderDirection' => $orderDirection, 'orderParams' => $orderParams, 'displayConditions' => $displayConditions, 'pageNavParams' => $pageNavParams, 'page' => $page, 'threadStartOffset' => ($page - 1) * $threadsPerPage + 1, 'threadEndOffset' => ($page - 1) * $threadsPerPage + count($threads), 'threadsPerPage' => $threadsPerPage, 'totalThreads' => $totalThreads, 'showPostedNotice' => $this->_input->filterSingle('posted', XenForo_Input::UINT)); return $this->responseView('Brivium_ThreadClassified_ViewPublic_Portal', 'BRTC_forum_list', $viewParams); }