Chunk.php
3 months ago
JScriptUIAssetFetcher.php
2 years ago
PluginUmdAssetFetcher.php
2 months ago
StaticUIAssetFetcher.php
2 years ago
StylesheetUIAssetFetcher.php
2 years ago
JScriptUIAssetFetcher.php
90 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\AssetManager\UIAssetFetcher; |
| 10 | |
| 11 | use Piwik\AssetManager\UIAssetFetcher; |
| 12 | use Piwik\Piwik; |
| 13 | class JScriptUIAssetFetcher extends UIAssetFetcher |
| 14 | { |
| 15 | protected function retrieveFileLocations() |
| 16 | { |
| 17 | if (!empty($this->plugins)) { |
| 18 | /** |
| 19 | * Triggered when gathering the list of all JavaScript files needed by Piwik |
| 20 | * and its plugins. |
| 21 | * |
| 22 | * Plugins that have their own JavaScript should use this event to make those |
| 23 | * files load in the browser. |
| 24 | * |
| 25 | * JavaScript files should be placed within a **javascripts** subdirectory in your |
| 26 | * plugin's root directory. |
| 27 | * |
| 28 | * _Note: While you are developing your plugin you should enable the config setting |
| 29 | * `[Development] disable_merged_assets` so JavaScript files will be reloaded immediately |
| 30 | * after every change._ |
| 31 | * |
| 32 | * **Example** |
| 33 | * |
| 34 | * public function getJsFiles(&$jsFiles) |
| 35 | * { |
| 36 | * $jsFiles[] = "plugins/MyPlugin/javascripts/myfile.js"; |
| 37 | * $jsFiles[] = "plugins/MyPlugin/javascripts/anotherone.js"; |
| 38 | * } |
| 39 | * |
| 40 | * @param string[] $jsFiles The JavaScript files to load. |
| 41 | */ |
| 42 | Piwik::postEvent('AssetManager.getJavaScriptFiles', array(&$this->fileLocations), null, $this->plugins); |
| 43 | } |
| 44 | $this->addThemeFiles(); |
| 45 | $this->mapBowerComponentFilesForBC($this->fileLocations); |
| 46 | } |
| 47 | protected function addThemeFiles() |
| 48 | { |
| 49 | $theme = $this->getTheme(); |
| 50 | if (!$theme) { |
| 51 | return; |
| 52 | } |
| 53 | if (in_array($theme->getThemeName(), $this->plugins)) { |
| 54 | $jsInThemes = $this->getTheme()->getJavaScriptFiles(); |
| 55 | if (!empty($jsInThemes)) { |
| 56 | foreach ($jsInThemes as $jsFile) { |
| 57 | $this->fileLocations[] = $jsFile; |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | protected function getPriorityOrder() |
| 63 | { |
| 64 | return array( |
| 65 | 'node_modules/jquery/dist/jquery.min.js', |
| 66 | 'node_modules/jquery/dist/jquery.js', |
| 67 | 'node_modules/@materializecss/materialize/dist/js/materialize.min.js', |
| 68 | // so jquery ui datepicker overrides materializecss |
| 69 | 'node_modules/jquery-ui-dist/jquery-ui.min.js', |
| 70 | 'node_modules/jquery-ui-dist/jquery-ui.js', |
| 71 | "plugins/CoreHome/javascripts/materialize-bc.js", |
| 72 | 'node_modules/', |
| 73 | 'libs/', |
| 74 | 'js/', |
| 75 | 'plugins/CoreVue/polyfills/dist/MatomoPolyfills', |
| 76 | 'piwik.js', |
| 77 | 'matomo.js', |
| 78 | 'plugins/CoreHome/javascripts/require.js', |
| 79 | 'plugins/Morpheus/javascripts/piwikHelper.js', |
| 80 | 'plugins/Morpheus/javascripts/', |
| 81 | 'plugins/CoreHome/javascripts/uiControl.js', |
| 82 | 'plugins/CoreHome/javascripts/broadcast.js', |
| 83 | 'plugins/CoreHome/javascripts/', |
| 84 | // load CoreHome JS before other plugins |
| 85 | 'plugins/', |
| 86 | 'tests/', |
| 87 | ); |
| 88 | } |
| 89 | } |
| 90 |