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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: plugin.php
===================================================================
--- a/plugin.php
+++ b/plugin.php
@@ -1,47 +1,44 @@
-$anwiki_data = FALSE;
+$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.
-function get_anwiki_template_path()
+function get_site_template_path()
{
global $prefs;
- return $prefs['tempdir'].DS.'anwiki_template';
+ return $prefs['tempdir'].DS.'site_template';
}
-function read_anwiki_data()
+function read_template_data()
{
- global $anwiki_data;
+ global $template_data;
- $data = file_get_contents(get_anwiki_template_path());
+ $data = file_get_contents(get_site_template_path());
$header = preg_replace('/<\\/header>.*/s', '</header>', $data);
+ $header = preg_replace('/<link\b[^>]*\brel="canonical"[^>]*>/s', '', $header);
$header = preg_replace('/<ul id="language-selector">.*?<\\/ul>/s', '', $header);
$header = preg_replace('/<li id="language">.*?<\\/li>/s', '', $header);
- $header = preg_replace('/ (itemscope|itemtype)="[^"]*"/', '', $header);
- $header = preg_replace('/<script\b[^<>]*>[^<>]+<\\/script>/s', '', $header);
+ $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
$header = preg_replace('/<title>.*?<\\/title>/s', '', $header);
$footer = preg_replace('/.*<footer\b/s', '<footer', $data);
- $footer = preg_replace('/<section id="anwiki-admin">.*?<\\/section>/s', '', $footer);
- $anwiki_data = array($header, $footer);
+ $template_data = array($header, $footer);
}
function abp_header($attrs, $contents)
{
- global $anwiki_data;
- if (!$anwiki_data)
- read_anwiki_data();
+ global $template_data;
+ if (!$template_data)
+ read_template_data();
- $header = preg_replace('/<\\/head>/s', parse($contents) . '</head>', $anwiki_data[0]);
- global $anwiki_file;
- global $prefs;
+ $header = preg_replace('/<\\/head>/s', parse($contents) . '</head>', $template_data[0]);
return $header;
}
function abp_footer()
{
- global $anwiki_data;
- if (!$anwiki_data)
- read_anwiki_data();
+ global $template_data;
+ if (!$template_data)
+ read_template_data();
- return $anwiki_data[1];
+ return $template_data[1];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld