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

Side by Side Diff: plugin.php

Issue 29355234: Issue 4293 - Make Textpattern use our current website content as template (Closed)
Patch Set: Created Sept. 28, 2016, 10:02 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 $anwiki_data = FALSE; 1 $template_data = FALSE;
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_anwiki_template_path() 3 function get_site_template_path()
4 { 4 {
5 global $prefs; 5 global $prefs;
6 return $prefs['tempdir'].DS.'anwiki_template'; 6 return $prefs['tempdir'].DS.'site_template';
7 } 7 }
8 8
9 function read_anwiki_data() 9 function read_template_data()
10 { 10 {
11 global $anwiki_data; 11 global $template_data;
12 12
13 $data = file_get_contents(get_anwiki_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('/<ul id="language-selector">.*?<\\/ul>/s', '', $header ); 17 $header = preg_replace('/<ul id="language-selector">.*?<\\/ul>/s', '', $header );
17 $header = preg_replace('/<li id="language">.*?<\\/li>/s', '', $header); 18 $header = preg_replace('/<li id="language">.*?<\\/li>/s', '', $header);
18 $header = preg_replace('/ (itemscope|itemtype)="[^"]*"/', '', $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
19 $header = preg_replace('/<script\b[^<>]*>[^<>]+<\\/script>/s', '', $header);
20 $header = preg_replace('/<title>.*?<\\/title>/s', '', $header); 20 $header = preg_replace('/<title>.*?<\\/title>/s', '', $header);
21 21
22 $footer = preg_replace('/.*<footer\b/s', '<footer', $data); 22 $footer = preg_replace('/.*<footer\b/s', '<footer', $data);
23 $footer = preg_replace('/<section id="anwiki-admin">.*?<\\/section>/s', '', $f ooter);
24 23
25 $anwiki_data = array($header, $footer); 24 $template_data = array($header, $footer);
26 } 25 }
27 26
28 function abp_header($attrs, $contents) 27 function abp_header($attrs, $contents)
29 { 28 {
30 global $anwiki_data; 29 global $template_data;
31 if (!$anwiki_data) 30 if (!$template_data)
32 read_anwiki_data(); 31 read_template_data();
33 32
34 $header = preg_replace('/<\\/head>/s', parse($contents) . '</head>', $anwiki_d ata[0]); 33 $header = preg_replace('/<\\/head>/s', parse($contents) . '</head>', $template _data[0]);
35 global $anwiki_file;
36 global $prefs;
37 return $header; 34 return $header;
38 } 35 }
39 36
40 function abp_footer() 37 function abp_footer()
41 { 38 {
42 global $anwiki_data; 39 global $template_data;
43 if (!$anwiki_data) 40 if (!$template_data)
44 read_anwiki_data(); 41 read_template_data();
45 42
46 return $anwiki_data[1]; 43 return $template_data[1];
47 } 44 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld