diff --git a/config/global.ini.php b/config/global.ini.php index af9275e6a39dd6a4d3be84595b7c19a2d84233ee..ffff48ea6bc6bf7fa6b4e40dc868d6f19a0d524f 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -131,6 +131,10 @@ datatable_archiving_maximum_rows_subtable_actions = 100 ; If set to 1, Piwik uses a Content Distribution Network use_ajax_cdn = 0 +; required AJAX library versions +jquery_version = 1.2.6 +swfobject_version = 2.2 + [Tracker] ; set to 0 if you want to stop tracking the visitors. Useful if you need to stop all the connections on the DB. record_statistics = 1 diff --git a/core/Controller.php b/core/Controller.php index 5f263d83b669d929ad381a2cb6cf2e4bc745279b..04d950fa80438ce9e41bf16178ba28e3cb8bb22a 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -253,7 +253,7 @@ abstract class Piwik_Controller $view->maxDateDay = $maxDate->toString('d'); $view->debugTrackVisitsInsidePiwikUI = Zend_Registry::get('config')->Debug->track_visits_inside_piwik_ui; - + } catch(Exception $e) { self::redirectToIndex(Piwik::getModule(), Piwik::getAction()); } diff --git a/core/SmartyPlugins/outputfilter.ajaxcdn.php b/core/SmartyPlugins/outputfilter.ajaxcdn.php index 2fc97a5b360e61bc78d38b3362c136f12f0a98a0..8a9c69252480ca3f12ee2ba013caa465e2d3b59d 100644 --- a/core/SmartyPlugins/outputfilter.ajaxcdn.php +++ b/core/SmartyPlugins/outputfilter.ajaxcdn.php @@ -34,16 +34,17 @@ function smarty_outputfilter_ajaxcdn($source, &$smarty) return $source; } + $jquery_version = Zend_Registry::get('config')->General->jquery_version; + $swfobject_version = Zend_Registry::get('config')->General->swfobject_version; + $pattern = array( '~<script type="text/javascript" src="libs/jquery/jquery\.js([^"]*)">~', - '~<script type="text/javascript" src="libs/jquery/jqueryui\.js([^"]*)">~', '~<script type="text/javascript" src="libs/swfobject/swfobject\.js([^"]*)">~', ); $replace = array( - '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">', - '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js">', - '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js">', + '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/'.$jquery_version.'/jquery.min.js">', + '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/'.$swfobject_version.'/swfobject.js">', ); return preg_replace($pattern, $replace, $source); diff --git a/core/View.php b/core/View.php index 369702f51d108788a707d54c31ea2589f014b49c..f85d33189fc782b2898ba5373c6868f8ce7c0877 100644 --- a/core/View.php +++ b/core/View.php @@ -62,7 +62,7 @@ class Piwik_View implements Piwik_iView $this->smarty->load_filter('output', 'ajaxcdn'); $this->smarty->load_filter('output', 'trimwhitespace'); } - + // global value accessible to all templates: the piwik base URL for the current request $this->piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName(); } diff --git a/tests/core/ReleaseCheckList.test.php b/tests/core/ReleaseCheckList.test.php index e505ba229f1612e766a036a7bf4c16232af12ff6..caef6d4a85d63d570633219fb23276066905f051 100644 --- a/tests/core/ReleaseCheckList.test.php +++ b/tests/core/ReleaseCheckList.test.php @@ -74,5 +74,21 @@ class Test_Piwik_ReleaseCheckList extends UnitTestCase include PIWIK_PATH_TEST_TO_ROOT . "/piwik.php"; $this->assertTrue($GLOBALS['PIWIK_TRACKER_DEBUG'] === false); } + + function test_ajaxLibraryVersions() + { + Piwik::createConfigObject(); + Zend_Registry::get('config')->setTestEnvironment(); + Zend_Registry::get('config')->disableSavingConfigurationFileUpdates(); + + $jqueryJs = file_get_contents( PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery.js', false, NULL, 0, 512 ); + $this->assertTrue( preg_match('/jQuery ([0-9.]+)/', $jqueryJs, $matches) ); + $this->assertEqual( $matches[1], Zend_Registry::get('config')->General->jquery_version ); + + + $swfobjectJs = file_get_contents( PIWIK_DOCUMENT_ROOT . '/libs/swfobject/swfobject.js', false, NULL, 0, 512 ); + $this->assertTrue( preg_match('/SWFObject v([0-9.]+)/', $swfobjectJs, $matches) ); + $this->assertEqual( $matches[1], Zend_Registry::get('config')->General->swfobject_version ); + } }