Completed
Push — master ( 2ebfe4...b746e6 )
by Jonathan
06:29
created
src/Webtrees/Module/WelcomeBlock/Views/WelcomeBlockView.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
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() . '&amp;ged=' . $tree->getNameUrl() . '">
@@ -46,50 +46,50 @@  discard block
 block discarded – undo
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>&nbsp;' . 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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/WelcomeBlock/PiwikController.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -23,77 +23,77 @@
 block discarded – undo
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
Please login to merge, or discard this patch.