Proyectos de Subversion Moodle

Rev

Rev 1 | Rev 1468 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 23... Línea 23...
23
 * @category page
23
 * @category page
24
 * @copyright  1999 onwards Martin Dougiamas  {@link http://moodle.com}
24
 * @copyright  1999 onwards Martin Dougiamas  {@link http://moodle.com}
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
26
 */
Línea 27... Línea 27...
27
 
27
 
28
defined('MOODLE_INTERNAL') || die();
-
 
29
 
28
use core\exception\moodle_exception;
30
use core\navigation\views\primary;
29
use core\navigation\views\primary;
31
use core\navigation\views\secondary;
30
use core\navigation\views\secondary;
32
use core\navigation\output\primary as primaryoutput;
31
use core\navigation\output\primary as primaryoutput;
-
 
32
use core\output\activity_header;
Línea 33... Línea 33...
33
use core\output\activity_header;
33
use core\output\xhtml_container_stack;
34
 
34
 
35
/**
35
/**
36
 * $PAGE is a central store of information about the current page we are
36
 * $PAGE is a central store of information about the current page we are
Línea 614... Línea 614...
614
     * Please do not call this method directly, use the ->layout_options syntax. {@link moodle_page::__get()}.
614
     * Please do not call this method directly, use the ->layout_options syntax. {@link moodle_page::__get()}.
615
     * @return array returns arrays with options for layout file
615
     * @return array returns arrays with options for layout file
616
     */
616
     */
617
    protected function magic_get_layout_options() {
617
    protected function magic_get_layout_options() {
618
        if (!is_array($this->_layout_options)) {
618
        if (!is_array($this->_layout_options)) {
619
            $this->_layout_options = $this->_theme->pagelayout_options($this->pagelayout);
619
            $this->_layout_options = $this->theme->pagelayout_options($this->pagelayout);
620
        }
620
        }
621
        return $this->_layout_options;
621
        return $this->_layout_options;
622
    }
622
    }
Línea 623... Línea 623...
623
 
623
 
Línea 876... Línea 876...
876
    }
876
    }
Línea 877... Línea 877...
877
 
877
 
878
    /**
878
    /**
879
     * Returns the secondary navigation object
879
     * Returns the secondary navigation object
880
     *
-
 
881
     * @todo MDL-74939 Remove support for old 'local\views\secondary' class location
880
     *
882
     * @return secondary
881
     * @return secondary
883
     */
882
     */
884
    protected function magic_get_secondarynav() {
883
    protected function magic_get_secondarynav() {
885
        if ($this->_secondarynav === null) {
884
        if ($this->_secondarynav === null) {
-
 
885
            $class = 'core\navigation\views\secondary';
886
            $class = 'core\navigation\views\secondary';
886
 
887
            // Try and load a custom class first.
887
            // Check whether activity defines its own secondary navigation.
888
            if (class_exists("mod_{$this->activityname}\\navigation\\views\\secondary")) {
888
            if (class_exists("mod_{$this->activityname}\\navigation\\views\\secondary")) {
889
                $class = "mod_{$this->activityname}\\navigation\\views\\secondary";
-
 
890
            } else if (class_exists("mod_{$this->activityname}\\local\\views\\secondary")) {
-
 
891
                // For backwards compatibility, support the old location for this class (it was in a
-
 
892
                // 'local' namespace which shouldn't be used for core APIs).
-
 
893
                debugging("The class mod_{$this->activityname}}\\local\\views\\secondary uses a deprecated " .
-
 
894
                        "namespace. Please move it to mod_{$this->activityname}\\navigation\\views\\secondary.",
-
 
895
                        DEBUG_DEVELOPER);
-
 
896
                $class = "mod_{$this->activityname}\\local\\views\\secondary";
889
                $class = "mod_{$this->activityname}\\navigation\\views\\secondary";
Línea 897... Línea 890...
897
            }
890
            }
898
 
891
 
899
            $this->_secondarynav = new $class($this);
892
            $this->_secondarynav = new $class($this);
Línea 1032... Línea 1025...
1032
     * Switches from the regular requirements manager to the fragment requirements manager to
1025
     * Switches from the regular requirements manager to the fragment requirements manager to
1033
     * capture all necessary JavaScript to display a chunk of HTML such as an mform. This is for use
1026
     * capture all necessary JavaScript to display a chunk of HTML such as an mform. This is for use
1034
     * by the get_fragment() web service and not for use elsewhere.
1027
     * by the get_fragment() web service and not for use elsewhere.
1035
     */
1028
     */
1036
    public function start_collecting_javascript_requirements() {
1029
    public function start_collecting_javascript_requirements() {
1037
        global $CFG;
-
 
1038
        require_once($CFG->libdir.'/outputfragmentrequirementslib.php');
-
 
1039
 
-
 
1040
        // Check that the requirements manager has not already been switched.
1030
        // Check that the requirements manager has not already been switched.
1041
        if (get_class($this->_requires) == 'fragment_requirements_manager') {
1031
        if (get_class($this->_requires) == 'fragment_requirements_manager') {
1042
            throw new coding_exception('JavaScript collection has already been started.');
1032
            throw new coding_exception('JavaScript collection has already been started.');
1043
        }
1033
        }
1044
        // The header needs to have been called to flush out the generic JavaScript for the page. This allows only
1034
        // The header needs to have been called to flush out the generic JavaScript for the page. This allows only
Línea 1104... Línea 1094...
1104
        }
1094
        }
1105
        $summary .= 'Page type ' . $this->pagetype .  '. ';
1095
        $summary .= 'Page type ' . $this->pagetype .  '. ';
1106
        if ($this->subpage) {
1096
        if ($this->subpage) {
1107
            $summary .= 'Sub-page ' . $this->subpage .  '. ';
1097
            $summary .= 'Sub-page ' . $this->subpage .  '. ';
1108
        }
1098
        }
-
 
1099
 
-
 
1100
        // Display deprecated icons in the console (if any).
-
 
1101
        $summary .= <<< EOF
-
 
1102
            <script type="text/javascript">
-
 
1103
            //<![CDATA[
-
 
1104
            document.querySelectorAll('.icon.deprecated').forEach((icon) => {
-
 
1105
                window.console.warn("Deprecated icon found: " + icon.className);
-
 
1106
            });
-
 
1107
            //]]>
-
 
1108
            </script>
-
 
1109
        EOF;
-
 
1110
 
1109
        return $summary;
1111
        return $summary;
1110
    }
1112
    }
Línea 1111... Línea 1113...
1111
 
1113
 
Línea 1491... Línea 1493...
1491
     *
1493
     *
1492
     * @param moodle_url|string $url URL relative to $CFG->wwwroot or {@link moodle_url} instance
1494
     * @param moodle_url|string $url URL relative to $CFG->wwwroot or {@link moodle_url} instance
1493
     * @param array $params parameters to add to the URL
1495
     * @param array $params parameters to add to the URL
1494
     * @throws coding_exception
1496
     * @throws coding_exception
1495
     */
1497
     */
1496
    public function set_url($url, array $params = null) {
1498
    public function set_url($url, ?array $params = null) {
1497
        global $CFG;
1499
        global $CFG;
Línea 1498... Línea 1500...
1498
 
1500
 
1499
        if (is_string($url) && strpos($url, 'http') !== 0) {
1501
        if (is_string($url) && strpos($url, 'http') !== 0) {
1500
            if (strpos($url, '/') === 0) {
1502
            if (strpos($url, '/') === 0) {
Línea 1666... Línea 1668...
1666
    public function force_lock_all_blocks(): void {
1668
    public function force_lock_all_blocks(): void {
1667
        $this->_forcelockallblocks = true;
1669
        $this->_forcelockallblocks = true;
1668
    }
1670
    }
Línea 1669... Línea 1671...
1669
 
1671
 
1670
    /**
-
 
1671
     * @deprecated since Moodle 3.4
-
 
1672
     */
-
 
1673
    public function https_required() {
-
 
1674
        throw new coding_exception('https_required() cannot be used anymore.');
-
 
1675
    }
-
 
1676
 
-
 
1677
    /**
-
 
1678
     * @deprecated since Moodle 3.4
-
 
1679
     */
-
 
1680
    public function verify_https_required() {
-
 
1681
        throw new coding_exception('verify_https_required() cannot be used anymore.');
-
 
1682
    }
-
 
1683
 
-
 
1684
    /**
1672
    /**
1685
     * Allows to 'serialize' the edited page information and store it in the session cache
1673
     * Allows to 'serialize' the edited page information and store it in the session cache
1686
     *
1674
     *
1687
     * Due to Moodle architectural decision and non-SPA approach, a lot of page setup is
1675
     * Due to Moodle architectural decision and non-SPA approach, a lot of page setup is
1688
     * happening in the actual page php file, for example, setting course/cm/context,
1676
     * happening in the actual page php file, for example, setting course/cm/context,
Línea 2176... Línea 2164...
2176
     */
2164
     */
2177
    protected function load_category($categoryid) {
2165
    protected function load_category($categoryid) {
2178
        global $DB;
2166
        global $DB;
2179
        $category = $DB->get_record('course_categories', array('id' => $categoryid));
2167
        $category = $DB->get_record('course_categories', array('id' => $categoryid));
2180
        if (!$category) {
2168
        if (!$category) {
2181
            throw new moodle_exception('unknowncategory');
2169
            throw new moodle_exception('unknowncategory', a: $categoryid);
2182
        }
2170
        }
2183
        $this->_categories[$category->id] = $category;
2171
        $this->_categories[$category->id] = $category;
2184
        $parentcategoryids = explode('/', trim($category->path, '/'));
2172
        $parentcategoryids = explode('/', trim($category->path, '/'));
2185
        array_pop($parentcategoryids);
2173
        array_pop($parentcategoryids);
2186
        foreach (array_reverse($parentcategoryids) as $catid) {
2174
        foreach (array_reverse($parentcategoryids) as $catid) {