| @@ -1,0 +1,85 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @package VikWP - Libraries | |
| 4 | + * @subpackage adapter.loader | |
| 5 | + * @author E4J s.r.l. | |
| 6 | + * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved. | |
| 7 | + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL | |
| 8 | + * @link https://vikwp.com | |
| 9 | + */ | |
| 10 | + | |
| 11 | +// No direct access | |
| 12 | +defined('ABSPATH') or die('No script kiddies please!'); | |
| 13 | + | |
| 14 | +// I hope JImport class is always loaded... | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Loads the specified file from the plugin libraries folder. | |
| 18 | + * Since multiple plugins may declare the same function, it is | |
| 19 | + * suggested to use it only to load files contained in the adapter folder. | |
| 20 | + * | |
| 21 | + * @param string $key The class name to look for (dot notation). | |
| 22 | + * | |
| 23 | + * @return boolean True on success, otherwise false. | |
| 24 | + * | |
| 25 | + * @since 10.0 | |
| 26 | + */ | |
| 27 | +if (!function_exists('jimport')) | |
| 28 | +{ | |
| 29 | + function jimport($key) | |
| 30 | + { | |
| 31 | + switch ($key) | |
| 32 | + { | |
| 33 | + case 'joomla.html.pagination': | |
| 34 | + $key = 'adapter.pagination.pagination'; | |
| 35 | + break; | |
| 36 | + | |
| 37 | + case 'joomla.application.component.view': | |
| 38 | + $key = 'adapter.mvc.view'; | |
| 39 | + break; | |
| 40 | + | |
| 41 | + case 'joomla.application.component.controller': | |
| 42 | + $key = 'adapter.mvc.controller'; | |
| 43 | + break; | |
| 44 | + | |
| 45 | + case 'joomla.application.component.controlleradmin': | |
| 46 | + $key = 'adapter.mvc.controllers.admin'; | |
| 47 | + break; | |
| 48 | + | |
| 49 | + case 'joomla.application.component.helper': | |
| 50 | + $key = 'adapter.component.helper'; | |
| 51 | + break; | |
| 52 | + | |
| 53 | + case 'joomla.application.module.helper': | |
| 54 | + $key = 'adapter.module.helper'; | |
| 55 | + break; | |
| 56 | + | |
| 57 | + case 'joomla.filesystem.file': | |
| 58 | + $key = 'adapter.filesystem.file'; | |
| 59 | + break; | |
| 60 | + | |
| 61 | + case 'joomla.form.formfield': | |
| 62 | + $key = 'adapter.form.field'; | |
| 63 | + break; | |
| 64 | + | |
| 65 | + case 'joomla.filesystem.archive': | |
| 66 | + $key = 'adapter.filesystem.archive'; | |
| 67 | + break; | |
| 68 | + | |
| 69 | + case 'joomla.filesystem.folder': | |
| 70 | + $key = 'adapter.filesystem.folder'; | |
| 71 | + break; | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * Route version when directly loaded. | |
| 75 | + * | |
| 76 | + * @since 10.1.26 | |
| 77 | + */ | |
| 78 | + case 'joomla.version': | |
| 79 | + $key = 'adapter.application.version'; | |
| 80 | + break; | |
| 81 | + } | |
| 82 | + | |
| 83 | + return JLoader::import($key); | |
| 84 | + } | |
| 85 | +} | |