@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | * {@inhericDoc} |
25 | 25 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
26 | 26 | */ |
27 | - protected function renderContent() { |
|
28 | - /** @var \Fisharebest\Webtrees\Individual $indi */ |
|
29 | - $indi = $this->data->get('indi'); |
|
27 | + protected function renderContent() { |
|
28 | + /** @var \Fisharebest\Webtrees\Individual $indi */ |
|
29 | + $indi = $this->data->get('indi'); |
|
30 | 30 | |
31 | - /** @var \Fisharebest\Webtrees\Tree $tree */ |
|
32 | - $tree = $this->data->get('tree'); |
|
31 | + /** @var \Fisharebest\Webtrees\Tree $tree */ |
|
32 | + $tree = $this->data->get('tree'); |
|
33 | 33 | |
34 | - //Welcome section - gedcom title, date, statistics - based on gedcom_block |
|
35 | - $content = |
|
36 | - '<table> |
|
34 | + //Welcome section - gedcom title, date, statistics - based on gedcom_block |
|
35 | + $content = |
|
36 | + '<table> |
|
37 | 37 | <tr> |
38 | 38 | <td> |
39 | 39 | <a href="pedigree.php?rootid=' . $indi->getXref() . '&ged=' . $tree->getNameUrl() . '"> |
@@ -46,50 +46,50 @@ discard block |
||
46 | 46 | </a> |
47 | 47 | </td>'; |
48 | 48 | |
49 | - if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) { |
|
50 | - $content .= ' |
|
49 | + if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) { |
|
50 | + $content .= ' |
|
51 | 51 | <td> |
52 | 52 | <a href="' . WT_LOGIN_URL . '?action=register"> |
53 | 53 | <i class="icon-user_add"></i><br>'.I18N::translate('Request a new user account').' |
54 | 54 | </a> |
55 | 55 | </td>'; |
56 | - } |
|
57 | - $content .= ' |
|
56 | + } |
|
57 | + $content .= ' |
|
58 | 58 | </tr> |
59 | 59 | </table>'; |
60 | 60 | |
61 | - // Piwik Statistics |
|
62 | - if ($this->data->get('piwik_enabled', false)){ |
|
63 | - $content .= ' |
|
61 | + // Piwik Statistics |
|
62 | + if ($this->data->get('piwik_enabled', false)){ |
|
63 | + $content .= ' |
|
64 | 64 | <div class="center"> |
65 | 65 | <div id="piwik_stats"> |
66 | 66 | <i class="icon-loading-small"></i> ' . I18N::translate('Retrieving Piwik statistics...') . ' |
67 | 67 | </div> |
68 | 68 | </div>'; |
69 | - } |
|
69 | + } |
|
70 | 70 | |
71 | - $content .= '<hr />'; |
|
71 | + $content .= '<hr />'; |
|
72 | 72 | |
73 | - // Login section - based on login_block |
|
74 | - if (Auth::check()) { |
|
75 | - $content .= ' |
|
73 | + // Login section - based on login_block |
|
74 | + if (Auth::check()) { |
|
75 | + $content .= ' |
|
76 | 76 | <div class="center"> |
77 | 77 | <form method="post" action="logout.php" name="logoutform" onsubmit="return true;"> |
78 | 78 | <br>' . |
79 | - I18N::translate('You are signed in as %s.', '<a href="edituser.php" class="name2">' . Auth::user()->getRealNameHtml() . '</a>') . |
|
80 | - '<br><br> |
|
79 | + I18N::translate('You are signed in as %s.', '<a href="edituser.php" class="name2">' . Auth::user()->getRealNameHtml() . '</a>') . |
|
80 | + '<br><br> |
|
81 | 81 | <input type="submit" value="'.I18N::translate('sign out').'"> |
82 | 82 | <br><br> |
83 | 83 | </form> |
84 | 84 | </div>'; |
85 | - } else { |
|
86 | - $content .= ' |
|
85 | + } else { |
|
86 | + $content .= ' |
|
87 | 87 | <div id="maj-login-box"> |
88 | 88 | <form id="maj-login-form" name="maj-login-form" method="post" action="'.WT_LOGIN_URL.'"> |
89 | 89 | <input type="hidden" name="action" value="login"> |
90 | 90 | <div> |
91 | 91 | <label for="maj-username">'. I18N::translate('Username'). |
92 | - '<input type="text" id="maj-username" name="username" class="formField"> |
|
92 | + '<input type="text" id="maj-username" name="username" class="formField"> |
|
93 | 93 | </label> |
94 | 94 | </div> |
95 | 95 | <div> |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | <div> |
104 | 104 | <a href="#" id="maj-passwd_click">'. I18N::translate('Request a new password').'</a> |
105 | 105 | </div>'; |
106 | - if (Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
107 | - $content.= ' |
|
106 | + if (Site::getPreference('USE_REGISTRATION_MODULE')) { |
|
107 | + $content.= ' |
|
108 | 108 | <div> |
109 | 109 | <a href="'.WT_LOGIN_URL.'?action=register">'. I18N::translate('Request a new user account').'</a> |
110 | 110 | </div>'; |
111 | - } |
|
112 | - $content.= ' |
|
111 | + } |
|
112 | + $content.= ' |
|
113 | 113 | </form>'; // close "login-form" |
114 | 114 | |
115 | - // hidden New Password block |
|
116 | - $content.= ' |
|
115 | + // hidden New Password block |
|
116 | + $content.= ' |
|
117 | 117 | <div id="maj-new_passwd"> |
118 | 118 | <form id="maj-new_passwd_form" name="new_passwd_form" action="'.WT_LOGIN_URL.'" method="post"> |
119 | 119 | <input type="hidden" name="time" value=""> |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | </form> |
131 | 131 | </div> |
132 | 132 | </div>';//"login-box" |
133 | - } |
|
133 | + } |
|
134 | 134 | |
135 | - return $content; |
|
136 | - } |
|
135 | + return $content; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | |
139 | 139 | } |
@@ -36,20 +36,20 @@ discard block |
||
36 | 36 | '<table> |
37 | 37 | <tr> |
38 | 38 | <td> |
39 | - <a href="pedigree.php?rootid=' . $indi->getXref() . '&ged=' . $tree->getNameUrl() . '"> |
|
40 | - <i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . ' |
|
39 | + <a href="pedigree.php?rootid=' . $indi->getXref().'&ged='.$tree->getNameUrl().'"> |
|
40 | + <i class="icon-pedigree"></i><br>' . I18N::translate('Default chart').' |
|
41 | 41 | </a> |
42 | 42 | </td> |
43 | 43 | <td> |
44 | - <a href="individual.php?pid=' . $indi->getXref() . '&ged=' . $tree->getNameUrl() . '"> |
|
45 | - <i class="icon-indis"></i><br>' . I18N::translate('Default individual') . ' |
|
44 | + <a href="individual.php?pid=' . $indi->getXref().'&ged='.$tree->getNameUrl().'"> |
|
45 | + <i class="icon-indis"></i><br>' . I18N::translate('Default individual').' |
|
46 | 46 | </a> |
47 | 47 | </td>'; |
48 | 48 | |
49 | 49 | if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) { |
50 | 50 | $content .= ' |
51 | 51 | <td> |
52 | - <a href="' . WT_LOGIN_URL . '?action=register"> |
|
52 | + <a href="' . WT_LOGIN_URL.'?action=register"> |
|
53 | 53 | <i class="icon-user_add"></i><br>'.I18N::translate('Request a new user account').' |
54 | 54 | </a> |
55 | 55 | </td>'; |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | </table>'; |
60 | 60 | |
61 | 61 | // Piwik Statistics |
62 | - if ($this->data->get('piwik_enabled', false)){ |
|
62 | + if ($this->data->get('piwik_enabled', false)) { |
|
63 | 63 | $content .= ' |
64 | 64 | <div class="center"> |
65 | 65 | <div id="piwik_stats"> |
66 | - <i class="icon-loading-small"></i> ' . I18N::translate('Retrieving Piwik statistics...') . ' |
|
66 | + <i class="icon-loading-small"></i> ' . I18N::translate('Retrieving Piwik statistics...').' |
|
67 | 67 | </div> |
68 | 68 | </div>'; |
69 | 69 | } |
70 | 70 | |
71 | - $content .= '<hr />'; |
|
71 | + $content .= '<hr />'; |
|
72 | 72 | |
73 | 73 | // Login section - based on login_block |
74 | 74 | if (Auth::check()) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | <div class="center"> |
77 | 77 | <form method="post" action="logout.php" name="logoutform" onsubmit="return true;"> |
78 | 78 | <br>' . |
79 | - I18N::translate('You are signed in as %s.', '<a href="edituser.php" class="name2">' . Auth::user()->getRealNameHtml() . '</a>') . |
|
79 | + I18N::translate('You are signed in as %s.', '<a href="edituser.php" class="name2">'.Auth::user()->getRealNameHtml().'</a>'). |
|
80 | 80 | '<br><br> |
81 | 81 | <input type="submit" value="'.I18N::translate('sign out').'"> |
82 | 82 | <br><br> |
@@ -98,34 +98,34 @@ discard block |
||
98 | 98 | </label> |
99 | 99 | </div> |
100 | 100 | <div> |
101 | - <input type="submit" value="'. I18N::translate('sign in'). '"> |
|
101 | + <input type="submit" value="'. I18N::translate('sign in').'"> |
|
102 | 102 | </div> |
103 | 103 | <div> |
104 | 104 | <a href="#" id="maj-passwd_click">'. I18N::translate('Request a new password').'</a> |
105 | 105 | </div>'; |
106 | 106 | if (Site::getPreference('USE_REGISTRATION_MODULE')) { |
107 | - $content.= ' |
|
107 | + $content .= ' |
|
108 | 108 | <div> |
109 | - <a href="'.WT_LOGIN_URL.'?action=register">'. I18N::translate('Request a new user account').'</a> |
|
109 | + <a href="'.WT_LOGIN_URL.'?action=register">'.I18N::translate('Request a new user account').'</a> |
|
110 | 110 | </div>'; |
111 | 111 | } |
112 | - $content.= ' |
|
112 | + $content .= ' |
|
113 | 113 | </form>'; // close "login-form" |
114 | 114 | |
115 | 115 | // hidden New Password block |
116 | - $content.= ' |
|
116 | + $content .= ' |
|
117 | 117 | <div id="maj-new_passwd"> |
118 | 118 | <form id="maj-new_passwd_form" name="new_passwd_form" action="'.WT_LOGIN_URL.'" method="post"> |
119 | 119 | <input type="hidden" name="time" value=""> |
120 | 120 | <input type="hidden" name="action" value="requestpw"> |
121 | 121 | <h4>'. I18N::translate('Lost password request').'</h4> |
122 | 122 | <div> |
123 | - <label for="maj-new_passwd_username">'. I18N::translate('Username or email address') . ' |
|
123 | + <label for="maj-new_passwd_username">'. I18N::translate('Username or email address').' |
|
124 | 124 | <input type="text" id="maj-new_passwd_username" name="new_passwd_username" value=""> |
125 | 125 | </label> |
126 | 126 | </div> |
127 | 127 | <div> |
128 | - <input type="submit" value="'. I18N::translate('Continue'). '"> |
|
128 | + <input type="submit" value="'. I18N::translate('Continue').'"> |
|
129 | 129 | </div> |
130 | 130 | </form> |
131 | 131 | </div> |
@@ -23,77 +23,77 @@ |
||
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 | - $cached_item = Cache::get('piwikCountYear', $this->module); |
|
77 | - $visitCountYear = $cached_item->get(); |
|
78 | - if(!$cached_item->isHit()) { |
|
79 | - $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
|
80 | - if(!is_null($visitCountYear)) { |
|
81 | - $cached_item->expiresAt(new \DateTime('tomorrow')); // Expires the next day at midnight |
|
82 | - Cache::save($cached_item, $visitCountYear); |
|
83 | - } |
|
84 | - } |
|
74 | + $block_id = Filter::get('block_id'); |
|
75 | + if($block_id){ |
|
76 | + $cached_item = Cache::get('piwikCountYear', $this->module); |
|
77 | + $visitCountYear = $cached_item->get(); |
|
78 | + if(!$cached_item->isHit()) { |
|
79 | + $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
|
80 | + if(!is_null($visitCountYear)) { |
|
81 | + $cached_item->expiresAt(new \DateTime('tomorrow')); // Expires the next day at midnight |
|
82 | + Cache::save($cached_item, $visitCountYear); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - if($visitCountYear){ |
|
87 | - $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
|
88 | - $visitCountYear = max( 0, $visitCountYear); |
|
86 | + if($visitCountYear){ |
|
87 | + $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
|
88 | + $visitCountYear = max( 0, $visitCountYear); |
|
89 | 89 | |
90 | - $data->set('has_stats', true); |
|
91 | - $data->set('visits_today', $visitCountToday); |
|
92 | - $data->set('visits_year', $visitCountYear + $visitCountToday); |
|
93 | - } |
|
94 | - } |
|
90 | + $data->set('has_stats', true); |
|
91 | + $data->set('visits_today', $visitCountToday); |
|
92 | + $data->set('visits_year', $visitCountYear + $visitCountToday); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | - ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render(); |
|
97 | - } |
|
96 | + ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render(); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | } |
100 | 100 | \ No newline at end of file |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param string $period |
31 | 31 | * @param (null|int) Number of visits |
32 | 32 | */ |
33 | - private function getNumberOfVisitsPiwik($block_id, $period='year'){ |
|
33 | + private function getNumberOfVisitsPiwik($block_id, $period = 'year') { |
|
34 | 34 | |
35 | 35 | $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url'); |
36 | 36 | $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid'); |
37 | 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 && |
|
39 | + if ($piwik_url && strlen($piwik_url) > 0 && |
|
40 | + $piwik_siteid && strlen($piwik_siteid) > 0 && |
|
41 | 41 | $piwik_token && strlen($piwik_token) |
42 | 42 | ) |
43 | 43 | { |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | $url .= '&format=PHP'; |
49 | 49 | $url .= '&token_auth='.$piwik_token; |
50 | 50 | |
51 | - if($fetched = File::fetchUrl($url)) { |
|
51 | + if ($fetched = File::fetchUrl($url)) { |
|
52 | 52 | $content = @unserialize($fetched); |
53 | - if(is_numeric($content)) return $content; |
|
53 | + if (is_numeric($content)) return $content; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | $data->set('has_stats', false); |
73 | 73 | |
74 | 74 | $block_id = Filter::get('block_id'); |
75 | - if($block_id){ |
|
75 | + if ($block_id) { |
|
76 | 76 | $cached_item = Cache::get('piwikCountYear', $this->module); |
77 | 77 | $visitCountYear = $cached_item->get(); |
78 | - if(!$cached_item->isHit()) { |
|
78 | + if (!$cached_item->isHit()) { |
|
79 | 79 | $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
80 | - if(!is_null($visitCountYear)) { |
|
81 | - $cached_item->expiresAt(new \DateTime('tomorrow')); // Expires the next day at midnight |
|
80 | + if (!is_null($visitCountYear)) { |
|
81 | + $cached_item->expiresAt(new \DateTime('tomorrow')); // Expires the next day at midnight |
|
82 | 82 | Cache::save($cached_item, $visitCountYear); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - if($visitCountYear){ |
|
86 | + if ($visitCountYear) { |
|
87 | 87 | $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
88 | - $visitCountYear = max( 0, $visitCountYear); |
|
88 | + $visitCountYear = max(0, $visitCountYear); |
|
89 | 89 | |
90 | 90 | $data->set('has_stats', true); |
91 | 91 | $data->set('visits_today', $visitCountToday); |