[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 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/>. 16 17 /** 18 * Mustache helper to load strings from string_manager. 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 26 namespace core\output; 27 28 use external_api; 29 use external_function_parameters; 30 use external_value; 31 use core_component; 32 use moodle_exception; 33 use context_system; 34 use theme_config; 35 36 /** 37 * This class contains a list of webservice functions related to output. 38 * 39 * @copyright 2015 Damyon Wiese 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 * @since 2.9 42 */ 43 class external extends external_api { 44 /** 45 * Returns description of load_template() parameters. 46 * 47 * @return external_function_parameters 48 */ 49 public static function load_template_parameters() { 50 return new external_function_parameters( 51 array('component' => new external_value(PARAM_COMPONENT, 'component containing the template'), 52 'template' => new external_value(PARAM_ALPHANUMEXT, 'name of the template'), 53 'themename' => new external_value(PARAM_ALPHANUMEXT, 'The current theme.'), 54 ) 55 ); 56 } 57 58 /** 59 * Return a mustache template, and all the strings it requires. 60 * 61 * @param string $component The component that holds the template. 62 * @param string $templatename The name of the template. 63 * @param string $themename The name of the current theme. 64 * @return string the template 65 */ 66 public static function load_template($component, $template, $themename) { 67 global $DB, $CFG, $PAGE; 68 69 $params = self::validate_parameters(self::load_template_parameters(), 70 array('component' => $component, 71 'template' => $template, 72 'themename' => $themename)); 73 74 $component = $params['component']; 75 $template = $params['template']; 76 $themename = $params['themename']; 77 78 $templatename = $component . '/' . $template; 79 80 // Will throw exceptions if the template does not exist. 81 $filename = mustache_template_finder::get_template_filepath($templatename, $themename); 82 $templatestr = file_get_contents($filename); 83 84 return $templatestr; 85 } 86 87 /** 88 * Returns description of load_template() result value. 89 * 90 * @return external_description 91 */ 92 public static function load_template_returns() { 93 return new external_value(PARAM_RAW, 'template'); 94 } 95 } 96
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |