@@ -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 |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Cache component to speed up some potential data retrievals |
16 | 16 | */ |
17 | -class Cache{ |
|
17 | +class Cache { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Underlying Zend Cache object |
21 | 21 | * @var \Zend_Cache_Core|\Zend_Cache_FrontEnd $cache |
22 | 22 | */ |
23 | - protected $cache=null; |
|
23 | + protected $cache = null; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Defines whether the cache has been initialised |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function init() { |
56 | 56 | // The translation libraries only work with a cache. |
57 | - $cache_options=array('automatic_serialization'=>true); |
|
57 | + $cache_options = array('automatic_serialization'=>true); |
|
58 | 58 | |
59 | 59 | if (ini_get('apc.enabled')) { |
60 | 60 | $this->cache = \Zend_Cache::factory('Core', 'Apc', $cache_options, array()); |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | * Initiliase the Cache if not done. |
80 | 80 | * |
81 | 81 | */ |
82 | - protected function checkInit(){ |
|
83 | - if(!$this->is_init) $this->init(); |
|
82 | + protected function checkInit() { |
|
83 | + if (!$this->is_init) $this->init(); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | * @param AbstractModule $mod Calling module |
91 | 91 | * @return string Cached key name |
92 | 92 | */ |
93 | - protected function getKeyName($value, AbstractModule $mod = null){ |
|
93 | + protected function getKeyName($value, AbstractModule $mod = null) { |
|
94 | 94 | $this->checkInit(); |
95 | 95 | $mod_name = 'myartjaub'; |
96 | - if($mod !== null) $mod_name = $mod->getName(); |
|
96 | + if ($mod !== null) $mod_name = $mod->getName(); |
|
97 | 97 | return $mod_name.'_'.$value; |
98 | 98 | } |
99 | 99 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param AbstractModule $mod Calling module |
128 | 128 | * @return unknown_type Cached value |
129 | 129 | */ |
130 | - public function getI($value, AbstractModule $mod = null){ |
|
130 | + public function getI($value, AbstractModule $mod = null) { |
|
131 | 131 | $this->checkInit(); |
132 | 132 | return $this->cache->load($this->getKeyName($value, $mod)); |
133 | 133 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param AbstractModule $mod Calling module |
140 | 140 | * @return unknown_type Cached value |
141 | 141 | */ |
142 | - public static function get($value, AbstractModule $mod = null){ |
|
142 | + public static function get($value, AbstractModule $mod = null) { |
|
143 | 143 | self::getInstance()->getI($value, $mod); |
144 | 144 | } |
145 | 145 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param AbstractModule $mod Calling module |
152 | 152 | * @return unknown_type Cached value |
153 | 153 | */ |
154 | - public function saveI($value, $data, AbstractModule $mod = null){ |
|
154 | + public function saveI($value, $data, AbstractModule $mod = null) { |
|
155 | 155 | $this->checkInit(); |
156 | 156 | $this->cache->save($data, $this->getKeyName($value, $mod)); |
157 | 157 | return $this->get($value, $mod); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param AbstractModule $mod Calling module |
166 | 166 | * @return unknown_type Cached value |
167 | 167 | */ |
168 | - public static function save($value, $data, AbstractModule $mod = null){ |
|
168 | + public static function save($value, $data, AbstractModule $mod = null) { |
|
169 | 169 | self::getInstance()->saveI($value, $data, $mod); |
170 | 170 | } |
171 | 171 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * Clean the cache |
174 | 174 | * |
175 | 175 | */ |
176 | - public function cleanI(){ |
|
176 | + public function cleanI() { |
|
177 | 177 | $this->checkInit(); |
178 | 178 | $this->cache->clean(); |
179 | 179 | } |
@@ -80,7 +80,9 @@ discard block |
||
80 | 80 | * |
81 | 81 | */ |
82 | 82 | protected function checkInit(){ |
83 | - if(!$this->is_init) $this->init(); |
|
83 | + if(!$this->is_init) { |
|
84 | + $this->init(); |
|
85 | + } |
|
84 | 86 | } |
85 | 87 | |
86 | 88 | /** |
@@ -93,7 +95,9 @@ discard block |
||
93 | 95 | protected function getKeyName($value, AbstractModule $mod = null){ |
94 | 96 | $this->checkInit(); |
95 | 97 | $mod_name = 'myartjaub'; |
96 | - if($mod !== null) $mod_name = $mod->getName(); |
|
98 | + if($mod !== null) { |
|
99 | + $mod_name = $mod->getName(); |
|
100 | + } |
|
97 | 101 | return $mod_name.'_'.$value; |
98 | 102 | } |
99 | 103 |
@@ -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'); |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * @param unknown_type $data Data to identify the individual |
30 | 30 | * @return \MyArtJaub\Webtrees\Family|null \MyArtJaub\Webtrees\Family instance |
31 | 31 | */ |
32 | - public static function getIntance($data){ |
|
32 | + public static function getIntance($data) { |
|
33 | 33 | $dfam = null; |
34 | 34 | $fam = fw\Family::getInstance($data); |
35 | - if($fam){ |
|
35 | + if ($fam) { |
|
36 | 36 | $dfam = new Family($fam); |
37 | 37 | } |
38 | 38 | return $dfam; |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return int Level of sources |
45 | 45 | * */ |
46 | - function isMarriageSourced(){ |
|
47 | - if($this->_ismarriagesourced !== null) return $this->_ismarriagesourced; |
|
46 | + function isMarriageSourced() { |
|
47 | + if ($this->_ismarriagesourced !== null) return $this->_ismarriagesourced; |
|
48 | 48 | $this->_ismarriagesourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
49 | 49 | return $this->_ismarriagesourced; |
50 | 50 | } |
@@ -44,7 +44,9 @@ |
||
44 | 44 | * @return int Level of sources |
45 | 45 | * */ |
46 | 46 | function isMarriageSourced(){ |
47 | - if($this->_ismarriagesourced !== null) return $this->_ismarriagesourced; |
|
47 | + if($this->_ismarriagesourced !== null) { |
|
48 | + return $this->_ismarriagesourced; |
|
49 | + } |
|
48 | 50 | $this->_ismarriagesourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
49 | 51 | return $this->_ismarriagesourced; |
50 | 52 | } |
@@ -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 | } |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param string $text Text to display |
42 | 42 | */ |
43 | - static public function promptAlert($text){ |
|
43 | + static public function promptAlert($text) { |
|
44 | 44 | echo '<script>'; |
45 | - echo 'alert("',fw\Filter::escapeHtml($text),'")'; |
|
45 | + echo 'alert("', fw\Filter::escapeHtml($text), '")'; |
|
46 | 46 | echo '</script>'; |
47 | 47 | } |
48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return float Result of the safe division |
56 | 56 | */ |
57 | 57 | public static function safeDivision($num, $denom, $default = 0) { |
58 | - if($denom && $denom!=0){ |
|
58 | + if ($denom && $denom != 0) { |
|
59 | 59 | return $num / $denom; |
60 | 60 | } |
61 | 61 | return $default; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param float $default Default value if denominator null or 0 |
70 | 70 | * @return float Percentage |
71 | 71 | */ |
72 | - public static function getPercentage($num, $denom, $default = 0){ |
|
72 | + public static function getPercentage($num, $denom, $default = 0) { |
|
73 | 73 | return 100 * self::safeDivision($num, $denom, $default); |
74 | 74 | } |
75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param int $target The final max width/height |
81 | 81 | * @return array array of ($width, $height). One of them must be $target |
82 | 82 | */ |
83 | - static public function getResizedImageSize($file, $target=25){ |
|
83 | + static public function getResizedImageSize($file, $target = 25) { |
|
84 | 84 | list($width, $height, $type, $attr) = getimagesize($file); |
85 | 85 | $max = max($width, $height); |
86 | 86 | $rapp = $target / $max; |
@@ -111,21 +111,21 @@ discard block |
||
111 | 111 | * @param int $length Length of the token, default to 32 |
112 | 112 | * @return string Random token |
113 | 113 | */ |
114 | - public static function generateRandomToken($length=32) { |
|
114 | + public static function generateRandomToken($length = 32) { |
|
115 | 115 | $chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); |
116 | 116 | $len_chars = count($chars); |
117 | 117 | $token = ''; |
118 | 118 | |
119 | 119 | for ($i = 0; $i < $length; $i++) |
120 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
120 | + $token .= $chars[mt_rand(0, $len_chars - 1)]; |
|
121 | 121 | |
122 | 122 | # Number of 32 char chunks |
123 | - $chunks = ceil( strlen($token) / 32 ); |
|
123 | + $chunks = ceil(strlen($token) / 32); |
|
124 | 124 | $md5token = ''; |
125 | 125 | |
126 | 126 | # Run each chunk through md5 |
127 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
128 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
127 | + for ($i = 1; $i <= $chunks; $i++) |
|
128 | + $md5token .= md5(substr($token, $i * 32 - 32, 32)); |
|
129 | 129 | |
130 | 130 | # Trim the token |
131 | 131 | return substr($md5token, 0, $length); |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @param string $data Text to encrypt |
139 | 139 | * @return string Encrypted and encoded text |
140 | 140 | */ |
141 | - public static function encryptToSafeBase64($data){ |
|
141 | + public static function encryptToSafeBase64($data) { |
|
142 | 142 | $key = 'STANDARDKEYIFNOSERVER'; |
143 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
143 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
144 | 144 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
145 | 145 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
146 | - $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
|
146 | + $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); |
|
147 | 147 | $encrypted = base64_encode($iv.$id); |
148 | 148 | // +, / and = are not URL-compatible |
149 | 149 | $encrypted = str_replace('+', '-', $encrypted); |
@@ -158,22 +158,22 @@ discard block |
||
158 | 158 | * @param string $encrypted Text to decrypt |
159 | 159 | * @return string Decrypted text |
160 | 160 | */ |
161 | - public static function decryptFromSafeBase64($encrypted){ |
|
161 | + public static function decryptFromSafeBase64($encrypted) { |
|
162 | 162 | $key = 'STANDARDKEYIFNOSERVER'; |
163 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
163 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
164 | 164 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
165 | 165 | $encrypted = str_replace('-', '+', $encrypted); |
166 | 166 | $encrypted = str_replace('_', '/', $encrypted); |
167 | 167 | $encrypted = str_replace('*', '=', $encrypted); |
168 | 168 | $encrypted = base64_decode($encrypted); |
169 | - if(!$encrypted) |
|
169 | + if (!$encrypted) |
|
170 | 170 | throw new InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
171 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
171 | + if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
172 | 172 | throw new InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
173 | 173 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
174 | 174 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
175 | 175 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
176 | - return preg_replace('~(?:\\000+)$~','',$decrypted); |
|
176 | + return preg_replace('~(?:\\000+)$~', '', $decrypted); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @param string $string Filesystem encoded string to encode |
183 | 183 | * @return string UTF-8 encoded string |
184 | 184 | */ |
185 | - public static function encodeFileSystemToUtf8($string){ |
|
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 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @param string $string UTF-8 encoded string to encode |
196 | 196 | * @return string Filesystem encoded string |
197 | 197 | */ |
198 | - public static function encodeUtf8ToFileSystem($string){ |
|
198 | + public static function encodeUtf8ToFileSystem($string) { |
|
199 | 199 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
200 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
200 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
201 | 201 | } |
202 | 202 | return $string; |
203 | 203 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @return boolean True if path valid |
211 | 211 | */ |
212 | 212 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
213 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
213 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
214 | 214 | return false; |
215 | 215 | } |
216 | 216 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @return array Array of month short names |
223 | 223 | */ |
224 | 224 | public static function getCalendarShortMonths($calendarId = 0) { |
225 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
225 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
226 | 226 | $calendar_info = cal_info($calendarId); |
227 | 227 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
228 | 228 | } |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param int $sosa Sosa number |
236 | 236 | * @return number |
237 | 237 | */ |
238 | - public static function getGeneration($sosa){ |
|
239 | - return(int)log($sosa, 2)+1; |
|
238 | + public static function getGeneration($sosa) { |
|
239 | + return(int)log($sosa, 2) + 1; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 |
@@ -116,16 +116,18 @@ discard block |
||
116 | 116 | $len_chars = count($chars); |
117 | 117 | $token = ''; |
118 | 118 | |
119 | - for ($i = 0; $i < $length; $i++) |
|
120 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
119 | + for ($i = 0; $i < $length; $i++) { |
|
120 | + $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
121 | + } |
|
121 | 122 | |
122 | 123 | # Number of 32 char chunks |
123 | 124 | $chunks = ceil( strlen($token) / 32 ); |
124 | 125 | $md5token = ''; |
125 | 126 | |
126 | 127 | # Run each chunk through md5 |
127 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
128 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
128 | + for ( $i=1; $i<=$chunks; $i++ ) { |
|
129 | + $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
130 | + } |
|
129 | 131 | |
130 | 132 | # Trim the token |
131 | 133 | return substr($md5token, 0, $length); |
@@ -140,8 +142,9 @@ discard block |
||
140 | 142 | */ |
141 | 143 | public static function encryptToSafeBase64($data){ |
142 | 144 | $key = 'STANDARDKEYIFNOSERVER'; |
143 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
144 | - $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
145 | + if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) { |
|
146 | + $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
147 | + } |
|
145 | 148 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
146 | 149 | $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
147 | 150 | $encrypted = base64_encode($iv.$id); |
@@ -160,16 +163,19 @@ discard block |
||
160 | 163 | */ |
161 | 164 | public static function decryptFromSafeBase64($encrypted){ |
162 | 165 | $key = 'STANDARDKEYIFNOSERVER'; |
163 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
164 | - $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
166 | + if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) { |
|
167 | + $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
|
168 | + } |
|
165 | 169 | $encrypted = str_replace('-', '+', $encrypted); |
166 | 170 | $encrypted = str_replace('_', '/', $encrypted); |
167 | 171 | $encrypted = str_replace('*', '=', $encrypted); |
168 | 172 | $encrypted = base64_decode($encrypted); |
169 | - if(!$encrypted) |
|
170 | - throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
171 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
172 | - throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
173 | + if(!$encrypted) { |
|
174 | + throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
175 | + } |
|
176 | + if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) { |
|
177 | + throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
178 | + } |
|
173 | 179 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
174 | 180 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
175 | 181 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
@@ -210,7 +216,9 @@ discard block |
||
210 | 216 | * @return boolean True if path valid |
211 | 217 | */ |
212 | 218 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
213 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
219 | + if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) { |
|
220 | + return true; |
|
221 | + } |
|
214 | 222 | return false; |
215 | 223 | } |
216 | 224 |
@@ -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 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return string List of elements |
33 | 33 | */ |
34 | 34 | static public function getListFromArray(array $array) { |
35 | - $n=count($array); |
|
35 | + $n = count($array); |
|
36 | 36 | switch ($n) { |
37 | 37 | case 0: |
38 | 38 | return ''; |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | default: |
42 | 42 | return implode( |
43 | 43 | /* I18N: list separator */ I18N::translate(', '), |
44 | - array_slice($array, 0, $n-1) |
|
45 | - ) . |
|
46 | - /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and ') . |
|
47 | - $array[$n-1]; |
|
44 | + array_slice($array, 0, $n - 1) |
|
45 | + ). |
|
46 | + /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and '). |
|
47 | + $array[$n - 1]; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | \Fisharebest\Webtrees\Fact $fact, |
60 | 60 | \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider |
61 | 61 | ) { |
62 | - $html=''; |
|
63 | - if($place = $fact->getPlace()) { |
|
64 | - $iconPlace= $mapProvider->getPlaceIcon($place); |
|
65 | - if($iconPlace && strlen($iconPlace) > 0){ |
|
66 | - $html.= '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; |
|
62 | + $html = ''; |
|
63 | + if ($place = $fact->getPlace()) { |
|
64 | + $iconPlace = $mapProvider->getPlaceIcon($place); |
|
65 | + if ($iconPlace && strlen($iconPlace) > 0) { |
|
66 | + $html .= '<div class="fact_flag">'.self::htmlPlaceIcon($place, $iconPlace, 50).'</div>'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | return $html; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @param number $size |
78 | 78 | * @return string HTML code of the inserted flag |
79 | 79 | */ |
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() . '" />'; |
|
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().'" />'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $minimum = PHP_INT_MAX; |
97 | 97 | $maximum = 1; |
98 | 98 | foreach ($list as $item => $params) { |
99 | - if(array_key_exists('count', $params)) { |
|
99 | + if (array_key_exists('count', $params)) { |
|
100 | 100 | $maximum = max($maximum, $params['count']); |
101 | 101 | $minimum = min($minimum, $params['count']); |
102 | 102 | } |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | $size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum); |
115 | 115 | } |
116 | 116 | |
117 | - $html .= '<a style="font-size:' . $size . '%" href="' . $url . '">'; |
|
117 | + $html .= '<a style="font-size:'.$size.'%" href="'.$url.'">'; |
|
118 | 118 | if ($totals) { |
119 | - $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $text . '</span>', I18N::number($count)); |
|
119 | + $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">'.$text.'</span>', I18N::number($count)); |
|
120 | 120 | } else { |
121 | 121 | $html .= $text; |
122 | 122 | } |
123 | 123 | $html .= '</a>'; |
124 | 124 | } |
125 | - return '<div class="tag_cloud">' . $html . '</div>'; |
|
125 | + return '<div class="tag_cloud">'.$html.'</div>'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * @param bool $isStrong Bolden the name ? |
158 | 158 | * @return string HTML Code for individual item |
159 | 159 | */ |
160 | - public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){ |
|
160 | + public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true) { |
|
161 | 161 | $html = ''; |
162 | 162 | $tag = 'em'; |
163 | - if($isStrong) $tag = 'strong'; |
|
164 | - if($individual && $individual->canShow()){ |
|
163 | + if ($isStrong) $tag = 'strong'; |
|
164 | + if ($individual && $individual->canShow()) { |
|
165 | 165 | $dindi = new Individual($individual); |
166 | 166 | $html = $individual->getSexImage(); |
167 | 167 | $html .= '<a class="list_item" href="'. |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $html .= '</a>'; |
177 | 177 | } |
178 | 178 | else { |
179 | - $html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>'; |
|
179 | + $html .= '<span class=\"list_item\"><'.$tag.'>'.I18N::translate('Private').'</'.$tag.'></span>'; |
|
180 | 180 | } |
181 | 181 | return $html; |
182 | 182 | } |
@@ -188,22 +188,22 @@ discard block |
||
188 | 188 | * @param boolean $anchor option to print a link to calendar |
189 | 189 | * @return string HTML code for short date |
190 | 190 | */ |
191 | - public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor=false) { |
|
191 | + public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor = false) { |
|
192 | 192 | global $SEARCH_SPIDER; |
193 | 193 | |
194 | - $html=''; |
|
194 | + $html = ''; |
|
195 | 195 | $date = $fact->getDate(); |
196 | - if($date->isOK()){ |
|
197 | - $html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
|
196 | + if ($date->isOK()) { |
|
197 | + $html .= ' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
|
198 | 198 | } |
199 | - else{ |
|
199 | + else { |
|
200 | 200 | // 1 DEAT Y with no DATE => print YES |
201 | 201 | // 1 BIRT 2 SOUR @S1@ => print YES |
202 | 202 | // 1 DEAT N is not allowed |
203 | 203 | // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen. |
204 | 204 | $factdetail = explode(' ', trim($fact->getGedcom())); |
205 | 205 | if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || (count($factdetail) == 4 && $factdetail[2] == 'SOUR')) { |
206 | - $html.=I18N::translate('yes'); |
|
206 | + $html .= I18N::translate('yes'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | return $html; |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | * @param boolean $anchor option to print a link to placelist |
218 | 218 | * @return string HTML code for short place |
219 | 219 | */ |
220 | - public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
|
221 | - $html=''; |
|
220 | + public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false) { |
|
221 | + $html = ''; |
|
222 | 222 | |
223 | 223 | if ($fact === null) return $html; |
224 | 224 | $place = $fact->getPlace(); |
225 | - if($place){ |
|
225 | + if ($place) { |
|
226 | 226 | $dplace = new Place($place); |
227 | 227 | $html .= $dplace->htmlFormattedName($format, $anchor); |
228 | 228 | } |
@@ -240,21 +240,21 @@ discard block |
||
240 | 240 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
241 | 241 | * @return string HTML code for the formatted Sosa numbers |
242 | 242 | */ |
243 | - public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small'){ |
|
243 | + public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small') { |
|
244 | 244 | $html = ''; |
245 | - switch($format){ |
|
245 | + switch ($format) { |
|
246 | 246 | case 1: |
247 | - if(count($sosatab)>0){ |
|
247 | + if (count($sosatab) > 0) { |
|
248 | 248 | $html = '<i class="icon-maj-sosa_'.$size.'" title="'.I18N::translate('Sosa').'"></i>'; |
249 | 249 | } |
250 | 250 | break; |
251 | 251 | case 2: |
252 | - if(count($sosatab)>0){ |
|
252 | + if (count($sosatab) > 0) { |
|
253 | 253 | ksort($sosatab); |
254 | 254 | $tmp_html = array(); |
255 | 255 | foreach ($sosatab as $sosa => $gen) { |
256 | 256 | $tmp_html[] = sprintf( |
257 | - '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen) .'</strong>', |
|
257 | + '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen).'</strong>', |
|
258 | 258 | $size, |
259 | 259 | $sosa |
260 | 260 | ); |
@@ -280,15 +280,15 @@ discard block |
||
280 | 280 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
281 | 281 | * @return string HTML code for IsSourced icon |
282 | 282 | */ |
283 | - public static function formatIsSourcedIcon($sourceType, $isSourced, $tag='EVEN', $format = 1, $size='normal'){ |
|
284 | - $html=''; |
|
285 | - $image=null; |
|
286 | - $title=null; |
|
287 | - switch($format){ |
|
283 | + public static function formatIsSourcedIcon($sourceType, $isSourced, $tag = 'EVEN', $format = 1, $size = 'normal') { |
|
284 | + $html = ''; |
|
285 | + $image = null; |
|
286 | + $title = null; |
|
287 | + switch ($format) { |
|
288 | 288 | case 1: |
289 | - switch($sourceType){ |
|
289 | + switch ($sourceType) { |
|
290 | 290 | case 'E': |
291 | - switch($isSourced){ |
|
291 | + switch ($isSourced) { |
|
292 | 292 | case 0: |
293 | 293 | $image = 'event_unknown'; |
294 | 294 | $title = I18N::translate('%s not found', GedcomTag::getLabel($tag)); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | break; |
320 | 320 | case 'R': |
321 | - switch($isSourced){ |
|
321 | + switch ($isSourced) { |
|
322 | 322 | case -1: |
323 | 323 | $image = 'record_notsourced'; |
324 | 324 | $title = I18N::translate('%s not sourced', GedcomTag::getLabel($tag)); |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | default: |
340 | 340 | break; |
341 | 341 | } |
342 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
342 | + if ($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
343 | 343 | break; |
344 | 344 | default: |
345 | 345 | break; |
@@ -160,7 +160,9 @@ discard block |
||
160 | 160 | public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){ |
161 | 161 | $html = ''; |
162 | 162 | $tag = 'em'; |
163 | - if($isStrong) $tag = 'strong'; |
|
163 | + if($isStrong) { |
|
164 | + $tag = 'strong'; |
|
165 | + } |
|
164 | 166 | if($individual && $individual->canShow()){ |
165 | 167 | $dindi = new Individual($individual); |
166 | 168 | $html = $individual->getSexImage(); |
@@ -174,8 +176,7 @@ discard block |
||
174 | 176 | $html .= ' <span><small><em>'.$dindi->format_first_major_fact(WT_EVENTS_BIRT, 10).'</em></small></span>'; |
175 | 177 | $html .= ' <span><small><em>'.$dindi->format_first_major_fact(WT_EVENTS_DEAT, 10).'</em></small></span>'; |
176 | 178 | $html .= '</a>'; |
177 | - } |
|
178 | - else { |
|
179 | + } else { |
|
179 | 180 | $html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>'; |
180 | 181 | } |
181 | 182 | return $html; |
@@ -195,8 +196,7 @@ discard block |
||
195 | 196 | $date = $fact->getDate(); |
196 | 197 | if($date->isOK()){ |
197 | 198 | $html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y'); |
198 | - } |
|
199 | - else{ |
|
199 | + } else{ |
|
200 | 200 | // 1 DEAT Y with no DATE => print YES |
201 | 201 | // 1 BIRT 2 SOUR @S1@ => print YES |
202 | 202 | // 1 DEAT N is not allowed |
@@ -220,7 +220,9 @@ discard block |
||
220 | 220 | public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
221 | 221 | $html=''; |
222 | 222 | |
223 | - if ($fact === null) return $html; |
|
223 | + if ($fact === null) { |
|
224 | + return $html; |
|
225 | + } |
|
224 | 226 | $place = $fact->getPlace(); |
225 | 227 | if($place){ |
226 | 228 | $dplace = new Place($place); |
@@ -339,7 +341,9 @@ discard block |
||
339 | 341 | default: |
340 | 342 | break; |
341 | 343 | } |
342 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
344 | + if($image && $title) { |
|
345 | + $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
346 | + } |
|
343 | 347 | break; |
344 | 348 | default: |
345 | 349 | break; |
@@ -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); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | class Individual extends GedcomRecord { |
23 | 23 | |
24 | 24 | /** @var array|null List of titles the individal holds */ |
25 | - protected $_titles=null; |
|
25 | + protected $_titles = null; |
|
26 | 26 | |
27 | 27 | /** @var string|null Individual's primary surname, without any privacy applied to it */ |
28 | 28 | protected $_unprotectedPrimarySurname = null; |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * @param null|string $gedcom |
45 | 45 | * @return null|Individual |
46 | 46 | */ |
47 | - public static function getIntance($xref, Tree $tree, $gedcom = null){ |
|
47 | + public static function getIntance($xref, Tree $tree, $gedcom = null) { |
|
48 | 48 | $indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom); |
49 | - if($indi){ |
|
49 | + if ($indi) { |
|
50 | 50 | return new Individual($indi); |
51 | 51 | } |
52 | 52 | return null; |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return array Array of titles |
59 | 59 | */ |
60 | - public function getTitles(){ |
|
61 | - if(is_null($this->_titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)){ |
|
60 | + public function getTitles() { |
|
61 | + if (is_null($this->_titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)) { |
|
62 | 62 | $pattern = '/(.*) (('.$module->getSetting('MAJ_TITLE_PREFIX', '').')(.*))/'; |
63 | - $this->_titles=array(); |
|
63 | + $this->_titles = array(); |
|
64 | 64 | $titlefacts = $this->gedcomrecord->getFacts('TITL'); |
65 | - foreach($titlefacts as $titlefact){ |
|
65 | + foreach ($titlefacts as $titlefact) { |
|
66 | 66 | $ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2); |
67 | - if($ct2>0){ |
|
68 | - $this->_titles[$match2[1][0]][]= trim($match2[2][0]); |
|
67 | + if ($ct2 > 0) { |
|
68 | + $this->_titles[$match2[1][0]][] = trim($match2[2][0]); |
|
69 | 69 | } |
70 | - else{ |
|
71 | - $this->_titles[$titlefact->getValue()][]=''; |
|
70 | + else { |
|
71 | + $this->_titles[$titlefact->getValue()][] = ''; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return string Primary surname |
83 | 83 | */ |
84 | 84 | public function getUnprotectedPrimarySurname() { |
85 | - if(!$this->_unprotectedPrimarySurname){ |
|
86 | - $tmp=$this->gedcomrecord->getAllNames(); |
|
85 | + if (!$this->_unprotectedPrimarySurname) { |
|
86 | + $tmp = $this->gedcomrecord->getAllNames(); |
|
87 | 87 | $this->_unprotectedPrimarySurname = $tmp[$this->gedcomrecord->getPrimaryName()]['surname']; |
88 | 88 | } |
89 | 89 | return $this->_unprotectedPrimarySurname; |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | * @param boolean $perc Should the coefficient of reliability be returned |
96 | 96 | * @return string|array Estimated birth place if found, null otherwise |
97 | 97 | */ |
98 | - public function getEstimatedBirthPlace($perc=false){ |
|
99 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
100 | - if($perc){ |
|
101 | - return array ($bplace, 1); |
|
98 | + public function getEstimatedBirthPlace($perc = false) { |
|
99 | + if ($bplace = $this->gedcomrecord->getBirthPlace()) { |
|
100 | + if ($perc) { |
|
101 | + return array($bplace, 1); |
|
102 | 102 | } |
103 | - else{ |
|
103 | + else { |
|
104 | 104 | return $bplace; |
105 | 105 | } |
106 | 106 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * @param boolean $perc Should the coefficient of reliability be returned |
114 | 114 | * @return string|array Estimated birth place if found, null otherwise |
115 | 115 | */ |
116 | - public function getSignificantPlace(){ |
|
117 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
116 | + public function getSignificantPlace() { |
|
117 | + if ($bplace = $this->gedcomrecord->getBirthPlace()) { |
|
118 | 118 | return $bplace; |
119 | 119 | } |
120 | 120 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
127 | + if ($dplace = $this->gedcomrecord->getDeathPlace()) { |
|
128 | 128 | return $dplace; |
129 | 129 | } |
130 | 130 | |
131 | - foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
131 | + foreach ($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
132 | 132 | foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
133 | 133 | if ($rplace) { |
134 | 134 | return $rplace; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return boolean Is the individual a Sosa ancestor |
146 | 146 | */ |
147 | - public function isSosa(){ |
|
147 | + public function isSosa() { |
|
148 | 148 | return count($this->getSosaNumbers()) > 0; |
149 | 149 | } |
150 | 150 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @uses \MyArtJaub\Webtrees\Functions\ModuleManager |
156 | 156 | * @return array List of Sosa numbers |
157 | 157 | */ |
158 | - public function getSosaNumbers(){ |
|
159 | - if($this->_sosa === null) { |
|
158 | + public function getSosaNumbers() { |
|
159 | + if ($this->_sosa === null) { |
|
160 | 160 | $provider = new SosaProvider($this->gedcomrecord->getTree()); |
161 | 161 | $this->_sosa = $provider->getSosaNumbers($this->gedcomrecord); |
162 | 162 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return int Level of sources |
170 | 170 | * */ |
171 | - public function isBirthSourced(){ |
|
172 | - if($this->_isbirthsourced !== null) return $this->_isbirthsourced; |
|
171 | + public function isBirthSourced() { |
|
172 | + if ($this->_isbirthsourced !== null) return $this->_isbirthsourced; |
|
173 | 173 | $this->_isbirthsourced = $this->isFactSourced(WT_EVENTS_BIRT); |
174 | 174 | return $this->_isbirthsourced; |
175 | 175 | } |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return int Level of sources |
181 | 181 | * */ |
182 | - public function isDeathSourced(){ |
|
183 | - if($this->_isdeathsourced !== null) return $this->_isdeathsourced; |
|
182 | + public function isDeathSourced() { |
|
183 | + if ($this->_isdeathsourced !== null) return $this->_isdeathsourced; |
|
184 | 184 | $this->_isdeathsourced = $this->isFactSourced(WT_EVENTS_DEAT); |
185 | 185 | return $this->_isdeathsourced; |
186 | 186 | } |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | $ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2); |
67 | 67 | if($ct2>0){ |
68 | 68 | $this->_titles[$match2[1][0]][]= trim($match2[2][0]); |
69 | - } |
|
70 | - else{ |
|
69 | + } else{ |
|
71 | 70 | $this->_titles[$titlefact->getValue()][]=''; |
72 | 71 | } |
73 | 72 | } |
@@ -99,8 +98,7 @@ discard block |
||
99 | 98 | if($bplace = $this->gedcomrecord->getBirthPlace()){ |
100 | 99 | if($perc){ |
101 | 100 | return array ($bplace, 1); |
102 | - } |
|
103 | - else{ |
|
101 | + } else{ |
|
104 | 102 | return $bplace; |
105 | 103 | } |
106 | 104 | } |
@@ -169,7 +167,9 @@ discard block |
||
169 | 167 | * @return int Level of sources |
170 | 168 | * */ |
171 | 169 | public function isBirthSourced(){ |
172 | - if($this->_isbirthsourced !== null) return $this->_isbirthsourced; |
|
170 | + if($this->_isbirthsourced !== null) { |
|
171 | + return $this->_isbirthsourced; |
|
172 | + } |
|
173 | 173 | $this->_isbirthsourced = $this->isFactSourced(WT_EVENTS_BIRT); |
174 | 174 | return $this->_isbirthsourced; |
175 | 175 | } |
@@ -180,7 +180,9 @@ discard block |
||
180 | 180 | * @return int Level of sources |
181 | 181 | * */ |
182 | 182 | public function isDeathSourced(){ |
183 | - if($this->_isdeathsourced !== null) return $this->_isdeathsourced; |
|
183 | + if($this->_isdeathsourced !== null) { |
|
184 | + return $this->_isdeathsourced; |
|
185 | + } |
|
184 | 186 | $this->_isdeathsourced = $this->isFactSourced(WT_EVENTS_DEAT); |
185 | 187 | return $this->_isdeathsourced; |
186 | 188 | } |
@@ -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 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param string $file Filename containing the task object |
82 | 82 | * @param TaskProviderInterface $provider Provider for tasks |
83 | 83 | */ |
84 | - public function __construct($file, TaskProviderInterface $provider = null){ |
|
84 | + public function __construct($file, TaskProviderInterface $provider = null) { |
|
85 | 85 | $this->name = trim(basename($file, '.php')); |
86 | 86 | $this->provider = $provider; |
87 | 87 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return TaskProviderInterface |
93 | 93 | */ |
94 | - public function getProvider(){ |
|
94 | + public function getProvider() { |
|
95 | 95 | return $this->provider; |
96 | 96 | } |
97 | 97 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param TaskProviderInterface $provider |
102 | 102 | * @return self Enable method-chaining |
103 | 103 | */ |
104 | - public function setProvider(TaskProviderInterface $provider){ |
|
104 | + public function setProvider(TaskProviderInterface $provider) { |
|
105 | 105 | $this->provider = $provider; |
106 | 106 | return $this; |
107 | 107 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
117 | 117 | * @param bool $is_running Indicates if the task is currently running |
118 | 118 | */ |
119 | - public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
119 | + public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running) { |
|
120 | 120 | $this->is_enabled = $is_enabled; |
121 | 121 | $this->last_updated = $last_updated; |
122 | 122 | $this->last_result = $last_result; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return string |
132 | 132 | */ |
133 | - public function getName(){ |
|
133 | + public function getName() { |
|
134 | 134 | return $this->name; |
135 | 135 | } |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return boolean True if enabled |
142 | 142 | */ |
143 | - public function isEnabled(){ |
|
143 | + public function isEnabled() { |
|
144 | 144 | return $this->is_enabled; |
145 | 145 | } |
146 | 146 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return \DateTime |
151 | 151 | */ |
152 | - public function getLastUpdated(){ |
|
152 | + public function getLastUpdated() { |
|
153 | 153 | return $this->last_updated; |
154 | 154 | } |
155 | 155 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return bool |
160 | 160 | */ |
161 | - public function isLastRunSuccess(){ |
|
161 | + public function isLastRunSuccess() { |
|
162 | 162 | return $this->last_result; |
163 | 163 | } |
164 | 164 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return int |
169 | 169 | */ |
170 | - public function getFrequency(){ |
|
170 | + public function getFrequency() { |
|
171 | 171 | return $this->frequency; |
172 | 172 | } |
173 | 173 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param int $frequency |
178 | 178 | * @return self Enable method-chaining |
179 | 179 | */ |
180 | - public function setFrequency($frequency){ |
|
180 | + public function setFrequency($frequency) { |
|
181 | 181 | $this->frequency = $frequency; |
182 | 182 | return $this; |
183 | 183 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return int |
189 | 189 | */ |
190 | - public function getRemainingOccurrences(){ |
|
190 | + public function getRemainingOccurrences() { |
|
191 | 191 | return $this->nb_occurrences; |
192 | 192 | } |
193 | 193 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param int $nb_occur |
198 | 198 | * @return self Enable method-chaining |
199 | 199 | */ |
200 | - public function setRemainingOccurrences($nb_occur){ |
|
200 | + public function setRemainingOccurrences($nb_occur) { |
|
201 | 201 | $this->nb_occurrences = $nb_occur; |
202 | 202 | return $this; |
203 | 203 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return bool |
209 | 209 | */ |
210 | - public function isRunning(){ |
|
210 | + public function isRunning() { |
|
211 | 211 | return $this->is_running; |
212 | 212 | } |
213 | 213 | |
@@ -236,7 +236,7 @@ discard block |
||
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 | |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * Execute the task, default skeleton |
245 | 245 | * |
246 | 246 | */ |
247 | - public function execute(){ |
|
247 | + public function execute() { |
|
248 | 248 | |
249 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
249 | + if ($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
250 | 250 | $this->is_running = false; |
251 | 251 | |
252 | - if(!$this->is_running){ //TODO put in place a time_out for running... |
|
252 | + if (!$this->is_running) { //TODO put in place a time_out for running... |
|
253 | 253 | //TODO Log the executions in the logs |
254 | 254 | $this->last_result = false; |
255 | 255 | $this->is_running = true; |
@@ -257,11 +257,11 @@ discard block |
||
257 | 257 | |
258 | 258 | Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
259 | 259 | $this->last_result = $this->executeSteps(); |
260 | - if($this->last_result){ |
|
260 | + if ($this->last_result) { |
|
261 | 261 | $this->last_updated = new \DateTime(); |
262 | - if($this->nb_occurrences > 0){ |
|
262 | + if ($this->nb_occurrences > 0) { |
|
263 | 263 | $this->nb_occurrences--; |
264 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
264 | + if ($this->nb_occurrences == 0) $this->is_enabled = false; |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | $this->is_running = false; |
@@ -236,7 +236,9 @@ discard block |
||
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) { |
|
240 | + throw new \Exception('The task has not been initialised with a provider.'); |
|
241 | + } |
|
240 | 242 | return $this->provider->updateTask($this); |
241 | 243 | } |
242 | 244 | |
@@ -246,8 +248,9 @@ discard block |
||
246 | 248 | */ |
247 | 249 | public function execute(){ |
248 | 250 | |
249 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
250 | - $this->is_running = false; |
|
251 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) { |
|
252 | + $this->is_running = false; |
|
253 | + } |
|
251 | 254 | |
252 | 255 | if(!$this->is_running){ //TODO put in place a time_out for running... |
253 | 256 | //TODO Log the executions in the logs |
@@ -261,7 +264,9 @@ discard block |
||
261 | 264 | $this->last_updated = new \DateTime(); |
262 | 265 | if($this->nb_occurrences > 0){ |
263 | 266 | $this->nb_occurrences--; |
264 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
267 | + if($this->nb_occurrences == 0) { |
|
268 | + $this->is_enabled = false; |
|
269 | + } |
|
265 | 270 | } |
266 | 271 | } |
267 | 272 | $this->is_running = false; |
@@ -11,7 +11,6 @@ |
||
11 | 11 | namespace MyArtJaub\Webtrees\Module\GeoDispersion\Model; |
12 | 12 | |
13 | 13 | use Fisharebest\Webtrees\I18N; |
14 | -use Fisharebest\Webtrees\Place; |
|
15 | 14 | use Fisharebest\Webtrees\Tree; |
16 | 15 | use MyArtJaub\Webtrees\Constants; |
17 | 16 | use MyArtJaub\Webtrees\Individual; |
@@ -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. |
@@ -35,7 +35,7 @@ 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 | 40 | /** @var string The "TITL" value from the GEDCOM |
41 | 41 | * This is a tweak to overcome the private level from the parent object... |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | $this->title = basename($this->getFilename(), '.'.$this->extension()); |
95 | 95 | |
96 | 96 | $ct = preg_match("/(?<year>\d{1,4})(\.(?<month>\d{1,2}))?(\.(?<day>\d{1,2}))?( (?<type>[A-Z]{1,2}) )?(?<details>.*)/", $this->title, $match); |
97 | - if($ct > 0){ |
|
98 | - $monthId = (int) $match['month']; |
|
97 | + if ($ct > 0) { |
|
98 | + $monthId = (int)$match['month']; |
|
99 | 99 | $calendarShortMonths = Functions::getCalendarShortMonths(); |
100 | 100 | $monthShortName = array_key_exists($monthId, $calendarShortMonths) ? $calendarShortMonths[$monthId] : $monthId; |
101 | 101 | $this->certDate = new Date($match['day'].' '.strtoupper($monthShortName).' '.$match['year']); |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | * @see \Fisharebest\Webtrees\GedcomRecord::getInstance() |
112 | 112 | */ |
113 | 113 | static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) { |
114 | - try{ |
|
114 | + try { |
|
115 | 115 | $certfile = Functions::decryptFromSafeBase64($xref); |
116 | 116 | |
117 | 117 | //NEED TO CHECK THAT !!! |
118 | - if(Functions::isValidPath($certfile, true)) { |
|
118 | + if (Functions::isValidPath($certfile, true)) { |
|
119 | 119 | return new Certificate($certfile, $tree, $provider); |
120 | 120 | } |
121 | 121 | } |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param string|Source $xref |
154 | 154 | */ |
155 | - public function setSource($xref){ |
|
156 | - if($xref instanceof Source){ |
|
155 | + public function setSource($xref) { |
|
156 | + if ($xref instanceof Source) { |
|
157 | 157 | $this->source = $data; |
158 | 158 | } else { |
159 | 159 | $this->source = Source::getInstance($xref, $this->tree); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return Date Certificate date |
175 | 175 | */ |
176 | - public function getCertificateDate(){ |
|
176 | + public function getCertificateDate() { |
|
177 | 177 | return $this->certDate; |
178 | 178 | } |
179 | 179 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string Certificate date |
184 | 184 | */ |
185 | - public function getCertificateType(){ |
|
185 | + public function getCertificateType() { |
|
186 | 186 | return $this->certType; |
187 | 187 | } |
188 | 188 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string Certificate details |
193 | 193 | */ |
194 | - public function getCertificateDetails(){ |
|
194 | + public function getCertificateDetails() { |
|
195 | 195 | return $this->certDetails; |
196 | 196 | } |
197 | 197 | |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string|NULL Certificate city |
202 | 202 | */ |
203 | - public function getCity(){ |
|
203 | + public function getCity() { |
|
204 | 204 | $chunks = explode('/', $this->getFilename(), 2); |
205 | - if(count($chunks) > 1) return $chunks[0]; |
|
205 | + if (count($chunks) > 1) return $chunks[0]; |
|
206 | 206 | return null; |
207 | 207 | } |
208 | 208 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * {@inhericDoc} |
211 | 211 | * @see \Fisharebest\Webtrees\Media::getServerFilename() |
212 | 212 | */ |
213 | - public function getServerFilename($which='main') { |
|
214 | - $filename = $this->provider->getRealCertificatesDirectory() . $this->getFilename(); |
|
213 | + public function getServerFilename($which = 'main') { |
|
214 | + $filename = $this->provider->getRealCertificatesDirectory().$this->getFilename(); |
|
215 | 215 | return Functions::encodeUtf8ToFileSystem($filename); |
216 | 216 | } |
217 | 217 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | public function getHtmlUrlDirect($which = 'main', $download = false) { |
223 | 223 | $sidstr = ($this->source) ? '&sid='.$this->source->getXref() : ''; |
224 | 224 | return |
225 | - 'module.php?mod='. \MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME . |
|
226 | - '&mod_action=Certificate@image' . |
|
227 | - '&ged='. $this->tree->getNameUrl() . |
|
228 | - '&cid=' . $this->getXref() . $sidstr . |
|
229 | - '&cb=' . $this->getEtag($which); |
|
225 | + 'module.php?mod='.\MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME. |
|
226 | + '&mod_action=Certificate@image'. |
|
227 | + '&ged='.$this->tree->getNameUrl(). |
|
228 | + '&cid='.$this->getXref().$sidstr. |
|
229 | + '&cb='.$this->getEtag($which); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,26 +237,26 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string Watermark text |
239 | 239 | */ |
240 | - public function getWatermarkText(){ |
|
240 | + public function getWatermarkText() { |
|
241 | 241 | $module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME); |
242 | 242 | |
243 | - if($module) { |
|
243 | + if ($module) { |
|
244 | 244 | $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
245 | - $sid= Filter::get('sid', WT_REGEX_XREF); |
|
245 | + $sid = Filter::get('sid', WT_REGEX_XREF); |
|
246 | 246 | |
247 | - if($sid){ |
|
247 | + if ($sid) { |
|
248 | 248 | $this->source = Source::getInstance($sid, $this->tree); |
249 | 249 | } |
250 | - else{ |
|
251 | - $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
250 | + else { |
|
251 | + $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
252 | 252 | } |
253 | 253 | |
254 | - if($this->source) { |
|
254 | + if ($this->source) { |
|
255 | 255 | $wmtext = '©'; |
256 | 256 | $repofact = $this->source->getFirstFact('REPO'); |
257 | - if($repofact) { |
|
257 | + if ($repofact) { |
|
258 | 258 | $repo = $repofact->getTarget(); |
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
259 | + if ($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
260 | 260 | } |
261 | 261 | $wmtext .= $this->source->getFullName(); |
262 | 262 | } |
@@ -279,45 +279,45 @@ discard block |
||
279 | 279 | '; |
280 | 280 | |
281 | 281 | $script = ''; |
282 | - if($controller && !($controller instanceof IndividualController)){ |
|
282 | + if ($controller && !($controller instanceof IndividualController)) { |
|
283 | 283 | $controller->addInlineJavascript('$(document).ready(function() { '.$js.' });'); |
284 | 284 | } else { |
285 | - $script = '<script>' . $js . '</script>'; |
|
285 | + $script = '<script>'.$js.'</script>'; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | if ($which == 'icon' || !file_exists($this->getServerFilename())) { |
289 | 289 | // Use an icon |
290 | 290 | $image = |
291 | - '<i dir="auto" class="icon-maj-certificate margin-h-2"' . |
|
292 | - ' title="' . strip_tags($this->getFullName()) . '"' . |
|
291 | + '<i dir="auto" class="icon-maj-certificate margin-h-2"'. |
|
292 | + ' title="'.strip_tags($this->getFullName()).'"'. |
|
293 | 293 | '></i>'; |
294 | 294 | } else { |
295 | 295 | $imgsize = getimagesize($this->getServerFilename()); |
296 | 296 | $image = |
297 | - '<img' . |
|
298 | - ' class ="'. 'certif_image' . '"' . |
|
299 | - ' dir="' . 'auto' . '"' . // For the tool-tip |
|
300 | - ' src="' . $this->getHtmlUrlDirect() . '"' . |
|
301 | - ' alt="' . strip_tags($this->getFullName()) . '"' . |
|
302 | - ' title="' . strip_tags($this->getFullName()) . '"' . |
|
303 | - $imgsize[3] . // height="yyy" width="xxx" |
|
297 | + '<img'. |
|
298 | + ' class ="'.'certif_image'.'"'. |
|
299 | + ' dir="'.'auto'.'"'.// For the tool-tip |
|
300 | + ' src="'.$this->getHtmlUrlDirect().'"'. |
|
301 | + ' alt="'.strip_tags($this->getFullName()).'"'. |
|
302 | + ' title="'.strip_tags($this->getFullName()).'"'. |
|
303 | + $imgsize[3].// height="yyy" width="xxx" |
|
304 | 304 | '>'; |
305 | 305 | } |
306 | 306 | return |
307 | - '<a' . |
|
308 | - ' class="' . 'certgallery' . '"' . |
|
309 | - ' href="' . $this->getHtmlUrlDirect() . '"' . |
|
310 | - ' type="' . $this->mimeType() . '"' . |
|
311 | - ' data-obje-url="' . $this->getHtmlUrl() . '"' . |
|
312 | - ' data-title="' . strip_tags($this->getFullName()) . '"' . |
|
313 | - '>' . $image . '</a>'.$script; |
|
307 | + '<a'. |
|
308 | + ' class="'.'certgallery'.'"'. |
|
309 | + ' href="'.$this->getHtmlUrlDirect().'"'. |
|
310 | + ' type="'.$this->mimeType().'"'. |
|
311 | + ' data-obje-url="'.$this->getHtmlUrl().'"'. |
|
312 | + ' data-title="'.strip_tags($this->getFullName()).'"'. |
|
313 | + '>'.$image.'</a>'.$script; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * {@inhericDoc} |
318 | 318 | * @see \Fisharebest\Webtrees\GedcomRecord::linkedIndividuals() |
319 | 319 | */ |
320 | - public function linkedIndividuals($link = '_ACT'){ |
|
320 | + public function linkedIndividuals($link = '_ACT') { |
|
321 | 321 | $rows = Database::prepare( |
322 | 322 | 'SELECT i_id AS xref, i_gedcom AS gedcom'. |
323 | 323 | ' FROM `##individuals`'. |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * {@inhericDoc} |
342 | 342 | * @see \Fisharebest\Webtrees\GedcomRecord::linkedFamilies() |
343 | 343 | */ |
344 | - public function linkedFamilies($link = '_ACT'){ |
|
344 | + public function linkedFamilies($link = '_ACT') { |
|
345 | 345 | $rows = Database::prepare( |
346 | 346 | 'SELECT f_id AS xref, f_gedcom AS gedcom'. |
347 | 347 | ' FROM `##families`'. |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return Source|NULL Linked source |
368 | 368 | */ |
369 | - public function fetchALinkedSource(){ |
|
369 | + public function fetchALinkedSource() { |
|
370 | 370 | $sid = null; |
371 | 371 | |
372 | 372 | // Try to find in individual, then families, then other types of records. We are interested in the first available value. |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'gedcom_id' => $this->tree->getTreeId(), |
379 | 379 | 'gedcom' => '%_ACT '.$this->getFilename().'%' |
380 | 380 | ))->fetchOne(); |
381 | - if(!$ged){ |
|
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') |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | 'gedcom_id' => $this->tree->getTreeId(), |
387 | 387 | 'gedcom' => '%_ACT '.$this->getFilename().'%' |
388 | 388 | ))->fetchOne(); |
389 | - if(!$ged){ |
|
389 | + if (!$ged) { |
|
390 | 390 | $ged = Database::prepare( |
391 | 391 | 'SELECT o_gedcom AS gedrec FROM `##other`'. |
392 | 392 | ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
@@ -397,28 +397,28 @@ discard block |
||
397 | 397 | } |
398 | 398 | } |
399 | 399 | //If a record has been found, parse it to find the source reference. |
400 | - if($ged){ |
|
400 | + if ($ged) { |
|
401 | 401 | $gedlines = explode("\n", $ged); |
402 | 402 | $level = 0; |
403 | 403 | $levelsource = -1; |
404 | - $sid_tmp=null; |
|
404 | + $sid_tmp = null; |
|
405 | 405 | $sourcefound = false; |
406 | - foreach($gedlines as $gedline){ |
|
406 | + foreach ($gedlines as $gedline) { |
|
407 | 407 | // Get the level |
408 | 408 | if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) { |
409 | 409 | $level = $match[1]; |
410 | 410 | //If we are not any more within the context of a source, reset |
411 | - if($level <= $levelsource){ |
|
411 | + if ($level <= $levelsource) { |
|
412 | 412 | $levelsource = -1; |
413 | 413 | $sid_tmp = null; |
414 | 414 | } |
415 | 415 | // If a source, get the level and the reference |
416 | 416 | if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) { |
417 | 417 | $levelsource = $level; |
418 | - $sid_tmp=$match2[1]; |
|
418 | + $sid_tmp = $match2[1]; |
|
419 | 419 | } |
420 | 420 | // If the image has be found, get the source reference and exit. |
421 | - if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){ |
|
421 | + if ($levelsource >= 0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)) { |
|
422 | 422 | $sid = $sid_tmp; |
423 | 423 | $sourcefound = true; |
424 | 424 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
429 | - if($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
429 | + if ($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
430 | 430 | |
431 | 431 | return $this->source; |
432 | 432 | } |
@@ -118,8 +118,7 @@ discard block |
||
118 | 118 | if(Functions::isValidPath($certfile, true)) { |
119 | 119 | return new Certificate($certfile, $tree, $provider); |
120 | 120 | } |
121 | - } |
|
122 | - catch (\Exception $ex) { |
|
121 | + } catch (\Exception $ex) { |
|
123 | 122 | Log::addErrorLog('Certificate module error : > '.$ex->getMessage().' < with data > '.$xref.' <'); |
124 | 123 | } |
125 | 124 | |
@@ -202,7 +201,9 @@ discard block |
||
202 | 201 | */ |
203 | 202 | public function getCity(){ |
204 | 203 | $chunks = explode('/', $this->getFilename(), 2); |
205 | - if(count($chunks) > 1) return $chunks[0]; |
|
204 | + if(count($chunks) > 1) { |
|
205 | + return $chunks[0]; |
|
206 | + } |
|
206 | 207 | return null; |
207 | 208 | } |
208 | 209 | |
@@ -246,8 +247,7 @@ discard block |
||
246 | 247 | |
247 | 248 | if($sid){ |
248 | 249 | $this->source = Source::getInstance($sid, $this->tree); |
249 | - } |
|
250 | - else{ |
|
250 | + } else{ |
|
251 | 251 | $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
252 | 252 | } |
253 | 253 | |
@@ -256,7 +256,9 @@ discard block |
||
256 | 256 | $repofact = $this->source->getFirstFact('REPO'); |
257 | 257 | if($repofact) { |
258 | 258 | $repo = $repofact->getTarget(); |
259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
259 | + if($repo && $repo instanceof Repository) { |
|
260 | + $wmtext .= ' '.$repo->getFullName().' - '; |
|
261 | + } |
|
260 | 262 | } |
261 | 263 | $wmtext .= $this->source->getFullName(); |
262 | 264 | } |
@@ -426,7 +428,9 @@ discard block |
||
426 | 428 | } |
427 | 429 | } |
428 | 430 | |
429 | - if($sid) $this->source = Source::getInstance($sid, $this->tree); |
|
431 | + if($sid) { |
|
432 | + $this->source = Source::getInstance($sid, $this->tree); |
|
433 | + } |
|
430 | 434 | |
431 | 435 | return $this->source; |
432 | 436 | } |
@@ -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){ |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | $sid=null; |
106 | 106 | |
107 | 107 | if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
108 | - if (!$srec || strlen($srec) == 0) return $html; |
|
108 | + if (!$srec || strlen($srec) == 0) { |
|
109 | + return $html; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | $certificate = null; |
111 | 113 | $subrecords = explode("\n", $srec); |
@@ -118,11 +120,14 @@ discard block |
||
118 | 120 | $level = substr($subrecords[$i], 0, 1); |
119 | 121 | $tag = substr($subrecords[$i], 2, 4); |
120 | 122 | $text = substr($subrecords[$i], 7); |
121 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
123 | + if($tag == '_ACT') { |
|
124 | + $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
125 | + } |
|
122 | 126 | } |
123 | 127 | |
124 | - if($certificate && $certificate->canShow()) |
|
125 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
128 | + if($certificate && $certificate->canShow()) { |
|
129 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
130 | + } |
|
126 | 131 | |
127 | 132 | } |
128 | 133 | return $html; |
@@ -150,7 +155,9 @@ discard block |
||
150 | 155 | $html = ''; |
151 | 156 | switch($tag){ |
152 | 157 | case '_ACT': |
153 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
158 | + if($context == 'SOUR') { |
|
159 | + $html = $this->getDisplay_ACT($value, $contextid); |
|
160 | + } |
|
154 | 161 | break; |
155 | 162 | } |
156 | 163 | return $html; |
@@ -180,7 +187,9 @@ discard block |
||
180 | 187 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
181 | 188 | foreach ($tabCities as $cities){ |
182 | 189 | $selectedCity=''; |
183 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
190 | + if($certificate && $cities== $certificate->getCity()) { |
|
191 | + $selectedCity='selected="true"'; |
|
192 | + } |
|
184 | 193 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
185 | 194 | } |
186 | 195 | $html .= '</select>'; |
@@ -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 |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
68 | 68 | */ |
69 | 69 | public function getConfigLink() { |
70 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
70 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getMenu(Tree $tree, $reference = null) { |
94 | 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')); |
|
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 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,27 +102,27 @@ discard block |
||
102 | 102 | public function hFactSourcePrepend($srec) { |
103 | 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)){ |
|
108 | + if ($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)) { |
|
109 | 109 | if (!$srec || strlen($srec) == 0) return $html; |
110 | 110 | |
111 | 111 | $certificate = null; |
112 | 112 | $subrecords = explode("\n", $srec); |
113 | 113 | $levelSOUR = substr($subrecords[0], 0, 1); |
114 | 114 | if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
115 | - $sid=$match[1]; |
|
115 | + $sid = $match[1]; |
|
116 | 116 | }; |
117 | 117 | $nb_subrecords = count($subrecords); |
118 | - for ($i=0; $i < $nb_subrecords; $i++) { |
|
118 | + for ($i = 0; $i < $nb_subrecords; $i++) { |
|
119 | 119 | $subrecords[$i] = trim($subrecords[$i]); |
120 | 120 | $tag = substr($subrecords[$i], 2, 4); |
121 | 121 | $text = substr($subrecords[$i], 7); |
122 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
122 | + if ($tag == '_ACT') $certificate = new Certificate($text, $WT_TREE, $this->getProvider()); |
|
123 | 123 | } |
124 | 124 | |
125 | - if($certificate && $certificate->canShow()) |
|
125 | + if ($certificate && $certificate->canShow()) |
|
126 | 126 | $html = $this->getDisplay_ACT($certificate, $sid); |
127 | 127 | |
128 | 128 | } |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
151 | 151 | $html = ''; |
152 | - switch($tag){ |
|
152 | + switch ($tag) { |
|
153 | 153 | case '_ACT': |
154 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
154 | + if ($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
155 | 155 | break; |
156 | 156 | } |
157 | 157 | return $html; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $html = ''; |
168 | 168 | |
169 | - switch($tag){ |
|
169 | + switch ($tag) { |
|
170 | 170 | case '_ACT': |
171 | 171 | $element_id = Uuid::uuid4(); |
172 | 172 | $controller |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/autocomplete.js') |
175 | 175 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/updatecertificatevalues.js'); |
176 | 176 | $certificate = null; |
177 | - if($value){ |
|
177 | + if ($value) { |
|
178 | 178 | $certificate = new Certificate($value, $WT_TREE, $this->getProvider()); |
179 | 179 | } |
180 | 180 | $tabCities = $this->getProvider()->getCitiesList(); |
181 | 181 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
182 | - foreach ($tabCities as $cities){ |
|
183 | - $selectedCity=''; |
|
184 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
182 | + foreach ($tabCities as $cities) { |
|
183 | + $selectedCity = ''; |
|
184 | + if ($certificate && $cities == $certificate->getCity()) $selectedCity = 'selected="true"'; |
|
185 | 185 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
186 | 186 | } |
187 | 187 | $html .= '</select>'; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
200 | 200 | */ |
201 | 201 | public function hAddSimpleTag($context, $level) { |
202 | - switch($context){ |
|
202 | + switch ($context) { |
|
203 | 203 | case 'SOUR': |
204 | 204 | FunctionsEdit::addSimpleTag($level.' _ACT'); |
205 | 205 | break; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
212 | 212 | */ |
213 | 213 | public function hHasHelpTextTag($tag) { |
214 | - switch($tag){ |
|
214 | + switch ($tag) { |
|
215 | 215 | case '_ACT': |
216 | 216 | return true; |
217 | 217 | break; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
225 | 225 | */ |
226 | 226 | public function hGetHelpTextTag($tag) { |
227 | - switch($tag){ |
|
227 | + switch ($tag) { |
|
228 | 228 | case '_ACT': |
229 | 229 | return array( |
230 | 230 | I18N::translate('Certificate'), |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | public function getProvider() { |
243 | 243 | global $WT_TREE; |
244 | 244 | |
245 | - if(!$this->provider) { |
|
245 | + if (!$this->provider) { |
|
246 | 246 | $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
247 | 247 | $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
248 | 248 | } |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
257 | 257 | * @param string|null $sid Linked Source ID, if it exists |
258 | 258 | */ |
259 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
259 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null) { |
|
260 | 260 | $html = ''; |
261 | - if($certificate){ |
|
261 | + if ($certificate) { |
|
262 | 262 | $certificate->setSource($sid); |
263 | 263 | $html = $certificate->displayImage('icon'); |
264 | 264 | } |