Commit 13fe5005 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review
Browse files

Changing additionalhtml to be based on config.php values

Bug #1073625

Change-Id: I79041c99681ad6304b81433da7d48dd459353589
parent f2baf73a
......@@ -343,3 +343,26 @@ $cfg->cleanurlusereditable = true;
// @$cfg->plugin->search->elasticsearch->bypassindexname = null;
// @$cfg->plugin->search->elasticsearch->analyzer = 'mahara_analyzer';
// @$cfg->plugin->search->elasticsearch->types = 'usr,interaction_instance,interaction_forum_post,group,view,artefact';
// Additional HTML: Use these settings to put snippets of HTML at the top of every page on the site.
// This is useful for e.g. Google Analytics. If you need to enter a multi-line snippet, it may be best
// to use a PHP nowdoc: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc
// Example:
// $cfg->additionalhtmlhead = <<<'HTML'
// <script type="text/javascript">
// var _gaq = _gaq || [];
// _gaq.push(['_setAccount', 'UA-XXXXX-X']);
// _gaq.push(['_trackPageview']);
// (function() {
// var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
// ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
// var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
// })();
// </script>
// HTML;
// additionalhtmlhead: Last item before the closing </head> tag
$cfg->additionalhtmlhead = '';
// additionalhtmltopofbody: Immediately after the opening <body> tag
$cfg->additionalhtmltopofbody = '';
// additionalhtmlfooter: Last item before the closing </body> tag
$cfg->additionalhtlmfooter = '';
......@@ -3213,19 +3213,6 @@ function xmldb_core_upgrade($oldversion=0) {
add_field($table, $field);
}
if ($oldversion < 2013071200) {
$additionalhtmlitems = site_content_additional_html_items();
$now = db_format_timestamp(time());
foreach ($additionalhtmlitems as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = '';
insert_record('site_content', $page);
}
}
if ($oldversion < 2013081400) {
// We've made a change to how update_safe_iframe_regex() generates the regex
// Call this function to make sure the stored value reflects that change.
......
......@@ -535,7 +535,6 @@ function upgrade_plugin($upgrade) {
function core_postinst() {
$status = true;
$pages = site_content_pages();
$additionalhtmlitems = site_content_additional_html_items();
$now = db_format_timestamp(time());
foreach ($pages as $name) {
$page = new stdClass();
......@@ -547,16 +546,6 @@ function core_postinst() {
$status = false;
}
}
foreach ($additionalhtmlitems as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = '';
if (!insert_record('site_content', $page)) {
$status = false;
}
}
// Attempt to create session directories
$sessionpath = get_config('dataroot') . 'sessions';
......
......@@ -661,15 +661,14 @@ EOF;
// Define additional html content
if (get_config('installed')) {
$additionalhtmlitemnames = site_content_additional_html_items();
$additionalhtmlitems = get_records_select_array(
'site_content',
'name IN (' . join(',', array_fill(0, count($additionalhtmlitemnames), '?')) . ')',
$additionalhtmlitemnames
$additionalhtmlitems = array(
'ADDITIONALHTMLHEAD' => get_config('additionalhtmlhead'),
'ADDITIONALHTMLTOPOFBODY' => get_config('additionalhtmltopofbody'),
'ADDITIONALHTMLFOOTER' => get_config('additionalhtmlfooter')
);
if ($additionalhtmlitems) {
foreach ($additionalhtmlitems as $item) {
$smarty->assign(strtoupper($item->name), $item->content);
foreach ($additionalhtmlitems as $name=>$content) {
$smarty->assign($name, $content);
}
}
}
......@@ -2642,14 +2641,6 @@ function site_content_pages() {
return array('about', 'home', 'loggedouthome', 'privacy', 'termsandconditions');
}
/**
* Returns the list of additional html itmes (site content pages)
* @return array of names
*/
function site_content_additional_html_items() {
return array('additionalhtmlhead', 'additionalhtmltopofbody', 'additionalhtmlfooter');
}
function get_site_page_content($pagename) {
if ($pagedata = get_record('site_content', 'name', $pagename)) {
return $pagedata->content;
......
{include file="header.tpl"}
<p>{str tag=additionalhtmldescription section=admin}</p>
{$contenteditform|safe}
{include file="footer.tpl"}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment