id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
209,500 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.getNamePlural | public function getNamePlural()
{
if (!empty($this->namePlural)) {
return Piwik::translate($this->namePlural);
}
return $this->getName();
} | php | public function getNamePlural()
{
if (!empty($this->namePlural)) {
return Piwik::translate($this->namePlural);
}
return $this->getName();
} | [
"public",
"function",
"getNamePlural",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"namePlural",
")",
")",
"{",
"return",
"Piwik",
"::",
"translate",
"(",
"$",
"this",
"->",
"namePlural",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"}"
] | Returns a translated name in plural for this dimension.
@return string
@api since Piwik 3.2.0 | [
"Returns",
"a",
"translated",
"name",
"in",
"plural",
"for",
"this",
"dimension",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L358-L365 |
209,501 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.groupValue | public function groupValue($value, $idSite)
{
switch ($this->type) {
case Dimension::TYPE_URL:
return str_replace(array('http://', 'https://'), '', $value);
case Dimension::TYPE_BOOL:
return !empty($value) ? '1' : '0';
case Dimension::TYPE_DURATION_MS:
return number_format($value / 1000, 2); // because we divide we need to group them and cannot do this in formatting step
}
return $value;
} | php | public function groupValue($value, $idSite)
{
switch ($this->type) {
case Dimension::TYPE_URL:
return str_replace(array('http://', 'https://'), '', $value);
case Dimension::TYPE_BOOL:
return !empty($value) ? '1' : '0';
case Dimension::TYPE_DURATION_MS:
return number_format($value / 1000, 2); // because we divide we need to group them and cannot do this in formatting step
}
return $value;
} | [
"public",
"function",
"groupValue",
"(",
"$",
"value",
",",
"$",
"idSite",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"Dimension",
"::",
"TYPE_URL",
":",
"return",
"str_replace",
"(",
"array",
"(",
"'http://'",
",",
"'https://'",
")",
",",
"''",
",",
"$",
"value",
")",
";",
"case",
"Dimension",
"::",
"TYPE_BOOL",
":",
"return",
"!",
"empty",
"(",
"$",
"value",
")",
"?",
"'1'",
":",
"'0'",
";",
"case",
"Dimension",
"::",
"TYPE_DURATION_MS",
":",
"return",
"number_format",
"(",
"$",
"value",
"/",
"1000",
",",
"2",
")",
";",
"// because we divide we need to group them and cannot do this in formatting step",
"}",
"return",
"$",
"value",
";",
"}"
] | A dimension should group values by using this method. Otherwise the same row may appear several times.
@param mixed $value
@param int $idSite
@return mixed
@api since Piwik 3.2.0 | [
"A",
"dimension",
"should",
"group",
"values",
"by",
"using",
"this",
"method",
".",
"Otherwise",
"the",
"same",
"row",
"may",
"appear",
"several",
"times",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L405-L416 |
209,502 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.formatValue | public function formatValue($value, $idSite, Formatter $formatter)
{
switch ($this->type) {
case Dimension::TYPE_BOOL:
if (empty($value)) {
return Piwik::translate('General_No');
}
return Piwik::translate('General_Yes');
case Dimension::TYPE_ENUM:
$values = $this->getEnumColumnValues();
if (isset($values[$value])) {
return $values[$value];
}
break;
case Dimension::TYPE_MONEY:
return $formatter->getPrettyMoney($value, $idSite);
case Dimension::TYPE_FLOAT:
return $formatter->getPrettyNumber((float) $value, $precision = 2);
case Dimension::TYPE_NUMBER:
return $formatter->getPrettyNumber($value);
case Dimension::TYPE_DURATION_S:
return $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = false);
case Dimension::TYPE_DURATION_MS:
return $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = true);
case Dimension::TYPE_PERCENT:
return $formatter->getPrettyPercentFromQuotient($value);
case Dimension::TYPE_BYTE:
return $formatter->getPrettySizeFromBytes($value);
}
return $value;
} | php | public function formatValue($value, $idSite, Formatter $formatter)
{
switch ($this->type) {
case Dimension::TYPE_BOOL:
if (empty($value)) {
return Piwik::translate('General_No');
}
return Piwik::translate('General_Yes');
case Dimension::TYPE_ENUM:
$values = $this->getEnumColumnValues();
if (isset($values[$value])) {
return $values[$value];
}
break;
case Dimension::TYPE_MONEY:
return $formatter->getPrettyMoney($value, $idSite);
case Dimension::TYPE_FLOAT:
return $formatter->getPrettyNumber((float) $value, $precision = 2);
case Dimension::TYPE_NUMBER:
return $formatter->getPrettyNumber($value);
case Dimension::TYPE_DURATION_S:
return $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = false);
case Dimension::TYPE_DURATION_MS:
return $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = true);
case Dimension::TYPE_PERCENT:
return $formatter->getPrettyPercentFromQuotient($value);
case Dimension::TYPE_BYTE:
return $formatter->getPrettySizeFromBytes($value);
}
return $value;
} | [
"public",
"function",
"formatValue",
"(",
"$",
"value",
",",
"$",
"idSite",
",",
"Formatter",
"$",
"formatter",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"Dimension",
"::",
"TYPE_BOOL",
":",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"Piwik",
"::",
"translate",
"(",
"'General_No'",
")",
";",
"}",
"return",
"Piwik",
"::",
"translate",
"(",
"'General_Yes'",
")",
";",
"case",
"Dimension",
"::",
"TYPE_ENUM",
":",
"$",
"values",
"=",
"$",
"this",
"->",
"getEnumColumnValues",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"values",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"$",
"values",
"[",
"$",
"value",
"]",
";",
"}",
"break",
";",
"case",
"Dimension",
"::",
"TYPE_MONEY",
":",
"return",
"$",
"formatter",
"->",
"getPrettyMoney",
"(",
"$",
"value",
",",
"$",
"idSite",
")",
";",
"case",
"Dimension",
"::",
"TYPE_FLOAT",
":",
"return",
"$",
"formatter",
"->",
"getPrettyNumber",
"(",
"(",
"float",
")",
"$",
"value",
",",
"$",
"precision",
"=",
"2",
")",
";",
"case",
"Dimension",
"::",
"TYPE_NUMBER",
":",
"return",
"$",
"formatter",
"->",
"getPrettyNumber",
"(",
"$",
"value",
")",
";",
"case",
"Dimension",
"::",
"TYPE_DURATION_S",
":",
"return",
"$",
"formatter",
"->",
"getPrettyTimeFromSeconds",
"(",
"$",
"value",
",",
"$",
"displayAsSentence",
"=",
"false",
")",
";",
"case",
"Dimension",
"::",
"TYPE_DURATION_MS",
":",
"return",
"$",
"formatter",
"->",
"getPrettyTimeFromSeconds",
"(",
"$",
"value",
",",
"$",
"displayAsSentence",
"=",
"true",
")",
";",
"case",
"Dimension",
"::",
"TYPE_PERCENT",
":",
"return",
"$",
"formatter",
"->",
"getPrettyPercentFromQuotient",
"(",
"$",
"value",
")",
";",
"case",
"Dimension",
"::",
"TYPE_BYTE",
":",
"return",
"$",
"formatter",
"->",
"getPrettySizeFromBytes",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Formats the dimension value. By default, the dimension is formatted based on the set dimension type.
@param mixed $value
@param int $idSite
@param Formatter $formatter
@return mixed
@api since Piwik 3.2.0 | [
"Formats",
"the",
"dimension",
"value",
".",
"By",
"default",
"the",
"dimension",
"is",
"formatted",
"based",
"on",
"the",
"set",
"dimension",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L427-L459 |
209,503 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.configureMetrics | public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
{
if ($this->getMetricId() && $this->dbTableName && $this->columnName && $this->getNamePlural()) {
if (in_array($this->getType(), array(self::TYPE_DATETIME, self::TYPE_DATE, self::TYPE_TIME, self::TYPE_TIMESTAMP))) {
// we do not generate any metrics from these types
return;
} elseif (in_array($this->getType(), array(self::TYPE_URL, self::TYPE_TEXT, self::TYPE_BINARY, self::TYPE_ENUM))) {
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_UNIQUE);
$metricsList->addMetric($metric);
} elseif (in_array($this->getType(), array(self::TYPE_BOOL))) {
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_SUM);
$metricsList->addMetric($metric);
} else {
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_SUM);
$metricsList->addMetric($metric);
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_MAX);
$metricsList->addMetric($metric);
}
}
} | php | public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory)
{
if ($this->getMetricId() && $this->dbTableName && $this->columnName && $this->getNamePlural()) {
if (in_array($this->getType(), array(self::TYPE_DATETIME, self::TYPE_DATE, self::TYPE_TIME, self::TYPE_TIMESTAMP))) {
// we do not generate any metrics from these types
return;
} elseif (in_array($this->getType(), array(self::TYPE_URL, self::TYPE_TEXT, self::TYPE_BINARY, self::TYPE_ENUM))) {
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_UNIQUE);
$metricsList->addMetric($metric);
} elseif (in_array($this->getType(), array(self::TYPE_BOOL))) {
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_SUM);
$metricsList->addMetric($metric);
} else {
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_SUM);
$metricsList->addMetric($metric);
$metric = $dimensionMetricFactory->createMetric(ArchivedMetric::AGGREGATION_MAX);
$metricsList->addMetric($metric);
}
}
} | [
"public",
"function",
"configureMetrics",
"(",
"MetricsList",
"$",
"metricsList",
",",
"DimensionMetricFactory",
"$",
"dimensionMetricFactory",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getMetricId",
"(",
")",
"&&",
"$",
"this",
"->",
"dbTableName",
"&&",
"$",
"this",
"->",
"columnName",
"&&",
"$",
"this",
"->",
"getNamePlural",
"(",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"array",
"(",
"self",
"::",
"TYPE_DATETIME",
",",
"self",
"::",
"TYPE_DATE",
",",
"self",
"::",
"TYPE_TIME",
",",
"self",
"::",
"TYPE_TIMESTAMP",
")",
")",
")",
"{",
"// we do not generate any metrics from these types",
"return",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"array",
"(",
"self",
"::",
"TYPE_URL",
",",
"self",
"::",
"TYPE_TEXT",
",",
"self",
"::",
"TYPE_BINARY",
",",
"self",
"::",
"TYPE_ENUM",
")",
")",
")",
"{",
"$",
"metric",
"=",
"$",
"dimensionMetricFactory",
"->",
"createMetric",
"(",
"ArchivedMetric",
"::",
"AGGREGATION_UNIQUE",
")",
";",
"$",
"metricsList",
"->",
"addMetric",
"(",
"$",
"metric",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"array",
"(",
"self",
"::",
"TYPE_BOOL",
")",
")",
")",
"{",
"$",
"metric",
"=",
"$",
"dimensionMetricFactory",
"->",
"createMetric",
"(",
"ArchivedMetric",
"::",
"AGGREGATION_SUM",
")",
";",
"$",
"metricsList",
"->",
"addMetric",
"(",
"$",
"metric",
")",
";",
"}",
"else",
"{",
"$",
"metric",
"=",
"$",
"dimensionMetricFactory",
"->",
"createMetric",
"(",
"ArchivedMetric",
"::",
"AGGREGATION_SUM",
")",
";",
"$",
"metricsList",
"->",
"addMetric",
"(",
"$",
"metric",
")",
";",
"$",
"metric",
"=",
"$",
"dimensionMetricFactory",
"->",
"createMetric",
"(",
"ArchivedMetric",
"::",
"AGGREGATION_MAX",
")",
";",
"$",
"metricsList",
"->",
"addMetric",
"(",
"$",
"metric",
")",
";",
"}",
"}",
"}"
] | Configures metrics for this dimension.
For certain dimension types, some metrics will be added automatically.
@param MetricsList $metricsList
@param DimensionMetricFactory $dimensionMetricFactory | [
"Configures",
"metrics",
"for",
"this",
"dimension",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L492-L512 |
209,504 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.hasImplementedEvent | public function hasImplementedEvent($method)
{
$method = new \ReflectionMethod($this, $method);
$declaringClass = $method->getDeclaringClass();
return 0 === strpos($declaringClass->name, 'Piwik\Plugins');
} | php | public function hasImplementedEvent($method)
{
$method = new \ReflectionMethod($this, $method);
$declaringClass = $method->getDeclaringClass();
return 0 === strpos($declaringClass->name, 'Piwik\Plugins');
} | [
"public",
"function",
"hasImplementedEvent",
"(",
"$",
"method",
")",
"{",
"$",
"method",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"this",
",",
"$",
"method",
")",
";",
"$",
"declaringClass",
"=",
"$",
"method",
"->",
"getDeclaringClass",
"(",
")",
";",
"return",
"0",
"===",
"strpos",
"(",
"$",
"declaringClass",
"->",
"name",
",",
"'Piwik\\Plugins'",
")",
";",
"}"
] | Check whether a dimension has overwritten a specific method.
@param $method
@return bool
@ignore | [
"Check",
"whether",
"a",
"dimension",
"has",
"overwritten",
"a",
"specific",
"method",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L520-L526 |
209,505 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.getSqlSegment | public function getSqlSegment()
{
if (!empty($this->sqlSegment)) {
return $this->sqlSegment;
}
if ($this->dbTableName && $this->columnName) {
return $this->dbTableName . '.' . $this->columnName;
}
} | php | public function getSqlSegment()
{
if (!empty($this->sqlSegment)) {
return $this->sqlSegment;
}
if ($this->dbTableName && $this->columnName) {
return $this->dbTableName . '.' . $this->columnName;
}
} | [
"public",
"function",
"getSqlSegment",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"sqlSegment",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sqlSegment",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"dbTableName",
"&&",
"$",
"this",
"->",
"columnName",
")",
"{",
"return",
"$",
"this",
"->",
"dbTableName",
".",
"'.'",
".",
"$",
"this",
"->",
"columnName",
";",
"}",
"}"
] | Returns a sql segment expression for this dimension.
@return string
@api since Piwik 3.2.0 | [
"Returns",
"a",
"sql",
"segment",
"expression",
"for",
"this",
"dimension",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L677-L686 |
209,506 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.getAllDimensions | public static function getAllDimensions()
{
$cacheId = CacheId::siteAware(CacheId::pluginAware('AllDimensions'));
$cache = PiwikCache::getTransientCache();
if (!$cache->contains($cacheId)) {
$plugins = PluginManager::getInstance()->getPluginsLoadedAndActivated();
$instances = array();
/**
* Triggered to add new dimensions that cannot be picked up automatically by the platform.
* This is useful if the plugin allows a user to create reports / dimensions dynamically. For example
* CustomDimensions or CustomVariables. There are a variable number of dimensions in this case and it
* wouldn't be really possible to create a report file for one of these dimensions as it is not known
* how many Custom Dimensions will exist.
*
* **Example**
*
* public function addDimension(&$dimensions)
* {
* $dimensions[] = new MyCustomDimension();
* }
*
* @param Dimension[] $reports An array of dimensions
*/
Piwik::postEvent('Dimension.addDimensions', array(&$instances));
foreach ($plugins as $plugin) {
foreach (self::getDimensions($plugin) as $instance) {
$instances[] = $instance;
}
}
/**
* Triggered to filter / restrict dimensions.
*
* **Example**
*
* public function filterDimensions(&$dimensions)
* {
* foreach ($dimensions as $index => $dimension) {
* if ($dimension->getName() === 'Page URL') {}
* unset($dimensions[$index]); // remove this dimension
* }
* }
* }
*
* @param Dimension[] $dimensions An array of dimensions
*/
Piwik::postEvent('Dimension.filterDimensions', array(&$instances));
$cache->save($cacheId, $instances);
}
return $cache->fetch($cacheId);
} | php | public static function getAllDimensions()
{
$cacheId = CacheId::siteAware(CacheId::pluginAware('AllDimensions'));
$cache = PiwikCache::getTransientCache();
if (!$cache->contains($cacheId)) {
$plugins = PluginManager::getInstance()->getPluginsLoadedAndActivated();
$instances = array();
/**
* Triggered to add new dimensions that cannot be picked up automatically by the platform.
* This is useful if the plugin allows a user to create reports / dimensions dynamically. For example
* CustomDimensions or CustomVariables. There are a variable number of dimensions in this case and it
* wouldn't be really possible to create a report file for one of these dimensions as it is not known
* how many Custom Dimensions will exist.
*
* **Example**
*
* public function addDimension(&$dimensions)
* {
* $dimensions[] = new MyCustomDimension();
* }
*
* @param Dimension[] $reports An array of dimensions
*/
Piwik::postEvent('Dimension.addDimensions', array(&$instances));
foreach ($plugins as $plugin) {
foreach (self::getDimensions($plugin) as $instance) {
$instances[] = $instance;
}
}
/**
* Triggered to filter / restrict dimensions.
*
* **Example**
*
* public function filterDimensions(&$dimensions)
* {
* foreach ($dimensions as $index => $dimension) {
* if ($dimension->getName() === 'Page URL') {}
* unset($dimensions[$index]); // remove this dimension
* }
* }
* }
*
* @param Dimension[] $dimensions An array of dimensions
*/
Piwik::postEvent('Dimension.filterDimensions', array(&$instances));
$cache->save($cacheId, $instances);
}
return $cache->fetch($cacheId);
} | [
"public",
"static",
"function",
"getAllDimensions",
"(",
")",
"{",
"$",
"cacheId",
"=",
"CacheId",
"::",
"siteAware",
"(",
"CacheId",
"::",
"pluginAware",
"(",
"'AllDimensions'",
")",
")",
";",
"$",
"cache",
"=",
"PiwikCache",
"::",
"getTransientCache",
"(",
")",
";",
"if",
"(",
"!",
"$",
"cache",
"->",
"contains",
"(",
"$",
"cacheId",
")",
")",
"{",
"$",
"plugins",
"=",
"PluginManager",
"::",
"getInstance",
"(",
")",
"->",
"getPluginsLoadedAndActivated",
"(",
")",
";",
"$",
"instances",
"=",
"array",
"(",
")",
";",
"/**\n * Triggered to add new dimensions that cannot be picked up automatically by the platform.\n * This is useful if the plugin allows a user to create reports / dimensions dynamically. For example\n * CustomDimensions or CustomVariables. There are a variable number of dimensions in this case and it\n * wouldn't be really possible to create a report file for one of these dimensions as it is not known\n * how many Custom Dimensions will exist.\n *\n * **Example**\n *\n * public function addDimension(&$dimensions)\n * {\n * $dimensions[] = new MyCustomDimension();\n * }\n *\n * @param Dimension[] $reports An array of dimensions\n */",
"Piwik",
"::",
"postEvent",
"(",
"'Dimension.addDimensions'",
",",
"array",
"(",
"&",
"$",
"instances",
")",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"foreach",
"(",
"self",
"::",
"getDimensions",
"(",
"$",
"plugin",
")",
"as",
"$",
"instance",
")",
"{",
"$",
"instances",
"[",
"]",
"=",
"$",
"instance",
";",
"}",
"}",
"/**\n * Triggered to filter / restrict dimensions.\n *\n * **Example**\n *\n * public function filterDimensions(&$dimensions)\n * {\n * foreach ($dimensions as $index => $dimension) {\n * if ($dimension->getName() === 'Page URL') {}\n * unset($dimensions[$index]); // remove this dimension\n * }\n * }\n * }\n *\n * @param Dimension[] $dimensions An array of dimensions\n */",
"Piwik",
"::",
"postEvent",
"(",
"'Dimension.filterDimensions'",
",",
"array",
"(",
"&",
"$",
"instances",
")",
")",
";",
"$",
"cache",
"->",
"save",
"(",
"$",
"cacheId",
",",
"$",
"instances",
")",
";",
"}",
"return",
"$",
"cache",
"->",
"fetch",
"(",
"$",
"cacheId",
")",
";",
"}"
] | Gets an instance of all available visit, action and conversion dimension.
@return Dimension[] | [
"Gets",
"an",
"instance",
"of",
"all",
"available",
"visit",
"action",
"and",
"conversion",
"dimension",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L748-L803 |
209,507 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.getModule | public function getModule()
{
$id = $this->getId();
if (empty($id)) {
throw new Exception("Invalid dimension ID: '$id'.");
}
$parts = explode('.', $id);
return reset($parts);
} | php | public function getModule()
{
$id = $this->getId();
if (empty($id)) {
throw new Exception("Invalid dimension ID: '$id'.");
}
$parts = explode('.', $id);
return reset($parts);
} | [
"public",
"function",
"getModule",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid dimension ID: '$id'.\"",
")",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"id",
")",
";",
"return",
"reset",
"(",
"$",
"parts",
")",
";",
"}"
] | Returns the name of the plugin that contains this Dimension.
@return string
@throws Exception if the Dimension is not located within a Plugin module.
@api | [
"Returns",
"the",
"name",
"of",
"the",
"plugin",
"that",
"contains",
"this",
"Dimension",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L840-L849 |
209,508 | matomo-org/matomo | core/Columns/Dimension.php | Dimension.getType | public function getType()
{
if (!empty($this->type)) {
return $this->type;
}
if ($this->getDbColumnJoin()) {
// best guess
return self::TYPE_TEXT;
}
if ($this->getEnumColumnValues()) {
// best guess
return self::TYPE_ENUM;
}
if (!empty($this->columnType)) {
// best guess
$type = strtolower($this->columnType);
if (strpos($type, 'datetime') !== false) {
return self::TYPE_DATETIME;
} elseif (strpos($type, 'timestamp') !== false) {
return self::TYPE_TIMESTAMP;
} elseif (strpos($type, 'date') !== false) {
return self::TYPE_DATE;
} elseif (strpos($type, 'time') !== false) {
return self::TYPE_TIME;
} elseif (strpos($type, 'float') !== false) {
return self::TYPE_FLOAT;
} elseif (strpos($type, 'decimal') !== false) {
return self::TYPE_FLOAT;
} elseif (strpos($type, 'int') !== false) {
return self::TYPE_NUMBER;
} elseif (strpos($type, 'binary') !== false) {
return self::TYPE_BINARY;
}
}
return self::TYPE_TEXT;
} | php | public function getType()
{
if (!empty($this->type)) {
return $this->type;
}
if ($this->getDbColumnJoin()) {
// best guess
return self::TYPE_TEXT;
}
if ($this->getEnumColumnValues()) {
// best guess
return self::TYPE_ENUM;
}
if (!empty($this->columnType)) {
// best guess
$type = strtolower($this->columnType);
if (strpos($type, 'datetime') !== false) {
return self::TYPE_DATETIME;
} elseif (strpos($type, 'timestamp') !== false) {
return self::TYPE_TIMESTAMP;
} elseif (strpos($type, 'date') !== false) {
return self::TYPE_DATE;
} elseif (strpos($type, 'time') !== false) {
return self::TYPE_TIME;
} elseif (strpos($type, 'float') !== false) {
return self::TYPE_FLOAT;
} elseif (strpos($type, 'decimal') !== false) {
return self::TYPE_FLOAT;
} elseif (strpos($type, 'int') !== false) {
return self::TYPE_NUMBER;
} elseif (strpos($type, 'binary') !== false) {
return self::TYPE_BINARY;
}
}
return self::TYPE_TEXT;
} | [
"public",
"function",
"getType",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"type",
")",
")",
"{",
"return",
"$",
"this",
"->",
"type",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getDbColumnJoin",
"(",
")",
")",
"{",
"// best guess",
"return",
"self",
"::",
"TYPE_TEXT",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getEnumColumnValues",
"(",
")",
")",
"{",
"// best guess",
"return",
"self",
"::",
"TYPE_ENUM",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"columnType",
")",
")",
"{",
"// best guess",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"columnType",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"type",
",",
"'datetime'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_DATETIME",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"type",
",",
"'timestamp'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_TIMESTAMP",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"type",
",",
"'date'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_DATE",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"type",
",",
"'time'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_TIME",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"type",
",",
"'float'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_FLOAT",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"type",
",",
"'decimal'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_FLOAT",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"type",
",",
"'int'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_NUMBER",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"type",
",",
"'binary'",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"TYPE_BINARY",
";",
"}",
"}",
"return",
"self",
"::",
"TYPE_TEXT",
";",
"}"
] | Returns the type of the dimension which defines what kind of value this dimension stores.
@return string
@api since Piwik 3.2.0 | [
"Returns",
"the",
"type",
"of",
"the",
"dimension",
"which",
"defines",
"what",
"kind",
"of",
"value",
"this",
"dimension",
"stores",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L856-L895 |
209,509 | matomo-org/matomo | core/Scheduler/Scheduler.php | Scheduler.run | public function run()
{
$tasks = $this->loader->loadTasks();
$this->logger->debug('{count} scheduled tasks loaded', array('count' => count($tasks)));
// remove from timetable tasks that are not active anymore
$this->timetable->removeInactiveTasks($tasks);
$this->logger->info("Starting Scheduled tasks... ");
// for every priority level, starting with the highest and concluding with the lowest
$executionResults = array();
for ($priority = Task::HIGHEST_PRIORITY; $priority <= Task::LOWEST_PRIORITY; ++$priority) {
$this->logger->debug("Executing tasks with priority {priority}:", array('priority' => $priority));
// loop through each task
foreach ($tasks as $task) {
// if the task does not have the current priority level, don't execute it yet
if ($task->getPriority() != $priority) {
continue;
}
$taskName = $task->getName();
$shouldExecuteTask = $this->timetable->shouldExecuteTask($taskName);
if ($this->timetable->taskShouldBeRescheduled($taskName)) {
$rescheduledDate = $this->timetable->rescheduleTask($task);
$this->logger->debug("Task {task} is scheduled to run again for {date}.", array('task' => $taskName, 'date' => $rescheduledDate));
}
/**
* Triggered before a task is executed.
*
* A plugin can listen to it and modify whether a specific task should be executed or not. This way
* you can force certain tasks to be executed more often or for example to be never executed.
*
* @param bool &$shouldExecuteTask Decides whether the task will be executed.
* @param Task $task The task that is about to be executed.
*/
Piwik::postEvent('ScheduledTasks.shouldExecuteTask', array(&$shouldExecuteTask, $task));
if ($shouldExecuteTask) {
$message = $this->executeTask($task);
$executionResults[] = array('task' => $taskName, 'output' => $message);
}
}
}
$this->logger->info("done");
return $executionResults;
} | php | public function run()
{
$tasks = $this->loader->loadTasks();
$this->logger->debug('{count} scheduled tasks loaded', array('count' => count($tasks)));
// remove from timetable tasks that are not active anymore
$this->timetable->removeInactiveTasks($tasks);
$this->logger->info("Starting Scheduled tasks... ");
// for every priority level, starting with the highest and concluding with the lowest
$executionResults = array();
for ($priority = Task::HIGHEST_PRIORITY; $priority <= Task::LOWEST_PRIORITY; ++$priority) {
$this->logger->debug("Executing tasks with priority {priority}:", array('priority' => $priority));
// loop through each task
foreach ($tasks as $task) {
// if the task does not have the current priority level, don't execute it yet
if ($task->getPriority() != $priority) {
continue;
}
$taskName = $task->getName();
$shouldExecuteTask = $this->timetable->shouldExecuteTask($taskName);
if ($this->timetable->taskShouldBeRescheduled($taskName)) {
$rescheduledDate = $this->timetable->rescheduleTask($task);
$this->logger->debug("Task {task} is scheduled to run again for {date}.", array('task' => $taskName, 'date' => $rescheduledDate));
}
/**
* Triggered before a task is executed.
*
* A plugin can listen to it and modify whether a specific task should be executed or not. This way
* you can force certain tasks to be executed more often or for example to be never executed.
*
* @param bool &$shouldExecuteTask Decides whether the task will be executed.
* @param Task $task The task that is about to be executed.
*/
Piwik::postEvent('ScheduledTasks.shouldExecuteTask', array(&$shouldExecuteTask, $task));
if ($shouldExecuteTask) {
$message = $this->executeTask($task);
$executionResults[] = array('task' => $taskName, 'output' => $message);
}
}
}
$this->logger->info("done");
return $executionResults;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"tasks",
"=",
"$",
"this",
"->",
"loader",
"->",
"loadTasks",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'{count} scheduled tasks loaded'",
",",
"array",
"(",
"'count'",
"=>",
"count",
"(",
"$",
"tasks",
")",
")",
")",
";",
"// remove from timetable tasks that are not active anymore",
"$",
"this",
"->",
"timetable",
"->",
"removeInactiveTasks",
"(",
"$",
"tasks",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Starting Scheduled tasks... \"",
")",
";",
"// for every priority level, starting with the highest and concluding with the lowest",
"$",
"executionResults",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"priority",
"=",
"Task",
"::",
"HIGHEST_PRIORITY",
";",
"$",
"priority",
"<=",
"Task",
"::",
"LOWEST_PRIORITY",
";",
"++",
"$",
"priority",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Executing tasks with priority {priority}:\"",
",",
"array",
"(",
"'priority'",
"=>",
"$",
"priority",
")",
")",
";",
"// loop through each task",
"foreach",
"(",
"$",
"tasks",
"as",
"$",
"task",
")",
"{",
"// if the task does not have the current priority level, don't execute it yet",
"if",
"(",
"$",
"task",
"->",
"getPriority",
"(",
")",
"!=",
"$",
"priority",
")",
"{",
"continue",
";",
"}",
"$",
"taskName",
"=",
"$",
"task",
"->",
"getName",
"(",
")",
";",
"$",
"shouldExecuteTask",
"=",
"$",
"this",
"->",
"timetable",
"->",
"shouldExecuteTask",
"(",
"$",
"taskName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"timetable",
"->",
"taskShouldBeRescheduled",
"(",
"$",
"taskName",
")",
")",
"{",
"$",
"rescheduledDate",
"=",
"$",
"this",
"->",
"timetable",
"->",
"rescheduleTask",
"(",
"$",
"task",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Task {task} is scheduled to run again for {date}.\"",
",",
"array",
"(",
"'task'",
"=>",
"$",
"taskName",
",",
"'date'",
"=>",
"$",
"rescheduledDate",
")",
")",
";",
"}",
"/**\n * Triggered before a task is executed.\n *\n * A plugin can listen to it and modify whether a specific task should be executed or not. This way\n * you can force certain tasks to be executed more often or for example to be never executed.\n *\n * @param bool &$shouldExecuteTask Decides whether the task will be executed.\n * @param Task $task The task that is about to be executed.\n */",
"Piwik",
"::",
"postEvent",
"(",
"'ScheduledTasks.shouldExecuteTask'",
",",
"array",
"(",
"&",
"$",
"shouldExecuteTask",
",",
"$",
"task",
")",
")",
";",
"if",
"(",
"$",
"shouldExecuteTask",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"executeTask",
"(",
"$",
"task",
")",
";",
"$",
"executionResults",
"[",
"]",
"=",
"array",
"(",
"'task'",
"=>",
"$",
"taskName",
",",
"'output'",
"=>",
"$",
"message",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"done\"",
")",
";",
"return",
"$",
"executionResults",
";",
"}"
] | Executes tasks that are scheduled to run, then reschedules them.
@return array An array describing the results of scheduled task execution. Each element
in the array will have the following format:
```
array(
'task' => 'task name',
'output' => '... task output ...'
)
``` | [
"Executes",
"tasks",
"that",
"are",
"scheduled",
"to",
"run",
"then",
"reschedules",
"them",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Scheduler/Scheduler.php#L92-L146 |
209,510 | matomo-org/matomo | core/Scheduler/Scheduler.php | Scheduler.runTaskNow | public function runTaskNow($taskName)
{
$tasks = $this->loader->loadTasks();
foreach ($tasks as $task) {
if ($task->getName() === $taskName) {
return $this->executeTask($task);
}
}
throw new \InvalidArgumentException('Task ' . $taskName . ' not found');
} | php | public function runTaskNow($taskName)
{
$tasks = $this->loader->loadTasks();
foreach ($tasks as $task) {
if ($task->getName() === $taskName) {
return $this->executeTask($task);
}
}
throw new \InvalidArgumentException('Task ' . $taskName . ' not found');
} | [
"public",
"function",
"runTaskNow",
"(",
"$",
"taskName",
")",
"{",
"$",
"tasks",
"=",
"$",
"this",
"->",
"loader",
"->",
"loadTasks",
"(",
")",
";",
"foreach",
"(",
"$",
"tasks",
"as",
"$",
"task",
")",
"{",
"if",
"(",
"$",
"task",
"->",
"getName",
"(",
")",
"===",
"$",
"taskName",
")",
"{",
"return",
"$",
"this",
"->",
"executeTask",
"(",
"$",
"task",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Task '",
".",
"$",
"taskName",
".",
"' not found'",
")",
";",
"}"
] | Run a specific task now. Will ignore the schedule completely.
@param string $taskName
@return string Task output. | [
"Run",
"a",
"specific",
"task",
"now",
".",
"Will",
"ignore",
"the",
"schedule",
"completely",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Scheduler/Scheduler.php#L154-L165 |
209,511 | matomo-org/matomo | core/Scheduler/Scheduler.php | Scheduler.getTaskList | public function getTaskList()
{
$tasks = $this->loader->loadTasks();
return array_map(function (Task $task) {
return $task->getName();
}, $tasks);
} | php | public function getTaskList()
{
$tasks = $this->loader->loadTasks();
return array_map(function (Task $task) {
return $task->getName();
}, $tasks);
} | [
"public",
"function",
"getTaskList",
"(",
")",
"{",
"$",
"tasks",
"=",
"$",
"this",
"->",
"loader",
"->",
"loadTasks",
"(",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"Task",
"$",
"task",
")",
"{",
"return",
"$",
"task",
"->",
"getName",
"(",
")",
";",
"}",
",",
"$",
"tasks",
")",
";",
"}"
] | Returns the list of the task names.
@return string[] | [
"Returns",
"the",
"list",
"of",
"the",
"task",
"names",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Scheduler/Scheduler.php#L230-L237 |
209,512 | matomo-org/matomo | core/Scheduler/Scheduler.php | Scheduler.executeTask | private function executeTask($task)
{
$this->logger->info("Scheduler: executing task {taskName}...", array(
'taskName' => $task->getName(),
));
$this->isRunningTask = true;
$timer = new Timer();
/**
* Triggered directly before a scheduled task is executed
*
* @param Task $task The task that is about to be executed
*/
Piwik::postEvent('ScheduledTasks.execute', array(&$task));
try {
$callable = array($task->getObjectInstance(), $task->getMethodName());
call_user_func($callable, $task->getMethodParameter());
$message = $timer->__toString();
} catch (Exception $e) {
$message = 'ERROR: ' . $e->getMessage();
}
$this->isRunningTask = false;
/**
* Triggered after a scheduled task is successfully executed.
*
* You can use the event to execute for example another task whenever a specific task is executed or to clean up
* certain resources.
*
* @param Task $task The task that was just executed
*/
Piwik::postEvent('ScheduledTasks.execute.end', array(&$task));
$this->logger->info("Scheduler: finished. {timeElapsed}", array(
'timeElapsed' => $timer,
));
return $message;
} | php | private function executeTask($task)
{
$this->logger->info("Scheduler: executing task {taskName}...", array(
'taskName' => $task->getName(),
));
$this->isRunningTask = true;
$timer = new Timer();
/**
* Triggered directly before a scheduled task is executed
*
* @param Task $task The task that is about to be executed
*/
Piwik::postEvent('ScheduledTasks.execute', array(&$task));
try {
$callable = array($task->getObjectInstance(), $task->getMethodName());
call_user_func($callable, $task->getMethodParameter());
$message = $timer->__toString();
} catch (Exception $e) {
$message = 'ERROR: ' . $e->getMessage();
}
$this->isRunningTask = false;
/**
* Triggered after a scheduled task is successfully executed.
*
* You can use the event to execute for example another task whenever a specific task is executed or to clean up
* certain resources.
*
* @param Task $task The task that was just executed
*/
Piwik::postEvent('ScheduledTasks.execute.end', array(&$task));
$this->logger->info("Scheduler: finished. {timeElapsed}", array(
'timeElapsed' => $timer,
));
return $message;
} | [
"private",
"function",
"executeTask",
"(",
"$",
"task",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Scheduler: executing task {taskName}...\"",
",",
"array",
"(",
"'taskName'",
"=>",
"$",
"task",
"->",
"getName",
"(",
")",
",",
")",
")",
";",
"$",
"this",
"->",
"isRunningTask",
"=",
"true",
";",
"$",
"timer",
"=",
"new",
"Timer",
"(",
")",
";",
"/**\n * Triggered directly before a scheduled task is executed\n *\n * @param Task $task The task that is about to be executed\n */",
"Piwik",
"::",
"postEvent",
"(",
"'ScheduledTasks.execute'",
",",
"array",
"(",
"&",
"$",
"task",
")",
")",
";",
"try",
"{",
"$",
"callable",
"=",
"array",
"(",
"$",
"task",
"->",
"getObjectInstance",
"(",
")",
",",
"$",
"task",
"->",
"getMethodName",
"(",
")",
")",
";",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"task",
"->",
"getMethodParameter",
"(",
")",
")",
";",
"$",
"message",
"=",
"$",
"timer",
"->",
"__toString",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"'ERROR: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"$",
"this",
"->",
"isRunningTask",
"=",
"false",
";",
"/**\n * Triggered after a scheduled task is successfully executed.\n *\n * You can use the event to execute for example another task whenever a specific task is executed or to clean up\n * certain resources.\n *\n * @param Task $task The task that was just executed\n */",
"Piwik",
"::",
"postEvent",
"(",
"'ScheduledTasks.execute.end'",
",",
"array",
"(",
"&",
"$",
"task",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Scheduler: finished. {timeElapsed}\"",
",",
"array",
"(",
"'timeElapsed'",
"=>",
"$",
"timer",
",",
")",
")",
";",
"return",
"$",
"message",
";",
"}"
] | Executes the given task
@param Task $task
@return string | [
"Executes",
"the",
"given",
"task"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Scheduler/Scheduler.php#L245-L287 |
209,513 | matomo-org/matomo | core/Application/Kernel/PluginList.php | PluginList.getPluginsBundledWithPiwik | public function getPluginsBundledWithPiwik()
{
$pathGlobal = $this->settings->getPathGlobal();
$section = $this->settings->getIniFileChain()->getFrom($pathGlobal, 'Plugins');
return $section['Plugins'];
} | php | public function getPluginsBundledWithPiwik()
{
$pathGlobal = $this->settings->getPathGlobal();
$section = $this->settings->getIniFileChain()->getFrom($pathGlobal, 'Plugins');
return $section['Plugins'];
} | [
"public",
"function",
"getPluginsBundledWithPiwik",
"(",
")",
"{",
"$",
"pathGlobal",
"=",
"$",
"this",
"->",
"settings",
"->",
"getPathGlobal",
"(",
")",
";",
"$",
"section",
"=",
"$",
"this",
"->",
"settings",
"->",
"getIniFileChain",
"(",
")",
"->",
"getFrom",
"(",
"$",
"pathGlobal",
",",
"'Plugins'",
")",
";",
"return",
"$",
"section",
"[",
"'Plugins'",
"]",
";",
"}"
] | Returns the list of plugins that are bundled with Piwik.
@return string[] | [
"Returns",
"the",
"list",
"of",
"plugins",
"that",
"are",
"bundled",
"with",
"Piwik",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Application/Kernel/PluginList.php#L76-L82 |
209,514 | matomo-org/matomo | core/Application/Kernel/PluginList.php | PluginList.sortPlugins | public function sortPlugins(array $plugins)
{
$global = $this->getPluginsBundledWithPiwik();
if (empty($global)) {
return $plugins;
}
// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
$global = array_merge($global, $this->corePluginsDisabledByDefault);
$global = array_values($global);
$plugins = array_values($plugins);
$defaultPluginsLoadedFirst = array_intersect($global, $plugins);
$otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
// sort by name to have a predictable order for those extra plugins
natcasesort($otherPluginsToLoadAfterDefaultPlugins);
$sorted = array_merge($defaultPluginsLoadedFirst, $otherPluginsToLoadAfterDefaultPlugins);
return $sorted;
} | php | public function sortPlugins(array $plugins)
{
$global = $this->getPluginsBundledWithPiwik();
if (empty($global)) {
return $plugins;
}
// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
$global = array_merge($global, $this->corePluginsDisabledByDefault);
$global = array_values($global);
$plugins = array_values($plugins);
$defaultPluginsLoadedFirst = array_intersect($global, $plugins);
$otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
// sort by name to have a predictable order for those extra plugins
natcasesort($otherPluginsToLoadAfterDefaultPlugins);
$sorted = array_merge($defaultPluginsLoadedFirst, $otherPluginsToLoadAfterDefaultPlugins);
return $sorted;
} | [
"public",
"function",
"sortPlugins",
"(",
"array",
"$",
"plugins",
")",
"{",
"$",
"global",
"=",
"$",
"this",
"->",
"getPluginsBundledWithPiwik",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"global",
")",
")",
"{",
"return",
"$",
"plugins",
";",
"}",
"// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin",
"$",
"global",
"=",
"array_merge",
"(",
"$",
"global",
",",
"$",
"this",
"->",
"corePluginsDisabledByDefault",
")",
";",
"$",
"global",
"=",
"array_values",
"(",
"$",
"global",
")",
";",
"$",
"plugins",
"=",
"array_values",
"(",
"$",
"plugins",
")",
";",
"$",
"defaultPluginsLoadedFirst",
"=",
"array_intersect",
"(",
"$",
"global",
",",
"$",
"plugins",
")",
";",
"$",
"otherPluginsToLoadAfterDefaultPlugins",
"=",
"array_diff",
"(",
"$",
"plugins",
",",
"$",
"defaultPluginsLoadedFirst",
")",
";",
"// sort by name to have a predictable order for those extra plugins",
"natcasesort",
"(",
"$",
"otherPluginsToLoadAfterDefaultPlugins",
")",
";",
"$",
"sorted",
"=",
"array_merge",
"(",
"$",
"defaultPluginsLoadedFirst",
",",
"$",
"otherPluginsToLoadAfterDefaultPlugins",
")",
";",
"return",
"$",
"sorted",
";",
"}"
] | Sorts an array of plugins in the order they should be loaded. We cannot use DI here as DI is not initialized
at this stage.
@params string[] $plugins
@return \string[] | [
"Sorts",
"an",
"array",
"of",
"plugins",
"in",
"the",
"order",
"they",
"should",
"be",
"loaded",
".",
"We",
"cannot",
"use",
"DI",
"here",
"as",
"DI",
"is",
"not",
"initialized",
"at",
"this",
"stage",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Application/Kernel/PluginList.php#L101-L124 |
209,515 | matomo-org/matomo | core/Application/Kernel/PluginList.php | PluginList.sortPluginsAndRespectDependencies | public function sortPluginsAndRespectDependencies(array $plugins, $pluginJsonCache = array())
{
$global = $this->getPluginsBundledWithPiwik();
if (empty($global)) {
return $plugins;
}
// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
$global = array_merge($global, $this->corePluginsDisabledByDefault);
$global = array_values($global);
$plugins = array_values($plugins);
$defaultPluginsLoadedFirst = array_intersect($global, $plugins);
$otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
// we still want to sort alphabetically by default
natcasesort($otherPluginsToLoadAfterDefaultPlugins);
$sorted = array();
foreach ($otherPluginsToLoadAfterDefaultPlugins as $pluginName) {
$sorted = $this->sortRequiredPlugin($pluginName, $pluginJsonCache, $otherPluginsToLoadAfterDefaultPlugins, $sorted);
}
$sorted = array_merge($defaultPluginsLoadedFirst, $sorted);
return $sorted;
} | php | public function sortPluginsAndRespectDependencies(array $plugins, $pluginJsonCache = array())
{
$global = $this->getPluginsBundledWithPiwik();
if (empty($global)) {
return $plugins;
}
// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
$global = array_merge($global, $this->corePluginsDisabledByDefault);
$global = array_values($global);
$plugins = array_values($plugins);
$defaultPluginsLoadedFirst = array_intersect($global, $plugins);
$otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
// we still want to sort alphabetically by default
natcasesort($otherPluginsToLoadAfterDefaultPlugins);
$sorted = array();
foreach ($otherPluginsToLoadAfterDefaultPlugins as $pluginName) {
$sorted = $this->sortRequiredPlugin($pluginName, $pluginJsonCache, $otherPluginsToLoadAfterDefaultPlugins, $sorted);
}
$sorted = array_merge($defaultPluginsLoadedFirst, $sorted);
return $sorted;
} | [
"public",
"function",
"sortPluginsAndRespectDependencies",
"(",
"array",
"$",
"plugins",
",",
"$",
"pluginJsonCache",
"=",
"array",
"(",
")",
")",
"{",
"$",
"global",
"=",
"$",
"this",
"->",
"getPluginsBundledWithPiwik",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"global",
")",
")",
"{",
"return",
"$",
"plugins",
";",
"}",
"// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin",
"$",
"global",
"=",
"array_merge",
"(",
"$",
"global",
",",
"$",
"this",
"->",
"corePluginsDisabledByDefault",
")",
";",
"$",
"global",
"=",
"array_values",
"(",
"$",
"global",
")",
";",
"$",
"plugins",
"=",
"array_values",
"(",
"$",
"plugins",
")",
";",
"$",
"defaultPluginsLoadedFirst",
"=",
"array_intersect",
"(",
"$",
"global",
",",
"$",
"plugins",
")",
";",
"$",
"otherPluginsToLoadAfterDefaultPlugins",
"=",
"array_diff",
"(",
"$",
"plugins",
",",
"$",
"defaultPluginsLoadedFirst",
")",
";",
"// we still want to sort alphabetically by default",
"natcasesort",
"(",
"$",
"otherPluginsToLoadAfterDefaultPlugins",
")",
";",
"$",
"sorted",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"otherPluginsToLoadAfterDefaultPlugins",
"as",
"$",
"pluginName",
")",
"{",
"$",
"sorted",
"=",
"$",
"this",
"->",
"sortRequiredPlugin",
"(",
"$",
"pluginName",
",",
"$",
"pluginJsonCache",
",",
"$",
"otherPluginsToLoadAfterDefaultPlugins",
",",
"$",
"sorted",
")",
";",
"}",
"$",
"sorted",
"=",
"array_merge",
"(",
"$",
"defaultPluginsLoadedFirst",
",",
"$",
"sorted",
")",
";",
"return",
"$",
"sorted",
";",
"}"
] | Sorts an array of plugins in the order they should be saved in config.ini.php. This basically influences
the order of the plugin config.php and which config will be loaded first. We want to make sure to require the
config or a required plugin first before loading the plugin that requires it.
We do not sort using this logic on each request since it is much slower than `sortPlugins()`. The order
of plugins in config.ini.php is only important for the ContainerFactory. During a regular request it is otherwise
fine to load the plugins in the order of `sortPlugins()` since we will make sure that required plugins will be
loaded first in plugin manager.
@param string[] $plugins
@param array[] $pluginJsonCache For internal testing only
@return \string[] | [
"Sorts",
"an",
"array",
"of",
"plugins",
"in",
"the",
"order",
"they",
"should",
"be",
"saved",
"in",
"config",
".",
"ini",
".",
"php",
".",
"This",
"basically",
"influences",
"the",
"order",
"of",
"the",
"plugin",
"config",
".",
"php",
"and",
"which",
"config",
"will",
"be",
"loaded",
"first",
".",
"We",
"want",
"to",
"make",
"sure",
"to",
"require",
"the",
"config",
"or",
"a",
"required",
"plugin",
"first",
"before",
"loading",
"the",
"plugin",
"that",
"requires",
"it",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Application/Kernel/PluginList.php#L140-L169 |
209,516 | matomo-org/matomo | plugins/Annotations/Controller.php | Controller.getAnnotationManager | public function getAnnotationManager($fetch = false, $date = false, $period = false, $lastN = false)
{
$this->checkSitePermission();
if ($date === false) {
$date = Common::getRequestVar('date', false);
}
if ($period === false) {
$period = Common::getRequestVar('period', 'day');
}
if ($lastN === false) {
$lastN = Common::getRequestVar('lastN', false);
}
// create & render the view
$view = new View('@Annotations/getAnnotationManager');
$allAnnotations = Request::processRequest(
'Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
$view->annotations = empty($allAnnotations[$this->idSite]) ? array() : $allAnnotations[$this->idSite];
$view->period = $period;
$view->lastN = $lastN;
list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
$view->startDate = $startDate->toString();
$view->endDate = $endDate->toString();
if ($startDate->toString() !== $endDate->toString()) {
$view->selectedDate = Date::today()->toString();
} else {
$view->selectedDate = $endDate->toString();
}
$dateFormat = Date::DATE_FORMAT_SHORT;
$view->startDatePretty = $startDate->getLocalized($dateFormat);
$view->endDatePretty = $endDate->getLocalized($dateFormat);
$view->canUserAddNotes = AnnotationList::canUserAddNotesFor($this->idSite);
return $view->render();
} | php | public function getAnnotationManager($fetch = false, $date = false, $period = false, $lastN = false)
{
$this->checkSitePermission();
if ($date === false) {
$date = Common::getRequestVar('date', false);
}
if ($period === false) {
$period = Common::getRequestVar('period', 'day');
}
if ($lastN === false) {
$lastN = Common::getRequestVar('lastN', false);
}
// create & render the view
$view = new View('@Annotations/getAnnotationManager');
$allAnnotations = Request::processRequest(
'Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
$view->annotations = empty($allAnnotations[$this->idSite]) ? array() : $allAnnotations[$this->idSite];
$view->period = $period;
$view->lastN = $lastN;
list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
$view->startDate = $startDate->toString();
$view->endDate = $endDate->toString();
if ($startDate->toString() !== $endDate->toString()) {
$view->selectedDate = Date::today()->toString();
} else {
$view->selectedDate = $endDate->toString();
}
$dateFormat = Date::DATE_FORMAT_SHORT;
$view->startDatePretty = $startDate->getLocalized($dateFormat);
$view->endDatePretty = $endDate->getLocalized($dateFormat);
$view->canUserAddNotes = AnnotationList::canUserAddNotesFor($this->idSite);
return $view->render();
} | [
"public",
"function",
"getAnnotationManager",
"(",
"$",
"fetch",
"=",
"false",
",",
"$",
"date",
"=",
"false",
",",
"$",
"period",
"=",
"false",
",",
"$",
"lastN",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"checkSitePermission",
"(",
")",
";",
"if",
"(",
"$",
"date",
"===",
"false",
")",
"{",
"$",
"date",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'date'",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"period",
"===",
"false",
")",
"{",
"$",
"period",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'period'",
",",
"'day'",
")",
";",
"}",
"if",
"(",
"$",
"lastN",
"===",
"false",
")",
"{",
"$",
"lastN",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'lastN'",
",",
"false",
")",
";",
"}",
"// create & render the view",
"$",
"view",
"=",
"new",
"View",
"(",
"'@Annotations/getAnnotationManager'",
")",
";",
"$",
"allAnnotations",
"=",
"Request",
"::",
"processRequest",
"(",
"'Annotations.getAll'",
",",
"array",
"(",
"'date'",
"=>",
"$",
"date",
",",
"'period'",
"=>",
"$",
"period",
",",
"'lastN'",
"=>",
"$",
"lastN",
")",
")",
";",
"$",
"view",
"->",
"annotations",
"=",
"empty",
"(",
"$",
"allAnnotations",
"[",
"$",
"this",
"->",
"idSite",
"]",
")",
"?",
"array",
"(",
")",
":",
"$",
"allAnnotations",
"[",
"$",
"this",
"->",
"idSite",
"]",
";",
"$",
"view",
"->",
"period",
"=",
"$",
"period",
";",
"$",
"view",
"->",
"lastN",
"=",
"$",
"lastN",
";",
"list",
"(",
"$",
"startDate",
",",
"$",
"endDate",
")",
"=",
"API",
"::",
"getDateRangeForPeriod",
"(",
"$",
"date",
",",
"$",
"period",
",",
"$",
"lastN",
")",
";",
"$",
"view",
"->",
"startDate",
"=",
"$",
"startDate",
"->",
"toString",
"(",
")",
";",
"$",
"view",
"->",
"endDate",
"=",
"$",
"endDate",
"->",
"toString",
"(",
")",
";",
"if",
"(",
"$",
"startDate",
"->",
"toString",
"(",
")",
"!==",
"$",
"endDate",
"->",
"toString",
"(",
")",
")",
"{",
"$",
"view",
"->",
"selectedDate",
"=",
"Date",
"::",
"today",
"(",
")",
"->",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"$",
"view",
"->",
"selectedDate",
"=",
"$",
"endDate",
"->",
"toString",
"(",
")",
";",
"}",
"$",
"dateFormat",
"=",
"Date",
"::",
"DATE_FORMAT_SHORT",
";",
"$",
"view",
"->",
"startDatePretty",
"=",
"$",
"startDate",
"->",
"getLocalized",
"(",
"$",
"dateFormat",
")",
";",
"$",
"view",
"->",
"endDatePretty",
"=",
"$",
"endDate",
"->",
"getLocalized",
"(",
"$",
"dateFormat",
")",
";",
"$",
"view",
"->",
"canUserAddNotes",
"=",
"AnnotationList",
"::",
"canUserAddNotesFor",
"(",
"$",
"this",
"->",
"idSite",
")",
";",
"return",
"$",
"view",
"->",
"render",
"(",
")",
";",
"}"
] | Controller action that returns HTML displaying annotations for a site and
specific date range.
Query Param Input:
- idSite: The ID of the site to get annotations for. Only one allowed.
- date: The date to get annotations for. If lastN is not supplied, this is the start date,
otherwise the start date in the last period.
- period: The period type.
- lastN: If supplied, the last N # of periods will be included w/ the range specified
by date + period.
Output:
- HTML displaying annotations for a specific range.
@param bool $fetch True if the annotation manager should be returned as a string,
false if it should be echo-ed.
@param bool|string $date Override for 'date' query parameter.
@param bool|string $period Override for 'period' query parameter.
@param bool|string $lastN Override for 'lastN' query parameter.
@return string|void | [
"Controller",
"action",
"that",
"returns",
"HTML",
"displaying",
"annotations",
"for",
"a",
"site",
"and",
"specific",
"date",
"range",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L44-L87 |
209,517 | matomo-org/matomo | plugins/Annotations/Controller.php | Controller.saveAnnotation | public function saveAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
$view = new View('@Annotations/saveAnnotation');
// NOTE: permissions checked in API method
// save the annotation
$view->annotation = Request::processRequest("Annotations.save");
return $view->render();
}
} | php | public function saveAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
$view = new View('@Annotations/saveAnnotation');
// NOTE: permissions checked in API method
// save the annotation
$view->annotation = Request::processRequest("Annotations.save");
return $view->render();
}
} | [
"public",
"function",
"saveAnnotation",
"(",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"POST\"",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"$",
"view",
"=",
"new",
"View",
"(",
"'@Annotations/saveAnnotation'",
")",
";",
"// NOTE: permissions checked in API method",
"// save the annotation",
"$",
"view",
"->",
"annotation",
"=",
"Request",
"::",
"processRequest",
"(",
"\"Annotations.save\"",
")",
";",
"return",
"$",
"view",
"->",
"render",
"(",
")",
";",
"}",
"}"
] | Controller action that modifies an annotation and returns HTML displaying
the modified annotation.
Query Param Input:
- idSite: The ID of the site the annotation belongs to. Only one ID is allowed.
- idNote: The ID of the annotation.
- date: The new date value for the annotation. (optional)
- note: The new text for the annotation. (optional)
- starred: Either 1 or 0. Whether the note should be starred or not. (optional)
Output:
- HTML displaying modified annotation.
If an optional query param is not supplied, that part of the annotation is
not modified. | [
"Controller",
"action",
"that",
"modifies",
"an",
"annotation",
"and",
"returns",
"HTML",
"displaying",
"the",
"modified",
"annotation",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L106-L119 |
209,518 | matomo-org/matomo | plugins/Annotations/Controller.php | Controller.addAnnotation | public function addAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// the date used is for the annotation manager HTML that gets echo'd. we
// use this date for the new annotation, unless it is a date range, in
// which case we use the first date of the range.
$date = Common::getRequestVar('date');
if (strpos($date, ',') !== false) {
$date = reset(explode(',', $date));
}
// add the annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.add", array('date' => $date));
$managerDate = Common::getRequestVar('managerDate', false);
$managerPeriod = Common::getRequestVar('managerPeriod', false);
return $this->getAnnotationManager($fetch = true, $managerDate, $managerPeriod);
}
} | php | public function addAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// the date used is for the annotation manager HTML that gets echo'd. we
// use this date for the new annotation, unless it is a date range, in
// which case we use the first date of the range.
$date = Common::getRequestVar('date');
if (strpos($date, ',') !== false) {
$date = reset(explode(',', $date));
}
// add the annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.add", array('date' => $date));
$managerDate = Common::getRequestVar('managerDate', false);
$managerPeriod = Common::getRequestVar('managerPeriod', false);
return $this->getAnnotationManager($fetch = true, $managerDate, $managerPeriod);
}
} | [
"public",
"function",
"addAnnotation",
"(",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"POST\"",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"// the date used is for the annotation manager HTML that gets echo'd. we",
"// use this date for the new annotation, unless it is a date range, in",
"// which case we use the first date of the range.",
"$",
"date",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'date'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"date",
",",
"','",
")",
"!==",
"false",
")",
"{",
"$",
"date",
"=",
"reset",
"(",
"explode",
"(",
"','",
",",
"$",
"date",
")",
")",
";",
"}",
"// add the annotation. NOTE: permissions checked in API method",
"Request",
"::",
"processRequest",
"(",
"\"Annotations.add\"",
",",
"array",
"(",
"'date'",
"=>",
"$",
"date",
")",
")",
";",
"$",
"managerDate",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'managerDate'",
",",
"false",
")",
";",
"$",
"managerPeriod",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'managerPeriod'",
",",
"false",
")",
";",
"return",
"$",
"this",
"->",
"getAnnotationManager",
"(",
"$",
"fetch",
"=",
"true",
",",
"$",
"managerDate",
",",
"$",
"managerPeriod",
")",
";",
"}",
"}"
] | Controller action that adds a new annotation for a site and returns new
annotation manager HTML for the site and date range.
Query Param Input:
- idSite: The ID of the site to add an annotation to.
- date: The date for the new annotation.
- note: The text of the annotation.
- starred: Either 1 or 0, whether the annotation should be starred or not.
Defaults to 0.
- managerDate: The date for the annotation manager. If a range is given, the start
date is used for the new annotation.
- managerPeriod: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
- lastN: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
Output:
- @see self::getAnnotationManager | [
"Controller",
"action",
"that",
"adds",
"a",
"new",
"annotation",
"for",
"a",
"site",
"and",
"returns",
"new",
"annotation",
"manager",
"HTML",
"for",
"the",
"site",
"and",
"date",
"range",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L140-L160 |
209,519 | matomo-org/matomo | plugins/Annotations/Controller.php | Controller.deleteAnnotation | public function deleteAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// delete annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.delete");
return $this->getAnnotationManager($fetch = true);
}
} | php | public function deleteAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// delete annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.delete");
return $this->getAnnotationManager($fetch = true);
}
} | [
"public",
"function",
"deleteAnnotation",
"(",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"POST\"",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"// delete annotation. NOTE: permissions checked in API method",
"Request",
"::",
"processRequest",
"(",
"\"Annotations.delete\"",
")",
";",
"return",
"$",
"this",
"->",
"getAnnotationManager",
"(",
"$",
"fetch",
"=",
"true",
")",
";",
"}",
"}"
] | Controller action that deletes an annotation and returns new annotation
manager HTML for the site & date range.
Query Param Input:
- idSite: The ID of the site this annotation belongs to.
- idNote: The ID of the annotation to delete.
- date: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
- period: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
- lastN: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
Output:
- @see self::getAnnotationManager | [
"Controller",
"action",
"that",
"deletes",
"an",
"annotation",
"and",
"returns",
"new",
"annotation",
"manager",
"HTML",
"for",
"the",
"site",
"&",
"date",
"range",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L179-L189 |
209,520 | matomo-org/matomo | plugins/Annotations/Controller.php | Controller.getEvolutionIcons | public function getEvolutionIcons()
{
// get annotation the count
$annotationCounts = Request::processRequest(
"Annotations.getAnnotationCountForDates", array('getAnnotationText' => 1));
// create & render the view
$view = new View('@Annotations/getEvolutionIcons');
$view->annotationCounts = reset($annotationCounts); // only one idSite allowed for this action
return $view->render();
} | php | public function getEvolutionIcons()
{
// get annotation the count
$annotationCounts = Request::processRequest(
"Annotations.getAnnotationCountForDates", array('getAnnotationText' => 1));
// create & render the view
$view = new View('@Annotations/getEvolutionIcons');
$view->annotationCounts = reset($annotationCounts); // only one idSite allowed for this action
return $view->render();
} | [
"public",
"function",
"getEvolutionIcons",
"(",
")",
"{",
"// get annotation the count",
"$",
"annotationCounts",
"=",
"Request",
"::",
"processRequest",
"(",
"\"Annotations.getAnnotationCountForDates\"",
",",
"array",
"(",
"'getAnnotationText'",
"=>",
"1",
")",
")",
";",
"// create & render the view",
"$",
"view",
"=",
"new",
"View",
"(",
"'@Annotations/getEvolutionIcons'",
")",
";",
"$",
"view",
"->",
"annotationCounts",
"=",
"reset",
"(",
"$",
"annotationCounts",
")",
";",
"// only one idSite allowed for this action",
"return",
"$",
"view",
"->",
"render",
"(",
")",
";",
"}"
] | Controller action that echo's HTML that displays marker icons for an
evolution graph's x-axis. The marker icons still need to be positioned
by the JavaScript.
Query Param Input:
- idSite: The ID of the site this annotation belongs to. Only one is allowed.
- date: The date to check for annotations. If lastN is not supplied, this is
the start of the date range used to check for annotations. If supplied,
this is the start of the last period in the date range.
- period: The period type.
- lastN: If supplied, the last N # of periods are included in the date range
used to check for annotations.
Output:
- HTML that displays marker icons for an evolution graph based on the
number of annotations & starred annotations in the graph's date range. | [
"Controller",
"action",
"that",
"echo",
"s",
"HTML",
"that",
"displays",
"marker",
"icons",
"for",
"an",
"evolution",
"graph",
"s",
"x",
"-",
"axis",
".",
"The",
"marker",
"icons",
"still",
"need",
"to",
"be",
"positioned",
"by",
"the",
"JavaScript",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L209-L220 |
209,521 | matomo-org/matomo | plugins/SitesManager/Model.php | Model.getAllSites | public function getAllSites()
{
$db = $this->getDb();
$sites = $db->fetchAll("SELECT * FROM " . $this->table . " ORDER BY idsite ASC");
return $sites;
} | php | public function getAllSites()
{
$db = $this->getDb();
$sites = $db->fetchAll("SELECT * FROM " . $this->table . " ORDER BY idsite ASC");
return $sites;
} | [
"public",
"function",
"getAllSites",
"(",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
";",
"$",
"sites",
"=",
"$",
"db",
"->",
"fetchAll",
"(",
"\"SELECT * FROM \"",
".",
"$",
"this",
"->",
"table",
".",
"\" ORDER BY idsite ASC\"",
")",
";",
"return",
"$",
"sites",
";",
"}"
] | Returns all websites
@return array The list of websites, indexed by idsite | [
"Returns",
"all",
"websites"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L75-L81 |
209,522 | matomo-org/matomo | plugins/SitesManager/Model.php | Model.getSitesWithVisits | public function getSitesWithVisits($time, $now)
{
$sites = Db::fetchAll("
SELECT idsite FROM " . $this->table . " s
WHERE EXISTS (
SELECT 1
FROM " . Common::prefixTable('log_visit') . " v
WHERE v.idsite = s.idsite
AND visit_last_action_time > ?
AND visit_last_action_time <= ?
LIMIT 1)
", array($time, $now));
return $sites;
} | php | public function getSitesWithVisits($time, $now)
{
$sites = Db::fetchAll("
SELECT idsite FROM " . $this->table . " s
WHERE EXISTS (
SELECT 1
FROM " . Common::prefixTable('log_visit') . " v
WHERE v.idsite = s.idsite
AND visit_last_action_time > ?
AND visit_last_action_time <= ?
LIMIT 1)
", array($time, $now));
return $sites;
} | [
"public",
"function",
"getSitesWithVisits",
"(",
"$",
"time",
",",
"$",
"now",
")",
"{",
"$",
"sites",
"=",
"Db",
"::",
"fetchAll",
"(",
"\"\n SELECT idsite FROM \"",
".",
"$",
"this",
"->",
"table",
".",
"\" s\n WHERE EXISTS (\n SELECT 1\n FROM \"",
".",
"Common",
"::",
"prefixTable",
"(",
"'log_visit'",
")",
".",
"\" v\n WHERE v.idsite = s.idsite\n AND visit_last_action_time > ?\n AND visit_last_action_time <= ?\n LIMIT 1)\n \"",
",",
"array",
"(",
"$",
"time",
",",
"$",
"now",
")",
")",
";",
"return",
"$",
"sites",
";",
"}"
] | Returns the list of the website IDs that received some visits since the specified timestamp.
@param string $time
@param string $now
@return array The list of website IDs | [
"Returns",
"the",
"list",
"of",
"the",
"website",
"IDs",
"that",
"received",
"some",
"visits",
"since",
"the",
"specified",
"timestamp",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L90-L104 |
209,523 | matomo-org/matomo | plugins/SitesManager/Model.php | Model.getSitesFromIds | public function getSitesFromIds($idSites, $limit = false)
{
if (count($idSites) === 0) {
return array();
}
if ($limit) {
$limit = "LIMIT " . (int)$limit;
} else {
$limit = '';
}
$idSites = array_map('intval', $idSites);
$db = $this->getDb();
$sites = $db->fetchAll("SELECT * FROM " . $this->table . "
WHERE idsite IN (" . implode(", ", $idSites) . ")
ORDER BY idsite ASC $limit");
return $sites;
} | php | public function getSitesFromIds($idSites, $limit = false)
{
if (count($idSites) === 0) {
return array();
}
if ($limit) {
$limit = "LIMIT " . (int)$limit;
} else {
$limit = '';
}
$idSites = array_map('intval', $idSites);
$db = $this->getDb();
$sites = $db->fetchAll("SELECT * FROM " . $this->table . "
WHERE idsite IN (" . implode(", ", $idSites) . ")
ORDER BY idsite ASC $limit");
return $sites;
} | [
"public",
"function",
"getSitesFromIds",
"(",
"$",
"idSites",
",",
"$",
"limit",
"=",
"false",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"idSites",
")",
"===",
"0",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"limit",
"=",
"\"LIMIT \"",
".",
"(",
"int",
")",
"$",
"limit",
";",
"}",
"else",
"{",
"$",
"limit",
"=",
"''",
";",
"}",
"$",
"idSites",
"=",
"array_map",
"(",
"'intval'",
",",
"$",
"idSites",
")",
";",
"$",
"db",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
";",
"$",
"sites",
"=",
"$",
"db",
"->",
"fetchAll",
"(",
"\"SELECT * FROM \"",
".",
"$",
"this",
"->",
"table",
".",
"\"\n WHERE idsite IN (\"",
".",
"implode",
"(",
"\", \"",
",",
"$",
"idSites",
")",
".",
"\")\n ORDER BY idsite ASC $limit\"",
")",
";",
"return",
"$",
"sites",
";",
"}"
] | Returns the list of websites from the ID array in parameters.
@param array $idSites list of website ID
@param bool $limit
@return array | [
"Returns",
"the",
"list",
"of",
"websites",
"from",
"the",
"ID",
"array",
"in",
"parameters",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L201-L221 |
209,524 | matomo-org/matomo | plugins/SitesManager/Model.php | Model.getSitesId | public function getSitesId()
{
$result = Db::fetchAll("SELECT idsite FROM " . Common::prefixTable('site'));
$idSites = array();
foreach ($result as $idSite) {
$idSites[] = $idSite['idsite'];
}
return $idSites;
} | php | public function getSitesId()
{
$result = Db::fetchAll("SELECT idsite FROM " . Common::prefixTable('site'));
$idSites = array();
foreach ($result as $idSite) {
$idSites[] = $idSite['idsite'];
}
return $idSites;
} | [
"public",
"function",
"getSitesId",
"(",
")",
"{",
"$",
"result",
"=",
"Db",
"::",
"fetchAll",
"(",
"\"SELECT idsite FROM \"",
".",
"Common",
"::",
"prefixTable",
"(",
"'site'",
")",
")",
";",
"$",
"idSites",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"idSite",
")",
"{",
"$",
"idSites",
"[",
"]",
"=",
"$",
"idSite",
"[",
"'idsite'",
"]",
";",
"}",
"return",
"$",
"idSites",
";",
"}"
] | Returns the list of all the website IDs registered.
Caller must check access.
@return array The list of website IDs | [
"Returns",
"the",
"list",
"of",
"all",
"the",
"website",
"IDs",
"registered",
".",
"Caller",
"must",
"check",
"access",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L245-L255 |
209,525 | matomo-org/matomo | plugins/SitesManager/Model.php | Model.getUniqueSiteTimezones | public function getUniqueSiteTimezones()
{
$results = Db::fetchAll("SELECT distinct timezone FROM " . $this->table);
$timezones = array();
foreach ($results as $result) {
$timezones[] = $result['timezone'];
}
return $timezones;
} | php | public function getUniqueSiteTimezones()
{
$results = Db::fetchAll("SELECT distinct timezone FROM " . $this->table);
$timezones = array();
foreach ($results as $result) {
$timezones[] = $result['timezone'];
}
return $timezones;
} | [
"public",
"function",
"getUniqueSiteTimezones",
"(",
")",
"{",
"$",
"results",
"=",
"Db",
"::",
"fetchAll",
"(",
"\"SELECT distinct timezone FROM \"",
".",
"$",
"this",
"->",
"table",
")",
";",
"$",
"timezones",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"timezones",
"[",
"]",
"=",
"$",
"result",
"[",
"'timezone'",
"]",
";",
"}",
"return",
"$",
"timezones",
";",
"}"
] | Returns the list of unique timezones from all configured sites.
@return array ( string ) | [
"Returns",
"the",
"list",
"of",
"unique",
"timezones",
"from",
"all",
"configured",
"sites",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L326-L336 |
209,526 | matomo-org/matomo | plugins/SitesManager/Model.php | Model.insertSiteUrl | public function insertSiteUrl($idSite, $url)
{
$db = $this->getDb();
$db->insert(Common::prefixTable("site_url"), array(
'idsite' => (int) $idSite,
'url' => $url
)
);
} | php | public function insertSiteUrl($idSite, $url)
{
$db = $this->getDb();
$db->insert(Common::prefixTable("site_url"), array(
'idsite' => (int) $idSite,
'url' => $url
)
);
} | [
"public",
"function",
"insertSiteUrl",
"(",
"$",
"idSite",
",",
"$",
"url",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
";",
"$",
"db",
"->",
"insert",
"(",
"Common",
"::",
"prefixTable",
"(",
"\"site_url\"",
")",
",",
"array",
"(",
"'idsite'",
"=>",
"(",
"int",
")",
"$",
"idSite",
",",
"'url'",
"=>",
"$",
"url",
")",
")",
";",
"}"
] | Insert the list of alias URLs for the website.
The URLs must not exist already for this website! | [
"Insert",
"the",
"list",
"of",
"alias",
"URLs",
"for",
"the",
"website",
".",
"The",
"URLs",
"must",
"not",
"exist",
"already",
"for",
"this",
"website!"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L380-L388 |
209,527 | matomo-org/matomo | plugins/SitesManager/Model.php | Model.deleteSiteAliasUrls | public function deleteSiteAliasUrls($idsite)
{
$db = $this->getDb();
$db->query("DELETE FROM " . Common::prefixTable("site_url") . " WHERE idsite = ?", $idsite);
} | php | public function deleteSiteAliasUrls($idsite)
{
$db = $this->getDb();
$db->query("DELETE FROM " . Common::prefixTable("site_url") . " WHERE idsite = ?", $idsite);
} | [
"public",
"function",
"deleteSiteAliasUrls",
"(",
"$",
"idsite",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
";",
"$",
"db",
"->",
"query",
"(",
"\"DELETE FROM \"",
".",
"Common",
"::",
"prefixTable",
"(",
"\"site_url\"",
")",
".",
"\" WHERE idsite = ?\"",
",",
"$",
"idsite",
")",
";",
"}"
] | Delete all the alias URLs for the given idSite. | [
"Delete",
"all",
"the",
"alias",
"URLs",
"for",
"the",
"given",
"idSite",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L436-L440 |
209,528 | matomo-org/matomo | libs/Zend/Mail/Protocol/Smtp.php | Zend_Mail_Protocol_Smtp._ehlo | protected function _ehlo($host)
{
// Support for older, less-compliant remote servers. Tries multiple attempts of EHLO or HELO.
try {
$this->_send('EHLO ' . $host);
$this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
} catch (Zend_Mail_Protocol_Exception $e) {
$this->_send('HELO ' . $host);
$this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
} catch (Zend_Mail_Protocol_Exception $e) {
throw $e;
}
} | php | protected function _ehlo($host)
{
// Support for older, less-compliant remote servers. Tries multiple attempts of EHLO or HELO.
try {
$this->_send('EHLO ' . $host);
$this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
} catch (Zend_Mail_Protocol_Exception $e) {
$this->_send('HELO ' . $host);
$this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
} catch (Zend_Mail_Protocol_Exception $e) {
throw $e;
}
} | [
"protected",
"function",
"_ehlo",
"(",
"$",
"host",
")",
"{",
"// Support for older, less-compliant remote servers. Tries multiple attempts of EHLO or HELO.",
"try",
"{",
"$",
"this",
"->",
"_send",
"(",
"'EHLO '",
".",
"$",
"host",
")",
";",
"$",
"this",
"->",
"_expect",
"(",
"250",
",",
"300",
")",
";",
"// Timeout set for 5 minutes as per RFC 2821 4.5.3.2",
"}",
"catch",
"(",
"Zend_Mail_Protocol_Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"_send",
"(",
"'HELO '",
".",
"$",
"host",
")",
";",
"$",
"this",
"->",
"_expect",
"(",
"250",
",",
"300",
")",
";",
"// Timeout set for 5 minutes as per RFC 2821 4.5.3.2",
"}",
"catch",
"(",
"Zend_Mail_Protocol_Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] | Send EHLO or HELO depending on capabilities of smtp host
@param string $host The client hostname or IP address (default: 127.0.0.1)
@throws Zend_Mail_Protocol_Exception
@return void | [
"Send",
"EHLO",
"or",
"HELO",
"depending",
"on",
"capabilities",
"of",
"smtp",
"host"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp.php#L228-L240 |
209,529 | matomo-org/matomo | libs/Zend/Mail/Protocol/Smtp.php | Zend_Mail_Protocol_Smtp.mail | public function mail($from)
{
if ($this->_sess !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('A valid session has not been started');
}
$this->_send('MAIL FROM:<' . $from . '>');
$this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
// Set mail to true, clear recipients and any existing data flags as per 4.1.1.2 of RFC 2821
$this->_mail = true;
$this->_rcpt = false;
$this->_data = false;
} | php | public function mail($from)
{
if ($this->_sess !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('A valid session has not been started');
}
$this->_send('MAIL FROM:<' . $from . '>');
$this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
// Set mail to true, clear recipients and any existing data flags as per 4.1.1.2 of RFC 2821
$this->_mail = true;
$this->_rcpt = false;
$this->_data = false;
} | [
"public",
"function",
"mail",
"(",
"$",
"from",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_sess",
"!==",
"true",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Exception.php';",
"throw",
"new",
"Zend_Mail_Protocol_Exception",
"(",
"'A valid session has not been started'",
")",
";",
"}",
"$",
"this",
"->",
"_send",
"(",
"'MAIL FROM:<'",
".",
"$",
"from",
".",
"'>'",
")",
";",
"$",
"this",
"->",
"_expect",
"(",
"250",
",",
"300",
")",
";",
"// Timeout set for 5 minutes as per RFC 2821 4.5.3.2",
"// Set mail to true, clear recipients and any existing data flags as per 4.1.1.2 of RFC 2821",
"$",
"this",
"->",
"_mail",
"=",
"true",
";",
"$",
"this",
"->",
"_rcpt",
"=",
"false",
";",
"$",
"this",
"->",
"_data",
"=",
"false",
";",
"}"
] | Issues MAIL command
@param string $from Sender mailbox
@throws Zend_Mail_Protocol_Exception
@return void | [
"Issues",
"MAIL",
"command"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp.php#L250-L267 |
209,530 | matomo-org/matomo | libs/Zend/Mail/Protocol/Smtp.php | Zend_Mail_Protocol_Smtp.rcpt | public function rcpt($to)
{
if ($this->_mail !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No sender reverse path has been supplied');
}
// Set rcpt to true, as per 4.1.1.3 of RFC 2821
$this->_send('RCPT TO:<' . $to . '>');
$this->_expect(array(250, 251), 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
$this->_rcpt = true;
} | php | public function rcpt($to)
{
if ($this->_mail !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No sender reverse path has been supplied');
}
// Set rcpt to true, as per 4.1.1.3 of RFC 2821
$this->_send('RCPT TO:<' . $to . '>');
$this->_expect(array(250, 251), 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2
$this->_rcpt = true;
} | [
"public",
"function",
"rcpt",
"(",
"$",
"to",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_mail",
"!==",
"true",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Exception.php';",
"throw",
"new",
"Zend_Mail_Protocol_Exception",
"(",
"'No sender reverse path has been supplied'",
")",
";",
"}",
"// Set rcpt to true, as per 4.1.1.3 of RFC 2821",
"$",
"this",
"->",
"_send",
"(",
"'RCPT TO:<'",
".",
"$",
"to",
".",
"'>'",
")",
";",
"$",
"this",
"->",
"_expect",
"(",
"array",
"(",
"250",
",",
"251",
")",
",",
"300",
")",
";",
"// Timeout set for 5 minutes as per RFC 2821 4.5.3.2",
"$",
"this",
"->",
"_rcpt",
"=",
"true",
";",
"}"
] | Issues RCPT command
@param string $to Receiver(s) mailbox
@throws Zend_Mail_Protocol_Exception
@return void | [
"Issues",
"RCPT",
"command"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp.php#L277-L291 |
209,531 | matomo-org/matomo | libs/Zend/Mail/Protocol/Smtp.php | Zend_Mail_Protocol_Smtp.data | public function data($data)
{
// Ensure recipients have been set
if ($this->_rcpt !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No recipient forward path has been supplied');
}
$this->_send('DATA');
$this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2
foreach (explode(Zend_Mime::LINEEND, $data) as $line) {
if (strpos($line, '.') === 0) {
// Escape lines prefixed with a '.'
$line = '.' . $line;
}
$this->_send($line);
}
$this->_send('.');
$this->_expect(250, 600); // Timeout set for 10 minutes as per RFC 2821 4.5.3.2
$this->_data = true;
} | php | public function data($data)
{
// Ensure recipients have been set
if ($this->_rcpt !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No recipient forward path has been supplied');
}
$this->_send('DATA');
$this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2
foreach (explode(Zend_Mime::LINEEND, $data) as $line) {
if (strpos($line, '.') === 0) {
// Escape lines prefixed with a '.'
$line = '.' . $line;
}
$this->_send($line);
}
$this->_send('.');
$this->_expect(250, 600); // Timeout set for 10 minutes as per RFC 2821 4.5.3.2
$this->_data = true;
} | [
"public",
"function",
"data",
"(",
"$",
"data",
")",
"{",
"// Ensure recipients have been set",
"if",
"(",
"$",
"this",
"->",
"_rcpt",
"!==",
"true",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Exception.php';",
"throw",
"new",
"Zend_Mail_Protocol_Exception",
"(",
"'No recipient forward path has been supplied'",
")",
";",
"}",
"$",
"this",
"->",
"_send",
"(",
"'DATA'",
")",
";",
"$",
"this",
"->",
"_expect",
"(",
"354",
",",
"120",
")",
";",
"// Timeout set for 2 minutes as per RFC 2821 4.5.3.2",
"foreach",
"(",
"explode",
"(",
"Zend_Mime",
"::",
"LINEEND",
",",
"$",
"data",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"line",
",",
"'.'",
")",
"===",
"0",
")",
"{",
"// Escape lines prefixed with a '.'",
"$",
"line",
"=",
"'.'",
".",
"$",
"line",
";",
"}",
"$",
"this",
"->",
"_send",
"(",
"$",
"line",
")",
";",
"}",
"$",
"this",
"->",
"_send",
"(",
"'.'",
")",
";",
"$",
"this",
"->",
"_expect",
"(",
"250",
",",
"600",
")",
";",
"// Timeout set for 10 minutes as per RFC 2821 4.5.3.2",
"$",
"this",
"->",
"_data",
"=",
"true",
";",
"}"
] | Issues DATA command
@param string $data
@throws Zend_Mail_Protocol_Exception
@return void | [
"Issues",
"DATA",
"command"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp.php#L301-L326 |
209,532 | matomo-org/matomo | libs/Zend/Mail/Protocol/Smtp.php | Zend_Mail_Protocol_Smtp.rset | public function rset()
{
$this->_send('RSET');
// MS ESMTP doesn't follow RFC, see [ZF-1377]
$this->_expect(array(250, 220));
$this->_mail = false;
$this->_rcpt = false;
$this->_data = false;
} | php | public function rset()
{
$this->_send('RSET');
// MS ESMTP doesn't follow RFC, see [ZF-1377]
$this->_expect(array(250, 220));
$this->_mail = false;
$this->_rcpt = false;
$this->_data = false;
} | [
"public",
"function",
"rset",
"(",
")",
"{",
"$",
"this",
"->",
"_send",
"(",
"'RSET'",
")",
";",
"// MS ESMTP doesn't follow RFC, see [ZF-1377]",
"$",
"this",
"->",
"_expect",
"(",
"array",
"(",
"250",
",",
"220",
")",
")",
";",
"$",
"this",
"->",
"_mail",
"=",
"false",
";",
"$",
"this",
"->",
"_rcpt",
"=",
"false",
";",
"$",
"this",
"->",
"_data",
"=",
"false",
";",
"}"
] | Issues the RSET command and validates answer
Can be used to restore a clean smtp communication state when a transaction has been cancelled or commencing a new transaction.
@return void | [
"Issues",
"the",
"RSET",
"command",
"and",
"validates",
"answer"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp.php#L336-L345 |
209,533 | matomo-org/matomo | core/Plugin/ViewDataTable.php | ViewDataTable.getViewDataTableId | public static function getViewDataTableId()
{
$id = static::ID;
if (empty($id)) {
$message = sprintf('ViewDataTable %s does not define an ID. Set the ID constant to fix this issue', get_called_class());
throw new \Exception($message);
}
return $id;
} | php | public static function getViewDataTableId()
{
$id = static::ID;
if (empty($id)) {
$message = sprintf('ViewDataTable %s does not define an ID. Set the ID constant to fix this issue', get_called_class());
throw new \Exception($message);
}
return $id;
} | [
"public",
"static",
"function",
"getViewDataTableId",
"(",
")",
"{",
"$",
"id",
"=",
"static",
"::",
"ID",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'ViewDataTable %s does not define an ID. Set the ID constant to fix this issue'",
",",
"get_called_class",
"(",
")",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"message",
")",
";",
"}",
"return",
"$",
"id",
";",
"}"
] | Returns the viewDataTable ID for this DataTable visualization.
Derived classes should not override this method. They should instead declare a const ID field
with the viewDataTable ID.
@throws \Exception
@return string | [
"Returns",
"the",
"viewDataTable",
"ID",
"for",
"this",
"DataTable",
"visualization",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ViewDataTable.php#L373-L383 |
209,534 | matomo-org/matomo | core/Plugin/ViewDataTable.php | ViewDataTable.isRequestingSingleDataTable | public function isRequestingSingleDataTable()
{
$requestArray = $this->request->getRequestArray() + $_GET + $_POST;
$date = Common::getRequestVar('date', null, 'string', $requestArray);
$period = Common::getRequestVar('period', null, 'string', $requestArray);
$idSite = Common::getRequestVar('idSite', null, 'string', $requestArray);
if (Period::isMultiplePeriod($date, $period)
|| strpos($idSite, ',') !== false
|| $idSite == 'all'
) {
return false;
}
return true;
} | php | public function isRequestingSingleDataTable()
{
$requestArray = $this->request->getRequestArray() + $_GET + $_POST;
$date = Common::getRequestVar('date', null, 'string', $requestArray);
$period = Common::getRequestVar('period', null, 'string', $requestArray);
$idSite = Common::getRequestVar('idSite', null, 'string', $requestArray);
if (Period::isMultiplePeriod($date, $period)
|| strpos($idSite, ',') !== false
|| $idSite == 'all'
) {
return false;
}
return true;
} | [
"public",
"function",
"isRequestingSingleDataTable",
"(",
")",
"{",
"$",
"requestArray",
"=",
"$",
"this",
"->",
"request",
"->",
"getRequestArray",
"(",
")",
"+",
"$",
"_GET",
"+",
"$",
"_POST",
";",
"$",
"date",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'date'",
",",
"null",
",",
"'string'",
",",
"$",
"requestArray",
")",
";",
"$",
"period",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'period'",
",",
"null",
",",
"'string'",
",",
"$",
"requestArray",
")",
";",
"$",
"idSite",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'idSite'",
",",
"null",
",",
"'string'",
",",
"$",
"requestArray",
")",
";",
"if",
"(",
"Period",
"::",
"isMultiplePeriod",
"(",
"$",
"date",
",",
"$",
"period",
")",
"||",
"strpos",
"(",
"$",
"idSite",
",",
"','",
")",
"!==",
"false",
"||",
"$",
"idSite",
"==",
"'all'",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Returns `true` if this instance will request a single DataTable, `false` if requesting
more than one.
@return bool | [
"Returns",
"true",
"if",
"this",
"instance",
"will",
"request",
"a",
"single",
"DataTable",
"false",
"if",
"requesting",
"more",
"than",
"one",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ViewDataTable.php#L502-L517 |
209,535 | matomo-org/matomo | core/Config/IniFileChain.php | IniFileChain.& | public function &get($name)
{
if (!isset($this->mergedSettings[$name])) {
$this->mergedSettings[$name] = array();
}
$result =& $this->mergedSettings[$name];
return $result;
} | php | public function &get($name)
{
if (!isset($this->mergedSettings[$name])) {
$this->mergedSettings[$name] = array();
}
$result =& $this->mergedSettings[$name];
return $result;
} | [
"public",
"function",
"&",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mergedSettings",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"mergedSettings",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"result",
"=",
"&",
"$",
"this",
"->",
"mergedSettings",
"[",
"$",
"name",
"]",
";",
"return",
"$",
"result",
";",
"}"
] | Return setting section by reference.
@param string $name
@return mixed | [
"Return",
"setting",
"section",
"by",
"reference",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config/IniFileChain.php#L69-L77 |
209,536 | matomo-org/matomo | core/Config/IniFileChain.php | IniFileChain.dumpChanges | public function dumpChanges($header = '')
{
$userSettingsFile = $this->getUserSettingsFile();
$defaultSettings = $this->getMergedDefaultSettings();
$existingMutableSettings = $this->settingsChain[$userSettingsFile];
$dirty = false;
$configToWrite = array();
foreach ($this->mergedSettings as $sectionName => $changedSection) {
if(isset($existingMutableSettings[$sectionName])){
$existingMutableSection = $existingMutableSettings[$sectionName];
} else{
$existingMutableSection = array();
}
// remove default values from both (they should not get written to local)
if (isset($defaultSettings[$sectionName])) {
$changedSection = $this->arrayUnmerge($defaultSettings[$sectionName], $changedSection);
$existingMutableSection = $this->arrayUnmerge($defaultSettings[$sectionName], $existingMutableSection);
}
// if either local/config have non-default values and the other doesn't,
// OR both have values, but different values, we must write to config.ini.php
if (empty($changedSection) xor empty($existingMutableSection)
|| (!empty($changedSection)
&& !empty($existingMutableSection)
&& self::compareElements($changedSection, $existingMutableSection))
) {
$dirty = true;
}
$configToWrite[$sectionName] = $changedSection;
}
if ($dirty) {
// sort config sections by how early they appear in the file chain
$self = $this;
uksort($configToWrite, function ($sectionNameLhs, $sectionNameRhs) use ($self) {
$lhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameLhs);
$rhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameRhs);
if ($lhsIndex == $rhsIndex) {
$lhsIndexInFile = $self->getIndexOfSectionInFile($lhsIndex, $sectionNameLhs);
$rhsIndexInFile = $self->getIndexOfSectionInFile($rhsIndex, $sectionNameRhs);
if ($lhsIndexInFile == $rhsIndexInFile) {
return 0;
} elseif ($lhsIndexInFile < $rhsIndexInFile) {
return -1;
} else {
return 1;
}
} elseif ($lhsIndex < $rhsIndex) {
return -1;
} else {
return 1;
}
});
return $this->dumpSettings($configToWrite, $header);
} else {
return null;
}
} | php | public function dumpChanges($header = '')
{
$userSettingsFile = $this->getUserSettingsFile();
$defaultSettings = $this->getMergedDefaultSettings();
$existingMutableSettings = $this->settingsChain[$userSettingsFile];
$dirty = false;
$configToWrite = array();
foreach ($this->mergedSettings as $sectionName => $changedSection) {
if(isset($existingMutableSettings[$sectionName])){
$existingMutableSection = $existingMutableSettings[$sectionName];
} else{
$existingMutableSection = array();
}
// remove default values from both (they should not get written to local)
if (isset($defaultSettings[$sectionName])) {
$changedSection = $this->arrayUnmerge($defaultSettings[$sectionName], $changedSection);
$existingMutableSection = $this->arrayUnmerge($defaultSettings[$sectionName], $existingMutableSection);
}
// if either local/config have non-default values and the other doesn't,
// OR both have values, but different values, we must write to config.ini.php
if (empty($changedSection) xor empty($existingMutableSection)
|| (!empty($changedSection)
&& !empty($existingMutableSection)
&& self::compareElements($changedSection, $existingMutableSection))
) {
$dirty = true;
}
$configToWrite[$sectionName] = $changedSection;
}
if ($dirty) {
// sort config sections by how early they appear in the file chain
$self = $this;
uksort($configToWrite, function ($sectionNameLhs, $sectionNameRhs) use ($self) {
$lhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameLhs);
$rhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameRhs);
if ($lhsIndex == $rhsIndex) {
$lhsIndexInFile = $self->getIndexOfSectionInFile($lhsIndex, $sectionNameLhs);
$rhsIndexInFile = $self->getIndexOfSectionInFile($rhsIndex, $sectionNameRhs);
if ($lhsIndexInFile == $rhsIndexInFile) {
return 0;
} elseif ($lhsIndexInFile < $rhsIndexInFile) {
return -1;
} else {
return 1;
}
} elseif ($lhsIndex < $rhsIndex) {
return -1;
} else {
return 1;
}
});
return $this->dumpSettings($configToWrite, $header);
} else {
return null;
}
} | [
"public",
"function",
"dumpChanges",
"(",
"$",
"header",
"=",
"''",
")",
"{",
"$",
"userSettingsFile",
"=",
"$",
"this",
"->",
"getUserSettingsFile",
"(",
")",
";",
"$",
"defaultSettings",
"=",
"$",
"this",
"->",
"getMergedDefaultSettings",
"(",
")",
";",
"$",
"existingMutableSettings",
"=",
"$",
"this",
"->",
"settingsChain",
"[",
"$",
"userSettingsFile",
"]",
";",
"$",
"dirty",
"=",
"false",
";",
"$",
"configToWrite",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"mergedSettings",
"as",
"$",
"sectionName",
"=>",
"$",
"changedSection",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"existingMutableSettings",
"[",
"$",
"sectionName",
"]",
")",
")",
"{",
"$",
"existingMutableSection",
"=",
"$",
"existingMutableSettings",
"[",
"$",
"sectionName",
"]",
";",
"}",
"else",
"{",
"$",
"existingMutableSection",
"=",
"array",
"(",
")",
";",
"}",
"// remove default values from both (they should not get written to local)",
"if",
"(",
"isset",
"(",
"$",
"defaultSettings",
"[",
"$",
"sectionName",
"]",
")",
")",
"{",
"$",
"changedSection",
"=",
"$",
"this",
"->",
"arrayUnmerge",
"(",
"$",
"defaultSettings",
"[",
"$",
"sectionName",
"]",
",",
"$",
"changedSection",
")",
";",
"$",
"existingMutableSection",
"=",
"$",
"this",
"->",
"arrayUnmerge",
"(",
"$",
"defaultSettings",
"[",
"$",
"sectionName",
"]",
",",
"$",
"existingMutableSection",
")",
";",
"}",
"// if either local/config have non-default values and the other doesn't,",
"// OR both have values, but different values, we must write to config.ini.php",
"if",
"(",
"empty",
"(",
"$",
"changedSection",
")",
"xor",
"empty",
"(",
"$",
"existingMutableSection",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"changedSection",
")",
"&&",
"!",
"empty",
"(",
"$",
"existingMutableSection",
")",
"&&",
"self",
"::",
"compareElements",
"(",
"$",
"changedSection",
",",
"$",
"existingMutableSection",
")",
")",
")",
"{",
"$",
"dirty",
"=",
"true",
";",
"}",
"$",
"configToWrite",
"[",
"$",
"sectionName",
"]",
"=",
"$",
"changedSection",
";",
"}",
"if",
"(",
"$",
"dirty",
")",
"{",
"// sort config sections by how early they appear in the file chain",
"$",
"self",
"=",
"$",
"this",
";",
"uksort",
"(",
"$",
"configToWrite",
",",
"function",
"(",
"$",
"sectionNameLhs",
",",
"$",
"sectionNameRhs",
")",
"use",
"(",
"$",
"self",
")",
"{",
"$",
"lhsIndex",
"=",
"$",
"self",
"->",
"findIndexOfFirstFileWithSection",
"(",
"$",
"sectionNameLhs",
")",
";",
"$",
"rhsIndex",
"=",
"$",
"self",
"->",
"findIndexOfFirstFileWithSection",
"(",
"$",
"sectionNameRhs",
")",
";",
"if",
"(",
"$",
"lhsIndex",
"==",
"$",
"rhsIndex",
")",
"{",
"$",
"lhsIndexInFile",
"=",
"$",
"self",
"->",
"getIndexOfSectionInFile",
"(",
"$",
"lhsIndex",
",",
"$",
"sectionNameLhs",
")",
";",
"$",
"rhsIndexInFile",
"=",
"$",
"self",
"->",
"getIndexOfSectionInFile",
"(",
"$",
"rhsIndex",
",",
"$",
"sectionNameRhs",
")",
";",
"if",
"(",
"$",
"lhsIndexInFile",
"==",
"$",
"rhsIndexInFile",
")",
"{",
"return",
"0",
";",
"}",
"elseif",
"(",
"$",
"lhsIndexInFile",
"<",
"$",
"rhsIndexInFile",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"1",
";",
"}",
"}",
"elseif",
"(",
"$",
"lhsIndex",
"<",
"$",
"rhsIndex",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"1",
";",
"}",
"}",
")",
";",
"return",
"$",
"this",
"->",
"dumpSettings",
"(",
"$",
"configToWrite",
",",
"$",
"header",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Writes the difference of the in-memory setting values and the on-disk user settings file setting
values to a string in INI format, and returns it.
If a config section is identical to the default settings section (as computed by merging
all default setting files), it is not written to the user settings file.
@param string $header The header of the INI output.
@return string The dumped INI contents. | [
"Writes",
"the",
"difference",
"of",
"the",
"in",
"-",
"memory",
"setting",
"values",
"and",
"the",
"on",
"-",
"disk",
"user",
"settings",
"file",
"setting",
"values",
"to",
"a",
"string",
"in",
"INI",
"format",
"and",
"returns",
"it",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config/IniFileChain.php#L133-L198 |
209,537 | matomo-org/matomo | core/Config/IniFileChain.php | IniFileChain.reload | public function reload($defaultSettingsFiles = array(), $userSettingsFile = null)
{
if (!empty($defaultSettingsFiles)
|| !empty($userSettingsFile)
) {
$this->resetSettingsChain($defaultSettingsFiles, $userSettingsFile);
}
$reader = new IniReader();
foreach ($this->settingsChain as $file => $ignore) {
if (is_readable($file)) {
try {
$contents = $reader->readFile($file);
$this->settingsChain[$file] = $this->decodeValues($contents);
} catch (IniReadingException $ex) {
throw new IniReadingException('Unable to read INI file {' . $file . '}: ' . $ex->getMessage() . "\n Your host may have disabled parse_ini_file().");
}
$this->decodeValues($this->settingsChain[$file]);
}
}
$merged = $this->mergeFileSettings();
// remove reference to $this->settingsChain... otherwise dump() or compareElements() will never notice a difference
// on PHP 7+ as they would be always equal
$this->mergedSettings = $this->copy($merged);
} | php | public function reload($defaultSettingsFiles = array(), $userSettingsFile = null)
{
if (!empty($defaultSettingsFiles)
|| !empty($userSettingsFile)
) {
$this->resetSettingsChain($defaultSettingsFiles, $userSettingsFile);
}
$reader = new IniReader();
foreach ($this->settingsChain as $file => $ignore) {
if (is_readable($file)) {
try {
$contents = $reader->readFile($file);
$this->settingsChain[$file] = $this->decodeValues($contents);
} catch (IniReadingException $ex) {
throw new IniReadingException('Unable to read INI file {' . $file . '}: ' . $ex->getMessage() . "\n Your host may have disabled parse_ini_file().");
}
$this->decodeValues($this->settingsChain[$file]);
}
}
$merged = $this->mergeFileSettings();
// remove reference to $this->settingsChain... otherwise dump() or compareElements() will never notice a difference
// on PHP 7+ as they would be always equal
$this->mergedSettings = $this->copy($merged);
} | [
"public",
"function",
"reload",
"(",
"$",
"defaultSettingsFiles",
"=",
"array",
"(",
")",
",",
"$",
"userSettingsFile",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"defaultSettingsFiles",
")",
"||",
"!",
"empty",
"(",
"$",
"userSettingsFile",
")",
")",
"{",
"$",
"this",
"->",
"resetSettingsChain",
"(",
"$",
"defaultSettingsFiles",
",",
"$",
"userSettingsFile",
")",
";",
"}",
"$",
"reader",
"=",
"new",
"IniReader",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"settingsChain",
"as",
"$",
"file",
"=>",
"$",
"ignore",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"try",
"{",
"$",
"contents",
"=",
"$",
"reader",
"->",
"readFile",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"settingsChain",
"[",
"$",
"file",
"]",
"=",
"$",
"this",
"->",
"decodeValues",
"(",
"$",
"contents",
")",
";",
"}",
"catch",
"(",
"IniReadingException",
"$",
"ex",
")",
"{",
"throw",
"new",
"IniReadingException",
"(",
"'Unable to read INI file {'",
".",
"$",
"file",
".",
"'}: '",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
".",
"\"\\n Your host may have disabled parse_ini_file().\"",
")",
";",
"}",
"$",
"this",
"->",
"decodeValues",
"(",
"$",
"this",
"->",
"settingsChain",
"[",
"$",
"file",
"]",
")",
";",
"}",
"}",
"$",
"merged",
"=",
"$",
"this",
"->",
"mergeFileSettings",
"(",
")",
";",
"// remove reference to $this->settingsChain... otherwise dump() or compareElements() will never notice a difference",
"// on PHP 7+ as they would be always equal",
"$",
"this",
"->",
"mergedSettings",
"=",
"$",
"this",
"->",
"copy",
"(",
"$",
"merged",
")",
";",
"}"
] | Reloads settings from disk. | [
"Reloads",
"settings",
"from",
"disk",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config/IniFileChain.php#L203-L229 |
209,538 | matomo-org/matomo | core/Config/IniFileChain.php | IniFileChain.encodeValues | protected function encodeValues(&$values)
{
if (is_array($values)) {
foreach ($values as &$value) {
$value = $this->encodeValues($value);
}
} elseif (is_float($values)) {
$values = Common::forceDotAsSeparatorForDecimalPoint($values);
} elseif (is_string($values)) {
$values = htmlentities($values, ENT_COMPAT, 'UTF-8');
$values = str_replace('$', '$', $values);
}
return $values;
} | php | protected function encodeValues(&$values)
{
if (is_array($values)) {
foreach ($values as &$value) {
$value = $this->encodeValues($value);
}
} elseif (is_float($values)) {
$values = Common::forceDotAsSeparatorForDecimalPoint($values);
} elseif (is_string($values)) {
$values = htmlentities($values, ENT_COMPAT, 'UTF-8');
$values = str_replace('$', '$', $values);
}
return $values;
} | [
"protected",
"function",
"encodeValues",
"(",
"&",
"$",
"values",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"encodeValues",
"(",
"$",
"value",
")",
";",
"}",
"}",
"elseif",
"(",
"is_float",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"Common",
"::",
"forceDotAsSeparatorForDecimalPoint",
"(",
"$",
"values",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"htmlentities",
"(",
"$",
"values",
",",
"ENT_COMPAT",
",",
"'UTF-8'",
")",
";",
"$",
"values",
"=",
"str_replace",
"(",
"'$'",
",",
"'$'",
",",
"$",
"values",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Encode HTML entities
@param mixed $values
@return mixed | [
"Encode",
"HTML",
"entities"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config/IniFileChain.php#L441-L454 |
209,539 | matomo-org/matomo | core/Config/IniFileChain.php | IniFileChain.decodeValues | protected function decodeValues(&$values)
{
if (is_array($values)) {
foreach ($values as &$value) {
$value = $this->decodeValues($value);
}
return $values;
} elseif (is_string($values)) {
return html_entity_decode($values, ENT_COMPAT, 'UTF-8');
}
return $values;
} | php | protected function decodeValues(&$values)
{
if (is_array($values)) {
foreach ($values as &$value) {
$value = $this->decodeValues($value);
}
return $values;
} elseif (is_string($values)) {
return html_entity_decode($values, ENT_COMPAT, 'UTF-8');
}
return $values;
} | [
"protected",
"function",
"decodeValues",
"(",
"&",
"$",
"values",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"decodeValues",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"values",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"values",
")",
")",
"{",
"return",
"html_entity_decode",
"(",
"$",
"values",
",",
"ENT_COMPAT",
",",
"'UTF-8'",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Decode HTML entities
@param mixed $values
@return mixed | [
"Decode",
"HTML",
"entities"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config/IniFileChain.php#L462-L473 |
209,540 | matomo-org/matomo | libs/Zend/Validate/Identical.php | Zend_Validate_Identical.setToken | public function setToken($token)
{
$this->_tokenString = (string) $token;
$this->_token = $token;
return $this;
} | php | public function setToken($token)
{
$this->_tokenString = (string) $token;
$this->_token = $token;
return $this;
} | [
"public",
"function",
"setToken",
"(",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"_tokenString",
"=",
"(",
"string",
")",
"$",
"token",
";",
"$",
"this",
"->",
"_token",
"=",
"$",
"token",
";",
"return",
"$",
"this",
";",
"}"
] | Set token against which to compare
@param mixed $token
@return Zend_Validate_Identical | [
"Set",
"token",
"against",
"which",
"to",
"compare"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Identical.php#L103-L108 |
209,541 | matomo-org/matomo | libs/Zend/Mail/Protocol/Abstract.php | Zend_Mail_Protocol_Abstract._addLog | protected function _addLog($value)
{
if ($this->_maximumLog >= 0 && count($this->_log) >= $this->_maximumLog) {
array_shift($this->_log);
}
$this->_log[] = $value;
} | php | protected function _addLog($value)
{
if ($this->_maximumLog >= 0 && count($this->_log) >= $this->_maximumLog) {
array_shift($this->_log);
}
$this->_log[] = $value;
} | [
"protected",
"function",
"_addLog",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_maximumLog",
">=",
"0",
"&&",
"count",
"(",
"$",
"this",
"->",
"_log",
")",
">=",
"$",
"this",
"->",
"_maximumLog",
")",
"{",
"array_shift",
"(",
"$",
"this",
"->",
"_log",
")",
";",
"}",
"$",
"this",
"->",
"_log",
"[",
"]",
"=",
"$",
"value",
";",
"}"
] | Add the transaction log
@param string new transaction
@return void | [
"Add",
"the",
"transaction",
"log"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Abstract.php#L243-L250 |
209,542 | matomo-org/matomo | libs/Zend/Mail/Protocol/Abstract.php | Zend_Mail_Protocol_Abstract._connect | protected function _connect($remote)
{
$errorNum = 0;
$errorStr = '';
// open connection
$this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);
if ($this->_socket === false) {
if ($errorNum == 0) {
$errorStr = 'Could not open socket';
}
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception($errorStr);
}
if (($result = $this->_setStreamTimeout(self::TIMEOUT_CONNECTION)) === false) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not set stream timeout');
}
return $result;
} | php | protected function _connect($remote)
{
$errorNum = 0;
$errorStr = '';
// open connection
$this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);
if ($this->_socket === false) {
if ($errorNum == 0) {
$errorStr = 'Could not open socket';
}
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception($errorStr);
}
if (($result = $this->_setStreamTimeout(self::TIMEOUT_CONNECTION)) === false) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not set stream timeout');
}
return $result;
} | [
"protected",
"function",
"_connect",
"(",
"$",
"remote",
")",
"{",
"$",
"errorNum",
"=",
"0",
";",
"$",
"errorStr",
"=",
"''",
";",
"// open connection",
"$",
"this",
"->",
"_socket",
"=",
"@",
"stream_socket_client",
"(",
"$",
"remote",
",",
"$",
"errorNum",
",",
"$",
"errorStr",
",",
"self",
"::",
"TIMEOUT_CONNECTION",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_socket",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"errorNum",
"==",
"0",
")",
"{",
"$",
"errorStr",
"=",
"'Could not open socket'",
";",
"}",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Exception.php';",
"throw",
"new",
"Zend_Mail_Protocol_Exception",
"(",
"$",
"errorStr",
")",
";",
"}",
"if",
"(",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"_setStreamTimeout",
"(",
"self",
"::",
"TIMEOUT_CONNECTION",
")",
")",
"===",
"false",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Exception.php';",
"throw",
"new",
"Zend_Mail_Protocol_Exception",
"(",
"'Could not set stream timeout'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Connect to the server using the supplied transport and target
An example $remote string may be 'tcp://mail.example.com:25' or 'ssh://hostname.com:2222'
@param string $remote Remote
@throws Zend_Mail_Protocol_Exception
@return boolean | [
"Connect",
"to",
"the",
"server",
"using",
"the",
"supplied",
"transport",
"and",
"target"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Abstract.php#L261-L289 |
209,543 | matomo-org/matomo | libs/Zend/Mail/Protocol/Abstract.php | Zend_Mail_Protocol_Abstract._send | protected function _send($request)
{
if (!is_resource($this->_socket)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
}
$this->_request = $request;
$result = fwrite($this->_socket, $request . self::EOL);
// Save request to internal log
$this->_addLog($request . self::EOL);
if ($result === false) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not send request to ' . $this->_host);
}
return $result;
} | php | protected function _send($request)
{
if (!is_resource($this->_socket)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
}
$this->_request = $request;
$result = fwrite($this->_socket, $request . self::EOL);
// Save request to internal log
$this->_addLog($request . self::EOL);
if ($result === false) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not send request to ' . $this->_host);
}
return $result;
} | [
"protected",
"function",
"_send",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_socket",
")",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Exception.php';",
"throw",
"new",
"Zend_Mail_Protocol_Exception",
"(",
"'No connection has been established to '",
".",
"$",
"this",
"->",
"_host",
")",
";",
"}",
"$",
"this",
"->",
"_request",
"=",
"$",
"request",
";",
"$",
"result",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"_socket",
",",
"$",
"request",
".",
"self",
"::",
"EOL",
")",
";",
"// Save request to internal log",
"$",
"this",
"->",
"_addLog",
"(",
"$",
"request",
".",
"self",
"::",
"EOL",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Exception.php';",
"throw",
"new",
"Zend_Mail_Protocol_Exception",
"(",
"'Could not send request to '",
".",
"$",
"this",
"->",
"_host",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Send the given request followed by a LINEEND to the server.
@param string $request
@throws Zend_Mail_Protocol_Exception
@return integer|boolean Number of bytes written to remote host | [
"Send",
"the",
"given",
"request",
"followed",
"by",
"a",
"LINEEND",
"to",
"the",
"server",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Abstract.php#L312-L338 |
209,544 | matomo-org/matomo | plugins/Dashboard/Controller.php | Controller.index | public function index()
{
$view = $this->_getDashboardView('@Dashboard/index');
$view->dashboardSettingsControl = new DashboardManagerControl();
$view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$view->dashboards = array();
if (!Piwik::isUserIsAnonymous()) {
$login = Piwik::getCurrentUserLogin();
$view->dashboards = $this->dashboard->getAllDashboards($login);
}
return $view->render();
} | php | public function index()
{
$view = $this->_getDashboardView('@Dashboard/index');
$view->dashboardSettingsControl = new DashboardManagerControl();
$view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$view->dashboards = array();
if (!Piwik::isUserIsAnonymous()) {
$login = Piwik::getCurrentUserLogin();
$view->dashboards = $this->dashboard->getAllDashboards($login);
}
return $view->render();
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"_getDashboardView",
"(",
"'@Dashboard/index'",
")",
";",
"$",
"view",
"->",
"dashboardSettingsControl",
"=",
"new",
"DashboardManagerControl",
"(",
")",
";",
"$",
"view",
"->",
"hasSomeAdminAccess",
"=",
"Piwik",
"::",
"isUserHasSomeAdminAccess",
"(",
")",
";",
"$",
"view",
"->",
"dashboards",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"Piwik",
"::",
"isUserIsAnonymous",
"(",
")",
")",
"{",
"$",
"login",
"=",
"Piwik",
"::",
"getCurrentUserLogin",
"(",
")",
";",
"$",
"view",
"->",
"dashboards",
"=",
"$",
"this",
"->",
"dashboard",
"->",
"getAllDashboards",
"(",
"$",
"login",
")",
";",
"}",
"return",
"$",
"view",
"->",
"render",
"(",
")",
";",
"}"
] | this is the exported widget | [
"this",
"is",
"the",
"exported",
"widget"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Dashboard/Controller.php#L57-L69 |
209,545 | matomo-org/matomo | plugins/Dashboard/Controller.php | Controller.resetLayout | public function resetLayout()
{
$this->checkTokenInUrl();
if (Piwik::isUserIsAnonymous()) {
$session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $this->dashboard->getDefaultLayout();
$session->setExpirationSeconds(1800);
} else {
Request::processRequest('Dashboard.resetDashboardLayout');
}
} | php | public function resetLayout()
{
$this->checkTokenInUrl();
if (Piwik::isUserIsAnonymous()) {
$session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $this->dashboard->getDefaultLayout();
$session->setExpirationSeconds(1800);
} else {
Request::processRequest('Dashboard.resetDashboardLayout');
}
} | [
"public",
"function",
"resetLayout",
"(",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"if",
"(",
"Piwik",
"::",
"isUserIsAnonymous",
"(",
")",
")",
"{",
"$",
"session",
"=",
"new",
"SessionNamespace",
"(",
"\"Dashboard\"",
")",
";",
"$",
"session",
"->",
"dashboardLayout",
"=",
"$",
"this",
"->",
"dashboard",
"->",
"getDefaultLayout",
"(",
")",
";",
"$",
"session",
"->",
"setExpirationSeconds",
"(",
"1800",
")",
";",
"}",
"else",
"{",
"Request",
"::",
"processRequest",
"(",
"'Dashboard.resetDashboardLayout'",
")",
";",
"}",
"}"
] | Resets the dashboard to the default widget configuration | [
"Resets",
"the",
"dashboard",
"to",
"the",
"default",
"widget",
"configuration"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Dashboard/Controller.php#L88-L98 |
209,546 | matomo-org/matomo | plugins/Dashboard/Controller.php | Controller.getAllDashboards | public function getAllDashboards()
{
$this->checkTokenInUrl();
if (Piwik::isUserIsAnonymous()) {
Json::sendHeaderJSON();
return '[]';
}
$login = Piwik::getCurrentUserLogin();
$dashboards = $this->dashboard->getAllDashboards($login);
Json::sendHeaderJSON();
return json_encode($dashboards);
} | php | public function getAllDashboards()
{
$this->checkTokenInUrl();
if (Piwik::isUserIsAnonymous()) {
Json::sendHeaderJSON();
return '[]';
}
$login = Piwik::getCurrentUserLogin();
$dashboards = $this->dashboard->getAllDashboards($login);
Json::sendHeaderJSON();
return json_encode($dashboards);
} | [
"public",
"function",
"getAllDashboards",
"(",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"if",
"(",
"Piwik",
"::",
"isUserIsAnonymous",
"(",
")",
")",
"{",
"Json",
"::",
"sendHeaderJSON",
"(",
")",
";",
"return",
"'[]'",
";",
"}",
"$",
"login",
"=",
"Piwik",
"::",
"getCurrentUserLogin",
"(",
")",
";",
"$",
"dashboards",
"=",
"$",
"this",
"->",
"dashboard",
"->",
"getAllDashboards",
"(",
"$",
"login",
")",
";",
"Json",
"::",
"sendHeaderJSON",
"(",
")",
";",
"return",
"json_encode",
"(",
"$",
"dashboards",
")",
";",
"}"
] | Outputs all available dashboards for the current user as a JSON string | [
"Outputs",
"all",
"available",
"dashboards",
"for",
"the",
"current",
"user",
"as",
"a",
"JSON",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Dashboard/Controller.php#L108-L122 |
209,547 | matomo-org/matomo | plugins/Dashboard/Controller.php | Controller.saveLayout | public function saveLayout()
{
$this->checkTokenInUrl();
$layout = Common::unsanitizeInputValue(Common::getRequestVar('layout'));
$layout = strip_tags($layout);
$idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
$name = Common::getRequestVar('name', '', 'string');
if (Piwik::isUserIsAnonymous()) {
$session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
$this->getModel()->createOrUpdateDashboard(Piwik::getCurrentUserLogin(), $idDashboard, $layout);
if (!empty($name)) {
$this->getModel()->updateDashboardName(Piwik::getCurrentUserLogin(), $idDashboard, $name);
}
}
} | php | public function saveLayout()
{
$this->checkTokenInUrl();
$layout = Common::unsanitizeInputValue(Common::getRequestVar('layout'));
$layout = strip_tags($layout);
$idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
$name = Common::getRequestVar('name', '', 'string');
if (Piwik::isUserIsAnonymous()) {
$session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
$this->getModel()->createOrUpdateDashboard(Piwik::getCurrentUserLogin(), $idDashboard, $layout);
if (!empty($name)) {
$this->getModel()->updateDashboardName(Piwik::getCurrentUserLogin(), $idDashboard, $name);
}
}
} | [
"public",
"function",
"saveLayout",
"(",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"$",
"layout",
"=",
"Common",
"::",
"unsanitizeInputValue",
"(",
"Common",
"::",
"getRequestVar",
"(",
"'layout'",
")",
")",
";",
"$",
"layout",
"=",
"strip_tags",
"(",
"$",
"layout",
")",
";",
"$",
"idDashboard",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'idDashboard'",
",",
"1",
",",
"'int'",
")",
";",
"$",
"name",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'name'",
",",
"''",
",",
"'string'",
")",
";",
"if",
"(",
"Piwik",
"::",
"isUserIsAnonymous",
"(",
")",
")",
"{",
"$",
"session",
"=",
"new",
"SessionNamespace",
"(",
"\"Dashboard\"",
")",
";",
"$",
"session",
"->",
"dashboardLayout",
"=",
"$",
"layout",
";",
"$",
"session",
"->",
"setExpirationSeconds",
"(",
"1800",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"createOrUpdateDashboard",
"(",
"Piwik",
"::",
"getCurrentUserLogin",
"(",
")",
",",
"$",
"idDashboard",
",",
"$",
"layout",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"updateDashboardName",
"(",
"Piwik",
"::",
"getCurrentUserLogin",
"(",
")",
",",
"$",
"idDashboard",
",",
"$",
"name",
")",
";",
"}",
"}",
"}"
] | Saves the layout for the current user
anonymous = in the session
authenticated user = in the DB | [
"Saves",
"the",
"layout",
"for",
"the",
"current",
"user",
"anonymous",
"=",
"in",
"the",
"session",
"authenticated",
"user",
"=",
"in",
"the",
"DB"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Dashboard/Controller.php#L129-L148 |
209,548 | matomo-org/matomo | plugins/Dashboard/Controller.php | Controller.saveLayoutAsDefault | public function saveLayoutAsDefault()
{
$this->checkTokenInUrl();
if (Piwik::hasUserSuperUserAccess()) {
$layout = Common::unsanitizeInputValue(Common::getRequestVar('layout'));
$layout = strip_tags($layout);
$this->getModel()->createOrUpdateDashboard('', '1', $layout);
}
} | php | public function saveLayoutAsDefault()
{
$this->checkTokenInUrl();
if (Piwik::hasUserSuperUserAccess()) {
$layout = Common::unsanitizeInputValue(Common::getRequestVar('layout'));
$layout = strip_tags($layout);
$this->getModel()->createOrUpdateDashboard('', '1', $layout);
}
} | [
"public",
"function",
"saveLayoutAsDefault",
"(",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"if",
"(",
"Piwik",
"::",
"hasUserSuperUserAccess",
"(",
")",
")",
"{",
"$",
"layout",
"=",
"Common",
"::",
"unsanitizeInputValue",
"(",
"Common",
"::",
"getRequestVar",
"(",
"'layout'",
")",
")",
";",
"$",
"layout",
"=",
"strip_tags",
"(",
"$",
"layout",
")",
";",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"createOrUpdateDashboard",
"(",
"''",
",",
"'1'",
",",
"$",
"layout",
")",
";",
"}",
"}"
] | Saves the layout as default | [
"Saves",
"the",
"layout",
"as",
"default"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Dashboard/Controller.php#L153-L162 |
209,549 | matomo-org/matomo | core/DataTable/Manager.php | Manager.addTable | public function addTable($table)
{
$this->nextTableId++;
$this[$this->nextTableId] = $table;
return $this->nextTableId;
} | php | public function addTable($table)
{
$this->nextTableId++;
$this[$this->nextTableId] = $table;
return $this->nextTableId;
} | [
"public",
"function",
"addTable",
"(",
"$",
"table",
")",
"{",
"$",
"this",
"->",
"nextTableId",
"++",
";",
"$",
"this",
"[",
"$",
"this",
"->",
"nextTableId",
"]",
"=",
"$",
"table",
";",
"return",
"$",
"this",
"->",
"nextTableId",
";",
"}"
] | Add a DataTable to the registry
@param DataTable $table
@return int Index of the table in the manager array | [
"Add",
"a",
"DataTable",
"to",
"the",
"registry"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Manager.php#L46-L51 |
209,550 | matomo-org/matomo | core/DataTable/Manager.php | Manager.deleteAll | public function deleteAll($deleteWhenIdTableGreaterThan = 0)
{
foreach ($this as $id => $table) {
if ($id > $deleteWhenIdTableGreaterThan) {
$this->deleteTable($id);
}
}
if ($deleteWhenIdTableGreaterThan == 0) {
$this->exchangeArray(array());
$this->nextTableId = 0;
}
} | php | public function deleteAll($deleteWhenIdTableGreaterThan = 0)
{
foreach ($this as $id => $table) {
if ($id > $deleteWhenIdTableGreaterThan) {
$this->deleteTable($id);
}
}
if ($deleteWhenIdTableGreaterThan == 0) {
$this->exchangeArray(array());
$this->nextTableId = 0;
}
} | [
"public",
"function",
"deleteAll",
"(",
"$",
"deleteWhenIdTableGreaterThan",
"=",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"id",
"=>",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"id",
">",
"$",
"deleteWhenIdTableGreaterThan",
")",
"{",
"$",
"this",
"->",
"deleteTable",
"(",
"$",
"id",
")",
";",
"}",
"}",
"if",
"(",
"$",
"deleteWhenIdTableGreaterThan",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"exchangeArray",
"(",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"nextTableId",
"=",
"0",
";",
"}",
"}"
] | Delete all the registered DataTables from the manager | [
"Delete",
"all",
"the",
"registered",
"DataTables",
"from",
"the",
"manager"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Manager.php#L84-L96 |
209,551 | matomo-org/matomo | core/DataTable/Manager.php | Manager.dumpAllTables | public function dumpAllTables()
{
echo "<hr />Manager->dumpAllTables()<br />";
foreach ($this as $id => $table) {
if (!($table instanceof DataTable)) {
echo "Error table $id is not instance of datatable<br />";
var_export($table);
} else {
echo "<hr />";
echo "Table (index=$id) TableId = " . $table->getId() . "<br />";
echo $table;
echo "<br />";
}
}
echo "<br />-- End Manager->dumpAllTables()<hr />";
} | php | public function dumpAllTables()
{
echo "<hr />Manager->dumpAllTables()<br />";
foreach ($this as $id => $table) {
if (!($table instanceof DataTable)) {
echo "Error table $id is not instance of datatable<br />";
var_export($table);
} else {
echo "<hr />";
echo "Table (index=$id) TableId = " . $table->getId() . "<br />";
echo $table;
echo "<br />";
}
}
echo "<br />-- End Manager->dumpAllTables()<hr />";
} | [
"public",
"function",
"dumpAllTables",
"(",
")",
"{",
"echo",
"\"<hr />Manager->dumpAllTables()<br />\"",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"id",
"=>",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"table",
"instanceof",
"DataTable",
")",
")",
"{",
"echo",
"\"Error table $id is not instance of datatable<br />\"",
";",
"var_export",
"(",
"$",
"table",
")",
";",
"}",
"else",
"{",
"echo",
"\"<hr />\"",
";",
"echo",
"\"Table (index=$id) TableId = \"",
".",
"$",
"table",
"->",
"getId",
"(",
")",
".",
"\"<br />\"",
";",
"echo",
"$",
"table",
";",
"echo",
"\"<br />\"",
";",
"}",
"}",
"echo",
"\"<br />-- End Manager->dumpAllTables()<hr />\"",
";",
"}"
] | Debug only. Dumps all tables currently registered in the Manager | [
"Debug",
"only",
".",
"Dumps",
"all",
"tables",
"currently",
"registered",
"in",
"the",
"Manager"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Manager.php#L143-L158 |
209,552 | matomo-org/matomo | core/Metrics.php | Metrics.getUnit | public static function getUnit($column, $idSite)
{
$nameToUnit = array(
'_rate' => '%',
'revenue' => Site::getCurrencySymbolFor($idSite),
'_time_' => 's'
);
$unit = null;
/**
* Use this event to define units for custom metrics used in evolution graphs and row evolution only.
*
* @param string $unit should hold the unit (e.g. %, €, s or empty string)
* @param string $column name of the column to determine
* @param string $idSite id of the current site
*/
Piwik::postEvent('Metrics.getEvolutionUnit', [&$unit, $column, $idSite]);
if (!empty($unit)) {
return $unit;
}
foreach ($nameToUnit as $pattern => $type) {
if (strpos($column, $pattern) !== false) {
return $type;
}
}
return '';
} | php | public static function getUnit($column, $idSite)
{
$nameToUnit = array(
'_rate' => '%',
'revenue' => Site::getCurrencySymbolFor($idSite),
'_time_' => 's'
);
$unit = null;
/**
* Use this event to define units for custom metrics used in evolution graphs and row evolution only.
*
* @param string $unit should hold the unit (e.g. %, €, s or empty string)
* @param string $column name of the column to determine
* @param string $idSite id of the current site
*/
Piwik::postEvent('Metrics.getEvolutionUnit', [&$unit, $column, $idSite]);
if (!empty($unit)) {
return $unit;
}
foreach ($nameToUnit as $pattern => $type) {
if (strpos($column, $pattern) !== false) {
return $type;
}
}
return '';
} | [
"public",
"static",
"function",
"getUnit",
"(",
"$",
"column",
",",
"$",
"idSite",
")",
"{",
"$",
"nameToUnit",
"=",
"array",
"(",
"'_rate'",
"=>",
"'%'",
",",
"'revenue'",
"=>",
"Site",
"::",
"getCurrencySymbolFor",
"(",
"$",
"idSite",
")",
",",
"'_time_'",
"=>",
"'s'",
")",
";",
"$",
"unit",
"=",
"null",
";",
"/**\n * Use this event to define units for custom metrics used in evolution graphs and row evolution only.\n *\n * @param string $unit should hold the unit (e.g. %, €, s or empty string)\n * @param string $column name of the column to determine\n * @param string $idSite id of the current site\n */",
"Piwik",
"::",
"postEvent",
"(",
"'Metrics.getEvolutionUnit'",
",",
"[",
"&",
"$",
"unit",
",",
"$",
"column",
",",
"$",
"idSite",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"unit",
")",
")",
"{",
"return",
"$",
"unit",
";",
"}",
"foreach",
"(",
"$",
"nameToUnit",
"as",
"$",
"pattern",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"column",
",",
"$",
"pattern",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"type",
";",
"}",
"}",
"return",
"''",
";",
"}"
] | Derive the unit name from a column name
@param $column
@param $idSite
@return string
@ignore | [
"Derive",
"the",
"unit",
"name",
"from",
"a",
"column",
"name"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Metrics.php#L236-L266 |
209,553 | matomo-org/matomo | core/Development.php | Development.isEnabled | public static function isEnabled()
{
if (is_null(self::$isEnabled)) {
self::$isEnabled = (bool) Config::getInstance()->Development['enabled'];
}
return self::$isEnabled;
} | php | public static function isEnabled()
{
if (is_null(self::$isEnabled)) {
self::$isEnabled = (bool) Config::getInstance()->Development['enabled'];
}
return self::$isEnabled;
} | [
"public",
"static",
"function",
"isEnabled",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"isEnabled",
")",
")",
"{",
"self",
"::",
"$",
"isEnabled",
"=",
"(",
"bool",
")",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"Development",
"[",
"'enabled'",
"]",
";",
"}",
"return",
"self",
"::",
"$",
"isEnabled",
";",
"}"
] | Returns `true` if development mode is enabled and `false` otherwise.
@return bool | [
"Returns",
"true",
"if",
"development",
"mode",
"is",
"enabled",
"and",
"false",
"otherwise",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Development.php#L33-L40 |
209,554 | matomo-org/matomo | plugins/ImageGraph/StaticGraph/PieGraph.php | PieGraph.truncateSmallValues | private function truncateSmallValues()
{
$metricColumns = array_keys($this->ordinateSeries);
$metricColumn = $metricColumns[0];
$ordinateValuesSum = 0;
foreach ($this->ordinateSeries[$metricColumn] as $ordinateValue) {
$ordinateValuesSum += $ordinateValue;
}
$truncatedOrdinateSeries[$metricColumn] = array();
$truncatedAbscissaSeries = array();
$smallValuesSum = 0;
$ordinateValuesCount = count($this->ordinateSeries[$metricColumn]);
for ($i = 0; $i < $ordinateValuesCount - 1; $i++) {
$ordinateValue = $this->ordinateSeries[$metricColumn][$i];
if ($ordinateValue / $ordinateValuesSum > 0.01) {
$truncatedOrdinateSeries[$metricColumn][] = $ordinateValue;
$truncatedAbscissaSeries[] = $this->abscissaSeries[$i];
} else {
$smallValuesSum += $ordinateValue;
}
}
$smallValuesSum += $this->ordinateSeries[$metricColumn][$ordinateValuesCount - 1];
if (($smallValuesSum / $ordinateValuesSum) > 0.01) {
$truncatedOrdinateSeries[$metricColumn][] = $smallValuesSum;
$truncatedAbscissaSeries[] = end($this->abscissaSeries);
}
$this->ordinateSeries = $truncatedOrdinateSeries;
$this->abscissaSeries = $truncatedAbscissaSeries;
} | php | private function truncateSmallValues()
{
$metricColumns = array_keys($this->ordinateSeries);
$metricColumn = $metricColumns[0];
$ordinateValuesSum = 0;
foreach ($this->ordinateSeries[$metricColumn] as $ordinateValue) {
$ordinateValuesSum += $ordinateValue;
}
$truncatedOrdinateSeries[$metricColumn] = array();
$truncatedAbscissaSeries = array();
$smallValuesSum = 0;
$ordinateValuesCount = count($this->ordinateSeries[$metricColumn]);
for ($i = 0; $i < $ordinateValuesCount - 1; $i++) {
$ordinateValue = $this->ordinateSeries[$metricColumn][$i];
if ($ordinateValue / $ordinateValuesSum > 0.01) {
$truncatedOrdinateSeries[$metricColumn][] = $ordinateValue;
$truncatedAbscissaSeries[] = $this->abscissaSeries[$i];
} else {
$smallValuesSum += $ordinateValue;
}
}
$smallValuesSum += $this->ordinateSeries[$metricColumn][$ordinateValuesCount - 1];
if (($smallValuesSum / $ordinateValuesSum) > 0.01) {
$truncatedOrdinateSeries[$metricColumn][] = $smallValuesSum;
$truncatedAbscissaSeries[] = end($this->abscissaSeries);
}
$this->ordinateSeries = $truncatedOrdinateSeries;
$this->abscissaSeries = $truncatedAbscissaSeries;
} | [
"private",
"function",
"truncateSmallValues",
"(",
")",
"{",
"$",
"metricColumns",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"ordinateSeries",
")",
";",
"$",
"metricColumn",
"=",
"$",
"metricColumns",
"[",
"0",
"]",
";",
"$",
"ordinateValuesSum",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"ordinateSeries",
"[",
"$",
"metricColumn",
"]",
"as",
"$",
"ordinateValue",
")",
"{",
"$",
"ordinateValuesSum",
"+=",
"$",
"ordinateValue",
";",
"}",
"$",
"truncatedOrdinateSeries",
"[",
"$",
"metricColumn",
"]",
"=",
"array",
"(",
")",
";",
"$",
"truncatedAbscissaSeries",
"=",
"array",
"(",
")",
";",
"$",
"smallValuesSum",
"=",
"0",
";",
"$",
"ordinateValuesCount",
"=",
"count",
"(",
"$",
"this",
"->",
"ordinateSeries",
"[",
"$",
"metricColumn",
"]",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"ordinateValuesCount",
"-",
"1",
";",
"$",
"i",
"++",
")",
"{",
"$",
"ordinateValue",
"=",
"$",
"this",
"->",
"ordinateSeries",
"[",
"$",
"metricColumn",
"]",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"ordinateValue",
"/",
"$",
"ordinateValuesSum",
">",
"0.01",
")",
"{",
"$",
"truncatedOrdinateSeries",
"[",
"$",
"metricColumn",
"]",
"[",
"]",
"=",
"$",
"ordinateValue",
";",
"$",
"truncatedAbscissaSeries",
"[",
"]",
"=",
"$",
"this",
"->",
"abscissaSeries",
"[",
"$",
"i",
"]",
";",
"}",
"else",
"{",
"$",
"smallValuesSum",
"+=",
"$",
"ordinateValue",
";",
"}",
"}",
"$",
"smallValuesSum",
"+=",
"$",
"this",
"->",
"ordinateSeries",
"[",
"$",
"metricColumn",
"]",
"[",
"$",
"ordinateValuesCount",
"-",
"1",
"]",
";",
"if",
"(",
"(",
"$",
"smallValuesSum",
"/",
"$",
"ordinateValuesSum",
")",
">",
"0.01",
")",
"{",
"$",
"truncatedOrdinateSeries",
"[",
"$",
"metricColumn",
"]",
"[",
"]",
"=",
"$",
"smallValuesSum",
";",
"$",
"truncatedAbscissaSeries",
"[",
"]",
"=",
"end",
"(",
"$",
"this",
"->",
"abscissaSeries",
")",
";",
"}",
"$",
"this",
"->",
"ordinateSeries",
"=",
"$",
"truncatedOrdinateSeries",
";",
"$",
"this",
"->",
"abscissaSeries",
"=",
"$",
"truncatedAbscissaSeries",
";",
"}"
] | this method logic is close to Piwik's core filter_truncate.
it uses a threshold to determine if an abscissa value should be drawn on the PIE
discarded abscissa values are summed in the 'other' abscissa value
if this process is not perform, CpChart will draw pie slices that are too small to see | [
"this",
"method",
"logic",
"is",
"close",
"to",
"Piwik",
"s",
"core",
"filter_truncate",
".",
"it",
"uses",
"a",
"threshold",
"to",
"determine",
"if",
"an",
"abscissa",
"value",
"should",
"be",
"drawn",
"on",
"the",
"PIE",
"discarded",
"abscissa",
"values",
"are",
"summed",
"in",
"the",
"other",
"abscissa",
"value"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ImageGraph/StaticGraph/PieGraph.php#L92-L125 |
209,555 | matomo-org/matomo | libs/HTML/QuickForm2/Element.php | HTML_QuickForm2_Element.getPersistentContent | protected function getPersistentContent()
{
if (!$this->persistent || null === ($value = $this->getValue())) {
return '';
}
return '<input type="hidden"' . self::getAttributesString(array(
'name' => $this->getName(),
'value' => $value,
'id' => $this->getId()
)) . ' />';
} | php | protected function getPersistentContent()
{
if (!$this->persistent || null === ($value = $this->getValue())) {
return '';
}
return '<input type="hidden"' . self::getAttributesString(array(
'name' => $this->getName(),
'value' => $value,
'id' => $this->getId()
)) . ' />';
} | [
"protected",
"function",
"getPersistentContent",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"persistent",
"||",
"null",
"===",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"'<input type=\"hidden\"'",
".",
"self",
"::",
"getAttributesString",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'value'",
"=>",
"$",
"value",
",",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
")",
")",
".",
"' />'",
";",
"}"
] | Generates hidden form field containing the element's value
This is used to pass the frozen element's value if 'persistent freeze'
feature is on
@return string | [
"Generates",
"hidden",
"form",
"field",
"containing",
"the",
"element",
"s",
"value"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Element.php#L77-L87 |
209,556 | matomo-org/matomo | libs/HTML/QuickForm2/Element.php | HTML_QuickForm2_Element.render | public function render(HTML_QuickForm2_Renderer $renderer)
{
foreach ($this->rules as $rule) {
if ($rule[1] & HTML_QuickForm2_Rule::RUNAT_CLIENT) {
$renderer->getJavascriptBuilder()->addRule($rule[0]);
}
}
$renderer->renderElement($this);
return $renderer;
} | php | public function render(HTML_QuickForm2_Renderer $renderer)
{
foreach ($this->rules as $rule) {
if ($rule[1] & HTML_QuickForm2_Rule::RUNAT_CLIENT) {
$renderer->getJavascriptBuilder()->addRule($rule[0]);
}
}
$renderer->renderElement($this);
return $renderer;
} | [
"public",
"function",
"render",
"(",
"HTML_QuickForm2_Renderer",
"$",
"renderer",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"rule",
"[",
"1",
"]",
"&",
"HTML_QuickForm2_Rule",
"::",
"RUNAT_CLIENT",
")",
"{",
"$",
"renderer",
"->",
"getJavascriptBuilder",
"(",
")",
"->",
"addRule",
"(",
"$",
"rule",
"[",
"0",
"]",
")",
";",
"}",
"}",
"$",
"renderer",
"->",
"renderElement",
"(",
"$",
"this",
")",
";",
"return",
"$",
"renderer",
";",
"}"
] | Renders the element using the given renderer
@param HTML_QuickForm2_Renderer Renderer instance
@return HTML_QuickForm2_Renderer | [
"Renders",
"the",
"element",
"using",
"the",
"given",
"renderer"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Element.php#L112-L121 |
209,557 | matomo-org/matomo | plugins/GeoIp2/GeoIP2AutoUpdater.php | GeoIP2AutoUpdater.downloadFile | protected function downloadFile($dbType, $url)
{
$url = trim($url);
$ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);
// NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity
$zippedFilename = LocationProviderGeoIp2::$dbNames[$dbType][0] . '.' . $ext;
$zippedOutputPath = LocationProviderGeoIp2::getPathForGeoIpDatabase($zippedFilename);
$url = self::removeDateFromUrl($url);
// download zipped file to misc dir
try {
$success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath': " . $ex->getMessage());
}
if ($success !== true) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath'! (Unknown error)");
}
Log::info("GeoIP2AutoUpdater: successfully downloaded '%s'", $url);
try {
self::unzipDownloadedFile($zippedOutputPath, $dbType, $unlink = true);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after "
. "downloading " . "'$url': " . $ex->getMessage());
}
Log::info("GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'", $url);
} | php | protected function downloadFile($dbType, $url)
{
$url = trim($url);
$ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);
// NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity
$zippedFilename = LocationProviderGeoIp2::$dbNames[$dbType][0] . '.' . $ext;
$zippedOutputPath = LocationProviderGeoIp2::getPathForGeoIpDatabase($zippedFilename);
$url = self::removeDateFromUrl($url);
// download zipped file to misc dir
try {
$success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath': " . $ex->getMessage());
}
if ($success !== true) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath'! (Unknown error)");
}
Log::info("GeoIP2AutoUpdater: successfully downloaded '%s'", $url);
try {
self::unzipDownloadedFile($zippedOutputPath, $dbType, $unlink = true);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after "
. "downloading " . "'$url': " . $ex->getMessage());
}
Log::info("GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'", $url);
} | [
"protected",
"function",
"downloadFile",
"(",
"$",
"dbType",
",",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"$",
"ext",
"=",
"GeoIP2AutoUpdater",
"::",
"getGeoIPUrlExtension",
"(",
"$",
"url",
")",
";",
"// NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity",
"$",
"zippedFilename",
"=",
"LocationProviderGeoIp2",
"::",
"$",
"dbNames",
"[",
"$",
"dbType",
"]",
"[",
"0",
"]",
".",
"'.'",
".",
"$",
"ext",
";",
"$",
"zippedOutputPath",
"=",
"LocationProviderGeoIp2",
"::",
"getPathForGeoIpDatabase",
"(",
"$",
"zippedFilename",
")",
";",
"$",
"url",
"=",
"self",
"::",
"removeDateFromUrl",
"(",
"$",
"url",
")",
";",
"// download zipped file to misc dir",
"try",
"{",
"$",
"success",
"=",
"Http",
"::",
"sendHttpRequest",
"(",
"$",
"url",
",",
"$",
"timeout",
"=",
"3600",
",",
"$",
"userAgent",
"=",
"null",
",",
"$",
"zippedOutputPath",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"GeoIP2AutoUpdater: failed to download '$url' to \"",
".",
"\"'$zippedOutputPath': \"",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"success",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"GeoIP2AutoUpdater: failed to download '$url' to \"",
".",
"\"'$zippedOutputPath'! (Unknown error)\"",
")",
";",
"}",
"Log",
"::",
"info",
"(",
"\"GeoIP2AutoUpdater: successfully downloaded '%s'\"",
",",
"$",
"url",
")",
";",
"try",
"{",
"self",
"::",
"unzipDownloadedFile",
"(",
"$",
"zippedOutputPath",
",",
"$",
"dbType",
",",
"$",
"unlink",
"=",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after \"",
".",
"\"downloading \"",
".",
"\"'$url': \"",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"Log",
"::",
"info",
"(",
"\"GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'\"",
",",
"$",
"url",
")",
";",
"}"
] | Downloads a GeoIP 2 database archive, extracts the .mmdb file and overwrites the existing
old database.
If something happens that causes the download to fail, no exception is thrown, but
an error is logged.
@param string $dbType
@param string $url URL to the database to download. The type of database is determined
from this URL.
@throws Exception | [
"Downloads",
"a",
"GeoIP",
"2",
"database",
"archive",
"extracts",
"the",
".",
"mmdb",
"file",
"and",
"overwrites",
"the",
"existing",
"old",
"database",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/GeoIP2AutoUpdater.php#L123-L159 |
209,558 | matomo-org/matomo | plugins/GeoIp2/GeoIP2AutoUpdater.php | GeoIP2AutoUpdater.getConfiguredUrls | public static function getConfiguredUrls()
{
$result = array();
foreach (self::$urlOptions as $key => $optionName) {
$result[$key] = Option::get($optionName);
}
return $result;
} | php | public static function getConfiguredUrls()
{
$result = array();
foreach (self::$urlOptions as $key => $optionName) {
$result[$key] = Option::get($optionName);
}
return $result;
} | [
"public",
"static",
"function",
"getConfiguredUrls",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"urlOptions",
"as",
"$",
"key",
"=>",
"$",
"optionName",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"Option",
"::",
"get",
"(",
"$",
"optionName",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Retrieves the URLs used to update various GeoIP 2 database files.
@return array | [
"Retrieves",
"the",
"URLs",
"used",
"to",
"update",
"various",
"GeoIP",
"2",
"database",
"files",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/GeoIP2AutoUpdater.php#L376-L383 |
209,559 | matomo-org/matomo | plugins/GeoIp2/GeoIP2AutoUpdater.php | GeoIP2AutoUpdater.getSchedulePeriod | public static function getSchedulePeriod()
{
$period = Option::get(self::SCHEDULE_PERIOD_OPTION_NAME);
if ($period === false) {
$period = self::SCHEDULE_PERIOD_MONTHLY;
}
return $period;
} | php | public static function getSchedulePeriod()
{
$period = Option::get(self::SCHEDULE_PERIOD_OPTION_NAME);
if ($period === false) {
$period = self::SCHEDULE_PERIOD_MONTHLY;
}
return $period;
} | [
"public",
"static",
"function",
"getSchedulePeriod",
"(",
")",
"{",
"$",
"period",
"=",
"Option",
"::",
"get",
"(",
"self",
"::",
"SCHEDULE_PERIOD_OPTION_NAME",
")",
";",
"if",
"(",
"$",
"period",
"===",
"false",
")",
"{",
"$",
"period",
"=",
"self",
"::",
"SCHEDULE_PERIOD_MONTHLY",
";",
"}",
"return",
"$",
"period",
";",
"}"
] | Returns the configured update period, either 'week' or 'month'. Defaults to
'month'.
@return string | [
"Returns",
"the",
"configured",
"update",
"period",
"either",
"week",
"or",
"month",
".",
"Defaults",
"to",
"month",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/GeoIP2AutoUpdater.php#L416-L423 |
209,560 | matomo-org/matomo | plugins/GeoIp2/GeoIP2AutoUpdater.php | GeoIP2AutoUpdater.getGeoIPUrlExtension | public static function getGeoIPUrlExtension($url)
{
// check for &suffix= query param that is special to MaxMind URLs
if (preg_match('/suffix=([^&]+)/', $url, $matches)) {
$ext = $matches[1];
} else {
// use basename of url
$filenameParts = explode('.', basename($url), 2);
if (count($filenameParts) > 1) {
$ext = end($filenameParts);
} else {
$ext = reset($filenameParts);
}
}
self::checkForSupportedArchiveType($ext);
return $ext;
} | php | public static function getGeoIPUrlExtension($url)
{
// check for &suffix= query param that is special to MaxMind URLs
if (preg_match('/suffix=([^&]+)/', $url, $matches)) {
$ext = $matches[1];
} else {
// use basename of url
$filenameParts = explode('.', basename($url), 2);
if (count($filenameParts) > 1) {
$ext = end($filenameParts);
} else {
$ext = reset($filenameParts);
}
}
self::checkForSupportedArchiveType($ext);
return $ext;
} | [
"public",
"static",
"function",
"getGeoIPUrlExtension",
"(",
"$",
"url",
")",
"{",
"// check for &suffix= query param that is special to MaxMind URLs",
"if",
"(",
"preg_match",
"(",
"'/suffix=([^&]+)/'",
",",
"$",
"url",
",",
"$",
"matches",
")",
")",
"{",
"$",
"ext",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"// use basename of url",
"$",
"filenameParts",
"=",
"explode",
"(",
"'.'",
",",
"basename",
"(",
"$",
"url",
")",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"filenameParts",
")",
">",
"1",
")",
"{",
"$",
"ext",
"=",
"end",
"(",
"$",
"filenameParts",
")",
";",
"}",
"else",
"{",
"$",
"ext",
"=",
"reset",
"(",
"$",
"filenameParts",
")",
";",
"}",
"}",
"self",
"::",
"checkForSupportedArchiveType",
"(",
"$",
"ext",
")",
";",
"return",
"$",
"ext",
";",
"}"
] | Returns the extension of a URL used to update a GeoIP 2 database, if it can be found. | [
"Returns",
"the",
"extension",
"of",
"a",
"URL",
"used",
"to",
"update",
"a",
"GeoIP",
"2",
"database",
"if",
"it",
"can",
"be",
"found",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/GeoIP2AutoUpdater.php#L452-L470 |
209,561 | matomo-org/matomo | plugins/GeoIp2/GeoIP2AutoUpdater.php | GeoIP2AutoUpdater.getOldAndNewPathsForBrokenDb | private function getOldAndNewPathsForBrokenDb($possibleDbNames)
{
$pathToDb = LocationProviderGeoIp2::getPathToGeoIpDatabase($possibleDbNames);
$newPath = false;
if ($pathToDb !== false) {
$newPath = $pathToDb . ".broken";
}
return array($pathToDb, $newPath);
} | php | private function getOldAndNewPathsForBrokenDb($possibleDbNames)
{
$pathToDb = LocationProviderGeoIp2::getPathToGeoIpDatabase($possibleDbNames);
$newPath = false;
if ($pathToDb !== false) {
$newPath = $pathToDb . ".broken";
}
return array($pathToDb, $newPath);
} | [
"private",
"function",
"getOldAndNewPathsForBrokenDb",
"(",
"$",
"possibleDbNames",
")",
"{",
"$",
"pathToDb",
"=",
"LocationProviderGeoIp2",
"::",
"getPathToGeoIpDatabase",
"(",
"$",
"possibleDbNames",
")",
";",
"$",
"newPath",
"=",
"false",
";",
"if",
"(",
"$",
"pathToDb",
"!==",
"false",
")",
"{",
"$",
"newPath",
"=",
"$",
"pathToDb",
".",
"\".broken\"",
";",
"}",
"return",
"array",
"(",
"$",
"pathToDb",
",",
"$",
"newPath",
")",
";",
"}"
] | Returns the path to a GeoIP 2 database and a path to rename it to if it's broken.
@param array $possibleDbNames The possible names of the database.
@return array Array with two elements, the path to the existing database, and
the path to rename it to if it is broken. The second will end
with something like .broken . | [
"Returns",
"the",
"path",
"to",
"a",
"GeoIP",
"2",
"database",
"and",
"a",
"path",
"to",
"rename",
"it",
"to",
"if",
"it",
"s",
"broken",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/GeoIP2AutoUpdater.php#L550-L560 |
209,562 | matomo-org/matomo | plugins/GeoIp2/GeoIP2AutoUpdater.php | GeoIP2AutoUpdater.getLastRunTime | public static function getLastRunTime()
{
$timestamp = Option::get(self::LAST_RUN_TIME_OPTION_NAME);
return $timestamp === false ? false : Date::factory((int)$timestamp);
} | php | public static function getLastRunTime()
{
$timestamp = Option::get(self::LAST_RUN_TIME_OPTION_NAME);
return $timestamp === false ? false : Date::factory((int)$timestamp);
} | [
"public",
"static",
"function",
"getLastRunTime",
"(",
")",
"{",
"$",
"timestamp",
"=",
"Option",
"::",
"get",
"(",
"self",
"::",
"LAST_RUN_TIME_OPTION_NAME",
")",
";",
"return",
"$",
"timestamp",
"===",
"false",
"?",
"false",
":",
"Date",
"::",
"factory",
"(",
"(",
"int",
")",
"$",
"timestamp",
")",
";",
"}"
] | Returns the time the auto updater was last run.
@return Date|false | [
"Returns",
"the",
"time",
"the",
"auto",
"updater",
"was",
"last",
"run",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/GeoIP2AutoUpdater.php#L567-L571 |
209,563 | matomo-org/matomo | core/Period/Month.php | Month.fillDayPeriods | private function fillDayPeriods($startDate, $endDate)
{
while (($startDate->isEarlier($endDate) || $startDate == $endDate)) {
$this->addSubperiod(new Day($startDate));
$startDate = $startDate->addDay(1);
}
} | php | private function fillDayPeriods($startDate, $endDate)
{
while (($startDate->isEarlier($endDate) || $startDate == $endDate)) {
$this->addSubperiod(new Day($startDate));
$startDate = $startDate->addDay(1);
}
} | [
"private",
"function",
"fillDayPeriods",
"(",
"$",
"startDate",
",",
"$",
"endDate",
")",
"{",
"while",
"(",
"(",
"$",
"startDate",
"->",
"isEarlier",
"(",
"$",
"endDate",
")",
"||",
"$",
"startDate",
"==",
"$",
"endDate",
")",
")",
"{",
"$",
"this",
"->",
"addSubperiod",
"(",
"new",
"Day",
"(",
"$",
"startDate",
")",
")",
";",
"$",
"startDate",
"=",
"$",
"startDate",
"->",
"addDay",
"(",
"1",
")",
";",
"}",
"}"
] | Fills the periods from startDate to endDate with days
@param Date $startDate
@param Date $endDate | [
"Fills",
"the",
"periods",
"from",
"startDate",
"to",
"endDate",
"with",
"days"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Period/Month.php#L110-L116 |
209,564 | matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.& | public function &get($idSite, $period)
{
if (!isset($this->data[$idSite][$period])) {
$this->data[$idSite][$period] = $this->defaultRow;
}
return $this->data[$idSite][$period];
} | php | public function &get($idSite, $period)
{
if (!isset($this->data[$idSite][$period])) {
$this->data[$idSite][$period] = $this->defaultRow;
}
return $this->data[$idSite][$period];
} | [
"public",
"function",
"&",
"get",
"(",
"$",
"idSite",
",",
"$",
"period",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"idSite",
"]",
"[",
"$",
"period",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"idSite",
"]",
"[",
"$",
"period",
"]",
"=",
"$",
"this",
"->",
"defaultRow",
";",
"}",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"idSite",
"]",
"[",
"$",
"period",
"]",
";",
"}"
] | Returns a reference to the data for a specific site & period. If there is
no data for the given site ID & period, it is set to the default row.
@param int $idSite
@param string $period eg, '2012-01-01,2012-01-31' | [
"Returns",
"a",
"reference",
"to",
"the",
"data",
"for",
"a",
"specific",
"site",
"&",
"period",
".",
"If",
"there",
"is",
"no",
"data",
"for",
"the",
"given",
"site",
"ID",
"&",
"period",
"it",
"is",
"set",
"to",
"the",
"default",
"row",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L132-L138 |
209,565 | matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.set | public function set($idSite, $period, $name, $value)
{
$row = & $this->get($idSite, $period);
$row[$name] = $value;
} | php | public function set($idSite, $period, $name, $value)
{
$row = & $this->get($idSite, $period);
$row[$name] = $value;
} | [
"public",
"function",
"set",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"row",
"=",
"&",
"$",
"this",
"->",
"get",
"(",
"$",
"idSite",
",",
"$",
"period",
")",
";",
"$",
"row",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] | Set data for a specific site & period. If there is no data for the given site ID & period,
it is set to the default row.
@param int $idSite
@param string $period eg, '2012-01-01,2012-01-31'
@param string $name eg 'nb_visits'
@param string $value eg 5 | [
"Set",
"data",
"for",
"a",
"specific",
"site",
"&",
"period",
".",
"If",
"there",
"is",
"no",
"data",
"for",
"the",
"given",
"site",
"ID",
"&",
"period",
"it",
"is",
"set",
"to",
"the",
"default",
"row",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L149-L153 |
209,566 | matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.addMetadata | public function addMetadata($idSite, $period, $name, $value)
{
$row = & $this->get($idSite, $period);
$row[self::METADATA_CONTAINER_ROW_KEY][$name] = $value;
} | php | public function addMetadata($idSite, $period, $name, $value)
{
$row = & $this->get($idSite, $period);
$row[self::METADATA_CONTAINER_ROW_KEY][$name] = $value;
} | [
"public",
"function",
"addMetadata",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"row",
"=",
"&",
"$",
"this",
"->",
"get",
"(",
"$",
"idSite",
",",
"$",
"period",
")",
";",
"$",
"row",
"[",
"self",
"::",
"METADATA_CONTAINER_ROW_KEY",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] | Adds a new metadata to the data for specific site & period. If there is no
data for the given site ID & period, it is set to the default row.
Note: Site ID and period range string are two special types of metadata. Since
the data stored in this class is indexed by site & period, this metadata is not
stored in individual data rows.
@param int $idSite
@param string $period eg, '2012-01-01,2012-01-31'
@param string $name The metadata name.
@param mixed $value The metadata name. | [
"Adds",
"a",
"new",
"metadata",
"to",
"the",
"data",
"for",
"specific",
"site",
"&",
"period",
".",
"If",
"there",
"is",
"no",
"data",
"for",
"the",
"given",
"site",
"ID",
"&",
"period",
"it",
"is",
"set",
"to",
"the",
"default",
"row",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L168-L172 |
209,567 | matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.getIndexedArray | public function getIndexedArray($resultIndices)
{
$indexKeys = array_keys($resultIndices);
$result = $this->createOrderedIndex($indexKeys);
foreach ($this->data as $idSite => $rowsByPeriod) {
foreach ($rowsByPeriod as $period => $row) {
// FIXME: This hack works around a strange bug that occurs when getting
// archive IDs through ArchiveProcessing instances. When a table
// does not already exist, for some reason the archive ID for
// today (or from two days ago) will be added to the Archive
// instances list. The Archive instance will then select data
// for periods outside of the requested set.
// working around the bug here, but ideally, we need to figure
// out why incorrect idarchives are being selected.
if (empty($this->periods[$period])) {
continue;
}
$this->putRowInIndex($result, $indexKeys, $row, $idSite, $period);
}
}
return $result;
} | php | public function getIndexedArray($resultIndices)
{
$indexKeys = array_keys($resultIndices);
$result = $this->createOrderedIndex($indexKeys);
foreach ($this->data as $idSite => $rowsByPeriod) {
foreach ($rowsByPeriod as $period => $row) {
// FIXME: This hack works around a strange bug that occurs when getting
// archive IDs through ArchiveProcessing instances. When a table
// does not already exist, for some reason the archive ID for
// today (or from two days ago) will be added to the Archive
// instances list. The Archive instance will then select data
// for periods outside of the requested set.
// working around the bug here, but ideally, we need to figure
// out why incorrect idarchives are being selected.
if (empty($this->periods[$period])) {
continue;
}
$this->putRowInIndex($result, $indexKeys, $row, $idSite, $period);
}
}
return $result;
} | [
"public",
"function",
"getIndexedArray",
"(",
"$",
"resultIndices",
")",
"{",
"$",
"indexKeys",
"=",
"array_keys",
"(",
"$",
"resultIndices",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"createOrderedIndex",
"(",
"$",
"indexKeys",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"idSite",
"=>",
"$",
"rowsByPeriod",
")",
"{",
"foreach",
"(",
"$",
"rowsByPeriod",
"as",
"$",
"period",
"=>",
"$",
"row",
")",
"{",
"// FIXME: This hack works around a strange bug that occurs when getting",
"// archive IDs through ArchiveProcessing instances. When a table",
"// does not already exist, for some reason the archive ID for",
"// today (or from two days ago) will be added to the Archive",
"// instances list. The Archive instance will then select data",
"// for periods outside of the requested set.",
"// working around the bug here, but ideally, we need to figure",
"// out why incorrect idarchives are being selected.",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"periods",
"[",
"$",
"period",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"putRowInIndex",
"(",
"$",
"result",
",",
"$",
"indexKeys",
",",
"$",
"row",
",",
"$",
"idSite",
",",
"$",
"period",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns archive data as an array indexed by metadata.
@param array $resultIndices An array mapping metadata names to pretty labels
for them. Each archive data row will be indexed
by the metadata specified here.
Eg, array('site' => 'idSite', 'period' => 'Date')
@return array | [
"Returns",
"archive",
"data",
"as",
"an",
"array",
"indexed",
"by",
"metadata",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L184-L208 |
209,568 | matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.getDataTable | public function getDataTable($resultIndices)
{
$dataTableFactory = new DataTableFactory(
$this->dataNames, $this->dataType, $this->sitesId, $this->periods, $this->defaultRow);
$index = $this->getIndexedArray($resultIndices);
return $dataTableFactory->make($index, $resultIndices);
} | php | public function getDataTable($resultIndices)
{
$dataTableFactory = new DataTableFactory(
$this->dataNames, $this->dataType, $this->sitesId, $this->periods, $this->defaultRow);
$index = $this->getIndexedArray($resultIndices);
return $dataTableFactory->make($index, $resultIndices);
} | [
"public",
"function",
"getDataTable",
"(",
"$",
"resultIndices",
")",
"{",
"$",
"dataTableFactory",
"=",
"new",
"DataTableFactory",
"(",
"$",
"this",
"->",
"dataNames",
",",
"$",
"this",
"->",
"dataType",
",",
"$",
"this",
"->",
"sitesId",
",",
"$",
"this",
"->",
"periods",
",",
"$",
"this",
"->",
"defaultRow",
")",
";",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndexedArray",
"(",
"$",
"resultIndices",
")",
";",
"return",
"$",
"dataTableFactory",
"->",
"make",
"(",
"$",
"index",
",",
"$",
"resultIndices",
")",
";",
"}"
] | Returns archive data as a DataTable indexed by metadata. Indexed data will
be represented by Map instances.
@param array $resultIndices An array mapping metadata names to pretty labels
for them. Each archive data row will be indexed
by the metadata specified here.
Eg, array('site' => 'idSite', 'period' => 'Date')
@return DataTable|DataTable\Map | [
"Returns",
"archive",
"data",
"as",
"a",
"DataTable",
"indexed",
"by",
"metadata",
".",
"Indexed",
"data",
"will",
"be",
"represented",
"by",
"Map",
"instances",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L221-L229 |
209,569 | matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.getExpandedDataTable | public function getExpandedDataTable($resultIndices, $idSubTable = null, $depth = null, $addMetadataSubTableId = false)
{
if ($this->dataType != 'blob') {
throw new Exception("DataCollection: cannot call getExpandedDataTable with "
. "{$this->dataType} data types. Only works with blob data.");
}
if (count($this->dataNames) !== 1) {
throw new Exception("DataCollection: cannot call getExpandedDataTable with "
. "more than one record.");
}
$dataTableFactory = new DataTableFactory(
$this->dataNames, 'blob', $this->sitesId, $this->periods, $this->defaultRow);
$dataTableFactory->expandDataTable($depth, $addMetadataSubTableId);
$dataTableFactory->useSubtable($idSubTable);
$index = $this->getIndexedArray($resultIndices);
return $dataTableFactory->make($index, $resultIndices);
} | php | public function getExpandedDataTable($resultIndices, $idSubTable = null, $depth = null, $addMetadataSubTableId = false)
{
if ($this->dataType != 'blob') {
throw new Exception("DataCollection: cannot call getExpandedDataTable with "
. "{$this->dataType} data types. Only works with blob data.");
}
if (count($this->dataNames) !== 1) {
throw new Exception("DataCollection: cannot call getExpandedDataTable with "
. "more than one record.");
}
$dataTableFactory = new DataTableFactory(
$this->dataNames, 'blob', $this->sitesId, $this->periods, $this->defaultRow);
$dataTableFactory->expandDataTable($depth, $addMetadataSubTableId);
$dataTableFactory->useSubtable($idSubTable);
$index = $this->getIndexedArray($resultIndices);
return $dataTableFactory->make($index, $resultIndices);
} | [
"public",
"function",
"getExpandedDataTable",
"(",
"$",
"resultIndices",
",",
"$",
"idSubTable",
"=",
"null",
",",
"$",
"depth",
"=",
"null",
",",
"$",
"addMetadataSubTableId",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dataType",
"!=",
"'blob'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"DataCollection: cannot call getExpandedDataTable with \"",
".",
"\"{$this->dataType} data types. Only works with blob data.\"",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"dataNames",
")",
"!==",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"DataCollection: cannot call getExpandedDataTable with \"",
".",
"\"more than one record.\"",
")",
";",
"}",
"$",
"dataTableFactory",
"=",
"new",
"DataTableFactory",
"(",
"$",
"this",
"->",
"dataNames",
",",
"'blob'",
",",
"$",
"this",
"->",
"sitesId",
",",
"$",
"this",
"->",
"periods",
",",
"$",
"this",
"->",
"defaultRow",
")",
";",
"$",
"dataTableFactory",
"->",
"expandDataTable",
"(",
"$",
"depth",
",",
"$",
"addMetadataSubTableId",
")",
";",
"$",
"dataTableFactory",
"->",
"useSubtable",
"(",
"$",
"idSubTable",
")",
";",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndexedArray",
"(",
"$",
"resultIndices",
")",
";",
"return",
"$",
"dataTableFactory",
"->",
"make",
"(",
"$",
"index",
",",
"$",
"resultIndices",
")",
";",
"}"
] | Returns archive data as a DataTable indexed by metadata. Indexed data will
be represented by Map instances. Each DataTable will have
its subtable IDs set.
This function will only work if blob data was loaded and only one record
was loaded (not including subtables of the record).
@param array $resultIndices An array mapping metadata names to pretty labels
for them. Each archive data row will be indexed
by the metadata specified here.
Eg, array('site' => 'idSite', 'period' => 'Date')
@param int|null $idSubTable The subtable to return.
@param int|null $depth max depth for subtables.
@param bool $addMetadataSubTableId Whether to add the DB subtable ID as metadata
to each datatable, or not.
@throws Exception
@return DataTable|DataTable\Map | [
"Returns",
"archive",
"data",
"as",
"a",
"DataTable",
"indexed",
"by",
"metadata",
".",
"Indexed",
"data",
"will",
"be",
"represented",
"by",
"Map",
"instances",
".",
"Each",
"DataTable",
"will",
"have",
"its",
"subtable",
"IDs",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L268-L288 |
209,570 | matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.putRowInIndex | private function putRowInIndex(&$index, $metadataNamesToIndexBy, $row, $idSite, $period)
{
$currentLevel = & $index;
foreach ($metadataNamesToIndexBy as $metadataName) {
if ($metadataName == DataTableFactory::TABLE_METADATA_SITE_INDEX) {
$key = $idSite;
} elseif ($metadataName == DataTableFactory::TABLE_METADATA_PERIOD_INDEX) {
$key = $period;
} else {
$key = $row[self::METADATA_CONTAINER_ROW_KEY][$metadataName];
}
if (!isset($currentLevel[$key])) {
$currentLevel[$key] = array();
}
$currentLevel = & $currentLevel[$key];
}
$currentLevel = $row;
} | php | private function putRowInIndex(&$index, $metadataNamesToIndexBy, $row, $idSite, $period)
{
$currentLevel = & $index;
foreach ($metadataNamesToIndexBy as $metadataName) {
if ($metadataName == DataTableFactory::TABLE_METADATA_SITE_INDEX) {
$key = $idSite;
} elseif ($metadataName == DataTableFactory::TABLE_METADATA_PERIOD_INDEX) {
$key = $period;
} else {
$key = $row[self::METADATA_CONTAINER_ROW_KEY][$metadataName];
}
if (!isset($currentLevel[$key])) {
$currentLevel[$key] = array();
}
$currentLevel = & $currentLevel[$key];
}
$currentLevel = $row;
} | [
"private",
"function",
"putRowInIndex",
"(",
"&",
"$",
"index",
",",
"$",
"metadataNamesToIndexBy",
",",
"$",
"row",
",",
"$",
"idSite",
",",
"$",
"period",
")",
"{",
"$",
"currentLevel",
"=",
"&",
"$",
"index",
";",
"foreach",
"(",
"$",
"metadataNamesToIndexBy",
"as",
"$",
"metadataName",
")",
"{",
"if",
"(",
"$",
"metadataName",
"==",
"DataTableFactory",
"::",
"TABLE_METADATA_SITE_INDEX",
")",
"{",
"$",
"key",
"=",
"$",
"idSite",
";",
"}",
"elseif",
"(",
"$",
"metadataName",
"==",
"DataTableFactory",
"::",
"TABLE_METADATA_PERIOD_INDEX",
")",
"{",
"$",
"key",
"=",
"$",
"period",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"row",
"[",
"self",
"::",
"METADATA_CONTAINER_ROW_KEY",
"]",
"[",
"$",
"metadataName",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"currentLevel",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"currentLevel",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"currentLevel",
"=",
"&",
"$",
"currentLevel",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"currentLevel",
"=",
"$",
"row",
";",
"}"
] | Puts an archive data row in an index. | [
"Puts",
"an",
"archive",
"data",
"row",
"in",
"an",
"index",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L353-L374 |
209,571 | matomo-org/matomo | core/Notification/Manager.php | Manager.cancelAllNonPersistent | public static function cancelAllNonPersistent()
{
foreach (static::getAllNotifications() as $id => $notification) {
if (Notification::TYPE_PERSISTENT != $notification->type) {
static::removeNotification($id);
}
}
} | php | public static function cancelAllNonPersistent()
{
foreach (static::getAllNotifications() as $id => $notification) {
if (Notification::TYPE_PERSISTENT != $notification->type) {
static::removeNotification($id);
}
}
} | [
"public",
"static",
"function",
"cancelAllNonPersistent",
"(",
")",
"{",
"foreach",
"(",
"static",
"::",
"getAllNotifications",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"notification",
")",
"{",
"if",
"(",
"Notification",
"::",
"TYPE_PERSISTENT",
"!=",
"$",
"notification",
"->",
"type",
")",
"{",
"static",
"::",
"removeNotification",
"(",
"$",
"id",
")",
";",
"}",
"}",
"}"
] | Removes all temporary notifications.
Call this method after the notifications have been
displayed to make sure temporary notifications won't be displayed twice. | [
"Removes",
"all",
"temporary",
"notifications",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Notification/Manager.php#L67-L74 |
209,572 | matomo-org/matomo | core/Notification/Manager.php | Manager.getAllNotificationsToDisplay | public static function getAllNotificationsToDisplay()
{
$notifications = static::getAllNotifications();
uasort($notifications, function ($n1, $n2) {
/** @var Notification $n1 */ /** @var Notification $n2 */
if ($n1->getPriority() == $n2->getPriority()) {
return 0;
}
return $n1->getPriority() > $n2->getPriority() ? -1 : 1;
});
return $notifications;
} | php | public static function getAllNotificationsToDisplay()
{
$notifications = static::getAllNotifications();
uasort($notifications, function ($n1, $n2) {
/** @var Notification $n1 */ /** @var Notification $n2 */
if ($n1->getPriority() == $n2->getPriority()) {
return 0;
}
return $n1->getPriority() > $n2->getPriority() ? -1 : 1;
});
return $notifications;
} | [
"public",
"static",
"function",
"getAllNotificationsToDisplay",
"(",
")",
"{",
"$",
"notifications",
"=",
"static",
"::",
"getAllNotifications",
"(",
")",
";",
"uasort",
"(",
"$",
"notifications",
",",
"function",
"(",
"$",
"n1",
",",
"$",
"n2",
")",
"{",
"/** @var Notification $n1 */",
"/** @var Notification $n2 */",
"if",
"(",
"$",
"n1",
"->",
"getPriority",
"(",
")",
"==",
"$",
"n2",
"->",
"getPriority",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"n1",
"->",
"getPriority",
"(",
")",
">",
"$",
"n2",
"->",
"getPriority",
"(",
")",
"?",
"-",
"1",
":",
"1",
";",
"}",
")",
";",
"return",
"$",
"notifications",
";",
"}"
] | Determine all notifications that needs to be displayed. They are sorted by priority. Highest priorities first.
@return \ArrayObject | [
"Determine",
"all",
"notifications",
"that",
"needs",
"to",
"be",
"displayed",
".",
"They",
"are",
"sorted",
"by",
"priority",
".",
"Highest",
"priorities",
"first",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Notification/Manager.php#L80-L94 |
209,573 | matomo-org/matomo | libs/HTML/QuickForm2/Element/Date.php | HTML_QuickForm2_Element_Date.setValue | public function setValue($value)
{
if (empty($value)) {
$value = array();
} elseif (is_scalar($value)) {
if (!is_numeric($value)) {
$value = strtotime($value);
}
// might be a unix epoch, then we fill all possible values
$arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value));
$value = array(
'D' => $arr[0],
'l' => $arr[0],
'd' => $arr[1],
'M' => $arr[2],
'm' => $arr[2],
'F' => $arr[2],
'Y' => $arr[3],
'y' => $arr[3],
'h' => $arr[4],
'g' => $arr[4],
'H' => $arr[5],
'i' => $this->trimLeadingZeros($arr[6]),
's' => $this->trimLeadingZeros($arr[7]),
'a' => $arr[8],
'A' => $arr[9],
'W' => $this->trimLeadingZeros($arr[10])
);
} else {
$value = array_map(array($this, 'trimLeadingZeros'), $value);
}
return parent::setValue($value);
} | php | public function setValue($value)
{
if (empty($value)) {
$value = array();
} elseif (is_scalar($value)) {
if (!is_numeric($value)) {
$value = strtotime($value);
}
// might be a unix epoch, then we fill all possible values
$arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value));
$value = array(
'D' => $arr[0],
'l' => $arr[0],
'd' => $arr[1],
'M' => $arr[2],
'm' => $arr[2],
'F' => $arr[2],
'Y' => $arr[3],
'y' => $arr[3],
'h' => $arr[4],
'g' => $arr[4],
'H' => $arr[5],
'i' => $this->trimLeadingZeros($arr[6]),
's' => $this->trimLeadingZeros($arr[7]),
'a' => $arr[8],
'A' => $arr[9],
'W' => $this->trimLeadingZeros($arr[10])
);
} else {
$value = array_map(array($this, 'trimLeadingZeros'), $value);
}
return parent::setValue($value);
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array",
"(",
")",
";",
"}",
"elseif",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"strtotime",
"(",
"$",
"value",
")",
";",
"}",
"// might be a unix epoch, then we fill all possible values",
"$",
"arr",
"=",
"explode",
"(",
"'-'",
",",
"date",
"(",
"'w-j-n-Y-g-G-i-s-a-A-W'",
",",
"(",
"int",
")",
"$",
"value",
")",
")",
";",
"$",
"value",
"=",
"array",
"(",
"'D'",
"=>",
"$",
"arr",
"[",
"0",
"]",
",",
"'l'",
"=>",
"$",
"arr",
"[",
"0",
"]",
",",
"'d'",
"=>",
"$",
"arr",
"[",
"1",
"]",
",",
"'M'",
"=>",
"$",
"arr",
"[",
"2",
"]",
",",
"'m'",
"=>",
"$",
"arr",
"[",
"2",
"]",
",",
"'F'",
"=>",
"$",
"arr",
"[",
"2",
"]",
",",
"'Y'",
"=>",
"$",
"arr",
"[",
"3",
"]",
",",
"'y'",
"=>",
"$",
"arr",
"[",
"3",
"]",
",",
"'h'",
"=>",
"$",
"arr",
"[",
"4",
"]",
",",
"'g'",
"=>",
"$",
"arr",
"[",
"4",
"]",
",",
"'H'",
"=>",
"$",
"arr",
"[",
"5",
"]",
",",
"'i'",
"=>",
"$",
"this",
"->",
"trimLeadingZeros",
"(",
"$",
"arr",
"[",
"6",
"]",
")",
",",
"'s'",
"=>",
"$",
"this",
"->",
"trimLeadingZeros",
"(",
"$",
"arr",
"[",
"7",
"]",
")",
",",
"'a'",
"=>",
"$",
"arr",
"[",
"8",
"]",
",",
"'A'",
"=>",
"$",
"arr",
"[",
"9",
"]",
",",
"'W'",
"=>",
"$",
"this",
"->",
"trimLeadingZeros",
"(",
"$",
"arr",
"[",
"10",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'trimLeadingZeros'",
")",
",",
"$",
"value",
")",
";",
"}",
"return",
"parent",
"::",
"setValue",
"(",
"$",
"value",
")",
";",
"}"
] | Tries to convert the given value to a usable date before setting the
element value
@param int|string|array A timestamp, a string compatible with strtotime()
or an array that fits the element names | [
"Tries",
"to",
"convert",
"the",
"given",
"value",
"to",
"a",
"usable",
"date",
"before",
"setting",
"the",
"element",
"value"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Element/Date.php#L272-L304 |
209,574 | matomo-org/matomo | core/API/DocumentationGenerator.php | DocumentationGenerator.getApiDocumentationAsString | public function getApiDocumentationAsString($outputExampleUrls = true)
{
list($toc, $str) = $this->generateDocumentation($outputExampleUrls, $prefixUrls = '', $displayTitlesAsAngularDirective = true);
return "<div piwik-content-block content-title='Quick access to APIs' id='topApiRef' name='topApiRef'>
$toc</div>
$str";
} | php | public function getApiDocumentationAsString($outputExampleUrls = true)
{
list($toc, $str) = $this->generateDocumentation($outputExampleUrls, $prefixUrls = '', $displayTitlesAsAngularDirective = true);
return "<div piwik-content-block content-title='Quick access to APIs' id='topApiRef' name='topApiRef'>
$toc</div>
$str";
} | [
"public",
"function",
"getApiDocumentationAsString",
"(",
"$",
"outputExampleUrls",
"=",
"true",
")",
"{",
"list",
"(",
"$",
"toc",
",",
"$",
"str",
")",
"=",
"$",
"this",
"->",
"generateDocumentation",
"(",
"$",
"outputExampleUrls",
",",
"$",
"prefixUrls",
"=",
"''",
",",
"$",
"displayTitlesAsAngularDirective",
"=",
"true",
")",
";",
"return",
"\"<div piwik-content-block content-title='Quick access to APIs' id='topApiRef' name='topApiRef'>\n\t\t\t\t$toc</div>\n\t\t\t\t$str\"",
";",
"}"
] | Returns a HTML page containing help for all the successfully loaded APIs.
@param bool $outputExampleUrls
@return string | [
"Returns",
"a",
"HTML",
"page",
"containing",
"help",
"for",
"all",
"the",
"successfully",
"loaded",
"APIs",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/DocumentationGenerator.php#L51-L58 |
209,575 | matomo-org/matomo | core/API/DocumentationGenerator.php | DocumentationGenerator.getApiDocumentationAsStringForDeveloperReference | public function getApiDocumentationAsStringForDeveloperReference($outputExampleUrls = true, $prefixUrls = '')
{
list($toc, $str) = $this->generateDocumentation($outputExampleUrls, $prefixUrls, $displayTitlesAsAngularDirective = false);
return "<h2 id='topApiRef' name='topApiRef'>Quick access to APIs</h2>
$toc
$str";
} | php | public function getApiDocumentationAsStringForDeveloperReference($outputExampleUrls = true, $prefixUrls = '')
{
list($toc, $str) = $this->generateDocumentation($outputExampleUrls, $prefixUrls, $displayTitlesAsAngularDirective = false);
return "<h2 id='topApiRef' name='topApiRef'>Quick access to APIs</h2>
$toc
$str";
} | [
"public",
"function",
"getApiDocumentationAsStringForDeveloperReference",
"(",
"$",
"outputExampleUrls",
"=",
"true",
",",
"$",
"prefixUrls",
"=",
"''",
")",
"{",
"list",
"(",
"$",
"toc",
",",
"$",
"str",
")",
"=",
"$",
"this",
"->",
"generateDocumentation",
"(",
"$",
"outputExampleUrls",
",",
"$",
"prefixUrls",
",",
"$",
"displayTitlesAsAngularDirective",
"=",
"false",
")",
";",
"return",
"\"<h2 id='topApiRef' name='topApiRef'>Quick access to APIs</h2>\n\t\t\t\t$toc\n\t\t\t\t$str\"",
";",
"}"
] | Used on developer.piwik.org
@param bool|true $outputExampleUrls
@param string $prefixUrls
@return string | [
"Used",
"on",
"developer",
".",
"piwik",
".",
"org"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/DocumentationGenerator.php#L67-L74 |
209,576 | matomo-org/matomo | core/Tracker/TrackerConfig.php | TrackerConfig.setConfigValue | public static function setConfigValue($name, $value)
{
$section = self::getConfig();
$section[$name] = $value;
Config::getInstance()->Tracker = $section;
} | php | public static function setConfigValue($name, $value)
{
$section = self::getConfig();
$section[$name] = $value;
Config::getInstance()->Tracker = $section;
} | [
"public",
"static",
"function",
"setConfigValue",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"section",
"=",
"self",
"::",
"getConfig",
"(",
")",
";",
"$",
"section",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"Tracker",
"=",
"$",
"section",
";",
"}"
] | Update Tracker config
@param string $name Setting name
@param mixed $value Value | [
"Update",
"Tracker",
"config"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/TrackerConfig.php#L22-L27 |
209,577 | matomo-org/matomo | core/DataAccess/LogQueryBuilder/JoinGenerator.php | JoinGenerator.generate | public function generate()
{
/** @var LogTable[] $availableLogTables */
$availableLogTables = array();
$this->tables->sort();
foreach ($this->tables as $i => $table) {
if (is_array($table)) {
// join condition provided
$alias = isset($table['tableAlias']) ? $table['tableAlias'] : $table['table'];
if (isset($table['join'])) {
$this->joinString .= ' ' . $table['join'];
} else {
$this->joinString .= ' LEFT JOIN';
}
if (!isset($table['joinOn']) && $this->tables->getLogTable($table['table'])) {
$logTable = $this->tables->getLogTable($table['table']);
if (!empty($availableLogTables)) {
$table['joinOn'] = $this->findJoinCriteriasForTables($logTable, $availableLogTables);
}
if (!isset($table['tableAlias'])) {
// eg array('table' => 'log_link_visit_action', 'join' => 'RIGHT JOIN')
// we treat this like a regular string table which we can join automatically
$availableLogTables[$table['table']] = $logTable;
}
}
$this->joinString .= ' ' . Common::prefixTable($table['table']) . " AS " . $alias
. " ON " . $table['joinOn'];
continue;
}
$tableSql = Common::prefixTable($table) . " AS $table";
$logTable = $this->tables->getLogTable($table);
if ($i == 0) {
// first table
$this->joinString .= $tableSql;
} else {
$join = $this->findJoinCriteriasForTables($logTable, $availableLogTables);
if ($join === null) {
$availableLogTables[$table] = $logTable;
continue;
}
// the join sql the default way
$this->joinString .= " LEFT JOIN $tableSql ON " . $join;
}
$availableLogTables[$table] = $logTable;
}
} | php | public function generate()
{
/** @var LogTable[] $availableLogTables */
$availableLogTables = array();
$this->tables->sort();
foreach ($this->tables as $i => $table) {
if (is_array($table)) {
// join condition provided
$alias = isset($table['tableAlias']) ? $table['tableAlias'] : $table['table'];
if (isset($table['join'])) {
$this->joinString .= ' ' . $table['join'];
} else {
$this->joinString .= ' LEFT JOIN';
}
if (!isset($table['joinOn']) && $this->tables->getLogTable($table['table'])) {
$logTable = $this->tables->getLogTable($table['table']);
if (!empty($availableLogTables)) {
$table['joinOn'] = $this->findJoinCriteriasForTables($logTable, $availableLogTables);
}
if (!isset($table['tableAlias'])) {
// eg array('table' => 'log_link_visit_action', 'join' => 'RIGHT JOIN')
// we treat this like a regular string table which we can join automatically
$availableLogTables[$table['table']] = $logTable;
}
}
$this->joinString .= ' ' . Common::prefixTable($table['table']) . " AS " . $alias
. " ON " . $table['joinOn'];
continue;
}
$tableSql = Common::prefixTable($table) . " AS $table";
$logTable = $this->tables->getLogTable($table);
if ($i == 0) {
// first table
$this->joinString .= $tableSql;
} else {
$join = $this->findJoinCriteriasForTables($logTable, $availableLogTables);
if ($join === null) {
$availableLogTables[$table] = $logTable;
continue;
}
// the join sql the default way
$this->joinString .= " LEFT JOIN $tableSql ON " . $join;
}
$availableLogTables[$table] = $logTable;
}
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"/** @var LogTable[] $availableLogTables */",
"$",
"availableLogTables",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"tables",
"->",
"sort",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"tables",
"as",
"$",
"i",
"=>",
"$",
"table",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"table",
")",
")",
"{",
"// join condition provided",
"$",
"alias",
"=",
"isset",
"(",
"$",
"table",
"[",
"'tableAlias'",
"]",
")",
"?",
"$",
"table",
"[",
"'tableAlias'",
"]",
":",
"$",
"table",
"[",
"'table'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"'join'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"joinString",
".=",
"' '",
".",
"$",
"table",
"[",
"'join'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"joinString",
".=",
"' LEFT JOIN'",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"table",
"[",
"'joinOn'",
"]",
")",
"&&",
"$",
"this",
"->",
"tables",
"->",
"getLogTable",
"(",
"$",
"table",
"[",
"'table'",
"]",
")",
")",
"{",
"$",
"logTable",
"=",
"$",
"this",
"->",
"tables",
"->",
"getLogTable",
"(",
"$",
"table",
"[",
"'table'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"availableLogTables",
")",
")",
"{",
"$",
"table",
"[",
"'joinOn'",
"]",
"=",
"$",
"this",
"->",
"findJoinCriteriasForTables",
"(",
"$",
"logTable",
",",
"$",
"availableLogTables",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"table",
"[",
"'tableAlias'",
"]",
")",
")",
"{",
"// eg array('table' => 'log_link_visit_action', 'join' => 'RIGHT JOIN')",
"// we treat this like a regular string table which we can join automatically",
"$",
"availableLogTables",
"[",
"$",
"table",
"[",
"'table'",
"]",
"]",
"=",
"$",
"logTable",
";",
"}",
"}",
"$",
"this",
"->",
"joinString",
".=",
"' '",
".",
"Common",
"::",
"prefixTable",
"(",
"$",
"table",
"[",
"'table'",
"]",
")",
".",
"\" AS \"",
".",
"$",
"alias",
".",
"\" ON \"",
".",
"$",
"table",
"[",
"'joinOn'",
"]",
";",
"continue",
";",
"}",
"$",
"tableSql",
"=",
"Common",
"::",
"prefixTable",
"(",
"$",
"table",
")",
".",
"\" AS $table\"",
";",
"$",
"logTable",
"=",
"$",
"this",
"->",
"tables",
"->",
"getLogTable",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"i",
"==",
"0",
")",
"{",
"// first table",
"$",
"this",
"->",
"joinString",
".=",
"$",
"tableSql",
";",
"}",
"else",
"{",
"$",
"join",
"=",
"$",
"this",
"->",
"findJoinCriteriasForTables",
"(",
"$",
"logTable",
",",
"$",
"availableLogTables",
")",
";",
"if",
"(",
"$",
"join",
"===",
"null",
")",
"{",
"$",
"availableLogTables",
"[",
"$",
"table",
"]",
"=",
"$",
"logTable",
";",
"continue",
";",
"}",
"// the join sql the default way",
"$",
"this",
"->",
"joinString",
".=",
"\" LEFT JOIN $tableSql ON \"",
".",
"$",
"join",
";",
"}",
"$",
"availableLogTables",
"[",
"$",
"table",
"]",
"=",
"$",
"logTable",
";",
"}",
"}"
] | Generate the join sql based on the needed tables
@throws Exception if tables can't be joined
@return array | [
"Generate",
"the",
"join",
"sql",
"based",
"on",
"the",
"needed",
"tables"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/LogQueryBuilder/JoinGenerator.php#L141-L199 |
209,578 | matomo-org/matomo | core/RankingQuery.php | RankingQuery.addLabelColumn | public function addLabelColumn($labelColumn)
{
if (is_array($labelColumn)) {
foreach ($labelColumn as $label) {
$this->addLabelColumn($label);
}
return;
}
$this->labelColumns[$labelColumn] = true;
} | php | public function addLabelColumn($labelColumn)
{
if (is_array($labelColumn)) {
foreach ($labelColumn as $label) {
$this->addLabelColumn($label);
}
return;
}
$this->labelColumns[$labelColumn] = true;
} | [
"public",
"function",
"addLabelColumn",
"(",
"$",
"labelColumn",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"labelColumn",
")",
")",
"{",
"foreach",
"(",
"$",
"labelColumn",
"as",
"$",
"label",
")",
"{",
"$",
"this",
"->",
"addLabelColumn",
"(",
"$",
"label",
")",
";",
"}",
"return",
";",
"}",
"$",
"this",
"->",
"labelColumns",
"[",
"$",
"labelColumn",
"]",
"=",
"true",
";",
"}"
] | Add a label column.
Labels are the columns that are replaced with "Others" after the limit.
@param string|array $labelColumn | [
"Add",
"a",
"label",
"column",
".",
"Labels",
"are",
"the",
"columns",
"that",
"are",
"replaced",
"with",
"Others",
"after",
"the",
"limit",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/RankingQuery.php#L127-L136 |
209,579 | matomo-org/matomo | core/RankingQuery.php | RankingQuery.addColumn | public function addColumn($column, $aggregationFunction = false)
{
if (is_array($column)) {
foreach ($column as $c) {
$this->addColumn($c, $aggregationFunction);
}
return;
}
$this->additionalColumns[$column] = $aggregationFunction;
} | php | public function addColumn($column, $aggregationFunction = false)
{
if (is_array($column)) {
foreach ($column as $c) {
$this->addColumn($c, $aggregationFunction);
}
return;
}
$this->additionalColumns[$column] = $aggregationFunction;
} | [
"public",
"function",
"addColumn",
"(",
"$",
"column",
",",
"$",
"aggregationFunction",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"column",
")",
")",
"{",
"foreach",
"(",
"$",
"column",
"as",
"$",
"c",
")",
"{",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
",",
"$",
"aggregationFunction",
")",
";",
"}",
"return",
";",
"}",
"$",
"this",
"->",
"additionalColumns",
"[",
"$",
"column",
"]",
"=",
"$",
"aggregationFunction",
";",
"}"
] | Add a column that has be added to the outer queries.
@param $column
@param string|bool $aggregationFunction If set, this function is used to aggregate the values of "Others",
eg, `'min'`, `'max'` or `'sum'`. | [
"Add",
"a",
"column",
"that",
"has",
"be",
"added",
"to",
"the",
"outer",
"queries",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/RankingQuery.php#L153-L162 |
209,580 | matomo-org/matomo | core/RankingQuery.php | RankingQuery.execute | public function execute($innerQuery, $bind = array())
{
$query = $this->generateRankingQuery($innerQuery);
$data = Db::fetchAll($query, $bind);
if ($this->columnToMarkExcludedRows !== false) {
// split the result into the regular result and the rows with special treatment
$excludedFromLimit = array();
$result = array();
foreach ($data as &$row) {
if ($row[$this->columnToMarkExcludedRows] != 0) {
$excludedFromLimit[] = $row;
} else {
$result[] = $row;
}
}
$data = array(
'result' => &$result,
'excludedFromLimit' => &$excludedFromLimit
);
}
if ($this->partitionColumn !== false) {
if ($this->columnToMarkExcludedRows !== false) {
$data['result'] = $this->splitPartitions($data['result']);
} else {
$data = $this->splitPartitions($data);
}
}
return $data;
} | php | public function execute($innerQuery, $bind = array())
{
$query = $this->generateRankingQuery($innerQuery);
$data = Db::fetchAll($query, $bind);
if ($this->columnToMarkExcludedRows !== false) {
// split the result into the regular result and the rows with special treatment
$excludedFromLimit = array();
$result = array();
foreach ($data as &$row) {
if ($row[$this->columnToMarkExcludedRows] != 0) {
$excludedFromLimit[] = $row;
} else {
$result[] = $row;
}
}
$data = array(
'result' => &$result,
'excludedFromLimit' => &$excludedFromLimit
);
}
if ($this->partitionColumn !== false) {
if ($this->columnToMarkExcludedRows !== false) {
$data['result'] = $this->splitPartitions($data['result']);
} else {
$data = $this->splitPartitions($data);
}
}
return $data;
} | [
"public",
"function",
"execute",
"(",
"$",
"innerQuery",
",",
"$",
"bind",
"=",
"array",
"(",
")",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"generateRankingQuery",
"(",
"$",
"innerQuery",
")",
";",
"$",
"data",
"=",
"Db",
"::",
"fetchAll",
"(",
"$",
"query",
",",
"$",
"bind",
")",
";",
"if",
"(",
"$",
"this",
"->",
"columnToMarkExcludedRows",
"!==",
"false",
")",
"{",
"// split the result into the regular result and the rows with special treatment",
"$",
"excludedFromLimit",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"&",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"[",
"$",
"this",
"->",
"columnToMarkExcludedRows",
"]",
"!=",
"0",
")",
"{",
"$",
"excludedFromLimit",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"}",
"$",
"data",
"=",
"array",
"(",
"'result'",
"=>",
"&",
"$",
"result",
",",
"'excludedFromLimit'",
"=>",
"&",
"$",
"excludedFromLimit",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"partitionColumn",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"columnToMarkExcludedRows",
"!==",
"false",
")",
"{",
"$",
"data",
"[",
"'result'",
"]",
"=",
"$",
"this",
"->",
"splitPartitions",
"(",
"$",
"data",
"[",
"'result'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"splitPartitions",
"(",
"$",
"data",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] | Executes the query.
The object has to be configured first using the other methods.
@param $innerQuery string The "payload" query that does the actual data aggregation. The ordering
has to be specified in this query. {@link RankingQuery} cannot apply ordering
itself.
@param $bind array Bindings for the inner query.
@return array The format depends on which methods have been used
to configure the ranking query. | [
"Executes",
"the",
"query",
".",
"The",
"object",
"has",
"to",
"be",
"configured",
"first",
"using",
"the",
"other",
"methods",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/RankingQuery.php#L223-L254 |
209,581 | matomo-org/matomo | core/DataAccess/TableMetadata.php | TableMetadata.getColumns | public function getColumns($table)
{
$table = str_replace("`", "", $table);
$columns = Db::fetchAll("SHOW COLUMNS FROM `" . $table . "`");
$columnNames = array();
foreach ($columns as $column) {
$columnNames[] = $column['Field'];
}
return $columnNames;
} | php | public function getColumns($table)
{
$table = str_replace("`", "", $table);
$columns = Db::fetchAll("SHOW COLUMNS FROM `" . $table . "`");
$columnNames = array();
foreach ($columns as $column) {
$columnNames[] = $column['Field'];
}
return $columnNames;
} | [
"public",
"function",
"getColumns",
"(",
"$",
"table",
")",
"{",
"$",
"table",
"=",
"str_replace",
"(",
"\"`\"",
",",
"\"\"",
",",
"$",
"table",
")",
";",
"$",
"columns",
"=",
"Db",
"::",
"fetchAll",
"(",
"\"SHOW COLUMNS FROM `\"",
".",
"$",
"table",
".",
"\"`\"",
")",
";",
"$",
"columnNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"columnNames",
"[",
"]",
"=",
"$",
"column",
"[",
"'Field'",
"]",
";",
"}",
"return",
"$",
"columnNames",
";",
"}"
] | Returns the list of column names for a table.
@param string $table Prefixed table name.
@return string[] List of column names.. | [
"Returns",
"the",
"list",
"of",
"column",
"names",
"for",
"a",
"table",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/TableMetadata.php#L24-L36 |
209,582 | matomo-org/matomo | core/DataAccess/TableMetadata.php | TableMetadata.getIdActionColumnNames | public function getIdActionColumnNames($table)
{
$columns = $this->getColumns($table);
$columns = array_filter($columns, function ($columnName) {
return strpos($columnName, 'idaction') !== false;
});
return array_values($columns);
} | php | public function getIdActionColumnNames($table)
{
$columns = $this->getColumns($table);
$columns = array_filter($columns, function ($columnName) {
return strpos($columnName, 'idaction') !== false;
});
return array_values($columns);
} | [
"public",
"function",
"getIdActionColumnNames",
"(",
"$",
"table",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
"$",
"table",
")",
";",
"$",
"columns",
"=",
"array_filter",
"(",
"$",
"columns",
",",
"function",
"(",
"$",
"columnName",
")",
"{",
"return",
"strpos",
"(",
"$",
"columnName",
",",
"'idaction'",
")",
"!==",
"false",
";",
"}",
")",
";",
"return",
"array_values",
"(",
"$",
"columns",
")",
";",
"}"
] | Returns the list of idaction columns in a table. A column is
assumed to be an idaction reference if it has `"idaction"` in its
name (eg, `"idaction_url"` or `"idaction_content_name"`.
@param string $table Prefixed table name.
@return string[] | [
"Returns",
"the",
"list",
"of",
"idaction",
"columns",
"in",
"a",
"table",
".",
"A",
"column",
"is",
"assumed",
"to",
"be",
"an",
"idaction",
"reference",
"if",
"it",
"has",
"idaction",
"in",
"its",
"name",
"(",
"eg",
"idaction_url",
"or",
"idaction_content_name",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/TableMetadata.php#L46-L55 |
209,583 | matomo-org/matomo | core/Tracker/Model.php | Model.createNewIdAction | public function createNewIdAction($name, $type, $urlPrefix)
{
$newActionId = $this->insertNewAction($name, $type, $urlPrefix);
$realFirstActionId = $this->getIdActionMatchingNameAndType($name, $type);
// if the inserted action ID is not the same as the queried action ID, then that means we inserted
// a duplicate, so remove it now
if ($realFirstActionId != $newActionId) {
$this->deleteDuplicateAction($newActionId);
}
return $realFirstActionId;
} | php | public function createNewIdAction($name, $type, $urlPrefix)
{
$newActionId = $this->insertNewAction($name, $type, $urlPrefix);
$realFirstActionId = $this->getIdActionMatchingNameAndType($name, $type);
// if the inserted action ID is not the same as the queried action ID, then that means we inserted
// a duplicate, so remove it now
if ($realFirstActionId != $newActionId) {
$this->deleteDuplicateAction($newActionId);
}
return $realFirstActionId;
} | [
"public",
"function",
"createNewIdAction",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"urlPrefix",
")",
"{",
"$",
"newActionId",
"=",
"$",
"this",
"->",
"insertNewAction",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"urlPrefix",
")",
";",
"$",
"realFirstActionId",
"=",
"$",
"this",
"->",
"getIdActionMatchingNameAndType",
"(",
"$",
"name",
",",
"$",
"type",
")",
";",
"// if the inserted action ID is not the same as the queried action ID, then that means we inserted",
"// a duplicate, so remove it now",
"if",
"(",
"$",
"realFirstActionId",
"!=",
"$",
"newActionId",
")",
"{",
"$",
"this",
"->",
"deleteDuplicateAction",
"(",
"$",
"newActionId",
")",
";",
"}",
"return",
"$",
"realFirstActionId",
";",
"}"
] | Inserts a new action into the log_action table. If there is an existing action that was inserted
due to another request pre-empting this one, the newly inserted action is deleted.
@param string $name
@param int $type
@param int $urlPrefix
@return int The ID of the action (can be for an existing action or new action). | [
"Inserts",
"a",
"new",
"action",
"into",
"the",
"log_action",
"table",
".",
"If",
"there",
"is",
"an",
"existing",
"action",
"that",
"was",
"inserted",
"due",
"to",
"another",
"request",
"pre",
"-",
"empting",
"this",
"one",
"the",
"newly",
"inserted",
"action",
"is",
"deleted",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Model.php#L161-L174 |
209,584 | matomo-org/matomo | core/Tracker/Model.php | Model.getIdsAction | public function getIdsAction($actionsNameAndType)
{
$sql = "SELECT MIN(idaction) as idaction, type, name FROM " . Common::prefixTable('log_action')
. " WHERE";
$bind = array();
$i = 0;
foreach ($actionsNameAndType as $actionNameType) {
$name = $actionNameType['name'];
if (empty($name)) {
continue;
}
if ($i > 0) {
$sql .= " OR";
}
$sql .= " " . $this->getSqlConditionToMatchSingleAction() . " ";
$bind[] = $name;
$bind[] = $name;
$bind[] = $actionNameType['type'];
$i++;
}
$sql .= " GROUP BY type, hash, name";
// Case URL & Title are empty
if (empty($bind)) {
return false;
}
$actionIds = $this->getDb()->fetchAll($sql, $bind);
return $actionIds;
} | php | public function getIdsAction($actionsNameAndType)
{
$sql = "SELECT MIN(idaction) as idaction, type, name FROM " . Common::prefixTable('log_action')
. " WHERE";
$bind = array();
$i = 0;
foreach ($actionsNameAndType as $actionNameType) {
$name = $actionNameType['name'];
if (empty($name)) {
continue;
}
if ($i > 0) {
$sql .= " OR";
}
$sql .= " " . $this->getSqlConditionToMatchSingleAction() . " ";
$bind[] = $name;
$bind[] = $name;
$bind[] = $actionNameType['type'];
$i++;
}
$sql .= " GROUP BY type, hash, name";
// Case URL & Title are empty
if (empty($bind)) {
return false;
}
$actionIds = $this->getDb()->fetchAll($sql, $bind);
return $actionIds;
} | [
"public",
"function",
"getIdsAction",
"(",
"$",
"actionsNameAndType",
")",
"{",
"$",
"sql",
"=",
"\"SELECT MIN(idaction) as idaction, type, name FROM \"",
".",
"Common",
"::",
"prefixTable",
"(",
"'log_action'",
")",
".",
"\" WHERE\"",
";",
"$",
"bind",
"=",
"array",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"actionsNameAndType",
"as",
"$",
"actionNameType",
")",
"{",
"$",
"name",
"=",
"$",
"actionNameType",
"[",
"'name'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"i",
">",
"0",
")",
"{",
"$",
"sql",
".=",
"\" OR\"",
";",
"}",
"$",
"sql",
".=",
"\" \"",
".",
"$",
"this",
"->",
"getSqlConditionToMatchSingleAction",
"(",
")",
".",
"\" \"",
";",
"$",
"bind",
"[",
"]",
"=",
"$",
"name",
";",
"$",
"bind",
"[",
"]",
"=",
"$",
"name",
";",
"$",
"bind",
"[",
"]",
"=",
"$",
"actionNameType",
"[",
"'type'",
"]",
";",
"$",
"i",
"++",
";",
"}",
"$",
"sql",
".=",
"\" GROUP BY type, hash, name\"",
";",
"// Case URL & Title are empty",
"if",
"(",
"empty",
"(",
"$",
"bind",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"actionIds",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"fetchAll",
"(",
"$",
"sql",
",",
"$",
"bind",
")",
";",
"return",
"$",
"actionIds",
";",
"}"
] | Returns the IDs for multiple actions based on name + type values.
@param array $actionsNameAndType Array like `array( array('name' => '...', 'type' => 1), ... )`
@return array|false Array of DB rows w/ columns: **idaction**, **type**, **name**. | [
"Returns",
"the",
"IDs",
"for",
"multiple",
"actions",
"based",
"on",
"name",
"+",
"type",
"values",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Model.php#L216-L252 |
209,585 | matomo-org/matomo | core/Tracker/Model.php | Model.isSiteEmpty | public function isSiteEmpty($siteId)
{
$sql = sprintf('SELECT idsite FROM %s WHERE idsite = ? limit 1', Common::prefixTable('log_visit'));
$result = \Piwik\Db::fetchOne($sql, array($siteId));
return $result == null;
} | php | public function isSiteEmpty($siteId)
{
$sql = sprintf('SELECT idsite FROM %s WHERE idsite = ? limit 1', Common::prefixTable('log_visit'));
$result = \Piwik\Db::fetchOne($sql, array($siteId));
return $result == null;
} | [
"public",
"function",
"isSiteEmpty",
"(",
"$",
"siteId",
")",
"{",
"$",
"sql",
"=",
"sprintf",
"(",
"'SELECT idsite FROM %s WHERE idsite = ? limit 1'",
",",
"Common",
"::",
"prefixTable",
"(",
"'log_visit'",
")",
")",
";",
"$",
"result",
"=",
"\\",
"Piwik",
"\\",
"Db",
"::",
"fetchOne",
"(",
"$",
"sql",
",",
"array",
"(",
"$",
"siteId",
")",
")",
";",
"return",
"$",
"result",
"==",
"null",
";",
"}"
] | Returns true if the site doesn't have raw data.
@param int $siteId
@return bool | [
"Returns",
"true",
"if",
"the",
"site",
"doesn",
"t",
"have",
"raw",
"data",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Model.php#L421-L428 |
209,586 | matomo-org/matomo | plugins/Installation/Controller.php | Controller.saveLanguage | public function saveLanguage()
{
if (DbHelper::isInstalled()) {
$this->checkTokenInUrl();
}
$language = $this->getParam('language');
LanguagesManager::setLanguageForSession($language);
Url::redirectToReferrer();
} | php | public function saveLanguage()
{
if (DbHelper::isInstalled()) {
$this->checkTokenInUrl();
}
$language = $this->getParam('language');
LanguagesManager::setLanguageForSession($language);
Url::redirectToReferrer();
} | [
"public",
"function",
"saveLanguage",
"(",
")",
"{",
"if",
"(",
"DbHelper",
"::",
"isInstalled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"}",
"$",
"language",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'language'",
")",
";",
"LanguagesManager",
"::",
"setLanguageForSession",
"(",
"$",
"language",
")",
";",
"Url",
"::",
"redirectToReferrer",
"(",
")",
";",
"}"
] | Save language selection in session-store | [
"Save",
"language",
"selection",
"in",
"session",
"-",
"store"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/Controller.php#L477-L485 |
209,587 | matomo-org/matomo | plugins/Installation/Controller.php | Controller.createConfigFile | private function createConfigFile($dbInfos)
{
$config = Config::getInstance();
// make sure DB sessions are used if the filesystem is NFS
if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) {
$config->General['proxy_client_headers'] = $headers;
}
if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) {
$config->General['proxy_host_headers'] = $headers;
}
if (Common::getRequestVar('clientProtocol', 'http', 'string') == 'https') {
$protocol = 'https';
} else {
$protocol = ProxyHeaders::getProtocolInformation();
}
if (!empty($protocol)
&& !\Piwik\ProxyHttp::isHttps()) {
$config->General['assume_secure_protocol'] = '1';
}
$config->General['salt'] = Common::generateUniqId();
$config->General['installation_in_progress'] = 1;
$config->database = $dbInfos;
if (!DbHelper::isDatabaseConnectionUTF8()) {
$config->database['charset'] = 'utf8';
}
$config->forceSave();
// re-save the currently viewed language (since we saved the config file, there is now a salt which makes the
// existing session cookie invalid)
$this->resetLanguageCookie();
} | php | private function createConfigFile($dbInfos)
{
$config = Config::getInstance();
// make sure DB sessions are used if the filesystem is NFS
if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) {
$config->General['proxy_client_headers'] = $headers;
}
if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) {
$config->General['proxy_host_headers'] = $headers;
}
if (Common::getRequestVar('clientProtocol', 'http', 'string') == 'https') {
$protocol = 'https';
} else {
$protocol = ProxyHeaders::getProtocolInformation();
}
if (!empty($protocol)
&& !\Piwik\ProxyHttp::isHttps()) {
$config->General['assume_secure_protocol'] = '1';
}
$config->General['salt'] = Common::generateUniqId();
$config->General['installation_in_progress'] = 1;
$config->database = $dbInfos;
if (!DbHelper::isDatabaseConnectionUTF8()) {
$config->database['charset'] = 'utf8';
}
$config->forceSave();
// re-save the currently viewed language (since we saved the config file, there is now a salt which makes the
// existing session cookie invalid)
$this->resetLanguageCookie();
} | [
"private",
"function",
"createConfigFile",
"(",
"$",
"dbInfos",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"getInstance",
"(",
")",
";",
"// make sure DB sessions are used if the filesystem is NFS",
"if",
"(",
"count",
"(",
"$",
"headers",
"=",
"ProxyHeaders",
"::",
"getProxyClientHeaders",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"config",
"->",
"General",
"[",
"'proxy_client_headers'",
"]",
"=",
"$",
"headers",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"headers",
"=",
"ProxyHeaders",
"::",
"getProxyHostHeaders",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"config",
"->",
"General",
"[",
"'proxy_host_headers'",
"]",
"=",
"$",
"headers",
";",
"}",
"if",
"(",
"Common",
"::",
"getRequestVar",
"(",
"'clientProtocol'",
",",
"'http'",
",",
"'string'",
")",
"==",
"'https'",
")",
"{",
"$",
"protocol",
"=",
"'https'",
";",
"}",
"else",
"{",
"$",
"protocol",
"=",
"ProxyHeaders",
"::",
"getProtocolInformation",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"protocol",
")",
"&&",
"!",
"\\",
"Piwik",
"\\",
"ProxyHttp",
"::",
"isHttps",
"(",
")",
")",
"{",
"$",
"config",
"->",
"General",
"[",
"'assume_secure_protocol'",
"]",
"=",
"'1'",
";",
"}",
"$",
"config",
"->",
"General",
"[",
"'salt'",
"]",
"=",
"Common",
"::",
"generateUniqId",
"(",
")",
";",
"$",
"config",
"->",
"General",
"[",
"'installation_in_progress'",
"]",
"=",
"1",
";",
"$",
"config",
"->",
"database",
"=",
"$",
"dbInfos",
";",
"if",
"(",
"!",
"DbHelper",
"::",
"isDatabaseConnectionUTF8",
"(",
")",
")",
"{",
"$",
"config",
"->",
"database",
"[",
"'charset'",
"]",
"=",
"'utf8'",
";",
"}",
"$",
"config",
"->",
"forceSave",
"(",
")",
";",
"// re-save the currently viewed language (since we saved the config file, there is now a salt which makes the",
"// existing session cookie invalid)",
"$",
"this",
"->",
"resetLanguageCookie",
"(",
")",
";",
"}"
] | Write configuration file from session-store | [
"Write",
"configuration",
"file",
"from",
"session",
"-",
"store"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/Controller.php#L550-L586 |
209,588 | matomo-org/matomo | plugins/Installation/Controller.php | Controller.redirectToNextStep | private function redirectToNextStep($currentStep, $parameters = array())
{
$steps = array_keys($this->steps);
$nextStep = $steps[1 + array_search($currentStep, $steps)];
Piwik::redirectToModule('Installation', $nextStep, $parameters);
} | php | private function redirectToNextStep($currentStep, $parameters = array())
{
$steps = array_keys($this->steps);
$nextStep = $steps[1 + array_search($currentStep, $steps)];
Piwik::redirectToModule('Installation', $nextStep, $parameters);
} | [
"private",
"function",
"redirectToNextStep",
"(",
"$",
"currentStep",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"steps",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"steps",
")",
";",
"$",
"nextStep",
"=",
"$",
"steps",
"[",
"1",
"+",
"array_search",
"(",
"$",
"currentStep",
",",
"$",
"steps",
")",
"]",
";",
"Piwik",
"::",
"redirectToModule",
"(",
"'Installation'",
",",
"$",
"nextStep",
",",
"$",
"parameters",
")",
";",
"}"
] | Redirect to next step
@param string $currentStep Current step
@return void | [
"Redirect",
"to",
"next",
"step"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/Controller.php#L629-L634 |
209,589 | matomo-org/matomo | plugins/Installation/Controller.php | Controller.extractHost | private function extractHost($url)
{
$urlParts = parse_url($url);
if (isset($urlParts['host']) && strlen($host = $urlParts['host'])) {
return $host;
}
return false;
} | php | private function extractHost($url)
{
$urlParts = parse_url($url);
if (isset($urlParts['host']) && strlen($host = $urlParts['host'])) {
return $host;
}
return false;
} | [
"private",
"function",
"extractHost",
"(",
"$",
"url",
")",
"{",
"$",
"urlParts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"urlParts",
"[",
"'host'",
"]",
")",
"&&",
"strlen",
"(",
"$",
"host",
"=",
"$",
"urlParts",
"[",
"'host'",
"]",
")",
")",
"{",
"return",
"$",
"host",
";",
"}",
"return",
"false",
";",
"}"
] | Extract host from URL
@param string $url URL
@return string|false | [
"Extract",
"host",
"from",
"URL"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/Controller.php#L643-L651 |
209,590 | matomo-org/matomo | plugins/Installation/Controller.php | Controller.addTrustedHosts | private function addTrustedHosts($siteUrl)
{
$trustedHosts = array();
// extract host from the request header
if (($host = $this->extractHost('http://' . Url::getHost())) !== false) {
$trustedHosts[] = $host;
}
// extract host from first web site
if (($host = $this->extractHost(urldecode($siteUrl))) !== false) {
$trustedHosts[] = $host;
}
$trustedHosts = array_unique($trustedHosts);
if (count($trustedHosts)) {
$general = Config::getInstance()->General;
$general['trusted_hosts'] = $trustedHosts;
Config::getInstance()->General = $general;
Config::getInstance()->forceSave();
}
} | php | private function addTrustedHosts($siteUrl)
{
$trustedHosts = array();
// extract host from the request header
if (($host = $this->extractHost('http://' . Url::getHost())) !== false) {
$trustedHosts[] = $host;
}
// extract host from first web site
if (($host = $this->extractHost(urldecode($siteUrl))) !== false) {
$trustedHosts[] = $host;
}
$trustedHosts = array_unique($trustedHosts);
if (count($trustedHosts)) {
$general = Config::getInstance()->General;
$general['trusted_hosts'] = $trustedHosts;
Config::getInstance()->General = $general;
Config::getInstance()->forceSave();
}
} | [
"private",
"function",
"addTrustedHosts",
"(",
"$",
"siteUrl",
")",
"{",
"$",
"trustedHosts",
"=",
"array",
"(",
")",
";",
"// extract host from the request header",
"if",
"(",
"(",
"$",
"host",
"=",
"$",
"this",
"->",
"extractHost",
"(",
"'http://'",
".",
"Url",
"::",
"getHost",
"(",
")",
")",
")",
"!==",
"false",
")",
"{",
"$",
"trustedHosts",
"[",
"]",
"=",
"$",
"host",
";",
"}",
"// extract host from first web site",
"if",
"(",
"(",
"$",
"host",
"=",
"$",
"this",
"->",
"extractHost",
"(",
"urldecode",
"(",
"$",
"siteUrl",
")",
")",
")",
"!==",
"false",
")",
"{",
"$",
"trustedHosts",
"[",
"]",
"=",
"$",
"host",
";",
"}",
"$",
"trustedHosts",
"=",
"array_unique",
"(",
"$",
"trustedHosts",
")",
";",
"if",
"(",
"count",
"(",
"$",
"trustedHosts",
")",
")",
"{",
"$",
"general",
"=",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"General",
";",
"$",
"general",
"[",
"'trusted_hosts'",
"]",
"=",
"$",
"trustedHosts",
";",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"General",
"=",
"$",
"general",
";",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"forceSave",
"(",
")",
";",
"}",
"}"
] | Add trusted hosts | [
"Add",
"trusted",
"hosts"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/Controller.php#L656-L679 |
209,591 | matomo-org/matomo | plugins/Installation/Controller.php | Controller.hasEnoughTablesToReuseDb | public function hasEnoughTablesToReuseDb($tablesInstalled)
{
if (empty($tablesInstalled) || !is_array($tablesInstalled)) {
return false;
}
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$baseTablesInstalled = count($tablesInstalled) - count($archiveTables);
$minimumCountPiwikTables = 12;
return $baseTablesInstalled >= $minimumCountPiwikTables;
} | php | public function hasEnoughTablesToReuseDb($tablesInstalled)
{
if (empty($tablesInstalled) || !is_array($tablesInstalled)) {
return false;
}
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$baseTablesInstalled = count($tablesInstalled) - count($archiveTables);
$minimumCountPiwikTables = 12;
return $baseTablesInstalled >= $minimumCountPiwikTables;
} | [
"public",
"function",
"hasEnoughTablesToReuseDb",
"(",
"$",
"tablesInstalled",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"tablesInstalled",
")",
"||",
"!",
"is_array",
"(",
"$",
"tablesInstalled",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"archiveTables",
"=",
"ArchiveTableCreator",
"::",
"getTablesArchivesInstalled",
"(",
")",
";",
"$",
"baseTablesInstalled",
"=",
"count",
"(",
"$",
"tablesInstalled",
")",
"-",
"count",
"(",
"$",
"archiveTables",
")",
";",
"$",
"minimumCountPiwikTables",
"=",
"12",
";",
"return",
"$",
"baseTablesInstalled",
">=",
"$",
"minimumCountPiwikTables",
";",
"}"
] | should be private but there's a bug in php 5.3.6 | [
"should",
"be",
"private",
"but",
"there",
"s",
"a",
"bug",
"in",
"php",
"5",
".",
"3",
".",
"6"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/Controller.php#L692-L703 |
209,592 | matomo-org/matomo | core/Access/RolesProvider.php | RolesProvider.getAllRoleIds | public function getAllRoleIds()
{
$ids = array();
foreach ($this->getAllRoles() as $role) {
$ids[] = $role->getId();
}
return $ids;
} | php | public function getAllRoleIds()
{
$ids = array();
foreach ($this->getAllRoles() as $role) {
$ids[] = $role->getId();
}
return $ids;
} | [
"public",
"function",
"getAllRoleIds",
"(",
")",
"{",
"$",
"ids",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAllRoles",
"(",
")",
"as",
"$",
"role",
")",
"{",
"$",
"ids",
"[",
"]",
"=",
"$",
"role",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"$",
"ids",
";",
"}"
] | Returns the list of the existing Access level.
Useful when a given API method requests a given acccess Level.
We first check that the required access level exists.
@return array | [
"Returns",
"the",
"list",
"of",
"the",
"existing",
"Access",
"level",
".",
"Useful",
"when",
"a",
"given",
"API",
"method",
"requests",
"a",
"given",
"acccess",
"Level",
".",
"We",
"first",
"check",
"that",
"the",
"required",
"access",
"level",
"exists",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Access/RolesProvider.php#L38-L45 |
209,593 | matomo-org/matomo | plugins/CoreAdminHome/Commands/SetConfig/ConfigSettingManipulation.php | ConfigSettingManipulation.manipulate | public function manipulate(Config $config)
{
if ($this->isArrayAppend) {
$this->appendToArraySetting($config);
} else {
$this->setSingleConfigValue($config);
}
} | php | public function manipulate(Config $config)
{
if ($this->isArrayAppend) {
$this->appendToArraySetting($config);
} else {
$this->setSingleConfigValue($config);
}
} | [
"public",
"function",
"manipulate",
"(",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isArrayAppend",
")",
"{",
"$",
"this",
"->",
"appendToArraySetting",
"(",
"$",
"config",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setSingleConfigValue",
"(",
"$",
"config",
")",
";",
"}",
"}"
] | Performs the INI config manipulation.
@param Config $config
@throws \Exception if trying to append to a non-array setting value or if trying to set an
array value to a non-array setting | [
"Performs",
"the",
"INI",
"config",
"manipulation",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreAdminHome/Commands/SetConfig/ConfigSettingManipulation.php#L60-L67 |
209,594 | matomo-org/matomo | core/DataTable/Row.php | Row.export | public function export()
{
return array(
self::COLUMNS => $this->getArrayCopy(),
self::METADATA => $this->metadata,
self::DATATABLE_ASSOCIATED => $this->subtableId,
);
} | php | public function export()
{
return array(
self::COLUMNS => $this->getArrayCopy(),
self::METADATA => $this->metadata,
self::DATATABLE_ASSOCIATED => $this->subtableId,
);
} | [
"public",
"function",
"export",
"(",
")",
"{",
"return",
"array",
"(",
"self",
"::",
"COLUMNS",
"=>",
"$",
"this",
"->",
"getArrayCopy",
"(",
")",
",",
"self",
"::",
"METADATA",
"=>",
"$",
"this",
"->",
"metadata",
",",
"self",
"::",
"DATATABLE_ASSOCIATED",
"=>",
"$",
"this",
"->",
"subtableId",
",",
")",
";",
"}"
] | Used when archiving to serialize the Row's properties.
@return array
@ignore | [
"Used",
"when",
"archiving",
"to",
"serialize",
"the",
"Row",
"s",
"properties",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L88-L95 |
209,595 | matomo-org/matomo | core/DataTable/Row.php | Row.getMetadata | public function getMetadata($name = null)
{
if (is_null($name)) {
return $this->metadata;
}
if (!isset($this->metadata[$name])) {
return false;
}
return $this->metadata[$name];
} | php | public function getMetadata($name = null)
{
if (is_null($name)) {
return $this->metadata;
}
if (!isset($this->metadata[$name])) {
return false;
}
return $this->metadata[$name];
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"metadata",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"metadata",
"[",
"$",
"name",
"]",
";",
"}"
] | Returns the array of all metadata, or one requested metadata value.
@param string|null $name The name of the metadata to return or null to return all metadata.
@return mixed | [
"Returns",
"the",
"array",
"of",
"all",
"metadata",
"or",
"one",
"requested",
"metadata",
"value",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L197-L206 |
209,596 | matomo-org/matomo | core/DataTable/Row.php | Row.getSubtable | public function getSubtable()
{
if ($this->isSubtableLoaded) {
try {
return Manager::getInstance()->getTable($this->subtableId);
} catch (TableNotFoundException $e) {
// edge case
}
}
return false;
} | php | public function getSubtable()
{
if ($this->isSubtableLoaded) {
try {
return Manager::getInstance()->getTable($this->subtableId);
} catch (TableNotFoundException $e) {
// edge case
}
}
return false;
} | [
"public",
"function",
"getSubtable",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSubtableLoaded",
")",
"{",
"try",
"{",
"return",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"getTable",
"(",
"$",
"this",
"->",
"subtableId",
")",
";",
"}",
"catch",
"(",
"TableNotFoundException",
"$",
"e",
")",
"{",
"// edge case",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns the associated subtable, if one exists. Returns `false` if none exists.
@return DataTable|bool | [
"Returns",
"the",
"associated",
"subtable",
"if",
"one",
"exists",
".",
"Returns",
"false",
"if",
"none",
"exists",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L252-L262 |
209,597 | matomo-org/matomo | core/DataTable/Row.php | Row.sumSubtable | public function sumSubtable(DataTable $subTable)
{
if ($this->isSubtableLoaded) {
$thisSubTable = $this->getSubtable();
} else {
$this->warnIfSubtableAlreadyExists();
$thisSubTable = new DataTable();
$this->setSubtable($thisSubTable);
}
$columnOps = $subTable->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$thisSubTable->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnOps);
$thisSubTable->addDataTable($subTable);
} | php | public function sumSubtable(DataTable $subTable)
{
if ($this->isSubtableLoaded) {
$thisSubTable = $this->getSubtable();
} else {
$this->warnIfSubtableAlreadyExists();
$thisSubTable = new DataTable();
$this->setSubtable($thisSubTable);
}
$columnOps = $subTable->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$thisSubTable->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnOps);
$thisSubTable->addDataTable($subTable);
} | [
"public",
"function",
"sumSubtable",
"(",
"DataTable",
"$",
"subTable",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSubtableLoaded",
")",
"{",
"$",
"thisSubTable",
"=",
"$",
"this",
"->",
"getSubtable",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warnIfSubtableAlreadyExists",
"(",
")",
";",
"$",
"thisSubTable",
"=",
"new",
"DataTable",
"(",
")",
";",
"$",
"this",
"->",
"setSubtable",
"(",
"$",
"thisSubTable",
")",
";",
"}",
"$",
"columnOps",
"=",
"$",
"subTable",
"->",
"getMetadata",
"(",
"DataTable",
"::",
"COLUMN_AGGREGATION_OPS_METADATA_NAME",
")",
";",
"$",
"thisSubTable",
"->",
"setMetadata",
"(",
"DataTable",
"::",
"COLUMN_AGGREGATION_OPS_METADATA_NAME",
",",
"$",
"columnOps",
")",
";",
"$",
"thisSubTable",
"->",
"addDataTable",
"(",
"$",
"subTable",
")",
";",
"}"
] | Sums a DataTable to this row's subtable. If this row has no subtable a new
one is created.
See {@link Piwik\DataTable::addDataTable()} to learn how DataTables are summed.
@param DataTable $subTable Table to sum to this row's subtable. | [
"Sums",
"a",
"DataTable",
"to",
"this",
"row",
"s",
"subtable",
".",
"If",
"this",
"row",
"has",
"no",
"subtable",
"a",
"new",
"one",
"is",
"created",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L282-L295 |
209,598 | matomo-org/matomo | core/DataTable/Row.php | Row.setSubtable | public function setSubtable(DataTable $subTable)
{
$this->subtableId = $subTable->getId();
$this->isSubtableLoaded = true;
return $subTable;
} | php | public function setSubtable(DataTable $subTable)
{
$this->subtableId = $subTable->getId();
$this->isSubtableLoaded = true;
return $subTable;
} | [
"public",
"function",
"setSubtable",
"(",
"DataTable",
"$",
"subTable",
")",
"{",
"$",
"this",
"->",
"subtableId",
"=",
"$",
"subTable",
"->",
"getId",
"(",
")",
";",
"$",
"this",
"->",
"isSubtableLoaded",
"=",
"true",
";",
"return",
"$",
"subTable",
";",
"}"
] | Attaches a subtable to this row, overwriting the existing subtable,
if any.
@param DataTable $subTable DataTable to associate to this row.
@return DataTable Returns `$subTable`. | [
"Attaches",
"a",
"subtable",
"to",
"this",
"row",
"overwriting",
"the",
"existing",
"subtable",
"if",
"any",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L304-L310 |
209,599 | matomo-org/matomo | core/DataTable/Row.php | Row.deleteMetadata | public function deleteMetadata($name = false)
{
if ($name === false) {
$this->metadata = array();
return true;
}
if (!isset($this->metadata[$name])) {
return false;
}
unset($this->metadata[$name]);
return true;
} | php | public function deleteMetadata($name = false)
{
if ($name === false) {
$this->metadata = array();
return true;
}
if (!isset($this->metadata[$name])) {
return false;
}
unset($this->metadata[$name]);
return true;
} | [
"public",
"function",
"deleteMetadata",
"(",
"$",
"name",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"metadata",
"=",
"array",
"(",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"$",
"name",
"]",
")",
";",
"return",
"true",
";",
"}"
] | Deletes one metadata value or all metadata values.
@param bool|string $name Metadata name (omit to delete entire metadata).
@return bool `true` on success, `false` if the column didn't exist | [
"Deletes",
"one",
"metadata",
"value",
"or",
"all",
"metadata",
"values",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L371-L382 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.