1 | <?php |
||
23 | abstract class Theme |
||
24 | { |
||
25 | const STANDARD = 'standard'; |
||
26 | const DEFERRED = 'defer'; |
||
27 | const ALL = -1; |
||
28 | |||
29 | protected $id; |
||
30 | |||
31 | protected $templates; |
||
32 | protected $layers; |
||
33 | |||
34 | protected $html_headers = array(); |
||
35 | protected $links = array(); |
||
36 | protected $js_files = array(); |
||
37 | protected $js_inline = array( |
||
38 | 'standard' => array(), |
||
39 | 'defer' => array() |
||
40 | ); |
||
41 | protected $js_vars = array(); |
||
42 | protected $css_files = array(); |
||
43 | |||
44 | protected $rtl; |
||
45 | |||
46 | /** |
||
47 | * @param int $id |
||
48 | */ |
||
49 | 1 | public function __construct($id) |
|
57 | |||
58 | /** |
||
59 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
||
60 | * |
||
61 | * @param mixed[] $vars array of vars to include in the output done as 'varname' => 'var value' |
||
62 | * @param bool $escape = false, whether or not to escape the value |
||
63 | */ |
||
64 | 1 | public function addJavascriptVar($vars, $escape = false) |
|
72 | |||
73 | public function getJavascriptVars() |
||
77 | |||
78 | /** |
||
79 | * @param int|self::ALL $type One of ALL, SELF, DEFERRED class constants |
||
80 | * @return array |
||
81 | * @throws Exception if the type is not known |
||
82 | */ |
||
83 | public function getInlineJavascript($type = self::ALL) |
||
97 | |||
98 | /** |
||
99 | * Add a block of inline Javascript code to be executed later |
||
100 | * |
||
101 | * What it does: |
||
102 | * - only use this if you have to, generally external JS files are better, but for very small scripts |
||
103 | * or for scripts that require help from PHP/whatever, this can be useful. |
||
104 | * - all code added with this function is added to the same <script> tag so do make sure your JS is clean! |
||
105 | * |
||
106 | * @param string $javascript |
||
107 | * @param bool $defer = false, define if the script should load in <head> or before the closing <html> tag |
||
108 | */ |
||
109 | function addInlineJavascript($javascript, $defer = false) |
||
114 | |||
115 | public function setRTL($toggle) |
||
120 | } |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.