Completed
Push — feature/code-analysis ( 5519b1...bdc52b )
by Jonathan
02:58
created
src/Webtrees/Module/CertificatesModule.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -30,151 +30,151 @@  discard block
 block discarded – undo
30 30
  * Certificates Module.
31 31
  */
32 32
 class CertificatesModule 
33
-    extends AbstractModule 
34
-    implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface, DependentInterface
33
+	extends AbstractModule 
34
+	implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface, DependentInterface
35 35
 {
36
-    /** @var string For custom modules - link for support, upgrades, etc. */
37
-    const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
36
+	/** @var string For custom modules - link for support, upgrades, etc. */
37
+	const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
38 38
         
39
-    /**
40
-     * Provider for Certificates
41
-     * @var CertificateProviderInterface $provider
42
-     */
43
-    protected $provider;
39
+	/**
40
+	 * Provider for Certificates
41
+	 * @var CertificateProviderInterface $provider
42
+	 */
43
+	protected $provider;
44 44
     
45
-    /**
46
-     * {@inhericDoc}
47
-     */
48
-    public function getTitle() {
49
-        return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates');
50
-    }
45
+	/**
46
+	 * {@inhericDoc}
47
+	 */
48
+	public function getTitle() {
49
+		return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates');
50
+	}
51 51
     
52
-    /**
53
-     * {@inhericDoc}
54
-     */
55
-    public function getDescription() {
56
-        return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.');
57
-    }
52
+	/**
53
+	 * {@inhericDoc}
54
+	 */
55
+	public function getDescription() {
56
+		return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.');
57
+	}
58 58
     
59
-    /**
60
-     * {@inhericDoc}
61
-     */
62
-    public function modAction($mod_action) {
63
-        \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
64
-    }
59
+	/**
60
+	 * {@inhericDoc}
61
+	 */
62
+	public function modAction($mod_action) {
63
+		\MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
64
+	}
65 65
 
66
-    /**
67
-     * {@inheritDoc}
68
-     * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
69
-     */
70
-    public function validatePrerequisites() {
71
-        return Functions::isEncryptionCompatible();    
72
-    }
66
+	/**
67
+	 * {@inheritDoc}
68
+	 * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
69
+	 */
70
+	public function validatePrerequisites() {
71
+		return Functions::isEncryptionCompatible();    
72
+	}
73 73
     
74
-    /**
75
-     * {@inhericDoc}
76
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
77
-     */
78
-    public function getConfigLink() {
79
-        return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig';
80
-    }
74
+	/**
75
+	 * {@inhericDoc}
76
+	 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
77
+	 */
78
+	public function getConfigLink() {
79
+		return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig';
80
+	}
81 81
     
82
-    /**
83
-     * {@inhericDoc}
84
-     * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks()
85
-     */
86
-    public function getSubscribedHooks() {
87
-        return array(
88
-            'hFactSourcePrepend' => 50,
89
-            'hGetExpectedTags' => 50,
90
-            'hHtmlSimpleTagDisplay#_ACT' => 50,
91
-            'hHtmlSimpleTagEditor#_ACT'	=> 50,
92
-            'hAddSimpleTag#SOUR'	=> 50,
93
-            'hHasHelpTextTag#_ACT'	=> 50,
94
-            'hGetHelpTextTag#_ACT'	=> 50
95
-        );
96
-    }
82
+	/**
83
+	 * {@inhericDoc}
84
+	 * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks()
85
+	 */
86
+	public function getSubscribedHooks() {
87
+		return array(
88
+			'hFactSourcePrepend' => 50,
89
+			'hGetExpectedTags' => 50,
90
+			'hHtmlSimpleTagDisplay#_ACT' => 50,
91
+			'hHtmlSimpleTagEditor#_ACT'	=> 50,
92
+			'hAddSimpleTag#SOUR'	=> 50,
93
+			'hHasHelpTextTag#_ACT'	=> 50,
94
+			'hGetHelpTextTag#_ACT'	=> 50
95
+		);
96
+	}
97 97
     
98
-    /**
99
-     * {@inhericDoc}
100
-     * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu()
101
-     */
102
-    public function getMenu(Tree $tree, $reference = null) {
103
-        $tree_url = $tree ? $tree->getNameUrl() : '';
104
-        return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
105
-    }
98
+	/**
99
+	 * {@inhericDoc}
100
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu()
101
+	 */
102
+	public function getMenu(Tree $tree, $reference = null) {
103
+		$tree_url = $tree ? $tree->getNameUrl() : '';
104
+		return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
105
+	}
106 106
     
107
-    /**
108
-     * {@inhericDoc}
109
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend()
110
-     */
111
-    public function hFactSourcePrepend($srec) {
112
-        global $WT_TREE;
107
+	/**
108
+	 * {@inhericDoc}
109
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend()
110
+	 */
111
+	public function hFactSourcePrepend($srec) {
112
+		global $WT_TREE;
113 113
         
114
-        $html='';
115
-        $sid=null;
114
+		$html='';
115
+		$sid=null;
116 116
         
117
-        if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){
118
-            if (!$srec || strlen($srec) == 0) return $html;
117
+		if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){
118
+			if (!$srec || strlen($srec) == 0) return $html;
119 119
             	
120
-            $certificate = null;
121
-            $subrecords = explode("\n", $srec);
122
-            $levelSOUR = substr($subrecords[0], 0, 1);
123
-            $match = null;
124
-            if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) {
125
-                $sid=$match[1];
126
-            };
127
-            $nb_subrecords = count($subrecords);
128
-            for ($i=0; $i < $nb_subrecords; $i++) {
129
-                $subrecords[$i] = trim($subrecords[$i]);
130
-                $tag = substr($subrecords[$i], 2, 4);
131
-                $text = substr($subrecords[$i], 7);
132
-                if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider());
133
-            }
120
+			$certificate = null;
121
+			$subrecords = explode("\n", $srec);
122
+			$levelSOUR = substr($subrecords[0], 0, 1);
123
+			$match = null;
124
+			if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) {
125
+				$sid=$match[1];
126
+			};
127
+			$nb_subrecords = count($subrecords);
128
+			for ($i=0; $i < $nb_subrecords; $i++) {
129
+				$subrecords[$i] = trim($subrecords[$i]);
130
+				$tag = substr($subrecords[$i], 2, 4);
131
+				$text = substr($subrecords[$i], 7);
132
+				if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider());
133
+			}
134 134
             	
135
-            if($certificate && $certificate->canShow())
136
-                $html = $this->getDisplay_ACT($certificate, $sid);
135
+			if($certificate && $certificate->canShow())
136
+				$html = $this->getDisplay_ACT($certificate, $sid);
137 137
                 	
138
-        }
139
-        return $html;
140
-    }
138
+		}
139
+		return $html;
140
+	}
141 141
    
142
-    /**
143
-     * {@inhericDoc}
144
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend()
145
-     */
146
-    public function hFactSourceAppend($srec) { }
142
+	/**
143
+	 * {@inhericDoc}
144
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend()
145
+	 */
146
+	public function hFactSourceAppend($srec) { }
147 147
     
148
-    /**
149
-     * {@inhericDoc}
150
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags()
151
-     */
152
-    public function hGetExpectedTags() {
153
-        return array('SOUR' => '_ACT');
154
-    }
148
+	/**
149
+	 * {@inhericDoc}
150
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags()
151
+	 */
152
+	public function hGetExpectedTags() {
153
+		return array('SOUR' => '_ACT');
154
+	}
155 155
     
156
-    /**
157
-     * {@inhericDoc}
158
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay()
159
-     */
160
-    public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) {
161
-        $html = '';
162
-        switch($tag){
163
-            case '_ACT':
164
-                if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
165
-                break;
166
-        }
167
-        return $html;
168
-    }
156
+	/**
157
+	 * {@inhericDoc}
158
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay()
159
+	 */
160
+	public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) {
161
+		$html = '';
162
+		switch($tag){
163
+			case '_ACT':
164
+				if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
165
+				break;
166
+		}
167
+		return $html;
168
+	}
169 169
     
170
-    /**
171
-     * {@inhericDoc}
172
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor()
173
-     */
174
-    public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) {
175
-        global $controller, $WT_TREE;
170
+	/**
171
+	 * {@inhericDoc}
172
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor()
173
+	 */
174
+	public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) {
175
+		global $controller, $WT_TREE;
176 176
         
177
-        $html = '';
177
+		$html = '';
178 178
 		
179 179
 		switch($tag){
180 180
 			case '_ACT':
@@ -202,77 +202,77 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 		
204 204
 		return $html;
205
-    }
205
+	}
206 206
     
207
-    /**
208
-     * {@inhericDoc}
209
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag()
210
-     */
211
-    public function hAddSimpleTag($context, $level) {
212
-        switch($context){
213
-            case 'SOUR':
214
-                FunctionsEdit::addSimpleTag($level.' _ACT');
215
-                break;
216
-        }
217
-    }
207
+	/**
208
+	 * {@inhericDoc}
209
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag()
210
+	 */
211
+	public function hAddSimpleTag($context, $level) {
212
+		switch($context){
213
+			case 'SOUR':
214
+				FunctionsEdit::addSimpleTag($level.' _ACT');
215
+				break;
216
+		}
217
+	}
218 218
     
219
-    /**
220
-     * {@inhericDoc}
221
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag()
222
-     */
223
-    public function hHasHelpTextTag($tag) {
224
-        switch($tag){
219
+	/**
220
+	 * {@inhericDoc}
221
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag()
222
+	 */
223
+	public function hHasHelpTextTag($tag) {
224
+		switch($tag){
225 225
 			case '_ACT':
226 226
 				return true;
227 227
 		}
228 228
 		return false;
229
-    }
229
+	}
230 230
     
231
-    /**
232
-     * {@inhericDoc}
233
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag()
234
-     */
235
-    public function hGetHelpTextTag($tag) {
236
-        switch($tag){
237
-            case '_ACT':
238
-                return array(
239
-                I18N::translate('Certificate'),
240
-                '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>');
241
-            default:
242
-                return null;
243
-        }
244
-    }
231
+	/**
232
+	 * {@inhericDoc}
233
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag()
234
+	 */
235
+	public function hGetHelpTextTag($tag) {
236
+		switch($tag){
237
+			case '_ACT':
238
+				return array(
239
+				I18N::translate('Certificate'),
240
+				'<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>');
241
+			default:
242
+				return null;
243
+		}
244
+	}
245 245
 
246
-    /**
247
-     * Returns the default Certificate File Provider, as configured in the module
248
-     *
249
-     * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface
250
-     */
251
-    public function getProvider() {
252
-        global $WT_TREE;
246
+	/**
247
+	 * Returns the default Certificate File Provider, as configured in the module
248
+	 *
249
+	 * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface
250
+	 */
251
+	public function getProvider() {
252
+		global $WT_TREE;
253 253
     
254
-        if(!$this->provider) {
255
-            $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/');
256
-            $this->provider = new CertificateFileProvider($root_path, $WT_TREE);
257
-        }
258
-        return $this->provider;
259
-    }
254
+		if(!$this->provider) {
255
+			$root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/');
256
+			$this->provider = new CertificateFileProvider($root_path, $WT_TREE);
257
+		}
258
+		return $this->provider;
259
+	}
260 260
     
261 261
     
262
-    /**
263
-     * Return the HTML code for custom simple tag _ACT
264
-     *
265
-     * @param Certificate $certificatePath Certificate (as per the GEDCOM)
266
-     * @param string|null $sid Linked Source ID, if it exists
267
-     */
268
-    protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
269
-        $html = '';
270
-        if($certificate){
271
-            $certificate->setSource($sid);
272
-            $html = $certificate->displayImage('icon');
273
-        }
274
-        return $html;
275
-    }
262
+	/**
263
+	 * Return the HTML code for custom simple tag _ACT
264
+	 *
265
+	 * @param Certificate $certificatePath Certificate (as per the GEDCOM)
266
+	 * @param string|null $sid Linked Source ID, if it exists
267
+	 */
268
+	protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
269
+		$html = '';
270
+		if($certificate){
271
+			$certificate->setSource($sid);
272
+			$html = $certificate->displayImage('icon');
273
+		}
274
+		return $html;
275
+	}
276 276
 
277 277
 
278 278
 }
Please login to merge, or discard this patch.
src/Webtrees/Functions/Functions.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return boolean
136 136
 	 */
137 137
 	public static function isEncryptionCompatible() {
138
-	    return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt');
138
+		return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt');
139 139
 	}
140 140
 	
141 141
 	/**	  
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @return string Encrypted and encoded text
147 147
 	 */
148 148
 	public static function encryptToSafeBase64($data){
149
-	    if(!self::isEncryptionCompatible())
150
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
149
+		if(!self::isEncryptionCompatible())
150
+			throw new \Exception('MCrypt PHP extension is required to use encryption.');
151 151
 	    
152 152
 		$key = 'STANDARDKEYIFNOSERVER';
153 153
 		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 * @return string Decrypted text
170 170
 	 */
171 171
 	public static function decryptFromSafeBase64($encrypted){
172
-	    if(!self::isEncryptionCompatible())
173
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
172
+		if(!self::isEncryptionCompatible())
173
+			throw new \Exception('MCrypt PHP extension is required to use encryption.');
174 174
 	    
175 175
 		$key = 'STANDARDKEYIFNOSERVER';
176 176
 		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public static function encodeFileSystemToUtf8($string){
199 199
 		if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') {
200
-		    return iconv('cp1252', 'utf-8//IGNORE',$string);
200
+			return iconv('cp1252', 'utf-8//IGNORE',$string);
201 201
 		}
202 202
 		return $string;
203 203
 	}
@@ -262,20 +262,20 @@  discard block
 block discarded – undo
262 262
 	 * @return boolean|string Is supported?
263 263
 	 */
264 264
 	public static function isImageTypeSupported($reqtype) {
265
-	    $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
266
-	    $reqtype = strtolower($reqtype);
265
+		$supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
266
+		$reqtype = strtolower($reqtype);
267 267
 	
268
-	    if (empty($supportByGD[$reqtype])) {
269
-	        return false;
270
-	    }
268
+		if (empty($supportByGD[$reqtype])) {
269
+			return false;
270
+		}
271 271
 	
272
-	    $type = $supportByGD[$reqtype];
272
+		$type = $supportByGD[$reqtype];
273 273
 	
274
-	    if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) {
275
-	        return $type;
276
-	    }
274
+		if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) {
275
+			return $type;
276
+		}
277 277
 	
278
-	    return false;
278
+		return false;
279 279
 	}
280 280
 		
281 281
 }
Please login to merge, or discard this patch.