@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param \Fisharebest\Webtrees\Controller\IndividualController $ctrlIndividual_in The Individual Controller to extend |
35 | 35 | */ |
36 | - public function __construct(fw\Controller\IndividualController $ctrlIndividual_in){ |
|
36 | + public function __construct(fw\Controller\IndividualController $ctrlIndividual_in) { |
|
37 | 37 | $this->ctrlIndividual = $ctrlIndividual_in; |
38 | 38 | $this->dindi = new mw\Individual($this->ctrlIndividual->getSignificantIndividual()); |
39 | 39 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
46 | 46 | */ |
47 | - public function printHeaderExtensions(){ |
|
47 | + public function printHeaderExtensions() { |
|
48 | 48 | $hook_extend_indi_header_left = new mw\Hook\Hook('hExtendIndiHeaderLeft'); |
49 | 49 | $hook_extend_indi_header_right = new mw\Hook\Hook('hExtendIndiHeaderRight'); |
50 | 50 | $hook_extend_indi_header_left = $hook_extend_indi_header_left->execute($this->ctrlIndividual); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | echo '<div id="indi_perso_header">', |
54 | 54 | '<div id="indi_perso_header_left">'; |
55 | 55 | foreach ($hook_extend_indi_header_left as $div) { |
56 | - if(count($div)==2){ |
|
56 | + if (count($div) == 2) { |
|
57 | 57 | echo '<div id="', $div[0], '" class="indi_perso_header_left_div">', |
58 | 58 | $div[1], '</div>'; |
59 | 59 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | echo '</div>', |
62 | 62 | '<div id="indi_perso_header_right">'; |
63 | 63 | foreach ($hook_extend_indi_header_right as $div) { |
64 | - if(count($div)==2){ |
|
64 | + if (count($div) == 2) { |
|
65 | 65 | echo '<div id="', $div[0], '" class="indi_perso_header_right_div">', |
66 | 66 | $div[1], '</div>'; |
67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
78 | 78 | */ |
79 | - public function printHeaderExtraIcons(){ |
|
79 | + public function printHeaderExtraIcons() { |
|
80 | 80 | $hook_extend_indi_header_icons = new Hook('hExtendIndiHeaderIcons'); |
81 | 81 | $hook_extend_indi_header_icons = $hook_extend_indi_header_icons->execute($this->ctrlIndividual); |
82 | 82 |
@@ -34,26 +34,26 @@ |
||
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); |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 | } |
@@ -65,7 +65,6 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param string $facts List of facts to find information from |
67 | 67 | * @param int $style Style to apply to the information. Number >= 10 should be used in this function, lower number will return the core function. |
68 | - |
|
69 | 68 | */ |
70 | 69 | public function format_first_major_fact($facts, $style) { |
71 | 70 | return $this->formatFirstMajorFact($facts, $style); |
@@ -109,7 +108,7 @@ discard block |
||
109 | 108 | |
110 | 109 | if(!$this->gedcomrecord->canShow($access_level)) return false; |
111 | 110 | if($access_level === null ) |
112 | - $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
111 | + $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
113 | 112 | |
114 | 113 | if (isset($global_facts['SOUR'])) { |
115 | 114 | return $global_facts['SOUR'] >= $access_level; |
@@ -147,7 +146,7 @@ discard block |
||
147 | 146 | * @return int Level of sources |
148 | 147 | */ |
149 | 148 | public function isFactSourced($eventslist){ |
150 | - if(empty($eventslist)) return 0; |
|
149 | + if(empty($eventslist)) return 0; |
|
151 | 150 | $isSourced=0; |
152 | 151 | $facts = $this->gedcomrecord->getFacts($eventslist); |
153 | 152 | foreach($facts as $fact){ |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | protected $gedcomrecord; |
24 | 24 | |
25 | 25 | /** @var bool Is the GedcomRecord sourced (cache) */ |
26 | - protected $_issourced=null; |
|
26 | + protected $_issourced = null; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Contructor for the decorator |
30 | 30 | * |
31 | 31 | * @param \Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in The GedcomRecord to extend |
32 | 32 | */ |
33 | - public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in){ |
|
33 | + public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in) { |
|
34 | 34 | $this->gedcomrecord = $gedcomrecord_in; |
35 | 35 | } |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return \Fisharebest\Webtrees\GedcomRecord Embedded gedcom record |
41 | 41 | */ |
42 | - public function getDerivedRecord(){ |
|
42 | + public function getDerivedRecord() { |
|
43 | 43 | return $this->gedcomrecord; |
44 | 44 | } |
45 | 45 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if (($fact->getDate() || $fact->getPlace()) && $fact->canShow()) { |
86 | 86 | switch ($style) { |
87 | 87 | case 10: |
88 | - return '<i>'.$fact->getLabel().' '. mw\Functions\FunctionsPrint::formatFactDateShort($fact) .' '. mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1') .'</i>'; |
|
88 | + return '<i>'.$fact->getLabel().' '.mw\Functions\FunctionsPrint::formatFactDateShort($fact).' '.mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1').'</i>'; |
|
89 | 89 | break; |
90 | 90 | default: |
91 | 91 | return $this->gedcomrecord->formatFirstMajorFact($facts, $style); |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | * @param int $access_level |
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | - public function canDisplayIsSourced($access_level = null){ |
|
104 | + public function canDisplayIsSourced($access_level = null) { |
|
105 | 105 | global $global_facts; |
106 | 106 | |
107 | - if(!$this->gedcomrecord->canShow($access_level)) return false; |
|
108 | - if($access_level === null ) |
|
107 | + if (!$this->gedcomrecord->canShow($access_level)) return false; |
|
108 | + if ($access_level === null) |
|
109 | 109 | $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
110 | 110 | |
111 | 111 | if (isset($global_facts['SOUR'])) { |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return int Level of sources |
126 | 126 | */ |
127 | - public function isSourced(){ |
|
128 | - if($this->_issourced !== null) return $this->_issourced; |
|
129 | - $this->_issourced=-1; |
|
127 | + public function isSourced() { |
|
128 | + if ($this->_issourced !== null) return $this->_issourced; |
|
129 | + $this->_issourced = -1; |
|
130 | 130 | $sourcesfacts = $this->gedcomrecord->getFacts('SOUR'); |
131 | - foreach($sourcesfacts as $sourcefact){ |
|
132 | - $this->_issourced=max($this->_issourced, 1); |
|
133 | - if($sourcefact->getAttribute('_ACT')){ |
|
134 | - $this->_issourced=max($this->_issourced, 2); |
|
131 | + foreach ($sourcesfacts as $sourcefact) { |
|
132 | + $this->_issourced = max($this->_issourced, 1); |
|
133 | + if ($sourcefact->getAttribute('_ACT')) { |
|
134 | + $this->_issourced = max($this->_issourced, 2); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | return $this->_issourced; |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | * @param string $eventslist |
144 | 144 | * @return int Level of sources |
145 | 145 | */ |
146 | - public function isFactSourced($eventslist){ |
|
147 | - if(empty($eventslist)) return 0; |
|
148 | - $isSourced=0; |
|
146 | + public function isFactSourced($eventslist) { |
|
147 | + if (empty($eventslist)) return 0; |
|
148 | + $isSourced = 0; |
|
149 | 149 | $facts = $this->gedcomrecord->getFacts($eventslist); |
150 | - foreach($facts as $fact){ |
|
151 | - if($isSourced < Fact::MAX_IS_SOURCED_LEVEL){ |
|
150 | + foreach ($facts as $fact) { |
|
151 | + if ($isSourced < Fact::MAX_IS_SOURCED_LEVEL) { |
|
152 | 152 | $dfact = new Fact($fact); |
153 | 153 | $tmpIsSourced = $dfact->isSourced(); |
154 | - if($tmpIsSourced != 0) { |
|
155 | - if($isSourced==0) { |
|
156 | - $isSourced = $tmpIsSourced; |
|
154 | + if ($tmpIsSourced != 0) { |
|
155 | + if ($isSourced == 0) { |
|
156 | + $isSourced = $tmpIsSourced; |
|
157 | 157 | } |
158 | - else{ |
|
158 | + else { |
|
159 | 159 | $isSourced = max($isSourced, $tmpIsSourced); |
160 | 160 | } |
161 | 161 | } |
@@ -104,9 +104,12 @@ discard block |
||
104 | 104 | public function canDisplayIsSourced($access_level = null){ |
105 | 105 | global $global_facts; |
106 | 106 | |
107 | - if(!$this->gedcomrecord->canShow($access_level)) return false; |
|
108 | - if($access_level === null ) |
|
109 | - $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
107 | + if(!$this->gedcomrecord->canShow($access_level)) { |
|
108 | + return false; |
|
109 | + } |
|
110 | + if($access_level === null ) { |
|
111 | + $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
112 | + } |
|
110 | 113 | |
111 | 114 | if (isset($global_facts['SOUR'])) { |
112 | 115 | return $global_facts['SOUR'] >= $access_level; |
@@ -125,7 +128,9 @@ discard block |
||
125 | 128 | * @return int Level of sources |
126 | 129 | */ |
127 | 130 | public function isSourced(){ |
128 | - if($this->_issourced !== null) return $this->_issourced; |
|
131 | + if($this->_issourced !== null) { |
|
132 | + return $this->_issourced; |
|
133 | + } |
|
129 | 134 | $this->_issourced=-1; |
130 | 135 | $sourcesfacts = $this->gedcomrecord->getFacts('SOUR'); |
131 | 136 | foreach($sourcesfacts as $sourcefact){ |
@@ -144,7 +149,9 @@ discard block |
||
144 | 149 | * @return int Level of sources |
145 | 150 | */ |
146 | 151 | public function isFactSourced($eventslist){ |
147 | - if(empty($eventslist)) return 0; |
|
152 | + if(empty($eventslist)) { |
|
153 | + return 0; |
|
154 | + } |
|
148 | 155 | $isSourced=0; |
149 | 156 | $facts = $this->gedcomrecord->getFacts($eventslist); |
150 | 157 | foreach($facts as $fact){ |
@@ -154,8 +161,7 @@ discard block |
||
154 | 161 | if($tmpIsSourced != 0) { |
155 | 162 | if($isSourced==0) { |
156 | 163 | $isSourced = $tmpIsSourced; |
157 | - } |
|
158 | - else{ |
|
164 | + } else{ |
|
159 | 165 | $isSourced = max($isSourced, $tmpIsSourced); |
160 | 166 | } |
161 | 167 | } |
@@ -15,12 +15,12 @@ |
||
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 |
@@ -17,28 +17,28 @@ |
||
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 |
@@ -19,35 +19,35 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -50,10 +50,10 @@ discard block |
||
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 |
||
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 { |
@@ -71,12 +71,10 @@ |
||
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 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * @param \Fisharebest\Webtrees\Module\AbstractModule $module |
22 | 22 | * @param string $request |
23 | 23 | */ |
24 | - public function handle(\Fisharebest\Webtrees\Module\AbstractModule $module, $request); |
|
24 | + public function handle(\Fisharebest\Webtrees\Module\AbstractModule $module, $request); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | 28 | \ No newline at end of file |
@@ -17,87 +17,87 @@ |
||
17 | 17 | */ |
18 | 18 | class ViewFactory { |
19 | 19 | |
20 | - /** |
|
21 | - * @var ViewFactory $instance Singleton pattern instance |
|
22 | - */ |
|
23 | - private static $instance = null; |
|
20 | + /** |
|
21 | + * @var ViewFactory $instance Singleton pattern instance |
|
22 | + */ |
|
23 | + private static $instance = null; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Returns the *ViewFactory* instance of this class. |
|
27 | - * |
|
28 | - * @return ViewFactory The *Singleton* instance. |
|
29 | - */ |
|
30 | - public static function getInstance() |
|
31 | - { |
|
32 | - if (null === static::$instance) { |
|
33 | - static::$instance = new static(); |
|
34 | - } |
|
25 | + /** |
|
26 | + * Returns the *ViewFactory* instance of this class. |
|
27 | + * |
|
28 | + * @return ViewFactory The *Singleton* instance. |
|
29 | + */ |
|
30 | + public static function getInstance() |
|
31 | + { |
|
32 | + if (null === static::$instance) { |
|
33 | + static::$instance = new static(); |
|
34 | + } |
|
35 | 35 | |
36 | - return static::$instance; |
|
37 | - } |
|
36 | + return static::$instance; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Protected constructor |
|
41 | - */ |
|
42 | - protected function __construct() {} |
|
39 | + /** |
|
40 | + * Protected constructor |
|
41 | + */ |
|
42 | + protected function __construct() {} |
|
43 | 43 | |
44 | - /** |
|
45 | - * Return the view specified by the controller and view name, using data from the ViewBag |
|
46 | - * |
|
47 | - * @param string $view_name |
|
48 | - * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
49 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
50 | - * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
51 | - * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
52 | - * @throws \Exception |
|
53 | - */ |
|
54 | - public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
55 | - { |
|
56 | - if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | - if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | - if(!$view_name) throw new \Exception('View not defined'); |
|
44 | + /** |
|
45 | + * Return the view specified by the controller and view name, using data from the ViewBag |
|
46 | + * |
|
47 | + * @param string $view_name |
|
48 | + * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
49 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
50 | + * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
51 | + * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
52 | + * @throws \Exception |
|
53 | + */ |
|
54 | + public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
55 | + { |
|
56 | + if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | + if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | + if(!$view_name) throw new \Exception('View not defined'); |
|
59 | 59 | |
60 | - $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
|
61 | - $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
|
62 | - if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
60 | + $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
|
61 | + $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
|
62 | + if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
63 | 63 | |
64 | - return new $view_class($ctrl, $data); |
|
65 | - } |
|
64 | + return new $view_class($ctrl, $data); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Static invocation of the makeView method |
|
69 | - * |
|
70 | - * @param string $view_name |
|
71 | - * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
72 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
73 | - * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
74 | - * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
75 | - * @see \MyArtJaub\Webtrees\Mvc\View\ViewFactory::handle() |
|
76 | - */ |
|
77 | - public static function make($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
78 | - { |
|
79 | - return self::getInstance()->makeView($view_name, $mvc_ctrl, $ctrl, $data); |
|
80 | - } |
|
67 | + /** |
|
68 | + * Static invocation of the makeView method |
|
69 | + * |
|
70 | + * @param string $view_name |
|
71 | + * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl |
|
72 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
73 | + * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data |
|
74 | + * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View |
|
75 | + * @see \MyArtJaub\Webtrees\Mvc\View\ViewFactory::handle() |
|
76 | + */ |
|
77 | + public static function make($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
|
78 | + { |
|
79 | + return self::getInstance()->makeView($view_name, $mvc_ctrl, $ctrl, $data); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Private clone method to prevent cloning of the instance of the |
|
84 | - * *Dispatcher* instance. |
|
85 | - * |
|
86 | - * @return void |
|
87 | - */ |
|
88 | - private function __clone() |
|
89 | - { |
|
90 | - } |
|
82 | + /** |
|
83 | + * Private clone method to prevent cloning of the instance of the |
|
84 | + * *Dispatcher* instance. |
|
85 | + * |
|
86 | + * @return void |
|
87 | + */ |
|
88 | + private function __clone() |
|
89 | + { |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
94 | - * instance. |
|
95 | - * |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - private function __wakeup() |
|
99 | - { |
|
100 | - } |
|
92 | + /** |
|
93 | + * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
94 | + * instance. |
|
95 | + * |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + private function __wakeup() |
|
99 | + { |
|
100 | + } |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
104 | 104 | \ No newline at end of file |
@@ -53,13 +53,13 @@ |
||
53 | 53 | */ |
54 | 54 | public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
55 | 55 | { |
56 | - if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | - if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | - if(!$view_name) throw new \Exception('View not defined'); |
|
56 | + if (!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | + if (!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | + if (!$view_name) throw new \Exception('View not defined'); |
|
59 | 59 | |
60 | 60 | $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
61 | - $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
|
62 | - if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
61 | + $view_class = $mvc_ctrl_refl->getNamespaceName().'\\Views\\'.$view_name.'View'; |
|
62 | + if (!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
63 | 63 | |
64 | 64 | return new $view_class($ctrl, $data); |
65 | 65 | } |
@@ -53,13 +53,21 @@ |
||
53 | 53 | */ |
54 | 54 | public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
55 | 55 | { |
56 | - if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | - if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | - if(!$view_name) throw new \Exception('View not defined'); |
|
56 | + if(!$mvc_ctrl) { |
|
57 | + throw new \Exception('Mvc Controller not defined'); |
|
58 | + } |
|
59 | + if(!$ctrl) { |
|
60 | + throw new \Exception('Base Controller not defined'); |
|
61 | + } |
|
62 | + if(!$view_name) { |
|
63 | + throw new \Exception('View not defined'); |
|
64 | + } |
|
59 | 65 | |
60 | 66 | $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
61 | 67 | $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
62 | - if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
68 | + if(!class_exists($view_class)) { |
|
69 | + throw new \Exception('View does not exist'); |
|
70 | + } |
|
63 | 71 | |
64 | 72 | return new $view_class($ctrl, $data); |
65 | 73 | } |
@@ -15,62 +15,62 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class AbstractView { |
17 | 17 | |
18 | - /** |
|
19 | - * Reference controller |
|
20 | - * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
21 | - */ |
|
22 | - protected $ctrl; |
|
18 | + /** |
|
19 | + * Reference controller |
|
20 | + * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
21 | + */ |
|
22 | + protected $ctrl; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Structure containing the data of the view |
|
26 | - * @var ViewBag $data |
|
27 | - */ |
|
28 | - protected $data; |
|
24 | + /** |
|
25 | + * Structure containing the data of the view |
|
26 | + * @var ViewBag $data |
|
27 | + */ |
|
28 | + protected $data; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Constructor |
|
32 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
33 | - * @param ViewBag $data ViewBag holding view data |
|
34 | - */ |
|
35 | - public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
36 | - $this->ctrl = $ctrl; |
|
37 | - $this->data = $data; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Constructor |
|
32 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
33 | + * @param ViewBag $data ViewBag holding view data |
|
34 | + */ |
|
35 | + public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
36 | + $this->ctrl = $ctrl; |
|
37 | + $this->data = $data; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Render the view to the page, including header. |
|
42 | - * |
|
43 | - * @throws \Exception |
|
44 | - */ |
|
45 | - public function render() { |
|
40 | + /** |
|
41 | + * Render the view to the page, including header. |
|
42 | + * |
|
43 | + * @throws \Exception |
|
44 | + */ |
|
45 | + public function render() { |
|
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
49 | 49 | |
50 | 50 | $controller = $this->ctrl; |
51 | - $this->ctrl->pageHeader(); |
|
51 | + $this->ctrl->pageHeader(); |
|
52 | 52 | |
53 | - echo $this->renderContent(); |
|
54 | - } |
|
53 | + echo $this->renderContent(); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Render the view to the page, without any header |
|
58 | - */ |
|
59 | - public function renderPartial() { |
|
60 | - echo $this->getHtmlPartial(); |
|
61 | - } |
|
56 | + /** |
|
57 | + * Render the view to the page, without any header |
|
58 | + */ |
|
59 | + public function renderPartial() { |
|
60 | + echo $this->getHtmlPartial(); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Return the HTML code generated by the view, without any header |
|
65 | - */ |
|
66 | - public function getHtmlPartial() { |
|
67 | - return $this->renderContent(); |
|
68 | - } |
|
63 | + /** |
|
64 | + * Return the HTML code generated by the view, without any header |
|
65 | + */ |
|
66 | + public function getHtmlPartial() { |
|
67 | + return $this->renderContent(); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Abstract method containing the details of the view. |
|
72 | - */ |
|
73 | - abstract protected function renderContent(); |
|
70 | + /** |
|
71 | + * Abstract method containing the details of the view. |
|
72 | + */ |
|
73 | + abstract protected function renderContent(); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | \ No newline at end of file |
@@ -45,7 +45,7 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if (!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
49 | 49 | |
50 | 50 | $controller = $this->ctrl; |
51 | 51 | $this->ctrl->pageHeader(); |
@@ -45,7 +45,9 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if(!$this->ctrl) { |
|
49 | + throw new \Exception('Controller not initialised'); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | $controller = $this->ctrl; |
51 | 53 | $this->ctrl->pageHeader(); |