Completed
Push — master ( 3603f5...72e2c3 )
by Jonathan
02:00
created
src/Webtrees/Module/CertificatesModule.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -31,140 +31,140 @@  discard block
 block discarded – undo
31 31
  * Certificates Module.
32 32
  */
33 33
 class CertificatesModule 
34
-    extends AbstractModule 
35
-    implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface
34
+	extends AbstractModule 
35
+	implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface
36 36
 {
37
-    /** @var string For custom modules - link for support, upgrades, etc. */
38
-    const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
37
+	/** @var string For custom modules - link for support, upgrades, etc. */
38
+	const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
39 39
         
40
-    /**
41
-     * Provider for Certificates
42
-     * @var CertificateProviderInterface $provider
43
-     */
44
-    protected $provider;
40
+	/**
41
+	 * Provider for Certificates
42
+	 * @var CertificateProviderInterface $provider
43
+	 */
44
+	protected $provider;
45 45
     
46
-    /**
47
-     * {@inhericDoc}
48
-     */
49
-    public function getTitle() {
50
-        return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates');
51
-    }
46
+	/**
47
+	 * {@inhericDoc}
48
+	 */
49
+	public function getTitle() {
50
+		return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates');
51
+	}
52 52
     
53
-    /**
54
-     * {@inhericDoc}
55
-     */
56
-    public function getDescription() {
57
-        return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.');
58
-    }
53
+	/**
54
+	 * {@inhericDoc}
55
+	 */
56
+	public function getDescription() {
57
+		return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.');
58
+	}
59 59
     
60
-    /**
61
-     * {@inhericDoc}
62
-     */
63
-    public function modAction($mod_action) {
64
-        \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
65
-    }
60
+	/**
61
+	 * {@inhericDoc}
62
+	 */
63
+	public function modAction($mod_action) {
64
+		\MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
65
+	}
66 66
     
67
-    /**
68
-     * {@inhericDoc}
69
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
70
-     */
71
-    public function getConfigLink() {
72
-        return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig';
73
-    }
67
+	/**
68
+	 * {@inhericDoc}
69
+	 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
70
+	 */
71
+	public function getConfigLink() {
72
+		return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig';
73
+	}
74 74
     
75
-    /**
76
-     * {@inhericDoc}
77
-     * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks()
78
-     */
79
-    public function getSubscribedHooks() {
80
-        return array(
81
-            'hFactSourcePrepend' => 50,
82
-            'hGetExpectedTags' => 50,
83
-            'hHtmlSimpleTagDisplay#_ACT' => 50,
84
-            'hHtmlSimpleTagEditor#_ACT'	=> 50,
85
-            'hAddSimpleTag#SOUR'	=> 50,
86
-            'hHasHelpTextTag#_ACT'	=> 50,
87
-            'hGetHelpTextTag#_ACT'	=> 50
88
-        );
89
-    }
75
+	/**
76
+	 * {@inhericDoc}
77
+	 * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks()
78
+	 */
79
+	public function getSubscribedHooks() {
80
+		return array(
81
+			'hFactSourcePrepend' => 50,
82
+			'hGetExpectedTags' => 50,
83
+			'hHtmlSimpleTagDisplay#_ACT' => 50,
84
+			'hHtmlSimpleTagEditor#_ACT'	=> 50,
85
+			'hAddSimpleTag#SOUR'	=> 50,
86
+			'hHasHelpTextTag#_ACT'	=> 50,
87
+			'hGetHelpTextTag#_ACT'	=> 50
88
+		);
89
+	}
90 90
     
91
-    /**
92
-     * {@inhericDoc}
93
-     * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu()
94
-     */
95
-    public function getMenu(Tree $tree, $reference = null) {
96
-        $tree_url = $tree ? $tree->getNameUrl() : '';
97
-        return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
98
-    }
91
+	/**
92
+	 * {@inhericDoc}
93
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu()
94
+	 */
95
+	public function getMenu(Tree $tree, $reference = null) {
96
+		$tree_url = $tree ? $tree->getNameUrl() : '';
97
+		return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
98
+	}
99 99
     
100
-    /**
101
-     * {@inhericDoc}
102
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend()
103
-     */
104
-    public function hFactSourcePrepend($srec) {
105
-        $wt_tree = Globals::getTree();
106
-        $html='';
107
-        $sid=null;
100
+	/**
101
+	 * {@inhericDoc}
102
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend()
103
+	 */
104
+	public function hFactSourcePrepend($srec) {
105
+		$wt_tree = Globals::getTree();
106
+		$html='';
107
+		$sid=null;
108 108
         
109
-        if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($wt_tree)){
110
-            if (!$srec || strlen($srec) == 0) return $html;
109
+		if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($wt_tree)){
110
+			if (!$srec || strlen($srec) == 0) return $html;
111 111
             	
112
-            $certificate = null;
113
-            $subrecords = explode("\n", $srec);
114
-            $levelSOUR = substr($subrecords[0], 0, 1);
115
-            $match = null;
116
-            if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) {
117
-                $sid=$match[1];
118
-            };
119
-            $nb_subrecords = count($subrecords);
120
-            for ($i=0; $i < $nb_subrecords; $i++) {
121
-                $subrecords[$i] = trim($subrecords[$i]);
122
-                $tag = substr($subrecords[$i], 2, 4);
123
-                $text = substr($subrecords[$i], 7);
124
-                if($tag == '_ACT') $certificate= new Certificate($text, $wt_tree, $this->getProvider());
125
-            }
112
+			$certificate = null;
113
+			$subrecords = explode("\n", $srec);
114
+			$levelSOUR = substr($subrecords[0], 0, 1);
115
+			$match = null;
116
+			if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) {
117
+				$sid=$match[1];
118
+			};
119
+			$nb_subrecords = count($subrecords);
120
+			for ($i=0; $i < $nb_subrecords; $i++) {
121
+				$subrecords[$i] = trim($subrecords[$i]);
122
+				$tag = substr($subrecords[$i], 2, 4);
123
+				$text = substr($subrecords[$i], 7);
124
+				if($tag == '_ACT') $certificate= new Certificate($text, $wt_tree, $this->getProvider());
125
+			}
126 126
             	
127
-            if($certificate && $certificate->canShow())
128
-                $html = $this->getDisplay_ACT($certificate, $sid);
127
+			if($certificate && $certificate->canShow())
128
+				$html = $this->getDisplay_ACT($certificate, $sid);
129 129
                 	
130
-        }
131
-        return $html;
132
-    }
130
+		}
131
+		return $html;
132
+	}
133 133
    
134
-    /**
135
-     * {@inhericDoc}
136
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend()
137
-     */
138
-    public function hFactSourceAppend($srec) { }
134
+	/**
135
+	 * {@inhericDoc}
136
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend()
137
+	 */
138
+	public function hFactSourceAppend($srec) { }
139 139
     
140
-    /**
141
-     * {@inhericDoc}
142
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags()
143
-     */
144
-    public function hGetExpectedTags() {
145
-        return array('SOUR' => '_ACT');
146
-    }
140
+	/**
141
+	 * {@inhericDoc}
142
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags()
143
+	 */
144
+	public function hGetExpectedTags() {
145
+		return array('SOUR' => '_ACT');
146
+	}
147 147
     
148
-    /**
149
-     * {@inhericDoc}
150
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay()
151
-     */
152
-    public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) {
153
-        $html = '';
154
-        switch($tag){
155
-            case '_ACT':
156
-                if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
157
-                break;
158
-        }
159
-        return $html;
160
-    }
148
+	/**
149
+	 * {@inhericDoc}
150
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay()
151
+	 */
152
+	public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) {
153
+		$html = '';
154
+		switch($tag){
155
+			case '_ACT':
156
+				if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
157
+				break;
158
+		}
159
+		return $html;
160
+	}
161 161
     
162
-    /**
163
-     * {@inhericDoc}
164
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor()
165
-     */
166
-    public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) {        
167
-        $html = '';
162
+	/**
163
+	 * {@inhericDoc}
164
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor()
165
+	 */
166
+	public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) {        
167
+		$html = '';
168 168
 		
169 169
 		switch($tag){
170 170
 			case '_ACT':
@@ -192,75 +192,75 @@  discard block
 block discarded – undo
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
 		}
218 218
 		return false;
219
-    }
219
+	}
220 220
     
221
-    /**
222
-     * {@inhericDoc}
223
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag()
224
-     */
225
-    public function hGetHelpTextTag($tag) {
226
-        switch($tag){
227
-            case '_ACT':
228
-                return array(
229
-                I18N::translate('Certificate'),
230
-                '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>');
231
-            default:
232
-                return null;
233
-        }
234
-    }
221
+	/**
222
+	 * {@inhericDoc}
223
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag()
224
+	 */
225
+	public function hGetHelpTextTag($tag) {
226
+		switch($tag){
227
+			case '_ACT':
228
+				return array(
229
+				I18N::translate('Certificate'),
230
+				'<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>');
231
+			default:
232
+				return null;
233
+		}
234
+	}
235 235
 
236
-    /**
237
-     * Returns the default Certificate File Provider, as configured in the module
238
-     *
239
-     * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface
240
-     */
241
-    public function getProvider() {
242
-        if(!$this->provider) {
243
-            $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/');
244
-            $this->provider = new CertificateFileProvider($root_path, Globals::getTree());
245
-        }
246
-        return $this->provider;
247
-    }
236
+	/**
237
+	 * Returns the default Certificate File Provider, as configured in the module
238
+	 *
239
+	 * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface
240
+	 */
241
+	public function getProvider() {
242
+		if(!$this->provider) {
243
+			$root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/');
244
+			$this->provider = new CertificateFileProvider($root_path, Globals::getTree());
245
+		}
246
+		return $this->provider;
247
+	}
248 248
     
249 249
     
250
-    /**
251
-     * Return the HTML code for custom simple tag _ACT
252
-     *
253
-     * @param Certificate $certificatePath Certificate (as per the GEDCOM)
254
-     * @param string|null $sid Linked Source ID, if it exists
255
-     */
256
-    protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
257
-        $html = '';
258
-        if($certificate){
259
-            $certificate->setSource($sid);
260
-            $html = $certificate->displayImage('icon');
261
-        }
262
-        return $html;
263
-    }
250
+	/**
251
+	 * Return the HTML code for custom simple tag _ACT
252
+	 *
253
+	 * @param Certificate $certificatePath Certificate (as per the GEDCOM)
254
+	 * @param string|null $sid Linked Source ID, if it exists
255
+	 */
256
+	protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
257
+		$html = '';
258
+		if($certificate){
259
+			$certificate->setSource($sid);
260
+			$html = $certificate->displayImage('icon');
261
+		}
262
+		return $html;
263
+	}
264 264
 
265 265
 
266 266
 }
Please login to merge, or discard this patch.