Completed
Push — master ( 6465ee...6276bd )
by Jonathan
02:42
created
src/Webtrees/Module/GeoDispersionModule.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     public function getConfigLink() {
65 65
         Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
66 66
         
67
-        return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig';
67
+        return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig';
68 68
     }
69 69
     
70 70
     /**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public function getProvider() {
84 84
         global $WT_TREE;
85 85
         
86
-        if(!$this->provider) {
86
+        if (!$this->provider) {
87 87
             $this->provider = new GeoAnalysisProvider($WT_TREE);
88 88
         }
89 89
         return $this->provider;
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -24,88 +24,88 @@
 block discarded – undo
24 24
 class GeoDispersionModule extends AbstractModule implements ModuleConfigInterface, DependentInterface {
25 25
     
26 26
 	// How to update the database schema for this module
27
-    const SCHEMA_TARGET_VERSION   = 1;
28
-    const SCHEMA_SETTING_NAME     = 'MAJ_GEODISP_SCHEMA_VERSION';
29
-    const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\GeoDispersion\Schema';
27
+	const SCHEMA_TARGET_VERSION   = 1;
28
+	const SCHEMA_SETTING_NAME     = 'MAJ_GEODISP_SCHEMA_VERSION';
29
+	const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\GeoDispersion\Schema';
30 30
     
31
-    /** @var string For custom modules - link for support, upgrades, etc. */
32
-    const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
31
+	/** @var string For custom modules - link for support, upgrades, etc. */
32
+	const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
33 33
         
34
-    /**
35
-     * GeoDispersion analysis provider
36
-     * @var \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider $provider
37
-     */
38
-    protected $provider;
34
+	/**
35
+	 * GeoDispersion analysis provider
36
+	 * @var \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider $provider
37
+	 */
38
+	protected $provider;
39 39
     
40
-    /**
41
-     * {@inhericDoc}
42
-     */
43
-    public function getTitle() {
44
-        return /* I18N: Name of the “Hooks” module */ I18N::translate('Geographical Dispersion');
45
-    }
40
+	/**
41
+	 * {@inhericDoc}
42
+	 */
43
+	public function getTitle() {
44
+		return /* I18N: Name of the “Hooks” module */ I18N::translate('Geographical Dispersion');
45
+	}
46 46
     
47
-    /**
48
-     * {@inhericDoc}
49
-     */
50
-    public function getDescription() {
51
-        return /* I18N: Description of the “Hooks” module */ I18N::translate('Display the geographical dispersion of the root person’s Sosa ancestors.');
52
-    }
47
+	/**
48
+	 * {@inhericDoc}
49
+	 */
50
+	public function getDescription() {
51
+		return /* I18N: Description of the “Hooks” module */ I18N::translate('Display the geographical dispersion of the root person’s Sosa ancestors.');
52
+	}
53 53
     
54
-    /**
55
-     * {@inhericDoc}
56
-     */
57
-    public function modAction($mod_action) {
58
-        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
54
+	/**
55
+	 * {@inhericDoc}
56
+	 */
57
+	public function modAction($mod_action) {
58
+		Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
59 59
         
60
-        \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
61
-    }
60
+		\MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
61
+	}
62 62
     
63
-    /**
64
-     * {@inhericDoc}
65
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
66
-     */
67
-    public function getConfigLink() {
68
-        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
63
+	/**
64
+	 * {@inhericDoc}
65
+	 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
66
+	 */
67
+	public function getConfigLink() {
68
+		Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
69 69
         
70
-        return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig';
71
-    }
70
+		return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig';
71
+	}
72 72
     
73
-    /**
74
-     * {@inhericDoc}
75
-     * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
76
-     */
77
-    public function validatePrerequisites() {
78
-        try {
79
-            Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
73
+	/**
74
+	 * {@inhericDoc}
75
+	 * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
76
+	 */
77
+	public function validatePrerequisites() {
78
+		try {
79
+			Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
80 80
             
81
-            return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME));
82
-        }
83
-        catch (\Exception $ex) {  }
84
-        return false;
85
-    }
81
+			return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME));
82
+		}
83
+		catch (\Exception $ex) {  }
84
+		return false;
85
+	}
86 86
     
87 87
 	/**
88 88
 	 * Get the GeoAnalysis Provider (initialise it if not done yet).
89 89
 	 *
90 90
 	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider
91 91
 	 */
92
-    public function getProvider() {
93
-        global $WT_TREE;
92
+	public function getProvider() {
93
+		global $WT_TREE;
94 94
         
95
-        if(!$this->provider) {
96
-            $this->provider = new GeoAnalysisProvider($WT_TREE);
97
-        }
98
-        return $this->provider;
99
-    }
95
+		if(!$this->provider) {
96
+			$this->provider = new GeoAnalysisProvider($WT_TREE);
97
+		}
98
+		return $this->provider;
99
+	}
100 100
 	
101 101
 	/**
102 102
 	 * Set the GeoAnalysis Provider.
103 103
 	 *
104 104
 	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider
105 105
 	 */
106
-    public function setProvider(GeoAnalysisProvider $provider) {
107
-        $this->provider = $provider;
108
-    }
106
+	public function setProvider(GeoAnalysisProvider $provider) {
107
+		$this->provider = $provider;
108
+	}
109 109
     
110 110
 
111 111
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@
 block discarded – undo
79 79
             Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
80 80
             
81 81
             return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME));
82
-        }
83
-        catch (\Exception $ex) {  }
82
+        } catch (\Exception $ex) {  }
84 83
         return false;
85 84
     }
86 85
     
Please login to merge, or discard this patch.
src/Webtrees/Fact.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,26 +34,26 @@
 block discarded – undo
34 34
 	protected $fact; 
35 35
 	
36 36
 	/**
37
-	* Contructor for the decorator
38
-	*
39
-	* @param \Fisharebest\Webtrees\Fact $fact_in The Fact to extend
40
-	*/
37
+	 * Contructor for the decorator
38
+	 *
39
+	 * @param \Fisharebest\Webtrees\Fact $fact_in The Fact to extend
40
+	 */
41 41
 	public function __construct(\Fisharebest\Webtrees\Fact $fact_in){
42 42
 		$this->fact = $fact_in;
43 43
 	}
44 44
 	
45 45
 	/**
46
-	* Check if a fact has a date and is sourced
47
-	* Values:
48
-	* 		- 0, if no date is found for the fact
49
-	* 		- -1, if the date is not precise
50
-	* 		- -2, if the date is precise, but no source is found
51
-	* 		- 1, if the date is precise, and a source is found
52
-	* 		- 2, if the date is precise, a source exists, and is supported by a certificate (requires _ACT usage)
53
-	* 		- 3, if the date is precise, a source exists, and the certificate supporting the fact is within an acceptable range of date
54
-	*
55
-	* @return int Level of sources
56
-	*/
46
+	 * Check if a fact has a date and is sourced
47
+	 * Values:
48
+	 * 		- 0, if no date is found for the fact
49
+	 * 		- -1, if the date is not precise
50
+	 * 		- -2, if the date is precise, but no source is found
51
+	 * 		- 1, if the date is precise, and a source is found
52
+	 * 		- 2, if the date is precise, a source exists, and is supported by a certificate (requires _ACT usage)
53
+	 * 		- 3, if the date is precise, a source exists, and the certificate supporting the fact is within an acceptable range of date
54
+	 *
55
+	 * @return int Level of sources
56
+	 */
57 57
 	public function isSourced(){
58 58
 		$isSourced=0;
59 59
 		$date = $this->fact->getDate(false);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	*
39 39
 	* @param \Fisharebest\Webtrees\Fact $fact_in The Fact to extend
40 40
 	*/
41
-	public function __construct(\Fisharebest\Webtrees\Fact $fact_in){
41
+	public function __construct(\Fisharebest\Webtrees\Fact $fact_in) {
42 42
 		$this->fact = $fact_in;
43 43
 	}
44 44
 	
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
 	*
55 55
 	* @return int Level of sources
56 56
 	*/
57
-	public function isSourced(){
58
-		$isSourced=0;
57
+	public function isSourced() {
58
+		$isSourced = 0;
59 59
 		$date = $this->fact->getDate(false);
60
-		if($date->isOK()) {
61
-			$isSourced=-1;
62
-			if($date->qual1=='' && $date->minimumJulianDay() == $date->maximumJulianDay()){
63
-				$isSourced=-2;
60
+		if ($date->isOK()) {
61
+			$isSourced = -1;
62
+			if ($date->qual1 == '' && $date->minimumJulianDay() == $date->maximumJulianDay()) {
63
+				$isSourced = -2;
64 64
 				$citations = $this->fact->getCitations();
65
-				foreach($citations as $citation){
66
-					$isSourced=max($isSourced, 1);
67
-					if(preg_match('/3 _ACT (.*)/', $citation) ){
68
- 						$isSourced=max($isSourced, 2);
65
+				foreach ($citations as $citation) {
66
+					$isSourced = max($isSourced, 1);
67
+					if (preg_match('/3 _ACT (.*)/', $citation)) {
68
+ 						$isSourced = max($isSourced, 2);
69 69
  						preg_match_all("/4 DATE (.*)/", $citation, $datessource, PREG_SET_ORDER);
70
- 						foreach($datessource as $daterec){
70
+ 						foreach ($datessource as $daterec) {
71 71
  							$datesource = new Date($daterec[1]);
72
- 							if(abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN){
72
+ 							if (abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN) {
73 73
  								$isSourced = max($isSourced, 3); //If this level increases, do not forget to change the constant MAX_IS_SOURCED_LEVEL
74 74
  							}
75 75
  						}
Please login to merge, or discard this patch.
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/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/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.