@@ -1,8 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | $userid = (int)$value; |
3 | 3 | if (!isset($modx->filter->cache['ui'][$userid])) { |
4 | - if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid)); |
|
5 | - else $user = $modx->getUserInfo($userid); |
|
4 | + if ($userid < 0) { |
|
5 | + $user = $modx->getWebUserInfo(abs($userid)); |
|
6 | + } else { |
|
7 | + $user = $modx->getUserInfo($userid); |
|
8 | + } |
|
6 | 9 | $modx->filter->cache['ui'][$userid] = $user; |
7 | 10 | } else { |
8 | 11 | $user = $modx->filter->cache['ui'][$userid]; |
@@ -1,9 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -if(strpos($opt,',')) list($limit,$delim) = explode(',', $opt); |
|
3 | -elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} |
|
4 | -else {$limit=124;$delim='';} |
|
2 | +if(strpos($opt,',')) { |
|
3 | + list($limit,$delim) = explode(',', $opt); |
|
4 | +} elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} else {$limit=124;$delim='';} |
|
5 | 5 | |
6 | -if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
6 | +if($delim==='') { |
|
7 | + $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
8 | +} |
|
7 | 9 | $limit = (int)$limit; |
8 | 10 | |
9 | 11 | $content = $modx->filter->parseDocumentSource($value); |
@@ -11,8 +13,9 @@ discard block |
||
11 | 13 | $content = strip_tags($content); |
12 | 14 | |
13 | 15 | $content = str_replace(array("\r\n","\r","\n","\t",' '),' ',$content); |
14 | -if(preg_match('/\s+/',$content)) |
|
16 | +if(preg_match('/\s+/',$content)) { |
|
15 | 17 | $content = preg_replace('/\s+/',' ',$content); |
18 | +} |
|
16 | 19 | $content = trim($content); |
17 | 20 | |
18 | 21 | $pos = $modx->filter->strpos($content, $delim); |
@@ -21,23 +24,35 @@ discard block |
||
21 | 24 | $_ = explode($delim, $content); |
22 | 25 | $text = ''; |
23 | 26 | foreach($_ as $v) { |
24 | - if($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
27 | + if($limit <= $modx->filter->strlen($text.$v.$delim)) { |
|
28 | + break; |
|
29 | + } |
|
25 | 30 | $text .= $v.$delim; |
26 | 31 | } |
27 | - if($text) $content = $text; |
|
28 | -} |
|
32 | + if($text) { |
|
33 | + $content = $text; |
|
34 | + } |
|
35 | + } |
|
29 | 36 | |
30 | 37 | if($limit<$modx->filter->strlen($content) && strpos($content,' ')!==false) { |
31 | 38 | $_ = explode(' ', $content); |
32 | 39 | $text = ''; |
33 | 40 | foreach($_ as $v) { |
34 | - if($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
41 | + if($limit <= $modx->filter->strlen($text.$v.' ')) { |
|
42 | + break; |
|
43 | + } |
|
35 | 44 | $text .= $v . ' '; |
36 | 45 | } |
37 | - if($text!=='') $content = $text; |
|
38 | -} |
|
46 | + if($text!=='') { |
|
47 | + $content = $text; |
|
48 | + } |
|
49 | + } |
|
39 | 50 | |
40 | -if($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
41 | -if($modx->filter->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim; |
|
51 | +if($limit < $modx->filter->strlen($content)) { |
|
52 | + $content = $modx->filter->substr($content, 0, $limit); |
|
53 | +} |
|
54 | +if($modx->filter->substr($content,-1)==$delim) { |
|
55 | + $content = rtrim($content,$delim) . $delim; |
|
56 | +} |
|
42 | 57 | |
43 | 58 | return $content; |
@@ -1,16 +1,32 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | $this->old = new OldFunctions(); |
3 | -class OldFunctions { |
|
3 | +class OldFunctions |
|
4 | +{ |
|
4 | 5 | |
5 | - public function dbConnect() {global $modx; $modx->db->connect();$modx->rs = $modx->db->conn;} |
|
6 | - public function dbQuery($sql) {global $modx;return $modx->db->query($sql);} |
|
7 | - public function recordCount($rs) {global $modx;return $modx->db->getRecordCount($rs);} |
|
8 | - public function fetchRow($rs,$mode='assoc') {global $modx;return $modx->db->getRow($rs, $mode);} |
|
9 | - public function affectedRows($rs) {global $modx;return $modx->db->getAffectedRows($rs);} |
|
10 | - public function insertId($rs) {global $modx;return $modx->db->getInsertId($rs);} |
|
11 | - public function dbClose() {global $modx; $modx->db->disconnect();} |
|
6 | + public function dbConnect() |
|
7 | + { |
|
8 | +global $modx; $modx->db->connect();$modx->rs = $modx->db->conn;} |
|
9 | + public function dbQuery($sql) |
|
10 | + { |
|
11 | +global $modx;return $modx->db->query($sql);} |
|
12 | + public function recordCount($rs) |
|
13 | + { |
|
14 | +global $modx;return $modx->db->getRecordCount($rs);} |
|
15 | + public function fetchRow($rs,$mode='assoc') |
|
16 | + { |
|
17 | +global $modx;return $modx->db->getRow($rs, $mode);} |
|
18 | + public function affectedRows($rs) |
|
19 | + { |
|
20 | +global $modx;return $modx->db->getAffectedRows($rs);} |
|
21 | + public function insertId($rs) |
|
22 | + { |
|
23 | +global $modx;return $modx->db->getInsertId($rs);} |
|
24 | + public function dbClose() |
|
25 | + { |
|
26 | +global $modx; $modx->db->disconnect();} |
|
12 | 27 | |
13 | - public function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) { |
|
28 | + public function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) |
|
29 | + { |
|
14 | 30 | // first find out whether the value passed is an array |
15 | 31 | if (!is_array($array)) { |
16 | 32 | return "<ul><li>Bad list</li></ul>"; |
@@ -37,7 +53,8 @@ discard block |
||
37 | 53 | } |
38 | 54 | |
39 | 55 | |
40 | - public function getUserData() { |
|
56 | + public function getUserData() |
|
57 | + { |
|
41 | 58 | $client['ip'] = $_SERVER['REMOTE_ADDR']; |
42 | 59 | $client['ua'] = $_SERVER['HTTP_USER_AGENT']; |
43 | 60 | return $client; |
@@ -45,35 +62,42 @@ discard block |
||
45 | 62 | |
46 | 63 | # Returns true, install or interact when inside manager |
47 | 64 | // deprecated |
48 | - public function insideManager() { |
|
65 | + public function insideManager() |
|
66 | + { |
|
49 | 67 | $m= false; |
50 | 68 | if( defined('IN_MANAGER_MODE') && IN_MANAGER_MODE === true) { |
51 | 69 | $m= true; |
52 | - if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') |
|
53 | - $m= "interact"; |
|
54 | - else |
|
55 | - if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') |
|
56 | - $m= "install"; |
|
70 | + if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') { |
|
71 | + $m= "interact"; |
|
72 | + } else |
|
73 | + if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') { |
|
74 | + $m= "install"; |
|
75 | + } |
|
57 | 76 | } |
58 | 77 | return $m; |
59 | 78 | } |
60 | 79 | |
61 | 80 | // deprecated |
62 | - public function putChunk($chunkName) { // alias name >.< |
|
81 | + public function putChunk($chunkName) |
|
82 | + { |
|
83 | +// alias name >.< |
|
63 | 84 | global $modx; |
64 | 85 | return $modx->getChunk($chunkName); |
65 | 86 | } |
66 | 87 | |
67 | - public function getDocGroups() { |
|
88 | + public function getDocGroups() |
|
89 | + { |
|
68 | 90 | global $modx; |
69 | 91 | return $modx->getUserDocGroups(); |
70 | 92 | } // deprecated |
71 | 93 | |
72 | - public function changePassword($o, $n) { |
|
94 | + public function changePassword($o, $n) |
|
95 | + { |
|
73 | 96 | return changeWebUserPassword($o, $n); |
74 | 97 | } // deprecated |
75 | 98 | |
76 | - public function userLoggedIn() { |
|
99 | + public function userLoggedIn() |
|
100 | + { |
|
77 | 101 | global $modx; |
78 | 102 | $userdetails= array (); |
79 | 103 | if ($modx->isFrontend() && isset ($_SESSION['webValidated'])) { |
@@ -96,18 +120,22 @@ discard block |
||
96 | 120 | } |
97 | 121 | } |
98 | 122 | |
99 | - public function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) { |
|
123 | + public function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) |
|
124 | + { |
|
100 | 125 | // function to retrieve form results into an associative array |
101 | 126 | global $modx; |
102 | 127 | $results= array (); |
103 | 128 | $method= strtoupper($method); |
104 | - if ($method == "") |
|
105 | - $method= $REQUEST_METHOD; |
|
106 | - if ($method == "POST") |
|
107 | - $method= & $_POST; |
|
108 | - elseif ($method == "GET") $method= & $_GET; |
|
109 | - else |
|
110 | - return false; |
|
129 | + if ($method == "") { |
|
130 | + $method= $REQUEST_METHOD; |
|
131 | + } |
|
132 | + if ($method == "POST") { |
|
133 | + $method= & $_POST; |
|
134 | + } elseif ($method == "GET") { |
|
135 | + $method= & $_GET; |
|
136 | + } else { |
|
137 | + return false; |
|
138 | + } |
|
111 | 139 | reset($method); |
112 | 140 | foreach ($method as $key => $value) { |
113 | 141 | if (($prefix != "") && (substr($key, 0, strlen($prefix)) == $prefix)) { |
@@ -115,10 +143,12 @@ discard block |
||
115 | 143 | $pieces= explode($prefix, $key, 2); |
116 | 144 | $key= $pieces[1]; |
117 | 145 | $results[$key]= $value; |
118 | - } else |
|
119 | - $results[$key]= $value; |
|
146 | + } else { |
|
147 | + $results[$key]= $value; |
|
148 | + } |
|
149 | + } elseif ($prefix == "") { |
|
150 | + $results[$key]= $value; |
|
120 | 151 | } |
121 | - elseif ($prefix == "") $results[$key]= $value; |
|
122 | 152 | } |
123 | 153 | return $results; |
124 | 154 | } |
@@ -129,7 +159,8 @@ discard block |
||
129 | 159 | * @param string $msg Message to show |
130 | 160 | * @param string $url URL to redirect to |
131 | 161 | */ |
132 | - public function webAlert($msg, $url= "") { |
|
162 | + public function webAlert($msg, $url= "") |
|
163 | + { |
|
133 | 164 | global $modx; |
134 | 165 | $msg= addslashes($modx->db->escape($msg)); |
135 | 166 | if (substr(strtolower($url), 0, 11) == "javascript:") { |
@@ -139,9 +170,9 @@ discard block |
||
139 | 170 | $act= ($url ? "window.location.href='" . addslashes($url) . "';" : ""); |
140 | 171 | } |
141 | 172 | $html= "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>"; |
142 | - if ($modx->isFrontend()) |
|
143 | - $modx->regClientScript($html); |
|
144 | - else { |
|
173 | + if ($modx->isFrontend()) { |
|
174 | + $modx->regClientScript($html); |
|
175 | + } else { |
|
145 | 176 | echo $html; |
146 | 177 | } |
147 | 178 | } |
@@ -13,27 +13,31 @@ discard block |
||
13 | 13 | public $dirCheckCount = 0; |
14 | 14 | |
15 | 15 | public function __construct() |
16 | - { |
|
16 | + { |
|
17 | 17 | global $modx; |
18 | 18 | |
19 | - if(!defined('MODX_BASE_PATH')) return false; |
|
19 | + if(!defined('MODX_BASE_PATH')) { |
|
20 | + return false; |
|
21 | + } |
|
20 | 22 | $this->exportstart = $this->get_mtime(); |
21 | 23 | $this->count = 0; |
22 | 24 | $this->setUrlMode(); |
23 | 25 | $this->generate_mode = 'crawl'; |
24 | 26 | $this->targetDir = $modx->config['base_path'] . 'temp/export'; |
25 | - if(!isset($this->total)) $this->getTotal(); |
|
27 | + if(!isset($this->total)) { |
|
28 | + $this->getTotal(); |
|
29 | + } |
|
26 | 30 | } |
27 | 31 | |
28 | 32 | public function setExportDir($dir) |
29 | - { |
|
33 | + { |
|
30 | 34 | $dir = str_replace('\\','/',$dir); |
31 | 35 | $dir = rtrim($dir, '/'); |
32 | 36 | $this->targetDir = $dir; |
33 | 37 | } |
34 | 38 | |
35 | 39 | public function get_mtime() |
36 | - { |
|
40 | + { |
|
37 | 41 | $mtime = microtime(); |
38 | 42 | $mtime = explode(' ', $mtime); |
39 | 43 | $mtime = $mtime[1] + $mtime[0]; |
@@ -41,11 +45,10 @@ discard block |
||
41 | 45 | } |
42 | 46 | |
43 | 47 | public function setUrlMode() |
44 | - { |
|
48 | + { |
|
45 | 49 | global $modx; |
46 | 50 | |
47 | - if($modx->config['friendly_urls']==0) |
|
48 | - { |
|
51 | + if($modx->config['friendly_urls']==0) { |
|
49 | 52 | $modx->config['friendly_urls'] = 1; |
50 | 53 | $modx->config['use_alias_path'] = 1; |
51 | 54 | $modx->clearCache('full'); |
@@ -54,13 +57,12 @@ discard block |
||
54 | 57 | } |
55 | 58 | |
56 | 59 | public function getTotal($ignore_ids='', $noncache='0') |
57 | - { |
|
60 | + { |
|
58 | 61 | global $modx; |
59 | 62 | $tbl_site_content = $modx->getFullTableName('site_content'); |
60 | 63 | |
61 | 64 | $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids))); |
62 | - if(count($ignore_ids)>0) |
|
63 | - { |
|
65 | + if(count($ignore_ids)>0) { |
|
64 | 66 | $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')"; |
65 | 67 | } else { |
66 | 68 | $ignore_ids = ''; |
@@ -76,67 +78,80 @@ discard block |
||
76 | 78 | } |
77 | 79 | |
78 | 80 | public function removeDirectoryAll($directory='') |
79 | - { |
|
81 | + { |
|
80 | 82 | $rs = false; |
81 | - if(empty($directory)) $directory = $this->targetDir; |
|
83 | + if(empty($directory)) { |
|
84 | + $directory = $this->targetDir; |
|
85 | + } |
|
82 | 86 | $directory = rtrim($directory,'/'); |
83 | 87 | // 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; |
|
88 | + if(empty($directory)) { |
|
89 | + return false; |
|
90 | + } |
|
91 | + if(strpos($directory,MODX_BASE_PATH)===false) { |
|
92 | + return $rs; |
|
93 | + } |
|
86 | 94 | |
87 | - if(!is_dir($directory)) return $rs; |
|
88 | - elseif(!is_readable($directory)) return $rs; |
|
89 | - else |
|
90 | - { |
|
95 | + if(!is_dir($directory)) { |
|
96 | + return $rs; |
|
97 | + } elseif(!is_readable($directory)) { |
|
98 | + return $rs; |
|
99 | + } else { |
|
91 | 100 | $files = glob($directory . '/*'); |
92 | - if(!empty($files)) |
|
93 | - { |
|
94 | - foreach($files as $path) |
|
95 | - { |
|
101 | + if(!empty($files)) { |
|
102 | + foreach($files as $path) { |
|
96 | 103 | $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path); |
97 | 104 | } |
98 | 105 | } |
99 | 106 | } |
100 | - if($directory !== $this->targetDir) $rs = rmdir($directory); |
|
107 | + if($directory !== $this->targetDir) { |
|
108 | + $rs = rmdir($directory); |
|
109 | + } |
|
101 | 110 | |
102 | 111 | return $rs; |
103 | 112 | } |
104 | 113 | |
105 | 114 | public function makeFile($docid, $filepath) |
106 | - { |
|
115 | + { |
|
107 | 116 | global $modx,$_lang; |
108 | 117 | $file_permission = octdec($modx->config['new_file_permissions']); |
109 | - if($this->generate_mode==='direct') |
|
110 | - { |
|
118 | + if($this->generate_mode==='direct') { |
|
111 | 119 | $back_lang = $_lang; |
112 | 120 | $src = $modx->executeParser($docid); |
113 | 121 | |
114 | 122 | $_lang = $back_lang; |
123 | + } else { |
|
124 | + $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}"); |
|
115 | 125 | } |
116 | - else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}"); |
|
117 | 126 | |
118 | 127 | |
119 | - if($src !== false) |
|
120 | - { |
|
121 | - if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src); |
|
128 | + if($src !== false) { |
|
129 | + if($this->repl_before!==$this->repl_after) { |
|
130 | + $src = str_replace($this->repl_before,$this->repl_after,$src); |
|
131 | + } |
|
122 | 132 | $result = file_put_contents($filepath,$src); |
123 | - if($result!==false) @chmod($filepath, $file_permission); |
|
133 | + if($result!==false) { |
|
134 | + @chmod($filepath, $file_permission); |
|
135 | + } |
|
124 | 136 | |
125 | - if($result !== false) return 'success'; |
|
126 | - else return 'failed_no_write'; |
|
137 | + if($result !== false) { |
|
138 | + return 'success'; |
|
139 | + } else { |
|
140 | + return 'failed_no_write'; |
|
141 | + } |
|
142 | + } else { |
|
143 | + return 'failed_no_retrieve'; |
|
127 | 144 | } |
128 | - else return 'failed_no_retrieve'; |
|
129 | 145 | } |
130 | 146 | |
131 | 147 | public function getFileName($docid, $alias='', $prefix, $suffix) |
132 | - { |
|
148 | + { |
|
133 | 149 | global $modx; |
134 | 150 | |
135 | - if($alias==='') $filename = $prefix.$docid.$suffix; |
|
136 | - else |
|
137 | - { |
|
138 | - if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false) |
|
139 | - { |
|
151 | + if($alias==='') { |
|
152 | + $filename = $prefix.$docid.$suffix; |
|
153 | + } else { |
|
154 | + if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false) { |
|
140 | 155 | $suffix = ''; |
141 | 156 | } |
142 | 157 | $filename = $prefix.$alias.$suffix; |
@@ -145,7 +160,7 @@ discard block |
||
145 | 160 | } |
146 | 161 | |
147 | 162 | public function run($parent=0) |
148 | - { |
|
163 | + { |
|
149 | 164 | global $_lang; |
150 | 165 | global $modx; |
151 | 166 | |
@@ -187,24 +202,20 @@ discard block |
||
187 | 202 | $ph = array(); |
188 | 203 | $ph['total'] = $this->total; |
189 | 204 | $folder_permission = octdec($modx->config['new_folder_permissions']); |
190 | - while($row = $modx->db->getRow($rs)) |
|
191 | - { |
|
205 | + while($row = $modx->db->getRow($rs)) { |
|
192 | 206 | $this->count++; |
193 | 207 | $filename = ''; |
194 | 208 | $row['count'] = $this->count; |
195 | 209 | $row['url'] = $modx->makeUrl($row['id']); |
196 | 210 | |
197 | - if (!$row['wasNull']) |
|
198 | - { // needs writing a document |
|
211 | + if (!$row['wasNull']) { |
|
212 | +// needs writing a document |
|
199 | 213 | $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix); |
200 | 214 | $filename = $dirpath.$docname; |
201 | - if (!is_file($filename)) |
|
202 | - { |
|
203 | - if($row['published']==='1') |
|
204 | - { |
|
215 | + if (!is_file($filename)) { |
|
216 | + if($row['published']==='1') { |
|
205 | 217 | $status = $this->makeFile($row['id'], $filename); |
206 | - switch($status) |
|
207 | - { |
|
218 | + switch($status) { |
|
208 | 219 | case 'failed_no_write' : |
209 | 220 | $row['status'] = $msg_failed_no_write; |
210 | 221 | break; |
@@ -214,34 +225,38 @@ discard block |
||
214 | 225 | default: |
215 | 226 | $row['status'] = $msg_success; |
216 | 227 | } |
228 | + } else { |
|
229 | + $row['status'] = $msg_failed_no_retrieve; |
|
217 | 230 | } |
218 | - else $row['status'] = $msg_failed_no_retrieve; |
|
231 | + } else { |
|
232 | + $row['status'] = $msg_success_skip_doc; |
|
219 | 233 | } |
220 | - else $row['status'] = $msg_success_skip_doc; |
|
221 | 234 | $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row); |
222 | - } |
|
223 | - else |
|
224 | - { |
|
235 | + } else { |
|
225 | 236 | $row['status'] = $msg_success_skip_dir; |
226 | 237 | $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row); |
227 | 238 | } |
228 | - if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false)) |
|
229 | - { // needs making a folder |
|
239 | + if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false)) { |
|
240 | +// needs making a folder |
|
230 | 241 | $end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id']; |
231 | 242 | $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); |
|
243 | + if(strpos($dir_path,MODX_BASE_PATH)===false) { |
|
244 | + return FALSE; |
|
245 | + } |
|
246 | + if (!is_dir($dir_path)) { |
|
247 | + if (is_file($dir_path)) { |
|
248 | + @unlink($dir_path); |
|
249 | + } |
|
236 | 250 | mkdir($dir_path); |
237 | 251 | @chmod($dir_path, $folder_permission); |
238 | 252 | |
239 | 253 | } |
240 | 254 | |
241 | 255 | |
242 | - if($modx->config['make_folders']==='1' && $row['published']==='1') |
|
243 | - { |
|
244 | - if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html'); |
|
256 | + if($modx->config['make_folders']==='1' && $row['published']==='1') { |
|
257 | + if( ! empty($filename) && is_file($filename)) { |
|
258 | + rename($filename,$dir_path . '/index.html'); |
|
259 | + } |
|
245 | 260 | } |
246 | 261 | $this->targetDir = $dir_path; |
247 | 262 | $this->run($row['id']); |
@@ -252,7 +267,9 @@ discard block |
||
252 | 267 | |
253 | 268 | public function curl_get_contents($url, $timeout = 30 ) |
254 | 269 | { |
255 | - if(!function_exists('curl_init')) return @file_get_contents($url); |
|
270 | + if(!function_exists('curl_init')) { |
|
271 | + return @file_get_contents($url); |
|
272 | + } |
|
256 | 273 | |
257 | 274 | $ch = curl_init(); |
258 | 275 | curl_setopt($ch, CURLOPT_URL, $url); |
@@ -269,8 +286,7 @@ discard block |
||
269 | 286 | |
270 | 287 | public function parsePlaceholder($tpl,$ph=array()) |
271 | 288 | { |
272 | - foreach($ph as $k=>$v) |
|
273 | - { |
|
289 | + foreach($ph as $k=>$v) { |
|
274 | 290 | $k = "[+{$k}+]"; |
275 | 291 | $tpl = str_replace($k,$v,$tpl); |
276 | 292 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | public $ds; // datasource |
16 | 17 | public $id; |
@@ -72,7 +73,8 @@ discard block |
||
72 | 73 | */ |
73 | 74 | public $cdelim; |
74 | 75 | |
75 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
76 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) |
|
77 | + { |
|
76 | 78 | global $__DataGridCnt; |
77 | 79 | |
78 | 80 | // set id |
@@ -88,11 +90,13 @@ discard block |
||
88 | 90 | $this->pagerLocation = 'top-right'; |
89 | 91 | } |
90 | 92 | |
91 | - public function setDataSource($ds) { |
|
93 | + public function setDataSource($ds) |
|
94 | + { |
|
92 | 95 | $this->ds = $ds; |
93 | 96 | } |
94 | 97 | |
95 | - public function render() { |
|
98 | + public function render() |
|
99 | + { |
|
96 | 100 | global $modx; |
97 | 101 | $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
98 | 102 | $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
@@ -127,7 +131,9 @@ discard block |
||
127 | 131 | |
128 | 132 | if($this->_isDataset && !$this->columns) { |
129 | 133 | $cols = $modx->db->numFields($this->ds); |
130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
134 | + for($i = 0; $i < $cols; $i++) { |
|
135 | + $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
136 | + } |
|
131 | 137 | } |
132 | 138 | |
133 | 139 | // start grid |
@@ -207,7 +213,8 @@ discard block |
||
207 | 213 | |
208 | 214 | // format column values |
209 | 215 | |
210 | - public function RenderRowFnc($n, $row) { |
|
216 | + public function RenderRowFnc($n, $row) |
|
217 | + { |
|
211 | 218 | if($this->_alt == 0) { |
212 | 219 | $Style = $this->_itemStyle; |
213 | 220 | $Class = $this->_itemClass; |
@@ -237,7 +244,8 @@ discard block |
||
237 | 244 | return $o; |
238 | 245 | } |
239 | 246 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
247 | + public function formatColumnValue($row, $value, $type, &$align) |
|
248 | + { |
|
241 | 249 | if(strpos($type, ":") !== false) { |
242 | 250 | list($type, $type_format) = explode(":", $type, 2); |
243 | 251 | } |
@@ -3,7 +3,8 @@ discard block |
||
3 | 3 | global $ContextMenuCnt; |
4 | 4 | $ContextMenuCnt = 0; |
5 | 5 | |
6 | -class ContextMenu { |
|
6 | +class ContextMenu |
|
7 | +{ |
|
7 | 8 | public $id; |
8 | 9 | /** |
9 | 10 | * @var string |
@@ -18,7 +19,8 @@ discard block |
||
18 | 19 | */ |
19 | 20 | public $width = 120; |
20 | 21 | |
21 | - public function __construct($id = '', $width = 120, $visible = false) { |
|
22 | + public function __construct($id = '', $width = 120, $visible = false) |
|
23 | + { |
|
22 | 24 | global $ContextMenuCnt; |
23 | 25 | $ContextMenuCnt++; |
24 | 26 | $this->html = ""; |
@@ -27,7 +29,8 @@ discard block |
||
27 | 29 | $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt; // set id |
28 | 30 | } |
29 | 31 | |
30 | - public function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
32 | + public function addItem($text, $action = "", $img = "", $disabled = 0) |
|
33 | + { |
|
31 | 34 | global $base_url, $_style; |
32 | 35 | if($disabled) { |
33 | 36 | return; |
@@ -52,13 +55,15 @@ discard block |
||
52 | 55 | $this->html .= $img . ' ' . $text . '</div>'; |
53 | 56 | } |
54 | 57 | |
55 | - public function addSeparator() { |
|
58 | + public function addSeparator() |
|
59 | + { |
|
56 | 60 | $this->html .= " |
57 | 61 | <div class='cntxMnuSeparator'></div> |
58 | 62 | "; |
59 | 63 | } |
60 | 64 | |
61 | - public function render() { |
|
65 | + public function render() |
|
66 | + { |
|
62 | 67 | global $ContextMenuScript; |
63 | 68 | |
64 | 69 | $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>"; |
@@ -66,7 +71,8 @@ discard block |
||
66 | 71 | return $html; |
67 | 72 | } |
68 | 73 | |
69 | - public function getClientScriptObject() { |
|
74 | + public function getClientScriptObject() |
|
75 | + { |
|
70 | 76 | return "getCntxMenu('" . $this->id . "')"; |
71 | 77 | } |
72 | 78 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | public $ds; // datasource |
16 | 17 | public $pageSize; |
@@ -31,7 +32,8 @@ discard block |
||
31 | 32 | public $renderPagerFnc; |
32 | 33 | public $renderPagerFncArgs; |
33 | 34 | |
34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
35 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
36 | + { |
|
35 | 37 | global $_PAGE; // use view state object |
36 | 38 | |
37 | 39 | global $__DataSetPagerCnt; |
@@ -61,35 +63,42 @@ discard block |
||
61 | 63 | $this->pager = ''; |
62 | 64 | } |
63 | 65 | |
64 | - public function getRenderedPager() { |
|
66 | + public function getRenderedPager() |
|
67 | + { |
|
65 | 68 | return $this->pager; |
66 | 69 | } |
67 | 70 | |
68 | - public function getRenderedRows() { |
|
71 | + public function getRenderedRows() |
|
72 | + { |
|
69 | 73 | return $this->rows; |
70 | 74 | } |
71 | 75 | |
72 | - public function setDataSource($ds) { |
|
76 | + public function setDataSource($ds) |
|
77 | + { |
|
73 | 78 | $this->ds = $ds; |
74 | 79 | } |
75 | 80 | |
76 | - public function setPageSize($ps) { |
|
81 | + public function setPageSize($ps) |
|
82 | + { |
|
77 | 83 | $this->pageSize = $ps; |
78 | 84 | } |
79 | 85 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
86 | + public function setRenderRowFnc($fncName, $args = "") |
|
87 | + { |
|
81 | 88 | $this->renderRowFnc = &$fncName; |
82 | 89 | $this->renderRowFncArgs = $args; // extra agruments |
83 | 90 | |
84 | 91 | |
85 | 92 | } |
86 | 93 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
94 | + public function setRenderPagerFnc($fncName, $args = "") |
|
95 | + { |
|
88 | 96 | $this->renderPagerFnc = $fncName; |
89 | 97 | $this->renderPagerFncArgs = $args; // extra agruments |
90 | 98 | } |
91 | 99 | |
92 | - public function render() { |
|
100 | + public function render() |
|
101 | + { |
|
93 | 102 | global $modx, $_PAGE; |
94 | 103 | |
95 | 104 | $isDataset = $modx->db->isResult($this->ds); |
@@ -142,8 +151,10 @@ discard block |
||
142 | 151 | $url = $_SERVER['PHP_SELF'] . '?'; |
143 | 152 | } |
144 | 153 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
154 | + foreach($_GET as $n => $v) { |
|
155 | + if($n != 'dpgn' . $this->id) { |
|
146 | 156 | $i++; |
157 | + } |
|
147 | 158 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
148 | 159 | } |
149 | 160 | if($i >= 1) { |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // this is the old error handler. Here for legacy, until i replace all the old errors. |
3 | -class errorHandler{ |
|
3 | +class errorHandler |
|
4 | +{ |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * @var int |
@@ -15,7 +16,8 @@ discard block |
||
15 | 16 | */ |
16 | 17 | public $errormessage; |
17 | 18 | |
18 | - public function __construct() { |
|
19 | + public function __construct() |
|
20 | + { |
|
19 | 21 | |
20 | 22 | $_lang = $this->include_lang('errormsg'); |
21 | 23 | |
@@ -50,25 +52,31 @@ discard block |
||
50 | 52 | ); |
51 | 53 | } |
52 | 54 | |
53 | - function include_lang($context='common') { |
|
55 | + function include_lang($context='common') |
|
56 | + { |
|
54 | 57 | global $modx; |
55 | 58 | $_lang = array(); |
56 | 59 | |
57 | 60 | $context = trim($context,'/'); |
58 | - if(strpos($context,'..')!==false) return; |
|
61 | + if(strpos($context,'..')!==false) { |
|
62 | + return; |
|
63 | + } |
|
59 | 64 | |
60 | - if($context === 'common') |
|
61 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/'; |
|
62 | - else |
|
63 | - $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/"; |
|
65 | + if($context === 'common') { |
|
66 | + $lang_path = MODX_MANAGER_PATH . 'includes/lang/'; |
|
67 | + } else { |
|
68 | + $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/"; |
|
69 | + } |
|
64 | 70 | include_once($lang_path . 'english.inc.php'); |
65 | 71 | $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"); |
|
72 | + if(is_file("{$lang_path}{$manager_language}.inc.php")) { |
|
73 | + include_once("{$lang_path}{$manager_language}.inc.php"); |
|
74 | + } |
|
68 | 75 | return $_lang; |
69 | 76 | } |
70 | 77 | |
71 | - function setError($errorcode, $custommessage=""){ |
|
78 | + function setError($errorcode, $custommessage="") |
|
79 | + { |
|
72 | 80 | $this->errorcode=$errorcode; |
73 | 81 | $this->errormessage=$this->errors[$errorcode]; |
74 | 82 | if($custommessage!="") { |
@@ -76,11 +84,13 @@ discard block |
||
76 | 84 | } |
77 | 85 | } |
78 | 86 | |
79 | - function getError() { |
|
87 | + function getError() |
|
88 | + { |
|
80 | 89 | return $this->errorcode; |
81 | 90 | } |
82 | 91 | |
83 | - function dumpError(){ |
|
92 | + function dumpError() |
|
93 | + { |
|
84 | 94 | ?> |
85 | 95 | <html> |
86 | 96 | <head> |
@@ -3,13 +3,15 @@ discard block |
||
3 | 3 | global $site_sessionname; |
4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
5 | 5 | |
6 | -function genEvoSessionName() { |
|
6 | +function genEvoSessionName() |
|
7 | +{ |
|
7 | 8 | $_ = crc32(__FILE__); |
8 | 9 | $_ = sprintf('%u', $_); |
9 | 10 | return 'evo' . base_convert($_,10,36); |
10 | 11 | } |
11 | 12 | |
12 | -function startCMSSession(){ |
|
13 | +function startCMSSession() |
|
14 | +{ |
|
13 | 15 | |
14 | 16 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
15 | 17 | |
@@ -23,24 +25,27 @@ discard block |
||
23 | 25 | session_start(); |
24 | 26 | |
25 | 27 | $key = "modx.{$context}.session.cookie.lifetime"; |
26 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
28 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
27 | 29 | $cookieLifetime= (int)$_SESSION[$key]; |
28 | - if($cookieLifetime) $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime; |
|
30 | + if($cookieLifetime) { |
|
31 | + $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime; |
|
32 | + } |
|
29 | 33 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
30 | 34 | } |
31 | - if (!isset($_SESSION['modx.session.created.time'])) { |
|
35 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
32 | 36 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
33 | 37 | } |
34 | 38 | } |
35 | 39 | |
36 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) { |
|
37 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) |
|
38 | - { |
|
40 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
41 | +{ |
|
42 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
39 | 43 | unset($storage[$session_name]); |
40 | 44 | } |
41 | 45 | } |
42 | 46 | |
43 | -function removeInvalidCmsSessionIds($session_name) { |
|
47 | +function removeInvalidCmsSessionIds($session_name) |
|
48 | +{ |
|
44 | 49 | // session ids is invalid iff it is empty string |
45 | 50 | // storage priorioty can see in PHP source ext/session/session.c |
46 | 51 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |