Completed
Push — develop ( dd48c1...053968 )
by Maxim
06:38 queued 01:16
created
manager/includes/extenders/deprecated.functions.inc.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function getUserData() {
41 41
         $client['ip'] = $_SERVER['REMOTE_ADDR'];
42 42
         $client['ua'] = $_SERVER['HTTP_USER_AGENT'];
43
-    	return $client;
43
+        return $client;
44 44
     }
45 45
 
46 46
     # Returns true, install or interact when inside manager
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 
61 61
     // deprecated
62 62
     public function putChunk($chunkName) { // alias name >.<
63
-    	global $modx;
63
+        global $modx;
64 64
         return $modx->getChunk($chunkName);
65 65
     }
66 66
 
67 67
     public function getDocGroups() {
68
-    	global $modx;
68
+        global $modx;
69 69
         return $modx->getUserDocGroups();
70 70
     } // deprecated
71 71
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     } // deprecated
75 75
 
76 76
     public function userLoggedIn() {
77
-    	global $modx;
77
+        global $modx;
78 78
         $userdetails= array ();
79 79
         if ($modx->isFrontend() && isset ($_SESSION['webValidated'])) {
80 80
             // web user
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
     public function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) {
100 100
         //  function to retrieve form results into an associative array
101
-    	global $modx;
101
+        global $modx;
102 102
         $results= array ();
103 103
         $method= strtoupper($method);
104 104
         if ($method == "")
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      * @param string $url URL to redirect to
131 131
      */
132 132
     public function webAlert($msg, $url= "") {
133
-    	global $modx;
133
+        global $modx;
134 134
         $msg= addslashes($modx->db->escape($msg));
135 135
         if (substr(strtolower($url), 0, 11) == "javascript:") {
136 136
             $act= "__WebAlert();";
Please login to merge, or discard this patch.
manager/includes/extenders/export.class.inc.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class EXPORT_SITE
3 3
 {
4
-	public $targetDir;
4
+    public $targetDir;
5 5
     public $generate_mode;
6 6
     public $total;
7 7
     public $count;
@@ -13,246 +13,246 @@  discard block
 block discarded – undo
13 13
     public $dirCheckCount = 0;
14 14
 
15 15
     public function __construct()
16
-	{
17
-		global $modx;
18
-
19
-		if(!defined('MODX_BASE_PATH'))  return false;
20
-		$this->exportstart = $this->get_mtime();
21
-		$this->count = 0;
22
-		$this->setUrlMode();
23
-		$this->generate_mode = 'crawl';
24
-		$this->targetDir = $modx->config['base_path'] . 'temp/export';
25
-		if(!isset($this->total)) $this->getTotal();
26
-	}
16
+    {
17
+        global $modx;
18
+
19
+        if(!defined('MODX_BASE_PATH'))  return false;
20
+        $this->exportstart = $this->get_mtime();
21
+        $this->count = 0;
22
+        $this->setUrlMode();
23
+        $this->generate_mode = 'crawl';
24
+        $this->targetDir = $modx->config['base_path'] . 'temp/export';
25
+        if(!isset($this->total)) $this->getTotal();
26
+    }
27 27
 
28 28
     public function setExportDir($dir)
29
-	{
30
-		$dir = str_replace('\\','/',$dir);
31
-		$dir = rtrim($dir, '/');
32
-		$this->targetDir = $dir;
33
-	}
29
+    {
30
+        $dir = str_replace('\\','/',$dir);
31
+        $dir = rtrim($dir, '/');
32
+        $this->targetDir = $dir;
33
+    }
34 34
 
35 35
     public function get_mtime()
36
-	{
37
-		$mtime = microtime();
38
-		$mtime = explode(' ', $mtime);
39
-		$mtime = $mtime[1] + $mtime[0];
40
-		return $mtime;
41
-	}
36
+    {
37
+        $mtime = microtime();
38
+        $mtime = explode(' ', $mtime);
39
+        $mtime = $mtime[1] + $mtime[0];
40
+        return $mtime;
41
+    }
42 42
 
43 43
     public function setUrlMode()
44
-	{
45
-		global $modx;
46
-
47
-		if($modx->config['friendly_urls']==0)
48
-		{
49
-			$modx->config['friendly_urls']  = 1;
50
-			$modx->config['use_alias_path'] = 1;
51
-			$modx->clearCache('full');
52
-		}
53
-		$modx->config['make_folders'] = '1';
54
-	}
44
+    {
45
+        global $modx;
46
+
47
+        if($modx->config['friendly_urls']==0)
48
+        {
49
+            $modx->config['friendly_urls']  = 1;
50
+            $modx->config['use_alias_path'] = 1;
51
+            $modx->clearCache('full');
52
+        }
53
+        $modx->config['make_folders'] = '1';
54
+    }
55 55
 
56 56
     public function getTotal($ignore_ids='', $noncache='0')
57
-	{
58
-		global $modx;
59
-		$tbl_site_content = $modx->getFullTableName('site_content');
60
-
61
-		$ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
-		if(count($ignore_ids)>0)
63
-		{
64
-			$ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65
-		} else {
66
-			$ignore_ids = '';
67
-		}
68
-
69
-		$this->ignore_ids = $ignore_ids;
70
-
71
-		$noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
72
-		$where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
73
-		$rs  = $modx->db->select('count(id)',$tbl_site_content,$where);
74
-		$this->total = $modx->db->getValue($rs);
75
-		return $this->total;
76
-	}
57
+    {
58
+        global $modx;
59
+        $tbl_site_content = $modx->getFullTableName('site_content');
60
+
61
+        $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
+        if(count($ignore_ids)>0)
63
+        {
64
+            $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65
+        } else {
66
+            $ignore_ids = '';
67
+        }
68
+
69
+        $this->ignore_ids = $ignore_ids;
70
+
71
+        $noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
72
+        $where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
73
+        $rs  = $modx->db->select('count(id)',$tbl_site_content,$where);
74
+        $this->total = $modx->db->getValue($rs);
75
+        return $this->total;
76
+    }
77 77
 
78 78
     public function removeDirectoryAll($directory='')
79
-	{
80
-	    $rs = false;
81
-		if(empty($directory)) $directory = $this->targetDir;
82
-		$directory = rtrim($directory,'/');
83
-		// if the path is not valid or is not a directory ...
84
-		if(empty($directory)) return false;
85
-		if(strpos($directory,MODX_BASE_PATH)===false) return $rs;
86
-
87
-		if(!is_dir($directory))          return $rs;
88
-		elseif(!is_readable($directory)) return $rs;
89
-		else
90
-		{
91
-			$files = glob($directory . '/*');
92
-			if(!empty($files))
93
-			{
94
-    			foreach($files as $path)
95
-    			{
79
+    {
80
+        $rs = false;
81
+        if(empty($directory)) $directory = $this->targetDir;
82
+        $directory = rtrim($directory,'/');
83
+        // if the path is not valid or is not a directory ...
84
+        if(empty($directory)) return false;
85
+        if(strpos($directory,MODX_BASE_PATH)===false) return $rs;
86
+
87
+        if(!is_dir($directory))          return $rs;
88
+        elseif(!is_readable($directory)) return $rs;
89
+        else
90
+        {
91
+            $files = glob($directory . '/*');
92
+            if(!empty($files))
93
+            {
94
+                foreach($files as $path)
95
+                {
96 96
                     $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path);
97
-    			}
98
-			}
99
-		}
100
-		if($directory !== $this->targetDir) $rs = rmdir($directory);
97
+                }
98
+            }
99
+        }
100
+        if($directory !== $this->targetDir) $rs = rmdir($directory);
101 101
 
102
-		return $rs;
103
-	}
102
+        return $rs;
103
+    }
104 104
 
105 105
     public function makeFile($docid, $filepath)
106
-	{
107
-		global  $modx,$_lang;
108
-		$file_permission = octdec($modx->config['new_file_permissions']);
109
-		if($this->generate_mode==='direct')
110
-		{
111
-			$back_lang = $_lang;
112
-			$src = $modx->executeParser($docid);
113
-
114
-			$_lang = $back_lang;
115
-		}
116
-		else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
117
-
118
-
119
-		if($src !== false)
120
-		{
121
-			if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
122
-			$result = file_put_contents($filepath,$src);
123
-			if($result!==false) @chmod($filepath, $file_permission);
124
-
125
-			if($result !== false) return 'success';
126
-			else                  return 'failed_no_write';
127
-		}
128
-		else                      return 'failed_no_retrieve';
129
-	}
106
+    {
107
+        global  $modx,$_lang;
108
+        $file_permission = octdec($modx->config['new_file_permissions']);
109
+        if($this->generate_mode==='direct')
110
+        {
111
+            $back_lang = $_lang;
112
+            $src = $modx->executeParser($docid);
113
+
114
+            $_lang = $back_lang;
115
+        }
116
+        else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
117
+
118
+
119
+        if($src !== false)
120
+        {
121
+            if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
122
+            $result = file_put_contents($filepath,$src);
123
+            if($result!==false) @chmod($filepath, $file_permission);
124
+
125
+            if($result !== false) return 'success';
126
+            else                  return 'failed_no_write';
127
+        }
128
+        else                      return 'failed_no_retrieve';
129
+    }
130 130
 
131 131
     public function getFileName($docid, $alias='', $prefix, $suffix)
132
-	{
133
-		global $modx;
134
-
135
-		if($alias==='') $filename = $prefix.$docid.$suffix;
136
-		else
137
-		{
138
-			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
139
-			{
140
-				$suffix = '';
141
-			}
142
-			$filename = $prefix.$alias.$suffix;
143
-		}
144
-		return $filename;
145
-	}
132
+    {
133
+        global $modx;
134
+
135
+        if($alias==='') $filename = $prefix.$docid.$suffix;
136
+        else
137
+        {
138
+            if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
139
+            {
140
+                $suffix = '';
141
+            }
142
+            $filename = $prefix.$alias.$suffix;
143
+        }
144
+        return $filename;
145
+    }
146 146
 
147 147
     public function run($parent=0)
148
-	{
149
-		global $_lang;
150
-		global $modx;
148
+    {
149
+        global $_lang;
150
+        global $modx;
151 151
 
152
-		$tbl_site_content = $modx->getFullTableName('site_content');
152
+        $tbl_site_content = $modx->getFullTableName('site_content');
153 153
 
154
-		$ignore_ids = $this->ignore_ids;
155
-		$dirpath = $this->targetDir . '/';
154
+        $ignore_ids = $this->ignore_ids;
155
+        $dirpath = $this->targetDir . '/';
156 156
 
157
-		$prefix = $modx->config['friendly_url_prefix'];
158
-		$suffix = $modx->config['friendly_url_suffix'];
157
+        $prefix = $modx->config['friendly_url_prefix'];
158
+        $suffix = $modx->config['friendly_url_suffix'];
159 159
 
160
-		$tpl = ' <span class="[+status+]">[+msg1+]</span> [+msg2+]</span>';
161
-		$ph = array();
160
+        $tpl = ' <span class="[+status+]">[+msg1+]</span> [+msg2+]</span>';
161
+        $ph = array();
162 162
 
163
-		$ph['status'] = 'fail';
164
-		$ph['msg1']   = $_lang['export_site_failed'];
165
-		$ph['msg2']   = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
166
-		$msg_failed_no_write    = $this->parsePlaceholder($tpl,$ph);
163
+        $ph['status'] = 'fail';
164
+        $ph['msg1']   = $_lang['export_site_failed'];
165
+        $ph['msg2']   = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
166
+        $msg_failed_no_write    = $this->parsePlaceholder($tpl,$ph);
167 167
 
168
-		$ph['msg2']   = $_lang["export_site_failed_no_retrieve"];
169
-		$msg_failed_no_retrieve = $this->parsePlaceholder($tpl,$ph);
168
+        $ph['msg2']   = $_lang["export_site_failed_no_retrieve"];
169
+        $msg_failed_no_retrieve = $this->parsePlaceholder($tpl,$ph);
170 170
 
171
-		$ph['status'] = 'success';
172
-		$ph['msg1']   = $_lang['export_site_success'];
173
-		$ph['msg2']   = '';
174
-		$msg_success            = $this->parsePlaceholder($tpl,$ph);
171
+        $ph['status'] = 'success';
172
+        $ph['msg1']   = $_lang['export_site_success'];
173
+        $ph['msg2']   = '';
174
+        $msg_success            = $this->parsePlaceholder($tpl,$ph);
175 175
 
176
-		$ph['msg2']   = $_lang['export_site_success_skip_doc'];
177
-		$msg_success_skip_doc = $this->parsePlaceholder($tpl,$ph);
176
+        $ph['msg2']   = $_lang['export_site_success_skip_doc'];
177
+        $msg_success_skip_doc = $this->parsePlaceholder($tpl,$ph);
178 178
 
179
-		$ph['msg2']   = $_lang['export_site_success_skip_dir'];
180
-		$msg_success_skip_dir = $this->parsePlaceholder($tpl,$ph);
179
+        $ph['msg2']   = $_lang['export_site_success_skip_dir'];
180
+        $msg_success_skip_dir = $this->parsePlaceholder($tpl,$ph);
181 181
 
182
-		$fields = "id, alias, pagetitle, isfolder, (content = '' AND template = 0) AS wasNull, published";
183
-		$noncache = $_POST['includenoncache']==1 ? '' : 'AND cacheable=1';
184
-		$where = "parent = '{$parent}' AND deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
185
-		$rs = $modx->db->select($fields,$tbl_site_content,$where);
182
+        $fields = "id, alias, pagetitle, isfolder, (content = '' AND template = 0) AS wasNull, published";
183
+        $noncache = $_POST['includenoncache']==1 ? '' : 'AND cacheable=1';
184
+        $where = "parent = '{$parent}' AND deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
185
+        $rs = $modx->db->select($fields,$tbl_site_content,$where);
186 186
 
187
-		$ph = array();
188
-		$ph['total']     = $this->total;
189
-		$folder_permission = octdec($modx->config['new_folder_permissions']);
190
-		while($row = $modx->db->getRow($rs))
191
-		{
192
-			$this->count++;
187
+        $ph = array();
188
+        $ph['total']     = $this->total;
189
+        $folder_permission = octdec($modx->config['new_folder_permissions']);
190
+        while($row = $modx->db->getRow($rs))
191
+        {
192
+            $this->count++;
193 193
             $filename = '';
194
-			$row['count']     = $this->count;
195
-			$row['url'] = $modx->makeUrl($row['id']);
196
-
197
-			if (!$row['wasNull'])
198
-			{ // needs writing a document
199
-				$docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
200
-				$filename = $dirpath.$docname;
201
-				if (!is_file($filename))
202
-				{
203
-					if($row['published']==='1')
204
-					{
205
-						$status = $this->makeFile($row['id'], $filename);
206
-						switch($status)
207
-						{
208
-							case 'failed_no_write'   :
194
+            $row['count']     = $this->count;
195
+            $row['url'] = $modx->makeUrl($row['id']);
196
+
197
+            if (!$row['wasNull'])
198
+            { // needs writing a document
199
+                $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
200
+                $filename = $dirpath.$docname;
201
+                if (!is_file($filename))
202
+                {
203
+                    if($row['published']==='1')
204
+                    {
205
+                        $status = $this->makeFile($row['id'], $filename);
206
+                        switch($status)
207
+                        {
208
+                            case 'failed_no_write'   :
209 209
                                                             $row['status'] = $msg_failed_no_write;
210 210
                                                             break;
211
-							case 'failed_no_retrieve':
211
+                            case 'failed_no_retrieve':
212 212
                                                             $row['status'] = $msg_failed_no_retrieve;
213 213
                                                             break;
214
-							default:
214
+                            default:
215 215
                                                             $row['status'] = $msg_success;
216
-						}
217
-					}
218
-					else $row['status'] = $msg_failed_no_retrieve;
219
-				}
220
-				else     $row['status'] = $msg_success_skip_doc;
221
-				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
222
-			}
223
-			else
224
-			{
225
-				$row['status'] = $msg_success_skip_dir;
226
-				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227
-			}
228
-			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
229
-			{ // needs making a folder
230
-				$end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231
-				$dir_path = $dirpath . $end_dir;
232
-				if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
233
-				if (!is_dir($dir_path))
234
-				{
235
-					if (is_file($dir_path)) @unlink($dir_path);
236
-					mkdir($dir_path);
237
-					@chmod($dir_path, $folder_permission);
238
-
239
-				}
240
-
241
-
242
-				if($modx->config['make_folders']==='1' && $row['published']==='1')
243
-				{
244
-					if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html');
245
-				}
246
-				$this->targetDir = $dir_path;
247
-				$this->run($row['id']);
248
-			}
249
-		}
250
-		return implode("\n", $this->output);
251
-	}
216
+                        }
217
+                    }
218
+                    else $row['status'] = $msg_failed_no_retrieve;
219
+                }
220
+                else     $row['status'] = $msg_success_skip_doc;
221
+                $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
222
+            }
223
+            else
224
+            {
225
+                $row['status'] = $msg_success_skip_dir;
226
+                $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227
+            }
228
+            if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
229
+            { // needs making a folder
230
+                $end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231
+                $dir_path = $dirpath . $end_dir;
232
+                if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
233
+                if (!is_dir($dir_path))
234
+                {
235
+                    if (is_file($dir_path)) @unlink($dir_path);
236
+                    mkdir($dir_path);
237
+                    @chmod($dir_path, $folder_permission);
238
+
239
+                }
240
+
241
+
242
+                if($modx->config['make_folders']==='1' && $row['published']==='1')
243
+                {
244
+                    if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html');
245
+                }
246
+                $this->targetDir = $dir_path;
247
+                $this->run($row['id']);
248
+            }
249
+        }
250
+        return implode("\n", $this->output);
251
+    }
252 252
 
253 253
     public function curl_get_contents($url, $timeout = 30 )
254 254
     {
255
-    	if(!function_exists('curl_init')) return @file_get_contents($url);
255
+        if(!function_exists('curl_init')) return @file_get_contents($url);
256 256
 
257 257
         $ch = curl_init();
258 258
         curl_setopt($ch, CURLOPT_URL, $url);
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
 
270 270
     public function parsePlaceholder($tpl,$ph=array())
271 271
     {
272
-    	foreach($ph as $k=>$v)
273
-    	{
274
-    		$k = "[+{$k}+]";
275
-    		$tpl = str_replace($k,$v,$tpl);
276
-    	}
277
-    	return $tpl;
272
+        foreach($ph as $k=>$v)
273
+        {
274
+            $k = "[+{$k}+]";
275
+            $tpl = str_replace($k,$v,$tpl);
276
+        }
277
+        return $tpl;
278 278
     }
279 279
 
280 280
 }
Please login to merge, or discard this patch.
manager/includes/controls/datagrid.class.php 1 patch
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 class DataGrid {
14 14
 
15
-	public $ds; // datasource
15
+    public $ds; // datasource
16 16
     public $id;
17 17
     public $pageSize;            // pager settings
18 18
     public $pageNumber;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public $colWraps;
37 37
     public $colColors;
38 38
     public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39
-	// data type: integer,float,currency,date
39
+    // data type: integer,float,currency,date
40 40
 
41 41
     public $header;
42 42
     public $footer;
@@ -73,239 +73,239 @@  discard block
 block discarded – undo
73 73
     public $cdelim;
74 74
 
75 75
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
76
-		global $__DataGridCnt;
76
+        global $__DataGridCnt;
77 77
 
78
-		// set id
79
-		$__DataGridCnt++;
80
-		$this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
78
+        // set id
79
+        $__DataGridCnt++;
80
+        $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
81 81
 
82
-		// set datasource
83
-		$this->ds = $ds;
82
+        // set datasource
83
+        $this->ds = $ds;
84 84
 
85
-		// set pager
86
-		$this->pageSize = $pageSize;
87
-		$this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
88
-		$this->pagerLocation = 'top-right';
89
-	}
85
+        // set pager
86
+        $this->pageSize = $pageSize;
87
+        $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
88
+        $this->pagerLocation = 'top-right';
89
+    }
90 90
 
91 91
     public function setDataSource($ds) {
92
-		$this->ds = $ds;
93
-	}
92
+        $this->ds = $ds;
93
+    }
94 94
 
95 95
     public function render() {
96
-		global $modx;
97
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
101
-
102
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
104
-
105
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
109
-
110
-		$this->_alt = 0;
111
-		$this->_total = 0;
112
-
113
-		$this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114
-
115
-		if(!$cssStyle && !$cssClass) {
116
-			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117
-		}
118
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
119
-			$columnHeaderStyle = "style='color:black;background-color:silver'";
120
-		}
121
-		if(!$this->_itemStyle && !$this->_itemClass) {
122
-			$this->_itemStyle = "style='color:black;'";
123
-		}
124
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
125
-			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126
-		}
127
-
128
-		if($this->_isDataset && !$this->columns) {
129
-			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
131
-		}
132
-
133
-		// start grid
134
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
135
-		$tblEnd = "</table>";
136
-
137
-		// build column header
138
-		$this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
139
-		$this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
140
-		$this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
141
-		$this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
142
-		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143
-		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144
-		$this->_colcount = count($this->_colnames);
145
-		if(!$this->_isDataset) {
146
-			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147
-			$this->ds = array_chunk($this->ds, $this->_colcount);
148
-		}
149
-		$tblColHdr = "<thead><tr>";
150
-		for($c = 0; $c < $this->_colcount; $c++) {
151
-			$name = $this->_colnames[$c];
152
-			$width = $this->_colwidths[$c];
153
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
154
-		}
155
-		$tblColHdr .= "</tr></thead>\n";
156
-
157
-		// build rows
158
-		$rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159
-		$this->_fieldnames = explode(",", $this->fields);
160
-		if($rowcount == 0) {
161
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
162
-		} else {
163
-			// render grid items
164
-			if($this->pageSize <= 0) {
165
-				for($r = 0; $r < $rowcount; $r++) {
166
-					$row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167
-					$tblRows .= $this->RenderRowFnc($r + 1, $row);
168
-				}
169
-			} else {
170
-				if(!$this->pager) {
171
-					include_once dirname(__FILE__) . "/datasetpager.class.php";
172
-					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
-					$this->pager->setRenderRowFnc($this); // pass this object
174
-					$this->pager->cssStyle = $pagerStyle;
175
-					$this->pager->cssClass = $pagerClass;
176
-				} else {
177
-					$this->pager->pageSize = $this->pageSize;
178
-					$this->pager->pageNumber = $this->pageNumber;
179
-				}
180
-
181
-				$this->pager->render();
182
-				$tblRows = $this->pager->getRenderedRows();
183
-				$tblPager = $this->pager->getRenderedPager();
184
-			}
185
-		}
186
-
187
-		// setup header,pager and footer
188
-		$o = $tblStart;
189
-		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
-		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
-		if($this->header) {
192
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
-		}
194
-		if($tblPager && $ptop) {
195
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
-		}
197
-		$o .= $tblColHdr . $tblRows;
198
-		if($tblPager && $pbot) {
199
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
-		}
201
-		if($this->footer) {
202
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
-		}
204
-		$o .= $tblEnd;
205
-		return $o;
206
-	}
207
-
208
-	// format column values
96
+        global $modx;
97
+        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
+        $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
+        $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
+        $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
101
+
102
+        $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
+        $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
104
+
105
+        $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
+        $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
+        $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
+        $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
109
+
110
+        $this->_alt = 0;
111
+        $this->_total = 0;
112
+
113
+        $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114
+
115
+        if(!$cssStyle && !$cssClass) {
116
+            $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117
+        }
118
+        if(!$columnHeaderStyle && !$columnHeaderClass) {
119
+            $columnHeaderStyle = "style='color:black;background-color:silver'";
120
+        }
121
+        if(!$this->_itemStyle && !$this->_itemClass) {
122
+            $this->_itemStyle = "style='color:black;'";
123
+        }
124
+        if(!$this->_altItemStyle && !$this->_altItemClass) {
125
+            $this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126
+        }
127
+
128
+        if($this->_isDataset && !$this->columns) {
129
+            $cols = $modx->db->numFields($this->ds);
130
+            for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
131
+        }
132
+
133
+        // start grid
134
+        $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
135
+        $tblEnd = "</table>";
136
+
137
+        // build column header
138
+        $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
139
+        $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
140
+        $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
141
+        $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
142
+        $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143
+        $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144
+        $this->_colcount = count($this->_colnames);
145
+        if(!$this->_isDataset) {
146
+            $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147
+            $this->ds = array_chunk($this->ds, $this->_colcount);
148
+        }
149
+        $tblColHdr = "<thead><tr>";
150
+        for($c = 0; $c < $this->_colcount; $c++) {
151
+            $name = $this->_colnames[$c];
152
+            $width = $this->_colwidths[$c];
153
+            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
154
+        }
155
+        $tblColHdr .= "</tr></thead>\n";
156
+
157
+        // build rows
158
+        $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159
+        $this->_fieldnames = explode(",", $this->fields);
160
+        if($rowcount == 0) {
161
+            $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
162
+        } else {
163
+            // render grid items
164
+            if($this->pageSize <= 0) {
165
+                for($r = 0; $r < $rowcount; $r++) {
166
+                    $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167
+                    $tblRows .= $this->RenderRowFnc($r + 1, $row);
168
+                }
169
+            } else {
170
+                if(!$this->pager) {
171
+                    include_once dirname(__FILE__) . "/datasetpager.class.php";
172
+                    $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
+                    $this->pager->setRenderRowFnc($this); // pass this object
174
+                    $this->pager->cssStyle = $pagerStyle;
175
+                    $this->pager->cssClass = $pagerClass;
176
+                } else {
177
+                    $this->pager->pageSize = $this->pageSize;
178
+                    $this->pager->pageNumber = $this->pageNumber;
179
+                }
180
+
181
+                $this->pager->render();
182
+                $tblRows = $this->pager->getRenderedRows();
183
+                $tblPager = $this->pager->getRenderedPager();
184
+            }
185
+        }
186
+
187
+        // setup header,pager and footer
188
+        $o = $tblStart;
189
+        $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
+        $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
+        if($this->header) {
192
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
+        }
194
+        if($tblPager && $ptop) {
195
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
+        }
197
+        $o .= $tblColHdr . $tblRows;
198
+        if($tblPager && $pbot) {
199
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
+        }
201
+        if($this->footer) {
202
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
+        }
204
+        $o .= $tblEnd;
205
+        return $o;
206
+    }
207
+
208
+    // format column values
209 209
 
210 210
     public function RenderRowFnc($n, $row) {
211
-		if($this->_alt == 0) {
212
-			$Style = $this->_itemStyle;
213
-			$Class = $this->_itemClass;
214
-			$this->_alt = 1;
215
-		} else {
216
-			$Style = $this->_altItemStyle;
217
-			$Class = $this->_altItemClass;
218
-			$this->_alt = 0;
219
-		}
220
-		$o = "<tr>";
221
-		for($c = 0; $c < $this->_colcount; $c++) {
222
-			$colStyle = $Style;
223
-			$fld = trim($this->_fieldnames[$c]);
224
-			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
-			$align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
-			$color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
-			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
-			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
-			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
-			if($color && $Style) {
231
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
-			}
233
-			$value = $this->formatColumnValue($row, $value, $type, $align);
234
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
-		}
236
-		$o .= "</tr>\n";
237
-		return $o;
238
-	}
211
+        if($this->_alt == 0) {
212
+            $Style = $this->_itemStyle;
213
+            $Class = $this->_itemClass;
214
+            $this->_alt = 1;
215
+        } else {
216
+            $Style = $this->_altItemStyle;
217
+            $Class = $this->_altItemClass;
218
+            $this->_alt = 0;
219
+        }
220
+        $o = "<tr>";
221
+        for($c = 0; $c < $this->_colcount; $c++) {
222
+            $colStyle = $Style;
223
+            $fld = trim($this->_fieldnames[$c]);
224
+            $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
+            $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
+            $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
+            $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
+            $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
+            $value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
+            if($color && $Style) {
231
+                $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
+            }
233
+            $value = $this->formatColumnValue($row, $value, $type, $align);
234
+            $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
+        }
236
+        $o .= "</tr>\n";
237
+        return $o;
238
+    }
239 239
 
240 240
     public function formatColumnValue($row, $value, $type, &$align) {
241
-		if(strpos($type, ":") !== false) {
242
-			list($type, $type_format) = explode(":", $type, 2);
243
-		}
244
-		switch(strtolower($type)) {
245
-			case "integer":
246
-				if($align == "") {
247
-					$align = "right";
248
-				}
249
-				$value = number_format($value);
250
-				break;
251
-
252
-			case "float":
253
-				if($align == "") {
254
-					$align = "right";
255
-				}
256
-				if(!$type_format) {
257
-					$type_format = 2;
258
-				}
259
-				$value = number_format($value, $type_format);
260
-				break;
261
-
262
-			case "currency":
263
-				if($align == "") {
264
-					$align = "right";
265
-				}
266
-				if(!$type_format) {
267
-					$type_format = 2;
268
-				}
269
-				$value = "$" . number_format($value, $type_format);
270
-				break;
271
-
272
-			case "date":
273
-				if($align == "") {
274
-					$align = "right";
275
-				}
276
-				if(!is_numeric($value)) {
277
-					$value = strtotime($value);
278
-				}
279
-				if(!$type_format) {
280
-					$type_format = "%A %d, %B %Y";
281
-				}
282
-				$value = strftime($type_format, $value);
283
-				break;
284
-
285
-			case "boolean":
286
-				if($align == '') {
287
-					$align = "center";
288
-				}
289
-				$value = number_format($value);
290
-				if($value) {
291
-					$value = '&bull;';
292
-				} else {
293
-					$value = '&nbsp;';
294
-				}
295
-				break;
296
-
297
-			case "template":
298
-				// replace [+value+] first
299
-				$value = str_replace("[+value+]", $value, $type_format);
300
-				// replace other [+fields+]
301
-				if(strpos($value, "[+") !== false) {
302
-					foreach($row as $k => $v) {
303
-						$value = str_replace("[+$k+]", $v, $value);
304
-					}
305
-				}
306
-				break;
307
-
308
-		}
309
-		return $value;
310
-	}
241
+        if(strpos($type, ":") !== false) {
242
+            list($type, $type_format) = explode(":", $type, 2);
243
+        }
244
+        switch(strtolower($type)) {
245
+            case "integer":
246
+                if($align == "") {
247
+                    $align = "right";
248
+                }
249
+                $value = number_format($value);
250
+                break;
251
+
252
+            case "float":
253
+                if($align == "") {
254
+                    $align = "right";
255
+                }
256
+                if(!$type_format) {
257
+                    $type_format = 2;
258
+                }
259
+                $value = number_format($value, $type_format);
260
+                break;
261
+
262
+            case "currency":
263
+                if($align == "") {
264
+                    $align = "right";
265
+                }
266
+                if(!$type_format) {
267
+                    $type_format = 2;
268
+                }
269
+                $value = "$" . number_format($value, $type_format);
270
+                break;
271
+
272
+            case "date":
273
+                if($align == "") {
274
+                    $align = "right";
275
+                }
276
+                if(!is_numeric($value)) {
277
+                    $value = strtotime($value);
278
+                }
279
+                if(!$type_format) {
280
+                    $type_format = "%A %d, %B %Y";
281
+                }
282
+                $value = strftime($type_format, $value);
283
+                break;
284
+
285
+            case "boolean":
286
+                if($align == '') {
287
+                    $align = "center";
288
+                }
289
+                $value = number_format($value);
290
+                if($value) {
291
+                    $value = '&bull;';
292
+                } else {
293
+                    $value = '&nbsp;';
294
+                }
295
+                break;
296
+
297
+            case "template":
298
+                // replace [+value+] first
299
+                $value = str_replace("[+value+]", $value, $type_format);
300
+                // replace other [+fields+]
301
+                if(strpos($value, "[+") !== false) {
302
+                    foreach($row as $k => $v) {
303
+                        $value = str_replace("[+$k+]", $v, $value);
304
+                    }
305
+                }
306
+                break;
307
+
308
+        }
309
+        return $value;
310
+    }
311 311
 }
Please login to merge, or discard this patch.
manager/includes/controls/contextmenu.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -4,71 +4,71 @@
 block discarded – undo
4 4
 $ContextMenuCnt = 0;
5 5
 
6 6
 class ContextMenu {
7
-	public $id;
7
+    public $id;
8 8
     /**
9 9
      * @var string
10 10
      */
11
-	public $html = '';
11
+    public $html = '';
12 12
     /**
13 13
      * @var bool
14 14
      */
15
-	public $visible = false;
15
+    public $visible = false;
16 16
     /**
17 17
      * @var int
18 18
      */
19
-	public $width = 120;
19
+    public $width = 120;
20 20
 
21 21
     public function __construct($id = '', $width = 120, $visible = false) {
22
-		global $ContextMenuCnt;
23
-		$ContextMenuCnt++;
24
-		$this->html = "";
25
-		$this->visible = $visible ? $visible : false;
26
-		$this->width = is_numeric($width) ? (int)$width : 120;
27
-		$this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt;    // set id
28
-	}
22
+        global $ContextMenuCnt;
23
+        $ContextMenuCnt++;
24
+        $this->html = "";
25
+        $this->visible = $visible ? $visible : false;
26
+        $this->width = is_numeric($width) ? (int)$width : 120;
27
+        $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt;    // set id
28
+    }
29 29
 
30 30
     public function addItem($text, $action = "", $img = "", $disabled = 0) {
31
-		global $base_url, $_style;
31
+        global $base_url, $_style;
32 32
         if($disabled) {
33 33
             return;
34 34
         }
35
-		if(!$img) {
36
-			$img = $base_url . $_style['tx'];
37
-		}
38
-		if(substr($action, 0, 3) == "js:") {
39
-			$action = substr($action, 3);
40
-		} else if(substr($action, 0, 3) == "hl:") {
41
-			$action = "window.location.href='" . substr($action, 3) . "'";
42
-		} else {
43
-			$action = "window.location.href='" . $action . "'";
44
-		}
45
-		$action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('" . $this->id . "');\"";
46
-		$this->html .= "<div class='" . ($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem") . "' $action>";
35
+        if(!$img) {
36
+            $img = $base_url . $_style['tx'];
37
+        }
38
+        if(substr($action, 0, 3) == "js:") {
39
+            $action = substr($action, 3);
40
+        } else if(substr($action, 0, 3) == "hl:") {
41
+            $action = "window.location.href='" . substr($action, 3) . "'";
42
+        } else {
43
+            $action = "window.location.href='" . $action . "'";
44
+        }
45
+        $action = " onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('" . $this->id . "');\"";
46
+        $this->html .= "<div class='" . ($disabled ? "cntxMnuItemDisabled" : "cntxMnuItem") . "' $action>";
47 47
         if(substr($img, 0, 5) == 'fa fa') {
48 48
             $img = '<i class="' . $img . '"></i>';
49 49
         } else if(substr($img, 0, 1) != '<') {
50 50
             $img = '<img src="' . $img . '" />';
51 51
         }
52
-		$this->html .= $img . '&nbsp;' . $text . '</div>';
53
-	}
52
+        $this->html .= $img . '&nbsp;' . $text . '</div>';
53
+    }
54 54
 
55 55
     public function addSeparator() {
56
-		$this->html .= "
56
+        $this->html .= "
57 57
 			<div class='cntxMnuSeparator'></div>
58 58
 		";
59
-	}
59
+    }
60 60
 
61 61
     public function render() {
62
-		global $ContextMenuScript;
62
+        global $ContextMenuScript;
63 63
 
64
-		$html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>";
65
-		$ContextMenuScript = ""; // reset css
66
-		return $html;
67
-	}
64
+        $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>";
65
+        $ContextMenuScript = ""; // reset css
66
+        return $html;
67
+    }
68 68
 
69 69
     public function getClientScriptObject() {
70
-		return "getCntxMenu('" . $this->id . "')";
71
-	}
70
+        return "getCntxMenu('" . $this->id . "')";
71
+    }
72 72
 }
73 73
 
74 74
 $ContextMenuScript = <<<BLOCK
Please login to merge, or discard this patch.
manager/includes/controls/datasetpager.class.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -12,18 +12,18 @@  discard block
 block discarded – undo
12 12
 
13 13
 class DataSetPager {
14 14
 
15
-	public $ds; // datasource
15
+    public $ds; // datasource
16 16
     public $pageSize;
17 17
     public $pageNumber;
18 18
     public $rows;
19 19
     public $pager;
20 20
     public $id;
21 21
 
22
-	// normal page
22
+    // normal page
23 23
     public $pageStyle;
24 24
     public $pageClass;
25 25
 
26
-	// selected page
26
+    // selected page
27 27
     public $selPageStyle;
28 28
     public $selPageClass;
29 29
     public $renderRowFnc;
@@ -32,166 +32,166 @@  discard block
 block discarded – undo
32 32
     public $renderPagerFncArgs;
33 33
 
34 34
     public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35
-		global $_PAGE; // use view state object
36
-
37
-		global $__DataSetPagerCnt;
38
-
39
-		// set id
40
-		$__DataSetPagerCnt++;
41
-		$this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
-
43
-		// get pagenumber
44
-		// by setting pager to -1 cause pager to load it's last page number
45
-		if($pageNumber == -1) {
46
-			$pageNumber = 1;
47
-			if(isset($_GET["dpgn" . $this->id])) {
48
-				$pageNumber = $_GET["dpgn" . $this->id];
49
-			} elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
-				$pageNumber = $_PAGE['vs'][$id . '_dpgn'];
51
-			}
52
-		}
53
-		if(!is_numeric($pageNumber)) {
54
-			$pageNumber = 1;
55
-		}
56
-
57
-		$this->ds = $ds; // datasource
58
-		$this->pageSize = $pageSize;
59
-		$this->pageNumber = $pageNumber;
60
-		$this->rows = '';
61
-		$this->pager = '';
62
-	}
35
+        global $_PAGE; // use view state object
36
+
37
+        global $__DataSetPagerCnt;
38
+
39
+        // set id
40
+        $__DataSetPagerCnt++;
41
+        $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
+
43
+        // get pagenumber
44
+        // by setting pager to -1 cause pager to load it's last page number
45
+        if($pageNumber == -1) {
46
+            $pageNumber = 1;
47
+            if(isset($_GET["dpgn" . $this->id])) {
48
+                $pageNumber = $_GET["dpgn" . $this->id];
49
+            } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
+                $pageNumber = $_PAGE['vs'][$id . '_dpgn'];
51
+            }
52
+        }
53
+        if(!is_numeric($pageNumber)) {
54
+            $pageNumber = 1;
55
+        }
56
+
57
+        $this->ds = $ds; // datasource
58
+        $this->pageSize = $pageSize;
59
+        $this->pageNumber = $pageNumber;
60
+        $this->rows = '';
61
+        $this->pager = '';
62
+    }
63 63
 
64 64
     public function getRenderedPager() {
65
-		return $this->pager;
66
-	}
65
+        return $this->pager;
66
+    }
67 67
 
68 68
     public function getRenderedRows() {
69
-		return $this->rows;
70
-	}
69
+        return $this->rows;
70
+    }
71 71
 
72 72
     public function setDataSource($ds) {
73
-		$this->ds = $ds;
74
-	}
73
+        $this->ds = $ds;
74
+    }
75 75
 
76 76
     public function setPageSize($ps) {
77
-		$this->pageSize = $ps;
78
-	}
77
+        $this->pageSize = $ps;
78
+    }
79 79
 
80 80
     public function setRenderRowFnc($fncName, $args = "") {
81
-		$this->renderRowFnc = &$fncName;
82
-		$this->renderRowFncArgs = $args;    // extra agruments
81
+        $this->renderRowFnc = &$fncName;
82
+        $this->renderRowFncArgs = $args;    // extra agruments
83 83
 
84 84
 
85
-	}
85
+    }
86 86
 
87 87
     public function setRenderPagerFnc($fncName, $args = "") {
88
-		$this->renderPagerFnc = $fncName;
89
-		$this->renderPagerFncArgs = $args;    // extra agruments
90
-	}
88
+        $this->renderPagerFnc = $fncName;
89
+        $this->renderPagerFncArgs = $args;    // extra agruments
90
+    }
91 91
 
92 92
     public function render() {
93
-		global $modx, $_PAGE;
94
-
95
-		$isDataset = $modx->db->isResult($this->ds);
96
-
97
-		if(!$this->selPageStyle) {
98
-			$this->selPageStyle = "font-weight:bold";
99
-		}
100
-
101
-		// get total number of rows
102
-		$tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103
-
104
-		// render: no records found
105
-		if($tnr <= 0) {
106
-			$fnc = $this->renderRowFnc;
107
-			$args = $this->renderRowFncArgs;
108
-			if(isset($fnc)) {
109
-				if($args != "") {
110
-					$this->rows .= $fnc(0, null, $args);
111
-				} // if agrs was specified then we will pass three params
112
-				else {
113
-					$this->rows .= $fnc(0, null);
114
-				}                 // otherwise two will be passed
115
-			}
116
-			return;
117
-		}
118
-
119
-		// get total pages
120
-		$tp = ceil($tnr / $this->pageSize);
121
-		if($this->pageNumber > $tp) {
122
-			$this->pageNumber = 1;
123
-		}
124
-
125
-		// get page number
126
-		$p = $this->pageNumber;
127
-
128
-		// save page number to view state if available
129
-		if(isset($_PAGE['vs'])) {
130
-			$_PAGE['vs'][$this->id . '_dpgn'] = $p;
131
-		}
132
-
133
-		// render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
-		if($tp > 1) {
135
-		    $url = '';
136
-			$fnc = $this->renderPagerFnc;
137
-			$args = $this->renderPagerFncArgs;
138
-			if(!isset($fnc)) {
139
-				if($modx->isFrontend()) {
140
-					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
141
-				} else {
142
-					$url = $_SERVER['PHP_SELF'] . '?';
143
-				}
144
-				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
146
-					$i++;
147
-					$url .= (($i > 1) ? "&" : "") . "$n=$v";
148
-				}
149
-				if($i >= 1) {
150
-					$url .= "&";
151
-				}
152
-			}
153
-			for($i = 1; $i <= $tp; $i++) {
154
-				if(isset($fnc)) {
155
-					if($args != "") {
156
-						$this->pager .= $fnc($p, $i, $args);
157
-					} else {
158
-						$this->pager .= $fnc($p, $i);
159
-					}
160
-				} else {
161
-					$this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
162
-				}
163
-			}
164
-		}
165
-
166
-		// render row : renderRowFnc($rowNumber,$row,$arguments="")
167
-		$fnc = $this->renderRowFnc;
168
-		$args = $this->renderRowFncArgs;
169
-
170
-		if(isset($fnc)) {
171
-			$i = 1;
172
-			$fncObject = is_object($fnc);
173
-			$minitems = (($p - 1) * $this->pageSize) + 1;
174
-			$maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
-			while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
-				if($i >= $minitems && $i <= $maxitems) {
177
-					if($fncObject) {
178
-						if($args != "") {
179
-							$this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180
-						} else {
181
-							$this->rows .= $fnc->RenderRowFnc($i, $row);
182
-						}
183
-					} else {
184
-						if($args != "") {
185
-							$this->rows .= $fnc($i, $row, $args);
186
-						} // if agrs was specified then we wil pass three params
187
-						else {
188
-							$this->rows .= $fnc($i, $row);
189
-						}                 // otherwise two will be passed
190
-					}
191
-
192
-				}
193
-				$i++;
194
-			}
195
-		}
196
-	}
93
+        global $modx, $_PAGE;
94
+
95
+        $isDataset = $modx->db->isResult($this->ds);
96
+
97
+        if(!$this->selPageStyle) {
98
+            $this->selPageStyle = "font-weight:bold";
99
+        }
100
+
101
+        // get total number of rows
102
+        $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103
+
104
+        // render: no records found
105
+        if($tnr <= 0) {
106
+            $fnc = $this->renderRowFnc;
107
+            $args = $this->renderRowFncArgs;
108
+            if(isset($fnc)) {
109
+                if($args != "") {
110
+                    $this->rows .= $fnc(0, null, $args);
111
+                } // if agrs was specified then we will pass three params
112
+                else {
113
+                    $this->rows .= $fnc(0, null);
114
+                }                 // otherwise two will be passed
115
+            }
116
+            return;
117
+        }
118
+
119
+        // get total pages
120
+        $tp = ceil($tnr / $this->pageSize);
121
+        if($this->pageNumber > $tp) {
122
+            $this->pageNumber = 1;
123
+        }
124
+
125
+        // get page number
126
+        $p = $this->pageNumber;
127
+
128
+        // save page number to view state if available
129
+        if(isset($_PAGE['vs'])) {
130
+            $_PAGE['vs'][$this->id . '_dpgn'] = $p;
131
+        }
132
+
133
+        // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
+        if($tp > 1) {
135
+            $url = '';
136
+            $fnc = $this->renderPagerFnc;
137
+            $args = $this->renderPagerFncArgs;
138
+            if(!isset($fnc)) {
139
+                if($modx->isFrontend()) {
140
+                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
141
+                } else {
142
+                    $url = $_SERVER['PHP_SELF'] . '?';
143
+                }
144
+                $i = 0;
145
+                foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
146
+                    $i++;
147
+                    $url .= (($i > 1) ? "&" : "") . "$n=$v";
148
+                }
149
+                if($i >= 1) {
150
+                    $url .= "&";
151
+                }
152
+            }
153
+            for($i = 1; $i <= $tp; $i++) {
154
+                if(isset($fnc)) {
155
+                    if($args != "") {
156
+                        $this->pager .= $fnc($p, $i, $args);
157
+                    } else {
158
+                        $this->pager .= $fnc($p, $i);
159
+                    }
160
+                } else {
161
+                    $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
162
+                }
163
+            }
164
+        }
165
+
166
+        // render row : renderRowFnc($rowNumber,$row,$arguments="")
167
+        $fnc = $this->renderRowFnc;
168
+        $args = $this->renderRowFncArgs;
169
+
170
+        if(isset($fnc)) {
171
+            $i = 1;
172
+            $fncObject = is_object($fnc);
173
+            $minitems = (($p - 1) * $this->pageSize) + 1;
174
+            $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
+            while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
+                if($i >= $minitems && $i <= $maxitems) {
177
+                    if($fncObject) {
178
+                        if($args != "") {
179
+                            $this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180
+                        } else {
181
+                            $this->rows .= $fnc->RenderRowFnc($i, $row);
182
+                        }
183
+                    } else {
184
+                        if($args != "") {
185
+                            $this->rows .= $fnc($i, $row, $args);
186
+                        } // if agrs was specified then we wil pass three params
187
+                        else {
188
+                            $this->rows .= $fnc($i, $row);
189
+                        }                 // otherwise two will be passed
190
+                    }
191
+
192
+                }
193
+                $i++;
194
+            }
195
+        }
196
+    }
197 197
 }
Please login to merge, or discard this patch.
manager/includes/error.class.inc.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -17,70 +17,70 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function __construct() {
19 19
 
20
-		$_lang = $this->include_lang('errormsg');
20
+        $_lang = $this->include_lang('errormsg');
21 21
 
22
-		$this->errors = array(
23
-		0	=>	$_lang["No errors occured."],
24
-		1	=>	$_lang["An error occured!"],
25
-		2	=>	$_lang["Document's ID not passed in request!"],
26
-		3	=>	$_lang["You don't have enough privileges for this action!"],
27
-		4	=>	$_lang["ID passed in request is NaN!"],
28
-		5	=>	$_lang["The document is locked!"],
29
-		6	=>	$_lang["Too many results returned from database!"],
30
-		7	=>	$_lang["Not enough/ no results returned from database!"],
31
-		8	=>	$_lang["Couldn't find parent document's name!"],
32
-		9	=>	$_lang["Logging error!"],
33
-		10	=>	$_lang["Table to optimise not found in request!"],
34
-		11	=>	$_lang["No settings found in request!"],
35
-		12	=>	$_lang["The document must have a title!"],
36
-		13	=>	$_lang["No user selected as recipient of this message!"],
37
-		14	=>	$_lang["No group selected as recipient of this message!"],
38
-		15	=>	$_lang["The document was not found!"],
22
+        $this->errors = array(
23
+        0	=>	$_lang["No errors occured."],
24
+        1	=>	$_lang["An error occured!"],
25
+        2	=>	$_lang["Document's ID not passed in request!"],
26
+        3	=>	$_lang["You don't have enough privileges for this action!"],
27
+        4	=>	$_lang["ID passed in request is NaN!"],
28
+        5	=>	$_lang["The document is locked!"],
29
+        6	=>	$_lang["Too many results returned from database!"],
30
+        7	=>	$_lang["Not enough/ no results returned from database!"],
31
+        8	=>	$_lang["Couldn't find parent document's name!"],
32
+        9	=>	$_lang["Logging error!"],
33
+        10	=>	$_lang["Table to optimise not found in request!"],
34
+        11	=>	$_lang["No settings found in request!"],
35
+        12	=>	$_lang["The document must have a title!"],
36
+        13	=>	$_lang["No user selected as recipient of this message!"],
37
+        14	=>	$_lang["No group selected as recipient of this message!"],
38
+        15	=>	$_lang["The document was not found!"],
39 39
 
40
-		100 =>	$_lang["Double action (GET & POST) posted!"],
41
-		600 =>	$_lang["Document cannot be it's own parent!"],
42
-		601 =>	$_lang["Document's ID not passed in request!"],
43
-		602 =>	$_lang["New parent not set in request!"],
44
-		900 =>	$_lang["don't know the user!"], // don't know the user!
45
-		901 =>	$_lang["wrong password!"], // wrong password!
46
-		902 =>	$_lang["Due to too many failed logins, you have been blocked!"],
47
-		903 =>	$_lang["You are blocked and cannot log in!"],
48
-		904 =>	$_lang["You are blocked and cannot log in! Please try again later."],
49
-		905 =>	$_lang["The security code you entered didn't validate! Please try to login again!"]
50
-	);
51
-	}
40
+        100 =>	$_lang["Double action (GET & POST) posted!"],
41
+        600 =>	$_lang["Document cannot be it's own parent!"],
42
+        601 =>	$_lang["Document's ID not passed in request!"],
43
+        602 =>	$_lang["New parent not set in request!"],
44
+        900 =>	$_lang["don't know the user!"], // don't know the user!
45
+        901 =>	$_lang["wrong password!"], // wrong password!
46
+        902 =>	$_lang["Due to too many failed logins, you have been blocked!"],
47
+        903 =>	$_lang["You are blocked and cannot log in!"],
48
+        904 =>	$_lang["You are blocked and cannot log in! Please try again later."],
49
+        905 =>	$_lang["The security code you entered didn't validate! Please try to login again!"]
50
+    );
51
+    }
52 52
 
53
-	function include_lang($context='common') {
54
-		global $modx;
55
-		$_lang = array();
53
+    function include_lang($context='common') {
54
+        global $modx;
55
+        $_lang = array();
56 56
 
57
-		$context = trim($context,'/');
58
-		if(strpos($context,'..')!==false) return;
57
+        $context = trim($context,'/');
58
+        if(strpos($context,'..')!==false) return;
59 59
 
60
-		if($context === 'common')
61
-			$lang_path = MODX_MANAGER_PATH . 'includes/lang/';
62
-		else
63
-			$lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/";
64
-		include_once($lang_path . 'english.inc.php');
65
-		$manager_language = $modx->config['manager_language'];
66
-		if(is_file("{$lang_path}{$manager_language}.inc.php"))
67
-			include_once("{$lang_path}{$manager_language}.inc.php");
68
-		return $_lang;
69
-	}
60
+        if($context === 'common')
61
+            $lang_path = MODX_MANAGER_PATH . 'includes/lang/';
62
+        else
63
+            $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/";
64
+        include_once($lang_path . 'english.inc.php');
65
+        $manager_language = $modx->config['manager_language'];
66
+        if(is_file("{$lang_path}{$manager_language}.inc.php"))
67
+            include_once("{$lang_path}{$manager_language}.inc.php");
68
+        return $_lang;
69
+    }
70 70
 
71
-	function setError($errorcode, $custommessage=""){
72
-		$this->errorcode=$errorcode;
73
-		$this->errormessage=$this->errors[$errorcode];
74
-		if($custommessage!="") {
75
-			$this->errormessage=$custommessage;
76
-		}
77
-	}
71
+    function setError($errorcode, $custommessage=""){
72
+        $this->errorcode=$errorcode;
73
+        $this->errormessage=$this->errors[$errorcode];
74
+        if($custommessage!="") {
75
+            $this->errormessage=$custommessage;
76
+        }
77
+    }
78 78
 
79
-	function getError() {
80
-		return $this->errorcode;
81
-	}
79
+    function getError() {
80
+        return $this->errorcode;
81
+    }
82 82
 
83
-	function dumpError(){
83
+    function dumpError(){
84 84
 ?>
85 85
 	<html>
86 86
 	<head>
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	</body>
99 99
 	</html>
100 100
 <?php
101
-		exit;
102
-	}
101
+        exit;
102
+    }
103 103
 }
104 104
 ?>
Please login to merge, or discard this patch.
manager/includes/tmplvars.commands.inc.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 
120 120
 function ProcessFile($file) {
121 121
     // get the file
122
-	$buffer = @file_get_contents($file);
123
-	if ($buffer===false) $buffer = " Could not retrieve document '$file'.";
122
+    $buffer = @file_get_contents($file);
123
+    if ($buffer===false) $buffer = " Could not retrieve document '$file'.";
124 124
     return $buffer;
125 125
 }
126 126
 
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
 // Parse MODX Template-Variables
145 145
 function parseTvValues($param, $tvsArray)
146 146
 {
147
-	global $modx;
148
-	$tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray;
149
-	if (strpos($param, '[*') !== false) {
150
-		$matches = $modx->getTagsFromContent($param, '[*', '*]');
151
-		foreach ($matches[0] as $i=>$match) {
152
-			if(isset($tvsArray[ $matches[1][$i] ])) {
153
-				if(is_array($tvsArray[ $matches[1][$i] ])) {
154
-					$value = $tvsArray[$matches[1][$i]]['value'];
155
-					$value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value;
156
-				} else {
157
-					$value = $tvsArray[ $matches[1][$i] ];
158
-				}
159
-				$param = str_replace($match, $value, $param);
160
-			}
161
-		}
162
-	}
163
-	return $param;
147
+    global $modx;
148
+    $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray;
149
+    if (strpos($param, '[*') !== false) {
150
+        $matches = $modx->getTagsFromContent($param, '[*', '*]');
151
+        foreach ($matches[0] as $i=>$match) {
152
+            if(isset($tvsArray[ $matches[1][$i] ])) {
153
+                if(is_array($tvsArray[ $matches[1][$i] ])) {
154
+                    $value = $tvsArray[$matches[1][$i]]['value'];
155
+                    $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value;
156
+                } else {
157
+                    $value = $tvsArray[ $matches[1][$i] ];
158
+                }
159
+                $param = str_replace($match, $value, $param);
160
+            }
161
+        }
162
+    }
163
+    return $param;
164 164
 }
Please login to merge, or discard this patch.
manager/includes/rss.inc.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
  *  MODX Manager Home Page Implmentation by pixelchutes (www.pixelchutes.com)
4 4
  *  Based on kudo's kRSS Module v1.0.72
5 5
  *
@@ -30,44 +30,44 @@  discard block
 block discarded – undo
30 30
 require_once(MODX_MANAGER_PATH.'media/rss/rss_fetch.inc');
31 31
 // Convert relative path into absolute url
32 32
 function rel2abs( $rel, $base ) {
33
-	// parse base URL  and convert to local variables: $scheme, $host,  $path
33
+    // parse base URL  and convert to local variables: $scheme, $host,  $path
34 34
     $tmp = parse_url( $base );
35 35
     extract( $tmp );
36
-	if ( strpos( $rel,"//" ) === 0 ) {
37
-		return $scheme . ':' . $rel;
38
-	}
39
-	// return if already absolute URL
40
-	if ( parse_url( $rel, PHP_URL_SCHEME ) != '' ) {
41
-		return $rel;
42
-	}
43
-	// queries and anchors
44
-	if ( $rel[0] == '#' || $rel[0] == '?' ) {
45
-		return $base . $rel;
46
-	}
47
-	// remove non-directory element from path
48
-	$path = preg_replace( '#/[^/]*$#', '', $path );
49
-	// destroy path if relative url points to root
50
-	if ( $rel[0] ==  '/' ) {
51
-		$path = '';
52
-	}
53
-	// dirty absolute URL
54
-	$abs = $host . $path . "/" . $rel;
55
-	// replace '//' or  '/./' or '/foo/../' with '/'
56
-	$abs = preg_replace( "/(\/\.?\/)/", "/", $abs );
57
-	$abs = preg_replace( "/\/(?!\.\.)[^\/]+\/\.\.\//", "/", $abs );
58
-	// absolute URL is ready!
59
-	return $scheme . '://' . $abs;
36
+    if ( strpos( $rel,"//" ) === 0 ) {
37
+        return $scheme . ':' . $rel;
38
+    }
39
+    // return if already absolute URL
40
+    if ( parse_url( $rel, PHP_URL_SCHEME ) != '' ) {
41
+        return $rel;
42
+    }
43
+    // queries and anchors
44
+    if ( $rel[0] == '#' || $rel[0] == '?' ) {
45
+        return $base . $rel;
46
+    }
47
+    // remove non-directory element from path
48
+    $path = preg_replace( '#/[^/]*$#', '', $path );
49
+    // destroy path if relative url points to root
50
+    if ( $rel[0] ==  '/' ) {
51
+        $path = '';
52
+    }
53
+    // dirty absolute URL
54
+    $abs = $host . $path . "/" . $rel;
55
+    // replace '//' or  '/./' or '/foo/../' with '/'
56
+    $abs = preg_replace( "/(\/\.?\/)/", "/", $abs );
57
+    $abs = preg_replace( "/\/(?!\.\.)[^\/]+\/\.\.\//", "/", $abs );
58
+    // absolute URL is ready!
59
+    return $scheme . '://' . $abs;
60 60
 }
61 61
 $feedData = array();
62 62
 
63 63
 // create Feed
64 64
 foreach ($urls as $section=>$url) {
65
-	$output = '';
65
+    $output = '';
66 66
     $rss = @fetch_rss($url);
67 67
     if( !$rss ){
68
-    	$feedData[$section] = 'Failed to retrieve ' . $url;
69
-    	continue;
70
-	}
68
+        $feedData[$section] = 'Failed to retrieve ' . $url;
69
+        continue;
70
+    }
71 71
     $output .= '<ul>';
72 72
 
73 73
     $items = array_slice($rss->items, 0, $itemsNumber);
@@ -85,5 +85,5 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     $output .= '</ul>';
88
-	$feedData[$section] = $output;
88
+    $feedData[$section] = $output;
89 89
 }
Please login to merge, or discard this patch.
manager/includes/tmplvars.format.inc.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -7,366 +7,366 @@
 block discarded – undo
7 7
 // Added by Raymond 20-Jan-2005
8 8
 function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') {
9 9
 
10
-	global $modx;
10
+    global $modx;
11 11
     $o = '';
12 12
 
13 13
     // process any TV commands in value
14
-	$docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier;
15
-	$value = ProcessTVCommand($value, $name, $docid);
14
+    $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier;
15
+    $value = ProcessTVCommand($value, $name, $docid);
16 16
 
17
-	$params = array();
18
-	if($paramstring) {
19
-		$cp = explode("&", $paramstring);
20
-		foreach($cp as $p => $v) {
21
-			$v = trim($v); // trim
22
-			$ar = explode("=", $v);
23
-			if(is_array($ar) && count($ar) == 2) {
24
-				$params[$ar[0]] = decodeParamValue($ar[1]);
25
-			}
26
-		}
27
-	}
17
+    $params = array();
18
+    if($paramstring) {
19
+        $cp = explode("&", $paramstring);
20
+        foreach($cp as $p => $v) {
21
+            $v = trim($v); // trim
22
+            $ar = explode("=", $v);
23
+            if(is_array($ar) && count($ar) == 2) {
24
+                $params[$ar[0]] = decodeParamValue($ar[1]);
25
+            }
26
+        }
27
+    }
28 28
 
29
-	$id = "tv$name";
30
-	switch($format) {
31
-		case 'image':
32
-			$images = parseInput($value, '||', 'array');
33
-			foreach($images as $image) {
34
-				if(!is_array($image)) {
35
-					$image = explode('==', $image);
36
-				}
37
-				$src = $image[0];
29
+    $id = "tv$name";
30
+    switch($format) {
31
+        case 'image':
32
+            $images = parseInput($value, '||', 'array');
33
+            foreach($images as $image) {
34
+                if(!is_array($image)) {
35
+                    $image = explode('==', $image);
36
+                }
37
+                $src = $image[0];
38 38
 
39
-				if($src) {
40
-					// We have a valid source
41
-					$attributes = '';
42
-					$attr = array(
43
-						'class' => $params['class'],
44
-						'src' => $src,
45
-						'id' => ($params['id'] ? $params['id'] : ''),
46
-						'alt' => $modx->htmlspecialchars($params['alttext']),
47
-						'style' => $params['style']
48
-					);
49
-					if(isset($params['align']) && $params['align'] != 'none') {
50
-						$attr['align'] = $params['align'];
51
-					}
52
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
53
-					$attributes .= ' ' . $params['attrib'];
39
+                if($src) {
40
+                    // We have a valid source
41
+                    $attributes = '';
42
+                    $attr = array(
43
+                        'class' => $params['class'],
44
+                        'src' => $src,
45
+                        'id' => ($params['id'] ? $params['id'] : ''),
46
+                        'alt' => $modx->htmlspecialchars($params['alttext']),
47
+                        'style' => $params['style']
48
+                    );
49
+                    if(isset($params['align']) && $params['align'] != 'none') {
50
+                        $attr['align'] = $params['align'];
51
+                    }
52
+                    foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
53
+                    $attributes .= ' ' . $params['attrib'];
54 54
 
55
-					// Output the image with attributes
56
-					$o .= '<img' . rtrim($attributes) . ' />';
57
-				}
58
-			}
59
-			break;
55
+                    // Output the image with attributes
56
+                    $o .= '<img' . rtrim($attributes) . ' />';
57
+                }
58
+            }
59
+            break;
60 60
 
61
-		case "delim":    // display as delimitted list
62
-			$value = parseInput($value, "||");
63
-			$p = $params['format'] ? $params['format'] : " ";
64
-			if($p == "\\n") {
65
-				$p = "\n";
66
-			}
67
-			$o = str_replace("||", $p, $value);
68
-			break;
61
+        case "delim":    // display as delimitted list
62
+            $value = parseInput($value, "||");
63
+            $p = $params['format'] ? $params['format'] : " ";
64
+            if($p == "\\n") {
65
+                $p = "\n";
66
+            }
67
+            $o = str_replace("||", $p, $value);
68
+            break;
69 69
 
70
-		case "string":
71
-			$value = parseInput($value);
72
-			$format = strtolower($params['format']);
73
-			if($format == 'upper case') {
74
-				$o = strtoupper($value);
75
-			} else if($format == 'lower case') {
76
-				$o = strtolower($value);
77
-			} else if($format == 'sentence case') {
78
-				$o = ucfirst($value);
79
-			} else if($format == 'capitalize') {
80
-				$o = ucwords($value);
81
-			} else {
82
-				$o = $value;
83
-			}
84
-			break;
70
+        case "string":
71
+            $value = parseInput($value);
72
+            $format = strtolower($params['format']);
73
+            if($format == 'upper case') {
74
+                $o = strtoupper($value);
75
+            } else if($format == 'lower case') {
76
+                $o = strtolower($value);
77
+            } else if($format == 'sentence case') {
78
+                $o = ucfirst($value);
79
+            } else if($format == 'capitalize') {
80
+                $o = ucwords($value);
81
+            } else {
82
+                $o = $value;
83
+            }
84
+            break;
85 85
 
86
-		case "date":
87
-			if($value != '' || $params['default'] == 'Yes') {
88
-				if(empty($value)) {
89
-					$value = 'now';
90
-				}
91
-				$timestamp = getUnixtimeFromDateString($value);
92
-				$p = $params['format'] ? $params['format'] : "%A %d, %B %Y";
93
-				$o = strftime($p, $timestamp);
94
-			} else {
95
-				$value = '';
96
-			}
97
-			break;
86
+        case "date":
87
+            if($value != '' || $params['default'] == 'Yes') {
88
+                if(empty($value)) {
89
+                    $value = 'now';
90
+                }
91
+                $timestamp = getUnixtimeFromDateString($value);
92
+                $p = $params['format'] ? $params['format'] : "%A %d, %B %Y";
93
+                $o = strftime($p, $timestamp);
94
+            } else {
95
+                $value = '';
96
+            }
97
+            break;
98 98
 
99
-		case "hyperlink":
100
-			$value = parseInput($value, "||", "array");
101
-			$o = '';
102
-			$countValue = count($value);
103
-			for($i = 0; $i < $countValue; $i++) {
104
-				list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]);
105
-				if(!$url) {
106
-					$url = $name;
107
-				}
108
-				if($url) {
109
-					if($o) {
110
-						$o .= '<br />';
111
-					}
112
-					$attributes = '';
113
-					// setup the link attributes
114
-					$attr = array(
115
-						'href' => $url,
116
-						'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name,
117
-						'class' => $params['class'],
118
-						'style' => $params['style'],
119
-						'target' => $params['target'],
120
-					);
121
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
122
-					$attributes .= ' ' . $params['attrib']; // add extra
99
+        case "hyperlink":
100
+            $value = parseInput($value, "||", "array");
101
+            $o = '';
102
+            $countValue = count($value);
103
+            for($i = 0; $i < $countValue; $i++) {
104
+                list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]);
105
+                if(!$url) {
106
+                    $url = $name;
107
+                }
108
+                if($url) {
109
+                    if($o) {
110
+                        $o .= '<br />';
111
+                    }
112
+                    $attributes = '';
113
+                    // setup the link attributes
114
+                    $attr = array(
115
+                        'href' => $url,
116
+                        'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name,
117
+                        'class' => $params['class'],
118
+                        'style' => $params['style'],
119
+                        'target' => $params['target'],
120
+                    );
121
+                    foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
122
+                    $attributes .= ' ' . $params['attrib']; // add extra
123 123
 
124
-					// Output the link
125
-					$o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>';
126
-				}
127
-			}
128
-			break;
124
+                    // Output the link
125
+                    $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>';
126
+                }
127
+            }
128
+            break;
129 129
 
130
-		case "htmltag":
131
-			$value = parseInput($value, "||", "array");
132
-			$tagid = $params['tagid'];
133
-			$tagname = ($params['tagname']) ? $params['tagname'] : 'div';
134
-			$o = '';
135
-			// Loop through a list of tags
130
+        case "htmltag":
131
+            $value = parseInput($value, "||", "array");
132
+            $tagid = $params['tagid'];
133
+            $tagname = ($params['tagname']) ? $params['tagname'] : 'div';
134
+            $o = '';
135
+            // Loop through a list of tags
136 136
             $countValue = count($value);
137
-			for($i = 0; $i < $countValue; $i++) {
138
-				$tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i];
139
-				if(!$tagvalue) {
140
-					continue;
141
-				}
137
+            for($i = 0; $i < $countValue; $i++) {
138
+                $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i];
139
+                if(!$tagvalue) {
140
+                    continue;
141
+                }
142 142
 
143
-				$attributes = '';
144
-				$attr = array(
145
-					'id' => ($tagid ? $tagid : $id),
146
-					// 'tv' already added to id
147
-					'class' => $params['class'],
148
-					'style' => $params['style'],
149
-				);
150
-				foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
151
-				$attributes .= ' ' . $params['attrib']; // add extra
143
+                $attributes = '';
144
+                $attr = array(
145
+                    'id' => ($tagid ? $tagid : $id),
146
+                    // 'tv' already added to id
147
+                    'class' => $params['class'],
148
+                    'style' => $params['style'],
149
+                );
150
+                foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
151
+                $attributes .= ' ' . $params['attrib']; // add extra
152 152
 
153
-				// Output the HTML Tag
154
-				$o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>';
155
-			}
156
-			break;
153
+                // Output the HTML Tag
154
+                $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>';
155
+            }
156
+            break;
157 157
 
158
-		case "richtext":
159
-			$value = parseInput($value);
160
-			$w = $params['w'] ? $params['w'] : '100%';
161
-			$h = $params['h'] ? $params['h'] : '400px';
162
-			$richtexteditor = $params['edt'] ? $params['edt'] : "";
163
-			$o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">';
164
-			$o .= $modx->htmlspecialchars($value);
165
-			$o .= '</textarea></div>';
166
-			$replace_richtext = array($id);
167
-			// setup editors
168
-			if(!empty($replace_richtext) && !empty($richtexteditor)) {
169
-				// invoke OnRichTextEditorInit event
170
-				$evtOut = $modx->invokeEvent("OnRichTextEditorInit", array(
171
-					'editor' => $richtexteditor,
172
-					'elements' => $replace_richtext,
173
-					'forfrontend' => 1,
174
-					'width' => $w,
175
-					'height' => $h
176
-				));
177
-				if(is_array($evtOut)) {
178
-					$o .= implode("", $evtOut);
179
-				}
180
-			}
181
-			break;
158
+        case "richtext":
159
+            $value = parseInput($value);
160
+            $w = $params['w'] ? $params['w'] : '100%';
161
+            $h = $params['h'] ? $params['h'] : '400px';
162
+            $richtexteditor = $params['edt'] ? $params['edt'] : "";
163
+            $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">';
164
+            $o .= $modx->htmlspecialchars($value);
165
+            $o .= '</textarea></div>';
166
+            $replace_richtext = array($id);
167
+            // setup editors
168
+            if(!empty($replace_richtext) && !empty($richtexteditor)) {
169
+                // invoke OnRichTextEditorInit event
170
+                $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array(
171
+                    'editor' => $richtexteditor,
172
+                    'elements' => $replace_richtext,
173
+                    'forfrontend' => 1,
174
+                    'width' => $w,
175
+                    'height' => $h
176
+                ));
177
+                if(is_array($evtOut)) {
178
+                    $o .= implode("", $evtOut);
179
+                }
180
+            }
181
+            break;
182 182
 
183
-		case "unixtime":
184
-			$value = parseInput($value);
185
-			$o = getUnixtimeFromDateString($value);
186
-			break;
183
+        case "unixtime":
184
+            $value = parseInput($value);
185
+            $o = getUnixtimeFromDateString($value);
186
+            break;
187 187
 
188
-		case "viewport":
189
-			$value = parseInput($value);
190
-			$id = '_' . time();
191
-			if(!$params['vpid']) {
192
-				$params['vpid'] = $id;
193
-			}
194
-			$sTag = "<iframe";
195
-			$eTag = "</iframe>";
196
-			$autoMode = "0";
197
-			$w = $params['width'];
198
-			$h = $params['height'];
199
-			if($params['stretch'] == 'Yes') {
200
-				$w = "100%";
201
-				$h = "100%";
202
-			}
203
-			if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) {
204
-				$autoMode = "3";  //both
205
-			} else if($params['awidth'] == 'Yes') {
206
-				$autoMode = "1"; //width only
207
-			} else if($params['aheight'] == 'Yes') {
208
-				$autoMode = "2";    //height only
209
-			}
188
+        case "viewport":
189
+            $value = parseInput($value);
190
+            $id = '_' . time();
191
+            if(!$params['vpid']) {
192
+                $params['vpid'] = $id;
193
+            }
194
+            $sTag = "<iframe";
195
+            $eTag = "</iframe>";
196
+            $autoMode = "0";
197
+            $w = $params['width'];
198
+            $h = $params['height'];
199
+            if($params['stretch'] == 'Yes') {
200
+                $w = "100%";
201
+                $h = "100%";
202
+            }
203
+            if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) {
204
+                $autoMode = "3";  //both
205
+            } else if($params['awidth'] == 'Yes') {
206
+                $autoMode = "1"; //width only
207
+            } else if($params['aheight'] == 'Yes') {
208
+                $autoMode = "2";    //height only
209
+            }
210 210
 
211
-			$modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array(
212
-				'name' => 'viewport',
213
-				'version' => '0',
214
-				'plaintext' => false
215
-			));
216
-			$o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' ";
217
-			if($params['class']) {
218
-				$o .= " class='" . $params['class'] . "' ";
219
-			}
220
-			if($params['style']) {
221
-				$o .= " style='" . $params['style'] . "' ";
222
-			}
223
-			if($params['attrib']) {
224
-				$o .= $params['attrib'] . " ";
225
-			}
226
-			$o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' ";
227
-			$o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' ";
228
-			$o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' ";
229
-			$o .= ">";
230
-			$o .= $eTag;
231
-			break;
211
+            $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array(
212
+                'name' => 'viewport',
213
+                'version' => '0',
214
+                'plaintext' => false
215
+            ));
216
+            $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' ";
217
+            if($params['class']) {
218
+                $o .= " class='" . $params['class'] . "' ";
219
+            }
220
+            if($params['style']) {
221
+                $o .= " style='" . $params['style'] . "' ";
222
+            }
223
+            if($params['attrib']) {
224
+                $o .= $params['attrib'] . " ";
225
+            }
226
+            $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' ";
227
+            $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' ";
228
+            $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' ";
229
+            $o .= ">";
230
+            $o .= $eTag;
231
+            break;
232 232
 
233
-		case "datagrid":
234
-			include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
235
-			$grd = new DataGrid('', $value);
233
+        case "datagrid":
234
+            include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php";
235
+            $grd = new DataGrid('', $value);
236 236
 
237
-			$grd->noRecordMsg = $params['egmsg'];
237
+            $grd->noRecordMsg = $params['egmsg'];
238 238
 
239
-			$grd->columnHeaderClass = $params['chdrc'];
240
-			$grd->cssClass = $params['tblc'];
241
-			$grd->itemClass = $params['itmc'];
242
-			$grd->altItemClass = $params['aitmc'];
239
+            $grd->columnHeaderClass = $params['chdrc'];
240
+            $grd->cssClass = $params['tblc'];
241
+            $grd->itemClass = $params['itmc'];
242
+            $grd->altItemClass = $params['aitmc'];
243 243
 
244
-			$grd->columnHeaderStyle = $params['chdrs'];
245
-			$grd->cssStyle = $params['tbls'];
246
-			$grd->itemStyle = $params['itms'];
247
-			$grd->altItemStyle = $params['aitms'];
244
+            $grd->columnHeaderStyle = $params['chdrs'];
245
+            $grd->cssStyle = $params['tbls'];
246
+            $grd->itemStyle = $params['itms'];
247
+            $grd->altItemStyle = $params['aitms'];
248 248
 
249
-			$grd->columns = $params['cols'];
250
-			$grd->fields = $params['flds'];
251
-			$grd->colWidths = $params['cwidth'];
252
-			$grd->colAligns = $params['calign'];
253
-			$grd->colColors = $params['ccolor'];
254
-			$grd->colTypes = $params['ctype'];
249
+            $grd->columns = $params['cols'];
250
+            $grd->fields = $params['flds'];
251
+            $grd->colWidths = $params['cwidth'];
252
+            $grd->colAligns = $params['calign'];
253
+            $grd->colColors = $params['ccolor'];
254
+            $grd->colTypes = $params['ctype'];
255 255
 
256
-			$grd->cellPadding = $params['cpad'];
257
-			$grd->cellSpacing = $params['cspace'];
258
-			$grd->header = $params['head'];
259
-			$grd->footer = $params['foot'];
260
-			$grd->pageSize = $params['psize'];
261
-			$grd->pagerLocation = $params['ploc'];
262
-			$grd->pagerClass = $params['pclass'];
263
-			$grd->pagerStyle = $params['pstyle'];
264
-			$o = $grd->render();
265
-			break;
256
+            $grd->cellPadding = $params['cpad'];
257
+            $grd->cellSpacing = $params['cspace'];
258
+            $grd->header = $params['head'];
259
+            $grd->footer = $params['foot'];
260
+            $grd->pageSize = $params['psize'];
261
+            $grd->pagerLocation = $params['ploc'];
262
+            $grd->pagerClass = $params['pclass'];
263
+            $grd->pagerStyle = $params['pstyle'];
264
+            $o = $grd->render();
265
+            break;
266 266
 
267
-		case 'htmlentities':
268
-			$value = parseInput($value);
269
-			if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
270
-				// remove delimiter from checkbox and listbox-multiple TVs
271
-				$value = str_replace('||', '', $value);
272
-			}
273
-			$o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']);
274
-			break;
267
+        case 'htmlentities':
268
+            $value = parseInput($value);
269
+            if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
270
+                // remove delimiter from checkbox and listbox-multiple TVs
271
+                $value = str_replace('||', '', $value);
272
+            }
273
+            $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']);
274
+            break;
275 275
 
276
-		case 'custom_widget':
277
-			$widget_output = '';
278
-			$o = '';
279
-			/* If we are loading a file */
280
-			if(substr($params['output'], 0, 5) == "@FILE") {
281
-				$file_name = MODX_BASE_PATH . trim(substr($params['output'], 6));
282
-				if(!file_exists($file_name)) {
283
-					$widget_output = $file_name . ' does not exist';
284
-				} else {
285
-					$widget_output = file_get_contents($file_name);
286
-				}
287
-			} elseif(substr($params['output'], 0, 8) == '@INCLUDE') {
288
-				$file_name = MODX_BASE_PATH . trim(substr($params['output'], 9));
289
-				if(!file_exists($file_name)) {
290
-					$widget_output = $file_name . ' does not exist';
291
-				} else {
292
-					/* The included file needs to set $widget_output. Can be string, array, object */
293
-					include $file_name;
294
-				}
295
-			} elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') {
296
-				$chunk_name = trim(substr($params['output'], 7));
297
-				$widget_output = $modx->getChunk($chunk_name);
298
-			} elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') {
299
-				$eval_str = trim(substr($params['output'], 6));
300
-				$widget_output = eval($eval_str);
301
-			} elseif($value !== '') {
302
-				$widget_output = $params['output'];
303
-			} else {
304
-				$widget_output = '';
305
-			}
306
-			if(is_string($widget_output)) {
307
-				$_ = $modx->config['enable_filter'];
308
-				$modx->config['enable_filter'] = 1;
309
-				$widget_output = $modx->parseText($widget_output, array('value' => $value));
310
-				$modx->config['enable_filter'] = $_;
311
-				$o = $modx->parseDocumentSource($widget_output);
312
-			} else {
313
-				$o = $widget_output;
314
-			}
315
-			break;
276
+        case 'custom_widget':
277
+            $widget_output = '';
278
+            $o = '';
279
+            /* If we are loading a file */
280
+            if(substr($params['output'], 0, 5) == "@FILE") {
281
+                $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6));
282
+                if(!file_exists($file_name)) {
283
+                    $widget_output = $file_name . ' does not exist';
284
+                } else {
285
+                    $widget_output = file_get_contents($file_name);
286
+                }
287
+            } elseif(substr($params['output'], 0, 8) == '@INCLUDE') {
288
+                $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9));
289
+                if(!file_exists($file_name)) {
290
+                    $widget_output = $file_name . ' does not exist';
291
+                } else {
292
+                    /* The included file needs to set $widget_output. Can be string, array, object */
293
+                    include $file_name;
294
+                }
295
+            } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') {
296
+                $chunk_name = trim(substr($params['output'], 7));
297
+                $widget_output = $modx->getChunk($chunk_name);
298
+            } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') {
299
+                $eval_str = trim(substr($params['output'], 6));
300
+                $widget_output = eval($eval_str);
301
+            } elseif($value !== '') {
302
+                $widget_output = $params['output'];
303
+            } else {
304
+                $widget_output = '';
305
+            }
306
+            if(is_string($widget_output)) {
307
+                $_ = $modx->config['enable_filter'];
308
+                $modx->config['enable_filter'] = 1;
309
+                $widget_output = $modx->parseText($widget_output, array('value' => $value));
310
+                $modx->config['enable_filter'] = $_;
311
+                $o = $modx->parseDocumentSource($widget_output);
312
+            } else {
313
+                $o = $widget_output;
314
+            }
315
+            break;
316 316
 
317
-		default:
318
-			$value = parseInput($value);
319
-			if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
320
-				// add separator
321
-				$value = explode('||', $value);
322
-				$value = implode($sep, $value);
323
-			}
324
-			$o = $value;
325
-			break;
326
-	}
327
-	return $o;
317
+        default:
318
+            $value = parseInput($value);
319
+            if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') {
320
+                // add separator
321
+                $value = explode('||', $value);
322
+                $value = implode($sep, $value);
323
+            }
324
+            $o = $value;
325
+            break;
326
+    }
327
+    return $o;
328 328
 }
329 329
 
330 330
 function decodeParamValue($s) {
331
-	$s = str_replace("%3D", '=', $s); // =
332
-	$s = str_replace("%26", '&', $s); // &
333
-	return $s;
331
+    $s = str_replace("%3D", '=', $s); // =
332
+    $s = str_replace("%26", '&', $s); // &
333
+    return $s;
334 334
 }
335 335
 
336 336
 // returns an array if a delimiter is present. returns array is a recordset is present
337 337
 function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array
338
-	global $modx;
339
-	if($modx->db->isResult($src)) {
340
-		// must be a recordset
341
-		$rows = array();
342
-		while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
343
-		return ($type == "array") ? $rows : implode($delim, $rows);
344
-	} else {
345
-		// must be a text
346
-		if($type == "array") {
347
-			return explode($delim, $src);
348
-		} else {
349
-			return $src;
350
-		}
351
-	}
338
+    global $modx;
339
+    if($modx->db->isResult($src)) {
340
+        // must be a recordset
341
+        $rows = array();
342
+        while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
343
+        return ($type == "array") ? $rows : implode($delim, $rows);
344
+    } else {
345
+        // must be a text
346
+        if($type == "array") {
347
+            return explode($delim, $src);
348
+        } else {
349
+            return $src;
350
+        }
351
+    }
352 352
 }
353 353
 
354 354
 function getUnixtimeFromDateString($value) {
355
-	$timestamp = false;
356
-	// Check for MySQL or legacy style date
357
-	$date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
358
-	$date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
359
-	$matches = array();
360
-	if(strpos($value, '-') !== false) {
361
-		if(preg_match($date_match_1, $value, $matches)) {
362
-			$timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
363
-		} elseif(preg_match($date_match_2, $value, $matches)) {
364
-			$timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
365
-		}
366
-	}
367
-	// If those didn't work, use strtotime to figure out the date
368
-	if($timestamp === false || $timestamp === -1) {
369
-		$timestamp = strtotime($value);
370
-	}
371
-	return $timestamp;
355
+    $timestamp = false;
356
+    // Check for MySQL or legacy style date
357
+    $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
358
+    $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
359
+    $matches = array();
360
+    if(strpos($value, '-') !== false) {
361
+        if(preg_match($date_match_1, $value, $matches)) {
362
+            $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
363
+        } elseif(preg_match($date_match_2, $value, $matches)) {
364
+            $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
365
+        }
366
+    }
367
+    // If those didn't work, use strtotime to figure out the date
368
+    if($timestamp === false || $timestamp === -1) {
369
+        $timestamp = strtotime($value);
370
+    }
371
+    return $timestamp;
372 372
 }
Please login to merge, or discard this patch.