Completed
Push — feature/code-analysis ( c314d5...820b23 )
by Jonathan
02:56
created
src/Webtrees/Mvc/Controller/MvcControllerInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
  */
16 16
 interface MvcControllerInterface {
17 17
     
18
-    /**
19
-     * Return the module attached to this controller.
20
-     * 
21
-     * @return \Fisharebest\Webtrees\Module\AbstractModule
22
-     */
23
-    function getModule();
18
+	/**
19
+	 * Return the module attached to this controller.
20
+	 * 
21
+	 * @return \Fisharebest\Webtrees\Module\AbstractModule
22
+	 */
23
+	function getModule();
24 24
     
25 25
 }
26 26
  
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Mvc/Controller/MvcController.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -17,28 +17,28 @@
 block discarded – undo
17 17
  */
18 18
 class MvcController implements MvcControllerInterface 
19 19
 {
20
-    /**
21
-     * Reference module
22
-     * @var Fisharebest\Webtrees\Module\AbstractModule $module
23
-     */
24
-    protected $module;
20
+	/**
21
+	 * Reference module
22
+	 * @var Fisharebest\Webtrees\Module\AbstractModule $module
23
+	 */
24
+	protected $module;
25 25
     
26
-    /**
27
-     * Constructor for MvcController
28
-     * 
29
-     * @param AbstractModule $module
30
-     */
31
-    public function __construct(AbstractModule $module) {
32
-        $this->module = $module;
33
-    }
26
+	/**
27
+	 * Constructor for MvcController
28
+	 * 
29
+	 * @param AbstractModule $module
30
+	 */
31
+	public function __construct(AbstractModule $module) {
32
+		$this->module = $module;
33
+	}
34 34
     
35
-    /**
36
-     * {@inheritDoc}
37
-     * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface::getModule()
38
-     */
39
-    public function getModule() {
40
-        return $this->module;
41
-    }
35
+	/**
36
+	 * {@inheritDoc}
37
+	 * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface::getModule()
38
+	 */
39
+	public function getModule() {
40
+		return $this->module;
41
+	}
42 42
         
43 43
 }
44 44
  
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Mvc/DispatcherInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Webtrees/Mvc/View/ViewFactory.php 3 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,87 +17,87 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,13 +53,13 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,13 +53,21 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Webtrees/ImageBuilder.php 3 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -87,7 +87,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	
Please login to merge, or discard this patch.
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -22,54 +22,54 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Webtrees/Hook/HookSubscriberInterface.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Webtrees/Hook/HookInterfaces/FactSourceTextExtenderInterface.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -19,6 +19,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 	
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
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
 /**
Please login to merge, or discard this patch.
src/Webtrees/Cache.php 4 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
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
 	 */
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageBuilder.php 2 patches
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -54,30 +54,30 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Braces   +24 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 				}
Please login to merge, or discard this patch.