diff --git a/core/DataTable/Renderer/Json.php b/core/DataTable/Renderer/Json.php index f5f6fc12bbc1f3bfefb480b81944eaf7ab1feea7..89dd73ab376818ba7d20d87700cd843da97d524f 100644 --- a/core/DataTable/Renderer/Json.php +++ b/core/DataTable/Renderer/Json.php @@ -79,7 +79,11 @@ class Json extends Renderer } // decode all entities - $callback = create_function('&$value,$key', 'if(is_string($value)){$value = html_entity_decode($value, ENT_QUOTES, "UTF-8");}'); + $callback = function(&$value,$key) { + if(is_string($value)) { + $value = html_entity_decode($value, ENT_QUOTES, "UTF-8"); + }; + }; array_walk_recursive($array, $callback); $str = Common::json_encode($array); diff --git a/core/Piwik.php b/core/Piwik.php index 97b6d47b58c255502540bcf8b782f1077de63fe7..96d5b6a15cbfa53a1c213ddd0bdec4302c835a1e 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -686,7 +686,9 @@ class Piwik $outputHandler = ini_get('output_handler'); // output handlers can be stacked - $obHandlers = array_filter(ob_list_handlers(), create_function('$var', 'return $var !== "default output handler";')); + $obHandlers = array_filter(ob_list_handlers(), function($var) { + return $var !== "default output handler"; + }); // user defined handler via wrapper $autoPrependFile = ini_get('auto_prepend_file'); @@ -2258,13 +2260,13 @@ class Piwik if (Zend_Registry::get('db')->hasBulkLoader()) { try { -// throw new Exception(''); - $fileSpec = array( 'delim' => "\t", 'quote' => '"', // chr(34) 'escape' => '\\\\', // chr(92) - 'escapespecial_cb' => create_function('$str', 'return str_replace(array(chr(92), chr(34)), array(chr(92).chr(92), chr(92).chr(34)), $str);'), + 'escapespecial_cb' => function($str) { + return str_replace(array(chr(92), chr(34)), array(chr(92).chr(92), chr(92).chr(34)), $str); + }, 'eol' => "\r\n", 'null' => 'NULL', ); diff --git a/core/Unzip/PclZip.php b/core/Unzip/PclZip.php index ad92555ab2ebd341c0b3efa1e071a7f15c4a1d2f..6b2873766e01c41482ad05d3f0da32149875badc 100644 --- a/core/Unzip/PclZip.php +++ b/core/Unzip/PclZip.php @@ -76,10 +76,9 @@ class PclZip implements UncompressInterface PCLZIP_OPT_PATH, $pathExtracted, PCLZIP_OPT_STOP_ON_ERROR, PCLZIP_OPT_REPLACE_NEWER, - PCLZIP_CB_PRE_EXTRACT, create_function( - '$p_event, &$p_header', - "return strncmp(\$p_header['filename'], '$pathExtracted', strlen('$pathExtracted')) ? 0 : 1;" - ) + PCLZIP_CB_PRE_EXTRACT, function($p_event, &$p_header) { + return strncmp($p_header['filename'], '$pathExtracted', strlen('$pathExtracted')) ? 0 : 1; + } ); } diff --git a/core/View.php b/core/View.php index 9d221c9d9cb4387aec9c610ce1956c49c59fbead..d1374575060d924579c45ea188f939377918ea83 100644 --- a/core/View.php +++ b/core/View.php @@ -111,7 +111,9 @@ class View implements ViewInterface $count = Piwik::getWebsitesCountToDisplay(); $sites = SitesManagerAPI::getInstance()->getSitesWithAtLeastViewAccess($count); - usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);')); + usort($sites, function($site1, $site2) { + return strcasecmp($site1["name"], $site2["name"]); + }); $this->sites = $sites; $this->url = Common::sanitizeInputValue(Url::getCurrentUrl()); $this->token_auth = Piwik::getCurrentUserTokenAuth(); diff --git a/plugins/API/API.php b/plugins/API/API.php index 977e4accd83ef115f5bbfa515f3699c7568510c9..41818811320c218cd6dab7cc9b8afb622aebe0ce 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -146,7 +146,7 @@ class API 'segment' => 'visitorType', 'acceptedValues' => 'new, returning, returningCustomer' . ". " . Piwik_Translate('General_VisitTypeExample', '"&segment=visitorType==returning,visitorType==returningCustomer"'), 'sqlSegment' => 'log_visit.visitor_returning', - 'sqlFilter' => create_function('$type', 'return $type == "new" ? 0 : ($type == "returning" ? 1 : 2);'), + 'sqlFilter' => function($type) { return $type == "new" ? 0 : ($type == "returning" ? 1 : 2); } ); $segments[] = array( 'type' => 'metric', diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php index 1a7a551fa8eb16242e46b92b2a8e4aba4daddc9a..9b055362273d515512df1220050528cfb859c08d 100644 --- a/plugins/Actions/API.php +++ b/plugins/Actions/API.php @@ -182,7 +182,7 @@ class API // Keep only pages which are following site search $dataTable->filter('ColumnCallbackDeleteRow', array( 'nb_hits_following_search', - create_function('$value', 'return $value > 0;') + function($value) { return $value > 0; } )); } @@ -322,7 +322,7 @@ class API $dataTable->filter('ColumnCallbackDeleteRow', array( Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT, - create_function('$value', 'return $value >= 1;') + function($value) { return $value >= 1; } )); $dataTable->deleteRow(DataTable::ID_SUMMARY_ROW); $dataTable->deleteColumn(Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT); diff --git a/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php b/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php index 128935c8845fa47ad7fefb105c48ef6060c0acf3..0f0cccb22c723af44fb4c1caa94de4bc283daf95 100644 --- a/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php +++ b/plugins/CoreVisualizations/JqplotDataGenerator/Chart.php @@ -63,7 +63,7 @@ class Chart 'internalLabel' => $label ); - array_walk($data, create_function('&$v', '$v = (float)$v;')); + array_walk($data, function(&$v) { $v = (float)$v; }); $this->data[] = & $data; } } diff --git a/plugins/CustomVariables/API.php b/plugins/CustomVariables/API.php index 21bdca1f55d2395763c5aa22115ec1053a2271fb..7e42e6de4947a4905c7e62c4d3dd5ada90c9d204 100644 --- a/plugins/CustomVariables/API.php +++ b/plugins/CustomVariables/API.php @@ -113,10 +113,11 @@ class API // Hack Ecommerce product price tracking to display correctly $dataTable->renameColumn('price_viewed', 'price'); } - $dataTable->queueFilter('ColumnCallbackReplace', array('label', create_function('$label', ' - return $label == \\Piwik\\Plugins\\CustomVariables\\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED - ? "' . Piwik_Translate('General_NotDefined', Piwik_Translate('CustomVariables_ColumnCustomVariableValue')) . '" - : $label;'))); + $dataTable->queueFilter('ColumnCallbackReplace', array('label', function($label) { + return $label == \Piwik\Plugins\CustomVariables\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED + ? Piwik_Translate('General_NotDefined', Piwik_Translate('CustomVariables_ColumnCustomVariableValue')) + : $label; + })); return $dataTable; } } diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index 00bfa35aac09091381538fd89c02816a533f723d..6f298348e9583e27dbade120ce25f9b797d7a03e 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -94,7 +94,7 @@ class DevicesDetection extends \Piwik\Plugin 'deviceType', 'log_visit.config_device_type', implode(", ", UserAgentParserEnhanced::$deviceTypes), // comma separated examples - create_function('$type', 'return array_search( strtolower(trim(urldecode($type))), UserAgentParserEnhanced::$deviceTypes);') + function($type) { return array_search( strtolower(trim(urldecode($type))), UserAgentParserEnhanced::$deviceTypes); } ), // device brands report array( diff --git a/plugins/MultiSites/API.php b/plugins/MultiSites/API.php index 6b2381c0d5e04eb5f99dada2f9f26fd919b04571..d3554ff6f6bd6868712c2d7853ba921b926a304e 100755 --- a/plugins/MultiSites/API.php +++ b/plugins/MultiSites/API.php @@ -314,7 +314,7 @@ class API 'ColumnCallbackDeleteRow', array( self::NB_VISITS_METRIC, - create_function('$value', 'return $value != 0;') + function($value) { return $value != 0; } ) ); } diff --git a/plugins/Referers/API.php b/plugins/Referers/API.php index 8e65899d1e2310c36eb1a74c7708963cff065ca4..1c3e5b3793530054cbda567a8dc8733a496a9e5f 100644 --- a/plugins/Referers/API.php +++ b/plugins/Referers/API.php @@ -306,7 +306,7 @@ class API $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable); // the htmlspecialchars_decode call is for BC for before 1.1 // as the Referrer URL was previously encoded in the log tables, but is now recorded raw - $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', create_function('$label', 'return htmlspecialchars_decode($label);'))); + $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', function($label) { return htmlspecialchars_decode($label); })); $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPathFromUrl')); return $dataTable; } diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index db68b112ccb2f1bd51c09bdbfc626eff34a78681..5904097dd6101d5feaaf271a8e7445196c27dc1d 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -1079,7 +1079,7 @@ class API public function getCurrencyList() { $currencies = Piwik::getCurrencyList(); - return array_map(create_function('$a', 'return $a[1]." (".$a[0].")";'), $currencies); + return array_map(function($a) { return $a[1]." (".$a[0].")"; }, $currencies); } /** @@ -1090,7 +1090,7 @@ class API public function getCurrencySymbols() { $currencies = Piwik::getCurrencyList(); - return array_map(create_function('$a', 'return $a[0];'), $currencies); + return array_map(function($a) { return $a[0]; }, $currencies); } /** diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php index a621b9344ccc75c41c16d3c7b387c815b7b3a253..b62076385c55ef6566081cded1af83bb2b0e8775 100644 --- a/plugins/UserCountry/API.php +++ b/plugins/UserCountry/API.php @@ -132,7 +132,7 @@ class API array('label', 'city_name', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 0, $strUnknown))); $dataTable->filter('MetadataCallbackAddMetadata', - array('city_name', 'city', create_function('$city', ' if ($city == "' . $strUnknown . '") { return "xx"; } else { return false; } '))); + array('city_name', 'city', function($city) use ($strUnknown) { if ($city == $strUnknown) { return "xx"; } else { return false; } })); $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 1, $unk))); $dataTable->filter('ColumnCallbackAddMetadata',