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,600 | matomo-org/matomo | core/DataTable/Row.php | Row.addColumn | public function addColumn($name, $value)
{
if (isset($this[$name])) {
throw new Exception("Column $name already in the array!");
}
$this->setColumn($name, $value);
} | php | public function addColumn($name, $value)
{
if (isset($this[$name])) {
throw new Exception("Column $name already in the array!");
}
$this->setColumn($name, $value);
} | [
"public",
"function",
"addColumn",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Column $name already in the array!\"",
")",
";",
"}",
"$",
"this",
"->",
"setColumn",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] | Add a new column to the row. If the column already exists, throws an exception.
@param string $name name of the column to add.
@param mixed $value value of the column to set or a PHP callable.
@throws Exception if the column already exists. | [
"Add",
"a",
"new",
"column",
"to",
"the",
"row",
".",
"If",
"the",
"column",
"already",
"exists",
"throws",
"an",
"exception",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L391-L397 |
209,601 | matomo-org/matomo | core/DataTable/Row.php | Row.addColumns | public function addColumns($columns)
{
foreach ($columns as $name => $value) {
try {
$this->addColumn($name, $value);
} catch (Exception $e) {
}
}
if (!empty($e)) {
throw $e;
}
} | php | public function addColumns($columns)
{
foreach ($columns as $name => $value) {
try {
$this->addColumn($name, $value);
} catch (Exception $e) {
}
}
if (!empty($e)) {
throw $e;
}
} | [
"public",
"function",
"addColumns",
"(",
"$",
"columns",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"e",
")",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] | Add many columns to this row.
@param array $columns Name/Value pairs, e.g., `array('name' => $value , ...)`
@throws Exception if any column name does not exist.
@return void | [
"Add",
"many",
"columns",
"to",
"this",
"row",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L406-L418 |
209,602 | matomo-org/matomo | core/DataTable/Row.php | Row.addMetadata | public function addMetadata($name, $value)
{
if (isset($this->metadata[$name])) {
throw new Exception("Metadata $name already in the array!");
}
$this->setMetadata($name, $value);
} | php | public function addMetadata($name, $value)
{
if (isset($this->metadata[$name])) {
throw new Exception("Metadata $name already in the array!");
}
$this->setMetadata($name, $value);
} | [
"public",
"function",
"addMetadata",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Metadata $name already in the array!\"",
")",
";",
"}",
"$",
"this",
"->",
"setMetadata",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] | Add a new metadata to the row. If the metadata already exists, throws an exception.
@param string $name name of the metadata to add.
@param mixed $value value of the metadata to set.
@throws Exception if the metadata already exists. | [
"Add",
"a",
"new",
"metadata",
"to",
"the",
"row",
".",
"If",
"the",
"metadata",
"already",
"exists",
"throws",
"an",
"exception",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L427-L433 |
209,603 | matomo-org/matomo | core/DataTable/Row.php | Row.isEqual | public static function isEqual(Row $row1, Row $row2)
{
//same columns
$cols1 = $row1->getColumns();
$cols2 = $row2->getColumns();
$diff1 = array_udiff($cols1, $cols2, array(__CLASS__, 'compareElements'));
$diff2 = array_udiff($cols2, $cols1, array(__CLASS__, 'compareElements'));
if ($diff1 != $diff2) {
return false;
}
$dets1 = $row1->getMetadata();
$dets2 = $row2->getMetadata();
ksort($dets1);
ksort($dets2);
if ($dets1 != $dets2) {
return false;
}
// either both are null
// or both have a value
if (!(is_null($row1->getIdSubDataTable())
&& is_null($row2->getIdSubDataTable())
)
) {
$subtable1 = $row1->getSubtable();
$subtable2 = $row2->getSubtable();
if (!DataTable::isEqual($subtable1, $subtable2)) {
return false;
}
}
return true;
} | php | public static function isEqual(Row $row1, Row $row2)
{
//same columns
$cols1 = $row1->getColumns();
$cols2 = $row2->getColumns();
$diff1 = array_udiff($cols1, $cols2, array(__CLASS__, 'compareElements'));
$diff2 = array_udiff($cols2, $cols1, array(__CLASS__, 'compareElements'));
if ($diff1 != $diff2) {
return false;
}
$dets1 = $row1->getMetadata();
$dets2 = $row2->getMetadata();
ksort($dets1);
ksort($dets2);
if ($dets1 != $dets2) {
return false;
}
// either both are null
// or both have a value
if (!(is_null($row1->getIdSubDataTable())
&& is_null($row2->getIdSubDataTable())
)
) {
$subtable1 = $row1->getSubtable();
$subtable2 = $row2->getSubtable();
if (!DataTable::isEqual($subtable1, $subtable2)) {
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"isEqual",
"(",
"Row",
"$",
"row1",
",",
"Row",
"$",
"row2",
")",
"{",
"//same columns",
"$",
"cols1",
"=",
"$",
"row1",
"->",
"getColumns",
"(",
")",
";",
"$",
"cols2",
"=",
"$",
"row2",
"->",
"getColumns",
"(",
")",
";",
"$",
"diff1",
"=",
"array_udiff",
"(",
"$",
"cols1",
",",
"$",
"cols2",
",",
"array",
"(",
"__CLASS__",
",",
"'compareElements'",
")",
")",
";",
"$",
"diff2",
"=",
"array_udiff",
"(",
"$",
"cols2",
",",
"$",
"cols1",
",",
"array",
"(",
"__CLASS__",
",",
"'compareElements'",
")",
")",
";",
"if",
"(",
"$",
"diff1",
"!=",
"$",
"diff2",
")",
"{",
"return",
"false",
";",
"}",
"$",
"dets1",
"=",
"$",
"row1",
"->",
"getMetadata",
"(",
")",
";",
"$",
"dets2",
"=",
"$",
"row2",
"->",
"getMetadata",
"(",
")",
";",
"ksort",
"(",
"$",
"dets1",
")",
";",
"ksort",
"(",
"$",
"dets2",
")",
";",
"if",
"(",
"$",
"dets1",
"!=",
"$",
"dets2",
")",
"{",
"return",
"false",
";",
"}",
"// either both are null",
"// or both have a value",
"if",
"(",
"!",
"(",
"is_null",
"(",
"$",
"row1",
"->",
"getIdSubDataTable",
"(",
")",
")",
"&&",
"is_null",
"(",
"$",
"row2",
"->",
"getIdSubDataTable",
"(",
")",
")",
")",
")",
"{",
"$",
"subtable1",
"=",
"$",
"row1",
"->",
"getSubtable",
"(",
")",
";",
"$",
"subtable2",
"=",
"$",
"row2",
"->",
"getSubtable",
"(",
")",
";",
"if",
"(",
"!",
"DataTable",
"::",
"isEqual",
"(",
"$",
"subtable1",
",",
"$",
"subtable2",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Helper function that tests if two rows are equal.
Two rows are equal if:
- they have exactly the same columns / metadata
- they have a subDataTable associated, then we check that both of them are the same.
Column order is not important.
@param \Piwik\DataTable\Row $row1 first to compare
@param \Piwik\DataTable\Row $row2 second to compare
@return bool | [
"Helper",
"function",
"that",
"tests",
"if",
"two",
"rows",
"are",
"equal",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L682-L718 |
209,604 | matomo-org/matomo | core/View/RenderTokenParser.php | RenderTokenParser.parse | public function parse(Twig_Token $token)
{
$parser = $this->parser;
$stream = $parser->getStream();
$view = $parser->getExpressionParser()->parseExpression();
$variablesOverride = new Twig_Node_Expression_Array(array(), $token->getLine());
if ($stream->test(Twig_Token::NAME_TYPE, 'with')) {
$stream->next();
$variablesOverride->addElement($this->parser->getExpressionParser()->parseExpression());
}
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$viewTemplateExpr = new Twig_Node_Expression_MethodCall(
$view,
'getTemplateFile',
new Twig_Node_Expression_Array(array(), $token->getLine()),
$token->getLine()
);
$variablesExpr = new Twig_Node_Expression_MethodCall(
$view,
'getTemplateVars',
$variablesOverride,
$token->getLine()
);
return new Twig_Node_Include(
$viewTemplateExpr,
$variablesExpr,
$only = false,
$ignoreMissing = false,
$token->getLine()
);
} | php | public function parse(Twig_Token $token)
{
$parser = $this->parser;
$stream = $parser->getStream();
$view = $parser->getExpressionParser()->parseExpression();
$variablesOverride = new Twig_Node_Expression_Array(array(), $token->getLine());
if ($stream->test(Twig_Token::NAME_TYPE, 'with')) {
$stream->next();
$variablesOverride->addElement($this->parser->getExpressionParser()->parseExpression());
}
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$viewTemplateExpr = new Twig_Node_Expression_MethodCall(
$view,
'getTemplateFile',
new Twig_Node_Expression_Array(array(), $token->getLine()),
$token->getLine()
);
$variablesExpr = new Twig_Node_Expression_MethodCall(
$view,
'getTemplateVars',
$variablesOverride,
$token->getLine()
);
return new Twig_Node_Include(
$viewTemplateExpr,
$variablesExpr,
$only = false,
$ignoreMissing = false,
$token->getLine()
);
} | [
"public",
"function",
"parse",
"(",
"Twig_Token",
"$",
"token",
")",
"{",
"$",
"parser",
"=",
"$",
"this",
"->",
"parser",
";",
"$",
"stream",
"=",
"$",
"parser",
"->",
"getStream",
"(",
")",
";",
"$",
"view",
"=",
"$",
"parser",
"->",
"getExpressionParser",
"(",
")",
"->",
"parseExpression",
"(",
")",
";",
"$",
"variablesOverride",
"=",
"new",
"Twig_Node_Expression_Array",
"(",
"array",
"(",
")",
",",
"$",
"token",
"->",
"getLine",
"(",
")",
")",
";",
"if",
"(",
"$",
"stream",
"->",
"test",
"(",
"Twig_Token",
"::",
"NAME_TYPE",
",",
"'with'",
")",
")",
"{",
"$",
"stream",
"->",
"next",
"(",
")",
";",
"$",
"variablesOverride",
"->",
"addElement",
"(",
"$",
"this",
"->",
"parser",
"->",
"getExpressionParser",
"(",
")",
"->",
"parseExpression",
"(",
")",
")",
";",
"}",
"$",
"stream",
"->",
"expect",
"(",
"Twig_Token",
"::",
"BLOCK_END_TYPE",
")",
";",
"$",
"viewTemplateExpr",
"=",
"new",
"Twig_Node_Expression_MethodCall",
"(",
"$",
"view",
",",
"'getTemplateFile'",
",",
"new",
"Twig_Node_Expression_Array",
"(",
"array",
"(",
")",
",",
"$",
"token",
"->",
"getLine",
"(",
")",
")",
",",
"$",
"token",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"variablesExpr",
"=",
"new",
"Twig_Node_Expression_MethodCall",
"(",
"$",
"view",
",",
"'getTemplateVars'",
",",
"$",
"variablesOverride",
",",
"$",
"token",
"->",
"getLine",
"(",
")",
")",
";",
"return",
"new",
"Twig_Node_Include",
"(",
"$",
"viewTemplateExpr",
",",
"$",
"variablesExpr",
",",
"$",
"only",
"=",
"false",
",",
"$",
"ignoreMissing",
"=",
"false",
",",
"$",
"token",
"->",
"getLine",
"(",
")",
")",
";",
"}"
] | Parses the Twig stream and creates a Twig_Node_Include instance that includes
the View's template.
@return Twig_Node_Include | [
"Parses",
"the",
"Twig",
"stream",
"and",
"creates",
"a",
"Twig_Node_Include",
"instance",
"that",
"includes",
"the",
"View",
"s",
"template",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/View/RenderTokenParser.php#L34-L71 |
209,605 | matomo-org/matomo | core/CronArchive.php | CronArchive.main | public function main()
{
if ($this->isMaintenanceModeEnabled()) {
$this->logger->info("Archiving won't run because maintenance mode is enabled");
return;
}
$self = $this;
Access::doAsSuperUser(function () use ($self) {
$self->init();
$self->run();
$self->runScheduledTasks();
$self->end();
});
} | php | public function main()
{
if ($this->isMaintenanceModeEnabled()) {
$this->logger->info("Archiving won't run because maintenance mode is enabled");
return;
}
$self = $this;
Access::doAsSuperUser(function () use ($self) {
$self->init();
$self->run();
$self->runScheduledTasks();
$self->end();
});
} | [
"public",
"function",
"main",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isMaintenanceModeEnabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Archiving won't run because maintenance mode is enabled\"",
")",
";",
"return",
";",
"}",
"$",
"self",
"=",
"$",
"this",
";",
"Access",
"::",
"doAsSuperUser",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"self",
")",
"{",
"$",
"self",
"->",
"init",
"(",
")",
";",
"$",
"self",
"->",
"run",
"(",
")",
";",
"$",
"self",
"->",
"runScheduledTasks",
"(",
")",
";",
"$",
"self",
"->",
"end",
"(",
")",
";",
"}",
")",
";",
"}"
] | Initializes and runs the cron archiver. | [
"Initializes",
"and",
"runs",
"the",
"cron",
"archiver",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L306-L320 |
209,606 | matomo-org/matomo | core/CronArchive.php | CronArchive.end | public function end()
{
/**
* This event is triggered after archiving.
*
* @param CronArchive $this
*/
Piwik::postEvent('CronArchive.end', array($this));
if (empty($this->errors)) {
// No error -> Logs the successful script execution until completion
Option::set(self::OPTION_ARCHIVING_FINISHED_TS, time());
return;
}
$this->logSection("SUMMARY OF ERRORS");
foreach ($this->errors as $error) {
// do not logError since errors are already in stderr
$this->logger->info("Error: " . $error);
}
$summary = count($this->errors) . " total errors during this script execution, please investigate and try and fix these errors.";
$this->logFatalError($summary);
} | php | public function end()
{
/**
* This event is triggered after archiving.
*
* @param CronArchive $this
*/
Piwik::postEvent('CronArchive.end', array($this));
if (empty($this->errors)) {
// No error -> Logs the successful script execution until completion
Option::set(self::OPTION_ARCHIVING_FINISHED_TS, time());
return;
}
$this->logSection("SUMMARY OF ERRORS");
foreach ($this->errors as $error) {
// do not logError since errors are already in stderr
$this->logger->info("Error: " . $error);
}
$summary = count($this->errors) . " total errors during this script execution, please investigate and try and fix these errors.";
$this->logFatalError($summary);
} | [
"public",
"function",
"end",
"(",
")",
"{",
"/**\n * This event is triggered after archiving.\n *\n * @param CronArchive $this\n */",
"Piwik",
"::",
"postEvent",
"(",
"'CronArchive.end'",
",",
"array",
"(",
"$",
"this",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"errors",
")",
")",
"{",
"// No error -> Logs the successful script execution until completion",
"Option",
"::",
"set",
"(",
"self",
"::",
"OPTION_ARCHIVING_FINISHED_TS",
",",
"time",
"(",
")",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"logSection",
"(",
"\"SUMMARY OF ERRORS\"",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"errors",
"as",
"$",
"error",
")",
"{",
"// do not logError since errors are already in stderr",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Error: \"",
".",
"$",
"error",
")",
";",
"}",
"$",
"summary",
"=",
"count",
"(",
"$",
"this",
"->",
"errors",
")",
".",
"\" total errors during this script execution, please investigate and try and fix these errors.\"",
";",
"$",
"this",
"->",
"logFatalError",
"(",
"$",
"summary",
")",
";",
"}"
] | End of the script | [
"End",
"of",
"the",
"script"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L548-L571 |
209,607 | matomo-org/matomo | core/CronArchive.php | CronArchive.logSection | private function logSection($title = "")
{
$this->logger->info("---------------------------");
if (!empty($title)) {
$this->logger->info($title);
}
} | php | private function logSection($title = "")
{
$this->logger->info("---------------------------");
if (!empty($title)) {
$this->logger->info($title);
}
} | [
"private",
"function",
"logSection",
"(",
"$",
"title",
"=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"---------------------------\"",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"title",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"$",
"title",
")",
";",
"}",
"}"
] | Logs a section in the output
@param string $title | [
"Logs",
"a",
"section",
"in",
"the",
"output"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L1057-L1063 |
209,608 | matomo-org/matomo | core/CronArchive.php | CronArchive.initStateFromParameters | private function initStateFromParameters()
{
$this->todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive();
$this->processPeriodsMaximumEverySeconds = $this->getDelayBetweenPeriodsArchives();
$this->lastSuccessRunTimestamp = $this->getLastSuccessRunTimestamp();
$this->shouldArchiveOnlySitesWithTrafficSince = $this->isShouldArchiveAllSitesWithTrafficSince();
$this->shouldArchiveOnlySpecificPeriods = $this->getPeriodsToProcess();
if ($this->shouldArchiveOnlySitesWithTrafficSince !== false) {
// force-all-periods is set here
$this->archiveAndRespectTTL = false;
}
} | php | private function initStateFromParameters()
{
$this->todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive();
$this->processPeriodsMaximumEverySeconds = $this->getDelayBetweenPeriodsArchives();
$this->lastSuccessRunTimestamp = $this->getLastSuccessRunTimestamp();
$this->shouldArchiveOnlySitesWithTrafficSince = $this->isShouldArchiveAllSitesWithTrafficSince();
$this->shouldArchiveOnlySpecificPeriods = $this->getPeriodsToProcess();
if ($this->shouldArchiveOnlySitesWithTrafficSince !== false) {
// force-all-periods is set here
$this->archiveAndRespectTTL = false;
}
} | [
"private",
"function",
"initStateFromParameters",
"(",
")",
"{",
"$",
"this",
"->",
"todayArchiveTimeToLive",
"=",
"Rules",
"::",
"getTodayArchiveTimeToLive",
"(",
")",
";",
"$",
"this",
"->",
"processPeriodsMaximumEverySeconds",
"=",
"$",
"this",
"->",
"getDelayBetweenPeriodsArchives",
"(",
")",
";",
"$",
"this",
"->",
"lastSuccessRunTimestamp",
"=",
"$",
"this",
"->",
"getLastSuccessRunTimestamp",
"(",
")",
";",
"$",
"this",
"->",
"shouldArchiveOnlySitesWithTrafficSince",
"=",
"$",
"this",
"->",
"isShouldArchiveAllSitesWithTrafficSince",
"(",
")",
";",
"$",
"this",
"->",
"shouldArchiveOnlySpecificPeriods",
"=",
"$",
"this",
"->",
"getPeriodsToProcess",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"shouldArchiveOnlySitesWithTrafficSince",
"!==",
"false",
")",
"{",
"// force-all-periods is set here",
"$",
"this",
"->",
"archiveAndRespectTTL",
"=",
"false",
";",
"}",
"}"
] | Initializes the various parameters to the script, based on input parameters. | [
"Initializes",
"the",
"various",
"parameters",
"to",
"the",
"script",
"based",
"on",
"input",
"parameters",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L1132-L1144 |
209,609 | matomo-org/matomo | core/CronArchive.php | CronArchive.initWebsiteIds | public function initWebsiteIds()
{
if (count($this->shouldArchiveSpecifiedSites) > 0) {
$this->logger->info("- Will process " . count($this->shouldArchiveSpecifiedSites) . " websites (--force-idsites)");
return $this->shouldArchiveSpecifiedSites;
}
$this->findWebsiteIdsInTimezoneWithNewDay($this->allWebsites);
$this->findInvalidatedSitesToReprocess();
if ($this->shouldArchiveAllSites) {
$this->logger->info("- Will process all " . count($this->allWebsites) . " websites");
}
return $this->allWebsites;
} | php | public function initWebsiteIds()
{
if (count($this->shouldArchiveSpecifiedSites) > 0) {
$this->logger->info("- Will process " . count($this->shouldArchiveSpecifiedSites) . " websites (--force-idsites)");
return $this->shouldArchiveSpecifiedSites;
}
$this->findWebsiteIdsInTimezoneWithNewDay($this->allWebsites);
$this->findInvalidatedSitesToReprocess();
if ($this->shouldArchiveAllSites) {
$this->logger->info("- Will process all " . count($this->allWebsites) . " websites");
}
return $this->allWebsites;
} | [
"public",
"function",
"initWebsiteIds",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"shouldArchiveSpecifiedSites",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"- Will process \"",
".",
"count",
"(",
"$",
"this",
"->",
"shouldArchiveSpecifiedSites",
")",
".",
"\" websites (--force-idsites)\"",
")",
";",
"return",
"$",
"this",
"->",
"shouldArchiveSpecifiedSites",
";",
"}",
"$",
"this",
"->",
"findWebsiteIdsInTimezoneWithNewDay",
"(",
"$",
"this",
"->",
"allWebsites",
")",
";",
"$",
"this",
"->",
"findInvalidatedSitesToReprocess",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"shouldArchiveAllSites",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"- Will process all \"",
".",
"count",
"(",
"$",
"this",
"->",
"allWebsites",
")",
".",
"\" websites\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"allWebsites",
";",
"}"
] | Returns the list of sites to loop over and archive.
@return array | [
"Returns",
"the",
"list",
"of",
"sites",
"to",
"loop",
"over",
"and",
"archive",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L1221-L1237 |
209,610 | matomo-org/matomo | core/CronArchive.php | CronArchive.hadWebsiteTrafficSinceMidnightInTimezone | private function hadWebsiteTrafficSinceMidnightInTimezone($idSite)
{
$timezone = Site::getTimezoneFor($idSite);
$nowInTimezone = Date::factory('now', $timezone);
$midnightInTimezone = $nowInTimezone->setTime('00:00:00');
$secondsSinceMidnight = $nowInTimezone->getTimestamp() - $midnightInTimezone->getTimestamp();
$secondsSinceLastArchive = $this->getSecondsSinceLastArchive();
if ($secondsSinceLastArchive < $secondsSinceMidnight) {
$secondsBackToLookForVisits = $secondsSinceLastArchive;
$sinceInfo = "(since the last successful archiving)";
} else {
$secondsBackToLookForVisits = $secondsSinceMidnight;
$sinceInfo = "(since midnight)";
}
$from = Date::now()->subSeconds($secondsBackToLookForVisits)->getDatetime();
$to = Date::now()->addHour(1)->getDatetime();
$dao = new RawLogDao();
$hasVisits = $dao->hasSiteVisitsBetweenTimeframe($from, $to, $idSite);
if ($hasVisits) {
$this->logger->info("- tracking data found for website id $idSite since $from UTC $sinceInfo");
} else {
$this->logger->info("- no new tracking data for website id $idSite since $from UTC $sinceInfo");
}
return $hasVisits;
} | php | private function hadWebsiteTrafficSinceMidnightInTimezone($idSite)
{
$timezone = Site::getTimezoneFor($idSite);
$nowInTimezone = Date::factory('now', $timezone);
$midnightInTimezone = $nowInTimezone->setTime('00:00:00');
$secondsSinceMidnight = $nowInTimezone->getTimestamp() - $midnightInTimezone->getTimestamp();
$secondsSinceLastArchive = $this->getSecondsSinceLastArchive();
if ($secondsSinceLastArchive < $secondsSinceMidnight) {
$secondsBackToLookForVisits = $secondsSinceLastArchive;
$sinceInfo = "(since the last successful archiving)";
} else {
$secondsBackToLookForVisits = $secondsSinceMidnight;
$sinceInfo = "(since midnight)";
}
$from = Date::now()->subSeconds($secondsBackToLookForVisits)->getDatetime();
$to = Date::now()->addHour(1)->getDatetime();
$dao = new RawLogDao();
$hasVisits = $dao->hasSiteVisitsBetweenTimeframe($from, $to, $idSite);
if ($hasVisits) {
$this->logger->info("- tracking data found for website id $idSite since $from UTC $sinceInfo");
} else {
$this->logger->info("- no new tracking data for website id $idSite since $from UTC $sinceInfo");
}
return $hasVisits;
} | [
"private",
"function",
"hadWebsiteTrafficSinceMidnightInTimezone",
"(",
"$",
"idSite",
")",
"{",
"$",
"timezone",
"=",
"Site",
"::",
"getTimezoneFor",
"(",
"$",
"idSite",
")",
";",
"$",
"nowInTimezone",
"=",
"Date",
"::",
"factory",
"(",
"'now'",
",",
"$",
"timezone",
")",
";",
"$",
"midnightInTimezone",
"=",
"$",
"nowInTimezone",
"->",
"setTime",
"(",
"'00:00:00'",
")",
";",
"$",
"secondsSinceMidnight",
"=",
"$",
"nowInTimezone",
"->",
"getTimestamp",
"(",
")",
"-",
"$",
"midnightInTimezone",
"->",
"getTimestamp",
"(",
")",
";",
"$",
"secondsSinceLastArchive",
"=",
"$",
"this",
"->",
"getSecondsSinceLastArchive",
"(",
")",
";",
"if",
"(",
"$",
"secondsSinceLastArchive",
"<",
"$",
"secondsSinceMidnight",
")",
"{",
"$",
"secondsBackToLookForVisits",
"=",
"$",
"secondsSinceLastArchive",
";",
"$",
"sinceInfo",
"=",
"\"(since the last successful archiving)\"",
";",
"}",
"else",
"{",
"$",
"secondsBackToLookForVisits",
"=",
"$",
"secondsSinceMidnight",
";",
"$",
"sinceInfo",
"=",
"\"(since midnight)\"",
";",
"}",
"$",
"from",
"=",
"Date",
"::",
"now",
"(",
")",
"->",
"subSeconds",
"(",
"$",
"secondsBackToLookForVisits",
")",
"->",
"getDatetime",
"(",
")",
";",
"$",
"to",
"=",
"Date",
"::",
"now",
"(",
")",
"->",
"addHour",
"(",
"1",
")",
"->",
"getDatetime",
"(",
")",
";",
"$",
"dao",
"=",
"new",
"RawLogDao",
"(",
")",
";",
"$",
"hasVisits",
"=",
"$",
"dao",
"->",
"hasSiteVisitsBetweenTimeframe",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"idSite",
")",
";",
"if",
"(",
"$",
"hasVisits",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"- tracking data found for website id $idSite since $from UTC $sinceInfo\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"- no new tracking data for website id $idSite since $from UTC $sinceInfo\"",
")",
";",
"}",
"return",
"$",
"hasVisits",
";",
"}"
] | Detects whether a site had visits since midnight in the websites timezone
@param $idSite
@return bool | [
"Detects",
"whether",
"a",
"site",
"had",
"visits",
"since",
"midnight",
"in",
"the",
"websites",
"timezone"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L1272-L1303 |
209,611 | matomo-org/matomo | core/CronArchive.php | CronArchive.getTimezonesHavingNewDaySinceLastRun | private function getTimezonesHavingNewDaySinceLastRun()
{
$timestamp = $this->lastSuccessRunTimestamp;
$uniqueTimezones = APISitesManager::getInstance()->getUniqueSiteTimezones();
$timezoneToProcess = array();
foreach ($uniqueTimezones as &$timezone) {
$processedDateInTz = Date::factory((int)$timestamp, $timezone);
$currentDateInTz = Date::factory('now', $timezone);
if ($processedDateInTz->toString() != $currentDateInTz->toString()) {
$timezoneToProcess[] = $timezone;
}
}
return $timezoneToProcess;
} | php | private function getTimezonesHavingNewDaySinceLastRun()
{
$timestamp = $this->lastSuccessRunTimestamp;
$uniqueTimezones = APISitesManager::getInstance()->getUniqueSiteTimezones();
$timezoneToProcess = array();
foreach ($uniqueTimezones as &$timezone) {
$processedDateInTz = Date::factory((int)$timestamp, $timezone);
$currentDateInTz = Date::factory('now', $timezone);
if ($processedDateInTz->toString() != $currentDateInTz->toString()) {
$timezoneToProcess[] = $timezone;
}
}
return $timezoneToProcess;
} | [
"private",
"function",
"getTimezonesHavingNewDaySinceLastRun",
"(",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"lastSuccessRunTimestamp",
";",
"$",
"uniqueTimezones",
"=",
"APISitesManager",
"::",
"getInstance",
"(",
")",
"->",
"getUniqueSiteTimezones",
"(",
")",
";",
"$",
"timezoneToProcess",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"uniqueTimezones",
"as",
"&",
"$",
"timezone",
")",
"{",
"$",
"processedDateInTz",
"=",
"Date",
"::",
"factory",
"(",
"(",
"int",
")",
"$",
"timestamp",
",",
"$",
"timezone",
")",
";",
"$",
"currentDateInTz",
"=",
"Date",
"::",
"factory",
"(",
"'now'",
",",
"$",
"timezone",
")",
";",
"if",
"(",
"$",
"processedDateInTz",
"->",
"toString",
"(",
")",
"!=",
"$",
"currentDateInTz",
"->",
"toString",
"(",
")",
")",
"{",
"$",
"timezoneToProcess",
"[",
"]",
"=",
"$",
"timezone",
";",
"}",
"}",
"return",
"$",
"timezoneToProcess",
";",
"}"
] | Returns the list of timezones where the specified timestamp in that timezone
is on a different day than today in that timezone.
@return array | [
"Returns",
"the",
"list",
"of",
"timezones",
"where",
"the",
"specified",
"timestamp",
"in",
"that",
"timezone",
"is",
"on",
"a",
"different",
"day",
"than",
"today",
"in",
"that",
"timezone",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L1311-L1325 |
209,612 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.detectGoalsMatchingUrl | public function detectGoalsMatchingUrl($idSite, $action)
{
if (!Common::isGoalPluginEnabled()) {
return array();
}
$goals = $this->getGoalDefinitions($idSite);
$convertedGoals = array();
foreach ($goals as $goal) {
$convertedUrl = $this->detectGoalMatch($goal, $action);
if (!is_null($convertedUrl)) {
$convertedGoals[] = array('url' => $convertedUrl) + $goal;
}
}
return $convertedGoals;
} | php | public function detectGoalsMatchingUrl($idSite, $action)
{
if (!Common::isGoalPluginEnabled()) {
return array();
}
$goals = $this->getGoalDefinitions($idSite);
$convertedGoals = array();
foreach ($goals as $goal) {
$convertedUrl = $this->detectGoalMatch($goal, $action);
if (!is_null($convertedUrl)) {
$convertedGoals[] = array('url' => $convertedUrl) + $goal;
}
}
return $convertedGoals;
} | [
"public",
"function",
"detectGoalsMatchingUrl",
"(",
"$",
"idSite",
",",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"Common",
"::",
"isGoalPluginEnabled",
"(",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"goals",
"=",
"$",
"this",
"->",
"getGoalDefinitions",
"(",
"$",
"idSite",
")",
";",
"$",
"convertedGoals",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"goals",
"as",
"$",
"goal",
")",
"{",
"$",
"convertedUrl",
"=",
"$",
"this",
"->",
"detectGoalMatch",
"(",
"$",
"goal",
",",
"$",
"action",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"convertedUrl",
")",
")",
"{",
"$",
"convertedGoals",
"[",
"]",
"=",
"array",
"(",
"'url'",
"=>",
"$",
"convertedUrl",
")",
"+",
"$",
"goal",
";",
"}",
"}",
"return",
"$",
"convertedGoals",
";",
"}"
] | Look at the URL or Page Title and sees if it matches any existing Goal definition
@param int $idSite
@param Action $action
@throws Exception
@return array[] Goals matched | [
"Look",
"at",
"the",
"URL",
"or",
"Page",
"Title",
"and",
"sees",
"if",
"it",
"matches",
"any",
"existing",
"Goal",
"definition"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L125-L141 |
209,613 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.detectGoalMatch | public function detectGoalMatch($goal, Action $action)
{
$actionType = $action->getActionType();
$attribute = $goal['match_attribute'];
// if the attribute to match is not the type of the current action
if ((($attribute == 'url' || $attribute == 'title') && $actionType != Action::TYPE_PAGE_URL)
|| ($attribute == 'file' && $actionType != Action::TYPE_DOWNLOAD)
|| ($attribute == 'external_website' && $actionType != Action::TYPE_OUTLINK)
|| ($attribute == 'manually')
|| self::isEventMatchingGoal($goal) && $actionType != Action::TYPE_EVENT
) {
return null;
}
switch ($attribute) {
case 'title':
// Matching on Page Title
$actionToMatch = $action->getActionName();
break;
case 'event_action':
$actionToMatch = $action->getEventAction();
break;
case 'event_name':
$actionToMatch = $action->getEventName();
break;
case 'event_category':
$actionToMatch = $action->getEventCategory();
break;
// url, external_website, file, manually...
default:
$actionToMatch = $action->getActionUrlRaw();
break;
}
$pattern_type = $goal['pattern_type'];
$match = $this->isUrlMatchingGoal($goal, $pattern_type, $actionToMatch);
if (!$match) {
return null;
}
return $action->getActionUrl();
} | php | public function detectGoalMatch($goal, Action $action)
{
$actionType = $action->getActionType();
$attribute = $goal['match_attribute'];
// if the attribute to match is not the type of the current action
if ((($attribute == 'url' || $attribute == 'title') && $actionType != Action::TYPE_PAGE_URL)
|| ($attribute == 'file' && $actionType != Action::TYPE_DOWNLOAD)
|| ($attribute == 'external_website' && $actionType != Action::TYPE_OUTLINK)
|| ($attribute == 'manually')
|| self::isEventMatchingGoal($goal) && $actionType != Action::TYPE_EVENT
) {
return null;
}
switch ($attribute) {
case 'title':
// Matching on Page Title
$actionToMatch = $action->getActionName();
break;
case 'event_action':
$actionToMatch = $action->getEventAction();
break;
case 'event_name':
$actionToMatch = $action->getEventName();
break;
case 'event_category':
$actionToMatch = $action->getEventCategory();
break;
// url, external_website, file, manually...
default:
$actionToMatch = $action->getActionUrlRaw();
break;
}
$pattern_type = $goal['pattern_type'];
$match = $this->isUrlMatchingGoal($goal, $pattern_type, $actionToMatch);
if (!$match) {
return null;
}
return $action->getActionUrl();
} | [
"public",
"function",
"detectGoalMatch",
"(",
"$",
"goal",
",",
"Action",
"$",
"action",
")",
"{",
"$",
"actionType",
"=",
"$",
"action",
"->",
"getActionType",
"(",
")",
";",
"$",
"attribute",
"=",
"$",
"goal",
"[",
"'match_attribute'",
"]",
";",
"// if the attribute to match is not the type of the current action",
"if",
"(",
"(",
"(",
"$",
"attribute",
"==",
"'url'",
"||",
"$",
"attribute",
"==",
"'title'",
")",
"&&",
"$",
"actionType",
"!=",
"Action",
"::",
"TYPE_PAGE_URL",
")",
"||",
"(",
"$",
"attribute",
"==",
"'file'",
"&&",
"$",
"actionType",
"!=",
"Action",
"::",
"TYPE_DOWNLOAD",
")",
"||",
"(",
"$",
"attribute",
"==",
"'external_website'",
"&&",
"$",
"actionType",
"!=",
"Action",
"::",
"TYPE_OUTLINK",
")",
"||",
"(",
"$",
"attribute",
"==",
"'manually'",
")",
"||",
"self",
"::",
"isEventMatchingGoal",
"(",
"$",
"goal",
")",
"&&",
"$",
"actionType",
"!=",
"Action",
"::",
"TYPE_EVENT",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"$",
"attribute",
")",
"{",
"case",
"'title'",
":",
"// Matching on Page Title",
"$",
"actionToMatch",
"=",
"$",
"action",
"->",
"getActionName",
"(",
")",
";",
"break",
";",
"case",
"'event_action'",
":",
"$",
"actionToMatch",
"=",
"$",
"action",
"->",
"getEventAction",
"(",
")",
";",
"break",
";",
"case",
"'event_name'",
":",
"$",
"actionToMatch",
"=",
"$",
"action",
"->",
"getEventName",
"(",
")",
";",
"break",
";",
"case",
"'event_category'",
":",
"$",
"actionToMatch",
"=",
"$",
"action",
"->",
"getEventCategory",
"(",
")",
";",
"break",
";",
"// url, external_website, file, manually...",
"default",
":",
"$",
"actionToMatch",
"=",
"$",
"action",
"->",
"getActionUrlRaw",
"(",
")",
";",
"break",
";",
"}",
"$",
"pattern_type",
"=",
"$",
"goal",
"[",
"'pattern_type'",
"]",
";",
"$",
"match",
"=",
"$",
"this",
"->",
"isUrlMatchingGoal",
"(",
"$",
"goal",
",",
"$",
"pattern_type",
",",
"$",
"actionToMatch",
")",
";",
"if",
"(",
"!",
"$",
"match",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"action",
"->",
"getActionUrl",
"(",
")",
";",
"}"
] | Detects if an Action matches a given goal. If it does, the URL that triggered the goal
is returned. Otherwise null is returned.
@param array $goal
@param Action $action
@return if a goal is matched, a string of the Action URL is returned, or if no goal was matched it returns null | [
"Detects",
"if",
"an",
"Action",
"matches",
"a",
"given",
"goal",
".",
"If",
"it",
"does",
"the",
"URL",
"that",
"triggered",
"the",
"goal",
"is",
"returned",
".",
"Otherwise",
"null",
"is",
"returned",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L151-L196 |
209,614 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.recordGoals | public function recordGoals(VisitProperties $visitProperties, Request $request)
{
$visitorInformation = $visitProperties->getProperties();
$visitCustomVariables = $request->getMetadata('CustomVariables', 'visitCustomVariables') ?: array();
/** @var Action $action */
$action = $request->getMetadata('Actions', 'action');
$goal = $this->getGoalFromVisitor($visitProperties, $request, $action);
// Copy Custom Variables from Visit row to the Goal conversion
// Otherwise, set the Custom Variables found in the cookie sent with this request
$goal += $visitCustomVariables;
$maxCustomVariables = CustomVariables::getNumUsableCustomVariables();
for ($i = 1; $i <= $maxCustomVariables; $i++) {
if (isset($visitorInformation['custom_var_k' . $i])
&& strlen($visitorInformation['custom_var_k' . $i])
) {
$goal['custom_var_k' . $i] = $visitorInformation['custom_var_k' . $i];
}
if (isset($visitorInformation['custom_var_v' . $i])
&& strlen($visitorInformation['custom_var_v' . $i])
) {
$goal['custom_var_v' . $i] = $visitorInformation['custom_var_v' . $i];
}
}
// some goals are converted, so must be ecommerce Order or Cart Update
$isRequestEcommerce = $request->getMetadata('Ecommerce', 'isRequestEcommerce');
if ($isRequestEcommerce) {
$this->recordEcommerceGoal($visitProperties, $request, $goal, $action);
} else {
$this->recordStandardGoals($visitProperties, $request, $goal, $action);
}
} | php | public function recordGoals(VisitProperties $visitProperties, Request $request)
{
$visitorInformation = $visitProperties->getProperties();
$visitCustomVariables = $request->getMetadata('CustomVariables', 'visitCustomVariables') ?: array();
/** @var Action $action */
$action = $request->getMetadata('Actions', 'action');
$goal = $this->getGoalFromVisitor($visitProperties, $request, $action);
// Copy Custom Variables from Visit row to the Goal conversion
// Otherwise, set the Custom Variables found in the cookie sent with this request
$goal += $visitCustomVariables;
$maxCustomVariables = CustomVariables::getNumUsableCustomVariables();
for ($i = 1; $i <= $maxCustomVariables; $i++) {
if (isset($visitorInformation['custom_var_k' . $i])
&& strlen($visitorInformation['custom_var_k' . $i])
) {
$goal['custom_var_k' . $i] = $visitorInformation['custom_var_k' . $i];
}
if (isset($visitorInformation['custom_var_v' . $i])
&& strlen($visitorInformation['custom_var_v' . $i])
) {
$goal['custom_var_v' . $i] = $visitorInformation['custom_var_v' . $i];
}
}
// some goals are converted, so must be ecommerce Order or Cart Update
$isRequestEcommerce = $request->getMetadata('Ecommerce', 'isRequestEcommerce');
if ($isRequestEcommerce) {
$this->recordEcommerceGoal($visitProperties, $request, $goal, $action);
} else {
$this->recordStandardGoals($visitProperties, $request, $goal, $action);
}
} | [
"public",
"function",
"recordGoals",
"(",
"VisitProperties",
"$",
"visitProperties",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"visitorInformation",
"=",
"$",
"visitProperties",
"->",
"getProperties",
"(",
")",
";",
"$",
"visitCustomVariables",
"=",
"$",
"request",
"->",
"getMetadata",
"(",
"'CustomVariables'",
",",
"'visitCustomVariables'",
")",
"?",
":",
"array",
"(",
")",
";",
"/** @var Action $action */",
"$",
"action",
"=",
"$",
"request",
"->",
"getMetadata",
"(",
"'Actions'",
",",
"'action'",
")",
";",
"$",
"goal",
"=",
"$",
"this",
"->",
"getGoalFromVisitor",
"(",
"$",
"visitProperties",
",",
"$",
"request",
",",
"$",
"action",
")",
";",
"// Copy Custom Variables from Visit row to the Goal conversion",
"// Otherwise, set the Custom Variables found in the cookie sent with this request",
"$",
"goal",
"+=",
"$",
"visitCustomVariables",
";",
"$",
"maxCustomVariables",
"=",
"CustomVariables",
"::",
"getNumUsableCustomVariables",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"maxCustomVariables",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"visitorInformation",
"[",
"'custom_var_k'",
".",
"$",
"i",
"]",
")",
"&&",
"strlen",
"(",
"$",
"visitorInformation",
"[",
"'custom_var_k'",
".",
"$",
"i",
"]",
")",
")",
"{",
"$",
"goal",
"[",
"'custom_var_k'",
".",
"$",
"i",
"]",
"=",
"$",
"visitorInformation",
"[",
"'custom_var_k'",
".",
"$",
"i",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"visitorInformation",
"[",
"'custom_var_v'",
".",
"$",
"i",
"]",
")",
"&&",
"strlen",
"(",
"$",
"visitorInformation",
"[",
"'custom_var_v'",
".",
"$",
"i",
"]",
")",
")",
"{",
"$",
"goal",
"[",
"'custom_var_v'",
".",
"$",
"i",
"]",
"=",
"$",
"visitorInformation",
"[",
"'custom_var_v'",
".",
"$",
"i",
"]",
";",
"}",
"}",
"// some goals are converted, so must be ecommerce Order or Cart Update",
"$",
"isRequestEcommerce",
"=",
"$",
"request",
"->",
"getMetadata",
"(",
"'Ecommerce'",
",",
"'isRequestEcommerce'",
")",
";",
"if",
"(",
"$",
"isRequestEcommerce",
")",
"{",
"$",
"this",
"->",
"recordEcommerceGoal",
"(",
"$",
"visitProperties",
",",
"$",
"request",
",",
"$",
"goal",
",",
"$",
"action",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"recordStandardGoals",
"(",
"$",
"visitProperties",
",",
"$",
"request",
",",
"$",
"goal",
",",
"$",
"action",
")",
";",
"}",
"}"
] | Records one or several goals matched in this request.
@param Visitor $visitor
@param array $visitorInformation
@param array $visitCustomVariables
@param Action $action | [
"Records",
"one",
"or",
"several",
"goals",
"matched",
"in",
"this",
"request",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L227-L262 |
209,615 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.getEcommerceItemsFromRequest | private function getEcommerceItemsFromRequest(Request $request)
{
$items = $request->getParam('ec_items');
if (empty($items)) {
Common::printDebug("There are no Ecommerce items in the request");
// we still record an Ecommerce order without any item in it
return array();
}
if (!is_array($items)) {
Common::printDebug("Error while json_decode the Ecommerce items = " . var_export($items, true));
return false;
}
$items = Common::unsanitizeInputValues($items);
$cleanedItems = $this->getCleanedEcommerceItems($items);
return $cleanedItems;
} | php | private function getEcommerceItemsFromRequest(Request $request)
{
$items = $request->getParam('ec_items');
if (empty($items)) {
Common::printDebug("There are no Ecommerce items in the request");
// we still record an Ecommerce order without any item in it
return array();
}
if (!is_array($items)) {
Common::printDebug("Error while json_decode the Ecommerce items = " . var_export($items, true));
return false;
}
$items = Common::unsanitizeInputValues($items);
$cleanedItems = $this->getCleanedEcommerceItems($items);
return $cleanedItems;
} | [
"private",
"function",
"getEcommerceItemsFromRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"items",
"=",
"$",
"request",
"->",
"getParam",
"(",
"'ec_items'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"items",
")",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"There are no Ecommerce items in the request\"",
")",
";",
"// we still record an Ecommerce order without any item in it",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"items",
")",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"Error while json_decode the Ecommerce items = \"",
".",
"var_export",
"(",
"$",
"items",
",",
"true",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"items",
"=",
"Common",
"::",
"unsanitizeInputValues",
"(",
"$",
"items",
")",
";",
"$",
"cleanedItems",
"=",
"$",
"this",
"->",
"getCleanedEcommerceItems",
"(",
"$",
"items",
")",
";",
"return",
"$",
"cleanedItems",
";",
"}"
] | Returns Items read from the request string
@return array|bool | [
"Returns",
"Items",
"read",
"from",
"the",
"request",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L354-L373 |
209,616 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.updateEcommerceItems | protected function updateEcommerceItems($goal, $itemsToUpdate)
{
if (empty($itemsToUpdate)) {
return;
}
Common::printDebug("Goal data used to update ecommerce items:");
Common::printDebug($goal);
foreach ($itemsToUpdate as $item) {
$newRow = $this->getItemRowEnriched($goal, $item);
Common::printDebug($newRow);
$this->getModel()->updateEcommerceItem($item['idorder_original_value'], $newRow);
}
} | php | protected function updateEcommerceItems($goal, $itemsToUpdate)
{
if (empty($itemsToUpdate)) {
return;
}
Common::printDebug("Goal data used to update ecommerce items:");
Common::printDebug($goal);
foreach ($itemsToUpdate as $item) {
$newRow = $this->getItemRowEnriched($goal, $item);
Common::printDebug($newRow);
$this->getModel()->updateEcommerceItem($item['idorder_original_value'], $newRow);
}
} | [
"protected",
"function",
"updateEcommerceItems",
"(",
"$",
"goal",
",",
"$",
"itemsToUpdate",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"itemsToUpdate",
")",
")",
"{",
"return",
";",
"}",
"Common",
"::",
"printDebug",
"(",
"\"Goal data used to update ecommerce items:\"",
")",
";",
"Common",
"::",
"printDebug",
"(",
"$",
"goal",
")",
";",
"foreach",
"(",
"$",
"itemsToUpdate",
"as",
"$",
"item",
")",
"{",
"$",
"newRow",
"=",
"$",
"this",
"->",
"getItemRowEnriched",
"(",
"$",
"goal",
",",
"$",
"item",
")",
";",
"Common",
"::",
"printDebug",
"(",
"$",
"newRow",
")",
";",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"updateEcommerceItem",
"(",
"$",
"item",
"[",
"'idorder_original_value'",
"]",
",",
"$",
"newRow",
")",
";",
"}",
"}"
] | Updates the cart items in the DB
that have been modified since the last cart update
@param array $goal
@param array $itemsToUpdate
@return void | [
"Updates",
"the",
"cart",
"items",
"in",
"the",
"DB",
"that",
"have",
"been",
"modified",
"since",
"the",
"last",
"cart",
"update"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L569-L584 |
209,617 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.insertEcommerceItems | protected function insertEcommerceItems($goal, $itemsToInsert)
{
if (empty($itemsToInsert)) {
return;
}
Common::printDebug("Ecommerce items that are added to the cart/order");
Common::printDebug($itemsToInsert);
$items = array();
foreach ($itemsToInsert as $item) {
$items[] = $this->getItemRowEnriched($goal, $item);
}
$this->getModel()->createEcommerceItems($items);
} | php | protected function insertEcommerceItems($goal, $itemsToInsert)
{
if (empty($itemsToInsert)) {
return;
}
Common::printDebug("Ecommerce items that are added to the cart/order");
Common::printDebug($itemsToInsert);
$items = array();
foreach ($itemsToInsert as $item) {
$items[] = $this->getItemRowEnriched($goal, $item);
}
$this->getModel()->createEcommerceItems($items);
} | [
"protected",
"function",
"insertEcommerceItems",
"(",
"$",
"goal",
",",
"$",
"itemsToInsert",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"itemsToInsert",
")",
")",
"{",
"return",
";",
"}",
"Common",
"::",
"printDebug",
"(",
"\"Ecommerce items that are added to the cart/order\"",
")",
";",
"Common",
"::",
"printDebug",
"(",
"$",
"itemsToInsert",
")",
";",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"itemsToInsert",
"as",
"$",
"item",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"$",
"this",
"->",
"getItemRowEnriched",
"(",
"$",
"goal",
",",
"$",
"item",
")",
";",
"}",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"createEcommerceItems",
"(",
"$",
"items",
")",
";",
"}"
] | Inserts in the cart in the DB the new items
that were not previously in the cart
@param array $goal
@param array $itemsToInsert
@return void | [
"Inserts",
"in",
"the",
"cart",
"in",
"the",
"DB",
"the",
"new",
"items",
"that",
"were",
"not",
"previously",
"in",
"the",
"cart"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L600-L616 |
209,618 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.getItemRowCast | protected function getItemRowCast($row)
{
return array(
(string)(int)$row[self::INTERNAL_ITEM_SKU],
(string)(int)$row[self::INTERNAL_ITEM_NAME],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY2],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY3],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY4],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY5],
(string)$row[self::INTERNAL_ITEM_PRICE],
(string)$row[self::INTERNAL_ITEM_QUANTITY],
);
} | php | protected function getItemRowCast($row)
{
return array(
(string)(int)$row[self::INTERNAL_ITEM_SKU],
(string)(int)$row[self::INTERNAL_ITEM_NAME],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY2],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY3],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY4],
(string)(int)$row[self::INTERNAL_ITEM_CATEGORY5],
(string)$row[self::INTERNAL_ITEM_PRICE],
(string)$row[self::INTERNAL_ITEM_QUANTITY],
);
} | [
"protected",
"function",
"getItemRowCast",
"(",
"$",
"row",
")",
"{",
"return",
"array",
"(",
"(",
"string",
")",
"(",
"int",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_SKU",
"]",
",",
"(",
"string",
")",
"(",
"int",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_NAME",
"]",
",",
"(",
"string",
")",
"(",
"int",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_CATEGORY",
"]",
",",
"(",
"string",
")",
"(",
"int",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_CATEGORY2",
"]",
",",
"(",
"string",
")",
"(",
"int",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_CATEGORY3",
"]",
",",
"(",
"string",
")",
"(",
"int",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_CATEGORY4",
"]",
",",
"(",
"string",
")",
"(",
"int",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_CATEGORY5",
"]",
",",
"(",
"string",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_PRICE",
"]",
",",
"(",
"string",
")",
"$",
"row",
"[",
"self",
"::",
"INTERNAL_ITEM_QUANTITY",
"]",
",",
")",
";",
"}"
] | Casts the item array so that array comparisons work nicely
@param array $row
@return array | [
"Casts",
"the",
"item",
"array",
"so",
"that",
"array",
"comparisons",
"work",
"nicely"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L763-L776 |
209,619 | matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.formatRegex | public static function formatRegex($pattern)
{
if (strpos($pattern, '/') !== false
&& strpos($pattern, '\\/') === false
) {
$pattern = str_replace('/', '\\/', $pattern);
}
return '/' . $pattern . '/';
} | php | public static function formatRegex($pattern)
{
if (strpos($pattern, '/') !== false
&& strpos($pattern, '\\/') === false
) {
$pattern = str_replace('/', '\\/', $pattern);
}
return '/' . $pattern . '/';
} | [
"public",
"static",
"function",
"formatRegex",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"pattern",
",",
"'/'",
")",
"!==",
"false",
"&&",
"strpos",
"(",
"$",
"pattern",
",",
"'\\\\/'",
")",
"===",
"false",
")",
"{",
"$",
"pattern",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\/'",
",",
"$",
"pattern",
")",
";",
"}",
"return",
"'/'",
".",
"$",
"pattern",
".",
"'/'",
";",
"}"
] | Formats a goal regex pattern to a usable regex
@param string $pattern
@return string | [
"Formats",
"a",
"goal",
"regex",
"pattern",
"to",
"a",
"usable",
"regex"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L900-L908 |
209,620 | matomo-org/matomo | core/API/DataTablePostProcessor.php | DataTablePostProcessor.process | public function process(DataTableInterface $dataTable)
{
// TODO: when calculating metrics before hand, only calculate for needed metrics, not all. NOTE:
// this is non-trivial since it will require, eg, to make sure processed metrics aren't added
// after pivotBy is handled.
$dataTable = $this->applyPivotByFilter($dataTable);
$dataTable = $this->applyTotalsCalculator($dataTable);
$dataTable = $this->applyFlattener($dataTable);
if ($this->callbackBeforeGenericFilters) {
call_user_func($this->callbackBeforeGenericFilters, $dataTable);
}
$dataTable = $this->applyGenericFilters($dataTable);
$this->applyComputeProcessedMetrics($dataTable);
if ($this->callbackAfterGenericFilters) {
call_user_func($this->callbackAfterGenericFilters, $dataTable);
}
// we automatically safe decode all datatable labels (against xss)
$dataTable->queueFilter('SafeDecodeLabel');
$dataTable = $this->convertSegmentValueToSegment($dataTable);
$dataTable = $this->applyQueuedFilters($dataTable);
$dataTable = $this->applyRequestedColumnDeletion($dataTable);
$dataTable = $this->applyLabelFilter($dataTable);
$dataTable = $this->applyMetricsFormatting($dataTable);
return $dataTable;
} | php | public function process(DataTableInterface $dataTable)
{
// TODO: when calculating metrics before hand, only calculate for needed metrics, not all. NOTE:
// this is non-trivial since it will require, eg, to make sure processed metrics aren't added
// after pivotBy is handled.
$dataTable = $this->applyPivotByFilter($dataTable);
$dataTable = $this->applyTotalsCalculator($dataTable);
$dataTable = $this->applyFlattener($dataTable);
if ($this->callbackBeforeGenericFilters) {
call_user_func($this->callbackBeforeGenericFilters, $dataTable);
}
$dataTable = $this->applyGenericFilters($dataTable);
$this->applyComputeProcessedMetrics($dataTable);
if ($this->callbackAfterGenericFilters) {
call_user_func($this->callbackAfterGenericFilters, $dataTable);
}
// we automatically safe decode all datatable labels (against xss)
$dataTable->queueFilter('SafeDecodeLabel');
$dataTable = $this->convertSegmentValueToSegment($dataTable);
$dataTable = $this->applyQueuedFilters($dataTable);
$dataTable = $this->applyRequestedColumnDeletion($dataTable);
$dataTable = $this->applyLabelFilter($dataTable);
$dataTable = $this->applyMetricsFormatting($dataTable);
return $dataTable;
} | [
"public",
"function",
"process",
"(",
"DataTableInterface",
"$",
"dataTable",
")",
"{",
"// TODO: when calculating metrics before hand, only calculate for needed metrics, not all. NOTE:",
"// this is non-trivial since it will require, eg, to make sure processed metrics aren't added",
"// after pivotBy is handled.",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyPivotByFilter",
"(",
"$",
"dataTable",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyTotalsCalculator",
"(",
"$",
"dataTable",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyFlattener",
"(",
"$",
"dataTable",
")",
";",
"if",
"(",
"$",
"this",
"->",
"callbackBeforeGenericFilters",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"callbackBeforeGenericFilters",
",",
"$",
"dataTable",
")",
";",
"}",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyGenericFilters",
"(",
"$",
"dataTable",
")",
";",
"$",
"this",
"->",
"applyComputeProcessedMetrics",
"(",
"$",
"dataTable",
")",
";",
"if",
"(",
"$",
"this",
"->",
"callbackAfterGenericFilters",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"callbackAfterGenericFilters",
",",
"$",
"dataTable",
")",
";",
"}",
"// we automatically safe decode all datatable labels (against xss)",
"$",
"dataTable",
"->",
"queueFilter",
"(",
"'SafeDecodeLabel'",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"convertSegmentValueToSegment",
"(",
"$",
"dataTable",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyQueuedFilters",
"(",
"$",
"dataTable",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyRequestedColumnDeletion",
"(",
"$",
"dataTable",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyLabelFilter",
"(",
"$",
"dataTable",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"applyMetricsFormatting",
"(",
"$",
"dataTable",
")",
";",
"return",
"$",
"dataTable",
";",
"}"
] | Apply post-processing logic to a DataTable of a report for an API request.
@param DataTableInterface $dataTable The data table to process.
@return DataTableInterface A new data table. | [
"Apply",
"post",
"-",
"processing",
"logic",
"to",
"a",
"DataTable",
"of",
"a",
"report",
"for",
"an",
"API",
"request",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/DataTablePostProcessor.php#L106-L134 |
209,621 | matomo-org/matomo | plugins/CoreConsole/Commands/CoreArchiver.php | CoreArchiver.makeArchiver | public static function makeArchiver($url, InputInterface $input)
{
$archiver = new CronArchive();
$archiver->disableScheduledTasks = $input->getOption('disable-scheduled-tasks');
$archiver->acceptInvalidSSLCertificate = $input->getOption("accept-invalid-ssl-certificate");
$archiver->shouldArchiveAllSites = (bool) $input->getOption("force-all-websites");
$archiver->shouldStartProfiler = (bool) $input->getOption("xhprof");
$archiver->shouldArchiveSpecifiedSites = self::getSitesListOption($input, "force-idsites");
$archiver->shouldSkipSpecifiedSites = self::getSitesListOption($input, "skip-idsites");
$archiver->forceTimeoutPeriod = $input->getOption("force-timeout-for-periods");
$archiver->shouldArchiveAllPeriodsSince = $input->getOption("force-all-periods");
$archiver->restrictToDateRange = $input->getOption("force-date-range");
$archiver->phpCliConfigurationOptions = $input->getOption("php-cli-options");
$restrictToPeriods = $input->getOption("force-periods");
$restrictToPeriods = explode(',', $restrictToPeriods);
$archiver->restrictToPeriods = array_map('trim', $restrictToPeriods);
$archiver->dateLastForced = $input->getOption('force-date-last-n');
$archiver->concurrentRequestsPerWebsite = $input->getOption('concurrent-requests-per-website');
$archiver->maxConcurrentArchivers = $input->getOption('concurrent-archivers');
$archiver->disableSegmentsArchiving = $input->getOption('skip-all-segments');
$segmentIds = $input->getOption('force-idsegments');
$segmentIds = explode(',', $segmentIds);
$segmentIds = array_map('trim', $segmentIds);
$archiver->setSegmentsToForceFromSegmentIds($segmentIds);
$archiver->setUrlToPiwik($url);
return $archiver;
} | php | public static function makeArchiver($url, InputInterface $input)
{
$archiver = new CronArchive();
$archiver->disableScheduledTasks = $input->getOption('disable-scheduled-tasks');
$archiver->acceptInvalidSSLCertificate = $input->getOption("accept-invalid-ssl-certificate");
$archiver->shouldArchiveAllSites = (bool) $input->getOption("force-all-websites");
$archiver->shouldStartProfiler = (bool) $input->getOption("xhprof");
$archiver->shouldArchiveSpecifiedSites = self::getSitesListOption($input, "force-idsites");
$archiver->shouldSkipSpecifiedSites = self::getSitesListOption($input, "skip-idsites");
$archiver->forceTimeoutPeriod = $input->getOption("force-timeout-for-periods");
$archiver->shouldArchiveAllPeriodsSince = $input->getOption("force-all-periods");
$archiver->restrictToDateRange = $input->getOption("force-date-range");
$archiver->phpCliConfigurationOptions = $input->getOption("php-cli-options");
$restrictToPeriods = $input->getOption("force-periods");
$restrictToPeriods = explode(',', $restrictToPeriods);
$archiver->restrictToPeriods = array_map('trim', $restrictToPeriods);
$archiver->dateLastForced = $input->getOption('force-date-last-n');
$archiver->concurrentRequestsPerWebsite = $input->getOption('concurrent-requests-per-website');
$archiver->maxConcurrentArchivers = $input->getOption('concurrent-archivers');
$archiver->disableSegmentsArchiving = $input->getOption('skip-all-segments');
$segmentIds = $input->getOption('force-idsegments');
$segmentIds = explode(',', $segmentIds);
$segmentIds = array_map('trim', $segmentIds);
$archiver->setSegmentsToForceFromSegmentIds($segmentIds);
$archiver->setUrlToPiwik($url);
return $archiver;
} | [
"public",
"static",
"function",
"makeArchiver",
"(",
"$",
"url",
",",
"InputInterface",
"$",
"input",
")",
"{",
"$",
"archiver",
"=",
"new",
"CronArchive",
"(",
")",
";",
"$",
"archiver",
"->",
"disableScheduledTasks",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'disable-scheduled-tasks'",
")",
";",
"$",
"archiver",
"->",
"acceptInvalidSSLCertificate",
"=",
"$",
"input",
"->",
"getOption",
"(",
"\"accept-invalid-ssl-certificate\"",
")",
";",
"$",
"archiver",
"->",
"shouldArchiveAllSites",
"=",
"(",
"bool",
")",
"$",
"input",
"->",
"getOption",
"(",
"\"force-all-websites\"",
")",
";",
"$",
"archiver",
"->",
"shouldStartProfiler",
"=",
"(",
"bool",
")",
"$",
"input",
"->",
"getOption",
"(",
"\"xhprof\"",
")",
";",
"$",
"archiver",
"->",
"shouldArchiveSpecifiedSites",
"=",
"self",
"::",
"getSitesListOption",
"(",
"$",
"input",
",",
"\"force-idsites\"",
")",
";",
"$",
"archiver",
"->",
"shouldSkipSpecifiedSites",
"=",
"self",
"::",
"getSitesListOption",
"(",
"$",
"input",
",",
"\"skip-idsites\"",
")",
";",
"$",
"archiver",
"->",
"forceTimeoutPeriod",
"=",
"$",
"input",
"->",
"getOption",
"(",
"\"force-timeout-for-periods\"",
")",
";",
"$",
"archiver",
"->",
"shouldArchiveAllPeriodsSince",
"=",
"$",
"input",
"->",
"getOption",
"(",
"\"force-all-periods\"",
")",
";",
"$",
"archiver",
"->",
"restrictToDateRange",
"=",
"$",
"input",
"->",
"getOption",
"(",
"\"force-date-range\"",
")",
";",
"$",
"archiver",
"->",
"phpCliConfigurationOptions",
"=",
"$",
"input",
"->",
"getOption",
"(",
"\"php-cli-options\"",
")",
";",
"$",
"restrictToPeriods",
"=",
"$",
"input",
"->",
"getOption",
"(",
"\"force-periods\"",
")",
";",
"$",
"restrictToPeriods",
"=",
"explode",
"(",
"','",
",",
"$",
"restrictToPeriods",
")",
";",
"$",
"archiver",
"->",
"restrictToPeriods",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"restrictToPeriods",
")",
";",
"$",
"archiver",
"->",
"dateLastForced",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'force-date-last-n'",
")",
";",
"$",
"archiver",
"->",
"concurrentRequestsPerWebsite",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'concurrent-requests-per-website'",
")",
";",
"$",
"archiver",
"->",
"maxConcurrentArchivers",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'concurrent-archivers'",
")",
";",
"$",
"archiver",
"->",
"disableSegmentsArchiving",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'skip-all-segments'",
")",
";",
"$",
"segmentIds",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'force-idsegments'",
")",
";",
"$",
"segmentIds",
"=",
"explode",
"(",
"','",
",",
"$",
"segmentIds",
")",
";",
"$",
"segmentIds",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"segmentIds",
")",
";",
"$",
"archiver",
"->",
"setSegmentsToForceFromSegmentIds",
"(",
"$",
"segmentIds",
")",
";",
"$",
"archiver",
"->",
"setUrlToPiwik",
"(",
"$",
"url",
")",
";",
"return",
"$",
"archiver",
";",
"}"
] | also used by another console command | [
"also",
"used",
"by",
"another",
"console",
"command"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreConsole/Commands/CoreArchiver.php#L31-L64 |
209,622 | matomo-org/matomo | core/ViewDataTable/Manager.php | Manager.getIdsWithInheritance | public static function getIdsWithInheritance($klass)
{
$klasses = Common::getClassLineage($klass);
$result = array();
foreach ($klasses as $klass) {
try {
$result[] = $klass::getViewDataTableId();
} catch (\Exception $e) {
// in case $klass did not define an id: eg Plugin\ViewDataTable
continue;
}
}
return $result;
} | php | public static function getIdsWithInheritance($klass)
{
$klasses = Common::getClassLineage($klass);
$result = array();
foreach ($klasses as $klass) {
try {
$result[] = $klass::getViewDataTableId();
} catch (\Exception $e) {
// in case $klass did not define an id: eg Plugin\ViewDataTable
continue;
}
}
return $result;
} | [
"public",
"static",
"function",
"getIdsWithInheritance",
"(",
"$",
"klass",
")",
"{",
"$",
"klasses",
"=",
"Common",
"::",
"getClassLineage",
"(",
"$",
"klass",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"klasses",
"as",
"$",
"klass",
")",
"{",
"try",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"klass",
"::",
"getViewDataTableId",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// in case $klass did not define an id: eg Plugin\\ViewDataTable",
"continue",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the viewDataTable IDs of a visualization's class lineage.
@see self::getVisualizationClassLineage
@param string $klass The visualization class.
@return array | [
"Returns",
"the",
"viewDataTable",
"IDs",
"of",
"a",
"visualization",
"s",
"class",
"lineage",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Manager.php#L40-L55 |
209,623 | matomo-org/matomo | core/ViewDataTable/Manager.php | Manager.getAvailableViewDataTables | public static function getAvailableViewDataTables()
{
$cache = Cache::getTransientCache();
$cacheId = 'ViewDataTable.getAvailableViewDataTables';
$dataTables = $cache->fetch($cacheId);
if (!empty($dataTables)) {
return $dataTables;
}
$klassToExtend = '\\Piwik\\Plugin\\ViewDataTable';
/** @var string[] $visualizations */
$visualizations = PluginManager::getInstance()->findMultipleComponents('Visualizations', $klassToExtend);
$result = array();
foreach ($visualizations as $viz) {
if (!class_exists($viz)) {
throw new \Exception("Invalid visualization class '$viz' found in Visualization.getAvailableVisualizations.");
}
if (!is_subclass_of($viz, $klassToExtend)) {
throw new \Exception("ViewDataTable class '$viz' does not extend Plugin/ViewDataTable");
}
$vizId = $viz::getViewDataTableId();
if (isset($result[$vizId])) {
throw new \Exception("ViewDataTable ID '$vizId' is already in use!");
}
$result[$vizId] = $viz;
}
/**
* Triggered to filter available DataTable visualizations.
*
* Plugins that want to disable certain visualizations should subscribe to
* this event and remove visualizations from the incoming array.
*
* **Example**
*
* public function filterViewDataTable(&$visualizations)
* {
* unset($visualizations[HtmlTable::ID]);
* }
*
* @param array &$visualizations An array of all available visualizations indexed by visualization ID.
* @since Piwik 3.0.0
*/
Piwik::postEvent('ViewDataTable.filterViewDataTable', array(&$result));
$cache->save($cacheId, $result);
return $result;
} | php | public static function getAvailableViewDataTables()
{
$cache = Cache::getTransientCache();
$cacheId = 'ViewDataTable.getAvailableViewDataTables';
$dataTables = $cache->fetch($cacheId);
if (!empty($dataTables)) {
return $dataTables;
}
$klassToExtend = '\\Piwik\\Plugin\\ViewDataTable';
/** @var string[] $visualizations */
$visualizations = PluginManager::getInstance()->findMultipleComponents('Visualizations', $klassToExtend);
$result = array();
foreach ($visualizations as $viz) {
if (!class_exists($viz)) {
throw new \Exception("Invalid visualization class '$viz' found in Visualization.getAvailableVisualizations.");
}
if (!is_subclass_of($viz, $klassToExtend)) {
throw new \Exception("ViewDataTable class '$viz' does not extend Plugin/ViewDataTable");
}
$vizId = $viz::getViewDataTableId();
if (isset($result[$vizId])) {
throw new \Exception("ViewDataTable ID '$vizId' is already in use!");
}
$result[$vizId] = $viz;
}
/**
* Triggered to filter available DataTable visualizations.
*
* Plugins that want to disable certain visualizations should subscribe to
* this event and remove visualizations from the incoming array.
*
* **Example**
*
* public function filterViewDataTable(&$visualizations)
* {
* unset($visualizations[HtmlTable::ID]);
* }
*
* @param array &$visualizations An array of all available visualizations indexed by visualization ID.
* @since Piwik 3.0.0
*/
Piwik::postEvent('ViewDataTable.filterViewDataTable', array(&$result));
$cache->save($cacheId, $result);
return $result;
} | [
"public",
"static",
"function",
"getAvailableViewDataTables",
"(",
")",
"{",
"$",
"cache",
"=",
"Cache",
"::",
"getTransientCache",
"(",
")",
";",
"$",
"cacheId",
"=",
"'ViewDataTable.getAvailableViewDataTables'",
";",
"$",
"dataTables",
"=",
"$",
"cache",
"->",
"fetch",
"(",
"$",
"cacheId",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dataTables",
")",
")",
"{",
"return",
"$",
"dataTables",
";",
"}",
"$",
"klassToExtend",
"=",
"'\\\\Piwik\\\\Plugin\\\\ViewDataTable'",
";",
"/** @var string[] $visualizations */",
"$",
"visualizations",
"=",
"PluginManager",
"::",
"getInstance",
"(",
")",
"->",
"findMultipleComponents",
"(",
"'Visualizations'",
",",
"$",
"klassToExtend",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"visualizations",
"as",
"$",
"viz",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"viz",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid visualization class '$viz' found in Visualization.getAvailableVisualizations.\"",
")",
";",
"}",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"viz",
",",
"$",
"klassToExtend",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"ViewDataTable class '$viz' does not extend Plugin/ViewDataTable\"",
")",
";",
"}",
"$",
"vizId",
"=",
"$",
"viz",
"::",
"getViewDataTableId",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"vizId",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"ViewDataTable ID '$vizId' is already in use!\"",
")",
";",
"}",
"$",
"result",
"[",
"$",
"vizId",
"]",
"=",
"$",
"viz",
";",
"}",
"/**\n * Triggered to filter available DataTable visualizations.\n *\n * Plugins that want to disable certain visualizations should subscribe to\n * this event and remove visualizations from the incoming array.\n *\n * **Example**\n *\n * public function filterViewDataTable(&$visualizations)\n * {\n * unset($visualizations[HtmlTable::ID]);\n * }\n *\n * @param array &$visualizations An array of all available visualizations indexed by visualization ID.\n * @since Piwik 3.0.0\n */",
"Piwik",
"::",
"postEvent",
"(",
"'ViewDataTable.filterViewDataTable'",
",",
"array",
"(",
"&",
"$",
"result",
")",
")",
";",
"$",
"cache",
"->",
"save",
"(",
"$",
"cacheId",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns all registered visualization classes. Uses the 'Visualization.getAvailable'
event to retrieve visualizations.
@return array Array mapping visualization IDs with their associated visualization classes.
@throws \Exception If a visualization class does not exist or if a duplicate visualization ID
is found.
@return array | [
"Returns",
"all",
"registered",
"visualization",
"classes",
".",
"Uses",
"the",
"Visualization",
".",
"getAvailable",
"event",
"to",
"retrieve",
"visualizations",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Manager.php#L66-L122 |
209,624 | matomo-org/matomo | core/ViewDataTable/Manager.php | Manager.getNonCoreViewDataTables | public static function getNonCoreViewDataTables()
{
$result = array();
foreach (static::getAvailableViewDataTables() as $vizId => $vizClass) {
if (false === strpos($vizClass, 'Piwik\\Plugins\\CoreVisualizations')
&& false === strpos($vizClass, 'Piwik\\Plugins\\Goals\\Visualizations\\Goals')) {
$result[$vizId] = $vizClass;
}
}
return $result;
} | php | public static function getNonCoreViewDataTables()
{
$result = array();
foreach (static::getAvailableViewDataTables() as $vizId => $vizClass) {
if (false === strpos($vizClass, 'Piwik\\Plugins\\CoreVisualizations')
&& false === strpos($vizClass, 'Piwik\\Plugins\\Goals\\Visualizations\\Goals')) {
$result[$vizId] = $vizClass;
}
}
return $result;
} | [
"public",
"static",
"function",
"getNonCoreViewDataTables",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"static",
"::",
"getAvailableViewDataTables",
"(",
")",
"as",
"$",
"vizId",
"=>",
"$",
"vizClass",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"vizClass",
",",
"'Piwik\\\\Plugins\\\\CoreVisualizations'",
")",
"&&",
"false",
"===",
"strpos",
"(",
"$",
"vizClass",
",",
"'Piwik\\\\Plugins\\\\Goals\\\\Visualizations\\\\Goals'",
")",
")",
"{",
"$",
"result",
"[",
"$",
"vizId",
"]",
"=",
"$",
"vizClass",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns all available visualizations that are not part of the CoreVisualizations plugin.
@return array Array mapping visualization IDs with their associated visualization classes. | [
"Returns",
"all",
"available",
"visualizations",
"that",
"are",
"not",
"part",
"of",
"the",
"CoreVisualizations",
"plugin",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Manager.php#L129-L141 |
209,625 | matomo-org/matomo | core/ViewDataTable/Manager.php | Manager.configureFooterIcons | public static function configureFooterIcons(ViewDataTable $view)
{
$result = array();
$normalViewIcons = self::getNormalViewIcons($view);
if (!empty($normalViewIcons['buttons'])) {
$result[] = $normalViewIcons;
}
// add insight views
$insightsViewIcons = array(
'class' => 'tableInsightViews',
'buttons' => array(),
);
$graphViewIcons = self::getGraphViewIcons($view);
$nonCoreVisualizations = static::getNonCoreViewDataTables();
foreach ($nonCoreVisualizations as $id => $klass) {
if ($klass::canDisplayViewDataTable($view)) {
$footerIcon = static::getFooterIconFor($id);
if (Insight::ID == $footerIcon['id']) {
$insightsViewIcons['buttons'][] = static::getFooterIconFor($id);
} else {
$graphViewIcons['buttons'][] = static::getFooterIconFor($id);
}
}
}
$graphViewIcons['buttons'] = array_filter($graphViewIcons['buttons']);
if (!empty($insightsViewIcons['buttons'])
&& $view->config->show_insights
) {
$result[] = $insightsViewIcons;
}
if (!empty($graphViewIcons['buttons'])) {
$result[] = $graphViewIcons;
}
return $result;
} | php | public static function configureFooterIcons(ViewDataTable $view)
{
$result = array();
$normalViewIcons = self::getNormalViewIcons($view);
if (!empty($normalViewIcons['buttons'])) {
$result[] = $normalViewIcons;
}
// add insight views
$insightsViewIcons = array(
'class' => 'tableInsightViews',
'buttons' => array(),
);
$graphViewIcons = self::getGraphViewIcons($view);
$nonCoreVisualizations = static::getNonCoreViewDataTables();
foreach ($nonCoreVisualizations as $id => $klass) {
if ($klass::canDisplayViewDataTable($view)) {
$footerIcon = static::getFooterIconFor($id);
if (Insight::ID == $footerIcon['id']) {
$insightsViewIcons['buttons'][] = static::getFooterIconFor($id);
} else {
$graphViewIcons['buttons'][] = static::getFooterIconFor($id);
}
}
}
$graphViewIcons['buttons'] = array_filter($graphViewIcons['buttons']);
if (!empty($insightsViewIcons['buttons'])
&& $view->config->show_insights
) {
$result[] = $insightsViewIcons;
}
if (!empty($graphViewIcons['buttons'])) {
$result[] = $graphViewIcons;
}
return $result;
} | [
"public",
"static",
"function",
"configureFooterIcons",
"(",
"ViewDataTable",
"$",
"view",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"normalViewIcons",
"=",
"self",
"::",
"getNormalViewIcons",
"(",
"$",
"view",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"normalViewIcons",
"[",
"'buttons'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"normalViewIcons",
";",
"}",
"// add insight views",
"$",
"insightsViewIcons",
"=",
"array",
"(",
"'class'",
"=>",
"'tableInsightViews'",
",",
"'buttons'",
"=>",
"array",
"(",
")",
",",
")",
";",
"$",
"graphViewIcons",
"=",
"self",
"::",
"getGraphViewIcons",
"(",
"$",
"view",
")",
";",
"$",
"nonCoreVisualizations",
"=",
"static",
"::",
"getNonCoreViewDataTables",
"(",
")",
";",
"foreach",
"(",
"$",
"nonCoreVisualizations",
"as",
"$",
"id",
"=>",
"$",
"klass",
")",
"{",
"if",
"(",
"$",
"klass",
"::",
"canDisplayViewDataTable",
"(",
"$",
"view",
")",
")",
"{",
"$",
"footerIcon",
"=",
"static",
"::",
"getFooterIconFor",
"(",
"$",
"id",
")",
";",
"if",
"(",
"Insight",
"::",
"ID",
"==",
"$",
"footerIcon",
"[",
"'id'",
"]",
")",
"{",
"$",
"insightsViewIcons",
"[",
"'buttons'",
"]",
"[",
"]",
"=",
"static",
"::",
"getFooterIconFor",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"graphViewIcons",
"[",
"'buttons'",
"]",
"[",
"]",
"=",
"static",
"::",
"getFooterIconFor",
"(",
"$",
"id",
")",
";",
"}",
"}",
"}",
"$",
"graphViewIcons",
"[",
"'buttons'",
"]",
"=",
"array_filter",
"(",
"$",
"graphViewIcons",
"[",
"'buttons'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"insightsViewIcons",
"[",
"'buttons'",
"]",
")",
"&&",
"$",
"view",
"->",
"config",
"->",
"show_insights",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"insightsViewIcons",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"graphViewIcons",
"[",
"'buttons'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"graphViewIcons",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | This method determines the default set of footer icons to display below a report.
$result has the following format:
```
array(
array( // footer icon group 1
'class' => 'footerIconGroup1CssClass',
'buttons' => array(
'id' => 'myid',
'title' => 'My Tooltip',
'icon' => 'path/to/my/icon.png'
)
),
array( // footer icon group 2
'class' => 'footerIconGroup2CssClass',
'buttons' => array(...)
),
...
)
``` | [
"This",
"method",
"determines",
"the",
"default",
"set",
"of",
"footer",
"icons",
"to",
"display",
"below",
"a",
"report",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Manager.php#L166-L210 |
209,626 | matomo-org/matomo | core/ViewDataTable/Manager.php | Manager.getFooterIconFor | private static function getFooterIconFor($viewDataTableId)
{
$tables = static::getAvailableViewDataTables();
if (!array_key_exists($viewDataTableId, $tables)) {
return;
}
$klass = $tables[$viewDataTableId];
return array(
'id' => $klass::getViewDataTableId(),
'title' => Piwik::translate($klass::FOOTER_ICON_TITLE),
'icon' => $klass::FOOTER_ICON,
);
} | php | private static function getFooterIconFor($viewDataTableId)
{
$tables = static::getAvailableViewDataTables();
if (!array_key_exists($viewDataTableId, $tables)) {
return;
}
$klass = $tables[$viewDataTableId];
return array(
'id' => $klass::getViewDataTableId(),
'title' => Piwik::translate($klass::FOOTER_ICON_TITLE),
'icon' => $klass::FOOTER_ICON,
);
} | [
"private",
"static",
"function",
"getFooterIconFor",
"(",
"$",
"viewDataTableId",
")",
"{",
"$",
"tables",
"=",
"static",
"::",
"getAvailableViewDataTables",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"viewDataTableId",
",",
"$",
"tables",
")",
")",
"{",
"return",
";",
"}",
"$",
"klass",
"=",
"$",
"tables",
"[",
"$",
"viewDataTableId",
"]",
";",
"return",
"array",
"(",
"'id'",
"=>",
"$",
"klass",
"::",
"getViewDataTableId",
"(",
")",
",",
"'title'",
"=>",
"Piwik",
"::",
"translate",
"(",
"$",
"klass",
"::",
"FOOTER_ICON_TITLE",
")",
",",
"'icon'",
"=>",
"$",
"klass",
"::",
"FOOTER_ICON",
",",
")",
";",
"}"
] | Returns an array with information necessary for adding the viewDataTable to the footer.
@param string $viewDataTableId
@return array | [
"Returns",
"an",
"array",
"with",
"information",
"necessary",
"for",
"adding",
"the",
"viewDataTable",
"to",
"the",
"footer",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Manager.php#L219-L234 |
209,627 | matomo-org/matomo | plugins/SegmentEditor/SegmentEditor.php | SegmentEditor.getKnownSegmentsToArchiveForSite | public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
{
$model = new Model();
$segmentToAutoArchive = $model->getSegmentsToAutoArchive($idSite);
foreach ($segmentToAutoArchive as $segmentInfo) {
$segments[] = $segmentInfo['definition'];
}
$segments = array_unique($segments);
} | php | public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
{
$model = new Model();
$segmentToAutoArchive = $model->getSegmentsToAutoArchive($idSite);
foreach ($segmentToAutoArchive as $segmentInfo) {
$segments[] = $segmentInfo['definition'];
}
$segments = array_unique($segments);
} | [
"public",
"function",
"getKnownSegmentsToArchiveForSite",
"(",
"&",
"$",
"segments",
",",
"$",
"idSite",
")",
"{",
"$",
"model",
"=",
"new",
"Model",
"(",
")",
";",
"$",
"segmentToAutoArchive",
"=",
"$",
"model",
"->",
"getSegmentsToAutoArchive",
"(",
"$",
"idSite",
")",
";",
"foreach",
"(",
"$",
"segmentToAutoArchive",
"as",
"$",
"segmentInfo",
")",
"{",
"$",
"segments",
"[",
"]",
"=",
"$",
"segmentInfo",
"[",
"'definition'",
"]",
";",
"}",
"$",
"segments",
"=",
"array_unique",
"(",
"$",
"segments",
")",
";",
"}"
] | Adds the pre-processed segments to the list of Segments.
Used by CronArchive, ArchiveProcessor\Rules, etc.
@param $segments
@param $idSite | [
"Adds",
"the",
"pre",
"-",
"processed",
"segments",
"to",
"the",
"list",
"of",
"Segments",
".",
"Used",
"by",
"CronArchive",
"ArchiveProcessor",
"\\",
"Rules",
"etc",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SegmentEditor/SegmentEditor.php#L79-L89 |
209,628 | matomo-org/matomo | plugins/DBStats/Reports/Base.php | Base.setIndividualSummaryFooterMessage | protected function setIndividualSummaryFooterMessage(ViewDataTable $view)
{
$lastGenerated = self::getDateOfLastCachingRun();
if ($lastGenerated !== false) {
$view->config->show_footer_message = Piwik::translate('Mobile_LastUpdated', $lastGenerated);
}
} | php | protected function setIndividualSummaryFooterMessage(ViewDataTable $view)
{
$lastGenerated = self::getDateOfLastCachingRun();
if ($lastGenerated !== false) {
$view->config->show_footer_message = Piwik::translate('Mobile_LastUpdated', $lastGenerated);
}
} | [
"protected",
"function",
"setIndividualSummaryFooterMessage",
"(",
"ViewDataTable",
"$",
"view",
")",
"{",
"$",
"lastGenerated",
"=",
"self",
"::",
"getDateOfLastCachingRun",
"(",
")",
";",
"if",
"(",
"$",
"lastGenerated",
"!==",
"false",
")",
"{",
"$",
"view",
"->",
"config",
"->",
"show_footer_message",
"=",
"Piwik",
"::",
"translate",
"(",
"'Mobile_LastUpdated'",
",",
"$",
"lastGenerated",
")",
";",
"}",
"}"
] | Sets the footer message for the Individual...Summary reports. | [
"Sets",
"the",
"footer",
"message",
"for",
"the",
"Individual",
"...",
"Summary",
"reports",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DBStats/Reports/Base.php#L147-L153 |
209,629 | matomo-org/matomo | core/ProxyHeaders.php | ProxyHeaders.getProtocolInformation | public static function getProtocolInformation()
{
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
return 'SERVER_PORT=443';
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
return 'X-Forwarded-Proto';
}
if (isset($_SERVER['HTTP_X_FORWARDED_SCHEME']) && strtolower($_SERVER['HTTP_X_FORWARDED_SCHEME']) == 'https') {
return 'X-Forwarded-Scheme';
}
if (isset($_SERVER['HTTP_X_URL_SCHEME']) && strtolower($_SERVER['HTTP_X_URL_SCHEME']) == 'https') {
return 'X-Url-Scheme';
}
return null;
} | php | public static function getProtocolInformation()
{
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
return 'SERVER_PORT=443';
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
return 'X-Forwarded-Proto';
}
if (isset($_SERVER['HTTP_X_FORWARDED_SCHEME']) && strtolower($_SERVER['HTTP_X_FORWARDED_SCHEME']) == 'https') {
return 'X-Forwarded-Scheme';
}
if (isset($_SERVER['HTTP_X_URL_SCHEME']) && strtolower($_SERVER['HTTP_X_URL_SCHEME']) == 'https') {
return 'X-Url-Scheme';
}
return null;
} | [
"public",
"static",
"function",
"getProtocolInformation",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
"==",
"443",
")",
"{",
"return",
"'SERVER_PORT=443'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_PROTO'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_PROTO'",
"]",
")",
"==",
"'https'",
")",
"{",
"return",
"'X-Forwarded-Proto'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_SCHEME'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_SCHEME'",
"]",
")",
"==",
"'https'",
")",
"{",
"return",
"'X-Forwarded-Scheme'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_URL_SCHEME'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_URL_SCHEME'",
"]",
")",
"==",
"'https'",
")",
"{",
"return",
"'X-Url-Scheme'",
";",
"}",
"return",
"null",
";",
"}"
] | Get protocol information, with the exception of HTTPS
@return string protocol information | [
"Get",
"protocol",
"information",
"with",
"the",
"exception",
"of",
"HTTPS"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ProxyHeaders.php#L22-L41 |
209,630 | matomo-org/matomo | core/ProxyHeaders.php | ProxyHeaders.getHeaders | private static function getHeaders($recognizedHeaders)
{
$headers = array();
foreach ($recognizedHeaders as $header) {
if (isset($_SERVER[$header])) {
$headers[] = $header;
}
}
return $headers;
} | php | private static function getHeaders($recognizedHeaders)
{
$headers = array();
foreach ($recognizedHeaders as $header) {
if (isset($_SERVER[$header])) {
$headers[] = $header;
}
}
return $headers;
} | [
"private",
"static",
"function",
"getHeaders",
"(",
"$",
"recognizedHeaders",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"recognizedHeaders",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"$",
"header",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"$",
"header",
";",
"}",
"}",
"return",
"$",
"headers",
";",
"}"
] | Get headers present in the HTTP request
@param array $recognizedHeaders
@return array HTTP headers | [
"Get",
"headers",
"present",
"in",
"the",
"HTTP",
"request"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ProxyHeaders.php#L49-L60 |
209,631 | matomo-org/matomo | plugins/Referrers/API.php | API.getReferrerType | public function getReferrerType($idSite, $period, $date, $segment = false, $typeReferrer = false,
$idSubtable = false, $expanded = false)
{
Piwik::checkUserHasViewAccess($idSite);
$this->checkSingleSite($idSite, 'getReferrerType');
// if idSubtable is supplied, interpret idSubtable as referrer type and return correct report
if ($idSubtable !== false) {
$result = false;
switch ($idSubtable) {
case Common::REFERRER_TYPE_SEARCH_ENGINE:
$result = $this->getKeywords($idSite, $period, $date, $segment);
break;
case Common::REFERRER_TYPE_SOCIAL_NETWORK:
$result = $this->getSocials($idSite, $period, $date, $segment);
break;
case Common::REFERRER_TYPE_WEBSITE:
$result = $this->getWebsites($idSite, $period, $date, $segment);
break;
case Common::REFERRER_TYPE_CAMPAIGN:
$result = $this->getCampaigns($idSite, $period, $date, $segment);
break;
default: // invalid idSubtable, return whole report
break;
}
if ($result) {
$result->filter('ColumnCallbackDeleteMetadata', array('segment'));
$result->filter('ColumnCallbackDeleteMetadata', array('segmentValue'));
return $this->removeSubtableIds($result); // this report won't return subtables of individual reports
}
}
// get visits by referrer type
$dataTable = $this->getDataTable(Archiver::REFERRER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
if ($typeReferrer !== false) // filter for a specific referrer type
{
$dataTable->filter('Pattern', array('label', $typeReferrer));
}
// set subtable IDs for each row to the label (which holds the int referrer type)
$dataTable->filter('Piwik\Plugins\Referrers\DataTable\Filter\SetGetReferrerTypeSubtables', array($idSite, $period, $date, $segment, $expanded));
$dataTable->filter('AddSegmentByLabelMapping', array(
'referrerType',
array(
Common::REFERRER_TYPE_DIRECT_ENTRY => 'direct',
Common::REFERRER_TYPE_CAMPAIGN => 'campaign',
Common::REFERRER_TYPE_SEARCH_ENGINE => 'search',
Common::REFERRER_TYPE_SOCIAL_NETWORK => 'social',
Common::REFERRER_TYPE_WEBSITE => 'website',
)
));
// set referrer type column to readable value
$dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getReferrerTypeLabel'));
return $dataTable;
} | php | public function getReferrerType($idSite, $period, $date, $segment = false, $typeReferrer = false,
$idSubtable = false, $expanded = false)
{
Piwik::checkUserHasViewAccess($idSite);
$this->checkSingleSite($idSite, 'getReferrerType');
// if idSubtable is supplied, interpret idSubtable as referrer type and return correct report
if ($idSubtable !== false) {
$result = false;
switch ($idSubtable) {
case Common::REFERRER_TYPE_SEARCH_ENGINE:
$result = $this->getKeywords($idSite, $period, $date, $segment);
break;
case Common::REFERRER_TYPE_SOCIAL_NETWORK:
$result = $this->getSocials($idSite, $period, $date, $segment);
break;
case Common::REFERRER_TYPE_WEBSITE:
$result = $this->getWebsites($idSite, $period, $date, $segment);
break;
case Common::REFERRER_TYPE_CAMPAIGN:
$result = $this->getCampaigns($idSite, $period, $date, $segment);
break;
default: // invalid idSubtable, return whole report
break;
}
if ($result) {
$result->filter('ColumnCallbackDeleteMetadata', array('segment'));
$result->filter('ColumnCallbackDeleteMetadata', array('segmentValue'));
return $this->removeSubtableIds($result); // this report won't return subtables of individual reports
}
}
// get visits by referrer type
$dataTable = $this->getDataTable(Archiver::REFERRER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
if ($typeReferrer !== false) // filter for a specific referrer type
{
$dataTable->filter('Pattern', array('label', $typeReferrer));
}
// set subtable IDs for each row to the label (which holds the int referrer type)
$dataTable->filter('Piwik\Plugins\Referrers\DataTable\Filter\SetGetReferrerTypeSubtables', array($idSite, $period, $date, $segment, $expanded));
$dataTable->filter('AddSegmentByLabelMapping', array(
'referrerType',
array(
Common::REFERRER_TYPE_DIRECT_ENTRY => 'direct',
Common::REFERRER_TYPE_CAMPAIGN => 'campaign',
Common::REFERRER_TYPE_SEARCH_ENGINE => 'search',
Common::REFERRER_TYPE_SOCIAL_NETWORK => 'social',
Common::REFERRER_TYPE_WEBSITE => 'website',
)
));
// set referrer type column to readable value
$dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getReferrerTypeLabel'));
return $dataTable;
} | [
"public",
"function",
"getReferrerType",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"typeReferrer",
"=",
"false",
",",
"$",
"idSubtable",
"=",
"false",
",",
"$",
"expanded",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"$",
"this",
"->",
"checkSingleSite",
"(",
"$",
"idSite",
",",
"'getReferrerType'",
")",
";",
"// if idSubtable is supplied, interpret idSubtable as referrer type and return correct report",
"if",
"(",
"$",
"idSubtable",
"!==",
"false",
")",
"{",
"$",
"result",
"=",
"false",
";",
"switch",
"(",
"$",
"idSubtable",
")",
"{",
"case",
"Common",
"::",
"REFERRER_TYPE_SEARCH_ENGINE",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"getKeywords",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
")",
";",
"break",
";",
"case",
"Common",
"::",
"REFERRER_TYPE_SOCIAL_NETWORK",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"getSocials",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
")",
";",
"break",
";",
"case",
"Common",
"::",
"REFERRER_TYPE_WEBSITE",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"getWebsites",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
")",
";",
"break",
";",
"case",
"Common",
"::",
"REFERRER_TYPE_CAMPAIGN",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"getCampaigns",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
")",
";",
"break",
";",
"default",
":",
"// invalid idSubtable, return whole report",
"break",
";",
"}",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"result",
"->",
"filter",
"(",
"'ColumnCallbackDeleteMetadata'",
",",
"array",
"(",
"'segment'",
")",
")",
";",
"$",
"result",
"->",
"filter",
"(",
"'ColumnCallbackDeleteMetadata'",
",",
"array",
"(",
"'segmentValue'",
")",
")",
";",
"return",
"$",
"this",
"->",
"removeSubtableIds",
"(",
"$",
"result",
")",
";",
"// this report won't return subtables of individual reports",
"}",
"}",
"// get visits by referrer type",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getDataTable",
"(",
"Archiver",
"::",
"REFERRER_TYPE_RECORD_NAME",
",",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
")",
";",
"if",
"(",
"$",
"typeReferrer",
"!==",
"false",
")",
"// filter for a specific referrer type",
"{",
"$",
"dataTable",
"->",
"filter",
"(",
"'Pattern'",
",",
"array",
"(",
"'label'",
",",
"$",
"typeReferrer",
")",
")",
";",
"}",
"// set subtable IDs for each row to the label (which holds the int referrer type)",
"$",
"dataTable",
"->",
"filter",
"(",
"'Piwik\\Plugins\\Referrers\\DataTable\\Filter\\SetGetReferrerTypeSubtables'",
",",
"array",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
",",
"$",
"expanded",
")",
")",
";",
"$",
"dataTable",
"->",
"filter",
"(",
"'AddSegmentByLabelMapping'",
",",
"array",
"(",
"'referrerType'",
",",
"array",
"(",
"Common",
"::",
"REFERRER_TYPE_DIRECT_ENTRY",
"=>",
"'direct'",
",",
"Common",
"::",
"REFERRER_TYPE_CAMPAIGN",
"=>",
"'campaign'",
",",
"Common",
"::",
"REFERRER_TYPE_SEARCH_ENGINE",
"=>",
"'search'",
",",
"Common",
"::",
"REFERRER_TYPE_SOCIAL_NETWORK",
"=>",
"'social'",
",",
"Common",
"::",
"REFERRER_TYPE_WEBSITE",
"=>",
"'website'",
",",
")",
")",
")",
";",
"// set referrer type column to readable value",
"$",
"dataTable",
"->",
"queueFilter",
"(",
"'ColumnCallbackReplace'",
",",
"array",
"(",
"'label'",
",",
"__NAMESPACE__",
".",
"'\\getReferrerTypeLabel'",
")",
")",
";",
"return",
"$",
"dataTable",
";",
"}"
] | Returns a report describing visit information for each possible referrer type. The
result is a datatable whose subtables are the reports for each parent row's referrer type.
The subtable reports are: 'getKeywords' (for search engine referrer type), 'getWebsites',
and 'getCampaigns'.
@param string $idSite The site ID.
@param string $period The period to get data for, either 'day', 'week', 'month', 'year',
or 'range'.
@param string $date The date of the period.
@param bool|string $segment The segment to use.
@param bool|int $typeReferrer (deprecated) If you want to get data only for a specific referrer
type, supply a type for this parameter.
@param bool|int $idSubtable For this report this value is a referrer type ID and not an actual
subtable ID. The result when using this parameter will be the
specific report for the given referrer type.
@param bool $expanded Whether to get report w/ subtables loaded or not.
@return DataTable | [
"Returns",
"a",
"report",
"describing",
"visit",
"information",
"for",
"each",
"possible",
"referrer",
"type",
".",
"The",
"result",
"is",
"a",
"datatable",
"whose",
"subtables",
"are",
"the",
"reports",
"for",
"each",
"parent",
"row",
"s",
"referrer",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L67-L127 |
209,632 | matomo-org/matomo | plugins/Referrers/API.php | API.getAll | public function getAll($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$this->checkSingleSite($idSite, 'getAll');
$dataTable = $this->getReferrerType($idSite, $period, $date, $segment, $typeReferrer = false, $idSubtable = false, $expanded = true);
if ($dataTable instanceof DataTable\Map) {
throw new Exception("Referrers.getAll with multiple sites or dates is not supported (yet).");
}
$dataTable = $dataTable->mergeSubtables($labelColumn = 'referer_type', $useMetadataColumn = true);
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
} | php | public function getAll($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$this->checkSingleSite($idSite, 'getAll');
$dataTable = $this->getReferrerType($idSite, $period, $date, $segment, $typeReferrer = false, $idSubtable = false, $expanded = true);
if ($dataTable instanceof DataTable\Map) {
throw new Exception("Referrers.getAll with multiple sites or dates is not supported (yet).");
}
$dataTable = $dataTable->mergeSubtables($labelColumn = 'referer_type', $useMetadataColumn = true);
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
} | [
"public",
"function",
"getAll",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"$",
"this",
"->",
"checkSingleSite",
"(",
"$",
"idSite",
",",
"'getAll'",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getReferrerType",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
",",
"$",
"typeReferrer",
"=",
"false",
",",
"$",
"idSubtable",
"=",
"false",
",",
"$",
"expanded",
"=",
"true",
")",
";",
"if",
"(",
"$",
"dataTable",
"instanceof",
"DataTable",
"\\",
"Map",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Referrers.getAll with multiple sites or dates is not supported (yet).\"",
")",
";",
"}",
"$",
"dataTable",
"=",
"$",
"dataTable",
"->",
"mergeSubtables",
"(",
"$",
"labelColumn",
"=",
"'referer_type'",
",",
"$",
"useMetadataColumn",
"=",
"true",
")",
";",
"$",
"dataTable",
"->",
"queueFilter",
"(",
"'ReplaceColumnNames'",
")",
";",
"$",
"dataTable",
"->",
"queueFilter",
"(",
"'ReplaceSummaryRowLabel'",
")",
";",
"return",
"$",
"dataTable",
";",
"}"
] | Returns a report that shows | [
"Returns",
"a",
"report",
"that",
"shows"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L141-L157 |
209,633 | matomo-org/matomo | plugins/Referrers/API.php | API.getUrlsForSocial | public function getUrlsForSocial($idSite, $period, $date, $segment = false, $idSubtable = false)
{
Piwik::checkUserHasViewAccess($idSite);
$dataTable = $this->getDataTable(Archiver::SOCIAL_NETWORKS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true, $idSubtable);
if (!$idSubtable) {
$dataTable = $dataTable->mergeSubtables();
}
$dataTable = $this->combineDataTables($dataTable, function() use ($idSite, $period, $date, $segment, $idSubtable) {
$dataTableFiltered = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true);
$socialNetworks = array_values(Social::getInstance()->getDefinitions());
$social = isset($socialNetworks[$idSubtable - 1]) ? $socialNetworks[$idSubtable - 1] : false;
// filter out everything but social network indicated by $idSubtable
$dataTableFiltered->filter(
'ColumnCallbackDeleteRow',
array('label',
function ($url) use ($social) {
return !Social::getInstance()->isSocialUrl($url, $social);
}
)
);
return $dataTableFiltered->mergeSubtables();
});
$dataTable->filter('AddSegmentByLabel', array('referrerUrl'));
$dataTable->filter('Piwik\Plugins\Referrers\DataTable\Filter\UrlsForSocial', array(true));
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
} | php | public function getUrlsForSocial($idSite, $period, $date, $segment = false, $idSubtable = false)
{
Piwik::checkUserHasViewAccess($idSite);
$dataTable = $this->getDataTable(Archiver::SOCIAL_NETWORKS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true, $idSubtable);
if (!$idSubtable) {
$dataTable = $dataTable->mergeSubtables();
}
$dataTable = $this->combineDataTables($dataTable, function() use ($idSite, $period, $date, $segment, $idSubtable) {
$dataTableFiltered = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true);
$socialNetworks = array_values(Social::getInstance()->getDefinitions());
$social = isset($socialNetworks[$idSubtable - 1]) ? $socialNetworks[$idSubtable - 1] : false;
// filter out everything but social network indicated by $idSubtable
$dataTableFiltered->filter(
'ColumnCallbackDeleteRow',
array('label',
function ($url) use ($social) {
return !Social::getInstance()->isSocialUrl($url, $social);
}
)
);
return $dataTableFiltered->mergeSubtables();
});
$dataTable->filter('AddSegmentByLabel', array('referrerUrl'));
$dataTable->filter('Piwik\Plugins\Referrers\DataTable\Filter\UrlsForSocial', array(true));
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
} | [
"public",
"function",
"getUrlsForSocial",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"idSubtable",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getDataTable",
"(",
"Archiver",
"::",
"SOCIAL_NETWORKS_RECORD_NAME",
",",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
",",
"$",
"expanded",
"=",
"true",
",",
"$",
"idSubtable",
")",
";",
"if",
"(",
"!",
"$",
"idSubtable",
")",
"{",
"$",
"dataTable",
"=",
"$",
"dataTable",
"->",
"mergeSubtables",
"(",
")",
";",
"}",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"combineDataTables",
"(",
"$",
"dataTable",
",",
"function",
"(",
")",
"use",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
",",
"$",
"idSubtable",
")",
"{",
"$",
"dataTableFiltered",
"=",
"$",
"this",
"->",
"getDataTable",
"(",
"Archiver",
"::",
"WEBSITES_RECORD_NAME",
",",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
",",
"$",
"expanded",
"=",
"true",
")",
";",
"$",
"socialNetworks",
"=",
"array_values",
"(",
"Social",
"::",
"getInstance",
"(",
")",
"->",
"getDefinitions",
"(",
")",
")",
";",
"$",
"social",
"=",
"isset",
"(",
"$",
"socialNetworks",
"[",
"$",
"idSubtable",
"-",
"1",
"]",
")",
"?",
"$",
"socialNetworks",
"[",
"$",
"idSubtable",
"-",
"1",
"]",
":",
"false",
";",
"// filter out everything but social network indicated by $idSubtable",
"$",
"dataTableFiltered",
"->",
"filter",
"(",
"'ColumnCallbackDeleteRow'",
",",
"array",
"(",
"'label'",
",",
"function",
"(",
"$",
"url",
")",
"use",
"(",
"$",
"social",
")",
"{",
"return",
"!",
"Social",
"::",
"getInstance",
"(",
")",
"->",
"isSocialUrl",
"(",
"$",
"url",
",",
"$",
"social",
")",
";",
"}",
")",
")",
";",
"return",
"$",
"dataTableFiltered",
"->",
"mergeSubtables",
"(",
")",
";",
"}",
")",
";",
"$",
"dataTable",
"->",
"filter",
"(",
"'AddSegmentByLabel'",
",",
"array",
"(",
"'referrerUrl'",
")",
")",
";",
"$",
"dataTable",
"->",
"filter",
"(",
"'Piwik\\Plugins\\Referrers\\DataTable\\Filter\\UrlsForSocial'",
",",
"array",
"(",
"true",
")",
")",
";",
"$",
"dataTable",
"->",
"queueFilter",
"(",
"'ReplaceColumnNames'",
")",
";",
"return",
"$",
"dataTable",
";",
"}"
] | Returns report containing individual referrer URLs for a specific social networking
site.
@param string $idSite
@param string $period
@param string $date
@param bool|string $segment
@param bool|int $idSubtable This ID does not reference a real DataTable record. Instead, it
is the array index of an item in the Socials list file.
The urls are filtered by the social network at this index.
If false, no filtering is done and every social URL is returned.
@return DataTable | [
"Returns",
"report",
"containing",
"individual",
"referrer",
"URLs",
"for",
"a",
"specific",
"social",
"networking",
"site",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L464-L497 |
209,634 | matomo-org/matomo | plugins/Referrers/API.php | API.removeSubtableMetadata | private function removeSubtableMetadata($dataTable)
{
if ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $childTable) {
$this->removeSubtableMetadata($childTable);
}
} else {
foreach ($dataTable->getRows() as $row) {
$row->deleteMetadata('idsubdatatable_in_db');
}
}
} | php | private function removeSubtableMetadata($dataTable)
{
if ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $childTable) {
$this->removeSubtableMetadata($childTable);
}
} else {
foreach ($dataTable->getRows() as $row) {
$row->deleteMetadata('idsubdatatable_in_db');
}
}
} | [
"private",
"function",
"removeSubtableMetadata",
"(",
"$",
"dataTable",
")",
"{",
"if",
"(",
"$",
"dataTable",
"instanceof",
"DataTable",
"\\",
"Map",
")",
"{",
"foreach",
"(",
"$",
"dataTable",
"->",
"getDataTables",
"(",
")",
"as",
"$",
"childTable",
")",
"{",
"$",
"this",
"->",
"removeSubtableMetadata",
"(",
"$",
"childTable",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"dataTable",
"->",
"getRows",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"row",
"->",
"deleteMetadata",
"(",
"'idsubdatatable_in_db'",
")",
";",
"}",
"}",
"}"
] | Removes idsubdatatable_in_db metadata from a DataTable. Used by Social tables since
they use fake subtable IDs.
@param DataTable $dataTable | [
"Removes",
"idsubdatatable_in_db",
"metadata",
"from",
"a",
"DataTable",
".",
"Used",
"by",
"Social",
"tables",
"since",
"they",
"use",
"fake",
"subtable",
"IDs",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L542-L553 |
209,635 | matomo-org/matomo | plugins/Referrers/API.php | API.setSocialIdSubtables | private function setSocialIdSubtables($dataTable)
{
if ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $childTable) {
$this->setSocialIdSubtables($childTable);
}
} else {
foreach ($dataTable->getRows() as $row) {
$socialName = $row->getColumn('label');
$i = 1; // start at one because idSubtable=0 is equivalent to idSubtable=false
foreach (Social::getInstance()->getDefinitions() as $name) {
if ($name == $socialName) {
$row->setNonLoadedSubtableId($i);
break;
}
++$i;
}
}
}
} | php | private function setSocialIdSubtables($dataTable)
{
if ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $childTable) {
$this->setSocialIdSubtables($childTable);
}
} else {
foreach ($dataTable->getRows() as $row) {
$socialName = $row->getColumn('label');
$i = 1; // start at one because idSubtable=0 is equivalent to idSubtable=false
foreach (Social::getInstance()->getDefinitions() as $name) {
if ($name == $socialName) {
$row->setNonLoadedSubtableId($i);
break;
}
++$i;
}
}
}
} | [
"private",
"function",
"setSocialIdSubtables",
"(",
"$",
"dataTable",
")",
"{",
"if",
"(",
"$",
"dataTable",
"instanceof",
"DataTable",
"\\",
"Map",
")",
"{",
"foreach",
"(",
"$",
"dataTable",
"->",
"getDataTables",
"(",
")",
"as",
"$",
"childTable",
")",
"{",
"$",
"this",
"->",
"setSocialIdSubtables",
"(",
"$",
"childTable",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"dataTable",
"->",
"getRows",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"socialName",
"=",
"$",
"row",
"->",
"getColumn",
"(",
"'label'",
")",
";",
"$",
"i",
"=",
"1",
";",
"// start at one because idSubtable=0 is equivalent to idSubtable=false",
"foreach",
"(",
"Social",
"::",
"getInstance",
"(",
")",
"->",
"getDefinitions",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"$",
"socialName",
")",
"{",
"$",
"row",
"->",
"setNonLoadedSubtableId",
"(",
"$",
"i",
")",
";",
"break",
";",
"}",
"++",
"$",
"i",
";",
"}",
"}",
"}",
"}"
] | Sets the subtable IDs for the DataTable returned by getSocial.
The IDs are int indexes into the array in of defined socials.
@param DataTable $dataTable | [
"Sets",
"the",
"subtable",
"IDs",
"for",
"the",
"DataTable",
"returned",
"by",
"getSocial",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L562-L583 |
209,636 | matomo-org/matomo | libs/Zend/Db.php | Zend_Db.factory | public static function factory($adapter, $config = array())
{
if ($config instanceof Zend_Config) {
$config = $config->toArray();
}
/*
* Convert Zend_Config argument to plain string
* adapter name and separate config object.
*/
if ($adapter instanceof Zend_Config) {
if (isset($adapter->params)) {
$config = $adapter->params->toArray();
}
if (isset($adapter->adapter)) {
$adapter = (string) $adapter->adapter;
} else {
$adapter = null;
}
}
/*
* Verify that adapter parameters are in an array.
*/
if (!is_array($config)) {
/**
* @see Zend_Db_Exception
*/
// require_once 'Zend/Db/Exception.php';
throw new Zend_Db_Exception('Adapter parameters must be in an array or a Zend_Config object');
}
/*
* Verify that an adapter name has been specified.
*/
if (!is_string($adapter) || empty($adapter)) {
/**
* @see Zend_Db_Exception
*/
// require_once 'Zend/Db/Exception.php';
throw new Zend_Db_Exception('Adapter name must be specified in a string');
}
/*
* Form full adapter class name
*/
$adapterNamespace = 'Zend_Db_Adapter';
if (isset($config['adapterNamespace'])) {
if ($config['adapterNamespace'] != '') {
$adapterNamespace = $config['adapterNamespace'];
}
unset($config['adapterNamespace']);
}
// Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606
$adapterName = $adapterNamespace . '_';
$adapterName .= str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($adapter))));
/*
* Load the adapter class. This throws an exception
* if the specified class cannot be loaded.
*/
if (!class_exists($adapterName)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($adapterName);
}
/*
* Create an instance of the adapter class.
* Pass the config to the adapter class constructor.
*/
$dbAdapter = new $adapterName($config);
/*
* Verify that the object created is a descendent of the abstract adapter type.
*/
if (! $dbAdapter instanceof Zend_Db_Adapter_Abstract) {
/**
* @see Zend_Db_Exception
*/
// require_once 'Zend/Db/Exception.php';
throw new Zend_Db_Exception("Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract");
}
return $dbAdapter;
} | php | public static function factory($adapter, $config = array())
{
if ($config instanceof Zend_Config) {
$config = $config->toArray();
}
/*
* Convert Zend_Config argument to plain string
* adapter name and separate config object.
*/
if ($adapter instanceof Zend_Config) {
if (isset($adapter->params)) {
$config = $adapter->params->toArray();
}
if (isset($adapter->adapter)) {
$adapter = (string) $adapter->adapter;
} else {
$adapter = null;
}
}
/*
* Verify that adapter parameters are in an array.
*/
if (!is_array($config)) {
/**
* @see Zend_Db_Exception
*/
// require_once 'Zend/Db/Exception.php';
throw new Zend_Db_Exception('Adapter parameters must be in an array or a Zend_Config object');
}
/*
* Verify that an adapter name has been specified.
*/
if (!is_string($adapter) || empty($adapter)) {
/**
* @see Zend_Db_Exception
*/
// require_once 'Zend/Db/Exception.php';
throw new Zend_Db_Exception('Adapter name must be specified in a string');
}
/*
* Form full adapter class name
*/
$adapterNamespace = 'Zend_Db_Adapter';
if (isset($config['adapterNamespace'])) {
if ($config['adapterNamespace'] != '') {
$adapterNamespace = $config['adapterNamespace'];
}
unset($config['adapterNamespace']);
}
// Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606
$adapterName = $adapterNamespace . '_';
$adapterName .= str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($adapter))));
/*
* Load the adapter class. This throws an exception
* if the specified class cannot be loaded.
*/
if (!class_exists($adapterName)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($adapterName);
}
/*
* Create an instance of the adapter class.
* Pass the config to the adapter class constructor.
*/
$dbAdapter = new $adapterName($config);
/*
* Verify that the object created is a descendent of the abstract adapter type.
*/
if (! $dbAdapter instanceof Zend_Db_Adapter_Abstract) {
/**
* @see Zend_Db_Exception
*/
// require_once 'Zend/Db/Exception.php';
throw new Zend_Db_Exception("Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract");
}
return $dbAdapter;
} | [
"public",
"static",
"function",
"factory",
"(",
"$",
"adapter",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"config",
"instanceof",
"Zend_Config",
")",
"{",
"$",
"config",
"=",
"$",
"config",
"->",
"toArray",
"(",
")",
";",
"}",
"/*\n * Convert Zend_Config argument to plain string\n * adapter name and separate config object.\n */",
"if",
"(",
"$",
"adapter",
"instanceof",
"Zend_Config",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"adapter",
"->",
"params",
")",
")",
"{",
"$",
"config",
"=",
"$",
"adapter",
"->",
"params",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"adapter",
"->",
"adapter",
")",
")",
"{",
"$",
"adapter",
"=",
"(",
"string",
")",
"$",
"adapter",
"->",
"adapter",
";",
"}",
"else",
"{",
"$",
"adapter",
"=",
"null",
";",
"}",
"}",
"/*\n * Verify that adapter parameters are in an array.\n */",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"/**\n * @see Zend_Db_Exception\n */",
"// require_once 'Zend/Db/Exception.php';",
"throw",
"new",
"Zend_Db_Exception",
"(",
"'Adapter parameters must be in an array or a Zend_Config object'",
")",
";",
"}",
"/*\n * Verify that an adapter name has been specified.\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"adapter",
")",
"||",
"empty",
"(",
"$",
"adapter",
")",
")",
"{",
"/**\n * @see Zend_Db_Exception\n */",
"// require_once 'Zend/Db/Exception.php';",
"throw",
"new",
"Zend_Db_Exception",
"(",
"'Adapter name must be specified in a string'",
")",
";",
"}",
"/*\n * Form full adapter class name\n */",
"$",
"adapterNamespace",
"=",
"'Zend_Db_Adapter'",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'adapterNamespace'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"config",
"[",
"'adapterNamespace'",
"]",
"!=",
"''",
")",
"{",
"$",
"adapterNamespace",
"=",
"$",
"config",
"[",
"'adapterNamespace'",
"]",
";",
"}",
"unset",
"(",
"$",
"config",
"[",
"'adapterNamespace'",
"]",
")",
";",
"}",
"// Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606",
"$",
"adapterName",
"=",
"$",
"adapterNamespace",
".",
"'_'",
";",
"$",
"adapterName",
".=",
"str_replace",
"(",
"' '",
",",
"'_'",
",",
"ucwords",
"(",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"strtolower",
"(",
"$",
"adapter",
")",
")",
")",
")",
";",
"/*\n * Load the adapter class. This throws an exception\n * if the specified class cannot be loaded.\n */",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"adapterName",
")",
")",
"{",
"// require_once 'Zend/Loader.php';",
"Zend_Loader",
"::",
"loadClass",
"(",
"$",
"adapterName",
")",
";",
"}",
"/*\n * Create an instance of the adapter class.\n * Pass the config to the adapter class constructor.\n */",
"$",
"dbAdapter",
"=",
"new",
"$",
"adapterName",
"(",
"$",
"config",
")",
";",
"/*\n * Verify that the object created is a descendent of the abstract adapter type.\n */",
"if",
"(",
"!",
"$",
"dbAdapter",
"instanceof",
"Zend_Db_Adapter_Abstract",
")",
"{",
"/**\n * @see Zend_Db_Exception\n */",
"// require_once 'Zend/Db/Exception.php';",
"throw",
"new",
"Zend_Db_Exception",
"(",
"\"Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract\"",
")",
";",
"}",
"return",
"$",
"dbAdapter",
";",
"}"
] | Factory for Zend_Db_Adapter_Abstract classes.
First argument may be a string containing the base of the adapter class
name, e.g. 'Mysqli' corresponds to class Zend_Db_Adapter_Mysqli. This
name is currently case-insensitive, but is not ideal to rely on this behavior.
If your class is named 'My_Company_Pdo_Mysql', where 'My_Company' is the namespace
and 'Pdo_Mysql' is the adapter name, it is best to use the name exactly as it
is defined in the class. This will ensure proper use of the factory API.
First argument may alternatively be an object of type Zend_Config.
The adapter class base name is read from the 'adapter' property.
The adapter config parameters are read from the 'params' property.
Second argument is optional and may be an associative array of key-value
pairs. This is used as the argument to the adapter constructor.
If the first argument is of type Zend_Config, it is assumed to contain
all parameters, and the second argument is ignored.
@param mixed $adapter String name of base adapter class, or Zend_Config object.
@param mixed $config OPTIONAL; an array or Zend_Config object with adapter parameters.
@return Zend_Db_Adapter_Abstract
@throws Zend_Db_Exception | [
"Factory",
"for",
"Zend_Db_Adapter_Abstract",
"classes",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db.php#L199-L284 |
209,637 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.getDefinitions | public function getDefinitions()
{
$cache = Cache::getEagerCache();
$cacheId = 'SearchEngine-' . self::OPTION_STORAGE_NAME;
if ($cache->contains($cacheId)) {
$list = $cache->fetch($cacheId);
} else {
$list = $this->loadDefinitions();
$cache->save($cacheId, $list);
}
return $list;
} | php | public function getDefinitions()
{
$cache = Cache::getEagerCache();
$cacheId = 'SearchEngine-' . self::OPTION_STORAGE_NAME;
if ($cache->contains($cacheId)) {
$list = $cache->fetch($cacheId);
} else {
$list = $this->loadDefinitions();
$cache->save($cacheId, $list);
}
return $list;
} | [
"public",
"function",
"getDefinitions",
"(",
")",
"{",
"$",
"cache",
"=",
"Cache",
"::",
"getEagerCache",
"(",
")",
";",
"$",
"cacheId",
"=",
"'SearchEngine-'",
".",
"self",
"::",
"OPTION_STORAGE_NAME",
";",
"if",
"(",
"$",
"cache",
"->",
"contains",
"(",
"$",
"cacheId",
")",
")",
"{",
"$",
"list",
"=",
"$",
"cache",
"->",
"fetch",
"(",
"$",
"cacheId",
")",
";",
"}",
"else",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"loadDefinitions",
"(",
")",
";",
"$",
"cache",
"->",
"save",
"(",
"$",
"cacheId",
",",
"$",
"list",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Returns list of search engines by URL
@return array Array of ( URL => array( searchEngineName, keywordParameter, path, charset ) ) | [
"Returns",
"list",
"of",
"search",
"engines",
"by",
"URL"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L35-L48 |
209,638 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.getNames | public function getNames()
{
$cacheId = 'SearchEngine.getSearchEngineNames';
$cache = Cache::getTransientCache();
$nameToUrl = $cache->fetch($cacheId);
if (empty($nameToUrl)) {
$searchEngines = $this->getDefinitions();
$nameToUrl = array();
foreach ($searchEngines as $url => $info) {
if (!isset($nameToUrl[$info['name']])) {
$nameToUrl[$info['name']] = $url;
}
}
$cache->save($cacheId, $nameToUrl);
}
return $nameToUrl;
} | php | public function getNames()
{
$cacheId = 'SearchEngine.getSearchEngineNames';
$cache = Cache::getTransientCache();
$nameToUrl = $cache->fetch($cacheId);
if (empty($nameToUrl)) {
$searchEngines = $this->getDefinitions();
$nameToUrl = array();
foreach ($searchEngines as $url => $info) {
if (!isset($nameToUrl[$info['name']])) {
$nameToUrl[$info['name']] = $url;
}
}
$cache->save($cacheId, $nameToUrl);
}
return $nameToUrl;
} | [
"public",
"function",
"getNames",
"(",
")",
"{",
"$",
"cacheId",
"=",
"'SearchEngine.getSearchEngineNames'",
";",
"$",
"cache",
"=",
"Cache",
"::",
"getTransientCache",
"(",
")",
";",
"$",
"nameToUrl",
"=",
"$",
"cache",
"->",
"fetch",
"(",
"$",
"cacheId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"nameToUrl",
")",
")",
"{",
"$",
"searchEngines",
"=",
"$",
"this",
"->",
"getDefinitions",
"(",
")",
";",
"$",
"nameToUrl",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"searchEngines",
"as",
"$",
"url",
"=>",
"$",
"info",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"nameToUrl",
"[",
"$",
"info",
"[",
"'name'",
"]",
"]",
")",
")",
"{",
"$",
"nameToUrl",
"[",
"$",
"info",
"[",
"'name'",
"]",
"]",
"=",
"$",
"url",
";",
"}",
"}",
"$",
"cache",
"->",
"save",
"(",
"$",
"cacheId",
",",
"$",
"nameToUrl",
")",
";",
"}",
"return",
"$",
"nameToUrl",
";",
"}"
] | Returns list of search engines by name
@return array Array of ( searchEngineName => URL ) | [
"Returns",
"list",
"of",
"search",
"engines",
"by",
"name"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L133-L152 |
209,639 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.getDefinitionByHost | public function getDefinitionByHost($host)
{
$searchEngines = $this->getDefinitions();
if (!array_key_exists($host, $searchEngines)) {
return array();
}
return $searchEngines[$host];
} | php | public function getDefinitionByHost($host)
{
$searchEngines = $this->getDefinitions();
if (!array_key_exists($host, $searchEngines)) {
return array();
}
return $searchEngines[$host];
} | [
"public",
"function",
"getDefinitionByHost",
"(",
"$",
"host",
")",
"{",
"$",
"searchEngines",
"=",
"$",
"this",
"->",
"getDefinitions",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"host",
",",
"$",
"searchEngines",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"searchEngines",
"[",
"$",
"host",
"]",
";",
"}"
] | Returns definitions for the given search engine host
@param string $host
@return array | [
"Returns",
"definitions",
"for",
"the",
"given",
"search",
"engine",
"host"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L160-L169 |
209,640 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.convertCharset | protected function convertCharset($string, $charsets)
{
if (function_exists('iconv')
&& !empty($charsets)
) {
$charset = $charsets[0];
if (count($charsets) > 1
&& function_exists('mb_detect_encoding')
) {
$charset = mb_detect_encoding($string, $charsets);
if ($charset === false) {
$charset = $charsets[0];
}
}
$newKey = @iconv($charset, 'UTF-8//IGNORE', $string);
if (!empty($newKey)) {
$string = $newKey;
}
}
return $string;
} | php | protected function convertCharset($string, $charsets)
{
if (function_exists('iconv')
&& !empty($charsets)
) {
$charset = $charsets[0];
if (count($charsets) > 1
&& function_exists('mb_detect_encoding')
) {
$charset = mb_detect_encoding($string, $charsets);
if ($charset === false) {
$charset = $charsets[0];
}
}
$newKey = @iconv($charset, 'UTF-8//IGNORE', $string);
if (!empty($newKey)) {
$string = $newKey;
}
}
return $string;
} | [
"protected",
"function",
"convertCharset",
"(",
"$",
"string",
",",
"$",
"charsets",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'iconv'",
")",
"&&",
"!",
"empty",
"(",
"$",
"charsets",
")",
")",
"{",
"$",
"charset",
"=",
"$",
"charsets",
"[",
"0",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"charsets",
")",
">",
"1",
"&&",
"function_exists",
"(",
"'mb_detect_encoding'",
")",
")",
"{",
"$",
"charset",
"=",
"mb_detect_encoding",
"(",
"$",
"string",
",",
"$",
"charsets",
")",
";",
"if",
"(",
"$",
"charset",
"===",
"false",
")",
"{",
"$",
"charset",
"=",
"$",
"charsets",
"[",
"0",
"]",
";",
"}",
"}",
"$",
"newKey",
"=",
"@",
"iconv",
"(",
"$",
"charset",
",",
"'UTF-8//IGNORE'",
",",
"$",
"string",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"newKey",
")",
")",
"{",
"$",
"string",
"=",
"$",
"newKey",
";",
"}",
"}",
"return",
"$",
"string",
";",
"}"
] | Tries to convert the given string from one of the given charsets to UTF-8
@param string $string
@param array $charsets
@return string | [
"Tries",
"to",
"convert",
"the",
"given",
"string",
"from",
"one",
"of",
"the",
"given",
"charsets",
"to",
"UTF",
"-",
"8"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L397-L419 |
209,641 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.getUrlFromName | public function getUrlFromName($name)
{
$searchEngineNames = $this->getNames();
if (isset($searchEngineNames[$name])) {
$url = 'http://' . $searchEngineNames[$name];
} else {
$url = 'URL unknown!';
}
return $url;
} | php | public function getUrlFromName($name)
{
$searchEngineNames = $this->getNames();
if (isset($searchEngineNames[$name])) {
$url = 'http://' . $searchEngineNames[$name];
} else {
$url = 'URL unknown!';
}
return $url;
} | [
"public",
"function",
"getUrlFromName",
"(",
"$",
"name",
")",
"{",
"$",
"searchEngineNames",
"=",
"$",
"this",
"->",
"getNames",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"searchEngineNames",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"url",
"=",
"'http://'",
".",
"$",
"searchEngineNames",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"'URL unknown!'",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Return search engine URL by name
@see core/DataFiles/SearchEnginges.php
@param string $name
@return string URL | [
"Return",
"search",
"engine",
"URL",
"by",
"name"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L429-L438 |
209,642 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.getHostFromUrl | private function getHostFromUrl($url)
{
if (strpos($url, '//')) {
$url = substr($url, strpos($url, '//') + 2);
}
if (($p = strpos($url, '/')) !== false) {
$url = substr($url, 0, $p);
}
return $url;
} | php | private function getHostFromUrl($url)
{
if (strpos($url, '//')) {
$url = substr($url, strpos($url, '//') + 2);
}
if (($p = strpos($url, '/')) !== false) {
$url = substr($url, 0, $p);
}
return $url;
} | [
"private",
"function",
"getHostFromUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"'//'",
")",
")",
"{",
"$",
"url",
"=",
"substr",
"(",
"$",
"url",
",",
"strpos",
"(",
"$",
"url",
",",
"'//'",
")",
"+",
"2",
")",
";",
"}",
"if",
"(",
"(",
"$",
"p",
"=",
"strpos",
"(",
"$",
"url",
",",
"'/'",
")",
")",
"!==",
"false",
")",
"{",
"$",
"url",
"=",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"$",
"p",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Return search engine host in URL
@param string $url
@return string host | [
"Return",
"search",
"engine",
"host",
"in",
"URL"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L446-L455 |
209,643 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.getLogoFromUrl | public function getLogoFromUrl($url)
{
$pathInPiwik = 'plugins/Morpheus/icons/dist/searchEngines/%s.png';
$pathWithCode = sprintf($pathInPiwik, $this->getHostFromUrl($url));
$absolutePath = PIWIK_INCLUDE_PATH . '/' . $pathWithCode;
if (file_exists($absolutePath)) {
return $pathWithCode;
}
return sprintf($pathInPiwik, 'xx');
} | php | public function getLogoFromUrl($url)
{
$pathInPiwik = 'plugins/Morpheus/icons/dist/searchEngines/%s.png';
$pathWithCode = sprintf($pathInPiwik, $this->getHostFromUrl($url));
$absolutePath = PIWIK_INCLUDE_PATH . '/' . $pathWithCode;
if (file_exists($absolutePath)) {
return $pathWithCode;
}
return sprintf($pathInPiwik, 'xx');
} | [
"public",
"function",
"getLogoFromUrl",
"(",
"$",
"url",
")",
"{",
"$",
"pathInPiwik",
"=",
"'plugins/Morpheus/icons/dist/searchEngines/%s.png'",
";",
"$",
"pathWithCode",
"=",
"sprintf",
"(",
"$",
"pathInPiwik",
",",
"$",
"this",
"->",
"getHostFromUrl",
"(",
"$",
"url",
")",
")",
";",
"$",
"absolutePath",
"=",
"PIWIK_INCLUDE_PATH",
".",
"'/'",
".",
"$",
"pathWithCode",
";",
"if",
"(",
"file_exists",
"(",
"$",
"absolutePath",
")",
")",
"{",
"return",
"$",
"pathWithCode",
";",
"}",
"return",
"sprintf",
"(",
"$",
"pathInPiwik",
",",
"'xx'",
")",
";",
"}"
] | Return search engine logo path by URL
@param string $url
@return string path
@see plugins/Morpheus/icons/dist/searchEnginges/ | [
"Return",
"search",
"engine",
"logo",
"path",
"by",
"URL"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L465-L474 |
209,644 | matomo-org/matomo | plugins/Referrers/SearchEngine.php | SearchEngine.getBackLinkFromUrlAndKeyword | public function getBackLinkFromUrlAndKeyword($url, $keyword)
{
if ($keyword === API::LABEL_KEYWORD_NOT_DEFINED) {
return 'https://matomo.org/faq/general/#faq_144';
}
$keyword = urlencode($keyword);
$keyword = str_replace(urlencode('+'), urlencode(' '), $keyword);
$host = substr($url, strpos($url, '//') + 2);
$definition = $this->getDefinitionByHost($host);
if (empty($definition['backlink'])) {
return false;
}
$path = str_replace("{k}", $keyword, $definition['backlink']);
return $url . (substr($url, -1) != '/' ? '/' : '') . $path;
} | php | public function getBackLinkFromUrlAndKeyword($url, $keyword)
{
if ($keyword === API::LABEL_KEYWORD_NOT_DEFINED) {
return 'https://matomo.org/faq/general/#faq_144';
}
$keyword = urlencode($keyword);
$keyword = str_replace(urlencode('+'), urlencode(' '), $keyword);
$host = substr($url, strpos($url, '//') + 2);
$definition = $this->getDefinitionByHost($host);
if (empty($definition['backlink'])) {
return false;
}
$path = str_replace("{k}", $keyword, $definition['backlink']);
return $url . (substr($url, -1) != '/' ? '/' : '') . $path;
} | [
"public",
"function",
"getBackLinkFromUrlAndKeyword",
"(",
"$",
"url",
",",
"$",
"keyword",
")",
"{",
"if",
"(",
"$",
"keyword",
"===",
"API",
"::",
"LABEL_KEYWORD_NOT_DEFINED",
")",
"{",
"return",
"'https://matomo.org/faq/general/#faq_144'",
";",
"}",
"$",
"keyword",
"=",
"urlencode",
"(",
"$",
"keyword",
")",
";",
"$",
"keyword",
"=",
"str_replace",
"(",
"urlencode",
"(",
"'+'",
")",
",",
"urlencode",
"(",
"' '",
")",
",",
"$",
"keyword",
")",
";",
"$",
"host",
"=",
"substr",
"(",
"$",
"url",
",",
"strpos",
"(",
"$",
"url",
",",
"'//'",
")",
"+",
"2",
")",
";",
"$",
"definition",
"=",
"$",
"this",
"->",
"getDefinitionByHost",
"(",
"$",
"host",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"definition",
"[",
"'backlink'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"path",
"=",
"str_replace",
"(",
"\"{k}\"",
",",
"$",
"keyword",
",",
"$",
"definition",
"[",
"'backlink'",
"]",
")",
";",
"return",
"$",
"url",
".",
"(",
"substr",
"(",
"$",
"url",
",",
"-",
"1",
")",
"!=",
"'/'",
"?",
"'/'",
":",
"''",
")",
".",
"$",
"path",
";",
"}"
] | Return search engine URL for URL and keyword
@see core/DataFiles/SearchEnginges.php
@param string $url Domain name, e.g., search.piwik.org
@param string $keyword Keyword, e.g., web+analytics
@return string URL, e.g., http://search.piwik.org/q=web+analytics | [
"Return",
"search",
"engine",
"URL",
"for",
"URL",
"and",
"keyword"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L485-L499 |
209,645 | matomo-org/matomo | libs/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php | Zend_Mail_Protocol_Smtp_Auth_Crammd5._hmacMd5 | protected function _hmacMd5($key, $data, $block = 64)
{
if (strlen($key) > 64) {
$key = pack('H32', md5($key));
} elseif (strlen($key) < 64) {
$key = str_pad($key, $block, "\0");
}
$k_ipad = substr($key, 0, 64) ^ str_repeat(chr(0x36), 64);
$k_opad = substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64);
$inner = pack('H32', md5($k_ipad . $data));
$digest = md5($k_opad . $inner);
return $digest;
} | php | protected function _hmacMd5($key, $data, $block = 64)
{
if (strlen($key) > 64) {
$key = pack('H32', md5($key));
} elseif (strlen($key) < 64) {
$key = str_pad($key, $block, "\0");
}
$k_ipad = substr($key, 0, 64) ^ str_repeat(chr(0x36), 64);
$k_opad = substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64);
$inner = pack('H32', md5($k_ipad . $data));
$digest = md5($k_opad . $inner);
return $digest;
} | [
"protected",
"function",
"_hmacMd5",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"block",
"=",
"64",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"key",
")",
">",
"64",
")",
"{",
"$",
"key",
"=",
"pack",
"(",
"'H32'",
",",
"md5",
"(",
"$",
"key",
")",
")",
";",
"}",
"elseif",
"(",
"strlen",
"(",
"$",
"key",
")",
"<",
"64",
")",
"{",
"$",
"key",
"=",
"str_pad",
"(",
"$",
"key",
",",
"$",
"block",
",",
"\"\\0\"",
")",
";",
"}",
"$",
"k_ipad",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"64",
")",
"^",
"str_repeat",
"(",
"chr",
"(",
"0x36",
")",
",",
"64",
")",
";",
"$",
"k_opad",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"64",
")",
"^",
"str_repeat",
"(",
"chr",
"(",
"0x5C",
")",
",",
"64",
")",
";",
"$",
"inner",
"=",
"pack",
"(",
"'H32'",
",",
"md5",
"(",
"$",
"k_ipad",
".",
"$",
"data",
")",
")",
";",
"$",
"digest",
"=",
"md5",
"(",
"$",
"k_opad",
".",
"$",
"inner",
")",
";",
"return",
"$",
"digest",
";",
"}"
] | Prepare CRAM-MD5 response to server's ticket
@param string $key Challenge key (usually password)
@param string $data Challenge data
@param string $block Length of blocks
@return string | [
"Prepare",
"CRAM",
"-",
"MD5",
"response",
"to",
"server",
"s",
"ticket"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php#L92-L107 |
209,646 | matomo-org/matomo | plugins/Login/Login.php | Login.noAccess | public function noAccess(Exception $exception)
{
$frontController = FrontController::getInstance();
if (Common::isXmlHttpRequest()) {
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'ajaxNoAccess', array($exception->getMessage()));
return;
}
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'login', array($exception->getMessage()));
} | php | public function noAccess(Exception $exception)
{
$frontController = FrontController::getInstance();
if (Common::isXmlHttpRequest()) {
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'ajaxNoAccess', array($exception->getMessage()));
return;
}
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'login', array($exception->getMessage()));
} | [
"public",
"function",
"noAccess",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"frontController",
"=",
"FrontController",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"Common",
"::",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"echo",
"$",
"frontController",
"->",
"dispatch",
"(",
"Piwik",
"::",
"getLoginPluginName",
"(",
")",
",",
"'ajaxNoAccess'",
",",
"array",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"return",
";",
"}",
"echo",
"$",
"frontController",
"->",
"dispatch",
"(",
"Piwik",
"::",
"getLoginPluginName",
"(",
")",
",",
"'login'",
",",
"array",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}"
] | Redirects to Login form with error message.
Listens to User.isNotAuthorized hook. | [
"Redirects",
"to",
"Login",
"form",
"with",
"error",
"message",
".",
"Listens",
"to",
"User",
".",
"isNotAuthorized",
"hook",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/Login.php#L159-L169 |
209,647 | matomo-org/matomo | plugins/Login/Login.php | Login.ApiRequestAuthenticate | public function ApiRequestAuthenticate($tokenAuth)
{
$this->beforeLoginCheckBruteForce();
/** @var \Piwik\Auth $auth */
$auth = StaticContainer::get('Piwik\Auth');
$auth->setLogin($login = null);
$auth->setTokenAuth($tokenAuth);
} | php | public function ApiRequestAuthenticate($tokenAuth)
{
$this->beforeLoginCheckBruteForce();
/** @var \Piwik\Auth $auth */
$auth = StaticContainer::get('Piwik\Auth');
$auth->setLogin($login = null);
$auth->setTokenAuth($tokenAuth);
} | [
"public",
"function",
"ApiRequestAuthenticate",
"(",
"$",
"tokenAuth",
")",
"{",
"$",
"this",
"->",
"beforeLoginCheckBruteForce",
"(",
")",
";",
"/** @var \\Piwik\\Auth $auth */",
"$",
"auth",
"=",
"StaticContainer",
"::",
"get",
"(",
"'Piwik\\Auth'",
")",
";",
"$",
"auth",
"->",
"setLogin",
"(",
"$",
"login",
"=",
"null",
")",
";",
"$",
"auth",
"->",
"setTokenAuth",
"(",
"$",
"tokenAuth",
")",
";",
"}"
] | Set login name and authentication token for API request.
Listens to API.Request.authenticate hook. | [
"Set",
"login",
"name",
"and",
"authentication",
"token",
"for",
"API",
"request",
".",
"Listens",
"to",
"API",
".",
"Request",
".",
"authenticate",
"hook",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/Login.php#L175-L183 |
209,648 | matomo-org/matomo | plugins/SegmentEditor/Model.php | Model.getAllSegmentsAndIgnoreVisibility | public function getAllSegmentsAndIgnoreVisibility()
{
$sql = "SELECT * FROM " . $this->getTable() . " WHERE deleted = 0";
$segments = $this->getDb()->fetchAll($sql);
return $segments;
} | php | public function getAllSegmentsAndIgnoreVisibility()
{
$sql = "SELECT * FROM " . $this->getTable() . " WHERE deleted = 0";
$segments = $this->getDb()->fetchAll($sql);
return $segments;
} | [
"public",
"function",
"getAllSegmentsAndIgnoreVisibility",
"(",
")",
"{",
"$",
"sql",
"=",
"\"SELECT * FROM \"",
".",
"$",
"this",
"->",
"getTable",
"(",
")",
".",
"\" WHERE deleted = 0\"",
";",
"$",
"segments",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"fetchAll",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"segments",
";",
"}"
] | Returns all stored segments that haven't been deleted. Ignores the site the segments are enabled
for and whether to auto archive or not.
@return array | [
"Returns",
"all",
"stored",
"segments",
"that",
"haven",
"t",
"been",
"deleted",
".",
"Ignores",
"the",
"site",
"the",
"segments",
"are",
"enabled",
"for",
"and",
"whether",
"to",
"auto",
"archive",
"or",
"not",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SegmentEditor/Model.php#L33-L40 |
209,649 | matomo-org/matomo | plugins/SegmentEditor/Model.php | Model.getAllSegments | public function getAllSegments($userLogin)
{
$bind = array($userLogin);
$sql = $this->buildQuerySortedByName('deleted = 0 AND (enable_all_users = 1 OR login = ?)');
$segments = $this->getDb()->fetchAll($sql, $bind);
return $segments;
} | php | public function getAllSegments($userLogin)
{
$bind = array($userLogin);
$sql = $this->buildQuerySortedByName('deleted = 0 AND (enable_all_users = 1 OR login = ?)');
$segments = $this->getDb()->fetchAll($sql, $bind);
return $segments;
} | [
"public",
"function",
"getAllSegments",
"(",
"$",
"userLogin",
")",
"{",
"$",
"bind",
"=",
"array",
"(",
"$",
"userLogin",
")",
";",
"$",
"sql",
"=",
"$",
"this",
"->",
"buildQuerySortedByName",
"(",
"'deleted = 0 AND (enable_all_users = 1 OR login = ?)'",
")",
";",
"$",
"segments",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"fetchAll",
"(",
"$",
"sql",
",",
"$",
"bind",
")",
";",
"return",
"$",
"segments",
";",
"}"
] | Returns all stored segments that are available to the given login.
@param string $userLogin
@return array | [
"Returns",
"all",
"stored",
"segments",
"that",
"are",
"available",
"to",
"the",
"given",
"login",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SegmentEditor/Model.php#L73-L81 |
209,650 | matomo-org/matomo | plugins/SegmentEditor/Model.php | Model.getAllSegmentsForSite | public function getAllSegmentsForSite($idSite, $userLogin)
{
$bind = array($idSite, $userLogin);
$sql = $this->buildQuerySortedByName('(enable_only_idsite = ? OR enable_only_idsite = 0)
AND deleted = 0
AND (enable_all_users = 1 OR login = ?)');
$segments = $this->getDb()->fetchAll($sql, $bind);
return $segments;
} | php | public function getAllSegmentsForSite($idSite, $userLogin)
{
$bind = array($idSite, $userLogin);
$sql = $this->buildQuerySortedByName('(enable_only_idsite = ? OR enable_only_idsite = 0)
AND deleted = 0
AND (enable_all_users = 1 OR login = ?)');
$segments = $this->getDb()->fetchAll($sql, $bind);
return $segments;
} | [
"public",
"function",
"getAllSegmentsForSite",
"(",
"$",
"idSite",
",",
"$",
"userLogin",
")",
"{",
"$",
"bind",
"=",
"array",
"(",
"$",
"idSite",
",",
"$",
"userLogin",
")",
";",
"$",
"sql",
"=",
"$",
"this",
"->",
"buildQuerySortedByName",
"(",
"'(enable_only_idsite = ? OR enable_only_idsite = 0)\n AND deleted = 0\n AND (enable_all_users = 1 OR login = ?)'",
")",
";",
"$",
"segments",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"fetchAll",
"(",
"$",
"sql",
",",
"$",
"bind",
")",
";",
"return",
"$",
"segments",
";",
"}"
] | Returns all stored segments that are available for the given site and login.
@param string $userLogin
@param int $idSite Whether to return stored segments for a specific idSite, or all of them. If supplied, must be a valid site ID.
@return array | [
"Returns",
"all",
"stored",
"segments",
"that",
"are",
"available",
"for",
"the",
"given",
"site",
"and",
"login",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SegmentEditor/Model.php#L90-L99 |
209,651 | matomo-org/matomo | plugins/SegmentEditor/Model.php | Model.getAllSegmentsForAllUsers | public function getAllSegmentsForAllUsers($idSite = false)
{
$bind = array();
$sqlWhereCondition = '';
if(!empty($idSite)) {
$bind = array($idSite);
$sqlWhereCondition = '(enable_only_idsite = ? OR enable_only_idsite = 0) AND';
}
$sqlWhereCondition = $this->buildQuerySortedByName($sqlWhereCondition . ' deleted = 0');
$segments = $this->getDb()->fetchAll($sqlWhereCondition, $bind);
return $segments;
} | php | public function getAllSegmentsForAllUsers($idSite = false)
{
$bind = array();
$sqlWhereCondition = '';
if(!empty($idSite)) {
$bind = array($idSite);
$sqlWhereCondition = '(enable_only_idsite = ? OR enable_only_idsite = 0) AND';
}
$sqlWhereCondition = $this->buildQuerySortedByName($sqlWhereCondition . ' deleted = 0');
$segments = $this->getDb()->fetchAll($sqlWhereCondition, $bind);
return $segments;
} | [
"public",
"function",
"getAllSegmentsForAllUsers",
"(",
"$",
"idSite",
"=",
"false",
")",
"{",
"$",
"bind",
"=",
"array",
"(",
")",
";",
"$",
"sqlWhereCondition",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"idSite",
")",
")",
"{",
"$",
"bind",
"=",
"array",
"(",
"$",
"idSite",
")",
";",
"$",
"sqlWhereCondition",
"=",
"'(enable_only_idsite = ? OR enable_only_idsite = 0) AND'",
";",
"}",
"$",
"sqlWhereCondition",
"=",
"$",
"this",
"->",
"buildQuerySortedByName",
"(",
"$",
"sqlWhereCondition",
".",
"' deleted = 0'",
")",
";",
"$",
"segments",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"fetchAll",
"(",
"$",
"sqlWhereCondition",
",",
"$",
"bind",
")",
";",
"return",
"$",
"segments",
";",
"}"
] | This should be used _only_ by Super Users
@param $idSite
@return array | [
"This",
"should",
"be",
"used",
"_only_",
"by",
"Super",
"Users"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SegmentEditor/Model.php#L106-L120 |
209,652 | matomo-org/matomo | plugins/CustomPiwikJs/API.php | API.doesIncludePluginTrackersAutomatically | public function doesIncludePluginTrackersAutomatically()
{
Piwik::checkUserHasSomeAdminAccess();
try {
$updater = StaticContainer::get('Piwik\Plugins\CustomPiwikJs\TrackerUpdater');
$updater->checkWillSucceed();
return true;
} catch (AccessDeniedException $e) {
return false;
} catch (\Exception $e) {
return false;
}
} | php | public function doesIncludePluginTrackersAutomatically()
{
Piwik::checkUserHasSomeAdminAccess();
try {
$updater = StaticContainer::get('Piwik\Plugins\CustomPiwikJs\TrackerUpdater');
$updater->checkWillSucceed();
return true;
} catch (AccessDeniedException $e) {
return false;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"function",
"doesIncludePluginTrackersAutomatically",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeAdminAccess",
"(",
")",
";",
"try",
"{",
"$",
"updater",
"=",
"StaticContainer",
"::",
"get",
"(",
"'Piwik\\Plugins\\CustomPiwikJs\\TrackerUpdater'",
")",
";",
"$",
"updater",
"->",
"checkWillSucceed",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"AccessDeniedException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Detects whether plugin trackers will be automatically added to piwik.js or not. If not, the plugin tracker files
need to be loaded manually.
@return bool | [
"Detects",
"whether",
"plugin",
"trackers",
"will",
"be",
"automatically",
"added",
"to",
"piwik",
".",
"js",
"or",
"not",
".",
"If",
"not",
"the",
"plugin",
"tracker",
"files",
"need",
"to",
"be",
"loaded",
"manually",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CustomPiwikJs/API.php#L27-L40 |
209,653 | matomo-org/matomo | core/Piwik.php | Piwik.exitWithErrorMessage | public static function exitWithErrorMessage($message)
{
Common::sendHeader('Content-Type: text/html; charset=utf-8');
$message = str_replace("\n", "<br/>", $message);
$output = "<html><body>".
"<style>a{color:red;}</style>\n" .
"<div style='color:red;font-size:120%; width:100%;margin: 30px;'>" .
" <div style='width: 50px; float: left;'><img src='plugins/Morpheus/images/error_medium.png' /></div>" .
" <div style='margin-left: 70px; min-width: 950px;'>" .
$message .
" </div>" .
" </div>" .
"</div>".
"</body></html>";
print($output);
exit;
} | php | public static function exitWithErrorMessage($message)
{
Common::sendHeader('Content-Type: text/html; charset=utf-8');
$message = str_replace("\n", "<br/>", $message);
$output = "<html><body>".
"<style>a{color:red;}</style>\n" .
"<div style='color:red;font-size:120%; width:100%;margin: 30px;'>" .
" <div style='width: 50px; float: left;'><img src='plugins/Morpheus/images/error_medium.png' /></div>" .
" <div style='margin-left: 70px; min-width: 950px;'>" .
$message .
" </div>" .
" </div>" .
"</div>".
"</body></html>";
print($output);
exit;
} | [
"public",
"static",
"function",
"exitWithErrorMessage",
"(",
"$",
"message",
")",
"{",
"Common",
"::",
"sendHeader",
"(",
"'Content-Type: text/html; charset=utf-8'",
")",
";",
"$",
"message",
"=",
"str_replace",
"(",
"\"\\n\"",
",",
"\"<br/>\"",
",",
"$",
"message",
")",
";",
"$",
"output",
"=",
"\"<html><body>\"",
".",
"\"<style>a{color:red;}</style>\\n\"",
".",
"\"<div style='color:red;font-size:120%; width:100%;margin: 30px;'>\"",
".",
"\" <div style='width: 50px; float: left;'><img src='plugins/Morpheus/images/error_medium.png' /></div>\"",
".",
"\" <div style='margin-left: 70px; min-width: 950px;'>\"",
".",
"$",
"message",
".",
"\" </div>\"",
".",
"\" </div>\"",
".",
"\"</div>\"",
".",
"\"</body></html>\"",
";",
"print",
"(",
"$",
"output",
")",
";",
"exit",
";",
"}"
] | Display the message in a nice red font with a nice icon
... and dies
@param string $message | [
"Display",
"the",
"message",
"in",
"a",
"nice",
"red",
"font",
"with",
"a",
"nice",
"icon",
"...",
"and",
"dies"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L76-L94 |
209,654 | matomo-org/matomo | core/Piwik.php | Piwik.secureDiv | public static function secureDiv($i1, $i2)
{
if (is_numeric($i1) && is_numeric($i2) && floatval($i2) != 0) {
return $i1 / $i2;
}
return 0;
} | php | public static function secureDiv($i1, $i2)
{
if (is_numeric($i1) && is_numeric($i2) && floatval($i2) != 0) {
return $i1 / $i2;
}
return 0;
} | [
"public",
"static",
"function",
"secureDiv",
"(",
"$",
"i1",
",",
"$",
"i2",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"i1",
")",
"&&",
"is_numeric",
"(",
"$",
"i2",
")",
"&&",
"floatval",
"(",
"$",
"i2",
")",
"!=",
"0",
")",
"{",
"return",
"$",
"i1",
"/",
"$",
"i2",
";",
"}",
"return",
"0",
";",
"}"
] | Computes the division of i1 by i2. If either i1 or i2 are not number, or if i2 has a value of zero
we return 0 to avoid the division by zero.
@param number $i1
@param number $i2
@return number The result of the division or zero | [
"Computes",
"the",
"division",
"of",
"i1",
"by",
"i2",
".",
"If",
"either",
"i1",
"or",
"i2",
"are",
"not",
"number",
"or",
"if",
"i2",
"has",
"a",
"value",
"of",
"zero",
"we",
"return",
"0",
"to",
"avoid",
"the",
"division",
"by",
"zero",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L104-L110 |
209,655 | matomo-org/matomo | core/Piwik.php | Piwik.getRandomTitle | public static function getRandomTitle()
{
static $titles = array(
'Web analytics',
'Open analytics platform',
'Real Time Web Analytics',
'Analytics',
'Real Time Analytics',
'Analytics in Real time',
'Analytics Platform',
'Data Platform',
);
$id = abs(intval(md5(Url::getCurrentHost())));
$title = $titles[$id % count($titles)];
return $title;
} | php | public static function getRandomTitle()
{
static $titles = array(
'Web analytics',
'Open analytics platform',
'Real Time Web Analytics',
'Analytics',
'Real Time Analytics',
'Analytics in Real time',
'Analytics Platform',
'Data Platform',
);
$id = abs(intval(md5(Url::getCurrentHost())));
$title = $titles[$id % count($titles)];
return $title;
} | [
"public",
"static",
"function",
"getRandomTitle",
"(",
")",
"{",
"static",
"$",
"titles",
"=",
"array",
"(",
"'Web analytics'",
",",
"'Open analytics platform'",
",",
"'Real Time Web Analytics'",
",",
"'Analytics'",
",",
"'Real Time Analytics'",
",",
"'Analytics in Real time'",
",",
"'Analytics Platform'",
",",
"'Data Platform'",
",",
")",
";",
"$",
"id",
"=",
"abs",
"(",
"intval",
"(",
"md5",
"(",
"Url",
"::",
"getCurrentHost",
"(",
")",
")",
")",
")",
";",
"$",
"title",
"=",
"$",
"titles",
"[",
"$",
"id",
"%",
"count",
"(",
"$",
"titles",
")",
"]",
";",
"return",
"$",
"title",
";",
"}"
] | Generate a title for image tags
@return string | [
"Generate",
"a",
"title",
"for",
"image",
"tags"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L146-L161 |
209,656 | matomo-org/matomo | core/Piwik.php | Piwik.getAllSuperUserAccessEmailAddresses | public static function getAllSuperUserAccessEmailAddresses()
{
$emails = array();
try {
$superUsers = APIUsersManager::getInstance()->getUsersHavingSuperUserAccess();
} catch (\Exception $e) {
return $emails;
}
foreach ($superUsers as $superUser) {
$emails[$superUser['login']] = $superUser['email'];
}
return $emails;
} | php | public static function getAllSuperUserAccessEmailAddresses()
{
$emails = array();
try {
$superUsers = APIUsersManager::getInstance()->getUsersHavingSuperUserAccess();
} catch (\Exception $e) {
return $emails;
}
foreach ($superUsers as $superUser) {
$emails[$superUser['login']] = $superUser['email'];
}
return $emails;
} | [
"public",
"static",
"function",
"getAllSuperUserAccessEmailAddresses",
"(",
")",
"{",
"$",
"emails",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"superUsers",
"=",
"APIUsersManager",
"::",
"getInstance",
"(",
")",
"->",
"getUsersHavingSuperUserAccess",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"emails",
";",
"}",
"foreach",
"(",
"$",
"superUsers",
"as",
"$",
"superUser",
")",
"{",
"$",
"emails",
"[",
"$",
"superUser",
"[",
"'login'",
"]",
"]",
"=",
"$",
"superUser",
"[",
"'email'",
"]",
";",
"}",
"return",
"$",
"emails",
";",
"}"
] | Get a list of all email addresses having Super User access.
@return array | [
"Get",
"a",
"list",
"of",
"all",
"email",
"addresses",
"having",
"Super",
"User",
"access",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L184-L199 |
209,657 | matomo-org/matomo | core/Piwik.php | Piwik.checkUserHasSuperUserAccessOrIsTheUser | public static function checkUserHasSuperUserAccessOrIsTheUser($theUser)
{
try {
if (Piwik::getCurrentUserLogin() !== $theUser) {
// or to the Super User
Piwik::checkUserHasSuperUserAccess();
}
} catch (NoAccessException $e) {
throw new NoAccessException(Piwik::translate('General_ExceptionCheckUserHasSuperUserAccessOrIsTheUser', array($theUser)));
}
} | php | public static function checkUserHasSuperUserAccessOrIsTheUser($theUser)
{
try {
if (Piwik::getCurrentUserLogin() !== $theUser) {
// or to the Super User
Piwik::checkUserHasSuperUserAccess();
}
} catch (NoAccessException $e) {
throw new NoAccessException(Piwik::translate('General_ExceptionCheckUserHasSuperUserAccessOrIsTheUser', array($theUser)));
}
} | [
"public",
"static",
"function",
"checkUserHasSuperUserAccessOrIsTheUser",
"(",
"$",
"theUser",
")",
"{",
"try",
"{",
"if",
"(",
"Piwik",
"::",
"getCurrentUserLogin",
"(",
")",
"!==",
"$",
"theUser",
")",
"{",
"// or to the Super User",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"NoAccessException",
"$",
"e",
")",
"{",
"throw",
"new",
"NoAccessException",
"(",
"Piwik",
"::",
"translate",
"(",
"'General_ExceptionCheckUserHasSuperUserAccessOrIsTheUser'",
",",
"array",
"(",
"$",
"theUser",
")",
")",
")",
";",
"}",
"}"
] | Check that the current user is either the specified user or the superuser.
@param string $theUser A username.
@throws NoAccessException If the user is neither the Super User nor the user `$theUser`.
@api | [
"Check",
"that",
"the",
"current",
"user",
"is",
"either",
"the",
"specified",
"user",
"or",
"the",
"superuser",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L253-L263 |
209,658 | matomo-org/matomo | core/Piwik.php | Piwik.hasTheUserSuperUserAccess | public static function hasTheUserSuperUserAccess($theUser)
{
if (empty($theUser)) {
return false;
}
if (Piwik::getCurrentUserLogin() === $theUser && Piwik::hasUserSuperUserAccess()) {
return true;
}
try {
$superUsers = APIUsersManager::getInstance()->getUsersHavingSuperUserAccess();
} catch (\Exception $e) {
return false;
}
foreach ($superUsers as $superUser) {
if ($theUser === $superUser['login']) {
return true;
}
}
return false;
} | php | public static function hasTheUserSuperUserAccess($theUser)
{
if (empty($theUser)) {
return false;
}
if (Piwik::getCurrentUserLogin() === $theUser && Piwik::hasUserSuperUserAccess()) {
return true;
}
try {
$superUsers = APIUsersManager::getInstance()->getUsersHavingSuperUserAccess();
} catch (\Exception $e) {
return false;
}
foreach ($superUsers as $superUser) {
if ($theUser === $superUser['login']) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"hasTheUserSuperUserAccess",
"(",
"$",
"theUser",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"theUser",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Piwik",
"::",
"getCurrentUserLogin",
"(",
")",
"===",
"$",
"theUser",
"&&",
"Piwik",
"::",
"hasUserSuperUserAccess",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"$",
"superUsers",
"=",
"APIUsersManager",
"::",
"getInstance",
"(",
")",
"->",
"getUsersHavingSuperUserAccess",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"superUsers",
"as",
"$",
"superUser",
")",
"{",
"if",
"(",
"$",
"theUser",
"===",
"$",
"superUser",
"[",
"'login'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check whether the given user has superuser access.
@param string $theUser A username.
@return bool
@api | [
"Check",
"whether",
"the",
"given",
"user",
"has",
"superuser",
"access",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L272-L295 |
209,659 | matomo-org/matomo | core/Piwik.php | Piwik.isUserHasCapability | public static function isUserHasCapability($idSites, $capability)
{
try {
self::checkUserHasCapability($idSites, $capability);
return true;
} catch (Exception $e) {
return false;
}
} | php | public static function isUserHasCapability($idSites, $capability)
{
try {
self::checkUserHasCapability($idSites, $capability);
return true;
} catch (Exception $e) {
return false;
}
} | [
"public",
"static",
"function",
"isUserHasCapability",
"(",
"$",
"idSites",
",",
"$",
"capability",
")",
"{",
"try",
"{",
"self",
"::",
"checkUserHasCapability",
"(",
"$",
"idSites",
",",
"$",
"capability",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Returns `true` if the current user has the given capability for the given sites.
@return bool
@api | [
"Returns",
"true",
"if",
"the",
"current",
"user",
"has",
"the",
"given",
"capability",
"for",
"the",
"given",
"sites",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L447-L455 |
209,660 | matomo-org/matomo | core/Piwik.php | Piwik.redirectToModule | public static function redirectToModule($newModule, $newAction = '', $parameters = array())
{
$newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
Url::redirectToUrl($newUrl);
} | php | public static function redirectToModule($newModule, $newAction = '', $parameters = array())
{
$newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
Url::redirectToUrl($newUrl);
} | [
"public",
"static",
"function",
"redirectToModule",
"(",
"$",
"newModule",
",",
"$",
"newAction",
"=",
"''",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"newUrl",
"=",
"'index.php'",
".",
"Url",
"::",
"getCurrentQueryStringWithParametersModified",
"(",
"array",
"(",
"'module'",
"=>",
"$",
"newModule",
",",
"'action'",
"=>",
"$",
"newAction",
")",
"+",
"$",
"parameters",
")",
";",
"Url",
"::",
"redirectToUrl",
"(",
"$",
"newUrl",
")",
";",
"}"
] | Redirects the current request to a new module and action.
@param string $newModule The target module, eg, `'UserCountry'`.
@param string $newAction The target controller action, eg, `'index'`.
@param array $parameters The query parameter values to modify before redirecting.
@api | [
"Redirects",
"the",
"current",
"request",
"to",
"a",
"new",
"module",
"and",
"action",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L630-L637 |
209,661 | matomo-org/matomo | core/Piwik.php | Piwik.checkObjectTypeIs | public static function checkObjectTypeIs($o, $types)
{
foreach ($types as $type) {
if ($o instanceof $type) {
return;
}
}
$oType = is_object($o) ? get_class($o) : gettype($o);
throw new Exception("Invalid variable type '$oType', expected one of following: " . implode(', ', $types));
} | php | public static function checkObjectTypeIs($o, $types)
{
foreach ($types as $type) {
if ($o instanceof $type) {
return;
}
}
$oType = is_object($o) ? get_class($o) : gettype($o);
throw new Exception("Invalid variable type '$oType', expected one of following: " . implode(', ', $types));
} | [
"public",
"static",
"function",
"checkObjectTypeIs",
"(",
"$",
"o",
",",
"$",
"types",
")",
"{",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"o",
"instanceof",
"$",
"type",
")",
"{",
"return",
";",
"}",
"}",
"$",
"oType",
"=",
"is_object",
"(",
"$",
"o",
")",
"?",
"get_class",
"(",
"$",
"o",
")",
":",
"gettype",
"(",
"$",
"o",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"Invalid variable type '$oType', expected one of following: \"",
".",
"implode",
"(",
"', '",
",",
"$",
"types",
")",
")",
";",
"}"
] | Utility function that checks if an object type is in a set of types.
@param mixed $o
@param array $types List of class names that $o is expected to be one of.
@throws Exception if $o is not an instance of the types contained in $types. | [
"Utility",
"function",
"that",
"checks",
"if",
"an",
"object",
"type",
"is",
"in",
"a",
"set",
"of",
"types",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L691-L701 |
209,662 | matomo-org/matomo | core/Piwik.php | Piwik.isAssociativeArray | public static function isAssociativeArray($array)
{
reset($array);
if (!is_numeric(key($array))
|| key($array) != 0
) {
// first key must be 0
return true;
}
// check that each key is == next key - 1 w/o actually indexing the array
while (true) {
$current = key($array);
next($array);
$next = key($array);
if ($next === null) {
break;
} elseif ($current + 1 != $next) {
return true;
}
}
return false;
} | php | public static function isAssociativeArray($array)
{
reset($array);
if (!is_numeric(key($array))
|| key($array) != 0
) {
// first key must be 0
return true;
}
// check that each key is == next key - 1 w/o actually indexing the array
while (true) {
$current = key($array);
next($array);
$next = key($array);
if ($next === null) {
break;
} elseif ($current + 1 != $next) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"isAssociativeArray",
"(",
"$",
"array",
")",
"{",
"reset",
"(",
"$",
"array",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"key",
"(",
"$",
"array",
")",
")",
"||",
"key",
"(",
"$",
"array",
")",
"!=",
"0",
")",
"{",
"// first key must be 0",
"return",
"true",
";",
"}",
"// check that each key is == next key - 1 w/o actually indexing the array",
"while",
"(",
"true",
")",
"{",
"$",
"current",
"=",
"key",
"(",
"$",
"array",
")",
";",
"next",
"(",
"$",
"array",
")",
";",
"$",
"next",
"=",
"key",
"(",
"$",
"array",
")",
";",
"if",
"(",
"$",
"next",
"===",
"null",
")",
"{",
"break",
";",
"}",
"elseif",
"(",
"$",
"current",
"+",
"1",
"!=",
"$",
"next",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if an array is an associative array, false if otherwise.
This method determines if an array is associative by checking that the
first element's key is 0, and that each successive element's key is
one greater than the last.
@param array $array
@return bool | [
"Returns",
"true",
"if",
"an",
"array",
"is",
"an",
"associative",
"array",
"false",
"if",
"otherwise",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L713-L739 |
209,663 | matomo-org/matomo | core/Piwik.php | Piwik.getUnnamespacedClassName | public static function getUnnamespacedClassName($object)
{
$className = is_string($object) ? $object : get_class($object);
$parts = explode('\\', $className);
return end($parts);
} | php | public static function getUnnamespacedClassName($object)
{
$className = is_string($object) ? $object : get_class($object);
$parts = explode('\\', $className);
return end($parts);
} | [
"public",
"static",
"function",
"getUnnamespacedClassName",
"(",
"$",
"object",
")",
"{",
"$",
"className",
"=",
"is_string",
"(",
"$",
"object",
")",
"?",
"$",
"object",
":",
"get_class",
"(",
"$",
"object",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"className",
")",
";",
"return",
"end",
"(",
"$",
"parts",
")",
";",
"}"
] | Returns the class name of an object without its namespace.
@param mixed|string $object
@return string | [
"Returns",
"the",
"class",
"name",
"of",
"an",
"object",
"without",
"its",
"namespace",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L760-L765 |
209,664 | matomo-org/matomo | core/Piwik.php | Piwik.postEvent | public static function postEvent($eventName, $params = array(), $pending = false, $plugins = null)
{
EventDispatcher::getInstance()->postEvent($eventName, $params, $pending, $plugins);
} | php | public static function postEvent($eventName, $params = array(), $pending = false, $plugins = null)
{
EventDispatcher::getInstance()->postEvent($eventName, $params, $pending, $plugins);
} | [
"public",
"static",
"function",
"postEvent",
"(",
"$",
"eventName",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"pending",
"=",
"false",
",",
"$",
"plugins",
"=",
"null",
")",
"{",
"EventDispatcher",
"::",
"getInstance",
"(",
")",
"->",
"postEvent",
"(",
"$",
"eventName",
",",
"$",
"params",
",",
"$",
"pending",
",",
"$",
"plugins",
")",
";",
"}"
] | Post an event to Piwik's event dispatcher which will execute the event's observers.
@param string $eventName The event name.
@param array $params The parameter array to forward to observer callbacks.
@param bool $pending If true, plugins that are loaded after this event is fired will
have their observers for this event executed.
@param array|null $plugins The list of plugins to execute observers for. If null, all
plugin observers will be executed.
@api | [
"Post",
"an",
"event",
"to",
"Piwik",
"s",
"event",
"dispatcher",
"which",
"will",
"execute",
"the",
"event",
"s",
"observers",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L778-L781 |
209,665 | matomo-org/matomo | core/Piwik.php | Piwik.translate | public static function translate($translationId, $args = array(), $language = null)
{
/** @var Translator $translator */
$translator = StaticContainer::get('Piwik\Translation\Translator');
return $translator->translate($translationId, $args, $language);
} | php | public static function translate($translationId, $args = array(), $language = null)
{
/** @var Translator $translator */
$translator = StaticContainer::get('Piwik\Translation\Translator');
return $translator->translate($translationId, $args, $language);
} | [
"public",
"static",
"function",
"translate",
"(",
"$",
"translationId",
",",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"language",
"=",
"null",
")",
"{",
"/** @var Translator $translator */",
"$",
"translator",
"=",
"StaticContainer",
"::",
"get",
"(",
"'Piwik\\Translation\\Translator'",
")",
";",
"return",
"$",
"translator",
"->",
"translate",
"(",
"$",
"translationId",
",",
"$",
"args",
",",
"$",
"language",
")",
";",
"}"
] | Returns an internationalized string using a translation token. If a translation
cannot be found for the token, the token is returned.
@param string $translationId Translation ID, eg, `'General_Date'`.
@param array|string|int $args `sprintf` arguments to be applied to the internationalized
string.
@param string|null $language Optionally force the language.
@return string The translated string or `$translationId`.
@api | [
"Returns",
"an",
"internationalized",
"string",
"using",
"a",
"translation",
"token",
".",
"If",
"a",
"translation",
"cannot",
"be",
"found",
"for",
"the",
"token",
"the",
"token",
"is",
"returned",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L820-L826 |
209,666 | matomo-org/matomo | core/Tracker/VisitExcluded.php | VisitExcluded.isExcluded | public function isExcluded()
{
$excluded = false;
if ($this->isNonHumanBot()) {
Common::printDebug('Search bot detected, visit excluded');
$excluded = true;
}
/*
* Requests built with piwik.js will contain a rec=1 parameter. This is used as
* an indication that the request is made by a JS enabled device. By default, Piwik
* doesn't track non-JS visitors.
*/
if (!$excluded) {
$toRecord = $this->request->getParam($parameterForceRecord = 'rec');
if (!$toRecord) {
Common::printDebug(@$_SERVER['REQUEST_METHOD'] . ' parameter ' . $parameterForceRecord . ' not found in URL, request excluded');
$excluded = true;
Common::printDebug("'$parameterForceRecord' parameter not found.");
}
}
/**
* Triggered on every tracking request.
*
* This event can be used to tell the Tracker not to record this particular action or visit.
*
* @param bool &$excluded Whether the request should be excluded or not. Initialized
* to `false`. Event subscribers should set it to `true` in
* order to exclude the request.
* @param Request $request The request object which contains all of the request's information
*
*/
Piwik::postEvent('Tracker.isExcludedVisit', array(&$excluded, $this->request));
/*
* Following exclude operations happen after the hook.
* These are of higher priority and should not be overwritten by plugins.
*/
// Checking if the Piwik ignore cookie is set
if (!$excluded) {
$excluded = $this->isIgnoreCookieFound();
if ($excluded) {
Common::printDebug("Ignore cookie found.");
}
}
// Checking for excluded IPs
if (!$excluded) {
$excluded = $this->isVisitorIpExcluded();
if ($excluded) {
Common::printDebug("IP excluded.");
}
}
// Check if user agent should be excluded
if (!$excluded) {
$excluded = $this->isUserAgentExcluded();
if ($excluded) {
Common::printDebug("User agent excluded.");
}
}
// Check if Referrer URL is a known spam
if (!$excluded) {
$excluded = $this->isReferrerSpamExcluded();
if ($excluded) {
Common::printDebug("Referrer URL is blacklisted as spam.");
}
}
// Check if request URL is excluded
if (!$excluded) {
$excluded = $this->isUrlExcluded();
if ($excluded) {
Common::printDebug("Unknown URL is not allowed to track.");
}
}
if (!$excluded) {
if ($this->isPrefetchDetected()) {
$excluded = true;
Common::printDebug("Prefetch request detected, not a real visit so we Ignore this visit/pageview");
}
}
if ($excluded) {
Common::printDebug("Visitor excluded.");
return true;
}
return false;
} | php | public function isExcluded()
{
$excluded = false;
if ($this->isNonHumanBot()) {
Common::printDebug('Search bot detected, visit excluded');
$excluded = true;
}
/*
* Requests built with piwik.js will contain a rec=1 parameter. This is used as
* an indication that the request is made by a JS enabled device. By default, Piwik
* doesn't track non-JS visitors.
*/
if (!$excluded) {
$toRecord = $this->request->getParam($parameterForceRecord = 'rec');
if (!$toRecord) {
Common::printDebug(@$_SERVER['REQUEST_METHOD'] . ' parameter ' . $parameterForceRecord . ' not found in URL, request excluded');
$excluded = true;
Common::printDebug("'$parameterForceRecord' parameter not found.");
}
}
/**
* Triggered on every tracking request.
*
* This event can be used to tell the Tracker not to record this particular action or visit.
*
* @param bool &$excluded Whether the request should be excluded or not. Initialized
* to `false`. Event subscribers should set it to `true` in
* order to exclude the request.
* @param Request $request The request object which contains all of the request's information
*
*/
Piwik::postEvent('Tracker.isExcludedVisit', array(&$excluded, $this->request));
/*
* Following exclude operations happen after the hook.
* These are of higher priority and should not be overwritten by plugins.
*/
// Checking if the Piwik ignore cookie is set
if (!$excluded) {
$excluded = $this->isIgnoreCookieFound();
if ($excluded) {
Common::printDebug("Ignore cookie found.");
}
}
// Checking for excluded IPs
if (!$excluded) {
$excluded = $this->isVisitorIpExcluded();
if ($excluded) {
Common::printDebug("IP excluded.");
}
}
// Check if user agent should be excluded
if (!$excluded) {
$excluded = $this->isUserAgentExcluded();
if ($excluded) {
Common::printDebug("User agent excluded.");
}
}
// Check if Referrer URL is a known spam
if (!$excluded) {
$excluded = $this->isReferrerSpamExcluded();
if ($excluded) {
Common::printDebug("Referrer URL is blacklisted as spam.");
}
}
// Check if request URL is excluded
if (!$excluded) {
$excluded = $this->isUrlExcluded();
if ($excluded) {
Common::printDebug("Unknown URL is not allowed to track.");
}
}
if (!$excluded) {
if ($this->isPrefetchDetected()) {
$excluded = true;
Common::printDebug("Prefetch request detected, not a real visit so we Ignore this visit/pageview");
}
}
if ($excluded) {
Common::printDebug("Visitor excluded.");
return true;
}
return false;
} | [
"public",
"function",
"isExcluded",
"(",
")",
"{",
"$",
"excluded",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isNonHumanBot",
"(",
")",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"'Search bot detected, visit excluded'",
")",
";",
"$",
"excluded",
"=",
"true",
";",
"}",
"/*\n * Requests built with piwik.js will contain a rec=1 parameter. This is used as\n * an indication that the request is made by a JS enabled device. By default, Piwik\n * doesn't track non-JS visitors.\n */",
"if",
"(",
"!",
"$",
"excluded",
")",
"{",
"$",
"toRecord",
"=",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"$",
"parameterForceRecord",
"=",
"'rec'",
")",
";",
"if",
"(",
"!",
"$",
"toRecord",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"@",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
".",
"' parameter '",
".",
"$",
"parameterForceRecord",
".",
"' not found in URL, request excluded'",
")",
";",
"$",
"excluded",
"=",
"true",
";",
"Common",
"::",
"printDebug",
"(",
"\"'$parameterForceRecord' parameter not found.\"",
")",
";",
"}",
"}",
"/**\n * Triggered on every tracking request.\n *\n * This event can be used to tell the Tracker not to record this particular action or visit.\n *\n * @param bool &$excluded Whether the request should be excluded or not. Initialized\n * to `false`. Event subscribers should set it to `true` in\n * order to exclude the request.\n * @param Request $request The request object which contains all of the request's information\n *\n */",
"Piwik",
"::",
"postEvent",
"(",
"'Tracker.isExcludedVisit'",
",",
"array",
"(",
"&",
"$",
"excluded",
",",
"$",
"this",
"->",
"request",
")",
")",
";",
"/*\n * Following exclude operations happen after the hook.\n * These are of higher priority and should not be overwritten by plugins.\n */",
"// Checking if the Piwik ignore cookie is set",
"if",
"(",
"!",
"$",
"excluded",
")",
"{",
"$",
"excluded",
"=",
"$",
"this",
"->",
"isIgnoreCookieFound",
"(",
")",
";",
"if",
"(",
"$",
"excluded",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"Ignore cookie found.\"",
")",
";",
"}",
"}",
"// Checking for excluded IPs",
"if",
"(",
"!",
"$",
"excluded",
")",
"{",
"$",
"excluded",
"=",
"$",
"this",
"->",
"isVisitorIpExcluded",
"(",
")",
";",
"if",
"(",
"$",
"excluded",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"IP excluded.\"",
")",
";",
"}",
"}",
"// Check if user agent should be excluded",
"if",
"(",
"!",
"$",
"excluded",
")",
"{",
"$",
"excluded",
"=",
"$",
"this",
"->",
"isUserAgentExcluded",
"(",
")",
";",
"if",
"(",
"$",
"excluded",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"User agent excluded.\"",
")",
";",
"}",
"}",
"// Check if Referrer URL is a known spam",
"if",
"(",
"!",
"$",
"excluded",
")",
"{",
"$",
"excluded",
"=",
"$",
"this",
"->",
"isReferrerSpamExcluded",
"(",
")",
";",
"if",
"(",
"$",
"excluded",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"Referrer URL is blacklisted as spam.\"",
")",
";",
"}",
"}",
"// Check if request URL is excluded",
"if",
"(",
"!",
"$",
"excluded",
")",
"{",
"$",
"excluded",
"=",
"$",
"this",
"->",
"isUrlExcluded",
"(",
")",
";",
"if",
"(",
"$",
"excluded",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"Unknown URL is not allowed to track.\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"excluded",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPrefetchDetected",
"(",
")",
")",
"{",
"$",
"excluded",
"=",
"true",
";",
"Common",
"::",
"printDebug",
"(",
"\"Prefetch request detected, not a real visit so we Ignore this visit/pageview\"",
")",
";",
"}",
"}",
"if",
"(",
"$",
"excluded",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"\"Visitor excluded.\"",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Test if the current visitor is excluded from the statistics.
Plugins can for example exclude visitors based on the
- IP
- If a given cookie is found
@return bool True if the visit must not be saved, false otherwise | [
"Test",
"if",
"the",
"current",
"visitor",
"is",
"excluded",
"from",
"the",
"statistics",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/VisitExcluded.php#L61-L155 |
209,667 | matomo-org/matomo | core/Tracker/VisitExcluded.php | VisitExcluded.isVisitorIpExcluded | protected function isVisitorIpExcluded()
{
$excludedIps = $this->getAttributes('excluded_ips', 'global_excluded_ips');
if (!empty($excludedIps)) {
$ip = IP::fromBinaryIP($this->ip);
if ($ip->isInRanges($excludedIps)) {
Common::printDebug('Visitor IP ' . $ip->toString() . ' is excluded from being tracked');
return true;
}
}
return false;
} | php | protected function isVisitorIpExcluded()
{
$excludedIps = $this->getAttributes('excluded_ips', 'global_excluded_ips');
if (!empty($excludedIps)) {
$ip = IP::fromBinaryIP($this->ip);
if ($ip->isInRanges($excludedIps)) {
Common::printDebug('Visitor IP ' . $ip->toString() . ' is excluded from being tracked');
return true;
}
}
return false;
} | [
"protected",
"function",
"isVisitorIpExcluded",
"(",
")",
"{",
"$",
"excludedIps",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"'excluded_ips'",
",",
"'global_excluded_ips'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludedIps",
")",
")",
"{",
"$",
"ip",
"=",
"IP",
"::",
"fromBinaryIP",
"(",
"$",
"this",
"->",
"ip",
")",
";",
"if",
"(",
"$",
"ip",
"->",
"isInRanges",
"(",
"$",
"excludedIps",
")",
")",
"{",
"Common",
"::",
"printDebug",
"(",
"'Visitor IP '",
".",
"$",
"ip",
"->",
"toString",
"(",
")",
".",
"' is excluded from being tracked'",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if the visitor ip is in the excluded list
@return bool | [
"Checks",
"if",
"the",
"visitor",
"ip",
"is",
"in",
"the",
"excluded",
"list"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/VisitExcluded.php#L273-L286 |
209,668 | matomo-org/matomo | core/Tracker/VisitExcluded.php | VisitExcluded.isUrlExcluded | protected function isUrlExcluded()
{
$excludedUrls = $this->getAttributes('exclude_unknown_urls', null);
$siteUrls = $this->getAttributes('urls', null);
if (!empty($excludedUrls) && !empty($siteUrls)) {
$url = $this->request->getParam('url');
$parsedUrl = parse_url($url);
$trackingUrl = new SiteUrls();
$urls = $trackingUrl->groupUrlsByHost(array($this->idSite => $siteUrls));
$idSites = $trackingUrl->getIdSitesMatchingUrl($parsedUrl, $urls);
$isUrlExcluded = !isset($idSites) || !in_array($this->idSite, $idSites);
return $isUrlExcluded;
}
return false;
} | php | protected function isUrlExcluded()
{
$excludedUrls = $this->getAttributes('exclude_unknown_urls', null);
$siteUrls = $this->getAttributes('urls', null);
if (!empty($excludedUrls) && !empty($siteUrls)) {
$url = $this->request->getParam('url');
$parsedUrl = parse_url($url);
$trackingUrl = new SiteUrls();
$urls = $trackingUrl->groupUrlsByHost(array($this->idSite => $siteUrls));
$idSites = $trackingUrl->getIdSitesMatchingUrl($parsedUrl, $urls);
$isUrlExcluded = !isset($idSites) || !in_array($this->idSite, $idSites);
return $isUrlExcluded;
}
return false;
} | [
"protected",
"function",
"isUrlExcluded",
"(",
")",
"{",
"$",
"excludedUrls",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"'exclude_unknown_urls'",
",",
"null",
")",
";",
"$",
"siteUrls",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"'urls'",
",",
"null",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludedUrls",
")",
"&&",
"!",
"empty",
"(",
"$",
"siteUrls",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'url'",
")",
";",
"$",
"parsedUrl",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"trackingUrl",
"=",
"new",
"SiteUrls",
"(",
")",
";",
"$",
"urls",
"=",
"$",
"trackingUrl",
"->",
"groupUrlsByHost",
"(",
"array",
"(",
"$",
"this",
"->",
"idSite",
"=>",
"$",
"siteUrls",
")",
")",
";",
"$",
"idSites",
"=",
"$",
"trackingUrl",
"->",
"getIdSitesMatchingUrl",
"(",
"$",
"parsedUrl",
",",
"$",
"urls",
")",
";",
"$",
"isUrlExcluded",
"=",
"!",
"isset",
"(",
"$",
"idSites",
")",
"||",
"!",
"in_array",
"(",
"$",
"this",
"->",
"idSite",
",",
"$",
"idSites",
")",
";",
"return",
"$",
"isUrlExcluded",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if request URL is excluded
@return bool | [
"Checks",
"if",
"request",
"URL",
"is",
"excluded"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/VisitExcluded.php#L312-L331 |
209,669 | matomo-org/matomo | core/Tracker/VisitExcluded.php | VisitExcluded.isUserAgentExcluded | protected function isUserAgentExcluded()
{
$excludedAgents = $this->getAttributes('excluded_user_agents', 'global_excluded_user_agents');
if (!empty($excludedAgents)) {
foreach ($excludedAgents as $excludedUserAgent) {
// if the excluded user agent string part is in this visit's user agent, this visit should be excluded
if (stripos($this->userAgent, $excludedUserAgent) !== false) {
return true;
}
}
}
return false;
} | php | protected function isUserAgentExcluded()
{
$excludedAgents = $this->getAttributes('excluded_user_agents', 'global_excluded_user_agents');
if (!empty($excludedAgents)) {
foreach ($excludedAgents as $excludedUserAgent) {
// if the excluded user agent string part is in this visit's user agent, this visit should be excluded
if (stripos($this->userAgent, $excludedUserAgent) !== false) {
return true;
}
}
}
return false;
} | [
"protected",
"function",
"isUserAgentExcluded",
"(",
")",
"{",
"$",
"excludedAgents",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"'excluded_user_agents'",
",",
"'global_excluded_user_agents'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludedAgents",
")",
")",
"{",
"foreach",
"(",
"$",
"excludedAgents",
"as",
"$",
"excludedUserAgent",
")",
"{",
"// if the excluded user agent string part is in this visit's user agent, this visit should be excluded",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"userAgent",
",",
"$",
"excludedUserAgent",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if the specified user agent should be excluded for the current site or not.
Visits whose user agent string contains one of the excluded_user_agents strings for the
site being tracked (or one of the global strings) will be excluded.
@internal param string $this ->userAgent The user agent string.
@return bool | [
"Returns",
"true",
"if",
"the",
"specified",
"user",
"agent",
"should",
"be",
"excluded",
"for",
"the",
"current",
"site",
"or",
"not",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/VisitExcluded.php#L342-L356 |
209,670 | matomo-org/matomo | plugins/Goals/Model.php | Model.deleteGoalConversions | public function deleteGoalConversions($idSite, $idGoal)
{
$table = Common::prefixTable("log_conversion");
Db::deleteAllRows($table, "WHERE idgoal = ? AND idsite = ?", "idvisit", 100000, array($idGoal, $idSite));
} | php | public function deleteGoalConversions($idSite, $idGoal)
{
$table = Common::prefixTable("log_conversion");
Db::deleteAllRows($table, "WHERE idgoal = ? AND idsite = ?", "idvisit", 100000, array($idGoal, $idSite));
} | [
"public",
"function",
"deleteGoalConversions",
"(",
"$",
"idSite",
",",
"$",
"idGoal",
")",
"{",
"$",
"table",
"=",
"Common",
"::",
"prefixTable",
"(",
"\"log_conversion\"",
")",
";",
"Db",
"::",
"deleteAllRows",
"(",
"$",
"table",
",",
"\"WHERE idgoal = ? AND idsite = ?\"",
",",
"\"idvisit\"",
",",
"100000",
",",
"array",
"(",
"$",
"idGoal",
",",
"$",
"idSite",
")",
")",
";",
"}"
] | actually this should be in a log_conversion model | [
"actually",
"this",
"should",
"be",
"in",
"a",
"log_conversion",
"model"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Goals/Model.php#L60-L65 |
209,671 | matomo-org/matomo | core/Db/Adapter.php | Adapter.getAdapterClassName | private static function getAdapterClassName($adapterName)
{
$className = 'Piwik\Db\Adapter\\' . str_replace(' ', '\\', ucwords(str_replace(array('_', '\\'), ' ', strtolower($adapterName))));
if (!class_exists($className)) {
throw new \Exception(sprintf("Adapter '%s' is not valid. Maybe check that your Matomo configuration files in config/*.ini.php are readable by the webserver.", $adapterName));
}
return $className;
} | php | private static function getAdapterClassName($adapterName)
{
$className = 'Piwik\Db\Adapter\\' . str_replace(' ', '\\', ucwords(str_replace(array('_', '\\'), ' ', strtolower($adapterName))));
if (!class_exists($className)) {
throw new \Exception(sprintf("Adapter '%s' is not valid. Maybe check that your Matomo configuration files in config/*.ini.php are readable by the webserver.", $adapterName));
}
return $className;
} | [
"private",
"static",
"function",
"getAdapterClassName",
"(",
"$",
"adapterName",
")",
"{",
"$",
"className",
"=",
"'Piwik\\Db\\Adapter\\\\'",
".",
"str_replace",
"(",
"' '",
",",
"'\\\\'",
",",
"ucwords",
"(",
"str_replace",
"(",
"array",
"(",
"'_'",
",",
"'\\\\'",
")",
",",
"' '",
",",
"strtolower",
"(",
"$",
"adapterName",
")",
")",
")",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"Adapter '%s' is not valid. Maybe check that your Matomo configuration files in config/*.ini.php are readable by the webserver.\"",
",",
"$",
"adapterName",
")",
")",
";",
"}",
"return",
"$",
"className",
";",
"}"
] | Get adapter class name
@param string $adapterName
@return string
@throws \Exception | [
"Get",
"adapter",
"class",
"name"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Adapter.php#L68-L75 |
209,672 | matomo-org/matomo | core/Db/Adapter.php | Adapter.getAdapters | public static function getAdapters()
{
static $adapterNames = array(
// currently supported by Piwik
'Pdo\Mysql',
'Mysqli',
// other adapters supported by Zend_Db
// 'Pdo_Pgsql',
// 'Pdo_Mssql',
// 'Sqlsrv',
// 'Pdo_Ibm',
// 'Db2',
// 'Pdo_Oci',
// 'Oracle',
);
$adapters = array();
foreach ($adapterNames as $adapterName) {
$className = '\Piwik\Db\Adapter\\' . $adapterName;
if (call_user_func(array($className, 'isEnabled'))) {
$adapters[strtoupper($adapterName)] = call_user_func(array($className, 'getDefaultPort'));
}
}
return $adapters;
} | php | public static function getAdapters()
{
static $adapterNames = array(
// currently supported by Piwik
'Pdo\Mysql',
'Mysqli',
// other adapters supported by Zend_Db
// 'Pdo_Pgsql',
// 'Pdo_Mssql',
// 'Sqlsrv',
// 'Pdo_Ibm',
// 'Db2',
// 'Pdo_Oci',
// 'Oracle',
);
$adapters = array();
foreach ($adapterNames as $adapterName) {
$className = '\Piwik\Db\Adapter\\' . $adapterName;
if (call_user_func(array($className, 'isEnabled'))) {
$adapters[strtoupper($adapterName)] = call_user_func(array($className, 'getDefaultPort'));
}
}
return $adapters;
} | [
"public",
"static",
"function",
"getAdapters",
"(",
")",
"{",
"static",
"$",
"adapterNames",
"=",
"array",
"(",
"// currently supported by Piwik",
"'Pdo\\Mysql'",
",",
"'Mysqli'",
",",
"// other adapters supported by Zend_Db",
"//\t\t\t'Pdo_Pgsql',",
"//\t\t\t'Pdo_Mssql',",
"//\t\t\t'Sqlsrv',",
"//\t\t\t'Pdo_Ibm',",
"//\t\t\t'Db2',",
"//\t\t\t'Pdo_Oci',",
"//\t\t\t'Oracle',",
")",
";",
"$",
"adapters",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"adapterNames",
"as",
"$",
"adapterName",
")",
"{",
"$",
"className",
"=",
"'\\Piwik\\Db\\Adapter\\\\'",
".",
"$",
"adapterName",
";",
"if",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"className",
",",
"'isEnabled'",
")",
")",
")",
"{",
"$",
"adapters",
"[",
"strtoupper",
"(",
"$",
"adapterName",
")",
"]",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"className",
",",
"'getDefaultPort'",
")",
")",
";",
"}",
"}",
"return",
"$",
"adapters",
";",
"}"
] | Get list of adapters
@return array | [
"Get",
"list",
"of",
"adapters"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Adapter.php#L94-L121 |
209,673 | matomo-org/matomo | core/Settings/Storage/Storage.php | Storage.getValue | public function getValue($key, $defaultValue, $type)
{
$this->loadSettingsIfNotDoneYet();
if (array_key_exists($key, $this->settingsValues)) {
settype($this->settingsValues[$key], $type);
return $this->settingsValues[$key];
}
return $defaultValue;
} | php | public function getValue($key, $defaultValue, $type)
{
$this->loadSettingsIfNotDoneYet();
if (array_key_exists($key, $this->settingsValues)) {
settype($this->settingsValues[$key], $type);
return $this->settingsValues[$key];
}
return $defaultValue;
} | [
"public",
"function",
"getValue",
"(",
"$",
"key",
",",
"$",
"defaultValue",
",",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"loadSettingsIfNotDoneYet",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"settingsValues",
")",
")",
"{",
"settype",
"(",
"$",
"this",
"->",
"settingsValues",
"[",
"$",
"key",
"]",
",",
"$",
"type",
")",
";",
"return",
"$",
"this",
"->",
"settingsValues",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"defaultValue",
";",
"}"
] | Returns the current value for a setting. If no value is stored, the default value
is be returned.
@param string $key The name / key of a setting
@param mixed $defaultValue Default value that will be used in case no value for this setting exists yet
@param string $type The PHP internal type the value of the setting should have, see FieldConfig::TYPE_*
constants. Only an actual value of the setting will be converted to the given type, the
default value will not be converted.
@return mixed | [
"Returns",
"the",
"current",
"value",
"for",
"a",
"setting",
".",
"If",
"no",
"value",
"is",
"stored",
"the",
"default",
"value",
"is",
"be",
"returned",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Settings/Storage/Storage.php#L81-L91 |
209,674 | matomo-org/matomo | libs/HTML/QuickForm2/Container/Group.php | HTML_QuickForm2_Container_Group.render | public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->startGroup($this);
foreach ($this as $element) {
$element->render($renderer);
}
$renderer->finishGroup($this);
return $renderer;
} | php | public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->startGroup($this);
foreach ($this as $element) {
$element->render($renderer);
}
$renderer->finishGroup($this);
return $renderer;
} | [
"public",
"function",
"render",
"(",
"HTML_QuickForm2_Renderer",
"$",
"renderer",
")",
"{",
"$",
"renderer",
"->",
"startGroup",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"element",
")",
"{",
"$",
"element",
"->",
"render",
"(",
"$",
"renderer",
")",
";",
"}",
"$",
"renderer",
"->",
"finishGroup",
"(",
"$",
"this",
")",
";",
"return",
"$",
"renderer",
";",
"}"
] | Renders the group using the given renderer
@param HTML_QuickForm2_Renderer Renderer instance
@return HTML_QuickForm2_Renderer | [
"Renders",
"the",
"group",
"using",
"the",
"given",
"renderer"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Container/Group.php#L308-L316 |
209,675 | matomo-org/matomo | core/Plugin/Menu.php | Menu.urlForDefaultUserParams | public function urlForDefaultUserParams($websiteId = false, $defaultPeriod = false, $defaultDate = false)
{
$userPreferences = new UserPreferences();
if (empty($websiteId)) {
$websiteId = $userPreferences->getDefaultWebsiteId();
}
if (empty($websiteId)) {
throw new \Exception("A website ID was not specified and a website to default to could not be found.");
}
if (empty($defaultDate)) {
$defaultDate = $userPreferences->getDefaultDate();
}
if (empty($defaultPeriod)) {
$defaultPeriod = $userPreferences->getDefaultPeriod(false);
}
return array(
'idSite' => $websiteId,
'period' => $defaultPeriod,
'date' => $defaultDate,
);
} | php | public function urlForDefaultUserParams($websiteId = false, $defaultPeriod = false, $defaultDate = false)
{
$userPreferences = new UserPreferences();
if (empty($websiteId)) {
$websiteId = $userPreferences->getDefaultWebsiteId();
}
if (empty($websiteId)) {
throw new \Exception("A website ID was not specified and a website to default to could not be found.");
}
if (empty($defaultDate)) {
$defaultDate = $userPreferences->getDefaultDate();
}
if (empty($defaultPeriod)) {
$defaultPeriod = $userPreferences->getDefaultPeriod(false);
}
return array(
'idSite' => $websiteId,
'period' => $defaultPeriod,
'date' => $defaultDate,
);
} | [
"public",
"function",
"urlForDefaultUserParams",
"(",
"$",
"websiteId",
"=",
"false",
",",
"$",
"defaultPeriod",
"=",
"false",
",",
"$",
"defaultDate",
"=",
"false",
")",
"{",
"$",
"userPreferences",
"=",
"new",
"UserPreferences",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"websiteId",
")",
")",
"{",
"$",
"websiteId",
"=",
"$",
"userPreferences",
"->",
"getDefaultWebsiteId",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"websiteId",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"A website ID was not specified and a website to default to could not be found.\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"defaultDate",
")",
")",
"{",
"$",
"defaultDate",
"=",
"$",
"userPreferences",
"->",
"getDefaultDate",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"defaultPeriod",
")",
")",
"{",
"$",
"defaultPeriod",
"=",
"$",
"userPreferences",
"->",
"getDefaultPeriod",
"(",
"false",
")",
";",
"}",
"return",
"array",
"(",
"'idSite'",
"=>",
"$",
"websiteId",
",",
"'period'",
"=>",
"$",
"defaultPeriod",
",",
"'date'",
"=>",
"$",
"defaultDate",
",",
")",
";",
"}"
] | Returns the &idSite=X&period=Y&date=Z query string fragment,
fetched from current logged-in user's preferences.
@param bool $websiteId
@param bool $defaultPeriod
@param bool $defaultDate
@return string eg '&idSite=1&period=week&date=today'
@throws \Exception in case a website was not specified and a default website id could not be found | [
"Returns",
"the",
"&idSite",
"=",
"X&period",
"=",
"Y&date",
"=",
"Z",
"query",
"string",
"fragment",
"fetched",
"from",
"current",
"logged",
"-",
"in",
"user",
"s",
"preferences",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Menu.php#L188-L208 |
209,676 | matomo-org/matomo | core/Plugin/ComponentFactory.php | ComponentFactory.factory | public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
{
if (empty($pluginName) || empty($componentClassSimpleName)) {
Log::debug("ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
__FUNCTION__, $pluginName, $componentClassSimpleName);
return null;
}
$plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
if (empty($plugin)) {
return null;
}
$subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
$desiredComponentClass = 'Piwik\\Plugins\\' . $pluginName . '\\' . $subnamespace . '\\' . $componentClassSimpleName;
$components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
foreach ($components as $class) {
if ($class == $desiredComponentClass) {
return new $class();
}
}
Log::debug("ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
__FUNCTION__, $pluginName, $componentClassSimpleName, $componentTypeClass);
return null;
} | php | public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
{
if (empty($pluginName) || empty($componentClassSimpleName)) {
Log::debug("ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
__FUNCTION__, $pluginName, $componentClassSimpleName);
return null;
}
$plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
if (empty($plugin)) {
return null;
}
$subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
$desiredComponentClass = 'Piwik\\Plugins\\' . $pluginName . '\\' . $subnamespace . '\\' . $componentClassSimpleName;
$components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
foreach ($components as $class) {
if ($class == $desiredComponentClass) {
return new $class();
}
}
Log::debug("ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
__FUNCTION__, $pluginName, $componentClassSimpleName, $componentTypeClass);
return null;
} | [
"public",
"static",
"function",
"factory",
"(",
"$",
"pluginName",
",",
"$",
"componentClassSimpleName",
",",
"$",
"componentTypeClass",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pluginName",
")",
"||",
"empty",
"(",
"$",
"componentClassSimpleName",
")",
")",
"{",
"Log",
"::",
"debug",
"(",
"\"ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)\"",
",",
"__FUNCTION__",
",",
"$",
"pluginName",
",",
"$",
"componentClassSimpleName",
")",
";",
"return",
"null",
";",
"}",
"$",
"plugin",
"=",
"self",
"::",
"getActivatedPlugin",
"(",
"__FUNCTION__",
",",
"$",
"pluginName",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"plugin",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"subnamespace",
"=",
"$",
"componentTypeClass",
"::",
"COMPONENT_SUBNAMESPACE",
";",
"$",
"desiredComponentClass",
"=",
"'Piwik\\\\Plugins\\\\'",
".",
"$",
"pluginName",
".",
"'\\\\'",
".",
"$",
"subnamespace",
".",
"'\\\\'",
".",
"$",
"componentClassSimpleName",
";",
"$",
"components",
"=",
"$",
"plugin",
"->",
"findMultipleComponents",
"(",
"$",
"subnamespace",
",",
"$",
"componentTypeClass",
")",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"==",
"$",
"desiredComponentClass",
")",
"{",
"return",
"new",
"$",
"class",
"(",
")",
";",
"}",
"}",
"Log",
"::",
"debug",
"(",
"\"ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).\"",
",",
"__FUNCTION__",
",",
"$",
"pluginName",
",",
"$",
"componentClassSimpleName",
",",
"$",
"componentTypeClass",
")",
";",
"return",
"null",
";",
"}"
] | Create a component instance that exists within a specific plugin. Uses the component's
unqualified class name and expected base type.
This method will only create a class if it is located within the component type's
associated subdirectory.
@param string $pluginName The name of the plugin the component is expected to belong to,
eg, `'DevicesDetection'`.
@param string $componentClassSimpleName The component's class name w/o namespace, eg,
`"GetKeywords"`.
@param string $componentTypeClass The fully qualified class name of the component type, eg,
`"Piwik\Plugin\Report"`.
@return mixed|null A new instance of the desired component or null if not found. If the
plugin is not loaded or activated or the component is not located in
in the sub-namespace specified by `$componentTypeClass::COMPONENT_SUBNAMESPACE`,
this method will return null. | [
"Create",
"a",
"component",
"instance",
"that",
"exists",
"within",
"a",
"specific",
"plugin",
".",
"Uses",
"the",
"component",
"s",
"unqualified",
"class",
"name",
"and",
"expected",
"base",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ComponentFactory.php#L37-L65 |
209,677 | matomo-org/matomo | core/Plugin/ComponentFactory.php | ComponentFactory.getComponentIf | public static function getComponentIf($componentTypeClass, $pluginName, $predicate)
{
$pluginManager = PluginManager::getInstance();
// get components to search through
$subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
if (empty($pluginName)) {
$components = $pluginManager->findMultipleComponents($subnamespace, $componentTypeClass);
} else {
$plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
if (empty($plugin)) {
return null;
}
$components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
}
// find component that satisfieds predicate
foreach ($components as $class) {
$component = new $class();
if ($predicate($component)) {
return $component;
}
}
Log::debug("ComponentFactory::%s: Could not find component that satisfies predicate (args = ['%s', '%s', '%s']).",
__FUNCTION__, $componentTypeClass, $pluginName, get_class($predicate));
return null;
} | php | public static function getComponentIf($componentTypeClass, $pluginName, $predicate)
{
$pluginManager = PluginManager::getInstance();
// get components to search through
$subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
if (empty($pluginName)) {
$components = $pluginManager->findMultipleComponents($subnamespace, $componentTypeClass);
} else {
$plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
if (empty($plugin)) {
return null;
}
$components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
}
// find component that satisfieds predicate
foreach ($components as $class) {
$component = new $class();
if ($predicate($component)) {
return $component;
}
}
Log::debug("ComponentFactory::%s: Could not find component that satisfies predicate (args = ['%s', '%s', '%s']).",
__FUNCTION__, $componentTypeClass, $pluginName, get_class($predicate));
return null;
} | [
"public",
"static",
"function",
"getComponentIf",
"(",
"$",
"componentTypeClass",
",",
"$",
"pluginName",
",",
"$",
"predicate",
")",
"{",
"$",
"pluginManager",
"=",
"PluginManager",
"::",
"getInstance",
"(",
")",
";",
"// get components to search through",
"$",
"subnamespace",
"=",
"$",
"componentTypeClass",
"::",
"COMPONENT_SUBNAMESPACE",
";",
"if",
"(",
"empty",
"(",
"$",
"pluginName",
")",
")",
"{",
"$",
"components",
"=",
"$",
"pluginManager",
"->",
"findMultipleComponents",
"(",
"$",
"subnamespace",
",",
"$",
"componentTypeClass",
")",
";",
"}",
"else",
"{",
"$",
"plugin",
"=",
"self",
"::",
"getActivatedPlugin",
"(",
"__FUNCTION__",
",",
"$",
"pluginName",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"plugin",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"components",
"=",
"$",
"plugin",
"->",
"findMultipleComponents",
"(",
"$",
"subnamespace",
",",
"$",
"componentTypeClass",
")",
";",
"}",
"// find component that satisfieds predicate",
"foreach",
"(",
"$",
"components",
"as",
"$",
"class",
")",
"{",
"$",
"component",
"=",
"new",
"$",
"class",
"(",
")",
";",
"if",
"(",
"$",
"predicate",
"(",
"$",
"component",
")",
")",
"{",
"return",
"$",
"component",
";",
"}",
"}",
"Log",
"::",
"debug",
"(",
"\"ComponentFactory::%s: Could not find component that satisfies predicate (args = ['%s', '%s', '%s']).\"",
",",
"__FUNCTION__",
",",
"$",
"componentTypeClass",
",",
"$",
"pluginName",
",",
"get_class",
"(",
"$",
"predicate",
")",
")",
";",
"return",
"null",
";",
"}"
] | Finds a component instance that satisfies a given predicate.
@param string $componentTypeClass The fully qualified class name of the component type, eg,
`"Piwik\Plugin\Report"`.
@param string $pluginName|false The name of the plugin the component is expected to belong to,
eg, `'DevicesDetection'`.
@param callback $predicate
@return mixed The component that satisfies $predicate or null if not found. | [
"Finds",
"a",
"component",
"instance",
"that",
"satisfies",
"a",
"given",
"predicate",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ComponentFactory.php#L77-L106 |
209,678 | matomo-org/matomo | core/ArchiveProcessor/PluginsArchiver.php | PluginsArchiver.callAggregateAllPlugins | public function callAggregateAllPlugins($visits, $visitsConverted, $forceArchivingWithoutVisits = false)
{
Log::debug("PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]",
__FUNCTION__, $visits, $visitsConverted);
/** @var Logger $performanceLogger */
$performanceLogger = StaticContainer::get(Logger::class);
$this->archiveProcessor->setNumberOfVisits($visits, $visitsConverted);
$archivers = static::getPluginArchivers();
foreach ($archivers as $pluginName => $archiverClass) {
// We clean up below all tables created during this function call (and recursive calls)
$latestUsedTableId = Manager::getInstance()->getMostRecentTableId();
/** @var Archiver $archiver */
$archiver = $this->makeNewArchiverObject($archiverClass, $pluginName);
if (!$archiver->isEnabled()) {
Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (disabled).", __FUNCTION__, $pluginName);
continue;
}
if (!$forceArchivingWithoutVisits && !$visits && !$archiver->shouldRunEvenWhenNoVisits()) {
Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (no visits).", __FUNCTION__, $pluginName);
continue;
}
if ($this->shouldProcessReportsForPlugin($pluginName)) {
$this->logAggregator->setQueryOriginHint($pluginName);
try {
$timer = new Timer();
if ($this->shouldAggregateFromRawData) {
Log::debug("PluginsArchiver::%s: Archiving day reports for plugin '%s'.", __FUNCTION__, $pluginName);
$archiver->callAggregateDayReport();
} else {
Log::debug("PluginsArchiver::%s: Archiving period reports for plugin '%s'.", __FUNCTION__, $pluginName);
$archiver->callAggregateMultipleReports();
}
$this->logAggregator->setQueryOriginHint('');
$performanceLogger->logMeasurement('plugin', $pluginName, $this->params, $timer);
Log::debug("PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s.",
__FUNCTION__,
$timer->getMemoryLeak(),
$this->params->getPeriod()->getLabel(),
$pluginName,
$this->params->getSegment() ? sprintf("(for segment = '%s')", $this->params->getSegment()->getString()) : ''
);
} catch (Exception $e) {
throw new PluginsArchiverException($e->getMessage() . " - in plugin $pluginName", $e->getCode(), $e);
}
} else {
Log::debug("PluginsArchiver::%s: Not archiving reports for plugin '%s'.", __FUNCTION__, $pluginName);
}
Manager::getInstance()->deleteAll($latestUsedTableId);
unset($archiver);
}
} | php | public function callAggregateAllPlugins($visits, $visitsConverted, $forceArchivingWithoutVisits = false)
{
Log::debug("PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]",
__FUNCTION__, $visits, $visitsConverted);
/** @var Logger $performanceLogger */
$performanceLogger = StaticContainer::get(Logger::class);
$this->archiveProcessor->setNumberOfVisits($visits, $visitsConverted);
$archivers = static::getPluginArchivers();
foreach ($archivers as $pluginName => $archiverClass) {
// We clean up below all tables created during this function call (and recursive calls)
$latestUsedTableId = Manager::getInstance()->getMostRecentTableId();
/** @var Archiver $archiver */
$archiver = $this->makeNewArchiverObject($archiverClass, $pluginName);
if (!$archiver->isEnabled()) {
Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (disabled).", __FUNCTION__, $pluginName);
continue;
}
if (!$forceArchivingWithoutVisits && !$visits && !$archiver->shouldRunEvenWhenNoVisits()) {
Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (no visits).", __FUNCTION__, $pluginName);
continue;
}
if ($this->shouldProcessReportsForPlugin($pluginName)) {
$this->logAggregator->setQueryOriginHint($pluginName);
try {
$timer = new Timer();
if ($this->shouldAggregateFromRawData) {
Log::debug("PluginsArchiver::%s: Archiving day reports for plugin '%s'.", __FUNCTION__, $pluginName);
$archiver->callAggregateDayReport();
} else {
Log::debug("PluginsArchiver::%s: Archiving period reports for plugin '%s'.", __FUNCTION__, $pluginName);
$archiver->callAggregateMultipleReports();
}
$this->logAggregator->setQueryOriginHint('');
$performanceLogger->logMeasurement('plugin', $pluginName, $this->params, $timer);
Log::debug("PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s.",
__FUNCTION__,
$timer->getMemoryLeak(),
$this->params->getPeriod()->getLabel(),
$pluginName,
$this->params->getSegment() ? sprintf("(for segment = '%s')", $this->params->getSegment()->getString()) : ''
);
} catch (Exception $e) {
throw new PluginsArchiverException($e->getMessage() . " - in plugin $pluginName", $e->getCode(), $e);
}
} else {
Log::debug("PluginsArchiver::%s: Not archiving reports for plugin '%s'.", __FUNCTION__, $pluginName);
}
Manager::getInstance()->deleteAll($latestUsedTableId);
unset($archiver);
}
} | [
"public",
"function",
"callAggregateAllPlugins",
"(",
"$",
"visits",
",",
"$",
"visitsConverted",
",",
"$",
"forceArchivingWithoutVisits",
"=",
"false",
")",
"{",
"Log",
"::",
"debug",
"(",
"\"PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]\"",
",",
"__FUNCTION__",
",",
"$",
"visits",
",",
"$",
"visitsConverted",
")",
";",
"/** @var Logger $performanceLogger */",
"$",
"performanceLogger",
"=",
"StaticContainer",
"::",
"get",
"(",
"Logger",
"::",
"class",
")",
";",
"$",
"this",
"->",
"archiveProcessor",
"->",
"setNumberOfVisits",
"(",
"$",
"visits",
",",
"$",
"visitsConverted",
")",
";",
"$",
"archivers",
"=",
"static",
"::",
"getPluginArchivers",
"(",
")",
";",
"foreach",
"(",
"$",
"archivers",
"as",
"$",
"pluginName",
"=>",
"$",
"archiverClass",
")",
"{",
"// We clean up below all tables created during this function call (and recursive calls)",
"$",
"latestUsedTableId",
"=",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"getMostRecentTableId",
"(",
")",
";",
"/** @var Archiver $archiver */",
"$",
"archiver",
"=",
"$",
"this",
"->",
"makeNewArchiverObject",
"(",
"$",
"archiverClass",
",",
"$",
"pluginName",
")",
";",
"if",
"(",
"!",
"$",
"archiver",
"->",
"isEnabled",
"(",
")",
")",
"{",
"Log",
"::",
"debug",
"(",
"\"PluginsArchiver::%s: Skipping archiving for plugin '%s' (disabled).\"",
",",
"__FUNCTION__",
",",
"$",
"pluginName",
")",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"forceArchivingWithoutVisits",
"&&",
"!",
"$",
"visits",
"&&",
"!",
"$",
"archiver",
"->",
"shouldRunEvenWhenNoVisits",
"(",
")",
")",
"{",
"Log",
"::",
"debug",
"(",
"\"PluginsArchiver::%s: Skipping archiving for plugin '%s' (no visits).\"",
",",
"__FUNCTION__",
",",
"$",
"pluginName",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"shouldProcessReportsForPlugin",
"(",
"$",
"pluginName",
")",
")",
"{",
"$",
"this",
"->",
"logAggregator",
"->",
"setQueryOriginHint",
"(",
"$",
"pluginName",
")",
";",
"try",
"{",
"$",
"timer",
"=",
"new",
"Timer",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"shouldAggregateFromRawData",
")",
"{",
"Log",
"::",
"debug",
"(",
"\"PluginsArchiver::%s: Archiving day reports for plugin '%s'.\"",
",",
"__FUNCTION__",
",",
"$",
"pluginName",
")",
";",
"$",
"archiver",
"->",
"callAggregateDayReport",
"(",
")",
";",
"}",
"else",
"{",
"Log",
"::",
"debug",
"(",
"\"PluginsArchiver::%s: Archiving period reports for plugin '%s'.\"",
",",
"__FUNCTION__",
",",
"$",
"pluginName",
")",
";",
"$",
"archiver",
"->",
"callAggregateMultipleReports",
"(",
")",
";",
"}",
"$",
"this",
"->",
"logAggregator",
"->",
"setQueryOriginHint",
"(",
"''",
")",
";",
"$",
"performanceLogger",
"->",
"logMeasurement",
"(",
"'plugin'",
",",
"$",
"pluginName",
",",
"$",
"this",
"->",
"params",
",",
"$",
"timer",
")",
";",
"Log",
"::",
"debug",
"(",
"\"PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s.\"",
",",
"__FUNCTION__",
",",
"$",
"timer",
"->",
"getMemoryLeak",
"(",
")",
",",
"$",
"this",
"->",
"params",
"->",
"getPeriod",
"(",
")",
"->",
"getLabel",
"(",
")",
",",
"$",
"pluginName",
",",
"$",
"this",
"->",
"params",
"->",
"getSegment",
"(",
")",
"?",
"sprintf",
"(",
"\"(for segment = '%s')\"",
",",
"$",
"this",
"->",
"params",
"->",
"getSegment",
"(",
")",
"->",
"getString",
"(",
")",
")",
":",
"''",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PluginsArchiverException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\" - in plugin $pluginName\"",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}",
"else",
"{",
"Log",
"::",
"debug",
"(",
"\"PluginsArchiver::%s: Not archiving reports for plugin '%s'.\"",
",",
"__FUNCTION__",
",",
"$",
"pluginName",
")",
";",
"}",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"deleteAll",
"(",
"$",
"latestUsedTableId",
")",
";",
"unset",
"(",
"$",
"archiver",
")",
";",
"}",
"}"
] | Instantiates the Archiver class in each plugin that defines it,
and triggers Aggregation processing on these plugins. | [
"Instantiates",
"the",
"Archiver",
"class",
"in",
"each",
"plugin",
"that",
"defines",
"it",
"and",
"triggers",
"Aggregation",
"processing",
"on",
"these",
"plugins",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor/PluginsArchiver.php#L121-L187 |
209,679 | matomo-org/matomo | core/ArchiveProcessor/PluginsArchiver.php | PluginsArchiver.doesAnyPluginArchiveWithoutVisits | public static function doesAnyPluginArchiveWithoutVisits()
{
$archivers = static::getPluginArchivers();
foreach ($archivers as $pluginName => $archiverClass) {
if ($archiverClass::shouldRunEvenWhenNoVisits()) {
return true;
}
}
return false;
} | php | public static function doesAnyPluginArchiveWithoutVisits()
{
$archivers = static::getPluginArchivers();
foreach ($archivers as $pluginName => $archiverClass) {
if ($archiverClass::shouldRunEvenWhenNoVisits()) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"doesAnyPluginArchiveWithoutVisits",
"(",
")",
"{",
"$",
"archivers",
"=",
"static",
"::",
"getPluginArchivers",
"(",
")",
";",
"foreach",
"(",
"$",
"archivers",
"as",
"$",
"pluginName",
"=>",
"$",
"archiverClass",
")",
"{",
"if",
"(",
"$",
"archiverClass",
"::",
"shouldRunEvenWhenNoVisits",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns if any plugin archiver archives without visits | [
"Returns",
"if",
"any",
"plugin",
"archiver",
"archives",
"without",
"visits"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor/PluginsArchiver.php#L199-L210 |
209,680 | matomo-org/matomo | core/ArchiveProcessor/PluginsArchiver.php | PluginsArchiver.getPluginArchivers | protected static function getPluginArchivers()
{
if (empty(static::$archivers)) {
$pluginNames = \Piwik\Plugin\Manager::getInstance()->getActivatedPlugins();
$archivers = array();
foreach ($pluginNames as $pluginName) {
$archivers[$pluginName] = self::getPluginArchiverClass($pluginName);
}
static::$archivers = array_filter($archivers);
}
return static::$archivers;
} | php | protected static function getPluginArchivers()
{
if (empty(static::$archivers)) {
$pluginNames = \Piwik\Plugin\Manager::getInstance()->getActivatedPlugins();
$archivers = array();
foreach ($pluginNames as $pluginName) {
$archivers[$pluginName] = self::getPluginArchiverClass($pluginName);
}
static::$archivers = array_filter($archivers);
}
return static::$archivers;
} | [
"protected",
"static",
"function",
"getPluginArchivers",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"archivers",
")",
")",
"{",
"$",
"pluginNames",
"=",
"\\",
"Piwik",
"\\",
"Plugin",
"\\",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"getActivatedPlugins",
"(",
")",
";",
"$",
"archivers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pluginNames",
"as",
"$",
"pluginName",
")",
"{",
"$",
"archivers",
"[",
"$",
"pluginName",
"]",
"=",
"self",
"::",
"getPluginArchiverClass",
"(",
"$",
"pluginName",
")",
";",
"}",
"static",
"::",
"$",
"archivers",
"=",
"array_filter",
"(",
"$",
"archivers",
")",
";",
"}",
"return",
"static",
"::",
"$",
"archivers",
";",
"}"
] | Loads Archiver class from any plugin that defines one.
@return \Piwik\Plugin\Archiver[] | [
"Loads",
"Archiver",
"class",
"from",
"any",
"plugin",
"that",
"defines",
"one",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor/PluginsArchiver.php#L217-L228 |
209,681 | matomo-org/matomo | core/ArchiveProcessor/PluginsArchiver.php | PluginsArchiver.shouldProcessReportsForPlugin | protected function shouldProcessReportsForPlugin($pluginName)
{
if ($this->params->getRequestedPlugin() == $pluginName) {
return true;
}
if ($this->params->shouldOnlyArchiveRequestedPlugin()) {
return false;
}
if (Rules::shouldProcessReportsAllPlugins(
$this->params->getIdSites(),
$this->params->getSegment(),
$this->params->getPeriod()->getLabel())) {
return true;
}
if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded($this->params->getRequestedPlugin())) {
return true;
}
return false;
} | php | protected function shouldProcessReportsForPlugin($pluginName)
{
if ($this->params->getRequestedPlugin() == $pluginName) {
return true;
}
if ($this->params->shouldOnlyArchiveRequestedPlugin()) {
return false;
}
if (Rules::shouldProcessReportsAllPlugins(
$this->params->getIdSites(),
$this->params->getSegment(),
$this->params->getPeriod()->getLabel())) {
return true;
}
if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded($this->params->getRequestedPlugin())) {
return true;
}
return false;
} | [
"protected",
"function",
"shouldProcessReportsForPlugin",
"(",
"$",
"pluginName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"params",
"->",
"getRequestedPlugin",
"(",
")",
"==",
"$",
"pluginName",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"params",
"->",
"shouldOnlyArchiveRequestedPlugin",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Rules",
"::",
"shouldProcessReportsAllPlugins",
"(",
"$",
"this",
"->",
"params",
"->",
"getIdSites",
"(",
")",
",",
"$",
"this",
"->",
"params",
"->",
"getSegment",
"(",
")",
",",
"$",
"this",
"->",
"params",
"->",
"getPeriod",
"(",
")",
"->",
"getLabel",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"\\",
"Piwik",
"\\",
"Plugin",
"\\",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"isPluginLoaded",
"(",
"$",
"this",
"->",
"params",
"->",
"getRequestedPlugin",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Whether the specified plugin's reports should be archived
@param string $pluginName
@return bool | [
"Whether",
"the",
"specified",
"plugin",
"s",
"reports",
"should",
"be",
"archived"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor/PluginsArchiver.php#L245-L266 |
209,682 | matomo-org/matomo | libs/Zend/Validate.php | Zend_Validate.addValidator | public function addValidator(Zend_Validate_Interface $validator, $breakChainOnFailure = false)
{
$this->_validators[] = array(
'instance' => $validator,
'breakChainOnFailure' => (boolean) $breakChainOnFailure
);
return $this;
} | php | public function addValidator(Zend_Validate_Interface $validator, $breakChainOnFailure = false)
{
$this->_validators[] = array(
'instance' => $validator,
'breakChainOnFailure' => (boolean) $breakChainOnFailure
);
return $this;
} | [
"public",
"function",
"addValidator",
"(",
"Zend_Validate_Interface",
"$",
"validator",
",",
"$",
"breakChainOnFailure",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_validators",
"[",
"]",
"=",
"array",
"(",
"'instance'",
"=>",
"$",
"validator",
",",
"'breakChainOnFailure'",
"=>",
"(",
"boolean",
")",
"$",
"breakChainOnFailure",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a validator to the end of the chain
If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain,
if one exists, will not be executed.
@param Zend_Validate_Interface $validator
@param boolean $breakChainOnFailure
@return Zend_Validate Provides a fluent interface | [
"Adds",
"a",
"validator",
"to",
"the",
"end",
"of",
"the",
"chain"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate.php#L74-L81 |
209,683 | matomo-org/matomo | core/Scheduler/Schedule/Monthly.php | Monthly.setDayOfWeek | public function setDayOfWeek($_day, $_week)
{
if (!($_day >= 0 && $_day < 7)) {
throw new Exception("Invalid day of week parameter, must be >= 0 & < 7");
}
if (!($_week >= 0 && $_week < 4)) {
throw new Exception("Invalid week number, must be >= 1 & < 4");
}
$this->dayOfWeek = $_day;
$this->week = $_week;
} | php | public function setDayOfWeek($_day, $_week)
{
if (!($_day >= 0 && $_day < 7)) {
throw new Exception("Invalid day of week parameter, must be >= 0 & < 7");
}
if (!($_week >= 0 && $_week < 4)) {
throw new Exception("Invalid week number, must be >= 1 & < 4");
}
$this->dayOfWeek = $_day;
$this->week = $_week;
} | [
"public",
"function",
"setDayOfWeek",
"(",
"$",
"_day",
",",
"$",
"_week",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"_day",
">=",
"0",
"&&",
"$",
"_day",
"<",
"7",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid day of week parameter, must be >= 0 & < 7\"",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"_week",
">=",
"0",
"&&",
"$",
"_week",
"<",
"4",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid week number, must be >= 1 & < 4\"",
")",
";",
"}",
"$",
"this",
"->",
"dayOfWeek",
"=",
"$",
"_day",
";",
"$",
"this",
"->",
"week",
"=",
"$",
"_week",
";",
"}"
] | Makes this scheduled time execute on a particular day of the week on each month.
@param int $_day the day of the week to use, between 0-6 (inclusive). 0 -> Sunday
@param int $_week the week to use, between 0-3 (inclusive)
@throws Exception if either parameter is invalid | [
"Makes",
"this",
"scheduled",
"time",
"execute",
"on",
"a",
"particular",
"day",
"of",
"the",
"week",
"on",
"each",
"month",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Scheduler/Schedule/Monthly.php#L131-L143 |
209,684 | matomo-org/matomo | core/Metrics/Sorter.php | Sorter.getPrimaryColumnToSort | public function getPrimaryColumnToSort(DataTable $table, $columnToSort)
{
// we fallback to nb_visits in case columnToSort does not exist
$columnsToCheck = array($columnToSort, 'nb_visits');
$row = $table->getFirstRow();
foreach ($columnsToCheck as $column) {
$column = Metric::getActualMetricColumn($table, $column);
if ($row->hasColumn($column)) {
// since getActualMetricColumn() returns a default value, we need to make sure it actually has that column
return $column;
}
}
return $columnToSort;
} | php | public function getPrimaryColumnToSort(DataTable $table, $columnToSort)
{
// we fallback to nb_visits in case columnToSort does not exist
$columnsToCheck = array($columnToSort, 'nb_visits');
$row = $table->getFirstRow();
foreach ($columnsToCheck as $column) {
$column = Metric::getActualMetricColumn($table, $column);
if ($row->hasColumn($column)) {
// since getActualMetricColumn() returns a default value, we need to make sure it actually has that column
return $column;
}
}
return $columnToSort;
} | [
"public",
"function",
"getPrimaryColumnToSort",
"(",
"DataTable",
"$",
"table",
",",
"$",
"columnToSort",
")",
"{",
"// we fallback to nb_visits in case columnToSort does not exist",
"$",
"columnsToCheck",
"=",
"array",
"(",
"$",
"columnToSort",
",",
"'nb_visits'",
")",
";",
"$",
"row",
"=",
"$",
"table",
"->",
"getFirstRow",
"(",
")",
";",
"foreach",
"(",
"$",
"columnsToCheck",
"as",
"$",
"column",
")",
"{",
"$",
"column",
"=",
"Metric",
"::",
"getActualMetricColumn",
"(",
"$",
"table",
",",
"$",
"column",
")",
";",
"if",
"(",
"$",
"row",
"->",
"hasColumn",
"(",
"$",
"column",
")",
")",
"{",
"// since getActualMetricColumn() returns a default value, we need to make sure it actually has that column",
"return",
"$",
"column",
";",
"}",
"}",
"return",
"$",
"columnToSort",
";",
"}"
] | Detect the column to be used for sorting
@param DataTable $table
@param string|int $columnToSort column name or column id
@return int | [
"Detect",
"the",
"column",
"to",
"be",
"used",
"for",
"sorting"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Metrics/Sorter.php#L141-L158 |
209,685 | matomo-org/matomo | core/Metrics/Sorter.php | Sorter.getSecondaryColumnToSort | public function getSecondaryColumnToSort(Row $row, $primaryColumnToSort)
{
$defaultSecondaryColumn = array(Metrics::INDEX_NB_VISITS, 'nb_visits');
if (in_array($primaryColumnToSort, $defaultSecondaryColumn)) {
// if sorted by visits, then sort by label as a secondary column
$column = 'label';
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
return null;
}
if ($primaryColumnToSort !== 'label') {
// we do not add this by default to make sure we do not sort by label as a first and secondary column
$defaultSecondaryColumn[] = 'label';
}
foreach ($defaultSecondaryColumn as $column) {
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
}
} | php | public function getSecondaryColumnToSort(Row $row, $primaryColumnToSort)
{
$defaultSecondaryColumn = array(Metrics::INDEX_NB_VISITS, 'nb_visits');
if (in_array($primaryColumnToSort, $defaultSecondaryColumn)) {
// if sorted by visits, then sort by label as a secondary column
$column = 'label';
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
return null;
}
if ($primaryColumnToSort !== 'label') {
// we do not add this by default to make sure we do not sort by label as a first and secondary column
$defaultSecondaryColumn[] = 'label';
}
foreach ($defaultSecondaryColumn as $column) {
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
}
} | [
"public",
"function",
"getSecondaryColumnToSort",
"(",
"Row",
"$",
"row",
",",
"$",
"primaryColumnToSort",
")",
"{",
"$",
"defaultSecondaryColumn",
"=",
"array",
"(",
"Metrics",
"::",
"INDEX_NB_VISITS",
",",
"'nb_visits'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"primaryColumnToSort",
",",
"$",
"defaultSecondaryColumn",
")",
")",
"{",
"// if sorted by visits, then sort by label as a secondary column",
"$",
"column",
"=",
"'label'",
";",
"$",
"value",
"=",
"$",
"row",
"->",
"hasColumn",
"(",
"$",
"column",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"false",
")",
"{",
"return",
"$",
"column",
";",
"}",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"primaryColumnToSort",
"!==",
"'label'",
")",
"{",
"// we do not add this by default to make sure we do not sort by label as a first and secondary column",
"$",
"defaultSecondaryColumn",
"[",
"]",
"=",
"'label'",
";",
"}",
"foreach",
"(",
"$",
"defaultSecondaryColumn",
"as",
"$",
"column",
")",
"{",
"$",
"value",
"=",
"$",
"row",
"->",
"hasColumn",
"(",
"$",
"column",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"false",
")",
"{",
"return",
"$",
"column",
";",
"}",
"}",
"}"
] | Detect the secondary sort column to be used for sorting
@param Row $row
@param int|string $primaryColumnToSort
@return int | [
"Detect",
"the",
"secondary",
"sort",
"column",
"to",
"be",
"used",
"for",
"sorting"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Metrics/Sorter.php#L167-L193 |
209,686 | matomo-org/matomo | plugins/CoreVisualizations/Visualizations/Cloud.php | Cloud.addWord | public function addWord($word, $value = 1)
{
if (isset($this->wordsArray[$word])) {
$this->wordsArray[$word] += $value;
} else {
$this->wordsArray[$word] = $value;
}
} | php | public function addWord($word, $value = 1)
{
if (isset($this->wordsArray[$word])) {
$this->wordsArray[$word] += $value;
} else {
$this->wordsArray[$word] = $value;
}
} | [
"public",
"function",
"addWord",
"(",
"$",
"word",
",",
"$",
"value",
"=",
"1",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"wordsArray",
"[",
"$",
"word",
"]",
")",
")",
"{",
"$",
"this",
"->",
"wordsArray",
"[",
"$",
"word",
"]",
"+=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"wordsArray",
"[",
"$",
"word",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Assign word to array
@param string $word
@param int $value
@return string | [
"Assign",
"word",
"to",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/Visualizations/Cloud.php#L91-L98 |
209,687 | matomo-org/matomo | plugins/CoreVisualizations/Visualizations/Cloud.php | Cloud.shuffleCloud | protected function shuffleCloud()
{
if (self::$debugDisableShuffle) {
return;
}
$keys = array_keys($this->wordsArray);
shuffle($keys);
if (count($keys) && is_array($keys)) {
$tmpArray = $this->wordsArray;
$this->wordsArray = array();
foreach ($keys as $value) {
$this->wordsArray[$value] = $tmpArray[$value];
}
}
} | php | protected function shuffleCloud()
{
if (self::$debugDisableShuffle) {
return;
}
$keys = array_keys($this->wordsArray);
shuffle($keys);
if (count($keys) && is_array($keys)) {
$tmpArray = $this->wordsArray;
$this->wordsArray = array();
foreach ($keys as $value) {
$this->wordsArray[$value] = $tmpArray[$value];
}
}
} | [
"protected",
"function",
"shuffleCloud",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"debugDisableShuffle",
")",
"{",
"return",
";",
"}",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"wordsArray",
")",
";",
"shuffle",
"(",
"$",
"keys",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
"&&",
"is_array",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"tmpArray",
"=",
"$",
"this",
"->",
"wordsArray",
";",
"$",
"this",
"->",
"wordsArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"wordsArray",
"[",
"$",
"value",
"]",
"=",
"$",
"tmpArray",
"[",
"$",
"value",
"]",
";",
"}",
"}",
"}"
] | Shuffle associated names in array | [
"Shuffle",
"associated",
"names",
"in",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/Visualizations/Cloud.php#L132-L152 |
209,688 | matomo-org/matomo | plugins/CoreVisualizations/Visualizations/Cloud.php | Cloud.getClassFromPercent | protected function getClassFromPercent($percent)
{
$mapping = array(95, 70, 50, 30, 15, 5, 0);
foreach ($mapping as $key => $value) {
if ($percent >= $value) {
return $key;
}
}
return 0;
} | php | protected function getClassFromPercent($percent)
{
$mapping = array(95, 70, 50, 30, 15, 5, 0);
foreach ($mapping as $key => $value) {
if ($percent >= $value) {
return $key;
}
}
return 0;
} | [
"protected",
"function",
"getClassFromPercent",
"(",
"$",
"percent",
")",
"{",
"$",
"mapping",
"=",
"array",
"(",
"95",
",",
"70",
",",
"50",
",",
"30",
",",
"15",
",",
"5",
",",
"0",
")",
";",
"foreach",
"(",
"$",
"mapping",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"percent",
">=",
"$",
"value",
")",
"{",
"return",
"$",
"key",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Get the class range using a percentage
@param $percent
@return int class | [
"Get",
"the",
"class",
"range",
"using",
"a",
"percentage"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/Visualizations/Cloud.php#L161-L170 |
209,689 | matomo-org/matomo | libs/Zend/Mime/Message.php | Zend_Mime_Message.generateMessage | public function generateMessage($EOL = Zend_Mime::LINEEND)
{
if (! $this->isMultiPart()) {
$body = array_shift($this->_parts);
$body = $body->getContent($EOL);
} else {
$mime = $this->getMime();
$boundaryLine = $mime->boundaryLine($EOL);
$body = 'This is a message in Mime Format. If you see this, '
. "your mail reader does not support this format." . $EOL;
foreach (array_keys($this->_parts) as $p) {
$body .= $boundaryLine
. $this->getPartHeaders($p, $EOL)
. $EOL
. $this->getPartContent($p, $EOL);
}
$body .= $mime->mimeEnd($EOL);
}
return trim($body);
} | php | public function generateMessage($EOL = Zend_Mime::LINEEND)
{
if (! $this->isMultiPart()) {
$body = array_shift($this->_parts);
$body = $body->getContent($EOL);
} else {
$mime = $this->getMime();
$boundaryLine = $mime->boundaryLine($EOL);
$body = 'This is a message in Mime Format. If you see this, '
. "your mail reader does not support this format." . $EOL;
foreach (array_keys($this->_parts) as $p) {
$body .= $boundaryLine
. $this->getPartHeaders($p, $EOL)
. $EOL
. $this->getPartContent($p, $EOL);
}
$body .= $mime->mimeEnd($EOL);
}
return trim($body);
} | [
"public",
"function",
"generateMessage",
"(",
"$",
"EOL",
"=",
"Zend_Mime",
"::",
"LINEEND",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isMultiPart",
"(",
")",
")",
"{",
"$",
"body",
"=",
"array_shift",
"(",
"$",
"this",
"->",
"_parts",
")",
";",
"$",
"body",
"=",
"$",
"body",
"->",
"getContent",
"(",
"$",
"EOL",
")",
";",
"}",
"else",
"{",
"$",
"mime",
"=",
"$",
"this",
"->",
"getMime",
"(",
")",
";",
"$",
"boundaryLine",
"=",
"$",
"mime",
"->",
"boundaryLine",
"(",
"$",
"EOL",
")",
";",
"$",
"body",
"=",
"'This is a message in Mime Format. If you see this, '",
".",
"\"your mail reader does not support this format.\"",
".",
"$",
"EOL",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_parts",
")",
"as",
"$",
"p",
")",
"{",
"$",
"body",
".=",
"$",
"boundaryLine",
".",
"$",
"this",
"->",
"getPartHeaders",
"(",
"$",
"p",
",",
"$",
"EOL",
")",
".",
"$",
"EOL",
".",
"$",
"this",
"->",
"getPartContent",
"(",
"$",
"p",
",",
"$",
"EOL",
")",
";",
"}",
"$",
"body",
".=",
"$",
"mime",
"->",
"mimeEnd",
"(",
"$",
"EOL",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"body",
")",
";",
"}"
] | Generate MIME-compliant message from the current configuration
This can be a multipart message if more than one MIME part was added. If
only one part is present, the content of this part is returned. If no
part had been added, an empty string is returned.
Parts are seperated by the mime boundary as defined in Zend_Mime. If
{@link setMime()} has been called before this method, the Zend_Mime
object set by this call will be used. Otherwise, a new Zend_Mime object
is generated and used.
@param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
@return string | [
"Generate",
"MIME",
"-",
"compliant",
"message",
"from",
"the",
"current",
"configuration"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Message.php#L135-L158 |
209,690 | matomo-org/matomo | libs/Zend/Mime/Message.php | Zend_Mime_Message.getPartHeaders | public function getPartHeaders($partnum, $EOL = Zend_Mime::LINEEND)
{
return $this->_parts[$partnum]->getHeaders($EOL);
} | php | public function getPartHeaders($partnum, $EOL = Zend_Mime::LINEEND)
{
return $this->_parts[$partnum]->getHeaders($EOL);
} | [
"public",
"function",
"getPartHeaders",
"(",
"$",
"partnum",
",",
"$",
"EOL",
"=",
"Zend_Mime",
"::",
"LINEEND",
")",
"{",
"return",
"$",
"this",
"->",
"_parts",
"[",
"$",
"partnum",
"]",
"->",
"getHeaders",
"(",
"$",
"EOL",
")",
";",
"}"
] | Get the headers of a given part as a string
@param int $partnum
@return string | [
"Get",
"the",
"headers",
"of",
"a",
"given",
"part",
"as",
"a",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Message.php#L177-L180 |
209,691 | matomo-org/matomo | libs/Zend/Mime/Message.php | Zend_Mime_Message.createFromMessage | public static function createFromMessage($message, $boundary, $EOL = Zend_Mime::LINEEND)
{
// require_once 'Zend/Mime/Decode.php';
$parts = Zend_Mime_Decode::splitMessageStruct($message, $boundary, $EOL);
$res = new self();
foreach ($parts as $part) {
// now we build a new MimePart for the current Message Part:
$newPart = new Zend_Mime_Part($part['body']);
foreach ($part['header'] as $key => $value) {
/**
* @todo check for characterset and filename
*/
switch(strtolower($key)) {
case 'content-type':
$newPart->type = $value;
break;
case 'content-transfer-encoding':
$newPart->encoding = $value;
break;
case 'content-id':
$newPart->id = trim($value,'<>');
break;
case 'content-disposition':
$newPart->disposition = $value;
break;
case 'content-description':
$newPart->description = $value;
break;
case 'content-location':
$newPart->location = $value;
break;
case 'content-language':
$newPart->language = $value;
break;
default:
throw new Zend_Exception('Unknown header ignored for MimePart:' . $key);
}
}
$res->addPart($newPart);
}
return $res;
} | php | public static function createFromMessage($message, $boundary, $EOL = Zend_Mime::LINEEND)
{
// require_once 'Zend/Mime/Decode.php';
$parts = Zend_Mime_Decode::splitMessageStruct($message, $boundary, $EOL);
$res = new self();
foreach ($parts as $part) {
// now we build a new MimePart for the current Message Part:
$newPart = new Zend_Mime_Part($part['body']);
foreach ($part['header'] as $key => $value) {
/**
* @todo check for characterset and filename
*/
switch(strtolower($key)) {
case 'content-type':
$newPart->type = $value;
break;
case 'content-transfer-encoding':
$newPart->encoding = $value;
break;
case 'content-id':
$newPart->id = trim($value,'<>');
break;
case 'content-disposition':
$newPart->disposition = $value;
break;
case 'content-description':
$newPart->description = $value;
break;
case 'content-location':
$newPart->location = $value;
break;
case 'content-language':
$newPart->language = $value;
break;
default:
throw new Zend_Exception('Unknown header ignored for MimePart:' . $key);
}
}
$res->addPart($newPart);
}
return $res;
} | [
"public",
"static",
"function",
"createFromMessage",
"(",
"$",
"message",
",",
"$",
"boundary",
",",
"$",
"EOL",
"=",
"Zend_Mime",
"::",
"LINEEND",
")",
"{",
"// require_once 'Zend/Mime/Decode.php';",
"$",
"parts",
"=",
"Zend_Mime_Decode",
"::",
"splitMessageStruct",
"(",
"$",
"message",
",",
"$",
"boundary",
",",
"$",
"EOL",
")",
";",
"$",
"res",
"=",
"new",
"self",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"// now we build a new MimePart for the current Message Part:",
"$",
"newPart",
"=",
"new",
"Zend_Mime_Part",
"(",
"$",
"part",
"[",
"'body'",
"]",
")",
";",
"foreach",
"(",
"$",
"part",
"[",
"'header'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"/**\n * @todo check for characterset and filename\n */",
"switch",
"(",
"strtolower",
"(",
"$",
"key",
")",
")",
"{",
"case",
"'content-type'",
":",
"$",
"newPart",
"->",
"type",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'content-transfer-encoding'",
":",
"$",
"newPart",
"->",
"encoding",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'content-id'",
":",
"$",
"newPart",
"->",
"id",
"=",
"trim",
"(",
"$",
"value",
",",
"'<>'",
")",
";",
"break",
";",
"case",
"'content-disposition'",
":",
"$",
"newPart",
"->",
"disposition",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'content-description'",
":",
"$",
"newPart",
"->",
"description",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'content-location'",
":",
"$",
"newPart",
"->",
"location",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'content-language'",
":",
"$",
"newPart",
"->",
"language",
"=",
"$",
"value",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Zend_Exception",
"(",
"'Unknown header ignored for MimePart:'",
".",
"$",
"key",
")",
";",
"}",
"}",
"$",
"res",
"->",
"addPart",
"(",
"$",
"newPart",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Decodes a MIME encoded string and returns a Zend_Mime_Message object with
all the MIME parts set according to the given string
@param string $message
@param string $boundary
@param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
@return Zend_Mime_Message | [
"Decodes",
"a",
"MIME",
"encoded",
"string",
"and",
"returns",
"a",
"Zend_Mime_Message",
"object",
"with",
"all",
"the",
"MIME",
"parts",
"set",
"according",
"to",
"the",
"given",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Message.php#L243-L285 |
209,692 | matomo-org/matomo | core/ProfessionalServices/Advertising.php | Advertising.getPromoUrlForProfessionalServices | public function getPromoUrlForProfessionalServices($campaignMedium, $campaignContent = '')
{
$url = 'https://matomo.org/support/?';
$campaign = $this->getCampaignParametersForPromoUrl(
$name = self::CAMPAIGN_NAME_PROFESSIONAL_SERVICES,
$campaignMedium,
$campaignContent
);
return $url . $campaign;
} | php | public function getPromoUrlForProfessionalServices($campaignMedium, $campaignContent = '')
{
$url = 'https://matomo.org/support/?';
$campaign = $this->getCampaignParametersForPromoUrl(
$name = self::CAMPAIGN_NAME_PROFESSIONAL_SERVICES,
$campaignMedium,
$campaignContent
);
return $url . $campaign;
} | [
"public",
"function",
"getPromoUrlForProfessionalServices",
"(",
"$",
"campaignMedium",
",",
"$",
"campaignContent",
"=",
"''",
")",
"{",
"$",
"url",
"=",
"'https://matomo.org/support/?'",
";",
"$",
"campaign",
"=",
"$",
"this",
"->",
"getCampaignParametersForPromoUrl",
"(",
"$",
"name",
"=",
"self",
"::",
"CAMPAIGN_NAME_PROFESSIONAL_SERVICES",
",",
"$",
"campaignMedium",
",",
"$",
"campaignContent",
")",
";",
"return",
"$",
"url",
".",
"$",
"campaign",
";",
"}"
] | Get URL for promoting Professional Services for Piwik
@param string $campaignMedium
@param string $campaignContent
@return string | [
"Get",
"URL",
"for",
"promoting",
"Professional",
"Services",
"for",
"Piwik"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ProfessionalServices/Advertising.php#L56-L67 |
209,693 | matomo-org/matomo | core/ProfessionalServices/Advertising.php | Advertising.addPromoCampaignParametersToUrl | public function addPromoCampaignParametersToUrl($url, $campaignName, $campaignMedium, $campaignContent = '')
{
if (empty($url)) {
return '';
}
if (strpos($url, '?') === false) {
$url .= '?';
} else {
$url .= '&';
}
$url .= $this->getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent);
return $url;
} | php | public function addPromoCampaignParametersToUrl($url, $campaignName, $campaignMedium, $campaignContent = '')
{
if (empty($url)) {
return '';
}
if (strpos($url, '?') === false) {
$url .= '?';
} else {
$url .= '&';
}
$url .= $this->getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent);
return $url;
} | [
"public",
"function",
"addPromoCampaignParametersToUrl",
"(",
"$",
"url",
",",
"$",
"campaignName",
",",
"$",
"campaignMedium",
",",
"$",
"campaignContent",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"'?'",
")",
"===",
"false",
")",
"{",
"$",
"url",
".=",
"'?'",
";",
"}",
"else",
"{",
"$",
"url",
".=",
"'&'",
";",
"}",
"$",
"url",
".=",
"$",
"this",
"->",
"getCampaignParametersForPromoUrl",
"(",
"$",
"campaignName",
",",
"$",
"campaignMedium",
",",
"$",
"campaignContent",
")",
";",
"return",
"$",
"url",
";",
"}"
] | Appends campaign parameters to the given URL for promoting any Professional Support for Piwik service.
@param string $url
@param string $campaignName
@param string $campaignMedium
@param string $campaignContent
@return string | [
"Appends",
"campaign",
"parameters",
"to",
"the",
"given",
"URL",
"for",
"promoting",
"any",
"Professional",
"Support",
"for",
"Piwik",
"service",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ProfessionalServices/Advertising.php#L78-L93 |
209,694 | matomo-org/matomo | core/ProfessionalServices/Advertising.php | Advertising.getCampaignParametersForPromoUrl | private function getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent = '')
{
$campaignName = sprintf('pk_campaign=%s&pk_medium=%s&pk_source=Piwik_App', $campaignName, $campaignMedium);
if (!empty($campaignContent)) {
$campaignName .= '&pk_content=' . $campaignContent;
}
return $campaignName;
} | php | private function getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent = '')
{
$campaignName = sprintf('pk_campaign=%s&pk_medium=%s&pk_source=Piwik_App', $campaignName, $campaignMedium);
if (!empty($campaignContent)) {
$campaignName .= '&pk_content=' . $campaignContent;
}
return $campaignName;
} | [
"private",
"function",
"getCampaignParametersForPromoUrl",
"(",
"$",
"campaignName",
",",
"$",
"campaignMedium",
",",
"$",
"campaignContent",
"=",
"''",
")",
"{",
"$",
"campaignName",
"=",
"sprintf",
"(",
"'pk_campaign=%s&pk_medium=%s&pk_source=Piwik_App'",
",",
"$",
"campaignName",
",",
"$",
"campaignMedium",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"campaignContent",
")",
")",
"{",
"$",
"campaignName",
".=",
"'&pk_content='",
".",
"$",
"campaignContent",
";",
"}",
"return",
"$",
"campaignName",
";",
"}"
] | Generates campaign URL parameters that can be used with promoting Professional Support service.
@param string $campaignName
@param string $campaignMedium
@param string $campaignContent Optional
@return string URL parameters without a leading ? or & | [
"Generates",
"campaign",
"URL",
"parameters",
"that",
"can",
"be",
"used",
"with",
"promoting",
"Professional",
"Support",
"service",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ProfessionalServices/Advertising.php#L103-L112 |
209,695 | matomo-org/matomo | libs/Zend/Mime/Part.php | Zend_Mime_Part.getEncodedStream | public function getEncodedStream()
{
if (!$this->_isStream) {
// require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Attempt to get a stream from a string part');
}
//stream_filter_remove(); // ??? is that right?
switch ($this->encoding) {
case Zend_Mime::ENCODING_QUOTEDPRINTABLE:
$filter = stream_filter_append(
$this->_content,
'convert.quoted-printable-encode',
STREAM_FILTER_READ,
array(
'line-length' => 76,
'line-break-chars' => Zend_Mime::LINEEND
)
);
if (!is_resource($filter)) {
// require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Failed to append quoted-printable filter');
}
break;
case Zend_Mime::ENCODING_BASE64:
$filter = stream_filter_append(
$this->_content,
'convert.base64-encode',
STREAM_FILTER_READ,
array(
'line-length' => 76,
'line-break-chars' => Zend_Mime::LINEEND
)
);
if (!is_resource($filter)) {
// require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Failed to append base64 filter');
}
break;
default:
}
return $this->_content;
} | php | public function getEncodedStream()
{
if (!$this->_isStream) {
// require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Attempt to get a stream from a string part');
}
//stream_filter_remove(); // ??? is that right?
switch ($this->encoding) {
case Zend_Mime::ENCODING_QUOTEDPRINTABLE:
$filter = stream_filter_append(
$this->_content,
'convert.quoted-printable-encode',
STREAM_FILTER_READ,
array(
'line-length' => 76,
'line-break-chars' => Zend_Mime::LINEEND
)
);
if (!is_resource($filter)) {
// require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Failed to append quoted-printable filter');
}
break;
case Zend_Mime::ENCODING_BASE64:
$filter = stream_filter_append(
$this->_content,
'convert.base64-encode',
STREAM_FILTER_READ,
array(
'line-length' => 76,
'line-break-chars' => Zend_Mime::LINEEND
)
);
if (!is_resource($filter)) {
// require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Failed to append base64 filter');
}
break;
default:
}
return $this->_content;
} | [
"public",
"function",
"getEncodedStream",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isStream",
")",
"{",
"// require_once 'Zend/Mime/Exception.php';",
"throw",
"new",
"Zend_Mime_Exception",
"(",
"'Attempt to get a stream from a string part'",
")",
";",
"}",
"//stream_filter_remove(); // ??? is that right?",
"switch",
"(",
"$",
"this",
"->",
"encoding",
")",
"{",
"case",
"Zend_Mime",
"::",
"ENCODING_QUOTEDPRINTABLE",
":",
"$",
"filter",
"=",
"stream_filter_append",
"(",
"$",
"this",
"->",
"_content",
",",
"'convert.quoted-printable-encode'",
",",
"STREAM_FILTER_READ",
",",
"array",
"(",
"'line-length'",
"=>",
"76",
",",
"'line-break-chars'",
"=>",
"Zend_Mime",
"::",
"LINEEND",
")",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"filter",
")",
")",
"{",
"// require_once 'Zend/Mime/Exception.php';",
"throw",
"new",
"Zend_Mime_Exception",
"(",
"'Failed to append quoted-printable filter'",
")",
";",
"}",
"break",
";",
"case",
"Zend_Mime",
"::",
"ENCODING_BASE64",
":",
"$",
"filter",
"=",
"stream_filter_append",
"(",
"$",
"this",
"->",
"_content",
",",
"'convert.base64-encode'",
",",
"STREAM_FILTER_READ",
",",
"array",
"(",
"'line-length'",
"=>",
"76",
",",
"'line-break-chars'",
"=>",
"Zend_Mime",
"::",
"LINEEND",
")",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"filter",
")",
")",
"{",
"// require_once 'Zend/Mime/Exception.php';",
"throw",
"new",
"Zend_Mime_Exception",
"(",
"'Failed to append base64 filter'",
")",
";",
"}",
"break",
";",
"default",
":",
"}",
"return",
"$",
"this",
"->",
"_content",
";",
"}"
] | if this was created with a stream, return a filtered stream for
reading the content. very useful for large file attachments.
@return stream
@throws Zend_Mime_Exception if not a stream or unable to append filter | [
"if",
"this",
"was",
"created",
"with",
"a",
"stream",
"return",
"a",
"filtered",
"stream",
"for",
"reading",
"the",
"content",
".",
"very",
"useful",
"for",
"large",
"file",
"attachments",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Part.php#L92-L134 |
209,696 | matomo-org/matomo | libs/Zend/Mime/Part.php | Zend_Mime_Part.getContent | public function getContent($EOL = Zend_Mime::LINEEND)
{
if ($this->_isStream) {
return stream_get_contents($this->getEncodedStream());
} else {
return Zend_Mime::encode($this->_content, $this->encoding, $EOL);
}
} | php | public function getContent($EOL = Zend_Mime::LINEEND)
{
if ($this->_isStream) {
return stream_get_contents($this->getEncodedStream());
} else {
return Zend_Mime::encode($this->_content, $this->encoding, $EOL);
}
} | [
"public",
"function",
"getContent",
"(",
"$",
"EOL",
"=",
"Zend_Mime",
"::",
"LINEEND",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isStream",
")",
"{",
"return",
"stream_get_contents",
"(",
"$",
"this",
"->",
"getEncodedStream",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"Zend_Mime",
"::",
"encode",
"(",
"$",
"this",
"->",
"_content",
",",
"$",
"this",
"->",
"encoding",
",",
"$",
"EOL",
")",
";",
"}",
"}"
] | Get the Content of the current Mime Part in the given encoding.
@return String | [
"Get",
"the",
"Content",
"of",
"the",
"current",
"Mime",
"Part",
"in",
"the",
"given",
"encoding",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Part.php#L141-L148 |
209,697 | matomo-org/matomo | libs/Zend/Mime/Part.php | Zend_Mime_Part.getHeadersArray | public function getHeadersArray($EOL = Zend_Mime::LINEEND)
{
$headers = array();
$contentType = $this->type;
if ($this->charset) {
$contentType .= '; charset=' . $this->charset;
}
if ($this->boundary) {
$contentType .= ';' . $EOL
. " boundary=\"" . $this->boundary . '"';
}
$headers[] = array('Content-Type', $contentType);
if ($this->encoding) {
$headers[] = array('Content-Transfer-Encoding', $this->encoding);
}
if ($this->id) {
$headers[] = array('Content-ID', '<' . $this->id . '>');
}
if ($this->disposition) {
$disposition = $this->disposition;
if ($this->filename) {
$disposition .= '; filename="' . $this->filename . '"';
}
$headers[] = array('Content-Disposition', $disposition);
}
if ($this->description) {
$headers[] = array('Content-Description', $this->description);
}
if ($this->location) {
$headers[] = array('Content-Location', $this->location);
}
if ($this->language){
$headers[] = array('Content-Language', $this->language);
}
return $headers;
} | php | public function getHeadersArray($EOL = Zend_Mime::LINEEND)
{
$headers = array();
$contentType = $this->type;
if ($this->charset) {
$contentType .= '; charset=' . $this->charset;
}
if ($this->boundary) {
$contentType .= ';' . $EOL
. " boundary=\"" . $this->boundary . '"';
}
$headers[] = array('Content-Type', $contentType);
if ($this->encoding) {
$headers[] = array('Content-Transfer-Encoding', $this->encoding);
}
if ($this->id) {
$headers[] = array('Content-ID', '<' . $this->id . '>');
}
if ($this->disposition) {
$disposition = $this->disposition;
if ($this->filename) {
$disposition .= '; filename="' . $this->filename . '"';
}
$headers[] = array('Content-Disposition', $disposition);
}
if ($this->description) {
$headers[] = array('Content-Description', $this->description);
}
if ($this->location) {
$headers[] = array('Content-Location', $this->location);
}
if ($this->language){
$headers[] = array('Content-Language', $this->language);
}
return $headers;
} | [
"public",
"function",
"getHeadersArray",
"(",
"$",
"EOL",
"=",
"Zend_Mime",
"::",
"LINEEND",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"contentType",
"=",
"$",
"this",
"->",
"type",
";",
"if",
"(",
"$",
"this",
"->",
"charset",
")",
"{",
"$",
"contentType",
".=",
"'; charset='",
".",
"$",
"this",
"->",
"charset",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"boundary",
")",
"{",
"$",
"contentType",
".=",
"';'",
".",
"$",
"EOL",
".",
"\" boundary=\\\"\"",
".",
"$",
"this",
"->",
"boundary",
".",
"'\"'",
";",
"}",
"$",
"headers",
"[",
"]",
"=",
"array",
"(",
"'Content-Type'",
",",
"$",
"contentType",
")",
";",
"if",
"(",
"$",
"this",
"->",
"encoding",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"array",
"(",
"'Content-Transfer-Encoding'",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"id",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"array",
"(",
"'Content-ID'",
",",
"'<'",
".",
"$",
"this",
"->",
"id",
".",
"'>'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"disposition",
")",
"{",
"$",
"disposition",
"=",
"$",
"this",
"->",
"disposition",
";",
"if",
"(",
"$",
"this",
"->",
"filename",
")",
"{",
"$",
"disposition",
".=",
"'; filename=\"'",
".",
"$",
"this",
"->",
"filename",
".",
"'\"'",
";",
"}",
"$",
"headers",
"[",
"]",
"=",
"array",
"(",
"'Content-Disposition'",
",",
"$",
"disposition",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"description",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"array",
"(",
"'Content-Description'",
",",
"$",
"this",
"->",
"description",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"location",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"array",
"(",
"'Content-Location'",
",",
"$",
"this",
"->",
"location",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"language",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"array",
"(",
"'Content-Language'",
",",
"$",
"this",
"->",
"language",
")",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] | Create and return the array of headers for this MIME part
@access public
@return array | [
"Create",
"and",
"return",
"the",
"array",
"of",
"headers",
"for",
"this",
"MIME",
"part"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Part.php#L169-L214 |
209,698 | matomo-org/matomo | libs/Zend/Mime/Part.php | Zend_Mime_Part.getHeaders | public function getHeaders($EOL = Zend_Mime::LINEEND)
{
$res = '';
foreach ($this->getHeadersArray($EOL) as $header) {
$res .= $header[0] . ': ' . $header[1] . $EOL;
}
return $res;
} | php | public function getHeaders($EOL = Zend_Mime::LINEEND)
{
$res = '';
foreach ($this->getHeadersArray($EOL) as $header) {
$res .= $header[0] . ': ' . $header[1] . $EOL;
}
return $res;
} | [
"public",
"function",
"getHeaders",
"(",
"$",
"EOL",
"=",
"Zend_Mime",
"::",
"LINEEND",
")",
"{",
"$",
"res",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"getHeadersArray",
"(",
"$",
"EOL",
")",
"as",
"$",
"header",
")",
"{",
"$",
"res",
".=",
"$",
"header",
"[",
"0",
"]",
".",
"': '",
".",
"$",
"header",
"[",
"1",
"]",
".",
"$",
"EOL",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Return the headers for this part as a string
@return String | [
"Return",
"the",
"headers",
"for",
"this",
"part",
"as",
"a",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Part.php#L221-L229 |
209,699 | matomo-org/matomo | core/Filesystem.php | Filesystem.mkdir | public static function mkdir($path)
{
if (!is_dir($path)) {
// the mode in mkdir is modified by the current umask
@mkdir($path, self::getChmodForPath($path), $recursive = true);
}
// try to overcome restrictive umask (mis-)configuration
if (!is_writable($path)) {
@chmod($path, 0755);
if (!is_writable($path)) {
@chmod($path, 0775);
// enough! we're not going to make the directory world-writeable
}
}
self::createIndexFilesToPreventDirectoryListing($path);
} | php | public static function mkdir($path)
{
if (!is_dir($path)) {
// the mode in mkdir is modified by the current umask
@mkdir($path, self::getChmodForPath($path), $recursive = true);
}
// try to overcome restrictive umask (mis-)configuration
if (!is_writable($path)) {
@chmod($path, 0755);
if (!is_writable($path)) {
@chmod($path, 0775);
// enough! we're not going to make the directory world-writeable
}
}
self::createIndexFilesToPreventDirectoryListing($path);
} | [
"public",
"static",
"function",
"mkdir",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"// the mode in mkdir is modified by the current umask",
"@",
"mkdir",
"(",
"$",
"path",
",",
"self",
"::",
"getChmodForPath",
"(",
"$",
"path",
")",
",",
"$",
"recursive",
"=",
"true",
")",
";",
"}",
"// try to overcome restrictive umask (mis-)configuration",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"path",
")",
")",
"{",
"@",
"chmod",
"(",
"$",
"path",
",",
"0755",
")",
";",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"path",
")",
")",
"{",
"@",
"chmod",
"(",
"$",
"path",
",",
"0775",
")",
";",
"// enough! we're not going to make the directory world-writeable",
"}",
"}",
"self",
"::",
"createIndexFilesToPreventDirectoryListing",
"(",
"$",
"path",
")",
";",
"}"
] | Attempts to create a new directory. All errors are silenced.
_Note: This function does **not** create directories recursively._
@param string $path The path of the directory to create.
@api | [
"Attempts",
"to",
"create",
"a",
"new",
"directory",
".",
"All",
"errors",
"are",
"silenced",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L97-L114 |
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.