forked from brendanheywood/moodle-local_cleanurls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.patch
85 lines (75 loc) · 2.97 KB
/
core.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From ccf27824e19fd906b35df333f2b21f08efc57700 Mon Sep 17 00:00:00 2001
From: Brendan Heywood <brendan@catalyst-au.net>
Date: Mon, 12 Oct 2015 22:48:44 +1100
Subject: [PATCH 1/2] MDL-28030 themes: Add pre_head_content hook
---
lib/outputrenderers.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php
index a42d377..3a8f1ab 100644
--- a/lib/outputrenderers.php
+++ b/lib/outputrenderers.php
@@ -475,6 +475,15 @@ class core_renderer extends renderer_base {
}
$output = '';
+
+ // Give plugins a hook to add dynamic head
+ $pluginswithfunction = get_plugins_with_function('pre_head_content', 'lib.php');
+ foreach ($pluginswithfunction as $plugins) {
+ foreach ($plugins as $function) {
+ $output .= $function();
+ }
+ }
+
$output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
$output .= '<meta name="keywords" content="moodle, ' . $this->page->title . '" />' . "\n";
// This is only set by the {@link redirect()} method
--
1.7.9.5
From ecd4aa80b1786bf9817f301bfb6106df0e4c981b Mon Sep 17 00:00:00 2001
From: Brendan Heywood <brendan@catalyst-au.net>
Date: Mon, 12 Oct 2015 22:49:25 +1100
Subject: [PATCH 2/2] MDL-28030 weblib: Add url_rewrite hook
---
lib/weblib.php | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/lib/weblib.php b/lib/weblib.php
index 81b075d..6c35408 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -557,6 +557,35 @@ class moodle_url {
debugging('Escape parameter must be of type boolean, '.gettype($escaped).' given instead.');
}
+ // Give plugins an opportunity to rewrite the url.
+ $url = $this;
+ $pluginswithfunction = get_plugins_with_function('url_rewrite', 'lib.php');
+ foreach ($pluginswithfunction as $plugins) {
+ foreach ($plugins as $function) {
+ if (($pluginurl = $function($url)) && ($pluginurl instanceof moodle_url)) {
+ $url = $pluginurl;
+ }
+ }
+ }
+
+ return $url->raw_out($escaped, $overrideparams);
+
+ }
+
+ /**
+ * Output url without any rewrites
+ *
+ * This is identical in signature and use to out() but doesn't call the rewrite hook.
+ *
+ * @param bool $escaped Use & as params separator instead of plain &
+ * @param array $overrideparams params to add to the output url, these override existing ones with the same name.
+ * @return string Resulting URL
+ */
+ public function raw_out($escaped = true, array $overrideparams = null) {
+ if (!is_bool($escaped)) {
+ debugging('Escape parameter must be of type boolean, '.gettype($escaped).' given instead.');
+ }
+
$uri = $this->out_omit_querystring().$this->slashargument;
$querystring = $this->get_query_string($escaped, $overrideparams);
--
1.7.9.5