mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
MDL-70207 core_navigation: Initial backend for primary navigation
This commit is contained in:
parent
f0eb6a5729
commit
f8f83eae0e
67
lib/classes/navigation/views/primary.php
Normal file
67
lib/classes/navigation/views/primary.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core\navigation\views;
|
||||
|
||||
/**
|
||||
* Class primary.
|
||||
*
|
||||
* The primary navigation view is a combination of few components - navigation, output->navbar,
|
||||
*
|
||||
* @package core
|
||||
* @category navigation
|
||||
* @copyright 2021 onwards Peter Dias
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class primary extends view {
|
||||
/**
|
||||
* Initialise the primary navigation node
|
||||
*/
|
||||
public function initialise(): void {
|
||||
if (during_initial_install() || $this->initialised) {
|
||||
return;
|
||||
}
|
||||
$this->id = 'primary_navigation';
|
||||
$this->add(get_string('home'), new \moodle_url('/'), self::TYPE_SYSTEM,
|
||||
null, 'home', new \pix_icon('i/home', ''));
|
||||
|
||||
// Add the dashboard link.
|
||||
if (isloggedin() && !isguestuser()) { // Makes no sense if you aren't logged in.
|
||||
$this->rootnodes['home'] = $this->add(get_string('myhome'), new \moodle_url('/my/'),
|
||||
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
|
||||
}
|
||||
|
||||
// Add a dummy mycourse link to a mycourses page.
|
||||
$this->add(get_string('mycourses'), new \moodle_url('/course/index.php'), self::TYPE_ROOTNODE, null, 'courses');
|
||||
|
||||
// Add the site admin node. We are using the settingsnav so as to avoid rechecking permissions again.
|
||||
$settingsnav = $this->page->settingsnav;
|
||||
$node = $settingsnav->find('siteadministration', self::TYPE_SITE_ADMIN);
|
||||
if (!$node) {
|
||||
// Try again. This node can exist with 2 different keys.
|
||||
$node = $settingsnav->find('root', self::TYPE_SITE_ADMIN);
|
||||
}
|
||||
|
||||
if ($node) {
|
||||
// We don't need everything from the node just the initial link.
|
||||
$this->add($node->text, $node->action(), self::TYPE_SITE_ADMIN, null, 'siteadminnode', $node->icon);
|
||||
}
|
||||
|
||||
// Search and set the active node.
|
||||
$this->search_for_active_node();
|
||||
$this->initialised = true;
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
use core\navigation\views\primary;
|
||||
use core\navigation\views\secondary;
|
||||
|
||||
/**
|
||||
@ -82,6 +83,7 @@ use core\navigation\views\secondary;
|
||||
* @property-read navbar $navbar The navbar object used to display the navbar
|
||||
* @property-read secondary $secondarynav The secondary navigation object
|
||||
* used to display the secondarynav in boost
|
||||
* @property-read primary $primarynav The primary navigation object used to display the primary nav in boost
|
||||
* @property-read global_navigation $navigation The navigation structure for this page.
|
||||
* @property-read xhtml_container_stack $opencontainers Tracks XHTML tags on this page that have been opened but not closed.
|
||||
* mainly for internal use by the rendering code.
|
||||
@ -303,6 +305,12 @@ class moodle_page {
|
||||
*/
|
||||
protected $_secondarynav = null;
|
||||
|
||||
/**
|
||||
* @var primary Contains the nav nodes that will appear
|
||||
* in the primary navigation.
|
||||
*/
|
||||
protected $_primarynav = null;
|
||||
|
||||
/**
|
||||
* @var navbar Contains the navbar structure.
|
||||
*/
|
||||
@ -804,6 +812,18 @@ class moodle_page {
|
||||
return $this->_secondarynav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary navigation object
|
||||
* @return primary
|
||||
*/
|
||||
protected function magic_get_primarynav() {
|
||||
if ($this->_primarynav === null) {
|
||||
$this->_primarynav = new primary($this);
|
||||
$this->_primarynav->initialise();
|
||||
}
|
||||
return $this->_primarynav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns request IP address.
|
||||
*
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2021052500.73; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2021052500.74; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.0dev (Build: 20210330)'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user