Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: plugin.php

Issue 29355234: Issue 4293 - Make Textpattern use our current website content as template (Closed)
Left Patch Set: Created Sept. 28, 2016, 10:02 a.m.
Right Patch Set: Don't remove hamburger menu Created Sept. 28, 2016, 1:29 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 $template_data = FALSE; 1 $template_data = NULL;
kzar 2016/09/28 10:11:07 Nit: I guess this should be NULL not FALSE?
Wladimir Palant 2016/09/28 10:14:42 Done.
2 2
3 function get_site_template_path() 3 function get_site_template_path()
4 { 4 {
5 global $prefs; 5 global $prefs;
6 return $prefs['tempdir'].DS.'site_template'; 6 return $prefs['tempdir'].DS.'site_template';
7 } 7 }
8 8
9 function read_template_data() 9 function read_template_data()
10 { 10 {
11 global $template_data; 11 global $template_data;
12 12
13 $data = file_get_contents(get_site_template_path()); 13 $data = file_get_contents(get_site_template_path());
14 14
15 $header = preg_replace('/<\\/header>.*/s', '</header>', $data); 15 $header = preg_replace('/<\\/header>.*/s', '</header>', $data);
16 $header = preg_replace('/<link\b[^>]*\brel="canonical"[^>]*>/s', '', $header); 16 $header = preg_replace('/<link\b[^>]*\brel="canonical"[^>]*>/s', '', $header);
17 $header = preg_replace('/<ul id="language-selector">.*?<\\/ul>/s', '', $header ); 17 $header = preg_replace('/<ul id="language-selector">.*?<\\/ul>/s', '', $header );
18 $header = preg_replace('/<li id="language">.*?<\\/li>/s', '', $header); 18 $header = preg_replace('/<li id="language">.*?<\\/li>/s', '', $header);
19 $header = preg_replace('/<a\b[^>]*\bid="hamburger".*?<\\/a>/s', '', $header);
kzar 2016/09/28 10:11:07 We don't check for the closing `>` after "hamburge
Wladimir Palant 2016/09/28 10:14:42 Do we care about it? It is certainly there somewhe
kzar 2016/09/28 10:19:11 I guess you're right it doesn't matter too much, b
kzar 2016/09/28 10:28:26 Argh, I meant `.+?`...
Wladimir Palant 2016/09/28 10:32:48 You probably mean .+? (still a non-greedy regular
kzar 2016/09/28 10:39:06 Yep that's what I meant, sorry. Makes sense anyway
20 $header = preg_replace('/<title>.*?<\\/title>/s', '', $header); 19 $header = preg_replace('/<title>.*?<\\/title>/s', '', $header);
21 20
22 $footer = preg_replace('/.*<footer\b/s', '<footer', $data); 21 $footer = preg_replace('/.*<footer\b/s', '<footer', $data);
23 22
24 $template_data = array($header, $footer); 23 $template_data = array($header, $footer);
25 } 24 }
26 25
27 function abp_header($attrs, $contents) 26 function abp_header($attrs, $contents)
28 { 27 {
29 global $template_data; 28 global $template_data;
30 if (!$template_data) 29 if (!$template_data)
31 read_template_data(); 30 read_template_data();
32 31
33 $header = preg_replace('/<\\/head>/s', parse($contents) . '</head>', $template _data[0]); 32 $header = preg_replace('/<\\/head>/s', parse($contents) . '</head>', $template _data[0]);
34 return $header; 33 return $header;
35 } 34 }
36 35
37 function abp_footer() 36 function abp_footer()
38 { 37 {
39 global $template_data; 38 global $template_data;
40 if (!$template_data) 39 if (!$template_data)
41 read_template_data(); 40 read_template_data();
42 41
43 return $template_data[1]; 42 return $template_data[1];
44 } 43 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld