General['API_datatable_default_limit'];
}
}
$request = new Request($token);
$response = $request->process();
if (is_array($response)) {
if ($format == 'original'
&& $serialize != 1
) {
Original::sendPlainTextHeader();
}
$response = var_export($response, true);
}
return $response;
}
public function listAllMethods()
{
Piwik::checkUserHasSomeViewAccess();
$ApiDocumentation = new DocumentationGenerator();
$prefixUrls = Common::getRequestVar('prefixUrl', 'https://demo.matomo.org/', 'string');
$hostname = parse_url($prefixUrls, PHP_URL_HOST);
if (empty($hostname) || !UrlHelper::isLookLikeUrl($prefixUrls) || strpos($prefixUrls, 'http') !== 0 || !Url::isValidHost($hostname)) {
$prefixUrls = '';
}
return $ApiDocumentation->getApiDocumentationAsStringForDeveloperReference($outputExampleUrls = true, $prefixUrls);
}
public function listAllAPI()
{
$view = new View("@API/listAllAPI");
$this->setGeneralVariablesView($view);
$ApiDocumentation = new DocumentationGenerator();
$view->countLoadedAPI = Proxy::getInstance()->getCountRegisteredClasses();
$view->list_api_methods_with_links = $ApiDocumentation->getApiDocumentationAsString();
return $view->render();
}
public function listSegments()
{
$segments = API::getInstance()->getSegmentsMetadata($this->idSite);
$tableDimensions = $tableMetrics = '';
$customVariables = 0;
$lastCategory = array();
foreach ($segments as $segment) {
$onlyDisplay = array('customVariableName1', 'customVariableName2',
'customVariableValue1', 'customVariableValue2',
'customVariablePageName1', 'customVariablePageValue1');
$customVariableWillBeDisplayed = in_array($segment['segment'], $onlyDisplay);
// Don't display more than 4 custom variables name/value rows
if ($segment['category'] == 'Custom Variables'
&& !$customVariableWillBeDisplayed
) {
continue;
}
$thisCategory = $segment['category'];
$output = '';
if (empty($lastCategory[$segment['type']])
|| $lastCategory[$segment['type']] != $thisCategory
) {
$output .= '
' . $thisCategory . ' |
';
}
$lastCategory[$segment['type']] = $thisCategory;
$exampleValues = isset($segment['acceptedValues'])
? 'Example values: ' . $segment['acceptedValues'] . '
'
: '';
$restrictedToAdmin = isset($segment['permission']) ? '
Note: This segment can only be used by an Admin user' : '';
$output .= '
' . $segment['segment'] . ' |
' . $segment['name'] . $restrictedToAdmin . ' ' . $exampleValues . ' |
';
// Show only 2 custom variables and display message for rest
if ($customVariableWillBeDisplayed) {
$customVariables++;
if ($customVariables == count($onlyDisplay)) {
$output .= ' There are 5 custom variables available, so you can segment across any segment name and value range.
For example, customVariableName1==Type;customVariableValue1==Customer
Returns all visitors that have the Custom Variable "Type" set to "Customer".
Custom Variables of scope "page" can be queried separately. For example, to query the Custom Variable of scope "page",
stored in index 1, you would use the segment customVariablePageName1==ArticleLanguage;customVariablePageValue1==FR
|
';
}
}
if ($segment['type'] == 'dimension') {
$tableDimensions .= $output;
} else {
$tableMetrics .= $output;
}
}
return "
Dimensions
Metrics
";
}
public function glossary()
{
Piwik::checkUserHasSomeViewAccess();
$reports = Request::processRequest('API', array('method' => 'API.getGlossaryReports', 'filter_limit' => -1));
$metrics = Request::processRequest('API', array('method' => 'API.getGlossaryMetrics', 'filter_limit' => -1));
$glossaryItems = array(
'metrics' => array(
'title' => Piwik::translate('General_Metrics'),
'entries' => $metrics
),
'reports' => array(
'title' => Piwik::translate('General_Reports'),
'entries' => $reports
)
);
/**
* Triggered to add or modify glossary items. You can either modify one of the existing core categories
* 'reports' and 'metrics' or add your own category.
*
* **Example**
*
* public function addGlossaryItems(&$glossaryItems)
* {
* $glossaryItems['users'] = array('title' => 'Users', 'entries' => array(
* array('name' => 'User1', 'documentation' => 'This user has ...'),
* array('name' => 'User2', 'documentation' => 'This user has ...'),
* ));
* $glossaryItems['reports']['entries'][] = array('name' => 'My Report', 'documentation' => 'This report has ...');
* }
*
* @param array &$glossaryItems An array containing all glossary items.
*/
Piwik::postEvent('API.addGlossaryItems', array(&$glossaryItems));
foreach ($glossaryItems as &$item) {
$item['letters'] = array();
foreach ($item['entries'] as &$entry) {
$cleanEntryName = preg_replace('/["\']/', '', $entry['name']);
$entry['letter'] = mb_strtoupper(substr($cleanEntryName, 0, 1));
$item['letters'][] = $entry['letter'];
}
$item['letters'] = array_unique($item['letters']);
sort($item['letters']);
}
return $this->renderTemplate('glossary', array(
'glossaryItems' => $glossaryItems,
));
}
}