43 |
43 |
44 $page = new PageProcessor($page_id, $namespace); |
44 $page = new PageProcessor($page_id, $namespace); |
45 $text = $page->fetch_text(); |
45 $text = $page->fetch_text(); |
46 |
46 |
47 if ( !$render ) |
47 if ( !$render ) |
|
48 { |
|
49 $code = $plugins->setHook('render_getpage_norender'); |
|
50 foreach ( $code as $cmd ) |
|
51 { |
|
52 eval($cmd); |
|
53 } |
48 return $text; |
54 return $text; |
|
55 } |
49 |
56 |
50 $text = self::render($text, $wiki, $smilies, $filter_links); |
57 $text = self::render($text, $wiki, $smilies, $filter_links); |
51 return $text; |
58 return $text; |
52 } |
59 } |
53 |
60 |
54 public static function getTemplate($id, $parms) |
61 public static function getTemplate($id, $parms) |
55 { |
62 { |
56 global $db, $session, $paths, $template, $plugins; // Common objects |
63 global $db, $session, $paths, $template, $plugins; // Common objects |
|
64 |
|
65 // Verify target exists -- if not, double-bracket it to convert it to a redlink |
57 if ( !isPage($paths->get_pathskey($id, 'Template')) ) |
66 if ( !isPage($paths->get_pathskey($id, 'Template')) ) |
58 { |
67 { |
59 return '[['.$paths->nslist['Template'].$id.']]'; |
68 return '[['.$paths->nslist['Template'].$id.']]'; |
60 } |
69 } |
|
70 |
|
71 // fetch from DB or template cache |
61 if(isset($paths->template_cache[$id])) |
72 if(isset($paths->template_cache[$id])) |
62 { |
73 { |
63 $text = $paths->template_cache[$id]; |
74 $text = $paths->template_cache[$id]; |
64 } |
75 } |
65 else |
76 else |
67 $page = new PageProcessor($id, 'Template'); |
78 $page = new PageProcessor($id, 'Template'); |
68 $text = $page->fetch_text(); |
79 $text = $page->fetch_text(); |
69 $paths->template_cache[$id] = $text; |
80 $paths->template_cache[$id] = $text; |
70 } |
81 } |
71 |
82 |
|
83 // noinclude is not shown within the included template, only on the template's page when you load it |
|
84 // nodisplay is not shown on the template's page, only in the included template |
72 $text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '', $text); |
85 $text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '', $text); |
73 $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '\\1', $text); |
86 $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '\\1', $text); |
74 |
87 |
75 preg_match_all('#\(_([0-9]+)_\)#', $text, $matchlist); |
88 preg_match_all('#\(_([0-9]+)_\)#', $text, $matchlist); |
76 |
89 |
89 } |
102 } |
90 $text = RenderMan::include_templates($text); |
103 $text = RenderMan::include_templates($text); |
91 return $text; |
104 return $text; |
92 } |
105 } |
93 |
106 |
94 public static function fetch_template_text($id) |
107 public static function fetch_template_text($id, $params) |
95 { |
108 { |
96 global $db, $session, $paths, $template, $plugins; // Common objects |
109 global $db, $session, $paths, $template, $plugins; // Common objects |
97 $fetch_ns = 'Template'; |
110 $fetch_ns = 'Template'; |
98 if ( !isPage($paths->get_pathskey($id, 'Template')) ) |
111 if ( !isPage($paths->get_pathskey($id, 'Template')) ) |
99 { |
112 { |
129 else |
142 else |
130 { |
143 { |
131 return '[['.$paths->nslist['Template'].$id.']]'; |
144 return '[['.$paths->nslist['Template'].$id.']]'; |
132 } |
145 } |
133 } |
146 } |
|
147 |
|
148 $template->context_push(); |
|
149 |
|
150 $template->assign_vars($params); |
|
151 |
134 if(isset($paths->template_cache[$id])) |
152 if(isset($paths->template_cache[$id])) |
135 { |
153 { |
136 $text = $paths->template_cache[$id]; |
154 $text = $paths->template_cache[$id]; |
137 } |
155 } |
138 else |
156 else |
139 { |
157 { |
140 $text = RenderMan::getPage($id, $fetch_ns, 0, false, false, false, false); |
158 $text = RenderMan::getPage($id, $fetch_ns, 0, false, false, false, false); |
141 $paths->template_cache[$id] = $text; |
159 $paths->template_cache[$id] = $text; |
142 } |
160 } |
|
161 |
|
162 $template->context_pop(); |
143 |
163 |
144 if ( is_string($text) ) |
164 if ( is_string($text) ) |
145 { |
165 { |
146 $text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '', $text); |
166 $text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '', $text); |
147 $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '\\1', $text); |
167 $text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '\\1', $text); |