See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
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 * Test factory for lib/outputfactories.php. 19 * 20 * @package core 21 * @category phpunit 22 * @copyright 2014 Damyon Wiese 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 global $CFG; 29 require_once($CFG->libdir . '/outputfactories.php'); 30 31 /** 32 * This is renderer factory testing of the classname autoloading. 33 * 34 * @copyright 2014 Damyon Wiese 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 * @package core 37 * @category phpunit 38 */ 39 class test_output_factory extends renderer_factory_base { 40 41 /** 42 * Constructor. 43 * 44 */ 45 public function __construct() { 46 $this->prefixes = array('theme_child', 'theme_parent'); 47 } 48 49 /** 50 * Not used - we want to test the autoloaded class locations - even if there are no classes yet. 51 */ 52 public function get_renderer(moodle_page $page, $component, $subtype = null, $target = null) { 53 throw new coding_exception('Do not call this function, this class is for testing only.'); 54 } 55 56 /* 57 * Return the list of classnames searched for by the standard_renderer_factory. 58 * 59 * @param string $component name such as 'core', 'mod_forum' or 'qtype_multichoice'. 60 * @param string $subtype optional subtype such as 'news' resulting to 'mod_forum_news' 61 * @param string $target one of rendering target constants 62 * @return string[] of classnames 63 */ 64 public function get_standard_renderer_factory_search_paths($component, $subtype = null, $target = null) { 65 $classnames = $this->standard_renderer_classnames($component, $subtype); 66 $searchtargets = array(); 67 68 list($target, $suffix) = $this->get_target_suffix($target); 69 // Add all suffix versions first - to match the real search order. 70 foreach ($classnames as $classnamedetails) { 71 if ($classnamedetails['validwithoutprefix']) { 72 $newclassname = $classnamedetails['classname'] . $suffix; 73 $searchtargets[] = $newclassname; 74 } 75 } 76 // Add all non-suffixed versions now. 77 foreach ($classnames as $classnamedetails) { 78 if ($classnamedetails['validwithoutprefix']) { 79 $newclassname = $classnamedetails['classname']; 80 $searchtargets[] = $newclassname; 81 } 82 } 83 84 return $searchtargets; 85 } 86 87 /** 88 * Return the list of classnames searched for by the get_renderer method of theme_overridden_renderer. 89 * 90 * @param string $component name such as 'core', 'mod_forum' or 'qtype_multichoice'. 91 * @param string $subtype optional subtype such as 'news' resulting to 'mod_forum_news' 92 * @param string $target one of rendering target constants 93 * @return string[] of classnames 94 */ 95 public function get_theme_overridden_renderer_factory_search_paths($component, $subtype = null, $target = null) { 96 $searchtargets = array(); 97 $classnames = $this->standard_renderer_classnames($component, $subtype); 98 99 list($target, $suffix) = $this->get_target_suffix($target); 100 101 // Theme lib.php and renderers.php files are loaded automatically 102 // when loading the theme configs. 103 104 // First try the renderers with correct suffix. 105 foreach ($this->prefixes as $prefix) { 106 foreach ($classnames as $classnamedetails) { 107 if ($classnamedetails['validwithprefix']) { 108 if ($classnamedetails['autoloaded']) { 109 $newclassname = $prefix . $classnamedetails['classname'] . $suffix; 110 } else { 111 $newclassname = $prefix . '_' . $classnamedetails['classname'] . $suffix; 112 } 113 $searchtargets[] = $newclassname; 114 } 115 } 116 } 117 foreach ($classnames as $classnamedetails) { 118 if ($classnamedetails['validwithoutprefix']) { 119 $newclassname = $classnamedetails['classname'] . $suffix; 120 $searchtargets[] = $newclassname; 121 } 122 } 123 124 // Then try general renderer. 125 foreach ($this->prefixes as $prefix) { 126 foreach ($classnames as $classnamedetails) { 127 if ($classnamedetails['validwithprefix']) { 128 if ($classnamedetails['autoloaded']) { 129 $newclassname = $prefix . $classnamedetails['classname']; 130 } else { 131 $newclassname = $prefix . '_' . $classnamedetails['classname']; 132 } 133 $searchtargets[] = $newclassname; 134 } 135 } 136 } 137 138 // Final attempt - no prefix or suffix. 139 foreach ($classnames as $classnamedetails) { 140 if ($classnamedetails['validwithoutprefix']) { 141 $newclassname = $classnamedetails['classname']; 142 $searchtargets[] = $newclassname; 143 } 144 } 145 return $searchtargets; 146 } 147 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body