@@ -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(); |
@@ -15,66 +15,66 @@ |
||
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 | - ob_start(); |
|
68 | - $html_render = $this->renderContent(); |
|
69 | - $html_buffer = ob_get_clean(); |
|
63 | + /** |
|
64 | + * Return the HTML code generated by the view, without any header |
|
65 | + */ |
|
66 | + public function getHtmlPartial() { |
|
67 | + ob_start(); |
|
68 | + $html_render = $this->renderContent(); |
|
69 | + $html_buffer = ob_get_clean(); |
|
70 | 70 | |
71 | - return empty($html_render) ? $html_buffer : $html_render; |
|
72 | - } |
|
71 | + return empty($html_render) ? $html_buffer : $html_render; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Abstract method containing the details of the view. |
|
76 | - */ |
|
77 | - abstract protected function renderContent(); |
|
74 | + /** |
|
75 | + * Abstract method containing the details of the view. |
|
76 | + */ |
|
77 | + abstract protected function renderContent(); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | \ No newline at end of file |
@@ -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 |
@@ -22,54 +22,54 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class ImageBuilder { |
24 | 24 | |
25 | - /** |
|
26 | - * Reference media |
|
27 | - * @var Media $media |
|
28 | - */ |
|
29 | - protected $media; |
|
25 | + /** |
|
26 | + * Reference media |
|
27 | + * @var Media $media |
|
28 | + */ |
|
29 | + protected $media; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Use TTF font |
|
33 | - * @var bool $use_ttf |
|
34 | - */ |
|
35 | - protected $use_ttf; |
|
31 | + /** |
|
32 | + * Use TTF font |
|
33 | + * @var bool $use_ttf |
|
34 | + */ |
|
35 | + protected $use_ttf; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Expiration offset. Default is one day. |
|
39 | - * @var int $expire_offset |
|
40 | - */ |
|
41 | - protected $expire_offset; |
|
37 | + /** |
|
38 | + * Expiration offset. Default is one day. |
|
39 | + * @var int $expire_offset |
|
40 | + */ |
|
41 | + protected $expire_offset; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Should the certificate display a watermark |
|
45 | - * @var bool $show_watermark |
|
46 | - */ |
|
47 | - protected $show_watermark; |
|
43 | + /** |
|
44 | + * Should the certificate display a watermark |
|
45 | + * @var bool $show_watermark |
|
46 | + */ |
|
47 | + protected $show_watermark; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Maximum watermark font size. Default is 18. |
|
51 | - * @var int $font_max_size |
|
52 | - */ |
|
53 | - protected $font_max_size; |
|
49 | + /** |
|
50 | + * Maximum watermark font size. Default is 18. |
|
51 | + * @var int $font_max_size |
|
52 | + */ |
|
53 | + protected $font_max_size; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Watermark font color, in hexadecimal. Default is #4D6DF3. |
|
57 | - * @var string $font_color |
|
58 | - */ |
|
59 | - protected $font_color; |
|
55 | + /** |
|
56 | + * Watermark font color, in hexadecimal. Default is #4D6DF3. |
|
57 | + * @var string $font_color |
|
58 | + */ |
|
59 | + protected $font_color; |
|
60 | 60 | |
61 | 61 | /** |
62 | - * Contructor for ImageBuilder |
|
63 | - * |
|
64 | - * @param Media|null $media Reference media object |
|
65 | - */ |
|
62 | + * Contructor for ImageBuilder |
|
63 | + * |
|
64 | + * @param Media|null $media Reference media object |
|
65 | + */ |
|
66 | 66 | public function __construct(Media $media = null){ |
67 | - $this->media = $media; |
|
68 | - $this->use_ttf = function_exists('imagettftext'); |
|
69 | - $this->expire_offset = 3600 * 24; |
|
70 | - $this->show_watermark = true; |
|
71 | - $this->font_max_size = 18; |
|
72 | - $this->font_color = '#4D6DF3'; |
|
67 | + $this->media = $media; |
|
68 | + $this->use_ttf = function_exists('imagettftext'); |
|
69 | + $this->expire_offset = 3600 * 24; |
|
70 | + $this->show_watermark = true; |
|
71 | + $this->font_max_size = 18; |
|
72 | + $this->font_color = '#4D6DF3'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return int |
79 | 79 | */ |
80 | 80 | public function getExpireOffset() { |
81 | - return $this->expire_offset; |
|
81 | + return $this->expire_offset; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @return ImageBuilder |
89 | 89 | */ |
90 | 90 | public function setExpireOffset($expireOffset) { |
91 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
92 | - return $this; |
|
91 | + if($expireOffset) $this->expire_offset = $expireOffset; |
|
92 | + return $this; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @return bool |
99 | 99 | */ |
100 | 100 | public function isShowWatermark() { |
101 | - return $this->show_watermark; |
|
101 | + return $this->show_watermark; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @return ImageBuilder |
109 | 109 | */ |
110 | 110 | public function setShowWatermark($show_watermark) { |
111 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
112 | - return $this; |
|
111 | + if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
112 | + return $this; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @return ImageBuilder |
120 | 120 | */ |
121 | 121 | public function setFontMaxSize($font_max_size) { |
122 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
123 | - return $this; |
|
122 | + if($font_max_size) $this->font_max_size = $font_max_size; |
|
123 | + return $this; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | * @return ImageBuilder |
131 | 131 | */ |
132 | 132 | public function setFontColor($font_color) { |
133 | - if($font_color) $this->font_color = $font_color; |
|
134 | - return $this; |
|
133 | + if($font_color) $this->font_color = $font_color; |
|
134 | + return $this; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,134 +139,134 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function render(){ |
141 | 141 | |
142 | - if (!$this->media || !$this->media->canShow()) { |
|
143 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
144 | - $this->renderError(); |
|
145 | - } |
|
142 | + if (!$this->media || !$this->media->canShow()) { |
|
143 | + Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
144 | + $this->renderError(); |
|
145 | + } |
|
146 | 146 | |
147 | - $serverFilename = $this->media->getServerFilename(); |
|
147 | + $serverFilename = $this->media->getServerFilename(); |
|
148 | 148 | |
149 | - if (!file_exists($serverFilename)) { |
|
150 | - Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
151 | - $this->renderError(); |
|
152 | - } |
|
149 | + if (!file_exists($serverFilename)) { |
|
150 | + Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
151 | + $this->renderError(); |
|
152 | + } |
|
153 | 153 | |
154 | - $mimetype = $this->media->mimeType(); |
|
155 | - $imgsize = $this->media->getImageAttributes(); |
|
156 | - $filetime = $this->media->getFiletime(); |
|
157 | - $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
158 | - $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
154 | + $mimetype = $this->media->mimeType(); |
|
155 | + $imgsize = $this->media->getImageAttributes(); |
|
156 | + $filetime = $this->media->getFiletime(); |
|
157 | + $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
158 | + $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
159 | 159 | |
160 | - $type = Functions::isImageTypeSupported($imgsize['ext']); |
|
161 | - $usewatermark = false; |
|
162 | - // if this image supports watermarks and the watermark module is intalled... |
|
163 | - if ($type) { |
|
164 | - $usewatermark = $this->isShowWatermark(); |
|
165 | - } |
|
160 | + $type = Functions::isImageTypeSupported($imgsize['ext']); |
|
161 | + $usewatermark = false; |
|
162 | + // if this image supports watermarks and the watermark module is intalled... |
|
163 | + if ($type) { |
|
164 | + $usewatermark = $this->isShowWatermark(); |
|
165 | + } |
|
166 | 166 | |
167 | - // determine whether we have enough memory to watermark this image |
|
168 | - if ($usewatermark) { |
|
169 | - if (!FunctionsMedia::hasMemoryForImage($serverFilename)) { |
|
170 | - // not enough memory to watermark this file |
|
171 | - $usewatermark = false; |
|
172 | - } |
|
173 | - } |
|
167 | + // determine whether we have enough memory to watermark this image |
|
168 | + if ($usewatermark) { |
|
169 | + if (!FunctionsMedia::hasMemoryForImage($serverFilename)) { |
|
170 | + // not enough memory to watermark this file |
|
171 | + $usewatermark = false; |
|
172 | + } |
|
173 | + } |
|
174 | 174 | |
175 | - $etag = $this->media->getEtag(); |
|
175 | + $etag = $this->media->getEtag(); |
|
176 | 176 | |
177 | - // parse IF_MODIFIED_SINCE header from client |
|
178 | - $if_modified_since = 'x'; |
|
179 | - if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) { |
|
180 | - $if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE')); |
|
181 | - } |
|
177 | + // parse IF_MODIFIED_SINCE header from client |
|
178 | + $if_modified_since = 'x'; |
|
179 | + if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) { |
|
180 | + $if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE')); |
|
181 | + } |
|
182 | 182 | |
183 | - // parse IF_NONE_MATCH header from client |
|
184 | - $if_none_match = 'x'; |
|
185 | - if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) { |
|
186 | - $if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH')); |
|
187 | - } |
|
183 | + // parse IF_NONE_MATCH header from client |
|
184 | + $if_none_match = 'x'; |
|
185 | + if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) { |
|
186 | + $if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH')); |
|
187 | + } |
|
188 | 188 | |
189 | - // add caching headers. allow browser to cache file, but not proxy |
|
190 | - header('Last-Modified: ' . $filetimeHeader); |
|
191 | - header('ETag: "' . $etag . '"'); |
|
192 | - header('Expires: ' . $expireHeader); |
|
193 | - header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
189 | + // add caching headers. allow browser to cache file, but not proxy |
|
190 | + header('Last-Modified: ' . $filetimeHeader); |
|
191 | + header('ETag: "' . $etag . '"'); |
|
192 | + header('Expires: ' . $expireHeader); |
|
193 | + header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
194 | 194 | |
195 | - // if this file is already in the user’s cache, don’t resend it |
|
196 | - // first check if the if_modified_since param matches |
|
197 | - if ($if_modified_since === $filetimeHeader) { |
|
198 | - // then check if the etag matches |
|
199 | - if ($if_none_match === $etag) { |
|
200 | - http_response_code(304); |
|
195 | + // if this file is already in the user’s cache, don’t resend it |
|
196 | + // first check if the if_modified_since param matches |
|
197 | + if ($if_modified_since === $filetimeHeader) { |
|
198 | + // then check if the etag matches |
|
199 | + if ($if_none_match === $etag) { |
|
200 | + http_response_code(304); |
|
201 | 201 | |
202 | - return; |
|
203 | - } |
|
204 | - } |
|
202 | + return; |
|
203 | + } |
|
204 | + } |
|
205 | 205 | |
206 | - // send headers for the image |
|
207 | - header('Content-Type: ' . $mimetype); |
|
208 | - header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
206 | + // send headers for the image |
|
207 | + header('Content-Type: ' . $mimetype); |
|
208 | + header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
209 | 209 | |
210 | - if ($usewatermark) { |
|
211 | - // generate the watermarked image |
|
212 | - $imCreateFunc = 'imagecreatefrom' . $type; |
|
213 | - $imSendFunc = 'image' . $type; |
|
210 | + if ($usewatermark) { |
|
211 | + // generate the watermarked image |
|
212 | + $imCreateFunc = 'imagecreatefrom' . $type; |
|
213 | + $imSendFunc = 'image' . $type; |
|
214 | 214 | |
215 | - if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
|
216 | - $im = $imCreateFunc($serverFilename); |
|
217 | - $im = $this->applyWatermark($im); |
|
215 | + if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
|
216 | + $im = $imCreateFunc($serverFilename); |
|
217 | + $im = $this->applyWatermark($im); |
|
218 | 218 | |
219 | - // send the image |
|
220 | - $imSendFunc($im); |
|
221 | - imagedestroy($im); |
|
219 | + // send the image |
|
220 | + $imSendFunc($im); |
|
221 | + imagedestroy($im); |
|
222 | 222 | |
223 | - return; |
|
224 | - } else { |
|
225 | - // this image is defective. log it |
|
226 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
227 | - } |
|
228 | - } |
|
223 | + return; |
|
224 | + } else { |
|
225 | + // this image is defective. log it |
|
226 | + Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | - // determine filesize of image (could be original or watermarked version) |
|
231 | - $filesize = filesize($serverFilename); |
|
230 | + // determine filesize of image (could be original or watermarked version) |
|
231 | + $filesize = filesize($serverFilename); |
|
232 | 232 | |
233 | - // set content-length header, send file |
|
234 | - header('Content-Length: ' . $filesize); |
|
233 | + // set content-length header, send file |
|
234 | + header('Content-Length: ' . $filesize); |
|
235 | 235 | |
236 | - // Some servers disable fpassthru() and readfile() |
|
237 | - if (function_exists('readfile')) { |
|
238 | - readfile($serverFilename); |
|
239 | - } else { |
|
240 | - $fp = fopen($serverFilename, 'rb'); |
|
241 | - if (function_exists('fpassthru')) { |
|
242 | - fpassthru($fp); |
|
243 | - } else { |
|
244 | - while (!feof($fp)) { |
|
245 | - echo fread($fp, 65536); |
|
246 | - } |
|
247 | - } |
|
248 | - fclose($fp); |
|
249 | - } |
|
236 | + // Some servers disable fpassthru() and readfile() |
|
237 | + if (function_exists('readfile')) { |
|
238 | + readfile($serverFilename); |
|
239 | + } else { |
|
240 | + $fp = fopen($serverFilename, 'rb'); |
|
241 | + if (function_exists('fpassthru')) { |
|
242 | + fpassthru($fp); |
|
243 | + } else { |
|
244 | + while (!feof($fp)) { |
|
245 | + echo fread($fp, 65536); |
|
246 | + } |
|
247 | + } |
|
248 | + fclose($fp); |
|
249 | + } |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Render an error as an image. |
254 | 254 | */ |
255 | 255 | protected function renderError() { |
256 | - $error = I18N::translate('The media file was not found in this family tree.'); |
|
256 | + $error = I18N::translate('The media file was not found in this family tree.'); |
|
257 | 257 | |
258 | - $width = (mb_strlen($error) * 6.5 + 50) * 1.15; |
|
259 | - $height = 60; |
|
260 | - $im = imagecreatetruecolor($width, $height); /* Create a black image */ |
|
261 | - $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
|
262 | - imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
|
258 | + $width = (mb_strlen($error) * 6.5 + 50) * 1.15; |
|
259 | + $height = 60; |
|
260 | + $im = imagecreatetruecolor($width, $height); /* Create a black image */ |
|
261 | + $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
|
262 | + imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
|
263 | 263 | |
264 | - $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
264 | + $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
265 | 265 | |
266 | - http_response_code(404); |
|
267 | - header('Content-Type: image/png'); |
|
268 | - imagepng($im); |
|
269 | - imagedestroy($im); |
|
266 | + http_response_code(404); |
|
267 | + header('Content-Type: image/png'); |
|
268 | + imagepng($im); |
|
269 | + imagedestroy($im); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | */ |
279 | 279 | protected function applyWatermark($im) { |
280 | 280 | |
281 | - // text to watermark with |
|
282 | - if(method_exists($this->media, 'getWatermarkText')) { |
|
283 | - $word1_text = $this->media->getWatermarkText(); |
|
284 | - } |
|
285 | - else { |
|
286 | - $word1_text = $this->media->getTitle(); |
|
287 | - } |
|
281 | + // text to watermark with |
|
282 | + if(method_exists($this->media, 'getWatermarkText')) { |
|
283 | + $word1_text = $this->media->getWatermarkText(); |
|
284 | + } |
|
285 | + else { |
|
286 | + $word1_text = $this->media->getTitle(); |
|
287 | + } |
|
288 | 288 | |
289 | - $this->embedText( |
|
290 | - $im, |
|
291 | - $word1_text, |
|
292 | - $this->font_max_size, |
|
293 | - $this->font_color, |
|
294 | - WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
295 | - 'top', |
|
296 | - 'left' |
|
297 | - ); |
|
289 | + $this->embedText( |
|
290 | + $im, |
|
291 | + $word1_text, |
|
292 | + $this->font_max_size, |
|
293 | + $this->font_color, |
|
294 | + WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
295 | + 'top', |
|
296 | + 'left' |
|
297 | + ); |
|
298 | 298 | |
299 | - return ($im); |
|
299 | + return ($im); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -313,94 +313,94 @@ discard block |
||
313 | 313 | */ |
314 | 314 | protected function embedText($im, $text, $maxsize, $color, $font, $vpos, $hpos) { |
315 | 315 | |
316 | - // there are two ways to embed text with PHP |
|
317 | - // (preferred) using GD and FreeType you can embed text using any True Type font |
|
318 | - // (fall back) if that is not available, you can insert basic monospaced text |
|
316 | + // there are two ways to embed text with PHP |
|
317 | + // (preferred) using GD and FreeType you can embed text using any True Type font |
|
318 | + // (fall back) if that is not available, you can insert basic monospaced text |
|
319 | 319 | |
320 | - $col = $this->hexrgb($color); |
|
321 | - $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']); |
|
320 | + $col = $this->hexrgb($color); |
|
321 | + $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']); |
|
322 | 322 | |
323 | - // make adjustments to settings that imagestring and imagestringup can’t handle |
|
324 | - if (!$this->use_ttf) { |
|
325 | - // imagestringup only writes up, can’t use top2bottom |
|
326 | - if ($hpos === 'top2bottom') { |
|
327 | - $hpos = 'bottom2top'; |
|
328 | - } |
|
329 | - } |
|
323 | + // make adjustments to settings that imagestring and imagestringup can’t handle |
|
324 | + if (!$this->use_ttf) { |
|
325 | + // imagestringup only writes up, can’t use top2bottom |
|
326 | + if ($hpos === 'top2bottom') { |
|
327 | + $hpos = 'bottom2top'; |
|
328 | + } |
|
329 | + } |
|
330 | 330 | |
331 | - $text = I18N::reverseText($text); |
|
332 | - $height = imagesy($im); |
|
333 | - $width = imagesx($im); |
|
334 | - $calc_angle = rad2deg(atan($height / $width)); |
|
335 | - $hypoth = $height / sin(deg2rad($calc_angle)); |
|
331 | + $text = I18N::reverseText($text); |
|
332 | + $height = imagesy($im); |
|
333 | + $width = imagesx($im); |
|
334 | + $calc_angle = rad2deg(atan($height / $width)); |
|
335 | + $hypoth = $height / sin(deg2rad($calc_angle)); |
|
336 | 336 | |
337 | - // vertical and horizontal position of the text |
|
338 | - switch ($vpos) { |
|
339 | - default: |
|
340 | - case 'top': |
|
341 | - $taille = $this->textLength($maxsize, $width, $text); |
|
342 | - $pos_y = $height * 0.15 + $taille; |
|
343 | - $pos_x = $width * 0.15; |
|
344 | - $rotation = 0; |
|
345 | - break; |
|
346 | - case 'middle': |
|
347 | - $taille = $this->textLength($maxsize, $width, $text); |
|
348 | - $pos_y = ($height + $taille) / 2; |
|
349 | - $pos_x = $width * 0.15; |
|
350 | - $rotation = 0; |
|
351 | - break; |
|
352 | - case 'bottom': |
|
353 | - $taille = $this->textLength($maxsize, $width, $text); |
|
354 | - $pos_y = ($height * .85 - $taille); |
|
355 | - $pos_x = $width * 0.15; |
|
356 | - $rotation = 0; |
|
357 | - break; |
|
358 | - case 'across': |
|
359 | - switch ($hpos) { |
|
360 | - default: |
|
361 | - case 'left': |
|
362 | - $taille = $this->textLength($maxsize, $hypoth, $text); |
|
363 | - $pos_y = ($height * .85 - $taille); |
|
364 | - $pos_x = $width * 0.15; |
|
365 | - $rotation = $calc_angle; |
|
366 | - break; |
|
367 | - case 'right': |
|
368 | - $taille = $this->textLength($maxsize, $hypoth, $text); |
|
369 | - $pos_y = ($height * .15 - $taille); |
|
370 | - $pos_x = $width * 0.85; |
|
371 | - $rotation = $calc_angle + 180; |
|
372 | - break; |
|
373 | - case 'top2bottom': |
|
374 | - $taille = $this->textLength($maxsize, $height, $text); |
|
375 | - $pos_y = ($height * .15 - $taille); |
|
376 | - $pos_x = ($width * .90 - $taille); |
|
377 | - $rotation = -90; |
|
378 | - break; |
|
379 | - case 'bottom2top': |
|
380 | - $taille = $this->textLength($maxsize, $height, $text); |
|
381 | - $pos_y = $height * 0.85; |
|
382 | - $pos_x = $width * 0.15; |
|
383 | - $rotation = 90; |
|
384 | - break; |
|
385 | - } |
|
386 | - break; |
|
387 | - } |
|
337 | + // vertical and horizontal position of the text |
|
338 | + switch ($vpos) { |
|
339 | + default: |
|
340 | + case 'top': |
|
341 | + $taille = $this->textLength($maxsize, $width, $text); |
|
342 | + $pos_y = $height * 0.15 + $taille; |
|
343 | + $pos_x = $width * 0.15; |
|
344 | + $rotation = 0; |
|
345 | + break; |
|
346 | + case 'middle': |
|
347 | + $taille = $this->textLength($maxsize, $width, $text); |
|
348 | + $pos_y = ($height + $taille) / 2; |
|
349 | + $pos_x = $width * 0.15; |
|
350 | + $rotation = 0; |
|
351 | + break; |
|
352 | + case 'bottom': |
|
353 | + $taille = $this->textLength($maxsize, $width, $text); |
|
354 | + $pos_y = ($height * .85 - $taille); |
|
355 | + $pos_x = $width * 0.15; |
|
356 | + $rotation = 0; |
|
357 | + break; |
|
358 | + case 'across': |
|
359 | + switch ($hpos) { |
|
360 | + default: |
|
361 | + case 'left': |
|
362 | + $taille = $this->textLength($maxsize, $hypoth, $text); |
|
363 | + $pos_y = ($height * .85 - $taille); |
|
364 | + $pos_x = $width * 0.15; |
|
365 | + $rotation = $calc_angle; |
|
366 | + break; |
|
367 | + case 'right': |
|
368 | + $taille = $this->textLength($maxsize, $hypoth, $text); |
|
369 | + $pos_y = ($height * .15 - $taille); |
|
370 | + $pos_x = $width * 0.85; |
|
371 | + $rotation = $calc_angle + 180; |
|
372 | + break; |
|
373 | + case 'top2bottom': |
|
374 | + $taille = $this->textLength($maxsize, $height, $text); |
|
375 | + $pos_y = ($height * .15 - $taille); |
|
376 | + $pos_x = ($width * .90 - $taille); |
|
377 | + $rotation = -90; |
|
378 | + break; |
|
379 | + case 'bottom2top': |
|
380 | + $taille = $this->textLength($maxsize, $height, $text); |
|
381 | + $pos_y = $height * 0.85; |
|
382 | + $pos_x = $width * 0.15; |
|
383 | + $rotation = 90; |
|
384 | + break; |
|
385 | + } |
|
386 | + break; |
|
387 | + } |
|
388 | 388 | |
389 | - // apply the text |
|
390 | - if ($this->use_ttf) { |
|
391 | - // if imagettftext throws errors, catch them with a custom error handler |
|
392 | - set_error_handler(array($this, 'imageTtfTextErrorHandler')); |
|
393 | - imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text); |
|
394 | - restore_error_handler(); |
|
395 | - } |
|
396 | - // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false |
|
397 | - if (!$this->use_ttf) { |
|
398 | - if ($rotation !== 90) { |
|
399 | - imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
400 | - } else { |
|
401 | - imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
402 | - } |
|
403 | - } |
|
389 | + // apply the text |
|
390 | + if ($this->use_ttf) { |
|
391 | + // if imagettftext throws errors, catch them with a custom error handler |
|
392 | + set_error_handler(array($this, 'imageTtfTextErrorHandler')); |
|
393 | + imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text); |
|
394 | + restore_error_handler(); |
|
395 | + } |
|
396 | + // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false |
|
397 | + if (!$this->use_ttf) { |
|
398 | + if ($rotation !== 90) { |
|
399 | + imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
400 | + } else { |
|
401 | + imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor); |
|
402 | + } |
|
403 | + } |
|
404 | 404 | |
405 | 405 | } |
406 | 406 | |
@@ -412,53 +412,53 @@ discard block |
||
412 | 412 | */ |
413 | 413 | protected function hexrgb ($hexstr) |
414 | 414 | { |
415 | - $int = hexdec($hexstr); |
|
415 | + $int = hexdec($hexstr); |
|
416 | 416 | |
417 | - return array('red' => 0xFF & ($int >> 0x10), |
|
418 | - 'green' => 0xFF & ($int >> 0x8), |
|
419 | - 'blue' => 0xFF & $int); |
|
417 | + return array('red' => 0xFF & ($int >> 0x10), |
|
418 | + 'green' => 0xFF & ($int >> 0x8), |
|
419 | + 'blue' => 0xFF & $int); |
|
420 | 420 | } |
421 | 421 | |
422 | - /** |
|
423 | - * Generate an approximate length of text, in pixels. |
|
424 | - * |
|
425 | - * @param int $t |
|
426 | - * @param int $mxl |
|
427 | - * @param string $text |
|
428 | - * |
|
429 | - * @return int |
|
430 | - */ |
|
431 | - function textLength($t, $mxl, $text) { |
|
432 | - $taille_c = $t; |
|
433 | - $len = mb_strlen($text); |
|
434 | - while (($taille_c - 2) * $len > $mxl) { |
|
435 | - $taille_c--; |
|
436 | - if ($taille_c == 2) { |
|
437 | - break; |
|
438 | - } |
|
439 | - } |
|
422 | + /** |
|
423 | + * Generate an approximate length of text, in pixels. |
|
424 | + * |
|
425 | + * @param int $t |
|
426 | + * @param int $mxl |
|
427 | + * @param string $text |
|
428 | + * |
|
429 | + * @return int |
|
430 | + */ |
|
431 | + function textLength($t, $mxl, $text) { |
|
432 | + $taille_c = $t; |
|
433 | + $len = mb_strlen($text); |
|
434 | + while (($taille_c - 2) * $len > $mxl) { |
|
435 | + $taille_c--; |
|
436 | + if ($taille_c == 2) { |
|
437 | + break; |
|
438 | + } |
|
439 | + } |
|
440 | 440 | |
441 | - return $taille_c; |
|
442 | - } |
|
441 | + return $taille_c; |
|
442 | + } |
|
443 | 443 | |
444 | - /** |
|
445 | - * imagettftext is the function that is most likely to throw an error |
|
446 | - * use this custom error handler to catch and log it |
|
447 | - * |
|
448 | - * @param int $errno |
|
449 | - * @param string $errstr |
|
450 | - * |
|
451 | - * @return bool |
|
452 | - */ |
|
453 | - function imageTtfTextErrorHandler($errno, $errstr) { |
|
454 | - // log the error |
|
455 | - Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
444 | + /** |
|
445 | + * imagettftext is the function that is most likely to throw an error |
|
446 | + * use this custom error handler to catch and log it |
|
447 | + * |
|
448 | + * @param int $errno |
|
449 | + * @param string $errstr |
|
450 | + * |
|
451 | + * @return bool |
|
452 | + */ |
|
453 | + function imageTtfTextErrorHandler($errno, $errstr) { |
|
454 | + // log the error |
|
455 | + Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
456 | 456 | |
457 | - // change value of useTTF to false so the fallback watermarking can be used. |
|
458 | - $this->use_ttf = false; |
|
457 | + // change value of useTTF to false so the fallback watermarking can be used. |
|
458 | + $this->use_ttf = false; |
|
459 | 459 | |
460 | - return true; |
|
461 | - } |
|
460 | + return true; |
|
461 | + } |
|
462 | 462 | |
463 | 463 | } |
464 | 464 |
@@ -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 | 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 @@ |
||
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 | /** |
@@ -21,6 +21,7 @@ discard block |
||
21 | 21 | * Insert some content before the record name text. |
22 | 22 | * |
23 | 23 | * @param GedcomRecord $grec Gedcom record |
24 | + * @return void |
|
24 | 25 | */ |
25 | 26 | public function hRecordNamePrepend(GedcomRecord $grec); |
26 | 27 | |
@@ -28,6 +29,7 @@ discard block |
||
28 | 29 | * Insert some content after the record name text. |
29 | 30 | * |
30 | 31 | * @param GedcomRecord $grec Gedcom record |
32 | + * @return string |
|
31 | 33 | */ |
32 | 34 | public function hRecordNameAppend(GedcomRecord $grec); |
33 | 35 |
@@ -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\HookInterfaces; |
12 | 12 | |
13 | 13 | use Fisharebest\Webtrees\GedcomRecord; |
@@ -80,7 +80,9 @@ discard block |
||
80 | 80 | * |
81 | 81 | */ |
82 | 82 | protected function checkInit(){ |
83 | - if(!$this->is_init) $this->init(); |
|
83 | + if(!$this->is_init) { |
|
84 | + $this->init(); |
|
85 | + } |
|
84 | 86 | } |
85 | 87 | |
86 | 88 | /** |
@@ -93,7 +95,9 @@ discard block |
||
93 | 95 | protected function getKeyName($value, AbstractModule $mod = null){ |
94 | 96 | $this->checkInit(); |
95 | 97 | $mod_name = 'myartjaub'; |
96 | - if($mod !== null) $mod_name = $mod->getName(); |
|
98 | + if($mod !== null) { |
|
99 | + $mod_name = $mod->getName(); |
|
100 | + } |
|
97 | 101 | return $mod_name.'_'.$value; |
98 | 102 | } |
99 | 103 |
@@ -146,7 +146,7 @@ |
||
146 | 146 | /** |
147 | 147 | * Static invocation of the *save* method. |
148 | 148 | * |
149 | - * @param string|\Psr\Cache\CacheItemInterface $value Value name |
|
149 | + * @param CacheItemInterface $value Value name |
|
150 | 150 | * @param mixed $data Value |
151 | 151 | * @param AbstractModule $mod Calling module |
152 | 152 | */ |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class Cache{ |
24 | 24 | |
25 | - /** |
|
26 | - * Underlying Cache object |
|
27 | - * @var CacheItemPoolInterface $cache |
|
28 | - */ |
|
25 | + /** |
|
26 | + * Underlying Cache object |
|
27 | + * @var CacheItemPoolInterface $cache |
|
28 | + */ |
|
29 | 29 | protected $cache=null; |
30 | 30 | |
31 | 31 | /** |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected static function getInstance() |
49 | 49 | { |
50 | - if (null === static::$instance) { |
|
51 | - static::$instance = new static(); |
|
52 | - } |
|
50 | + if (null === static::$instance) { |
|
51 | + static::$instance = new static(); |
|
52 | + } |
|
53 | 53 | |
54 | - return static::$instance; |
|
54 | + return static::$instance; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * |
60 | 60 | */ |
61 | 61 | protected function init() { |
62 | - if(Apc::isAvailable()) { |
|
63 | - $driver = new Apc(); |
|
62 | + if(Apc::isAvailable()) { |
|
63 | + $driver = new Apc(); |
|
64 | 64 | } else { |
65 | 65 | if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) { |
66 | 66 | // We may not have permission - especially during setup, before we instruct |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | @mkdir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache'); |
69 | 69 | } |
70 | 70 | if (is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) { |
71 | - $driver = new FileSystem(array('path' => WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')); |
|
71 | + $driver = new FileSystem(array('path' => WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')); |
|
72 | 72 | } else { |
73 | 73 | // No cache available, let's just use a basic one :-( |
74 | 74 | $driver = new Ephemeral(); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return string Cached key name |
96 | 96 | */ |
97 | 97 | protected function getKeyName($value, AbstractModule $mod = null){ |
98 | - $this->checkInit(); |
|
98 | + $this->checkInit(); |
|
99 | 99 | $mod_name = 'myartjaub'; |
100 | 100 | if($mod !== null) $mod_name = $mod->getName(); |
101 | 101 | return $mod_name.'_'.$value; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return \Psr\Cache\CacheItemInterface |
110 | 110 | */ |
111 | 111 | public function getI($value, AbstractModule $mod = null){ |
112 | - $this->checkInit(); |
|
112 | + $this->checkInit(); |
|
113 | 113 | return $this->cache->getItem($this->getKeyName($value, $mod)); |
114 | 114 | } |
115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return \Psr\Cache\CacheItemInterface |
122 | 122 | */ |
123 | 123 | public static function get($value, AbstractModule $mod = null){ |
124 | - return self::getInstance()->getI($value, $mod); |
|
124 | + return self::getInstance()->getI($value, $mod); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | |
137 | 137 | $item = $value; |
138 | 138 | if(!($value instanceof CacheItemInterface)) { |
139 | - $item = new \Stash\Item(); |
|
140 | - $item->setKey($this->getKeyName($value, $mod)); |
|
139 | + $item = new \Stash\Item(); |
|
140 | + $item->setKey($this->getKeyName($value, $mod)); |
|
141 | 141 | } |
142 | 142 | $item->set($data); |
143 | 143 | $this->cache->save($item); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param AbstractModule $mod Calling module |
152 | 152 | */ |
153 | 153 | public static function save($value, $data, AbstractModule $mod = null){ |
154 | - self::getInstance()->saveI($value, $data, $mod); |
|
154 | + self::getInstance()->saveI($value, $data, $mod); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * @return bool Deletion successful? |
163 | 163 | */ |
164 | 164 | public function deleteI($value, AbstractModule $mod = null){ |
165 | - $this->checkInit(); |
|
166 | - return $this->cache->deleteItem($this->getKeyName($value, $mod)); |
|
165 | + $this->checkInit(); |
|
166 | + return $this->cache->deleteItem($this->getKeyName($value, $mod)); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @return bool Deletion successful? |
175 | 175 | */ |
176 | 176 | public static function delete($value, AbstractModule $mod = null){ |
177 | - return self::getInstance()->deleteI($value, $mod); |
|
177 | + return self::getInstance()->deleteI($value, $mod); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * |
183 | 183 | */ |
184 | 184 | public function cleanI(){ |
185 | - $this->checkInit(); |
|
185 | + $this->checkInit(); |
|
186 | 186 | $this->cache->clear(); |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * Static invocation of the *clean* method. |
191 | 191 | */ |
192 | 192 | public static function clean() { |
193 | - self::getInstance()->cleanI(); |
|
193 | + self::getInstance()->cleanI(); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | \ No newline at end of file |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Cache component to speed up some potential data retrievals |
22 | 22 | */ |
23 | -class Cache{ |
|
23 | +class Cache { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Underlying Cache object |
27 | 27 | * @var CacheItemPoolInterface $cache |
28 | 28 | */ |
29 | - protected $cache=null; |
|
29 | + protected $cache = null; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Defines whether the cache has been initialised |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | */ |
61 | 61 | protected function init() { |
62 | - if(Apc::isAvailable()) { |
|
62 | + if (Apc::isAvailable()) { |
|
63 | 63 | $driver = new Apc(); |
64 | 64 | } else { |
65 | 65 | if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) { |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * Initiliase the Cache if not done. |
84 | 84 | * |
85 | 85 | */ |
86 | - protected function checkInit(){ |
|
87 | - if(!$this->is_init) $this->init(); |
|
86 | + protected function checkInit() { |
|
87 | + if (!$this->is_init) $this->init(); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @param AbstractModule $mod Calling module |
95 | 95 | * @return string Cached key name |
96 | 96 | */ |
97 | - protected function getKeyName($value, AbstractModule $mod = null){ |
|
97 | + protected function getKeyName($value, AbstractModule $mod = null) { |
|
98 | 98 | $this->checkInit(); |
99 | 99 | $mod_name = 'myartjaub'; |
100 | - if($mod !== null) $mod_name = $mod->getName(); |
|
100 | + if ($mod !== null) $mod_name = $mod->getName(); |
|
101 | 101 | return $mod_name.'_'.$value; |
102 | 102 | } |
103 | 103 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param AbstractModule $mod Calling module |
109 | 109 | * @return \Psr\Cache\CacheItemInterface |
110 | 110 | */ |
111 | - public function getI($value, AbstractModule $mod = null){ |
|
111 | + public function getI($value, AbstractModule $mod = null) { |
|
112 | 112 | $this->checkInit(); |
113 | 113 | return $this->cache->getItem($this->getKeyName($value, $mod)); |
114 | 114 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param AbstractModule $mod Calling module |
121 | 121 | * @return \Psr\Cache\CacheItemInterface |
122 | 122 | */ |
123 | - public static function get($value, AbstractModule $mod = null){ |
|
123 | + public static function get($value, AbstractModule $mod = null) { |
|
124 | 124 | return self::getInstance()->getI($value, $mod); |
125 | 125 | } |
126 | 126 | |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * @param mixed $data Value |
132 | 132 | * @param AbstractModule $mod Calling module |
133 | 133 | */ |
134 | - public function saveI($value, $data, AbstractModule $mod = null){ |
|
134 | + public function saveI($value, $data, AbstractModule $mod = null) { |
|
135 | 135 | $this->checkInit(); |
136 | 136 | |
137 | 137 | $item = $value; |
138 | - if(!($value instanceof CacheItemInterface)) { |
|
138 | + if (!($value instanceof CacheItemInterface)) { |
|
139 | 139 | $item = new \Stash\Item(); |
140 | 140 | $item->setKey($this->getKeyName($value, $mod)); |
141 | 141 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param mixed $data Value |
151 | 151 | * @param AbstractModule $mod Calling module |
152 | 152 | */ |
153 | - public static function save($value, $data, AbstractModule $mod = null){ |
|
153 | + public static function save($value, $data, AbstractModule $mod = null) { |
|
154 | 154 | self::getInstance()->saveI($value, $data, $mod); |
155 | 155 | } |
156 | 156 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param AbstractModule $mod Calling module |
162 | 162 | * @return bool Deletion successful? |
163 | 163 | */ |
164 | - public function deleteI($value, AbstractModule $mod = null){ |
|
164 | + public function deleteI($value, AbstractModule $mod = null) { |
|
165 | 165 | $this->checkInit(); |
166 | 166 | return $this->cache->deleteItem($this->getKeyName($value, $mod)); |
167 | 167 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param AbstractModule $mod Calling module |
174 | 174 | * @return bool Deletion successful? |
175 | 175 | */ |
176 | - public static function delete($value, AbstractModule $mod = null){ |
|
176 | + public static function delete($value, AbstractModule $mod = null) { |
|
177 | 177 | return self::getInstance()->deleteI($value, $mod); |
178 | 178 | } |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * Clean the cache |
182 | 182 | * |
183 | 183 | */ |
184 | - public function cleanI(){ |
|
184 | + public function cleanI() { |
|
185 | 185 | $this->checkInit(); |
186 | 186 | $this->cache->clear(); |
187 | 187 | } |
@@ -104,9 +104,12 @@ discard block |
||
104 | 104 | public function canDisplayIsSourced($access_level = null){ |
105 | 105 | global $global_facts; |
106 | 106 | |
107 | - if(!$this->gedcomrecord->canShow($access_level)) return false; |
|
108 | - if($access_level === null ) |
|
109 | - $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
107 | + if(!$this->gedcomrecord->canShow($access_level)) { |
|
108 | + return false; |
|
109 | + } |
|
110 | + if($access_level === null ) { |
|
111 | + $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
112 | + } |
|
110 | 113 | |
111 | 114 | if (isset($global_facts['SOUR'])) { |
112 | 115 | return $global_facts['SOUR'] >= $access_level; |
@@ -125,7 +128,9 @@ discard block |
||
125 | 128 | * @return int Level of sources |
126 | 129 | */ |
127 | 130 | public function isSourced(){ |
128 | - if($this->_issourced !== null) return $this->_issourced; |
|
131 | + if($this->_issourced !== null) { |
|
132 | + return $this->_issourced; |
|
133 | + } |
|
129 | 134 | $this->_issourced=-1; |
130 | 135 | $sourcesfacts = $this->gedcomrecord->getFacts('SOUR'); |
131 | 136 | foreach($sourcesfacts as $sourcefact){ |
@@ -144,7 +149,9 @@ discard block |
||
144 | 149 | * @return int Level of sources |
145 | 150 | */ |
146 | 151 | public function isFactSourced($eventslist){ |
147 | - if(empty($eventslist)) return 0; |
|
152 | + if(empty($eventslist)) { |
|
153 | + return 0; |
|
154 | + } |
|
148 | 155 | $isSourced=0; |
149 | 156 | $facts = $this->gedcomrecord->getFacts($eventslist); |
150 | 157 | foreach($facts as $fact){ |
@@ -154,8 +161,7 @@ discard block |
||
154 | 161 | if($tmpIsSourced != 0) { |
155 | 162 | if($isSourced==0) { |
156 | 163 | $isSourced = $tmpIsSourced; |
157 | - } |
|
158 | - else{ |
|
164 | + } else{ |
|
159 | 165 | $isSourced = max($isSourced, $tmpIsSourced); |
160 | 166 | } |
161 | 167 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | if(!$this->gedcomrecord->canShow($access_level)) return false; |
93 | 93 | if($access_level === null ) |
94 | - $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
94 | + $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
95 | 95 | |
96 | 96 | if (isset($global_facts['SOUR'])) { |
97 | 97 | return $global_facts['SOUR'] >= $access_level; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return int Level of sources |
130 | 130 | */ |
131 | 131 | public function isFactSourced($eventslist){ |
132 | - if(empty($eventslist)) return 0; |
|
132 | + if(empty($eventslist)) return 0; |
|
133 | 133 | $isSourced=0; |
134 | 134 | $facts = $this->gedcomrecord->getFacts($eventslist); |
135 | 135 | foreach($facts as $fact){ |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | protected $gedcomrecord; |
24 | 24 | |
25 | 25 | /** @var bool Is the GedcomRecord sourced (cache) */ |
26 | - protected $_issourced=null; |
|
26 | + protected $_issourced = null; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Contructor for the decorator |
30 | 30 | * |
31 | 31 | * @param \Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in The GedcomRecord to extend |
32 | 32 | */ |
33 | - public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in){ |
|
33 | + public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in) { |
|
34 | 34 | $this->gedcomrecord = $gedcomrecord_in; |
35 | 35 | } |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return \Fisharebest\Webtrees\GedcomRecord Embedded gedcom record |
41 | 41 | */ |
42 | - public function getDerivedRecord(){ |
|
42 | + public function getDerivedRecord() { |
|
43 | 43 | return $this->gedcomrecord; |
44 | 44 | } |
45 | 45 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (($fact->getDate() || $fact->getPlace()) && $fact->canShow()) { |
71 | 71 | switch ($style) { |
72 | 72 | case 10: |
73 | - return '<i>'.$fact->getLabel().' '. mw\Functions\FunctionsPrint::formatFactDateShort($fact) .' '. mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1') .'</i>'; |
|
73 | + return '<i>'.$fact->getLabel().' '.mw\Functions\FunctionsPrint::formatFactDateShort($fact).' '.mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1').'</i>'; |
|
74 | 74 | default: |
75 | 75 | return $this->gedcomrecord->formatFirstMajorFact($facts, $style); |
76 | 76 | } |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | * @param int $access_level |
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | - public function canDisplayIsSourced($access_level = null){ |
|
88 | + public function canDisplayIsSourced($access_level = null) { |
|
89 | 89 | global $global_facts; |
90 | 90 | |
91 | - if(!$this->gedcomrecord->canShow($access_level)) return false; |
|
92 | - if($access_level === null ) |
|
91 | + if (!$this->gedcomrecord->canShow($access_level)) return false; |
|
92 | + if ($access_level === null) |
|
93 | 93 | $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
94 | 94 | |
95 | 95 | if (isset($global_facts['SOUR'])) { |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return int Level of sources |
110 | 110 | */ |
111 | - public function isSourced(){ |
|
112 | - if($this->_issourced !== null) return $this->_issourced; |
|
113 | - $this->_issourced=-1; |
|
111 | + public function isSourced() { |
|
112 | + if ($this->_issourced !== null) return $this->_issourced; |
|
113 | + $this->_issourced = -1; |
|
114 | 114 | $sourcesfacts = $this->gedcomrecord->getFacts('SOUR'); |
115 | - foreach($sourcesfacts as $sourcefact){ |
|
116 | - $this->_issourced=max($this->_issourced, 1); |
|
117 | - if($sourcefact->getAttribute('_ACT')){ |
|
118 | - $this->_issourced=max($this->_issourced, 2); |
|
115 | + foreach ($sourcesfacts as $sourcefact) { |
|
116 | + $this->_issourced = max($this->_issourced, 1); |
|
117 | + if ($sourcefact->getAttribute('_ACT')) { |
|
118 | + $this->_issourced = max($this->_issourced, 2); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | return $this->_issourced; |
@@ -127,19 +127,19 @@ discard block |
||
127 | 127 | * @param string $eventslist |
128 | 128 | * @return int Level of sources |
129 | 129 | */ |
130 | - public function isFactSourced($eventslist){ |
|
131 | - if(empty($eventslist)) return 0; |
|
132 | - $isSourced=0; |
|
130 | + public function isFactSourced($eventslist) { |
|
131 | + if (empty($eventslist)) return 0; |
|
132 | + $isSourced = 0; |
|
133 | 133 | $facts = $this->gedcomrecord->getFacts($eventslist); |
134 | - foreach($facts as $fact){ |
|
135 | - if($isSourced < Fact::MAX_IS_SOURCED_LEVEL){ |
|
134 | + foreach ($facts as $fact) { |
|
135 | + if ($isSourced < Fact::MAX_IS_SOURCED_LEVEL) { |
|
136 | 136 | $dfact = new Fact($fact); |
137 | 137 | $tmpIsSourced = $dfact->isSourced(); |
138 | - if($tmpIsSourced != 0) { |
|
139 | - if($isSourced==0) { |
|
140 | - $isSourced = $tmpIsSourced; |
|
138 | + if ($tmpIsSourced != 0) { |
|
139 | + if ($isSourced == 0) { |
|
140 | + $isSourced = $tmpIsSourced; |
|
141 | 141 | } |
142 | - else{ |
|
142 | + else { |
|
143 | 143 | $isSourced = max($isSourced, $tmpIsSourced); |
144 | 144 | } |
145 | 145 | } |
@@ -54,30 +54,30 @@ discard block |
||
54 | 54 | public function buildLineages() { |
55 | 55 | $indis = \Fisharebest\Webtrees\Query\QueryName::individuals($this->tree, $this->surname, null, null, false, false); |
56 | 56 | |
57 | - if(count($indis) == 0) return null; |
|
57 | + if (count($indis) == 0) return null; |
|
58 | 58 | |
59 | 59 | $root_lineages = array(); |
60 | 60 | |
61 | - foreach($indis as $indi) { |
|
61 | + foreach ($indis as $indi) { |
|
62 | 62 | $pid = $indi->getXref(); |
63 | - if(!isset($this->used_indis[$pid])){ |
|
63 | + if (!isset($this->used_indis[$pid])) { |
|
64 | 64 | //Find the root of the lineage |
65 | 65 | /** @var Fisharebest\Webtrees\Individual $indiFirst */ |
66 | - $indiFirst= $this->getLineageRootIndividual($indi); |
|
67 | - if($indiFirst){ |
|
66 | + $indiFirst = $this->getLineageRootIndividual($indi); |
|
67 | + if ($indiFirst) { |
|
68 | 68 | $this->used_indis[$indiFirst->getXref()] = true; |
69 | - if($indiFirst->canShow()){ |
|
69 | + if ($indiFirst->canShow()) { |
|
70 | 70 | //Check if the root individual has brothers and sisters, without parents |
71 | 71 | $indiChildFamily = $indiFirst->getPrimaryChildFamily(); |
72 | - if($indiChildFamily !== null){ |
|
72 | + if ($indiChildFamily !== null) { |
|
73 | 73 | $root_node = new LineageRootNode(null); |
74 | 74 | $root_node->addFamily($indiChildFamily); |
75 | 75 | } |
76 | - else{ |
|
76 | + else { |
|
77 | 77 | $root_node = new LineageRootNode($indiFirst); |
78 | 78 | } |
79 | 79 | $root_node = $this->buildLineage($root_node); |
80 | - if($root_node) $root_lineages[] = $root_node; |
|
80 | + if ($root_node) $root_lineages[] = $root_node; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
@@ -94,45 +94,45 @@ discard block |
||
94 | 94 | * @return (Individual|null) Root individual |
95 | 95 | */ |
96 | 96 | protected function getLineageRootIndividual(Individual $indi) { |
97 | - $is_first=false; |
|
97 | + $is_first = false; |
|
98 | 98 | $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
99 | - $indi_surname=$dindi->getUnprotectedPrimarySurname(); |
|
99 | + $indi_surname = $dindi->getUnprotectedPrimarySurname(); |
|
100 | 100 | $resIndi = $indi; |
101 | - while(!$is_first){ |
|
101 | + while (!$is_first) { |
|
102 | 102 | //Get the individual parents family |
103 | - $fam=$resIndi->getPrimaryChildFamily(); |
|
104 | - if($fam){ |
|
105 | - $husb=$fam->getHusband(); |
|
106 | - $wife=$fam->getWife(); |
|
103 | + $fam = $resIndi->getPrimaryChildFamily(); |
|
104 | + if ($fam) { |
|
105 | + $husb = $fam->getHusband(); |
|
106 | + $wife = $fam->getWife(); |
|
107 | 107 | //If the father exists, take him |
108 | - if($husb){ |
|
108 | + if ($husb) { |
|
109 | 109 | $dhusb = new \MyArtJaub\Webtrees\Individual($husb); |
110 | - $dhusb->isNewAddition() ? $is_first = true : $resIndi=$husb; |
|
110 | + $dhusb->isNewAddition() ? $is_first = true : $resIndi = $husb; |
|
111 | 111 | } |
112 | 112 | //If only a mother exists |
113 | - else if($wife){ |
|
113 | + else if ($wife) { |
|
114 | 114 | $dwife = new \MyArtJaub\Webtrees\Individual($wife); |
115 | - $wife_surname=$dwife->getUnprotectedPrimarySurname(); |
|
115 | + $wife_surname = $dwife->getUnprotectedPrimarySurname(); |
|
116 | 116 | //Check if the child is a natural child of the mother (based on the surname - Warning : surname must be identical) |
117 | - if(!$dwife->isNewAddition() && I18N::strcasecmp($wife_surname, $indi_surname) == 0){ |
|
118 | - $resIndi=$wife; |
|
117 | + if (!$dwife->isNewAddition() && I18N::strcasecmp($wife_surname, $indi_surname) == 0) { |
|
118 | + $resIndi = $wife; |
|
119 | 119 | } |
120 | - else{ |
|
121 | - $is_first=true; |
|
120 | + else { |
|
121 | + $is_first = true; |
|
122 | 122 | } |
123 | 123 | } |
124 | - else{ |
|
125 | - $is_first=true; |
|
124 | + else { |
|
125 | + $is_first = true; |
|
126 | 126 | } |
127 | 127 | } |
128 | - else{ |
|
129 | - $is_first=true; |
|
128 | + else { |
|
129 | + $is_first = true; |
|
130 | 130 | } |
131 | 131 | } |
132 | - if(isset($this->used_indis[$resIndi->getXref()])){ |
|
132 | + if (isset($this->used_indis[$resIndi->getXref()])) { |
|
133 | 133 | return null; |
134 | 134 | } |
135 | - else{ |
|
135 | + else { |
|
136 | 136 | return $resIndi; |
137 | 137 | } |
138 | 138 | } |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @return LineageNode Computed lineage |
146 | 146 | */ |
147 | 147 | protected function buildLineage(LineageNode $node) { |
148 | - if($node === null) return; |
|
148 | + if ($node === null) return; |
|
149 | 149 | |
150 | 150 | $indi_surname = null; |
151 | 151 | |
152 | 152 | $indi_node = $node->getIndividual(); |
153 | - if($indi_node) { |
|
154 | - if(count($node->getFamiliesNodes()) == 0) { |
|
153 | + if ($indi_node) { |
|
154 | + if (count($node->getFamiliesNodes()) == 0) { |
|
155 | 155 | $indiSpouseFamilies = $indi_node->getSpouseFamilies(); |
156 | - foreach($indiSpouseFamilies as $indiSpouseFamily) { |
|
156 | + foreach ($indiSpouseFamilies as $indiSpouseFamily) { |
|
157 | 157 | $node->addFamily($indiSpouseFamily); |
158 | 158 | } |
159 | 159 | } |
@@ -162,62 +162,62 @@ discard block |
||
162 | 162 | $indi_surname = $dindi_node->getUnprotectedPrimarySurname(); |
163 | 163 | |
164 | 164 | //Get the estimated birth place and put it in the place table |
165 | - $place=$dindi_node->getEstimatedBirthPlace(false); |
|
166 | - if($place && strlen($place) > 0){ |
|
167 | - $place=trim($place); |
|
165 | + $place = $dindi_node->getEstimatedBirthPlace(false); |
|
166 | + if ($place && strlen($place) > 0) { |
|
167 | + $place = trim($place); |
|
168 | 168 | $node->getRootNode()->addPlace(new Place($place, $this->tree)); |
169 | 169 | } |
170 | 170 | |
171 | 171 | //Tag the individual as used |
172 | - $this->used_indis[$indi_node->getXref()]=true; |
|
172 | + $this->used_indis[$indi_node->getXref()] = true; |
|
173 | 173 | } |
174 | 174 | |
175 | - foreach($node->getFamiliesNodes() as $family) { |
|
175 | + foreach ($node->getFamiliesNodes() as $family) { |
|
176 | 176 | $spouse_surname = null; |
177 | - if($indi_node && $spouse = $family->getSpouse($indi_node)) { |
|
177 | + if ($indi_node && $spouse = $family->getSpouse($indi_node)) { |
|
178 | 178 | $dspouse = new \MyArtJaub\Webtrees\Individual($spouse); |
179 | - $spouse_surname=$dspouse->getUnprotectedPrimarySurname(); |
|
179 | + $spouse_surname = $dspouse->getUnprotectedPrimarySurname(); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $children = $family->getChildren(); |
183 | 183 | |
184 | - $nbChildren=0; |
|
185 | - $nbNatural=0; |
|
184 | + $nbChildren = 0; |
|
185 | + $nbNatural = 0; |
|
186 | 186 | |
187 | - foreach($children as $child){ |
|
187 | + foreach ($children as $child) { |
|
188 | 188 | $dchild = new \MyArtJaub\Webtrees\Individual($child); |
189 | - $child_surname=$dchild->getUnprotectedPrimarySurname(); |
|
189 | + $child_surname = $dchild->getUnprotectedPrimarySurname(); |
|
190 | 190 | |
191 | - if(!$dchild->isNewAddition()) { |
|
191 | + if (!$dchild->isNewAddition()) { |
|
192 | 192 | $nbChildren++; |
193 | 193 | //If the root individual is the mother |
194 | - if($indi_node && I18N::strcasecmp($indi_node->getSex(), 'F') == 0) { |
|
194 | + if ($indi_node && I18N::strcasecmp($indi_node->getSex(), 'F') == 0) { |
|
195 | 195 | //Print only lineages of children with the same surname as their mother (supposing they are natural children) |
196 | - if(!$spouse || ($spouse_surname && I18N::strcasecmp($child_surname, $spouse_surname) != 0)){ |
|
197 | - if(I18N::strcasecmp($child_surname, $indi_surname) == 0){ |
|
196 | + if (!$spouse || ($spouse_surname && I18N::strcasecmp($child_surname, $spouse_surname) != 0)) { |
|
197 | + if (I18N::strcasecmp($child_surname, $indi_surname) == 0) { |
|
198 | 198 | $nbNatural++; |
199 | 199 | $node_child = new LineageNode($child, $node->getRootNode()); |
200 | 200 | $node_child = $this->buildLineage($node_child); |
201 | - if($node_child) $node->addChild($family, $node_child); |
|
201 | + if ($node_child) $node->addChild($family, $node_child); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
205 | 205 | //If the root individual is the father |
206 | 206 | else { |
207 | 207 | //Print if the children does not bear the same name as his mother (and different from his father) |
208 | - if( strlen($child_surname) == 0 || strlen($indi_surname) == 0 || strlen($spouse_surname) == 0 || |
|
208 | + if (strlen($child_surname) == 0 || strlen($indi_surname) == 0 || strlen($spouse_surname) == 0 || |
|
209 | 209 | I18N::strcasecmp($child_surname, $indi_surname) == 0 || |
210 | - I18N::strcasecmp($child_surname, $spouse_surname) != 0 ) |
|
210 | + I18N::strcasecmp($child_surname, $spouse_surname) != 0) |
|
211 | 211 | { |
212 | 212 | $nbNatural++; |
213 | 213 | $node_child = new LineageNode($child, $node->getRootNode()); |
214 | 214 | $node_child = $this->buildLineage($node_child); |
215 | - if($node_child) $node->addChild($family, $node_child); |
|
215 | + if ($node_child) $node->addChild($family, $node_child); |
|
216 | 216 | } |
217 | 217 | else { |
218 | 218 | $nbNatural++; |
219 | 219 | $node_child = new LineageNode($child, $node->getRootNode(), $child_surname); |
220 | - if($node_child) $node->addChild($family, $node_child); |
|
220 | + if ($node_child) $node->addChild($family, $node_child); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | |
227 | 227 | //Do not print other children |
228 | - if(($nbChildren-$nbNatural)>0){ |
|
228 | + if (($nbChildren - $nbNatural) > 0) { |
|
229 | 229 | $node->addChild($family, null); |
230 | 230 | } |
231 | 231 | } |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function buildLineages() { |
55 | 55 | $indis = \Fisharebest\Webtrees\Query\QueryName::individuals($this->tree, $this->surname, null, null, false, false); |
56 | 56 | |
57 | - if(count($indis) == 0) return null; |
|
57 | + if(count($indis) == 0) { |
|
58 | + return null; |
|
59 | + } |
|
58 | 60 | |
59 | 61 | $root_lineages = array(); |
60 | 62 | |
@@ -72,12 +74,13 @@ discard block |
||
72 | 74 | if($indiChildFamily !== null){ |
73 | 75 | $root_node = new LineageRootNode(null); |
74 | 76 | $root_node->addFamily($indiChildFamily); |
75 | - } |
|
76 | - else{ |
|
77 | + } else{ |
|
77 | 78 | $root_node = new LineageRootNode($indiFirst); |
78 | 79 | } |
79 | 80 | $root_node = $this->buildLineage($root_node); |
80 | - if($root_node) $root_lineages[] = $root_node; |
|
81 | + if($root_node) { |
|
82 | + $root_lineages[] = $root_node; |
|
83 | + } |
|
81 | 84 | } |
82 | 85 | } |
83 | 86 | } |
@@ -116,23 +119,19 @@ discard block |
||
116 | 119 | //Check if the child is a natural child of the mother (based on the surname - Warning : surname must be identical) |
117 | 120 | if(!$dwife->isNewAddition() && I18N::strcasecmp($wife_surname, $indi_surname) == 0){ |
118 | 121 | $resIndi=$wife; |
119 | - } |
|
120 | - else{ |
|
122 | + } else{ |
|
121 | 123 | $is_first=true; |
122 | 124 | } |
123 | - } |
|
124 | - else{ |
|
125 | + } else{ |
|
125 | 126 | $is_first=true; |
126 | 127 | } |
127 | - } |
|
128 | - else{ |
|
128 | + } else{ |
|
129 | 129 | $is_first=true; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | if(isset($this->used_indis[$resIndi->getXref()])){ |
133 | 133 | return null; |
134 | - } |
|
135 | - else{ |
|
134 | + } else{ |
|
136 | 135 | return $resIndi; |
137 | 136 | } |
138 | 137 | } |
@@ -145,7 +144,9 @@ discard block |
||
145 | 144 | * @return LineageNode Computed lineage |
146 | 145 | */ |
147 | 146 | protected function buildLineage(LineageNode $node) { |
148 | - if($node === null) return; |
|
147 | + if($node === null) { |
|
148 | + return; |
|
149 | + } |
|
149 | 150 | |
150 | 151 | $indi_surname = null; |
151 | 152 | |
@@ -198,7 +199,9 @@ discard block |
||
198 | 199 | $nbNatural++; |
199 | 200 | $node_child = new LineageNode($child, $node->getRootNode()); |
200 | 201 | $node_child = $this->buildLineage($node_child); |
201 | - if($node_child) $node->addChild($family, $node_child); |
|
202 | + if($node_child) { |
|
203 | + $node->addChild($family, $node_child); |
|
204 | + } |
|
202 | 205 | } |
203 | 206 | } |
204 | 207 | } |
@@ -212,12 +215,15 @@ discard block |
||
212 | 215 | $nbNatural++; |
213 | 216 | $node_child = new LineageNode($child, $node->getRootNode()); |
214 | 217 | $node_child = $this->buildLineage($node_child); |
215 | - if($node_child) $node->addChild($family, $node_child); |
|
216 | - } |
|
217 | - else { |
|
218 | + if($node_child) { |
|
219 | + $node->addChild($family, $node_child); |
|
220 | + } |
|
221 | + } else { |
|
218 | 222 | $nbNatural++; |
219 | 223 | $node_child = new LineageNode($child, $node->getRootNode(), $child_surname); |
220 | - if($node_child) $node->addChild($family, $node_child); |
|
224 | + if($node_child) { |
|
225 | + $node->addChild($family, $node_child); |
|
226 | + } |
|
221 | 227 | } |
222 | 228 | } |
223 | 229 | } |