@@ -21,7 +21,7 @@ |
||
21 | 21 | * @param \Fisharebest\Webtrees\Module\AbstractModule $module |
22 | 22 | * @param string $request |
23 | 23 | */ |
24 | - public function handle(\Fisharebest\Webtrees\Module\AbstractModule $module, $request); |
|
24 | + public function handle(\Fisharebest\Webtrees\Module\AbstractModule $module, $request); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | 28 | \ No newline at end of file |
@@ -17,87 +17,87 @@ |
||
17 | 17 | */ |
18 | 18 | class ViewFactory { |
19 | 19 | |
20 | - /** |
|
21 | - * @var ViewFactory $instance Singleton pattern instance |
|
22 | - */ |
|
23 | - private static $instance = null; |
|
20 | + /** |
|
21 | + * @var ViewFactory $instance Singleton pattern instance |
|
22 | + */ |
|
23 | + private static $instance = null; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Returns the *ViewFactory* instance of this class. |
|
27 | - * |
|
28 | - * @return ViewFactory The *Singleton* instance. |
|
29 | - */ |
|
30 | - public static function getInstance() |
|
31 | - { |
|
32 | - if (null === static::$instance) { |
|
33 | - static::$instance = new static(); |
|
34 | - } |
|
25 | + /** |
|
26 | + * Returns the *ViewFactory* instance of this class. |
|
27 | + * |
|
28 | + * @return ViewFactory The *Singleton* instance. |
|
29 | + */ |
|
30 | + public static function getInstance() |
|
31 | + { |
|
32 | + if (null === static::$instance) { |
|
33 | + static::$instance = new static(); |
|
34 | + } |
|
35 | 35 | |
36 | - return static::$instance; |
|
37 | - } |
|
36 | + return static::$instance; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Protected constructor |
|
41 | - */ |
|
42 | - protected function __construct() {} |
|
39 | + /** |
|
40 | + * Protected constructor |
|
41 | + */ |
|
42 | + protected function __construct() {} |
|
43 | 43 | |
44 | - /** |
|
45 | - * Return the view specified by the controller and view name, using data from the ViewBag |
|
46 | - * |
|
47 | - * @param string $view_name |
|
48 | - * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
49 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
50 | - * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
51 | - * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
52 | - * @throws \Exception |
|
53 | - */ |
|
54 | - public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
55 | - { |
|
56 | - if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | - if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | - if(!$view_name) throw new \Exception('View not defined'); |
|
44 | + /** |
|
45 | + * Return the view specified by the controller and view name, using data from the ViewBag |
|
46 | + * |
|
47 | + * @param string $view_name |
|
48 | + * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
49 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
50 | + * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
51 | + * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
52 | + * @throws \Exception |
|
53 | + */ |
|
54 | + public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
55 | + { |
|
56 | + if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | + if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | + if(!$view_name) throw new \Exception('View not defined'); |
|
59 | 59 | |
60 | - $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
|
61 | - $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
|
62 | - if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
60 | + $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
|
61 | + $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
|
62 | + if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
63 | 63 | |
64 | - return new $view_class($ctrl, $data); |
|
65 | - } |
|
64 | + return new $view_class($ctrl, $data); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Static invocation of the makeView method |
|
69 | - * |
|
70 | - * @param string $view_name |
|
71 | - * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
72 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
73 | - * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
74 | - * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
75 | - * @see \MyArtJaub\Webtrees\Mvc\View\ViewFactory::handle() |
|
76 | - */ |
|
77 | - public static function make($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
78 | - { |
|
79 | - return self::getInstance()->makeView($view_name, $mvc_ctrl, $ctrl, $data); |
|
80 | - } |
|
67 | + /** |
|
68 | + * Static invocation of the makeView method |
|
69 | + * |
|
70 | + * @param string $view_name |
|
71 | + * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
72 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
73 | + * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
74 | + * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
75 | + * @see \MyArtJaub\Webtrees\Mvc\View\ViewFactory::handle() |
|
76 | + */ |
|
77 | + public static function make($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
78 | + { |
|
79 | + return self::getInstance()->makeView($view_name, $mvc_ctrl, $ctrl, $data); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Private clone method to prevent cloning of the instance of the |
|
84 | - * *Dispatcher* instance. |
|
85 | - * |
|
86 | - * @return void |
|
87 | - */ |
|
88 | - private function __clone() |
|
89 | - { |
|
90 | - } |
|
82 | + /** |
|
83 | + * Private clone method to prevent cloning of the instance of the |
|
84 | + * *Dispatcher* instance. |
|
85 | + * |
|
86 | + * @return void |
|
87 | + */ |
|
88 | + private function __clone() |
|
89 | + { |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
94 | - * instance. |
|
95 | - * |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - private function __wakeup() |
|
99 | - { |
|
100 | - } |
|
92 | + /** |
|
93 | + * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
94 | + * instance. |
|
95 | + * |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + private function __wakeup() |
|
99 | + { |
|
100 | + } |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
104 | 104 | \ No newline at end of file |
@@ -53,13 +53,13 @@ |
||
53 | 53 | */ |
54 | 54 | public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
55 | 55 | { |
56 | - if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | - if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | - if(!$view_name) throw new \Exception('View not defined'); |
|
56 | + if (!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | + if (!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | + if (!$view_name) throw new \Exception('View not defined'); |
|
59 | 59 | |
60 | 60 | $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
61 | - $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
|
62 | - if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
61 | + $view_class = $mvc_ctrl_refl->getNamespaceName().'\\Views\\'.$view_name.'View'; |
|
62 | + if (!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
63 | 63 | |
64 | 64 | return new $view_class($ctrl, $data); |
65 | 65 | } |
@@ -53,13 +53,21 @@ |
||
53 | 53 | */ |
54 | 54 | public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
55 | 55 | { |
56 | - if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | - if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | - if(!$view_name) throw new \Exception('View not defined'); |
|
56 | + if(!$mvc_ctrl) { |
|
57 | + throw new \Exception('Mvc Controller not defined'); |
|
58 | + } |
|
59 | + if(!$ctrl) { |
|
60 | + throw new \Exception('Base Controller not defined'); |
|
61 | + } |
|
62 | + if(!$view_name) { |
|
63 | + throw new \Exception('View not defined'); |
|
64 | + } |
|
59 | 65 | |
60 | 66 | $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
61 | 67 | $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
62 | - if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
68 | + if(!class_exists($view_class)) { |
|
69 | + throw new \Exception('View does not exist'); |
|
70 | + } |
|
63 | 71 | |
64 | 72 | return new $view_class($ctrl, $data); |
65 | 73 | } |
@@ -15,62 +15,62 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class AbstractView { |
17 | 17 | |
18 | - /** |
|
19 | - * Reference controller |
|
20 | - * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
21 | - */ |
|
22 | - protected $ctrl; |
|
18 | + /** |
|
19 | + * Reference controller |
|
20 | + * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
21 | + */ |
|
22 | + protected $ctrl; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Structure containing the data of the view |
|
26 | - * @var ViewBag $data |
|
27 | - */ |
|
28 | - protected $data; |
|
24 | + /** |
|
25 | + * Structure containing the data of the view |
|
26 | + * @var ViewBag $data |
|
27 | + */ |
|
28 | + protected $data; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Constructor |
|
32 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
33 | - * @param ViewBag $data ViewBag holding view data |
|
34 | - */ |
|
35 | - public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
36 | - $this->ctrl = $ctrl; |
|
37 | - $this->data = $data; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Constructor |
|
32 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
33 | + * @param ViewBag $data ViewBag holding view data |
|
34 | + */ |
|
35 | + public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
36 | + $this->ctrl = $ctrl; |
|
37 | + $this->data = $data; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Render the view to the page, including header. |
|
42 | - * |
|
43 | - * @throws \Exception |
|
44 | - */ |
|
45 | - public function render() { |
|
40 | + /** |
|
41 | + * Render the view to the page, including header. |
|
42 | + * |
|
43 | + * @throws \Exception |
|
44 | + */ |
|
45 | + public function render() { |
|
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
49 | 49 | |
50 | 50 | $controller = $this->ctrl; |
51 | - $this->ctrl->pageHeader(); |
|
51 | + $this->ctrl->pageHeader(); |
|
52 | 52 | |
53 | - echo $this->renderContent(); |
|
54 | - } |
|
53 | + echo $this->renderContent(); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Render the view to the page, without any header |
|
58 | - */ |
|
59 | - public function renderPartial() { |
|
60 | - echo $this->getHtmlPartial(); |
|
61 | - } |
|
56 | + /** |
|
57 | + * Render the view to the page, without any header |
|
58 | + */ |
|
59 | + public function renderPartial() { |
|
60 | + echo $this->getHtmlPartial(); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Return the HTML code generated by the view, without any header |
|
65 | - */ |
|
66 | - public function getHtmlPartial() { |
|
67 | - return $this->renderContent(); |
|
68 | - } |
|
63 | + /** |
|
64 | + * Return the HTML code generated by the view, without any header |
|
65 | + */ |
|
66 | + public function getHtmlPartial() { |
|
67 | + return $this->renderContent(); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Abstract method containing the details of the view. |
|
72 | - */ |
|
73 | - abstract protected function renderContent(); |
|
70 | + /** |
|
71 | + * Abstract method containing the details of the view. |
|
72 | + */ |
|
73 | + abstract protected function renderContent(); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | \ No newline at end of file |
@@ -45,7 +45,7 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if (!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
49 | 49 | |
50 | 50 | $controller = $this->ctrl; |
51 | 51 | $this->ctrl->pageHeader(); |
@@ -45,7 +45,9 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if(!$this->ctrl) { |
|
49 | + throw new \Exception('Controller not initialised'); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | $controller = $this->ctrl; |
51 | 53 | $this->ctrl->pageHeader(); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public static function encodeFileSystemToUtf8($string){ |
186 | 186 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
187 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
187 | + return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
188 | 188 | } |
189 | 189 | return $string; |
190 | 190 | } |
@@ -249,20 +249,20 @@ discard block |
||
249 | 249 | * @return boolean|string Is supported? |
250 | 250 | */ |
251 | 251 | public static function isImageTypeSupported($reqtype) { |
252 | - $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
253 | - $reqtype = strtolower($reqtype); |
|
252 | + $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
253 | + $reqtype = strtolower($reqtype); |
|
254 | 254 | |
255 | - if (empty($supportByGD[$reqtype])) { |
|
256 | - return false; |
|
257 | - } |
|
255 | + if (empty($supportByGD[$reqtype])) { |
|
256 | + return false; |
|
257 | + } |
|
258 | 258 | |
259 | - $type = $supportByGD[$reqtype]; |
|
259 | + $type = $supportByGD[$reqtype]; |
|
260 | 260 | |
261 | - if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
262 | - return $type; |
|
263 | - } |
|
261 | + if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
262 | + return $type; |
|
263 | + } |
|
264 | 264 | |
265 | - return false; |
|
265 | + return false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | } |
@@ -116,16 +116,18 @@ discard block |
||
116 | 116 | $len_chars = count($chars); |
117 | 117 | $token = ''; |
118 | 118 | |
119 | - for ($i = 0; $i < $length; $i++) |
|
120 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
119 | + for ($i = 0; $i < $length; $i++) { |
|
120 | + $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
121 | + } |
|
121 | 122 | |
122 | 123 | # Number of 32 char chunks |
123 | 124 | $chunks = ceil( strlen($token) / 32 ); |
124 | 125 | $md5token = ''; |
125 | 126 | |
126 | 127 | # Run each chunk through md5 |
127 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
128 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
128 | + for ( $i=1; $i<=$chunks; $i++ ) { |
|
129 | + $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
130 | + } |
|
129 | 131 | |
130 | 132 | # Trim the token |
131 | 133 | return substr($md5token, 0, $length); |
@@ -140,8 +142,9 @@ discard block |
||
140 | 142 | */ |
141 | 143 | public static function encryptToSafeBase64($data){ |
142 | 144 | $key = 'STANDARDKEYIFNOSERVER'; |
143 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
144 | - $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
145 | + if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) { |
|
146 | + $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
147 | + } |
|
145 | 148 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
146 | 149 | $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
147 | 150 | $encrypted = base64_encode($iv.$id); |
@@ -160,16 +163,19 @@ discard block |
||
160 | 163 | */ |
161 | 164 | public static function decryptFromSafeBase64($encrypted){ |
162 | 165 | $key = 'STANDARDKEYIFNOSERVER'; |
163 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
164 | - $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
166 | + if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) { |
|
167 | + $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
168 | + } |
|
165 | 169 | $encrypted = str_replace('-', '+', $encrypted); |
166 | 170 | $encrypted = str_replace('_', '/', $encrypted); |
167 | 171 | $encrypted = str_replace('*', '=', $encrypted); |
168 | 172 | $encrypted = base64_decode($encrypted); |
169 | - if(!$encrypted) |
|
170 | - throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
171 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
172 | - throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
173 | + if(!$encrypted) { |
|
174 | + throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
175 | + } |
|
176 | + if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) { |
|
177 | + throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
178 | + } |
|
173 | 179 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
174 | 180 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
175 | 181 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
@@ -210,7 +216,9 @@ discard block |
||
210 | 216 | * @return boolean True if path valid |
211 | 217 | */ |
212 | 218 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
213 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
219 | + if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) { |
|
220 | + return true; |
|
221 | + } |
|
214 | 222 | return false; |
215 | 223 | } |
216 | 224 |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string $text Text to display |
40 | 40 | */ |
41 | - static public function promptAlert($text){ |
|
41 | + static public function promptAlert($text) { |
|
42 | 42 | echo '<script>'; |
43 | - echo 'alert("',fw\Filter::escapeHtml($text),'")'; |
|
43 | + echo 'alert("', fw\Filter::escapeHtml($text), '")'; |
|
44 | 44 | echo '</script>'; |
45 | 45 | } |
46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return float Result of the safe division |
54 | 54 | */ |
55 | 55 | public static function safeDivision($num, $denom, $default = 0) { |
56 | - if($denom && $denom!=0){ |
|
56 | + if ($denom && $denom != 0) { |
|
57 | 57 | return $num / $denom; |
58 | 58 | } |
59 | 59 | return $default; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param float $default Default value if denominator null or 0 |
68 | 68 | * @return float Percentage |
69 | 69 | */ |
70 | - public static function getPercentage($num, $denom, $default = 0){ |
|
70 | + public static function getPercentage($num, $denom, $default = 0) { |
|
71 | 71 | return 100 * self::safeDivision($num, $denom, $default); |
72 | 72 | } |
73 | 73 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param int $target The final max width/height |
79 | 79 | * @return array array of ($width, $height). One of them must be $target |
80 | 80 | */ |
81 | - static public function getResizedImageSize($file, $target=25){ |
|
82 | - list($width, $height, , ) = getimagesize($file); |
|
81 | + static public function getResizedImageSize($file, $target = 25) { |
|
82 | + list($width, $height,,) = getimagesize($file); |
|
83 | 83 | $max = max($width, $height); |
84 | 84 | $rapp = $target / $max; |
85 | 85 | $width = intval($rapp * $width); |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | * @param int $length Length of the token, default to 32 |
110 | 110 | * @return string Random token |
111 | 111 | */ |
112 | - public static function generateRandomToken($length=32) { |
|
112 | + public static function generateRandomToken($length = 32) { |
|
113 | 113 | $chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); |
114 | 114 | $len_chars = count($chars); |
115 | 115 | $token = ''; |
116 | 116 | |
117 | 117 | for ($i = 0; $i < $length; $i++) |
118 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
118 | + $token .= $chars[mt_rand(0, $len_chars - 1)]; |
|
119 | 119 | |
120 | 120 | # Number of 32 char chunks |
121 | - $chunks = ceil( strlen($token) / 32 ); |
|
121 | + $chunks = ceil(strlen($token) / 32); |
|
122 | 122 | $md5token = ''; |
123 | 123 | |
124 | 124 | # Run each chunk through md5 |
125 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
126 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
125 | + for ($i = 1; $i <= $chunks; $i++) |
|
126 | + $md5token .= md5(substr($token, $i * 32 - 32, 32)); |
|
127 | 127 | |
128 | 128 | # Trim the token |
129 | 129 | return substr($md5token, 0, $length); |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | * @param string $data Text to encrypt |
137 | 137 | * @return string Encrypted and encoded text |
138 | 138 | */ |
139 | - public static function encryptToSafeBase64($data){ |
|
139 | + public static function encryptToSafeBase64($data) { |
|
140 | 140 | $key = 'STANDARDKEYIFNOSERVER'; |
141 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
141 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
142 | 142 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
143 | 143 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
144 | - $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
|
144 | + $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); |
|
145 | 145 | $encrypted = base64_encode($iv.$id); |
146 | 146 | // +, / and = are not URL-compatible |
147 | 147 | $encrypted = str_replace('+', '-', $encrypted); |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | * @param string $encrypted Text to decrypt |
157 | 157 | * @return string Decrypted text |
158 | 158 | */ |
159 | - public static function decryptFromSafeBase64($encrypted){ |
|
159 | + public static function decryptFromSafeBase64($encrypted) { |
|
160 | 160 | $key = 'STANDARDKEYIFNOSERVER'; |
161 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
161 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
162 | 162 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
163 | 163 | $encrypted = str_replace('-', '+', $encrypted); |
164 | 164 | $encrypted = str_replace('_', '/', $encrypted); |
165 | 165 | $encrypted = str_replace('*', '=', $encrypted); |
166 | 166 | $encrypted = base64_decode($encrypted); |
167 | - if(!$encrypted) |
|
167 | + if (!$encrypted) |
|
168 | 168 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
169 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
169 | + if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
170 | 170 | throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
171 | 171 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
172 | 172 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
173 | 173 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
174 | - return preg_replace('~(?:\\000+)$~','',$decrypted); |
|
174 | + return preg_replace('~(?:\\000+)$~', '', $decrypted); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param string $string Filesystem encoded string to encode |
181 | 181 | * @return string UTF-8 encoded string |
182 | 182 | */ |
183 | - public static function encodeFileSystemToUtf8($string){ |
|
183 | + public static function encodeFileSystemToUtf8($string) { |
|
184 | 184 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
185 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
185 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
186 | 186 | } |
187 | 187 | return $string; |
188 | 188 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @param string $string UTF-8 encoded string to encode |
194 | 194 | * @return string Filesystem encoded string |
195 | 195 | */ |
196 | - public static function encodeUtf8ToFileSystem($string){ |
|
196 | + public static function encodeUtf8ToFileSystem($string) { |
|
197 | 197 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
198 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
198 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
199 | 199 | } |
200 | 200 | return $string; |
201 | 201 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @return boolean True if path valid |
209 | 209 | */ |
210 | 210 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
211 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
211 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return array Array of month short names |
221 | 221 | */ |
222 | 222 | public static function getCalendarShortMonths($calendarId = 0) { |
223 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
223 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
224 | 224 | $calendar_info = cal_info($calendarId); |
225 | 225 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
226 | 226 | } |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param int $sosa Sosa number |
234 | 234 | * @return number |
235 | 235 | */ |
236 | - public static function getGeneration($sosa){ |
|
237 | - return(int)log($sosa, 2)+1; |
|
236 | + public static function getGeneration($sosa) { |
|
237 | + return(int)log($sosa, 2) + 1; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 |
@@ -21,54 +21,54 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class ImageBuilder { |
23 | 23 | |
24 | - /** |
|
25 | - * Reference media |
|
26 | - * @var Media $media |
|
27 | - */ |
|
28 | - protected $media; |
|
24 | + /** |
|
25 | + * Reference media |
|
26 | + * @var Media $media |
|
27 | + */ |
|
28 | + protected $media; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Use TTF font |
|
32 | - * @var bool $use_ttf |
|
33 | - */ |
|
34 | - protected $use_ttf; |
|
30 | + /** |
|
31 | + * Use TTF font |
|
32 | + * @var bool $use_ttf |
|
33 | + */ |
|
34 | + protected $use_ttf; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Expiration offset. Default is one day. |
|
38 | - * @var int $expire_offset |
|
39 | - */ |
|
40 | - protected $expire_offset; |
|
36 | + /** |
|
37 | + * Expiration offset. Default is one day. |
|
38 | + * @var int $expire_offset |
|
39 | + */ |
|
40 | + protected $expire_offset; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Should the certificate display a watermark |
|
44 | - * @var bool $show_watermark |
|
45 | - */ |
|
46 | - protected $show_watermark; |
|
42 | + /** |
|
43 | + * Should the certificate display a watermark |
|
44 | + * @var bool $show_watermark |
|
45 | + */ |
|
46 | + protected $show_watermark; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Maximum watermark font size. Default is 18. |
|
50 | - * @var int $font_max_size |
|
51 | - */ |
|
52 | - protected $font_max_size; |
|
48 | + /** |
|
49 | + * Maximum watermark font size. Default is 18. |
|
50 | + * @var int $font_max_size |
|
51 | + */ |
|
52 | + protected $font_max_size; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Watermark font color, in hexadecimal. Default is #4D6DF3. |
|
56 | - * @var string $font_color |
|
57 | - */ |
|
58 | - protected $font_color; |
|
54 | + /** |
|
55 | + * Watermark font color, in hexadecimal. Default is #4D6DF3. |
|
56 | + * @var string $font_color |
|
57 | + */ |
|
58 | + protected $font_color; |
|
59 | 59 | |
60 | 60 | /** |
61 | - * Contructor for ImageBuilder |
|
62 | - * |
|
63 | - * @param Media|null $media Reference media object |
|
64 | - */ |
|
61 | + * Contructor for ImageBuilder |
|
62 | + * |
|
63 | + * @param Media|null $media Reference media object |
|
64 | + */ |
|
65 | 65 | public function __construct(Media $media = null){ |
66 | - $this->media = $media; |
|
67 | - $this->use_ttf = function_exists('imagettftext'); |
|
68 | - $this->expire_offset = 3600 * 24; |
|
69 | - $this->show_watermark = true; |
|
70 | - $this->font_max_size = 18; |
|
71 | - $this->font_color = '#4D6DF3'; |
|
66 | + $this->media = $media; |
|
67 | + $this->use_ttf = function_exists('imagettftext'); |
|
68 | + $this->expire_offset = 3600 * 24; |
|
69 | + $this->show_watermark = true; |
|
70 | + $this->font_max_size = 18; |
|
71 | + $this->font_color = '#4D6DF3'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return int |
78 | 78 | */ |
79 | 79 | public function getExpireOffset() { |
80 | - return $this->expire_offset; |
|
80 | + return $this->expire_offset; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * @return ImageBuilder |
88 | 88 | */ |
89 | 89 | public function setExpireOffset($expireOffset) { |
90 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
91 | - return $this; |
|
90 | + if($expireOffset) $this->expire_offset = $expireOffset; |
|
91 | + return $this; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @return bool |
98 | 98 | */ |
99 | 99 | public function isShowWatermark() { |
100 | - return $this->show_watermark; |
|
100 | + return $this->show_watermark; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * @return ImageBuilder |
108 | 108 | */ |
109 | 109 | public function setShowWatermark($show_watermark) { |
110 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
111 | - return $this; |
|
110 | + if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
111 | + return $this; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @return ImageBuilder |
119 | 119 | */ |
120 | 120 | public function setFontMaxSize($font_max_size) { |
121 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
122 | - return $this; |
|
121 | + if($font_max_size) $this->font_max_size = $font_max_size; |
|
122 | + return $this; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @return ImageBuilder |
130 | 130 | */ |
131 | 131 | public function setFontColor($font_color) { |
132 | - if($font_color) $this->font_color = $font_color; |
|
133 | - return $this; |
|
132 | + if($font_color) $this->font_color = $font_color; |
|
133 | + return $this; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -138,134 +138,134 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function render(){ |
140 | 140 | |
141 | - if (!$this->media || !$this->media->canShow()) { |
|
142 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
143 | - $this->renderError(); |
|
144 | - } |
|
141 | + if (!$this->media || !$this->media->canShow()) { |
|
142 | + Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
143 | + $this->renderError(); |
|
144 | + } |
|
145 | 145 | |
146 | - $serverFilename = $this->media->getServerFilename(); |
|
146 | + $serverFilename = $this->media->getServerFilename(); |
|
147 | 147 | |
148 | - if (!file_exists($serverFilename)) { |
|
149 | - Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
150 | - $this->renderError(); |
|
151 | - } |
|
148 | + if (!file_exists($serverFilename)) { |
|
149 | + Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
150 | + $this->renderError(); |
|
151 | + } |
|
152 | 152 | |
153 | - $mimetype = $this->media->mimeType(); |
|
154 | - $imgsize = $this->media->getImageAttributes(); |
|
155 | - $filetime = $this->media->getFiletime(); |
|
156 | - $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
157 | - $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
153 | + $mimetype = $this->media->mimeType(); |
|
154 | + $imgsize = $this->media->getImageAttributes(); |
|
155 | + $filetime = $this->media->getFiletime(); |
|
156 | + $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
157 | + $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
158 | 158 | |
159 | - $type = Functions::isImageTypeSupported($imgsize['ext']); |
|
160 | - $usewatermark = false; |
|
161 | - // if this image supports watermarks and the watermark module is intalled... |
|
162 | - if ($type) { |
|
163 | - $usewatermark = $this->isShowWatermark(); |
|
164 | - } |
|
159 | + $type = Functions::isImageTypeSupported($imgsize['ext']); |
|
160 | + $usewatermark = false; |
|
161 | + // if this image supports watermarks and the watermark module is intalled... |
|
162 | + if ($type) { |
|
163 | + $usewatermark = $this->isShowWatermark(); |
|
164 | + } |
|
165 | 165 | |
166 | - // determine whether we have enough memory to watermark this image |
|
167 | - if ($usewatermark) { |
|
168 | - if (!FunctionsMedia::hasMemoryForImage($serverFilename)) { |
|
169 | - // not enough memory to watermark this file |
|
170 | - $usewatermark = false; |
|
171 | - } |
|
172 | - } |
|
166 | + // determine whether we have enough memory to watermark this image |
|
167 | + if ($usewatermark) { |
|
168 | + if (!FunctionsMedia::hasMemoryForImage($serverFilename)) { |
|
169 | + // not enough memory to watermark this file |
|
170 | + $usewatermark = false; |
|
171 | + } |
|
172 | + } |
|
173 | 173 | |
174 | - $etag = $this->media->getEtag(); |
|
174 | + $etag = $this->media->getEtag(); |
|
175 | 175 | |
176 | - // parse IF_MODIFIED_SINCE header from client |
|
177 | - $if_modified_since = 'x'; |
|
178 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { |
|
179 | - $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
180 | - } |
|
176 | + // parse IF_MODIFIED_SINCE header from client |
|
177 | + $if_modified_since = 'x'; |
|
178 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { |
|
179 | + $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
180 | + } |
|
181 | 181 | |
182 | - // parse IF_NONE_MATCH header from client |
|
183 | - $if_none_match = 'x'; |
|
184 | - if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
|
185 | - $if_none_match = str_replace('"', '', $_SERVER['HTTP_IF_NONE_MATCH']); |
|
186 | - } |
|
182 | + // parse IF_NONE_MATCH header from client |
|
183 | + $if_none_match = 'x'; |
|
184 | + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
|
185 | + $if_none_match = str_replace('"', '', $_SERVER['HTTP_IF_NONE_MATCH']); |
|
186 | + } |
|
187 | 187 | |
188 | - // add caching headers. allow browser to cache file, but not proxy |
|
189 | - header('Last-Modified: ' . $filetimeHeader); |
|
190 | - header('ETag: "' . $etag . '"'); |
|
191 | - header('Expires: ' . $expireHeader); |
|
192 | - header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
188 | + // add caching headers. allow browser to cache file, but not proxy |
|
189 | + header('Last-Modified: ' . $filetimeHeader); |
|
190 | + header('ETag: "' . $etag . '"'); |
|
191 | + header('Expires: ' . $expireHeader); |
|
192 | + header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
193 | 193 | |
194 | - // if this file is already in the user’s cache, don’t resend it |
|
195 | - // first check if the if_modified_since param matches |
|
196 | - if ($if_modified_since === $filetimeHeader) { |
|
197 | - // then check if the etag matches |
|
198 | - if ($if_none_match === $etag) { |
|
199 | - http_response_code(304); |
|
194 | + // if this file is already in the user’s cache, don’t resend it |
|
195 | + // first check if the if_modified_since param matches |
|
196 | + if ($if_modified_since === $filetimeHeader) { |
|
197 | + // then check if the etag matches |
|
198 | + if ($if_none_match === $etag) { |
|
199 | + http_response_code(304); |
|
200 | 200 | |
201 | - return; |
|
202 | - } |
|
203 | - } |
|
201 | + return; |
|
202 | + } |
|
203 | + } |
|
204 | 204 | |
205 | - // send headers for the image |
|
206 | - header('Content-Type: ' . $mimetype); |
|
207 | - header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
205 | + // send headers for the image |
|
206 | + header('Content-Type: ' . $mimetype); |
|
207 | + header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
208 | 208 | |
209 | - if ($usewatermark) { |
|
210 | - // generate the watermarked image |
|
211 | - $imCreateFunc = 'imagecreatefrom' . $type; |
|
212 | - $imSendFunc = 'image' . $type; |
|
209 | + if ($usewatermark) { |
|
210 | + // generate the watermarked image |
|
211 | + $imCreateFunc = 'imagecreatefrom' . $type; |
|
212 | + $imSendFunc = 'image' . $type; |
|
213 | 213 | |
214 | - if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
|
215 | - $im = $imCreateFunc($serverFilename); |
|
216 | - $im = $this->applyWatermark($im); |
|
214 | + if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
|
215 | + $im = $imCreateFunc($serverFilename); |
|
216 | + $im = $this->applyWatermark($im); |
|
217 | 217 | |
218 | - // send the image |
|
219 | - $imSendFunc($im); |
|
220 | - imagedestroy($im); |
|
218 | + // send the image |
|
219 | + $imSendFunc($im); |
|
220 | + imagedestroy($im); |
|
221 | 221 | |
222 | - return; |
|
223 | - } else { |
|
224 | - // this image is defective. log it |
|
225 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
226 | - } |
|
227 | - } |
|
222 | + return; |
|
223 | + } else { |
|
224 | + // this image is defective. log it |
|
225 | + Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - // determine filesize of image (could be original or watermarked version) |
|
230 | - $filesize = filesize($serverFilename); |
|
229 | + // determine filesize of image (could be original or watermarked version) |
|
230 | + $filesize = filesize($serverFilename); |
|
231 | 231 | |
232 | - // set content-length header, send file |
|
233 | - header('Content-Length: ' . $filesize); |
|
232 | + // set content-length header, send file |
|
233 | + header('Content-Length: ' . $filesize); |
|
234 | 234 | |
235 | - // Some servers disable fpassthru() and readfile() |
|
236 | - if (function_exists('readfile')) { |
|
237 | - readfile($serverFilename); |
|
238 | - } else { |
|
239 | - $fp = fopen($serverFilename, 'rb'); |
|
240 | - if (function_exists('fpassthru')) { |
|
241 | - fpassthru($fp); |
|
242 | - } else { |
|
243 | - while (!feof($fp)) { |
|
244 | - echo fread($fp, 65536); |
|
245 | - } |
|
246 | - } |
|
247 | - fclose($fp); |
|
248 | - } |
|
235 | + // Some servers disable fpassthru() and readfile() |
|
236 | + if (function_exists('readfile')) { |
|
237 | + readfile($serverFilename); |
|
238 | + } else { |
|
239 | + $fp = fopen($serverFilename, 'rb'); |
|
240 | + if (function_exists('fpassthru')) { |
|
241 | + fpassthru($fp); |
|
242 | + } else { |
|
243 | + while (!feof($fp)) { |
|
244 | + echo fread($fp, 65536); |
|
245 | + } |
|
246 | + } |
|
247 | + fclose($fp); |
|
248 | + } |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | 252 | * Render an error as an image. |
253 | 253 | */ |
254 | 254 | protected function renderError() { |
255 | - $error = I18N::translate('The media file was not found in this family tree.'); |
|
255 | + $error = I18N::translate('The media file was not found in this family tree.'); |
|
256 | 256 | |
257 | - $width = (mb_strlen($error) * 6.5 + 50) * 1.15; |
|
258 | - $height = 60; |
|
259 | - $im = imagecreatetruecolor($width, $height); /* Create a black image */ |
|
260 | - $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
|
261 | - imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
|
257 | + $width = (mb_strlen($error) * 6.5 + 50) * 1.15; |
|
258 | + $height = 60; |
|
259 | + $im = imagecreatetruecolor($width, $height); /* Create a black image */ |
|
260 | + $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
|
261 | + imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
|
262 | 262 | |
263 | - $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
263 | + $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
264 | 264 | |
265 | - http_response_code(404); |
|
266 | - header('Content-Type: image/png'); |
|
267 | - imagepng($im); |
|
268 | - imagedestroy($im); |
|
265 | + http_response_code(404); |
|
266 | + header('Content-Type: image/png'); |
|
267 | + imagepng($im); |
|
268 | + imagedestroy($im); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | */ |
278 | 278 | protected function applyWatermark($im) { |
279 | 279 | |
280 | - // text to watermark with |
|
281 | - if(method_exists($this->media, 'getWatermarkText')) { |
|
282 | - $word1_text = $this->media->getWatermarkText(); |
|
283 | - } |
|
284 | - else { |
|
285 | - $word1_text = $this->media->getTitle(); |
|
286 | - } |
|
280 | + // text to watermark with |
|
281 | + if(method_exists($this->media, 'getWatermarkText')) { |
|
282 | + $word1_text = $this->media->getWatermarkText(); |
|
283 | + } |
|
284 | + else { |
|
285 | + $word1_text = $this->media->getTitle(); |
|
286 | + } |
|
287 | 287 | |
288 | - $this->embedText( |
|
289 | - $im, |
|
290 | - $word1_text, |
|
291 | - $this->font_max_size, |
|
292 | - $this->font_color, |
|
293 | - WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
294 | - 'top', |
|
295 | - 'left' |
|
296 | - ); |
|
288 | + $this->embedText( |
|
289 | + $im, |
|
290 | + $word1_text, |
|
291 | + $this->font_max_size, |
|
292 | + $this->font_color, |
|
293 | + WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
294 | + 'top', |
|
295 | + 'left' |
|
296 | + ); |
|
297 | 297 | |
298 | - return ($im); |
|
298 | + return ($im); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -312,94 +312,94 @@ discard block |
||
312 | 312 | */ |
313 | 313 | protected function embedText($im, $text, $maxsize, $color, $font, $vpos, $hpos) { |
314 | 314 | |
315 | - // there are two ways to embed text with PHP |
|
316 | - // (preferred) using GD and FreeType you can embed text using any True Type font |
|
317 | - // (fall back) if that is not available, you can insert basic monospaced text |
|
315 | + // there are two ways to embed text with PHP |
|
316 | + // (preferred) using GD and FreeType you can embed text using any True Type font |
|
317 | + // (fall back) if that is not available, you can insert basic monospaced text |
|
318 | 318 | |
319 | - $col = $this->hexrgb($color); |
|
320 | - $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']); |
|
319 | + $col = $this->hexrgb($color); |
|
320 | + $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']); |
|
321 | 321 | |
322 | - // make adjustments to settings that imagestring and imagestringup can’t handle |
|
323 | - if (!$this->use_ttf) { |
|
324 | - // imagestringup only writes up, can’t use top2bottom |
|
325 | - if ($hpos === 'top2bottom') { |
|
326 | - $hpos = 'bottom2top'; |
|
327 | - } |
|
328 | - } |
|
322 | + // make adjustments to settings that imagestring and imagestringup can’t handle |
|
323 | + if (!$this->use_ttf) { |
|
324 | + // imagestringup only writes up, can’t use top2bottom |
|
325 | + if ($hpos === 'top2bottom') { |
|
326 | + $hpos = 'bottom2top'; |
|
327 | + } |
|
328 | + } |
|
329 | 329 | |
330 | - $text = I18N::reverseText($text); |
|
331 | - $height = imagesy($im); |
|
332 | - $width = imagesx($im); |
|
333 | - $calc_angle = rad2deg(atan($height / $width)); |
|
334 | - $hypoth = $height / sin(deg2rad($calc_angle)); |
|
330 | + $text = I18N::reverseText($text); |
|
331 | + $height = imagesy($im); |
|
332 | + $width = imagesx($im); |
|
333 | + $calc_angle = rad2deg(atan($height / $width)); |
|
334 | + $hypoth = $height / sin(deg2rad($calc_angle)); |
|
335 | 335 | |
336 | - // vertical and horizontal position of the text |
|
337 | - switch ($vpos) { |
|
338 | - default: |
|
339 | - case 'top': |
|
340 | - $taille = $this->textLength($maxsize, $width, $text); |
|
341 | - $pos_y = $height * 0.15 + $taille; |
|
342 | - $pos_x = $width * 0.15; |
|
343 | - $rotation = 0; |
|
344 | - break; |
|
345 | - case 'middle': |
|
346 | - $taille = $this->textLength($maxsize, $width, $text); |
|
347 | - $pos_y = ($height + $taille) / 2; |
|
348 | - $pos_x = $width * 0.15; |
|
349 | - $rotation = 0; |
|
350 | - break; |
|
351 | - case 'bottom': |
|
352 | - $taille = $this->textLength($maxsize, $width, $text); |
|
353 | - $pos_y = ($height * .85 - $taille); |
|
354 | - $pos_x = $width * 0.15; |
|
355 | - $rotation = 0; |
|
356 | - break; |
|
357 | - case 'across': |
|
358 | - switch ($hpos) { |
|
359 | - default: |
|
360 | - case 'left': |
|
361 | - $taille = $this->textLength($maxsize, $hypoth, $text); |
|
362 | - $pos_y = ($height * .85 - $taille); |
|
363 | - $pos_x = $width * 0.15; |
|
364 | - $rotation = $calc_angle; |
|
365 | - break; |
|
366 | - case 'right': |
|
367 | - $taille = $this->textLength($maxsize, $hypoth, $text); |
|
368 | - $pos_y = ($height * .15 - $taille); |
|
369 | - $pos_x = $width * 0.85; |
|
370 | - $rotation = $calc_angle + 180; |
|
371 | - break; |
|
372 | - case 'top2bottom': |
|
373 | - $taille = $this->textLength($maxsize, $height, $text); |
|
374 | - $pos_y = ($height * .15 - $taille); |
|
375 | - $pos_x = ($width * .90 - $taille); |
|
376 | - $rotation = -90; |
|
377 | - break; |
|
378 | - case 'bottom2top': |
|
379 | - $taille = $this->textLength($maxsize, $height, $text); |
|
380 | - $pos_y = $height * 0.85; |
|
381 | - $pos_x = $width * 0.15; |
|
382 | - $rotation = 90; |
|
383 | - break; |
|
384 | - } |
|
385 | - break; |
|
386 | - } |
|
336 | + // vertical and horizontal position of the text |
|
337 | + switch ($vpos) { |
|
338 | + default: |
|
339 | + case 'top': |
|
340 | + $taille = $this->textLength($maxsize, $width, $text); |
|
341 | + $pos_y = $height * 0.15 + $taille; |
|
342 | + $pos_x = $width * 0.15; |
|
343 | + $rotation = 0; |
|
344 | + break; |
|
345 | + case 'middle': |
|
346 | + $taille = $this->textLength($maxsize, $width, $text); |
|
347 | + $pos_y = ($height + $taille) / 2; |
|
348 | + $pos_x = $width * 0.15; |
|
349 | + $rotation = 0; |
|
350 | + break; |
|
351 | + case 'bottom': |
|
352 | + $taille = $this->textLength($maxsize, $width, $text); |
|
353 | + $pos_y = ($height * .85 - $taille); |
|
354 | + $pos_x = $width * 0.15; |
|
355 | + $rotation = 0; |
|
356 | + break; |
|
357 | + case 'across': |
|
358 | + switch ($hpos) { |
|
359 | + default: |
|
360 | + case 'left': |
|
361 | + $taille = $this->textLength($maxsize, $hypoth, $text); |
|
362 | + $pos_y = ($height * .85 - $taille); |
|
363 | + $pos_x = $width * 0.15; |
|
364 | + $rotation = $calc_angle; |
|
365 | + break; |
|
366 | + case 'right': |
|
367 | + $taille = $this->textLength($maxsize, $hypoth, $text); |
|
368 | + $pos_y = ($height * .15 - $taille); |
|
369 | + $pos_x = $width * 0.85; |
|
370 | + $rotation = $calc_angle + 180; |
|
371 | + break; |
|
372 | + case 'top2bottom': |
|
373 | + $taille = $this->textLength($maxsize, $height, $text); |
|
374 | + $pos_y = ($height * .15 - $taille); |
|
375 | + $pos_x = ($width * .90 - $taille); |
|
376 | + $rotation = -90; |
|
377 | + break; |
|
378 | + case 'bottom2top': |
|
379 | + $taille = $this->textLength($maxsize, $height, $text); |
|
380 | + $pos_y = $height * 0.85; |
|
381 | + $pos_x = $width * 0.15; |
|
382 | + $rotation = 90; |
|
383 | + break; |
|
384 | + } |
|
385 | + break; |
|
386 | + } |
|
387 | 387 | |
388 | - // apply the text |
|
389 | - if ($this->use_ttf) { |
|
390 | - // if imagettftext throws errors, catch them with a custom error handler |
|
391 | - set_error_handler(array($this, 'imageTtfTextErrorHandler')); |
|
392 | - imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text); |
|
393 | - restore_error_handler(); |
|
394 | - } |
|
395 | - // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false |
|
396 | - if (!$this->use_ttf) { |
|
397 | - if ($rotation !== 90) { |
|
398 | - imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
399 | - } else { |
|
400 | - imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
401 | - } |
|
402 | - } |
|
388 | + // apply the text |
|
389 | + if ($this->use_ttf) { |
|
390 | + // if imagettftext throws errors, catch them with a custom error handler |
|
391 | + set_error_handler(array($this, 'imageTtfTextErrorHandler')); |
|
392 | + imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text); |
|
393 | + restore_error_handler(); |
|
394 | + } |
|
395 | + // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false |
|
396 | + if (!$this->use_ttf) { |
|
397 | + if ($rotation !== 90) { |
|
398 | + imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
399 | + } else { |
|
400 | + imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
401 | + } |
|
402 | + } |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
@@ -411,53 +411,53 @@ discard block |
||
411 | 411 | */ |
412 | 412 | protected function hexrgb ($hexstr) |
413 | 413 | { |
414 | - $int = hexdec($hexstr); |
|
414 | + $int = hexdec($hexstr); |
|
415 | 415 | |
416 | - return array('red' => 0xFF & ($int >> 0x10), |
|
417 | - 'green' => 0xFF & ($int >> 0x8), |
|
418 | - 'blue' => 0xFF & $int); |
|
416 | + return array('red' => 0xFF & ($int >> 0x10), |
|
417 | + 'green' => 0xFF & ($int >> 0x8), |
|
418 | + 'blue' => 0xFF & $int); |
|
419 | 419 | } |
420 | 420 | |
421 | - /** |
|
422 | - * Generate an approximate length of text, in pixels. |
|
423 | - * |
|
424 | - * @param int $t |
|
425 | - * @param int $mxl |
|
426 | - * @param string $text |
|
427 | - * |
|
428 | - * @return int |
|
429 | - */ |
|
430 | - function textLength($t, $mxl, $text) { |
|
431 | - $taille_c = $t; |
|
432 | - $len = mb_strlen($text); |
|
433 | - while (($taille_c - 2) * $len > $mxl) { |
|
434 | - $taille_c--; |
|
435 | - if ($taille_c == 2) { |
|
436 | - break; |
|
437 | - } |
|
438 | - } |
|
421 | + /** |
|
422 | + * Generate an approximate length of text, in pixels. |
|
423 | + * |
|
424 | + * @param int $t |
|
425 | + * @param int $mxl |
|
426 | + * @param string $text |
|
427 | + * |
|
428 | + * @return int |
|
429 | + */ |
|
430 | + function textLength($t, $mxl, $text) { |
|
431 | + $taille_c = $t; |
|
432 | + $len = mb_strlen($text); |
|
433 | + while (($taille_c - 2) * $len > $mxl) { |
|
434 | + $taille_c--; |
|
435 | + if ($taille_c == 2) { |
|
436 | + break; |
|
437 | + } |
|
438 | + } |
|
439 | 439 | |
440 | - return $taille_c; |
|
441 | - } |
|
440 | + return $taille_c; |
|
441 | + } |
|
442 | 442 | |
443 | - /** |
|
444 | - * imagettftext is the function that is most likely to throw an error |
|
445 | - * use this custom error handler to catch and log it |
|
446 | - * |
|
447 | - * @param int $errno |
|
448 | - * @param string $errstr |
|
449 | - * |
|
450 | - * @return bool |
|
451 | - */ |
|
452 | - function imageTtfTextErrorHandler($errno, $errstr) { |
|
453 | - // log the error |
|
454 | - Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
443 | + /** |
|
444 | + * imagettftext is the function that is most likely to throw an error |
|
445 | + * use this custom error handler to catch and log it |
|
446 | + * |
|
447 | + * @param int $errno |
|
448 | + * @param string $errstr |
|
449 | + * |
|
450 | + * @return bool |
|
451 | + */ |
|
452 | + function imageTtfTextErrorHandler($errno, $errstr) { |
|
453 | + // log the error |
|
454 | + Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
455 | 455 | |
456 | - // change value of useTTF to false so the fallback watermarking can be used. |
|
457 | - $this->use_ttf = false; |
|
456 | + // change value of useTTF to false so the fallback watermarking can be used. |
|
457 | + $this->use_ttf = false; |
|
458 | 458 | |
459 | - return true; |
|
460 | - } |
|
459 | + return true; |
|
460 | + } |
|
461 | 461 | |
462 | 462 | } |
463 | 463 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param Media|null $media Reference media object |
64 | 64 | */ |
65 | - public function __construct(Media $media = null){ |
|
65 | + public function __construct(Media $media = null) { |
|
66 | 66 | $this->media = $media; |
67 | 67 | $this->use_ttf = function_exists('imagettftext'); |
68 | 68 | $this->expire_offset = 3600 * 24; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return ImageBuilder |
88 | 88 | */ |
89 | 89 | public function setExpireOffset($expireOffset) { |
90 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
90 | + if ($expireOffset) $this->expire_offset = $expireOffset; |
|
91 | 91 | return $this; |
92 | 92 | } |
93 | 93 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return ImageBuilder |
108 | 108 | */ |
109 | 109 | public function setShowWatermark($show_watermark) { |
110 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
110 | + if (!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return ImageBuilder |
119 | 119 | */ |
120 | 120 | public function setFontMaxSize($font_max_size) { |
121 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
121 | + if ($font_max_size) $this->font_max_size = $font_max_size; |
|
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
@@ -129,32 +129,32 @@ discard block |
||
129 | 129 | * @return ImageBuilder |
130 | 130 | */ |
131 | 131 | public function setFontColor($font_color) { |
132 | - if($font_color) $this->font_color = $font_color; |
|
132 | + if ($font_color) $this->font_color = $font_color; |
|
133 | 133 | return $this; |
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Render the image to the output. |
138 | 138 | */ |
139 | - public function render(){ |
|
139 | + public function render() { |
|
140 | 140 | |
141 | 141 | if (!$this->media || !$this->media->canShow()) { |
142 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
142 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('Missing or private media object.')); |
|
143 | 143 | $this->renderError(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | $serverFilename = $this->media->getServerFilename(); |
147 | 147 | |
148 | 148 | if (!file_exists($serverFilename)) { |
149 | - Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
149 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
150 | 150 | $this->renderError(); |
151 | 151 | } |
152 | 152 | |
153 | 153 | $mimetype = $this->media->mimeType(); |
154 | 154 | $imgsize = $this->media->getImageAttributes(); |
155 | 155 | $filetime = $this->media->getFiletime(); |
156 | - $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
157 | - $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
156 | + $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime).' GMT'; |
|
157 | + $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()).' GMT'; |
|
158 | 158 | |
159 | 159 | $type = Functions::isImageTypeSupported($imgsize['ext']); |
160 | 160 | $usewatermark = false; |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | // add caching headers. allow browser to cache file, but not proxy |
189 | - header('Last-Modified: ' . $filetimeHeader); |
|
190 | - header('ETag: "' . $etag . '"'); |
|
191 | - header('Expires: ' . $expireHeader); |
|
192 | - header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
189 | + header('Last-Modified: '.$filetimeHeader); |
|
190 | + header('ETag: "'.$etag.'"'); |
|
191 | + header('Expires: '.$expireHeader); |
|
192 | + header('Cache-Control: max-age='.$this->getExpireOffset().', s-maxage=0, proxy-revalidate'); |
|
193 | 193 | |
194 | 194 | // if this file is already in the user’s cache, don’t resend it |
195 | 195 | // first check if the if_modified_since param matches |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | // send headers for the image |
206 | - header('Content-Type: ' . $mimetype); |
|
207 | - header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
206 | + header('Content-Type: '.$mimetype); |
|
207 | + header('Content-Disposition: filename="'.addslashes(basename($this->media->getFilename())).'"'); |
|
208 | 208 | |
209 | 209 | if ($usewatermark) { |
210 | 210 | // generate the watermarked image |
211 | - $imCreateFunc = 'imagecreatefrom' . $type; |
|
212 | - $imSendFunc = 'image' . $type; |
|
211 | + $imCreateFunc = 'imagecreatefrom'.$type; |
|
212 | + $imSendFunc = 'image'.$type; |
|
213 | 213 | |
214 | 214 | if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
215 | 215 | $im = $imCreateFunc($serverFilename); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | return; |
223 | 223 | } else { |
224 | 224 | // this image is defective. log it |
225 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
225 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('This media file is broken and cannot be watermarked.').'< in file >'.$serverFilename.'< memory used: '.memory_get_usage()); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $filesize = filesize($serverFilename); |
231 | 231 | |
232 | 232 | // set content-length header, send file |
233 | - header('Content-Length: ' . $filesize); |
|
233 | + header('Content-Length: '.$filesize); |
|
234 | 234 | |
235 | 235 | // Some servers disable fpassthru() and readfile() |
236 | 236 | if (function_exists('readfile')) { |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
261 | 261 | imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
262 | 262 | |
263 | - $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
263 | + $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
264 | 264 | |
265 | 265 | http_response_code(404); |
266 | 266 | header('Content-Type: image/png'); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | protected function applyWatermark($im) { |
279 | 279 | |
280 | 280 | // text to watermark with |
281 | - if(method_exists($this->media, 'getWatermarkText')) { |
|
281 | + if (method_exists($this->media, 'getWatermarkText')) { |
|
282 | 282 | $word1_text = $this->media->getWatermarkText(); |
283 | 283 | } |
284 | 284 | else { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $word1_text, |
291 | 291 | $this->font_max_size, |
292 | 292 | $this->font_color, |
293 | - WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
293 | + WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, |
|
294 | 294 | 'top', |
295 | 295 | 'left' |
296 | 296 | ); |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @param string $hexstr |
410 | 410 | * @return int[] |
411 | 411 | */ |
412 | - protected function hexrgb ($hexstr) |
|
412 | + protected function hexrgb($hexstr) |
|
413 | 413 | { |
414 | 414 | $int = hexdec($hexstr); |
415 | 415 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | */ |
452 | 452 | function imageTtfTextErrorHandler($errno, $errstr) { |
453 | 453 | // log the error |
454 | - Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
454 | + Log::addErrorLog('Image Builder error: >'.$errno.'/'.$errstr.'< while processing file >'.$this->media->getServerFilename().'<'); |
|
455 | 455 | |
456 | 456 | // change value of useTTF to false so the fallback watermarking can be used. |
457 | 457 | $this->use_ttf = false; |
@@ -87,7 +87,9 @@ discard block |
||
87 | 87 | * @return ImageBuilder |
88 | 88 | */ |
89 | 89 | public function setExpireOffset($expireOffset) { |
90 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
90 | + if($expireOffset) { |
|
91 | + $this->expire_offset = $expireOffset; |
|
92 | + } |
|
91 | 93 | return $this; |
92 | 94 | } |
93 | 95 | |
@@ -107,7 +109,9 @@ discard block |
||
107 | 109 | * @return ImageBuilder |
108 | 110 | */ |
109 | 111 | public function setShowWatermark($show_watermark) { |
110 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
112 | + if(!is_null($show_watermark)) { |
|
113 | + $this->show_watermark = $show_watermark; |
|
114 | + } |
|
111 | 115 | return $this; |
112 | 116 | } |
113 | 117 | |
@@ -118,7 +122,9 @@ discard block |
||
118 | 122 | * @return ImageBuilder |
119 | 123 | */ |
120 | 124 | public function setFontMaxSize($font_max_size) { |
121 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
125 | + if($font_max_size) { |
|
126 | + $this->font_max_size = $font_max_size; |
|
127 | + } |
|
122 | 128 | return $this; |
123 | 129 | } |
124 | 130 | |
@@ -129,7 +135,9 @@ discard block |
||
129 | 135 | * @return ImageBuilder |
130 | 136 | */ |
131 | 137 | public function setFontColor($font_color) { |
132 | - if($font_color) $this->font_color = $font_color; |
|
138 | + if($font_color) { |
|
139 | + $this->font_color = $font_color; |
|
140 | + } |
|
133 | 141 | return $this; |
134 | 142 | } |
135 | 143 | |
@@ -280,8 +288,7 @@ discard block |
||
280 | 288 | // text to watermark with |
281 | 289 | if(method_exists($this->media, 'getWatermarkText')) { |
282 | 290 | $word1_text = $this->media->getWatermarkText(); |
283 | - } |
|
284 | - else { |
|
291 | + } else { |
|
285 | 292 | $word1_text = $this->media->getTitle(); |
286 | 293 | } |
287 | 294 |
@@ -74,16 +74,14 @@ |
||
74 | 74 | if(is_int($key)) { |
75 | 75 | $hook_item = $value; |
76 | 76 | $priority = self::DEFAULT_PRIORITY; |
77 | - } |
|
78 | - else{ |
|
77 | + } else{ |
|
79 | 78 | $hook_item = explode('#', $key, 2); |
80 | 79 | $priority = $value; |
81 | 80 | } |
82 | 81 | if($hook_item && count($hook_item) == 2){ |
83 | 82 | $hook_func = $hook_item[0]; |
84 | 83 | $hook_cont = $hook_item[1]; |
85 | - } |
|
86 | - else{ |
|
84 | + } else{ |
|
87 | 85 | $hook_func = $hook_item[0]; |
88 | 86 | $hook_cont = 'all'; |
89 | 87 | } |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function getInstance() |
44 | 44 | { |
45 | - if (null === static::$instance) { |
|
46 | - static::$instance = new static(); |
|
47 | - } |
|
45 | + if (null === static::$instance) { |
|
46 | + static::$instance = new static(); |
|
47 | + } |
|
48 | 48 | |
49 | - return static::$instance; |
|
49 | + return static::$instance; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::get() |
55 | 55 | */ |
56 | 56 | public function get($hook_function, $hook_context = null) { |
57 | - return new Hook($hook_function, $hook_context); |
|
57 | + return new Hook($hook_function, $hook_context); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | public function getPossibleHooks() { |
73 | 73 | static $hooks=null; |
74 | 74 | if ($hooks === null) { |
75 | - $hooks = array(); |
|
76 | - foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) { |
|
77 | - try { |
|
78 | - $module = include $file; |
|
79 | - if($module instanceof HookSubscriberInterface){ |
|
75 | + $hooks = array(); |
|
76 | + foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) { |
|
77 | + try { |
|
78 | + $module = include $file; |
|
79 | + if($module instanceof HookSubscriberInterface){ |
|
80 | 80 | $subscribedhooks = $module->getSubscribedHooks(); |
81 | 81 | if(is_array($subscribedhooks)){ |
82 | 82 | foreach($subscribedhooks as $key => $value){ |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
105 | - } catch (\Exception $ex) { |
|
106 | - // Old or invalid module? |
|
107 | - } |
|
105 | + } catch (\Exception $ex) { |
|
106 | + // Old or invalid module? |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | return $hooks; |
@@ -146,33 +146,33 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function updateHooks() { |
148 | 148 | |
149 | - if(Auth::isAdmin()){ |
|
150 | - $ihooks = self::getInstalledHooks(); |
|
151 | - $phooks = self::getPossibleHooks(); |
|
149 | + if(Auth::isAdmin()){ |
|
150 | + $ihooks = self::getInstalledHooks(); |
|
151 | + $phooks = self::getPossibleHooks(); |
|
152 | 152 | |
153 | - // Insert hooks not existing yet in the DB |
|
154 | - if($phooks !== null){ |
|
155 | - foreach($phooks as $phook => $priority){ |
|
156 | - $array_hook = explode('#', $phook); |
|
157 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
158 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
159 | - $chook->subscribe($array_hook[0]); |
|
160 | - $chook->setPriority($array_hook[0], $priority); |
|
161 | - } |
|
162 | - } |
|
163 | - } |
|
153 | + // Insert hooks not existing yet in the DB |
|
154 | + if($phooks !== null){ |
|
155 | + foreach($phooks as $phook => $priority){ |
|
156 | + $array_hook = explode('#', $phook); |
|
157 | + if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
158 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
159 | + $chook->subscribe($array_hook[0]); |
|
160 | + $chook->setPriority($array_hook[0], $priority); |
|
161 | + } |
|
162 | + } |
|
163 | + } |
|
164 | 164 | |
165 | - //Remove hooks not existing any more in the file system |
|
166 | - if($ihooks !== null){ |
|
167 | - foreach($ihooks as $ihook => $status){ |
|
168 | - $array_hook = explode('#', $ihook); |
|
169 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
170 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
171 | - $chook->remove($array_hook[0]); |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
165 | + //Remove hooks not existing any more in the file system |
|
166 | + if($ihooks !== null){ |
|
167 | + foreach($ihooks as $ihook => $status){ |
|
168 | + $array_hook = explode('#', $ihook); |
|
169 | + if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
170 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
171 | + $chook->remove($array_hook[0]); |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | } |
179 | 179 | \ No newline at end of file |
@@ -70,34 +70,34 @@ discard block |
||
70 | 70 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getPossibleHooks() |
71 | 71 | */ |
72 | 72 | public function getPossibleHooks() { |
73 | - static $hooks=null; |
|
73 | + static $hooks = null; |
|
74 | 74 | if ($hooks === null) { |
75 | 75 | $hooks = array(); |
76 | - foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) { |
|
76 | + foreach (glob(WT_ROOT.WT_MODULES_DIR.'*/module.php') as $file) { |
|
77 | 77 | try { |
78 | 78 | $module = include $file; |
79 | - if($module instanceof HookSubscriberInterface){ |
|
79 | + if ($module instanceof HookSubscriberInterface) { |
|
80 | 80 | $subscribedhooks = $module->getSubscribedHooks(); |
81 | - if(is_array($subscribedhooks)){ |
|
82 | - foreach($subscribedhooks as $key => $value){ |
|
83 | - if(is_int($key)) { |
|
81 | + if (is_array($subscribedhooks)) { |
|
82 | + foreach ($subscribedhooks as $key => $value) { |
|
83 | + if (is_int($key)) { |
|
84 | 84 | $hook_item = $value; |
85 | 85 | $priority = self::DEFAULT_PRIORITY; |
86 | 86 | } |
87 | - else{ |
|
87 | + else { |
|
88 | 88 | $hook_item = explode('#', $key, 2); |
89 | 89 | $priority = $value; |
90 | 90 | } |
91 | - if($hook_item && count($hook_item) == 2){ |
|
91 | + if ($hook_item && count($hook_item) == 2) { |
|
92 | 92 | $hook_func = $hook_item[0]; |
93 | 93 | $hook_cont = $hook_item[1]; |
94 | 94 | } |
95 | - else{ |
|
95 | + else { |
|
96 | 96 | $hook_func = $hook_item[0]; |
97 | 97 | $hook_cont = 'all'; |
98 | 98 | } |
99 | - if(method_exists($module, $hook_func)){ |
|
100 | - $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont]=$priority; |
|
99 | + if (method_exists($module, $hook_func)) { |
|
100 | + $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont] = $priority; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * {@inheritDoc} |
115 | 115 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getRawInstalledHooks() |
116 | 116 | */ |
117 | - public function getRawInstalledHooks(){ |
|
118 | - if(self::isModuleOperational()){ |
|
117 | + public function getRawInstalledHooks() { |
|
118 | + if (self::isModuleOperational()) { |
|
119 | 119 | return fw\Database::prepare( |
120 | 120 | "SELECT majh_id AS id, majh_module_name AS module, majh_hook_function AS hook, majh_hook_context as context, majh_module_priority AS priority, majh_status AS status". |
121 | 121 | " FROM `##maj_hooks`". |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | * {@inheritDoc} |
130 | 130 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getInstalledHooks() |
131 | 131 | */ |
132 | - public function getInstalledHooks(){ |
|
133 | - static $installedhooks =null; |
|
134 | - if($installedhooks===null){ |
|
135 | - $dbhooks=self::getRawInstalledHooks(); |
|
136 | - foreach($dbhooks as $dbhook){ |
|
132 | + public function getInstalledHooks() { |
|
133 | + static $installedhooks = null; |
|
134 | + if ($installedhooks === null) { |
|
135 | + $dbhooks = self::getRawInstalledHooks(); |
|
136 | + foreach ($dbhooks as $dbhook) { |
|
137 | 137 | $installedhooks[($dbhook->module).'#'.($dbhook->hook).'#'.($dbhook->context)] = array('id' => $dbhook->id, 'status' => $dbhook->status, 'priority' => $dbhook->priority); |
138 | 138 | } |
139 | 139 | } |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function updateHooks() { |
148 | 148 | |
149 | - if(Auth::isAdmin()){ |
|
149 | + if (Auth::isAdmin()) { |
|
150 | 150 | $ihooks = self::getInstalledHooks(); |
151 | 151 | $phooks = self::getPossibleHooks(); |
152 | 152 | |
153 | 153 | // Insert hooks not existing yet in the DB |
154 | - if($phooks !== null){ |
|
155 | - foreach($phooks as $phook => $priority){ |
|
154 | + if ($phooks !== null) { |
|
155 | + foreach ($phooks as $phook => $priority) { |
|
156 | 156 | $array_hook = explode('#', $phook); |
157 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
157 | + if ($ihooks === null || !array_key_exists($phook, $ihooks)) { |
|
158 | 158 | $chook = new Hook($array_hook[1], $array_hook[2]); |
159 | 159 | $chook->subscribe($array_hook[0]); |
160 | 160 | $chook->setPriority($array_hook[0], $priority); |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | //Remove hooks not existing any more in the file system |
166 | - if($ihooks !== null){ |
|
167 | - foreach($ihooks as $ihook => $status){ |
|
166 | + if ($ihooks !== null) { |
|
167 | + foreach ($ihooks as $ihook => $status) { |
|
168 | 168 | $array_hook = explode('#', $ihook); |
169 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
169 | + if ($phooks === null || !array_key_exists($ihook, $phooks)) { |
|
170 | 170 | $chook = new Hook($array_hook[1], $array_hook[2]); |
171 | 171 | $chook->remove($array_hook[0]); |
172 | 172 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * webtrees-lib: MyArtJaub library for webtrees |
|
4 | - * |
|
5 | - * @package MyArtJaub\Webtrees |
|
6 | - * @subpackage Hook |
|
7 | - * @author Jonathan Jaubart <[email protected]> |
|
8 | - * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
9 | - * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10 | - */ |
|
3 | + * webtrees-lib: MyArtJaub library for webtrees |
|
4 | + * |
|
5 | + * @package MyArtJaub\Webtrees |
|
6 | + * @subpackage Hook |
|
7 | + * @author Jonathan Jaubart <[email protected]> |
|
8 | + * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
9 | + * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10 | + */ |
|
11 | 11 | namespace MyArtJaub\Webtrees\Hook; |
12 | 12 | |
13 | 13 | use \Fisharebest\Webtrees as fw; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string $hook_function_in Hook function to be subscribed or executed |
31 | 31 | * @param string $hook_context_in Hook context to be subscribed or executed |
32 | 32 | */ |
33 | - public function __construct($hook_function_in, $hook_context_in = 'all'){ |
|
33 | + public function __construct($hook_function_in, $hook_context_in = 'all') { |
|
34 | 34 | $this->hook_function = $hook_function_in; |
35 | 35 | $this->hook_context = $hook_context_in; |
36 | 36 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param string $hsubscriber Name of the subscriber module |
48 | 48 | */ |
49 | - public function subscribe($hsubscriber){ |
|
50 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
49 | + public function subscribe($hsubscriber) { |
|
50 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
51 | 51 | $statement = fw\Database::prepare( |
52 | 52 | "INSERT IGNORE INTO `##maj_hooks` (majh_hook_function, majh_hook_context, majh_module_name)". |
53 | 53 | " VALUES (?, ?, ?)" |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param string $hsubscriber Name of the subscriber module |
62 | 62 | * @param int $priority Priority of execution |
63 | 63 | */ |
64 | - public function setPriority($hsubscriber, $priority){ |
|
65 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
64 | + public function setPriority($hsubscriber, $priority) { |
|
65 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
66 | 66 | fw\Database::prepare( |
67 | 67 | "UPDATE `##maj_hooks`". |
68 | 68 | " SET majh_module_priority=?". |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param string $hsubscriber Name of the subscriber module |
80 | 80 | */ |
81 | - public function enable($hsubscriber){ |
|
82 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
81 | + public function enable($hsubscriber) { |
|
82 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
83 | 83 | fw\Database::prepare( |
84 | 84 | "UPDATE `##maj_hooks`". |
85 | 85 | " SET majh_status='enabled'". |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param string $hsubscriber Name of the subscriber module |
97 | 97 | */ |
98 | - public function disable($hsubscriber){ |
|
99 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
98 | + public function disable($hsubscriber) { |
|
99 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
100 | 100 | fw\Database::prepare( |
101 | 101 | "UPDATE `##maj_hooks`". |
102 | 102 | " SET majh_status='disabled'". |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @param string $hsubscriber Name of the subscriber module |
114 | 114 | */ |
115 | - public function remove($hsubscriber){ |
|
116 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
115 | + public function remove($hsubscriber) { |
|
116 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
117 | 117 | fw\Database::prepare( |
118 | 118 | "DELETE FROM `##maj_hooks`". |
119 | 119 | " WHERE majh_hook_function=?". |
@@ -135,24 +135,24 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return array Results of the hook executions |
137 | 137 | */ |
138 | - public function execute(){ |
|
138 | + public function execute() { |
|
139 | 139 | $result = array(); |
140 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
140 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
141 | 141 | $params = func_get_args(); |
142 | 142 | $sqlquery = ''; |
143 | 143 | $sqlparams = array($this->hook_function); |
144 | - if($this->hook_context != 'all') { |
|
144 | + if ($this->hook_context != 'all') { |
|
145 | 145 | $sqlparams = array($this->hook_function, $this->hook_context); |
146 | 146 | $sqlquery = " OR majh_hook_context=?"; |
147 | 147 | } |
148 | - $module_names=fw\Database::prepare( |
|
148 | + $module_names = fw\Database::prepare( |
|
149 | 149 | "SELECT majh_module_name AS module, majh_module_priority AS priority FROM `##maj_hooks`". |
150 | 150 | " WHERE majh_hook_function = ? AND (majh_hook_context='all'".$sqlquery.") AND majh_status='enabled'". |
151 | 151 | " ORDER BY majh_module_priority ASC, module ASC" |
152 | 152 | )->execute($sqlparams)->fetchAssoc(); |
153 | 153 | asort($module_names); |
154 | 154 | foreach ($module_names as $module_name => $module_priority) { |
155 | - $module = include WT_ROOT . WT_MODULES_DIR . $module_name . '/module.php'; |
|
155 | + $module = include WT_ROOT.WT_MODULES_DIR.$module_name.'/module.php'; |
|
156 | 156 | $result[] = call_user_func_array(array($module, $this->hook_function), $params); |
157 | 157 | } |
158 | 158 | } |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return int Number of active modules |
166 | 166 | */ |
167 | - public function getNumberActiveModules(){ |
|
168 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
167 | + public function getNumberActiveModules() { |
|
168 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
169 | 169 | $sqlquery = ''; |
170 | 170 | $sqlparams = array($this->hook_function); |
171 | - if($this->hook_context != 'all') { |
|
171 | + if ($this->hook_context != 'all') { |
|
172 | 172 | $sqlparams = array($this->hook_function, $this->hook_context); |
173 | 173 | $sqlquery = " OR majh_hook_context=?"; |
174 | 174 | } |
175 | - $module_names=fw\Database::prepare( |
|
175 | + $module_names = fw\Database::prepare( |
|
176 | 176 | "SELECT majh_module_name AS modules FROM `##maj_hooks`". |
177 | 177 | " WHERE majh_hook_function = ? AND (majh_hook_context='all'".$sqlquery.") AND majh_status='enabled'" |
178 | 178 | )->execute($sqlparams)->fetchOneColumn(); |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return bool True is active modules exist, false otherwise |
188 | 188 | */ |
189 | - public function hasAnyActiveModule(){ |
|
190 | - return ($this->getNumberActiveModules()>0); |
|
189 | + public function hasAnyActiveModule() { |
|
190 | + return ($this->getNumberActiveModules() > 0); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | } |
@@ -15,13 +15,13 @@ |
||
15 | 15 | */ |
16 | 16 | interface HookSubscriberInterface { |
17 | 17 | |
18 | - /** |
|
18 | + /** |
|
19 | 19 | * Return the list of functions implementented in the class which needs to be registered as hooks. |
20 | 20 | * The format is either { function1, function 2,...} in which case the priority is the default one |
21 | 21 | * or { function1 => priority1, function2 => priority2, ...} |
22 | 22 | * |
23 | 23 | * @return array Array of hooks |
24 | 24 | */ |
25 | - public function getSubscribedHooks(); |
|
25 | + public function getSubscribedHooks(); |
|
26 | 26 | |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -19,6 +19,7 @@ discard block |
||
19 | 19 | * Insert some content before the fact source text. |
20 | 20 | * |
21 | 21 | * @param string $srec Source fact record |
22 | + * @return string |
|
22 | 23 | */ |
23 | 24 | public function hFactSourcePrepend($srec); |
24 | 25 | |
@@ -26,6 +27,7 @@ discard block |
||
26 | 27 | * Insert some content after the fact source text. |
27 | 28 | * |
28 | 29 | * @param string $srec Source fact record |
30 | + * @return void |
|
29 | 31 | */ |
30 | 32 | public function hFactSourceAppend($srec); |
31 | 33 |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * webtrees-lib: MyArtJaub library for webtrees |
|
4 | - * |
|
5 | - * @package MyArtJaub\Webtrees |
|
6 | - * @subpackage Hook |
|
7 | - * @author Jonathan Jaubart <[email protected]> |
|
8 | - * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
9 | - * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10 | - */ |
|
3 | + * webtrees-lib: MyArtJaub library for webtrees |
|
4 | + * |
|
5 | + * @package MyArtJaub\Webtrees |
|
6 | + * @subpackage Hook |
|
7 | + * @author Jonathan Jaubart <[email protected]> |
|
8 | + * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
9 | + * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10 | + */ |
|
11 | 11 | namespace MyArtJaub\Webtrees\Hook\HookInterfaces; |
12 | 12 | |
13 | 13 | /** |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | interface CustomSimpleTagManager { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Returns the list of expected tags, classified by type of records. |
|
23 | - * |
|
24 | - * @return array List of expected tags |
|
25 | - */ |
|
26 | - public function hGetExpectedTags(); |
|
21 | + /** |
|
22 | + * Returns the list of expected tags, classified by type of records. |
|
23 | + * |
|
24 | + * @return array List of expected tags |
|
25 | + */ |
|
26 | + public function hGetExpectedTags(); |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Return the HTML code to be display for this tag. |