diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2010-06-29 10:45:34 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2010-06-29 10:45:34 +0400 |
commit | 78edf2b8fbc2c9ca0967faad4f8febf636a2b32b (patch) | |
tree | 92c73c8676893d23b0334e3e162bea4776f60a64 /plugins | |
parent | 9c5f65ba1f94d0fbe028b6649e21aad26a216866 (diff) |
Fixes #660 - Thanks Julien Moumne for the patch! great new feature improving Piwik responsiveness and load time.
* Added new writable dir /tmp/assets/ to write the merged CSS/JS
* I had to update checkDirectoriesWritableOrDie and added a slash at the end of all paths, or directory creation in checkDirectoriesWritable was failing
git-svn-id: http://dev.piwik.org/svn/trunk@2392 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins')
46 files changed, 459 insertions, 311 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php index 8d616b153d..65fe67b7ce 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -26,4 +26,18 @@ class Piwik_API extends Piwik_Plugin 'version' => Piwik_Version::VERSION, ); } + + function getListHooksRegistered() + { + return array( + 'AssetManager.getCssFiles' => 'getCssFiles' + ); + } + + function getCssFiles( $notification ) + { + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "plugins/API/templates/styles.css"; + } } diff --git a/plugins/API/templates/listAllAPI.tpl b/plugins/API/templates/listAllAPI.tpl index 68d51b6684..3db1275f5c 100644 --- a/plugins/API/templates/listAllAPI.tpl +++ b/plugins/API/templates/listAllAPI.tpl @@ -3,9 +3,6 @@ {assign var=showMenu value=false} {include file="CoreAdminHome/templates/header.tpl"} -<style> -{fetch file="plugins/API/templates/styles.css"} -</style> <h2>{'API_QuickDocumentationTitle'|translate}</h2> <p>{'API_PluginDescription'|translate}</p> diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php index 8b15308f92..ca4dbaadea 100644 --- a/plugins/CoreAdminHome/CoreAdminHome.php +++ b/plugins/CoreAdminHome/CoreAdminHome.php @@ -29,14 +29,36 @@ class Piwik_CoreAdminHome extends Piwik_Plugin public function getListHooksRegistered() { return array( - 'template_css_import' => 'css', + 'AssetManager.getCssFiles' => 'getCssFiles', + 'AssetManager.getJsFiles' => 'getJsFiles', 'AdminMenu.add' => 'addMenu' ); } - - function css() + + function getCssFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"plugins/CoreAdminHome/templates/menu.css\" />\n"; + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "plugins/CoreAdminHome/templates/menu.css"; + $cssFiles[] = "themes/default/common.css"; + $cssFiles[] = "libs/jquery/themes/base/jquery-ui.css"; + $cssFiles[] = "plugins/CoreAdminHome/templates/styles.css"; + } + + function getJsFiles ( $notification ) { + + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "libs/jquery/jquery.js"; + $jsFiles[] = "libs/jquery/jquery-ui.js"; + $jsFiles[] = "libs/jquery/jquery.bgiframe.js"; + $jsFiles[] = "libs/jquery/jquery.blockUI.js"; + $jsFiles[] = "libs/jquery/fdd2div-modified.js"; + $jsFiles[] = "libs/javascript/sprintf.js"; + $jsFiles[] = "themes/default/common.js"; + $jsFiles[] = "libs/jquery/jquery.history.js"; + $jsFiles[] = "plugins/CoreHome/templates/broadcast.js"; + $jsFiles[] = "plugins/CoreAdminHome/templates/generalSettings.js"; } function addMenu() diff --git a/plugins/CoreAdminHome/templates/generalSettings.tpl b/plugins/CoreAdminHome/templates/generalSettings.tpl index fa103f4347..7ea024ec77 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.tpl +++ b/plugins/CoreAdminHome/templates/generalSettings.tpl @@ -2,7 +2,6 @@ {assign var=showPeriodSelection value=false} {include file="CoreAdminHome/templates/header.tpl"} {loadJavascriptTranslations plugins='UsersManager'} -<script type="text/javascript" src="plugins/CoreAdminHome/templates/generalSettings.js"></script> <h2>{'General_GeneralSettings'|translate}</h2> diff --git a/plugins/CoreAdminHome/templates/header.tpl b/plugins/CoreAdminHome/templates/header.tpl index c40295db70..ca464e8f38 100644 --- a/plugins/CoreAdminHome/templates/header.tpl +++ b/plugins/CoreAdminHome/templates/header.tpl @@ -7,24 +7,12 @@ <meta name="generator" content="Piwik {$piwik_version}" /> <link rel="shortcut icon" href="plugins/CoreHome/templates/images/favicon.ico" /> -{include file="CoreHome/templates/js_global_variables.tpl"} - -<link rel="stylesheet" type="text/css" href="themes/default/common.css" /> -<link rel="stylesheet" type="text/css" href="libs/jquery/themes/base/jquery-ui.css" class="ui-theme" /> -<link rel="stylesheet" type="text/css" href="plugins/CoreAdminHome/templates/styles.css" /> -{postEvent name="template_css_import"} +{loadJavascriptTranslations plugins='CoreAdminHome'} -<script type="text/javascript" src="libs/jquery/jquery.js"></script> -<script type="text/javascript" src="libs/jquery/jquery-ui.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.bgiframe.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.blockUI.js"></script> -<script type="text/javascript" src="libs/jquery/fdd2div-modified.js"></script> -<script type="text/javascript" src="libs/javascript/sprintf.js"></script> -<script type="text/javascript" src="themes/default/common.js"></script> +{include file="CoreHome/templates/js_global_variables.tpl"} -<script type="text/javascript" src="libs/jquery/jquery.history.js"></script> -<script type="text/javascript" src="plugins/CoreHome/templates/broadcast.js"></script> -{postEvent name="template_js_import"} +{includeAssets type="css"} +{includeAssets type="js"} </head> <body> @@ -39,7 +27,7 @@ <br class="clearAll" /> -<div id="content"> +<div id="content" class="admin"> {ajaxRequestErrorDiv} {if !isset($showMenu) || $showMenu} diff --git a/plugins/CoreAdminHome/templates/styles.css b/plugins/CoreAdminHome/templates/styles.css index 3c2bbdda7b..79f81d5ea7 100644 --- a/plugins/CoreAdminHome/templates/styles.css +++ b/plugins/CoreAdminHome/templates/styles.css @@ -1,10 +1,10 @@ -img { +.admin img { vertical-align: baseline; } textarea { font-size: 1em; } -a { +.admin a { color: black; } @@ -84,7 +84,7 @@ table.admin tbody td:hover, table.admin tbody th:hover { padding: 15px; } -h2 { +.admin h2 { border-bottom-color:#DADADA; color:#666666; border-bottom-style:solid; @@ -99,16 +99,17 @@ h2 { padding:0pt 0px 7px 0pt; } -p { +.admin p { margin-top:10px; line-height:140%; padding-bottom:0.8em; } -#content { +#content.admin { margin:0pt 15px; padding:0pt; } -textarea, input, select { + +.admin textarea, .admin input, .admin select { background-color:#FFFFFF; border-color:#939EA5; -moz-border-radius:4px; @@ -118,6 +119,7 @@ textarea, input, select { margin:1px; padding:3px; } + input[disabled] { background-color:#F7F7F7; } diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php index 7fb831ce9d..a0f5b00b1f 100644 --- a/plugins/CoreHome/CoreHome.php +++ b/plugins/CoreHome/CoreHome.php @@ -25,4 +25,49 @@ class Piwik_CoreHome extends Piwik_Plugin 'version' => Piwik_Version::VERSION, ); } + + function getListHooksRegistered() + { + return array( + 'AssetManager.getCssFiles' => 'getCssFiles', + 'AssetManager.getJsFiles' => 'getJsFiles' + ); + } + + function getCssFiles( $notification ) + { + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "themes/default/common.css"; + $cssFiles[] = "libs/jquery/themes/base/jquery-ui.css"; + $cssFiles[] = "plugins/CoreHome/templates/styles.css"; + $cssFiles[] = "plugins/CoreHome/templates/menu.css"; + $cssFiles[] = "plugins/CoreHome/templates/datatable.css"; + $cssFiles[] = "plugins/CoreHome/templates/cloud.css"; + } + + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "libs/jquery/jquery.js"; + $jsFiles[] = "libs/jquery/jquery-ui.js"; + $jsFiles[] = "libs/jquery/jquery.bgiframe.js"; + $jsFiles[] = "libs/jquery/jquery.tooltip.js"; + $jsFiles[] = "libs/jquery/jquery.truncate.js"; + $jsFiles[] = "libs/jquery/jquery.scrollTo.js"; + $jsFiles[] = "libs/jquery/jquery.blockUI.js"; + $jsFiles[] = "libs/jquery/fdd2div-modified.js"; + $jsFiles[] = "libs/jquery/superfish_modified.js"; + $jsFiles[] = "libs/jquery/jquery.history.js"; + $jsFiles[] = "libs/swfobject/swfobject.js"; + $jsFiles[] = "libs/javascript/sprintf.js"; + $jsFiles[] = "themes/default/common.js"; + $jsFiles[] = "plugins/CoreHome/templates/datatable.js"; + $jsFiles[] = "plugins/CoreHome/templates/broadcast.js"; + $jsFiles[] = "plugins/CoreHome/templates/menu.js"; + $jsFiles[] = "plugins/CoreHome/templates/calendar.js"; + $jsFiles[] = "plugins/CoreHome/templates/date.js"; + } + } diff --git a/plugins/CoreHome/templates/index.tpl b/plugins/CoreHome/templates/index.tpl index cba7cbed4d..0dcff6e91c 100644 --- a/plugins/CoreHome/templates/index.tpl +++ b/plugins/CoreHome/templates/index.tpl @@ -7,7 +7,7 @@ {ajaxLoadingDiv} {ajaxRequestErrorDiv} -<div id="content"> +<div id="content" class="home"> {if $content}{$content}{/if} </div> diff --git a/plugins/CoreHome/templates/js_css_includes.tpl b/plugins/CoreHome/templates/js_css_includes.tpl index 868ebc0025..d18fa8769a 100644 --- a/plugins/CoreHome/templates/js_css_includes.tpl +++ b/plugins/CoreHome/templates/js_css_includes.tpl @@ -1,26 +1,2 @@ -<link rel="stylesheet" type="text/css" href="themes/default/common.css" /> -<link rel="stylesheet" type="text/css" href="libs/jquery/themes/base/jquery-ui.css" class="ui-theme" /> -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/styles.css" /> -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/menu.css" /> -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/datatable.css" /> -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/cloud.css" /> -{postEvent name="template_css_import"} - -<script type="text/javascript" src="libs/jquery/jquery.js"></script> -<script type="text/javascript" src="libs/jquery/jquery-ui.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.bgiframe.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.tooltip.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.truncate.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.scrollTo.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.blockUI.js"></script> -<script type="text/javascript" src="libs/jquery/fdd2div-modified.js"></script> -<script type="text/javascript" src="libs/jquery/superfish_modified.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.history.js"></script> -<script type="text/javascript" src="libs/swfobject/swfobject.js"></script> -<script type="text/javascript" src="libs/javascript/sprintf.js"></script> -<script type="text/javascript" src="themes/default/common.js"></script> -<script type="text/javascript" src="plugins/CoreHome/templates/datatable.js"></script> -<script type="text/javascript" src="plugins/CoreHome/templates/broadcast.js"></script> -<script type="text/javascript" src="plugins/CoreHome/templates/menu.js"></script> -{postEvent name="template_js_import"} - +{includeAssets type="css"} +{includeAssets type="js"}
\ No newline at end of file diff --git a/plugins/CoreHome/templates/logo.tpl b/plugins/CoreHome/templates/logo.tpl index 9c50908926..d0cd5cb852 100644 --- a/plugins/CoreHome/templates/logo.tpl +++ b/plugins/CoreHome/templates/logo.tpl @@ -1,6 +1,6 @@ <span id="logo"> <a href="index.php" title="Piwik # {'General_OpenSourceWebAnalytics'|translate}" style="text-decoration: none;"> <span style="color: rgb(245, 223, 114);">P</span><span style="color: rgb(241, 175, 108);">i</span><span style="color: rgb(241, 117, 117);">w</span><span style="color: rgb(155, 106, 58);">i</span><span style="color: rgb(107, 50, 11);">k</span> - {if $currentModule != 'CoreHome'}<span style="padding-left:1em;font-size: 20pt; letter-spacing: -1pt; color: rgb(107, 50, 11);">› {$currentPluginName}</span>{/if} </a> +{if $currentModule != 'CoreHome'}<span style="padding-left:1em;font-size: 20pt; letter-spacing: -1pt; color: rgb(107, 50, 11);">› {$currentPluginName}</span>{/if} </span> diff --git a/plugins/CoreHome/templates/period_select.tpl b/plugins/CoreHome/templates/period_select.tpl index 1c704ff5b5..c397dec858 100644 --- a/plugins/CoreHome/templates/period_select.tpl +++ b/plugins/CoreHome/templates/period_select.tpl @@ -1,6 +1,4 @@ {loadJavascriptTranslations plugins='CoreHome'} -<script type="text/javascript" src="plugins/CoreHome/templates/calendar.js"></script> -<script type="text/javascript" src="plugins/CoreHome/templates/date.js"></script> <span id="periodString"> <span id="date"><img src='themes/default/images/icon-calendar.gif' style="vertical-align:middle" alt="" /> {$prettyDate}</span> - diff --git a/plugins/CoreHome/templates/styles.css b/plugins/CoreHome/templates/styles.css index 850935ef0b..d674dc1bcf 100644 --- a/plugins/CoreHome/templates/styles.css +++ b/plugins/CoreHome/templates/styles.css @@ -21,14 +21,14 @@ h3 { color: #1D3256; } -p { +.home p { padding-bottom: 1em; margin-right: 1em; margin-left:1em; } /* Content */ -#content { +#content.home { margin-left: 10px; } diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index 266121356e..91e83ffd88 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -17,7 +17,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller { const CONFIG_FILE_BACKUP = '/config/global.ini.auto-backup-before-update.php'; - const PATH_TO_EXTRACT_LATEST_VERSION = '/tmp/latest'; + const PATH_TO_EXTRACT_LATEST_VERSION = '/tmp/latest/'; const LATEST_PIWIK_URL = 'http://piwik.org/latest.zip'; private $coreError = false; @@ -296,6 +296,9 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller private function doExecuteUpdates($view, $updater, $componentsWithUpdateFile) { + // Delete merged js/css files to force regenerations based on new versions of css/js files + Piwik_AssetManager::removeMergedAssets(); + $this->loadAndExecuteUpdateFiles($updater, $componentsWithUpdateFile); $view->coreError = $this->coreError; diff --git a/plugins/CoreUpdater/templates/header.tpl b/plugins/CoreUpdater/templates/header.tpl index 076801771d..bf17369b2b 100644 --- a/plugins/CoreUpdater/templates/header.tpl +++ b/plugins/CoreUpdater/templates/header.tpl @@ -21,7 +21,8 @@ } </style> {/literal} - {postEvent name="template_css_import"} + + {includeAssets type="css"} <script type="text/javascript" src="libs/jquery/jquery.js"></script> <script type="text/javascript" src="libs/jquery/jquery-ui.js"></script> diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php index cf9cacfb06..740231eec1 100644 --- a/plugins/Dashboard/Dashboard.php +++ b/plugins/Dashboard/Dashboard.php @@ -28,24 +28,28 @@ class Piwik_Dashboard extends Piwik_Plugin public function getListHooksRegistered() { return array( - 'template_js_import' => 'js', - 'template_css_import' => 'css', + 'AssetManager.getJsFiles' => 'getJsFiles', + 'AssetManager.getCssFiles' => 'getCssFiles', 'UsersManager.deleteUser' => 'deleteDashboardLayout', ); } - function js() + function getJsFiles( $notification ) { - echo ' -<script type="text/javascript" src="plugins/Dashboard/templates/widgetMenu.js"></script> -<script type="text/javascript" src="libs/javascript/json2.js"></script> -<script type="text/javascript" src="plugins/Dashboard/templates/Dashboard.js"></script> - '; - } - - function css() + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/Dashboard/templates/widgetMenu.js"; + $jsFiles[] = "libs/javascript/json2.js"; + $jsFiles[] = "plugins/Dashboard/templates/Dashboard.js"; + } + + function getCssFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"plugins/Dashboard/templates/dashboard.css\" />\n"; + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "plugins/Dashboard/templates/dashboard.css"; + $cssFiles[] = "plugins/CoreHome/templates/datatable.css"; + $cssFiles[] = "plugins/Dashboard/templates/dashboard.css"; } function deleteDashboardLayout($notification) diff --git a/plugins/Dashboard/templates/header.tpl b/plugins/Dashboard/templates/header.tpl index 45e688748f..141f7953b2 100644 --- a/plugins/Dashboard/templates/header.tpl +++ b/plugins/Dashboard/templates/header.tpl @@ -6,7 +6,5 @@ {loadJavascriptTranslations plugins='CoreHome Dashboard'} {include file="CoreHome/templates/js_global_variables.tpl"} {include file="CoreHome/templates/js_css_includes.tpl"} -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/datatable.css" /> -<link rel="stylesheet" type="text/css" href="plugins/Dashboard/templates/dashboard.css" /> </head> <body> diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php index f36f850e7e..16944a5711 100644 --- a/plugins/ExampleRssWidget/ExampleRssWidget.php +++ b/plugins/ExampleRssWidget/ExampleRssWidget.php @@ -35,13 +35,15 @@ class Piwik_ExampleRssWidget extends Piwik_Plugin public function getListHooksRegistered() { - return array( 'template_css_import' => 'css'); + return array( 'AssetManager.getCssFiles' => 'getCssFiles'); } - function css() + function getCssFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"plugins/ExampleRssWidget/templates/styles.css\" />\n"; - } + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "plugins/ExampleRssWidget/templates/styles.css"; + } } Piwik_AddWidget('Example Widgets', 'Piwik.org Blog', 'ExampleRssWidget', 'rssPiwik'); @@ -112,7 +114,7 @@ class Piwik_ExampleRssWidget_Rss $date = @strftime("%B %e, %Y", strtotime($post->pubDate())); $link = $post->link(); - $output .= '<li><a class="rss-title" title="" href="'.$link.'">'.$title.'</a>'. + $output .= '<li><a class="rss-title" title="" target="_blank" href="misc/redirectToUrl.php?url='.$link.'">'.$title.'</a>'. '<span class="rss-date">'.$date.'</span>'; if($this->showDescription) { diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php index 5cbd0afdf2..e540f966a3 100644 --- a/plugins/Feedback/Feedback.php +++ b/plugins/Feedback/Feedback.php @@ -29,18 +29,23 @@ class Piwik_Feedback extends Piwik_Plugin function getListHooksRegistered() { return array( - 'template_css_import' => 'css', - 'template_js_import' => 'js', + 'AssetManager.getCssFiles' => 'getCssFiles', + 'AssetManager.getJsFiles' => 'getJsFiles', ); } - function css() + function getCssFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"plugins/Feedback/templates/styles.css\" />\n"; + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "plugins/Feedback/templates/styles.css"; } - function js() + function getJsFiles( $notification ) { - echo "<script type=\"text/javascript\" src=\"plugins/Feedback/templates/feedback.js\"></script>\n"; - } + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/Feedback/templates/feedback.js"; + } + } diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 6ab468f09e..aea549a866 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -39,6 +39,7 @@ class Piwik_Goals extends Piwik_Plugin function getListHooksRegistered() { $hooks = array( + 'AssetManager.getJsFiles' => 'getJsFiles', 'Common.fetchWebsiteAttributes' => 'fetchGoalsFromDb', 'ArchiveProcessing_Day.compute' => 'archiveDay', 'ArchiveProcessing_Period.compute' => 'archivePeriod', @@ -48,6 +49,14 @@ class Piwik_Goals extends Piwik_Plugin return $hooks; } + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/Goals/templates/GoalForm.js"; + $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; + } + function fetchGoalsFromDb($notification) { $idsite = $notification->getNotificationInfo(); diff --git a/plugins/Goals/templates/add_edit_goal.tpl b/plugins/Goals/templates/add_edit_goal.tpl index e78a8eb391..976e20e4a5 100644 --- a/plugins/Goals/templates/add_edit_goal.tpl +++ b/plugins/Goals/templates/add_edit_goal.tpl @@ -28,7 +28,6 @@ </div> {loadJavascriptTranslations plugins='Goals'} -<script type="text/javascript" src="plugins/Goals/templates/GoalForm.js"></script> <script type="text/javascript"> var mappingMatchTypeName = {ldelim} diff --git a/plugins/Goals/templates/title_and_evolution_graph.tpl b/plugins/Goals/templates/title_and_evolution_graph.tpl index 0ac5707d00..fa6dadb81c 100644 --- a/plugins/Goals/templates/title_and_evolution_graph.tpl +++ b/plugins/Goals/templates/title_and_evolution_graph.tpl @@ -1,4 +1,3 @@ -<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script> <a name="evolutionGraph" graphId="{$nameGraphEvolution}"></a> diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index ef0929899e..e05f98154f 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -72,6 +72,9 @@ class Piwik_Installation_Controller extends Piwik_Controller */ function welcome($message) { + // Delete merged js/css files to force regenerations based on updated activated plugin list + Piwik_AssetManager::removeMergedAssets(); + $view = new Piwik_Installation_View( $this->pathView . 'welcome.tpl', $this->getInstallationSteps(), diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index 6ee5178910..ac0f55240a 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -30,17 +30,19 @@ class Piwik_LanguagesManager extends Piwik_Plugin public function getListHooksRegistered() { return array( - 'template_css_import' => 'css', + 'AssetManager.getCssFiles' => 'getCssFiles', 'template_topBar' => 'showLanguagesSelector', 'Translate.getLanguageToLoad' => 'getLanguageToLoad', 'UsersManager.deleteUser' => 'deleteUserLanguage', ); } - - function css() + + function getCssFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/default/styles.css\" />\n"; - } + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "themes/default/styles.css"; + } /** * Show styled language selection drop-down list diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index 4fbec02c54..b6832cca5b 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -29,15 +29,25 @@ class Piwik_Live extends Piwik_Plugin function getListHooksRegistered() { return array( - 'template_css_import' => 'css', + 'AssetManager.getJsFiles' => 'getJsFiles', + 'AssetManager.getCssFiles' => 'getCssFiles', 'WidgetsList.add' => 'addWidget', 'Menu.add' => 'addMenu', ); } - - function css() + + function getCssFiles( $notification ) + { + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "themes/default/styles.css"; + } + + function getJsFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/default/styles.css\" />\n"; + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/Live/templates/scripts/spy.js"; } function addMenu() diff --git a/plugins/Live/templates/index.tpl b/plugins/Live/templates/index.tpl index 617dc91660..2e086047c7 100644 --- a/plugins/Live/templates/index.tpl +++ b/plugins/Live/templates/index.tpl @@ -1,6 +1,4 @@ {literal} -<script type="text/javascript" src="plugins/Live/templates/scripts/spy.js"></script> - <script type="text/javascript" charset="utf-8"> $(document).ready(function() { diff --git a/plugins/Login/templates/header.tpl b/plugins/Login/templates/header.tpl index b1cb4b4ae7..ff72a23093 100644 --- a/plugins/Login/templates/header.tpl +++ b/plugins/Login/templates/header.tpl @@ -7,7 +7,6 @@ <link rel="shortcut icon" href="plugins/CoreHome/templates/images/favicon.ico" /> <link rel="stylesheet" type="text/css" href="plugins/Login/templates/login.css" media="screen" /> - {postEvent name="template_css_import"} {literal} <script type="text/javascript"> @@ -22,7 +21,6 @@ </script> {/literal} <script type="text/javascript" src="libs/jquery/jquery.js"></script> - {postEvent name="template_js_import"} </head> <body class="login"> diff --git a/plugins/MultiSites/MultiSites.php b/plugins/MultiSites/MultiSites.php index ccdc2169b6..4cd6be3be1 100644 --- a/plugins/MultiSites/MultiSites.php +++ b/plugins/MultiSites/MultiSites.php @@ -29,18 +29,21 @@ class Piwik_MultiSites extends Piwik_Plugin public function getListHooksRegistered() { return array( - 'template_css_import' => 'css', - 'template_js_import' => 'js', + 'AssetManager.getCssFiles' => 'getCssFiles', + 'AssetManager.getJsFiles' => 'getJsFiles', ); } - - public function css() + function getJsFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"plugins/MultiSites/templates/styles.css\" />\n"; + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/MultiSites/templates/common.js"; } - - public function js() + + function getCssFiles( $notification ) { - echo "<script type=\"text/javascript\" src=\"plugins/MultiSites/templates/common.js\"></script>\n"; + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "plugins/MultiSites/templates/styles.css"; } } diff --git a/plugins/MultiSites/templates/index.tpl b/plugins/MultiSites/templates/index.tpl index d4aa6e0097..275a69b69f 100644 --- a/plugins/MultiSites/templates/index.tpl +++ b/plugins/MultiSites/templates/index.tpl @@ -4,11 +4,6 @@ {assign var=showPeriodSelection value=true} {include file="CoreHome/templates/header.tpl"} -<script type="text/javascript" src="plugins/MultiSites/templates/common.js"></script> -<style> -{fetch file="plugins/MultiSites/templates/styles.css"} -</style> - <div id="multisites" style="margin: auto"> <div id="main"> {include file="MultiSites/templates/row.tpl" assign="row"} diff --git a/plugins/MultiSites/templates/styles.css b/plugins/MultiSites/templates/styles.css index 5c8204d9d0..bd62a2d3c8 100644 --- a/plugins/MultiSites/templates/styles.css +++ b/plugins/MultiSites/templates/styles.css @@ -35,12 +35,12 @@ width: 10px; height: 12px; display: inline-block; - background-image: url('plugins/MultiSites/images/arrow_asc.gif'); + background-image: url('../images/arrow_asc.gif'); } .multisites_desc { width: 10px; height: 13px; display: inline-block; - background-image: url('plugins/MultiSites/images/arrow_desc.gif'); + background-image: url('../images/arrow_desc.gif'); }
\ No newline at end of file diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php index 291971370c..a40330a923 100644 --- a/plugins/Referers/Referers.php +++ b/plugins/Referers/Referers.php @@ -35,6 +35,7 @@ class Piwik_Referers extends Piwik_Plugin function getListHooksRegistered() { $hooks = array( + 'AssetManager.getJsFiles' => 'getJsFiles', 'ArchiveProcessing_Day.compute' => 'archiveDay', 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', @@ -43,6 +44,13 @@ class Piwik_Referers extends Piwik_Plugin ); return $hooks; } + + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; + } function __construct() { diff --git a/plugins/Referers/templates/index.tpl b/plugins/Referers/templates/index.tpl index bd7dfd96cf..da46300eaf 100644 --- a/plugins/Referers/templates/index.tpl +++ b/plugins/Referers/templates/index.tpl @@ -1,5 +1,3 @@ -<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script> - <a name="evolutionGraph" graphId="{$nameGraphEvolutionReferers}"></a> <h2>{'Referers_Evolution'|translate}</h2> {$graphEvolutionReferers} diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php index dfca3e2c6f..19ec4739dc 100644 --- a/plugins/SitesManager/SitesManager.php +++ b/plugins/SitesManager/SitesManager.php @@ -30,7 +30,8 @@ class Piwik_SitesManager extends Piwik_Plugin function getListHooksRegistered() { return array( - 'template_css_import' => 'css', + 'AssetManager.getJsFiles' => 'getJsFiles', + 'AssetManager.getCssFiles' => 'getCssFiles', 'AdminMenu.add' => 'addMenu', 'Common.fetchWebsiteAttributes' => 'recordWebsiteDataInCache', ); @@ -44,9 +45,18 @@ class Piwik_SitesManager extends Piwik_Plugin $order = 5); } - function css() + function getCssFiles( $notification ) { - echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/default/styles.css\" />\n"; + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "themes/default/styles.css"; + } + + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/SitesManager/templates/SitesManager.js"; } /** diff --git a/plugins/SitesManager/templates/SitesManager.js b/plugins/SitesManager/templates/SitesManager.js index cf14893c8c..04ab005df1 100644 --- a/plugins/SitesManager/templates/SitesManager.js +++ b/plugins/SitesManager/templates/SitesManager.js @@ -1,121 +1,128 @@ -function getDeleteSiteAJAX( idSite ) -{ - var ajaxRequest = piwikHelper.getStandardAjaxConf(); +function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurrency ) { - var parameters = {}; - parameters.module = 'API'; - parameters.format = 'json'; - parameters.method = 'SitesManager.deleteSite'; - parameters.idSite = idSite; - parameters.token_auth = piwik.token_auth; - - ajaxRequest.data = parameters; - - return ajaxRequest; -} + var timezones = _timezones; + var currencies = _currencies; + var defaultTimezone = _defaultTimezone; + var defaultCurrency = _defaultCurrency; -function getAddSiteAJAX( row ) -{ - var ajaxRequest = piwikHelper.getStandardAjaxConf(); + function getDeleteSiteAJAX( idSite ) + { + var ajaxRequest = piwikHelper.getStandardAjaxConf(); - var parameters = {}; - var siteName = $(row).find('input#name').val(); - var urls = $(row).find('textarea#urls').val(); - urls = getApiFormatUrls(urls); - var excludedIps = $(row).find('textarea#excludedIps').val(); - excludedIps = getApiFormatTextarea(excludedIps); - var timezone = encodeURIComponent($(row).find('#timezones option:selected').val()); - var currency = encodeURIComponent($(row).find('#currencies option:selected').val()); - var excludedQueryParameters = $(row).find('textarea#excludedQueryParameters').val(); - excludedQueryParameters = getApiFormatTextarea(excludedQueryParameters); + var parameters = {}; + parameters.module = 'API'; + parameters.format = 'json'; + parameters.method = 'SitesManager.deleteSite'; + parameters.idSite = idSite; + parameters.token_auth = piwik.token_auth; + + ajaxRequest.data = parameters; + + return ajaxRequest; + } - var request = ''; - request += '&module=API'; - request += '&format=json'; - request += '&method=SitesManager.addSite'; - siteName = encodeURIComponent(siteName); - request += '&siteName='+siteName; - request += '&timezone='+timezone; - request += '¤cy='+currency; - request += '&excludedIps='+excludedIps; - request += '&excludedQueryParameters='+excludedQueryParameters; - $.each(urls, function (key,value){ request+= '&urls[]='+escape(value);} ); - request += '&token_auth=' + piwik.token_auth; - - ajaxRequest.data = request; - - return ajaxRequest; -} - -function getApiFormatUrls(urls) -{ - var aUrls = urls.trim().split("\n"); - for(var i=0; i < aUrls.length; i++) { - aUrls[i] = encodeURIComponent(aUrls[i]); + function getAddSiteAJAX( row ) + { + var ajaxRequest = piwikHelper.getStandardAjaxConf(); + + var parameters = {}; + var siteName = $(row).find('input#name').val(); + var urls = $(row).find('textarea#urls').val(); + urls = getApiFormatUrls(urls); + var excludedIps = $(row).find('textarea#excludedIps').val(); + excludedIps = getApiFormatTextarea(excludedIps); + var timezone = encodeURIComponent($(row).find('#timezones option:selected').val()); + var currency = encodeURIComponent($(row).find('#currencies option:selected').val()); + var excludedQueryParameters = $(row).find('textarea#excludedQueryParameters').val(); + excludedQueryParameters = getApiFormatTextarea(excludedQueryParameters); + + var request = ''; + request += '&module=API'; + request += '&format=json'; + request += '&method=SitesManager.addSite'; + siteName = encodeURIComponent(siteName); + request += '&siteName='+siteName; + request += '&timezone='+timezone; + request += '¤cy='+currency; + request += '&excludedIps='+excludedIps; + request += '&excludedQueryParameters='+excludedQueryParameters; + $.each(urls, function (key,value){ request+= '&urls[]='+escape(value);} ); + request += '&token_auth=' + piwik.token_auth; + + ajaxRequest.data = request; + + return ajaxRequest; } - return aUrls; -} -function getApiFormatTextarea(textareaContent) -{ - return textareaContent.trim().split("\n").join(','); -} - -function getUpdateSiteAJAX( row ) -{ - var ajaxRequest = piwikHelper.getStandardAjaxConf(); - var siteName = $(row).find('input#siteName').val(); - var idSite = $(row).children('#idSite').html(); - var urls = $(row).find('textarea#urls').val(); - urls = getApiFormatUrls(urls); - var excludedIps = $(row).find('textarea#excludedIps').val(); - excludedIps = getApiFormatTextarea(excludedIps); - var excludedQueryParameters = $(row).find('textarea#excludedQueryParameters').val(); - excludedQueryParameters = getApiFormatTextarea(excludedQueryParameters); - var timezone = encodeURIComponent($(row).find('#timezones option:selected').val()); - var currency = encodeURIComponent($(row).find('#currencies option:selected').val()); - var request = ''; - request += '&module=API'; - request += '&format=json'; - request += '&method=SitesManager.updateSite'; - siteName = encodeURIComponent(siteName); - request += '&siteName='+siteName; - request += '&idSite='+idSite; - request += '&timezone='+timezone; - request += '¤cy='+currency; - request += '&excludedIps='+excludedIps; - request += '&excludedQueryParameters='+excludedQueryParameters; - $.each(urls, function (key,value){ if(value.length>1) request+= '&urls[]='+value;} ); - request += '&token_auth=' + piwik.token_auth; - - ajaxRequest.data = request; + function getApiFormatUrls(urls) + { + var aUrls = urls.trim().split("\n"); + for(var i=0; i < aUrls.length; i++) { + aUrls[i] = encodeURIComponent(aUrls[i]); + } + return aUrls; + } + function getApiFormatTextarea(textareaContent) + { + return textareaContent.trim().split("\n").join(','); + } - return ajaxRequest; -} - -function getGlobalSettingsAJAX() -{ - var ajaxRequest = piwikHelper.getStandardAjaxConf('ajaxLoadingGlobalSettings', 'ajaxErrorGlobalSettings'); - var timezone = encodeURIComponent($('#defaultTimezone option:selected').val()); - var currency = encodeURIComponent($('#defaultCurrency option:selected').val()); - var excludedIps = $('textarea#globalExcludedIps').val(); - excludedIps = getApiFormatTextarea(excludedIps); - var excludedQueryParameters = $('textarea#globalExcludedQueryParameters').val(); - excludedQueryParameters = getApiFormatTextarea(excludedQueryParameters); - var request = ''; - request += 'module=SitesManager'; - request += '&action=setGlobalSettings'; - request += '&format=json'; - request += '&timezone='+timezone; - request += '¤cy='+currency; - request += '&excludedIps='+excludedIps; - request += '&excludedQueryParameters='+excludedQueryParameters; - request += '&token_auth=' + piwik.token_auth; - ajaxRequest.data = request; - return ajaxRequest; -} + function getUpdateSiteAJAX( row ) + { + var ajaxRequest = piwikHelper.getStandardAjaxConf(); + + var siteName = $(row).find('input#siteName').val(); + var idSite = $(row).children('#idSite').html(); + var urls = $(row).find('textarea#urls').val(); + urls = getApiFormatUrls(urls); + var excludedIps = $(row).find('textarea#excludedIps').val(); + excludedIps = getApiFormatTextarea(excludedIps); + var excludedQueryParameters = $(row).find('textarea#excludedQueryParameters').val(); + excludedQueryParameters = getApiFormatTextarea(excludedQueryParameters); + var timezone = encodeURIComponent($(row).find('#timezones option:selected').val()); + var currency = encodeURIComponent($(row).find('#currencies option:selected').val()); + var request = ''; + request += '&module=API'; + request += '&format=json'; + request += '&method=SitesManager.updateSite'; + siteName = encodeURIComponent(siteName); + request += '&siteName='+siteName; + request += '&idSite='+idSite; + request += '&timezone='+timezone; + request += '¤cy='+currency; + request += '&excludedIps='+excludedIps; + request += '&excludedQueryParameters='+excludedQueryParameters; + $.each(urls, function (key,value){ if(value.length>1) request+= '&urls[]='+value;} ); + request += '&token_auth=' + piwik.token_auth; + + ajaxRequest.data = request; + + return ajaxRequest; + } + + function getGlobalSettingsAJAX() + { + var ajaxRequest = piwikHelper.getStandardAjaxConf('ajaxLoadingGlobalSettings', 'ajaxErrorGlobalSettings'); + var timezone = encodeURIComponent($('#defaultTimezone option:selected').val()); + var currency = encodeURIComponent($('#defaultCurrency option:selected').val()); + var excludedIps = $('textarea#globalExcludedIps').val(); + excludedIps = getApiFormatTextarea(excludedIps); + var excludedQueryParameters = $('textarea#globalExcludedQueryParameters').val(); + excludedQueryParameters = getApiFormatTextarea(excludedQueryParameters); + var request = ''; + request += 'module=SitesManager'; + request += '&action=setGlobalSettings'; + request += '&format=json'; + request += '&timezone='+timezone; + request += '¤cy='+currency; + request += '&excludedIps='+excludedIps; + request += '&excludedQueryParameters='+excludedQueryParameters; + request += '&token_auth=' + piwik.token_auth; + ajaxRequest.data = request; + return ajaxRequest; + } -$(document).ready( function() { + this.init = function () { $('.addRowSite').click( function() { piwikHelper.hideAjaxError(); $(this).toggle(); @@ -136,8 +143,16 @@ $(document).ready( function() { </tr>') .appendTo('#editSites') ; - $('.addsite').click( function(){ $.ajax( getAddSiteAJAX($('tr#'+newRowId)) ); } ); - $('.cancel').click(function() { piwikHelper.hideAjaxError(); $(this).parents('tr').remove(); $('.addRowSite').toggle(); }); + + $('.addsite').click( function(){ + $.ajax( getAddSiteAJAX($('tr#'+newRowId)) ); + }); + + $('.cancel').click(function() { + piwikHelper.hideAjaxError(); + $(this).parents('tr').remove(); + $('.addRowSite').toggle(); + }); return false; } ); @@ -211,58 +226,58 @@ $(document).ready( function() { .prepend( $('<img src="plugins/UsersManager/images/ok.png" class="updateSite" title="' + _pk_translate('SitesManager_Save_js') + '" />') .click( function(){ $.ajax( getUpdateSiteAJAX( $('tr#'+idRow) ) ); } ) ); + }); + + $('#globalSettingsSubmit').click( function() { + $.ajax( getGlobalSettingsAJAX() ); + }); + + $('#defaultTimezone').html( getTimezoneSelector(defaultTimezone)); + $('#defaultCurrency').html( getCurrencySelector(defaultCurrency)); + + $('td.editableSite').click( function(){ $(this).parent().find('.editSite').click(); } ); + } + + function getTimezoneSelector(selectedTimezone) + { + var html = '<select id="timezones">'; + for(var continent in timezones) { + html += '<optgroup label="' + continent + '">'; + for(var timezoneId in timezones[continent]) { + var selected = ''; + if(timezoneId == selectedTimezone) { + selected = ' selected="selected" '; + } + html += '<option ' + selected + ' value="'+ timezoneId + '">' + timezones[continent][timezoneId] + '</option>'; + } + html += "</optgroup>\n"; } - ); + html += '</select>'; + return html; + } - $('#globalSettingsSubmit').click( function() { - $.ajax( getGlobalSettingsAJAX() ); - }); - - $('#defaultTimezone').html( getTimezoneSelector(defaultTimezone)); - $('#defaultCurrency').html( getCurrencySelector(defaultCurrency)); - $('td.editableSite').click( function(){ $(this).parent().find('.editSite').click(); } ); -}); - -function getTimezoneSelector(selectedTimezone) -{ - var html = '<select id="timezones">'; - for(var continent in timezones) { - html += '<optgroup label="' + continent + '">'; - for(var timezoneId in timezones[continent]) { + function getCurrencySelector(selectedCurrency) + { + var html = '<select id="currencies">'; + for(var currency in currencies) { var selected = ''; - if(timezoneId == selectedTimezone) { + if(currency == selectedCurrency) { selected = ' selected="selected" '; } - html += '<option ' + selected + ' value="'+ timezoneId + '">' + timezones[continent][timezoneId] + '</option>'; + html += '<option ' + selected + ' value="'+ currency + '">' + currencies[currency] + '</option>'; } - html += "</optgroup>\n"; + html += '</select>'; + return html; } - html += '</select>'; - return html; -} - - -function getCurrencySelector(selectedCurrency) -{ - var html = '<select id="currencies">'; - for(var currency in currencies) { - var selected = ''; - if(currency == selectedCurrency) { - selected = ' selected="selected" '; - } - html += '<option ' + selected + ' value="'+ currency + '">' + currencies[currency] + '</option>'; - } - html += '</select>'; - return html; -} - -function submitSiteOnEnter(e) -{ - var key=e.keyCode || e.which; - if (key==13) + + function submitSiteOnEnter(e) { - $(this).parent().find('.updateSite').click(); - $(this).find('.addsite').click(); + var key=e.keyCode || e.which; + if (key==13) + { + $(this).parent().find('.updateSite').click(); + $(this).find('.addsite').click(); + } } -} +}
\ No newline at end of file diff --git a/plugins/SitesManager/templates/SitesManager.tpl b/plugins/SitesManager/templates/SitesManager.tpl index b61a3eaea2..06854efab3 100644 --- a/plugins/SitesManager/templates/SitesManager.tpl +++ b/plugins/SitesManager/templates/SitesManager.tpl @@ -35,15 +35,15 @@ var excludedQueryParametersHelp = '{$excludedQueryParametersHelp|escape:javascri var timezoneHelp = '{$timezoneHelpPlain|inlineHelp|escape:javascript}'; var currencyHelp = '{$currencyHelpPlain|escape:javascript}'; {assign var=defaultTimezoneHelp value=$defaultTimezoneHelpPlain|inlineHelp}; -var timezones = {$timezones}; -var currencies = {$currencies}; -var defaultTimezone = '{$defaultTimezone}'; -var defaultCurrency = '{$defaultCurrency}'; -</script> -<script type="text/javascript" src="plugins/SitesManager/templates/SitesManager.js"></script> +var sitesManager = new SitesManager ( {$timezones}, {$currencies}, '{$defaultTimezone}', '{$defaultCurrency}'); {literal} +$(document).ready( function() { + sitesManager.init(); +}); +</script> + <style> .addRowSite:hover, .editableSite:hover, .addsite:hover, .cancel:hover, .deleteSite:hover, .editSite:hover, .updateSite:hover{ cursor: pointer; diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index f397b0a379..28809f2277 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -30,6 +30,7 @@ class Piwik_UserCountry extends Piwik_Plugin function getListHooksRegistered() { $hooks = array( + 'AssetManager.getJsFiles' => 'getJsFiles', 'ArchiveProcessing_Day.compute' => 'archiveDay', 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', @@ -39,6 +40,13 @@ class Piwik_UserCountry extends Piwik_Plugin return $hooks; } + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; + } + function addWidgets() { Piwik_AddWidget( 'General_Visitors', 'UserCountry_WidgetContinents', 'UserCountry', 'getContinent'); diff --git a/plugins/UserCountry/templates/index.tpl b/plugins/UserCountry/templates/index.tpl index da9b84f503..a8d33b5e85 100644 --- a/plugins/UserCountry/templates/index.tpl +++ b/plugins/UserCountry/templates/index.tpl @@ -1,7 +1,5 @@ {postEvent name="template_headerUserCountry"} -<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script> - <h2>{'UserCountry_Country'|translate}</h2> {$dataTableCountry} diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php index 5471a75658..7a98f41711 100644 --- a/plugins/UsersManager/UsersManager.php +++ b/plugins/UsersManager/UsersManager.php @@ -30,7 +30,18 @@ class Piwik_UsersManager extends Piwik_Plugin function getListHooksRegistered() { - return array('AdminMenu.add' => 'addMenu'); + return array( + 'AdminMenu.add' => 'addMenu', + 'AssetManager.getJsFiles' => 'getJsFiles' + ); + } + + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/UsersManager/templates/UsersManager.js"; + $jsFiles[] = "plugins/UsersManager/templates/userSettings.js"; } function addMenu() diff --git a/plugins/UsersManager/templates/UsersManager.tpl b/plugins/UsersManager/templates/UsersManager.tpl index ecd42dcd30..8f280a3372 100644 --- a/plugins/UsersManager/templates/UsersManager.tpl +++ b/plugins/UsersManager/templates/UsersManager.tpl @@ -38,7 +38,6 @@ } </style> {/literal} -<script type="text/javascript" src="plugins/UsersManager/templates/UsersManager.js"></script> <h2>{'UsersManager_ManageAccess'|translate}</h2> <p>{'UsersManager_MainDescription'|translate}</p> diff --git a/plugins/UsersManager/templates/userSettings.tpl b/plugins/UsersManager/templates/userSettings.tpl index c4b18b2cbd..887498a1bf 100644 --- a/plugins/UsersManager/templates/userSettings.tpl +++ b/plugins/UsersManager/templates/userSettings.tpl @@ -2,7 +2,6 @@ {assign var=showPeriodSelection value=false} {include file="CoreAdminHome/templates/header.tpl"} {loadJavascriptTranslations plugins='UsersManager'} -<script type="text/javascript" src="plugins/UsersManager/templates/userSettings.js"></script> <h2>{'UsersManager_MenuUserSettings'|translate}</h2> <br /> diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php index 5dcdfeb581..c9dc9b1c4b 100644 --- a/plugins/VisitFrequency/VisitFrequency.php +++ b/plugins/VisitFrequency/VisitFrequency.php @@ -30,6 +30,7 @@ class Piwik_VisitFrequency extends Piwik_Plugin function getListHooksRegistered() { $hooks = array( + 'AssetManager.getJsFiles' => 'getJsFiles', 'ArchiveProcessing_Day.compute' => 'archiveDay', 'ArchiveProcessing_Period.compute' => 'archivePeriod', 'WidgetsList.add' => 'addWidgets', @@ -38,6 +39,13 @@ class Piwik_VisitFrequency extends Piwik_Plugin return $hooks; } + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; + } + function addWidgets() { Piwik_AddWidget( 'General_Visitors', 'VisitFrequency_WidgetOverview', 'VisitFrequency', 'getSparklines'); diff --git a/plugins/VisitFrequency/templates/index.tpl b/plugins/VisitFrequency/templates/index.tpl index 1d7e483157..8e98139aa5 100644 --- a/plugins/VisitFrequency/templates/index.tpl +++ b/plugins/VisitFrequency/templates/index.tpl @@ -1,5 +1,4 @@ {postEvent name="template_headerVisitsFrequency"} -<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script> <a name="evolutionGraph" graphId="VisitFrequencygetEvolutionGraph"></a> <h2>{'VisitFrequency_ColumnReturningVisits'|translate}</h2> diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php index 77273376ea..de764738f8 100644 --- a/plugins/VisitsSummary/VisitsSummary.php +++ b/plugins/VisitsSummary/VisitsSummary.php @@ -30,11 +30,19 @@ class Piwik_VisitsSummary extends Piwik_Plugin function getListHooksRegistered() { return array( + 'AssetManager.getJsFiles' => 'getJsFiles', 'WidgetsList.add' => 'addWidgets', 'Menu.add' => 'addMenu', ); } + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "plugins/CoreHome/templates/sparkline.js"; + } + function addWidgets() { Piwik_AddWidget( 'VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetLastVisits', 'VisitsSummary', 'getEvolutionGraph', array('columns' => array('nb_visits'))); diff --git a/plugins/VisitsSummary/templates/index.tpl b/plugins/VisitsSummary/templates/index.tpl index 4cf972d9b5..6462978d9e 100644 --- a/plugins/VisitsSummary/templates/index.tpl +++ b/plugins/VisitsSummary/templates/index.tpl @@ -1,4 +1,3 @@ -<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script> <a name="evolutionGraph" graphId="VisitsSummarygetEvolutionGraph"></a> <h2>{'VisitsSummary_EvolutionOverLastPeriods'|translate:$periodsNames.$period.plural}</h2> diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php index 700c9885f7..d158c9ac23 100644 --- a/plugins/Widgetize/Controller.php +++ b/plugins/Widgetize/Controller.php @@ -63,6 +63,7 @@ class Piwik_Widgetize_Controller extends Piwik_Controller $parameters = array ( $fetch = true ); $outputDataTable = Piwik_FrontController::getInstance()->fetchDispatch( $controllerName, $actionName, $parameters); $view = Piwik_View::factory('iframe'); + $this->setGeneralVariablesView($view); $view->content = $outputDataTable; echo $view->render(); } diff --git a/plugins/Widgetize/Widgetize.php b/plugins/Widgetize/Widgetize.php index cfe98e3aa1..66ce97bce9 100644 --- a/plugins/Widgetize/Widgetize.php +++ b/plugins/Widgetize/Widgetize.php @@ -25,4 +25,36 @@ class Piwik_Widgetize extends Piwik_Plugin 'version' => Piwik_Version::VERSION, ); } + + public function getListHooksRegistered() + { + return array( + 'AssetManager.getJsFiles' => 'getJsFiles', + 'AssetManager.getCssFiles' => 'getCssFiles' + ); + } + + function getJsFiles( $notification ) + { + $jsFiles = &$notification->getNotificationObject(); + + $jsFiles[] = "libs/swfobject/swfobject.js"; + $jsFiles[] = "libs/jquery/jquery.tooltip.js"; + $jsFiles[] = "libs/jquery/jquery.truncate.js"; + $jsFiles[] = "libs/jquery/jquery.scrollTo.js"; + $jsFiles[] = "themes/default/common.js"; + $jsFiles[] = "plugins/CoreHome/templates/datatable.js"; + $jsFiles[] = "plugins/Dashboard/templates/widgetMenu.js"; + $jsFiles[] = "plugins/Widgetize/templates/widgetize.js"; + } + + function getCssFiles( $notification ) + { + $cssFiles = &$notification->getNotificationObject(); + + $cssFiles[] = "plugins/CoreHome/templates/styles.css"; + $cssFiles[] = "plugins/CoreHome/templates/datatable.css"; + $cssFiles[] = "plugins/CoreHome/templates/cloud.css"; + $cssFiles[] = "plugins/Dashboard/templates/dashboard.css"; + } } diff --git a/plugins/Widgetize/templates/index.tpl b/plugins/Widgetize/templates/index.tpl index 20b61cd5e2..5a3bd9e166 100644 --- a/plugins/Widgetize/templates/index.tpl +++ b/plugins/Widgetize/templates/index.tpl @@ -3,21 +3,6 @@ {include file="CoreHome/templates/header.tpl"} {loadJavascriptTranslations plugins='Dashboard'} -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/styles.css" /> -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/datatable.css" /> -<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/cloud.css" /> -<link rel="stylesheet" type="text/css" href="plugins/Dashboard/templates/dashboard.css" /> - -<script type="text/javascript" src="libs/swfobject/swfobject.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.tooltip.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.truncate.js"></script> -<script type="text/javascript" src="libs/jquery/jquery.scrollTo.js"></script> -<script type="text/javascript" src="themes/default/common.js"></script> -<script type="text/javascript" src="plugins/CoreHome/templates/datatable.js"></script> -<script type="text/javascript" src="plugins/Dashboard/templates/widgetMenu.js"></script> - -<script type="text/javascript" src="plugins/Widgetize/templates/widgetize.js"></script> - {literal} <style> .menu { |