Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea -...
16
 
-
 
17
/**
-
 
18
 * List the valid locations to search for a template with a given name.
-
 
19
 *
-
 
20
 * @package    core
-
 
21
 * @category   output
-
 
22
 * @copyright  2015 Damyon Wiese
-
 
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
24
 */
-
 
25
 
16
 
Línea 26... Línea 17...
26
namespace core\output;
17
namespace core\output;
27
 
18
 
28
use coding_exception;
19
use core\exception\coding_exception;
29
use moodle_exception;
-
 
Línea 30... Línea 20...
30
use core_component;
20
use core\exception\moodle_exception;
31
use theme_config;
21
use core_component;
32
 
22
 
33
/**
23
/**
34
 * Get information about valid locations for mustache templates.
24
 * Get information about valid locations for mustache templates.
35
 *
25
 *
-
 
26
 * @copyright  2015 Damyon Wiese
36
 * @copyright  2015 Damyon Wiese
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 * @since      2.9
38
 * @since      2.9
-
 
39
 */
29
 * @package core
40
class mustache_template_finder {
30
 */
41
 
31
class mustache_template_finder {
42
    /**
32
    /**
43
     * Helper function for getting a list of valid template directories for a specific component.
33
     * Helper function for getting a list of valid template directories for a specific component.
Línea 57... Línea 47...
57
        // Clean params for safety.
47
        // Clean params for safety.
58
        $component = clean_param($component, PARAM_COMPONENT);
48
        $component = clean_param($component, PARAM_COMPONENT);
59
        $themename = clean_param($themename, PARAM_COMPONENT);
49
        $themename = clean_param($themename, PARAM_COMPONENT);
Línea 60... Línea 50...
60
 
50
 
61
        // Validate the component.
51
        // Validate the component.
62
        $dirs = array();
52
        $dirs = [];
63
        $compdirectory = core_component::get_component_directory($component);
53
        $compdirectory = core_component::get_component_directory($component);
64
        if (!$compdirectory) {
54
        if (!$compdirectory) {
65
            throw new coding_exception("Component was not valid: " . s($component));
55
            throw new coding_exception("Component was not valid: " . s($component));
Línea 66... Línea 56...
66
        }
56
        }
67
 
57
 
68
        // Find the parent themes.
58
        // Find the parent themes.
69
        $parents = array();
59
        $parents = [];
70
        if ($themename === $PAGE->theme->name) {
60
        if ($themename === $PAGE->theme->name) {
71
            $parents = $PAGE->theme->parents;
61
            $parents = $PAGE->theme->parents;
72
        } else {
62
        } else {
Línea 106... Línea 96...
106
        if (strpos($name, '/') === false) {
96
        if (strpos($name, '/') === false) {
107
            throw new coding_exception('Templates names must be specified as "componentname/templatename"' .
97
            throw new coding_exception('Templates names must be specified as "componentname/templatename"' .
108
                                       ' (' . s($name) . ' requested) ');
98
                                       ' (' . s($name) . ' requested) ');
109
        }
99
        }
Línea 110... Línea 100...
110
 
100
 
111
        list($component, $templatename) = explode('/', $name, 2);
101
        [$component, $templatename] = explode('/', $name, 2);
Línea 112... Línea 102...
112
        $component = clean_param($component, PARAM_COMPONENT);
102
        $component = clean_param($component, PARAM_COMPONENT);
Línea 113... Línea 103...
113
 
103