Skip to content
Extraits de code Groupes Projets
Valider fbc3cc8b rédigé par robocoder's avatar robocoder
Parcourir les fichiers

Add option to use a known CDN for AJAX libraries

git-svn-id: http://dev.piwik.org/svn/trunk@1499 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent d23cde5c
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -127,6 +127,10 @@ datatable_archiving_maximum_rows_actions = 500 ...@@ -127,6 +127,10 @@ datatable_archiving_maximum_rows_actions = 500
; maximum number of rows for pages in categories (sub pages, when clicking on the + for a page category) ; maximum number of rows for pages in categories (sub pages, when clicking on the + for a page category)
datatable_archiving_maximum_rows_subtable_actions = 100 datatable_archiving_maximum_rows_subtable_actions = 100
; by default, Piwik uses self-hosted AJAX libraries.
; If set to 1, Piwik uses a Content Distribution Network
use_ajax_cdn = 0
[Tracker] [Tracker]
; set to 0 if you want to stop tracking the visitors. Useful if you need to stop all the connections on the DB. ; 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 record_statistics = 1
......
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
*
* @category Piwik
* @package SmartyPlugins
*/
/**
* Smarty AJAX Libraries CDN outputfilter plugin
*
* File: outputfilter.ajaxcdn.php<br>
* Type: outputfilter<br>
* Name: ajaxcdn<br>
* Date: Oct 13, 2009<br>
* Purpose: use AJAX Libraries Content Distribution Network<br>
* Install: Drop into the plugin directory, call
* <code>$smarty->load_filter('output','ajaxcdn');</code>
* from application.
* @author Anthon Pang <apang at softwaredevelopment dot ca>
* @version 1.0
* @param string
* @param Smarty
*/
function smarty_outputfilter_ajaxcdn($source, &$smarty)
{
$use_ajax_cdn = Zend_Registry::get('config')->General->use_ajax_cdn;
if(!$use_ajax_cdn)
{
return $source;
}
$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">',
);
return preg_replace($pattern, $replace, $source);
}
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* of external CSS stylesheets and * of external CSS stylesheets and
* JavaScript scripts<br> * JavaScript scripts<br>
* Install: Drop into the plugin directory, call * Install: Drop into the plugin directory, call
* <code>$smarty->assign('tag','XXXX');</code> * <code>$smarty->assign('tag', 'some_unique_tag');</code>
* <code>$smarty->load_filter('output','cachebuster');</code> * <code>$smarty->load_filter('output','cachebuster');</code>
* from application. * from application.
* @author Anthon Pang <apang at softwaredevelopment dot ca> * @author Anthon Pang <apang at softwaredevelopment dot ca>
...@@ -41,7 +41,7 @@ function smarty_outputfilter_cachebuster($source, &$smarty) ...@@ -41,7 +41,7 @@ function smarty_outputfilter_cachebuster($source, &$smarty)
$replace = array( $replace = array(
'<script type="text/javascript" src="$1?'. $tag .'">', '<script type="text/javascript" src="$1?'. $tag .'">',
'<script src="$1?'. $tag .'" type="text/javascript">', '<script type="text/javascript" src="$1?'. $tag .'">',
'<link rel="stylesheet" type="text/css" href="$1?'. $tag .'" />', '<link rel="stylesheet" type="text/css" href="$1?'. $tag .'" />',
); );
......
...@@ -59,7 +59,7 @@ class Piwik_View implements Piwik_iView ...@@ -59,7 +59,7 @@ class Piwik_View implements Piwik_iView
if($filter) if($filter)
{ {
$this->smarty->load_filter('output', 'cachebuster'); $this->smarty->load_filter('output', 'cachebuster');
$this->smarty->load_filter('output', 'ajaxcdn');
$this->smarty->load_filter('output', 'trimwhitespace'); $this->smarty->load_filter('output', 'trimwhitespace');
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter