1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

Issue #2726, Issue #4452 - Added new e_print.php addon which uses v2.x standards.

This commit is contained in:
Cameron
2021-03-17 11:22:25 -07:00
parent 3400c34d59
commit 07faad666a
4 changed files with 62 additions and 23 deletions

View File

@@ -0,0 +1,10 @@
<?php
$PRINT_TEMPLATE['default'] = '<div style="background-color:white">
<div style="text-align:{ALIGN}">{LOGO: h=100}</div>
<hr />
<div style="text-align:{ALIGN}; margin-bottom:50px">{TEXT}</div>
<div class="hidden-print" style="text-align:center">{BUTTON}</div>
</div>';

View File

@@ -46,8 +46,8 @@ class e_plugin
'e_linkgen', 'e_linkgen',
'e_list', 'e_list',
'e_meta', // @Deprecated 'e_meta', // @deprecated
'e_emailprint', 'e_emailprint', /* @deprecated - see e_print */
'e_print', // new v2.2 'e_print', // new v2.2
'e_frontpage', 'e_frontpage',
'e_latest', /* @deprecated - see e_dashboard */ 'e_latest', /* @deprecated - see e_dashboard */
@@ -71,6 +71,7 @@ class e_plugin
'e_tohtml', /* @deprecated - use e_parse */ 'e_tohtml', /* @deprecated - use e_parse */
'e_featurebox', 'e_featurebox',
'e_parse', 'e_parse',
'e_print', // new v2.3.1
'e_related', 'e_related',
'e_rss', 'e_rss',
'e_upload', 'e_upload',

View File

@@ -0,0 +1,15 @@
<?php
class forum_print // plugin-folder + '_print'
{
public function render($parm)
{
// var_dump($parm);
return "TODO!";
}
}

View File

@@ -51,14 +51,18 @@ e107::css('inline',$CSS);
define('e_IFRAME', true); define('e_IFRAME', true);
$source = preg_replace('/[^\w\d_\:]/',"", $qs[0]); $source = preg_replace('/[^\w\d_\:]/',"", $qs[0]);
$parms = varset($qs[1],''); $parms = varset($qs[1]);
unset($qs); unset($qs);
if(strpos($source,'plugin:') !== FALSE) if(strpos($source,'plugin:') !== false)
{ {
$plugin = substr($source, 7); $plugin = substr($source, 7);
if(file_exists(e_PLUGIN.$plugin."/e_emailprint.php")) if($obj = e107::getAddon($plugin, 'e_print'))
{
$print_text = e107::callMethod($obj,'render', $parms);
}
elseif(file_exists(e_PLUGIN.$plugin."/e_emailprint.php"))
{ {
include_once(e_PLUGIN.$plugin."/e_emailprint.php"); include_once(e_PLUGIN.$plugin."/e_emailprint.php");
$print_text = print_item($parms); $print_text = print_item($parms);
@@ -70,7 +74,7 @@ if(strpos($source,'plugin:') !== FALSE)
return; return;
} }
} }
else else // @todo move to e107_plugins/news/e_print.php
{ {
//$con = new convert; //$con = new convert;
// $id = intval($parms); // $id = intval($parms);
@@ -88,8 +92,9 @@ else
$tmp = e107::getTemplate('news', 'news_view', $newsViewTemplate); $tmp = e107::getTemplate('news', 'news_view', $newsViewTemplate);
} }
$title = $tp->toText($row['news_title']); $title = e107::getParser()->toText($row['news_title']);
define('e_PAGETITLE', '[print] '. $title); // define('e_PAGETITLE', '[print] '. $title);
e107::title('[print] '. $title);
e107::meta('robots', 'noindex'); e107::meta('robots', 'noindex');
$template = $tmp['item']; $template = $tmp['item'];
@@ -112,29 +117,37 @@ else
} }
if(defined("TEXTDIRECTION") && TEXTDIRECTION == "rtl"){ if(defined("TEXTDIRECTION") && TEXTDIRECTION === "rtl")
{
$align = 'right'; $align = 'right';
}else{ }
else
{
$align = 'left'; $align = 'left';
} }
// Header down here to give us a chance to set a page title // Header down here to give us a chance to set a page title
require_once(HEADERF); require_once(HEADERF);
//temporary solution - object of future cahges
if(is_readable(THEME.'print_template.php')) if(is_readable(THEME.'print_template.php')) // legacy location.
{ {
$PRINT_TEMPLATE = ''; $PRINT_TEMPLATE = '';
include_once(THEME.'print_template.php'); include_once(THEME.'print_template.php');
echo $tp->parseTemplate($PRINT_TEMPLATE); echo e107::getParser()->parseTemplate($PRINT_TEMPLATE);
} }
else else // v2.3.1+
{ {
echo " $PRINT_TEMPLATE = e107::getCoreTemplate('print', 'default');
<div style='background-color:white'>
<div style='text-align:".$align."'>".$tp->parseTemplate("{LOGO: h=100}", TRUE)."</div><hr /> $vars = array(
<div style='text-align:".$align."'>".$print_text."</div><br /><br /> 'TEXT' => $print_text,
<form action='#'><div class='hidden-print' style='text-align:center'><input class='btn btn-primary ' type='button' value='".LAN_PRINT_307."' onclick='window.print()' /></div></form></div>"; 'ALIGN' => $align,
'BUTTON' => "<button class='btn btn-primary ' type='button' onclick='window.print()' />".LAN_PRINT_307."</button>"
);
echo e107::getParser()->parseTemplate($PRINT_TEMPLATE, true, $vars);
} }
require_once(FOOTERF); require_once(FOOTERF);