@@ -114,7 +114,7 @@ |
||
114 | 114 | * |
115 | 115 | * @param string $value Value name |
116 | 116 | * @param AbstractModule $mod Calling module |
117 | - * @return bool True is cached |
|
117 | + * @return boolean|null True is cached |
|
118 | 118 | */ |
119 | 119 | public static function isCached($value, AbstractModule $mod = null) { |
120 | 120 | self::getInstance()->isCachedI($value, $mod); |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Cache{ |
18 | 18 | |
19 | - /** |
|
20 | - * Underlying Zend Cache object |
|
21 | - * @var \Zend_Cache_Core|\Zend_Cache_FrontEnd $cache |
|
22 | - */ |
|
19 | + /** |
|
20 | + * Underlying Zend Cache object |
|
21 | + * @var \Zend_Cache_Core|\Zend_Cache_FrontEnd $cache |
|
22 | + */ |
|
23 | 23 | protected $cache=null; |
24 | 24 | |
25 | 25 | /** |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected static function getInstance() |
43 | 43 | { |
44 | - if (null === static::$instance) { |
|
45 | - static::$instance = new static(); |
|
46 | - } |
|
44 | + if (null === static::$instance) { |
|
45 | + static::$instance = new static(); |
|
46 | + } |
|
47 | 47 | |
48 | - return static::$instance; |
|
48 | + return static::$instance; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return string Cached key name |
92 | 92 | */ |
93 | 93 | protected function getKeyName($value, AbstractModule $mod = null){ |
94 | - $this->checkInit(); |
|
94 | + $this->checkInit(); |
|
95 | 95 | $mod_name = 'myartjaub'; |
96 | 96 | if($mod != null) $mod_name = $mod->getName(); |
97 | 97 | return $mod_name.'_'.$value; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return bool True is cached |
118 | 118 | */ |
119 | 119 | public static function isCached($value, AbstractModule $mod = null) { |
120 | - self::getInstance()->isCachedI($value, $mod); |
|
120 | + self::getInstance()->isCachedI($value, $mod); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return unknown_type Cached value |
141 | 141 | */ |
142 | 142 | public static function get($value, AbstractModule $mod = null){ |
143 | - self::getInstance()->getI($value, $mod); |
|
143 | + self::getInstance()->getI($value, $mod); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return unknown_type Cached value |
167 | 167 | */ |
168 | 168 | public static function save($value, $data, AbstractModule $mod = null){ |
169 | - self::getInstance()->saveI($value, $data, $mod); |
|
169 | + self::getInstance()->saveI($value, $data, $mod); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * |
175 | 175 | */ |
176 | 176 | public function cleanI(){ |
177 | - $this->checkInit(); |
|
177 | + $this->checkInit(); |
|
178 | 178 | $this->cache->clean(); |
179 | 179 | } |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * Static invocation of the *clean* method. |
183 | 183 | */ |
184 | 184 | public static function clean() { |
185 | - self::getInstance()->cleanI(); |
|
185 | + self::getInstance()->cleanI(); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | \ No newline at end of file |
@@ -52,7 +52,7 @@ |
||
52 | 52 | /** |
53 | 53 | * Find the spouse of a person, using the Xref comparison. |
54 | 54 | * |
55 | - * @param Individual $person |
|
55 | + * @param fw\Individual $person |
|
56 | 56 | * |
57 | 57 | * @return Individual|null |
58 | 58 | */ |
@@ -39,10 +39,10 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Check if this family's marriages are sourced |
|
43 | - * |
|
44 | - * @return int Level of sources |
|
45 | - * */ |
|
42 | + * Check if this family's marriages are sourced |
|
43 | + * |
|
44 | + * @return int Level of sources |
|
45 | + * */ |
|
46 | 46 | function isMarriageSourced(){ |
47 | 47 | if($this->_ismarriagesourced != null) return $this->_ismarriagesourced; |
48 | 48 | $this->_ismarriagesourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param integer $num Numerator |
53 | 53 | * @param integer $denom Denominator |
54 | - * @param float $default Default value if denominator null or 0 |
|
55 | - * @return float Result of the safe division |
|
54 | + * @param integer $default Default value if denominator null or 0 |
|
55 | + * @return integer Result of the safe division |
|
56 | 56 | */ |
57 | 57 | public static function safeDivision($num, $denom, $default = 0) { |
58 | 58 | if($denom && $denom!=0){ |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $num Numerator |
68 | 68 | * @param int $denom Denominator |
69 | - * @param float $default Default value if denominator null or 0 |
|
70 | - * @return float Percentage |
|
69 | + * @param integer $default Default value if denominator null or 0 |
|
70 | + * @return integer Percentage |
|
71 | 71 | */ |
72 | 72 | public static function getPercentage($num, $denom, $default = 0){ |
73 | 73 | return 100 * self::safeDivision($num, $denom, $default); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param string $file The image to resize |
80 | 80 | * @param int $target The final max width/height |
81 | - * @return array array of ($width, $height). One of them must be $target |
|
81 | + * @return integer[] array of ($width, $height). One of them must be $target |
|
82 | 82 | */ |
83 | 83 | static public function getResizedImageSize($file, $target=25){ |
84 | 84 | list($width, $height, $type, $attr) = getimagesize($file); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * Returns the generation associated with a Sosa number |
234 | 234 | * |
235 | 235 | * @param int $sosa Sosa number |
236 | - * @return number |
|
236 | + * @return integer |
|
237 | 237 | */ |
238 | 238 | public static function getGeneration($sosa){ |
239 | 239 | return(int)log($sosa, 2)+1; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * Returns whether the image type is supported by the system, and if so, return the standardised type |
247 | 247 | * |
248 | 248 | * @param string $reqtype Extension to test |
249 | - * @return boolean|string Is supported? |
|
249 | + * @return false|string Is supported? |
|
250 | 250 | */ |
251 | 251 | public static function isImageTypeSupported($reqtype) { |
252 | 252 | $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public static function encodeFileSystemToUtf8($string){ |
186 | 186 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
187 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
187 | + return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
188 | 188 | } |
189 | 189 | return $string; |
190 | 190 | } |
@@ -249,20 +249,20 @@ discard block |
||
249 | 249 | * @return boolean|string Is supported? |
250 | 250 | */ |
251 | 251 | public static function isImageTypeSupported($reqtype) { |
252 | - $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
253 | - $reqtype = strtolower($reqtype); |
|
252 | + $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
253 | + $reqtype = strtolower($reqtype); |
|
254 | 254 | |
255 | - if (empty($supportByGD[$reqtype])) { |
|
256 | - return false; |
|
257 | - } |
|
255 | + if (empty($supportByGD[$reqtype])) { |
|
256 | + return false; |
|
257 | + } |
|
258 | 258 | |
259 | - $type = $supportByGD[$reqtype]; |
|
259 | + $type = $supportByGD[$reqtype]; |
|
260 | 260 | |
261 | - if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
262 | - return $type; |
|
263 | - } |
|
261 | + if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
262 | + return $type; |
|
263 | + } |
|
264 | 264 | |
265 | - return false; |
|
265 | + return false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param \Fisharebest\Webtrees\Place $place |
76 | 76 | * @param string $icon_path |
77 | - * @param number $size |
|
77 | + * @param integer $size |
|
78 | 78 | * @return string HTML code of the inserted flag |
79 | 79 | */ |
80 | 80 | public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
@@ -184,7 +184,6 @@ discard block |
||
184 | 184 | /** |
185 | 185 | * Format date to display short (just years) |
186 | 186 | * |
187 | - * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date |
|
188 | 187 | * @param boolean $anchor option to print a link to calendar |
189 | 188 | * @return string HTML code for short date |
190 | 189 | */ |
@@ -212,7 +211,6 @@ discard block |
||
212 | 211 | /** |
213 | 212 | * Format fact place to display short |
214 | 213 | * |
215 | - * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date |
|
216 | 214 | * @param string $format Format of the place |
217 | 215 | * @param boolean $anchor option to print a link to placelist |
218 | 216 | * @return string HTML code for short place |
@@ -78,7 +78,7 @@ |
||
78 | 78 | * @return string HTML code of the inserted flag |
79 | 79 | */ |
80 | 80 | public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
81 | - return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
81 | + return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * Returns an estimated birth place based on statistics on the base |
94 | 94 | * |
95 | 95 | * @param boolean $perc Should the coefficient of reliability be returned |
96 | - * @return string|array Estimated birth place if found, null otherwise |
|
96 | + * @return string Estimated birth place if found, null otherwise |
|
97 | 97 | */ |
98 | 98 | public function getEstimatedBirthPlace($perc=false){ |
99 | 99 | if($bplace = $this->gedcomrecord->getBirthPlace()){ |
@@ -110,7 +110,6 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * Returns a significant place for the individual |
112 | 112 | * |
113 | - * @param boolean $perc Should the coefficient of reliability be returned |
|
114 | 113 | * @return string|array Estimated birth place if found, null otherwise |
115 | 114 | */ |
116 | 115 | public function getSignificantPlace(){ |
@@ -114,29 +114,29 @@ discard block |
||
114 | 114 | * @return string|array Estimated birth place if found, null otherwise |
115 | 115 | */ |
116 | 116 | public function getSignificantPlace(){ |
117 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
118 | - return $bplace; |
|
119 | - } |
|
117 | + if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
118 | + return $bplace; |
|
119 | + } |
|
120 | 120 | |
121 | - foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { |
|
122 | - if ($rplace) { |
|
123 | - return $rplace; |
|
124 | - } |
|
125 | - } |
|
121 | + foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { |
|
122 | + if ($rplace) { |
|
123 | + return $rplace; |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | - if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
128 | - return $dplace; |
|
129 | - } |
|
127 | + if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
128 | + return $dplace; |
|
129 | + } |
|
130 | 130 | |
131 | - foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
132 | - foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
|
133 | - if ($rplace) { |
|
134 | - return $rplace; |
|
135 | - } |
|
136 | - } |
|
137 | - } |
|
131 | + foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
132 | + foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
|
133 | + if ($rplace) { |
|
134 | + return $rplace; |
|
135 | + } |
|
136 | + } |
|
137 | + } |
|
138 | 138 | |
139 | - return null; |
|
139 | + return null; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return boolean Is the individual a Sosa ancestor |
146 | 146 | */ |
147 | 147 | public function isSosa(){ |
148 | - return count($this->getSosaNumbers()) > 0; |
|
148 | + return count($this->getSosaNumbers()) > 0; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @return array List of Sosa numbers |
157 | 157 | */ |
158 | 158 | public function getSosaNumbers(){ |
159 | - if($this->_sosa === null) { |
|
160 | - $provider = new SosaProvider($this->gedcomrecord->getTree()); |
|
161 | - $this->_sosa = $provider->getSosaNumbers($this->gedcomrecord); |
|
162 | - } |
|
163 | - return $this->_sosa; |
|
159 | + if($this->_sosa === null) { |
|
160 | + $provider = new SosaProvider($this->gedcomrecord->getTree()); |
|
161 | + $this->_sosa = $provider->getSosaNumbers($this->gedcomrecord); |
|
162 | + } |
|
163 | + return $this->_sosa; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Check if this individual's death is sourced |
|
179 | - * |
|
180 | - * @return int Level of sources |
|
181 | - * */ |
|
178 | + * Check if this individual's death is sourced |
|
179 | + * |
|
180 | + * @return int Level of sources |
|
181 | + * */ |
|
182 | 182 | public function isDeathSourced(){ |
183 | 183 | if($this->_isdeathsourced != null) return $this->_isdeathsourced; |
184 | 184 | $this->_isdeathsourced = $this->isFactSourced(WT_EVENTS_DEAT); |
@@ -110,7 +110,7 @@ |
||
110 | 110 | * Set parameters of the Task |
111 | 111 | * |
112 | 112 | * @param bool $is_enabled Status of the task |
113 | - * @param \DateTime $lastupdated Time of the last task run |
|
113 | + * @param \DateTime $last_updated Time of the last task run |
|
114 | 114 | * @param bool $last_result Result of the last run, true for success, false for failure |
115 | 115 | * @param int $frequency Frequency of execution in minutes |
116 | 116 | * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
@@ -21,254 +21,254 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class AbstractTask { |
23 | 23 | |
24 | - /** |
|
25 | - * Time out for runnign tasks, in seconds. Default 5 min |
|
26 | - * @var int TASK_TIME_OUT |
|
27 | - */ |
|
28 | - const TASK_TIME_OUT = 300; |
|
24 | + /** |
|
25 | + * Time out for runnign tasks, in seconds. Default 5 min |
|
26 | + * @var int TASK_TIME_OUT |
|
27 | + */ |
|
28 | + const TASK_TIME_OUT = 300; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Task provider |
|
32 | - * @var TaskProviderInterface $provider |
|
33 | - */ |
|
30 | + /** |
|
31 | + * Task provider |
|
32 | + * @var TaskProviderInterface $provider |
|
33 | + */ |
|
34 | 34 | protected $provider; |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Task name |
38 | 38 | * @var string $name |
39 | 39 | */ |
40 | - protected $name; |
|
40 | + protected $name; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Status of the task |
|
44 | - * @var bool $is_enabled |
|
45 | - */ |
|
46 | - protected $is_enabled; |
|
42 | + /** |
|
43 | + * Status of the task |
|
44 | + * @var bool $is_enabled |
|
45 | + */ |
|
46 | + protected $is_enabled; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Last updated date |
|
50 | - * @var \DateTime $last_updated |
|
51 | - */ |
|
52 | - protected $last_updated; |
|
48 | + /** |
|
49 | + * Last updated date |
|
50 | + * @var \DateTime $last_updated |
|
51 | + */ |
|
52 | + protected $last_updated; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Last run result |
|
56 | - * @var bool $last_result |
|
57 | - */ |
|
58 | - protected $last_result; |
|
54 | + /** |
|
55 | + * Last run result |
|
56 | + * @var bool $last_result |
|
57 | + */ |
|
58 | + protected $last_result; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Task run frequency |
|
62 | - * @var int $frequency |
|
63 | - */ |
|
64 | - protected $frequency; |
|
60 | + /** |
|
61 | + * Task run frequency |
|
62 | + * @var int $frequency |
|
63 | + */ |
|
64 | + protected $frequency; |
|
65 | 65 | |
66 | - /** |
|
67 | - * Task remaining runs |
|
68 | - * @var int $nb_occurrences |
|
69 | - */ |
|
70 | - protected $nb_occurrences; |
|
66 | + /** |
|
67 | + * Task remaining runs |
|
68 | + * @var int $nb_occurrences |
|
69 | + */ |
|
70 | + protected $nb_occurrences; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Current running status of the task |
|
74 | - * @var bool $is_running |
|
75 | - */ |
|
76 | - protected $is_running; |
|
72 | + /** |
|
73 | + * Current running status of the task |
|
74 | + * @var bool $is_running |
|
75 | + */ |
|
76 | + protected $is_running; |
|
77 | 77 | |
78 | - /** |
|
79 | - * Constructor for the Admin task class |
|
78 | + /** |
|
79 | + * Constructor for the Admin task class |
|
80 | 80 | * |
81 | 81 | * @param string $file Filename containing the task object |
82 | 82 | * @param TaskProviderInterface $provider Provider for tasks |
83 | - */ |
|
84 | - public function __construct($file, TaskProviderInterface $provider = null){ |
|
85 | - $this->name = trim(basename($file, '.php')); |
|
83 | + */ |
|
84 | + public function __construct($file, TaskProviderInterface $provider = null){ |
|
85 | + $this->name = trim(basename($file, '.php')); |
|
86 | 86 | $this->provider = $provider; |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Get the provider. |
|
91 | - * |
|
92 | - * @return TaskProviderInterface |
|
93 | - */ |
|
94 | - public function getProvider(){ |
|
95 | - return $this->provider; |
|
96 | - } |
|
89 | + /** |
|
90 | + * Get the provider. |
|
91 | + * |
|
92 | + * @return TaskProviderInterface |
|
93 | + */ |
|
94 | + public function getProvider(){ |
|
95 | + return $this->provider; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Set the provider. |
|
100 | - * |
|
101 | - * @param TaskProviderInterface $provider |
|
102 | - * @return self Enable method-chaining |
|
103 | - */ |
|
104 | - public function setProvider(TaskProviderInterface $provider){ |
|
105 | - $this->provider = $provider; |
|
106 | - return $this; |
|
107 | - } |
|
98 | + /** |
|
99 | + * Set the provider. |
|
100 | + * |
|
101 | + * @param TaskProviderInterface $provider |
|
102 | + * @return self Enable method-chaining |
|
103 | + */ |
|
104 | + public function setProvider(TaskProviderInterface $provider){ |
|
105 | + $this->provider = $provider; |
|
106 | + return $this; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Set parameters of the Task |
|
111 | - * |
|
112 | - * @param bool $is_enabled Status of the task |
|
113 | - * @param \DateTime $lastupdated Time of the last task run |
|
114 | - * @param bool $last_result Result of the last run, true for success, false for failure |
|
115 | - * @param int $frequency Frequency of execution in minutes |
|
116 | - * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
117 | - * @param bool $is_running Indicates if the task is currently running |
|
118 | - */ |
|
119 | - public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
120 | - $this->is_enabled = $is_enabled; |
|
121 | - $this->last_updated = $last_updated; |
|
122 | - $this->last_result = $last_result; |
|
123 | - $this->frequency = $frequency; |
|
124 | - $this->nb_occurrences = $nb_occur; |
|
125 | - $this->is_running = $is_running; |
|
126 | - } |
|
109 | + /** |
|
110 | + * Set parameters of the Task |
|
111 | + * |
|
112 | + * @param bool $is_enabled Status of the task |
|
113 | + * @param \DateTime $lastupdated Time of the last task run |
|
114 | + * @param bool $last_result Result of the last run, true for success, false for failure |
|
115 | + * @param int $frequency Frequency of execution in minutes |
|
116 | + * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
117 | + * @param bool $is_running Indicates if the task is currently running |
|
118 | + */ |
|
119 | + public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
120 | + $this->is_enabled = $is_enabled; |
|
121 | + $this->last_updated = $last_updated; |
|
122 | + $this->last_result = $last_result; |
|
123 | + $this->frequency = $frequency; |
|
124 | + $this->nb_occurrences = $nb_occur; |
|
125 | + $this->is_running = $is_running; |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Get the name of the task |
|
130 | - * |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function getName(){ |
|
134 | - return $this->name; |
|
135 | - } |
|
128 | + /** |
|
129 | + * Get the name of the task |
|
130 | + * |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function getName(){ |
|
134 | + return $this->name; |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | - /** |
|
139 | - * Return the status of the task in a boolean way |
|
140 | - * |
|
141 | - * @return boolean True if enabled |
|
142 | - */ |
|
143 | - public function isEnabled(){ |
|
144 | - return $this->is_enabled; |
|
145 | - } |
|
138 | + /** |
|
139 | + * Return the status of the task in a boolean way |
|
140 | + * |
|
141 | + * @return boolean True if enabled |
|
142 | + */ |
|
143 | + public function isEnabled(){ |
|
144 | + return $this->is_enabled; |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Get the last updated time. |
|
149 | - * |
|
150 | - * @return \DateTime |
|
151 | - */ |
|
152 | - public function getLastUpdated(){ |
|
153 | - return $this->last_updated; |
|
154 | - } |
|
147 | + /** |
|
148 | + * Get the last updated time. |
|
149 | + * |
|
150 | + * @return \DateTime |
|
151 | + */ |
|
152 | + public function getLastUpdated(){ |
|
153 | + return $this->last_updated; |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * Check if the last result has been successful. |
|
158 | - * |
|
159 | - * @return bool |
|
160 | - */ |
|
161 | - public function isLastRunSuccess(){ |
|
162 | - return $this->last_result; |
|
163 | - } |
|
156 | + /** |
|
157 | + * Check if the last result has been successful. |
|
158 | + * |
|
159 | + * @return bool |
|
160 | + */ |
|
161 | + public function isLastRunSuccess(){ |
|
162 | + return $this->last_result; |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * Get the task frequency. |
|
167 | - * |
|
168 | - * @return int |
|
169 | - */ |
|
170 | - public function getFrequency(){ |
|
171 | - return $this->frequency; |
|
172 | - } |
|
165 | + /** |
|
166 | + * Get the task frequency. |
|
167 | + * |
|
168 | + * @return int |
|
169 | + */ |
|
170 | + public function getFrequency(){ |
|
171 | + return $this->frequency; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | /** |
175 | - * Set the task frequency. |
|
176 | - * |
|
175 | + * Set the task frequency. |
|
176 | + * |
|
177 | 177 | * @param int $frequency |
178 | - * @return self Enable method-chaining |
|
179 | - */ |
|
180 | - public function setFrequency($frequency){ |
|
181 | - $this->frequency = $frequency; |
|
178 | + * @return self Enable method-chaining |
|
179 | + */ |
|
180 | + public function setFrequency($frequency){ |
|
181 | + $this->frequency = $frequency; |
|
182 | 182 | return $this; |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * Get the number of remaining occurrences. |
|
187 | - * |
|
188 | - * @return int |
|
189 | - */ |
|
190 | - public function getRemainingOccurrences(){ |
|
191 | - return $this->nb_occurrences; |
|
192 | - } |
|
185 | + /** |
|
186 | + * Get the number of remaining occurrences. |
|
187 | + * |
|
188 | + * @return int |
|
189 | + */ |
|
190 | + public function getRemainingOccurrences(){ |
|
191 | + return $this->nb_occurrences; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | /** |
195 | - * Set the number of remaining occurrences. |
|
196 | - * |
|
195 | + * Set the number of remaining occurrences. |
|
196 | + * |
|
197 | 197 | * @param int $nb_occur |
198 | - * @return self Enable method-chaining |
|
199 | - */ |
|
200 | - public function setRemainingOccurrences($nb_occur){ |
|
201 | - $this->nb_occurrences = $nb_occur; |
|
198 | + * @return self Enable method-chaining |
|
199 | + */ |
|
200 | + public function setRemainingOccurrences($nb_occur){ |
|
201 | + $this->nb_occurrences = $nb_occur; |
|
202 | 202 | return $this; |
203 | - } |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * Check if the task if running. |
|
207 | - * |
|
208 | - * @return bool |
|
209 | - */ |
|
210 | - public function isRunning(){ |
|
211 | - return $this->is_running; |
|
212 | - } |
|
205 | + /** |
|
206 | + * Check if the task if running. |
|
207 | + * |
|
208 | + * @return bool |
|
209 | + */ |
|
210 | + public function isRunning(){ |
|
211 | + return $this->is_running; |
|
212 | + } |
|
213 | 213 | |
214 | 214 | |
215 | - /** |
|
216 | - * Return the name to display for the task |
|
217 | - * |
|
218 | - * @return string Title for the task |
|
219 | - */ |
|
220 | - abstract public function getTitle(); |
|
215 | + /** |
|
216 | + * Return the name to display for the task |
|
217 | + * |
|
218 | + * @return string Title for the task |
|
219 | + */ |
|
220 | + abstract public function getTitle(); |
|
221 | 221 | |
222 | - /** |
|
223 | - * Return the default frequency for the execution of the task |
|
224 | - * |
|
225 | - * @return int Frequency for the execution of the task |
|
226 | - */ |
|
227 | - abstract public function getDefaultFrequency(); |
|
222 | + /** |
|
223 | + * Return the default frequency for the execution of the task |
|
224 | + * |
|
225 | + * @return int Frequency for the execution of the task |
|
226 | + */ |
|
227 | + abstract public function getDefaultFrequency(); |
|
228 | 228 | |
229 | - /** |
|
230 | - * Execute the task's actions |
|
231 | - */ |
|
232 | - abstract protected function executeSteps(); |
|
229 | + /** |
|
230 | + * Execute the task's actions |
|
231 | + */ |
|
232 | + abstract protected function executeSteps(); |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * Persist task state into database. |
236 | 236 | * @return bool |
237 | 237 | */ |
238 | 238 | public function save() { |
239 | - if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
239 | + if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
240 | 240 | return $this->provider->updateTask($this); |
241 | 241 | } |
242 | 242 | |
243 | - /** |
|
244 | - * Execute the task, default skeleton |
|
245 | - * |
|
246 | - */ |
|
247 | - public function execute(){ |
|
243 | + /** |
|
244 | + * Execute the task, default skeleton |
|
245 | + * |
|
246 | + */ |
|
247 | + public function execute(){ |
|
248 | 248 | |
249 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
250 | - $this->is_running = false; |
|
249 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
250 | + $this->is_running = false; |
|
251 | 251 | |
252 | - if(!$this->is_running){ //TODO put in place a time_out for running... |
|
253 | - //TODO Log the executions in the logs |
|
254 | - $this->last_result = false; |
|
255 | - $this->is_running = true; |
|
256 | - $this->save(); |
|
252 | + if(!$this->is_running){ //TODO put in place a time_out for running... |
|
253 | + //TODO Log the executions in the logs |
|
254 | + $this->last_result = false; |
|
255 | + $this->is_running = true; |
|
256 | + $this->save(); |
|
257 | 257 | |
258 | - Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
259 | - $this->last_result = $this->executeSteps(); |
|
260 | - if($this->last_result){ |
|
261 | - $this->last_updated = new \DateTime(); |
|
262 | - if($this->nb_occurrences > 0){ |
|
263 | - $this->nb_occurrences--; |
|
264 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
265 | - } |
|
266 | - } |
|
267 | - $this->is_running = false; |
|
268 | - $this->save(); |
|
269 | - Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
270 | - } |
|
271 | - } |
|
258 | + Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
259 | + $this->last_result = $this->executeSteps(); |
|
260 | + if($this->last_result){ |
|
261 | + $this->last_updated = new \DateTime(); |
|
262 | + if($this->nb_occurrences > 0){ |
|
263 | + $this->nb_occurrences--; |
|
264 | + if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
265 | + } |
|
266 | + } |
|
267 | + $this->is_running = false; |
|
268 | + $this->save(); |
|
269 | + Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
270 | + } |
|
271 | + } |
|
272 | 272 | |
273 | 273 | |
274 | 274 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * Set the status of a specific admin task. |
33 | 33 | * The status can be enabled (true), or disabled (false). |
34 | 34 | * |
35 | - * @param AbstractTask $ga |
|
36 | 35 | * @param bool $status |
36 | + * @return void |
|
37 | 37 | */ |
38 | 38 | public function setTaskStatus(AbstractTask $task, $status); |
39 | 39 | |
@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | * Delete the task from the database, in a transactional manner. |
50 | 50 | * |
51 | 51 | * @param string $task_name Task to delete |
52 | + * @return boolean |
|
52 | 53 | */ |
53 | 54 | public function deleteTask($task_name); |
54 | 55 | |
@@ -75,7 +76,7 @@ discard block |
||
75 | 76 | * Returns the list of tasks that are currently meant to run. |
76 | 77 | * Tasks to run can be forced, or can be limited to only one. |
77 | 78 | * |
78 | - * @param string|null $force Force the enabled tasks to run. |
|
79 | + * @param boolean $force Force the enabled tasks to run. |
|
79 | 80 | * @param string|null $task_name Name of the specific task to run |
80 | 81 | */ |
81 | 82 | function getTasksToRun($force = false, $task_name = null); |
@@ -37,47 +37,47 @@ |
||
37 | 37 | */ |
38 | 38 | public function setTaskStatus(AbstractTask $task, $status); |
39 | 39 | |
40 | - /** |
|
41 | - * Update an Admin Task in the database. |
|
42 | - * |
|
43 | - * @param AbstractTask $task Task to update |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - function updateTask(AbstractTask $task); |
|
40 | + /** |
|
41 | + * Update an Admin Task in the database. |
|
42 | + * |
|
43 | + * @param AbstractTask $task Task to update |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + function updateTask(AbstractTask $task); |
|
47 | 47 | |
48 | - /** |
|
49 | - * Delete the task from the database, in a transactional manner. |
|
50 | - * |
|
51 | - * @param string $task_name Task to delete |
|
52 | - */ |
|
53 | - public function deleteTask($task_name); |
|
48 | + /** |
|
49 | + * Delete the task from the database, in a transactional manner. |
|
50 | + * |
|
51 | + * @param string $task_name Task to delete |
|
52 | + */ |
|
53 | + public function deleteTask($task_name); |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Returns the number of Admin Tasks (active and inactive). |
|
58 | - * |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function getTasksCount(); |
|
56 | + /** |
|
57 | + * Returns the number of Admin Tasks (active and inactive). |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function getTasksCount(); |
|
62 | 62 | |
63 | - /** |
|
64 | - * Return the list of Admin Tasks matching specified criterias. |
|
65 | - * |
|
66 | - * @param string $search Search criteria in analysis description |
|
67 | - * @param array $order_by Columns to order by |
|
68 | - * @param int $start Offset to start with (for pagination) |
|
69 | - * @param int|null $limit Max number of items to return (for pagination) |
|
70 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
71 | - */ |
|
72 | - function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null); |
|
63 | + /** |
|
64 | + * Return the list of Admin Tasks matching specified criterias. |
|
65 | + * |
|
66 | + * @param string $search Search criteria in analysis description |
|
67 | + * @param array $order_by Columns to order by |
|
68 | + * @param int $start Offset to start with (for pagination) |
|
69 | + * @param int|null $limit Max number of items to return (for pagination) |
|
70 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
71 | + */ |
|
72 | + function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null); |
|
73 | 73 | |
74 | - /** |
|
75 | - * Returns the list of tasks that are currently meant to run. |
|
76 | - * Tasks to run can be forced, or can be limited to only one. |
|
77 | - * |
|
78 | - * @param string|null $force Force the enabled tasks to run. |
|
79 | - * @param string|null $task_name Name of the specific task to run |
|
80 | - */ |
|
74 | + /** |
|
75 | + * Returns the list of tasks that are currently meant to run. |
|
76 | + * Tasks to run can be forced, or can be limited to only one. |
|
77 | + * |
|
78 | + * @param string|null $force Force the enabled tasks to run. |
|
79 | + * @param string|null $task_name Name of the specific task to run |
|
80 | + */ |
|
81 | 81 | function getTasksToRun($force = false, $task_name = null); |
82 | 82 | |
83 | 83 | /** |
@@ -109,6 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * {@inhericDoc} |
111 | 111 | * @see \Fisharebest\Webtrees\GedcomRecord::getInstance() |
112 | + * @param string $xref |
|
112 | 113 | */ |
113 | 114 | static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) { |
114 | 115 | try{ |
@@ -150,7 +151,7 @@ discard block |
||
150 | 151 | /** |
151 | 152 | * Define a source associated with the certificate |
152 | 153 | * |
153 | - * @param string|Source $xref |
|
154 | + * @param string|null $xref |
|
154 | 155 | */ |
155 | 156 | public function setSource($xref){ |
156 | 157 | if($xref instanceof Source){ |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class Certificate extends Media { |
37 | 37 | |
38 | - const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
38 | + const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
39 | 39 | |
40 | - /** @var string The "TITL" value from the GEDCOM |
|
41 | - * This is a tweak to overcome the private level from the parent object... |
|
42 | - */ |
|
43 | - protected $title = ''; |
|
40 | + /** @var string The "TITL" value from the GEDCOM |
|
41 | + * This is a tweak to overcome the private level from the parent object... |
|
42 | + */ |
|
43 | + protected $title = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Certificate provider |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param CertificateProviderInterface $provider |
81 | 81 | */ |
82 | 82 | public function __construct($data, Tree $tree, CertificateProviderInterface $provider) { |
83 | - $this->provider = $provider; |
|
83 | + $this->provider = $provider; |
|
84 | 84 | // Data is only the file name |
85 | 85 | $data = str_replace("\\", '/', $data); |
86 | 86 | $xref = Functions::encryptToSafeBase64($data); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @see \Fisharebest\Webtrees\Media::getTitle() |
166 | 166 | */ |
167 | 167 | public function getTitle() { |
168 | - return $this->title; |
|
168 | + return $this->title; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -241,26 +241,26 @@ discard block |
||
241 | 241 | $module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME); |
242 | 242 | |
243 | 243 | if($module) { |
244 | - $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
245 | - $sid= Filter::get('sid', WT_REGEX_XREF); |
|
244 | + $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
245 | + $sid= Filter::get('sid', WT_REGEX_XREF); |
|
246 | 246 | |
247 | - if($sid){ |
|
248 | - $this->source = Source::getInstance($sid, $this->tree); |
|
249 | - } |
|
250 | - else{ |
|
251 | - $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | - } |
|
247 | + if($sid){ |
|
248 | + $this->source = Source::getInstance($sid, $this->tree); |
|
249 | + } |
|
250 | + else{ |
|
251 | + $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | + } |
|
253 | 253 | |
254 | - if($this->source) { |
|
255 | - $wmtext = '©'; |
|
256 | - $repofact = $this->source->getFirstFact('REPO'); |
|
257 | - if($repofact) { |
|
258 | - $repo = $repofact->getTarget(); |
|
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | - } |
|
261 | - $wmtext .= $this->source->getFullName(); |
|
262 | - } |
|
263 | - return $wmtext; |
|
254 | + if($this->source) { |
|
255 | + $wmtext = '©'; |
|
256 | + $repofact = $this->source->getFirstFact('REPO'); |
|
257 | + if($repofact) { |
|
258 | + $repo = $repofact->getTarget(); |
|
259 | + if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | + } |
|
261 | + $wmtext .= $this->source->getFullName(); |
|
262 | + } |
|
263 | + return $wmtext; |
|
264 | 264 | } |
265 | 265 | return ''; |
266 | 266 | } |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | ' FROM `##individuals`'. |
324 | 324 | ' WHERE i_file= :gedcom_id AND i_gedcom LIKE :gedcom') |
325 | 325 | ->execute(array( |
326 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
327 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
326 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
327 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
328 | 328 | ))->fetchAll(); |
329 | 329 | |
330 | 330 | $list = array(); |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | ' FROM `##families`'. |
348 | 348 | ' WHERE f_file= :gedcom_id AND f_gedcom LIKE :gedcom') |
349 | 349 | ->execute(array( |
350 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
351 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
350 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
351 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
352 | 352 | ))->fetchAll(); |
353 | 353 | |
354 | 354 | $list = array(); |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | 'SELECT i_gedcom AS gedrec FROM `##individuals`'. |
376 | 376 | ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') |
377 | 377 | ->execute(array( |
378 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
379 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
378 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
379 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
380 | 380 | ))->fetchOne(); |
381 | 381 | if(!$ged){ |
382 | 382 | $ged = Database::prepare( |
383 | 383 | 'SELECT f_gedcom AS gedrec FROM `##families`'. |
384 | 384 | ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') |
385 | - ->execute(array( |
|
386 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
387 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
388 | - ))->fetchOne(); |
|
385 | + ->execute(array( |
|
386 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
387 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
388 | + ))->fetchOne(); |
|
389 | 389 | if(!$ged){ |
390 | 390 | $ged = Database::prepare( |
391 | - 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
392 | - ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
393 | - ->execute(array( |
|
394 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
395 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
396 | - ))->fetchOne(); |
|
391 | + 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
392 | + ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
393 | + ->execute(array( |
|
394 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
395 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
396 | + ))->fetchOne(); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | //If a record has been found, parse it to find the source reference. |
@@ -252,7 +252,7 @@ |
||
252 | 252 | /** |
253 | 253 | * Return the HTML code for custom simple tag _ACT |
254 | 254 | * |
255 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
255 | + * @param Certificate $certificate Certificate (as per the GEDCOM) |
|
256 | 256 | * @param string|null $sid Linked Source ID, if it exists |
257 | 257 | */ |
258 | 258 | protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
@@ -29,142 +29,142 @@ discard block |
||
29 | 29 | * Certificates Module. |
30 | 30 | */ |
31 | 31 | class CertificatesModule |
32 | - extends AbstractModule |
|
33 | - implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
32 | + extends AbstractModule |
|
33 | + implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface |
|
34 | 34 | { |
35 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
35 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Provider for Certificates |
|
40 | - * @var CertificateProviderInterface $provider |
|
41 | - */ |
|
42 | - protected $provider; |
|
38 | + /** |
|
39 | + * Provider for Certificates |
|
40 | + * @var CertificateProviderInterface $provider |
|
41 | + */ |
|
42 | + protected $provider; |
|
43 | 43 | |
44 | - /** |
|
45 | - * {@inhericDoc} |
|
46 | - */ |
|
47 | - public function getTitle() { |
|
48 | - return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
49 | - } |
|
44 | + /** |
|
45 | + * {@inhericDoc} |
|
46 | + */ |
|
47 | + public function getTitle() { |
|
48 | + return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates'); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inhericDoc} |
|
53 | - */ |
|
54 | - public function getDescription() { |
|
55 | - return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
56 | - } |
|
51 | + /** |
|
52 | + * {@inhericDoc} |
|
53 | + */ |
|
54 | + public function getDescription() { |
|
55 | + return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.'); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inhericDoc} |
|
60 | - */ |
|
61 | - public function modAction($mod_action) { |
|
62 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
63 | - } |
|
58 | + /** |
|
59 | + * {@inhericDoc} |
|
60 | + */ |
|
61 | + public function modAction($mod_action) { |
|
62 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inhericDoc} |
|
67 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
68 | - */ |
|
69 | - public function getConfigLink() { |
|
70 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | - } |
|
65 | + /** |
|
66 | + * {@inhericDoc} |
|
67 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
68 | + */ |
|
69 | + public function getConfigLink() { |
|
70 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * {@inhericDoc} |
|
75 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
76 | - */ |
|
77 | - public function getSubscribedHooks() { |
|
78 | - return array( |
|
79 | - 'hFactSourcePrepend' => 50, |
|
80 | - 'hGetExpectedTags' => 50, |
|
81 | - 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
82 | - 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
83 | - 'hAddSimpleTag#SOUR' => 50, |
|
84 | - 'hHasHelpTextTag#_ACT' => 50, |
|
85 | - 'hGetHelpTextTag#_ACT' => 50 |
|
86 | - ); |
|
87 | - } |
|
73 | + /** |
|
74 | + * {@inhericDoc} |
|
75 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
76 | + */ |
|
77 | + public function getSubscribedHooks() { |
|
78 | + return array( |
|
79 | + 'hFactSourcePrepend' => 50, |
|
80 | + 'hGetExpectedTags' => 50, |
|
81 | + 'hHtmlSimpleTagDisplay#_ACT' => 50, |
|
82 | + 'hHtmlSimpleTagEditor#_ACT' => 50, |
|
83 | + 'hAddSimpleTag#SOUR' => 50, |
|
84 | + 'hHasHelpTextTag#_ACT' => 50, |
|
85 | + 'hGetHelpTextTag#_ACT' => 50 |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * {@inhericDoc} |
|
91 | - * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
92 | - */ |
|
93 | - public function getMenu(Tree $tree, $reference = null) { |
|
94 | - $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
95 | - return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
96 | - } |
|
89 | + /** |
|
90 | + * {@inhericDoc} |
|
91 | + * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu() |
|
92 | + */ |
|
93 | + public function getMenu(Tree $tree, $reference = null) { |
|
94 | + $tree_url = $tree ? $tree->getNameUrl() : ''; |
|
95 | + return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * {@inhericDoc} |
|
100 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
101 | - */ |
|
102 | - public function hFactSourcePrepend($srec) { |
|
103 | - global $WT_TREE; |
|
98 | + /** |
|
99 | + * {@inhericDoc} |
|
100 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend() |
|
101 | + */ |
|
102 | + public function hFactSourcePrepend($srec) { |
|
103 | + global $WT_TREE; |
|
104 | 104 | |
105 | - $html=''; |
|
106 | - $sid=null; |
|
105 | + $html=''; |
|
106 | + $sid=null; |
|
107 | 107 | |
108 | - if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
109 | - if (!$srec || strlen($srec) == 0) return $html; |
|
108 | + if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
109 | + if (!$srec || strlen($srec) == 0) return $html; |
|
110 | 110 | |
111 | - $certificate = null; |
|
112 | - $subrecords = explode("\n", $srec); |
|
113 | - $levelSOUR = substr($subrecords[0], 0, 1); |
|
114 | - if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
115 | - $sid=$match[1]; |
|
116 | - }; |
|
117 | - $nb_subrecords = count($subrecords); |
|
118 | - for ($i=0; $i < $nb_subrecords; $i++) { |
|
119 | - $subrecords[$i] = trim($subrecords[$i]); |
|
120 | - $tag = substr($subrecords[$i], 2, 4); |
|
121 | - $text = substr($subrecords[$i], 7); |
|
122 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
123 | - } |
|
111 | + $certificate = null; |
|
112 | + $subrecords = explode("\n", $srec); |
|
113 | + $levelSOUR = substr($subrecords[0], 0, 1); |
|
114 | + if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
|
115 | + $sid=$match[1]; |
|
116 | + }; |
|
117 | + $nb_subrecords = count($subrecords); |
|
118 | + for ($i=0; $i < $nb_subrecords; $i++) { |
|
119 | + $subrecords[$i] = trim($subrecords[$i]); |
|
120 | + $tag = substr($subrecords[$i], 2, 4); |
|
121 | + $text = substr($subrecords[$i], 7); |
|
122 | + if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
123 | + } |
|
124 | 124 | |
125 | - if($certificate && $certificate->canShow()) |
|
126 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
125 | + if($certificate && $certificate->canShow()) |
|
126 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
127 | 127 | |
128 | - } |
|
129 | - return $html; |
|
130 | - } |
|
128 | + } |
|
129 | + return $html; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * {@inhericDoc} |
|
134 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
135 | - */ |
|
136 | - public function hFactSourceAppend($srec) { } |
|
132 | + /** |
|
133 | + * {@inhericDoc} |
|
134 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend() |
|
135 | + */ |
|
136 | + public function hFactSourceAppend($srec) { } |
|
137 | 137 | |
138 | - /** |
|
139 | - * {@inhericDoc} |
|
140 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
141 | - */ |
|
142 | - public function hGetExpectedTags() { |
|
143 | - return array('SOUR' => '_ACT'); |
|
144 | - } |
|
138 | + /** |
|
139 | + * {@inhericDoc} |
|
140 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags() |
|
141 | + */ |
|
142 | + public function hGetExpectedTags() { |
|
143 | + return array('SOUR' => '_ACT'); |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * {@inhericDoc} |
|
148 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
149 | - */ |
|
150 | - public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
151 | - $html = ''; |
|
152 | - switch($tag){ |
|
153 | - case '_ACT': |
|
154 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
155 | - break; |
|
156 | - } |
|
157 | - return $html; |
|
158 | - } |
|
146 | + /** |
|
147 | + * {@inhericDoc} |
|
148 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay() |
|
149 | + */ |
|
150 | + public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
|
151 | + $html = ''; |
|
152 | + switch($tag){ |
|
153 | + case '_ACT': |
|
154 | + if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
155 | + break; |
|
156 | + } |
|
157 | + return $html; |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * {@inhericDoc} |
|
162 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
163 | - */ |
|
164 | - public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
165 | - global $controller, $WT_TREE; |
|
160 | + /** |
|
161 | + * {@inhericDoc} |
|
162 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor() |
|
163 | + */ |
|
164 | + public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) { |
|
165 | + global $controller, $WT_TREE; |
|
166 | 166 | |
167 | - $html = ''; |
|
167 | + $html = ''; |
|
168 | 168 | |
169 | 169 | switch($tag){ |
170 | 170 | case '_ACT': |
@@ -192,78 +192,78 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | return $html; |
195 | - } |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * {@inhericDoc} |
|
199 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
200 | - */ |
|
201 | - public function hAddSimpleTag($context, $level) { |
|
202 | - switch($context){ |
|
203 | - case 'SOUR': |
|
204 | - FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
205 | - break; |
|
206 | - } |
|
207 | - } |
|
197 | + /** |
|
198 | + * {@inhericDoc} |
|
199 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
|
200 | + */ |
|
201 | + public function hAddSimpleTag($context, $level) { |
|
202 | + switch($context){ |
|
203 | + case 'SOUR': |
|
204 | + FunctionsEdit::addSimpleTag($level.' _ACT'); |
|
205 | + break; |
|
206 | + } |
|
207 | + } |
|
208 | 208 | |
209 | - /** |
|
210 | - * {@inhericDoc} |
|
211 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
212 | - */ |
|
213 | - public function hHasHelpTextTag($tag) { |
|
214 | - switch($tag){ |
|
209 | + /** |
|
210 | + * {@inhericDoc} |
|
211 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
|
212 | + */ |
|
213 | + public function hHasHelpTextTag($tag) { |
|
214 | + switch($tag){ |
|
215 | 215 | case '_ACT': |
216 | 216 | return true; |
217 | 217 | break; |
218 | 218 | } |
219 | 219 | return false; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * {@inhericDoc} |
|
224 | - * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
225 | - */ |
|
226 | - public function hGetHelpTextTag($tag) { |
|
227 | - switch($tag){ |
|
228 | - case '_ACT': |
|
229 | - return array( |
|
230 | - I18N::translate('Certificate'), |
|
231 | - '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
232 | - default: |
|
233 | - return null; |
|
234 | - } |
|
235 | - } |
|
222 | + /** |
|
223 | + * {@inhericDoc} |
|
224 | + * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
|
225 | + */ |
|
226 | + public function hGetHelpTextTag($tag) { |
|
227 | + switch($tag){ |
|
228 | + case '_ACT': |
|
229 | + return array( |
|
230 | + I18N::translate('Certificate'), |
|
231 | + '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>'); |
|
232 | + default: |
|
233 | + return null; |
|
234 | + } |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * Returns the default Certificate File Provider, as configured in the module |
|
239 | - * |
|
240 | - * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
241 | - */ |
|
242 | - public function getProvider() { |
|
243 | - global $WT_TREE; |
|
237 | + /** |
|
238 | + * Returns the default Certificate File Provider, as configured in the module |
|
239 | + * |
|
240 | + * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface |
|
241 | + */ |
|
242 | + public function getProvider() { |
|
243 | + global $WT_TREE; |
|
244 | 244 | |
245 | - if(!$this->provider) { |
|
246 | - $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
247 | - $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
248 | - } |
|
249 | - return $this->provider; |
|
250 | - } |
|
245 | + if(!$this->provider) { |
|
246 | + $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
|
247 | + $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
|
248 | + } |
|
249 | + return $this->provider; |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - /** |
|
254 | - * Return the HTML code for custom simple tag _ACT |
|
255 | - * |
|
256 | - * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
257 | - * @param string|null $sid Linked Source ID, if it exists |
|
258 | - */ |
|
259 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
260 | - $html = ''; |
|
261 | - if($certificate){ |
|
262 | - $certificate->setSource($sid); |
|
263 | - $html = $certificate->displayImage('icon'); |
|
264 | - } |
|
265 | - return $html; |
|
266 | - } |
|
253 | + /** |
|
254 | + * Return the HTML code for custom simple tag _ACT |
|
255 | + * |
|
256 | + * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
|
257 | + * @param string|null $sid Linked Source ID, if it exists |
|
258 | + */ |
|
259 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
260 | + $html = ''; |
|
261 | + if($certificate){ |
|
262 | + $certificate->setSource($sid); |
|
263 | + $html = $certificate->displayImage('icon'); |
|
264 | + } |
|
265 | + return $html; |
|
266 | + } |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | 270 | \ No newline at end of file |