Completed
Push — master ( 604bee...544e34 )
by Jonathan
05:30
created
src/Webtrees/Cache.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
 	/**
147 147
 	 * Static invocation of the *save* method.
148 148
 	 *
149
-	 * @param string|\Psr\Cache\CacheItemInterface $value Value name
149
+	 * @param CacheItemInterface $value Value name
150 150
 	 * @param mixed $data Value
151 151
 	 * @param AbstractModule $mod Calling module
152 152
 	 */
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Cache{
24 24
 	
25
-    /**
26
-     * Underlying Cache object
27
-     * @var CacheItemPoolInterface $cache
28
-     */
25
+	/**
26
+	 * Underlying Cache object
27
+	 * @var CacheItemPoolInterface $cache
28
+	 */
29 29
 	protected $cache=null;
30 30
 	
31 31
 	/**
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	protected static function getInstance()
49 49
 	{
50
-	    if (null === static::$instance) {
51
-	        static::$instance = new static();
52
-	    }
50
+		if (null === static::$instance) {
51
+			static::$instance = new static();
52
+		}
53 53
 	
54
-	    return static::$instance;
54
+		return static::$instance;
55 55
 	}
56 56
 	
57 57
 	/**
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 */
61 61
 	protected function init() {		
62
-	    if(Apc::isAvailable()) {
63
-		    $driver = new Apc();
62
+		if(Apc::isAvailable()) {
63
+			$driver = new Apc();
64 64
 		} else {
65 65
 			if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
66 66
 				// We may not have permission - especially during setup, before we instruct
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				@mkdir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache');
69 69
 			}
70 70
 			if (is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
71
-			    $driver = new FileSystem(array('path' => WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache'));
71
+				$driver = new FileSystem(array('path' => WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache'));
72 72
 			} else {
73 73
 				// No cache available, let's just use a basic one :-(
74 74
 				$driver = new Ephemeral();
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return string Cached key name
96 96
 	 */
97 97
 	protected function getKeyName($value, AbstractModule $mod = null){
98
-	    $this->checkInit();
98
+		$this->checkInit();
99 99
 		$mod_name = 'myartjaub';
100 100
 		if($mod !== null) $mod_name = $mod->getName();
101 101
 		return $mod_name.'_'.$value;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return \Psr\Cache\CacheItemInterface
110 110
 	 */
111 111
 	public function getI($value, AbstractModule $mod = null){
112
-	    $this->checkInit();
112
+		$this->checkInit();
113 113
 		return $this->cache->getItem($this->getKeyName($value, $mod));
114 114
 	}
115 115
 	
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return \Psr\Cache\CacheItemInterface
122 122
 	 */
123 123
 	public static function get($value, AbstractModule $mod = null){
124
-	    return self::getInstance()->getI($value, $mod);
124
+		return self::getInstance()->getI($value, $mod);
125 125
 	}
126 126
 	
127 127
 	/**
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 		
137 137
 		$item = $value;
138 138
 		if(!($value instanceof CacheItemInterface)) {
139
-		    $item = new \Stash\Item();
140
-    		$item->setKey($this->getKeyName($value, $mod));
139
+			$item = new \Stash\Item();
140
+			$item->setKey($this->getKeyName($value, $mod));
141 141
 		}		
142 142
 		$item->set($data);
143 143
 		$this->cache->save($item);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @param AbstractModule $mod Calling module
152 152
 	 */
153 153
 	public static function save($value, $data, AbstractModule $mod = null){
154
-	    self::getInstance()->saveI($value, $data, $mod);
154
+		self::getInstance()->saveI($value, $data, $mod);
155 155
 	}
156 156
 	
157 157
 	/**
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @return bool Deletion successful?
163 163
 	 */
164 164
 	public function deleteI($value, AbstractModule $mod = null){
165
-	    $this->checkInit();	
166
-	    return $this->cache->deleteItem($this->getKeyName($value, $mod));
165
+		$this->checkInit();	
166
+		return $this->cache->deleteItem($this->getKeyName($value, $mod));
167 167
 	}
168 168
 	
169 169
 	/**
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return bool Deletion successful?
175 175
 	 */
176 176
 	public static function delete($value, AbstractModule $mod = null){
177
-	    return self::getInstance()->deleteI($value, $mod);
177
+		return self::getInstance()->deleteI($value, $mod);
178 178
 	}
179 179
 	
180 180
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 */
184 184
 	public function cleanI(){
185
-	    $this->checkInit();
185
+		$this->checkInit();
186 186
 		$this->cache->clear();
187 187
 	}
188 188
 	
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * Static invocation of the *clean* method.
191 191
 	 */
192 192
 	public static function clean() {
193
-	    self::getInstance()->cleanI();
193
+		self::getInstance()->cleanI();
194 194
 	}
195 195
 	
196 196
 }
197 197
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Cache component to speed up some potential data retrievals
22 22
  */
23
-class Cache{
23
+class Cache {
24 24
 	
25 25
     /**
26 26
      * Underlying Cache object
27 27
      * @var CacheItemPoolInterface $cache
28 28
      */
29
-	protected $cache=null;
29
+	protected $cache = null;
30 30
 	
31 31
 	/**
32 32
 	 * Defines whether the cache has been initialised
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 */
61 61
 	protected function init() {		
62
-	    if(Apc::isAvailable()) {
62
+	    if (Apc::isAvailable()) {
63 63
 		    $driver = new Apc();
64 64
 		} else {
65 65
 			if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 * Initiliase the Cache if not done.
84 84
 	 *
85 85
 	 */
86
-	protected function checkInit(){
87
-		if(!$this->is_init) $this->init();
86
+	protected function checkInit() {
87
+		if (!$this->is_init) $this->init();
88 88
 	}
89 89
 	
90 90
 	/**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 	 * @param AbstractModule $mod Calling module
95 95
 	 * @return string Cached key name
96 96
 	 */
97
-	protected function getKeyName($value, AbstractModule $mod = null){
97
+	protected function getKeyName($value, AbstractModule $mod = null) {
98 98
 	    $this->checkInit();
99 99
 		$mod_name = 'myartjaub';
100
-		if($mod !== null) $mod_name = $mod->getName();
100
+		if ($mod !== null) $mod_name = $mod->getName();
101 101
 		return $mod_name.'_'.$value;
102 102
 	}
103 103
 	
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @param AbstractModule $mod Calling module
109 109
 	 * @return \Psr\Cache\CacheItemInterface
110 110
 	 */
111
-	public function getI($value, AbstractModule $mod = null){
111
+	public function getI($value, AbstractModule $mod = null) {
112 112
 	    $this->checkInit();
113 113
 		return $this->cache->getItem($this->getKeyName($value, $mod));
114 114
 	}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param AbstractModule $mod Calling module
121 121
 	 * @return \Psr\Cache\CacheItemInterface
122 122
 	 */
123
-	public static function get($value, AbstractModule $mod = null){
123
+	public static function get($value, AbstractModule $mod = null) {
124 124
 	    return self::getInstance()->getI($value, $mod);
125 125
 	}
126 126
 	
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 	 * @param mixed $data Value
132 132
 	 * @param AbstractModule $mod Calling module
133 133
 	 */
134
-	public function saveI($value, $data, AbstractModule $mod = null){
134
+	public function saveI($value, $data, AbstractModule $mod = null) {
135 135
 		$this->checkInit();
136 136
 		
137 137
 		$item = $value;
138
-		if(!($value instanceof CacheItemInterface)) {
138
+		if (!($value instanceof CacheItemInterface)) {
139 139
 		    $item = new \Stash\Item();
140 140
     		$item->setKey($this->getKeyName($value, $mod));
141 141
 		}		
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param mixed $data Value
151 151
 	 * @param AbstractModule $mod Calling module
152 152
 	 */
153
-	public static function save($value, $data, AbstractModule $mod = null){
153
+	public static function save($value, $data, AbstractModule $mod = null) {
154 154
 	    self::getInstance()->saveI($value, $data, $mod);
155 155
 	}
156 156
 	
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @param AbstractModule $mod Calling module
162 162
 	 * @return bool Deletion successful?
163 163
 	 */
164
-	public function deleteI($value, AbstractModule $mod = null){
164
+	public function deleteI($value, AbstractModule $mod = null) {
165 165
 	    $this->checkInit();	
166 166
 	    return $this->cache->deleteItem($this->getKeyName($value, $mod));
167 167
 	}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 * @param AbstractModule $mod Calling module
174 174
 	 * @return bool Deletion successful?
175 175
 	 */
176
-	public static function delete($value, AbstractModule $mod = null){
176
+	public static function delete($value, AbstractModule $mod = null) {
177 177
 	    return self::getInstance()->deleteI($value, $mod);
178 178
 	}
179 179
 	
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * Clean the cache
182 182
 	 *
183 183
 	 */
184
-	public function cleanI(){
184
+	public function cleanI() {
185 185
 	    $this->checkInit();
186 186
 		$this->cache->clear();
187 187
 	}
Please login to merge, or discard this patch.
src/Webtrees/Controller/JsonController.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -18,50 +18,50 @@
 block discarded – undo
18 18
  */
19 19
 class JsonController extends BaseController {
20 20
     
21
-    /**
22
-     * {@inheritDoc}
23
-     * @see \Fisharebest\Webtrees\Controller\BaseController::pageHeader()
24
-     */
25
-    public function pageHeader() {        
26
-        header('Content-Type: application/json');
27
-        header('Cache-Control: no-cache, must-revalidate');
28
-        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
29
-        // We've displayed the header - display the footer automatically
30
-        register_shutdown_function(array($this, 'pageFooter'));
21
+	/**
22
+	 * {@inheritDoc}
23
+	 * @see \Fisharebest\Webtrees\Controller\BaseController::pageHeader()
24
+	 */
25
+	public function pageHeader() {        
26
+		header('Content-Type: application/json');
27
+		header('Cache-Control: no-cache, must-revalidate');
28
+		header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
29
+		// We've displayed the header - display the footer automatically
30
+		register_shutdown_function(array($this, 'pageFooter'));
31 31
         
32
-        return $this;
33
-    }
32
+		return $this;
33
+	}
34 34
     
35
-    /**
36
-     * {@inheritDoc}
37
-     * @see \Fisharebest\Webtrees\Controller\BaseController::pageFooter()
38
-     */
39
-    public function pageFooter() {
40
-        return $this;
41
-    }
35
+	/**
36
+	 * {@inheritDoc}
37
+	 * @see \Fisharebest\Webtrees\Controller\BaseController::pageFooter()
38
+	 */
39
+	public function pageFooter() {
40
+		return $this;
41
+	}
42 42
     
43
-    /**
44
-     * Restrict access.
45
-     *
46
-     * @param bool $condition
47
-     *
48
-     * @return $this
49
-     */
50
-    public function restrictAccess($condition) {
51
-        if ($condition !== true) {
52
-            throw new MvcException(403);
53
-        }
43
+	/**
44
+	 * Restrict access.
45
+	 *
46
+	 * @param bool $condition
47
+	 *
48
+	 * @return $this
49
+	 */
50
+	public function restrictAccess($condition) {
51
+		if ($condition !== true) {
52
+			throw new MvcException(403);
53
+		}
54 54
     
55
-        return $this;
56
-    }
55
+		return $this;
56
+	}
57 57
     
58
-    /**
59
-     * Encode the data to JSON format.
60
-     * 
61
-     * @param array $data Data to encode
62
-     * @param number $options JSON options mask. See http://php.net/manual/fr/json.constants.php
63
-     */
64
-    public function encode(array $data, $options = 0) {
65
-        echo json_encode($data, $options);
66
-    }
58
+	/**
59
+	 * Encode the data to JSON format.
60
+	 * 
61
+	 * @param array $data Data to encode
62
+	 * @param number $options JSON options mask. See http://php.net/manual/fr/json.constants.php
63
+	 */
64
+	public function encode(array $data, $options = 0) {
65
+		echo json_encode($data, $options);
66
+	}
67 67
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/AdminConfigController.php 1 patch
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -35,59 +35,59 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class AdminConfigController extends MvcController
37 37
 {    
38
-    /**
39
-     * GeoAnalysis Provider
40
-     * @var GeoAnalysisProvider $provider
41
-     */
42
-    protected $provider;    
38
+	/**
39
+	 * GeoAnalysis Provider
40
+	 * @var GeoAnalysisProvider $provider
41
+	 */
42
+	protected $provider;    
43 43
     
44
-    /**
45
-     * Constructor for Admin Config controller
46
-     * @param AbstractModule $module
47
-     */
48
-    public function __construct(AbstractModule $module) {
49
-        parent::__construct($module);
44
+	/**
45
+	 * Constructor for Admin Config controller
46
+	 * @param AbstractModule $module
47
+	 */
48
+	public function __construct(AbstractModule $module) {
49
+		parent::__construct($module);
50 50
         
51
-        $this->provider = $this->module->getProvider();
52
-    }    
51
+		$this->provider = $this->module->getProvider();
52
+	}    
53 53
     
54
-    /**
55
-     * Pages
56
-     */
54
+	/**
55
+	 * Pages
56
+	 */
57 57
         
58
-    /**
59
-     * AdminConfig@index
60
-     */
61
-    public function index() {
62
-        global $WT_TREE;
58
+	/**
59
+	 * AdminConfig@index
60
+	 */
61
+	public function index() {
62
+		global $WT_TREE;
63 63
         
64
-        Theme::theme(new AdministrationTheme)->init($WT_TREE);
65
-        $controller = new PageController();
66
-        $controller
67
-            ->restrictAccess(Auth::isManager($WT_TREE))
68
-            ->setPageTitle($this->module->getTitle());
64
+		Theme::theme(new AdministrationTheme)->init($WT_TREE);
65
+		$controller = new PageController();
66
+		$controller
67
+			->restrictAccess(Auth::isManager($WT_TREE))
68
+			->setPageTitle($this->module->getTitle());
69 69
         
70
-        $data = new ViewBag();
71
-        $data->set('title', $controller->getPageTitle());
72
-        $data->set('tree', $WT_TREE);
70
+		$data = new ViewBag();
71
+		$data->set('title', $controller->getPageTitle());
72
+		$data->set('tree', $WT_TREE);
73 73
         
74
-        $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
74
+		$data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
75 75
                 
76
-        $table_id = 'table-geoanalysis-' . Uuid::uuid4();
77
-        $data->set('table_id', $table_id);
76
+		$table_id = 'table-geoanalysis-' . Uuid::uuid4();
77
+		$data->set('table_id', $table_id);
78 78
         
79
-        $other_trees = array();
80
-        foreach (Tree::getAll() as $tree) {
81
-            if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree;
82
-        }      
83
-        $data->set('other_trees', $other_trees);
79
+		$other_trees = array();
80
+		foreach (Tree::getAll() as $tree) {
81
+			if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree;
82
+		}      
83
+		$data->set('other_trees', $other_trees);
84 84
         
85
-        $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
85
+		$data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
86 86
         
87
-        $controller
88
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
89
-            ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
90
-            ->addInlineJavascript('
87
+		$controller
88
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
89
+			->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
90
+			->addInlineJavascript('
91 91
                 //Datatable initialisation
92 92
 				jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
93 93
 				jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				});
123 123
                 
124 124
                 ')
125
-                ->addInlineJavascript('				
125
+				->addInlineJavascript('				
126 126
                     function set_geoanalysis_status(ga_id, status, gedcom) {
127 127
                 		jQuery.ajax({
128 128
                             url: "module.php", 
@@ -166,55 +166,55 @@  discard block
 block discarded – undo
166 166
                 ');
167 167
         
168 168
         
169
-        ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
170
-    }
169
+		ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
170
+	}
171 171
 
172
-    /**
173
-     * AdminConfig@jsonGeoAnalysisList
174
-     */
175
-    public function jsonGeoAnalysisList() {
176
-        global $WT_TREE;
172
+	/**
173
+	 * AdminConfig@jsonGeoAnalysisList
174
+	 */
175
+	public function jsonGeoAnalysisList() {
176
+		global $WT_TREE;
177 177
         
178
-        $controller = new JsonController();
179
-        $controller
180
-            ->restrictAccess(Auth::isManager($WT_TREE));
178
+		$controller = new JsonController();
179
+		$controller
180
+			->restrictAccess(Auth::isManager($WT_TREE));
181 181
         
182
-        // Generate an AJAX/JSON response for datatables to load a block of rows
183
-        $search = Filter::postArray('search');
184
-        if($search) $search = $search['value'];
185
-        $start  = Filter::postInteger('start');
186
-        $length = Filter::postInteger('length');
187
-        $order  = Filter::postArray('order');
182
+		// Generate an AJAX/JSON response for datatables to load a block of rows
183
+		$search = Filter::postArray('search');
184
+		if($search) $search = $search['value'];
185
+		$start  = Filter::postInteger('start');
186
+		$length = Filter::postInteger('length');
187
+		$order  = Filter::postArray('order');
188 188
         
189
-        foreach($order as $key => &$value) {
190
-            switch($value['column']) {
191
-                case 3:
192
-                    $value['column'] = 'majgd_descr';
193
-                    break;
194
-                case 5;
195
-                    $value['column'] = 'majgd_sublevel';
196
-                    break;
197
-                default:
198
-                    unset($order[$key]);
199
-            }
200
-        }
189
+		foreach($order as $key => &$value) {
190
+			switch($value['column']) {
191
+				case 3:
192
+					$value['column'] = 'majgd_descr';
193
+					break;
194
+				case 5;
195
+					$value['column'] = 'majgd_sublevel';
196
+					break;
197
+				default:
198
+					unset($order[$key]);
199
+			}
200
+		}
201 201
         
202
-        /** @var GeoAnalysisProvider $provider */
203
-        $provider = $this->module->getProvider();
202
+		/** @var GeoAnalysisProvider $provider */
203
+		$provider = $this->module->getProvider();
204 204
         
205
-        $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length);
206
-        $recordsFiltered = count($list);
207
-        $recordsTotal = $this->provider->getGeoAnalysisCount();
205
+		$list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length);
206
+		$recordsFiltered = count($list);
207
+		$recordsTotal = $this->provider->getGeoAnalysisCount();
208 208
         
209
-        $data = array();
210
-        $place_hierarchy = $this->provider->getPlacesHierarchy();
211
-        foreach($list as $ga) {
212
-            /** @var GeoAnalysis $ga */
209
+		$data = array();
210
+		$place_hierarchy = $this->provider->getPlacesHierarchy();
211
+		foreach($list as $ga) {
212
+			/** @var GeoAnalysis $ga */
213 213
             
214
-            $datum = array();
215
-            $options= $ga->getOptions();
214
+			$datum = array();
215
+			$options= $ga->getOptions();
216 216
             
217
-            $datum[0] = '
217
+			$datum[0] = '
218 218
                 <div class="btn-group">
219 219
                     <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
220 220
                         <i class="fa fa-pencil"></i><span class="caret"></span>
@@ -238,108 +238,108 @@  discard block
 block discarded – undo
238 238
                        </li>
239 239
                     </ul>
240 240
                 </div>';
241
-		    $datum[1] = $ga->getId();
242
-		    $datum[2] = $ga->isEnabled() ? 
241
+			$datum[1] = $ga->getId();
242
+			$datum[2] = $ga->isEnabled() ? 
243 243
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : 
244 244
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
245
-		    $datum[3] = $ga->getTitle();
246
-		    $analysis_level = $ga->getAnalysisLevel();
247
-		    if($place_hierarchy['type'] == 'header') {
248
-		        $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
249
-		    } else {
250
-		        $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
251
-		    }
252
-		    $datum[5] = $ga->getAnalysisLevel();
253
-		    $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
254
-		    $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
255
-		    if($ga->hasMap()) {
256
-		        $datum[6] = $options->getMap()->getDescription();
257
-		        $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
258
-		        $top_level = $options->getMapLevel();
259
-		        if($place_hierarchy['type'] == 'header') {
260
-		            $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
261
-		        } else {
262
-		            $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
263
-		        }
264
-		        $datum[7] .= '</span>';
265
-		    }
266
-		    $datum[8] = $options->isUsingFlags() ? 
245
+			$datum[3] = $ga->getTitle();
246
+			$analysis_level = $ga->getAnalysisLevel();
247
+			if($place_hierarchy['type'] == 'header') {
248
+				$datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
249
+			} else {
250
+				$datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
251
+			}
252
+			$datum[5] = $ga->getAnalysisLevel();
253
+			$datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
254
+			$datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
255
+			if($ga->hasMap()) {
256
+				$datum[6] = $options->getMap()->getDescription();
257
+				$datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
258
+				$top_level = $options->getMapLevel();
259
+				if($place_hierarchy['type'] == 'header') {
260
+					$datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
261
+				} else {
262
+					$datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
263
+				}
264
+				$datum[7] .= '</span>';
265
+			}
266
+			$datum[8] = $options->isUsingFlags() ? 
267 267
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : 
268 268
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
269
-		    $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
269
+			$datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
270 270
 		    
271
-		    $data[] = $datum;
272
-        }
271
+			$data[] = $datum;
272
+		}
273 273
         
274
-        $controller->pageHeader();
274
+		$controller->pageHeader();
275 275
         
276
-        $controller->encode(array(
277
-            'draw'            => Filter::getInteger('draw'),
278
-            'recordsTotal'    => $recordsTotal,
279
-            'recordsFiltered' => $recordsFiltered,
280
-            'data'            => $data
281
-        ));
276
+		$controller->encode(array(
277
+			'draw'            => Filter::getInteger('draw'),
278
+			'recordsTotal'    => $recordsTotal,
279
+			'recordsFiltered' => $recordsFiltered,
280
+			'data'            => $data
281
+		));
282 282
         
283
-    }
283
+	}
284 284
 
285
-    /**
286
-     * AdminConfig@edit
287
-     */
288
-    public function edit() {
289
-        $ga_id = Filter::getInteger('ga_id');
290
-        $ga = $this->provider->getGeoAnalysis($ga_id, false);
285
+	/**
286
+	 * AdminConfig@edit
287
+	 */
288
+	public function edit() {
289
+		$ga_id = Filter::getInteger('ga_id');
290
+		$ga = $this->provider->getGeoAnalysis($ga_id, false);
291 291
         
292
-        $this->renderEdit($ga);
293
-    }
292
+		$this->renderEdit($ga);
293
+	}
294 294
     
295
-    /**
296
-     * AdminConfig@add
297
-     */
298
-    public function add() {
299
-        $this->renderEdit(null);
300
-    }
295
+	/**
296
+	 * AdminConfig@add
297
+	 */
298
+	public function add() {
299
+		$this->renderEdit(null);
300
+	}
301 301
     
302
-    /**
303
-     * AdminConfig@save
304
-     */
305
-    public function save() {
306
-        global $WT_TREE;
302
+	/**
303
+	 * AdminConfig@save
304
+	 */
305
+	public function save() {
306
+		global $WT_TREE;
307 307
         
308
-        $tmp_contrl = new PageController();
309
-        $tmp_contrl->restrictAccess(
310
-            Auth::isManager($WT_TREE) 
311
-            && Filter::checkCsrf()
312
-         );
308
+		$tmp_contrl = new PageController();
309
+		$tmp_contrl->restrictAccess(
310
+			Auth::isManager($WT_TREE) 
311
+			&& Filter::checkCsrf()
312
+		 );
313 313
         
314
-        $ga_id          = Filter::postInteger('ga_id');
315
-        $description    = Filter::post('description');
316
-        $analysislevel  = Filter::postInteger('analysislevel');
317
-        $use_map        = Filter::postBool('use_map');
318
-        if($use_map) {
319
-            $map_file   = base64_decode(Filter::post('map_file'));
320
-            $map_top_level   = Filter::postInteger('map_top_level');
321
-        }
322
-        $use_flags      = Filter::postBool('use_flags');
323
-        $gen_details    = Filter::postInteger('gen_details');
314
+		$ga_id          = Filter::postInteger('ga_id');
315
+		$description    = Filter::post('description');
316
+		$analysislevel  = Filter::postInteger('analysislevel');
317
+		$use_map        = Filter::postBool('use_map');
318
+		if($use_map) {
319
+			$map_file   = base64_decode(Filter::post('map_file'));
320
+			$map_top_level   = Filter::postInteger('map_top_level');
321
+		}
322
+		$use_flags      = Filter::postBool('use_flags');
323
+		$gen_details    = Filter::postInteger('gen_details');
324 324
         
325
-        $success = false; 
326
-        if($ga_id) {
327
-            $ga = $this->provider->getGeoAnalysis($ga_id, false);
328
-            if($ga) {
329
-                $ga->setTitle($description);
330
-                $ga->setAnalysisLevel($analysislevel + 1);
331
-                $options = $ga->getOptions();
332
-                if($options) {
333
-                    $options->setUsingFlags($use_flags);
334
-                    $options->setMaxDetailsInGen($gen_details);
335
-                    if($use_map) {
336
-                        $options->setMap(new OutlineMap($map_file));
337
-                        $options->setMapLevel($map_top_level + 1);
338
-                    }
339
-                    else {
340
-                        $options->setMap(null);
341
-                    }
342
-                }
325
+		$success = false; 
326
+		if($ga_id) {
327
+			$ga = $this->provider->getGeoAnalysis($ga_id, false);
328
+			if($ga) {
329
+				$ga->setTitle($description);
330
+				$ga->setAnalysisLevel($analysislevel + 1);
331
+				$options = $ga->getOptions();
332
+				if($options) {
333
+					$options->setUsingFlags($use_flags);
334
+					$options->setMaxDetailsInGen($gen_details);
335
+					if($use_map) {
336
+						$options->setMap(new OutlineMap($map_file));
337
+						$options->setMapLevel($map_top_level + 1);
338
+					}
339
+					else {
340
+						$options->setMap(null);
341
+					}
342
+				}
343 343
 				
344 344
 				$res = $this->provider->updateGeoAnalysis($ga);
345 345
 				if($res) {
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 					FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger');
353 353
 					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.');
354 354
 				}
355
-            }
356
-        } else {
355
+			}
356
+		} else {
357 357
 			$ga = $this->provider->createGeoAnalysis(
358 358
 				$description,
359 359
 				$analysislevel + 1,
@@ -371,34 +371,34 @@  discard block
 block discarded – undo
371 371
 				FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger');
372 372
 				Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.');
373 373
 			}
374
-        }
374
+		}
375 375
         
376
-        $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl();
377
-        if(!$success) {			
378
-            if($ga) {
379
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl();
380
-            }
381
-            else {
382
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl();
383
-            }
384
-        }        
385
-        header('Location: ' . WT_BASE_URL . $redirection_url);
376
+		$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl();
377
+		if(!$success) {			
378
+			if($ga) {
379
+				$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl();
380
+			}
381
+			else {
382
+				$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl();
383
+			}
384
+		}        
385
+		header('Location: ' . WT_BASE_URL . $redirection_url);
386 386
         
387
-    }
387
+	}
388 388
      
389 389
 	/**
390 390
 	 * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one.
391 391
 	 * 
392 392
 	 * @param (GeoAnalysis!null) $ga GeoAnalysis to edit
393 393
 	 */
394
-    protected function renderEdit(GeoAnalysis $ga = null) {
395
-        global $WT_TREE;
394
+	protected function renderEdit(GeoAnalysis $ga = null) {
395
+		global $WT_TREE;
396 396
         
397
-        Theme::theme(new AdministrationTheme)->init($WT_TREE);
398
-        $controller = new PageController();        
399
-        $controller
400
-            ->restrictAccess(Auth::isManager($WT_TREE))
401
-            ->addInlineJavascript('
397
+		Theme::theme(new AdministrationTheme)->init($WT_TREE);
398
+		$controller = new PageController();        
399
+		$controller
400
+			->restrictAccess(Auth::isManager($WT_TREE))
401
+			->addInlineJavascript('
402 402
                 function toggleMapOptions() {
403 403
                     if($("input:radio[name=\'use_map\']:checked").val() == 1) {
404 404
                         $("#map_options").show();
@@ -412,34 +412,34 @@  discard block
 block discarded – undo
412 412
                 toggleMapOptions();
413 413
             ');
414 414
         
415
-        $data = new ViewBag();
416
-        if($ga) {
417
-            $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
418
-            $data->set('geo_analysis', $ga);
419
-        } else {
420
-            $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
421
-        }
415
+		$data = new ViewBag();
416
+		if($ga) {
417
+			$controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
418
+			$data->set('geo_analysis', $ga);
419
+		} else {
420
+			$controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
421
+		}
422 422
         
423
-        $data->set('title', $controller->getPageTitle());
424
-        $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl());
425
-        $data->set('module_title', $this->module->getTitle());
426
-        $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl());
427
-        $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
423
+		$data->set('title', $controller->getPageTitle());
424
+		$data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl());
425
+		$data->set('module_title', $this->module->getTitle());
426
+		$data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl());
427
+		$data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
428 428
     
429
-        $map_list = array_map(
430
-            function(OutlineMap $map) {
431
-                return $map->getDescription();
432
-            },
433
-            $this->provider->getOutlineMapsList()
434
-            );
435
-        asort($map_list);
436
-        $data->set('map_list', $map_list);
429
+		$map_list = array_map(
430
+			function(OutlineMap $map) {
431
+				return $map->getDescription();
432
+			},
433
+			$this->provider->getOutlineMapsList()
434
+			);
435
+		asort($map_list);
436
+		$data->set('map_list', $map_list);
437 437
     
438
-        $gen_details = array(0 => I18N::translate('All'));
439
-        for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
440
-        $data->set('generation_details', $gen_details);
438
+		$gen_details = array(0 => I18N::translate('All'));
439
+		for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
440
+		$data->set('generation_details', $gen_details);
441 441
     
442
-        ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
443
-    }
442
+		ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
443
+	}
444 444
     
445 445
 }
446 446
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/GeoAnalysisController.php 1 patch
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -35,47 +35,47 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class GeoAnalysisController extends MvcController
37 37
 {
38
-    /**
39
-     * GeoAnalysis Provider
40
-     * @var GeoAnalysisProvider $provider
41
-     */
42
-    protected $provider;
38
+	/**
39
+	 * GeoAnalysis Provider
40
+	 * @var GeoAnalysisProvider $provider
41
+	 */
42
+	protected $provider;
43 43
     
44
-    /**
45
-     * Constructor for GeoAnalysis controller
46
-     * @param AbstractModule $module
47
-     */
48
-    public function __construct(AbstractModule $module) {
49
-        parent::__construct($module);
44
+	/**
45
+	 * Constructor for GeoAnalysis controller
46
+	 * @param AbstractModule $module
47
+	 */
48
+	public function __construct(AbstractModule $module) {
49
+		parent::__construct($module);
50 50
         
51
-        $this->provider = $this->module->getProvider();
52
-    }    
51
+		$this->provider = $this->module->getProvider();
52
+	}    
53 53
     
54
-    /**
55
-     * Pages
56
-     */
54
+	/**
55
+	 * Pages
56
+	 */
57 57
         
58
-    /**
59
-     * GeoAnalysis@index
60
-     */
61
-    public function index() {
58
+	/**
59
+	 * GeoAnalysis@index
60
+	 */
61
+	public function index() {
62 62
         
63
-        $controller = new PageController();
64
-        $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion'));
63
+		$controller = new PageController();
64
+		$controller->setPageTitle(I18N::translate('Sosa Geographical dispersion'));
65 65
         
66
-        $data = new ViewBag();
67
-        $data->set('title', $controller->getPageTitle());
68
-        $data->set('has_analysis', false);
66
+		$data = new ViewBag();
67
+		$data->set('title', $controller->getPageTitle());
68
+		$data->set('has_analysis', false);
69 69
         
70
-        $ga_id = Filter::getInteger('ga_id');        
70
+		$ga_id = Filter::getInteger('ga_id');        
71 71
         
72
-        if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) {
73
-            $data->set('has_analysis', true);
74
-            $data->set('geoanalysis', $ga);
72
+		if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) {
73
+			$data->set('has_analysis', true);
74
+			$data->set('geoanalysis', $ga);
75 75
             
76
-            $controller
77
-                ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL())
78
-                ->addInlineJavascript('
76
+			$controller
77
+				->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL())
78
+				->addInlineJavascript('
79 79
                 jQuery("#geodispersion-tabs").tabs();
80 80
                 jQuery("#geodispersion-tabs").css("visibility", "visible");
81 81
                 
@@ -96,133 +96,133 @@  discard block
 block discarded – undo
96 96
 					"json"
97 97
 				);
98 98
             ');
99
-        }
99
+		}
100 100
         
101
-        ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render();
102
-    }
101
+		ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render();
102
+	}
103 103
     
104
-    /**
105
-     * GeoAnalysis@listAll
106
-     */
107
-    public function listAll() {
104
+	/**
105
+	 * GeoAnalysis@listAll
106
+	 */
107
+	public function listAll() {
108 108
         
109
-        $controller = new PageController();
110
-        $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion'));
109
+		$controller = new PageController();
110
+		$controller->setPageTitle(I18N::translate('Sosa Geographical dispersion'));
111 111
         
112
-        $data = new ViewBag();
113
-        $data->set('title', $controller->getPageTitle());
114
-        $data->set('has_list', false);
112
+		$data = new ViewBag();
113
+		$data->set('title', $controller->getPageTitle());
114
+		$data->set('has_list', false);
115 115
         
116
-        $ga_list = $this->provider->getGeoAnalysisList();
117
-        if(count($ga_list) > 0 ) {
118
-             $data->set('has_list', true);
119
-             $data->set('geoanalysislist', $ga_list);
120
-        }
116
+		$ga_list = $this->provider->getGeoAnalysisList();
117
+		if(count($ga_list) > 0 ) {
118
+			 $data->set('has_list', true);
119
+			 $data->set('geoanalysislist', $ga_list);
120
+		}
121 121
         
122
-        ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render();        
123
-    }
122
+		ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render();        
123
+	}
124 124
     	
125 125
 	/**
126 126
 	 * GeoAnalysis@setStatus
127 127
 	 */
128
-    public function setStatus() {  
129
-        global $WT_TREE;
128
+	public function setStatus() {  
129
+		global $WT_TREE;
130 130
         
131
-        $controller = new JsonController();
131
+		$controller = new JsonController();
132 132
         
133
-        $ga_id = Filter::getInteger('ga_id');
134
-        $ga = $this->provider->getGeoAnalysis($ga_id, false);
133
+		$ga_id = Filter::getInteger('ga_id');
134
+		$ga = $this->provider->getGeoAnalysis($ga_id, false);
135 135
         
136
-        $controller->restrictAccess(
137
-            true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
138
-            &&  Auth::isManager($WT_TREE) 
139
-            && $ga !== null
140
-        );
136
+		$controller->restrictAccess(
137
+			true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
138
+			&&  Auth::isManager($WT_TREE) 
139
+			&& $ga !== null
140
+		);
141 141
         
142
-        $status = Filter::getBool('status');
143
-        $res = array('geoanalysis' => $ga->getId() , 'error' => null);
144
-        try{
145
-            $this->provider->setGeoAnalysisStatus($ga, $status);
146
-            $res['status'] = $status;
142
+		$status = Filter::getBool('status');
143
+		$res = array('geoanalysis' => $ga->getId() , 'error' => null);
144
+		try{
145
+			$this->provider->setGeoAnalysisStatus($ga, $status);
146
+			$res['status'] = $status;
147 147
 			Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.');
148
-        }
149
-        catch (\Exception $ex) {
150
-            $res['error'] = $ex->getMessage();
148
+		}
149
+		catch (\Exception $ex) {
150
+			$res['error'] = $ex->getMessage();
151 151
 			Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage());
152
-        }
152
+		}
153 153
         
154
-        $controller->pageHeader();
155
-        if($res['error']) http_response_code(500);
154
+		$controller->pageHeader();
155
+		if($res['error']) http_response_code(500);
156 156
         
157
-        $controller->encode($res);
158
-    }
157
+		$controller->encode($res);
158
+	}
159 159
     
160 160
 	/**
161
-     * GeoAnalysis@delete
162
-     */
163
-    public function delete() {
164
-        global $WT_TREE;
161
+	 * GeoAnalysis@delete
162
+	 */
163
+	public function delete() {
164
+		global $WT_TREE;
165 165
     
166
-        $controller = new JsonController();
166
+		$controller = new JsonController();
167 167
     
168
-        $ga_id = Filter::getInteger('ga_id');
169
-        $ga = $this->provider->getGeoAnalysis($ga_id, false);
168
+		$ga_id = Filter::getInteger('ga_id');
169
+		$ga = $this->provider->getGeoAnalysis($ga_id, false);
170 170
     
171
-        $controller->restrictAccess(
172
-            true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
173
-            &&  Auth::isManager($WT_TREE)
174
-            && $ga
175
-            );
171
+		$controller->restrictAccess(
172
+			true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
173
+			&&  Auth::isManager($WT_TREE)
174
+			&& $ga
175
+			);
176 176
             
177
-        $res = array('geoanalysis' => $ga->getId() , 'error' => null);
178
-        try{
179
-            $this->provider->deleteGeoAnalysis($ga);
177
+		$res = array('geoanalysis' => $ga->getId() , 'error' => null);
178
+		try{
179
+			$this->provider->deleteGeoAnalysis($ga);
180 180
 			Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.');
181
-        }
182
-        catch (\Exception $ex) {
183
-            $res['error'] = $ex->getMessage();
181
+		}
182
+		catch (\Exception $ex) {
183
+			$res['error'] = $ex->getMessage();
184 184
 			Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage());
185
-        }
185
+		}
186 186
     
187
-        $controller->pageHeader();
188
-        if($res['error']) http_response_code(500);
187
+		$controller->pageHeader();
188
+		if($res['error']) http_response_code(500);
189 189
 
190
-        $controller->encode($res);
191
-    }
190
+		$controller->encode($res);
191
+	}
192 192
         	
193
-    /**
194
-     * GeoAnalysis@dataTabs
195
-     */
196
-    public function dataTabs() {
197
-        global $WT_TREE;
193
+	/**
194
+	 * GeoAnalysis@dataTabs
195
+	 */
196
+	public function dataTabs() {
197
+		global $WT_TREE;
198 198
         
199
-        $controller = new JsonController();
199
+		$controller = new JsonController();
200 200
         
201
-        $ga_id = Filter::getInteger('ga_id');
202
-        $ga = $this->provider->getGeoAnalysis($ga_id);
203
-        $sosa_provider = new SosaProvider($WT_TREE, Auth::user());
201
+		$ga_id = Filter::getInteger('ga_id');
202
+		$ga = $this->provider->getGeoAnalysis($ga_id);
203
+		$sosa_provider = new SosaProvider($WT_TREE, Auth::user());
204 204
         
205
-        $controller
206
-            ->restrictAccess($ga && $sosa_provider->isSetup())
207
-            ->pageHeader();
205
+		$controller
206
+			->restrictAccess($ga && $sosa_provider->isSetup())
207
+			->pageHeader();
208 208
         
209
-        $jsonArray = array();
209
+		$jsonArray = array();
210 210
         
211
-        list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations());
211
+		list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations());
212 212
         
213
-        $flags = array();
214
-        if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) {
215
-            $mapProvider = new GoogleMapsProvider();            
216
-            foreach($placesDispGeneral['places'] as $place => $count) {
217
-                $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE));
218
-            }
219
-        }
213
+		$flags = array();
214
+		if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) {
215
+			$mapProvider = new GoogleMapsProvider();            
216
+			foreach($placesDispGeneral['places'] as $place => $count) {
217
+				$flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE));
218
+			}
219
+		}
220 220
         
221
-        $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags);
222
-        $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags);
221
+		$jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags);
222
+		$jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags);
223 223
 
224
-        $controller->encode($jsonArray);
225
-    }
224
+		$controller->encode($jsonArray);
225
+	}
226 226
     
227 227
 	/**
228 228
 	 * Returns HTML code for the GeoAnalysis general tab (can be either a map or a table).
@@ -232,70 +232,70 @@  discard block
 block discarded – undo
232 232
 	 * @param (null|array) $flags Array of flags
233 233
 	 * @return string HTML code for the general tab
234 234
 	 */
235
-    protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) {
236
-        global $WT_TREE;
235
+	protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) {
236
+		global $WT_TREE;
237 237
         
238
-        if(!empty($placesGeneralResults)){
239
-            $data = new ViewBag();
238
+		if(!empty($placesGeneralResults)){
239
+			$data = new ViewBag();
240 240
             
241
-            $nb_found = $placesGeneralResults['knownsum'];
242
-            $nb_other = 0;
243
-            if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other'];
244
-            $nb_unknown = $placesGeneralResults['unknown'];
241
+			$nb_found = $placesGeneralResults['knownsum'];
242
+			$nb_other = 0;
243
+			if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other'];
244
+			$nb_unknown = $placesGeneralResults['unknown'];
245 245
             
246
-            $data->set('stats_gen_nb_found', $nb_found);
247
-            $data->set('stats_gen_nb_other', $nb_other);
248
-            $data->set('stats_gen_nb_unknown', $nb_unknown);
246
+			$data->set('stats_gen_nb_found', $nb_found);
247
+			$data->set('stats_gen_nb_other', $nb_other);
248
+			$data->set('stats_gen_nb_unknown', $nb_unknown);
249 249
             
250
-            $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags());
250
+			$data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags());
251 251
             
252
-            if($ga->hasMap()) {
253
-                $max = $placesGeneralResults['max'];
254
-                $map = $ga->getOptions()->getMap();
255
-                $results_by_subdivs = $map->getSubdivisions();
256
-                $places_mappings = $map->getPlacesMappings();
257
-                foreach ($placesGeneralResults['places'] as $location => $count) {
258
-                    $levelvalues = array_reverse(array_map('trim',explode(',', $location)));
259
-                    $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel();
260
-                    if($level_map >= 0 && $level_map < count($levelvalues)) {
261
-                        $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map];
262
-                        if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; }
263
-                    }
264
-                    else {
265
-                        $levelref = $levelvalues[0];
266
-                    }
267
-                    if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref];
268
-                    if(isset($results_by_subdivs[$levelref])) {
269
-                        $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0;
270
-                        $count_subd  += $count;
271
-                        $results_by_subdivs[$levelref]['count'] = $count_subd;   
272
-                        $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max);
273
-                        if($ga->getOptions()->isUsingFlags() && $flags) {
274
-                            $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE);
275
-                            $results_by_subdivs[$levelref]['flag'] = $flags[$location];
276
-                        }
277
-                    }
278
-                }             
252
+			if($ga->hasMap()) {
253
+				$max = $placesGeneralResults['max'];
254
+				$map = $ga->getOptions()->getMap();
255
+				$results_by_subdivs = $map->getSubdivisions();
256
+				$places_mappings = $map->getPlacesMappings();
257
+				foreach ($placesGeneralResults['places'] as $location => $count) {
258
+					$levelvalues = array_reverse(array_map('trim',explode(',', $location)));
259
+					$level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel();
260
+					if($level_map >= 0 && $level_map < count($levelvalues)) {
261
+						$levelref = $levelvalues[0] . '@' . $levelvalues[$level_map];
262
+						if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; }
263
+					}
264
+					else {
265
+						$levelref = $levelvalues[0];
266
+					}
267
+					if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref];
268
+					if(isset($results_by_subdivs[$levelref])) {
269
+						$count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0;
270
+						$count_subd  += $count;
271
+						$results_by_subdivs[$levelref]['count'] = $count_subd;   
272
+						$results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max);
273
+						if($ga->getOptions()->isUsingFlags() && $flags) {
274
+							$results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE);
275
+							$results_by_subdivs[$levelref]['flag'] = $flags[$location];
276
+						}
277
+					}
278
+				}             
279 279
                 
280
-                $data->set('map', $ga->getOptions()->getMap());
281
-                $data->set('results_by_subdivisions', $results_by_subdivs);
280
+				$data->set('map', $ga->getOptions()->getMap());
281
+				$data->set('results_by_subdivisions', $results_by_subdivs);
282 282
                 
283
-                $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial();
284
-            }
285
-            else {
286
-                $results = $placesGeneralResults['places'];
287
-                arsort($results);
288
-                $data->set('results', $results);
289
-                $data->set('analysis_level', $ga->getAnalysisLevel());
283
+				$html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial();
284
+			}
285
+			else {
286
+				$results = $placesGeneralResults['places'];
287
+				arsort($results);
288
+				$data->set('results', $results);
289
+				$data->set('analysis_level', $ga->getAnalysisLevel());
290 290
                 
291
-                $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial();
292
-            }
293
-        }
294
-        else {
295
-            $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>';
296
-        }
297
-        return $html;
298
-    }
291
+				$html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial();
292
+			}
293
+		}
294
+		else {
295
+			$html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>';
296
+		}
297
+		return $html;
298
+	}
299 299
     
300 300
 	/**
301 301
 	 * Returns HTML code for the GeoAnalysis generations tab.
@@ -305,68 +305,68 @@  discard block
 block discarded – undo
305 305
 	 * @param (null|array) $flags Array of flags
306 306
 	 * @return string HTML code for the generations tab
307 307
 	 */
308
-    protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) {
309
-        global $WT_TREE;
308
+	protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) {
309
+		global $WT_TREE;
310 310
         
311
-        if(!empty($placesGenerationsResults) && $ga->getOptions()){
312
-            $data = new ViewBag();
311
+		if(!empty($placesGenerationsResults) && $ga->getOptions()){
312
+			$data = new ViewBag();
313 313
             
314
-            ksort($placesGenerationsResults);
314
+			ksort($placesGenerationsResults);
315 315
             
316
-            $detailslevel = $ga->getOptions()->getMaxDetailsInGen();
317
-            $data->set('max_details_gen', $detailslevel);    
318
-            $data->set('use_flags', $ga->getOptions()->isUsingFlags());
319
-            $data->set('analysis_level', $ga->getAnalysisLevel());
320
-            $display_all_places = !is_null($detailslevel) && $detailslevel == 0;
321
-            $data->set('display_all_places', $display_all_places);
316
+			$detailslevel = $ga->getOptions()->getMaxDetailsInGen();
317
+			$data->set('max_details_gen', $detailslevel);    
318
+			$data->set('use_flags', $ga->getOptions()->isUsingFlags());
319
+			$data->set('analysis_level', $ga->getAnalysisLevel());
320
+			$display_all_places = !is_null($detailslevel) && $detailslevel == 0;
321
+			$data->set('display_all_places', $display_all_places);
322 322
             
323
-            $results_by_gen = array();
324
-            foreach($placesGenerationsResults as $gen => $genData){
325
-                $sum = 0;
326
-                $other = 0;
327
-                $unknown = 0;
328
-                if(isset($genData['sum'])) $sum = $genData['sum'];
329
-                if(isset($genData['other'])) $other = $genData['other'];
330
-                if(isset($genData['unknown'])) $unknown = $genData['unknown'];
323
+			$results_by_gen = array();
324
+			foreach($placesGenerationsResults as $gen => $genData){
325
+				$sum = 0;
326
+				$other = 0;
327
+				$unknown = 0;
328
+				if(isset($genData['sum'])) $sum = $genData['sum'];
329
+				if(isset($genData['other'])) $other = $genData['other'];
330
+				if(isset($genData['unknown'])) $unknown = $genData['unknown'];
331 331
                 
332
-                if($sum > 0) {                
333
-                    $results_by_gen[$gen]['sum'] = $sum;
334
-                    $results_by_gen[$gen]['other'] = $other;
335
-                    $results_by_gen[$gen]['unknown'] = $unknown;
336
-                    $results_by_gen[$gen]['places'] = array();                    
337
-                    arsort($genData['places']);
332
+				if($sum > 0) {                
333
+					$results_by_gen[$gen]['sum'] = $sum;
334
+					$results_by_gen[$gen]['other'] = $other;
335
+					$results_by_gen[$gen]['unknown'] = $unknown;
336
+					$results_by_gen[$gen]['places'] = array();                    
337
+					arsort($genData['places']);
338 338
                     
339
-                    if($display_all_places){
340
-                        foreach($genData['places'] as $placename=> $count){
341
-                            $results_by_gen[$gen]['places'][$placename]['count'] = $count;
339
+					if($display_all_places){
340
+						foreach($genData['places'] as $placename=> $count){
341
+							$results_by_gen[$gen]['places'][$placename]['count'] = $count;
342 342
                             
343
-                            if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){
344
-                                $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE);
345
-                                $results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
346
-                            }
347
-                        }
348
-                    }
349
-                    else {
350
-                        $tmp = $genData['places'];
351
-                        if($other > 0) {
352
-                            $tmp = array_slice($tmp, 0, 5, true);
353
-                            $tmp['other'] = $other;
354
-                            arsort($tmp);  
355
-                        }                      
356
-                        $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true);                        
357
-                    }
358
-                }
359
-            }
343
+							if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){
344
+								$results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE);
345
+								$results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
346
+							}
347
+						}
348
+					}
349
+					else {
350
+						$tmp = $genData['places'];
351
+						if($other > 0) {
352
+							$tmp = array_slice($tmp, 0, 5, true);
353
+							$tmp['other'] = $other;
354
+							arsort($tmp);  
355
+						}                      
356
+						$results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true);                        
357
+					}
358
+				}
359
+			}
360 360
             
361
-            $data->set('results_by_generations', $results_by_gen);
361
+			$data->set('results_by_generations', $results_by_gen);
362 362
             
363
-            $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial();
363
+			$html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial();
364 364
             
365
-        }
366
-        else {
367
-            $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
368
-        }
369
-        return $html;
370
-    }
365
+		}
366
+		else {
367
+			$html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
368
+		}
369
+		return $html;
370
+	}
371 371
         
372 372
 }
373 373
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/Certificates/CertificateController.php 1 patch
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -32,158 +32,158 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class CertificateController extends MvcController
34 34
 {
35
-    /**
36
-     * Certificate Provider
37
-     * @var CertificateProviderInterface $provider
38
-     */
39
-    protected $provider;
35
+	/**
36
+	 * Certificate Provider
37
+	 * @var CertificateProviderInterface $provider
38
+	 */
39
+	protected $provider;
40 40
     
41
-    /**
42
-     * Constructor for Certificate controller
43
-     * @param AbstractModule $module
44
-     */
45
-    public function __construct(AbstractModule $module) {
46
-        parent::__construct($module);
47
-        
48
-        $this->provider = $this->module->getProvider();
49
-    }
41
+	/**
42
+	 * Constructor for Certificate controller
43
+	 * @param AbstractModule $module
44
+	 */
45
+	public function __construct(AbstractModule $module) {
46
+		parent::__construct($module);
47
+        
48
+		$this->provider = $this->module->getProvider();
49
+	}
50 50
     
51 51
     
52
-    /**
53
-     * Pages
54
-     */
55
-        
56
-    /**
57
-     * Certificate@index
58
-     */
59
-    public function index() {
60
-        global $WT_TREE;
61
-        
62
-        $controller = new PageController();
63
-        $controller
64
-        ->setPageTitle(I18N::translate('Certificate'))
65
-        ->restrictAccess(
66
-            $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
67
-        );
68
-        
69
-        $cid = Filter::get('cid');
70
-        
71
-        $certificate = null;
72
-        if(!empty($cid) && strlen($cid) > 22){
73
-            $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
74
-        }
75
-        
76
-        $data = new ViewBag();
77
-        $data->set('title', $controller->getPageTitle());
78
-        
79
-        $data->set('has_certif', false);
80
-        if($certificate) {
81
-            $controller->restrictAccess($certificate->canShow());
82
-            $data->set('title', $certificate->getTitle());
83
-            $data->set('has_certif', true);
84
-            $data->set('certificate', $certificate);
52
+	/**
53
+	 * Pages
54
+	 */
55
+        
56
+	/**
57
+	 * Certificate@index
58
+	 */
59
+	public function index() {
60
+		global $WT_TREE;
61
+        
62
+		$controller = new PageController();
63
+		$controller
64
+		->setPageTitle(I18N::translate('Certificate'))
65
+		->restrictAccess(
66
+			$this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
67
+		);
68
+        
69
+		$cid = Filter::get('cid');
70
+        
71
+		$certificate = null;
72
+		if(!empty($cid) && strlen($cid) > 22){
73
+			$certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
74
+		}
75
+        
76
+		$data = new ViewBag();
77
+		$data->set('title', $controller->getPageTitle());
78
+        
79
+		$data->set('has_certif', false);
80
+		if($certificate) {
81
+			$controller->restrictAccess($certificate->canShow());
82
+			$data->set('title', $certificate->getTitle());
83
+			$data->set('has_certif', true);
84
+			$data->set('certificate', $certificate);
85 85
             
86
-            $data->set(
87
-                'url_certif_city', 
88
-                'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . 
89
-                    '&mod_action=Certificate@listAll' .
90
-                    '&ged=' . $WT_TREE->getNameUrl() .
91
-                    '&city=' . Functions::encryptToSafeBase64($certificate->getCity())
92
-            );
86
+			$data->set(
87
+				'url_certif_city', 
88
+				'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . 
89
+					'&mod_action=Certificate@listAll' .
90
+					'&ged=' . $WT_TREE->getNameUrl() .
91
+					'&city=' . Functions::encryptToSafeBase64($certificate->getCity())
92
+			);
93 93
             
94
-            $controller->addInlineJavascript('
94
+			$controller->addInlineJavascript('
95 95
                 jQuery("#certificate-tabs").tabs();
96 96
 			    jQuery("#certificate-tabs").css("visibility", "visible");    
97 97
             ');
98 98
             
99
-            $data->set('has_linked_indis', false);
100
-            $data->set('has_linked_fams', false);
99
+			$data->set('has_linked_indis', false);
100
+			$data->set('has_linked_fams', false);
101 101
             
102
-            $linked_indis = $certificate->linkedIndividuals();
103
-            $linked_fams = $certificate->linkedFamilies();
102
+			$linked_indis = $certificate->linkedIndividuals();
103
+			$linked_fams = $certificate->linkedFamilies();
104 104
                         
105
-            if($linked_indis && count($linked_indis) > 0) {
106
-                $data->set('has_linked_indis', true);
107
-                $data->set('linked_indis', $linked_indis);
108
-            }
105
+			if($linked_indis && count($linked_indis) > 0) {
106
+				$data->set('has_linked_indis', true);
107
+				$data->set('linked_indis', $linked_indis);
108
+			}
109 109
             
110
-            if(!empty($linked_fams)) {
111
-                $data->set('has_linked_fams', true);
112
-                $data->set('linked_fams', $linked_fams);
113
-            }
114
-        }
115
-        
116
-        ViewFactory::make('Certificate', $this, $controller, $data)->render();
117
-    }
110
+			if(!empty($linked_fams)) {
111
+				$data->set('has_linked_fams', true);
112
+				$data->set('linked_fams', $linked_fams);
113
+			}
114
+		}
115
+        
116
+		ViewFactory::make('Certificate', $this, $controller, $data)->render();
117
+	}
118 118
     
119
-    /**
120
-     * Certificate@image
121
-     */
122
-    public function image() {      
123
-        global $WT_TREE;
119
+	/**
120
+	 * Certificate@image
121
+	 */
122
+	public function image() {      
123
+		global $WT_TREE;
124 124
         
125
-        $cid   = Filter::get('cid');
126
-        $certificate = null;
127
-        if(!empty($cid)) $certificate =  Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
125
+		$cid   = Filter::get('cid');
126
+		$certificate = null;
127
+		if(!empty($cid)) $certificate =  Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
128 128
         
129
-        $imageBuilder = new ImageBuilder($certificate);
129
+		$imageBuilder = new ImageBuilder($certificate);
130 130
         
131
-        if (!empty(Filter::get('cb'))) {
132
-            $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7);
133
-        }
131
+		if (!empty(Filter::get('cb'))) {
132
+			$imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7);
133
+		}
134 134
         
135
-        $imageBuilder
136
-            ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE))
137
-            ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18))
138
-            ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3'))
139
-        ;
135
+		$imageBuilder
136
+			->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE))
137
+			->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18))
138
+			->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3'))
139
+		;
140 140
         
141
-        $imageBuilder->render();
141
+		$imageBuilder->render();
142 142
         
143
-    }
143
+	}
144 144
     
145
-    /**
146
-     * Certificate@listAll
147
-     */
148
-    public function listAll() {
149
-        global $WT_TREE;
150
-        
151
-        $controller = new PageController();
152
-        $controller
153
-            ->setPageTitle(I18N::translate('Certificates'))
154
-            ->restrictAccess(
155
-                $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
156
-            );
157
-        
158
-        $city = Filter::get('city');
159
-        
160
-        if(!empty($city) && strlen($city) > 22){
161
-            $city = Functions::decryptFromSafeBase64($city);
162
-            $controller->setPageTitle(I18N::translate('Certificates for %s', $city));
163
-        }
164
-        
165
-        $data = new ViewBag();
166
-        $data->set('title', $controller->getPageTitle());
167
-        $data->set('url_module', $this->module->getName());
168
-        $data->set('url_action', 'Certificate@listAll');
169
-        $data->set('url_ged', $WT_TREE->getNameUrl());
170
-        
171
-        $data->set('cities', $this->provider->getCitiesList());
172
-        $data->set('selected_city', $city);
173
-        
174
-        $data->set('has_list', false);        
175
-        if(!empty($city)) {            
176
-            $table_id = 'table-certiflist-' . Uuid::uuid4();
145
+	/**
146
+	 * Certificate@listAll
147
+	 */
148
+	public function listAll() {
149
+		global $WT_TREE;
150
+        
151
+		$controller = new PageController();
152
+		$controller
153
+			->setPageTitle(I18N::translate('Certificates'))
154
+			->restrictAccess(
155
+				$this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
156
+			);
157
+        
158
+		$city = Filter::get('city');
159
+        
160
+		if(!empty($city) && strlen($city) > 22){
161
+			$city = Functions::decryptFromSafeBase64($city);
162
+			$controller->setPageTitle(I18N::translate('Certificates for %s', $city));
163
+		}
164
+        
165
+		$data = new ViewBag();
166
+		$data->set('title', $controller->getPageTitle());
167
+		$data->set('url_module', $this->module->getName());
168
+		$data->set('url_action', 'Certificate@listAll');
169
+		$data->set('url_ged', $WT_TREE->getNameUrl());
170
+        
171
+		$data->set('cities', $this->provider->getCitiesList());
172
+		$data->set('selected_city', $city);
173
+        
174
+		$data->set('has_list', false);        
175
+		if(!empty($city)) {            
176
+			$table_id = 'table-certiflist-' . Uuid::uuid4();
177 177
             
178
-            $certif_list = $this->provider->getCertificatesList($city);            
179
-            if(!empty($certif_list)) {                
180
-                $data->set('has_list', true);
181
-                $data->set('table_id', $table_id);
182
-                $data->set('certificate_list', $certif_list);
178
+			$certif_list = $this->provider->getCertificatesList($city);            
179
+			if(!empty($certif_list)) {                
180
+				$data->set('has_list', true);
181
+				$data->set('table_id', $table_id);
182
+				$data->set('certificate_list', $certif_list);
183 183
                 
184
-                $controller
185
-                    ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
186
-                    ->addInlineJavascript('
184
+				$controller
185
+					->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
186
+					->addInlineJavascript('
187 187
                         /* Initialise datatables */
188 188
         				jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
189 189
         				jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
@@ -210,29 +210,29 @@  discard block
 block discarded – undo
210 210
         				jQuery(".certificate-list").css("visibility", "visible");
211 211
         				jQuery(".loading-image").css("display", "none");
212 212
                     ');
213
-            }
214
-        }
213
+			}
214
+		}
215 215
         
216
-        ViewFactory::make('CertificatesList', $this, $controller, $data)->render();
216
+		ViewFactory::make('CertificatesList', $this, $controller, $data)->render();
217 217
         
218
-    }
218
+	}
219 219
     
220
-    /**
221
-     * Certificate@autocomplete
222
-     */
223
-    public function autocomplete() {
224
-        global $WT_TREE;
220
+	/**
221
+	 * Certificate@autocomplete
222
+	 */
223
+	public function autocomplete() {
224
+		global $WT_TREE;
225 225
         
226
-        $controller = new JsonController();
226
+		$controller = new JsonController();
227 227
         
228
-        $city = Filter::get('city');
229
-        $contains = Filter::get('term');        
228
+		$city = Filter::get('city');
229
+		$contains = Filter::get('term');        
230 230
 
231
-        $controller
232
-            ->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains))
233
-            ->pageHeader();
231
+		$controller
232
+			->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains))
233
+			->pageHeader();
234 234
         
235
-        $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); 
236
-        $controller->encode($listCert);
237
-    }
235
+		$listCert = $this->provider->getCertificatesListBeginWith($city, $contains); 
236
+		$controller->encode($listCert);
237
+	}
238 238
 }
239 239
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/AdminConfigController.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -34,37 +34,37 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class AdminConfigController extends MvcController
36 36
 {    
37
-    /**
38
-     * Tasks Provider
39
-     * @var TaskProviderInterface $provider
40
-     */
41
-    protected $provider;    
37
+	/**
38
+	 * Tasks Provider
39
+	 * @var TaskProviderInterface $provider
40
+	 */
41
+	protected $provider;    
42 42
     
43
-    /**
44
-     * Constructor for Admin Config controller
45
-     * @param \Fisharebest\Webtrees\Module\AbstractModule $module
46
-     */
47
-    public function __construct(AbstractModule $module) {
48
-        parent::__construct($module);
43
+	/**
44
+	 * Constructor for Admin Config controller
45
+	 * @param \Fisharebest\Webtrees\Module\AbstractModule $module
46
+	 */
47
+	public function __construct(AbstractModule $module) {
48
+		parent::__construct($module);
49 49
         
50
-        $this->provider = $this->module->getProvider();
51
-    }    
50
+		$this->provider = $this->module->getProvider();
51
+	}    
52 52
     
53
-    /**
54
-     * Pages
55
-     */
53
+	/**
54
+	 * Pages
55
+	 */
56 56
         
57
-    /**
58
-     * AdminConfig@index
59
-     */
60
-    public function index() {
61
-        global $WT_TREE;
57
+	/**
58
+	 * AdminConfig@index
59
+	 */
60
+	public function index() {
61
+		global $WT_TREE;
62 62
         
63
-        Theme::theme(new AdministrationTheme)->init($WT_TREE);
64
-        $controller = new PageController();
65
-        $controller
66
-            ->restrictAccess(Auth::isAdmin())
67
-            ->setPageTitle($this->module->getTitle());
63
+		Theme::theme(new AdministrationTheme)->init($WT_TREE);
64
+		$controller = new PageController();
65
+		$controller
66
+			->restrictAccess(Auth::isAdmin())
67
+			->setPageTitle($this->module->getTitle());
68 68
 			
69 69
 		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
70 70
 		if(is_null($token)) {
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 			$this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token);
73 73
 		}
74 74
         
75
-        $data = new ViewBag();
76
-        $data->set('title', $controller->getPageTitle());
75
+		$data = new ViewBag();
76
+		$data->set('title', $controller->getPageTitle());
77 77
         
78
-        $table_id = 'table-admintasks-' . Uuid::uuid4();
79
-        $data->set('table_id', $table_id);
78
+		$table_id = 'table-admintasks-' . Uuid::uuid4();
79
+		$data->set('table_id', $table_id);
80 80
 		
81 81
 		$data->set('trigger_url_root', WT_BASE_URL.'module.php?mod='.$this->module->getName().'&mod_action=Task@trigger');
82 82
 		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 		$this->provider->getInstalledTasks();
90 90
 		
91 91
 		$controller
92
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
93
-            ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
94
-            ->addInlineJavascript('
92
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
93
+			->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
94
+			->addInlineJavascript('
95 95
                 //Datatable initialisation
96 96
 				jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
97 97
 				jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 				});
124 124
                 
125 125
                 ')
126
-                ->addInlineJavascript('					
126
+				->addInlineJavascript('					
127 127
 					function generate_force_token() {
128 128
 						jQuery("#bt_genforcetoken").attr("disabled", "disabled");
129 129
 						jQuery("#bt_tokentext").empty().html("<i class=\"fa fa-spinner fa-pulse fa-fw\"></i>");
@@ -171,56 +171,56 @@  discard block
 block discarded – undo
171 171
                     } 
172 172
                 ');
173 173
         
174
-        ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
175
-    }
174
+		ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
175
+	}
176 176
     
177
-    /**
178
-     * AdminConfig@jsonTasksList
179
-     */
180
-    public function jsonTasksList() {
181
-        global $WT_TREE;
177
+	/**
178
+	 * AdminConfig@jsonTasksList
179
+	 */
180
+	public function jsonTasksList() {
181
+		global $WT_TREE;
182 182
     
183
-        $controller = new JsonController();
184
-        $controller
185
-            ->restrictAccess(Auth::isAdmin());
183
+		$controller = new JsonController();
184
+		$controller
185
+			->restrictAccess(Auth::isAdmin());
186 186
     
187
-        // Generate an AJAX/JSON response for datatables to load a block of rows
188
-        $search = Filter::postArray('search');
189
-        if($search) $search = $search['value'];
190
-        $start  = Filter::postInteger('start');
191
-        $length = Filter::postInteger('length');
192
-        $order  = Filter::postArray('order');
187
+		// Generate an AJAX/JSON response for datatables to load a block of rows
188
+		$search = Filter::postArray('search');
189
+		if($search) $search = $search['value'];
190
+		$start  = Filter::postInteger('start');
191
+		$length = Filter::postInteger('length');
192
+		$order  = Filter::postArray('order');
193 193
     
194 194
 		$order_by_name = false;
195
-        foreach($order as $key => &$value) {
196
-            switch($value['column']) {
197
-                case 3:
195
+		foreach($order as $key => &$value) {
196
+			switch($value['column']) {
197
+				case 3:
198 198
 					$order_by_name = true;
199
-                    unset($order[$key]);
200
-                    break;
201
-                case 4;
199
+					unset($order[$key]);
200
+					break;
201
+				case 4;
202 202
 					$value['column'] = 'majat_last_run';
203 203
 					break;
204 204
 				case 4;
205 205
 					$value['column'] = 'majat_last_result';
206 206
 					break;
207
-                default:
208
-                    unset($order[$key]);
209
-            }
210
-        }
207
+				default:
208
+					unset($order[$key]);
209
+			}
210
+		}
211 211
     
212
-        $list = $this->provider->getFilteredTasksList($search, $order, $start, $length);
212
+		$list = $this->provider->getFilteredTasksList($search, $order, $start, $length);
213 213
 		if($order_by_name) {
214 214
 			usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); });
215 215
 		}
216
-        $recordsFiltered = count($list);
217
-        $recordsTotal = $this->provider->getTasksCount();
216
+		$recordsFiltered = count($list);
217
+		$recordsTotal = $this->provider->getTasksCount();
218 218
     
219
-        $data = array();
220
-        foreach($list as $task) {    
221
-            $datum = array();
219
+		$data = array();
220
+		foreach($list as $task) {    
221
+			$datum = array();
222 222
 			
223
-            $datum[0] = '
223
+			$datum[0] = '
224 224
                 <div class="btn-group">
225 225
                     <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
226 226
                         <i class="fa fa-pencil"></i><span class="caret"></span>
@@ -238,50 +238,50 @@  discard block
 block discarded – undo
238 238
                        </li>
239 239
                     </ul>
240 240
                 </div>';
241
-            $datum[1] = $task->getName();
242
-            $datum[2] = $task->isEnabled() ? 
241
+			$datum[1] = $task->getName();
242
+			$datum[2] = $task->isEnabled() ? 
243 243
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : 
244 244
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
245
-            $datum[3] = $task->getTitle();
246
-            $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s';
245
+			$datum[3] = $task->getTitle();
246
+			$date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s';
247 247
 			$datum[4] = $task->getLastUpdated()->format($date_format);
248
-            $datum[5] = $task->isLastRunSuccess() ? 
248
+			$datum[5] = $task->isLastRunSuccess() ? 
249 249
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : 
250 250
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
251
-            $dtF = new \DateTime('@0');
252
-            $dtT = new \DateTime('@' . ($task->getFrequency() * 60));            
253
-            $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m'));
251
+			$dtF = new \DateTime('@0');
252
+			$dtT = new \DateTime('@' . ($task->getFrequency() * 60));            
253
+			$datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m'));
254 254
 			$datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited');
255 255
 			$datum[8] = $task->isRunning() ? 
256 256
 				'<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : 
257 257
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>';
258 258
 			if($task->isEnabled() && !$task->isRunning()) {
259
-			    $datum[9] = '
259
+				$datum[9] = '
260 260
     			    <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')">
261 261
     			         <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div>
262 262
     			    </button>';
263 263
 			}
264 264
 			else {
265
-			    $datum[9] = '';
265
+				$datum[9] = '';
266 266
 			}			    
267 267
 						
268
-            $data[] = $datum;
269
-        }
268
+			$data[] = $datum;
269
+		}
270 270
     
271
-        $controller->pageHeader();
271
+		$controller->pageHeader();
272 272
     
273
-        $controller->encode(array(
274
-            'draw'            => Filter::getInteger('draw'),
275
-            'recordsTotal'    => $recordsTotal,
276
-            'recordsFiltered' => $recordsFiltered,
277
-            'data'            => $data
278
-        ));
273
+		$controller->encode(array(
274
+			'draw'            => Filter::getInteger('draw'),
275
+			'recordsTotal'    => $recordsTotal,
276
+			'recordsFiltered' => $recordsFiltered,
277
+			'data'            => $data
278
+		));
279 279
     
280
-    }
280
+	}
281 281
 		
282 282
 	/**
283 283
 	 * AdminConfig@generateToken
284
-     *
284
+	 *
285 285
 	 * Ajax call to generate a new token. Display the token, if generated.
286 286
 	 * Tokens call only be generated by a site administrator.
287 287
 	 *
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/TaskController.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -34,25 +34,25 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class TaskController extends MvcController
36 36
 {    
37
-    /**
38
-     * Tasks Provider
39
-     * @var TaskProviderInterface $provider
40
-     */
41
-    protected $provider;    
37
+	/**
38
+	 * Tasks Provider
39
+	 * @var TaskProviderInterface $provider
40
+	 */
41
+	protected $provider;    
42 42
     
43
-    /**
44
-     * Constructor for Admin Config controller
45
-     * @param AbstractModule $module
46
-     */
47
-    public function __construct(AbstractModule $module) {
48
-        parent::__construct($module);
43
+	/**
44
+	 * Constructor for Admin Config controller
45
+	 * @param AbstractModule $module
46
+	 */
47
+	public function __construct(AbstractModule $module) {
48
+		parent::__construct($module);
49 49
         
50
-        $this->provider = $this->module->getProvider();
51
-    }    
50
+		$this->provider = $this->module->getProvider();
51
+	}    
52 52
     
53
-    /**
54
-     * Pages
55
-     */        
53
+	/**
54
+	 * Pages
55
+	 */        
56 56
 	
57 57
 	/**
58 58
 	 * Task@trigger
@@ -76,35 +76,35 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	 * Task@setStatus
78 78
 	 */
79
-    public function setStatus() {          
80
-        $controller = new JsonController();
79
+	public function setStatus() {          
80
+		$controller = new JsonController();
81 81
         
82
-        $task_name = Filter::get('task');
83
-        $task = $this->provider->getTask($task_name, false);
82
+		$task_name = Filter::get('task');
83
+		$task = $this->provider->getTask($task_name, false);
84 84
         
85
-        $controller->restrictAccess(
86
-            true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
87
-            &&  Auth::isAdmin() 
88
-            && $task
89
-        );
85
+		$controller->restrictAccess(
86
+			true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
87
+			&&  Auth::isAdmin() 
88
+			&& $task
89
+		);
90 90
         
91
-        $status = Filter::getBool('status');
92
-        $res = array('task' => $task->getName() , 'error' => null);
93
-        try{
94
-            $this->provider->setTaskStatus($task, $status);
95
-            $res['status'] = $status;
91
+		$status = Filter::getBool('status');
92
+		$res = array('task' => $task->getName() , 'error' => null);
93
+		try{
94
+			$this->provider->setTaskStatus($task, $status);
95
+			$res['status'] = $status;
96 96
 			Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.');
97
-        }
98
-        catch (\Exception $ex) {
99
-            $res['error'] = $ex->getMessage();
97
+		}
98
+		catch (\Exception $ex) {
99
+			$res['error'] = $ex->getMessage();
100 100
 			Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage());
101
-        }
101
+		}
102 102
         
103
-        $controller->pageHeader();
104
-        if($res['error']) http_response_code(500);
103
+		$controller->pageHeader();
104
+		if($res['error']) http_response_code(500);
105 105
         
106
-        $controller->encode($res);
107
-    }
106
+		$controller->encode($res);
107
+	}
108 108
 	
109 109
 	/**
110 110
 	 * Task@edit
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 	public function edit() {
113 113
 		global $WT_TREE;
114 114
         		
115
-        $task_name = Filter::get('task');
116
-        $task = $this->provider->getTask($task_name, false);
115
+		$task_name = Filter::get('task');
116
+		$task = $this->provider->getTask($task_name, false);
117 117
 		
118
-        Theme::theme(new AdministrationTheme)->init($WT_TREE);
119
-        $controller = new PageController();        
120
-        $controller
121
-            ->restrictAccess(Auth::isAdmin() && $task)
118
+		Theme::theme(new AdministrationTheme)->init($WT_TREE);
119
+		$controller = new PageController();        
120
+		$controller
121
+			->restrictAccess(Auth::isAdmin() && $task)
122 122
 			->setPageTitle(I18N::translate('Edit the administrative task'))
123
-            ->addInlineJavascript('
123
+			->addInlineJavascript('
124 124
                 function toggleRemainingOccurrences() {
125 125
                     if($("input:radio[name=\'is_limited\']:checked").val() == 1) {
126 126
                         $("#nb_occurences").show();
@@ -133,39 +133,39 @@  discard block
 block discarded – undo
133 133
                 $("[name=\'is_limited\']").on("change", toggleRemainingOccurrences);
134 134
                 toggleRemainingOccurrences();
135 135
             ')
136
-        ;
136
+		;
137 137
         
138 138
         
139
-        $data = new ViewBag();        
140
-        $data->set('title', $controller->getPageTitle());
139
+		$data = new ViewBag();        
140
+		$data->set('title', $controller->getPageTitle());
141 141
 		$data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl());
142
-        $data->set('module_title', $this->module->getTitle());
142
+		$data->set('module_title', $this->module->getTitle());
143 143
 		$data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $WT_TREE->getNameUrl());
144 144
 		$data->set('task', $task);
145 145
 		    
146
-        ViewFactory::make('TaskEdit', $this, $controller, $data)->render();	
146
+		ViewFactory::make('TaskEdit', $this, $controller, $data)->render();	
147 147
 	}	
148 148
 	
149 149
 	/**
150 150
 	 * Task@save
151 151
 	 */
152 152
 	public function save() {		
153
-        $tmp_contrl = new PageController();
153
+		$tmp_contrl = new PageController();
154 154
 				
155
-        $tmp_contrl->restrictAccess(
156
-            Auth::isAdmin() 
157
-            && Filter::checkCsrf()
158
-         );
155
+		$tmp_contrl->restrictAccess(
156
+			Auth::isAdmin() 
157
+			&& Filter::checkCsrf()
158
+		 );
159 159
         
160 160
 		$task_name      = Filter::post('task');
161
-        $frequency    	= Filter::postInteger('frequency');
162
-        $is_limited  	= Filter::postInteger('is_limited', 0, 1);
163
-        $nb_occur       = Filter::postInteger('nb_occur');
161
+		$frequency    	= Filter::postInteger('frequency');
162
+		$is_limited  	= Filter::postInteger('is_limited', 0, 1);
163
+		$nb_occur       = Filter::postInteger('nb_occur');
164 164
 				
165 165
 		$task = $this->provider->getTask($task_name, false);
166 166
         
167
-        $success = false; 
168
-        if($task) {
167
+		$success = false; 
168
+		if($task) {
169 169
 			$task->setFrequency($frequency);
170 170
 			if($is_limited == 1) {
171 171
 				$task->setRemainingOccurrences($nb_occur);
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 				Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.');
198 198
 			}
199 199
 			
200
-        }
200
+		}
201 201
         
202
-        $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig';
203
-        if(!$success) {
202
+		$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig';
203
+		if(!$success) {
204 204
 			$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task='. $task->getName();
205
-        }        
206
-        header('Location: ' . WT_BASE_URL . $redirection_url);
205
+		}        
206
+		header('Location: ' . WT_BASE_URL . $redirection_url);
207 207
 	}
208 208
      
209 209
 }
210 210
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/WelcomeBlock/WelcomeBlockController.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
 class WelcomeBlockController extends MvcController
30 30
 {   
31 31
     
32
-    /**
33
-     * Pages
34
-     */
32
+	/**
33
+	 * Pages
34
+	 */
35 35
         
36
-    /**
37
-     * WelcomeBlock@index
38
-     * 
39
-     * @param PageController $parent_controller
40
-     * @param Tree $tree
41
-     * @param string $block_id
42
-     * @param string $template
43
-     * @return $string
44
-     */
45
-    public function index(PageController $parent_controller, Tree $tree, $block_id, $template) {        
46
-        $view_bag = new ViewBag();
36
+	/**
37
+	 * WelcomeBlock@index
38
+	 * 
39
+	 * @param PageController $parent_controller
40
+	 * @param Tree $tree
41
+	 * @param string $block_id
42
+	 * @param string $template
43
+	 * @return $string
44
+	 */
45
+	public function index(PageController $parent_controller, Tree $tree, $block_id, $template) {        
46
+		$view_bag = new ViewBag();
47 47
         
48
-        if($parent_controller && $tree) {
48
+		if($parent_controller && $tree) {
49 49
         
50
-            $view_bag->set('tree', $tree);
51
-            $view_bag->set('indi', $parent_controller->getSignificantIndividual());
50
+			$view_bag->set('tree', $tree);
51
+			$view_bag->set('indi', $parent_controller->getSignificantIndividual());
52 52
         
53
-            $id = $this->module->getName().$block_id;
54
-            $class = $this->module->getName().'_block';
55
-            $parent_controller->addInlineJavascript('
53
+			$id = $this->module->getName().$block_id;
54
+			$class = $this->module->getName().'_block';
55
+			$parent_controller->addInlineJavascript('
56 56
                 jQuery("#maj-new_passwd").hide();
57 57
                 jQuery("#maj-passwd_click").click(function()
58 58
                 {
@@ -63,63 +63,63 @@  discard block
 block discarded – undo
63 63
     				  });
64 64
     			');
65 65
     
66
-            if (Auth::isAdmin()) {
67
-                $title='<a class="icon-admin" title="'.I18N::translate('Configure').'" href="block_edit.php?block_id='.$block_id.'&amp;ged=' . $tree->getNameHtml() . '&amp;ctype=gedcom"></a>';
68
-            } else {
69
-                $title='';
70
-            }
71
-            $title .='<span dir="auto">'.$tree->getTitleHtml().'</span>';
66
+			if (Auth::isAdmin()) {
67
+				$title='<a class="icon-admin" title="'.I18N::translate('Configure').'" href="block_edit.php?block_id='.$block_id.'&amp;ged=' . $tree->getNameHtml() . '&amp;ctype=gedcom"></a>';
68
+			} else {
69
+				$title='';
70
+			}
71
+			$title .='<span dir="auto">'.$tree->getTitleHtml().'</span>';
72 72
     
73
-            $piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false);
74
-            $view_bag->set('piwik_enabled', $piwik_enabled);
75
-            if($piwik_enabled) {
76
-                $parent_controller->addInlineJavascript(
77
-                    '$("#piwik_stats")
73
+			$piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false);
74
+			$view_bag->set('piwik_enabled', $piwik_enabled);
75
+			if($piwik_enabled) {
76
+				$parent_controller->addInlineJavascript(
77
+					'$("#piwik_stats")
78 78
                         .load("module.php?mod='.$this->module->getName().'&mod_action=Piwik&block_id='.$block_id.'");'
79
-                );
80
-            }
79
+				);
80
+			}
81 81
     
82
-            $content = ViewFactory::make('WelcomeBlock', $this,  new BaseController(), $view_bag)->getHtmlPartial();   
82
+			$content = ViewFactory::make('WelcomeBlock', $this,  new BaseController(), $view_bag)->getHtmlPartial();   
83 83
             
84
-            if ($template) {
85
-                return Theme::theme()->formatBlock($id, $title, $class, $content);
86
-            } else {
87
-                return $content;
88
-            }
89
-        }
90
-    }
84
+			if ($template) {
85
+				return Theme::theme()->formatBlock($id, $title, $class, $content);
86
+			} else {
87
+				return $content;
88
+			}
89
+		}
90
+	}
91 91
     
92 92
     
93 93
     
94
-    /**
95
-     * WelcomeBlock@config
96
-     * 
97
-     * @param string $block_id
98
-     */
99
-    public function config($block_id) {
94
+	/**
95
+	 * WelcomeBlock@config
96
+	 * 
97
+	 * @param string $block_id
98
+	 */
99
+	public function config($block_id) {
100 100
 
101
-        if (Filter::postBool('save') && Filter::checkCsrf()) {
102
-            $this->module->setBlockSetting($block_id, 'piwik_enabled', Filter::postBool('piwik_enabled'));
103
-            $this->module->setBlockSetting($block_id, 'piwik_url', trim(Filter::postUrl('piwik_url')));
104
-            $this->module->setBlockSetting($block_id, 'piwik_siteid', trim(Filter::post('piwik_siteid')));
105
-            $this->module->setBlockSetting($block_id, 'piwik_token', trim(Filter::post('piwik_token'))); 
106
-            Cache::delete('piwikCountYear', $this->module);          
107
-            throw new MvcException(200); // Use this instead of exit
108
-        }
101
+		if (Filter::postBool('save') && Filter::checkCsrf()) {
102
+			$this->module->setBlockSetting($block_id, 'piwik_enabled', Filter::postBool('piwik_enabled'));
103
+			$this->module->setBlockSetting($block_id, 'piwik_url', trim(Filter::postUrl('piwik_url')));
104
+			$this->module->setBlockSetting($block_id, 'piwik_siteid', trim(Filter::post('piwik_siteid')));
105
+			$this->module->setBlockSetting($block_id, 'piwik_token', trim(Filter::post('piwik_token'))); 
106
+			Cache::delete('piwikCountYear', $this->module);          
107
+			throw new MvcException(200); // Use this instead of exit
108
+		}
109 109
         
110
-        $view_bag = new ViewBag();
110
+		$view_bag = new ViewBag();
111 111
         
112
-        // Is Piwik Statistic Enabled ?
113
-        $view_bag->set('piwik_enabled', $this->module->getBlockSetting($block_id, 'piwik_enabled', '0'));
114
-        //Piwik Root Url
115
-        $view_bag->set('piwik_url', $this->module->getBlockSetting($block_id, 'piwik_url', ''));
116
-        // Piwik token
117
-        $view_bag->set('piwik_token', $this->module->getBlockSetting($block_id, 'piwik_token', ''));
118
-        // Piwik side id
119
-        $view_bag->set('piwik_siteid', $this->module->getBlockSetting($block_id, 'piwik_siteid', ''));
112
+		// Is Piwik Statistic Enabled ?
113
+		$view_bag->set('piwik_enabled', $this->module->getBlockSetting($block_id, 'piwik_enabled', '0'));
114
+		//Piwik Root Url
115
+		$view_bag->set('piwik_url', $this->module->getBlockSetting($block_id, 'piwik_url', ''));
116
+		// Piwik token
117
+		$view_bag->set('piwik_token', $this->module->getBlockSetting($block_id, 'piwik_token', ''));
118
+		// Piwik side id
119
+		$view_bag->set('piwik_siteid', $this->module->getBlockSetting($block_id, 'piwik_siteid', ''));
120 120
         
121
-        ViewFactory::make('WelcomeBlockConfig', $this, new BaseController(), $view_bag)->renderPartial();
122
-    }
121
+		ViewFactory::make('WelcomeBlockConfig', $this, new BaseController(), $view_bag)->renderPartial();
122
+	}
123 123
     
124 124
     
125 125
     
Please login to merge, or discard this patch.
src/Webtrees/Module/WelcomeBlock/PiwikController.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -23,74 +23,74 @@
 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
-                Cache::save($cached_item, $visitCountYear);
81
-            }
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
+				Cache::save($cached_item, $visitCountYear);
81
+			}
82 82
             
83
-            if($visitCountYear){
84
-                $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day'));
85
-                $visitCountYear = max( 0, $visitCountYear);
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
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,17 +72,17 @@  discard block
 block discarded – undo
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 80
                 Cache::save($cached_item, $visitCountYear);
81 81
             }
82 82
             
83
-            if($visitCountYear){
83
+            if ($visitCountYear) {
84 84
                 $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day'));
85
-                $visitCountYear = max( 0, $visitCountYear);
85
+                $visitCountYear = max(0, $visitCountYear);
86 86
                 
87 87
                 $data->set('has_stats', true);
88 88
                 $data->set('visits_today', $visitCountToday);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,9 @@
 block discarded – undo
50 50
         
51 51
             if($fetched = File::fetchUrl($url)) {
52 52
                 $content = @unserialize($fetched);
53
-                if(is_numeric($content)) return $content;
53
+                if(is_numeric($content)) {
54
+                	return $content;
55
+                }
54 56
             }
55 57
         }
56 58
     
Please login to merge, or discard this patch.