Skip to content

Commit

Permalink
Fixed Print Pages for Articles and Staticpages javascript crashing issue
Browse files Browse the repository at this point in the history
Fix for issue #1049

Had to add cookie consent stuff from COM_createHTMLDocument and also include plg_footercode.

With staticpage also added plg_headercode (along with plg_footercode) and removed title from displaying if page is not surrounded by block
  • Loading branch information
eSilverStrike committed Mar 26, 2020
1 parent a88b07f commit ed0507b
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 17 deletions.
31 changes: 30 additions & 1 deletion plugins/staticpages/functions.inc
Expand Up @@ -648,11 +648,39 @@ function SP_displayPage($page, $A, $comment_order = 'ASC', $comment_mode = 'nest
function SP_printPage($page, $A)
{
global $_CONF, $_TABLES, $LANG01, $LANG_STATIC, $LANG_DIRECTION,
$_IMAGE_TYPE;
$_IMAGE_TYPE, $_SCRIPTS;

$print = COM_newTemplate(CTL_plugin_templatePath('staticpages'));
$print->set_file(array('print' => 'printable.thtml'));
$print->set_var('site_slogan', $_CONF['site_slogan']);


// Add Cookie Consent ( https://cookieconsent.osano.com )
if (isset($_CONF['cookie_consent']) && $_CONF['cookie_consent']) {
$_SCRIPTS->setCssFile(
'cookiconsent', 'https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css',
true, array(), 100
);
$_SCRIPTS->setJavaScriptFile(
'cookie_consent', 'https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js',
false, 100, false,
array('data-cfasync' => 'false')
);

if (isset($_CONF['cookie_consent_theme_customization']) && $_CONF['cookie_consent_theme_customization']) {
// Theme should have already set customizations in functions.php

} else {
$_SCRIPTS->setJavaScriptFile(
'cookie_consent_config', '/javascript/cookie_consent.js',
true, 110
);
}
}

$print->set_var('plg_headercode', $_SCRIPTS->getHeader());

$print->set_var('plg_footercode', $_SCRIPTS->getFooter());

$print->set_var('direction', $LANG_DIRECTION);
COM_setLangIdAndAttribute($print);
Expand All @@ -669,6 +697,7 @@ function SP_printPage($page, $A)
. '/staticpages/index.php?page=' . $page);
$print->set_var('sp_url', $sp_url);
$print->set_var('sp_title', stripslashes($A['sp_title']));
$print->set_var('sp_inblock', $A['sp_inblock']);
$print->set_var('sp_content', $A['sp_content']);

$author_name = COM_getDisplayName($A['owner_id']);
Expand Down
4 changes: 4 additions & 0 deletions plugins/staticpages/templates/default/printable.thtml
Expand Up @@ -5,6 +5,7 @@
<meta name="robots" content="NOINDEX"{xhtml}>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"{xhtml}>
<meta http-equiv="Content-Style-Type" content="text/css"{xhtml}>
{plg_headercode}
<link rel="stylesheet" type="text/css" href="{layout_url}/print.css"{xhtml}>
<link rel="stylesheet" type="text/css" media="print" href="{layout_url}/print.css"{xhtml}>
<link rel="shortcut icon" href="{layout_url}/images/favicon.ico"{xhtml}>
Expand All @@ -13,7 +14,9 @@
<body dir="{direction}">
{# begin {templatelocation} #}

{!if sp_inblock}
<h1>{sp_title}</h1>
{!endif}

{sp_content}

Expand All @@ -25,6 +28,7 @@
<dt>{site_name}</dt>
<dd><a href="{sp_url}">{sp_url}</a></dd>
</dl>
{plg_footercode}

{# end {templatelocation} #}
</body>
Expand Down
8 changes: 6 additions & 2 deletions plugins/staticpages/templates/denim/printable.thtml
Expand Up @@ -5,6 +5,7 @@
<meta name="robots" content="NOINDEX"{xhtml}>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"{xhtml}>
<meta http-equiv="Content-Style-Type" content="text/css"{xhtml}>
{plg_headercode}
<link rel="stylesheet" type="text/css" href="{layout_url}/css_{direction}/print.css"{xhtml}>
<link rel="stylesheet" type="text/css" media="print" href="{layout_url}/css_{direction}/print.css"{xhtml}>
<link rel="shortcut icon" href="{layout_url}/images/favicon.ico"{xhtml}>
Expand All @@ -14,10 +15,12 @@
{# begin {templatelocation} #}

<div id="wrapper">
{!if sp_inblock}
<div id="header">
<h2>{sp_title}</h2>
<h1>{sp_title}</h1>
</div>

{!endif}

<div id="story">
{sp_content}
</div>
Expand All @@ -30,6 +33,7 @@
<p>{page_title}<br>{sp_url}</p>
</div>
</div>
{plg_footercode}

{# end {templatelocation} #}
</body>
Expand Down
6 changes: 5 additions & 1 deletion plugins/staticpages/templates/denim_three/printable.thtml
Expand Up @@ -5,6 +5,7 @@
<meta name="robots" content="NOINDEX"{xhtml}>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"{xhtml}>
<meta http-equiv="Content-Style-Type" content="text/css"{xhtml}>
{plg_headercode}
<link rel="stylesheet" type="text/css" href="{layout_url}/css_{direction}/print.css"{xhtml}>
<link rel="stylesheet" type="text/css" media="print" href="{layout_url}/css_{direction}/print.css"{xhtml}>
<link rel="shortcut icon" href="{layout_url}/images/favicon.ico"{xhtml}>
Expand All @@ -14,9 +15,11 @@
{# begin {templatelocation} #}

<div id="wrapper">
{!if sp_inblock}
<div id="header">
<h2>{sp_title}</h2>
<h1>{sp_title}</h1>
</div>
{!endif}

<div id="story">
{sp_content}
Expand All @@ -30,6 +33,7 @@
<p>{page_title}<br>{sp_url}</p>
</div>
</div>
{plg_footercode}

{# end {templatelocation} #}
</body>
Expand Down
30 changes: 28 additions & 2 deletions public_html/article.php
Expand Up @@ -193,10 +193,36 @@ function extractExternalLinks($text) {
$_SCRIPTS->setCssFile('print', '/' . $path, true, array('media' => 'print'));
}
}

// Override style for <a> tags
// Override style for <a> tags
$_SCRIPTS->setCSS('a { color: blue !important; text-decoration: underline !important; }');

// Add Cookie Consent ( https://cookieconsent.osano.com )
if (isset($_CONF['cookie_consent']) && $_CONF['cookie_consent']) {
$_SCRIPTS->setCssFile(
'cookiconsent', 'https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css',
true, array(), 100
);
$_SCRIPTS->setJavaScriptFile(
'cookie_consent', 'https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js',
false, 100, false,
array('data-cfasync' => 'false')
);

if (isset($_CONF['cookie_consent_theme_customization']) && $_CONF['cookie_consent_theme_customization']) {
// Theme should have already set customizations in functions.php

} else {
$_SCRIPTS->setJavaScriptFile(
'cookie_consent_config', '/javascript/cookie_consent.js',
true, 110
);
}
}

$articleTemplate->set_var('plg_headercode', $_SCRIPTS->getHeader());

$articleTemplate->set_var('plg_footercode', $_SCRIPTS->getFooter());

$page_title = $article->DisplayElements('page_title');
if (empty($page_title)) {
Expand Down
1 change: 1 addition & 0 deletions public_html/docs/history
Expand Up @@ -21,6 +21,7 @@ For more in-depth explanation of the issues below see: https://github.com/Geeklo
- [Bug] [#1046] Fixed Users can only be set to certain statuses by Admins [Tom]
- [Bug] [#1047] Fixed Admin login form for those who try to access the Geeklog Admin area. Regular Logged in Users get just a message now instead of showing a login form [Tom]
- [Bug] [#1048] Fixed related Articles are Missing From the Article Page [Tom]
- [Bug] [#1049] Fixed Print Pages for Articles and Staticpages javascript crashing issue [Tom]

The following items are all current Geeklog API, functions, and/or global variables that are planned to be either required or depreciated by a current Geeklog version. Plugin and Theme developers please take note of these changes in case they affect you.

Expand Down
1 change: 1 addition & 0 deletions public_html/docs/japanese/history.html
Expand Up @@ -47,6 +47,7 @@ <h2>March ? 2020 (2.2.1sr1)</h2>
<li>[Bug] [#1046] Fixed Users can only be set to certain statuses by Admins [Tom]</li>
<li>[Bug] [#1047] Fixed Admin login form for those who try to access the Geeklog Admin area. Regular Logged in Users get just a message now instead of showing a login form [Tom]</li>
<li>[Bug] [#1048] Fixed related Articles are Missing From the Article Page [Tom]</li>
<li>[Bug] [#1049] Fixed Print Pages for Articles and Staticpages javascript crashing issue [Tom]</li>
</ul>

<p>The following items are all current Geeklog API, functions, and/or global variables that are planned to be either required or depreciated by a current Geeklog version. Plugin and Theme developers please take note of these changes in case they affect you.<br>
Expand Down
13 changes: 7 additions & 6 deletions public_html/layout/denim/article/printable.thtml
Expand Up @@ -17,21 +17,22 @@
<h2>{story_title}</h2>
<p>{lang_contributedby} {story_author} {story_date}</p>
</div>

<div id="print_story">
{story_text_no_br}
</div>

<p>{comments_with_count}</p>

<hr class="hidden">

<div id="print_footer">
<p>{page_title}<br>{article_url}</p>
{external_links}
</div>
</div>

{# end {templatelocation} #}
{plg_footercode}

{# end {templatelocation} #}
</body>
</html>
11 changes: 6 additions & 5 deletions public_html/layout/denim_three/article/printable.thtml
Expand Up @@ -17,21 +17,22 @@
<h2>{story_title}</h2>
<p>{lang_contributedby} {story_author} {story_date}</p>
</div>

<div id="print_story">
{story_text_no_br}
</div>

<p>{comments_with_count}</p>

<hr class="hidden">

<div id="print_footer">
<p>{page_title}<br>{article_url}</p>
{external_links}
</div>
</div>
{plg_footercode}

{# end {templatelocation} #}
{# end {templatelocation} #}
</body>
</html>
2 changes: 2 additions & 0 deletions public_html/layout/modern_curve/article/printable.thtml
Expand Up @@ -31,6 +31,8 @@
</dl>
{external_links}

{plg_footercode}

{# end {templatelocation} #}
</body>
</html>

0 comments on commit ed0507b

Please sign in to comment.