|
1
|
|
|
<?php namespace XoopsModules\Smartobject; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* Module: SmartObject |
|
6
|
|
|
* Author: The SmartFactory <www.smartfactory.ca> |
|
7
|
|
|
* Licence: GNU |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
use XoopsModules\Smartobject; |
|
11
|
|
|
|
|
12
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class to manage a printer friendly page |
|
16
|
|
|
* @author The SmartFactory <www.smartfactory.ca> |
|
17
|
|
|
*/ |
|
18
|
|
|
class PrinterFriendly |
|
19
|
|
|
{ |
|
20
|
|
|
public $_title; |
|
21
|
|
|
public $_dsc; |
|
22
|
|
|
public $_content; |
|
23
|
|
|
public $_tpl; |
|
24
|
|
|
public $_pageTitle = false; |
|
25
|
|
|
public $_width = 680; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* SmartPrinterFriendly constructor. |
|
29
|
|
|
* @param $content |
|
30
|
|
|
* @param bool $title |
|
31
|
|
|
* @param bool $dsc |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct($content, $title = false, $dsc = false) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->_title = $title; |
|
36
|
|
|
$this->_dsc = $dsc; |
|
37
|
|
|
$this->_content = $content; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function render() |
|
41
|
|
|
{ |
|
42
|
|
|
/** |
|
43
|
|
|
* @todo move the output to a template |
|
44
|
|
|
* @todo make the output XHTML compliant |
|
45
|
|
|
*/ |
|
46
|
|
|
|
|
47
|
|
|
require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
48
|
|
|
|
|
49
|
|
|
$this->_tpl = new \XoopsTpl(); |
|
50
|
|
|
|
|
51
|
|
|
$this->_tpl->assign('smartobject_print_pageTitle', $this->_pageTitle ?: $this->_title); |
|
52
|
|
|
$this->_tpl->assign('smartobject_print_title', $this->_title); |
|
53
|
|
|
$this->_tpl->assign('smartobject_print_dsc', $this->_dsc); |
|
54
|
|
|
$this->_tpl->assign('smartobject_print_content', $this->_content); |
|
55
|
|
|
$this->_tpl->assign('smartobject_print_width', $this->_width); |
|
56
|
|
|
|
|
57
|
|
|
$current_urls = Smartobject\Utility::getCurrentUrls(); |
|
58
|
|
|
$current_url = $current_urls['full']; |
|
59
|
|
|
|
|
60
|
|
|
$this->_tpl->assign('smartobject_print_currenturl', $current_url); |
|
61
|
|
|
$this->_tpl->assign('smartobject_print_url', $this->url); |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
$this->_tpl->display('db:smartobject_print.tpl'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param $text |
|
68
|
|
|
*/ |
|
69
|
|
|
public function setPageTitle($text) |
|
70
|
|
|
{ |
|
71
|
|
|
$this->_pageTitle = $text; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param $width |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setWidth($width) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->_width = $width; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: