本文整理汇总了PHP中Piwik_API_Request::getGenericFiltersInformation方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_API_Request::getGenericFiltersInformation方法的具体用法?PHP Piwik_API_Request::getGenericFiltersInformation怎么用?PHP Piwik_API_Request::getGenericFiltersInformation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_API_Request
的用法示例。
在下文中一共展示了Piwik_API_Request::getGenericFiltersInformation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyDataTableGenericFilters
/**
* Apply generic filters to the DataTable object resulting from the API Call.
* Disable this feature by setting the parameter disable_generic_filters to 1 in the API call request.
*
* @param Piwik_DataTable
* @return void
*/
protected function applyDataTableGenericFilters($dataTable)
{
// Generic filters
// PatternFileName => Parameter names to match to constructor parameters
/*
* Order to apply the filters:
* 1 - Filter that remove filtered rows
* 2 - Filter that sort the remaining rows
* 3 - Filter that keep only a subset of the results
*/
$genericFilters = Piwik_API_Request::getGenericFiltersInformation();
// if the flag disable_generic_filters is defined we skip the generic filters
if (Piwik_Common::getRequestVar('disable_generic_filters', 'false', 'string', $this->requestToUse) != 'false') {
return;
}
foreach ($genericFilters as $filterName => $parameters) {
$filterParameters = array();
$exceptionRaised = false;
foreach ($parameters as $name => $info) {
// parameter type to cast to
$type = $info[0];
// default value if specified, when the parameter doesn't have a value
$defaultValue = null;
if (isset($info[1])) {
$defaultValue = $info[1];
}
try {
$value = Piwik_Common::getRequestVar($name, $defaultValue, $type, $this->requestToUse);
settype($value, $type);
$filterParameters[] = $value;
} catch (Exception $e) {
// print($e->getMessage());
$exceptionRaised = true;
break;
}
}
if (!$exceptionRaised) {
// a generic filter class name must follow this pattern
$class = "Piwik_DataTable_Filter_" . $filterName;
if ($filterName == 'Limit') {
$dataTable->setRowsCountBeforeLimitFilter();
}
// build the set of parameters for the filter
$filterParameters = array_merge(array($dataTable), $filterParameters);
// make a reflection object
$reflectionObj = new ReflectionClass($class);
// use Reflection to create a new instance, using the $args
$filter = $reflectionObj->newInstanceArgs($filterParameters);
}
}
}
示例2: getJavascriptVariablesToSet
/**
* 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
* - display the search box under the table
* - display the links Next & Previous under the 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_Request::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 getJavascriptVariablesToSet()
{
// build javascript variables to set
$javascriptVariablesToSet = array();
$genericFilters = Piwik_API_Request::getGenericFiltersInformation();
foreach ($genericFilters as $filter) {
foreach ($filter as $filterVariableName => $filterInfo) {
// if there is a default value for this filter variable we set it
// so that it is propagated to the javascript
if (isset($filterInfo[1])) {
$javascriptVariablesToSet[$filterVariableName] = $filterInfo[1];
// we set the default specified column and Order to sort by
// when this javascript variable is not set already
// for example during an AJAX call this variable will be set in the URL
// so this will not be executed (and the default sorted not be used as the sorted column might have changed in the meanwhile)
if (false !== ($defaultValue = $this->getDefault($filterVariableName))) {
$javascriptVariablesToSet[$filterVariableName] = $defaultValue;
}
}
}
}
// var_dump($javascriptVariablesToSet);exit;
// See
foreach ($_GET as $name => $value) {
try {
$requestValue = Piwik_Common::getRequestVar($name);
} catch (Exception $e) {
$requestValue = '';
}
$javascriptVariablesToSet[$name] = $requestValue;
}
// at this point there are some filters values we may have not set,
// case of the filter without default values and parameters set directly in this class
// for example setExcludeLowPopulation
// we go through all the $this->variablesDefault array and set the variables not set yet
foreach ($this->variablesDefault as $name => $value) {
if (!isset($javascriptVariablesToSet[$name])) {
$javascriptVariablesToSet[$name] = $value;
}
}
$javascriptVariablesToSet['module'] = $this->currentControllerName;
$javascriptVariablesToSet['action'] = $this->currentControllerAction;
if (!is_null($this->actionToLoadTheSubTable)) {
$javascriptVariablesToSet['actionToLoadTheSubTable'] = $this->actionToLoadTheSubTable;
}
// var_dump($this->variablesDefault);
// var_dump($javascriptVariablesToSet); exit;
if ($this->dataTable) {
$javascriptVariablesToSet['totalRows'] = $this->dataTable->getRowsCountBeforeLimitFilter();
}
$javascriptVariablesToSet['show_search'] = $this->getSearchBox();
$javascriptVariablesToSet['show_offset_information'] = $this->getOffsetInformation();
$javascriptVariablesToSet['show_exclude_low_population'] = $this->getExcludeLowPopulation();
// we escape the values that will be displayed in the javascript footer of each datatable
// to make sure there is malicious code injected (the value are already htmlspecialchar'ed as they
// are loaded with Piwik_Common::getRequestVar()
foreach ($javascriptVariablesToSet as &$value) {
$value = addslashes($value);
}
return $javascriptVariablesToSet;
}