@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | * {@inhericDoc} |
24 | 24 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
25 | 25 | */ |
26 | - protected function renderContent() { |
|
27 | - ?> |
|
26 | + protected function renderContent() { |
|
27 | + ?> |
|
28 | 28 | <div id="maj-geodisp-list-page" class="center"> |
29 | 29 | <h2><?php echo $this->data->get('title'); ?></h2> |
30 | 30 | |
31 | 31 | <?php |
32 | 32 | if($this->data->get('has_list', false)) { |
33 | - $galist = $this->data->get('geoanalysislist'); |
|
34 | - ?> |
|
33 | + $galist = $this->data->get('geoanalysislist'); |
|
34 | + ?> |
|
35 | 35 | |
36 | 36 | <p class="center"><?php echo I18N::translate('Choose a geographical dispersion analysis:'); ?><p> |
37 | 37 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | </div> |
59 | 59 | |
60 | 60 | <?php |
61 | - } |
|
61 | + } |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | 65 | \ No newline at end of file |
@@ -25,27 +25,27 @@ discard block |
||
25 | 25 | * {@inhericDoc} |
26 | 26 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
27 | 27 | */ |
28 | - protected function renderContent() { |
|
29 | - $nb_found = $this->data->get('stats_gen_nb_found'); |
|
30 | - $nb_other = $this->data->get('stats_gen_nb_other'); |
|
31 | - $nb_unknown = $this->data->get('stats_gen_nb_unknown'); |
|
32 | - $perc_known = Functions::safeDivision($nb_found - $nb_other, $nb_found + $nb_unknown); |
|
28 | + protected function renderContent() { |
|
29 | + $nb_found = $this->data->get('stats_gen_nb_found'); |
|
30 | + $nb_other = $this->data->get('stats_gen_nb_other'); |
|
31 | + $nb_unknown = $this->data->get('stats_gen_nb_unknown'); |
|
32 | + $perc_known = Functions::safeDivision($nb_found - $nb_other, $nb_found + $nb_unknown); |
|
33 | 33 | |
34 | - $html = '<div id="geodispersion_summary"> |
|
34 | + $html = '<div id="geodispersion_summary"> |
|
35 | 35 | <div class="maj-table center"> |
36 | 36 | <div class="maj-row"> |
37 | 37 | <div class="label">' . I18N::translate('Places found'). '</div> |
38 | 38 | <div class="value">' . I18N::translate('%1$d (%2$s)',$nb_found - $nb_other, I18N::percentage($perc_known)). '</div> |
39 | 39 | </div>'; |
40 | - if($nb_other > 0){ |
|
41 | - $perc_other = Functions::safeDivision($nb_other, $nb_found + $nb_unknown); |
|
42 | - $html .= |
|
43 | - '<div class="maj-row"> |
|
40 | + if($nb_other > 0){ |
|
41 | + $perc_other = Functions::safeDivision($nb_other, $nb_found + $nb_unknown); |
|
42 | + $html .= |
|
43 | + '<div class="maj-row"> |
|
44 | 44 | <div class="label">' . I18N::translate('Other places'). '</div> |
45 | 45 | <div class="value">' . I18N::translate('%1$d (%2$s)',$nb_other, I18N::percentage($perc_other)). '</div> |
46 | 46 | </div>'; |
47 | - } |
|
48 | - $html .= '<div class="maj-row"> |
|
47 | + } |
|
48 | + $html .= '<div class="maj-row"> |
|
49 | 49 | <div class="label">' . I18N::translate('Places not found'). '</div> |
50 | 50 | <div class="value">' . I18N::translate('%1$d (%2$s)',$nb_unknown, I18N::percentage(1 - $perc_known)). '</div> |
51 | 51 | </div> |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | ' . $this->htmlAnalysisData(). ' |
57 | 57 | </div>'; |
58 | 58 | |
59 | - return $html; |
|
60 | - } |
|
59 | + return $html; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Returns HTML code to display the analysis data, under the appropriate format. |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @return string HTML Code for analysis display |
66 | 66 | * @abstract |
67 | 67 | */ |
68 | - protected abstract function htmlAnalysisData(); |
|
68 | + protected abstract function htmlAnalysisData(); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | 72 | \ No newline at end of file |
@@ -22,44 +22,44 @@ |
||
22 | 22 | * {@inheritDoc} |
23 | 23 | * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisTabGeneralView::htmlAnalysisData() |
24 | 24 | */ |
25 | - protected function htmlAnalysisData() { |
|
26 | - $results = $this->data->get('results'); |
|
27 | - $analysis_level = $this->data->get('analysis_level'); |
|
25 | + protected function htmlAnalysisData() { |
|
26 | + $results = $this->data->get('results'); |
|
27 | + $analysis_level = $this->data->get('analysis_level'); |
|
28 | 28 | |
29 | - $nb_found = $this->data->get('stats_gen_nb_found'); |
|
30 | - $nb_other = $this->data->get('stats_gen_nb_other'); |
|
29 | + $nb_found = $this->data->get('stats_gen_nb_found'); |
|
30 | + $nb_other = $this->data->get('stats_gen_nb_other'); |
|
31 | 31 | |
32 | - $i=1; |
|
33 | - $previous_nb=0; |
|
32 | + $i=1; |
|
33 | + $previous_nb=0; |
|
34 | 34 | |
35 | - $html='<div class="maj-table center">'; |
|
36 | - foreach($results as $place => $nb){ |
|
37 | - $perc = Functions::safeDivision($nb, $nb_found - $nb_other); |
|
38 | - if($nb!=$previous_nb){ |
|
39 | - $j= I18N::number($i); |
|
40 | - } |
|
41 | - else{ |
|
42 | - $j=' '; |
|
43 | - } |
|
35 | + $html='<div class="maj-table center">'; |
|
36 | + foreach($results as $place => $nb){ |
|
37 | + $perc = Functions::safeDivision($nb, $nb_found - $nb_other); |
|
38 | + if($nb!=$previous_nb){ |
|
39 | + $j= I18N::number($i); |
|
40 | + } |
|
41 | + else{ |
|
42 | + $j=' '; |
|
43 | + } |
|
44 | 44 | |
45 | - $levels = array_map('trim',explode(',', $place)); |
|
46 | - $placename = $levels[$analysis_level-1]; |
|
47 | - if($placename == '' && $analysis_level > 1) $placename = I18N::translate('Unknown (%s)', $levels[$analysis_level-2]); |
|
48 | - $html.= |
|
49 | - '<div class="maj-row"> |
|
45 | + $levels = array_map('trim',explode(',', $place)); |
|
46 | + $placename = $levels[$analysis_level-1]; |
|
47 | + if($placename == '' && $analysis_level > 1) $placename = I18N::translate('Unknown (%s)', $levels[$analysis_level-2]); |
|
48 | + $html.= |
|
49 | + '<div class="maj-row"> |
|
50 | 50 | <div class="label"><strong>'.$j.'</strong></div> |
51 | 51 | <div class="label">'.$placename.'</div> |
52 | 52 | <div class="value">'.I18N::translate('%d',$nb).'</div> |
53 | 53 | <div class="value">'.I18N::percentage($perc,1).'</div> |
54 | 54 | </div>'; |
55 | - $i++; |
|
56 | - $previous_nb=$nb; |
|
57 | - } |
|
55 | + $i++; |
|
56 | + $previous_nb=$nb; |
|
57 | + } |
|
58 | 58 | |
59 | - $html.='</div>'; |
|
59 | + $html.='</div>'; |
|
60 | 60 | |
61 | - return $html; |
|
62 | - } |
|
61 | + return $html; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
66 | 66 | \ No newline at end of file |
@@ -17,41 +17,41 @@ |
||
17 | 17 | */ |
18 | 18 | interface CertificateProviderInterface { |
19 | 19 | |
20 | - /** |
|
21 | - * Returns the certificates directory path as it is really (within the firewall directory). |
|
22 | - * |
|
23 | - * @return string Real certificates directory path |
|
24 | - */ |
|
25 | - function getRealCertificatesDirectory(); |
|
20 | + /** |
|
21 | + * Returns the certificates directory path as it is really (within the firewall directory). |
|
22 | + * |
|
23 | + * @return string Real certificates directory path |
|
24 | + */ |
|
25 | + function getRealCertificatesDirectory(); |
|
26 | 26 | |
27 | - /** |
|
28 | - * Returns an array of the folders (cities) in the certificate directory. |
|
29 | - * Cities name are UTF8 encoded. |
|
30 | - * |
|
31 | - * @return array Array of cities name |
|
32 | - */ |
|
33 | - function getCitiesList(); |
|
27 | + /** |
|
28 | + * Returns an array of the folders (cities) in the certificate directory. |
|
29 | + * Cities name are UTF8 encoded. |
|
30 | + * |
|
31 | + * @return array Array of cities name |
|
32 | + */ |
|
33 | + function getCitiesList(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Returns the list of available certificates for a specified city. |
|
37 | - * Format of the list : |
|
38 | - * < file name , date of the certificate , type of certificate , name of the certificate > |
|
39 | - * Data are UTF8 encoded. |
|
40 | - * |
|
41 | - * @param string $selCity City to look in |
|
42 | - * @return array List of certificates |
|
43 | - */ |
|
44 | - function getCertificatesList($selCity); |
|
35 | + /** |
|
36 | + * Returns the list of available certificates for a specified city. |
|
37 | + * Format of the list : |
|
38 | + * < file name , date of the certificate , type of certificate , name of the certificate > |
|
39 | + * Data are UTF8 encoded. |
|
40 | + * |
|
41 | + * @param string $selCity City to look in |
|
42 | + * @return array List of certificates |
|
43 | + */ |
|
44 | + function getCertificatesList($selCity); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Return the list of certificates from a city $city and containing the characters $contains |
|
48 | - * |
|
49 | - * @param string $city City to search in |
|
50 | - * @param string $contains Characters to match |
|
51 | - * @param string $limit Maximum number of results |
|
52 | - * @return array Array of matching certificates |
|
53 | - */ |
|
54 | - function getCertificatesListBeginWith($city, $contains, $limit); |
|
46 | + /** |
|
47 | + * Return the list of certificates from a city $city and containing the characters $contains |
|
48 | + * |
|
49 | + * @param string $city City to search in |
|
50 | + * @param string $contains Characters to match |
|
51 | + * @param string $limit Maximum number of results |
|
52 | + * @return array Array of matching certificates |
|
53 | + */ |
|
54 | + function getCertificatesListBeginWith($city, $contains, $limit); |
|
55 | 55 | |
56 | 56 | } |
57 | 57 |
@@ -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. |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | * {@inhericDoc} |
26 | 26 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
27 | 27 | */ |
28 | - protected function renderContent() { |
|
29 | - ?> |
|
28 | + protected function renderContent() { |
|
29 | + ?> |
|
30 | 30 | <div id="maj-cert-page" class="center"> |
31 | 31 | <h2><?php echo $this->data->get('title'); ?></h2> |
32 | 32 | |
33 | 33 | <?php if($this->data->get('has_certif', false)) { |
34 | - /** @var Certificate $certificate */ |
|
35 | - $certificate = $this->data->get('certificate'); |
|
36 | - $has_linked_indis = $this->data->get('has_linked_indis', false); |
|
37 | - $has_linked_fams = $this->data->get('has_linked_fams', false); |
|
38 | - ?> |
|
34 | + /** @var Certificate $certificate */ |
|
35 | + $certificate = $this->data->get('certificate'); |
|
36 | + $has_linked_indis = $this->data->get('has_linked_indis', false); |
|
37 | + $has_linked_fams = $this->data->get('has_linked_fams', false); |
|
38 | + ?> |
|
39 | 39 | <div id="certificate-details"> |
40 | 40 | <h3> |
41 | 41 | <?php echo $certificate->getCity(); ?> |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | </div> |
87 | 87 | |
88 | 88 | <?php |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | |
93 | 93 | \ No newline at end of file |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | * {@inhericDoc} |
27 | 27 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
28 | 28 | */ |
29 | - protected function renderContent() { |
|
29 | + protected function renderContent() { |
|
30 | 30 | |
31 | - /** @var AbstractModule $module */ |
|
32 | - $module = $this->data->get('module'); |
|
33 | - ?> |
|
31 | + /** @var AbstractModule $module */ |
|
32 | + $module = $this->data->get('module'); |
|
33 | + ?> |
|
34 | 34 | <ol class="breadcrumb small"> |
35 | 35 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
36 | 36 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | </form> |
187 | 187 | |
188 | 188 | <?php |
189 | - } |
|
189 | + } |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
193 | 193 | \ No newline at end of file |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * {@inhericDoc} |
26 | 26 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
27 | 27 | */ |
28 | - protected function renderContent() { |
|
28 | + protected function renderContent() { |
|
29 | 29 | |
30 | - $cities = $this->data->get('cities'); |
|
31 | - $selected_city = $this->data->get('selected_city'); |
|
30 | + $cities = $this->data->get('cities'); |
|
31 | + $selected_city = $this->data->get('selected_city'); |
|
32 | 32 | |
33 | - ?> |
|
33 | + ?> |
|
34 | 34 | <div id="maj-cert-list-page" class="center"> |
35 | 35 | <h2><?php echo $this->data->get('title'); ?></h2> |
36 | 36 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | </thead> |
62 | 62 | <tbody> |
63 | 63 | <?php foreach ($this->data->get('certificate_list') as $certificate) { |
64 | - /** @var \MyArtJaub\Webtrees\Module\Certificates\Model\Certificate $certificate */ |
|
65 | - ?> |
|
64 | + /** @var \MyArtJaub\Webtrees\Module\Certificates\Model\Certificate $certificate */ |
|
65 | + ?> |
|
66 | 66 | <tr> |
67 | 67 | <!-- Certificate date --> |
68 | 68 | <?php if($date = $certificate->getCertificateDate()) { ?> |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | <td><?php echo Filter::escapeHtml($certificate->getCertificateType() ?: ''); ?></td> |
77 | 77 | <!-- Certificate Name --> |
78 | 78 | <?php |
79 | - $name = $certificate->getCertificateDetails() ?: ''; |
|
80 | - $sortname = ""; |
|
81 | - $ct_names=preg_match("/([A-Z]{2,})/", $name, $match); |
|
82 | - if($ct_names > 0) $sortname = $match[1].'_'; |
|
83 | - $sortname .= $name; |
|
84 | - ?> |
|
79 | + $name = $certificate->getCertificateDetails() ?: ''; |
|
80 | + $sortname = ""; |
|
81 | + $ct_names=preg_match("/([A-Z]{2,})/", $name, $match); |
|
82 | + if($ct_names > 0) $sortname = $match[1].'_'; |
|
83 | + $sortname .= $name; |
|
84 | + ?> |
|
85 | 85 | <td><?php echo Filter::escapeHtml($sortname); ?></td> |
86 | 86 | <td> |
87 | 87 | <a href="<?php echo $certificate->getHtmlUrl(); ?>"><?php echo Filter::escapeHtml($name); ?></a> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | </div> |
96 | 96 | |
97 | 97 | <?php |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
102 | 102 | \ No newline at end of file |
@@ -23,74 +23,74 @@ |
||
23 | 23 | */ |
24 | 24 | class PiwikController extends MvcController |
25 | 25 | { |
26 | - /** |
|
27 | - * Retrieve the number of visitors from Piwik, for a given period. |
|
28 | - * |
|
29 | - * @param string $block_id |
|
30 | - * @param string $period |
|
31 | - * @param (null|int) Number of visits |
|
32 | - */ |
|
33 | - private function getNumberOfVisitsPiwik($block_id, $period='year'){ |
|
26 | + /** |
|
27 | + * Retrieve the number of visitors from Piwik, for a given period. |
|
28 | + * |
|
29 | + * @param string $block_id |
|
30 | + * @param string $period |
|
31 | + * @param (null|int) Number of visits |
|
32 | + */ |
|
33 | + private function getNumberOfVisitsPiwik($block_id, $period='year'){ |
|
34 | 34 | |
35 | - $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url'); |
|
36 | - $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid'); |
|
37 | - $piwik_token = $this->module->getBlockSetting($block_id, 'piwik_token'); |
|
35 | + $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url'); |
|
36 | + $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid'); |
|
37 | + $piwik_token = $this->module->getBlockSetting($block_id, 'piwik_token'); |
|
38 | 38 | |
39 | - if($piwik_url && strlen($piwik_url) > 0 && |
|
40 | - $piwik_siteid && strlen($piwik_siteid) > 0 && |
|
41 | - $piwik_token && strlen($piwik_token) |
|
42 | - ) |
|
43 | - { |
|
44 | - // calling Piwik REST API |
|
45 | - $url = $piwik_url; |
|
46 | - $url .= '?module=API&method=VisitsSummary.getVisits'; |
|
47 | - $url .= '&idSite='.$piwik_siteid.'&period='.$period.'&date=today'; |
|
48 | - $url .= '&format=PHP'; |
|
49 | - $url .= '&token_auth='.$piwik_token; |
|
39 | + if($piwik_url && strlen($piwik_url) > 0 && |
|
40 | + $piwik_siteid && strlen($piwik_siteid) > 0 && |
|
41 | + $piwik_token && strlen($piwik_token) |
|
42 | + ) |
|
43 | + { |
|
44 | + // calling Piwik REST API |
|
45 | + $url = $piwik_url; |
|
46 | + $url .= '?module=API&method=VisitsSummary.getVisits'; |
|
47 | + $url .= '&idSite='.$piwik_siteid.'&period='.$period.'&date=today'; |
|
48 | + $url .= '&format=PHP'; |
|
49 | + $url .= '&token_auth='.$piwik_token; |
|
50 | 50 | |
51 | - if($fetched = File::fetchUrl($url)) { |
|
52 | - $content = @unserialize($fetched); |
|
53 | - if(is_numeric($content)) return $content; |
|
54 | - } |
|
55 | - } |
|
51 | + if($fetched = File::fetchUrl($url)) { |
|
52 | + $content = @unserialize($fetched); |
|
53 | + if(is_numeric($content)) return $content; |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - return null; |
|
58 | - } |
|
57 | + return null; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Pages |
|
62 | - */ |
|
60 | + /** |
|
61 | + * Pages |
|
62 | + */ |
|
63 | 63 | |
64 | - /** |
|
65 | - * Piwik@index |
|
66 | - */ |
|
67 | - public function index() { |
|
64 | + /** |
|
65 | + * Piwik@index |
|
66 | + */ |
|
67 | + public function index() { |
|
68 | 68 | |
69 | - $ctrl = new AjaxController(); |
|
69 | + $ctrl = new AjaxController(); |
|
70 | 70 | |
71 | - $data = new ViewBag(); |
|
72 | - $data->set('has_stats', false); |
|
71 | + $data = new ViewBag(); |
|
72 | + $data->set('has_stats', false); |
|
73 | 73 | |
74 | - $block_id = Filter::get('block_id'); |
|
75 | - if($block_id){ |
|
76 | - if(Cache::isCached('piwikCountYear', $this->module)) { |
|
77 | - $visitCountYear = Cache::get('piwikCountYear', $this->module); |
|
78 | - } |
|
79 | - else{ |
|
80 | - $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
|
81 | - Cache::save('piwikCountYear', $visitCountYear, $this->module); |
|
82 | - } |
|
83 | - if($visitCountYear){ |
|
84 | - $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
|
85 | - $visitCountYear = max( 0, $visitCountYear); |
|
74 | + $block_id = Filter::get('block_id'); |
|
75 | + if($block_id){ |
|
76 | + if(Cache::isCached('piwikCountYear', $this->module)) { |
|
77 | + $visitCountYear = Cache::get('piwikCountYear', $this->module); |
|
78 | + } |
|
79 | + else{ |
|
80 | + $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
|
81 | + Cache::save('piwikCountYear', $visitCountYear, $this->module); |
|
82 | + } |
|
83 | + if($visitCountYear){ |
|
84 | + $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
|
85 | + $visitCountYear = max( 0, $visitCountYear); |
|
86 | 86 | |
87 | - $data->set('has_stats', true); |
|
88 | - $data->set('visits_today', $visitCountToday); |
|
89 | - $data->set('visits_year', $visitCountYear + $visitCountToday); |
|
90 | - } |
|
91 | - } |
|
87 | + $data->set('has_stats', true); |
|
88 | + $data->set('visits_today', $visitCountToday); |
|
89 | + $data->set('visits_year', $visitCountYear + $visitCountToday); |
|
90 | + } |
|
91 | + } |
|
92 | 92 | |
93 | - ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render(); |
|
94 | - } |
|
93 | + ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render(); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | \ No newline at end of file |