Completed
Push — master ( 0f93c5...bdc52b )
by Jonathan
04:53
created
src/Webtrees/Mvc/Dispatcher.php 3 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -19,35 +19,35 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Dispatcher implements DispatcherInterface {
21 21
     
22
-    /**
23
-     * @var Dispatcher $instance Singleton pattern instance
24
-     */
25
-    private static $instance = null;
22
+	/**
23
+	 * @var Dispatcher $instance Singleton pattern instance
24
+	 */
25
+	private static $instance = null;
26 26
     
27
-    /**
28
-     * Returns the *Dispatcher* instance of this class.
29
-     *
30
-     * @return Dispatcher The *Singleton* instance.
31
-     */
32
-    public static function getInstance()
33
-    {
34
-        if (null === static::$instance) {
35
-            static::$instance = new static();
36
-        }
27
+	/**
28
+	 * Returns the *Dispatcher* instance of this class.
29
+	 *
30
+	 * @return Dispatcher The *Singleton* instance.
31
+	 */
32
+	public static function getInstance()
33
+	{
34
+		if (null === static::$instance) {
35
+			static::$instance = new static();
36
+		}
37 37
     
38
-        return static::$instance;
39
-    }    
38
+		return static::$instance;
39
+	}    
40 40
     
41 41
 	/**
42
-     * Protected constructor.
43
-     */
44
-    protected function __construct() {}
42
+	 * Protected constructor.
43
+	 */
44
+	protected function __construct() {}
45 45
     
46
-    /**
47
-     * {@inheritdoc }
48
-     * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle()
49
-     */
50
-    public function handle(fw\Module\AbstractModule $module, $request) {
46
+	/**
47
+	 * {@inheritdoc }
48
+	 * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle()
49
+	 */
50
+	public function handle(fw\Module\AbstractModule $module, $request) {
51 51
 		
52 52
 		$fq_modclass_name = get_class($module);
53 53
 		$ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\';
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		
68 68
 		$ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller';
69 69
 		if(class_exists($ctrl_class) 
70
-		    && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController')
70
+			&& is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController')
71 71
 			&& $ctrl = new $ctrl_class($module) ) {
72 72
 			if(method_exists($ctrl, $method)) {
73 73
 				call_user_func_array(array($ctrl, $method), array());
@@ -79,27 +79,27 @@  discard block
 block discarded – undo
79 79
 		 else {
80 80
 			 throw new \Exception('The page requested does not exist');
81 81
 		 }
82
-    }
82
+	}
83 83
 
84
-    /**
85
-     * Private clone method to prevent cloning of the instance of the
86
-     * *Dispatcher* instance.
87
-     *
88
-     * @return void
89
-     */
90
-    private function __clone()
91
-    {
92
-    }
84
+	/**
85
+	 * Private clone method to prevent cloning of the instance of the
86
+	 * *Dispatcher* instance.
87
+	 *
88
+	 * @return void
89
+	 */
90
+	private function __clone()
91
+	{
92
+	}
93 93
     
94
-    /**
95
-     * Private unserialize method to prevent unserializing of the *Dispatcher*
96
-     * instance.
97
-     *
98
-     * @return void
99
-     */
100
-    private function __wakeup()
101
-    {
102
-    }
94
+	/**
95
+	 * Private unserialize method to prevent unserializing of the *Dispatcher*
96
+	 * instance.
97
+	 *
98
+	 * @return void
99
+	 */
100
+	private function __wakeup()
101
+	{
102
+	}
103 103
     
104 104
 }
105 105
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
     public function handle(fw\Module\AbstractModule $module, $request) {
51 51
 		
52 52
 		$fq_modclass_name = get_class($module);
53
-		$ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\';
53
+		$ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\';
54 54
 		
55
-		$args = explode( '@', $request, 2);
56
-		switch(count($args)) {
55
+		$args = explode('@', $request, 2);
56
+		switch (count($args)) {
57 57
 			case 1:
58 58
 				$ctrl_name = $args[0];
59 59
 				$method = 'index';
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 				break;
66 66
 		}
67 67
 		
68
-		$ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller';
69
-		if(class_exists($ctrl_class) 
68
+		$ctrl_class = $ctrl_namespace.$ctrl_name.'Controller';
69
+		if (class_exists($ctrl_class) 
70 70
 		    && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController')
71
-			&& $ctrl = new $ctrl_class($module) ) {
72
-			if(method_exists($ctrl, $method)) {
71
+			&& $ctrl = new $ctrl_class($module)) {
72
+			if (method_exists($ctrl, $method)) {
73 73
 				call_user_func_array(array($ctrl, $method), array());
74 74
 			}
75 75
 			 else {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,12 +71,10 @@
 block discarded – undo
71 71
 			&& $ctrl = new $ctrl_class($module) ) {
72 72
 			if(method_exists($ctrl, $method)) {
73 73
 				call_user_func_array(array($ctrl, $method), array());
74
-			}
75
-			 else {
74
+			} else {
76 75
 				 throw new \Exception('The page requested does not exist');
77 76
 			 }
78
-		 }
79
-		 else {
77
+		 } else {
80 78
 			 throw new \Exception('The page requested does not exist');
81 79
 		 }
82 80
     }
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/Mvc/View/AbstractView.php 3 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -15,62 +15,62 @@
 block discarded – undo
15 15
  */
16 16
 abstract class AbstractView {
17 17
     
18
-    /**
19
-     * Reference controller
20
-     * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl
21
-     */
22
-    protected $ctrl;
18
+	/**
19
+	 * Reference controller
20
+	 * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl
21
+	 */
22
+	protected $ctrl;
23 23
     
24
-    /**
25
-     * Structure containing the data of the view
26
-     * @var ViewBag $data
27
-     */
28
-    protected $data;
24
+	/**
25
+	 * Structure containing the data of the view
26
+	 * @var ViewBag $data
27
+	 */
28
+	protected $data;
29 29
     
30
-    /**
31
-     * Constructor 
32
-     * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller
33
-     * @param ViewBag $data ViewBag holding view data
34
-     */
35
-    public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) {
36
-        $this->ctrl = $ctrl;
37
-        $this->data = $data;
38
-    }
30
+	/**
31
+	 * Constructor 
32
+	 * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller
33
+	 * @param ViewBag $data ViewBag holding view data
34
+	 */
35
+	public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) {
36
+		$this->ctrl = $ctrl;
37
+		$this->data = $data;
38
+	}
39 39
     
40
-    /**
41
-     * Render the view to the page, including header.
42
-     * 
43
-     * @throws \Exception
44
-     */
45
-    public function render() {
40
+	/**
41
+	 * Render the view to the page, including header.
42
+	 * 
43
+	 * @throws \Exception
44
+	 */
45
+	public function render() {
46 46
 		global $controller;
47 47
 		
48
-        if(!$this->ctrl) throw new \Exception('Controller not initialised');
48
+		if(!$this->ctrl) throw new \Exception('Controller not initialised');
49 49
         
50 50
 		$controller = $this->ctrl;
51
-        $this->ctrl->pageHeader();
51
+		$this->ctrl->pageHeader();
52 52
         
53
-        echo $this->renderContent();
54
-    }
53
+		echo $this->renderContent();
54
+	}
55 55
     
56
-    /**
57
-     * Render the view to the page, without any header
58
-     */
59
-    public function renderPartial() {
60
-        echo $this->getHtmlPartial();
61
-    }
56
+	/**
57
+	 * Render the view to the page, without any header
58
+	 */
59
+	public function renderPartial() {
60
+		echo $this->getHtmlPartial();
61
+	}
62 62
     
63
-    /**
64
-     * Return the HTML code generated by the view, without any header
65
-     */
66
-    public function getHtmlPartial() {
67
-        return $this->renderContent();
68
-    }
63
+	/**
64
+	 * Return the HTML code generated by the view, without any header
65
+	 */
66
+	public function getHtmlPartial() {
67
+		return $this->renderContent();
68
+	}
69 69
     
70
-    /**
71
-     * Abstract method containing the details of the view.
72
-     */
73
-    abstract protected function renderContent();
70
+	/**
71
+	 * Abstract method containing the details of the view.
72
+	 */
73
+	abstract protected function renderContent();
74 74
     
75 75
 }
76 76
  
77 77
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@
 block discarded – undo
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();
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/HookProvider.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,16 +74,14 @@
 block discarded – undo
74 74
 								if(is_int($key)) {
75 75
 									$hook_item = $value;
76 76
 									$priority = self::DEFAULT_PRIORITY;
77
-								}
78
-								else{
77
+								} else{
79 78
 									$hook_item = explode('#', $key, 2);
80 79
 									$priority = $value;
81 80
 								}
82 81
 								if($hook_item && count($hook_item) == 2){
83 82
 									$hook_func = $hook_item[0];
84 83
 									$hook_cont = $hook_item[1];
85
-								}
86
-								else{
84
+								} else{
87 85
 									$hook_func = $hook_item[0];
88 86
 									$hook_cont = 'all';
89 87
 								}
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public static function getInstance()
44 44
 	{
45
-	    if (null === static::$instance) {
46
-	        static::$instance = new static();
47
-	    }
45
+		if (null === static::$instance) {
46
+			static::$instance = new static();
47
+		}
48 48
 	
49
-	    return static::$instance;
49
+		return static::$instance;
50 50
 	}
51 51
 	
52 52
 	/**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::get()
55 55
 	 */
56 56
 	public function get($hook_function, $hook_context = null) {
57
-	    return new Hook($hook_function, $hook_context);
57
+		return new Hook($hook_function, $hook_context);
58 58
 	}
59 59
 	
60 60
 	/**
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	public function getPossibleHooks() {
73 73
 		static $hooks=null;
74 74
 		if ($hooks === null) {
75
-		    $hooks = array();
76
-		    foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) {
77
-		        try {
78
-		            $module = include $file;
79
-		            if($module instanceof HookSubscriberInterface){
75
+			$hooks = array();
76
+			foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) {
77
+				try {
78
+					$module = include $file;
79
+					if($module instanceof HookSubscriberInterface){
80 80
 						$subscribedhooks = $module->getSubscribedHooks();
81 81
 						if(is_array($subscribedhooks)){
82 82
 							foreach($subscribedhooks as $key => $value){
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 							}
103 103
 						}
104 104
 					}
105
-    			} catch (\Exception $ex) {
106
-    				// Old or invalid module?
107
-    			}
105
+				} catch (\Exception $ex) {
106
+					// Old or invalid module?
107
+				}
108 108
 			}
109 109
 		}
110 110
 		return $hooks;
@@ -146,33 +146,33 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function updateHooks() {
148 148
 	    
149
-	    if(Auth::isAdmin()){
150
-	        $ihooks = self::getInstalledHooks();
151
-	        $phooks = self::getPossibleHooks();
149
+		if(Auth::isAdmin()){
150
+			$ihooks = self::getInstalledHooks();
151
+			$phooks = self::getPossibleHooks();
152 152
 	        	
153
-	        // Insert hooks not existing yet in the DB
154
-	        if($phooks !== null){
155
-	            foreach($phooks as $phook => $priority){
156
-	                $array_hook = explode('#', $phook);
157
-	                if($ihooks === null || !array_key_exists($phook, $ihooks)){
158
-	                    $chook = new Hook($array_hook[1], $array_hook[2]);
159
-	                    $chook->subscribe($array_hook[0]);
160
-	                    $chook->setPriority($array_hook[0], $priority);
161
-	                }
162
-	            }
163
-	        }
153
+			// Insert hooks not existing yet in the DB
154
+			if($phooks !== null){
155
+				foreach($phooks as $phook => $priority){
156
+					$array_hook = explode('#', $phook);
157
+					if($ihooks === null || !array_key_exists($phook, $ihooks)){
158
+						$chook = new Hook($array_hook[1], $array_hook[2]);
159
+						$chook->subscribe($array_hook[0]);
160
+						$chook->setPriority($array_hook[0], $priority);
161
+					}
162
+				}
163
+			}
164 164
 	        	
165
-	        //Remove hooks not existing any more in the file system
166
-	        if($ihooks !== null){
167
-	            foreach($ihooks as $ihook => $status){
168
-	                $array_hook = explode('#', $ihook);
169
-	                if($phooks === null || !array_key_exists($ihook, $phooks)){
170
-	                    $chook = new Hook($array_hook[1], $array_hook[2]);
171
-	                    $chook->remove($array_hook[0]);
172
-	                }
173
-	            }
174
-	        }
175
-	    }
165
+			//Remove hooks not existing any more in the file system
166
+			if($ihooks !== null){
167
+				foreach($ihooks as $ihook => $status){
168
+					$array_hook = explode('#', $ihook);
169
+					if($phooks === null || !array_key_exists($ihook, $phooks)){
170
+						$chook = new Hook($array_hook[1], $array_hook[2]);
171
+						$chook->remove($array_hook[0]);
172
+					}
173
+				}
174
+			}
175
+		}
176 176
 	}
177 177
 	
178 178
 }
179 179
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -70,34 +70,34 @@  discard block
 block discarded – undo
70 70
 	 * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getPossibleHooks()
71 71
 	 */
72 72
 	public function getPossibleHooks() {
73
-		static $hooks=null;
73
+		static $hooks = null;
74 74
 		if ($hooks === null) {
75 75
 		    $hooks = array();
76
-		    foreach (glob(WT_ROOT . WT_MODULES_DIR . '*/module.php') as $file) {
76
+		    foreach (glob(WT_ROOT.WT_MODULES_DIR.'*/module.php') as $file) {
77 77
 		        try {
78 78
 		            $module = include $file;
79
-		            if($module instanceof HookSubscriberInterface){
79
+		            if ($module instanceof HookSubscriberInterface) {
80 80
 						$subscribedhooks = $module->getSubscribedHooks();
81
-						if(is_array($subscribedhooks)){
82
-							foreach($subscribedhooks as $key => $value){
83
-								if(is_int($key)) {
81
+						if (is_array($subscribedhooks)) {
82
+							foreach ($subscribedhooks as $key => $value) {
83
+								if (is_int($key)) {
84 84
 									$hook_item = $value;
85 85
 									$priority = self::DEFAULT_PRIORITY;
86 86
 								}
87
-								else{
87
+								else {
88 88
 									$hook_item = explode('#', $key, 2);
89 89
 									$priority = $value;
90 90
 								}
91
-								if($hook_item && count($hook_item) == 2){
91
+								if ($hook_item && count($hook_item) == 2) {
92 92
 									$hook_func = $hook_item[0];
93 93
 									$hook_cont = $hook_item[1];
94 94
 								}
95
-								else{
95
+								else {
96 96
 									$hook_func = $hook_item[0];
97 97
 									$hook_cont = 'all';
98 98
 								}
99
-								if(method_exists($module, $hook_func)){
100
-									$hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont]=$priority;
99
+								if (method_exists($module, $hook_func)) {
100
+									$hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont] = $priority;
101 101
 								}
102 102
 							}
103 103
 						}
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * {@inheritDoc}
115 115
 	 * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getRawInstalledHooks()
116 116
 	 */
117
-	public function getRawInstalledHooks(){
118
-		if(self::isModuleOperational()){
117
+	public function getRawInstalledHooks() {
118
+		if (self::isModuleOperational()) {
119 119
 			return fw\Database::prepare(
120 120
 					"SELECT majh_id AS id, majh_module_name AS module, majh_hook_function AS hook, majh_hook_context as context, majh_module_priority AS priority,  majh_status AS status".
121 121
 					" FROM `##maj_hooks`".
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 	 * {@inheritDoc}
130 130
 	 * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getInstalledHooks()
131 131
 	 */
132
-	public function getInstalledHooks(){
133
-		static $installedhooks =null;
134
-		if($installedhooks===null){
135
-			$dbhooks=self::getRawInstalledHooks();
136
-			foreach($dbhooks as $dbhook){
132
+	public function getInstalledHooks() {
133
+		static $installedhooks = null;
134
+		if ($installedhooks === null) {
135
+			$dbhooks = self::getRawInstalledHooks();
136
+			foreach ($dbhooks as $dbhook) {
137 137
 				$installedhooks[($dbhook->module).'#'.($dbhook->hook).'#'.($dbhook->context)] = array('id' => $dbhook->id, 'status' => $dbhook->status, 'priority' => $dbhook->priority);
138 138
 			}
139 139
 		}
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function updateHooks() {
148 148
 	    
149
-	    if(Auth::isAdmin()){
149
+	    if (Auth::isAdmin()) {
150 150
 	        $ihooks = self::getInstalledHooks();
151 151
 	        $phooks = self::getPossibleHooks();
152 152
 	        	
153 153
 	        // Insert hooks not existing yet in the DB
154
-	        if($phooks !== null){
155
-	            foreach($phooks as $phook => $priority){
154
+	        if ($phooks !== null) {
155
+	            foreach ($phooks as $phook => $priority) {
156 156
 	                $array_hook = explode('#', $phook);
157
-	                if($ihooks === null || !array_key_exists($phook, $ihooks)){
157
+	                if ($ihooks === null || !array_key_exists($phook, $ihooks)) {
158 158
 	                    $chook = new Hook($array_hook[1], $array_hook[2]);
159 159
 	                    $chook->subscribe($array_hook[0]);
160 160
 	                    $chook->setPriority($array_hook[0], $priority);
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	        }
164 164
 	        	
165 165
 	        //Remove hooks not existing any more in the file system
166
-	        if($ihooks !== null){
167
-	            foreach($ihooks as $ihook => $status){
166
+	        if ($ihooks !== null) {
167
+	            foreach ($ihooks as $ihook => $status) {
168 168
 	                $array_hook = explode('#', $ihook);
169
-	                if($phooks === null || !array_key_exists($ihook, $phooks)){
169
+	                if ($phooks === null || !array_key_exists($ihook, $phooks)) {
170 170
 	                    $chook = new Hook($array_hook[1], $array_hook[2]);
171 171
 	                    $chook->remove($array_hook[0]);
172 172
 	                }
Please login to merge, or discard this patch.
src/Webtrees/Hook/Hook.php 2 patches
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;
12 12
 
13 13
 use \Fisharebest\Webtrees as fw;
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
46 46
 	 *
47 47
 	 * @param string $hsubscriber Name of the subscriber module
48 48
 	 */
49
-	public function subscribe($hsubscriber){
50
-		if(HookProvider::getInstance()->isModuleOperational()){
49
+	public function subscribe($hsubscriber) {
50
+		if (HookProvider::getInstance()->isModuleOperational()) {
51 51
 			$statement = fw\Database::prepare(
52 52
 					"INSERT IGNORE INTO `##maj_hooks` (majh_hook_function, majh_hook_context, majh_module_name)".
53 53
 					" VALUES (?, ?, ?)"
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
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/CustomSimpleTagManagerInterface.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   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 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
 /**
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 interface CustomSimpleTagManager {
19 19
 
20 20
 
21
-    /**
22
-     * Returns the list of expected tags, classified by type of records.
23
-     *
24
-     * @return array List of expected tags
25
-     */
26
-    public function hGetExpectedTags();
21
+	/**
22
+	 * Returns the list of expected tags, classified by type of records.
23
+	 *
24
+	 * @return array List of expected tags
25
+	 */
26
+	public function hGetExpectedTags();
27 27
     
28 28
 	/**
29 29
 	 * Return the HTML code to be display for this tag.
Please login to merge, or discard this patch.