1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** StMarksSmarty and related classes */ |
4
|
|
|
|
5
|
|
|
namespace smtech\StMarksSmarty; |
6
|
|
|
|
7
|
|
|
use Battis\BootstrapSmarty\BootstrapSmarty; |
8
|
|
|
use Battis\DataUtilities; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* A wrapper for Smarty to set (and maintain) defaults |
12
|
|
|
* |
13
|
|
|
* @author Seth Battis <[email protected]> |
14
|
|
|
**/ |
15
|
|
|
class StMarksSmarty extends BootstrapSmarty |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Identifier for UI layer provided by this class |
19
|
|
|
*/ |
20
|
|
|
const KEY = 'StMarks-BootstrapSmarty'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Is this app presented inside of an `iframe`? |
24
|
|
|
* @var boolean |
25
|
|
|
*/ |
26
|
|
|
private $isFramed = false; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @inheritDoc |
30
|
|
|
* |
31
|
|
|
* @param string $template |
32
|
|
|
* @param string $config |
33
|
|
|
* @param string $compile |
34
|
|
|
* @param string $cache |
35
|
|
|
* @return StMarksSmarty |
36
|
|
|
*/ |
37
|
|
|
public static function getSmarty($template = null, $config = null, $compile = null, $cache = null) |
38
|
|
|
{ |
39
|
|
|
if (self::$singleton === null) { |
40
|
|
|
self::$singleton = new self($template, $config, $compile, $cache); |
41
|
|
|
} |
42
|
|
|
return self::$singleton; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @inheritDoc |
47
|
|
|
* |
48
|
|
|
* @param string $template |
49
|
|
|
* @param string $config |
50
|
|
|
* @param string $compile |
51
|
|
|
* @param string $cache |
52
|
|
|
*/ |
53
|
|
|
public function __construct($template = null, $config = null, $compile = null, $cache = null) |
54
|
|
|
{ |
55
|
|
|
parent::__construct($template, $config, $compile, $cache); |
|
|
|
|
56
|
|
|
|
57
|
|
|
$this->prependTemplateDir(__DIR__ . '/../templates', self::KEY); |
58
|
|
|
$this->addStylesheet( |
59
|
|
|
DataUtilities::URLfromPath(__DIR__ . '/../css/StMarksSmarty.css'), |
|
|
|
|
60
|
|
|
self::KEY |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Set whether or not this app is in an `iframe` |
66
|
|
|
* |
67
|
|
|
* @param boolean $isFramed |
68
|
|
|
*/ |
69
|
|
|
public function setFramed($isFramed) |
70
|
|
|
{ |
71
|
|
|
$this->isFramed = (bool) $isFramed; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Is this app presented in an `iframe`? |
76
|
|
|
* |
77
|
|
|
* @return boolean |
78
|
|
|
*/ |
79
|
|
|
public function isFramed() |
80
|
|
|
{ |
81
|
|
|
return $this->isFramed; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @inheritDoc |
86
|
|
|
* |
87
|
|
|
* @param string $template |
88
|
|
|
* @param string $cache_id |
89
|
|
|
* @param string $compile_id |
90
|
|
|
* @param string $parent |
91
|
|
|
* @return void |
92
|
|
|
*/ |
93
|
|
|
public function display($template = 'page.tpl', $cache_id = null, $compile_id = null, $parent = null) |
94
|
|
|
{ |
95
|
|
|
if ($this->isFramed()) { |
96
|
|
|
$this->addStylesheet( |
97
|
|
|
DataUtilities::URLfromPath(__DIR__ . '/../css/StMarksSmarty.css') . '?isFramed=true', |
|
|
|
|
98
|
|
|
self::KEY |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
$this->assign('isFramed', $this->isFramed()); |
102
|
|
|
|
103
|
|
|
parent::display($template, $cache_id, $compile_id, $parent); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.