本文整理汇总了PHP中Piwik\API\Request::processRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::processRequest方法的具体用法?PHP Request::processRequest怎么用?PHP Request::processRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\API\Request
的用法示例。
在下文中一共展示了Request::processRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContentNames
protected function getContentNames($websiteId = null, $date = null)
{
if (!is_null($websiteId)) {
return \Piwik\API\Request::processRequest('Contents.getContentNames', array('idSite' => $websiteId, 'period' => 'year', 'date' => $date));
}
return Db::fetchAssoc("select `idaction`, `name` from `{$this->tablePrefix}log_action` where `type` = ?", array(\Piwik\Tracker\Action::TYPE_CONTENT_NAME));
}
示例2: createTrackToOwnPiwikSetting
private function createTrackToOwnPiwikSetting()
{
return $this->makeSetting('ownPiwikSiteId', $default = 0, FieldConfig::TYPE_INT, function (FieldConfig $field) {
$field->title = 'Site Id';
// ideally we would use a SELECT control and let user choose an existing site but this would make performance slow
// since we'd always have to get all site ids in each request
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
$field->introduction = 'Send anonymize usage data to this Piwik';
$field->description = 'If specified, anonymized usage data will be sent to the specified site in this Piwik.';
$field->validate = function ($idSite) {
if (empty($idSite)) {
return;
}
if (!is_numeric($idSite)) {
throw new Exception("Site Id '{$idSite}' should be a number");
}
$idSite = (int) $idSite;
try {
$siteExists = Request::processRequest('SitesManager.getSiteFromId', array('idSite' => $idSite));
} catch (Exception $e) {
$siteExists = false;
}
if (!$siteExists) {
throw new Exception("The specified idSite '{$idSite}' does not exist");
}
};
});
}
示例3: elementLiveLoadBars
/**
* This widget shows horizontal bars with cpu load, memory use, network traffic and disk use
**/
function elementLiveLoadBars()
{
$result = Request::processRequest('SimpleSysMon.getLiveSysLoadData');
$view = new View('@SimpleSysMon/widgetLiveSysLoadBars.twig');
$this->setBasicVariablesView($view);
$view->sysLoad = array('avgload' => array('used' => round($result['AvgLoad'], 0), 'free' => round(100.0 - $result['AvgLoad'], 0)), 'memory' => array('procUsed' => round($result['UsedMemProc'], 0), 'procCached' => round($result['CachedMemProc'], 0), 'procFree' => round(100.0 - $result['UsedMemProc'], 0), 'valUsed' => round($result['UsedMemVal'], 0), 'valCached' => round($result['CachedMemVal'], 0), 'valFree' => round($result['FreeMemProc'], 0)), 'net' => array('procUpload' => round($result['UpNetProc'], 0), 'procDownload' => round($result['DownNetProc'], 0), 'procFree' => round(100.0 - $result['DownNetProc'], 0), 'valUpload' => round($result['UpNetVal'], 0), 'valDownload' => round($result['DownNetVal'], 0)), 'disk' => array('procUsed' => round($result['UsedDiskProc'], 0), 'procFree' => round($result['FreeDiskProc'], 0), 'valUsed' => round($result['UsedDiskVal'], 0), 'valFree' => round($result['FreeDiskVal'], 0)));
return $view->render();
}
示例4: get
/**
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @param bool|array $columns
* @return mixed
*/
public function get($idSite, $period, $date, $segment = false, $columns = false)
{
$segment = $this->appendReturningVisitorSegment($segment);
$this->unprefixColumns($columns);
$params = array('idSite' => $idSite, 'period' => $period, 'date' => $date, 'segment' => $segment, 'columns' => implode(',', $columns), 'format' => 'original', 'serialize' => 0);
$table = Request::processRequest('VisitsSummary.get', $params);
$this->prefixColumns($table, $period);
return $table;
}
示例5: findSegment
public function findSegment($segmentName, $idSite)
{
$segments = Request::processRequest('API.getSegmentsMetadata', array('idSites' => array($idSite)));
foreach ($segments as $segment) {
if ($segment['segment'] == $segmentName && !empty($segmentName)) {
return $segment;
}
}
}
示例6: render
public function render()
{
$userLogins = Request::processRequest('UsersManager.getUsersLogin', array('filter_limit' => '-1'));
$websites = Request::processRequest('SitesManager.getAllSites', array('filter_limit' => '-1'));
$numUsers = count($userLogins);
if (in_array('anonymous', $userLogins)) {
$numUsers--;
}
return $this->renderTemplate('getSystemSummary', array('numWebsites' => count($websites), 'numUsers' => $numUsers, 'numSegments' => $this->getNumSegments(), 'numPlugins' => $this->getNumPlugins(), 'piwikVersion' => Version::VERSION, 'mySqlVersion' => $this->getMySqlVersion(), 'phpVersion' => phpversion()));
}
示例7: executeSomeApiMethods
private function executeSomeApiMethods()
{
Request::processRequest('API.getPiwikVersion');
Request::processRequest('API.getSettings');
Request::processRequest('UsersManager.getUsers');
Request::processRequest('API.getPiwikVersion');
Request::processRequest('VisitsSummary.get', array('idSite' => 1, 'period' => 'year', 'date' => 'today'));
$date = Date::factory('today')->toString();
Request::processRequest('CoreAdminHome.invalidateArchivedReports', array('idSites' => '1', 'period' => 'year', 'dates' => $date, 'cascadeDown' => '1'));
}
示例8: goalConversionsOverview
public function goalConversionsOverview()
{
$view = new View('@Goals/conversionOverview');
$idGoal = Common::getRequestVar('idGoal', null, 'string');
$view->topDimensions = $this->getTopDimensions($idGoal);
$goalMetrics = Request::processRequest('Goals.get', array('idGoal' => $idGoal));
// conversion rate for new and returning visitors
$view->conversion_rate_returning = $this->formatConversionRate($goalMetrics, 'conversion_rate_returning_visit');
$view->conversion_rate_new = $this->formatConversionRate($goalMetrics, 'conversion_rate_new_visit');
$view->idGoal = $idGoal;
return $view->render();
}
示例9: getServerVisitCustomVariables
/**
* We send this data via server to not expose eg PHP version to users
* @return array
*/
public function getServerVisitCustomVariables()
{
$users = Request::processRequest('UsersManager.getUsers', array('filter_limit' => '-1'));
$websites = Request::processRequest('SitesManager.getAllSites', array('filter_limit' => '-1'));
$customVars = array(array('id' => 1, 'name' => 'Piwik Version', 'value' => StaticContainer::get('AnonymousPiwikUsageMeasurement.piwikVersion')), array('id' => 2, 'name' => 'PHP Version', 'value' => StaticContainer::get('AnonymousPiwikUsageMeasurement.phpVersion')), array('id' => 3, 'name' => 'Num Users', 'value' => count($users)), array('id' => 4, 'name' => 'Num Websites', 'value' => count($websites)));
$segmentClass = 'Piwik\\Plugins\\SegmentEditor\\Services\\StoredSegmentService';
if (class_exists($segmentClass)) {
$service = StaticContainer::get($segmentClass);
$segments = $service->getAllSegmentsAndIgnoreVisibility();
$customVars[] = array('id' => 5, 'name' => 'Num Segments', 'value' => count($segments));
}
return $customVars;
}
示例10: render
public function render()
{
$lastMinutes = Config::getInstance()->General[Controller::SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY];
$lastNData = Request::processRequest('Live.getCounters', array('lastMinutes' => $lastMinutes));
$view = new View('@Live/getSimpleLastVisitCount');
$view->lastMinutes = $lastMinutes;
$view->visitors = MetricsFormatter::getPrettyNumber($lastNData[0]['visitors']);
$view->visits = MetricsFormatter::getPrettyNumber($lastNData[0]['visits']);
$view->actions = MetricsFormatter::getPrettyNumber($lastNData[0]['actions']);
$view->refreshAfterXSecs = Config::getInstance()->General['live_widget_refresh_after_seconds'];
$view->translations = array('one_visitor' => Piwik::translate('Live_NbVisitor'), 'visitors' => Piwik::translate('Live_NbVisitors'), 'one_visit' => Piwik::translate('General_OneVisit'), 'visits' => Piwik::translate('General_NVisits'), 'one_action' => Piwik::translate('General_OneAction'), 'actions' => Piwik::translate('VisitsSummary_NbActionsDescription'), 'one_minute' => Piwik::translate('General_OneMinute'), 'minutes' => Piwik::translate('General_NMinutes'));
return $view->render();
}
示例11: getConversionForGoal
public function getConversionForGoal($idGoal, $idSite, $period, $date)
{
if (!$period || !$date || !$idSite) {
return false;
}
$datatable = Request::processRequest('Goals.get', array('idGoal' => $idGoal, 'period' => $period, 'date' => $date, 'idSite' => $idSite, 'serialize' => 0, 'segment' => false));
// we ignore the segment even if there is one set. We still want to show conversion overview if there are conversions
// in general but not for this segment
$dataRow = $datatable->getFirstRow();
if (!$dataRow) {
return false;
}
return $dataRow->getColumn('nb_conversions');
}
示例12: getConversionsOverview
public function getConversionsOverview()
{
$view = new View('@Ecommerce/conversionOverview');
$idGoal = Common::getRequestVar('idGoal', null, 'string');
$goalMetrics = Request::processRequest('Goals.get', array('idGoal' => $idGoal));
$dataRow = $goalMetrics->getFirstRow();
$view->idSite = Common::getRequestVar('idSite', null, 'int');
$view->idGoal = $idGoal;
if ($dataRow) {
$view->revenue = $dataRow->getColumn('revenue');
$view->revenue_subtotal = $dataRow->getColumn('revenue_subtotal');
$view->revenue_tax = $dataRow->getColumn('revenue_tax');
$view->revenue_shipping = $dataRow->getColumn('revenue_shipping');
$view->revenue_discount = $dataRow->getColumn('revenue_discount');
}
return $view->render();
}
示例13: getBannerstatistics
/**
* Another example method that returns a data table.
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getBannerstatistics($idSite, $period, $date, $segment = false, $idSubtable = false, $filter_limit = 10, $filter_sort_column = 'impressions', $filter_sort_order = 'desc', $filter_pattern = null)
{
$params = array('idSite' => $idSite, 'period' => $period, 'date' => $date, 'segment' => $segment, 'filter_limit' => $filter_limit, 'filter_sort_column' => $filter_sort_column, 'filter_sort_order' => $filter_sort_order, 'filter_pattern' => $filter_pattern);
if ($idSubtable) {
return $this->bannerStats($idSubtable, $params);
}
$contentNames = \Piwik\API\Request::processRequest('Contents.getContentNames', $params);
$bannerTable = new Datatable();
//$period = $dataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX);
//$bannerTable->setMetadataValues($contentNames->getAllTableMetadata());
foreach ($contentNames->getRows() as $contentName) {
$bannerName = $contentName->getColumn('label');
$row = new Row(array(Row::COLUMNS => array('Name' => $bannerName, 'Visits' => $contentName->getColumn('nb_visits'), 'Impressions' => $contentName->getColumn('nb_impressions'), 'Interactions' => $contentName->getColumn('nb_interactions'), 'Conversion rate' => $contentName->getColumn('interaction_rate')), Row::DATATABLE_ASSOCIATED => $bannerName));
$bannerTable->addRow($row);
}
return $bannerTable;
}
示例14: test_shouldTrackApiCall
public function test_shouldTrackApiCall()
{
Request::processRequest('API.getPiwikVersion');
Request::processRequest('API.getSettings');
Request::processRequest('UsersManager.getUsers');
Request::processRequest('API.getPiwikVersion');
$profiles = new Profiles();
$pushedProfiles = $profiles->popAll();
foreach ($pushedProfiles as &$pushedProfile) {
$this->assertNotEmpty($pushedProfile['creation_date']);
unset($pushedProfile['creation_date']);
$this->assertGreaterThanOrEqual(1, $pushedProfile['wall_time']);
unset($pushedProfile['wall_time']);
}
$expected = array(array('category' => 'API', 'name' => 'API', 'action' => 'API.getPiwikVersion', 'count' => '2'), array('category' => 'API', 'name' => 'API', 'action' => 'API.getSettings', 'count' => '1'), array('category' => 'API', 'name' => 'UsersManager', 'action' => 'UsersManager.getUsers', 'count' => '1'));
$this->assertEquals($expected, $pushedProfiles);
}
开发者ID:andrzejewsky,项目名称:plugin-AnonymousPiwikUsageMeasurement,代码行数:17,代码来源:AnonymousPiwikUsageMeasurementTest.php
示例15: test_forceNewVisit_shouldNotForceANewVisitWhenNoKeywordIsSetAndReferrerHostChanges
public function test_forceNewVisit_shouldNotForceANewVisitWhenNoKeywordIsSetAndReferrerHostChanges()
{
$dateTime = '2015-01-03';
$idSite = self::$fixture->idSite;
$t = Fixture::getTracker($idSite, $dateTime . ' 00:01:02', $defaultInit = true);
// track a campaign that was opened directly (no referrer)
$t->setUrlReferrer('http://www.google.com');
$t->setUrl('http://piwik.net/?pk_campaign=adwbuccc');
$t->doTrackPageView('My Title');
// navigate to next page on same page
$t->setUrlReferrer('http://piwik.net/?pk_campaign=adwbuccc');
$t->setCustomTrackingParameter('_rcn', 'adwbuccc');
// this parameter would be set by piwik.js from cookie / attributionInfo
$t->setCustomTrackingParameter('_rck', '');
// no keyword was used in previous tracking request
$t->setUrl('http://piwik.net/page1');
$t->doTrackPageView('Page 1');
/** @var DataTable $visits */
$visits = Request::processRequest('VisitsSummary.get', array('idSite' => 1, 'period' => 'day', 'date' => $dateTime));
$this->assertEquals(1, $visits->getFirstRow()->getColumn('nb_visits'));
$this->assertEquals(2, $visits->getFirstRow()->getColumn('nb_actions'));
}