Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 15... Línea 15...
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...
16
 
16
 
Línea 17... Línea 17...
17
namespace core\output;
17
namespace core\output;
18
 
-
 
19
use moodle_page;
-
 
Línea 20... Línea 18...
20
use renderer_base;
18
 
21
use url_select;
19
use moodle_page;
22
 
20
 
23
/**
21
/**
Línea 29... Línea 27...
29
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 * @since Moodle 4.0
28
 * @since Moodle 4.0
31
 * @package core
29
 * @package core
32
 * @category output
30
 * @category output
33
 */
31
 */
34
class activity_header implements \renderable, \templatable {
32
class activity_header implements renderable, templatable {
35
    /** @var moodle_page $page The current page we are looking at */
33
    /** @var moodle_page $page The current page we are looking at */
36
    protected $page;
34
    protected $page;
37
    /** @var string $title The title to be displayed in the header. Defaults to activityrecord name. */
35
    /** @var string $title The title to be displayed in the header. Defaults to activityrecord name. */
38
    protected $title;
36
    protected $title;
39
    /** @var string $description The description to be displayed. Defaults to activityrecord intro. */
37
    /** @var string $description The description to be displayed. Defaults to activityrecord intro. */
Línea 56... Línea 54...
56
     * @param \stdClass $user
54
     * @param \stdClass $user
57
     */
55
     */
58
    public function __construct(moodle_page $page, \stdClass $user) {
56
    public function __construct(moodle_page $page, \stdClass $user) {
59
        $this->page = $page;
57
        $this->page = $page;
60
        $this->user = $user;
58
        $this->user = $user;
61
        $pageoptions = $this->page->theme->activityheaderconfig ?? [];
-
 
62
        $layoutoptions = $this->page->layout_options['activityheader'] ?? [];
59
        $layoutoptions = $this->page->layout_options['activityheader'] ?? [];
63
        // Do a basic setup for the header based on theme/page options.
60
        // Do a basic setup for the header based on theme/page options.
64
        if ($page->activityrecord) {
61
        if ($page->activityrecord) {
65
            if (empty($pageoptions['notitle']) && empty($layoutoptions['notitle'])) {
62
            if ($this->is_title_allowed()) {
66
                $this->title = format_string($page->activityrecord->name);
63
                $this->title = format_string($page->activityrecord->name);
67
            }
64
            }
Línea -... Línea 65...
-
 
65
 
68
 
66
            if (
69
            if (empty($layoutoptions['nodescription']) && !empty($page->activityrecord->intro) &&
67
                empty($layoutoptions['nodescription']) && !empty($page->activityrecord->intro) &&
-
 
68
                    trim($page->activityrecord->intro)
70
                    trim($page->activityrecord->intro)) {
69
            ) {
71
                $this->description = format_module_intro($this->page->activityname, $page->activityrecord, $page->cm->id);
70
                $this->description = format_module_intro($this->page->activityname, $page->activityrecord, $page->cm->id);
72
            }
71
            }
73
        }
72
        }
74
        $this->hidecompletion = !empty($layoutoptions['nocompletion']);
73
        $this->hidecompletion = !empty($layoutoptions['nocompletion']);
Línea 77... Línea 76...
77
    }
76
    }
Línea 78... Línea 77...
78
 
77
 
79
    /**
78
    /**
80
     * Checks if the theme has specified titles to be displayed.
79
     * Checks if the theme has specified titles to be displayed.
-
 
80
     *
-
 
81
     * First checks if the current layout has the notitle option set. If it is, uses that option to decide whether the title is
-
 
82
     * displayed. If not, then checks whether the theme has the notitle option set and uses that. If neither is set, the title
-
 
83
     * is allowed by default.
81
     *
84
     *
82
     * @return bool
85
     * @return bool
83
     */
86
     */
-
 
87
    public function is_title_allowed(): bool {
84
    public function is_title_allowed(): bool {
88
        $layoutoptions = $this->page->layout_options['activityheader'] ?? [];
-
 
89
        $themeoptions = $this->page->theme->activityheaderconfig;
-
 
90
        if (isset($layoutoptions['notitle'])) {
-
 
91
            return !$layoutoptions['notitle'];
-
 
92
        } else if (isset($themeoptions['notitle'])) {
-
 
93
            return !$themeoptions['notitle'];
-
 
94
        } else {
-
 
95
            return true;
85
        return empty($this->page->theme->activityheaderconfig['notitle']);
96
        }
Línea 86... Línea 97...
86
    }
97
    }
87
 
98
 
88
    /**
99
    /**
Línea 195... Línea 206...
195
                'core_courseformat/local/content/activity_header',
206
                'core_courseformat/local/content/activity_header',
196
                'init'
207
                'init'
197
            );
208
            );
198
        }
209
        }
Línea -... Línea 210...
-
 
210
 
-
 
211
        $additionalitems = '';
-
 
212
        if (!$this->hideoverflow && !is_null($this->additionalnavitems)) {
-
 
213
            $additionalitems = $this->additionalnavitems->export_for_template($output);
-
 
214
        }
199
 
215
 
200
        return [
216
        return [
201
            'title' => $this->title,
217
            'title' => $this->title,
202
            'description' => $this->description,
218
            'description' => $this->description,
203
            'completion' => $activityinfo,
219
            'completion' => $activityinfo,
204
            'additional_items' => $this->hideoverflow ? '' : $this->additionalnavitems,
220
            'additional_items' => $additionalitems,
205
        ];
221
        ];
Línea 206... Línea 222...
206
    }
222
    }
207
 
223