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,700
matomo-org/matomo
core/Filesystem.php
Filesystem.checkIfFileSystemIsNFS
public static function checkIfFileSystemIsNFS() { $sessionsPath = Session::getSessionsDirectory(); // this command will display details for the filesystem that holds the $sessionsPath // path, but only if its type is NFS. if not NFS, df will return one or less lines // and the return code 1. if NFS, it will return 0 and at least 2 lines of text. $command = "df -T -t nfs \"$sessionsPath\" 2>&1"; if (function_exists('exec')) { // use exec $output = $returnCode = null; @exec($command, $output, $returnCode); // check if filesystem is NFS if ($returnCode == 0 && count($output) > 1 ) { return true; } } elseif (function_exists('shell_exec')) { // use shell_exec $output = @shell_exec($command); if ($output) { $commandFailed = (false !== strpos($output, "no file systems processed")); $output = explode("\n", trim($output)); if (!$commandFailed && count($output) > 1) { // check if filesystem is NFS return true; } } } return false; // not NFS, or we can't run a program to find out }
php
public static function checkIfFileSystemIsNFS() { $sessionsPath = Session::getSessionsDirectory(); // this command will display details for the filesystem that holds the $sessionsPath // path, but only if its type is NFS. if not NFS, df will return one or less lines // and the return code 1. if NFS, it will return 0 and at least 2 lines of text. $command = "df -T -t nfs \"$sessionsPath\" 2>&1"; if (function_exists('exec')) { // use exec $output = $returnCode = null; @exec($command, $output, $returnCode); // check if filesystem is NFS if ($returnCode == 0 && count($output) > 1 ) { return true; } } elseif (function_exists('shell_exec')) { // use shell_exec $output = @shell_exec($command); if ($output) { $commandFailed = (false !== strpos($output, "no file systems processed")); $output = explode("\n", trim($output)); if (!$commandFailed && count($output) > 1) { // check if filesystem is NFS return true; } } } return false; // not NFS, or we can't run a program to find out }
[ "public", "static", "function", "checkIfFileSystemIsNFS", "(", ")", "{", "$", "sessionsPath", "=", "Session", "::", "getSessionsDirectory", "(", ")", ";", "// this command will display details for the filesystem that holds the $sessionsPath", "// path, but only if its type is NFS. if not NFS, df will return one or less lines", "// and the return code 1. if NFS, it will return 0 and at least 2 lines of text.", "$", "command", "=", "\"df -T -t nfs \\\"$sessionsPath\\\" 2>&1\"", ";", "if", "(", "function_exists", "(", "'exec'", ")", ")", "{", "// use exec", "$", "output", "=", "$", "returnCode", "=", "null", ";", "@", "exec", "(", "$", "command", ",", "$", "output", ",", "$", "returnCode", ")", ";", "// check if filesystem is NFS", "if", "(", "$", "returnCode", "==", "0", "&&", "count", "(", "$", "output", ")", ">", "1", ")", "{", "return", "true", ";", "}", "}", "elseif", "(", "function_exists", "(", "'shell_exec'", ")", ")", "{", "// use shell_exec", "$", "output", "=", "@", "shell_exec", "(", "$", "command", ")", ";", "if", "(", "$", "output", ")", "{", "$", "commandFailed", "=", "(", "false", "!==", "strpos", "(", "$", "output", ",", "\"no file systems processed\"", ")", ")", ";", "$", "output", "=", "explode", "(", "\"\\n\"", ",", "trim", "(", "$", "output", ")", ")", ";", "if", "(", "!", "$", "commandFailed", "&&", "count", "(", "$", "output", ")", ">", "1", ")", "{", "// check if filesystem is NFS", "return", "true", ";", "}", "}", "}", "return", "false", ";", "// not NFS, or we can't run a program to find out", "}" ]
Checks if the filesystem Piwik stores sessions in is NFS or not. This check is done in order to avoid using file based sessions on NFS system, since on such a filesystem file locking can make file based sessions incredibly slow. Note: In order to figure this out, we try to run the 'df' program. If the 'exec' or 'shell_exec' functions are not available, we can't do the check. @return bool True if on an NFS filesystem, false if otherwise or if we can't use shell_exec or exec.
[ "Checks", "if", "the", "filesystem", "Piwik", "stores", "sessions", "in", "is", "NFS", "or", "not", ".", "This", "check", "is", "done", "in", "order", "to", "avoid", "using", "file", "based", "sessions", "on", "NFS", "system", "since", "on", "such", "a", "filesystem", "file", "locking", "can", "make", "file", "based", "sessions", "incredibly", "slow", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L129-L166
209,701
matomo-org/matomo
core/Filesystem.php
Filesystem.globr
public static function globr($sDir, $sPattern, $nFlags = null) { if (($aFiles = \_glob("$sDir/$sPattern", $nFlags)) == false) { $aFiles = array(); } if (($aDirs = \_glob("$sDir/*", GLOB_ONLYDIR)) != false) { foreach ($aDirs as $sSubDir) { if (is_link($sSubDir)) { continue; } $aSubFiles = self::globr($sSubDir, $sPattern, $nFlags); $aFiles = array_merge($aFiles, $aSubFiles); } } sort($aFiles); return $aFiles; }
php
public static function globr($sDir, $sPattern, $nFlags = null) { if (($aFiles = \_glob("$sDir/$sPattern", $nFlags)) == false) { $aFiles = array(); } if (($aDirs = \_glob("$sDir/*", GLOB_ONLYDIR)) != false) { foreach ($aDirs as $sSubDir) { if (is_link($sSubDir)) { continue; } $aSubFiles = self::globr($sSubDir, $sPattern, $nFlags); $aFiles = array_merge($aFiles, $aSubFiles); } } sort($aFiles); return $aFiles; }
[ "public", "static", "function", "globr", "(", "$", "sDir", ",", "$", "sPattern", ",", "$", "nFlags", "=", "null", ")", "{", "if", "(", "(", "$", "aFiles", "=", "\\", "_glob", "(", "\"$sDir/$sPattern\"", ",", "$", "nFlags", ")", ")", "==", "false", ")", "{", "$", "aFiles", "=", "array", "(", ")", ";", "}", "if", "(", "(", "$", "aDirs", "=", "\\", "_glob", "(", "\"$sDir/*\"", ",", "GLOB_ONLYDIR", ")", ")", "!=", "false", ")", "{", "foreach", "(", "$", "aDirs", "as", "$", "sSubDir", ")", "{", "if", "(", "is_link", "(", "$", "sSubDir", ")", ")", "{", "continue", ";", "}", "$", "aSubFiles", "=", "self", "::", "globr", "(", "$", "sSubDir", ",", "$", "sPattern", ",", "$", "nFlags", ")", ";", "$", "aFiles", "=", "array_merge", "(", "$", "aFiles", ",", "$", "aSubFiles", ")", ";", "}", "}", "sort", "(", "$", "aFiles", ")", ";", "return", "$", "aFiles", ";", "}" ]
Recursively find pathnames that match a pattern. See {@link http://php.net/manual/en/function.glob.php glob} for more info. @param string $sDir directory The directory to glob in. @param string $sPattern pattern The pattern to match paths against. @param int $nFlags `glob()` . See {@link http://php.net/manual/en/function.glob.php glob()}. @return array The list of paths that match the pattern. @api
[ "Recursively", "find", "pathnames", "that", "match", "a", "pattern", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L179-L196
209,702
matomo-org/matomo
core/Filesystem.php
Filesystem.unlinkRecursive
public static function unlinkRecursive($dir, $deleteRootToo, \Closure $beforeUnlink = null) { if (!$dh = @opendir($dir)) { return; } while (false !== ($obj = readdir($dh))) { if ($obj == '.' || $obj == '..') { continue; } $path = $dir . '/' . $obj; if ($beforeUnlink) { $beforeUnlink($path); } if (!@unlink($path)) { self::unlinkRecursive($path, true); } } closedir($dh); if ($deleteRootToo) { @rmdir($dir); } return; }
php
public static function unlinkRecursive($dir, $deleteRootToo, \Closure $beforeUnlink = null) { if (!$dh = @opendir($dir)) { return; } while (false !== ($obj = readdir($dh))) { if ($obj == '.' || $obj == '..') { continue; } $path = $dir . '/' . $obj; if ($beforeUnlink) { $beforeUnlink($path); } if (!@unlink($path)) { self::unlinkRecursive($path, true); } } closedir($dh); if ($deleteRootToo) { @rmdir($dir); } return; }
[ "public", "static", "function", "unlinkRecursive", "(", "$", "dir", ",", "$", "deleteRootToo", ",", "\\", "Closure", "$", "beforeUnlink", "=", "null", ")", "{", "if", "(", "!", "$", "dh", "=", "@", "opendir", "(", "$", "dir", ")", ")", "{", "return", ";", "}", "while", "(", "false", "!==", "(", "$", "obj", "=", "readdir", "(", "$", "dh", ")", ")", ")", "{", "if", "(", "$", "obj", "==", "'.'", "||", "$", "obj", "==", "'..'", ")", "{", "continue", ";", "}", "$", "path", "=", "$", "dir", ".", "'/'", ".", "$", "obj", ";", "if", "(", "$", "beforeUnlink", ")", "{", "$", "beforeUnlink", "(", "$", "path", ")", ";", "}", "if", "(", "!", "@", "unlink", "(", "$", "path", ")", ")", "{", "self", "::", "unlinkRecursive", "(", "$", "path", ",", "true", ")", ";", "}", "}", "closedir", "(", "$", "dh", ")", ";", "if", "(", "$", "deleteRootToo", ")", "{", "@", "rmdir", "(", "$", "dir", ")", ";", "}", "return", ";", "}" ]
Recursively deletes a directory. @param string $dir Path of the directory to delete. @param boolean $deleteRootToo If true, `$dir` is deleted, otherwise just its contents. @param \Closure|false $beforeUnlink An optional closure to execute on a file path before unlinking. @api
[ "Recursively", "deletes", "a", "directory", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L206-L230
209,703
matomo-org/matomo
core/Filesystem.php
Filesystem.unlinkTargetFilesNotPresentInSource
public static function unlinkTargetFilesNotPresentInSource($source, $target) { $diff = self::directoryDiff($source, $target); $diff = self::sortFilesDescByPathLength($diff); foreach ($diff as $file) { $remove = $target . $file; if (is_dir($remove)) { @rmdir($remove); } else { self::deleteFileIfExists($remove); } } }
php
public static function unlinkTargetFilesNotPresentInSource($source, $target) { $diff = self::directoryDiff($source, $target); $diff = self::sortFilesDescByPathLength($diff); foreach ($diff as $file) { $remove = $target . $file; if (is_dir($remove)) { @rmdir($remove); } else { self::deleteFileIfExists($remove); } } }
[ "public", "static", "function", "unlinkTargetFilesNotPresentInSource", "(", "$", "source", ",", "$", "target", ")", "{", "$", "diff", "=", "self", "::", "directoryDiff", "(", "$", "source", ",", "$", "target", ")", ";", "$", "diff", "=", "self", "::", "sortFilesDescByPathLength", "(", "$", "diff", ")", ";", "foreach", "(", "$", "diff", "as", "$", "file", ")", "{", "$", "remove", "=", "$", "target", ".", "$", "file", ";", "if", "(", "is_dir", "(", "$", "remove", ")", ")", "{", "@", "rmdir", "(", "$", "remove", ")", ";", "}", "else", "{", "self", "::", "deleteFileIfExists", "(", "$", "remove", ")", ";", "}", "}", "}" ]
Removes all files and directories that are present in the target directory but are not in the source directory. @param string $source Path to the source directory @param string $target Path to the target
[ "Removes", "all", "files", "and", "directories", "that", "are", "present", "in", "the", "target", "directory", "but", "are", "not", "in", "the", "source", "directory", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L238-L252
209,704
matomo-org/matomo
core/Filesystem.php
Filesystem.getFileSize
public static function getFileSize($pathToFile, $unit = 'B') { $unit = strtoupper($unit); $units = array('TB' => pow(1024, 4), 'GB' => pow(1024, 3), 'MB' => pow(1024, 2), 'KB' => 1024, 'B' => 1); if (!array_key_exists($unit, $units)) { throw new \Exception('Invalid unit given'); } if (!file_exists($pathToFile)) { return; } $filesize = filesize($pathToFile); $factor = $units[$unit]; $converted = $filesize / $factor; return $converted; }
php
public static function getFileSize($pathToFile, $unit = 'B') { $unit = strtoupper($unit); $units = array('TB' => pow(1024, 4), 'GB' => pow(1024, 3), 'MB' => pow(1024, 2), 'KB' => 1024, 'B' => 1); if (!array_key_exists($unit, $units)) { throw new \Exception('Invalid unit given'); } if (!file_exists($pathToFile)) { return; } $filesize = filesize($pathToFile); $factor = $units[$unit]; $converted = $filesize / $factor; return $converted; }
[ "public", "static", "function", "getFileSize", "(", "$", "pathToFile", ",", "$", "unit", "=", "'B'", ")", "{", "$", "unit", "=", "strtoupper", "(", "$", "unit", ")", ";", "$", "units", "=", "array", "(", "'TB'", "=>", "pow", "(", "1024", ",", "4", ")", ",", "'GB'", "=>", "pow", "(", "1024", ",", "3", ")", ",", "'MB'", "=>", "pow", "(", "1024", ",", "2", ")", ",", "'KB'", "=>", "1024", ",", "'B'", "=>", "1", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "unit", ",", "$", "units", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid unit given'", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "pathToFile", ")", ")", "{", "return", ";", "}", "$", "filesize", "=", "filesize", "(", "$", "pathToFile", ")", ";", "$", "factor", "=", "$", "units", "[", "$", "unit", "]", ";", "$", "converted", "=", "$", "filesize", "/", "$", "factor", ";", "return", "$", "converted", ";", "}" ]
Get the size of a file in the specified unit. @param string $pathToFile @param string $unit eg 'B' for Byte, 'KB', 'MB', 'GB', 'TB'. @return float|null Returns null if file does not exist or the size of the file in the specified unit @throws Exception In case the unit is invalid
[ "Get", "the", "size", "of", "a", "file", "in", "the", "specified", "unit", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L413-L435
209,705
matomo-org/matomo
core/FrontController.php
FrontController.dispatch
public function dispatch($module = null, $action = null, $parameters = null) { if (self::$enableDispatch === false) { return; } $filter = new Router(); $redirection = $filter->filterUrl(Url::getCurrentUrl()); if ($redirection !== null) { Url::redirectToUrl($redirection); return; } try { $result = $this->doDispatch($module, $action, $parameters); return $result; } catch (NoAccessException $exception) { Log::debug($exception); /** * Triggered when a user with insufficient access permissions tries to view some resource. * * This event can be used to customize the error that occurs when a user is denied access * (for example, displaying an error message, redirecting to a page other than login, etc.). * * @param \Piwik\NoAccessException $exception The exception that was caught. */ Piwik::postEvent('User.isNotAuthorized', array($exception), $pending = true); } catch (\Twig_Error_Runtime $e) { echo $this->generateSafeModeOutputFromException($e); exit; } catch(StylesheetLessCompileException $e) { echo $this->generateSafeModeOutputFromException($e); exit; } catch(\Error $e) { echo $this->generateSafeModeOutputFromException($e); exit; } }
php
public function dispatch($module = null, $action = null, $parameters = null) { if (self::$enableDispatch === false) { return; } $filter = new Router(); $redirection = $filter->filterUrl(Url::getCurrentUrl()); if ($redirection !== null) { Url::redirectToUrl($redirection); return; } try { $result = $this->doDispatch($module, $action, $parameters); return $result; } catch (NoAccessException $exception) { Log::debug($exception); /** * Triggered when a user with insufficient access permissions tries to view some resource. * * This event can be used to customize the error that occurs when a user is denied access * (for example, displaying an error message, redirecting to a page other than login, etc.). * * @param \Piwik\NoAccessException $exception The exception that was caught. */ Piwik::postEvent('User.isNotAuthorized', array($exception), $pending = true); } catch (\Twig_Error_Runtime $e) { echo $this->generateSafeModeOutputFromException($e); exit; } catch(StylesheetLessCompileException $e) { echo $this->generateSafeModeOutputFromException($e); exit; } catch(\Error $e) { echo $this->generateSafeModeOutputFromException($e); exit; } }
[ "public", "function", "dispatch", "(", "$", "module", "=", "null", ",", "$", "action", "=", "null", ",", "$", "parameters", "=", "null", ")", "{", "if", "(", "self", "::", "$", "enableDispatch", "===", "false", ")", "{", "return", ";", "}", "$", "filter", "=", "new", "Router", "(", ")", ";", "$", "redirection", "=", "$", "filter", "->", "filterUrl", "(", "Url", "::", "getCurrentUrl", "(", ")", ")", ";", "if", "(", "$", "redirection", "!==", "null", ")", "{", "Url", "::", "redirectToUrl", "(", "$", "redirection", ")", ";", "return", ";", "}", "try", "{", "$", "result", "=", "$", "this", "->", "doDispatch", "(", "$", "module", ",", "$", "action", ",", "$", "parameters", ")", ";", "return", "$", "result", ";", "}", "catch", "(", "NoAccessException", "$", "exception", ")", "{", "Log", "::", "debug", "(", "$", "exception", ")", ";", "/**\n * Triggered when a user with insufficient access permissions tries to view some resource.\n *\n * This event can be used to customize the error that occurs when a user is denied access\n * (for example, displaying an error message, redirecting to a page other than login, etc.).\n *\n * @param \\Piwik\\NoAccessException $exception The exception that was caught.\n */", "Piwik", "::", "postEvent", "(", "'User.isNotAuthorized'", ",", "array", "(", "$", "exception", ")", ",", "$", "pending", "=", "true", ")", ";", "}", "catch", "(", "\\", "Twig_Error_Runtime", "$", "e", ")", "{", "echo", "$", "this", "->", "generateSafeModeOutputFromException", "(", "$", "e", ")", ";", "exit", ";", "}", "catch", "(", "StylesheetLessCompileException", "$", "e", ")", "{", "echo", "$", "this", "->", "generateSafeModeOutputFromException", "(", "$", "e", ")", ";", "exit", ";", "}", "catch", "(", "\\", "Error", "$", "e", ")", "{", "echo", "$", "this", "->", "generateSafeModeOutputFromException", "(", "$", "e", ")", ";", "exit", ";", "}", "}" ]
Executes the requested plugin controller method. @throws Exception|\Piwik\Exception\PluginDeactivatedException in case the plugin doesn't exist, the action doesn't exist, there is not enough permission, etc. @param string $module The name of the plugin whose controller to execute, eg, `'UserCountryMap'`. @param string $action The controller method name, eg, `'realtimeMap'`. @param array $parameters Array of parameters to pass to the controller method. @return void|mixed The returned value of the call. This is the output of the controller method. @api
[ "Executes", "the", "requested", "plugin", "controller", "method", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FrontController.php#L151-L189
209,706
matomo-org/matomo
core/FrontController.php
FrontController.fetchDispatch
public function fetchDispatch($module = null, $actionName = null, $parameters = null) { ob_start(); $output = $this->dispatch($module, $actionName, $parameters); // if nothing returned we try to load something that was printed on the screen if (empty($output)) { $output = ob_get_contents(); } else { // if something was returned, flush output buffer as it is meant to be written to the screen ob_flush(); } ob_end_clean(); return $output; }
php
public function fetchDispatch($module = null, $actionName = null, $parameters = null) { ob_start(); $output = $this->dispatch($module, $actionName, $parameters); // if nothing returned we try to load something that was printed on the screen if (empty($output)) { $output = ob_get_contents(); } else { // if something was returned, flush output buffer as it is meant to be written to the screen ob_flush(); } ob_end_clean(); return $output; }
[ "public", "function", "fetchDispatch", "(", "$", "module", "=", "null", ",", "$", "actionName", "=", "null", ",", "$", "parameters", "=", "null", ")", "{", "ob_start", "(", ")", ";", "$", "output", "=", "$", "this", "->", "dispatch", "(", "$", "module", ",", "$", "actionName", ",", "$", "parameters", ")", ";", "// if nothing returned we try to load something that was printed on the screen", "if", "(", "empty", "(", "$", "output", ")", ")", "{", "$", "output", "=", "ob_get_contents", "(", ")", ";", "}", "else", "{", "// if something was returned, flush output buffer as it is meant to be written to the screen", "ob_flush", "(", ")", ";", "}", "ob_end_clean", "(", ")", ";", "return", "$", "output", ";", "}" ]
Executes the requested plugin controller method and returns the data, capturing anything the method `echo`s. _Note: If the plugin controller returns something, the return value is returned instead of whatever is in the output buffer._ @param string $module The name of the plugin whose controller to execute, eg, `'UserCountryMap'`. @param string $actionName The controller action name, eg, `'realtimeMap'`. @param array $parameters Array of parameters to pass to the controller action method. @return string The `echo`'d data or the return value of the controller action. @deprecated
[ "Executes", "the", "requested", "plugin", "controller", "method", "and", "returns", "the", "data", "capturing", "anything", "the", "method", "echo", "s", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FrontController.php#L204-L217
209,707
matomo-org/matomo
core/FrontController.php
FrontController.throwIfPiwikVersionIsOlderThanDBSchema
private function throwIfPiwikVersionIsOlderThanDBSchema() { // When developing this situation happens often when switching branches if (Development::isEnabled()) { return; } if (!StaticContainer::get('EnableDbVersionCheck')) { return; } $updater = new Updater(); $dbSchemaVersion = $updater->getCurrentComponentVersion('core'); $current = Version::VERSION; if (-1 === version_compare($current, $dbSchemaVersion)) { $messages = array( Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebase', array($current, $dbSchemaVersion)), Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebaseWait'), // we cannot fill in the Super User emails as we are failing before Authentication was ready Piwik::translate('General_ExceptionContactSupportGeneric', array('', '')) ); throw new DatabaseSchemaIsNewerThanCodebaseException(implode(" ", $messages)); } }
php
private function throwIfPiwikVersionIsOlderThanDBSchema() { // When developing this situation happens often when switching branches if (Development::isEnabled()) { return; } if (!StaticContainer::get('EnableDbVersionCheck')) { return; } $updater = new Updater(); $dbSchemaVersion = $updater->getCurrentComponentVersion('core'); $current = Version::VERSION; if (-1 === version_compare($current, $dbSchemaVersion)) { $messages = array( Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebase', array($current, $dbSchemaVersion)), Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebaseWait'), // we cannot fill in the Super User emails as we are failing before Authentication was ready Piwik::translate('General_ExceptionContactSupportGeneric', array('', '')) ); throw new DatabaseSchemaIsNewerThanCodebaseException(implode(" ", $messages)); } }
[ "private", "function", "throwIfPiwikVersionIsOlderThanDBSchema", "(", ")", "{", "// When developing this situation happens often when switching branches", "if", "(", "Development", "::", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "StaticContainer", "::", "get", "(", "'EnableDbVersionCheck'", ")", ")", "{", "return", ";", "}", "$", "updater", "=", "new", "Updater", "(", ")", ";", "$", "dbSchemaVersion", "=", "$", "updater", "->", "getCurrentComponentVersion", "(", "'core'", ")", ";", "$", "current", "=", "Version", "::", "VERSION", ";", "if", "(", "-", "1", "===", "version_compare", "(", "$", "current", ",", "$", "dbSchemaVersion", ")", ")", "{", "$", "messages", "=", "array", "(", "Piwik", "::", "translate", "(", "'General_ExceptionDatabaseVersionNewerThanCodebase'", ",", "array", "(", "$", "current", ",", "$", "dbSchemaVersion", ")", ")", ",", "Piwik", "::", "translate", "(", "'General_ExceptionDatabaseVersionNewerThanCodebaseWait'", ")", ",", "// we cannot fill in the Super User emails as we are failing before Authentication was ready", "Piwik", "::", "translate", "(", "'General_ExceptionContactSupportGeneric'", ",", "array", "(", "''", ",", "''", ")", ")", ")", ";", "throw", "new", "DatabaseSchemaIsNewerThanCodebaseException", "(", "implode", "(", "\" \"", ",", "$", "messages", ")", ")", ";", "}", "}" ]
This method ensures that Piwik Platform cannot be running when using a NEWER database.
[ "This", "method", "ensures", "that", "Piwik", "Platform", "cannot", "be", "running", "when", "using", "a", "NEWER", "database", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FrontController.php#L622-L646
209,708
matomo-org/matomo
plugins/API/DataTable/MergeDataTables.php
MergeDataTables.mergeDataTables
public function mergeDataTables($table1, $table2) { // handle table arrays if ($table1 instanceof DataTable\Map && $table2 instanceof DataTable\Map) { $subTables2 = $table2->getDataTables(); foreach ($table1->getDataTables() as $index => $subTable1) { if (!array_key_exists($index, $subTables2)) { // occurs when archiving starts on dayN and continues into dayN+1, see https://github.com/piwik/piwik/issues/5168#issuecomment-50959925 continue; } $subTable2 = $subTables2[$index]; $this->mergeDataTables($subTable1, $subTable2); } return; } $firstRow2 = $table2->getFirstRow(); if (!($firstRow2 instanceof Row)) { return; } $firstRow1 = $table1->getFirstRow(); if (empty($firstRow1)) { $firstRow1 = $table1->addRow(new Row()); } foreach ($firstRow2->getColumns() as $metric => $value) { $firstRow1->setColumn($metric, $value); } }
php
public function mergeDataTables($table1, $table2) { // handle table arrays if ($table1 instanceof DataTable\Map && $table2 instanceof DataTable\Map) { $subTables2 = $table2->getDataTables(); foreach ($table1->getDataTables() as $index => $subTable1) { if (!array_key_exists($index, $subTables2)) { // occurs when archiving starts on dayN and continues into dayN+1, see https://github.com/piwik/piwik/issues/5168#issuecomment-50959925 continue; } $subTable2 = $subTables2[$index]; $this->mergeDataTables($subTable1, $subTable2); } return; } $firstRow2 = $table2->getFirstRow(); if (!($firstRow2 instanceof Row)) { return; } $firstRow1 = $table1->getFirstRow(); if (empty($firstRow1)) { $firstRow1 = $table1->addRow(new Row()); } foreach ($firstRow2->getColumns() as $metric => $value) { $firstRow1->setColumn($metric, $value); } }
[ "public", "function", "mergeDataTables", "(", "$", "table1", ",", "$", "table2", ")", "{", "// handle table arrays", "if", "(", "$", "table1", "instanceof", "DataTable", "\\", "Map", "&&", "$", "table2", "instanceof", "DataTable", "\\", "Map", ")", "{", "$", "subTables2", "=", "$", "table2", "->", "getDataTables", "(", ")", ";", "foreach", "(", "$", "table1", "->", "getDataTables", "(", ")", "as", "$", "index", "=>", "$", "subTable1", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "subTables2", ")", ")", "{", "// occurs when archiving starts on dayN and continues into dayN+1, see https://github.com/piwik/piwik/issues/5168#issuecomment-50959925", "continue", ";", "}", "$", "subTable2", "=", "$", "subTables2", "[", "$", "index", "]", ";", "$", "this", "->", "mergeDataTables", "(", "$", "subTable1", ",", "$", "subTable2", ")", ";", "}", "return", ";", "}", "$", "firstRow2", "=", "$", "table2", "->", "getFirstRow", "(", ")", ";", "if", "(", "!", "(", "$", "firstRow2", "instanceof", "Row", ")", ")", "{", "return", ";", "}", "$", "firstRow1", "=", "$", "table1", "->", "getFirstRow", "(", ")", ";", "if", "(", "empty", "(", "$", "firstRow1", ")", ")", "{", "$", "firstRow1", "=", "$", "table1", "->", "addRow", "(", "new", "Row", "(", ")", ")", ";", "}", "foreach", "(", "$", "firstRow2", "->", "getColumns", "(", ")", "as", "$", "metric", "=>", "$", "value", ")", "{", "$", "firstRow1", "->", "setColumn", "(", "$", "metric", ",", "$", "value", ")", ";", "}", "}" ]
Merge the columns of two data tables. Manipulates the first table. @param DataTable|DataTable\Map $table1 The table to eventually filter. @param DataTable|DataTable\Map $table2 Whether to delete rows with no visits or not.
[ "Merge", "the", "columns", "of", "two", "data", "tables", ".", "Manipulates", "the", "first", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/DataTable/MergeDataTables.php#L24-L53
209,709
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir.initMaildir
public static function initMaildir($dir) { if (file_exists($dir)) { if (!is_dir($dir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('maildir must be a directory if already exists'); } } else { if (!mkdir($dir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; $dir = dirname($dir); if (!file_exists($dir)) { throw new Zend_Mail_Storage_Exception("parent $dir not found"); } else if (!is_dir($dir)) { throw new Zend_Mail_Storage_Exception("parent $dir not a directory"); } else { throw new Zend_Mail_Storage_Exception('cannot create maildir'); } } } foreach (array('cur', 'tmp', 'new') as $subdir) { if (!@mkdir($dir . DIRECTORY_SEPARATOR . $subdir)) { // ignore if dir exists (i.e. was already valid maildir or two processes try to create one) if (!file_exists($dir . DIRECTORY_SEPARATOR . $subdir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('could not create subdir ' . $subdir); } } } }
php
public static function initMaildir($dir) { if (file_exists($dir)) { if (!is_dir($dir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('maildir must be a directory if already exists'); } } else { if (!mkdir($dir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; $dir = dirname($dir); if (!file_exists($dir)) { throw new Zend_Mail_Storage_Exception("parent $dir not found"); } else if (!is_dir($dir)) { throw new Zend_Mail_Storage_Exception("parent $dir not a directory"); } else { throw new Zend_Mail_Storage_Exception('cannot create maildir'); } } } foreach (array('cur', 'tmp', 'new') as $subdir) { if (!@mkdir($dir . DIRECTORY_SEPARATOR . $subdir)) { // ignore if dir exists (i.e. was already valid maildir or two processes try to create one) if (!file_exists($dir . DIRECTORY_SEPARATOR . $subdir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('could not create subdir ' . $subdir); } } } }
[ "public", "static", "function", "initMaildir", "(", "$", "dir", ")", "{", "if", "(", "file_exists", "(", "$", "dir", ")", ")", "{", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'maildir must be a directory if already exists'", ")", ";", "}", "}", "else", "{", "if", "(", "!", "mkdir", "(", "$", "dir", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "$", "dir", "=", "dirname", "(", "$", "dir", ")", ";", "if", "(", "!", "file_exists", "(", "$", "dir", ")", ")", "{", "throw", "new", "Zend_Mail_Storage_Exception", "(", "\"parent $dir not found\"", ")", ";", "}", "else", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "throw", "new", "Zend_Mail_Storage_Exception", "(", "\"parent $dir not a directory\"", ")", ";", "}", "else", "{", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'cannot create maildir'", ")", ";", "}", "}", "}", "foreach", "(", "array", "(", "'cur'", ",", "'tmp'", ",", "'new'", ")", "as", "$", "subdir", ")", "{", "if", "(", "!", "@", "mkdir", "(", "$", "dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "subdir", ")", ")", "{", "// ignore if dir exists (i.e. was already valid maildir or two processes try to create one)", "if", "(", "!", "file_exists", "(", "$", "dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "subdir", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'could not create subdir '", ".", "$", "subdir", ")", ";", "}", "}", "}", "}" ]
create a new maildir If the given dir is already a valid maildir this will not fail. @param string $dir directory for the new maildir (may already exist) @return null @throws Zend_Mail_Storage_Exception
[ "create", "a", "new", "maildir" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L62-L101
209,710
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir._createUniqueId
protected function _createUniqueId() { $id = ''; $id .= function_exists('microtime') ? microtime(true) : (time() . ' ' . rand(0, 100000)); $id .= '.' . (function_exists('posix_getpid') ? posix_getpid() : rand(50, 65535)); $id .= '.' . php_uname('n'); return $id; }
php
protected function _createUniqueId() { $id = ''; $id .= function_exists('microtime') ? microtime(true) : (time() . ' ' . rand(0, 100000)); $id .= '.' . (function_exists('posix_getpid') ? posix_getpid() : rand(50, 65535)); $id .= '.' . php_uname('n'); return $id; }
[ "protected", "function", "_createUniqueId", "(", ")", "{", "$", "id", "=", "''", ";", "$", "id", ".=", "function_exists", "(", "'microtime'", ")", "?", "microtime", "(", "true", ")", ":", "(", "time", "(", ")", ".", "' '", ".", "rand", "(", "0", ",", "100000", ")", ")", ";", "$", "id", ".=", "'.'", ".", "(", "function_exists", "(", "'posix_getpid'", ")", "?", "posix_getpid", "(", ")", ":", "rand", "(", "50", ",", "65535", ")", ")", ";", "$", "id", ".=", "'.'", ".", "php_uname", "(", "'n'", ")", ";", "return", "$", "id", ";", "}" ]
create a uniqueid for maildir filename This is nearly the format defined in the maildir standard. The microtime() call should already create a uniqueid, the pid is for multicore/-cpu machine that manage to call this function at the exact same time, and uname() gives us the hostname for multiple machines accessing the same storage. If someone disables posix we create a random number of the same size, so this method should also work on Windows - if you manage to get maildir working on Windows. Microtime could also be disabled, altough I've never seen it. @return string new uniqueid
[ "create", "a", "uniqueid", "for", "maildir", "filename" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L412-L420
209,711
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir._createTmpFile
protected function _createTmpFile($folder = 'INBOX') { if ($folder == 'INBOX') { $tmpdir = $this->_rootdir . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR; } else { $tmpdir = $this->_rootdir . '.' . $folder . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR; } if (!file_exists($tmpdir)) { if (!mkdir($tmpdir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('problems creating tmp dir'); } } // we should retry to create a unique id if a file with the same name exists // to avoid a script timeout we only wait 1 second (instead of 2) and stop // after a defined retry count // if you change this variable take into account that it can take up to $max_tries seconds // normally we should have a valid unique name after the first try, we're just following the "standard" here $max_tries = 5; for ($i = 0; $i < $max_tries; ++$i) { $uniq = $this->_createUniqueId(); if (!file_exists($tmpdir . $uniq)) { // here is the race condition! - as defined in the standard // to avoid having a long time between stat()ing the file and creating it we're opening it here // to mark the filename as taken $fh = fopen($tmpdir . $uniq, 'w'); if (!$fh) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('could not open temp file'); } break; } sleep(1); } if (!$fh) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("tried $max_tries unique ids for a temp file, but all were taken" . ' - giving up'); } return array('dirname' => $this->_rootdir . '.' . $folder, 'uniq' => $uniq, 'filename' => $tmpdir . $uniq, 'handle' => $fh); }
php
protected function _createTmpFile($folder = 'INBOX') { if ($folder == 'INBOX') { $tmpdir = $this->_rootdir . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR; } else { $tmpdir = $this->_rootdir . '.' . $folder . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR; } if (!file_exists($tmpdir)) { if (!mkdir($tmpdir)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('problems creating tmp dir'); } } // we should retry to create a unique id if a file with the same name exists // to avoid a script timeout we only wait 1 second (instead of 2) and stop // after a defined retry count // if you change this variable take into account that it can take up to $max_tries seconds // normally we should have a valid unique name after the first try, we're just following the "standard" here $max_tries = 5; for ($i = 0; $i < $max_tries; ++$i) { $uniq = $this->_createUniqueId(); if (!file_exists($tmpdir . $uniq)) { // here is the race condition! - as defined in the standard // to avoid having a long time between stat()ing the file and creating it we're opening it here // to mark the filename as taken $fh = fopen($tmpdir . $uniq, 'w'); if (!$fh) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('could not open temp file'); } break; } sleep(1); } if (!$fh) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception("tried $max_tries unique ids for a temp file, but all were taken" . ' - giving up'); } return array('dirname' => $this->_rootdir . '.' . $folder, 'uniq' => $uniq, 'filename' => $tmpdir . $uniq, 'handle' => $fh); }
[ "protected", "function", "_createTmpFile", "(", "$", "folder", "=", "'INBOX'", ")", "{", "if", "(", "$", "folder", "==", "'INBOX'", ")", "{", "$", "tmpdir", "=", "$", "this", "->", "_rootdir", ".", "DIRECTORY_SEPARATOR", ".", "'tmp'", ".", "DIRECTORY_SEPARATOR", ";", "}", "else", "{", "$", "tmpdir", "=", "$", "this", "->", "_rootdir", ".", "'.'", ".", "$", "folder", ".", "DIRECTORY_SEPARATOR", ".", "'tmp'", ".", "DIRECTORY_SEPARATOR", ";", "}", "if", "(", "!", "file_exists", "(", "$", "tmpdir", ")", ")", "{", "if", "(", "!", "mkdir", "(", "$", "tmpdir", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'problems creating tmp dir'", ")", ";", "}", "}", "// we should retry to create a unique id if a file with the same name exists", "// to avoid a script timeout we only wait 1 second (instead of 2) and stop", "// after a defined retry count", "// if you change this variable take into account that it can take up to $max_tries seconds", "// normally we should have a valid unique name after the first try, we're just following the \"standard\" here", "$", "max_tries", "=", "5", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "max_tries", ";", "++", "$", "i", ")", "{", "$", "uniq", "=", "$", "this", "->", "_createUniqueId", "(", ")", ";", "if", "(", "!", "file_exists", "(", "$", "tmpdir", ".", "$", "uniq", ")", ")", "{", "// here is the race condition! - as defined in the standard", "// to avoid having a long time between stat()ing the file and creating it we're opening it here", "// to mark the filename as taken", "$", "fh", "=", "fopen", "(", "$", "tmpdir", ".", "$", "uniq", ",", "'w'", ")", ";", "if", "(", "!", "$", "fh", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'could not open temp file'", ")", ";", "}", "break", ";", "}", "sleep", "(", "1", ")", ";", "}", "if", "(", "!", "$", "fh", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "\"tried $max_tries unique ids for a temp file, but all were taken\"", ".", "' - giving up'", ")", ";", "}", "return", "array", "(", "'dirname'", "=>", "$", "this", "->", "_rootdir", ".", "'.'", ".", "$", "folder", ",", "'uniq'", "=>", "$", "uniq", ",", "'filename'", "=>", "$", "tmpdir", ".", "$", "uniq", ",", "'handle'", "=>", "$", "fh", ")", ";", "}" ]
open a temporary maildir file makes sure tmp/ exists and create a file with a unique name you should close the returned filehandle! @param string $folder name of current folder without leading . @return array array('dirname' => dir of maildir folder, 'uniq' => unique id, 'filename' => name of create file 'handle' => file opened for writing) @throws Zend_Mail_Storage_Exception
[ "open", "a", "temporary", "maildir", "file" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L433-L486
209,712
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir._getInfoString
protected function _getInfoString(&$flags) { // accessing keys is easier, faster and it removes duplicated flags $wanted_flags = array_flip($flags); if (isset($wanted_flags[Zend_Mail_Storage::FLAG_RECENT])) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('recent flag may not be set'); } $info = ':2,'; $flags = array(); foreach (Zend_Mail_Storage_Maildir::$_knownFlags as $char => $flag) { if (!isset($wanted_flags[$flag])) { continue; } $info .= $char; $flags[$char] = $flag; unset($wanted_flags[$flag]); } if (!empty($wanted_flags)) { $wanted_flags = implode(', ', array_keys($wanted_flags)); /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('unknown flag(s): ' . $wanted_flags); } return $info; }
php
protected function _getInfoString(&$flags) { // accessing keys is easier, faster and it removes duplicated flags $wanted_flags = array_flip($flags); if (isset($wanted_flags[Zend_Mail_Storage::FLAG_RECENT])) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('recent flag may not be set'); } $info = ':2,'; $flags = array(); foreach (Zend_Mail_Storage_Maildir::$_knownFlags as $char => $flag) { if (!isset($wanted_flags[$flag])) { continue; } $info .= $char; $flags[$char] = $flag; unset($wanted_flags[$flag]); } if (!empty($wanted_flags)) { $wanted_flags = implode(', ', array_keys($wanted_flags)); /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('unknown flag(s): ' . $wanted_flags); } return $info; }
[ "protected", "function", "_getInfoString", "(", "&", "$", "flags", ")", "{", "// accessing keys is easier, faster and it removes duplicated flags", "$", "wanted_flags", "=", "array_flip", "(", "$", "flags", ")", ";", "if", "(", "isset", "(", "$", "wanted_flags", "[", "Zend_Mail_Storage", "::", "FLAG_RECENT", "]", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'recent flag may not be set'", ")", ";", "}", "$", "info", "=", "':2,'", ";", "$", "flags", "=", "array", "(", ")", ";", "foreach", "(", "Zend_Mail_Storage_Maildir", "::", "$", "_knownFlags", "as", "$", "char", "=>", "$", "flag", ")", "{", "if", "(", "!", "isset", "(", "$", "wanted_flags", "[", "$", "flag", "]", ")", ")", "{", "continue", ";", "}", "$", "info", ".=", "$", "char", ";", "$", "flags", "[", "$", "char", "]", "=", "$", "flag", ";", "unset", "(", "$", "wanted_flags", "[", "$", "flag", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "wanted_flags", ")", ")", "{", "$", "wanted_flags", "=", "implode", "(", "', '", ",", "array_keys", "(", "$", "wanted_flags", ")", ")", ";", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'unknown flag(s): '", ".", "$", "wanted_flags", ")", ";", "}", "return", "$", "info", ";", "}" ]
create an info string for filenames with given flags @param array $flags wanted flags, with the reference you'll get the set flags with correct key (= char for flag) @return string info string for version 2 filenames including the leading colon @throws Zend_Mail_Storage_Exception
[ "create", "an", "info", "string", "for", "filenames", "with", "given", "flags" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L495-L528
209,713
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir.copyMessage
public function copyMessage($id, $folder) { if ($this->_quota && $this->checkQuota()) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('storage is over quota!'); } if (!($folder instanceof Zend_Mail_Storage_Folder)) { $folder = $this->getFolders($folder); } $filedata = $this->_getFileData($id); $old_file = $filedata['filename']; $flags = $filedata['flags']; // copied message can't be recent while (($key = array_search(Zend_Mail_Storage::FLAG_RECENT, $flags)) !== false) { unset($flags[$key]); } $info = $this->_getInfoString($flags); // we're creating the copy as temp file before moving to cur/ $temp_file = $this->_createTmpFile($folder->getGlobalName()); // we don't write directly to the file fclose($temp_file['handle']); // we're adding the size to the filename for maildir++ $size = filesize($old_file); if ($size !== false) { $info = ',S=' . $size . $info; } $new_file = $temp_file['dirname'] . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . $temp_file['uniq'] . $info; // we're throwing any exception after removing our temp file and saving it to this variable instead $exception = null; if (!copy($old_file, $temp_file['filename'])) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot copy message file'); } else if (!link($temp_file['filename'], $new_file)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot link message file to final dir'); } @unlink($temp_file['filename']); if ($exception) { throw $exception; } if ($folder->getGlobalName() == $this->_currentFolder || ($this->_currentFolder == 'INBOX' && $folder->getGlobalName() == '/')) { $this->_files[] = array('uniq' => $temp_file['uniq'], 'flags' => $flags, 'filename' => $new_file); } if ($this->_quota) { $this->_addQuotaEntry((int)$size, 1); } }
php
public function copyMessage($id, $folder) { if ($this->_quota && $this->checkQuota()) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('storage is over quota!'); } if (!($folder instanceof Zend_Mail_Storage_Folder)) { $folder = $this->getFolders($folder); } $filedata = $this->_getFileData($id); $old_file = $filedata['filename']; $flags = $filedata['flags']; // copied message can't be recent while (($key = array_search(Zend_Mail_Storage::FLAG_RECENT, $flags)) !== false) { unset($flags[$key]); } $info = $this->_getInfoString($flags); // we're creating the copy as temp file before moving to cur/ $temp_file = $this->_createTmpFile($folder->getGlobalName()); // we don't write directly to the file fclose($temp_file['handle']); // we're adding the size to the filename for maildir++ $size = filesize($old_file); if ($size !== false) { $info = ',S=' . $size . $info; } $new_file = $temp_file['dirname'] . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . $temp_file['uniq'] . $info; // we're throwing any exception after removing our temp file and saving it to this variable instead $exception = null; if (!copy($old_file, $temp_file['filename'])) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot copy message file'); } else if (!link($temp_file['filename'], $new_file)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; $exception = new Zend_Mail_Storage_Exception('cannot link message file to final dir'); } @unlink($temp_file['filename']); if ($exception) { throw $exception; } if ($folder->getGlobalName() == $this->_currentFolder || ($this->_currentFolder == 'INBOX' && $folder->getGlobalName() == '/')) { $this->_files[] = array('uniq' => $temp_file['uniq'], 'flags' => $flags, 'filename' => $new_file); } if ($this->_quota) { $this->_addQuotaEntry((int)$size, 1); } }
[ "public", "function", "copyMessage", "(", "$", "id", ",", "$", "folder", ")", "{", "if", "(", "$", "this", "->", "_quota", "&&", "$", "this", "->", "checkQuota", "(", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'storage is over quota!'", ")", ";", "}", "if", "(", "!", "(", "$", "folder", "instanceof", "Zend_Mail_Storage_Folder", ")", ")", "{", "$", "folder", "=", "$", "this", "->", "getFolders", "(", "$", "folder", ")", ";", "}", "$", "filedata", "=", "$", "this", "->", "_getFileData", "(", "$", "id", ")", ";", "$", "old_file", "=", "$", "filedata", "[", "'filename'", "]", ";", "$", "flags", "=", "$", "filedata", "[", "'flags'", "]", ";", "// copied message can't be recent", "while", "(", "(", "$", "key", "=", "array_search", "(", "Zend_Mail_Storage", "::", "FLAG_RECENT", ",", "$", "flags", ")", ")", "!==", "false", ")", "{", "unset", "(", "$", "flags", "[", "$", "key", "]", ")", ";", "}", "$", "info", "=", "$", "this", "->", "_getInfoString", "(", "$", "flags", ")", ";", "// we're creating the copy as temp file before moving to cur/", "$", "temp_file", "=", "$", "this", "->", "_createTmpFile", "(", "$", "folder", "->", "getGlobalName", "(", ")", ")", ";", "// we don't write directly to the file", "fclose", "(", "$", "temp_file", "[", "'handle'", "]", ")", ";", "// we're adding the size to the filename for maildir++", "$", "size", "=", "filesize", "(", "$", "old_file", ")", ";", "if", "(", "$", "size", "!==", "false", ")", "{", "$", "info", "=", "',S='", ".", "$", "size", ".", "$", "info", ";", "}", "$", "new_file", "=", "$", "temp_file", "[", "'dirname'", "]", ".", "DIRECTORY_SEPARATOR", ".", "'cur'", ".", "DIRECTORY_SEPARATOR", ".", "$", "temp_file", "[", "'uniq'", "]", ".", "$", "info", ";", "// we're throwing any exception after removing our temp file and saving it to this variable instead", "$", "exception", "=", "null", ";", "if", "(", "!", "copy", "(", "$", "old_file", ",", "$", "temp_file", "[", "'filename'", "]", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "$", "exception", "=", "new", "Zend_Mail_Storage_Exception", "(", "'cannot copy message file'", ")", ";", "}", "else", "if", "(", "!", "link", "(", "$", "temp_file", "[", "'filename'", "]", ",", "$", "new_file", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "$", "exception", "=", "new", "Zend_Mail_Storage_Exception", "(", "'cannot link message file to final dir'", ")", ";", "}", "@", "unlink", "(", "$", "temp_file", "[", "'filename'", "]", ")", ";", "if", "(", "$", "exception", ")", "{", "throw", "$", "exception", ";", "}", "if", "(", "$", "folder", "->", "getGlobalName", "(", ")", "==", "$", "this", "->", "_currentFolder", "||", "(", "$", "this", "->", "_currentFolder", "==", "'INBOX'", "&&", "$", "folder", "->", "getGlobalName", "(", ")", "==", "'/'", ")", ")", "{", "$", "this", "->", "_files", "[", "]", "=", "array", "(", "'uniq'", "=>", "$", "temp_file", "[", "'uniq'", "]", ",", "'flags'", "=>", "$", "flags", ",", "'filename'", "=>", "$", "new_file", ")", ";", "}", "if", "(", "$", "this", "->", "_quota", ")", "{", "$", "this", "->", "_addQuotaEntry", "(", "(", "int", ")", "$", "size", ",", "1", ")", ";", "}", "}" ]
copy an existing message @param int $id number of message @param string|Zend_Mail_Storage_Folder $folder name or instance of targer folder @return null @throws Zend_Mail_Storage_Exception
[ "copy", "an", "existing", "message" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L615-L684
209,714
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir.setFlags
public function setFlags($id, $flags) { $info = $this->_getInfoString($flags); $filedata = $this->_getFileData($id); // NOTE: double dirname to make sure we always move to cur. if recent flag has been set (message is in new) it will be moved to cur. $new_filename = dirname(dirname($filedata['filename'])) . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . "$filedata[uniq]$info"; if (!@rename($filedata['filename'], $new_filename)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot rename file'); } $filedata['flags'] = $flags; $filedata['filename'] = $new_filename; $this->_files[$id - 1] = $filedata; }
php
public function setFlags($id, $flags) { $info = $this->_getInfoString($flags); $filedata = $this->_getFileData($id); // NOTE: double dirname to make sure we always move to cur. if recent flag has been set (message is in new) it will be moved to cur. $new_filename = dirname(dirname($filedata['filename'])) . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . "$filedata[uniq]$info"; if (!@rename($filedata['filename'], $new_filename)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot rename file'); } $filedata['flags'] = $flags; $filedata['filename'] = $new_filename; $this->_files[$id - 1] = $filedata; }
[ "public", "function", "setFlags", "(", "$", "id", ",", "$", "flags", ")", "{", "$", "info", "=", "$", "this", "->", "_getInfoString", "(", "$", "flags", ")", ";", "$", "filedata", "=", "$", "this", "->", "_getFileData", "(", "$", "id", ")", ";", "// NOTE: double dirname to make sure we always move to cur. if recent flag has been set (message is in new) it will be moved to cur.", "$", "new_filename", "=", "dirname", "(", "dirname", "(", "$", "filedata", "[", "'filename'", "]", ")", ")", ".", "DIRECTORY_SEPARATOR", ".", "'cur'", ".", "DIRECTORY_SEPARATOR", ".", "\"$filedata[uniq]$info\"", ";", "if", "(", "!", "@", "rename", "(", "$", "filedata", "[", "'filename'", "]", ",", "$", "new_filename", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'cannot rename file'", ")", ";", "}", "$", "filedata", "[", "'flags'", "]", "=", "$", "flags", ";", "$", "filedata", "[", "'filename'", "]", "=", "$", "new_filename", ";", "$", "this", "->", "_files", "[", "$", "id", "-", "1", "]", "=", "$", "filedata", ";", "}" ]
set flags for message NOTE: this method can't set the recent flag. @param int $id number of message @param array $flags new flags for message @throws Zend_Mail_Storage_Exception
[ "set", "flags", "for", "message" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L761-L781
209,715
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir.removeMessage
public function removeMessage($id) { $filename = $this->_getFileData($id, 'filename'); if ($this->_quota) { $size = filesize($filename); } if (!@unlink($filename)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot remove message'); } unset($this->_files[$id - 1]); // remove the gap $this->_files = array_values($this->_files); if ($this->_quota) { $this->_addQuotaEntry(0 - (int)$size, -1); } }
php
public function removeMessage($id) { $filename = $this->_getFileData($id, 'filename'); if ($this->_quota) { $size = filesize($filename); } if (!@unlink($filename)) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot remove message'); } unset($this->_files[$id - 1]); // remove the gap $this->_files = array_values($this->_files); if ($this->_quota) { $this->_addQuotaEntry(0 - (int)$size, -1); } }
[ "public", "function", "removeMessage", "(", "$", "id", ")", "{", "$", "filename", "=", "$", "this", "->", "_getFileData", "(", "$", "id", ",", "'filename'", ")", ";", "if", "(", "$", "this", "->", "_quota", ")", "{", "$", "size", "=", "filesize", "(", "$", "filename", ")", ";", "}", "if", "(", "!", "@", "unlink", "(", "$", "filename", ")", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'cannot remove message'", ")", ";", "}", "unset", "(", "$", "this", "->", "_files", "[", "$", "id", "-", "1", "]", ")", ";", "// remove the gap", "$", "this", "->", "_files", "=", "array_values", "(", "$", "this", "->", "_files", ")", ";", "if", "(", "$", "this", "->", "_quota", ")", "{", "$", "this", "->", "_addQuotaEntry", "(", "0", "-", "(", "int", ")", "$", "size", ",", "-", "1", ")", ";", "}", "}" ]
stub for not supported message deletion @return null @throws Zend_Mail_Storage_Exception
[ "stub", "for", "not", "supported", "message", "deletion" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L790-L811
209,716
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir.getQuota
public function getQuota($fromStorage = false) { if ($fromStorage) { $fh = @fopen($this->_rootdir . 'maildirsize', 'r'); if (!$fh) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot open maildirsize'); } $definition = fgets($fh); fclose($fh); $definition = explode(',', trim($definition)); $quota = array(); foreach ($definition as $member) { $key = $member[strlen($member) - 1]; if ($key == 'S' || $key == 'C') { $key = $key == 'C' ? 'count' : 'size'; } $quota[$key] = substr($member, 0, -1); } return $quota; } return $this->_quota; }
php
public function getQuota($fromStorage = false) { if ($fromStorage) { $fh = @fopen($this->_rootdir . 'maildirsize', 'r'); if (!$fh) { /** * @see Zend_Mail_Storage_Exception */ // require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot open maildirsize'); } $definition = fgets($fh); fclose($fh); $definition = explode(',', trim($definition)); $quota = array(); foreach ($definition as $member) { $key = $member[strlen($member) - 1]; if ($key == 'S' || $key == 'C') { $key = $key == 'C' ? 'count' : 'size'; } $quota[$key] = substr($member, 0, -1); } return $quota; } return $this->_quota; }
[ "public", "function", "getQuota", "(", "$", "fromStorage", "=", "false", ")", "{", "if", "(", "$", "fromStorage", ")", "{", "$", "fh", "=", "@", "fopen", "(", "$", "this", "->", "_rootdir", ".", "'maildirsize'", ",", "'r'", ")", ";", "if", "(", "!", "$", "fh", ")", "{", "/**\n * @see Zend_Mail_Storage_Exception\n */", "// require_once 'Zend/Mail/Storage/Exception.php';", "throw", "new", "Zend_Mail_Storage_Exception", "(", "'cannot open maildirsize'", ")", ";", "}", "$", "definition", "=", "fgets", "(", "$", "fh", ")", ";", "fclose", "(", "$", "fh", ")", ";", "$", "definition", "=", "explode", "(", "','", ",", "trim", "(", "$", "definition", ")", ")", ";", "$", "quota", "=", "array", "(", ")", ";", "foreach", "(", "$", "definition", "as", "$", "member", ")", "{", "$", "key", "=", "$", "member", "[", "strlen", "(", "$", "member", ")", "-", "1", "]", ";", "if", "(", "$", "key", "==", "'S'", "||", "$", "key", "==", "'C'", ")", "{", "$", "key", "=", "$", "key", "==", "'C'", "?", "'count'", ":", "'size'", ";", "}", "$", "quota", "[", "$", "key", "]", "=", "substr", "(", "$", "member", ",", "0", ",", "-", "1", ")", ";", "}", "return", "$", "quota", ";", "}", "return", "$", "this", "->", "_quota", ";", "}" ]
get currently set quota @see Zend_Mail_Storage_Writable_Maildir::setQuota() @return bool|array
[ "get", "currently", "set", "quota" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L835-L860
209,717
matomo-org/matomo
libs/Zend/Mail/Storage/Writable/Maildir.php
Zend_Mail_Storage_Writable_Maildir.checkQuota
public function checkQuota($detailedResponse = false, $forceRecalc = false) { $result = $this->_calculateQuota($forceRecalc); return $detailedResponse ? $result : $result['over_quota']; }
php
public function checkQuota($detailedResponse = false, $forceRecalc = false) { $result = $this->_calculateQuota($forceRecalc); return $detailedResponse ? $result : $result['over_quota']; }
[ "public", "function", "checkQuota", "(", "$", "detailedResponse", "=", "false", ",", "$", "forceRecalc", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "_calculateQuota", "(", "$", "forceRecalc", ")", ";", "return", "$", "detailedResponse", "?", "$", "result", ":", "$", "result", "[", "'over_quota'", "]", ";", "}" ]
check if storage is currently over quota @param bool $detailedResponse return known data of quota and current size and message count @see _calculateQuota() @return bool|array over quota state or detailed response
[ "check", "if", "storage", "is", "currently", "over", "quota" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L1045-L1048
209,718
matomo-org/matomo
plugins/Live/Visualizations/VisitorLog.php
VisitorLog.beforeRender
public function beforeRender() { $this->config->show_as_content_block = false; $this->config->title = Piwik::translate('Live_VisitorLog'); $this->config->disable_row_actions = true; $this->config->datatable_js_type = 'VisitorLog'; $this->config->enable_sort = false; $this->config->show_search = false; $this->config->show_exclude_low_population = false; $this->config->show_offset_information = false; $this->config->show_all_views_icons = false; $this->config->show_table_all_columns = false; $this->config->show_export_as_rss_feed = false; $this->config->disable_all_rows_filter_limit = true; $this->config->documentation = Piwik::translate('Live_VisitorLogDocumentation', array('<br />', '<br />')); if (!is_array($this->config->custom_parameters)) { $this->config->custom_parameters = array(); } // ensure to show next link if there are enough rows for a next page if ($this->dataTable->getRowsCount() > $this->requestConfig->filter_limit) { $this->dataTable->deleteRowsOffset($this->requestConfig->filter_limit); $this->config->custom_parameters['totalRows'] = 10000000; } $this->config->custom_parameters['smallWidth'] = (1 == Common::getRequestVar('small', 0, 'int')); $this->config->custom_parameters['hideProfileLink'] = (1 == Common::getRequestVar('hideProfileLink', 0, 'int')); $this->config->custom_parameters['pageUrlNotDefined'] = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageURL')); $this->config->footer_icons = array( array( 'class' => 'tableAllColumnsSwitch', 'buttons' => array( array( 'id' => static::ID, 'title' => Piwik::translate('Live_LinkVisitorLog'), 'icon' => 'plugins/Morpheus/images/table.png' ) ) ) ); $enableAddNewSegment = Common::getRequestVar('enableAddNewSegment', false); if ($enableAddNewSegment) { $this->config->datatable_actions[] = [ 'id' => 'addSegmentToMatomo', 'title' => Piwik::translate('SegmentEditor_AddThisToMatomo'), 'icon' => 'icon-segment', ]; } }
php
public function beforeRender() { $this->config->show_as_content_block = false; $this->config->title = Piwik::translate('Live_VisitorLog'); $this->config->disable_row_actions = true; $this->config->datatable_js_type = 'VisitorLog'; $this->config->enable_sort = false; $this->config->show_search = false; $this->config->show_exclude_low_population = false; $this->config->show_offset_information = false; $this->config->show_all_views_icons = false; $this->config->show_table_all_columns = false; $this->config->show_export_as_rss_feed = false; $this->config->disable_all_rows_filter_limit = true; $this->config->documentation = Piwik::translate('Live_VisitorLogDocumentation', array('<br />', '<br />')); if (!is_array($this->config->custom_parameters)) { $this->config->custom_parameters = array(); } // ensure to show next link if there are enough rows for a next page if ($this->dataTable->getRowsCount() > $this->requestConfig->filter_limit) { $this->dataTable->deleteRowsOffset($this->requestConfig->filter_limit); $this->config->custom_parameters['totalRows'] = 10000000; } $this->config->custom_parameters['smallWidth'] = (1 == Common::getRequestVar('small', 0, 'int')); $this->config->custom_parameters['hideProfileLink'] = (1 == Common::getRequestVar('hideProfileLink', 0, 'int')); $this->config->custom_parameters['pageUrlNotDefined'] = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageURL')); $this->config->footer_icons = array( array( 'class' => 'tableAllColumnsSwitch', 'buttons' => array( array( 'id' => static::ID, 'title' => Piwik::translate('Live_LinkVisitorLog'), 'icon' => 'plugins/Morpheus/images/table.png' ) ) ) ); $enableAddNewSegment = Common::getRequestVar('enableAddNewSegment', false); if ($enableAddNewSegment) { $this->config->datatable_actions[] = [ 'id' => 'addSegmentToMatomo', 'title' => Piwik::translate('SegmentEditor_AddThisToMatomo'), 'icon' => 'icon-segment', ]; } }
[ "public", "function", "beforeRender", "(", ")", "{", "$", "this", "->", "config", "->", "show_as_content_block", "=", "false", ";", "$", "this", "->", "config", "->", "title", "=", "Piwik", "::", "translate", "(", "'Live_VisitorLog'", ")", ";", "$", "this", "->", "config", "->", "disable_row_actions", "=", "true", ";", "$", "this", "->", "config", "->", "datatable_js_type", "=", "'VisitorLog'", ";", "$", "this", "->", "config", "->", "enable_sort", "=", "false", ";", "$", "this", "->", "config", "->", "show_search", "=", "false", ";", "$", "this", "->", "config", "->", "show_exclude_low_population", "=", "false", ";", "$", "this", "->", "config", "->", "show_offset_information", "=", "false", ";", "$", "this", "->", "config", "->", "show_all_views_icons", "=", "false", ";", "$", "this", "->", "config", "->", "show_table_all_columns", "=", "false", ";", "$", "this", "->", "config", "->", "show_export_as_rss_feed", "=", "false", ";", "$", "this", "->", "config", "->", "disable_all_rows_filter_limit", "=", "true", ";", "$", "this", "->", "config", "->", "documentation", "=", "Piwik", "::", "translate", "(", "'Live_VisitorLogDocumentation'", ",", "array", "(", "'<br />'", ",", "'<br />'", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "config", "->", "custom_parameters", ")", ")", "{", "$", "this", "->", "config", "->", "custom_parameters", "=", "array", "(", ")", ";", "}", "// ensure to show next link if there are enough rows for a next page", "if", "(", "$", "this", "->", "dataTable", "->", "getRowsCount", "(", ")", ">", "$", "this", "->", "requestConfig", "->", "filter_limit", ")", "{", "$", "this", "->", "dataTable", "->", "deleteRowsOffset", "(", "$", "this", "->", "requestConfig", "->", "filter_limit", ")", ";", "$", "this", "->", "config", "->", "custom_parameters", "[", "'totalRows'", "]", "=", "10000000", ";", "}", "$", "this", "->", "config", "->", "custom_parameters", "[", "'smallWidth'", "]", "=", "(", "1", "==", "Common", "::", "getRequestVar", "(", "'small'", ",", "0", ",", "'int'", ")", ")", ";", "$", "this", "->", "config", "->", "custom_parameters", "[", "'hideProfileLink'", "]", "=", "(", "1", "==", "Common", "::", "getRequestVar", "(", "'hideProfileLink'", ",", "0", ",", "'int'", ")", ")", ";", "$", "this", "->", "config", "->", "custom_parameters", "[", "'pageUrlNotDefined'", "]", "=", "Piwik", "::", "translate", "(", "'General_NotDefined'", ",", "Piwik", "::", "translate", "(", "'Actions_ColumnPageURL'", ")", ")", ";", "$", "this", "->", "config", "->", "footer_icons", "=", "array", "(", "array", "(", "'class'", "=>", "'tableAllColumnsSwitch'", ",", "'buttons'", "=>", "array", "(", "array", "(", "'id'", "=>", "static", "::", "ID", ",", "'title'", "=>", "Piwik", "::", "translate", "(", "'Live_LinkVisitorLog'", ")", ",", "'icon'", "=>", "'plugins/Morpheus/images/table.png'", ")", ")", ")", ")", ";", "$", "enableAddNewSegment", "=", "Common", "::", "getRequestVar", "(", "'enableAddNewSegment'", ",", "false", ")", ";", "if", "(", "$", "enableAddNewSegment", ")", "{", "$", "this", "->", "config", "->", "datatable_actions", "[", "]", "=", "[", "'id'", "=>", "'addSegmentToMatomo'", ",", "'title'", "=>", "Piwik", "::", "translate", "(", "'SegmentEditor_AddThisToMatomo'", ")", ",", "'icon'", "=>", "'icon-segment'", ",", "]", ";", "}", "}" ]
Configure visualization.
[ "Configure", "visualization", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Live/Visualizations/VisitorLog.php#L78-L130
209,719
matomo-org/matomo
plugins/LanguagesManager/LanguagesManager.php
LanguagesManager.getLanguagesSelector
public function getLanguagesSelector() { $view = new View("@LanguagesManager/getLanguagesSelector"); $view->languages = API::getInstance()->getAvailableLanguageNames(); $view->currentLanguageCode = self::getLanguageCodeForCurrentUser(); $view->currentLanguageName = self::getLanguageNameForCurrentUser(); return $view->render(); }
php
public function getLanguagesSelector() { $view = new View("@LanguagesManager/getLanguagesSelector"); $view->languages = API::getInstance()->getAvailableLanguageNames(); $view->currentLanguageCode = self::getLanguageCodeForCurrentUser(); $view->currentLanguageName = self::getLanguageNameForCurrentUser(); return $view->render(); }
[ "public", "function", "getLanguagesSelector", "(", ")", "{", "$", "view", "=", "new", "View", "(", "\"@LanguagesManager/getLanguagesSelector\"", ")", ";", "$", "view", "->", "languages", "=", "API", "::", "getInstance", "(", ")", "->", "getAvailableLanguageNames", "(", ")", ";", "$", "view", "->", "currentLanguageCode", "=", "self", "::", "getLanguageCodeForCurrentUser", "(", ")", ";", "$", "view", "->", "currentLanguageName", "=", "self", "::", "getLanguageNameForCurrentUser", "(", ")", ";", "return", "$", "view", "->", "render", "(", ")", ";", "}" ]
Renders and returns the language selector HTML. @return string
[ "Renders", "and", "returns", "the", "language", "selector", "HTML", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/LanguagesManager.php#L85-L92
209,720
matomo-org/matomo
plugins/LanguagesManager/LanguagesManager.php
LanguagesManager.getLanguageForSession
public static function getLanguageForSession() { $cookieName = Config::getInstance()->General['language_cookie_name']; $cookie = new Cookie($cookieName); if ($cookie->isCookieFound()) { return $cookie->get('language'); } return null; }
php
public static function getLanguageForSession() { $cookieName = Config::getInstance()->General['language_cookie_name']; $cookie = new Cookie($cookieName); if ($cookie->isCookieFound()) { return $cookie->get('language'); } return null; }
[ "public", "static", "function", "getLanguageForSession", "(", ")", "{", "$", "cookieName", "=", "Config", "::", "getInstance", "(", ")", "->", "General", "[", "'language_cookie_name'", "]", ";", "$", "cookie", "=", "new", "Cookie", "(", "$", "cookieName", ")", ";", "if", "(", "$", "cookie", "->", "isCookieFound", "(", ")", ")", "{", "return", "$", "cookie", "->", "get", "(", "'language'", ")", ";", "}", "return", "null", ";", "}" ]
Returns the language for the session @return string|null
[ "Returns", "the", "language", "for", "the", "session" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/LanguagesManager.php#L201-L209
209,721
matomo-org/matomo
plugins/LanguagesManager/LanguagesManager.php
LanguagesManager.setLanguageForSession
public static function setLanguageForSession($languageCode) { if (!API::getInstance()->isLanguageAvailable($languageCode)) { return false; } $cookieName = Config::getInstance()->General['language_cookie_name']; $cookie = new Cookie($cookieName, 0); $cookie->set('language', $languageCode); $cookie->setSecure(ProxyHttp::isHttps()); $cookie->save(); return true; }
php
public static function setLanguageForSession($languageCode) { if (!API::getInstance()->isLanguageAvailable($languageCode)) { return false; } $cookieName = Config::getInstance()->General['language_cookie_name']; $cookie = new Cookie($cookieName, 0); $cookie->set('language', $languageCode); $cookie->setSecure(ProxyHttp::isHttps()); $cookie->save(); return true; }
[ "public", "static", "function", "setLanguageForSession", "(", "$", "languageCode", ")", "{", "if", "(", "!", "API", "::", "getInstance", "(", ")", "->", "isLanguageAvailable", "(", "$", "languageCode", ")", ")", "{", "return", "false", ";", "}", "$", "cookieName", "=", "Config", "::", "getInstance", "(", ")", "->", "General", "[", "'language_cookie_name'", "]", ";", "$", "cookie", "=", "new", "Cookie", "(", "$", "cookieName", ",", "0", ")", ";", "$", "cookie", "->", "set", "(", "'language'", ",", "$", "languageCode", ")", ";", "$", "cookie", "->", "setSecure", "(", "ProxyHttp", "::", "isHttps", "(", ")", ")", ";", "$", "cookie", "->", "save", "(", ")", ";", "return", "true", ";", "}" ]
Set the language for the session @param string $languageCode ISO language code @return bool
[ "Set", "the", "language", "for", "the", "session" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/LanguagesManager.php#L217-L229
209,722
matomo-org/matomo
plugins/PrivacyManager/Tracker/RequestProcessor.php
RequestProcessor.anonymizeUserId
public static function anonymizeUserId($userId) { $trackerCache = Tracker\Cache::getCacheGeneral(); $salt = ''; if (!empty($trackerCache[PrivacyManager::OPTION_USERID_SALT])) { $salt = $trackerCache[PrivacyManager::OPTION_USERID_SALT]; } if(empty($salt)) { return $userId; } return sha1($userId . $salt); }
php
public static function anonymizeUserId($userId) { $trackerCache = Tracker\Cache::getCacheGeneral(); $salt = ''; if (!empty($trackerCache[PrivacyManager::OPTION_USERID_SALT])) { $salt = $trackerCache[PrivacyManager::OPTION_USERID_SALT]; } if(empty($salt)) { return $userId; } return sha1($userId . $salt); }
[ "public", "static", "function", "anonymizeUserId", "(", "$", "userId", ")", "{", "$", "trackerCache", "=", "Tracker", "\\", "Cache", "::", "getCacheGeneral", "(", ")", ";", "$", "salt", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "trackerCache", "[", "PrivacyManager", "::", "OPTION_USERID_SALT", "]", ")", ")", "{", "$", "salt", "=", "$", "trackerCache", "[", "PrivacyManager", "::", "OPTION_USERID_SALT", "]", ";", "}", "if", "(", "empty", "(", "$", "salt", ")", ")", "{", "return", "$", "userId", ";", "}", "return", "sha1", "(", "$", "userId", ".", "$", "salt", ")", ";", "}" ]
pseudo anonymization as we need to make sure to always generate the same UserId for the same original UserID @param $userId @return string
[ "pseudo", "anonymization", "as", "we", "need", "to", "make", "sure", "to", "always", "generate", "the", "same", "UserId", "for", "the", "same", "original", "UserID" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/Tracker/RequestProcessor.php#L47-L58
209,723
matomo-org/matomo
core/Console.php
Console.getAvailableCommands
private function getAvailableCommands() { $commands = $this->getDefaultPiwikCommands(); $detected = PluginManager::getInstance()->findMultipleComponents('Commands', 'Piwik\\Plugin\\ConsoleCommand'); $commands = array_merge($commands, $detected); /** * Triggered to filter / restrict console commands. Plugins that want to restrict commands * should subscribe to this event and remove commands from the existing list. * * **Example** * * public function filterConsoleCommands(&$commands) * { * $key = array_search('Piwik\Plugins\MyPlugin\Commands\MyCommand', $commands); * if (false !== $key) { * unset($commands[$key]); * } * } * * @param array &$commands An array containing a list of command class names. */ Piwik::postEvent('Console.filterCommands', array(&$commands)); $commands = array_values(array_unique($commands)); return $commands; }
php
private function getAvailableCommands() { $commands = $this->getDefaultPiwikCommands(); $detected = PluginManager::getInstance()->findMultipleComponents('Commands', 'Piwik\\Plugin\\ConsoleCommand'); $commands = array_merge($commands, $detected); /** * Triggered to filter / restrict console commands. Plugins that want to restrict commands * should subscribe to this event and remove commands from the existing list. * * **Example** * * public function filterConsoleCommands(&$commands) * { * $key = array_search('Piwik\Plugins\MyPlugin\Commands\MyCommand', $commands); * if (false !== $key) { * unset($commands[$key]); * } * } * * @param array &$commands An array containing a list of command class names. */ Piwik::postEvent('Console.filterCommands', array(&$commands)); $commands = array_values(array_unique($commands)); return $commands; }
[ "private", "function", "getAvailableCommands", "(", ")", "{", "$", "commands", "=", "$", "this", "->", "getDefaultPiwikCommands", "(", ")", ";", "$", "detected", "=", "PluginManager", "::", "getInstance", "(", ")", "->", "findMultipleComponents", "(", "'Commands'", ",", "'Piwik\\\\Plugin\\\\ConsoleCommand'", ")", ";", "$", "commands", "=", "array_merge", "(", "$", "commands", ",", "$", "detected", ")", ";", "/**\n * Triggered to filter / restrict console commands. Plugins that want to restrict commands\n * should subscribe to this event and remove commands from the existing list.\n *\n * **Example**\n *\n * public function filterConsoleCommands(&$commands)\n * {\n * $key = array_search('Piwik\\Plugins\\MyPlugin\\Commands\\MyCommand', $commands);\n * if (false !== $key) {\n * unset($commands[$key]);\n * }\n * }\n *\n * @param array &$commands An array containing a list of command class names.\n */", "Piwik", "::", "postEvent", "(", "'Console.filterCommands'", ",", "array", "(", "&", "$", "commands", ")", ")", ";", "$", "commands", "=", "array_values", "(", "array_unique", "(", "$", "commands", ")", ")", ";", "return", "$", "commands", ";", "}" ]
Returns a list of available command classnames. @return string[]
[ "Returns", "a", "list", "of", "available", "command", "classnames", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Console.php#L133-L161
209,724
matomo-org/matomo
plugins/DevicePlugins/DevicePlugins.php
DevicePlugins.getAllPluginColumns
public static function getAllPluginColumns() { $cacheId = CacheId::pluginAware('DevicePluginColumns'); $cache = Cache::getTransientCache(); if (!$cache->contains($cacheId)) { $instances = []; foreach (self::getAllDevicePluginsColumnClasses() as $className) { $instance = new $className(); $instances[] = $instance; } $cache->save($cacheId, $instances); } return $cache->fetch($cacheId); }
php
public static function getAllPluginColumns() { $cacheId = CacheId::pluginAware('DevicePluginColumns'); $cache = Cache::getTransientCache(); if (!$cache->contains($cacheId)) { $instances = []; foreach (self::getAllDevicePluginsColumnClasses() as $className) { $instance = new $className(); $instances[] = $instance; } $cache->save($cacheId, $instances); } return $cache->fetch($cacheId); }
[ "public", "static", "function", "getAllPluginColumns", "(", ")", "{", "$", "cacheId", "=", "CacheId", "::", "pluginAware", "(", "'DevicePluginColumns'", ")", ";", "$", "cache", "=", "Cache", "::", "getTransientCache", "(", ")", ";", "if", "(", "!", "$", "cache", "->", "contains", "(", "$", "cacheId", ")", ")", "{", "$", "instances", "=", "[", "]", ";", "foreach", "(", "self", "::", "getAllDevicePluginsColumnClasses", "(", ")", "as", "$", "className", ")", "{", "$", "instance", "=", "new", "$", "className", "(", ")", ";", "$", "instances", "[", "]", "=", "$", "instance", ";", "}", "$", "cache", "->", "save", "(", "$", "cacheId", ",", "$", "instances", ")", ";", "}", "return", "$", "cache", "->", "fetch", "(", "$", "cacheId", ")", ";", "}" ]
Returns all available DevicePlugins Columns @return Columns\DevicePluginColumn[] @throws \Exception
[ "Returns", "all", "available", "DevicePlugins", "Columns" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DevicePlugins/DevicePlugins.php#L47-L63
209,725
matomo-org/matomo
plugins/Referrers/Columns/Base.php
Base.detectReferrerSearchEngine
protected function detectReferrerSearchEngine() { $cache = \Piwik\Cache::getTransientCache(); $cacheKey = 'cachedReferrerSearchEngine'; $cachedReferrerSearchEngine = []; if ($cache->contains($cacheKey)) { $cachedReferrerSearchEngine = $cache->fetch($cacheKey); } if (isset($cachedReferrerSearchEngine[$this->referrerUrl])) { $searchEngineInformation = $cachedReferrerSearchEngine[$this->referrerUrl]; } else { $searchEngineInformation = SearchEngineDetection::getInstance()->extractInformationFromUrl($this->referrerUrl); /** * Triggered when detecting the search engine of a referrer URL. * * Plugins can use this event to provide custom search engine detection * logic. * * @param array &$searchEngineInformation An array with the following information: * * - **name**: The search engine name. * - **keywords**: The search keywords used. * * This parameter is initialized to the results * of Piwik's default search engine detection * logic. * @param string referrerUrl The referrer URL from the tracking request. */ Piwik::postEvent('Tracker.detectReferrerSearchEngine', array(&$searchEngineInformation, $this->referrerUrl)); $cachedReferrerSearchEngine[$this->referrerUrl] = $searchEngineInformation; $cache->save($cacheKey, $cachedReferrerSearchEngine); } if ($searchEngineInformation === false) { return false; } $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_SEARCH_ENGINE; $this->nameReferrerAnalyzed = $searchEngineInformation['name']; $this->keywordReferrerAnalyzed = $searchEngineInformation['keywords']; return true; }
php
protected function detectReferrerSearchEngine() { $cache = \Piwik\Cache::getTransientCache(); $cacheKey = 'cachedReferrerSearchEngine'; $cachedReferrerSearchEngine = []; if ($cache->contains($cacheKey)) { $cachedReferrerSearchEngine = $cache->fetch($cacheKey); } if (isset($cachedReferrerSearchEngine[$this->referrerUrl])) { $searchEngineInformation = $cachedReferrerSearchEngine[$this->referrerUrl]; } else { $searchEngineInformation = SearchEngineDetection::getInstance()->extractInformationFromUrl($this->referrerUrl); /** * Triggered when detecting the search engine of a referrer URL. * * Plugins can use this event to provide custom search engine detection * logic. * * @param array &$searchEngineInformation An array with the following information: * * - **name**: The search engine name. * - **keywords**: The search keywords used. * * This parameter is initialized to the results * of Piwik's default search engine detection * logic. * @param string referrerUrl The referrer URL from the tracking request. */ Piwik::postEvent('Tracker.detectReferrerSearchEngine', array(&$searchEngineInformation, $this->referrerUrl)); $cachedReferrerSearchEngine[$this->referrerUrl] = $searchEngineInformation; $cache->save($cacheKey, $cachedReferrerSearchEngine); } if ($searchEngineInformation === false) { return false; } $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_SEARCH_ENGINE; $this->nameReferrerAnalyzed = $searchEngineInformation['name']; $this->keywordReferrerAnalyzed = $searchEngineInformation['keywords']; return true; }
[ "protected", "function", "detectReferrerSearchEngine", "(", ")", "{", "$", "cache", "=", "\\", "Piwik", "\\", "Cache", "::", "getTransientCache", "(", ")", ";", "$", "cacheKey", "=", "'cachedReferrerSearchEngine'", ";", "$", "cachedReferrerSearchEngine", "=", "[", "]", ";", "if", "(", "$", "cache", "->", "contains", "(", "$", "cacheKey", ")", ")", "{", "$", "cachedReferrerSearchEngine", "=", "$", "cache", "->", "fetch", "(", "$", "cacheKey", ")", ";", "}", "if", "(", "isset", "(", "$", "cachedReferrerSearchEngine", "[", "$", "this", "->", "referrerUrl", "]", ")", ")", "{", "$", "searchEngineInformation", "=", "$", "cachedReferrerSearchEngine", "[", "$", "this", "->", "referrerUrl", "]", ";", "}", "else", "{", "$", "searchEngineInformation", "=", "SearchEngineDetection", "::", "getInstance", "(", ")", "->", "extractInformationFromUrl", "(", "$", "this", "->", "referrerUrl", ")", ";", "/**\n * Triggered when detecting the search engine of a referrer URL.\n *\n * Plugins can use this event to provide custom search engine detection\n * logic.\n *\n * @param array &$searchEngineInformation An array with the following information:\n *\n * - **name**: The search engine name.\n * - **keywords**: The search keywords used.\n *\n * This parameter is initialized to the results\n * of Piwik's default search engine detection\n * logic.\n * @param string referrerUrl The referrer URL from the tracking request.\n */", "Piwik", "::", "postEvent", "(", "'Tracker.detectReferrerSearchEngine'", ",", "array", "(", "&", "$", "searchEngineInformation", ",", "$", "this", "->", "referrerUrl", ")", ")", ";", "$", "cachedReferrerSearchEngine", "[", "$", "this", "->", "referrerUrl", "]", "=", "$", "searchEngineInformation", ";", "$", "cache", "->", "save", "(", "$", "cacheKey", ",", "$", "cachedReferrerSearchEngine", ")", ";", "}", "if", "(", "$", "searchEngineInformation", "===", "false", ")", "{", "return", "false", ";", "}", "$", "this", "->", "typeReferrerAnalyzed", "=", "Common", "::", "REFERRER_TYPE_SEARCH_ENGINE", ";", "$", "this", "->", "nameReferrerAnalyzed", "=", "$", "searchEngineInformation", "[", "'name'", "]", ";", "$", "this", "->", "keywordReferrerAnalyzed", "=", "$", "searchEngineInformation", "[", "'keywords'", "]", ";", "return", "true", ";", "}" ]
Search engine detection @return bool
[ "Search", "engine", "detection" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/Columns/Base.php#L150-L195
209,726
matomo-org/matomo
plugins/Referrers/Columns/Base.php
Base.detectReferrerSocialNetwork
protected function detectReferrerSocialNetwork() { $cache = \Piwik\Cache::getTransientCache(); $cacheKey = 'cachedReferrerSocialNetworks'; $cachedReferrerSocialNetworks = []; if ($cache->contains($cacheKey)) { $cachedReferrerSocialNetworks = $cache->fetch($cacheKey); } $socialNetworkName = false; if (isset($cachedReferrerSocialNetworks[$this->referrerUrl])) { $socialNetworkName = $cachedReferrerSocialNetworks[$this->referrerUrl]; } else { if (SocialNetworkDetection::getInstance()->isSocialUrl($this->referrerUrl)) { $socialNetworkName = SocialNetworkDetection::getInstance()->getSocialNetworkFromDomain($this->referrerUrl); } /** * Triggered when detecting the social network of a referrer URL. * * Plugins can use this event to provide custom social network detection * logic. * * @param string|false &$socialNetworkName Name of the social network, or false if none detected * * This parameter is initialized to the results * of Matomo's default social network detection * logic. * @param string referrerUrl The referrer URL from the tracking request. */ Piwik::postEvent('Tracker.detectReferrerSocialNetwork', array(&$socialNetworkName, $this->referrerUrl)); $cachedReferrerSocialNetworks[$this->referrerUrl] = $socialNetworkName; $cache->save($cacheKey, $cachedReferrerSocialNetworks); } if ($socialNetworkName === false) { return false; } $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_SOCIAL_NETWORK; $this->nameReferrerAnalyzed = $socialNetworkName; $this->keywordReferrerAnalyzed = ''; return true; }
php
protected function detectReferrerSocialNetwork() { $cache = \Piwik\Cache::getTransientCache(); $cacheKey = 'cachedReferrerSocialNetworks'; $cachedReferrerSocialNetworks = []; if ($cache->contains($cacheKey)) { $cachedReferrerSocialNetworks = $cache->fetch($cacheKey); } $socialNetworkName = false; if (isset($cachedReferrerSocialNetworks[$this->referrerUrl])) { $socialNetworkName = $cachedReferrerSocialNetworks[$this->referrerUrl]; } else { if (SocialNetworkDetection::getInstance()->isSocialUrl($this->referrerUrl)) { $socialNetworkName = SocialNetworkDetection::getInstance()->getSocialNetworkFromDomain($this->referrerUrl); } /** * Triggered when detecting the social network of a referrer URL. * * Plugins can use this event to provide custom social network detection * logic. * * @param string|false &$socialNetworkName Name of the social network, or false if none detected * * This parameter is initialized to the results * of Matomo's default social network detection * logic. * @param string referrerUrl The referrer URL from the tracking request. */ Piwik::postEvent('Tracker.detectReferrerSocialNetwork', array(&$socialNetworkName, $this->referrerUrl)); $cachedReferrerSocialNetworks[$this->referrerUrl] = $socialNetworkName; $cache->save($cacheKey, $cachedReferrerSocialNetworks); } if ($socialNetworkName === false) { return false; } $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_SOCIAL_NETWORK; $this->nameReferrerAnalyzed = $socialNetworkName; $this->keywordReferrerAnalyzed = ''; return true; }
[ "protected", "function", "detectReferrerSocialNetwork", "(", ")", "{", "$", "cache", "=", "\\", "Piwik", "\\", "Cache", "::", "getTransientCache", "(", ")", ";", "$", "cacheKey", "=", "'cachedReferrerSocialNetworks'", ";", "$", "cachedReferrerSocialNetworks", "=", "[", "]", ";", "if", "(", "$", "cache", "->", "contains", "(", "$", "cacheKey", ")", ")", "{", "$", "cachedReferrerSocialNetworks", "=", "$", "cache", "->", "fetch", "(", "$", "cacheKey", ")", ";", "}", "$", "socialNetworkName", "=", "false", ";", "if", "(", "isset", "(", "$", "cachedReferrerSocialNetworks", "[", "$", "this", "->", "referrerUrl", "]", ")", ")", "{", "$", "socialNetworkName", "=", "$", "cachedReferrerSocialNetworks", "[", "$", "this", "->", "referrerUrl", "]", ";", "}", "else", "{", "if", "(", "SocialNetworkDetection", "::", "getInstance", "(", ")", "->", "isSocialUrl", "(", "$", "this", "->", "referrerUrl", ")", ")", "{", "$", "socialNetworkName", "=", "SocialNetworkDetection", "::", "getInstance", "(", ")", "->", "getSocialNetworkFromDomain", "(", "$", "this", "->", "referrerUrl", ")", ";", "}", "/**\n * Triggered when detecting the social network of a referrer URL.\n *\n * Plugins can use this event to provide custom social network detection\n * logic.\n *\n * @param string|false &$socialNetworkName Name of the social network, or false if none detected\n *\n * This parameter is initialized to the results\n * of Matomo's default social network detection\n * logic.\n * @param string referrerUrl The referrer URL from the tracking request.\n */", "Piwik", "::", "postEvent", "(", "'Tracker.detectReferrerSocialNetwork'", ",", "array", "(", "&", "$", "socialNetworkName", ",", "$", "this", "->", "referrerUrl", ")", ")", ";", "$", "cachedReferrerSocialNetworks", "[", "$", "this", "->", "referrerUrl", "]", "=", "$", "socialNetworkName", ";", "$", "cache", "->", "save", "(", "$", "cacheKey", ",", "$", "cachedReferrerSocialNetworks", ")", ";", "}", "if", "(", "$", "socialNetworkName", "===", "false", ")", "{", "return", "false", ";", "}", "$", "this", "->", "typeReferrerAnalyzed", "=", "Common", "::", "REFERRER_TYPE_SOCIAL_NETWORK", ";", "$", "this", "->", "nameReferrerAnalyzed", "=", "$", "socialNetworkName", ";", "$", "this", "->", "keywordReferrerAnalyzed", "=", "''", ";", "return", "true", ";", "}" ]
Social network detection @return bool
[ "Social", "network", "detection" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/Columns/Base.php#L201-L246
209,727
matomo-org/matomo
plugins/Referrers/Columns/Base.php
Base.detectReferrerDirectEntry
protected function detectReferrerDirectEntry() { if (empty($this->referrerHost)) { return false; } $urlsByHost = $this->getCachedUrlsByHostAndIdSite(); $directEntry = new SiteUrls(); $matchingSites = $directEntry->getIdSitesMatchingUrl($this->referrerUrlParse, $urlsByHost); if (isset($matchingSites) && is_array($matchingSites) && in_array($this->idsite, $matchingSites)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; return true; } elseif (isset($matchingSites)) { return false; } $site = Cache::getCacheWebsiteAttributes($this->idsite); $excludeUnknowns = $site['exclude_unknown_urls']; // fallback logic if the referrer domain is not known to any site to not break BC if (!$excludeUnknowns && isset($this->currentUrlParse['host'])) { // this might be actually buggy if first thing tracked is eg an outlink and referrer is from that site $currentHost = Common::mb_strtolower($this->currentUrlParse['host']); if ($currentHost == Common::mb_strtolower($this->referrerHost)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; return true; } } return false; }
php
protected function detectReferrerDirectEntry() { if (empty($this->referrerHost)) { return false; } $urlsByHost = $this->getCachedUrlsByHostAndIdSite(); $directEntry = new SiteUrls(); $matchingSites = $directEntry->getIdSitesMatchingUrl($this->referrerUrlParse, $urlsByHost); if (isset($matchingSites) && is_array($matchingSites) && in_array($this->idsite, $matchingSites)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; return true; } elseif (isset($matchingSites)) { return false; } $site = Cache::getCacheWebsiteAttributes($this->idsite); $excludeUnknowns = $site['exclude_unknown_urls']; // fallback logic if the referrer domain is not known to any site to not break BC if (!$excludeUnknowns && isset($this->currentUrlParse['host'])) { // this might be actually buggy if first thing tracked is eg an outlink and referrer is from that site $currentHost = Common::mb_strtolower($this->currentUrlParse['host']); if ($currentHost == Common::mb_strtolower($this->referrerHost)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; return true; } } return false; }
[ "protected", "function", "detectReferrerDirectEntry", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "referrerHost", ")", ")", "{", "return", "false", ";", "}", "$", "urlsByHost", "=", "$", "this", "->", "getCachedUrlsByHostAndIdSite", "(", ")", ";", "$", "directEntry", "=", "new", "SiteUrls", "(", ")", ";", "$", "matchingSites", "=", "$", "directEntry", "->", "getIdSitesMatchingUrl", "(", "$", "this", "->", "referrerUrlParse", ",", "$", "urlsByHost", ")", ";", "if", "(", "isset", "(", "$", "matchingSites", ")", "&&", "is_array", "(", "$", "matchingSites", ")", "&&", "in_array", "(", "$", "this", "->", "idsite", ",", "$", "matchingSites", ")", ")", "{", "$", "this", "->", "typeReferrerAnalyzed", "=", "Common", "::", "REFERRER_TYPE_DIRECT_ENTRY", ";", "return", "true", ";", "}", "elseif", "(", "isset", "(", "$", "matchingSites", ")", ")", "{", "return", "false", ";", "}", "$", "site", "=", "Cache", "::", "getCacheWebsiteAttributes", "(", "$", "this", "->", "idsite", ")", ";", "$", "excludeUnknowns", "=", "$", "site", "[", "'exclude_unknown_urls'", "]", ";", "// fallback logic if the referrer domain is not known to any site to not break BC", "if", "(", "!", "$", "excludeUnknowns", "&&", "isset", "(", "$", "this", "->", "currentUrlParse", "[", "'host'", "]", ")", ")", "{", "// this might be actually buggy if first thing tracked is eg an outlink and referrer is from that site", "$", "currentHost", "=", "Common", "::", "mb_strtolower", "(", "$", "this", "->", "currentUrlParse", "[", "'host'", "]", ")", ";", "if", "(", "$", "currentHost", "==", "Common", "::", "mb_strtolower", "(", "$", "this", "->", "referrerHost", ")", ")", "{", "$", "this", "->", "typeReferrerAnalyzed", "=", "Common", "::", "REFERRER_TYPE_DIRECT_ENTRY", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
We have previously tried to detect the campaign variables in the URL so at this stage, if the referrer host is the current host, or if the referrer host is any of the registered URL for this website, it is considered a direct entry @return bool
[ "We", "have", "previously", "tried", "to", "detect", "the", "campaign", "variables", "in", "the", "URL", "so", "at", "this", "stage", "if", "the", "referrer", "host", "is", "the", "current", "host", "or", "if", "the", "referrer", "host", "is", "any", "of", "the", "registered", "URL", "for", "this", "website", "it", "is", "considered", "a", "direct", "entry" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/Columns/Base.php#L340-L372
209,728
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.distinct
public function distinct($flag = true) { $this->_parts[self::DISTINCT] = (bool) $flag; return $this; }
php
public function distinct($flag = true) { $this->_parts[self::DISTINCT] = (bool) $flag; return $this; }
[ "public", "function", "distinct", "(", "$", "flag", "=", "true", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "DISTINCT", "]", "=", "(", "bool", ")", "$", "flag", ";", "return", "$", "this", ";", "}" ]
Makes the query SELECT DISTINCT. @param bool $flag Whether or not the SELECT is DISTINCT (default true). @return Zend_Db_Select This Zend_Db_Select object.
[ "Makes", "the", "query", "SELECT", "DISTINCT", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L198-L202
209,729
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.columns
public function columns($cols = '*', $correlationName = null) { if ($correlationName === null && count($this->_parts[self::FROM])) { $correlationNameKeys = array_keys($this->_parts[self::FROM]); $correlationName = current($correlationNameKeys); } if (!array_key_exists($correlationName, $this->_parts[self::FROM])) { /** * @see Zend_Db_Select_Exception */ // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("No table has been specified for the FROM clause"); } $this->_tableCols($correlationName, $cols); return $this; }
php
public function columns($cols = '*', $correlationName = null) { if ($correlationName === null && count($this->_parts[self::FROM])) { $correlationNameKeys = array_keys($this->_parts[self::FROM]); $correlationName = current($correlationNameKeys); } if (!array_key_exists($correlationName, $this->_parts[self::FROM])) { /** * @see Zend_Db_Select_Exception */ // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("No table has been specified for the FROM clause"); } $this->_tableCols($correlationName, $cols); return $this; }
[ "public", "function", "columns", "(", "$", "cols", "=", "'*'", ",", "$", "correlationName", "=", "null", ")", "{", "if", "(", "$", "correlationName", "===", "null", "&&", "count", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", ")", ")", "{", "$", "correlationNameKeys", "=", "array_keys", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", ")", ";", "$", "correlationName", "=", "current", "(", "$", "correlationNameKeys", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "correlationName", ",", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", ")", ")", "{", "/**\n * @see Zend_Db_Select_Exception\n */", "// require_once 'Zend/Db/Select/Exception.php';", "throw", "new", "Zend_Db_Select_Exception", "(", "\"No table has been specified for the FROM clause\"", ")", ";", "}", "$", "this", "->", "_tableCols", "(", "$", "correlationName", ",", "$", "cols", ")", ";", "return", "$", "this", ";", "}" ]
Specifies the columns used in the FROM clause. The parameter can be a single string or Zend_Db_Expr object, or else an array of strings or Zend_Db_Expr objects. @param array|string|Zend_Db_Expr $cols The columns to select from this table. @param string $correlationName Correlation name of target table. OPTIONAL @return Zend_Db_Select This Zend_Db_Select object.
[ "Specifies", "the", "columns", "used", "in", "the", "FROM", "clause", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L243-L261
209,730
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.union
public function union($select = array(), $type = self::SQL_UNION) { if (!is_array($select)) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception( "union() only accepts an array of Zend_Db_Select instances of sql query strings." ); } if (!in_array($type, self::$_unionTypes)) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid union type '{$type}'"); } foreach ($select as $target) { $this->_parts[self::UNION][] = array($target, $type); } return $this; }
php
public function union($select = array(), $type = self::SQL_UNION) { if (!is_array($select)) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception( "union() only accepts an array of Zend_Db_Select instances of sql query strings." ); } if (!in_array($type, self::$_unionTypes)) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid union type '{$type}'"); } foreach ($select as $target) { $this->_parts[self::UNION][] = array($target, $type); } return $this; }
[ "public", "function", "union", "(", "$", "select", "=", "array", "(", ")", ",", "$", "type", "=", "self", "::", "SQL_UNION", ")", "{", "if", "(", "!", "is_array", "(", "$", "select", ")", ")", "{", "// require_once 'Zend/Db/Select/Exception.php';", "throw", "new", "Zend_Db_Select_Exception", "(", "\"union() only accepts an array of Zend_Db_Select instances of sql query strings.\"", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "type", ",", "self", "::", "$", "_unionTypes", ")", ")", "{", "// require_once 'Zend/Db/Select/Exception.php';", "throw", "new", "Zend_Db_Select_Exception", "(", "\"Invalid union type '{$type}'\"", ")", ";", "}", "foreach", "(", "$", "select", "as", "$", "target", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "UNION", "]", "[", "]", "=", "array", "(", "$", "target", ",", "$", "type", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a UNION clause to the query. The first parameter has to be an array of Zend_Db_Select or sql query strings. <code> $sql1 = $db->select(); $sql2 = "SELECT ..."; $select = $db->select() ->union(array($sql1, $sql2)) ->order("id"); </code> @param array $select Array of select clauses for the union. @return Zend_Db_Select This Zend_Db_Select object.
[ "Adds", "a", "UNION", "clause", "to", "the", "query", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L280-L299
209,731
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.join
public function join($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->joinInner($name, $cond, $cols, $schema); }
php
public function join($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->joinInner($name, $cond, $cols, $schema); }
[ "public", "function", "join", "(", "$", "name", ",", "$", "cond", ",", "$", "cols", "=", "self", "::", "SQL_WILDCARD", ",", "$", "schema", "=", "null", ")", "{", "return", "$", "this", "->", "joinInner", "(", "$", "name", ",", "$", "cond", ",", "$", "cols", ",", "$", "schema", ")", ";", "}" ]
Adds a JOIN table and columns to the query. The $name and $cols parameters follow the same logic as described in the from() method. @param array|string|Zend_Db_Expr $name The table name. @param string $cond Join on this condition. @param array|string $cols The columns to select from the joined table. @param string $schema The database name to specify, if any. @return Zend_Db_Select This Zend_Db_Select object.
[ "Adds", "a", "JOIN", "table", "and", "columns", "to", "the", "query", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L313-L316
209,732
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.joinLeft
public function joinLeft($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::LEFT_JOIN, $name, $cond, $cols, $schema); }
php
public function joinLeft($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::LEFT_JOIN, $name, $cond, $cols, $schema); }
[ "public", "function", "joinLeft", "(", "$", "name", ",", "$", "cond", ",", "$", "cols", "=", "self", "::", "SQL_WILDCARD", ",", "$", "schema", "=", "null", ")", "{", "return", "$", "this", "->", "_join", "(", "self", "::", "LEFT_JOIN", ",", "$", "name", ",", "$", "cond", ",", "$", "cols", ",", "$", "schema", ")", ";", "}" ]
Add a LEFT OUTER JOIN table and colums to the query All rows from the left operand table are included, matching rows from the right operand table included, and the columns from the right operand table are filled with NULLs if no row exists matching the left table. The $name and $cols parameters follow the same logic as described in the from() method. @param array|string|Zend_Db_Expr $name The table name. @param string $cond Join on this condition. @param array|string $cols The columns to select from the joined table. @param string $schema The database name to specify, if any. @return Zend_Db_Select This Zend_Db_Select object.
[ "Add", "a", "LEFT", "OUTER", "JOIN", "table", "and", "colums", "to", "the", "query", "All", "rows", "from", "the", "left", "operand", "table", "are", "included", "matching", "rows", "from", "the", "right", "operand", "table", "included", "and", "the", "columns", "from", "the", "right", "operand", "table", "are", "filled", "with", "NULLs", "if", "no", "row", "exists", "matching", "the", "left", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L355-L358
209,733
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.joinRight
public function joinRight($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::RIGHT_JOIN, $name, $cond, $cols, $schema); }
php
public function joinRight($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::RIGHT_JOIN, $name, $cond, $cols, $schema); }
[ "public", "function", "joinRight", "(", "$", "name", ",", "$", "cond", ",", "$", "cols", "=", "self", "::", "SQL_WILDCARD", ",", "$", "schema", "=", "null", ")", "{", "return", "$", "this", "->", "_join", "(", "self", "::", "RIGHT_JOIN", ",", "$", "name", ",", "$", "cond", ",", "$", "cols", ",", "$", "schema", ")", ";", "}" ]
Add a RIGHT OUTER JOIN table and colums to the query. Right outer join is the complement of left outer join. All rows from the right operand table are included, matching rows from the left operand table included, and the columns from the left operand table are filled with NULLs if no row exists matching the right table. The $name and $cols parameters follow the same logic as described in the from() method. @param array|string|Zend_Db_Expr $name The table name. @param string $cond Join on this condition. @param array|string $cols The columns to select from the joined table. @param string $schema The database name to specify, if any. @return Zend_Db_Select This Zend_Db_Select object.
[ "Add", "a", "RIGHT", "OUTER", "JOIN", "table", "and", "colums", "to", "the", "query", ".", "Right", "outer", "join", "is", "the", "complement", "of", "left", "outer", "join", ".", "All", "rows", "from", "the", "right", "operand", "table", "are", "included", "matching", "rows", "from", "the", "left", "operand", "table", "included", "and", "the", "columns", "from", "the", "left", "operand", "table", "are", "filled", "with", "NULLs", "if", "no", "row", "exists", "matching", "the", "right", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L377-L380
209,734
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.joinFull
public function joinFull($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::FULL_JOIN, $name, $cond, $cols, $schema); }
php
public function joinFull($name, $cond, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::FULL_JOIN, $name, $cond, $cols, $schema); }
[ "public", "function", "joinFull", "(", "$", "name", ",", "$", "cond", ",", "$", "cols", "=", "self", "::", "SQL_WILDCARD", ",", "$", "schema", "=", "null", ")", "{", "return", "$", "this", "->", "_join", "(", "self", "::", "FULL_JOIN", ",", "$", "name", ",", "$", "cond", ",", "$", "cols", ",", "$", "schema", ")", ";", "}" ]
Add a FULL OUTER JOIN table and colums to the query. A full outer join is like combining a left outer join and a right outer join. All rows from both tables are included, paired with each other on the same row of the result set if they satisfy the join condition, and otherwise paired with NULLs in place of columns from the other table. The $name and $cols parameters follow the same logic as described in the from() method. @param array|string|Zend_Db_Expr $name The table name. @param string $cond Join on this condition. @param array|string $cols The columns to select from the joined table. @param string $schema The database name to specify, if any. @return Zend_Db_Select This Zend_Db_Select object.
[ "Add", "a", "FULL", "OUTER", "JOIN", "table", "and", "colums", "to", "the", "query", ".", "A", "full", "outer", "join", "is", "like", "combining", "a", "left", "outer", "join", "and", "a", "right", "outer", "join", ".", "All", "rows", "from", "both", "tables", "are", "included", "paired", "with", "each", "other", "on", "the", "same", "row", "of", "the", "result", "set", "if", "they", "satisfy", "the", "join", "condition", "and", "otherwise", "paired", "with", "NULLs", "in", "place", "of", "columns", "from", "the", "other", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L399-L402
209,735
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.joinCross
public function joinCross($name, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::CROSS_JOIN, $name, null, $cols, $schema); }
php
public function joinCross($name, $cols = self::SQL_WILDCARD, $schema = null) { return $this->_join(self::CROSS_JOIN, $name, null, $cols, $schema); }
[ "public", "function", "joinCross", "(", "$", "name", ",", "$", "cols", "=", "self", "::", "SQL_WILDCARD", ",", "$", "schema", "=", "null", ")", "{", "return", "$", "this", "->", "_join", "(", "self", "::", "CROSS_JOIN", ",", "$", "name", ",", "null", ",", "$", "cols", ",", "$", "schema", ")", ";", "}" ]
Add a CROSS JOIN table and colums to the query. A cross join is a cartesian product; there is no join condition. The $name and $cols parameters follow the same logic as described in the from() method. @param array|string|Zend_Db_Expr $name The table name. @param array|string $cols The columns to select from the joined table. @param string $schema The database name to specify, if any. @return Zend_Db_Select This Zend_Db_Select object.
[ "Add", "a", "CROSS", "JOIN", "table", "and", "colums", "to", "the", "query", ".", "A", "cross", "join", "is", "a", "cartesian", "product", ";", "there", "is", "no", "join", "condition", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L416-L419
209,736
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.where
public function where($cond, $value = null, $type = null) { $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, true); return $this; }
php
public function where($cond, $value = null, $type = null) { $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, true); return $this; }
[ "public", "function", "where", "(", "$", "cond", ",", "$", "value", "=", "null", ",", "$", "type", "=", "null", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "WHERE", "]", "[", "]", "=", "$", "this", "->", "_where", "(", "$", "cond", ",", "$", "value", ",", "$", "type", ",", "true", ")", ";", "return", "$", "this", ";", "}" ]
Adds a WHERE condition to the query by AND. If a value is passed as the second param, it will be quoted and replaced into the condition wherever a question-mark appears. Array values are quoted and comma-separated. <code> // simplest but non-secure $select->where("id = $id"); // secure (ID is quoted but matched anyway) $select->where('id = ?', $id); // alternatively, with named binding $select->where('id = :id'); </code> Note that it is more correct to use named bindings in your queries for values other than strings. When you use named bindings, don't forget to pass the values when actually making a query: <code> $db->fetchAll($select, array('id' => 5)); </code> @param string $cond The WHERE condition. @param mixed $value OPTIONAL The value to quote into the condition. @param int $type OPTIONAL The type of the given value @return Zend_Db_Select This Zend_Db_Select object.
[ "Adds", "a", "WHERE", "condition", "to", "the", "query", "by", "AND", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L473-L478
209,737
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.orWhere
public function orWhere($cond, $value = null, $type = null) { $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, false); return $this; }
php
public function orWhere($cond, $value = null, $type = null) { $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, false); return $this; }
[ "public", "function", "orWhere", "(", "$", "cond", ",", "$", "value", "=", "null", ",", "$", "type", "=", "null", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "WHERE", "]", "[", "]", "=", "$", "this", "->", "_where", "(", "$", "cond", ",", "$", "value", ",", "$", "type", ",", "false", ")", ";", "return", "$", "this", ";", "}" ]
Adds a WHERE condition to the query by OR. Otherwise identical to where(). @param string $cond The WHERE condition. @param mixed $value OPTIONAL The value to quote into the condition. @param int $type OPTIONAL The type of the given value @return Zend_Db_Select This Zend_Db_Select object. @see where()
[ "Adds", "a", "WHERE", "condition", "to", "the", "query", "by", "OR", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L492-L497
209,738
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.group
public function group($spec) { if (!is_array($spec)) { $spec = array($spec); } foreach ($spec as $val) { if (preg_match('/\(.*\)/', (string) $val)) { $val = new Zend_Db_Expr($val); } $this->_parts[self::GROUP][] = $val; } return $this; }
php
public function group($spec) { if (!is_array($spec)) { $spec = array($spec); } foreach ($spec as $val) { if (preg_match('/\(.*\)/', (string) $val)) { $val = new Zend_Db_Expr($val); } $this->_parts[self::GROUP][] = $val; } return $this; }
[ "public", "function", "group", "(", "$", "spec", ")", "{", "if", "(", "!", "is_array", "(", "$", "spec", ")", ")", "{", "$", "spec", "=", "array", "(", "$", "spec", ")", ";", "}", "foreach", "(", "$", "spec", "as", "$", "val", ")", "{", "if", "(", "preg_match", "(", "'/\\(.*\\)/'", ",", "(", "string", ")", "$", "val", ")", ")", "{", "$", "val", "=", "new", "Zend_Db_Expr", "(", "$", "val", ")", ";", "}", "$", "this", "->", "_parts", "[", "self", "::", "GROUP", "]", "[", "]", "=", "$", "val", ";", "}", "return", "$", "this", ";", "}" ]
Adds grouping to the query. @param array|string $spec The column(s) to group by. @return Zend_Db_Select This Zend_Db_Select object.
[ "Adds", "grouping", "to", "the", "query", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L505-L519
209,739
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.having
public function having($cond, $value = null, $type = null) { if ($value !== null) { $cond = $this->_adapter->quoteInto($cond, $value, $type); } if ($this->_parts[self::HAVING]) { $this->_parts[self::HAVING][] = self::SQL_AND . " ($cond)"; } else { $this->_parts[self::HAVING][] = "($cond)"; } return $this; }
php
public function having($cond, $value = null, $type = null) { if ($value !== null) { $cond = $this->_adapter->quoteInto($cond, $value, $type); } if ($this->_parts[self::HAVING]) { $this->_parts[self::HAVING][] = self::SQL_AND . " ($cond)"; } else { $this->_parts[self::HAVING][] = "($cond)"; } return $this; }
[ "public", "function", "having", "(", "$", "cond", ",", "$", "value", "=", "null", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "cond", "=", "$", "this", "->", "_adapter", "->", "quoteInto", "(", "$", "cond", ",", "$", "value", ",", "$", "type", ")", ";", "}", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", "[", "]", "=", "self", "::", "SQL_AND", ".", "\" ($cond)\"", ";", "}", "else", "{", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", "[", "]", "=", "\"($cond)\"", ";", "}", "return", "$", "this", ";", "}" ]
Adds a HAVING condition to the query by AND. If a value is passed as the second param, it will be quoted and replaced into the condition wherever a question-mark appears. See {@link where()} for an example @param string $cond The HAVING condition. @param mixed $value OPTIONAL The value to quote into the condition. @param int $type OPTIONAL The type of the given value @return Zend_Db_Select This Zend_Db_Select object.
[ "Adds", "a", "HAVING", "condition", "to", "the", "query", "by", "AND", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L533-L546
209,740
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.orHaving
public function orHaving($cond, $value = null, $type = null) { if ($value !== null) { $cond = $this->_adapter->quoteInto($cond, $value, $type); } if ($this->_parts[self::HAVING]) { $this->_parts[self::HAVING][] = self::SQL_OR . " ($cond)"; } else { $this->_parts[self::HAVING][] = "($cond)"; } return $this; }
php
public function orHaving($cond, $value = null, $type = null) { if ($value !== null) { $cond = $this->_adapter->quoteInto($cond, $value, $type); } if ($this->_parts[self::HAVING]) { $this->_parts[self::HAVING][] = self::SQL_OR . " ($cond)"; } else { $this->_parts[self::HAVING][] = "($cond)"; } return $this; }
[ "public", "function", "orHaving", "(", "$", "cond", ",", "$", "value", "=", "null", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "cond", "=", "$", "this", "->", "_adapter", "->", "quoteInto", "(", "$", "cond", ",", "$", "value", ",", "$", "type", ")", ";", "}", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", "[", "]", "=", "self", "::", "SQL_OR", ".", "\" ($cond)\"", ";", "}", "else", "{", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", "[", "]", "=", "\"($cond)\"", ";", "}", "return", "$", "this", ";", "}" ]
Adds a HAVING condition to the query by OR. Otherwise identical to orHaving(). @param string $cond The HAVING condition. @param mixed $value OPTIONAL The value to quote into the condition. @param int $type OPTIONAL The type of the given value @return Zend_Db_Select This Zend_Db_Select object. @see having()
[ "Adds", "a", "HAVING", "condition", "to", "the", "query", "by", "OR", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L560-L573
209,741
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.order
public function order($spec) { if (!is_array($spec)) { $spec = array($spec); } // force 'ASC' or 'DESC' on each order spec, default is ASC. foreach ($spec as $val) { if ($val instanceof Zend_Db_Expr) { $expr = $val->__toString(); if (empty($expr)) { continue; } $this->_parts[self::ORDER][] = $val; } else { if (empty($val)) { continue; } $direction = self::SQL_ASC; if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) { $val = trim($matches[1]); $direction = $matches[2]; } if (preg_match('/\(.*\)/', $val)) { $val = new Zend_Db_Expr($val); } $this->_parts[self::ORDER][] = array($val, $direction); } } return $this; }
php
public function order($spec) { if (!is_array($spec)) { $spec = array($spec); } // force 'ASC' or 'DESC' on each order spec, default is ASC. foreach ($spec as $val) { if ($val instanceof Zend_Db_Expr) { $expr = $val->__toString(); if (empty($expr)) { continue; } $this->_parts[self::ORDER][] = $val; } else { if (empty($val)) { continue; } $direction = self::SQL_ASC; if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) { $val = trim($matches[1]); $direction = $matches[2]; } if (preg_match('/\(.*\)/', $val)) { $val = new Zend_Db_Expr($val); } $this->_parts[self::ORDER][] = array($val, $direction); } } return $this; }
[ "public", "function", "order", "(", "$", "spec", ")", "{", "if", "(", "!", "is_array", "(", "$", "spec", ")", ")", "{", "$", "spec", "=", "array", "(", "$", "spec", ")", ";", "}", "// force 'ASC' or 'DESC' on each order spec, default is ASC.", "foreach", "(", "$", "spec", "as", "$", "val", ")", "{", "if", "(", "$", "val", "instanceof", "Zend_Db_Expr", ")", "{", "$", "expr", "=", "$", "val", "->", "__toString", "(", ")", ";", "if", "(", "empty", "(", "$", "expr", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "_parts", "[", "self", "::", "ORDER", "]", "[", "]", "=", "$", "val", ";", "}", "else", "{", "if", "(", "empty", "(", "$", "val", ")", ")", "{", "continue", ";", "}", "$", "direction", "=", "self", "::", "SQL_ASC", ";", "if", "(", "preg_match", "(", "'/(.*\\W)('", ".", "self", "::", "SQL_ASC", ".", "'|'", ".", "self", "::", "SQL_DESC", ".", "')\\b/si'", ",", "$", "val", ",", "$", "matches", ")", ")", "{", "$", "val", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "direction", "=", "$", "matches", "[", "2", "]", ";", "}", "if", "(", "preg_match", "(", "'/\\(.*\\)/'", ",", "$", "val", ")", ")", "{", "$", "val", "=", "new", "Zend_Db_Expr", "(", "$", "val", ")", ";", "}", "$", "this", "->", "_parts", "[", "self", "::", "ORDER", "]", "[", "]", "=", "array", "(", "$", "val", ",", "$", "direction", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Adds a row order to the query. @param mixed $spec The column(s) and direction to order by. @return Zend_Db_Select This Zend_Db_Select object.
[ "Adds", "a", "row", "order", "to", "the", "query", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L581-L612
209,742
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.limit
public function limit($count = null, $offset = null) { $this->_parts[self::LIMIT_COUNT] = (int) $count; $this->_parts[self::LIMIT_OFFSET] = (int) $offset; return $this; }
php
public function limit($count = null, $offset = null) { $this->_parts[self::LIMIT_COUNT] = (int) $count; $this->_parts[self::LIMIT_OFFSET] = (int) $offset; return $this; }
[ "public", "function", "limit", "(", "$", "count", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_COUNT", "]", "=", "(", "int", ")", "$", "count", ";", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_OFFSET", "]", "=", "(", "int", ")", "$", "offset", ";", "return", "$", "this", ";", "}" ]
Sets a limit count and offset to the query. @param int $count OPTIONAL The number of rows to return. @param int $offset OPTIONAL Start returning after this many rows. @return Zend_Db_Select This Zend_Db_Select object.
[ "Sets", "a", "limit", "count", "and", "offset", "to", "the", "query", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L621-L626
209,743
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.limitPage
public function limitPage($page, $rowCount) { $page = ($page > 0) ? $page : 1; $rowCount = ($rowCount > 0) ? $rowCount : 1; $this->_parts[self::LIMIT_COUNT] = (int) $rowCount; $this->_parts[self::LIMIT_OFFSET] = (int) $rowCount * ($page - 1); return $this; }
php
public function limitPage($page, $rowCount) { $page = ($page > 0) ? $page : 1; $rowCount = ($rowCount > 0) ? $rowCount : 1; $this->_parts[self::LIMIT_COUNT] = (int) $rowCount; $this->_parts[self::LIMIT_OFFSET] = (int) $rowCount * ($page - 1); return $this; }
[ "public", "function", "limitPage", "(", "$", "page", ",", "$", "rowCount", ")", "{", "$", "page", "=", "(", "$", "page", ">", "0", ")", "?", "$", "page", ":", "1", ";", "$", "rowCount", "=", "(", "$", "rowCount", ">", "0", ")", "?", "$", "rowCount", ":", "1", ";", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_COUNT", "]", "=", "(", "int", ")", "$", "rowCount", ";", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_OFFSET", "]", "=", "(", "int", ")", "$", "rowCount", "*", "(", "$", "page", "-", "1", ")", ";", "return", "$", "this", ";", "}" ]
Sets the limit and count by page number. @param int $page Limit results to this page number. @param int $rowCount Use this many rows per page. @return Zend_Db_Select This Zend_Db_Select object.
[ "Sets", "the", "limit", "and", "count", "by", "page", "number", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L635-L642
209,744
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.forUpdate
public function forUpdate($flag = true) { $this->_parts[self::FOR_UPDATE] = (bool) $flag; return $this; }
php
public function forUpdate($flag = true) { $this->_parts[self::FOR_UPDATE] = (bool) $flag; return $this; }
[ "public", "function", "forUpdate", "(", "$", "flag", "=", "true", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "FOR_UPDATE", "]", "=", "(", "bool", ")", "$", "flag", ";", "return", "$", "this", ";", "}" ]
Makes the query SELECT FOR UPDATE. @param bool $flag Whether or not the SELECT is FOR UPDATE (default true). @return Zend_Db_Select This Zend_Db_Select object.
[ "Makes", "the", "query", "SELECT", "FOR", "UPDATE", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L650-L654
209,745
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.getPart
public function getPart($part) { $part = strtolower($part); if (!array_key_exists($part, $this->_parts)) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid Select part '$part'"); } return $this->_parts[$part]; }
php
public function getPart($part) { $part = strtolower($part); if (!array_key_exists($part, $this->_parts)) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid Select part '$part'"); } return $this->_parts[$part]; }
[ "public", "function", "getPart", "(", "$", "part", ")", "{", "$", "part", "=", "strtolower", "(", "$", "part", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "part", ",", "$", "this", "->", "_parts", ")", ")", "{", "// require_once 'Zend/Db/Select/Exception.php';", "throw", "new", "Zend_Db_Select_Exception", "(", "\"Invalid Select part '$part'\"", ")", ";", "}", "return", "$", "this", "->", "_parts", "[", "$", "part", "]", ";", "}" ]
Get part of the structured information for the currect query. @param string $part @return mixed @throws Zend_Db_Select_Exception
[ "Get", "part", "of", "the", "structured", "information", "for", "the", "currect", "query", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L663-L671
209,746
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.query
public function query($fetchMode = null, $bind = array()) { if (!empty($bind)) { $this->bind($bind); } $stmt = $this->_adapter->query($this); if ($fetchMode == null) { $fetchMode = $this->_adapter->getFetchMode(); } $stmt->setFetchMode($fetchMode); return $stmt; }
php
public function query($fetchMode = null, $bind = array()) { if (!empty($bind)) { $this->bind($bind); } $stmt = $this->_adapter->query($this); if ($fetchMode == null) { $fetchMode = $this->_adapter->getFetchMode(); } $stmt->setFetchMode($fetchMode); return $stmt; }
[ "public", "function", "query", "(", "$", "fetchMode", "=", "null", ",", "$", "bind", "=", "array", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "bind", ")", ")", "{", "$", "this", "->", "bind", "(", "$", "bind", ")", ";", "}", "$", "stmt", "=", "$", "this", "->", "_adapter", "->", "query", "(", "$", "this", ")", ";", "if", "(", "$", "fetchMode", "==", "null", ")", "{", "$", "fetchMode", "=", "$", "this", "->", "_adapter", "->", "getFetchMode", "(", ")", ";", "}", "$", "stmt", "->", "setFetchMode", "(", "$", "fetchMode", ")", ";", "return", "$", "stmt", ";", "}" ]
Executes the current select object and returns the result @param integer $fetchMode OPTIONAL @param mixed $bind An array of data to bind to the placeholders. @return PDO_Statement|Zend_Db_Statement
[ "Executes", "the", "current", "select", "object", "and", "returns", "the", "result" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L680-L692
209,747
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.assemble
public function assemble() { $sql = self::SQL_SELECT; foreach (array_keys(self::$_partsInit) as $part) { $method = '_render' . ucfirst($part); if (method_exists($this, $method)) { $sql = $this->$method($sql); } } return $sql; }
php
public function assemble() { $sql = self::SQL_SELECT; foreach (array_keys(self::$_partsInit) as $part) { $method = '_render' . ucfirst($part); if (method_exists($this, $method)) { $sql = $this->$method($sql); } } return $sql; }
[ "public", "function", "assemble", "(", ")", "{", "$", "sql", "=", "self", "::", "SQL_SELECT", ";", "foreach", "(", "array_keys", "(", "self", "::", "$", "_partsInit", ")", "as", "$", "part", ")", "{", "$", "method", "=", "'_render'", ".", "ucfirst", "(", "$", "part", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "sql", "=", "$", "this", "->", "$", "method", "(", "$", "sql", ")", ";", "}", "}", "return", "$", "sql", ";", "}" ]
Converts this object to an SQL SELECT string. @return string|null This object as a SELECT string. (or null if a string cannot be produced.)
[ "Converts", "this", "object", "to", "an", "SQL", "SELECT", "string", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L699-L709
209,748
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select.reset
public function reset($part = null) { if ($part == null) { $this->_parts = self::$_partsInit; } else if (array_key_exists($part, self::$_partsInit)) { $this->_parts[$part] = self::$_partsInit[$part]; } return $this; }
php
public function reset($part = null) { if ($part == null) { $this->_parts = self::$_partsInit; } else if (array_key_exists($part, self::$_partsInit)) { $this->_parts[$part] = self::$_partsInit[$part]; } return $this; }
[ "public", "function", "reset", "(", "$", "part", "=", "null", ")", "{", "if", "(", "$", "part", "==", "null", ")", "{", "$", "this", "->", "_parts", "=", "self", "::", "$", "_partsInit", ";", "}", "else", "if", "(", "array_key_exists", "(", "$", "part", ",", "self", "::", "$", "_partsInit", ")", ")", "{", "$", "this", "->", "_parts", "[", "$", "part", "]", "=", "self", "::", "$", "_partsInit", "[", "$", "part", "]", ";", "}", "return", "$", "this", ";", "}" ]
Clear parts of the Select object, or an individual part. @param string $part OPTIONAL @return Zend_Db_Select
[ "Clear", "parts", "of", "the", "Select", "object", "or", "an", "individual", "part", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L717-L725
209,749
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._joinUsing
public function _joinUsing($type, $name, $cond, $cols = '*', $schema = null) { if (empty($this->_parts[self::FROM])) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("You can only perform a joinUsing after specifying a FROM table"); } $join = $this->_adapter->quoteIdentifier(key($this->_parts[self::FROM]), true); $from = $this->_adapter->quoteIdentifier($this->_uniqueCorrelation($name), true); $cond1 = $from . '.' . $cond; $cond2 = $join . '.' . $cond; $cond = $cond1 . ' = ' . $cond2; return $this->_join($type, $name, $cond, $cols, $schema); }
php
public function _joinUsing($type, $name, $cond, $cols = '*', $schema = null) { if (empty($this->_parts[self::FROM])) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("You can only perform a joinUsing after specifying a FROM table"); } $join = $this->_adapter->quoteIdentifier(key($this->_parts[self::FROM]), true); $from = $this->_adapter->quoteIdentifier($this->_uniqueCorrelation($name), true); $cond1 = $from . '.' . $cond; $cond2 = $join . '.' . $cond; $cond = $cond1 . ' = ' . $cond2; return $this->_join($type, $name, $cond, $cols, $schema); }
[ "public", "function", "_joinUsing", "(", "$", "type", ",", "$", "name", ",", "$", "cond", ",", "$", "cols", "=", "'*'", ",", "$", "schema", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", ")", ")", "{", "// require_once 'Zend/Db/Select/Exception.php';", "throw", "new", "Zend_Db_Select_Exception", "(", "\"You can only perform a joinUsing after specifying a FROM table\"", ")", ";", "}", "$", "join", "=", "$", "this", "->", "_adapter", "->", "quoteIdentifier", "(", "key", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", ")", ",", "true", ")", ";", "$", "from", "=", "$", "this", "->", "_adapter", "->", "quoteIdentifier", "(", "$", "this", "->", "_uniqueCorrelation", "(", "$", "name", ")", ",", "true", ")", ";", "$", "cond1", "=", "$", "from", ".", "'.'", ".", "$", "cond", ";", "$", "cond2", "=", "$", "join", ".", "'.'", ".", "$", "cond", ";", "$", "cond", "=", "$", "cond1", ".", "' = '", ".", "$", "cond2", ";", "return", "$", "this", "->", "_join", "(", "$", "type", ",", "$", "name", ",", "$", "cond", ",", "$", "cols", ",", "$", "schema", ")", ";", "}" ]
Handle JOIN... USING... syntax This is functionality identical to the existing JOIN methods, however the join condition can be passed as a single column name. This method then completes the ON condition by using the same field for the FROM table and the JOIN table. <code> $select = $db->select()->from('table1') ->joinUsing('table2', 'column1'); // SELECT * FROM table1 JOIN table2 ON table1.column1 = table2.column2 </code> These joins are called by the developer simply by adding 'Using' to the method name. E.g. * joinUsing * joinInnerUsing * joinFullUsing * joinRightUsing * joinLeftUsing @return Zend_Db_Select This Zend_Db_Select object.
[ "Handle", "JOIN", "...", "USING", "...", "syntax" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L873-L888
209,750
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._uniqueCorrelation
private function _uniqueCorrelation($name) { if (is_array($name)) { $c = end($name); } else { // Extract just the last name of a qualified table name $dot = strrpos($name,'.'); $c = ($dot === false) ? $name : substr($name, $dot+1); } for ($i = 2; array_key_exists($c, $this->_parts[self::FROM]); ++$i) { $c = $name . '_' . (string) $i; } return $c; }
php
private function _uniqueCorrelation($name) { if (is_array($name)) { $c = end($name); } else { // Extract just the last name of a qualified table name $dot = strrpos($name,'.'); $c = ($dot === false) ? $name : substr($name, $dot+1); } for ($i = 2; array_key_exists($c, $this->_parts[self::FROM]); ++$i) { $c = $name . '_' . (string) $i; } return $c; }
[ "private", "function", "_uniqueCorrelation", "(", "$", "name", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "c", "=", "end", "(", "$", "name", ")", ";", "}", "else", "{", "// Extract just the last name of a qualified table name", "$", "dot", "=", "strrpos", "(", "$", "name", ",", "'.'", ")", ";", "$", "c", "=", "(", "$", "dot", "===", "false", ")", "?", "$", "name", ":", "substr", "(", "$", "name", ",", "$", "dot", "+", "1", ")", ";", "}", "for", "(", "$", "i", "=", "2", ";", "array_key_exists", "(", "$", "c", ",", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", ")", ";", "++", "$", "i", ")", "{", "$", "c", "=", "$", "name", ".", "'_'", ".", "(", "string", ")", "$", "i", ";", "}", "return", "$", "c", ";", "}" ]
Generate a unique correlation name @param string|array $name A qualified identifier. @return string A unique correlation name.
[ "Generate", "a", "unique", "correlation", "name" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L896-L909
209,751
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._tableCols
protected function _tableCols($correlationName, $cols, $afterCorrelationName = null) { if (!is_array($cols)) { $cols = array($cols); } if ($correlationName == null) { $correlationName = ''; } $columnValues = array(); foreach (array_filter($cols) as $alias => $col) { $currentCorrelationName = $correlationName; if (is_string($col)) { // Check for a column matching "<column> AS <alias>" and extract the alias name if (preg_match('/^(.+)\s+' . self::SQL_AS . '\s+(.+)$/i', $col, $m)) { $col = $m[1]; $alias = $m[2]; } // Check for columns that look like functions and convert to Zend_Db_Expr if (preg_match('/\(.*\)/', $col)) { $col = new Zend_Db_Expr($col); } elseif (preg_match('/(.+)\.(.+)/', $col, $m)) { $currentCorrelationName = $m[1]; $col = $m[2]; } } $columnValues[] = array($currentCorrelationName, $col, is_string($alias) ? $alias : null); } if ($columnValues) { // should we attempt to prepend or insert these values? if ($afterCorrelationName === true || is_string($afterCorrelationName)) { $tmpColumns = $this->_parts[self::COLUMNS]; $this->_parts[self::COLUMNS] = array(); } else { $tmpColumns = array(); } // find the correlation name to insert after if (is_string($afterCorrelationName)) { while ($tmpColumns) { $this->_parts[self::COLUMNS][] = $currentColumn = array_shift($tmpColumns); if ($currentColumn[0] == $afterCorrelationName) { break; } } } // apply current values to current stack foreach ($columnValues as $columnValue) { array_push($this->_parts[self::COLUMNS], $columnValue); } // finish ensuring that all previous values are applied (if they exist) while ($tmpColumns) { array_push($this->_parts[self::COLUMNS], array_shift($tmpColumns)); } } }
php
protected function _tableCols($correlationName, $cols, $afterCorrelationName = null) { if (!is_array($cols)) { $cols = array($cols); } if ($correlationName == null) { $correlationName = ''; } $columnValues = array(); foreach (array_filter($cols) as $alias => $col) { $currentCorrelationName = $correlationName; if (is_string($col)) { // Check for a column matching "<column> AS <alias>" and extract the alias name if (preg_match('/^(.+)\s+' . self::SQL_AS . '\s+(.+)$/i', $col, $m)) { $col = $m[1]; $alias = $m[2]; } // Check for columns that look like functions and convert to Zend_Db_Expr if (preg_match('/\(.*\)/', $col)) { $col = new Zend_Db_Expr($col); } elseif (preg_match('/(.+)\.(.+)/', $col, $m)) { $currentCorrelationName = $m[1]; $col = $m[2]; } } $columnValues[] = array($currentCorrelationName, $col, is_string($alias) ? $alias : null); } if ($columnValues) { // should we attempt to prepend or insert these values? if ($afterCorrelationName === true || is_string($afterCorrelationName)) { $tmpColumns = $this->_parts[self::COLUMNS]; $this->_parts[self::COLUMNS] = array(); } else { $tmpColumns = array(); } // find the correlation name to insert after if (is_string($afterCorrelationName)) { while ($tmpColumns) { $this->_parts[self::COLUMNS][] = $currentColumn = array_shift($tmpColumns); if ($currentColumn[0] == $afterCorrelationName) { break; } } } // apply current values to current stack foreach ($columnValues as $columnValue) { array_push($this->_parts[self::COLUMNS], $columnValue); } // finish ensuring that all previous values are applied (if they exist) while ($tmpColumns) { array_push($this->_parts[self::COLUMNS], array_shift($tmpColumns)); } } }
[ "protected", "function", "_tableCols", "(", "$", "correlationName", ",", "$", "cols", ",", "$", "afterCorrelationName", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "cols", ")", ")", "{", "$", "cols", "=", "array", "(", "$", "cols", ")", ";", "}", "if", "(", "$", "correlationName", "==", "null", ")", "{", "$", "correlationName", "=", "''", ";", "}", "$", "columnValues", "=", "array", "(", ")", ";", "foreach", "(", "array_filter", "(", "$", "cols", ")", "as", "$", "alias", "=>", "$", "col", ")", "{", "$", "currentCorrelationName", "=", "$", "correlationName", ";", "if", "(", "is_string", "(", "$", "col", ")", ")", "{", "// Check for a column matching \"<column> AS <alias>\" and extract the alias name", "if", "(", "preg_match", "(", "'/^(.+)\\s+'", ".", "self", "::", "SQL_AS", ".", "'\\s+(.+)$/i'", ",", "$", "col", ",", "$", "m", ")", ")", "{", "$", "col", "=", "$", "m", "[", "1", "]", ";", "$", "alias", "=", "$", "m", "[", "2", "]", ";", "}", "// Check for columns that look like functions and convert to Zend_Db_Expr", "if", "(", "preg_match", "(", "'/\\(.*\\)/'", ",", "$", "col", ")", ")", "{", "$", "col", "=", "new", "Zend_Db_Expr", "(", "$", "col", ")", ";", "}", "elseif", "(", "preg_match", "(", "'/(.+)\\.(.+)/'", ",", "$", "col", ",", "$", "m", ")", ")", "{", "$", "currentCorrelationName", "=", "$", "m", "[", "1", "]", ";", "$", "col", "=", "$", "m", "[", "2", "]", ";", "}", "}", "$", "columnValues", "[", "]", "=", "array", "(", "$", "currentCorrelationName", ",", "$", "col", ",", "is_string", "(", "$", "alias", ")", "?", "$", "alias", ":", "null", ")", ";", "}", "if", "(", "$", "columnValues", ")", "{", "// should we attempt to prepend or insert these values?", "if", "(", "$", "afterCorrelationName", "===", "true", "||", "is_string", "(", "$", "afterCorrelationName", ")", ")", "{", "$", "tmpColumns", "=", "$", "this", "->", "_parts", "[", "self", "::", "COLUMNS", "]", ";", "$", "this", "->", "_parts", "[", "self", "::", "COLUMNS", "]", "=", "array", "(", ")", ";", "}", "else", "{", "$", "tmpColumns", "=", "array", "(", ")", ";", "}", "// find the correlation name to insert after", "if", "(", "is_string", "(", "$", "afterCorrelationName", ")", ")", "{", "while", "(", "$", "tmpColumns", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "COLUMNS", "]", "[", "]", "=", "$", "currentColumn", "=", "array_shift", "(", "$", "tmpColumns", ")", ";", "if", "(", "$", "currentColumn", "[", "0", "]", "==", "$", "afterCorrelationName", ")", "{", "break", ";", "}", "}", "}", "// apply current values to current stack", "foreach", "(", "$", "columnValues", "as", "$", "columnValue", ")", "{", "array_push", "(", "$", "this", "->", "_parts", "[", "self", "::", "COLUMNS", "]", ",", "$", "columnValue", ")", ";", "}", "// finish ensuring that all previous values are applied (if they exist)", "while", "(", "$", "tmpColumns", ")", "{", "array_push", "(", "$", "this", "->", "_parts", "[", "self", "::", "COLUMNS", "]", ",", "array_shift", "(", "$", "tmpColumns", ")", ")", ";", "}", "}", "}" ]
Adds to the internal table-to-column mapping array. @param string $tbl The table/join the columns come from. @param array|string $cols The list of columns; preferably as an array, but possibly as a string containing one column. @param bool|string True if it should be prepended, a correlation name if it should be inserted @return void
[ "Adds", "to", "the", "internal", "table", "-", "to", "-", "column", "mapping", "array", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L920-L981
209,752
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._where
protected function _where($condition, $value = null, $type = null, $bool = true) { if (count($this->_parts[self::UNION])) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid use of where clause with " . self::SQL_UNION); } if ($value !== null) { $condition = $this->_adapter->quoteInto($condition, $value, $type); } $cond = ""; if ($this->_parts[self::WHERE]) { if ($bool === true) { $cond = self::SQL_AND . ' '; } else { $cond = self::SQL_OR . ' '; } } return $cond . "($condition)"; }
php
protected function _where($condition, $value = null, $type = null, $bool = true) { if (count($this->_parts[self::UNION])) { // require_once 'Zend/Db/Select/Exception.php'; throw new Zend_Db_Select_Exception("Invalid use of where clause with " . self::SQL_UNION); } if ($value !== null) { $condition = $this->_adapter->quoteInto($condition, $value, $type); } $cond = ""; if ($this->_parts[self::WHERE]) { if ($bool === true) { $cond = self::SQL_AND . ' '; } else { $cond = self::SQL_OR . ' '; } } return $cond . "($condition)"; }
[ "protected", "function", "_where", "(", "$", "condition", ",", "$", "value", "=", "null", ",", "$", "type", "=", "null", ",", "$", "bool", "=", "true", ")", "{", "if", "(", "count", "(", "$", "this", "->", "_parts", "[", "self", "::", "UNION", "]", ")", ")", "{", "// require_once 'Zend/Db/Select/Exception.php';", "throw", "new", "Zend_Db_Select_Exception", "(", "\"Invalid use of where clause with \"", ".", "self", "::", "SQL_UNION", ")", ";", "}", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "condition", "=", "$", "this", "->", "_adapter", "->", "quoteInto", "(", "$", "condition", ",", "$", "value", ",", "$", "type", ")", ";", "}", "$", "cond", "=", "\"\"", ";", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "WHERE", "]", ")", "{", "if", "(", "$", "bool", "===", "true", ")", "{", "$", "cond", "=", "self", "::", "SQL_AND", ".", "' '", ";", "}", "else", "{", "$", "cond", "=", "self", "::", "SQL_OR", ".", "' '", ";", "}", "}", "return", "$", "cond", ".", "\"($condition)\"", ";", "}" ]
Internal function for creating the where clause @param string $condition @param mixed $value optional @param string $type optional @param boolean $bool true = AND, false = OR @return string clause
[ "Internal", "function", "for", "creating", "the", "where", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L992-L1013
209,753
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._getQuotedSchema
protected function _getQuotedSchema($schema = null) { if ($schema === null) { return null; } return $this->_adapter->quoteIdentifier($schema, true) . '.'; }
php
protected function _getQuotedSchema($schema = null) { if ($schema === null) { return null; } return $this->_adapter->quoteIdentifier($schema, true) . '.'; }
[ "protected", "function", "_getQuotedSchema", "(", "$", "schema", "=", "null", ")", "{", "if", "(", "$", "schema", "===", "null", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "_adapter", "->", "quoteIdentifier", "(", "$", "schema", ",", "true", ")", ".", "'.'", ";", "}" ]
Return a quoted schema name @param string $schema The schema name OPTIONAL @return string|null
[ "Return", "a", "quoted", "schema", "name" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1029-L1035
209,754
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._getQuotedTable
protected function _getQuotedTable($tableName, $correlationName = null) { return $this->_adapter->quoteTableAs($tableName, $correlationName, true); }
php
protected function _getQuotedTable($tableName, $correlationName = null) { return $this->_adapter->quoteTableAs($tableName, $correlationName, true); }
[ "protected", "function", "_getQuotedTable", "(", "$", "tableName", ",", "$", "correlationName", "=", "null", ")", "{", "return", "$", "this", "->", "_adapter", "->", "quoteTableAs", "(", "$", "tableName", ",", "$", "correlationName", ",", "true", ")", ";", "}" ]
Return a quoted table name @param string $tableName The table name @param string $correlationName The correlation name OPTIONAL @return string
[ "Return", "a", "quoted", "table", "name" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1044-L1047
209,755
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderFrom
protected function _renderFrom($sql) { /* * If no table specified, use RDBMS-dependent solution * for table-less query. e.g. DUAL in Oracle. */ if (empty($this->_parts[self::FROM])) { $this->_parts[self::FROM] = $this->_getDummyTable(); } $from = array(); foreach ($this->_parts[self::FROM] as $correlationName => $table) { $tmp = ''; $joinType = ($table['joinType'] == self::FROM) ? self::INNER_JOIN : $table['joinType']; // Add join clause (if applicable) if (! empty($from)) { $tmp .= ' ' . strtoupper($joinType) . ' '; } $tmp .= $this->_getQuotedSchema($table['schema']); $tmp .= $this->_getQuotedTable($table['tableName'], $correlationName); // Add join conditions (if applicable) if (!empty($from) && ! empty($table['joinCondition'])) { $tmp .= ' ' . self::SQL_ON . ' ' . $table['joinCondition']; } // Add the table name and condition add to the list $from[] = $tmp; } // Add the list of all joins if (!empty($from)) { $sql .= ' ' . self::SQL_FROM . ' ' . implode("\n", $from); } return $sql; }
php
protected function _renderFrom($sql) { /* * If no table specified, use RDBMS-dependent solution * for table-less query. e.g. DUAL in Oracle. */ if (empty($this->_parts[self::FROM])) { $this->_parts[self::FROM] = $this->_getDummyTable(); } $from = array(); foreach ($this->_parts[self::FROM] as $correlationName => $table) { $tmp = ''; $joinType = ($table['joinType'] == self::FROM) ? self::INNER_JOIN : $table['joinType']; // Add join clause (if applicable) if (! empty($from)) { $tmp .= ' ' . strtoupper($joinType) . ' '; } $tmp .= $this->_getQuotedSchema($table['schema']); $tmp .= $this->_getQuotedTable($table['tableName'], $correlationName); // Add join conditions (if applicable) if (!empty($from) && ! empty($table['joinCondition'])) { $tmp .= ' ' . self::SQL_ON . ' ' . $table['joinCondition']; } // Add the table name and condition add to the list $from[] = $tmp; } // Add the list of all joins if (!empty($from)) { $sql .= ' ' . self::SQL_FROM . ' ' . implode("\n", $from); } return $sql; }
[ "protected", "function", "_renderFrom", "(", "$", "sql", ")", "{", "/*\n * If no table specified, use RDBMS-dependent solution\n * for table-less query. e.g. DUAL in Oracle.\n */", "if", "(", "empty", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", ")", ")", "{", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", "=", "$", "this", "->", "_getDummyTable", "(", ")", ";", "}", "$", "from", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", "as", "$", "correlationName", "=>", "$", "table", ")", "{", "$", "tmp", "=", "''", ";", "$", "joinType", "=", "(", "$", "table", "[", "'joinType'", "]", "==", "self", "::", "FROM", ")", "?", "self", "::", "INNER_JOIN", ":", "$", "table", "[", "'joinType'", "]", ";", "// Add join clause (if applicable)", "if", "(", "!", "empty", "(", "$", "from", ")", ")", "{", "$", "tmp", ".=", "' '", ".", "strtoupper", "(", "$", "joinType", ")", ".", "' '", ";", "}", "$", "tmp", ".=", "$", "this", "->", "_getQuotedSchema", "(", "$", "table", "[", "'schema'", "]", ")", ";", "$", "tmp", ".=", "$", "this", "->", "_getQuotedTable", "(", "$", "table", "[", "'tableName'", "]", ",", "$", "correlationName", ")", ";", "// Add join conditions (if applicable)", "if", "(", "!", "empty", "(", "$", "from", ")", "&&", "!", "empty", "(", "$", "table", "[", "'joinCondition'", "]", ")", ")", "{", "$", "tmp", ".=", "' '", ".", "self", "::", "SQL_ON", ".", "' '", ".", "$", "table", "[", "'joinCondition'", "]", ";", "}", "// Add the table name and condition add to the list", "$", "from", "[", "]", "=", "$", "tmp", ";", "}", "// Add the list of all joins", "if", "(", "!", "empty", "(", "$", "from", ")", ")", "{", "$", "sql", ".=", "' '", ".", "self", "::", "SQL_FROM", ".", "' '", ".", "implode", "(", "\"\\n\"", ",", "$", "from", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Render FROM clause @param string $sql SQL query @return string
[ "Render", "FROM", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1103-L1143
209,756
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderUnion
protected function _renderUnion($sql) { if ($this->_parts[self::UNION]) { $parts = count($this->_parts[self::UNION]); foreach ($this->_parts[self::UNION] as $cnt => $union) { list($target, $type) = $union; if ($target instanceof Zend_Db_Select) { $target = $target->assemble(); } $sql .= $target; if ($cnt < $parts - 1) { $sql .= ' ' . $type . ' '; } } } return $sql; }
php
protected function _renderUnion($sql) { if ($this->_parts[self::UNION]) { $parts = count($this->_parts[self::UNION]); foreach ($this->_parts[self::UNION] as $cnt => $union) { list($target, $type) = $union; if ($target instanceof Zend_Db_Select) { $target = $target->assemble(); } $sql .= $target; if ($cnt < $parts - 1) { $sql .= ' ' . $type . ' '; } } } return $sql; }
[ "protected", "function", "_renderUnion", "(", "$", "sql", ")", "{", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "UNION", "]", ")", "{", "$", "parts", "=", "count", "(", "$", "this", "->", "_parts", "[", "self", "::", "UNION", "]", ")", ";", "foreach", "(", "$", "this", "->", "_parts", "[", "self", "::", "UNION", "]", "as", "$", "cnt", "=>", "$", "union", ")", "{", "list", "(", "$", "target", ",", "$", "type", ")", "=", "$", "union", ";", "if", "(", "$", "target", "instanceof", "Zend_Db_Select", ")", "{", "$", "target", "=", "$", "target", "->", "assemble", "(", ")", ";", "}", "$", "sql", ".=", "$", "target", ";", "if", "(", "$", "cnt", "<", "$", "parts", "-", "1", ")", "{", "$", "sql", ".=", "' '", ".", "$", "type", ".", "' '", ";", "}", "}", "}", "return", "$", "sql", ";", "}" ]
Render UNION query @param string $sql SQL query @return string
[ "Render", "UNION", "query" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1151-L1168
209,757
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderWhere
protected function _renderWhere($sql) { if ($this->_parts[self::FROM] && $this->_parts[self::WHERE]) { $sql .= ' ' . self::SQL_WHERE . ' ' . implode(' ', $this->_parts[self::WHERE]); } return $sql; }
php
protected function _renderWhere($sql) { if ($this->_parts[self::FROM] && $this->_parts[self::WHERE]) { $sql .= ' ' . self::SQL_WHERE . ' ' . implode(' ', $this->_parts[self::WHERE]); } return $sql; }
[ "protected", "function", "_renderWhere", "(", "$", "sql", ")", "{", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", "&&", "$", "this", "->", "_parts", "[", "self", "::", "WHERE", "]", ")", "{", "$", "sql", ".=", "' '", ".", "self", "::", "SQL_WHERE", ".", "' '", ".", "implode", "(", "' '", ",", "$", "this", "->", "_parts", "[", "self", "::", "WHERE", "]", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Render WHERE clause @param string $sql SQL query @return string
[ "Render", "WHERE", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1176-L1183
209,758
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderGroup
protected function _renderGroup($sql) { if ($this->_parts[self::FROM] && $this->_parts[self::GROUP]) { $group = array(); foreach ($this->_parts[self::GROUP] as $term) { $group[] = $this->_adapter->quoteIdentifier($term, true); } $sql .= ' ' . self::SQL_GROUP_BY . ' ' . implode(",\n\t", $group); } return $sql; }
php
protected function _renderGroup($sql) { if ($this->_parts[self::FROM] && $this->_parts[self::GROUP]) { $group = array(); foreach ($this->_parts[self::GROUP] as $term) { $group[] = $this->_adapter->quoteIdentifier($term, true); } $sql .= ' ' . self::SQL_GROUP_BY . ' ' . implode(",\n\t", $group); } return $sql; }
[ "protected", "function", "_renderGroup", "(", "$", "sql", ")", "{", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", "&&", "$", "this", "->", "_parts", "[", "self", "::", "GROUP", "]", ")", "{", "$", "group", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_parts", "[", "self", "::", "GROUP", "]", "as", "$", "term", ")", "{", "$", "group", "[", "]", "=", "$", "this", "->", "_adapter", "->", "quoteIdentifier", "(", "$", "term", ",", "true", ")", ";", "}", "$", "sql", ".=", "' '", ".", "self", "::", "SQL_GROUP_BY", ".", "' '", ".", "implode", "(", "\",\\n\\t\"", ",", "$", "group", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Render GROUP clause @param string $sql SQL query @return string
[ "Render", "GROUP", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1191-L1202
209,759
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderHaving
protected function _renderHaving($sql) { if ($this->_parts[self::FROM] && $this->_parts[self::HAVING]) { $sql .= ' ' . self::SQL_HAVING . ' ' . implode(' ', $this->_parts[self::HAVING]); } return $sql; }
php
protected function _renderHaving($sql) { if ($this->_parts[self::FROM] && $this->_parts[self::HAVING]) { $sql .= ' ' . self::SQL_HAVING . ' ' . implode(' ', $this->_parts[self::HAVING]); } return $sql; }
[ "protected", "function", "_renderHaving", "(", "$", "sql", ")", "{", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "FROM", "]", "&&", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", ")", "{", "$", "sql", ".=", "' '", ".", "self", "::", "SQL_HAVING", ".", "' '", ".", "implode", "(", "' '", ",", "$", "this", "->", "_parts", "[", "self", "::", "HAVING", "]", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Render HAVING clause @param string $sql SQL query @return string
[ "Render", "HAVING", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1210-L1217
209,760
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderOrder
protected function _renderOrder($sql) { if ($this->_parts[self::ORDER]) { $order = array(); foreach ($this->_parts[self::ORDER] as $term) { if (is_array($term)) { if(is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) { $order[] = (int)trim($term[0]) . ' ' . $term[1]; } else { $order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1]; } } else if (is_numeric($term) && strval(intval($term)) == $term) { $order[] = (int)trim($term); } else { $order[] = $this->_adapter->quoteIdentifier($term, true); } } $sql .= ' ' . self::SQL_ORDER_BY . ' ' . implode(', ', $order); } return $sql; }
php
protected function _renderOrder($sql) { if ($this->_parts[self::ORDER]) { $order = array(); foreach ($this->_parts[self::ORDER] as $term) { if (is_array($term)) { if(is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) { $order[] = (int)trim($term[0]) . ' ' . $term[1]; } else { $order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1]; } } else if (is_numeric($term) && strval(intval($term)) == $term) { $order[] = (int)trim($term); } else { $order[] = $this->_adapter->quoteIdentifier($term, true); } } $sql .= ' ' . self::SQL_ORDER_BY . ' ' . implode(', ', $order); } return $sql; }
[ "protected", "function", "_renderOrder", "(", "$", "sql", ")", "{", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "ORDER", "]", ")", "{", "$", "order", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_parts", "[", "self", "::", "ORDER", "]", "as", "$", "term", ")", "{", "if", "(", "is_array", "(", "$", "term", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "term", "[", "0", "]", ")", "&&", "strval", "(", "intval", "(", "$", "term", "[", "0", "]", ")", ")", "==", "$", "term", "[", "0", "]", ")", "{", "$", "order", "[", "]", "=", "(", "int", ")", "trim", "(", "$", "term", "[", "0", "]", ")", ".", "' '", ".", "$", "term", "[", "1", "]", ";", "}", "else", "{", "$", "order", "[", "]", "=", "$", "this", "->", "_adapter", "->", "quoteIdentifier", "(", "$", "term", "[", "0", "]", ",", "true", ")", ".", "' '", ".", "$", "term", "[", "1", "]", ";", "}", "}", "else", "if", "(", "is_numeric", "(", "$", "term", ")", "&&", "strval", "(", "intval", "(", "$", "term", ")", ")", "==", "$", "term", ")", "{", "$", "order", "[", "]", "=", "(", "int", ")", "trim", "(", "$", "term", ")", ";", "}", "else", "{", "$", "order", "[", "]", "=", "$", "this", "->", "_adapter", "->", "quoteIdentifier", "(", "$", "term", ",", "true", ")", ";", "}", "}", "$", "sql", ".=", "' '", ".", "self", "::", "SQL_ORDER_BY", ".", "' '", ".", "implode", "(", "', '", ",", "$", "order", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Render ORDER clause @param string $sql SQL query @return string
[ "Render", "ORDER", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1225-L1246
209,761
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderLimitoffset
protected function _renderLimitoffset($sql) { $count = 0; $offset = 0; if (!empty($this->_parts[self::LIMIT_OFFSET])) { $offset = (int) $this->_parts[self::LIMIT_OFFSET]; $count = PHP_INT_MAX; } if (!empty($this->_parts[self::LIMIT_COUNT])) { $count = (int) $this->_parts[self::LIMIT_COUNT]; } /* * Add limits clause */ if ($count > 0) { $sql = trim($this->_adapter->limit($sql, $count, $offset)); } return $sql; }
php
protected function _renderLimitoffset($sql) { $count = 0; $offset = 0; if (!empty($this->_parts[self::LIMIT_OFFSET])) { $offset = (int) $this->_parts[self::LIMIT_OFFSET]; $count = PHP_INT_MAX; } if (!empty($this->_parts[self::LIMIT_COUNT])) { $count = (int) $this->_parts[self::LIMIT_COUNT]; } /* * Add limits clause */ if ($count > 0) { $sql = trim($this->_adapter->limit($sql, $count, $offset)); } return $sql; }
[ "protected", "function", "_renderLimitoffset", "(", "$", "sql", ")", "{", "$", "count", "=", "0", ";", "$", "offset", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_OFFSET", "]", ")", ")", "{", "$", "offset", "=", "(", "int", ")", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_OFFSET", "]", ";", "$", "count", "=", "PHP_INT_MAX", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_COUNT", "]", ")", ")", "{", "$", "count", "=", "(", "int", ")", "$", "this", "->", "_parts", "[", "self", "::", "LIMIT_COUNT", "]", ";", "}", "/*\n * Add limits clause\n */", "if", "(", "$", "count", ">", "0", ")", "{", "$", "sql", "=", "trim", "(", "$", "this", "->", "_adapter", "->", "limit", "(", "$", "sql", ",", "$", "count", ",", "$", "offset", ")", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Render LIMIT OFFSET clause @param string $sql SQL query @return string
[ "Render", "LIMIT", "OFFSET", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1254-L1276
209,762
matomo-org/matomo
libs/Zend/Db/Select.php
Zend_Db_Select._renderForupdate
protected function _renderForupdate($sql) { if ($this->_parts[self::FOR_UPDATE]) { $sql .= ' ' . self::SQL_FOR_UPDATE; } return $sql; }
php
protected function _renderForupdate($sql) { if ($this->_parts[self::FOR_UPDATE]) { $sql .= ' ' . self::SQL_FOR_UPDATE; } return $sql; }
[ "protected", "function", "_renderForupdate", "(", "$", "sql", ")", "{", "if", "(", "$", "this", "->", "_parts", "[", "self", "::", "FOR_UPDATE", "]", ")", "{", "$", "sql", ".=", "' '", ".", "self", "::", "SQL_FOR_UPDATE", ";", "}", "return", "$", "sql", ";", "}" ]
Render FOR UPDATE clause @param string $sql SQL query @return string
[ "Render", "FOR", "UPDATE", "clause" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1284-L1291
209,763
matomo-org/matomo
core/FileIntegrity.php
FileIntegrity.getFileIntegrityInformation
public static function getFileIntegrityInformation() { $messages = array(); $manifest = PIWIK_INCLUDE_PATH . '/config/manifest.inc.php'; if (file_exists($manifest)) { require_once $manifest; } if (!class_exists('Piwik\\Manifest')) { $messages[] = Piwik::translate('General_WarningFileIntegrityNoManifest') . '<br/>' . Piwik::translate('General_WarningFileIntegrityNoManifestDeployingFromGit'); return array( $success = false, $messages ); } $messages = self::getMessagesDirectoriesFoundButNotExpected($messages); $messages = self::getMessagesFilesFoundButNotExpected($messages); $messages = self::getMessagesFilesMismatch($messages); return array( $success = empty($messages), $messages ); }
php
public static function getFileIntegrityInformation() { $messages = array(); $manifest = PIWIK_INCLUDE_PATH . '/config/manifest.inc.php'; if (file_exists($manifest)) { require_once $manifest; } if (!class_exists('Piwik\\Manifest')) { $messages[] = Piwik::translate('General_WarningFileIntegrityNoManifest') . '<br/>' . Piwik::translate('General_WarningFileIntegrityNoManifestDeployingFromGit'); return array( $success = false, $messages ); } $messages = self::getMessagesDirectoriesFoundButNotExpected($messages); $messages = self::getMessagesFilesFoundButNotExpected($messages); $messages = self::getMessagesFilesMismatch($messages); return array( $success = empty($messages), $messages ); }
[ "public", "static", "function", "getFileIntegrityInformation", "(", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "$", "manifest", "=", "PIWIK_INCLUDE_PATH", ".", "'/config/manifest.inc.php'", ";", "if", "(", "file_exists", "(", "$", "manifest", ")", ")", "{", "require_once", "$", "manifest", ";", "}", "if", "(", "!", "class_exists", "(", "'Piwik\\\\Manifest'", ")", ")", "{", "$", "messages", "[", "]", "=", "Piwik", "::", "translate", "(", "'General_WarningFileIntegrityNoManifest'", ")", ".", "'<br/>'", ".", "Piwik", "::", "translate", "(", "'General_WarningFileIntegrityNoManifestDeployingFromGit'", ")", ";", "return", "array", "(", "$", "success", "=", "false", ",", "$", "messages", ")", ";", "}", "$", "messages", "=", "self", "::", "getMessagesDirectoriesFoundButNotExpected", "(", "$", "messages", ")", ";", "$", "messages", "=", "self", "::", "getMessagesFilesFoundButNotExpected", "(", "$", "messages", ")", ";", "$", "messages", "=", "self", "::", "getMessagesFilesMismatch", "(", "$", "messages", ")", ";", "return", "array", "(", "$", "success", "=", "empty", "(", "$", "messages", ")", ",", "$", "messages", ")", ";", "}" ]
Get file integrity information @return array(bool $success, array $messages)
[ "Get", "file", "integrity", "information" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FileIntegrity.php#L24-L56
209,764
matomo-org/matomo
core/FileIntegrity.php
FileIntegrity.getDirectoriesFoundButNotExpected
protected static function getDirectoriesFoundButNotExpected() { static $cache = null; if(!is_null($cache)) { return $cache; } $pluginsInManifest = self::getPluginsFoundInManifest(); $directoriesInManifest = self::getDirectoriesFoundInManifest(); $directoriesFoundButNotExpected = array(); foreach (self::getPathsToInvestigate() as $file) { $file = substr($file, strlen(PIWIK_DOCUMENT_ROOT)); // remove piwik path to match format in manifest.inc.php $file = ltrim($file, "\\/"); $directory = dirname($file); if(in_array($directory, $directoriesInManifest)) { continue; } if (self::isFileNotInManifestButExpectedAnyway($file)) { continue; } if (self::isFileFromPluginNotInManifest($file, $pluginsInManifest)) { continue; } if (!in_array($directory, $directoriesFoundButNotExpected)) { $directoriesFoundButNotExpected[] = $directory; } } $cache = self::getParentDirectoriesFromListOfDirectories($directoriesFoundButNotExpected); return $cache; }
php
protected static function getDirectoriesFoundButNotExpected() { static $cache = null; if(!is_null($cache)) { return $cache; } $pluginsInManifest = self::getPluginsFoundInManifest(); $directoriesInManifest = self::getDirectoriesFoundInManifest(); $directoriesFoundButNotExpected = array(); foreach (self::getPathsToInvestigate() as $file) { $file = substr($file, strlen(PIWIK_DOCUMENT_ROOT)); // remove piwik path to match format in manifest.inc.php $file = ltrim($file, "\\/"); $directory = dirname($file); if(in_array($directory, $directoriesInManifest)) { continue; } if (self::isFileNotInManifestButExpectedAnyway($file)) { continue; } if (self::isFileFromPluginNotInManifest($file, $pluginsInManifest)) { continue; } if (!in_array($directory, $directoriesFoundButNotExpected)) { $directoriesFoundButNotExpected[] = $directory; } } $cache = self::getParentDirectoriesFromListOfDirectories($directoriesFoundButNotExpected); return $cache; }
[ "protected", "static", "function", "getDirectoriesFoundButNotExpected", "(", ")", "{", "static", "$", "cache", "=", "null", ";", "if", "(", "!", "is_null", "(", "$", "cache", ")", ")", "{", "return", "$", "cache", ";", "}", "$", "pluginsInManifest", "=", "self", "::", "getPluginsFoundInManifest", "(", ")", ";", "$", "directoriesInManifest", "=", "self", "::", "getDirectoriesFoundInManifest", "(", ")", ";", "$", "directoriesFoundButNotExpected", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "getPathsToInvestigate", "(", ")", "as", "$", "file", ")", "{", "$", "file", "=", "substr", "(", "$", "file", ",", "strlen", "(", "PIWIK_DOCUMENT_ROOT", ")", ")", ";", "// remove piwik path to match format in manifest.inc.php", "$", "file", "=", "ltrim", "(", "$", "file", ",", "\"\\\\/\"", ")", ";", "$", "directory", "=", "dirname", "(", "$", "file", ")", ";", "if", "(", "in_array", "(", "$", "directory", ",", "$", "directoriesInManifest", ")", ")", "{", "continue", ";", "}", "if", "(", "self", "::", "isFileNotInManifestButExpectedAnyway", "(", "$", "file", ")", ")", "{", "continue", ";", "}", "if", "(", "self", "::", "isFileFromPluginNotInManifest", "(", "$", "file", ",", "$", "pluginsInManifest", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "in_array", "(", "$", "directory", ",", "$", "directoriesFoundButNotExpected", ")", ")", "{", "$", "directoriesFoundButNotExpected", "[", "]", "=", "$", "directory", ";", "}", "}", "$", "cache", "=", "self", "::", "getParentDirectoriesFromListOfDirectories", "(", "$", "directoriesFoundButNotExpected", ")", ";", "return", "$", "cache", ";", "}" ]
Look for whole directories which are in the filesystem, but should not be @return array
[ "Look", "for", "whole", "directories", "which", "are", "in", "the", "filesystem", "but", "should", "not", "be" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FileIntegrity.php#L161-L195
209,765
matomo-org/matomo
core/FileIntegrity.php
FileIntegrity.getFilesFoundButNotExpected
protected static function getFilesFoundButNotExpected() { $files = \Piwik\Manifest::$files; $pluginsInManifest = self::getPluginsFoundInManifest(); $filesFoundButNotExpected = array(); foreach (self::getPathsToInvestigate() as $file) { if (is_dir($file)) { continue; } $file = substr($file, strlen(PIWIK_DOCUMENT_ROOT)); // remove piwik path to match format in manifest.inc.php $file = ltrim($file, "\\/"); if (self::isFileFromPluginNotInManifest($file, $pluginsInManifest)) { continue; } if (self::isFileNotInManifestButExpectedAnyway($file)) { continue; } if (self::isFileFromDirectoryThatShouldBeDeleted($file)) { // we already report the directory as "Directory to delete" so no need to repeat the instruction for each file continue; } if (!isset($files[$file])) { $filesFoundButNotExpected[] = $file; } } return $filesFoundButNotExpected; }
php
protected static function getFilesFoundButNotExpected() { $files = \Piwik\Manifest::$files; $pluginsInManifest = self::getPluginsFoundInManifest(); $filesFoundButNotExpected = array(); foreach (self::getPathsToInvestigate() as $file) { if (is_dir($file)) { continue; } $file = substr($file, strlen(PIWIK_DOCUMENT_ROOT)); // remove piwik path to match format in manifest.inc.php $file = ltrim($file, "\\/"); if (self::isFileFromPluginNotInManifest($file, $pluginsInManifest)) { continue; } if (self::isFileNotInManifestButExpectedAnyway($file)) { continue; } if (self::isFileFromDirectoryThatShouldBeDeleted($file)) { // we already report the directory as "Directory to delete" so no need to repeat the instruction for each file continue; } if (!isset($files[$file])) { $filesFoundButNotExpected[] = $file; } } return $filesFoundButNotExpected; }
[ "protected", "static", "function", "getFilesFoundButNotExpected", "(", ")", "{", "$", "files", "=", "\\", "Piwik", "\\", "Manifest", "::", "$", "files", ";", "$", "pluginsInManifest", "=", "self", "::", "getPluginsFoundInManifest", "(", ")", ";", "$", "filesFoundButNotExpected", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "getPathsToInvestigate", "(", ")", "as", "$", "file", ")", "{", "if", "(", "is_dir", "(", "$", "file", ")", ")", "{", "continue", ";", "}", "$", "file", "=", "substr", "(", "$", "file", ",", "strlen", "(", "PIWIK_DOCUMENT_ROOT", ")", ")", ";", "// remove piwik path to match format in manifest.inc.php", "$", "file", "=", "ltrim", "(", "$", "file", ",", "\"\\\\/\"", ")", ";", "if", "(", "self", "::", "isFileFromPluginNotInManifest", "(", "$", "file", ",", "$", "pluginsInManifest", ")", ")", "{", "continue", ";", "}", "if", "(", "self", "::", "isFileNotInManifestButExpectedAnyway", "(", "$", "file", ")", ")", "{", "continue", ";", "}", "if", "(", "self", "::", "isFileFromDirectoryThatShouldBeDeleted", "(", "$", "file", ")", ")", "{", "// we already report the directory as \"Directory to delete\" so no need to repeat the instruction for each file", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "files", "[", "$", "file", "]", ")", ")", "{", "$", "filesFoundButNotExpected", "[", "]", "=", "$", "file", ";", "}", "}", "return", "$", "filesFoundButNotExpected", ";", "}" ]
Look for files which are in the filesystem, but should not be @return array
[ "Look", "for", "files", "which", "are", "in", "the", "filesystem", "but", "should", "not", "be" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FileIntegrity.php#L201-L232
209,766
matomo-org/matomo
core/FileIntegrity.php
FileIntegrity.isFileFromPluginNotInManifest
protected static function isFileFromPluginNotInManifest($file, $pluginsInManifest) { if (strpos($file, 'plugins/') !== 0) { return false; } if (substr_count($file, '/') < 2) { // must be a file plugins/abc.xyz and not a plugin directory return false; } $pluginName = self::getPluginNameFromFilepath($file); if(in_array($pluginName, $pluginsInManifest)) { return false; } return true; }
php
protected static function isFileFromPluginNotInManifest($file, $pluginsInManifest) { if (strpos($file, 'plugins/') !== 0) { return false; } if (substr_count($file, '/') < 2) { // must be a file plugins/abc.xyz and not a plugin directory return false; } $pluginName = self::getPluginNameFromFilepath($file); if(in_array($pluginName, $pluginsInManifest)) { return false; } return true; }
[ "protected", "static", "function", "isFileFromPluginNotInManifest", "(", "$", "file", ",", "$", "pluginsInManifest", ")", "{", "if", "(", "strpos", "(", "$", "file", ",", "'plugins/'", ")", "!==", "0", ")", "{", "return", "false", ";", "}", "if", "(", "substr_count", "(", "$", "file", ",", "'/'", ")", "<", "2", ")", "{", "// must be a file plugins/abc.xyz and not a plugin directory", "return", "false", ";", "}", "$", "pluginName", "=", "self", "::", "getPluginNameFromFilepath", "(", "$", "file", ")", ";", "if", "(", "in_array", "(", "$", "pluginName", ",", "$", "pluginsInManifest", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
If a plugin folder is not tracked in the manifest then we don't try to report any files in this folder Could be a third party plugin or any plugin from the Marketplace @param $file @param $pluginsInManifest @return bool
[ "If", "a", "plugin", "folder", "is", "not", "tracked", "in", "the", "manifest", "then", "we", "don", "t", "try", "to", "report", "any", "files", "in", "this", "folder", "Could", "be", "a", "third", "party", "plugin", "or", "any", "plugin", "from", "the", "Marketplace" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FileIntegrity.php#L285-L302
209,767
matomo-org/matomo
plugins/ExampleTracker/Columns/ExampleActionDimension.php
ExampleActionDimension.onNewAction
public function onNewAction(Request $request, Visitor $visitor, Action $action) { if (!($action instanceof ActionPageview)) { // save value only in case it is a page view. return false; } $value = Common::getRequestVar('my_page_keywords', false, 'string', $request->getParams()); if (false === $value) { return $value; } $value = trim($value); return substr($value, 0, 255); }
php
public function onNewAction(Request $request, Visitor $visitor, Action $action) { if (!($action instanceof ActionPageview)) { // save value only in case it is a page view. return false; } $value = Common::getRequestVar('my_page_keywords', false, 'string', $request->getParams()); if (false === $value) { return $value; } $value = trim($value); return substr($value, 0, 255); }
[ "public", "function", "onNewAction", "(", "Request", "$", "request", ",", "Visitor", "$", "visitor", ",", "Action", "$", "action", ")", "{", "if", "(", "!", "(", "$", "action", "instanceof", "ActionPageview", ")", ")", "{", "// save value only in case it is a page view.", "return", "false", ";", "}", "$", "value", "=", "Common", "::", "getRequestVar", "(", "'my_page_keywords'", ",", "false", ",", "'string'", ",", "$", "request", "->", "getParams", "(", ")", ")", ";", "if", "(", "false", "===", "$", "value", ")", "{", "return", "$", "value", ";", "}", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "return", "substr", "(", "$", "value", ",", "0", ",", "255", ")", ";", "}" ]
This event is triggered before a new action is logged to the log_link_visit_action table. It overwrites any looked up action so it makes usually no sense to implement both methods but it sometimes does. You can assign any value to the column or return boolan false in case you do not want to save any value. @param Request $request @param Visitor $visitor @param Action $action @return mixed|false
[ "This", "event", "is", "triggered", "before", "a", "new", "action", "is", "logged", "to", "the", "log_link_visit_action", "table", ".", "It", "overwrites", "any", "looked", "up", "action", "so", "it", "makes", "usually", "no", "sense", "to", "implement", "both", "methods", "but", "it", "sometimes", "does", ".", "You", "can", "assign", "any", "value", "to", "the", "column", "or", "return", "boolan", "false", "in", "case", "you", "do", "not", "want", "to", "save", "any", "value", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleTracker/Columns/ExampleActionDimension.php#L77-L93
209,768
matomo-org/matomo
libs/Zend/Db/Adapter/Pdo/Ibm.php
Zend_Db_Adapter_Pdo_Ibm._checkRequiredOptions
protected function _checkRequiredOptions(array $config) { parent::_checkRequiredOptions($config); if (array_key_exists('host', $this->_config) && !array_key_exists('port', $config)) { /** @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified"); } }
php
protected function _checkRequiredOptions(array $config) { parent::_checkRequiredOptions($config); if (array_key_exists('host', $this->_config) && !array_key_exists('port', $config)) { /** @see Zend_Db_Adapter_Exception */ // require_once 'Zend/Db/Adapter/Exception.php'; throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified"); } }
[ "protected", "function", "_checkRequiredOptions", "(", "array", "$", "config", ")", "{", "parent", "::", "_checkRequiredOptions", "(", "$", "config", ")", ";", "if", "(", "array_key_exists", "(", "'host'", ",", "$", "this", "->", "_config", ")", "&&", "!", "array_key_exists", "(", "'port'", ",", "$", "config", ")", ")", "{", "/** @see Zend_Db_Adapter_Exception */", "// require_once 'Zend/Db/Adapter/Exception.php';", "throw", "new", "Zend_Db_Adapter_Exception", "(", "\"Configuration must have a key for 'port' when 'host' is specified\"", ")", ";", "}", "}" ]
Checks required options @param array $config @throws Zend_Db_Adapter_Exception @return void
[ "Checks", "required", "options" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm.php#L174-L184
209,769
matomo-org/matomo
libs/Zend/Db/Adapter/Pdo/Ibm.php
Zend_Db_Adapter_Pdo_Ibm.insert
public function insert($table, array $bind) { $this->_connect(); $newbind = array(); if (is_array($bind)) { foreach ($bind as $name => $value) { if($value !== null) { $newbind[$name] = $value; } } } return parent::insert($table, $newbind); }
php
public function insert($table, array $bind) { $this->_connect(); $newbind = array(); if (is_array($bind)) { foreach ($bind as $name => $value) { if($value !== null) { $newbind[$name] = $value; } } } return parent::insert($table, $newbind); }
[ "public", "function", "insert", "(", "$", "table", ",", "array", "$", "bind", ")", "{", "$", "this", "->", "_connect", "(", ")", ";", "$", "newbind", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "bind", ")", ")", "{", "foreach", "(", "$", "bind", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "newbind", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "}", "return", "parent", "::", "insert", "(", "$", "table", ",", "$", "newbind", ")", ";", "}" ]
Inserts a table row with specified data. Special handling for PDO_IBM remove empty slots @param mixed $table The table to insert data into. @param array $bind Column-value pairs. @return int The number of affected rows.
[ "Inserts", "a", "table", "row", "with", "specified", "data", ".", "Special", "handling", "for", "PDO_IBM", "remove", "empty", "slots" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm.php#L257-L270
209,770
matomo-org/matomo
plugins/UsersManager/Model.php
Model.getUsersHavingSuperUserAccess
public function getUsersHavingSuperUserAccess() { $db = $this->getDb(); $users = $db->fetchAll("SELECT login, email, token_auth, superuser_access FROM " . Common::prefixTable("user") . " WHERE superuser_access = 1 ORDER BY date_registered ASC"); return $users; }
php
public function getUsersHavingSuperUserAccess() { $db = $this->getDb(); $users = $db->fetchAll("SELECT login, email, token_auth, superuser_access FROM " . Common::prefixTable("user") . " WHERE superuser_access = 1 ORDER BY date_registered ASC"); return $users; }
[ "public", "function", "getUsersHavingSuperUserAccess", "(", ")", "{", "$", "db", "=", "$", "this", "->", "getDb", "(", ")", ";", "$", "users", "=", "$", "db", "->", "fetchAll", "(", "\"SELECT login, email, token_auth, superuser_access\n FROM \"", ".", "Common", "::", "prefixTable", "(", "\"user\"", ")", ".", "\"\n WHERE superuser_access = 1\n ORDER BY date_registered ASC\"", ")", ";", "return", "$", "users", ";", "}" ]
Note that this returns the token_auth which is as private as the password! @return array[] containing login, email and token_auth
[ "Note", "that", "this", "returns", "the", "token_auth", "which", "is", "as", "private", "as", "the", "password!" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/Model.php#L307-L316
209,771
matomo-org/matomo
core/Concurrency/DistributedList.php
DistributedList.getAll
public function getAll() { $result = $this->getListOptionValue(); foreach ($result as $key => $item) { // remove non-array items (unexpected state, though can happen when upgrading from an old Piwik) if (is_array($item)) { $this->logger->info("Found array item in DistributedList option value '{name}': {data}", array( 'name' => $this->optionName, 'data' => var_export($result, true) )); unset($result[$key]); } } return $result; }
php
public function getAll() { $result = $this->getListOptionValue(); foreach ($result as $key => $item) { // remove non-array items (unexpected state, though can happen when upgrading from an old Piwik) if (is_array($item)) { $this->logger->info("Found array item in DistributedList option value '{name}': {data}", array( 'name' => $this->optionName, 'data' => var_export($result, true) )); unset($result[$key]); } } return $result; }
[ "public", "function", "getAll", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getListOptionValue", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "item", ")", "{", "// remove non-array items (unexpected state, though can happen when upgrading from an old Piwik)", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "\"Found array item in DistributedList option value '{name}': {data}\"", ",", "array", "(", "'name'", "=>", "$", "this", "->", "optionName", ",", "'data'", "=>", "var_export", "(", "$", "result", ",", "true", ")", ")", ")", ";", "unset", "(", "$", "result", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Queries the option table and returns all items in this list. @return array
[ "Queries", "the", "option", "table", "and", "returns", "all", "items", "in", "this", "list", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Concurrency/DistributedList.php#L53-L70
209,772
matomo-org/matomo
core/Concurrency/DistributedList.php
DistributedList.setAll
public function setAll($items) { foreach ($items as $key => &$item) { if (is_array($item)) { throw new \InvalidArgumentException("Array item encountered in DistributedList::setAll() [ key = $key ]."); } else { $item = (string)$item; } } Option::set($this->optionName, serialize($items)); }
php
public function setAll($items) { foreach ($items as $key => &$item) { if (is_array($item)) { throw new \InvalidArgumentException("Array item encountered in DistributedList::setAll() [ key = $key ]."); } else { $item = (string)$item; } } Option::set($this->optionName, serialize($items)); }
[ "public", "function", "setAll", "(", "$", "items", ")", "{", "foreach", "(", "$", "items", "as", "$", "key", "=>", "&", "$", "item", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Array item encountered in DistributedList::setAll() [ key = $key ].\"", ")", ";", "}", "else", "{", "$", "item", "=", "(", "string", ")", "$", "item", ";", "}", "}", "Option", "::", "set", "(", "$", "this", "->", "optionName", ",", "serialize", "(", "$", "items", ")", ")", ";", "}" ]
Sets the contents of the list in the option table. @param string[] $items
[ "Sets", "the", "contents", "of", "the", "list", "in", "the", "option", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Concurrency/DistributedList.php#L77-L88
209,773
matomo-org/matomo
core/Concurrency/DistributedList.php
DistributedList.add
public function add($item) { $allItems = $this->getAll(); if (is_array($item)) { $allItems = array_merge($allItems, $item); } else { $allItems[] = $item; } $this->setAll($allItems); }
php
public function add($item) { $allItems = $this->getAll(); if (is_array($item)) { $allItems = array_merge($allItems, $item); } else { $allItems[] = $item; } $this->setAll($allItems); }
[ "public", "function", "add", "(", "$", "item", ")", "{", "$", "allItems", "=", "$", "this", "->", "getAll", "(", ")", ";", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "allItems", "=", "array_merge", "(", "$", "allItems", ",", "$", "item", ")", ";", "}", "else", "{", "$", "allItems", "[", "]", "=", "$", "item", ";", "}", "$", "this", "->", "setAll", "(", "$", "allItems", ")", ";", "}" ]
Adds one or more items to the list in the option table. @param string|array $item
[ "Adds", "one", "or", "more", "items", "to", "the", "list", "in", "the", "option", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Concurrency/DistributedList.php#L95-L105
209,774
matomo-org/matomo
core/Concurrency/DistributedList.php
DistributedList.remove
public function remove($items) { if (!is_array($items)) { $items = array($items); } $allItems = $this->getAll(); foreach ($items as $item) { $existingIndex = array_search($item, $allItems); if ($existingIndex === false) { return; } unset($allItems[$existingIndex]); } $this->setAll(array_values($allItems)); }
php
public function remove($items) { if (!is_array($items)) { $items = array($items); } $allItems = $this->getAll(); foreach ($items as $item) { $existingIndex = array_search($item, $allItems); if ($existingIndex === false) { return; } unset($allItems[$existingIndex]); } $this->setAll(array_values($allItems)); }
[ "public", "function", "remove", "(", "$", "items", ")", "{", "if", "(", "!", "is_array", "(", "$", "items", ")", ")", "{", "$", "items", "=", "array", "(", "$", "items", ")", ";", "}", "$", "allItems", "=", "$", "this", "->", "getAll", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "existingIndex", "=", "array_search", "(", "$", "item", ",", "$", "allItems", ")", ";", "if", "(", "$", "existingIndex", "===", "false", ")", "{", "return", ";", "}", "unset", "(", "$", "allItems", "[", "$", "existingIndex", "]", ")", ";", "}", "$", "this", "->", "setAll", "(", "array_values", "(", "$", "allItems", ")", ")", ";", "}" ]
Removes one or more items by value from the list in the option table. Does not preserve array keys. @param string|array $items
[ "Removes", "one", "or", "more", "items", "by", "value", "from", "the", "list", "in", "the", "option", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Concurrency/DistributedList.php#L114-L132
209,775
matomo-org/matomo
core/Concurrency/DistributedList.php
DistributedList.removeByIndex
public function removeByIndex($indices) { if (!is_array($indices)) { $indices = array($indices); } $indices = array_unique($indices); $allItems = $this->getAll(); foreach ($indices as $index) { unset($allItems[$index]); } $this->setAll(array_values($allItems)); }
php
public function removeByIndex($indices) { if (!is_array($indices)) { $indices = array($indices); } $indices = array_unique($indices); $allItems = $this->getAll(); foreach ($indices as $index) { unset($allItems[$index]); } $this->setAll(array_values($allItems)); }
[ "public", "function", "removeByIndex", "(", "$", "indices", ")", "{", "if", "(", "!", "is_array", "(", "$", "indices", ")", ")", "{", "$", "indices", "=", "array", "(", "$", "indices", ")", ";", "}", "$", "indices", "=", "array_unique", "(", "$", "indices", ")", ";", "$", "allItems", "=", "$", "this", "->", "getAll", "(", ")", ";", "foreach", "(", "$", "indices", "as", "$", "index", ")", "{", "unset", "(", "$", "allItems", "[", "$", "index", "]", ")", ";", "}", "$", "this", "->", "setAll", "(", "array_values", "(", "$", "allItems", ")", ")", ";", "}" ]
Removes one or more items by index from the list in the option table. Does not preserve array keys. @param int[]|int $indices
[ "Removes", "one", "or", "more", "items", "by", "index", "from", "the", "list", "in", "the", "option", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Concurrency/DistributedList.php#L141-L155
209,776
matomo-org/matomo
core/CronArchive/FixedSiteIds.php
FixedSiteIds.getNumProcessedWebsites
public function getNumProcessedWebsites() { $numProcessed = $this->index + 1; if ($numProcessed > $this->getNumSites()) { return $this->getNumSites(); } return $numProcessed; }
php
public function getNumProcessedWebsites() { $numProcessed = $this->index + 1; if ($numProcessed > $this->getNumSites()) { return $this->getNumSites(); } return $numProcessed; }
[ "public", "function", "getNumProcessedWebsites", "(", ")", "{", "$", "numProcessed", "=", "$", "this", "->", "index", "+", "1", ";", "if", "(", "$", "numProcessed", ">", "$", "this", "->", "getNumSites", "(", ")", ")", "{", "return", "$", "this", "->", "getNumSites", "(", ")", ";", "}", "return", "$", "numProcessed", ";", "}" ]
Get the number of already processed websites. All websites were processed by the current archiver. @return int
[ "Get", "the", "number", "of", "already", "processed", "websites", ".", "All", "websites", "were", "processed", "by", "the", "current", "archiver", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive/FixedSiteIds.php#L44-L53
209,777
matomo-org/matomo
libs/Zend/Config/Writer/Yaml.php
Zend_Config_Writer_Yaml.render
public function render() { $data = $this->_config->toArray(); $sectionName = $this->_config->getSectionName(); $extends = $this->_config->getExtends(); if (is_string($sectionName)) { $data = array($sectionName => $data); } foreach ($extends as $section => $parentSection) { $data[$section][Zend_Config_Yaml::EXTENDS_NAME] = $parentSection; } // Ensure that each "extends" section actually exists foreach ($data as $section => $sectionData) { if (is_array($sectionData) && isset($sectionData[Zend_Config_Yaml::EXTENDS_NAME])) { $sectionExtends = $sectionData[Zend_Config_Yaml::EXTENDS_NAME]; if (!isset($data[$sectionExtends])) { // Remove "extends" declaration if section does not exist unset($data[$section][Zend_Config_Yaml::EXTENDS_NAME]); } } } return call_user_func($this->getYamlEncoder(), $data); }
php
public function render() { $data = $this->_config->toArray(); $sectionName = $this->_config->getSectionName(); $extends = $this->_config->getExtends(); if (is_string($sectionName)) { $data = array($sectionName => $data); } foreach ($extends as $section => $parentSection) { $data[$section][Zend_Config_Yaml::EXTENDS_NAME] = $parentSection; } // Ensure that each "extends" section actually exists foreach ($data as $section => $sectionData) { if (is_array($sectionData) && isset($sectionData[Zend_Config_Yaml::EXTENDS_NAME])) { $sectionExtends = $sectionData[Zend_Config_Yaml::EXTENDS_NAME]; if (!isset($data[$sectionExtends])) { // Remove "extends" declaration if section does not exist unset($data[$section][Zend_Config_Yaml::EXTENDS_NAME]); } } } return call_user_func($this->getYamlEncoder(), $data); }
[ "public", "function", "render", "(", ")", "{", "$", "data", "=", "$", "this", "->", "_config", "->", "toArray", "(", ")", ";", "$", "sectionName", "=", "$", "this", "->", "_config", "->", "getSectionName", "(", ")", ";", "$", "extends", "=", "$", "this", "->", "_config", "->", "getExtends", "(", ")", ";", "if", "(", "is_string", "(", "$", "sectionName", ")", ")", "{", "$", "data", "=", "array", "(", "$", "sectionName", "=>", "$", "data", ")", ";", "}", "foreach", "(", "$", "extends", "as", "$", "section", "=>", "$", "parentSection", ")", "{", "$", "data", "[", "$", "section", "]", "[", "Zend_Config_Yaml", "::", "EXTENDS_NAME", "]", "=", "$", "parentSection", ";", "}", "// Ensure that each \"extends\" section actually exists", "foreach", "(", "$", "data", "as", "$", "section", "=>", "$", "sectionData", ")", "{", "if", "(", "is_array", "(", "$", "sectionData", ")", "&&", "isset", "(", "$", "sectionData", "[", "Zend_Config_Yaml", "::", "EXTENDS_NAME", "]", ")", ")", "{", "$", "sectionExtends", "=", "$", "sectionData", "[", "Zend_Config_Yaml", "::", "EXTENDS_NAME", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "sectionExtends", "]", ")", ")", "{", "// Remove \"extends\" declaration if section does not exist", "unset", "(", "$", "data", "[", "$", "section", "]", "[", "Zend_Config_Yaml", "::", "EXTENDS_NAME", "]", ")", ";", "}", "}", "}", "return", "call_user_func", "(", "$", "this", "->", "getYamlEncoder", "(", ")", ",", "$", "data", ")", ";", "}" ]
Render a Zend_Config into a YAML config string. @since 1.10 @return string
[ "Render", "a", "Zend_Config", "into", "a", "YAML", "config", "string", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer/Yaml.php#L80-L106
209,778
matomo-org/matomo
libs/Zend/Config/Writer/Yaml.php
Zend_Config_Writer_Yaml._encodeYaml
protected static function _encodeYaml($indent, $data) { reset($data); $result = ""; $numeric = is_numeric(key($data)); foreach($data as $key => $value) { if(is_array($value)) { $encoded = "\n".self::_encodeYaml($indent+1, $value); } else { $encoded = (string)$value."\n"; } $result .= str_repeat(" ", $indent).($numeric?"- ":"$key: ").$encoded; } return $result; }
php
protected static function _encodeYaml($indent, $data) { reset($data); $result = ""; $numeric = is_numeric(key($data)); foreach($data as $key => $value) { if(is_array($value)) { $encoded = "\n".self::_encodeYaml($indent+1, $value); } else { $encoded = (string)$value."\n"; } $result .= str_repeat(" ", $indent).($numeric?"- ":"$key: ").$encoded; } return $result; }
[ "protected", "static", "function", "_encodeYaml", "(", "$", "indent", ",", "$", "data", ")", "{", "reset", "(", "$", "data", ")", ";", "$", "result", "=", "\"\"", ";", "$", "numeric", "=", "is_numeric", "(", "key", "(", "$", "data", ")", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "encoded", "=", "\"\\n\"", ".", "self", "::", "_encodeYaml", "(", "$", "indent", "+", "1", ",", "$", "value", ")", ";", "}", "else", "{", "$", "encoded", "=", "(", "string", ")", "$", "value", ".", "\"\\n\"", ";", "}", "$", "result", ".=", "str_repeat", "(", "\" \"", ",", "$", "indent", ")", ".", "(", "$", "numeric", "?", "\"- \"", ":", "\"$key: \"", ")", ".", "$", "encoded", ";", "}", "return", "$", "result", ";", "}" ]
Service function for encoding YAML @param int $indent Current indent level @param array $data Data to encode @return string
[ "Service", "function", "for", "encoding", "YAML" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer/Yaml.php#L128-L143
209,779
matomo-org/matomo
libs/HTML/QuickForm2/Renderer/Array.php
HTML_QuickForm2_Renderer_Array.setStyleForId
public function setStyleForId($idOrStyles, $style = null) { if (is_array($idOrStyles)) { $this->styles = array_merge($this->styles, $idOrStyles); } else { $this->styles[$idOrStyles] = $style; } return $this; }
php
public function setStyleForId($idOrStyles, $style = null) { if (is_array($idOrStyles)) { $this->styles = array_merge($this->styles, $idOrStyles); } else { $this->styles[$idOrStyles] = $style; } return $this; }
[ "public", "function", "setStyleForId", "(", "$", "idOrStyles", ",", "$", "style", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "idOrStyles", ")", ")", "{", "$", "this", "->", "styles", "=", "array_merge", "(", "$", "this", "->", "styles", ",", "$", "idOrStyles", ")", ";", "}", "else", "{", "$", "this", "->", "styles", "[", "$", "idOrStyles", "]", "=", "$", "style", ";", "}", "return", "$", "this", ";", "}" ]
Sets a style for element rendering "Style" is some information that is opaque to Array Renderer but may be of use to e.g. template engine that receives the resultant array. @param string|array Element id or array ('element id' => 'style') @param sting Element style if $idOrStyles is not an array @return HTML_QuickForm2_Renderer_Array
[ "Sets", "a", "style", "for", "element", "rendering" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Array.php#L290-L298
209,780
matomo-org/matomo
core/Widget/WidgetsList.php
WidgetsList.addWidgetConfig
public function addWidgetConfig(WidgetConfig $widget) { if ($widget instanceof WidgetContainerConfig) { $this->addContainer($widget); } elseif (Development::isEnabled()) { $this->checkIsValidWidget($widget); } $this->widgets[] = $widget; }
php
public function addWidgetConfig(WidgetConfig $widget) { if ($widget instanceof WidgetContainerConfig) { $this->addContainer($widget); } elseif (Development::isEnabled()) { $this->checkIsValidWidget($widget); } $this->widgets[] = $widget; }
[ "public", "function", "addWidgetConfig", "(", "WidgetConfig", "$", "widget", ")", "{", "if", "(", "$", "widget", "instanceof", "WidgetContainerConfig", ")", "{", "$", "this", "->", "addContainer", "(", "$", "widget", ")", ";", "}", "elseif", "(", "Development", "::", "isEnabled", "(", ")", ")", "{", "$", "this", "->", "checkIsValidWidget", "(", "$", "widget", ")", ";", "}", "$", "this", "->", "widgets", "[", "]", "=", "$", "widget", ";", "}" ]
Adds a new widget to the widget config. Please make sure the widget is enabled before adding a widget as no such checks will be performed. @param WidgetConfig $widget
[ "Adds", "a", "new", "widget", "to", "the", "widget", "config", ".", "Please", "make", "sure", "the", "widget", "is", "enabled", "before", "adding", "a", "widget", "as", "no", "such", "checks", "will", "be", "performed", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Widget/WidgetsList.php#L51-L60
209,781
matomo-org/matomo
core/Widget/WidgetsList.php
WidgetsList.addToContainerWidget
public function addToContainerWidget($containerId, WidgetConfig $widget) { if (isset($this->container[$containerId])) { $this->container[$containerId]->addWidgetConfig($widget); } else { if (!isset($this->containerWidgets[$containerId])) { $this->containerWidgets[$containerId] = array(); } $this->containerWidgets[$containerId][] = $widget; } }
php
public function addToContainerWidget($containerId, WidgetConfig $widget) { if (isset($this->container[$containerId])) { $this->container[$containerId]->addWidgetConfig($widget); } else { if (!isset($this->containerWidgets[$containerId])) { $this->containerWidgets[$containerId] = array(); } $this->containerWidgets[$containerId][] = $widget; } }
[ "public", "function", "addToContainerWidget", "(", "$", "containerId", ",", "WidgetConfig", "$", "widget", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "container", "[", "$", "containerId", "]", ")", ")", "{", "$", "this", "->", "container", "[", "$", "containerId", "]", "->", "addWidgetConfig", "(", "$", "widget", ")", ";", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "containerWidgets", "[", "$", "containerId", "]", ")", ")", "{", "$", "this", "->", "containerWidgets", "[", "$", "containerId", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "containerWidgets", "[", "$", "containerId", "]", "[", "]", "=", "$", "widget", ";", "}", "}" ]
Add a widget to a widget container. It doesn't matter whether the container was added to this list already or whether the container is added later. As long as a container having the same containerId is added at some point the widget will be added to that container. If no container having this id is added the widget will not be recognized. @param string $containerId eg 'Products' or 'Contents'. See {@link WidgetContainerConfig::setId} @param WidgetConfig $widget
[ "Add", "a", "widget", "to", "a", "widget", "container", ".", "It", "doesn", "t", "matter", "whether", "the", "container", "was", "added", "to", "this", "list", "already", "or", "whether", "the", "container", "is", "added", "later", ".", "As", "long", "as", "a", "container", "having", "the", "same", "containerId", "is", "added", "at", "some", "point", "the", "widget", "will", "be", "added", "to", "that", "container", ".", "If", "no", "container", "having", "this", "id", "is", "added", "the", "widget", "will", "not", "be", "recognized", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Widget/WidgetsList.php#L119-L130
209,782
matomo-org/matomo
core/Widget/WidgetsList.php
WidgetsList.remove
public function remove($widgetCategoryId, $widgetName = false) { foreach ($this->widgets as $index => $widget) { if ($widget->getCategoryId() === $widgetCategoryId) { if (!$widgetName || $widget->getName() === $widgetName) { unset($this->widgets[$index]); } } } }
php
public function remove($widgetCategoryId, $widgetName = false) { foreach ($this->widgets as $index => $widget) { if ($widget->getCategoryId() === $widgetCategoryId) { if (!$widgetName || $widget->getName() === $widgetName) { unset($this->widgets[$index]); } } } }
[ "public", "function", "remove", "(", "$", "widgetCategoryId", ",", "$", "widgetName", "=", "false", ")", "{", "foreach", "(", "$", "this", "->", "widgets", "as", "$", "index", "=>", "$", "widget", ")", "{", "if", "(", "$", "widget", "->", "getCategoryId", "(", ")", "===", "$", "widgetCategoryId", ")", "{", "if", "(", "!", "$", "widgetName", "||", "$", "widget", "->", "getName", "(", ")", "===", "$", "widgetName", ")", "{", "unset", "(", "$", "this", "->", "widgets", "[", "$", "index", "]", ")", ";", "}", "}", "}", "}" ]
Removes one or more widgets from the widget list. @param string $widgetCategoryId The widget category id. Can be a translation token eg 'General_Visits' see {@link WidgetConfig::setCategoryId()}. @param string|false $widgetName The name of the widget to remove eg 'VisitTime_ByServerTimeWidgetName'. If not supplied, all widgets within that category will be removed.
[ "Removes", "one", "or", "more", "widgets", "from", "the", "widget", "list", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Widget/WidgetsList.php#L140-L149
209,783
matomo-org/matomo
core/Widget/WidgetsList.php
WidgetsList.isDefined
public function isDefined($module, $action) { foreach ($this->widgets as $widget) { if ($widget->getModule() === $module && $widget->getAction() === $action) { return true; } } return false; }
php
public function isDefined($module, $action) { foreach ($this->widgets as $widget) { if ($widget->getModule() === $module && $widget->getAction() === $action) { return true; } } return false; }
[ "public", "function", "isDefined", "(", "$", "module", ",", "$", "action", ")", "{", "foreach", "(", "$", "this", "->", "widgets", "as", "$", "widget", ")", "{", "if", "(", "$", "widget", "->", "getModule", "(", ")", "===", "$", "module", "&&", "$", "widget", "->", "getAction", "(", ")", "===", "$", "action", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns `true` if a widget exists in the widget list, `false` if otherwise. @param string $module The controller name of the widget. @param string $action The controller action of the widget. @return bool
[ "Returns", "true", "if", "a", "widget", "exists", "in", "the", "widget", "list", "false", "if", "otherwise", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Widget/WidgetsList.php#L158-L167
209,784
matomo-org/matomo
core/Widget/WidgetsList.php
WidgetsList.get
public static function get() { $list = new static; $widgets = StaticContainer::get('Piwik\Plugin\WidgetsProvider'); $widgetContainerConfigs = $widgets->getWidgetContainerConfigs(); foreach ($widgetContainerConfigs as $config) { if ($config->isEnabled()) { $list->addWidgetConfig($config); } } $widgetConfigs = $widgets->getWidgetConfigs(); foreach ($widgetConfigs as $widget) { if ($widget->isEnabled()) { $list->addWidgetConfig($widget); } } $reports = StaticContainer::get('Piwik\Plugin\ReportsProvider'); $reports = $reports->getAllReports(); foreach ($reports as $report) { if ($report->isEnabled()) { $factory = new ReportWidgetFactory($report); $report->configureWidgets($list, $factory); } } /** * Triggered to filter widgets. * * **Example** * * public function removeWidgetConfigs(Piwik\Widget\WidgetsList $list) * { * $list->remove($category='General_Visits'); // remove all widgets having this category * } * * @param WidgetsList $list An instance of the WidgetsList. You can change the list of widgets this way. */ Piwik::postEvent('Widget.filterWidgets', array($list)); return $list; }
php
public static function get() { $list = new static; $widgets = StaticContainer::get('Piwik\Plugin\WidgetsProvider'); $widgetContainerConfigs = $widgets->getWidgetContainerConfigs(); foreach ($widgetContainerConfigs as $config) { if ($config->isEnabled()) { $list->addWidgetConfig($config); } } $widgetConfigs = $widgets->getWidgetConfigs(); foreach ($widgetConfigs as $widget) { if ($widget->isEnabled()) { $list->addWidgetConfig($widget); } } $reports = StaticContainer::get('Piwik\Plugin\ReportsProvider'); $reports = $reports->getAllReports(); foreach ($reports as $report) { if ($report->isEnabled()) { $factory = new ReportWidgetFactory($report); $report->configureWidgets($list, $factory); } } /** * Triggered to filter widgets. * * **Example** * * public function removeWidgetConfigs(Piwik\Widget\WidgetsList $list) * { * $list->remove($category='General_Visits'); // remove all widgets having this category * } * * @param WidgetsList $list An instance of the WidgetsList. You can change the list of widgets this way. */ Piwik::postEvent('Widget.filterWidgets', array($list)); return $list; }
[ "public", "static", "function", "get", "(", ")", "{", "$", "list", "=", "new", "static", ";", "$", "widgets", "=", "StaticContainer", "::", "get", "(", "'Piwik\\Plugin\\WidgetsProvider'", ")", ";", "$", "widgetContainerConfigs", "=", "$", "widgets", "->", "getWidgetContainerConfigs", "(", ")", ";", "foreach", "(", "$", "widgetContainerConfigs", "as", "$", "config", ")", "{", "if", "(", "$", "config", "->", "isEnabled", "(", ")", ")", "{", "$", "list", "->", "addWidgetConfig", "(", "$", "config", ")", ";", "}", "}", "$", "widgetConfigs", "=", "$", "widgets", "->", "getWidgetConfigs", "(", ")", ";", "foreach", "(", "$", "widgetConfigs", "as", "$", "widget", ")", "{", "if", "(", "$", "widget", "->", "isEnabled", "(", ")", ")", "{", "$", "list", "->", "addWidgetConfig", "(", "$", "widget", ")", ";", "}", "}", "$", "reports", "=", "StaticContainer", "::", "get", "(", "'Piwik\\Plugin\\ReportsProvider'", ")", ";", "$", "reports", "=", "$", "reports", "->", "getAllReports", "(", ")", ";", "foreach", "(", "$", "reports", "as", "$", "report", ")", "{", "if", "(", "$", "report", "->", "isEnabled", "(", ")", ")", "{", "$", "factory", "=", "new", "ReportWidgetFactory", "(", "$", "report", ")", ";", "$", "report", "->", "configureWidgets", "(", "$", "list", ",", "$", "factory", ")", ";", "}", "}", "/**\n * Triggered to filter widgets.\n *\n * **Example**\n *\n * public function removeWidgetConfigs(Piwik\\Widget\\WidgetsList $list)\n * {\n * $list->remove($category='General_Visits'); // remove all widgets having this category\n * }\n *\n * @param WidgetsList $list An instance of the WidgetsList. You can change the list of widgets this way.\n */", "Piwik", "::", "postEvent", "(", "'Widget.filterWidgets'", ",", "array", "(", "$", "list", ")", ")", ";", "return", "$", "list", ";", "}" ]
Get all widgets defined in the Piwik platform. @ignore @return static
[ "Get", "all", "widgets", "defined", "in", "the", "Piwik", "platform", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Widget/WidgetsList.php#L174-L218
209,785
matomo-org/matomo
core/Widget/WidgetsList.php
WidgetsList.getWidgetUniqueId
public static function getWidgetUniqueId($controllerName, $controllerAction, $customParameters = array()) { $widgetUniqueId = 'widget' . $controllerName . $controllerAction; foreach ($customParameters as $name => $value) { if (is_array($value)) { // use 'Array' for backward compatibility; // could we switch to using $value[0]? $value = 'Array'; } $value = urlencode($value); $value = str_replace('%', '', $value); $widgetUniqueId .= $name . $value; } return $widgetUniqueId; }
php
public static function getWidgetUniqueId($controllerName, $controllerAction, $customParameters = array()) { $widgetUniqueId = 'widget' . $controllerName . $controllerAction; foreach ($customParameters as $name => $value) { if (is_array($value)) { // use 'Array' for backward compatibility; // could we switch to using $value[0]? $value = 'Array'; } $value = urlencode($value); $value = str_replace('%', '', $value); $widgetUniqueId .= $name . $value; } return $widgetUniqueId; }
[ "public", "static", "function", "getWidgetUniqueId", "(", "$", "controllerName", ",", "$", "controllerAction", ",", "$", "customParameters", "=", "array", "(", ")", ")", "{", "$", "widgetUniqueId", "=", "'widget'", ".", "$", "controllerName", ".", "$", "controllerAction", ";", "foreach", "(", "$", "customParameters", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "// use 'Array' for backward compatibility;", "// could we switch to using $value[0]?", "$", "value", "=", "'Array'", ";", "}", "$", "value", "=", "urlencode", "(", "$", "value", ")", ";", "$", "value", "=", "str_replace", "(", "'%'", ",", "''", ",", "$", "value", ")", ";", "$", "widgetUniqueId", ".=", "$", "name", ".", "$", "value", ";", "}", "return", "$", "widgetUniqueId", ";", "}" ]
CAUTION! If you ever change this method, existing updates will fail as they currently use that method! If you change the output the uniqueId for existing widgets would not be found anymore Returns the unique id of an widget with the given parameters @param $controllerName @param $controllerAction @param array $customParameters @return string
[ "CAUTION!", "If", "you", "ever", "change", "this", "method", "existing", "updates", "will", "fail", "as", "they", "currently", "use", "that", "method!", "If", "you", "change", "the", "output", "the", "uniqueId", "for", "existing", "widgets", "would", "not", "be", "found", "anymore" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Widget/WidgetsList.php#L231-L247
209,786
matomo-org/matomo
plugins/DBStats/Controller.php
Controller.index
public function index() { Piwik::checkUserHasSuperUserAccess(); $view = new View('@DBStats/index'); $this->setBasicVariablesView($view); $_GET['showtitle'] = '1'; $view->databaseUsageSummary = $this->renderReport('getDatabaseUsageSummary'); $view->trackerDataSummary = $this->renderReport('getTrackerDataSummary'); $view->metricDataSummary = $this->renderReport('getMetricDataSummary'); $view->reportDataSummary = $this->renderReport('getReportDataSummary'); $view->adminDataSummary = $this->renderReport('getAdminDataSummary'); list($siteCount, $userCount, $totalSpaceUsed) = API::getInstance()->getGeneralInformation(); $formatter = new Formatter(); $view->siteCount = $formatter->getPrettyNumber($siteCount); $view->userCount = $formatter->getPrettyNumber($userCount); $view->totalSpaceUsed = $formatter->getPrettySizeFromBytes($totalSpaceUsed); return $view->render(); }
php
public function index() { Piwik::checkUserHasSuperUserAccess(); $view = new View('@DBStats/index'); $this->setBasicVariablesView($view); $_GET['showtitle'] = '1'; $view->databaseUsageSummary = $this->renderReport('getDatabaseUsageSummary'); $view->trackerDataSummary = $this->renderReport('getTrackerDataSummary'); $view->metricDataSummary = $this->renderReport('getMetricDataSummary'); $view->reportDataSummary = $this->renderReport('getReportDataSummary'); $view->adminDataSummary = $this->renderReport('getAdminDataSummary'); list($siteCount, $userCount, $totalSpaceUsed) = API::getInstance()->getGeneralInformation(); $formatter = new Formatter(); $view->siteCount = $formatter->getPrettyNumber($siteCount); $view->userCount = $formatter->getPrettyNumber($userCount); $view->totalSpaceUsed = $formatter->getPrettySizeFromBytes($totalSpaceUsed); return $view->render(); }
[ "public", "function", "index", "(", ")", "{", "Piwik", "::", "checkUserHasSuperUserAccess", "(", ")", ";", "$", "view", "=", "new", "View", "(", "'@DBStats/index'", ")", ";", "$", "this", "->", "setBasicVariablesView", "(", "$", "view", ")", ";", "$", "_GET", "[", "'showtitle'", "]", "=", "'1'", ";", "$", "view", "->", "databaseUsageSummary", "=", "$", "this", "->", "renderReport", "(", "'getDatabaseUsageSummary'", ")", ";", "$", "view", "->", "trackerDataSummary", "=", "$", "this", "->", "renderReport", "(", "'getTrackerDataSummary'", ")", ";", "$", "view", "->", "metricDataSummary", "=", "$", "this", "->", "renderReport", "(", "'getMetricDataSummary'", ")", ";", "$", "view", "->", "reportDataSummary", "=", "$", "this", "->", "renderReport", "(", "'getReportDataSummary'", ")", ";", "$", "view", "->", "adminDataSummary", "=", "$", "this", "->", "renderReport", "(", "'getAdminDataSummary'", ")", ";", "list", "(", "$", "siteCount", ",", "$", "userCount", ",", "$", "totalSpaceUsed", ")", "=", "API", "::", "getInstance", "(", ")", "->", "getGeneralInformation", "(", ")", ";", "$", "formatter", "=", "new", "Formatter", "(", ")", ";", "$", "view", "->", "siteCount", "=", "$", "formatter", "->", "getPrettyNumber", "(", "$", "siteCount", ")", ";", "$", "view", "->", "userCount", "=", "$", "formatter", "->", "getPrettyNumber", "(", "$", "userCount", ")", ";", "$", "view", "->", "totalSpaceUsed", "=", "$", "formatter", "->", "getPrettySizeFromBytes", "(", "$", "totalSpaceUsed", ")", ";", "return", "$", "view", "->", "render", "(", ")", ";", "}" ]
Returns the index for this plugin. Shows every other report defined by this plugin, except the '...ByYear' reports. These can be loaded as related reports. Also, the 'getIndividual...Summary' reports are loaded by AJAX, as they can take a significant amount of time to load on setups w/ lots of websites.
[ "Returns", "the", "index", "for", "this", "plugin", ".", "Shows", "every", "other", "report", "defined", "by", "this", "plugin", "except", "the", "...", "ByYear", "reports", ".", "These", "can", "be", "loaded", "as", "related", "reports", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DBStats/Controller.php#L26-L48
209,787
matomo-org/matomo
libs/HTML/QuickForm2/Rule/Nonempty.php
HTML_QuickForm2_Rule_Nonempty.setConfig
public function setConfig($config) { if (is_null($config)) { $config = 1; } elseif (1 > intval($config)) { throw new HTML_QuickForm2_InvalidArgumentException( 'Nonempty Rule accepts a positive count of nonempty values, ' . preg_replace('/\s+/', ' ', var_export($config, true)) . ' given' ); } return parent::setConfig(intval($config)); }
php
public function setConfig($config) { if (is_null($config)) { $config = 1; } elseif (1 > intval($config)) { throw new HTML_QuickForm2_InvalidArgumentException( 'Nonempty Rule accepts a positive count of nonempty values, ' . preg_replace('/\s+/', ' ', var_export($config, true)) . ' given' ); } return parent::setConfig(intval($config)); }
[ "public", "function", "setConfig", "(", "$", "config", ")", "{", "if", "(", "is_null", "(", "$", "config", ")", ")", "{", "$", "config", "=", "1", ";", "}", "elseif", "(", "1", ">", "intval", "(", "$", "config", ")", ")", "{", "throw", "new", "HTML_QuickForm2_InvalidArgumentException", "(", "'Nonempty Rule accepts a positive count of nonempty values, '", ".", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "var_export", "(", "$", "config", ",", "true", ")", ")", ".", "' given'", ")", ";", "}", "return", "parent", "::", "setConfig", "(", "intval", "(", "$", "config", ")", ")", ";", "}" ]
Sets minimum number of nonempty values This is useful for multiple selects and Containers, will be ignored for all other elements. Defaults to 1, thus multiple select will be considered not empty if at least one option is selected, Container will be considered not empty if at least one contained element is not empty. @param int Maximum allowed size @return HTML_QuickForm2_Rule @throws HTML_QuickForm2_InvalidArgumentException if a bogus size limit was provided
[ "Sets", "minimum", "number", "of", "nonempty", "values" ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule/Nonempty.php#L112-L123
209,788
matomo-org/matomo
core/DataTable/Filter/BeautifyTimeRangeLabels.php
BeautifyTimeRangeLabels.getRangeLabel
public function getRangeLabel($oldLabel, $lowerBound, $upperBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound, $upperBound); } else { return sprintf($this->labelPlural, ceil($lowerBound / 60) . "-" . ceil($upperBound / 60)); } }
php
public function getRangeLabel($oldLabel, $lowerBound, $upperBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound, $upperBound); } else { return sprintf($this->labelPlural, ceil($lowerBound / 60) . "-" . ceil($upperBound / 60)); } }
[ "public", "function", "getRangeLabel", "(", "$", "oldLabel", ",", "$", "lowerBound", ",", "$", "upperBound", ")", "{", "if", "(", "$", "lowerBound", "<", "60", ")", "{", "return", "sprintf", "(", "$", "this", "->", "labelSecondsPlural", ",", "$", "lowerBound", ",", "$", "upperBound", ")", ";", "}", "else", "{", "return", "sprintf", "(", "$", "this", "->", "labelPlural", ",", "ceil", "(", "$", "lowerBound", "/", "60", ")", ".", "\"-\"", ".", "ceil", "(", "$", "upperBound", "/", "60", ")", ")", ";", "}", "}" ]
Beautifies and returns a range label whose range is bounded and spans over more than one unit, ie 1-5, 5-10 but NOT 11+. If the lower bound of the range is less than 60 the pretty range label will be in seconds. Otherwise, it will be in minutes. @param string $oldLabel The original label value. @param int $lowerBound The lower bound of the range. @param int $upperBound The upper bound of the range. @return string The pretty range label.
[ "Beautifies", "and", "returns", "a", "range", "label", "whose", "range", "is", "bounded", "and", "spans", "over", "more", "than", "one", "unit", "ie", "1", "-", "5", "5", "-", "10", "but", "NOT", "11", "+", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/BeautifyTimeRangeLabels.php#L92-L99
209,789
matomo-org/matomo
core/DataTable/Filter/BeautifyTimeRangeLabels.php
BeautifyTimeRangeLabels.getUnboundedLabel
public function getUnboundedLabel($oldLabel, $lowerBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound); } else { // since we're using minutes, we use floor so 1801s+ will be 30m+ and not 31m+ return sprintf($this->labelPlural, "" . floor($lowerBound / 60) . urlencode('+')); } }
php
public function getUnboundedLabel($oldLabel, $lowerBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound); } else { // since we're using minutes, we use floor so 1801s+ will be 30m+ and not 31m+ return sprintf($this->labelPlural, "" . floor($lowerBound / 60) . urlencode('+')); } }
[ "public", "function", "getUnboundedLabel", "(", "$", "oldLabel", ",", "$", "lowerBound", ")", "{", "if", "(", "$", "lowerBound", "<", "60", ")", "{", "return", "sprintf", "(", "$", "this", "->", "labelSecondsPlural", ",", "$", "lowerBound", ")", ";", "}", "else", "{", "// since we're using minutes, we use floor so 1801s+ will be 30m+ and not 31m+", "return", "sprintf", "(", "$", "this", "->", "labelPlural", ",", "\"\"", ".", "floor", "(", "$", "lowerBound", "/", "60", ")", ".", "urlencode", "(", "'+'", ")", ")", ";", "}", "}" ]
Beautifies and returns a range label whose range is unbounded, ie 5+, 10+, etc. If the lower bound of the range is less than 60 the pretty range label will be in seconds. Otherwise, it will be in minutes. @param string $oldLabel The original label value. @param int $lowerBound The lower bound of the range. @return string The pretty range label.
[ "Beautifies", "and", "returns", "a", "range", "label", "whose", "range", "is", "unbounded", "ie", "5", "+", "10", "+", "etc", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/BeautifyTimeRangeLabels.php#L112-L120
209,790
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.sql
public function sql($sql, $errorCodesToIgnore = array()) { if ($errorCodesToIgnore === false) { $errorCodesToIgnore = array(); } return $this->container->make('Piwik\Updater\Migration\Db\Sql', array( 'sql' => $sql, 'errorCodesToIgnore' => $errorCodesToIgnore )); }
php
public function sql($sql, $errorCodesToIgnore = array()) { if ($errorCodesToIgnore === false) { $errorCodesToIgnore = array(); } return $this->container->make('Piwik\Updater\Migration\Db\Sql', array( 'sql' => $sql, 'errorCodesToIgnore' => $errorCodesToIgnore )); }
[ "public", "function", "sql", "(", "$", "sql", ",", "$", "errorCodesToIgnore", "=", "array", "(", ")", ")", "{", "if", "(", "$", "errorCodesToIgnore", "===", "false", ")", "{", "$", "errorCodesToIgnore", "=", "array", "(", ")", ";", "}", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\Sql'", ",", "array", "(", "'sql'", "=>", "$", "sql", ",", "'errorCodesToIgnore'", "=>", "$", "errorCodesToIgnore", ")", ")", ";", "}" ]
Performs a custom SQL query during the update. Example: $factory->sql("DELETE * FROM table_name WHERE plugin_name = 'MyPluginName'"); @param string $sql The SQL query that should be executed. Make sure to prefix a table name via {@link Piwik\Commin::prefixTable()}. @param int|int[] $errorCodesToIgnore Any given MySQL server error code will be ignored. For a list of all possible error codes have a look at {@link \Piwik\Updater\Migration\Db}. If no error should be ignored use an empty array or `false`. @return Sql
[ "Performs", "a", "custom", "SQL", "query", "during", "the", "update", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L46-L55
209,791
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.boundSql
public function boundSql($sql, $bind, $errorCodesToIgnore = array()) { if ($errorCodesToIgnore === false) { $errorCodesToIgnore = array(); } return $this->container->make('Piwik\Updater\Migration\Db\BoundSql', array( 'sql' => $sql, 'errorCodesToIgnore' => $errorCodesToIgnore, 'bind' => $bind )); }
php
public function boundSql($sql, $bind, $errorCodesToIgnore = array()) { if ($errorCodesToIgnore === false) { $errorCodesToIgnore = array(); } return $this->container->make('Piwik\Updater\Migration\Db\BoundSql', array( 'sql' => $sql, 'errorCodesToIgnore' => $errorCodesToIgnore, 'bind' => $bind )); }
[ "public", "function", "boundSql", "(", "$", "sql", ",", "$", "bind", ",", "$", "errorCodesToIgnore", "=", "array", "(", ")", ")", "{", "if", "(", "$", "errorCodesToIgnore", "===", "false", ")", "{", "$", "errorCodesToIgnore", "=", "array", "(", ")", ";", "}", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\BoundSql'", ",", "array", "(", "'sql'", "=>", "$", "sql", ",", "'errorCodesToIgnore'", "=>", "$", "errorCodesToIgnore", ",", "'bind'", "=>", "$", "bind", ")", ")", ";", "}" ]
Performs a custom SQL query that uses bound parameters during the update. You can replace values with a question mark and then pass the actual value via `$bind` for better security. Example: $factory->boundSql('DELETE * FROM table_name WHERE idsite = ?, array($idSite = 1)); @param string $sql The SQL query that should be executed. Make sure to prefix a table name via {@link Piwik\Commin::prefixTable()}. @param array $bind An array of values that need to be replaced with the question marks in the SQL query. @param int|int[] $errorCodesToIgnore Any given MySQL server error code will be ignored. For a list of all possible error codes have a look at {@link \Piwik\Updater\Migration\Db}. If no error should be ignored use `false`. @return BoundSql
[ "Performs", "a", "custom", "SQL", "query", "that", "uses", "bound", "parameters", "during", "the", "update", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L73-L82
209,792
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.createTable
public function createTable($table, $columnNames, $primaryKey = array()) { $table = $this->prefixTable($table); if (!empty($primaryKey) && !is_array($primaryKey)) { $primaryKey = array($primaryKey); } return $this->container->make('Piwik\Updater\Migration\Db\CreateTable', array( 'table' => $table, 'columnNames' => $columnNames, 'primaryKey' => $primaryKey )); }
php
public function createTable($table, $columnNames, $primaryKey = array()) { $table = $this->prefixTable($table); if (!empty($primaryKey) && !is_array($primaryKey)) { $primaryKey = array($primaryKey); } return $this->container->make('Piwik\Updater\Migration\Db\CreateTable', array( 'table' => $table, 'columnNames' => $columnNames, 'primaryKey' => $primaryKey )); }
[ "public", "function", "createTable", "(", "$", "table", ",", "$", "columnNames", ",", "$", "primaryKey", "=", "array", "(", ")", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "if", "(", "!", "empty", "(", "$", "primaryKey", ")", "&&", "!", "is_array", "(", "$", "primaryKey", ")", ")", "{", "$", "primaryKey", "=", "array", "(", "$", "primaryKey", ")", ";", "}", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\CreateTable'", ",", "array", "(", "'table'", "=>", "$", "table", ",", "'columnNames'", "=>", "$", "columnNames", ",", "'primaryKey'", "=>", "$", "primaryKey", ")", ")", ";", "}" ]
Creates a new database table. @param string $table Unprefixed database table name, eg 'log_visit'. @param array $columnNames An array of column names and their type they should use. For example: array('column_name_1' => 'VARCHAR(200) NOT NULL', 'column_name_2' => 'INT(10) DEFAULT 0') @param string|string[] $primaryKey Optional. One or multiple columns that shall define the primary key. @return CreateTable
[ "Creates", "a", "new", "database", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L92-L103
209,793
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.dropTable
public function dropTable($table) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\DropTable', array( 'table' => $table )); }
php
public function dropTable($table) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\DropTable', array( 'table' => $table )); }
[ "public", "function", "dropTable", "(", "$", "table", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\DropTable'", ",", "array", "(", "'table'", "=>", "$", "table", ")", ")", ";", "}" ]
Drops an existing database table. @param string $table Unprefixed database table name, eg 'log_visit'. @return DropTable
[ "Drops", "an", "existing", "database", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L110-L117
209,794
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.addColumn
public function addColumn($table, $columnName, $columnType, $placeColumnAfter = null) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\AddColumn', array( 'table' => $table, 'columnName' => $columnName, 'columnType' => $columnType, 'placeColumnAfter' => $placeColumnAfter )); }
php
public function addColumn($table, $columnName, $columnType, $placeColumnAfter = null) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\AddColumn', array( 'table' => $table, 'columnName' => $columnName, 'columnType' => $columnType, 'placeColumnAfter' => $placeColumnAfter )); }
[ "public", "function", "addColumn", "(", "$", "table", ",", "$", "columnName", ",", "$", "columnType", ",", "$", "placeColumnAfter", "=", "null", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\AddColumn'", ",", "array", "(", "'table'", "=>", "$", "table", ",", "'columnName'", "=>", "$", "columnName", ",", "'columnType'", "=>", "$", "columnType", ",", "'placeColumnAfter'", "=>", "$", "placeColumnAfter", ")", ")", ";", "}" ]
Adds a new database table column to an existing table. @param string $table Unprefixed database table name, eg 'log_visit'. @param string $columnName The name of the column that shall be added, eg 'my_column_name'. @param string $columnType The column type it should have, eg 'VARCHAR(200) NOT NULL'. @param string|null $placeColumnAfter If specified, the added column will be added after this specified column name. If you specify a column be sure it actually exists and can be added after this column. @return AddColumn
[ "Adds", "a", "new", "database", "table", "column", "to", "an", "existing", "table", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L130-L137
209,795
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.addColumns
public function addColumns($table, $columns, $placeColumnAfter = null) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\AddColumns', array( 'table' => $table, 'columns' => $columns, 'placeColumnAfter' => $placeColumnAfter )); }
php
public function addColumns($table, $columns, $placeColumnAfter = null) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\AddColumns', array( 'table' => $table, 'columns' => $columns, 'placeColumnAfter' => $placeColumnAfter )); }
[ "public", "function", "addColumns", "(", "$", "table", ",", "$", "columns", ",", "$", "placeColumnAfter", "=", "null", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\AddColumns'", ",", "array", "(", "'table'", "=>", "$", "table", ",", "'columns'", "=>", "$", "columns", ",", "'placeColumnAfter'", "=>", "$", "placeColumnAfter", ")", ")", ";", "}" ]
Adds multiple new database table columns to an existing table at once. Adding multiple columns at the same time can lead to performance improvements compared to adding each new column separately. @param string $table Unprefixed database table name, eg 'log_visit'. @param array $columns An array of column name to column type pairs, eg array('my_column_name' => 'VARCHAR(200) NOT NULL', 'column2' => '...') @param string|null $placeColumnAfter If specified, the first added column will be added after this specified column name. All following columns will be added after the previous specified in $columns. If you specify a column be sure it actually exists and can be added after this column. @return AddColumns
[ "Adds", "multiple", "new", "database", "table", "columns", "to", "an", "existing", "table", "at", "once", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L154-L161
209,796
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.dropColumn
public function dropColumn($table, $columnName) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\DropColumn', array( 'table' => $table, 'columnName' => $columnName )); }
php
public function dropColumn($table, $columnName) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\DropColumn', array( 'table' => $table, 'columnName' => $columnName )); }
[ "public", "function", "dropColumn", "(", "$", "table", ",", "$", "columnName", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\DropColumn'", ",", "array", "(", "'table'", "=>", "$", "table", ",", "'columnName'", "=>", "$", "columnName", ")", ")", ";", "}" ]
Drops an existing database table column. @param string $table Unprefixed database table name, eg 'log_visit'. @param string $columnName The name of the column that shall be dropped, eg 'my_column_name'. @return DropColumn
[ "Drops", "an", "existing", "database", "table", "column", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L170-L177
209,797
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.changeColumn
public function changeColumn($table, $oldColumnName, $newColumnName, $columnType) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\ChangeColumn', array( 'table' => $table, 'oldColumnName' => $oldColumnName, 'newColumnName' => $newColumnName, 'columnType' => $columnType )); }
php
public function changeColumn($table, $oldColumnName, $newColumnName, $columnType) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\ChangeColumn', array( 'table' => $table, 'oldColumnName' => $oldColumnName, 'newColumnName' => $newColumnName, 'columnType' => $columnType )); }
[ "public", "function", "changeColumn", "(", "$", "table", ",", "$", "oldColumnName", ",", "$", "newColumnName", ",", "$", "columnType", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\ChangeColumn'", ",", "array", "(", "'table'", "=>", "$", "table", ",", "'oldColumnName'", "=>", "$", "oldColumnName", ",", "'newColumnName'", "=>", "$", "newColumnName", ",", "'columnType'", "=>", "$", "columnType", ")", ")", ";", "}" ]
Changes the column name and column type of an existing database table column. @param string $table Unprefixed database table name, eg 'log_visit'. @param string $oldColumnName The current name of the column that shall be renamed/changed, eg 'column_name'. @param string $newColumnName The new name of the column, eg 'new_column_name'. @param string $columnType The updated type the new column should have, eg 'VARCHAR(200) NOT NULL'. @return ChangeColumn
[ "Changes", "the", "column", "name", "and", "column", "type", "of", "an", "existing", "database", "table", "column", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L189-L197
209,798
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.changeColumnType
public function changeColumnType($table, $columnName, $columnType) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\ChangeColumnType', array( 'table' => $table, 'columnName' => $columnName, 'columnType' => $columnType )); }
php
public function changeColumnType($table, $columnName, $columnType) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\ChangeColumnType', array( 'table' => $table, 'columnName' => $columnName, 'columnType' => $columnType )); }
[ "public", "function", "changeColumnType", "(", "$", "table", ",", "$", "columnName", ",", "$", "columnType", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\ChangeColumnType'", ",", "array", "(", "'table'", "=>", "$", "table", ",", "'columnName'", "=>", "$", "columnName", ",", "'columnType'", "=>", "$", "columnType", ")", ")", ";", "}" ]
Changes the type of an existing database table column. @param string $table Unprefixed database table name, eg 'log_visit'. @param string $columnName The name of the column that shall be changed, eg 'my_column_name'. @param string $columnType The updated type the column should have, eg 'VARCHAR(200) NOT NULL'. @return ChangeColumnType
[ "Changes", "the", "type", "of", "an", "existing", "database", "table", "column", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L208-L215
209,799
matomo-org/matomo
core/Updater/Migration/Db/Factory.php
Factory.changeColumnTypes
public function changeColumnTypes($table, $columns) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\ChangeColumnTypes', array( 'table' => $table, 'columns' => $columns )); }
php
public function changeColumnTypes($table, $columns) { $table = $this->prefixTable($table); return $this->container->make('Piwik\Updater\Migration\Db\ChangeColumnTypes', array( 'table' => $table, 'columns' => $columns )); }
[ "public", "function", "changeColumnTypes", "(", "$", "table", ",", "$", "columns", ")", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "return", "$", "this", "->", "container", "->", "make", "(", "'Piwik\\Updater\\Migration\\Db\\ChangeColumnTypes'", ",", "array", "(", "'table'", "=>", "$", "table", ",", "'columns'", "=>", "$", "columns", ")", ")", ";", "}" ]
Changes the type of multiple existing database table columns at the same time. Changing multiple columns at the same time can lead to performance improvements compared to changing the type of each column separately. @param string $table Unprefixed database table name, eg 'log_visit'. @param array $columns An array of column name to column type pairs, eg array('my_column_name' => 'VARCHAR(200) NOT NULL', 'column2' => '...') @return ChangeColumnTypes
[ "Changes", "the", "type", "of", "multiple", "existing", "database", "table", "columns", "at", "the", "same", "time", "." ]
72df150735664275a60a7861e468c6ff3b152a14
https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater/Migration/Db/Factory.php#L229-L236