本文整理汇总了PHP中Piwik\API\Request::getRawSegmentFromRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getRawSegmentFromRequest方法的具体用法?PHP Request::getRawSegmentFromRequest怎么用?PHP Request::getRawSegmentFromRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\API\Request
的用法示例。
在下文中一共展示了Request::getRawSegmentFromRequest方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestArray
/**
* @return array URL to call the API, eg. "method=Referrers.getKeywords&period=day&date=yesterday"...
*/
public function getRequestArray()
{
// we prepare the array to give to the API Request
// we setup the method and format variable
// - we request the method to call to get this specific DataTable
// - the format = original specifies that we want to get the original DataTable structure itself, not rendered
$requestArray = array('method' => $this->requestConfig->apiMethodToRequestDataTable, 'format' => 'original');
$toSetEventually = array('filter_limit', 'keep_summary_row', 'filter_sort_column', 'filter_sort_order', 'filter_excludelowpop', 'filter_excludelowpop_value', 'filter_column', 'filter_pattern', 'flat', 'expanded', 'pivotBy', 'pivotByColumn', 'pivotByColumnLimit');
foreach ($toSetEventually as $varToSet) {
$value = $this->getDefaultOrCurrent($varToSet);
if (false !== $value) {
$requestArray[$varToSet] = $value;
}
}
$segment = ApiRequest::getRawSegmentFromRequest();
if (!empty($segment)) {
$requestArray['segment'] = $segment;
}
if (ApiRequest::shouldLoadExpanded()) {
$requestArray['expanded'] = 1;
}
$requestArray = array_merge($requestArray, $this->requestConfig->request_parameters_to_modify);
if (!empty($requestArray['filter_limit']) && $requestArray['filter_limit'] === 0) {
unset($requestArray['filter_limit']);
}
if ($this->requestConfig->disable_generic_filters) {
$requestArray['disable_generic_filters'] = '1';
}
if ($this->requestConfig->disable_queued_filters) {
$requestArray['disable_queued_filters'] = 1;
}
return $requestArray;
}
示例2: requestApiReport
private function requestApiReport($apiReport)
{
if (!$this->canGenerateInsights()) {
return;
}
$idSite = Common::getRequestVar('idSite', null, 'int');
$period = Common::getRequestVar('period', null, 'string');
$date = Common::getRequestVar('date', null, 'string');
$segment = Request::getRawSegmentFromRequest();
return API::getInstance()->{$apiReport}($idSite, $period, $date, $segment);
}
示例3: initChartObjectData
/**
* @param DataTable|DataTable\Map $dataTable
* @param $visualization
*/
protected function initChartObjectData($dataTable, $visualization)
{
// if the loaded datatable is a simple DataTable, it is most likely a plugin plotting some custom data
// we don't expect plugin developers to return a well defined Set
if ($dataTable instanceof DataTable) {
parent::initChartObjectData($dataTable, $visualization);
return;
}
// the X label is extracted from the 'period' object in the table's metadata
$xLabels = array();
foreach ($dataTable->getDataTables() as $metadataDataTable) {
$xLabels[] = $metadataDataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLocalizedShortString();
// eg. "Aug 2009"
}
$units = $this->getUnitsForColumnsToDisplay();
// if rows to display are not specified, default to all rows (TODO: perhaps this should be done elsewhere?)
$rowsToDisplay = $this->properties['rows_to_display'] ?: array_unique($dataTable->getColumn('label')) ?: array(false);
// collect series data to show. each row-to-display/column-to-display permutation creates a series.
$allSeriesData = array();
$seriesUnits = array();
foreach ($rowsToDisplay as $rowLabel) {
foreach ($this->properties['columns_to_display'] as $columnName) {
$seriesLabel = $this->getSeriesLabel($rowLabel, $columnName);
$seriesData = $this->getSeriesData($rowLabel, $columnName, $dataTable);
$allSeriesData[$seriesLabel] = $seriesData;
$seriesUnits[$seriesLabel] = $units[$columnName];
}
}
$visualization->dataTable = $dataTable;
$visualization->properties = $this->properties;
$visualization->setAxisXLabels($xLabels);
$visualization->setAxisYValues($allSeriesData);
$visualization->setAxisYUnits($seriesUnits);
$dataTables = $dataTable->getDataTables();
if ($this->isLinkEnabled()) {
$idSite = Common::getRequestVar('idSite', null, 'int');
$periodLabel = reset($dataTables)->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLabel();
$axisXOnClick = array();
$queryStringAsHash = $this->getQueryStringAsHash();
foreach ($dataTable->getDataTables() as $idDataTable => $metadataDataTable) {
$dateInUrl = $metadataDataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart();
$parameters = array('idSite' => $idSite, 'period' => $periodLabel, 'date' => $dateInUrl->toString(), 'segment' => \Piwik\API\Request::getRawSegmentFromRequest());
$hash = '';
if (!empty($queryStringAsHash)) {
$hash = '#' . Url::getQueryStringFromParameters($queryStringAsHash + $parameters);
}
$link = 'index.php?' . Url::getQueryStringFromParameters(array('module' => 'CoreHome', 'action' => 'index') + $parameters) . $hash;
$axisXOnClick[] = $link;
}
$visualization->setAxisXOnClick($axisXOnClick);
}
}
示例4: __construct
/**
* Constructor.
*/
public function __construct($idSite = false)
{
parent::__construct();
$this->jsClass = "SegmentSelectorControl";
$this->cssIdentifier = "segmentEditorPanel";
$this->cssClass = "piwikTopControl borderedControl piwikSelector";
$this->idSite = $idSite ?: Common::getRequestVar('idSite', false, 'int');
$this->selectedSegment = Common::getRequestVar('segment', false, 'string');
$formatter = StaticContainer::get('Piwik\\Plugins\\SegmentEditor\\SegmentFormatter');
$this->segmentDescription = $formatter->getHumanReadable(Request::getRawSegmentFromRequest(), $this->idSite);
$this->isAddingSegmentsForAllWebsitesEnabled = SegmentEditor::isAddingSegmentsForAllWebsitesEnabled();
$segments = APIMetadata::getInstance()->getSegmentsMetadata($this->idSite);
$visitTitle = Piwik::translate('General_Visit');
$segmentsByCategory = array();
foreach ($segments as $segment) {
if ($segment['category'] == $visitTitle && ($segment['type'] == 'metric' && $segment['segment'] != 'visitIp')) {
$metricsLabel = Piwik::translate('General_Metrics');
$metricsLabel[0] = Common::mb_strtolower($metricsLabel[0]);
$segment['category'] .= ' (' . $metricsLabel . ')';
}
$segmentsByCategory[$segment['category']][] = $segment;
}
$this->createRealTimeSegmentsIsEnabled = Config::getInstance()->General['enable_create_realtime_segments'];
$this->segmentsByCategory = $segmentsByCategory;
$this->nameOfCurrentSegment = '';
$this->isSegmentNotAppliedBecauseBrowserArchivingIsDisabled = 0;
$this->availableSegments = API::getInstance()->getAll($this->idSite);
foreach ($this->availableSegments as &$savedSegment) {
$savedSegment['name'] = Common::sanitizeInputValue($savedSegment['name']);
if (!empty($this->selectedSegment) && $this->selectedSegment == $savedSegment['definition']) {
$this->nameOfCurrentSegment = $savedSegment['name'];
$this->isSegmentNotAppliedBecauseBrowserArchivingIsDisabled = $this->wouldApplySegment($savedSegment) ? 0 : 1;
}
}
$this->authorizedToCreateSegments = SegmentEditorAPI::getInstance()->isUserCanAddNewSegment($this->idSite);
$this->isUserAnonymous = Piwik::isUserIsAnonymous();
$this->segmentTranslations = $this->getTranslations();
$this->segmentProcessedOnRequest = Rules::isBrowserArchivingAvailableForSegments();
$this->hideSegmentDefinitionChangeMessage = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), 'hideSegmentDefinitionChangeMessage');
}
示例5: setSparklinesAndNumbers
protected function setSparklinesAndNumbers($view)
{
$view->urlSparklineNbVisits = $this->getUrlSparkline('getEvolutionGraph', array('columns' => $view->displayUniqueVisitors ? array('nb_visits', 'nb_uniq_visitors') : array('nb_visits')));
$view->urlSparklineNbPageviews = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_pageviews', 'nb_uniq_pageviews')));
$view->urlSparklineNbDownloads = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_downloads', 'nb_uniq_downloads')));
$view->urlSparklineNbOutlinks = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_outlinks', 'nb_uniq_outlinks')));
$view->urlSparklineAvgVisitDuration = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_on_site')));
$view->urlSparklineMaxActions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('max_actions')));
$view->urlSparklineActionsPerVisit = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions_per_visit')));
$view->urlSparklineBounceRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('bounce_rate')));
$view->urlSparklineAvgGenerationTime = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_generation')));
$idSite = Common::getRequestVar('idSite');
$displaySiteSearch = Site::isSiteSearchEnabledFor($idSite);
if ($displaySiteSearch) {
$view->urlSparklineNbSearches = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_searches', 'nb_keywords')));
}
$view->displaySiteSearch = $displaySiteSearch;
$dataTableVisit = self::getVisitsSummary();
$dataRow = $dataTableVisit->getRowsCount() == 0 ? new Row() : $dataTableVisit->getFirstRow();
$view->nbUniqVisitors = (int) $dataRow->getColumn('nb_uniq_visitors');
$nbVisits = (int) $dataRow->getColumn('nb_visits');
$view->nbVisits = $nbVisits;
$view->averageVisitDuration = $dataRow->getColumn('avg_time_on_site');
$nbBouncedVisits = $dataRow->getColumn('bounce_count');
$view->bounceRate = Piwik::getPercentageSafe($nbBouncedVisits, $nbVisits);
$view->maxActions = (int) $dataRow->getColumn('max_actions');
$view->nbActionsPerVisit = $dataRow->getColumn('nb_actions_per_visit');
if (Common::isActionsPluginEnabled()) {
$view->showActionsPluginReports = true;
$dataTableActions = APIActions::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), \Piwik\API\Request::getRawSegmentFromRequest());
$dataActionsRow = $dataTableActions->getRowsCount() == 0 ? new Row() : $dataTableActions->getFirstRow();
$view->nbPageviews = (int) $dataActionsRow->getColumn('nb_pageviews');
$view->nbUniquePageviews = (int) $dataActionsRow->getColumn('nb_uniq_pageviews');
$view->nbDownloads = (int) $dataActionsRow->getColumn('nb_downloads');
$view->nbUniqueDownloads = (int) $dataActionsRow->getColumn('nb_uniq_downloads');
$view->nbOutlinks = (int) $dataActionsRow->getColumn('nb_outlinks');
$view->nbUniqueOutlinks = (int) $dataActionsRow->getColumn('nb_uniq_outlinks');
$view->averageGenerationTime = $dataActionsRow->getColumn('avg_time_generation');
if ($displaySiteSearch) {
$view->nbSearches = (int) $dataActionsRow->getColumn('nb_searches');
$view->nbKeywords = (int) $dataActionsRow->getColumn('nb_keywords');
}
// backward compatibility:
// show actions if the finer metrics are not archived
$view->showOnlyActions = false;
if ($dataActionsRow->getColumn('nb_pageviews') + $dataActionsRow->getColumn('nb_downloads') + $dataActionsRow->getColumn('nb_outlinks') == 0 && $dataRow->getColumn('nb_actions') > 0) {
$view->showOnlyActions = true;
$view->nbActions = $dataRow->getColumn('nb_actions');
$view->urlSparklineNbActions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions')));
}
}
}
示例6: getClientSideParametersToSet
/**
* This functions reads the customization values for the DataTable and returns an array (name,value) to be printed in Javascript.
* This array defines things such as:
* - name of the module & action to call to request data for this table
* - optional filters information, eg. filter_limit and filter_offset
* - etc.
*
* The values are loaded:
* - from the generic filters that are applied by default @see Piwik\API\DataTableGenericFilter::getGenericFiltersInformation()
* - from the values already available in the GET array
* - from the values set using methods from this class (eg. setSearchPattern(), setLimit(), etc.)
*
* @return array eg. array('show_offset_information' => 0, 'show_...
*/
protected function getClientSideParametersToSet()
{
// build javascript variables to set
$javascriptVariablesToSet = array();
foreach ($this->config->custom_parameters as $name => $value) {
$javascriptVariablesToSet[$name] = $value;
}
foreach ($_GET as $name => $value) {
try {
$requestValue = Common::getRequestVar($name);
} catch (\Exception $e) {
$requestValue = '';
}
$javascriptVariablesToSet[$name] = $requestValue;
}
foreach ($this->requestConfig->clientSideParameters as $name) {
if (isset($javascriptVariablesToSet[$name])) {
continue;
}
$valueToConvert = false;
if (property_exists($this->requestConfig, $name)) {
$valueToConvert = $this->requestConfig->{$name};
} else {
if (property_exists($this->config, $name)) {
$valueToConvert = $this->config->{$name};
}
}
if (false !== $valueToConvert) {
$javascriptVariablesToSet[$name] = $this->getIntIfValueIsBool($valueToConvert);
}
}
$javascriptVariablesToSet['module'] = $this->config->controllerName;
$javascriptVariablesToSet['action'] = $this->config->controllerAction;
if (!isset($javascriptVariablesToSet['viewDataTable'])) {
$javascriptVariablesToSet['viewDataTable'] = static::getViewDataTableId();
}
if ($this->dataTable && !$this->dataTable instanceof DataTable\Map && empty($javascriptVariablesToSet['totalRows'])) {
$javascriptVariablesToSet['totalRows'] = $this->dataTable->getMetadata(DataTable::TOTAL_ROWS_BEFORE_LIMIT_METADATA_NAME) ?: $this->dataTable->getRowsCount();
}
$deleteFromJavascriptVariables = array('filter_excludelowpop', 'filter_excludelowpop_value');
foreach ($deleteFromJavascriptVariables as $name) {
if (isset($javascriptVariablesToSet[$name])) {
unset($javascriptVariablesToSet[$name]);
}
}
$rawSegment = \Piwik\API\Request::getRawSegmentFromRequest();
if (!empty($rawSegment)) {
$javascriptVariablesToSet['segment'] = $rawSegment;
}
return $javascriptVariablesToSet;
}
示例7: getApiRequestUrl
private function getApiRequestUrl($module, $action, $idSite, $period, $date, $token_auth, $filter_by_country = false, $segmentOverride = false)
{
// use processed reports
$url = "?module=" . $module . "&method=" . $module . "." . $action . "&format=JSON" . "&idSite=" . $idSite . "&period=" . $period . "&date=" . $date . "&token_auth=" . $token_auth . "&segment=" . ($segmentOverride ?: Request::getRawSegmentFromRequest()) . "&enable_filter_excludelowpop=1" . "&showRawMetrics=1";
if ($filter_by_country) {
$url .= "&filter_column=country" . "&filter_sort_column=nb_visits" . "&filter_limit=-1" . "&filter_pattern=";
} else {
$url .= "&filter_limit=-1";
}
return $url;
}
示例8: getReportMetadata
/**
* @param array $reports
* @param array $info
* @return mixed
*/
public function getReportMetadata(&$reports, $info)
{
$idSites = $info['idSites'];
// If only one website is selected, we add the Graph URL
if (count($idSites) != 1) {
return;
}
$idSite = reset($idSites);
// in case API.getReportMetadata was not called with date/period we use sane defaults
if (empty($info['period'])) {
$info['period'] = 'day';
}
if (empty($info['date'])) {
$info['date'] = 'today';
}
// need two sets of period & date, one for single period graphs, one for multiple periods graphs
if (Period::isMultiplePeriod($info['date'], $info['period'])) {
$periodForMultiplePeriodGraph = $info['period'];
$dateForMultiplePeriodGraph = $info['date'];
$periodForSinglePeriodGraph = 'range';
$dateForSinglePeriodGraph = $info['date'];
} else {
$periodForSinglePeriodGraph = $info['period'];
$dateForSinglePeriodGraph = $info['date'];
$piwikSite = new Site($idSite);
if ($periodForSinglePeriodGraph == 'range') {
// for period=range, show the configured sub-periods
$periodForMultiplePeriodGraph = Config::getInstance()->General['graphs_default_period_to_plot_when_period_range'];
$dateForMultiplePeriodGraph = $dateForSinglePeriodGraph;
} else {
if ($info['period'] == 'day' || !Config::getInstance()->General['graphs_show_evolution_within_selected_period']) {
// for period=day, always show the last n days
// if graphs_show_evolution_within_selected_period=false, show the last n periods
$periodForMultiplePeriodGraph = $periodForSinglePeriodGraph;
$dateForMultiplePeriodGraph = Range::getRelativeToEndDate($periodForSinglePeriodGraph, 'last' . self::GRAPH_EVOLUTION_LAST_PERIODS, $dateForSinglePeriodGraph, $piwikSite);
} else {
// if graphs_show_evolution_within_selected_period=true, show the days within the period
// (except if the period is day, see above)
$periodForMultiplePeriodGraph = 'day';
$period = PeriodFactory::build($info['period'], $info['date']);
$start = $period->getDateStart()->toString();
$end = $period->getDateEnd()->toString();
$dateForMultiplePeriodGraph = $start . ',' . $end;
}
}
}
$token_auth = Common::getRequestVar('token_auth', false);
$segment = Request::getRawSegmentFromRequest();
/** @var Scheduler $scheduler */
$scheduler = StaticContainer::getContainer()->get('Piwik\\Scheduler\\Scheduler');
$isRunningTask = $scheduler->isRunningTask();
// add the idSubtable if it exists
$idSubtable = Common::getRequestVar('idSubtable', false);
$urlPrefix = "index.php?";
foreach ($reports as &$report) {
$reportModule = $report['module'];
$reportAction = $report['action'];
$reportUniqueId = $reportModule . '_' . $reportAction;
$parameters = array();
$parameters['module'] = 'API';
$parameters['method'] = 'ImageGraph.get';
$parameters['idSite'] = $idSite;
$parameters['apiModule'] = $reportModule;
$parameters['apiAction'] = $reportAction;
if (!empty($token_auth)) {
$parameters['token_auth'] = $token_auth;
}
// Forward custom Report parameters to the graph URL
if (!empty($report['parameters'])) {
$parameters = array_merge($parameters, $report['parameters']);
}
if (empty($report['dimension'])) {
$parameters['period'] = $periodForMultiplePeriodGraph;
$parameters['date'] = $dateForMultiplePeriodGraph;
} else {
$parameters['period'] = $periodForSinglePeriodGraph;
$parameters['date'] = $dateForSinglePeriodGraph;
}
if ($idSubtable !== false) {
$parameters['idSubtable'] = $idSubtable;
}
if (!empty($_GET['_restrictSitesToLogin']) && $isRunningTask) {
$parameters['_restrictSitesToLogin'] = $_GET['_restrictSitesToLogin'];
}
if (!empty($segment)) {
$parameters['segment'] = $segment;
}
$report['imageGraphUrl'] = $urlPrefix . Url::getQueryStringFromParameters($parameters);
// thanks to API.getRowEvolution, reports with dimensions can now be plotted using an evolution graph
// however, most reports with a fixed set of dimension values are excluded
// this is done so Piwik Mobile and Scheduled Reports do not display them
$reportWithDimensionsSupportsEvolution = empty($report['constantRowsCount']) || in_array($reportUniqueId, self::$CONSTANT_ROW_COUNT_REPORT_EXCEPTIONS);
$reportSupportsEvolution = !in_array($reportUniqueId, self::$REPORTS_DISABLED_EVOLUTION_GRAPH);
if ($reportSupportsEvolution && $reportWithDimensionsSupportsEvolution) {
$parameters['period'] = $periodForMultiplePeriodGraph;
//.........这里部分代码省略.........
示例9: getSegmentWithVisitorId
private static function getSegmentWithVisitorId()
{
static $cached = null;
if ($cached === null) {
$segment = Request::getRawSegmentFromRequest();
if (!empty($segment)) {
$segment = urldecode($segment) . ';';
}
$idVisitor = Common::getRequestVar('visitorId', false);
if ($idVisitor === false) {
$idVisitor = Request::processRequest('Live.getMostRecentVisitorId');
}
$cached = urlencode($segment . 'visitorId==' . $idVisitor);
}
return $cached;
}
示例10: renderSidebar
/** Render the area left of the iframe */
public function renderSidebar()
{
$idSite = Common::getRequestVar('idSite');
$period = Common::getRequestVar('period');
$date = Common::getRequestVar('date');
$currentUrl = Common::getRequestVar('currentUrl');
$segment = Request::getRawSegmentFromRequest();
$currentUrl = Common::unsanitizeInputValue($currentUrl);
$segmentSidebar = '';
$normalizedCurrentUrl = PageUrl::excludeQueryParametersFromUrl($currentUrl, $idSite);
$normalizedCurrentUrl = Common::unsanitizeInputValue($normalizedCurrentUrl);
// load the appropriate row of the page urls report using the label filter
ArchivingHelper::reloadConfig();
$path = ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Action::TYPE_PAGE_URL);
$path = array_map('urlencode', $path);
$label = implode('>', $path);
$params = array('idSite' => $idSite, 'date' => $date, 'period' => $period, 'label' => $label, 'format' => 'original', 'format_metrics' => 0);
if (!empty($segment)) {
$params['segment'] = $segment;
}
$dataTable = Request::processRequest('Actions.getPageUrls', $params);
$formatter = new Metrics\Formatter\Html();
$data = array();
if ($dataTable->getRowsCount() > 0) {
$row = $dataTable->getFirstRow();
$translations = Metrics::getDefaultMetricTranslations();
$showMetrics = array('nb_hits', 'nb_visits', 'nb_users', 'nb_uniq_visitors', 'bounce_rate', 'exit_rate', 'avg_time_on_page');
$segmentSidebar = $row->getMetadata('segment');
if (!empty($segmentSidebar) && !empty($segment)) {
$segmentSidebar = $segment . ';' . $segmentSidebar;
}
foreach ($showMetrics as $metric) {
$value = $row->getColumn($metric);
if ($value === false) {
// skip unique visitors for period != day
continue;
}
if ($metric == 'bounce_rate' || $metric == 'exit_rate') {
$value = $formatter->getPrettyPercentFromQuotient($value);
} else {
if ($metric == 'avg_time_on_page') {
$value = $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = true);
}
}
$data[] = array('name' => $translations[$metric], 'value' => $value);
}
}
// generate page url string
foreach ($path as &$part) {
$part = preg_replace(';^/;', '', urldecode($part));
}
$page = '/' . implode('/', $path);
$page = preg_replace(';/index$;', '/', $page);
if ($page == '/') {
$page = '/index';
}
// render template
$view = new View('@Overlay/renderSidebar');
$view->data = $data;
$view->location = $page;
$view->normalizedUrl = $normalizedCurrentUrl;
$view->label = $label;
$view->idSite = $idSite;
$view->period = $period;
$view->date = $date;
$view->segment = $segmentSidebar;
$view->segmentDescription = $this->segmentFormatter->getHumanReadable($segment, $idSite);
$this->outputCORSHeaders();
return $view->render();
}
示例11: __construct
/**
* The constructor
* Initialize some local variables from the request
* @param int $idSite
* @param Date $date ($this->date from controller)
* @param null|string $graphType
* @throws Exception
*/
public function __construct($idSite, $date, $graphType = 'graphEvolution')
{
$this->apiMethod = Common::getRequestVar('apiMethod', '', 'string');
if (empty($this->apiMethod)) {
throw new Exception("Parameter apiMethod not set.");
}
$this->label = DataTablePostProcessor::getLabelFromRequest($_GET);
if (!is_array($this->label)) {
throw new Exception("Expected label to be an array, got instead: " . $this->label);
}
$this->label = $this->label[0];
if ($this->label === '') {
throw new Exception("Parameter label not set.");
}
$this->period = Common::getRequestVar('period', '', 'string');
PeriodFactory::checkPeriodIsEnabled($this->period);
$this->idSite = $idSite;
$this->graphType = $graphType;
if ($this->period != 'range') {
// handle day, week, month and year: display last X periods
$end = $date->toString();
list($this->date, $lastN) = EvolutionViz::getDateRangeAndLastN($this->period, $end);
}
$this->segment = \Piwik\API\Request::getRawSegmentFromRequest();
$this->loadEvolutionReport();
}
示例12: __construct
/**
* The constructor
* Initialize some local variables from the request
* @param int $idSite
* @param Date $date ($this->date from controller)
* @param null|string $graphType
* @throws Exception
*/
public function __construct($idSite, $date, $graphType = null)
{
$this->apiMethod = Common::getRequestVar('apiMethod', '', 'string');
if (empty($this->apiMethod)) {
throw new Exception("Parameter apiMethod not set.");
}
$this->label = ResponseBuilder::getLabelFromRequest($_GET);
$this->label = $this->label[0];
if ($this->label === '') {
throw new Exception("Parameter label not set.");
}
$this->period = Common::getRequestVar('period', '', 'string');
if (empty($this->period)) {
throw new Exception("Parameter period not set.");
}
$this->idSite = $idSite;
$this->graphType = $graphType;
if ($this->period != 'range') {
// handle day, week, month and year: display last X periods
$end = $date->toString();
list($this->date, $lastN) = EvolutionViz::getDateRangeAndLastN($this->period, $end);
}
$this->segment = \Piwik\API\Request::getRawSegmentFromRequest();
$this->loadEvolutionReport();
}