@@ -349,7 +349,7 @@ |
||
349 | 349 | /** |
350 | 350 | * returns an array if a delimiter is present. returns array is a recordset is present |
351 | 351 | * |
352 | - * @param $src |
|
352 | + * @param string $src |
|
353 | 353 | * @param string $delim |
354 | 354 | * @param string $type |
355 | 355 | * @param bool $columns |
@@ -17,324 +17,324 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
19 | 19 | |
20 | - global $modx; |
|
20 | + global $modx; |
|
21 | 21 | $o = ''; |
22 | 22 | |
23 | 23 | // process any TV commands in value |
24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
25 | - $value = ProcessTVCommand($value, $name, $docid); |
|
24 | + $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
25 | + $value = ProcessTVCommand($value, $name, $docid); |
|
26 | 26 | |
27 | - $params = array(); |
|
28 | - if($paramstring) { |
|
29 | - $cp = explode("&", $paramstring); |
|
30 | - foreach($cp as $p => $v) { |
|
31 | - $v = trim($v); // trim |
|
32 | - $ar = explode("=", $v); |
|
33 | - if(is_array($ar) && count($ar) == 2) { |
|
34 | - $params[$ar[0]] = decodeParamValue($ar[1]); |
|
35 | - } |
|
36 | - } |
|
37 | - } |
|
27 | + $params = array(); |
|
28 | + if($paramstring) { |
|
29 | + $cp = explode("&", $paramstring); |
|
30 | + foreach($cp as $p => $v) { |
|
31 | + $v = trim($v); // trim |
|
32 | + $ar = explode("=", $v); |
|
33 | + if(is_array($ar) && count($ar) == 2) { |
|
34 | + $params[$ar[0]] = decodeParamValue($ar[1]); |
|
35 | + } |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - $id = "tv$name"; |
|
40 | - switch($format) { |
|
41 | - case 'image': |
|
42 | - $images = parseInput($value, '||', 'array'); |
|
43 | - foreach($images as $image) { |
|
44 | - if(!is_array($image)) { |
|
45 | - $image = explode('==', $image); |
|
46 | - } |
|
47 | - $src = $image[0]; |
|
39 | + $id = "tv$name"; |
|
40 | + switch($format) { |
|
41 | + case 'image': |
|
42 | + $images = parseInput($value, '||', 'array'); |
|
43 | + foreach($images as $image) { |
|
44 | + if(!is_array($image)) { |
|
45 | + $image = explode('==', $image); |
|
46 | + } |
|
47 | + $src = $image[0]; |
|
48 | 48 | |
49 | - if($src) { |
|
50 | - // We have a valid source |
|
51 | - $attributes = ''; |
|
52 | - $attr = array( |
|
53 | - 'class' => $params['class'], |
|
54 | - 'src' => $src, |
|
55 | - 'id' => ($params['id'] ? $params['id'] : ''), |
|
56 | - 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
57 | - 'style' => $params['style'] |
|
58 | - ); |
|
59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
60 | - $attr['align'] = $params['align']; |
|
61 | - } |
|
62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
63 | - $attributes .= ' ' . $params['attrib']; |
|
49 | + if($src) { |
|
50 | + // We have a valid source |
|
51 | + $attributes = ''; |
|
52 | + $attr = array( |
|
53 | + 'class' => $params['class'], |
|
54 | + 'src' => $src, |
|
55 | + 'id' => ($params['id'] ? $params['id'] : ''), |
|
56 | + 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
57 | + 'style' => $params['style'] |
|
58 | + ); |
|
59 | + if(isset($params['align']) && $params['align'] != 'none') { |
|
60 | + $attr['align'] = $params['align']; |
|
61 | + } |
|
62 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
63 | + $attributes .= ' ' . $params['attrib']; |
|
64 | 64 | |
65 | - // Output the image with attributes |
|
66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
67 | - } |
|
68 | - } |
|
69 | - break; |
|
65 | + // Output the image with attributes |
|
66 | + $o .= '<img' . rtrim($attributes) . ' />'; |
|
67 | + } |
|
68 | + } |
|
69 | + break; |
|
70 | 70 | |
71 | - case "delim": // display as delimitted list |
|
72 | - $value = parseInput($value, "||"); |
|
73 | - $p = $params['format'] ? $params['format'] : " "; |
|
74 | - if($p == "\\n") { |
|
75 | - $p = "\n"; |
|
76 | - } |
|
77 | - $o = str_replace("||", $p, $value); |
|
78 | - break; |
|
71 | + case "delim": // display as delimitted list |
|
72 | + $value = parseInput($value, "||"); |
|
73 | + $p = $params['format'] ? $params['format'] : " "; |
|
74 | + if($p == "\\n") { |
|
75 | + $p = "\n"; |
|
76 | + } |
|
77 | + $o = str_replace("||", $p, $value); |
|
78 | + break; |
|
79 | 79 | |
80 | - case "string": |
|
81 | - $value = parseInput($value); |
|
82 | - $format = strtolower($params['format']); |
|
83 | - if($format == 'upper case') { |
|
84 | - $o = strtoupper($value); |
|
85 | - } else if($format == 'lower case') { |
|
86 | - $o = strtolower($value); |
|
87 | - } else if($format == 'sentence case') { |
|
88 | - $o = ucfirst($value); |
|
89 | - } else if($format == 'capitalize') { |
|
90 | - $o = ucwords($value); |
|
91 | - } else { |
|
92 | - $o = $value; |
|
93 | - } |
|
94 | - break; |
|
80 | + case "string": |
|
81 | + $value = parseInput($value); |
|
82 | + $format = strtolower($params['format']); |
|
83 | + if($format == 'upper case') { |
|
84 | + $o = strtoupper($value); |
|
85 | + } else if($format == 'lower case') { |
|
86 | + $o = strtolower($value); |
|
87 | + } else if($format == 'sentence case') { |
|
88 | + $o = ucfirst($value); |
|
89 | + } else if($format == 'capitalize') { |
|
90 | + $o = ucwords($value); |
|
91 | + } else { |
|
92 | + $o = $value; |
|
93 | + } |
|
94 | + break; |
|
95 | 95 | |
96 | - case "date": |
|
97 | - if($value != '' || $params['default'] == 'Yes') { |
|
98 | - if(empty($value)) { |
|
99 | - $value = 'now'; |
|
100 | - } |
|
101 | - $timestamp = getUnixtimeFromDateString($value); |
|
102 | - $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
103 | - $o = strftime($p, $timestamp); |
|
104 | - } else { |
|
105 | - $value = ''; |
|
106 | - } |
|
107 | - break; |
|
96 | + case "date": |
|
97 | + if($value != '' || $params['default'] == 'Yes') { |
|
98 | + if(empty($value)) { |
|
99 | + $value = 'now'; |
|
100 | + } |
|
101 | + $timestamp = getUnixtimeFromDateString($value); |
|
102 | + $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
103 | + $o = strftime($p, $timestamp); |
|
104 | + } else { |
|
105 | + $value = ''; |
|
106 | + } |
|
107 | + break; |
|
108 | 108 | |
109 | - case "hyperlink": |
|
110 | - $value = parseInput($value, "||", "array"); |
|
111 | - $o = ''; |
|
112 | - $countValue = count($value); |
|
113 | - for($i = 0; $i < $countValue; $i++) { |
|
114 | - list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
115 | - if(!$url) { |
|
116 | - $url = $name; |
|
117 | - } |
|
118 | - if($url) { |
|
119 | - if($o) { |
|
120 | - $o .= '<br />'; |
|
121 | - } |
|
122 | - $attributes = ''; |
|
123 | - // setup the link attributes |
|
124 | - $attr = array( |
|
125 | - 'href' => $url, |
|
126 | - 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
127 | - 'class' => $params['class'], |
|
128 | - 'style' => $params['style'], |
|
129 | - 'target' => $params['target'], |
|
130 | - ); |
|
131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
109 | + case "hyperlink": |
|
110 | + $value = parseInput($value, "||", "array"); |
|
111 | + $o = ''; |
|
112 | + $countValue = count($value); |
|
113 | + for($i = 0; $i < $countValue; $i++) { |
|
114 | + list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
115 | + if(!$url) { |
|
116 | + $url = $name; |
|
117 | + } |
|
118 | + if($url) { |
|
119 | + if($o) { |
|
120 | + $o .= '<br />'; |
|
121 | + } |
|
122 | + $attributes = ''; |
|
123 | + // setup the link attributes |
|
124 | + $attr = array( |
|
125 | + 'href' => $url, |
|
126 | + 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
127 | + 'class' => $params['class'], |
|
128 | + 'style' => $params['style'], |
|
129 | + 'target' => $params['target'], |
|
130 | + ); |
|
131 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
132 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
133 | 133 | |
134 | - // Output the link |
|
135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
136 | - } |
|
137 | - } |
|
138 | - break; |
|
134 | + // Output the link |
|
135 | + $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
136 | + } |
|
137 | + } |
|
138 | + break; |
|
139 | 139 | |
140 | - case "htmltag": |
|
141 | - $value = parseInput($value, "||", "array"); |
|
142 | - $tagid = $params['tagid']; |
|
143 | - $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
144 | - $o = ''; |
|
145 | - // Loop through a list of tags |
|
140 | + case "htmltag": |
|
141 | + $value = parseInput($value, "||", "array"); |
|
142 | + $tagid = $params['tagid']; |
|
143 | + $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
144 | + $o = ''; |
|
145 | + // Loop through a list of tags |
|
146 | 146 | $countValue = count($value); |
147 | - for($i = 0; $i < $countValue; $i++) { |
|
148 | - $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
149 | - if(!$tagvalue) { |
|
150 | - continue; |
|
151 | - } |
|
147 | + for($i = 0; $i < $countValue; $i++) { |
|
148 | + $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
149 | + if(!$tagvalue) { |
|
150 | + continue; |
|
151 | + } |
|
152 | 152 | |
153 | - $attributes = ''; |
|
154 | - $attr = array( |
|
155 | - 'id' => ($tagid ? $tagid : $id), |
|
156 | - // 'tv' already added to id |
|
157 | - 'class' => $params['class'], |
|
158 | - 'style' => $params['style'], |
|
159 | - ); |
|
160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
153 | + $attributes = ''; |
|
154 | + $attr = array( |
|
155 | + 'id' => ($tagid ? $tagid : $id), |
|
156 | + // 'tv' already added to id |
|
157 | + 'class' => $params['class'], |
|
158 | + 'style' => $params['style'], |
|
159 | + ); |
|
160 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
161 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
162 | 162 | |
163 | - // Output the HTML Tag |
|
164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
165 | - } |
|
166 | - break; |
|
163 | + // Output the HTML Tag |
|
164 | + $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
165 | + } |
|
166 | + break; |
|
167 | 167 | |
168 | - case "richtext": |
|
169 | - $value = parseInput($value); |
|
170 | - $w = $params['w'] ? $params['w'] : '100%'; |
|
171 | - $h = $params['h'] ? $params['h'] : '400px'; |
|
172 | - $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
174 | - $o .= $modx->htmlspecialchars($value); |
|
175 | - $o .= '</textarea></div>'; |
|
176 | - $replace_richtext = array($id); |
|
177 | - // setup editors |
|
178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
179 | - // invoke OnRichTextEditorInit event |
|
180 | - $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
181 | - 'editor' => $richtexteditor, |
|
182 | - 'elements' => $replace_richtext, |
|
183 | - 'forfrontend' => 1, |
|
184 | - 'width' => $w, |
|
185 | - 'height' => $h |
|
186 | - )); |
|
187 | - if(is_array($evtOut)) { |
|
188 | - $o .= implode("", $evtOut); |
|
189 | - } |
|
190 | - } |
|
191 | - break; |
|
168 | + case "richtext": |
|
169 | + $value = parseInput($value); |
|
170 | + $w = $params['w'] ? $params['w'] : '100%'; |
|
171 | + $h = $params['h'] ? $params['h'] : '400px'; |
|
172 | + $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
174 | + $o .= $modx->htmlspecialchars($value); |
|
175 | + $o .= '</textarea></div>'; |
|
176 | + $replace_richtext = array($id); |
|
177 | + // setup editors |
|
178 | + if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
179 | + // invoke OnRichTextEditorInit event |
|
180 | + $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
181 | + 'editor' => $richtexteditor, |
|
182 | + 'elements' => $replace_richtext, |
|
183 | + 'forfrontend' => 1, |
|
184 | + 'width' => $w, |
|
185 | + 'height' => $h |
|
186 | + )); |
|
187 | + if(is_array($evtOut)) { |
|
188 | + $o .= implode("", $evtOut); |
|
189 | + } |
|
190 | + } |
|
191 | + break; |
|
192 | 192 | |
193 | - case "unixtime": |
|
194 | - $value = parseInput($value); |
|
195 | - $o = getUnixtimeFromDateString($value); |
|
196 | - break; |
|
193 | + case "unixtime": |
|
194 | + $value = parseInput($value); |
|
195 | + $o = getUnixtimeFromDateString($value); |
|
196 | + break; |
|
197 | 197 | |
198 | - case "viewport": |
|
199 | - $value = parseInput($value); |
|
200 | - $id = '_' . time(); |
|
201 | - if(!$params['vpid']) { |
|
202 | - $params['vpid'] = $id; |
|
203 | - } |
|
204 | - $sTag = "<iframe"; |
|
205 | - $eTag = "</iframe>"; |
|
206 | - $autoMode = "0"; |
|
207 | - $w = $params['width']; |
|
208 | - $h = $params['height']; |
|
209 | - if($params['stretch'] == 'Yes') { |
|
210 | - $w = "100%"; |
|
211 | - $h = "100%"; |
|
212 | - } |
|
213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | - $autoMode = "3"; //both |
|
215 | - } else if($params['awidth'] == 'Yes') { |
|
216 | - $autoMode = "1"; //width only |
|
217 | - } else if($params['aheight'] == 'Yes') { |
|
218 | - $autoMode = "2"; //height only |
|
219 | - } |
|
198 | + case "viewport": |
|
199 | + $value = parseInput($value); |
|
200 | + $id = '_' . time(); |
|
201 | + if(!$params['vpid']) { |
|
202 | + $params['vpid'] = $id; |
|
203 | + } |
|
204 | + $sTag = "<iframe"; |
|
205 | + $eTag = "</iframe>"; |
|
206 | + $autoMode = "0"; |
|
207 | + $w = $params['width']; |
|
208 | + $h = $params['height']; |
|
209 | + if($params['stretch'] == 'Yes') { |
|
210 | + $w = "100%"; |
|
211 | + $h = "100%"; |
|
212 | + } |
|
213 | + if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | + $autoMode = "3"; //both |
|
215 | + } else if($params['awidth'] == 'Yes') { |
|
216 | + $autoMode = "1"; //width only |
|
217 | + } else if($params['aheight'] == 'Yes') { |
|
218 | + $autoMode = "2"; //height only |
|
219 | + } |
|
220 | 220 | |
221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
222 | - 'name' => 'viewport', |
|
223 | - 'version' => '0', |
|
224 | - 'plaintext' => false |
|
225 | - )); |
|
226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
227 | - if($params['class']) { |
|
228 | - $o .= " class='" . $params['class'] . "' "; |
|
229 | - } |
|
230 | - if($params['style']) { |
|
231 | - $o .= " style='" . $params['style'] . "' "; |
|
232 | - } |
|
233 | - if($params['attrib']) { |
|
234 | - $o .= $params['attrib'] . " "; |
|
235 | - } |
|
236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
239 | - $o .= ">"; |
|
240 | - $o .= $eTag; |
|
241 | - break; |
|
221 | + $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
222 | + 'name' => 'viewport', |
|
223 | + 'version' => '0', |
|
224 | + 'plaintext' => false |
|
225 | + )); |
|
226 | + $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
227 | + if($params['class']) { |
|
228 | + $o .= " class='" . $params['class'] . "' "; |
|
229 | + } |
|
230 | + if($params['style']) { |
|
231 | + $o .= " style='" . $params['style'] . "' "; |
|
232 | + } |
|
233 | + if($params['attrib']) { |
|
234 | + $o .= $params['attrib'] . " "; |
|
235 | + } |
|
236 | + $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
237 | + $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
239 | + $o .= ">"; |
|
240 | + $o .= $eTag; |
|
241 | + break; |
|
242 | 242 | |
243 | - case "datagrid": |
|
244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
245 | - $grd = new DataGrid('', $value); |
|
243 | + case "datagrid": |
|
244 | + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
245 | + $grd = new DataGrid('', $value); |
|
246 | 246 | |
247 | - $grd->noRecordMsg = $params['egmsg']; |
|
247 | + $grd->noRecordMsg = $params['egmsg']; |
|
248 | 248 | |
249 | - $grd->columnHeaderClass = $params['chdrc']; |
|
250 | - $grd->cssClass = $params['tblc']; |
|
251 | - $grd->itemClass = $params['itmc']; |
|
252 | - $grd->altItemClass = $params['aitmc']; |
|
249 | + $grd->columnHeaderClass = $params['chdrc']; |
|
250 | + $grd->cssClass = $params['tblc']; |
|
251 | + $grd->itemClass = $params['itmc']; |
|
252 | + $grd->altItemClass = $params['aitmc']; |
|
253 | 253 | |
254 | - $grd->columnHeaderStyle = $params['chdrs']; |
|
255 | - $grd->cssStyle = $params['tbls']; |
|
256 | - $grd->itemStyle = $params['itms']; |
|
257 | - $grd->altItemStyle = $params['aitms']; |
|
254 | + $grd->columnHeaderStyle = $params['chdrs']; |
|
255 | + $grd->cssStyle = $params['tbls']; |
|
256 | + $grd->itemStyle = $params['itms']; |
|
257 | + $grd->altItemStyle = $params['aitms']; |
|
258 | 258 | |
259 | - $grd->columns = $params['cols']; |
|
260 | - $grd->fields = $params['flds']; |
|
261 | - $grd->colWidths = $params['cwidth']; |
|
262 | - $grd->colAligns = $params['calign']; |
|
263 | - $grd->colColors = $params['ccolor']; |
|
264 | - $grd->colTypes = $params['ctype']; |
|
259 | + $grd->columns = $params['cols']; |
|
260 | + $grd->fields = $params['flds']; |
|
261 | + $grd->colWidths = $params['cwidth']; |
|
262 | + $grd->colAligns = $params['calign']; |
|
263 | + $grd->colColors = $params['ccolor']; |
|
264 | + $grd->colTypes = $params['ctype']; |
|
265 | 265 | |
266 | - $grd->cellPadding = $params['cpad']; |
|
267 | - $grd->cellSpacing = $params['cspace']; |
|
268 | - $grd->header = $params['head']; |
|
269 | - $grd->footer = $params['foot']; |
|
270 | - $grd->pageSize = $params['psize']; |
|
271 | - $grd->pagerLocation = $params['ploc']; |
|
272 | - $grd->pagerClass = $params['pclass']; |
|
273 | - $grd->pagerStyle = $params['pstyle']; |
|
274 | - $o = $grd->render(); |
|
275 | - break; |
|
266 | + $grd->cellPadding = $params['cpad']; |
|
267 | + $grd->cellSpacing = $params['cspace']; |
|
268 | + $grd->header = $params['head']; |
|
269 | + $grd->footer = $params['foot']; |
|
270 | + $grd->pageSize = $params['psize']; |
|
271 | + $grd->pagerLocation = $params['ploc']; |
|
272 | + $grd->pagerClass = $params['pclass']; |
|
273 | + $grd->pagerStyle = $params['pstyle']; |
|
274 | + $o = $grd->render(); |
|
275 | + break; |
|
276 | 276 | |
277 | - case 'htmlentities': |
|
278 | - $value = parseInput($value); |
|
279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
280 | - // remove delimiter from checkbox and listbox-multiple TVs |
|
281 | - $value = str_replace('||', '', $value); |
|
282 | - } |
|
283 | - $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
284 | - break; |
|
277 | + case 'htmlentities': |
|
278 | + $value = parseInput($value); |
|
279 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
280 | + // remove delimiter from checkbox and listbox-multiple TVs |
|
281 | + $value = str_replace('||', '', $value); |
|
282 | + } |
|
283 | + $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
284 | + break; |
|
285 | 285 | |
286 | - case 'custom_widget': |
|
287 | - $widget_output = ''; |
|
288 | - $o = ''; |
|
289 | - /* If we are loading a file */ |
|
290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
292 | - if(!file_exists($file_name)) { |
|
293 | - $widget_output = $file_name . ' does not exist'; |
|
294 | - } else { |
|
295 | - $widget_output = file_get_contents($file_name); |
|
296 | - } |
|
297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
299 | - if(!file_exists($file_name)) { |
|
300 | - $widget_output = $file_name . ' does not exist'; |
|
301 | - } else { |
|
302 | - /* The included file needs to set $widget_output. Can be string, array, object */ |
|
303 | - include $file_name; |
|
304 | - } |
|
305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
306 | - $chunk_name = trim(substr($params['output'], 7)); |
|
307 | - $widget_output = $modx->getChunk($chunk_name); |
|
308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
309 | - $eval_str = trim(substr($params['output'], 6)); |
|
310 | - $widget_output = eval($eval_str); |
|
311 | - } elseif($value !== '') { |
|
312 | - $widget_output = $params['output']; |
|
313 | - } else { |
|
314 | - $widget_output = ''; |
|
315 | - } |
|
316 | - if(is_string($widget_output)) { |
|
317 | - $_ = $modx->config['enable_filter']; |
|
318 | - $modx->config['enable_filter'] = 1; |
|
319 | - $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
320 | - $modx->config['enable_filter'] = $_; |
|
321 | - $o = $modx->parseDocumentSource($widget_output); |
|
322 | - } else { |
|
323 | - $o = $widget_output; |
|
324 | - } |
|
325 | - break; |
|
286 | + case 'custom_widget': |
|
287 | + $widget_output = ''; |
|
288 | + $o = ''; |
|
289 | + /* If we are loading a file */ |
|
290 | + if(substr($params['output'], 0, 5) == "@FILE") { |
|
291 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
292 | + if(!file_exists($file_name)) { |
|
293 | + $widget_output = $file_name . ' does not exist'; |
|
294 | + } else { |
|
295 | + $widget_output = file_get_contents($file_name); |
|
296 | + } |
|
297 | + } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
299 | + if(!file_exists($file_name)) { |
|
300 | + $widget_output = $file_name . ' does not exist'; |
|
301 | + } else { |
|
302 | + /* The included file needs to set $widget_output. Can be string, array, object */ |
|
303 | + include $file_name; |
|
304 | + } |
|
305 | + } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
306 | + $chunk_name = trim(substr($params['output'], 7)); |
|
307 | + $widget_output = $modx->getChunk($chunk_name); |
|
308 | + } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
309 | + $eval_str = trim(substr($params['output'], 6)); |
|
310 | + $widget_output = eval($eval_str); |
|
311 | + } elseif($value !== '') { |
|
312 | + $widget_output = $params['output']; |
|
313 | + } else { |
|
314 | + $widget_output = ''; |
|
315 | + } |
|
316 | + if(is_string($widget_output)) { |
|
317 | + $_ = $modx->config['enable_filter']; |
|
318 | + $modx->config['enable_filter'] = 1; |
|
319 | + $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
320 | + $modx->config['enable_filter'] = $_; |
|
321 | + $o = $modx->parseDocumentSource($widget_output); |
|
322 | + } else { |
|
323 | + $o = $widget_output; |
|
324 | + } |
|
325 | + break; |
|
326 | 326 | |
327 | - default: |
|
328 | - $value = parseInput($value); |
|
329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
330 | - // add separator |
|
331 | - $value = explode('||', $value); |
|
332 | - $value = implode($sep, $value); |
|
333 | - } |
|
334 | - $o = $value; |
|
335 | - break; |
|
336 | - } |
|
337 | - return $o; |
|
327 | + default: |
|
328 | + $value = parseInput($value); |
|
329 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
330 | + // add separator |
|
331 | + $value = explode('||', $value); |
|
332 | + $value = implode($sep, $value); |
|
333 | + } |
|
334 | + $o = $value; |
|
335 | + break; |
|
336 | + } |
|
337 | + return $o; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @return string |
343 | 343 | */ |
344 | 344 | function decodeParamValue($s) { |
345 | - $s = str_replace("%3D", '=', $s); // = |
|
346 | - return str_replace("%26", '&', $s); // & |
|
345 | + $s = str_replace("%3D", '=', $s); // = |
|
346 | + return str_replace("%26", '&', $s); // & |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -356,20 +356,20 @@ discard block |
||
356 | 356 | * @return array|string |
357 | 357 | */ |
358 | 358 | function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
359 | - global $modx; |
|
360 | - if($modx->db->isResult($src)) { |
|
361 | - // must be a recordset |
|
362 | - $rows = array(); |
|
363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
364 | - return ($type == "array") ? $rows : implode($delim, $rows); |
|
365 | - } else { |
|
366 | - // must be a text |
|
367 | - if($type == "array") { |
|
368 | - return explode($delim, $src); |
|
369 | - } else { |
|
370 | - return $src; |
|
371 | - } |
|
372 | - } |
|
359 | + global $modx; |
|
360 | + if($modx->db->isResult($src)) { |
|
361 | + // must be a recordset |
|
362 | + $rows = array(); |
|
363 | + while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
364 | + return ($type == "array") ? $rows : implode($delim, $rows); |
|
365 | + } else { |
|
366 | + // must be a text |
|
367 | + if($type == "array") { |
|
368 | + return explode($delim, $src); |
|
369 | + } else { |
|
370 | + return $src; |
|
371 | + } |
|
372 | + } |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -377,21 +377,21 @@ discard block |
||
377 | 377 | * @return bool|false|int |
378 | 378 | */ |
379 | 379 | function getUnixtimeFromDateString($value) { |
380 | - $timestamp = false; |
|
381 | - // Check for MySQL or legacy style date |
|
382 | - $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
383 | - $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
384 | - $matches = array(); |
|
385 | - if(strpos($value, '-') !== false) { |
|
386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
387 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
389 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
390 | - } |
|
391 | - } |
|
392 | - // If those didn't work, use strtotime to figure out the date |
|
393 | - if($timestamp === false || $timestamp === -1) { |
|
394 | - $timestamp = strtotime($value); |
|
395 | - } |
|
396 | - return $timestamp; |
|
380 | + $timestamp = false; |
|
381 | + // Check for MySQL or legacy style date |
|
382 | + $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
383 | + $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
384 | + $matches = array(); |
|
385 | + if(strpos($value, '-') !== false) { |
|
386 | + if(preg_match($date_match_1, $value, $matches)) { |
|
387 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
388 | + } elseif(preg_match($date_match_2, $value, $matches)) { |
|
389 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
390 | + } |
|
391 | + } |
|
392 | + // If those didn't work, use strtotime to figure out the date |
|
393 | + if($timestamp === false || $timestamp === -1) { |
|
394 | + $timestamp = strtotime($value); |
|
395 | + } |
|
396 | + return $timestamp; |
|
397 | 397 | } |
@@ -15,38 +15,38 @@ discard block |
||
15 | 15 | * @param string $sep |
16 | 16 | * @return mixed|string |
17 | 17 | */ |
18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){ |
|
19 | 19 | |
20 | 20 | global $modx; |
21 | 21 | $o = ''; |
22 | 22 | |
23 | 23 | // process any TV commands in value |
24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
24 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
25 | 25 | $value = ProcessTVCommand($value, $name, $docid); |
26 | 26 | |
27 | 27 | $params = array(); |
28 | - if($paramstring) { |
|
28 | + if ($paramstring) { |
|
29 | 29 | $cp = explode("&", $paramstring); |
30 | - foreach($cp as $p => $v) { |
|
30 | + foreach ($cp as $p => $v) { |
|
31 | 31 | $v = trim($v); // trim |
32 | 32 | $ar = explode("=", $v); |
33 | - if(is_array($ar) && count($ar) == 2) { |
|
33 | + if (is_array($ar) && count($ar) == 2) { |
|
34 | 34 | $params[$ar[0]] = decodeParamValue($ar[1]); |
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | $id = "tv$name"; |
40 | - switch($format) { |
|
40 | + switch ($format) { |
|
41 | 41 | case 'image': |
42 | 42 | $images = parseInput($value, '||', 'array'); |
43 | - foreach($images as $image) { |
|
44 | - if(!is_array($image)) { |
|
43 | + foreach ($images as $image) { |
|
44 | + if (!is_array($image)) { |
|
45 | 45 | $image = explode('==', $image); |
46 | 46 | } |
47 | 47 | $src = $image[0]; |
48 | 48 | |
49 | - if($src) { |
|
49 | + if ($src) { |
|
50 | 50 | // We have a valid source |
51 | 51 | $attributes = ''; |
52 | 52 | $attr = array( |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | 'alt' => $modx->htmlspecialchars($params['alttext']), |
57 | 57 | 'style' => $params['style'] |
58 | 58 | ); |
59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
59 | + if (isset($params['align']) && $params['align'] != 'none') { |
|
60 | 60 | $attr['align'] = $params['align']; |
61 | 61 | } |
62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
63 | - $attributes .= ' ' . $params['attrib']; |
|
62 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
63 | + $attributes .= ' '.$params['attrib']; |
|
64 | 64 | |
65 | 65 | // Output the image with attributes |
66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
66 | + $o .= '<img'.rtrim($attributes).' />'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | break; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | case "delim": // display as delimitted list |
72 | 72 | $value = parseInput($value, "||"); |
73 | 73 | $p = $params['format'] ? $params['format'] : " "; |
74 | - if($p == "\\n") { |
|
74 | + if ($p == "\\n") { |
|
75 | 75 | $p = "\n"; |
76 | 76 | } |
77 | 77 | $o = str_replace("||", $p, $value); |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | case "string": |
81 | 81 | $value = parseInput($value); |
82 | 82 | $format = strtolower($params['format']); |
83 | - if($format == 'upper case') { |
|
83 | + if ($format == 'upper case') { |
|
84 | 84 | $o = strtoupper($value); |
85 | - } else if($format == 'lower case') { |
|
85 | + } else if ($format == 'lower case') { |
|
86 | 86 | $o = strtolower($value); |
87 | - } else if($format == 'sentence case') { |
|
87 | + } else if ($format == 'sentence case') { |
|
88 | 88 | $o = ucfirst($value); |
89 | - } else if($format == 'capitalize') { |
|
89 | + } else if ($format == 'capitalize') { |
|
90 | 90 | $o = ucwords($value); |
91 | 91 | } else { |
92 | 92 | $o = $value; |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case "date": |
97 | - if($value != '' || $params['default'] == 'Yes') { |
|
98 | - if(empty($value)) { |
|
97 | + if ($value != '' || $params['default'] == 'Yes') { |
|
98 | + if (empty($value)) { |
|
99 | 99 | $value = 'now'; |
100 | 100 | } |
101 | 101 | $timestamp = getUnixtimeFromDateString($value); |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $value = parseInput($value, "||", "array"); |
111 | 111 | $o = ''; |
112 | 112 | $countValue = count($value); |
113 | - for($i = 0; $i < $countValue; $i++) { |
|
113 | + for ($i = 0; $i < $countValue; $i++) { |
|
114 | 114 | list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
115 | - if(!$url) { |
|
115 | + if (!$url) { |
|
116 | 116 | $url = $name; |
117 | 117 | } |
118 | - if($url) { |
|
119 | - if($o) { |
|
118 | + if ($url) { |
|
119 | + if ($o) { |
|
120 | 120 | $o .= '<br />'; |
121 | 121 | } |
122 | 122 | $attributes = ''; |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | 'style' => $params['style'], |
129 | 129 | 'target' => $params['target'], |
130 | 130 | ); |
131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
131 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
132 | + $attributes .= ' '.$params['attrib']; // add extra |
|
133 | 133 | |
134 | 134 | // Output the link |
135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
135 | + $o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>'; |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | break; |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | $o = ''; |
145 | 145 | // Loop through a list of tags |
146 | 146 | $countValue = count($value); |
147 | - for($i = 0; $i < $countValue; $i++) { |
|
147 | + for ($i = 0; $i < $countValue; $i++) { |
|
148 | 148 | $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
149 | - if(!$tagvalue) { |
|
149 | + if (!$tagvalue) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | 'class' => $params['class'], |
158 | 158 | 'style' => $params['style'], |
159 | 159 | ); |
160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
160 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
161 | + $attributes .= ' '.$params['attrib']; // add extra |
|
162 | 162 | |
163 | 163 | // Output the HTML Tag |
164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
164 | + $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>'; |
|
165 | 165 | } |
166 | 166 | break; |
167 | 167 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $w = $params['w'] ? $params['w'] : '100%'; |
171 | 171 | $h = $params['h'] ? $params['h'] : '400px'; |
172 | 172 | $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">'; |
|
174 | 174 | $o .= $modx->htmlspecialchars($value); |
175 | 175 | $o .= '</textarea></div>'; |
176 | 176 | $replace_richtext = array($id); |
177 | 177 | // setup editors |
178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
178 | + if (!empty($replace_richtext) && !empty($richtexteditor)) { |
|
179 | 179 | // invoke OnRichTextEditorInit event |
180 | 180 | $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
181 | 181 | 'editor' => $richtexteditor, |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'width' => $w, |
185 | 185 | 'height' => $h |
186 | 186 | )); |
187 | - if(is_array($evtOut)) { |
|
187 | + if (is_array($evtOut)) { |
|
188 | 188 | $o .= implode("", $evtOut); |
189 | 189 | } |
190 | 190 | } |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | |
198 | 198 | case "viewport": |
199 | 199 | $value = parseInput($value); |
200 | - $id = '_' . time(); |
|
201 | - if(!$params['vpid']) { |
|
200 | + $id = '_'.time(); |
|
201 | + if (!$params['vpid']) { |
|
202 | 202 | $params['vpid'] = $id; |
203 | 203 | } |
204 | 204 | $sTag = "<iframe"; |
@@ -206,42 +206,42 @@ discard block |
||
206 | 206 | $autoMode = "0"; |
207 | 207 | $w = $params['width']; |
208 | 208 | $h = $params['height']; |
209 | - if($params['stretch'] == 'Yes') { |
|
209 | + if ($params['stretch'] == 'Yes') { |
|
210 | 210 | $w = "100%"; |
211 | 211 | $h = "100%"; |
212 | 212 | } |
213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | - $autoMode = "3"; //both |
|
215 | - } else if($params['awidth'] == 'Yes') { |
|
213 | + if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | + $autoMode = "3"; //both |
|
215 | + } else if ($params['awidth'] == 'Yes') { |
|
216 | 216 | $autoMode = "1"; //width only |
217 | - } else if($params['aheight'] == 'Yes') { |
|
218 | - $autoMode = "2"; //height only |
|
217 | + } else if ($params['aheight'] == 'Yes') { |
|
218 | + $autoMode = "2"; //height only |
|
219 | 219 | } |
220 | 220 | |
221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
221 | + $modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array( |
|
222 | 222 | 'name' => 'viewport', |
223 | 223 | 'version' => '0', |
224 | 224 | 'plaintext' => false |
225 | 225 | )); |
226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
227 | - if($params['class']) { |
|
228 | - $o .= " class='" . $params['class'] . "' "; |
|
226 | + $o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' "; |
|
227 | + if ($params['class']) { |
|
228 | + $o .= " class='".$params['class']."' "; |
|
229 | 229 | } |
230 | - if($params['style']) { |
|
231 | - $o .= " style='" . $params['style'] . "' "; |
|
230 | + if ($params['style']) { |
|
231 | + $o .= " style='".$params['style']."' "; |
|
232 | 232 | } |
233 | - if($params['attrib']) { |
|
234 | - $o .= $params['attrib'] . " "; |
|
233 | + if ($params['attrib']) { |
|
234 | + $o .= $params['attrib']." "; |
|
235 | 235 | } |
236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
236 | + $o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' "; |
|
237 | + $o .= "src='".$value."' frameborder='".$params['borsize']."' "; |
|
238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' "; |
|
239 | 239 | $o .= ">"; |
240 | 240 | $o .= $eTag; |
241 | 241 | break; |
242 | 242 | |
243 | 243 | case "datagrid": |
244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
244 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
245 | 245 | $grd = new DataGrid('', $value); |
246 | 246 | |
247 | 247 | $grd->noRecordMsg = $params['egmsg']; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | case 'htmlentities': |
278 | 278 | $value = parseInput($value); |
279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
279 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
280 | 280 | // remove delimiter from checkbox and listbox-multiple TVs |
281 | 281 | $value = str_replace('||', '', $value); |
282 | 282 | } |
@@ -287,33 +287,33 @@ discard block |
||
287 | 287 | $widget_output = ''; |
288 | 288 | $o = ''; |
289 | 289 | /* If we are loading a file */ |
290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
292 | - if(!file_exists($file_name)) { |
|
293 | - $widget_output = $file_name . ' does not exist'; |
|
290 | + if (substr($params['output'], 0, 5) == "@FILE") { |
|
291 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 6)); |
|
292 | + if (!file_exists($file_name)) { |
|
293 | + $widget_output = $file_name.' does not exist'; |
|
294 | 294 | } else { |
295 | 295 | $widget_output = file_get_contents($file_name); |
296 | 296 | } |
297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
299 | - if(!file_exists($file_name)) { |
|
300 | - $widget_output = $file_name . ' does not exist'; |
|
297 | + } elseif (substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 9)); |
|
299 | + if (!file_exists($file_name)) { |
|
300 | + $widget_output = $file_name.' does not exist'; |
|
301 | 301 | } else { |
302 | 302 | /* The included file needs to set $widget_output. Can be string, array, object */ |
303 | 303 | include $file_name; |
304 | 304 | } |
305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
305 | + } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
306 | 306 | $chunk_name = trim(substr($params['output'], 7)); |
307 | 307 | $widget_output = $modx->getChunk($chunk_name); |
308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
308 | + } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
309 | 309 | $eval_str = trim(substr($params['output'], 6)); |
310 | 310 | $widget_output = eval($eval_str); |
311 | - } elseif($value !== '') { |
|
311 | + } elseif ($value !== '') { |
|
312 | 312 | $widget_output = $params['output']; |
313 | 313 | } else { |
314 | 314 | $widget_output = ''; |
315 | 315 | } |
316 | - if(is_string($widget_output)) { |
|
316 | + if (is_string($widget_output)) { |
|
317 | 317 | $_ = $modx->config['enable_filter']; |
318 | 318 | $modx->config['enable_filter'] = 1; |
319 | 319 | $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | default: |
328 | 328 | $value = parseInput($value); |
329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
329 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
330 | 330 | // add separator |
331 | 331 | $value = explode('||', $value); |
332 | 332 | $value = implode($sep, $value); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param string $s |
342 | 342 | * @return string |
343 | 343 | */ |
344 | -function decodeParamValue($s) { |
|
344 | +function decodeParamValue($s){ |
|
345 | 345 | $s = str_replace("%3D", '=', $s); // = |
346 | 346 | return str_replace("%26", '&', $s); // & |
347 | 347 | } |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | * @param bool $columns |
356 | 356 | * @return array|string |
357 | 357 | */ |
358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
358 | +function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array |
|
359 | 359 | global $modx; |
360 | - if($modx->db->isResult($src)) { |
|
360 | + if ($modx->db->isResult($src)) { |
|
361 | 361 | // must be a recordset |
362 | 362 | $rows = array(); |
363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
363 | + while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
364 | 364 | return ($type == "array") ? $rows : implode($delim, $rows); |
365 | 365 | } else { |
366 | 366 | // must be a text |
367 | - if($type == "array") { |
|
367 | + if ($type == "array") { |
|
368 | 368 | return explode($delim, $src); |
369 | 369 | } else { |
370 | 370 | return $src; |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | * @param string $value |
377 | 377 | * @return bool|false|int |
378 | 378 | */ |
379 | -function getUnixtimeFromDateString($value) { |
|
379 | +function getUnixtimeFromDateString($value){ |
|
380 | 380 | $timestamp = false; |
381 | 381 | // Check for MySQL or legacy style date |
382 | 382 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
383 | 383 | $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
384 | 384 | $matches = array(); |
385 | - if(strpos($value, '-') !== false) { |
|
386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
385 | + if (strpos($value, '-') !== false) { |
|
386 | + if (preg_match($date_match_1, $value, $matches)) { |
|
387 | 387 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
388 | + } elseif (preg_match($date_match_2, $value, $matches)) { |
|
389 | 389 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
390 | 390 | } |
391 | 391 | } |
392 | 392 | // If those didn't work, use strtotime to figure out the date |
393 | - if($timestamp === false || $timestamp === -1) { |
|
393 | + if ($timestamp === false || $timestamp === -1) { |
|
394 | 394 | $timestamp = strtotime($value); |
395 | 395 | } |
396 | 396 | return $timestamp; |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | * @param string $sep |
16 | 16 | * @return mixed|string |
17 | 17 | */ |
18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') |
|
19 | +{ |
|
19 | 20 | |
20 | 21 | global $modx; |
21 | 22 | $o = ''; |
@@ -59,7 +60,9 @@ discard block |
||
59 | 60 | if(isset($params['align']) && $params['align'] != 'none') { |
60 | 61 | $attr['align'] = $params['align']; |
61 | 62 | } |
62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
63 | + foreach($attr as $k => $v) { |
|
64 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
65 | + } |
|
63 | 66 | $attributes .= ' ' . $params['attrib']; |
64 | 67 | |
65 | 68 | // Output the image with attributes |
@@ -128,7 +131,9 @@ discard block |
||
128 | 131 | 'style' => $params['style'], |
129 | 132 | 'target' => $params['target'], |
130 | 133 | ); |
131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
134 | + foreach($attr as $k => $v) { |
|
135 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
136 | + } |
|
132 | 137 | $attributes .= ' ' . $params['attrib']; // add extra |
133 | 138 | |
134 | 139 | // Output the link |
@@ -157,7 +162,9 @@ discard block |
||
157 | 162 | 'class' => $params['class'], |
158 | 163 | 'style' => $params['style'], |
159 | 164 | ); |
160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
165 | + foreach($attr as $k => $v) { |
|
166 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
167 | + } |
|
161 | 168 | $attributes .= ' ' . $params['attrib']; // add extra |
162 | 169 | |
163 | 170 | // Output the HTML Tag |
@@ -341,7 +348,8 @@ discard block |
||
341 | 348 | * @param string $s |
342 | 349 | * @return string |
343 | 350 | */ |
344 | -function decodeParamValue($s) { |
|
351 | +function decodeParamValue($s) |
|
352 | +{ |
|
345 | 353 | $s = str_replace("%3D", '=', $s); // = |
346 | 354 | return str_replace("%26", '&', $s); // & |
347 | 355 | } |
@@ -355,12 +363,16 @@ discard block |
||
355 | 363 | * @param bool $columns |
356 | 364 | * @return array|string |
357 | 365 | */ |
358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
366 | +function parseInput($src, $delim = "||", $type = "string", $columns = true) |
|
367 | +{ |
|
368 | +// type can be: string, array |
|
359 | 369 | global $modx; |
360 | 370 | if($modx->db->isResult($src)) { |
361 | 371 | // must be a recordset |
362 | 372 | $rows = array(); |
363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
373 | + while($cols = $modx->db->getRow($src, 'num')) { |
|
374 | + $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
375 | + } |
|
364 | 376 | return ($type == "array") ? $rows : implode($delim, $rows); |
365 | 377 | } else { |
366 | 378 | // must be a text |
@@ -376,7 +388,8 @@ discard block |
||
376 | 388 | * @param string $value |
377 | 389 | * @return bool|false|int |
378 | 390 | */ |
379 | -function getUnixtimeFromDateString($value) { |
|
391 | +function getUnixtimeFromDateString($value) |
|
392 | +{ |
|
380 | 393 | $timestamp = false; |
381 | 394 | // Check for MySQL or legacy style date |
382 | 395 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
@@ -381,7 +381,7 @@ |
||
381 | 381 | } // end renderFormElement function |
382 | 382 | |
383 | 383 | /** |
384 | - * @param string|array|mysqli_result $v |
|
384 | + * @param string $v |
|
385 | 385 | * @return array |
386 | 386 | */ |
387 | 387 | function ParseIntputOptions($v) { |
@@ -13,159 +13,159 @@ discard block |
||
13 | 13 | * @return string |
14 | 14 | */ |
15 | 15 | function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
16 | - global $modx; |
|
17 | - global $_style; |
|
18 | - global $_lang; |
|
19 | - global $content; |
|
20 | - global $which_browser; |
|
16 | + global $modx; |
|
17 | + global $_style; |
|
18 | + global $_lang; |
|
19 | + global $content; |
|
20 | + global $which_browser; |
|
21 | 21 | |
22 | - if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
23 | - $eval_str = trim(substr($default_text, 7)); |
|
24 | - $default_text = eval($eval_str); |
|
25 | - $field_value = $default_text; |
|
26 | - } |
|
22 | + if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
23 | + $eval_str = trim(substr($default_text, 7)); |
|
24 | + $default_text = eval($eval_str); |
|
25 | + $field_value = $default_text; |
|
26 | + } |
|
27 | 27 | |
28 | - $field_html = ''; |
|
29 | - $cimode = strpos($field_type, ':'); |
|
30 | - if($cimode === false) { |
|
31 | - switch($field_type) { |
|
28 | + $field_html = ''; |
|
29 | + $cimode = strpos($field_type, ':'); |
|
30 | + if($cimode === false) { |
|
31 | + switch($field_type) { |
|
32 | 32 | |
33 | - case "text": // handler for regular text boxes |
|
34 | - case "rawtext"; // non-htmlentity converted text boxes |
|
35 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
36 | - break; |
|
37 | - case "email": // handles email input fields |
|
38 | - $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
39 | - break; |
|
40 | - case "number": // handles the input of numbers |
|
41 | - $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
42 | - break; |
|
43 | - case "textareamini": // handler for textarea mini boxes |
|
44 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
45 | - break; |
|
46 | - case "textarea": // handler for textarea boxes |
|
47 | - case "rawtextarea": // non-htmlentity convertex textarea boxes |
|
48 | - case "htmlarea": // handler for textarea boxes (deprecated) |
|
49 | - case "richtext": // handler for textarea boxes |
|
50 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
51 | - break; |
|
52 | - case "date": |
|
53 | - $field_id = str_replace(array( |
|
54 | - '-', |
|
55 | - '.' |
|
56 | - ), '_', urldecode($field_id)); |
|
57 | - if($field_value == '') { |
|
58 | - $field_value = 0; |
|
59 | - } |
|
60 | - $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
61 | - $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
33 | + case "text": // handler for regular text boxes |
|
34 | + case "rawtext"; // non-htmlentity converted text boxes |
|
35 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
36 | + break; |
|
37 | + case "email": // handles email input fields |
|
38 | + $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
39 | + break; |
|
40 | + case "number": // handles the input of numbers |
|
41 | + $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
42 | + break; |
|
43 | + case "textareamini": // handler for textarea mini boxes |
|
44 | + $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
45 | + break; |
|
46 | + case "textarea": // handler for textarea boxes |
|
47 | + case "rawtextarea": // non-htmlentity convertex textarea boxes |
|
48 | + case "htmlarea": // handler for textarea boxes (deprecated) |
|
49 | + case "richtext": // handler for textarea boxes |
|
50 | + $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
51 | + break; |
|
52 | + case "date": |
|
53 | + $field_id = str_replace(array( |
|
54 | + '-', |
|
55 | + '.' |
|
56 | + ), '_', urldecode($field_id)); |
|
57 | + if($field_value == '') { |
|
58 | + $field_value = 0; |
|
59 | + } |
|
60 | + $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
61 | + $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
62 | 62 | |
63 | - break; |
|
64 | - case "dropdown": // handler for select boxes |
|
65 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
66 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
67 | - while(list($item, $itemvalue) = each($index_list)) { |
|
68 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
69 | - if(strlen($itemvalue) == 0) { |
|
70 | - $itemvalue = $item; |
|
71 | - } |
|
72 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
73 | - } |
|
74 | - $field_html .= "</select>"; |
|
75 | - break; |
|
76 | - case "listbox": // handler for select boxes |
|
77 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
78 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
79 | - while(list($item, $itemvalue) = each($index_list)) { |
|
80 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
81 | - if(strlen($itemvalue) == 0) { |
|
82 | - $itemvalue = $item; |
|
83 | - } |
|
84 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
85 | - } |
|
86 | - $field_html .= "</select>"; |
|
87 | - break; |
|
88 | - case "listbox-multiple": // handler for select boxes where you can choose multiple items |
|
89 | - $field_value = explode("||", $field_value); |
|
90 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
91 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
92 | - while(list($item, $itemvalue) = each($index_list)) { |
|
93 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
94 | - if(strlen($itemvalue) == 0) { |
|
95 | - $itemvalue = $item; |
|
96 | - } |
|
97 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
98 | - } |
|
99 | - $field_html .= "</select>"; |
|
100 | - break; |
|
101 | - case "url": // handles url input fields |
|
102 | - $urls = array( |
|
103 | - '' => '--', |
|
104 | - 'http://' => 'http://', |
|
105 | - 'https://' => 'https://', |
|
106 | - 'ftp://' => 'ftp://', |
|
107 | - 'mailto:' => 'mailto:' |
|
108 | - ); |
|
109 | - $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
110 | - foreach($urls as $k => $v) { |
|
111 | - if(strpos($field_value, $v) === false) { |
|
112 | - $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
113 | - } else { |
|
114 | - $field_value = str_replace($v, '', $field_value); |
|
115 | - $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
116 | - } |
|
117 | - } |
|
118 | - $field_html .= '</select></td><td>'; |
|
119 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
120 | - break; |
|
121 | - case 'checkbox': // handles check boxes |
|
122 | - $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
|
123 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
124 | - $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
|
125 | - static $i = 0; |
|
126 | - $_ = array(); |
|
127 | - foreach($index_list as $c => $item) { |
|
128 | - if(is_array($item)) { |
|
129 | - $name = trim($item[0]); |
|
130 | - $value = isset($item[1]) ? $item[1] : $name; |
|
131 | - } else { |
|
132 | - $item = trim($item); |
|
133 | - list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array( |
|
134 | - $item, |
|
135 | - $item |
|
136 | - ); |
|
137 | - } |
|
138 | - $checked = in_array($value, $values) ? ' checked="checked"' : ''; |
|
139 | - $param = array( |
|
140 | - $modx->htmlspecialchars($value), |
|
141 | - $i, |
|
142 | - $field_id, |
|
143 | - $checked, |
|
144 | - $modx->htmlspecialchars($name) |
|
145 | - ); |
|
146 | - $_[] = vsprintf($tpl, $param); |
|
147 | - $i++; |
|
148 | - } |
|
149 | - $field_html = implode("\n", $_); |
|
150 | - break; |
|
151 | - case "option": // handles radio buttons |
|
152 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
153 | - static $i = 0; |
|
154 | - while(list($item, $itemvalue) = each($index_list)) { |
|
155 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
156 | - if(strlen($itemvalue) == 0) { |
|
157 | - $itemvalue = $item; |
|
158 | - } |
|
159 | - $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
160 | - $i++; |
|
161 | - } |
|
162 | - break; |
|
163 | - case "image": // handles image fields using htmlarea image manager |
|
164 | - global $_lang; |
|
165 | - global $ResourceManagerLoaded; |
|
166 | - global $content, $use_editor, $which_editor; |
|
167 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
168 | - $field_html .= " |
|
63 | + break; |
|
64 | + case "dropdown": // handler for select boxes |
|
65 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
66 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
67 | + while(list($item, $itemvalue) = each($index_list)) { |
|
68 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
69 | + if(strlen($itemvalue) == 0) { |
|
70 | + $itemvalue = $item; |
|
71 | + } |
|
72 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
73 | + } |
|
74 | + $field_html .= "</select>"; |
|
75 | + break; |
|
76 | + case "listbox": // handler for select boxes |
|
77 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
78 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
79 | + while(list($item, $itemvalue) = each($index_list)) { |
|
80 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
81 | + if(strlen($itemvalue) == 0) { |
|
82 | + $itemvalue = $item; |
|
83 | + } |
|
84 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
85 | + } |
|
86 | + $field_html .= "</select>"; |
|
87 | + break; |
|
88 | + case "listbox-multiple": // handler for select boxes where you can choose multiple items |
|
89 | + $field_value = explode("||", $field_value); |
|
90 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
91 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
92 | + while(list($item, $itemvalue) = each($index_list)) { |
|
93 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
94 | + if(strlen($itemvalue) == 0) { |
|
95 | + $itemvalue = $item; |
|
96 | + } |
|
97 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
98 | + } |
|
99 | + $field_html .= "</select>"; |
|
100 | + break; |
|
101 | + case "url": // handles url input fields |
|
102 | + $urls = array( |
|
103 | + '' => '--', |
|
104 | + 'http://' => 'http://', |
|
105 | + 'https://' => 'https://', |
|
106 | + 'ftp://' => 'ftp://', |
|
107 | + 'mailto:' => 'mailto:' |
|
108 | + ); |
|
109 | + $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
110 | + foreach($urls as $k => $v) { |
|
111 | + if(strpos($field_value, $v) === false) { |
|
112 | + $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
113 | + } else { |
|
114 | + $field_value = str_replace($v, '', $field_value); |
|
115 | + $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
116 | + } |
|
117 | + } |
|
118 | + $field_html .= '</select></td><td>'; |
|
119 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
120 | + break; |
|
121 | + case 'checkbox': // handles check boxes |
|
122 | + $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
|
123 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
124 | + $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
|
125 | + static $i = 0; |
|
126 | + $_ = array(); |
|
127 | + foreach($index_list as $c => $item) { |
|
128 | + if(is_array($item)) { |
|
129 | + $name = trim($item[0]); |
|
130 | + $value = isset($item[1]) ? $item[1] : $name; |
|
131 | + } else { |
|
132 | + $item = trim($item); |
|
133 | + list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array( |
|
134 | + $item, |
|
135 | + $item |
|
136 | + ); |
|
137 | + } |
|
138 | + $checked = in_array($value, $values) ? ' checked="checked"' : ''; |
|
139 | + $param = array( |
|
140 | + $modx->htmlspecialchars($value), |
|
141 | + $i, |
|
142 | + $field_id, |
|
143 | + $checked, |
|
144 | + $modx->htmlspecialchars($name) |
|
145 | + ); |
|
146 | + $_[] = vsprintf($tpl, $param); |
|
147 | + $i++; |
|
148 | + } |
|
149 | + $field_html = implode("\n", $_); |
|
150 | + break; |
|
151 | + case "option": // handles radio buttons |
|
152 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
153 | + static $i = 0; |
|
154 | + while(list($item, $itemvalue) = each($index_list)) { |
|
155 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
156 | + if(strlen($itemvalue) == 0) { |
|
157 | + $itemvalue = $item; |
|
158 | + } |
|
159 | + $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
160 | + $i++; |
|
161 | + } |
|
162 | + break; |
|
163 | + case "image": // handles image fields using htmlarea image manager |
|
164 | + global $_lang; |
|
165 | + global $ResourceManagerLoaded; |
|
166 | + global $content, $use_editor, $which_editor; |
|
167 | + if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
168 | + $field_html .= " |
|
169 | 169 | <script type=\"text/javascript\"> |
170 | 170 | /* <![CDATA[ */ |
171 | 171 | var lastImageCtrl; |
@@ -224,18 +224,18 @@ discard block |
||
224 | 224 | } |
225 | 225 | /* ]]> */ |
226 | 226 | </script>"; |
227 | - $ResourceManagerLoaded = true; |
|
228 | - } |
|
229 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
230 | - break; |
|
231 | - case "file": // handles the input of file uploads |
|
232 | - /* Modified by Timon for use with resource browser */ |
|
233 | - global $_lang; |
|
234 | - global $ResourceManagerLoaded; |
|
235 | - global $content, $use_editor, $which_editor; |
|
236 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
237 | - /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
|
238 | - $field_html .= " |
|
227 | + $ResourceManagerLoaded = true; |
|
228 | + } |
|
229 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
230 | + break; |
|
231 | + case "file": // handles the input of file uploads |
|
232 | + /* Modified by Timon for use with resource browser */ |
|
233 | + global $_lang; |
|
234 | + global $ResourceManagerLoaded; |
|
235 | + global $content, $use_editor, $which_editor; |
|
236 | + if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
237 | + /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
|
238 | + $field_html .= " |
|
239 | 239 | <script type=\"text/javascript\"> |
240 | 240 | /* <![CDATA[ */ |
241 | 241 | var lastImageCtrl; |
@@ -294,90 +294,90 @@ discard block |
||
294 | 294 | } |
295 | 295 | /* ]]> */ |
296 | 296 | </script>"; |
297 | - $ResourceManagerLoaded = true; |
|
298 | - } |
|
299 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
297 | + $ResourceManagerLoaded = true; |
|
298 | + } |
|
299 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
300 | 300 | |
301 | - break; |
|
301 | + break; |
|
302 | 302 | |
303 | - case 'custom_tv': |
|
304 | - $custom_output = ''; |
|
305 | - /* If we are loading a file */ |
|
306 | - if(substr($field_elements, 0, 5) == "@FILE") { |
|
307 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
308 | - if(!file_exists($file_name)) { |
|
309 | - $custom_output = $file_name . ' does not exist'; |
|
310 | - } else { |
|
311 | - $custom_output = file_get_contents($file_name); |
|
312 | - } |
|
313 | - } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
314 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
315 | - if(!file_exists($file_name)) { |
|
316 | - $custom_output = $file_name . ' does not exist'; |
|
317 | - } else { |
|
318 | - ob_start(); |
|
319 | - include $file_name; |
|
320 | - $custom_output = ob_get_contents(); |
|
321 | - ob_end_clean(); |
|
322 | - } |
|
323 | - } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
324 | - $chunk_name = trim(substr($field_elements, 7)); |
|
325 | - $chunk_body = $modx->getChunk($chunk_name); |
|
326 | - if($chunk_body == false) { |
|
327 | - $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
328 | - } else { |
|
329 | - $custom_output = $chunk_body; |
|
330 | - } |
|
331 | - } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
332 | - $eval_str = trim(substr($field_elements, 6)); |
|
333 | - $custom_output = eval($eval_str); |
|
334 | - } else { |
|
335 | - $custom_output = $field_elements; |
|
336 | - } |
|
337 | - $replacements = array( |
|
338 | - '[+field_type+]' => $field_type, |
|
339 | - '[+field_id+]' => $field_id, |
|
340 | - '[+default_text+]' => $default_text, |
|
341 | - '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
342 | - '[+field_style+]' => $field_style, |
|
343 | - ); |
|
344 | - $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
345 | - $modx->documentObject = $content; |
|
346 | - $modx->documentIdentifier = $content['id']; |
|
347 | - $custom_output = $modx->parseDocumentSource($custom_output); |
|
348 | - $field_html .= $custom_output; |
|
349 | - break; |
|
303 | + case 'custom_tv': |
|
304 | + $custom_output = ''; |
|
305 | + /* If we are loading a file */ |
|
306 | + if(substr($field_elements, 0, 5) == "@FILE") { |
|
307 | + $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
308 | + if(!file_exists($file_name)) { |
|
309 | + $custom_output = $file_name . ' does not exist'; |
|
310 | + } else { |
|
311 | + $custom_output = file_get_contents($file_name); |
|
312 | + } |
|
313 | + } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
314 | + $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
315 | + if(!file_exists($file_name)) { |
|
316 | + $custom_output = $file_name . ' does not exist'; |
|
317 | + } else { |
|
318 | + ob_start(); |
|
319 | + include $file_name; |
|
320 | + $custom_output = ob_get_contents(); |
|
321 | + ob_end_clean(); |
|
322 | + } |
|
323 | + } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
324 | + $chunk_name = trim(substr($field_elements, 7)); |
|
325 | + $chunk_body = $modx->getChunk($chunk_name); |
|
326 | + if($chunk_body == false) { |
|
327 | + $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
328 | + } else { |
|
329 | + $custom_output = $chunk_body; |
|
330 | + } |
|
331 | + } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
332 | + $eval_str = trim(substr($field_elements, 6)); |
|
333 | + $custom_output = eval($eval_str); |
|
334 | + } else { |
|
335 | + $custom_output = $field_elements; |
|
336 | + } |
|
337 | + $replacements = array( |
|
338 | + '[+field_type+]' => $field_type, |
|
339 | + '[+field_id+]' => $field_id, |
|
340 | + '[+default_text+]' => $default_text, |
|
341 | + '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
342 | + '[+field_style+]' => $field_style, |
|
343 | + ); |
|
344 | + $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
345 | + $modx->documentObject = $content; |
|
346 | + $modx->documentIdentifier = $content['id']; |
|
347 | + $custom_output = $modx->parseDocumentSource($custom_output); |
|
348 | + $field_html .= $custom_output; |
|
349 | + break; |
|
350 | 350 | |
351 | - default: // the default handler -- for errors, mostly |
|
352 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
351 | + default: // the default handler -- for errors, mostly |
|
352 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
353 | 353 | |
354 | - } // end switch statement |
|
355 | - } else { |
|
356 | - $custom = explode(":", $field_type); |
|
357 | - $custom_output = ''; |
|
358 | - $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
359 | - if(!file_exists($file_name)) { |
|
360 | - $custom_output = $file_name . ' does not exist'; |
|
361 | - } else { |
|
362 | - ob_start(); |
|
363 | - include $file_name; |
|
364 | - $custom_output = ob_get_contents(); |
|
365 | - ob_end_clean(); |
|
366 | - } |
|
367 | - $replacements = array( |
|
368 | - '[+field_type+]' => $field_type, |
|
369 | - '[+field_id+]' => $field_id, |
|
370 | - '[+default_text+]' => $default_text, |
|
371 | - '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
372 | - '[+field_style+]' => $field_style, |
|
373 | - ); |
|
374 | - $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
375 | - $modx->documentObject = $content; |
|
376 | - $custom_output = $modx->parseDocumentSource($custom_output); |
|
377 | - $field_html .= $custom_output; |
|
378 | - } |
|
354 | + } // end switch statement |
|
355 | + } else { |
|
356 | + $custom = explode(":", $field_type); |
|
357 | + $custom_output = ''; |
|
358 | + $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
359 | + if(!file_exists($file_name)) { |
|
360 | + $custom_output = $file_name . ' does not exist'; |
|
361 | + } else { |
|
362 | + ob_start(); |
|
363 | + include $file_name; |
|
364 | + $custom_output = ob_get_contents(); |
|
365 | + ob_end_clean(); |
|
366 | + } |
|
367 | + $replacements = array( |
|
368 | + '[+field_type+]' => $field_type, |
|
369 | + '[+field_id+]' => $field_id, |
|
370 | + '[+default_text+]' => $default_text, |
|
371 | + '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
372 | + '[+field_style+]' => $field_style, |
|
373 | + ); |
|
374 | + $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
375 | + $modx->documentObject = $content; |
|
376 | + $custom_output = $modx->parseDocumentSource($custom_output); |
|
377 | + $field_html .= $custom_output; |
|
378 | + } |
|
379 | 379 | |
380 | - return $field_html; |
|
380 | + return $field_html; |
|
381 | 381 | } // end renderFormElement function |
382 | 382 | |
383 | 383 | /** |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | * @return array |
386 | 386 | */ |
387 | 387 | function ParseIntputOptions($v) { |
388 | - global $modx; |
|
389 | - $a = array(); |
|
390 | - if(is_array($v)) { |
|
391 | - return $v; |
|
392 | - } else if($modx->db->isResult($v)) { |
|
393 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
394 | - } else { |
|
395 | - $a = explode("||", $v); |
|
396 | - } |
|
397 | - return $a; |
|
388 | + global $modx; |
|
389 | + $a = array(); |
|
390 | + if(is_array($v)) { |
|
391 | + return $v; |
|
392 | + } else if($modx->db->isResult($v)) { |
|
393 | + while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
394 | + } else { |
|
395 | + $a = explode("||", $v); |
|
396 | + } |
|
397 | + return $a; |
|
398 | 398 | } |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | * @param array $tvsArray |
13 | 13 | * @return string |
14 | 14 | */ |
15 | -function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
|
15 | +function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()){ |
|
16 | 16 | global $modx; |
17 | 17 | global $_style; |
18 | 18 | global $_lang; |
19 | 19 | global $content; |
20 | 20 | global $which_browser; |
21 | 21 | |
22 | - if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
22 | + if (substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
23 | 23 | $eval_str = trim(substr($default_text, 7)); |
24 | 24 | $default_text = eval($eval_str); |
25 | 25 | $field_value = $default_text; |
@@ -27,74 +27,74 @@ discard block |
||
27 | 27 | |
28 | 28 | $field_html = ''; |
29 | 29 | $cimode = strpos($field_type, ':'); |
30 | - if($cimode === false) { |
|
31 | - switch($field_type) { |
|
30 | + if ($cimode === false) { |
|
31 | + switch ($field_type) { |
|
32 | 32 | |
33 | 33 | case "text": // handler for regular text boxes |
34 | 34 | case "rawtext"; // non-htmlentity converted text boxes |
35 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
35 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" />'; |
|
36 | 36 | break; |
37 | 37 | case "email": // handles email input fields |
38 | - $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
38 | + $field_html .= '<input type="email" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%"/>'; |
|
39 | 39 | break; |
40 | 40 | case "number": // handles the input of numbers |
41 | - $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
41 | + $field_html .= '<input type="number" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
42 | 42 | break; |
43 | 43 | case "textareamini": // handler for textarea mini boxes |
44 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
44 | + $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>'; |
|
45 | 45 | break; |
46 | 46 | case "textarea": // handler for textarea boxes |
47 | 47 | case "rawtextarea": // non-htmlentity convertex textarea boxes |
48 | 48 | case "htmlarea": // handler for textarea boxes (deprecated) |
49 | 49 | case "richtext": // handler for textarea boxes |
50 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
50 | + $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>'; |
|
51 | 51 | break; |
52 | 52 | case "date": |
53 | 53 | $field_id = str_replace(array( |
54 | 54 | '-', |
55 | 55 | '.' |
56 | 56 | ), '_', urldecode($field_id)); |
57 | - if($field_value == '') { |
|
57 | + if ($field_value == '') { |
|
58 | 58 | $field_value = 0; |
59 | 59 | } |
60 | - $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
61 | - $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
60 | + $field_html .= '<input id="tv'.$field_id.'" name="tv'.$field_id.'" class="DatePicker" type="text" value="'.($field_value == 0 || !isset($field_value) ? "" : $field_value).'" onblur="documentDirty=true;" />'; |
|
61 | + $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].value=\'\';document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="'.$_style["actions_calendar_delete"].'"></i></a>'; |
|
62 | 62 | |
63 | 63 | break; |
64 | 64 | case "dropdown": // handler for select boxes |
65 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
65 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" size="1" onchange="documentDirty=true;">'; |
|
66 | 66 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
67 | - while(list($item, $itemvalue) = each($index_list)) { |
|
67 | + while (list($item, $itemvalue) = each($index_list)) { |
|
68 | 68 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
69 | - if(strlen($itemvalue) == 0) { |
|
69 | + if (strlen($itemvalue) == 0) { |
|
70 | 70 | $itemvalue = $item; |
71 | 71 | } |
72 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
72 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
73 | 73 | } |
74 | 74 | $field_html .= "</select>"; |
75 | 75 | break; |
76 | 76 | case "listbox": // handler for select boxes |
77 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
77 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" onchange="documentDirty=true;" size="8">'; |
|
78 | 78 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
79 | - while(list($item, $itemvalue) = each($index_list)) { |
|
79 | + while (list($item, $itemvalue) = each($index_list)) { |
|
80 | 80 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
81 | - if(strlen($itemvalue) == 0) { |
|
81 | + if (strlen($itemvalue) == 0) { |
|
82 | 82 | $itemvalue = $item; |
83 | 83 | } |
84 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
84 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
85 | 85 | } |
86 | 86 | $field_html .= "</select>"; |
87 | 87 | break; |
88 | 88 | case "listbox-multiple": // handler for select boxes where you can choose multiple items |
89 | 89 | $field_value = explode("||", $field_value); |
90 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
90 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
91 | 91 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
92 | - while(list($item, $itemvalue) = each($index_list)) { |
|
92 | + while (list($item, $itemvalue) = each($index_list)) { |
|
93 | 93 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
94 | - if(strlen($itemvalue) == 0) { |
|
94 | + if (strlen($itemvalue) == 0) { |
|
95 | 95 | $itemvalue = $item; |
96 | 96 | } |
97 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
97 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.(in_array($itemvalue, $field_value) ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
98 | 98 | } |
99 | 99 | $field_html .= "</select>"; |
100 | 100 | break; |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | 'ftp://' => 'ftp://', |
107 | 107 | 'mailto:' => 'mailto:' |
108 | 108 | ); |
109 | - $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
110 | - foreach($urls as $k => $v) { |
|
111 | - if(strpos($field_value, $v) === false) { |
|
112 | - $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
109 | + $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv'.$field_id.'_prefix" name="tv'.$field_id.'_prefix" onchange="documentDirty=true;">'; |
|
110 | + foreach ($urls as $k => $v) { |
|
111 | + if (strpos($field_value, $v) === false) { |
|
112 | + $field_html .= '<option value="'.$v.'">'.$k.'</option>'; |
|
113 | 113 | } else { |
114 | 114 | $field_value = str_replace($v, '', $field_value); |
115 | - $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
115 | + $field_html .= '<option value="'.$v.'" selected="selected">'.$k.'</option>'; |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | $field_html .= '</select></td><td>'; |
119 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
119 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" width="100" '.$field_style.' onchange="documentDirty=true;" /></td></tr></table>'; |
|
120 | 120 | break; |
121 | 121 | case 'checkbox': // handles check boxes |
122 | 122 | $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
125 | 125 | static $i = 0; |
126 | 126 | $_ = array(); |
127 | - foreach($index_list as $c => $item) { |
|
128 | - if(is_array($item)) { |
|
127 | + foreach ($index_list as $c => $item) { |
|
128 | + if (is_array($item)) { |
|
129 | 129 | $name = trim($item[0]); |
130 | 130 | $value = isset($item[1]) ? $item[1] : $name; |
131 | 131 | } else { |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | case "option": // handles radio buttons |
152 | 152 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
153 | 153 | static $i = 0; |
154 | - while(list($item, $itemvalue) = each($index_list)) { |
|
154 | + while (list($item, $itemvalue) = each($index_list)) { |
|
155 | 155 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
156 | - if(strlen($itemvalue) == 0) { |
|
156 | + if (strlen($itemvalue) == 0) { |
|
157 | 157 | $itemvalue = $item; |
158 | 158 | } |
159 | - $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
159 | + $field_html .= '<input type="radio" value="'.$modx->htmlspecialchars($itemvalue).'" id="tv_'.$i.'" name="tv'.$field_id.'" '.($itemvalue == $field_value ? 'checked="checked"' : '').' onchange="documentDirty=true;" /><label for="tv_'.$i.'" class="radio">'.$item.'</label><br />'; |
|
160 | 160 | $i++; |
161 | 161 | } |
162 | 162 | break; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | global $_lang; |
165 | 165 | global $ResourceManagerLoaded; |
166 | 166 | global $content, $use_editor, $which_editor; |
167 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
167 | + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
168 | 168 | $field_html .= " |
169 | 169 | <script type=\"text/javascript\"> |
170 | 170 | /* <![CDATA[ */ |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | lastImageCtrl = ctrl; |
187 | 187 | var w = screen.width * 0.5; |
188 | 188 | var h = screen.height * 0.5; |
189 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
189 | + OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
190 | 190 | } |
191 | 191 | function BrowseFileServer(ctrl) { |
192 | 192 | lastFileCtrl = ctrl; |
193 | 193 | var w = screen.width * 0.5; |
194 | 194 | var h = screen.height * 0.5; |
195 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
195 | + OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
196 | 196 | } |
197 | 197 | function SetUrlChange(el) { |
198 | 198 | if ('createEvent' in document) { |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | </script>"; |
227 | 227 | $ResourceManagerLoaded = true; |
228 | 228 | } |
229 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
229 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseServer(\'tv'.$field_id.'\')" />'; |
|
230 | 230 | break; |
231 | 231 | case "file": // handles the input of file uploads |
232 | 232 | /* Modified by Timon for use with resource browser */ |
233 | 233 | global $_lang; |
234 | 234 | global $ResourceManagerLoaded; |
235 | 235 | global $content, $use_editor, $which_editor; |
236 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
236 | + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
237 | 237 | /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
238 | 238 | $field_html .= " |
239 | 239 | <script type=\"text/javascript\"> |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | lastImageCtrl = ctrl; |
257 | 257 | var w = screen.width * 0.5; |
258 | 258 | var h = screen.height * 0.5; |
259 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
259 | + OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
260 | 260 | } |
261 | 261 | function BrowseFileServer(ctrl) { |
262 | 262 | lastFileCtrl = ctrl; |
263 | 263 | var w = screen.width * 0.5; |
264 | 264 | var h = screen.height * 0.5; |
265 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
265 | + OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
266 | 266 | } |
267 | 267 | function SetUrlChange(el) { |
268 | 268 | if ('createEvent' in document) { |
@@ -296,39 +296,39 @@ discard block |
||
296 | 296 | </script>"; |
297 | 297 | $ResourceManagerLoaded = true; |
298 | 298 | } |
299 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
299 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseFileServer(\'tv'.$field_id.'\')" />'; |
|
300 | 300 | |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'custom_tv': |
304 | 304 | $custom_output = ''; |
305 | 305 | /* If we are loading a file */ |
306 | - if(substr($field_elements, 0, 5) == "@FILE") { |
|
307 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
308 | - if(!file_exists($file_name)) { |
|
309 | - $custom_output = $file_name . ' does not exist'; |
|
306 | + if (substr($field_elements, 0, 5) == "@FILE") { |
|
307 | + $file_name = MODX_BASE_PATH.trim(substr($field_elements, 6)); |
|
308 | + if (!file_exists($file_name)) { |
|
309 | + $custom_output = $file_name.' does not exist'; |
|
310 | 310 | } else { |
311 | 311 | $custom_output = file_get_contents($file_name); |
312 | 312 | } |
313 | - } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
314 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
315 | - if(!file_exists($file_name)) { |
|
316 | - $custom_output = $file_name . ' does not exist'; |
|
313 | + } elseif (substr($field_elements, 0, 8) == '@INCLUDE') { |
|
314 | + $file_name = MODX_BASE_PATH.trim(substr($field_elements, 9)); |
|
315 | + if (!file_exists($file_name)) { |
|
316 | + $custom_output = $file_name.' does not exist'; |
|
317 | 317 | } else { |
318 | 318 | ob_start(); |
319 | 319 | include $file_name; |
320 | 320 | $custom_output = ob_get_contents(); |
321 | 321 | ob_end_clean(); |
322 | 322 | } |
323 | - } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
323 | + } elseif (substr($field_elements, 0, 6) == "@CHUNK") { |
|
324 | 324 | $chunk_name = trim(substr($field_elements, 7)); |
325 | 325 | $chunk_body = $modx->getChunk($chunk_name); |
326 | - if($chunk_body == false) { |
|
327 | - $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
326 | + if ($chunk_body == false) { |
|
327 | + $custom_output = $_lang['chunk_no_exist'].'('.$_lang['htmlsnippet_name'].':'.$chunk_name.')'; |
|
328 | 328 | } else { |
329 | 329 | $custom_output = $chunk_body; |
330 | 330 | } |
331 | - } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
331 | + } elseif (substr($field_elements, 0, 5) == "@EVAL") { |
|
332 | 332 | $eval_str = trim(substr($field_elements, 6)); |
333 | 333 | $custom_output = eval($eval_str); |
334 | 334 | } else { |
@@ -349,15 +349,15 @@ discard block |
||
349 | 349 | break; |
350 | 350 | |
351 | 351 | default: // the default handler -- for errors, mostly |
352 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
352 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' onchange="documentDirty=true;" />'; |
|
353 | 353 | |
354 | 354 | } // end switch statement |
355 | 355 | } else { |
356 | 356 | $custom = explode(":", $field_type); |
357 | 357 | $custom_output = ''; |
358 | - $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
359 | - if(!file_exists($file_name)) { |
|
360 | - $custom_output = $file_name . ' does not exist'; |
|
358 | + $file_name = MODX_BASE_PATH.'assets/tvs/'.$custom['1'].'/'.$custom['1'].'.customtv.php'; |
|
359 | + if (!file_exists($file_name)) { |
|
360 | + $custom_output = $file_name.' does not exist'; |
|
361 | 361 | } else { |
362 | 362 | ob_start(); |
363 | 363 | include $file_name; |
@@ -384,13 +384,13 @@ discard block |
||
384 | 384 | * @param string|array|mysqli_result $v |
385 | 385 | * @return array |
386 | 386 | */ |
387 | -function ParseIntputOptions($v) { |
|
387 | +function ParseIntputOptions($v){ |
|
388 | 388 | global $modx; |
389 | 389 | $a = array(); |
390 | - if(is_array($v)) { |
|
390 | + if (is_array($v)) { |
|
391 | 391 | return $v; |
392 | - } else if($modx->db->isResult($v)) { |
|
393 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
392 | + } else if ($modx->db->isResult($v)) { |
|
393 | + while ($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
394 | 394 | } else { |
395 | 395 | $a = explode("||", $v); |
396 | 396 | } |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @param array $tvsArray |
13 | 13 | * @return string |
14 | 14 | */ |
15 | -function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
|
15 | +function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) |
|
16 | +{ |
|
16 | 17 | global $modx; |
17 | 18 | global $_style; |
18 | 19 | global $_lang; |
@@ -384,13 +385,16 @@ discard block |
||
384 | 385 | * @param string|array|mysqli_result $v |
385 | 386 | * @return array |
386 | 387 | */ |
387 | -function ParseIntputOptions($v) { |
|
388 | +function ParseIntputOptions($v) |
|
389 | +{ |
|
388 | 390 | global $modx; |
389 | 391 | $a = array(); |
390 | 392 | if(is_array($v)) { |
391 | 393 | return $v; |
392 | 394 | } else if($modx->db->isResult($v)) { |
393 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
395 | + while($cols = $modx->db->getRow($v, 'num')) { |
|
396 | + $a[] = $cols; |
|
397 | + } |
|
394 | 398 | } else { |
395 | 399 | $a = explode("||", $v); |
396 | 400 | } |
@@ -237,7 +237,7 @@ |
||
237 | 237 | /** |
238 | 238 | * build siteCache file |
239 | 239 | * @param DocumentParser $modx |
240 | - * @return boolean success |
|
240 | + * @return null|boolean success |
|
241 | 241 | */ |
242 | 242 | public function buildCache($modx) |
243 | 243 | { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | if (isset($this->aliases[$id])) { |
95 | 95 | if ($this->aliasVisible[$id] == 1) { |
96 | 96 | if ($path != '') { |
97 | - $path = $this->aliases[$id] . '/' . $path; |
|
97 | + $path = $this->aliases[$id].'/'.$path; |
|
98 | 98 | } else { |
99 | 99 | $path = $this->aliases[$id]; |
100 | 100 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $modx->messageQuit("Cache path not set."); |
119 | 119 | } |
120 | 120 | |
121 | - $files = glob(realpath($this->cachePath) . '/*.pageCache.php'); |
|
121 | + $files = glob(realpath($this->cachePath).'/*.pageCache.php'); |
|
122 | 122 | $filesincache = count($files); |
123 | 123 | $deletedfiles = array(); |
124 | 124 | while ($file = array_shift($files)) { |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | if (isset($opcache)) { |
152 | 152 | echo '<p>Opcache empty.</p>'; |
153 | 153 | } |
154 | - echo '<p>' . $_lang['cache_files_deleted'] . '</p><ul>'; |
|
154 | + echo '<p>'.$_lang['cache_files_deleted'].'</p><ul>'; |
|
155 | 155 | foreach ($deletedfiles as $deletedfile) { |
156 | - echo '<li>' . $deletedfile . '</li>'; |
|
156 | + echo '<li>'.$deletedfile.'</li>'; |
|
157 | 157 | } |
158 | 158 | echo '</ul>'; |
159 | 159 | } |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | |
173 | 173 | |
174 | 174 | // write the file |
175 | - $content = '<?php' . "\n"; |
|
176 | - $content .= '$recent_update=\'' . $this->request_time . '\';' . "\n"; |
|
177 | - $content .= '$cacheRefreshTime=\'' . $cacheRefreshTime . '\';' . "\n"; |
|
175 | + $content = '<?php'."\n"; |
|
176 | + $content .= '$recent_update=\''.$this->request_time.'\';'."\n"; |
|
177 | + $content .= '$cacheRefreshTime=\''.$cacheRefreshTime.'\';'."\n"; |
|
178 | 178 | |
179 | - $filename = $this->cachePath . '/sitePublishing.idx.php'; |
|
179 | + $filename = $this->cachePath.'/sitePublishing.idx.php'; |
|
180 | 180 | if (!$handle = fopen($filename, 'w')) { |
181 | 181 | exit("Cannot open file ({$filename}"); |
182 | 182 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $timesArr = array(); |
201 | 201 | |
202 | 202 | $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', |
203 | - 'pub_date>' . $this->request_time); |
|
203 | + 'pub_date>'.$this->request_time); |
|
204 | 204 | if (!$result) { |
205 | 205 | echo "Couldn't determine next publish event!"; |
206 | 206 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', |
214 | - 'unpub_date>' . $this->request_time); |
|
214 | + 'unpub_date>'.$this->request_time); |
|
215 | 215 | if (!$result) { |
216 | 216 | echo "Couldn't determine next unpublish event!"; |
217 | 217 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $config = array(); |
251 | 251 | $content .= '$c=&$this->config;'; |
252 | 252 | while (list($key, $value) = $modx->db->getRow($rs, 'num')) { |
253 | - $content .= '$c[\'' . $key . '\']="' . $this->escapeDoubleQuotes($value) . '";'; |
|
253 | + $content .= '$c[\''.$key.'\']="'.$this->escapeDoubleQuotes($value).'";'; |
|
254 | 254 | $config[$key] = $value; |
255 | 255 | } |
256 | 256 | |
@@ -288,23 +288,23 @@ discard block |
||
288 | 288 | $docid = $doc['id']; |
289 | 289 | if ($use_alias_path) { |
290 | 290 | $tmpPath = $this->getParents($doc['parent']); |
291 | - $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '') . $doc['alias']; |
|
291 | + $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '').$doc['alias']; |
|
292 | 292 | $key = $alias; |
293 | 293 | } else { |
294 | 294 | $key = $doc['alias']; |
295 | 295 | } |
296 | 296 | |
297 | 297 | $doc['path'] = $tmpPath; |
298 | - $content .= '$a[' . $docid . ']=array(\'id\'=>' . $docid . ',\'alias\'=>\'' . $doc['alias'] . '\',\'path\'=>\'' . $doc['path'] . '\',\'parent\'=>' . $doc['parent'] . ',\'isfolder\'=>' . $doc['isfolder'] . ',\'alias_visible\'=>' . $doc['alias_visible'] . ');'; |
|
299 | - $content .= '$d[\'' . $key . '\']=' . $docid . ';'; |
|
300 | - $content .= '$m[]=array(' . $doc['parent'] . '=>' . $docid . ');'; |
|
298 | + $content .= '$a['.$docid.']=array(\'id\'=>'.$docid.',\'alias\'=>\''.$doc['alias'].'\',\'path\'=>\''.$doc['path'].'\',\'parent\'=>'.$doc['parent'].',\'isfolder\'=>'.$doc['isfolder'].',\'alias_visible\'=>'.$doc['alias_visible'].');'; |
|
299 | + $content .= '$d[\''.$key.'\']='.$docid.';'; |
|
300 | + $content .= '$m[]=array('.$doc['parent'].'=>'.$docid.');'; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | // get content types |
304 | 304 | $rs = $modx->db->select('id, contentType', '[+prefix+]site_content', "contentType!='text/html'"); |
305 | 305 | $content .= '$c=&$this->contentTypes;'; |
306 | 306 | while ($doc = $modx->db->getRow($rs)) { |
307 | - $content .= '$c[\'' . $doc['id'] . '\']=\'' . $doc['contentType'] . '\';'; |
|
307 | + $content .= '$c[\''.$doc['id'].'\']=\''.$doc['contentType'].'\';'; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // WRITE Chunks to cache file |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | if ($modx->config['minifyphp_incache']) { |
315 | 315 | $doc['snippet'] = $this->php_strip_whitespace($doc['snippet']); |
316 | 316 | } |
317 | - $content .= '$c[\'' . $doc['name'] . '\']=\'' . ($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])) . '\';'; |
|
317 | + $content .= '$c[\''.$doc['name'].'\']=\''.($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])).'\';'; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // WRITE snippets to cache file |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | while ($row = $modx->db->getRow($rs)) { |
326 | 326 | $key = $row['name']; |
327 | 327 | if ($row['disabled']) { |
328 | - $content .= '$s[\'' . $key . '\']=\'return false;\';'; |
|
328 | + $content .= '$s[\''.$key.'\']=\'return false;\';'; |
|
329 | 329 | } else { |
330 | 330 | $value = trim($row['snippet']); |
331 | 331 | if ($modx->config['minifyphp_incache']) { |
332 | 332 | $value = $this->php_strip_whitespace($value); |
333 | 333 | } |
334 | - $content .= '$s[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
334 | + $content .= '$s[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
335 | 335 | $properties = $modx->parseProperties($row['properties']); |
336 | 336 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
337 | 337 | $properties = array_merge($sharedproperties, $properties); |
338 | 338 | if (0 < count($properties)) { |
339 | - $content .= '$s[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
339 | + $content .= '$s[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | } |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | if ($modx->config['minifyphp_incache']) { |
355 | 355 | $value = $this->php_strip_whitespace($value); |
356 | 356 | } |
357 | - $content .= '$p[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
357 | + $content .= '$p[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
358 | 358 | if ($row['properties'] != '' || $row['sharedproperties'] != '') { |
359 | 359 | $properties = $modx->parseProperties($row['properties']); |
360 | 360 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
361 | 361 | $properties = array_merge($sharedproperties, $properties); |
362 | 362 | if (0 < count($properties)) { |
363 | - $content .= '$p[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
363 | + $content .= '$p[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | } |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | } |
384 | 384 | foreach ($events as $evtname => $pluginnames) { |
385 | 385 | $events[$evtname] = $pluginnames; |
386 | - $content .= '$e[\'' . $evtname . '\']=array(\'' . implode('\',\'', |
|
387 | - $this->escapeSingleQuotes($pluginnames)) . '\');'; |
|
386 | + $content .= '$e[\''.$evtname.'\']=array(\''.implode('\',\'', |
|
387 | + $this->escapeSingleQuotes($pluginnames)).'\');'; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | $content .= "\n"; |
391 | 391 | |
392 | 392 | // close and write the file |
393 | - $filename = $this->cachePath . 'siteCache.idx.php'; |
|
393 | + $filename = $this->cachePath.'siteCache.idx.php'; |
|
394 | 394 | |
395 | 395 | // invoke OnBeforeCacheUpdate event |
396 | 396 | if ($modx) { |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | exit("Cannot write main MODX cache file! Make sure the assets/cache directory is writable!"); |
402 | 402 | } |
403 | 403 | |
404 | - if (!is_file($this->cachePath . '/.htaccess')) { |
|
405 | - file_put_contents($this->cachePath . '/.htaccess', "order deny,allow\ndeny from all\n"); |
|
404 | + if (!is_file($this->cachePath.'/.htaccess')) { |
|
405 | + file_put_contents($this->cachePath.'/.htaccess', "order deny,allow\ndeny from all\n"); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | // invoke OnCacheUpdate event |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | |
425 | 425 | $source = trim($source); |
426 | 426 | if (substr($source, 0, 5) !== '<?php') { |
427 | - $source = '<?php ' . $source; |
|
427 | + $source = '<?php '.$source; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | $tokens = token_get_all($source); |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | } |
483 | 483 | } |
484 | 484 | $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'), |
485 | - array('', ' ', "\n" . '<!--', '-->' . "\n", '-->' . "\n" . '<!--'), $_); |
|
485 | + array('', ' ', "\n".'<!--', '-->'."\n", '-->'."\n".'<!--'), $_); |
|
486 | 486 | $source = trim($source); |
487 | 487 | |
488 | 488 | return $source; |
@@ -79,7 +79,8 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function getParents($id, $path = '') |
82 | - { // modx:returns child's parent |
|
82 | + { |
|
83 | +// modx:returns child's parent |
|
83 | 84 | global $modx; |
84 | 85 | if (empty($this->aliases)) { |
85 | 86 | $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible"; |
@@ -456,7 +457,8 @@ discard block |
||
456 | 457 | $_ = trim($_); |
457 | 458 | } |
458 | 459 | $lastChar = substr($_, -1); |
459 | - if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289 |
|
460 | + if (!in_array($lastChar, $chars)) { |
|
461 | +// ,320,327,288,284,289 |
|
460 | 462 | if (!in_array($prev_token, |
461 | 463 | array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) { |
462 | 464 | $_ .= ' '; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! function_exists('install_sessionCheck')) { |
|
2 | +if (!function_exists('install_sessionCheck')) { |
|
3 | 3 | function install_sessionCheck() |
4 | 4 | { |
5 | 5 | global $_lang; |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | </head> |
22 | 22 | <body> |
23 | 23 | <div class="install"> |
24 | - <p>' . $_lang["session_problem"] . '</p> |
|
25 | - <p><a href="./">' . $_lang["session_problem_try_again"] . '</a></p> |
|
24 | + <p>' . $_lang["session_problem"].'</p> |
|
25 | + <p><a href="./">' . $_lang["session_problem_try_again"].'</a></p> |
|
26 | 26 | </div> |
27 | 27 | </body> |
28 | 28 | </html>'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -if( ! function_exists('parse')) { |
|
35 | +if (!function_exists('parse')) { |
|
36 | 36 | /** |
37 | 37 | * @param string $src |
38 | 38 | * @param array $ph |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | function parse($src, $ph, $left = '[+', $right = '+]') |
44 | 44 | { |
45 | 45 | foreach ($ph as $k => $v) { |
46 | - $k = $left . $k . $right; |
|
46 | + $k = $left.$k.$right; |
|
47 | 47 | $src = str_replace($k, $v, $src); |
48 | 48 | } |
49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -if( ! function_exists('ph')) { |
|
54 | +if (!function_exists('ph')) { |
|
55 | 55 | /** |
56 | 56 | * @return array |
57 | 57 | */ |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $ph['textdir'] = $modx_textdir ? ' id="rtl"' : ''; |
71 | 71 | $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd']; |
72 | 72 | $ph['version'] = $moduleVersion; |
73 | - $ph['release_date'] = ($modx_textdir ? '‏' : '') . $modx_release_date; |
|
73 | + $ph['release_date'] = ($modx_textdir ? '‏' : '').$modx_release_date; |
|
74 | 74 | $ph['footer1'] = $_lang['modx_footer1']; |
75 | 75 | $ph['footer2'] = $_lang['modx_footer2']; |
76 | 76 | $ph['current_year'] = date('Y'); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | -if( ! function_exists('get_installmode')) { |
|
82 | +if (!function_exists('get_installmode')) { |
|
83 | 83 | /** |
84 | 84 | * @return int |
85 | 85 | */ |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | -if( ! function_exists('getLangs')) { |
|
144 | +if (!function_exists('getLangs')) { |
|
145 | 145 | /** |
146 | 146 | * @param string $install_language |
147 | 147 | * @return string |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | $langs = array(); |
158 | - if ($handle = opendir("../" . MGR_DIR . "/includes/lang")) { |
|
158 | + if ($handle = opendir("../".MGR_DIR."/includes/lang")) { |
|
159 | 159 | while (false !== ($file = readdir($handle))) { |
160 | 160 | if (strpos($file, '.inc.') !== false) { |
161 | 161 | $langs[] = $file; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
|
2 | +$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0; |
|
3 | 3 | |
4 | -if( ! function_exists('getTemplates')) { |
|
4 | +if (!function_exists('getTemplates')) { |
|
5 | 5 | /** |
6 | 6 | * @param array $presets |
7 | 7 | * @return string |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | $_[] = parse($tpl, $ph); |
26 | 26 | $i++; |
27 | 27 | } |
28 | - return (0 < count($_)) ? '<h3>[%templates%]</h3>' . implode("\n", $_) : ''; |
|
28 | + return (0 < count($_)) ? '<h3>[%templates%]</h3>'.implode("\n", $_) : ''; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -if( ! function_exists('getTVs')) { |
|
32 | +if (!function_exists('getTVs')) { |
|
33 | 33 | /** |
34 | 34 | * @param array $presets |
35 | 35 | * @return string |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | $_[] = parse($tpl, $ph); |
55 | 55 | $i++; |
56 | 56 | } |
57 | - return (0 < count($_)) ? '<h3>[%tvs%]</h3>' . implode("\n", $_) : ''; |
|
57 | + return (0 < count($_)) ? '<h3>[%tvs%]</h3>'.implode("\n", $_) : ''; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | -if( ! function_exists('getChunks')) { |
|
61 | +if (!function_exists('getChunks')) { |
|
62 | 62 | /** |
63 | 63 | * display chunks |
64 | 64 | * |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | $_[] = parse($tpl, $ph); |
85 | 85 | $i++; |
86 | 86 | } |
87 | - return (0 < count($_)) ? '<h3>[%chunks%]</h3>' . implode("\n", $_) : ''; |
|
87 | + return (0 < count($_)) ? '<h3>[%chunks%]</h3>'.implode("\n", $_) : ''; |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | -if( ! function_exists('getModules')) { |
|
91 | +if (!function_exists('getModules')) { |
|
92 | 92 | /** |
93 | 93 | * display modules |
94 | 94 | * |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | $_[] = parse($tpl, $ph); |
115 | 115 | $i++; |
116 | 116 | } |
117 | - return (0 < count($_)) ? '<h3>[%modules%]</h3>' . implode("\n", $_) : ''; |
|
117 | + return (0 < count($_)) ? '<h3>[%modules%]</h3>'.implode("\n", $_) : ''; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | -if( ! function_exists('getPlugins')) { |
|
121 | +if (!function_exists('getPlugins')) { |
|
122 | 122 | /** |
123 | 123 | * display plugins |
124 | 124 | * |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | $_[] = parse($tpl, $ph); |
149 | 149 | $i++; |
150 | 150 | } |
151 | - return (0 < count($_)) ? '<h3>[%plugins%]</h3>' . implode("\n", $_) : ''; |
|
151 | + return (0 < count($_)) ? '<h3>[%plugins%]</h3>'.implode("\n", $_) : ''; |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | -if( ! function_exists('getSnippets')) { |
|
155 | +if (!function_exists('getSnippets')) { |
|
156 | 156 | /** |
157 | 157 | * display snippets |
158 | 158 | * |
@@ -178,23 +178,23 @@ discard block |
||
178 | 178 | $_[] = parse($tpl, $ph); |
179 | 179 | $i++; |
180 | 180 | } |
181 | - return (0 < count($_)) ? '<h3>[%snippets%]</h3>' . implode("\n", $_) : ''; |
|
181 | + return (0 < count($_)) ? '<h3>[%snippets%]</h3>'.implode("\n", $_) : ''; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | -switch($installMode){ |
|
185 | +switch ($installMode) { |
|
186 | 186 | case 0: |
187 | 187 | case 2: |
188 | 188 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
189 | 189 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
190 | 190 | $_POST['database_connection_charset'] = $database_charset; |
191 | - if(empty($_SESSION['databaseloginpassword'])) |
|
191 | + if (empty($_SESSION['databaseloginpassword'])) |
|
192 | 192 | $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
193 | - if(empty($_SESSION['databaseloginname'])) |
|
193 | + if (empty($_SESSION['databaseloginname'])) |
|
194 | 194 | $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
195 | 195 | break; |
196 | 196 | case 1: |
197 | - include $base_path . MGR_DIR . '/includes/config.inc.php'; |
|
197 | + include $base_path.MGR_DIR.'/includes/config.inc.php'; |
|
198 | 198 | if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) { |
199 | 199 | if (@ mysqli_query($conn, "USE {$dbase}")) { |
200 | 200 | if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $ph['checked'] = isset ($_POST['installdata']) && $_POST['installdata'] == "1" ? 'checked' : ''; |
250 | 250 | |
251 | 251 | # load setup information file |
252 | -include($base_path . 'install/setup.info.php'); |
|
252 | +include($base_path.'install/setup.info.php'); |
|
253 | 253 | $ph['templates'] = getTemplates($moduleTemplates); |
254 | 254 | $ph['tvs'] = getTVs($moduleTVs); |
255 | 255 | $ph['chunks'] = getChunks($moduleChunks); |
@@ -259,6 +259,6 @@ discard block |
||
259 | 259 | |
260 | 260 | $ph['action'] = ($installMode == 1) ? 'mode' : 'connection'; |
261 | 261 | |
262 | -$tpl = file_get_contents($base_path . 'install/actions/tpl_options.html'); |
|
263 | -$content = parse($tpl,$ph); |
|
264 | -echo parse($content,$_lang,'[%','%]'); |
|
262 | +$tpl = file_get_contents($base_path.'install/actions/tpl_options.html'); |
|
263 | +$content = parse($tpl, $ph); |
|
264 | +echo parse($content, $_lang, '[%', '%]'); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | header("X-XSS-Protection: 0"); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | if (isset($_COOKIE['MODX_themeColor'])) { |
49 | - $body_class .= ' ' . $_COOKIE['MODX_themeColor']; |
|
49 | + $body_class .= ' '.$_COOKIE['MODX_themeColor']; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | if (isset($modx->pluginCache['ElementsInTree'])) { |
@@ -74,36 +74,36 @@ discard block |
||
74 | 74 | $user['which_browser'] = $modx->config['which_browser']; |
75 | 75 | } |
76 | 76 | |
77 | -$css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime; |
|
77 | +$css = 'media/style/'.$modx->config['manager_theme'].'/css/page.css?v='.$lastInstallTime; |
|
78 | 78 | |
79 | 79 | if ($modx->config['manager_theme'] == 'default') { |
80 | - if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
81 | - require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php'; |
|
80 | + if (!file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css') && is_writable(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css')) { |
|
81 | + require_once MODX_BASE_PATH.'assets/lib/Formatter/CSSMinify.php'; |
|
82 | 82 | $minifier = new Formatter\CSSMinify(); |
83 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css'); |
|
84 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css'); |
|
85 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/fonts.css'); |
|
86 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/forms.css'); |
|
87 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/mainmenu.css'); |
|
88 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tree.css'); |
|
89 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/custom.css'); |
|
90 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tabpane.css'); |
|
91 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/contextmenu.css'); |
|
92 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/index.css'); |
|
93 | - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/main.css'); |
|
83 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/common/bootstrap/css/bootstrap.min.css'); |
|
84 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/common/font-awesome/css/font-awesome.min.css'); |
|
85 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/fonts.css'); |
|
86 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/forms.css'); |
|
87 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/mainmenu.css'); |
|
88 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/tree.css'); |
|
89 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/custom.css'); |
|
90 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/tabpane.css'); |
|
91 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/contextmenu.css'); |
|
92 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/index.css'); |
|
93 | + $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/main.css'); |
|
94 | 94 | $css = $minifier->minify(); |
95 | - file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css); |
|
95 | + file_put_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css', $css); |
|
96 | 96 | } |
97 | - if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
98 | - $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; |
|
97 | + if (file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css')) { |
|
98 | + $css = 'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css?v='.$lastInstallTime; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | -$modx->config['global_tabs'] = (int)($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin'))); |
|
102 | +$modx->config['global_tabs'] = (int) ($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin'))); |
|
103 | 103 | |
104 | 104 | ?> |
105 | 105 | <!DOCTYPE html> |
106 | -<html <?= (isset($modx_textdir) && $modx_textdir ? 'dir="rtl" lang="' : 'lang="') . $mxla . '" xml:lang="' . $mxla . '"' ?>> |
|
106 | +<html <?= (isset($modx_textdir) && $modx_textdir ? 'dir="rtl" lang="' : 'lang="').$mxla.'" xml:lang="'.$mxla.'"' ?>> |
|
107 | 107 | <head> |
108 | 108 | <title><?= $site_name ?>- (EVO CMS Manager)</title> |
109 | 109 | <meta http-equiv="Content-Type" content="text/html; charset=<?= $modx_manager_charset ?>" /> |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | MODX_SITE_URL: '<?= MODX_SITE_URL ?>', |
135 | 135 | MODX_MANAGER_URL: '<?= MODX_MANAGER_URL ?>', |
136 | 136 | user: { |
137 | - role: <?= (int)$user['role'] ?>, |
|
137 | + role: <?= (int) $user['role'] ?>, |
|
138 | 138 | username: '<?= $user['username'] ?>' |
139 | 139 | }, |
140 | 140 | config: { |
141 | 141 | mail_check_timeperiod: <?= $modx->config['mail_check_timeperiod'] ?>, |
142 | - menu_height: <?= (int)$menu_height ?>, |
|
143 | - tree_width: <?= (int)$tree_width ?>, |
|
144 | - tree_min_width: <?= (int)$tree_min_width ?>, |
|
145 | - session_timeout: <?= (int)$modx->config['session_timeout'] ?>, |
|
146 | - site_start: <?= (int)$modx->config['site_start'] ?>, |
|
147 | - tree_page_click: <?=(!empty($modx->config['tree_page_click']) ? (int)$modx->config['tree_page_click'] : 27) ?>, |
|
142 | + menu_height: <?= (int) $menu_height ?>, |
|
143 | + tree_width: <?= (int) $tree_width ?>, |
|
144 | + tree_min_width: <?= (int) $tree_min_width ?>, |
|
145 | + session_timeout: <?= (int) $modx->config['session_timeout'] ?>, |
|
146 | + site_start: <?= (int) $modx->config['site_start'] ?>, |
|
147 | + tree_page_click: <?=(!empty($modx->config['tree_page_click']) ? (int) $modx->config['tree_page_click'] : 27) ?>, |
|
148 | 148 | theme: '<?= $modx->config['manager_theme'] ?>', |
149 | 149 | which_browser: '<?= $user['which_browser'] ?>', |
150 | - layout: <?= (int)$manager_layout ?>, |
|
150 | + layout: <?= (int) $manager_layout ?>, |
|
151 | 151 | textdir: '<?= $modx_textdir ?>', |
152 | 152 | global_tabs: <?= $modx->config['global_tabs'] ?> |
153 | 153 | |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | delete a[b]; |
233 | 233 | }, |
234 | 234 | openedArray: [], |
235 | - lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . "\n" ?> |
|
235 | + lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE)."\n" ?> |
|
236 | 236 | }; |
237 | 237 | <?php |
238 | 238 | $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray']))); |
239 | - echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n modx.openedArray[", $opened) . '] = 1;') . "\n"; |
|
239 | + echo (empty($opened) ? '' : 'modx.openedArray['.implode("] = 1;\n modx.openedArray[", $opened).'] = 1;')."\n"; |
|
240 | 240 | ?> |
241 | 241 | </script> |
242 | 242 | <script src="media/style/<?= $modx->config['manager_theme'] ?>/js/modx.min.js?v=<?= $lastInstallTime ?>"></script> |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | <a href="javascript:;" class="dropdown-toggle" onclick="return false;"> |
366 | 366 | <span class="username"><?= $user['username'] ?></span> |
367 | 367 | <?php if ($user['photo']) { ?> |
368 | - <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL . $user['photo'] ?>);"></span> |
|
368 | + <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL.$user['photo'] ?>);"></span> |
|
369 | 369 | <?php } else { ?> |
370 | 370 | <span class="icon"><?= $_style['menu_user'] ?></span> |
371 | 371 | <?php } ?> |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $version = 'Evolution'; |
393 | 393 | ?> |
394 | 394 | <?php |
395 | - echo sprintf('<li><span class="dropdown-item" title="%s – %s" %s>' . $version . ' %s</span></li>', $site_name, $modx->getVersionData('full_appname'), $style, $modx->config['settings_version']); |
|
395 | + echo sprintf('<li><span class="dropdown-item" title="%s – %s" %s>'.$version.' %s</span></li>', $site_name, $modx->getVersionData('full_appname'), $style, $modx->config['settings_version']); |
|
396 | 396 | ?> |
397 | 397 | </ul> |
398 | 398 | </li> |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | */ |
527 | 527 | function constructLink($action, $img, $text, $allowed) |
528 | 528 | { |
529 | - if ((bool)$allowed) { |
|
529 | + if ((bool) $allowed) { |
|
530 | 530 | echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action, $action); |
531 | 531 | echo sprintf('<i class="%s"></i> %s</div>', $img, $text); |
532 | 532 | } |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | <script type="text/javascript"> |
538 | 538 | |
539 | 539 | if (document.getElementById('treeMenu')) { |
540 | - <?php if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?> |
|
540 | + <?php if ($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?> |
|
541 | 541 | |
542 | 542 | document.getElementById('treeMenu_openelements').onclick = function(e) { |
543 | 543 | e.preventDefault(); |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | } |
556 | 556 | }; |
557 | 557 | <?php } ?> |
558 | - <?php if($use_browser && $modx->hasPermission('assets_images')) { ?> |
|
558 | + <?php if ($use_browser && $modx->hasPermission('assets_images')) { ?> |
|
559 | 559 | |
560 | 560 | document.getElementById('treeMenu_openimages').onclick = function(e) { |
561 | 561 | e.preventDefault(); |
562 | 562 | if (modx.config.global_tabs && !e.shiftKey) { |
563 | - modx.tabs({url: '<?= MODX_MANAGER_URL . 'media/browser/' . $which_browser . '/browse.php?filemanager=media/browser/' . $which_browser . '/browse.php&type=images' ?>', title: '<?= $_lang["images_management"] ?>'}); |
|
563 | + modx.tabs({url: '<?= MODX_MANAGER_URL.'media/browser/'.$which_browser.'/browse.php?filemanager=media/browser/'.$which_browser.'/browse.php&type=images' ?>', title: '<?= $_lang["images_management"] ?>'}); |
|
564 | 564 | } else { |
565 | 565 | var randomNum = '<?= $_lang["files_files"] ?>'; |
566 | 566 | if (e.shiftKey) { |
@@ -573,12 +573,12 @@ discard block |
||
573 | 573 | } |
574 | 574 | }; |
575 | 575 | <?php } ?> |
576 | - <?php if($use_browser && $modx->hasPermission('assets_files')) { ?> |
|
576 | + <?php if ($use_browser && $modx->hasPermission('assets_files')) { ?> |
|
577 | 577 | |
578 | 578 | document.getElementById('treeMenu_openfiles').onclick = function(e) { |
579 | 579 | e.preventDefault(); |
580 | 580 | if (modx.config.global_tabs && !e.shiftKey) { |
581 | - modx.tabs({url: '<?= MODX_MANAGER_URL . 'media/browser/' . $which_browser . '/browse.php?filemanager=media/browser/' . $which_browser . '/browse.php&type=files' ?>', title: '<?= $_lang["files_files"] ?>'}); |
|
581 | + modx.tabs({url: '<?= MODX_MANAGER_URL.'media/browser/'.$which_browser.'/browse.php?filemanager=media/browser/'.$which_browser.'/browse.php&type=files' ?>', title: '<?= $_lang["files_files"] ?>'}); |
|
582 | 582 | } else { |
583 | 583 | var randomNum = '<?= $_lang["files_files"] ?>'; |
584 | 584 | if (e.shiftKey) { |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | |
633 | 633 | </div> |
634 | 634 | <?php if ($modx->config['show_picker'] != "0") { |
635 | - include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php'); |
|
635 | + include('media/style/'.$modx->config['manager_theme'].'/color.switcher.php'); |
|
636 | 636 | } ?> |
637 | 637 | </body> |
638 | 638 | </html> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | header("X-XSS-Protection: 0"); |
@@ -11,22 +11,22 @@ discard block |
||
11 | 11 | |
12 | 12 | $mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en'; |
13 | 13 | |
14 | -if (!isset($modx->config['manager_menu_height'])) { |
|
14 | +if (!isset($modx->config['manager_menu_height'])) { |
|
15 | 15 | $modx->config['manager_menu_height'] = 2.2; // rem |
16 | 16 | } |
17 | 17 | |
18 | -if (!isset($modx->config['manager_tree_width'])) { |
|
18 | +if (!isset($modx->config['manager_tree_width'])) { |
|
19 | 19 | $modx->config['manager_tree_width'] = 20; // rem |
20 | 20 | } |
21 | 21 | |
22 | -if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) { |
|
22 | +if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) { |
|
23 | 23 | $initMainframeAction = $_SESSION['onLoginForwardToAction']; |
24 | 24 | unset($_SESSION['onLoginForwardToAction']); |
25 | -} else { |
|
25 | +} else { |
|
26 | 26 | $initMainframeAction = 2; // welcome.static |
27 | 27 | } |
28 | 28 | |
29 | -if (!isset($_SESSION['tree_show_only_folders'])) { |
|
29 | +if (!isset($_SESSION['tree_show_only_folders'])) { |
|
30 | 30 | $_SESSION['tree_show_only_folders'] = 0; |
31 | 31 | } |
32 | 32 | |
@@ -35,21 +35,21 @@ discard block |
||
35 | 35 | $tree_width = $modx->config['manager_tree_width']; |
36 | 36 | $tree_min_width = 0; |
37 | 37 | |
38 | -if (isset($_COOKIE['MODX_widthSideBar'])) { |
|
38 | +if (isset($_COOKIE['MODX_widthSideBar'])) { |
|
39 | 39 | $MODX_widthSideBar = $_COOKIE['MODX_widthSideBar']; |
40 | -} else { |
|
40 | +} else { |
|
41 | 41 | $MODX_widthSideBar = $tree_width; |
42 | 42 | } |
43 | 43 | |
44 | -if (!$MODX_widthSideBar) { |
|
44 | +if (!$MODX_widthSideBar) { |
|
45 | 45 | $body_class .= 'sidebar-closed'; |
46 | 46 | } |
47 | 47 | |
48 | -if (isset($_COOKIE['MODX_themeColor'])) { |
|
48 | +if (isset($_COOKIE['MODX_themeColor'])) { |
|
49 | 49 | $body_class .= ' ' . $_COOKIE['MODX_themeColor']; |
50 | 50 | } |
51 | 51 | |
52 | -if (isset($modx->pluginCache['ElementsInTree'])) { |
|
52 | +if (isset($modx->pluginCache['ElementsInTree'])) { |
|
53 | 53 | $body_class .= ' ElementsInTree'; |
54 | 54 | } |
55 | 55 | |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | 'type8' => $_lang["lock_element_type_8"] |
66 | 66 | ); |
67 | 67 | |
68 | -foreach ($unlockTranslations as $key => $value) { |
|
68 | +foreach ($unlockTranslations as $key => $value) { |
|
69 | 69 | $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
70 | 70 | } |
71 | 71 | |
72 | 72 | $user = $modx->getUserInfo($modx->getLoginUserID()); |
73 | -if ($user['which_browser'] == 'default') { |
|
73 | +if ($user['which_browser'] == 'default') { |
|
74 | 74 | $user['which_browser'] = $modx->config['which_browser']; |
75 | 75 | } |
76 | 76 | |
77 | 77 | $css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime; |
78 | 78 | |
79 | -if ($modx->config['manager_theme'] == 'default') { |
|
80 | - if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
79 | +if ($modx->config['manager_theme'] == 'default') { |
|
80 | + if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
81 | 81 | require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php'; |
82 | 82 | $minifier = new Formatter\CSSMinify(); |
83 | 83 | $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css'); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $css = $minifier->minify(); |
95 | 95 | file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css); |
96 | 96 | } |
97 | - if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
97 | + if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
98 | 98 | $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; |
99 | 99 | } |
100 | 100 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | <?php |
249 | 249 | // invoke OnManagerTopPrerender event |
250 | 250 | $evtOut = $modx->invokeEvent('OnManagerTopPrerender', $_REQUEST); |
251 | - if (is_array($evtOut)) { |
|
251 | + if (is_array($evtOut)) { |
|
252 | 252 | echo implode("\n", $evtOut); |
253 | 253 | } |
254 | 254 | ?> |
@@ -419,9 +419,12 @@ discard block |
||
419 | 419 | <div id="evo-tab-page-home" class="evo-tab-page show"> |
420 | 420 | <iframe id="mainframe" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe> |
421 | 421 | </div> |
422 | - <?php else: ?> |
|
422 | + <?php else { |
|
423 | + : ?> |
|
423 | 424 | <iframe id="mainframe" name="main" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe> |
424 | - <?php endif; ?> |
|
425 | + <?php endif; |
|
426 | +} |
|
427 | +?> |
|
425 | 428 | <div id="mainloader"></div> |
426 | 429 | </div> |
427 | 430 | <div id="resizer"></div> |
@@ -434,11 +437,11 @@ discard block |
||
434 | 437 | 'tree_sortdir', |
435 | 438 | 'tree_nodename' |
436 | 439 | ); |
437 | - foreach ($sortParams as $param) { |
|
438 | - if (isset($_REQUEST[$param])) { |
|
440 | + foreach ($sortParams as $param) { |
|
441 | + if (isset($_REQUEST[$param])) { |
|
439 | 442 | $modx->manager->saveLastUserSetting($param, $_REQUEST[$param]); |
440 | 443 | $_SESSION[$param] = $_REQUEST[$param]; |
441 | - } else if (!isset($_SESSION[$param])) { |
|
444 | + } else if (!isset($_SESSION[$param])) { |
|
442 | 445 | $_SESSION[$param] = $modx->manager->getLastUserSetting($param); |
443 | 446 | } |
444 | 447 | } |
@@ -524,9 +527,9 @@ discard block |
||
524 | 527 | * @param string $text |
525 | 528 | * @param bool $allowed |
526 | 529 | */ |
527 | - function constructLink($action, $img, $text, $allowed) |
|
528 | - { |
|
529 | - if ((bool)$allowed) { |
|
530 | + function constructLink($action, $img, $text, $allowed) |
|
531 | + { |
|
532 | + if ((bool)$allowed) { |
|
530 | 533 | echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action, $action); |
531 | 534 | echo sprintf('<i class="%s"></i> %s</div>', $img, $text); |
532 | 535 | } |
@@ -631,7 +634,7 @@ discard block |
||
631 | 634 | ?> |
632 | 635 | |
633 | 636 | </div> |
634 | -<?php if ($modx->config['show_picker'] != "0") { |
|
637 | +<?php if ($modx->config['show_picker'] != "0") { |
|
635 | 638 | include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php'); |
636 | 639 | } ?> |
637 | 640 | </body> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
3 | - die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
|
3 | + die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -12,443 +12,443 @@ discard block |
||
12 | 12 | * @return string |
13 | 13 | */ |
14 | 14 | function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
15 | - global $modx; |
|
16 | - global $icons, $iconsPrivate, $_style; |
|
17 | - global $_lang, $opened, $opened2, $closed2; //added global vars |
|
18 | - global $modx_textdir; |
|
19 | - |
|
20 | - $output = ''; |
|
21 | - |
|
22 | - // setup spacer |
|
23 | - $level = 0; |
|
24 | - $spacer = '<span class="indent">'; |
|
25 | - for($i = 2; $i <= $indent; $i++) { |
|
26 | - $spacer .= '<i></i>'; |
|
27 | - $level++; |
|
28 | - } |
|
29 | - $spacer .= '</span>'; |
|
30 | - |
|
31 | - // manage order-by |
|
32 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
33 | - // This is the first startup, set default sort order |
|
34 | - $_SESSION['tree_sortby'] = 'menuindex'; |
|
35 | - $_SESSION['tree_sortdir'] = 'ASC'; |
|
36 | - } |
|
37 | - |
|
38 | - switch($_SESSION['tree_sortby']) { |
|
39 | - case 'createdon': |
|
40 | - case 'editedon': |
|
41 | - case 'publishedon': |
|
42 | - case 'pub_date': |
|
43 | - case 'unpub_date': |
|
44 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
45 | - break; |
|
46 | - default: |
|
47 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
48 | - }; |
|
49 | - |
|
50 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
51 | - |
|
52 | - // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
53 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
54 | - $orderby .= ', menuindex ASC, pagetitle'; |
|
55 | - } |
|
56 | - |
|
57 | - $tblsc = $modx->getFullTableName('site_content'); |
|
58 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
59 | - $tblst = $modx->getFullTableName('site_templates'); |
|
60 | - // get document groups for current user |
|
61 | - $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
62 | - $showProtected = false; |
|
63 | - if(isset ($modx->config['tree_show_protected'])) { |
|
64 | - $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
65 | - } |
|
66 | - $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
67 | - if($showProtected == false) { |
|
68 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
69 | - } else { |
|
70 | - $access = ''; |
|
71 | - } |
|
72 | - $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
73 | - $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
15 | + global $modx; |
|
16 | + global $icons, $iconsPrivate, $_style; |
|
17 | + global $_lang, $opened, $opened2, $closed2; //added global vars |
|
18 | + global $modx_textdir; |
|
19 | + |
|
20 | + $output = ''; |
|
21 | + |
|
22 | + // setup spacer |
|
23 | + $level = 0; |
|
24 | + $spacer = '<span class="indent">'; |
|
25 | + for($i = 2; $i <= $indent; $i++) { |
|
26 | + $spacer .= '<i></i>'; |
|
27 | + $level++; |
|
28 | + } |
|
29 | + $spacer .= '</span>'; |
|
30 | + |
|
31 | + // manage order-by |
|
32 | + if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
33 | + // This is the first startup, set default sort order |
|
34 | + $_SESSION['tree_sortby'] = 'menuindex'; |
|
35 | + $_SESSION['tree_sortdir'] = 'ASC'; |
|
36 | + } |
|
37 | + |
|
38 | + switch($_SESSION['tree_sortby']) { |
|
39 | + case 'createdon': |
|
40 | + case 'editedon': |
|
41 | + case 'publishedon': |
|
42 | + case 'pub_date': |
|
43 | + case 'unpub_date': |
|
44 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
45 | + break; |
|
46 | + default: |
|
47 | + $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
48 | + }; |
|
49 | + |
|
50 | + $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
51 | + |
|
52 | + // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
53 | + if($_SESSION['tree_sortby'] == 'isfolder') { |
|
54 | + $orderby .= ', menuindex ASC, pagetitle'; |
|
55 | + } |
|
56 | + |
|
57 | + $tblsc = $modx->getFullTableName('site_content'); |
|
58 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
59 | + $tblst = $modx->getFullTableName('site_templates'); |
|
60 | + // get document groups for current user |
|
61 | + $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
62 | + $showProtected = false; |
|
63 | + if(isset ($modx->config['tree_show_protected'])) { |
|
64 | + $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
65 | + } |
|
66 | + $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
67 | + if($showProtected == false) { |
|
68 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
69 | + } else { |
|
70 | + $access = ''; |
|
71 | + } |
|
72 | + $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
73 | + $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
74 | 74 | MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$docgrp_cond}, 1, 0)) AS hasAccess, GROUP_CONCAT(document_group SEPARATOR ',') AS roles"; |
75 | - $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
76 | - $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
77 | - $result = $modx->db->select($field, $from, $where, $orderby); |
|
78 | - if($modx->db->getRecordCount($result) == 0) { |
|
79 | - $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
80 | - } |
|
81 | - |
|
82 | - $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
83 | - |
|
84 | - while($row = $modx->db->getRow($result)) { |
|
85 | - $node = ''; |
|
86 | - |
|
87 | - $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
88 | - $nodetitleDisplay = $nodetitle; |
|
89 | - |
|
90 | - $treeNodeClass = 'node'; |
|
91 | - $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
92 | - |
|
93 | - if($row['deleted'] == 1) { |
|
94 | - $treeNodeClass .= ' deleted'; |
|
95 | - //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
96 | - } elseif($row['published'] == 0) { |
|
97 | - $treeNodeClass .= ' unpublished'; |
|
98 | - //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
99 | - } elseif($row['hidemenu'] == 1) { |
|
100 | - $treeNodeClass .= ' hidemenu'; |
|
101 | - //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
102 | - } else { |
|
103 | - //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
104 | - } |
|
105 | - |
|
106 | - if($row['id'] == $hereid) { |
|
107 | - $treeNodeClass .= ' current'; |
|
108 | - } |
|
109 | - |
|
110 | - $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
111 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
112 | - |
|
113 | - // Prepare displaying user-locks |
|
114 | - $lockedByUser = ''; |
|
115 | - $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
116 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | - if($rowLock['sid'] == $modx->sid) { |
|
118 | - $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
119 | - 'element_type' => $_lang["lock_element_type_7"], |
|
120 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
121 | - )); |
|
122 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
123 | - } else { |
|
124 | - $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
125 | - 'element_type' => $_lang["lock_element_type_7"], |
|
126 | - 'username' => $rowLock['username'], |
|
127 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
128 | - )); |
|
129 | - if($modx->hasPermission('remove_locks')) { |
|
130 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
131 | - } else { |
|
132 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - $url = $modx->makeUrl($row['id']); |
|
138 | - |
|
139 | - $title = ''; |
|
140 | - if(isDateNode($nodeNameSource)) { |
|
141 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
142 | - } |
|
143 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
145 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
146 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
148 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
149 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
150 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
155 | - $title = $modx->htmlspecialchars($title); |
|
156 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
157 | - |
|
158 | - $data = array( |
|
159 | - 'id' => $row['id'], |
|
160 | - 'pagetitle' => $row['pagetitle'], |
|
161 | - 'longtitle' => $row['longtitle'], |
|
162 | - 'menutitle' => $row['menutitle'], |
|
163 | - 'parent' => $parent, |
|
164 | - 'isfolder' => $row['isfolder'], |
|
165 | - 'published' => $row['published'], |
|
166 | - 'deleted' => $row['deleted'], |
|
167 | - 'type' => $row['type'], |
|
168 | - 'menuindex' => $row['menuindex'], |
|
169 | - 'donthit' => $row['donthit'], |
|
170 | - 'hidemenu' => $row['hidemenu'], |
|
171 | - 'alias' => $row['alias'], |
|
172 | - 'contenttype' => $row['contentType'], |
|
173 | - 'privateweb' => $row['privateweb'], |
|
174 | - 'privatemgr' => $row['privatemgr'], |
|
175 | - 'hasAccess' => $row['hasAccess'], |
|
176 | - 'template' => $row['template'], |
|
177 | - 'nodetitle' => $nodetitle, |
|
178 | - 'url' => $url, |
|
179 | - 'title' => $title, |
|
180 | - 'nodetitleDisplay' => $nodetitleDisplay, |
|
181 | - 'weblinkDisplay' => $weblinkDisplay, |
|
182 | - 'pageIdDisplay' => $pageIdDisplay, |
|
183 | - 'lockedByUser' => $lockedByUser, |
|
184 | - 'treeNodeClass' => $treeNodeClass, |
|
185 | - 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
186 | - 'tree_page_click' => $modx->config['tree_page_click'], |
|
187 | - 'showChildren' => 1, |
|
188 | - 'openFolder' => 1, |
|
189 | - 'contextmenu' => '', |
|
190 | - 'tree_minusnode' => $_style['tree_minusnode'], |
|
191 | - 'tree_plusnode' => $_style['tree_plusnode'], |
|
192 | - 'spacer' => $spacer, |
|
193 | - 'subMenuState' => '', |
|
194 | - 'level' => $level, |
|
195 | - 'isPrivate' => 0, |
|
196 | - 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
197 | - ); |
|
198 | - |
|
199 | - $ph = $data; |
|
200 | - $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
201 | - $ph['indent'] = $indent + 1; |
|
202 | - $ph['expandAll'] = $expandAll; |
|
203 | - $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
204 | - |
|
205 | - if(!$row['isfolder']) { |
|
206 | - $tpl = getTplSingleNode(); |
|
207 | - switch($row['id']) { |
|
208 | - case $modx->config['site_start'] : |
|
209 | - $icon = $_style['tree_page_home']; |
|
210 | - break; |
|
211 | - case $modx->config['error_page'] : |
|
212 | - $icon = $_style['tree_page_404']; |
|
213 | - break; |
|
214 | - case $modx->config['site_unavailable_page'] : |
|
215 | - $icon = $_style['tree_page_hourglass']; |
|
216 | - break; |
|
217 | - case $modx->config['unauthorized_page'] : |
|
218 | - $icon = $_style['tree_page_info']; |
|
219 | - break; |
|
220 | - default: |
|
221 | - if(isset($icons[$row['contentType']])) { |
|
222 | - $icon = $icons[$row['contentType']]; |
|
223 | - } else { |
|
224 | - $icon = $_style['tree_page']; |
|
225 | - } |
|
226 | - } |
|
227 | - $ph['icon'] = $icon; |
|
228 | - |
|
229 | - // invoke OnManagerNodePrerender event |
|
230 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
231 | - if(is_array($prenode)) { |
|
232 | - $phnew = array(); |
|
233 | - foreach($prenode as $pnode) { |
|
234 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
235 | - } |
|
236 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
237 | - } |
|
238 | - |
|
239 | - if($ph['contextmenu']) { |
|
240 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
241 | - } |
|
242 | - |
|
243 | - if($_SESSION['tree_show_only_folders']) { |
|
244 | - if($row['parent'] == 0) { |
|
245 | - $node .= $modx->parseText($tpl, $ph); |
|
246 | - } else { |
|
247 | - $node .= ''; |
|
248 | - } |
|
249 | - } else { |
|
250 | - $node .= $modx->parseText($tpl, $ph); |
|
251 | - } |
|
252 | - |
|
253 | - } else { |
|
254 | - $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
255 | - $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
256 | - |
|
257 | - if($_SESSION['tree_show_only_folders']) { |
|
258 | - $tpl = getTplFolderNodeNotChildren(); |
|
259 | - $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
260 | - $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
261 | - $ph['tree_page_click'] = 3; |
|
262 | - |
|
263 | - // expandAll: two type for partial expansion |
|
264 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | - if($expandAll == 1) { |
|
266 | - $opened2[] = $row['id']; |
|
267 | - } |
|
268 | - $ph['icon'] = $ph['icon_folder_open']; |
|
269 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
270 | - $ph['node_toggle'] = 1; |
|
271 | - $ph['subMenuState'] = ' open'; |
|
272 | - |
|
273 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
274 | - $ph['showChildren'] = 1; |
|
275 | - $ph['icon_node_toggle'] = ''; |
|
276 | - $ph['icon'] = $ph['icon_folder_close']; |
|
277 | - } elseif(!$checkDocs && $checkFolders) { |
|
278 | - $ph['showChildren'] = 0; |
|
279 | - $ph['openFolder'] = 2; |
|
280 | - } else { |
|
281 | - $ph['openFolder'] = 2; |
|
282 | - } |
|
283 | - |
|
284 | - // invoke OnManagerNodePrerender event |
|
285 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
286 | - 'ph' => $ph, |
|
287 | - 'opened' => '1' |
|
288 | - )); |
|
289 | - if(is_array($prenode)) { |
|
290 | - $phnew = array(); |
|
291 | - foreach($prenode as $pnode) { |
|
292 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
293 | - } |
|
294 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
295 | - } |
|
296 | - |
|
297 | - if($ph['contextmenu']) { |
|
298 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
299 | - } |
|
300 | - |
|
301 | - $node .= $modx->parseText($tpl, $ph); |
|
302 | - if($checkFolders) { |
|
303 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
304 | - } |
|
305 | - $node .= '</div></div>'; |
|
306 | - } else { |
|
307 | - $closed2[] = $row['id']; |
|
308 | - $ph['icon'] = $ph['icon_folder_close']; |
|
309 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
310 | - $ph['node_toggle'] = 0; |
|
311 | - |
|
312 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
313 | - $ph['showChildren'] = 1; |
|
314 | - $ph['icon_node_toggle'] = ''; |
|
315 | - } elseif(!$checkDocs && $checkFolders) { |
|
316 | - $ph['showChildren'] = 0; |
|
317 | - $ph['openFolder'] = 2; |
|
318 | - } else { |
|
319 | - $ph['openFolder'] = 2; |
|
320 | - } |
|
321 | - |
|
322 | - // invoke OnManagerNodePrerender event |
|
323 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
324 | - 'ph' => $ph, |
|
325 | - 'opened' => '0' |
|
326 | - )); |
|
327 | - if(is_array($prenode)) { |
|
328 | - $phnew = array(); |
|
329 | - foreach($prenode as $pnode) { |
|
330 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
331 | - } |
|
332 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
333 | - } |
|
334 | - |
|
335 | - if($ph['contextmenu']) { |
|
336 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
337 | - } |
|
338 | - |
|
339 | - $node .= $modx->parseText($tpl, $ph); |
|
340 | - $node .= '</div></div>'; |
|
341 | - } |
|
342 | - } else { |
|
343 | - $tpl = getTplFolderNode(); |
|
344 | - // expandAll: two type for partial expansion |
|
345 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | - if($expandAll == 1) { |
|
347 | - $opened2[] = $row['id']; |
|
348 | - } |
|
349 | - $ph['icon'] = $ph['icon_folder_open']; |
|
350 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
351 | - $ph['node_toggle'] = 1; |
|
352 | - $ph['subMenuState'] = ' open'; |
|
353 | - |
|
354 | - if($ph['donthit'] == 1) { |
|
355 | - $ph['tree_page_click'] = 3; |
|
356 | - $ph['icon_node_toggle'] = ''; |
|
357 | - $ph['icon'] = $ph['icon_folder_close']; |
|
358 | - $ph['showChildren'] = 0; |
|
359 | - } |
|
360 | - |
|
361 | - // invoke OnManagerNodePrerender event |
|
362 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
363 | - 'ph' => $ph, |
|
364 | - 'opened' => '1' |
|
365 | - )); |
|
366 | - if(is_array($prenode)) { |
|
367 | - $phnew = array(); |
|
368 | - foreach($prenode as $pnode) { |
|
369 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
370 | - } |
|
371 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
372 | - if($ph['showChildren'] == 0) { |
|
373 | - unset($opened2[$row['id']]); |
|
374 | - $ph['node_toggle'] = 0; |
|
375 | - $ph['subMenuState'] = ''; |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - if($ph['showChildren'] == 0) { |
|
380 | - $ph['icon_node_toggle'] = ''; |
|
381 | - $ph['donthit'] = 1; |
|
382 | - $ph['icon'] = $ph['icon_folder_close']; |
|
383 | - $tpl = getTplFolderNodeNotChildren(); |
|
384 | - } |
|
385 | - |
|
386 | - if($ph['contextmenu']) { |
|
387 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
388 | - } |
|
389 | - |
|
390 | - $node .= $modx->parseText($tpl, $ph); |
|
391 | - if($ph['donthit'] == 0) { |
|
392 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
393 | - } |
|
394 | - $node .= '</div></div>'; |
|
395 | - } else { |
|
396 | - $closed2[] = $row['id']; |
|
397 | - $ph['icon'] = $ph['icon_folder_close']; |
|
398 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
399 | - $ph['node_toggle'] = 0; |
|
400 | - |
|
401 | - if($ph['donthit'] == 1) { |
|
402 | - $ph['tree_page_click'] = 3; |
|
403 | - $ph['icon_node_toggle'] = ''; |
|
404 | - $ph['icon'] = $ph['icon_folder_close']; |
|
405 | - $ph['showChildren'] = 0; |
|
406 | - } |
|
407 | - |
|
408 | - // invoke OnManagerNodePrerender event |
|
409 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
410 | - 'ph' => $ph, |
|
411 | - 'opened' => '0' |
|
412 | - )); |
|
413 | - if(is_array($prenode)) { |
|
414 | - $phnew = array(); |
|
415 | - foreach($prenode as $pnode) { |
|
416 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
417 | - } |
|
418 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
419 | - } |
|
420 | - |
|
421 | - if($ph['showChildren'] == 0) { |
|
422 | - $ph['icon_node_toggle'] = ''; |
|
423 | - $ph['donthit'] = 1; |
|
424 | - $ph['icon'] = $ph['icon_folder_close']; |
|
425 | - $tpl = getTplFolderNodeNotChildren(); |
|
426 | - } |
|
427 | - |
|
428 | - if($ph['contextmenu']) { |
|
429 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
430 | - } |
|
431 | - |
|
432 | - $node .= $modx->parseText($tpl, $ph); |
|
433 | - $node .= '</div></div>'; |
|
434 | - } |
|
435 | - } |
|
436 | - } |
|
437 | - |
|
438 | - // invoke OnManagerNodeRender event |
|
439 | - $data['node'] = $node; |
|
440 | - $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
441 | - if(is_array($evtOut)) { |
|
442 | - $evtOut = implode("\n", $evtOut); |
|
443 | - } |
|
444 | - if($evtOut != '') { |
|
445 | - $node = trim($evtOut); |
|
446 | - } |
|
447 | - |
|
448 | - $output .= $node; |
|
449 | - } |
|
450 | - |
|
451 | - return $output; |
|
75 | + $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
76 | + $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
77 | + $result = $modx->db->select($field, $from, $where, $orderby); |
|
78 | + if($modx->db->getRecordCount($result) == 0) { |
|
79 | + $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
80 | + } |
|
81 | + |
|
82 | + $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
83 | + |
|
84 | + while($row = $modx->db->getRow($result)) { |
|
85 | + $node = ''; |
|
86 | + |
|
87 | + $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
88 | + $nodetitleDisplay = $nodetitle; |
|
89 | + |
|
90 | + $treeNodeClass = 'node'; |
|
91 | + $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
92 | + |
|
93 | + if($row['deleted'] == 1) { |
|
94 | + $treeNodeClass .= ' deleted'; |
|
95 | + //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
96 | + } elseif($row['published'] == 0) { |
|
97 | + $treeNodeClass .= ' unpublished'; |
|
98 | + //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
99 | + } elseif($row['hidemenu'] == 1) { |
|
100 | + $treeNodeClass .= ' hidemenu'; |
|
101 | + //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
102 | + } else { |
|
103 | + //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
104 | + } |
|
105 | + |
|
106 | + if($row['id'] == $hereid) { |
|
107 | + $treeNodeClass .= ' current'; |
|
108 | + } |
|
109 | + |
|
110 | + $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
111 | + $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
112 | + |
|
113 | + // Prepare displaying user-locks |
|
114 | + $lockedByUser = ''; |
|
115 | + $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
116 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | + if($rowLock['sid'] == $modx->sid) { |
|
118 | + $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
119 | + 'element_type' => $_lang["lock_element_type_7"], |
|
120 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
121 | + )); |
|
122 | + $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
123 | + } else { |
|
124 | + $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
125 | + 'element_type' => $_lang["lock_element_type_7"], |
|
126 | + 'username' => $rowLock['username'], |
|
127 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
128 | + )); |
|
129 | + if($modx->hasPermission('remove_locks')) { |
|
130 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
131 | + } else { |
|
132 | + $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + $url = $modx->makeUrl($row['id']); |
|
138 | + |
|
139 | + $title = ''; |
|
140 | + if(isDateNode($nodeNameSource)) { |
|
141 | + $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
142 | + } |
|
143 | + $title .= $_lang['id'] . ': ' . $row['id']; |
|
144 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
145 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
146 | + $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | + $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
148 | + $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
149 | + $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
150 | + $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | + $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | + $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | + $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | + $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
155 | + $title = $modx->htmlspecialchars($title); |
|
156 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
157 | + |
|
158 | + $data = array( |
|
159 | + 'id' => $row['id'], |
|
160 | + 'pagetitle' => $row['pagetitle'], |
|
161 | + 'longtitle' => $row['longtitle'], |
|
162 | + 'menutitle' => $row['menutitle'], |
|
163 | + 'parent' => $parent, |
|
164 | + 'isfolder' => $row['isfolder'], |
|
165 | + 'published' => $row['published'], |
|
166 | + 'deleted' => $row['deleted'], |
|
167 | + 'type' => $row['type'], |
|
168 | + 'menuindex' => $row['menuindex'], |
|
169 | + 'donthit' => $row['donthit'], |
|
170 | + 'hidemenu' => $row['hidemenu'], |
|
171 | + 'alias' => $row['alias'], |
|
172 | + 'contenttype' => $row['contentType'], |
|
173 | + 'privateweb' => $row['privateweb'], |
|
174 | + 'privatemgr' => $row['privatemgr'], |
|
175 | + 'hasAccess' => $row['hasAccess'], |
|
176 | + 'template' => $row['template'], |
|
177 | + 'nodetitle' => $nodetitle, |
|
178 | + 'url' => $url, |
|
179 | + 'title' => $title, |
|
180 | + 'nodetitleDisplay' => $nodetitleDisplay, |
|
181 | + 'weblinkDisplay' => $weblinkDisplay, |
|
182 | + 'pageIdDisplay' => $pageIdDisplay, |
|
183 | + 'lockedByUser' => $lockedByUser, |
|
184 | + 'treeNodeClass' => $treeNodeClass, |
|
185 | + 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
186 | + 'tree_page_click' => $modx->config['tree_page_click'], |
|
187 | + 'showChildren' => 1, |
|
188 | + 'openFolder' => 1, |
|
189 | + 'contextmenu' => '', |
|
190 | + 'tree_minusnode' => $_style['tree_minusnode'], |
|
191 | + 'tree_plusnode' => $_style['tree_plusnode'], |
|
192 | + 'spacer' => $spacer, |
|
193 | + 'subMenuState' => '', |
|
194 | + 'level' => $level, |
|
195 | + 'isPrivate' => 0, |
|
196 | + 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
197 | + ); |
|
198 | + |
|
199 | + $ph = $data; |
|
200 | + $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
201 | + $ph['indent'] = $indent + 1; |
|
202 | + $ph['expandAll'] = $expandAll; |
|
203 | + $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
204 | + |
|
205 | + if(!$row['isfolder']) { |
|
206 | + $tpl = getTplSingleNode(); |
|
207 | + switch($row['id']) { |
|
208 | + case $modx->config['site_start'] : |
|
209 | + $icon = $_style['tree_page_home']; |
|
210 | + break; |
|
211 | + case $modx->config['error_page'] : |
|
212 | + $icon = $_style['tree_page_404']; |
|
213 | + break; |
|
214 | + case $modx->config['site_unavailable_page'] : |
|
215 | + $icon = $_style['tree_page_hourglass']; |
|
216 | + break; |
|
217 | + case $modx->config['unauthorized_page'] : |
|
218 | + $icon = $_style['tree_page_info']; |
|
219 | + break; |
|
220 | + default: |
|
221 | + if(isset($icons[$row['contentType']])) { |
|
222 | + $icon = $icons[$row['contentType']]; |
|
223 | + } else { |
|
224 | + $icon = $_style['tree_page']; |
|
225 | + } |
|
226 | + } |
|
227 | + $ph['icon'] = $icon; |
|
228 | + |
|
229 | + // invoke OnManagerNodePrerender event |
|
230 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
231 | + if(is_array($prenode)) { |
|
232 | + $phnew = array(); |
|
233 | + foreach($prenode as $pnode) { |
|
234 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
235 | + } |
|
236 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
237 | + } |
|
238 | + |
|
239 | + if($ph['contextmenu']) { |
|
240 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
241 | + } |
|
242 | + |
|
243 | + if($_SESSION['tree_show_only_folders']) { |
|
244 | + if($row['parent'] == 0) { |
|
245 | + $node .= $modx->parseText($tpl, $ph); |
|
246 | + } else { |
|
247 | + $node .= ''; |
|
248 | + } |
|
249 | + } else { |
|
250 | + $node .= $modx->parseText($tpl, $ph); |
|
251 | + } |
|
252 | + |
|
253 | + } else { |
|
254 | + $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
255 | + $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
256 | + |
|
257 | + if($_SESSION['tree_show_only_folders']) { |
|
258 | + $tpl = getTplFolderNodeNotChildren(); |
|
259 | + $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
260 | + $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
261 | + $ph['tree_page_click'] = 3; |
|
262 | + |
|
263 | + // expandAll: two type for partial expansion |
|
264 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | + if($expandAll == 1) { |
|
266 | + $opened2[] = $row['id']; |
|
267 | + } |
|
268 | + $ph['icon'] = $ph['icon_folder_open']; |
|
269 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
270 | + $ph['node_toggle'] = 1; |
|
271 | + $ph['subMenuState'] = ' open'; |
|
272 | + |
|
273 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
274 | + $ph['showChildren'] = 1; |
|
275 | + $ph['icon_node_toggle'] = ''; |
|
276 | + $ph['icon'] = $ph['icon_folder_close']; |
|
277 | + } elseif(!$checkDocs && $checkFolders) { |
|
278 | + $ph['showChildren'] = 0; |
|
279 | + $ph['openFolder'] = 2; |
|
280 | + } else { |
|
281 | + $ph['openFolder'] = 2; |
|
282 | + } |
|
283 | + |
|
284 | + // invoke OnManagerNodePrerender event |
|
285 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
286 | + 'ph' => $ph, |
|
287 | + 'opened' => '1' |
|
288 | + )); |
|
289 | + if(is_array($prenode)) { |
|
290 | + $phnew = array(); |
|
291 | + foreach($prenode as $pnode) { |
|
292 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
293 | + } |
|
294 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
295 | + } |
|
296 | + |
|
297 | + if($ph['contextmenu']) { |
|
298 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
299 | + } |
|
300 | + |
|
301 | + $node .= $modx->parseText($tpl, $ph); |
|
302 | + if($checkFolders) { |
|
303 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
304 | + } |
|
305 | + $node .= '</div></div>'; |
|
306 | + } else { |
|
307 | + $closed2[] = $row['id']; |
|
308 | + $ph['icon'] = $ph['icon_folder_close']; |
|
309 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
310 | + $ph['node_toggle'] = 0; |
|
311 | + |
|
312 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
313 | + $ph['showChildren'] = 1; |
|
314 | + $ph['icon_node_toggle'] = ''; |
|
315 | + } elseif(!$checkDocs && $checkFolders) { |
|
316 | + $ph['showChildren'] = 0; |
|
317 | + $ph['openFolder'] = 2; |
|
318 | + } else { |
|
319 | + $ph['openFolder'] = 2; |
|
320 | + } |
|
321 | + |
|
322 | + // invoke OnManagerNodePrerender event |
|
323 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
324 | + 'ph' => $ph, |
|
325 | + 'opened' => '0' |
|
326 | + )); |
|
327 | + if(is_array($prenode)) { |
|
328 | + $phnew = array(); |
|
329 | + foreach($prenode as $pnode) { |
|
330 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
331 | + } |
|
332 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
333 | + } |
|
334 | + |
|
335 | + if($ph['contextmenu']) { |
|
336 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
337 | + } |
|
338 | + |
|
339 | + $node .= $modx->parseText($tpl, $ph); |
|
340 | + $node .= '</div></div>'; |
|
341 | + } |
|
342 | + } else { |
|
343 | + $tpl = getTplFolderNode(); |
|
344 | + // expandAll: two type for partial expansion |
|
345 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | + if($expandAll == 1) { |
|
347 | + $opened2[] = $row['id']; |
|
348 | + } |
|
349 | + $ph['icon'] = $ph['icon_folder_open']; |
|
350 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
351 | + $ph['node_toggle'] = 1; |
|
352 | + $ph['subMenuState'] = ' open'; |
|
353 | + |
|
354 | + if($ph['donthit'] == 1) { |
|
355 | + $ph['tree_page_click'] = 3; |
|
356 | + $ph['icon_node_toggle'] = ''; |
|
357 | + $ph['icon'] = $ph['icon_folder_close']; |
|
358 | + $ph['showChildren'] = 0; |
|
359 | + } |
|
360 | + |
|
361 | + // invoke OnManagerNodePrerender event |
|
362 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
363 | + 'ph' => $ph, |
|
364 | + 'opened' => '1' |
|
365 | + )); |
|
366 | + if(is_array($prenode)) { |
|
367 | + $phnew = array(); |
|
368 | + foreach($prenode as $pnode) { |
|
369 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
370 | + } |
|
371 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
372 | + if($ph['showChildren'] == 0) { |
|
373 | + unset($opened2[$row['id']]); |
|
374 | + $ph['node_toggle'] = 0; |
|
375 | + $ph['subMenuState'] = ''; |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + if($ph['showChildren'] == 0) { |
|
380 | + $ph['icon_node_toggle'] = ''; |
|
381 | + $ph['donthit'] = 1; |
|
382 | + $ph['icon'] = $ph['icon_folder_close']; |
|
383 | + $tpl = getTplFolderNodeNotChildren(); |
|
384 | + } |
|
385 | + |
|
386 | + if($ph['contextmenu']) { |
|
387 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
388 | + } |
|
389 | + |
|
390 | + $node .= $modx->parseText($tpl, $ph); |
|
391 | + if($ph['donthit'] == 0) { |
|
392 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
393 | + } |
|
394 | + $node .= '</div></div>'; |
|
395 | + } else { |
|
396 | + $closed2[] = $row['id']; |
|
397 | + $ph['icon'] = $ph['icon_folder_close']; |
|
398 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
399 | + $ph['node_toggle'] = 0; |
|
400 | + |
|
401 | + if($ph['donthit'] == 1) { |
|
402 | + $ph['tree_page_click'] = 3; |
|
403 | + $ph['icon_node_toggle'] = ''; |
|
404 | + $ph['icon'] = $ph['icon_folder_close']; |
|
405 | + $ph['showChildren'] = 0; |
|
406 | + } |
|
407 | + |
|
408 | + // invoke OnManagerNodePrerender event |
|
409 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
410 | + 'ph' => $ph, |
|
411 | + 'opened' => '0' |
|
412 | + )); |
|
413 | + if(is_array($prenode)) { |
|
414 | + $phnew = array(); |
|
415 | + foreach($prenode as $pnode) { |
|
416 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
417 | + } |
|
418 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
419 | + } |
|
420 | + |
|
421 | + if($ph['showChildren'] == 0) { |
|
422 | + $ph['icon_node_toggle'] = ''; |
|
423 | + $ph['donthit'] = 1; |
|
424 | + $ph['icon'] = $ph['icon_folder_close']; |
|
425 | + $tpl = getTplFolderNodeNotChildren(); |
|
426 | + } |
|
427 | + |
|
428 | + if($ph['contextmenu']) { |
|
429 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
430 | + } |
|
431 | + |
|
432 | + $node .= $modx->parseText($tpl, $ph); |
|
433 | + $node .= '</div></div>'; |
|
434 | + } |
|
435 | + } |
|
436 | + } |
|
437 | + |
|
438 | + // invoke OnManagerNodeRender event |
|
439 | + $data['node'] = $node; |
|
440 | + $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
441 | + if(is_array($evtOut)) { |
|
442 | + $evtOut = implode("\n", $evtOut); |
|
443 | + } |
|
444 | + if($evtOut != '') { |
|
445 | + $node = trim($evtOut); |
|
446 | + } |
|
447 | + |
|
448 | + $output .= $node; |
|
449 | + } |
|
450 | + |
|
451 | + return $output; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -456,30 +456,30 @@ discard block |
||
456 | 456 | * @return array |
457 | 457 | */ |
458 | 458 | function getIconInfo($_style) { |
459 | - if(!isset($_style['tree_page_gif'])) { |
|
460 | - $_style['tree_page_gif'] = $_style['tree_page']; |
|
461 | - } |
|
462 | - if(!isset($_style['tree_page_jpg'])) { |
|
463 | - $_style['tree_page_jpg'] = $_style['tree_page']; |
|
464 | - } |
|
465 | - if(!isset($_style['tree_page_png'])) { |
|
466 | - $_style['tree_page_png'] = $_style['tree_page']; |
|
467 | - } |
|
468 | - $icons = array( |
|
469 | - 'text/html' => $_style['tree_page_html'], |
|
470 | - 'text/plain' => $_style['tree_page'], |
|
471 | - 'text/xml' => $_style['tree_page_xml'], |
|
472 | - 'text/css' => $_style['tree_page_css'], |
|
473 | - 'text/javascript' => $_style['tree_page_js'], |
|
474 | - 'application/rss+xml' => $_style['tree_page_rss'], |
|
475 | - 'application/pdf' => $_style['tree_page_pdf'], |
|
476 | - 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
477 | - 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
478 | - 'image/gif' => $_style['tree_page_gif'], |
|
479 | - 'image/jpg' => $_style['tree_page_jpg'], |
|
480 | - 'image/png' => $_style['tree_page_png'] |
|
481 | - ); |
|
482 | - return $icons; |
|
459 | + if(!isset($_style['tree_page_gif'])) { |
|
460 | + $_style['tree_page_gif'] = $_style['tree_page']; |
|
461 | + } |
|
462 | + if(!isset($_style['tree_page_jpg'])) { |
|
463 | + $_style['tree_page_jpg'] = $_style['tree_page']; |
|
464 | + } |
|
465 | + if(!isset($_style['tree_page_png'])) { |
|
466 | + $_style['tree_page_png'] = $_style['tree_page']; |
|
467 | + } |
|
468 | + $icons = array( |
|
469 | + 'text/html' => $_style['tree_page_html'], |
|
470 | + 'text/plain' => $_style['tree_page'], |
|
471 | + 'text/xml' => $_style['tree_page_xml'], |
|
472 | + 'text/css' => $_style['tree_page_css'], |
|
473 | + 'text/javascript' => $_style['tree_page_js'], |
|
474 | + 'application/rss+xml' => $_style['tree_page_rss'], |
|
475 | + 'application/pdf' => $_style['tree_page_pdf'], |
|
476 | + 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
477 | + 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
478 | + 'image/gif' => $_style['tree_page_gif'], |
|
479 | + 'image/jpg' => $_style['tree_page_jpg'], |
|
480 | + 'image/png' => $_style['tree_page_png'] |
|
481 | + ); |
|
482 | + return $icons; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -487,30 +487,30 @@ discard block |
||
487 | 487 | * @return array |
488 | 488 | */ |
489 | 489 | function getPrivateIconInfo($_style) { |
490 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
491 | - $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
492 | - } |
|
493 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
494 | - $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
495 | - } |
|
496 | - if(!isset($_style['tree_page_png_secure'])) { |
|
497 | - $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
498 | - } |
|
499 | - $iconsPrivate = array( |
|
500 | - 'text/html' => $_style['tree_page_html_secure'], |
|
501 | - 'text/plain' => $_style['tree_page_secure'], |
|
502 | - 'text/xml' => $_style['tree_page_xml_secure'], |
|
503 | - 'text/css' => $_style['tree_page_css_secure'], |
|
504 | - 'text/javascript' => $_style['tree_page_js_secure'], |
|
505 | - 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
506 | - 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
507 | - 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
508 | - 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
509 | - 'image/gif' => $_style['tree_page_gif_secure'], |
|
510 | - 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
511 | - 'image/png' => $_style['tree_page_png_secure'] |
|
512 | - ); |
|
513 | - return $iconsPrivate; |
|
490 | + if(!isset($_style['tree_page_gif_secure'])) { |
|
491 | + $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
492 | + } |
|
493 | + if(!isset($_style['tree_page_jpg_secure'])) { |
|
494 | + $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
495 | + } |
|
496 | + if(!isset($_style['tree_page_png_secure'])) { |
|
497 | + $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
498 | + } |
|
499 | + $iconsPrivate = array( |
|
500 | + 'text/html' => $_style['tree_page_html_secure'], |
|
501 | + 'text/plain' => $_style['tree_page_secure'], |
|
502 | + 'text/xml' => $_style['tree_page_xml_secure'], |
|
503 | + 'text/css' => $_style['tree_page_css_secure'], |
|
504 | + 'text/javascript' => $_style['tree_page_js_secure'], |
|
505 | + 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
506 | + 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
507 | + 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
508 | + 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
509 | + 'image/gif' => $_style['tree_page_gif_secure'], |
|
510 | + 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
511 | + 'image/png' => $_style['tree_page_png_secure'] |
|
512 | + ); |
|
513 | + return $iconsPrivate; |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -519,49 +519,49 @@ discard block |
||
519 | 519 | * @return string |
520 | 520 | */ |
521 | 521 | function getNodeTitle($nodeNameSource, $row) { |
522 | - global $modx; |
|
523 | - |
|
524 | - switch($nodeNameSource) { |
|
525 | - case 'menutitle': |
|
526 | - $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
527 | - break; |
|
528 | - case 'alias': |
|
529 | - $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
530 | - if(strpos($row['alias'], '.') === false) { |
|
531 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
532 | - $nodetitle .= $modx->config['friendly_url_suffix']; |
|
533 | - } |
|
534 | - } |
|
535 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
536 | - break; |
|
537 | - case 'pagetitle': |
|
538 | - $nodetitle = $row['pagetitle']; |
|
539 | - break; |
|
540 | - case 'longtitle': |
|
541 | - $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
542 | - break; |
|
543 | - case 'createdon': |
|
544 | - case 'editedon': |
|
545 | - case 'publishedon': |
|
546 | - case 'pub_date': |
|
547 | - case 'unpub_date': |
|
548 | - $doc = $modx->getDocumentObject('id', $row['id']); |
|
549 | - $date = $doc[$nodeNameSource]; |
|
550 | - if(!empty($date)) { |
|
551 | - $nodetitle = $modx->toDateFormat($date); |
|
552 | - } else { |
|
553 | - $nodetitle = '- - -'; |
|
554 | - } |
|
555 | - break; |
|
556 | - default: |
|
557 | - $nodetitle = $row['pagetitle']; |
|
558 | - } |
|
559 | - $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
560 | - "\r\n", |
|
561 | - "\n", |
|
562 | - "\r" |
|
563 | - ), ' ', $nodetitle), ENT_COMPAT); |
|
564 | - return $nodetitle; |
|
522 | + global $modx; |
|
523 | + |
|
524 | + switch($nodeNameSource) { |
|
525 | + case 'menutitle': |
|
526 | + $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
527 | + break; |
|
528 | + case 'alias': |
|
529 | + $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
530 | + if(strpos($row['alias'], '.') === false) { |
|
531 | + if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
532 | + $nodetitle .= $modx->config['friendly_url_suffix']; |
|
533 | + } |
|
534 | + } |
|
535 | + $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
536 | + break; |
|
537 | + case 'pagetitle': |
|
538 | + $nodetitle = $row['pagetitle']; |
|
539 | + break; |
|
540 | + case 'longtitle': |
|
541 | + $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
542 | + break; |
|
543 | + case 'createdon': |
|
544 | + case 'editedon': |
|
545 | + case 'publishedon': |
|
546 | + case 'pub_date': |
|
547 | + case 'unpub_date': |
|
548 | + $doc = $modx->getDocumentObject('id', $row['id']); |
|
549 | + $date = $doc[$nodeNameSource]; |
|
550 | + if(!empty($date)) { |
|
551 | + $nodetitle = $modx->toDateFormat($date); |
|
552 | + } else { |
|
553 | + $nodetitle = '- - -'; |
|
554 | + } |
|
555 | + break; |
|
556 | + default: |
|
557 | + $nodetitle = $row['pagetitle']; |
|
558 | + } |
|
559 | + $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
560 | + "\r\n", |
|
561 | + "\n", |
|
562 | + "\r" |
|
563 | + ), ' ', $nodetitle), ENT_COMPAT); |
|
564 | + return $nodetitle; |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -569,16 +569,16 @@ discard block |
||
569 | 569 | * @return bool |
570 | 570 | */ |
571 | 571 | function isDateNode($nodeNameSource) { |
572 | - switch($nodeNameSource) { |
|
573 | - case 'createdon': |
|
574 | - case 'editedon': |
|
575 | - case 'publishedon': |
|
576 | - case 'pub_date': |
|
577 | - case 'unpub_date': |
|
578 | - return true; |
|
579 | - default: |
|
580 | - return false; |
|
581 | - } |
|
572 | + switch($nodeNameSource) { |
|
573 | + case 'createdon': |
|
574 | + case 'editedon': |
|
575 | + case 'publishedon': |
|
576 | + case 'pub_date': |
|
577 | + case 'unpub_date': |
|
578 | + return true; |
|
579 | + default: |
|
580 | + return false; |
|
581 | + } |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | * @return int |
588 | 588 | */ |
589 | 589 | function checkIsFolder($parent = 0, $isfolder = 1) { |
590 | - global $modx; |
|
590 | + global $modx; |
|
591 | 591 | |
592 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
592 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -597,19 +597,19 @@ discard block |
||
597 | 597 | * @return string |
598 | 598 | */ |
599 | 599 | function _htmlentities($array) { |
600 | - global $modx; |
|
600 | + global $modx; |
|
601 | 601 | |
602 | - $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
603 | - $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
602 | + $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
603 | + $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
604 | 604 | |
605 | - return $array; |
|
605 | + return $array; |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
609 | 609 | * @return string |
610 | 610 | */ |
611 | 611 | function getTplSingleNode() { |
612 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
612 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
613 | 613 | onclick="modx.tree.treeAction(event,[+id+]);" |
614 | 614 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
615 | 615 | data-id="[+id+]" |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | * @return string |
637 | 637 | */ |
638 | 638 | function getTplFolderNode() { |
639 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
639 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
640 | 640 | onclick="modx.tree.treeAction(event,[+id+]);" |
641 | 641 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
642 | 642 | data-id="[+id+]" |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | * @return string |
676 | 676 | */ |
677 | 677 | function getTplFolderNodeNotChildren() { |
678 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
678 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
679 | 679 | onclick="modx.tree.treeAction(event,[+id+]);" |
680 | 680 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
681 | 681 | data-id="[+id+]" |
@@ -711,10 +711,10 @@ discard block |
||
711 | 711 | * @param bool $flag |
712 | 712 | */ |
713 | 713 | function dbug($str, $flag = false) { |
714 | - print('<pre>'); |
|
715 | - print_r($str); |
|
716 | - print('</pre>'); |
|
717 | - if($flag) { |
|
718 | - exit; |
|
719 | - } |
|
714 | + print('<pre>'); |
|
715 | + print_r($str); |
|
716 | + print('</pre>'); |
|
717 | + if($flag) { |
|
718 | + exit; |
|
719 | + } |
|
720 | 720 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
4 | 4 | } |
5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @param string $hereid |
12 | 12 | * @return string |
13 | 13 | */ |
14 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
14 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = ''){ |
|
15 | 15 | global $modx; |
16 | 16 | global $icons, $iconsPrivate, $_style; |
17 | 17 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -22,35 +22,35 @@ discard block |
||
22 | 22 | // setup spacer |
23 | 23 | $level = 0; |
24 | 24 | $spacer = '<span class="indent">'; |
25 | - for($i = 2; $i <= $indent; $i++) { |
|
25 | + for ($i = 2; $i <= $indent; $i++) { |
|
26 | 26 | $spacer .= '<i></i>'; |
27 | 27 | $level++; |
28 | 28 | } |
29 | 29 | $spacer .= '</span>'; |
30 | 30 | |
31 | 31 | // manage order-by |
32 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
32 | + if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
33 | 33 | // This is the first startup, set default sort order |
34 | 34 | $_SESSION['tree_sortby'] = 'menuindex'; |
35 | 35 | $_SESSION['tree_sortdir'] = 'ASC'; |
36 | 36 | } |
37 | 37 | |
38 | - switch($_SESSION['tree_sortby']) { |
|
38 | + switch ($_SESSION['tree_sortby']) { |
|
39 | 39 | case 'createdon': |
40 | 40 | case 'editedon': |
41 | 41 | case 'publishedon': |
42 | 42 | case 'pub_date': |
43 | 43 | case 'unpub_date': |
44 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
44 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']); |
|
45 | 45 | break; |
46 | 46 | default: |
47 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
47 | + $sortby = 'sc.'.$_SESSION['tree_sortby']; |
|
48 | 48 | }; |
49 | 49 | |
50 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
50 | + $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']); |
|
51 | 51 | |
52 | 52 | // Folder sorting gets special setup ;) Add menuindex and pagetitle |
53 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
53 | + if ($_SESSION['tree_sortby'] == 'isfolder') { |
|
54 | 54 | $orderby .= ', menuindex ASC, pagetitle'; |
55 | 55 | } |
56 | 56 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | // get document groups for current user |
61 | 61 | $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
62 | 62 | $showProtected = false; |
63 | - if(isset ($modx->config['tree_show_protected'])) { |
|
63 | + if (isset ($modx->config['tree_show_protected'])) { |
|
64 | 64 | $showProtected = (boolean) $modx->config['tree_show_protected']; |
65 | 65 | } |
66 | 66 | $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
67 | - if($showProtected == false) { |
|
68 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
67 | + if ($showProtected == false) { |
|
68 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
69 | 69 | } else { |
70 | 70 | $access = ''; |
71 | 71 | } |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
76 | 76 | $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
77 | 77 | $result = $modx->db->select($field, $from, $where, $orderby); |
78 | - if($modx->db->getRecordCount($result) == 0) { |
|
78 | + if ($modx->db->getRecordCount($result) == 0) { |
|
79 | 79 | $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
80 | 80 | } |
81 | 81 | |
82 | 82 | $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
83 | 83 | |
84 | - while($row = $modx->db->getRow($result)) { |
|
84 | + while ($row = $modx->db->getRow($result)) { |
|
85 | 85 | $node = ''; |
86 | 86 | |
87 | 87 | $nodetitle = getNodeTitle($nodeNameSource, $row); |
@@ -90,46 +90,46 @@ discard block |
||
90 | 90 | $treeNodeClass = 'node'; |
91 | 91 | $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
92 | 92 | |
93 | - if($row['deleted'] == 1) { |
|
93 | + if ($row['deleted'] == 1) { |
|
94 | 94 | $treeNodeClass .= ' deleted'; |
95 | 95 | //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
96 | - } elseif($row['published'] == 0) { |
|
96 | + } elseif ($row['published'] == 0) { |
|
97 | 97 | $treeNodeClass .= ' unpublished'; |
98 | 98 | //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
99 | - } elseif($row['hidemenu'] == 1) { |
|
99 | + } elseif ($row['hidemenu'] == 1) { |
|
100 | 100 | $treeNodeClass .= ' hidemenu'; |
101 | 101 | //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
102 | 102 | } else { |
103 | 103 | //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
104 | 104 | } |
105 | 105 | |
106 | - if($row['id'] == $hereid) { |
|
106 | + if ($row['id'] == $hereid) { |
|
107 | 107 | $treeNodeClass .= ' current'; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
111 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
111 | + $pageIdDisplay = '<small>('.($modx_textdir ? '‏' : '').$row['id'].')</small>'; |
|
112 | 112 | |
113 | 113 | // Prepare displaying user-locks |
114 | 114 | $lockedByUser = ''; |
115 | 115 | $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
116 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | - if($rowLock['sid'] == $modx->sid) { |
|
116 | + if ($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | + if ($rowLock['sid'] == $modx->sid) { |
|
118 | 118 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
119 | 119 | 'element_type' => $_lang["lock_element_type_7"], |
120 | 120 | 'lasthit_df' => $rowLock['lasthit_df'] |
121 | 121 | )); |
122 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
122 | + $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>'; |
|
123 | 123 | } else { |
124 | 124 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
125 | 125 | 'element_type' => $_lang["lock_element_type_7"], |
126 | 126 | 'username' => $rowLock['username'], |
127 | 127 | 'lasthit_df' => $rowLock['lasthit_df'] |
128 | 128 | )); |
129 | - if($modx->hasPermission('remove_locks')) { |
|
130 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
129 | + if ($modx->hasPermission('remove_locks')) { |
|
130 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
131 | 131 | } else { |
132 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
132 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | $url = $modx->makeUrl($row['id']); |
138 | 138 | |
139 | 139 | $title = ''; |
140 | - if(isDateNode($nodeNameSource)) { |
|
141 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
140 | + if (isDateNode($nodeNameSource)) { |
|
141 | + $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]'; |
|
142 | 142 | } |
143 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
145 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
146 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
148 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
149 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
150 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
143 | + $title .= $_lang['id'].': '.$row['id']; |
|
144 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_title'].': '.$row['menutitle']; |
|
145 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_index'].': '.$row['menuindex']; |
|
146 | + $title .= '[+lf+]'.$_lang['alias'].': '.(!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | + $title .= '[+lf+]'.$_lang['template'].': '.$row['templatename']; |
|
148 | + $title .= '[+lf+]'.$_lang['publish_date'].': '.$modx->toDateFormat($row['pub_date']); |
|
149 | + $title .= '[+lf+]'.$_lang['unpublish_date'].': '.$modx->toDateFormat($row['unpub_date']); |
|
150 | + $title .= '[+lf+]'.$_lang['page_data_web_access'].': '.($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | + $title .= '[+lf+]'.$_lang['page_data_mgr_access'].': '.($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | + $title .= '[+lf+]'.$_lang['resource_opt_richtext'].': '.($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | + $title .= '[+lf+]'.$_lang['page_data_searchable'].': '.($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | + $title .= '[+lf+]'.$_lang['page_data_cacheable'].': '.($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
155 | 155 | $title = $modx->htmlspecialchars($title); |
156 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
156 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
157 | 157 | |
158 | 158 | $data = array( |
159 | 159 | 'id' => $row['id'], |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $ph['expandAll'] = $expandAll; |
203 | 203 | $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
204 | 204 | |
205 | - if(!$row['isfolder']) { |
|
205 | + if (!$row['isfolder']) { |
|
206 | 206 | $tpl = getTplSingleNode(); |
207 | - switch($row['id']) { |
|
207 | + switch ($row['id']) { |
|
208 | 208 | case $modx->config['site_start'] : |
209 | 209 | $icon = $_style['tree_page_home']; |
210 | 210 | break; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $icon = $_style['tree_page_info']; |
219 | 219 | break; |
220 | 220 | default: |
221 | - if(isset($icons[$row['contentType']])) { |
|
221 | + if (isset($icons[$row['contentType']])) { |
|
222 | 222 | $icon = $icons[$row['contentType']]; |
223 | 223 | } else { |
224 | 224 | $icon = $_style['tree_page']; |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | |
229 | 229 | // invoke OnManagerNodePrerender event |
230 | 230 | $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
231 | - if(is_array($prenode)) { |
|
231 | + if (is_array($prenode)) { |
|
232 | 232 | $phnew = array(); |
233 | - foreach($prenode as $pnode) { |
|
233 | + foreach ($prenode as $pnode) { |
|
234 | 234 | $phnew = array_merge($phnew, unserialize($pnode)); |
235 | 235 | } |
236 | 236 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
237 | 237 | } |
238 | 238 | |
239 | - if($ph['contextmenu']) { |
|
240 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
239 | + if ($ph['contextmenu']) { |
|
240 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
241 | 241 | } |
242 | 242 | |
243 | - if($_SESSION['tree_show_only_folders']) { |
|
244 | - if($row['parent'] == 0) { |
|
243 | + if ($_SESSION['tree_show_only_folders']) { |
|
244 | + if ($row['parent'] == 0) { |
|
245 | 245 | $node .= $modx->parseText($tpl, $ph); |
246 | 246 | } else { |
247 | 247 | $node .= ''; |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
255 | 255 | $ph['icon_folder_close'] = $_style['tree_folder_new']; |
256 | 256 | |
257 | - if($_SESSION['tree_show_only_folders']) { |
|
257 | + if ($_SESSION['tree_show_only_folders']) { |
|
258 | 258 | $tpl = getTplFolderNodeNotChildren(); |
259 | 259 | $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
260 | 260 | $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
261 | 261 | $ph['tree_page_click'] = 3; |
262 | 262 | |
263 | 263 | // expandAll: two type for partial expansion |
264 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | - if($expandAll == 1) { |
|
264 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | + if ($expandAll == 1) { |
|
266 | 266 | $opened2[] = $row['id']; |
267 | 267 | } |
268 | 268 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | $ph['node_toggle'] = 1; |
271 | 271 | $ph['subMenuState'] = ' open'; |
272 | 272 | |
273 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
273 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
274 | 274 | $ph['showChildren'] = 1; |
275 | 275 | $ph['icon_node_toggle'] = ''; |
276 | 276 | $ph['icon'] = $ph['icon_folder_close']; |
277 | - } elseif(!$checkDocs && $checkFolders) { |
|
277 | + } elseif (!$checkDocs && $checkFolders) { |
|
278 | 278 | $ph['showChildren'] = 0; |
279 | 279 | $ph['openFolder'] = 2; |
280 | 280 | } else { |
@@ -286,20 +286,20 @@ discard block |
||
286 | 286 | 'ph' => $ph, |
287 | 287 | 'opened' => '1' |
288 | 288 | )); |
289 | - if(is_array($prenode)) { |
|
289 | + if (is_array($prenode)) { |
|
290 | 290 | $phnew = array(); |
291 | - foreach($prenode as $pnode) { |
|
291 | + foreach ($prenode as $pnode) { |
|
292 | 292 | $phnew = array_merge($phnew, unserialize($pnode)); |
293 | 293 | } |
294 | 294 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
295 | 295 | } |
296 | 296 | |
297 | - if($ph['contextmenu']) { |
|
298 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
297 | + if ($ph['contextmenu']) { |
|
298 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | $node .= $modx->parseText($tpl, $ph); |
302 | - if($checkFolders) { |
|
302 | + if ($checkFolders) { |
|
303 | 303 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
304 | 304 | } |
305 | 305 | $node .= '</div></div>'; |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
310 | 310 | $ph['node_toggle'] = 0; |
311 | 311 | |
312 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
312 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
313 | 313 | $ph['showChildren'] = 1; |
314 | 314 | $ph['icon_node_toggle'] = ''; |
315 | - } elseif(!$checkDocs && $checkFolders) { |
|
315 | + } elseif (!$checkDocs && $checkFolders) { |
|
316 | 316 | $ph['showChildren'] = 0; |
317 | 317 | $ph['openFolder'] = 2; |
318 | 318 | } else { |
@@ -324,16 +324,16 @@ discard block |
||
324 | 324 | 'ph' => $ph, |
325 | 325 | 'opened' => '0' |
326 | 326 | )); |
327 | - if(is_array($prenode)) { |
|
327 | + if (is_array($prenode)) { |
|
328 | 328 | $phnew = array(); |
329 | - foreach($prenode as $pnode) { |
|
329 | + foreach ($prenode as $pnode) { |
|
330 | 330 | $phnew = array_merge($phnew, unserialize($pnode)); |
331 | 331 | } |
332 | 332 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
333 | 333 | } |
334 | 334 | |
335 | - if($ph['contextmenu']) { |
|
336 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
335 | + if ($ph['contextmenu']) { |
|
336 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | $node .= $modx->parseText($tpl, $ph); |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | } else { |
343 | 343 | $tpl = getTplFolderNode(); |
344 | 344 | // expandAll: two type for partial expansion |
345 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | - if($expandAll == 1) { |
|
345 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | + if ($expandAll == 1) { |
|
347 | 347 | $opened2[] = $row['id']; |
348 | 348 | } |
349 | 349 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $ph['node_toggle'] = 1; |
352 | 352 | $ph['subMenuState'] = ' open'; |
353 | 353 | |
354 | - if($ph['donthit'] == 1) { |
|
354 | + if ($ph['donthit'] == 1) { |
|
355 | 355 | $ph['tree_page_click'] = 3; |
356 | 356 | $ph['icon_node_toggle'] = ''; |
357 | 357 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -363,32 +363,32 @@ discard block |
||
363 | 363 | 'ph' => $ph, |
364 | 364 | 'opened' => '1' |
365 | 365 | )); |
366 | - if(is_array($prenode)) { |
|
366 | + if (is_array($prenode)) { |
|
367 | 367 | $phnew = array(); |
368 | - foreach($prenode as $pnode) { |
|
368 | + foreach ($prenode as $pnode) { |
|
369 | 369 | $phnew = array_merge($phnew, unserialize($pnode)); |
370 | 370 | } |
371 | 371 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
372 | - if($ph['showChildren'] == 0) { |
|
372 | + if ($ph['showChildren'] == 0) { |
|
373 | 373 | unset($opened2[$row['id']]); |
374 | 374 | $ph['node_toggle'] = 0; |
375 | 375 | $ph['subMenuState'] = ''; |
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
379 | - if($ph['showChildren'] == 0) { |
|
379 | + if ($ph['showChildren'] == 0) { |
|
380 | 380 | $ph['icon_node_toggle'] = ''; |
381 | 381 | $ph['donthit'] = 1; |
382 | 382 | $ph['icon'] = $ph['icon_folder_close']; |
383 | 383 | $tpl = getTplFolderNodeNotChildren(); |
384 | 384 | } |
385 | 385 | |
386 | - if($ph['contextmenu']) { |
|
387 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
386 | + if ($ph['contextmenu']) { |
|
387 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | $node .= $modx->parseText($tpl, $ph); |
391 | - if($ph['donthit'] == 0) { |
|
391 | + if ($ph['donthit'] == 0) { |
|
392 | 392 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
393 | 393 | } |
394 | 394 | $node .= '</div></div>'; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
399 | 399 | $ph['node_toggle'] = 0; |
400 | 400 | |
401 | - if($ph['donthit'] == 1) { |
|
401 | + if ($ph['donthit'] == 1) { |
|
402 | 402 | $ph['tree_page_click'] = 3; |
403 | 403 | $ph['icon_node_toggle'] = ''; |
404 | 404 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -410,23 +410,23 @@ discard block |
||
410 | 410 | 'ph' => $ph, |
411 | 411 | 'opened' => '0' |
412 | 412 | )); |
413 | - if(is_array($prenode)) { |
|
413 | + if (is_array($prenode)) { |
|
414 | 414 | $phnew = array(); |
415 | - foreach($prenode as $pnode) { |
|
415 | + foreach ($prenode as $pnode) { |
|
416 | 416 | $phnew = array_merge($phnew, unserialize($pnode)); |
417 | 417 | } |
418 | 418 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
419 | 419 | } |
420 | 420 | |
421 | - if($ph['showChildren'] == 0) { |
|
421 | + if ($ph['showChildren'] == 0) { |
|
422 | 422 | $ph['icon_node_toggle'] = ''; |
423 | 423 | $ph['donthit'] = 1; |
424 | 424 | $ph['icon'] = $ph['icon_folder_close']; |
425 | 425 | $tpl = getTplFolderNodeNotChildren(); |
426 | 426 | } |
427 | 427 | |
428 | - if($ph['contextmenu']) { |
|
429 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
428 | + if ($ph['contextmenu']) { |
|
429 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $node .= $modx->parseText($tpl, $ph); |
@@ -438,10 +438,10 @@ discard block |
||
438 | 438 | // invoke OnManagerNodeRender event |
439 | 439 | $data['node'] = $node; |
440 | 440 | $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
441 | - if(is_array($evtOut)) { |
|
441 | + if (is_array($evtOut)) { |
|
442 | 442 | $evtOut = implode("\n", $evtOut); |
443 | 443 | } |
444 | - if($evtOut != '') { |
|
444 | + if ($evtOut != '') { |
|
445 | 445 | $node = trim($evtOut); |
446 | 446 | } |
447 | 447 | |
@@ -455,14 +455,14 @@ discard block |
||
455 | 455 | * @param array $_style |
456 | 456 | * @return array |
457 | 457 | */ |
458 | -function getIconInfo($_style) { |
|
459 | - if(!isset($_style['tree_page_gif'])) { |
|
458 | +function getIconInfo($_style){ |
|
459 | + if (!isset($_style['tree_page_gif'])) { |
|
460 | 460 | $_style['tree_page_gif'] = $_style['tree_page']; |
461 | 461 | } |
462 | - if(!isset($_style['tree_page_jpg'])) { |
|
462 | + if (!isset($_style['tree_page_jpg'])) { |
|
463 | 463 | $_style['tree_page_jpg'] = $_style['tree_page']; |
464 | 464 | } |
465 | - if(!isset($_style['tree_page_png'])) { |
|
465 | + if (!isset($_style['tree_page_png'])) { |
|
466 | 466 | $_style['tree_page_png'] = $_style['tree_page']; |
467 | 467 | } |
468 | 468 | $icons = array( |
@@ -486,14 +486,14 @@ discard block |
||
486 | 486 | * @param array $_style |
487 | 487 | * @return array |
488 | 488 | */ |
489 | -function getPrivateIconInfo($_style) { |
|
490 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
489 | +function getPrivateIconInfo($_style){ |
|
490 | + if (!isset($_style['tree_page_gif_secure'])) { |
|
491 | 491 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
492 | 492 | } |
493 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
493 | + if (!isset($_style['tree_page_jpg_secure'])) { |
|
494 | 494 | $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
495 | 495 | } |
496 | - if(!isset($_style['tree_page_png_secure'])) { |
|
496 | + if (!isset($_style['tree_page_png_secure'])) { |
|
497 | 497 | $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
498 | 498 | } |
499 | 499 | $iconsPrivate = array( |
@@ -518,21 +518,21 @@ discard block |
||
518 | 518 | * @param array $row |
519 | 519 | * @return string |
520 | 520 | */ |
521 | -function getNodeTitle($nodeNameSource, $row) { |
|
521 | +function getNodeTitle($nodeNameSource, $row){ |
|
522 | 522 | global $modx; |
523 | 523 | |
524 | - switch($nodeNameSource) { |
|
524 | + switch ($nodeNameSource) { |
|
525 | 525 | case 'menutitle': |
526 | 526 | $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
527 | 527 | break; |
528 | 528 | case 'alias': |
529 | 529 | $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
530 | - if(strpos($row['alias'], '.') === false) { |
|
531 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
530 | + if (strpos($row['alias'], '.') === false) { |
|
531 | + if ($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
532 | 532 | $nodetitle .= $modx->config['friendly_url_suffix']; |
533 | 533 | } |
534 | 534 | } |
535 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
535 | + $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle; |
|
536 | 536 | break; |
537 | 537 | case 'pagetitle': |
538 | 538 | $nodetitle = $row['pagetitle']; |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | case 'unpub_date': |
548 | 548 | $doc = $modx->getDocumentObject('id', $row['id']); |
549 | 549 | $date = $doc[$nodeNameSource]; |
550 | - if(!empty($date)) { |
|
550 | + if (!empty($date)) { |
|
551 | 551 | $nodetitle = $modx->toDateFormat($date); |
552 | 552 | } else { |
553 | 553 | $nodetitle = '- - -'; |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | * @param string $nodeNameSource |
569 | 569 | * @return bool |
570 | 570 | */ |
571 | -function isDateNode($nodeNameSource) { |
|
572 | - switch($nodeNameSource) { |
|
571 | +function isDateNode($nodeNameSource){ |
|
572 | + switch ($nodeNameSource) { |
|
573 | 573 | case 'createdon': |
574 | 574 | case 'editedon': |
575 | 575 | case 'publishedon': |
@@ -586,17 +586,17 @@ discard block |
||
586 | 586 | * @param int $isfolder |
587 | 587 | * @return int |
588 | 588 | */ |
589 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
589 | +function checkIsFolder($parent = 0, $isfolder = 1){ |
|
590 | 590 | global $modx; |
591 | 591 | |
592 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
592 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM '.$modx->getFullTableName('site_content').' WHERE parent='.$parent.' AND isfolder='.$isfolder.' ')); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
596 | 596 | * @param mixed $array |
597 | 597 | * @return string |
598 | 598 | */ |
599 | -function _htmlentities($array) { |
|
599 | +function _htmlentities($array){ |
|
600 | 600 | global $modx; |
601 | 601 | |
602 | 602 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | /** |
609 | 609 | * @return string |
610 | 610 | */ |
611 | -function getTplSingleNode() { |
|
611 | +function getTplSingleNode(){ |
|
612 | 612 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
613 | 613 | onclick="modx.tree.treeAction(event,[+id+]);" |
614 | 614 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | /** |
636 | 636 | * @return string |
637 | 637 | */ |
638 | -function getTplFolderNode() { |
|
638 | +function getTplFolderNode(){ |
|
639 | 639 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
640 | 640 | onclick="modx.tree.treeAction(event,[+id+]);" |
641 | 641 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | /** |
675 | 675 | * @return string |
676 | 676 | */ |
677 | -function getTplFolderNodeNotChildren() { |
|
677 | +function getTplFolderNodeNotChildren(){ |
|
678 | 678 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
679 | 679 | onclick="modx.tree.treeAction(event,[+id+]);" |
680 | 680 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -710,11 +710,11 @@ discard block |
||
710 | 710 | * @param int|string|array $str |
711 | 711 | * @param bool $flag |
712 | 712 | */ |
713 | -function dbug($str, $flag = false) { |
|
713 | +function dbug($str, $flag = false){ |
|
714 | 714 | print('<pre>'); |
715 | 715 | print_r($str); |
716 | 716 | print('</pre>'); |
717 | - if($flag) { |
|
717 | + if ($flag) { |
|
718 | 718 | exit; |
719 | 719 | } |
720 | 720 | } |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | * @param string $hereid |
12 | 12 | * @return string |
13 | 13 | */ |
14 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
14 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') |
|
15 | +{ |
|
15 | 16 | global $modx; |
16 | 17 | global $icons, $iconsPrivate, $_style; |
17 | 18 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -455,7 +456,8 @@ discard block |
||
455 | 456 | * @param array $_style |
456 | 457 | * @return array |
457 | 458 | */ |
458 | -function getIconInfo($_style) { |
|
459 | +function getIconInfo($_style) |
|
460 | +{ |
|
459 | 461 | if(!isset($_style['tree_page_gif'])) { |
460 | 462 | $_style['tree_page_gif'] = $_style['tree_page']; |
461 | 463 | } |
@@ -486,7 +488,8 @@ discard block |
||
486 | 488 | * @param array $_style |
487 | 489 | * @return array |
488 | 490 | */ |
489 | -function getPrivateIconInfo($_style) { |
|
491 | +function getPrivateIconInfo($_style) |
|
492 | +{ |
|
490 | 493 | if(!isset($_style['tree_page_gif_secure'])) { |
491 | 494 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
492 | 495 | } |
@@ -518,7 +521,8 @@ discard block |
||
518 | 521 | * @param array $row |
519 | 522 | * @return string |
520 | 523 | */ |
521 | -function getNodeTitle($nodeNameSource, $row) { |
|
524 | +function getNodeTitle($nodeNameSource, $row) |
|
525 | +{ |
|
522 | 526 | global $modx; |
523 | 527 | |
524 | 528 | switch($nodeNameSource) { |
@@ -568,7 +572,8 @@ discard block |
||
568 | 572 | * @param string $nodeNameSource |
569 | 573 | * @return bool |
570 | 574 | */ |
571 | -function isDateNode($nodeNameSource) { |
|
575 | +function isDateNode($nodeNameSource) |
|
576 | +{ |
|
572 | 577 | switch($nodeNameSource) { |
573 | 578 | case 'createdon': |
574 | 579 | case 'editedon': |
@@ -586,7 +591,8 @@ discard block |
||
586 | 591 | * @param int $isfolder |
587 | 592 | * @return int |
588 | 593 | */ |
589 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
594 | +function checkIsFolder($parent = 0, $isfolder = 1) |
|
595 | +{ |
|
590 | 596 | global $modx; |
591 | 597 | |
592 | 598 | return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
@@ -596,7 +602,8 @@ discard block |
||
596 | 602 | * @param mixed $array |
597 | 603 | * @return string |
598 | 604 | */ |
599 | -function _htmlentities($array) { |
|
605 | +function _htmlentities($array) |
|
606 | +{ |
|
600 | 607 | global $modx; |
601 | 608 | |
602 | 609 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -608,7 +615,8 @@ discard block |
||
608 | 615 | /** |
609 | 616 | * @return string |
610 | 617 | */ |
611 | -function getTplSingleNode() { |
|
618 | +function getTplSingleNode() |
|
619 | +{ |
|
612 | 620 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
613 | 621 | onclick="modx.tree.treeAction(event,[+id+]);" |
614 | 622 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -635,7 +643,8 @@ discard block |
||
635 | 643 | /** |
636 | 644 | * @return string |
637 | 645 | */ |
638 | -function getTplFolderNode() { |
|
646 | +function getTplFolderNode() |
|
647 | +{ |
|
639 | 648 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
640 | 649 | onclick="modx.tree.treeAction(event,[+id+]);" |
641 | 650 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -674,7 +683,8 @@ discard block |
||
674 | 683 | /** |
675 | 684 | * @return string |
676 | 685 | */ |
677 | -function getTplFolderNodeNotChildren() { |
|
686 | +function getTplFolderNodeNotChildren() |
|
687 | +{ |
|
678 | 688 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
679 | 689 | onclick="modx.tree.treeAction(event,[+id+]);" |
680 | 690 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -710,7 +720,8 @@ discard block |
||
710 | 720 | * @param int|string|array $str |
711 | 721 | * @param bool $flag |
712 | 722 | */ |
713 | -function dbug($str, $flag = false) { |
|
723 | +function dbug($str, $flag = false) |
|
724 | +{ |
|
714 | 725 | print('<pre>'); |
715 | 726 | print_r($str); |
716 | 727 | print('</pre>'); |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | $tpl = array( |
7 | - 'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'), |
|
8 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
9 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
10 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
11 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl') |
|
7 | + 'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'), |
|
8 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
9 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
10 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
11 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl') |
|
12 | 12 | ); |
13 | 13 | |
14 | 14 | /** |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | * @return string |
18 | 18 | */ |
19 | 19 | function parsePh($tpl, $ph) { |
20 | - global $modx, $_lang; |
|
21 | - $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
22 | - return $modx->parseText($tpl, $ph); |
|
20 | + global $modx, $_lang; |
|
21 | + $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
22 | + return $modx->parseText($tpl, $ph); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * @return string |
28 | 28 | */ |
29 | 29 | function renderViewSwitchButtons($cssId) { |
30 | - global $modx, $_lang, $tpl; |
|
30 | + global $modx, $_lang, $tpl; |
|
31 | 31 | |
32 | - return parsePh($tpl['viewForm'], array( |
|
33 | - 'cssId' => $cssId |
|
34 | - )); |
|
32 | + return parsePh($tpl['viewForm'], array( |
|
33 | + 'cssId' => $cssId |
|
34 | + )); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,52 +40,52 @@ discard block |
||
40 | 40 | * @return string |
41 | 41 | */ |
42 | 42 | function createResourceList($resourceTable, $resources) { |
43 | - global $modx, $_lang, $_style, $modx_textdir, $tpl; |
|
43 | + global $modx, $_lang, $_style, $modx_textdir, $tpl; |
|
44 | 44 | |
45 | - $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
|
45 | + $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
|
46 | 46 | |
47 | - if( ! is_array($items) || empty($items)) { |
|
48 | - return $_lang['no_results']; |
|
49 | - } |
|
47 | + if( ! is_array($items) || empty($items)) { |
|
48 | + return $_lang['no_results']; |
|
49 | + } |
|
50 | 50 | |
51 | - // Prepare elements- and categories-list |
|
52 | - $elements = array(); |
|
53 | - $categories = array(); |
|
54 | - foreach($items as $row) { |
|
55 | - $catid = $row['catid'] ? $row['catid'] : 0; |
|
56 | - $categories[$catid] = array('name' => stripslashes($row['category'])); |
|
57 | - $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
|
58 | - } |
|
51 | + // Prepare elements- and categories-list |
|
52 | + $elements = array(); |
|
53 | + $categories = array(); |
|
54 | + foreach($items as $row) { |
|
55 | + $catid = $row['catid'] ? $row['catid'] : 0; |
|
56 | + $categories[$catid] = array('name' => stripslashes($row['category'])); |
|
57 | + $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
|
58 | + } |
|
59 | 59 | |
60 | - // Now render categories / panel-collapse |
|
61 | - $panelGroup = ''; |
|
62 | - foreach($elements as $catid => $elList) { |
|
63 | - // Add panel-heading / category-collapse to output |
|
64 | - $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
65 | - 'tab' => $resourceTable, |
|
66 | - 'category' => $categories[$catid]['name'], |
|
67 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
68 | - 'catid' => $catid, |
|
69 | - )); |
|
60 | + // Now render categories / panel-collapse |
|
61 | + $panelGroup = ''; |
|
62 | + foreach($elements as $catid => $elList) { |
|
63 | + // Add panel-heading / category-collapse to output |
|
64 | + $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
65 | + 'tab' => $resourceTable, |
|
66 | + 'category' => $categories[$catid]['name'], |
|
67 | + 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
68 | + 'catid' => $catid, |
|
69 | + )); |
|
70 | 70 | |
71 | - // Prepare content for panel-collapse |
|
72 | - $panelCollapse = ''; |
|
73 | - foreach($elList as $el) { |
|
74 | - $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
|
75 | - } |
|
71 | + // Prepare content for panel-collapse |
|
72 | + $panelCollapse = ''; |
|
73 | + foreach($elList as $el) { |
|
74 | + $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
|
75 | + } |
|
76 | 76 | |
77 | - // Add panel-collapse with elements to output |
|
78 | - $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
79 | - 'tab' => $resourceTable, |
|
80 | - 'catid' => $catid, |
|
81 | - 'wrapper' => $panelCollapse, |
|
82 | - )); |
|
83 | - } |
|
77 | + // Add panel-collapse with elements to output |
|
78 | + $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
79 | + 'tab' => $resourceTable, |
|
80 | + 'catid' => $catid, |
|
81 | + 'wrapper' => $panelCollapse, |
|
82 | + )); |
|
83 | + } |
|
84 | 84 | |
85 | - return parsePh($tpl['panelGroup'], array( |
|
86 | - 'resourceTable' => $resourceTable, |
|
87 | - 'wrapper' => $panelGroup |
|
88 | - )); |
|
85 | + return parsePh($tpl['panelGroup'], array( |
|
86 | + 'resourceTable' => $resourceTable, |
|
87 | + 'wrapper' => $panelGroup |
|
88 | + )); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,54 +93,54 @@ discard block |
||
93 | 93 | * @return string |
94 | 94 | */ |
95 | 95 | function createCombinedView($resources) { |
96 | - global $modx, $_lang, $_style, $modx_textdir; |
|
96 | + global $modx, $_lang, $_style, $modx_textdir; |
|
97 | 97 | |
98 | - $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
|
99 | - $types = isset($resources->types) ? $resources->types : false; |
|
100 | - $categories = isset($resources->categories) ? $resources->categories : false; |
|
98 | + $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
|
99 | + $types = isset($resources->types) ? $resources->types : false; |
|
100 | + $categories = isset($resources->categories) ? $resources->categories : false; |
|
101 | 101 | |
102 | - if(!$itemsPerCategory) { |
|
103 | - return $_lang['no_results']; |
|
104 | - } |
|
102 | + if(!$itemsPerCategory) { |
|
103 | + return $_lang['no_results']; |
|
104 | + } |
|
105 | 105 | |
106 | - $tpl = array( |
|
107 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
108 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
109 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
110 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'), |
|
111 | - ); |
|
106 | + $tpl = array( |
|
107 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
108 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
109 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
110 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'), |
|
111 | + ); |
|
112 | 112 | |
113 | - // Easily loop through $itemsPerCategory-Array |
|
114 | - $panelGroup = ''; |
|
115 | - foreach($categories as $catid => $category) { |
|
116 | - // Prepare collapse content / elements-list |
|
117 | - $panelCollapse = ''; |
|
118 | - foreach($itemsPerCategory[$catid] as $el) { |
|
119 | - $resourceTable = $el['type']; |
|
120 | - $ph = prepareElementRowPh($el, $resourceTable, $resources); |
|
121 | - $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
|
122 | - } |
|
113 | + // Easily loop through $itemsPerCategory-Array |
|
114 | + $panelGroup = ''; |
|
115 | + foreach($categories as $catid => $category) { |
|
116 | + // Prepare collapse content / elements-list |
|
117 | + $panelCollapse = ''; |
|
118 | + foreach($itemsPerCategory[$catid] as $el) { |
|
119 | + $resourceTable = $el['type']; |
|
120 | + $ph = prepareElementRowPh($el, $resourceTable, $resources); |
|
121 | + $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
|
122 | + } |
|
123 | 123 | |
124 | - // Add panel-heading / button |
|
125 | - $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
126 | - 'tab' => 'categories_list', |
|
127 | - 'category' => $categories[$catid], |
|
128 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
129 | - 'catid' => $catid, |
|
130 | - )); |
|
124 | + // Add panel-heading / button |
|
125 | + $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
126 | + 'tab' => 'categories_list', |
|
127 | + 'category' => $categories[$catid], |
|
128 | + 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
129 | + 'catid' => $catid, |
|
130 | + )); |
|
131 | 131 | |
132 | - // Add panel |
|
133 | - $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
134 | - 'tab' => 'categories_list', |
|
135 | - 'catid' => $catid, |
|
136 | - 'wrapper' => $panelCollapse, |
|
137 | - )); |
|
138 | - } |
|
132 | + // Add panel |
|
133 | + $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
134 | + 'tab' => 'categories_list', |
|
135 | + 'catid' => $catid, |
|
136 | + 'wrapper' => $panelCollapse, |
|
137 | + )); |
|
138 | + } |
|
139 | 139 | |
140 | - return parsePh($tpl['panelGroup'], array( |
|
141 | - 'resourceTable' => 'categories_list', |
|
142 | - 'wrapper' => $panelGroup |
|
143 | - )); |
|
140 | + return parsePh($tpl['panelGroup'], array( |
|
141 | + 'resourceTable' => 'categories_list', |
|
142 | + 'wrapper' => $panelGroup |
|
143 | + )); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * @return array |
151 | 151 | */ |
152 | 152 | function prepareElementRowPh($row, $resourceTable, $resources) { |
153 | - global $modx, $modx_textdir, $_style, $_lang; |
|
153 | + global $modx, $modx_textdir, $_style, $_lang; |
|
154 | 154 | |
155 | - $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
|
155 | + $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
|
156 | 156 | |
157 | - $_lang["confirm_delete"] = $_lang["delete"]; |
|
157 | + $_lang["confirm_delete"] = $_lang["delete"]; |
|
158 | 158 | |
159 | - switch($resourceTable){ |
|
159 | + switch($resourceTable){ |
|
160 | 160 | case 'site_templates': |
161 | 161 | $class = $row['selectable'] ? '' : 'disabledPlugin'; |
162 | 162 | $lockElementType = 1; |
@@ -190,77 +190,77 @@ discard block |
||
190 | 190 | return array(); |
191 | 191 | } |
192 | 192 | |
193 | - // Prepare displaying user-locks |
|
194 | - $lockedByUser = ''; |
|
195 | - $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
|
196 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
197 | - if($rowLock['sid'] == $modx->sid) { |
|
198 | - $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
199 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
200 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
201 | - )); |
|
202 | - $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
|
203 | - } else { |
|
204 | - $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
205 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
206 | - 'username' => $rowLock['username'], |
|
207 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
208 | - )); |
|
209 | - if($modx->hasPermission('remove_locks')) { |
|
210 | - $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>'; |
|
211 | - } else { |
|
212 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
|
213 | - } |
|
214 | - } |
|
215 | - } |
|
216 | - if($lockedByUser) { |
|
217 | - $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
|
218 | - } |
|
193 | + // Prepare displaying user-locks |
|
194 | + $lockedByUser = ''; |
|
195 | + $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
|
196 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
197 | + if($rowLock['sid'] == $modx->sid) { |
|
198 | + $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
199 | + 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
200 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
201 | + )); |
|
202 | + $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
|
203 | + } else { |
|
204 | + $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
205 | + 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
206 | + 'username' => $rowLock['username'], |
|
207 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
208 | + )); |
|
209 | + if($modx->hasPermission('remove_locks')) { |
|
210 | + $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>'; |
|
211 | + } else { |
|
212 | + $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
|
213 | + } |
|
214 | + } |
|
215 | + } |
|
216 | + if($lockedByUser) { |
|
217 | + $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
|
218 | + } |
|
219 | 219 | |
220 | - // Caption |
|
221 | - if($resourceTable == 'site_tmplvars') { |
|
222 | - $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption']; |
|
223 | - } else { |
|
224 | - $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
|
225 | - } |
|
220 | + // Caption |
|
221 | + if($resourceTable == 'site_tmplvars') { |
|
222 | + $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption']; |
|
223 | + } else { |
|
224 | + $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
|
225 | + } |
|
226 | 226 | |
227 | - // Special marks |
|
228 | - $tplInfo = array(); |
|
229 | - if($row['locked']) { |
|
230 | - $tplInfo[] = $_lang['locked']; |
|
231 | - } |
|
232 | - if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
233 | - $tplInfo[] = $_lang['defaulttemplate_title']; |
|
234 | - } |
|
235 | - $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : ''; |
|
227 | + // Special marks |
|
228 | + $tplInfo = array(); |
|
229 | + if($row['locked']) { |
|
230 | + $tplInfo[] = $_lang['locked']; |
|
231 | + } |
|
232 | + if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
233 | + $tplInfo[] = $_lang['defaulttemplate_title']; |
|
234 | + } |
|
235 | + $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : ''; |
|
236 | 236 | |
237 | - /* row buttons */ |
|
238 | - $buttons = ''; |
|
239 | - if($modx->hasPermission($types['actions']['edit'][1])) { |
|
240 | - $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
241 | - } |
|
242 | - if($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
243 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
244 | - } |
|
245 | - if($modx->hasPermission($types['actions']['remove'][1])) { |
|
246 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
247 | - } |
|
248 | - $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
|
237 | + /* row buttons */ |
|
238 | + $buttons = ''; |
|
239 | + if($modx->hasPermission($types['actions']['edit'][1])) { |
|
240 | + $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
241 | + } |
|
242 | + if($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
243 | + $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
244 | + } |
|
245 | + if($modx->hasPermission($types['actions']['remove'][1])) { |
|
246 | + $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
247 | + } |
|
248 | + $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
|
249 | 249 | |
250 | - $catid = $row['catid'] ? $row['catid'] : 0; |
|
250 | + $catid = $row['catid'] ? $row['catid'] : 0; |
|
251 | 251 | |
252 | - // Placeholders for elements-row |
|
253 | - return array( |
|
254 | - 'class' => $class ? ' class="' . $class . '"' : '', |
|
255 | - 'lockedByUser' => $lockedByUser, |
|
256 | - 'name' => $row['name'], |
|
257 | - 'caption' => $caption, |
|
258 | - 'buttons' => $buttons, |
|
259 | - 'marks' => $marks, |
|
260 | - 'id' => $row['id'], |
|
261 | - 'resourceTable' => $resourceTable, |
|
262 | - 'actionEdit' => $types['actions']['edit'][0], |
|
263 | - 'catid' => $catid, |
|
264 | - 'textdir' => $modx_textdir ? '‏' : '', |
|
265 | - ); |
|
252 | + // Placeholders for elements-row |
|
253 | + return array( |
|
254 | + 'class' => $class ? ' class="' . $class . '"' : '', |
|
255 | + 'lockedByUser' => $lockedByUser, |
|
256 | + 'name' => $row['name'], |
|
257 | + 'caption' => $caption, |
|
258 | + 'buttons' => $buttons, |
|
259 | + 'marks' => $marks, |
|
260 | + 'id' => $row['id'], |
|
261 | + 'resourceTable' => $resourceTable, |
|
262 | + 'actionEdit' => $types['actions']['edit'][0], |
|
263 | + 'catid' => $catid, |
|
264 | + 'textdir' => $modx_textdir ? '‏' : '', |
|
265 | + ); |
|
266 | 266 | } |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | 6 | $tpl = array( |
7 | - 'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'), |
|
8 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
9 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
10 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
11 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl') |
|
7 | + 'viewForm' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_viewForm.tpl'), |
|
8 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'), |
|
9 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'), |
|
10 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'), |
|
11 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl') |
|
12 | 12 | ); |
13 | 13 | |
14 | 14 | /** |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param array $ph |
17 | 17 | * @return string |
18 | 18 | */ |
19 | -function parsePh($tpl, $ph) { |
|
19 | +function parsePh($tpl, $ph){ |
|
20 | 20 | global $modx, $_lang; |
21 | 21 | $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
22 | 22 | return $modx->parseText($tpl, $ph); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param string|int $cssId |
27 | 27 | * @return string |
28 | 28 | */ |
29 | -function renderViewSwitchButtons($cssId) { |
|
29 | +function renderViewSwitchButtons($cssId){ |
|
30 | 30 | global $modx, $_lang, $tpl; |
31 | 31 | |
32 | 32 | return parsePh($tpl['viewForm'], array( |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | * @param mgrResources $resources |
40 | 40 | * @return string |
41 | 41 | */ |
42 | -function createResourceList($resourceTable, $resources) { |
|
42 | +function createResourceList($resourceTable, $resources){ |
|
43 | 43 | global $modx, $_lang, $_style, $modx_textdir, $tpl; |
44 | 44 | |
45 | 45 | $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
46 | 46 | |
47 | - if( ! is_array($items) || empty($items)) { |
|
47 | + if (!is_array($items) || empty($items)) { |
|
48 | 48 | return $_lang['no_results']; |
49 | 49 | } |
50 | 50 | |
51 | 51 | // Prepare elements- and categories-list |
52 | 52 | $elements = array(); |
53 | 53 | $categories = array(); |
54 | - foreach($items as $row) { |
|
54 | + foreach ($items as $row) { |
|
55 | 55 | $catid = $row['catid'] ? $row['catid'] : 0; |
56 | 56 | $categories[$catid] = array('name' => stripslashes($row['category'])); |
57 | 57 | $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | |
60 | 60 | // Now render categories / panel-collapse |
61 | 61 | $panelGroup = ''; |
62 | - foreach($elements as $catid => $elList) { |
|
62 | + foreach ($elements as $catid => $elList) { |
|
63 | 63 | // Add panel-heading / category-collapse to output |
64 | 64 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
65 | 65 | 'tab' => $resourceTable, |
66 | 66 | 'category' => $categories[$catid]['name'], |
67 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
67 | + 'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '', |
|
68 | 68 | 'catid' => $catid, |
69 | 69 | )); |
70 | 70 | |
71 | 71 | // Prepare content for panel-collapse |
72 | 72 | $panelCollapse = ''; |
73 | - foreach($elList as $el) { |
|
73 | + foreach ($elList as $el) { |
|
74 | 74 | $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
75 | 75 | } |
76 | 76 | |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | * @param mgrResources $resources |
93 | 93 | * @return string |
94 | 94 | */ |
95 | -function createCombinedView($resources) { |
|
95 | +function createCombinedView($resources){ |
|
96 | 96 | global $modx, $_lang, $_style, $modx_textdir; |
97 | 97 | |
98 | 98 | $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
99 | 99 | $types = isset($resources->types) ? $resources->types : false; |
100 | 100 | $categories = isset($resources->categories) ? $resources->categories : false; |
101 | 101 | |
102 | - if(!$itemsPerCategory) { |
|
102 | + if (!$itemsPerCategory) { |
|
103 | 103 | return $_lang['no_results']; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $tpl = array( |
107 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
108 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
109 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
110 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'), |
|
107 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'), |
|
108 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'), |
|
109 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'), |
|
110 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl'), |
|
111 | 111 | ); |
112 | 112 | |
113 | 113 | // Easily loop through $itemsPerCategory-Array |
114 | 114 | $panelGroup = ''; |
115 | - foreach($categories as $catid => $category) { |
|
115 | + foreach ($categories as $catid => $category) { |
|
116 | 116 | // Prepare collapse content / elements-list |
117 | 117 | $panelCollapse = ''; |
118 | - foreach($itemsPerCategory[$catid] as $el) { |
|
118 | + foreach ($itemsPerCategory[$catid] as $el) { |
|
119 | 119 | $resourceTable = $el['type']; |
120 | 120 | $ph = prepareElementRowPh($el, $resourceTable, $resources); |
121 | 121 | $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
126 | 126 | 'tab' => 'categories_list', |
127 | 127 | 'category' => $categories[$catid], |
128 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '', |
|
128 | + 'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '', |
|
129 | 129 | 'catid' => $catid, |
130 | 130 | )); |
131 | 131 | |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | * @param mgrResources $resources |
150 | 150 | * @return array |
151 | 151 | */ |
152 | -function prepareElementRowPh($row, $resourceTable, $resources) { |
|
152 | +function prepareElementRowPh($row, $resourceTable, $resources){ |
|
153 | 153 | global $modx, $modx_textdir, $_style, $_lang; |
154 | 154 | |
155 | 155 | $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
156 | 156 | |
157 | 157 | $_lang["confirm_delete"] = $_lang["delete"]; |
158 | 158 | |
159 | - switch($resourceTable){ |
|
159 | + switch ($resourceTable) { |
|
160 | 160 | case 'site_templates': |
161 | 161 | $class = $row['selectable'] ? '' : 'disabledPlugin'; |
162 | 162 | $lockElementType = 1; |
@@ -193,65 +193,65 @@ discard block |
||
193 | 193 | // Prepare displaying user-locks |
194 | 194 | $lockedByUser = ''; |
195 | 195 | $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
196 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
197 | - if($rowLock['sid'] == $modx->sid) { |
|
196 | + if ($rowLock && $modx->hasPermission('display_locks')) { |
|
197 | + if ($rowLock['sid'] == $modx->sid) { |
|
198 | 198 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
199 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
199 | + 'element_type' => $_lang["lock_element_type_".$lockElementType], |
|
200 | 200 | 'lasthit_df' => $rowLock['lasthit_df'] |
201 | 201 | )); |
202 | - $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
|
202 | + $lockedByUser = '<span title="'.$title.'" class="editResource" style="cursor:context-menu;">'.$_style['tree_preview_resource'].'</span> '; |
|
203 | 203 | } else { |
204 | 204 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
205 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
205 | + 'element_type' => $_lang["lock_element_type_".$lockElementType], |
|
206 | 206 | 'username' => $rowLock['username'], |
207 | 207 | 'lasthit_df' => $rowLock['lasthit_df'] |
208 | 208 | )); |
209 | - if($modx->hasPermission('remove_locks')) { |
|
210 | - $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>'; |
|
209 | + if ($modx->hasPermission('remove_locks')) { |
|
210 | + $lockedByUser = '<a href="javascript:;" onclick="unlockElement('.$lockElementType.', '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource"><i class="'.$_style['icons_secured'].'"></i></a>'; |
|
211 | 211 | } else { |
212 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
|
212 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource" style="cursor:context-menu;"><i class="'.$_style['icons_secured'].'"></i></span>'; |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
216 | - if($lockedByUser) { |
|
217 | - $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
|
216 | + if ($lockedByUser) { |
|
217 | + $lockedByUser = '<div class="lockCell">'.$lockedByUser.'</div>'; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // Caption |
221 | - if($resourceTable == 'site_tmplvars') { |
|
222 | - $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption']; |
|
221 | + if ($resourceTable == 'site_tmplvars') { |
|
222 | + $caption = !empty($row['description']) ? ' '.$row['caption'].' <small>('.$row['description'].')</small>' : ' '.$row['caption']; |
|
223 | 223 | } else { |
224 | - $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
|
224 | + $caption = !empty($row['description']) ? ' '.$row['description'] : ''; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Special marks |
228 | 228 | $tplInfo = array(); |
229 | - if($row['locked']) { |
|
229 | + if ($row['locked']) { |
|
230 | 230 | $tplInfo[] = $_lang['locked']; |
231 | 231 | } |
232 | - if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
232 | + if ($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
233 | 233 | $tplInfo[] = $_lang['defaulttemplate_title']; |
234 | 234 | } |
235 | - $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : ''; |
|
235 | + $marks = !empty($tplInfo) ? ' <em>('.implode(', ', $tplInfo).')</em>' : ''; |
|
236 | 236 | |
237 | 237 | /* row buttons */ |
238 | 238 | $buttons = ''; |
239 | - if($modx->hasPermission($types['actions']['edit'][1])) { |
|
240 | - $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
239 | + if ($modx->hasPermission($types['actions']['edit'][1])) { |
|
240 | + $buttons .= '<li><a title="'.$_lang["edit_resource"].'" href="index.php?a='.$types['actions']['edit'][0].'&id='.$row['id'].'"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
241 | 241 | } |
242 | - if($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
243 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
242 | + if ($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
243 | + $buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_duplicate_record"].'\')" title="'.$_lang["resource_duplicate"].'" href="index.php?a='.$types['actions']['duplicate'][0].'&id='.$row['id'].'"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
244 | 244 | } |
245 | - if($modx->hasPermission($types['actions']['remove'][1])) { |
|
246 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
245 | + if ($modx->hasPermission($types['actions']['remove'][1])) { |
|
246 | + $buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_delete"].'\')" title="'.$_lang["delete"].'" href="index.php?a='.$types['actions']['remove'][0].'&id='.$row['id'].'"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
247 | 247 | } |
248 | - $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
|
248 | + $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">'.$buttons.'</ul></div>' : ''; |
|
249 | 249 | |
250 | 250 | $catid = $row['catid'] ? $row['catid'] : 0; |
251 | 251 | |
252 | 252 | // Placeholders for elements-row |
253 | 253 | return array( |
254 | - 'class' => $class ? ' class="' . $class . '"' : '', |
|
254 | + 'class' => $class ? ' class="'.$class.'"' : '', |
|
255 | 255 | 'lockedByUser' => $lockedByUser, |
256 | 256 | 'name' => $row['name'], |
257 | 257 | 'caption' => $caption, |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | * @param array $ph |
17 | 17 | * @return string |
18 | 18 | */ |
19 | -function parsePh($tpl, $ph) { |
|
19 | +function parsePh($tpl, $ph) |
|
20 | +{ |
|
20 | 21 | global $modx, $_lang; |
21 | 22 | $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
22 | 23 | return $modx->parseText($tpl, $ph); |
@@ -26,7 +27,8 @@ discard block |
||
26 | 27 | * @param string|int $cssId |
27 | 28 | * @return string |
28 | 29 | */ |
29 | -function renderViewSwitchButtons($cssId) { |
|
30 | +function renderViewSwitchButtons($cssId) |
|
31 | +{ |
|
30 | 32 | global $modx, $_lang, $tpl; |
31 | 33 | |
32 | 34 | return parsePh($tpl['viewForm'], array( |
@@ -39,19 +41,20 @@ discard block |
||
39 | 41 | * @param mgrResources $resources |
40 | 42 | * @return string |
41 | 43 | */ |
42 | -function createResourceList($resourceTable, $resources) { |
|
44 | +function createResourceList($resourceTable, $resources) |
|
45 | +{ |
|
43 | 46 | global $modx, $_lang, $_style, $modx_textdir, $tpl; |
44 | 47 | |
45 | 48 | $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
46 | 49 | |
47 | - if( ! is_array($items) || empty($items)) { |
|
50 | + if( ! is_array($items) || empty($items)) { |
|
48 | 51 | return $_lang['no_results']; |
49 | 52 | } |
50 | 53 | |
51 | 54 | // Prepare elements- and categories-list |
52 | 55 | $elements = array(); |
53 | 56 | $categories = array(); |
54 | - foreach($items as $row) { |
|
57 | + foreach($items as $row) { |
|
55 | 58 | $catid = $row['catid'] ? $row['catid'] : 0; |
56 | 59 | $categories[$catid] = array('name' => stripslashes($row['category'])); |
57 | 60 | $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
@@ -59,7 +62,7 @@ discard block |
||
59 | 62 | |
60 | 63 | // Now render categories / panel-collapse |
61 | 64 | $panelGroup = ''; |
62 | - foreach($elements as $catid => $elList) { |
|
65 | + foreach($elements as $catid => $elList) { |
|
63 | 66 | // Add panel-heading / category-collapse to output |
64 | 67 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
65 | 68 | 'tab' => $resourceTable, |
@@ -70,7 +73,7 @@ discard block |
||
70 | 73 | |
71 | 74 | // Prepare content for panel-collapse |
72 | 75 | $panelCollapse = ''; |
73 | - foreach($elList as $el) { |
|
76 | + foreach($elList as $el) { |
|
74 | 77 | $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
75 | 78 | } |
76 | 79 | |
@@ -92,14 +95,15 @@ discard block |
||
92 | 95 | * @param mgrResources $resources |
93 | 96 | * @return string |
94 | 97 | */ |
95 | -function createCombinedView($resources) { |
|
98 | +function createCombinedView($resources) |
|
99 | +{ |
|
96 | 100 | global $modx, $_lang, $_style, $modx_textdir; |
97 | 101 | |
98 | 102 | $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
99 | 103 | $types = isset($resources->types) ? $resources->types : false; |
100 | 104 | $categories = isset($resources->categories) ? $resources->categories : false; |
101 | 105 | |
102 | - if(!$itemsPerCategory) { |
|
106 | + if(!$itemsPerCategory) { |
|
103 | 107 | return $_lang['no_results']; |
104 | 108 | } |
105 | 109 | |
@@ -112,10 +116,10 @@ discard block |
||
112 | 116 | |
113 | 117 | // Easily loop through $itemsPerCategory-Array |
114 | 118 | $panelGroup = ''; |
115 | - foreach($categories as $catid => $category) { |
|
119 | + foreach($categories as $catid => $category) { |
|
116 | 120 | // Prepare collapse content / elements-list |
117 | 121 | $panelCollapse = ''; |
118 | - foreach($itemsPerCategory[$catid] as $el) { |
|
122 | + foreach($itemsPerCategory[$catid] as $el) { |
|
119 | 123 | $resourceTable = $el['type']; |
120 | 124 | $ph = prepareElementRowPh($el, $resourceTable, $resources); |
121 | 125 | $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
@@ -149,14 +153,15 @@ discard block |
||
149 | 153 | * @param mgrResources $resources |
150 | 154 | * @return array |
151 | 155 | */ |
152 | -function prepareElementRowPh($row, $resourceTable, $resources) { |
|
156 | +function prepareElementRowPh($row, $resourceTable, $resources) |
|
157 | +{ |
|
153 | 158 | global $modx, $modx_textdir, $_style, $_lang; |
154 | 159 | |
155 | 160 | $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
156 | 161 | |
157 | 162 | $_lang["confirm_delete"] = $_lang["delete"]; |
158 | 163 | |
159 | - switch($resourceTable){ |
|
164 | + switch($resourceTable) { |
|
160 | 165 | case 'site_templates': |
161 | 166 | $class = $row['selectable'] ? '' : 'disabledPlugin'; |
162 | 167 | $lockElementType = 1; |
@@ -193,56 +198,56 @@ discard block |
||
193 | 198 | // Prepare displaying user-locks |
194 | 199 | $lockedByUser = ''; |
195 | 200 | $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
196 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
197 | - if($rowLock['sid'] == $modx->sid) { |
|
201 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
202 | + if($rowLock['sid'] == $modx->sid) { |
|
198 | 203 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
199 | 204 | 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
200 | 205 | 'lasthit_df' => $rowLock['lasthit_df'] |
201 | 206 | )); |
202 | 207 | $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
203 | - } else { |
|
208 | + } else { |
|
204 | 209 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
205 | 210 | 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
206 | 211 | 'username' => $rowLock['username'], |
207 | 212 | 'lasthit_df' => $rowLock['lasthit_df'] |
208 | 213 | )); |
209 | - if($modx->hasPermission('remove_locks')) { |
|
214 | + if($modx->hasPermission('remove_locks')) { |
|
210 | 215 | $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>'; |
211 | - } else { |
|
216 | + } else { |
|
212 | 217 | $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
213 | 218 | } |
214 | 219 | } |
215 | 220 | } |
216 | - if($lockedByUser) { |
|
221 | + if($lockedByUser) { |
|
217 | 222 | $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
218 | 223 | } |
219 | 224 | |
220 | 225 | // Caption |
221 | - if($resourceTable == 'site_tmplvars') { |
|
226 | + if($resourceTable == 'site_tmplvars') { |
|
222 | 227 | $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption']; |
223 | - } else { |
|
228 | + } else { |
|
224 | 229 | $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
225 | 230 | } |
226 | 231 | |
227 | 232 | // Special marks |
228 | 233 | $tplInfo = array(); |
229 | - if($row['locked']) { |
|
234 | + if($row['locked']) { |
|
230 | 235 | $tplInfo[] = $_lang['locked']; |
231 | 236 | } |
232 | - if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
237 | + if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
233 | 238 | $tplInfo[] = $_lang['defaulttemplate_title']; |
234 | 239 | } |
235 | 240 | $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : ''; |
236 | 241 | |
237 | 242 | /* row buttons */ |
238 | 243 | $buttons = ''; |
239 | - if($modx->hasPermission($types['actions']['edit'][1])) { |
|
244 | + if($modx->hasPermission($types['actions']['edit'][1])) { |
|
240 | 245 | $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
241 | 246 | } |
242 | - if($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
247 | + if($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
243 | 248 | $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
244 | 249 | } |
245 | - if($modx->hasPermission($types['actions']['remove'][1])) { |
|
250 | + if($modx->hasPermission($types['actions']['remove'][1])) { |
|
246 | 251 | $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
247 | 252 | } |
248 | 253 | $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @var array |
9 | 9 | */ |
10 | - public $types = array(); |
|
10 | + public $types = array(); |
|
11 | 11 | /** |
12 | 12 | * @var array |
13 | 13 | */ |
@@ -25,73 +25,73 @@ discard block |
||
25 | 25 | * mgrResources constructor. |
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | - $this->setTypes(); |
|
29 | - $this->queryItemsFromDB(); |
|
30 | - $this->prepareCategoryArrays(); |
|
31 | - } |
|
28 | + $this->setTypes(); |
|
29 | + $this->queryItemsFromDB(); |
|
30 | + $this->prepareCategoryArrays(); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @return void |
35 | 35 | */ |
36 | 36 | public function setTypes() { |
37 | - global $_lang; |
|
38 | - $this->types['site_templates'] = array( |
|
39 | - 'title'=>$_lang["manage_templates"], |
|
40 | - 'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ), |
|
41 | - 'permissions'=>array('new_template','edit_template'), |
|
42 | - 'name'=>'templatename' |
|
43 | - ); |
|
44 | - $this->types['site_tmplvars'] = array( |
|
45 | - 'title'=>$_lang["tmplvars"], |
|
46 | - 'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')), |
|
47 | - 'permissions'=>array('new_template','edit_template'), |
|
48 | - ); |
|
49 | - $this->types['site_htmlsnippets'] = array( |
|
50 | - 'title'=>$_lang["manage_htmlsnippets"], |
|
51 | - 'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')), |
|
52 | - 'permissions'=>array('new_chunk','edit_chunk'), |
|
53 | - ); |
|
54 | - $this->types['site_snippets'] = array( |
|
55 | - 'title'=>$_lang["manage_snippets"], |
|
56 | - 'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')), |
|
57 | - 'permissions'=>array('new_snippet','edit_snippet'), |
|
58 | - ); |
|
59 | - $this->types['site_plugins'] = array( |
|
60 | - 'title'=>$_lang["manage_plugins"], |
|
61 | - 'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')), |
|
62 | - 'permissions'=>array('new_plugin','edit_plugin'), |
|
63 | - ); |
|
64 | - $this->types['site_modules'] = array( |
|
65 | - 'title'=>$_lang["manage_modules"], |
|
66 | - 'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')), |
|
67 | - 'permissions'=>array('new_module','edit_module'), |
|
68 | - ); |
|
69 | - } |
|
37 | + global $_lang; |
|
38 | + $this->types['site_templates'] = array( |
|
39 | + 'title'=>$_lang["manage_templates"], |
|
40 | + 'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ), |
|
41 | + 'permissions'=>array('new_template','edit_template'), |
|
42 | + 'name'=>'templatename' |
|
43 | + ); |
|
44 | + $this->types['site_tmplvars'] = array( |
|
45 | + 'title'=>$_lang["tmplvars"], |
|
46 | + 'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')), |
|
47 | + 'permissions'=>array('new_template','edit_template'), |
|
48 | + ); |
|
49 | + $this->types['site_htmlsnippets'] = array( |
|
50 | + 'title'=>$_lang["manage_htmlsnippets"], |
|
51 | + 'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')), |
|
52 | + 'permissions'=>array('new_chunk','edit_chunk'), |
|
53 | + ); |
|
54 | + $this->types['site_snippets'] = array( |
|
55 | + 'title'=>$_lang["manage_snippets"], |
|
56 | + 'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')), |
|
57 | + 'permissions'=>array('new_snippet','edit_snippet'), |
|
58 | + ); |
|
59 | + $this->types['site_plugins'] = array( |
|
60 | + 'title'=>$_lang["manage_plugins"], |
|
61 | + 'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')), |
|
62 | + 'permissions'=>array('new_plugin','edit_plugin'), |
|
63 | + ); |
|
64 | + $this->types['site_modules'] = array( |
|
65 | + 'title'=>$_lang["manage_modules"], |
|
66 | + 'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')), |
|
67 | + 'permissions'=>array('new_module','edit_module'), |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @return void |
73 | 73 | */ |
74 | 74 | public function queryItemsFromDB() { |
75 | - foreach($this->types as $resourceTable=>$type) { |
|
76 | - if($this->hasAnyPermissions($type['permissions'])) { |
|
77 | - $nameField = isset($type['name']) ? $type['name'] : 'name'; |
|
78 | - $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
75 | + foreach($this->types as $resourceTable=>$type) { |
|
76 | + if($this->hasAnyPermissions($type['permissions'])) { |
|
77 | + $nameField = isset($type['name']) ? $type['name'] : 'name'; |
|
78 | + $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @param array $permissions |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | 87 | public function hasAnyPermissions($permissions) { |
88 | - global $modx; |
|
88 | + global $modx; |
|
89 | 89 | |
90 | - foreach($permissions as $p) |
|
91 | - if($modx->hasPermission($p)) return true; |
|
90 | + foreach($permissions as $p) |
|
91 | + if($modx->hasPermission($p)) return true; |
|
92 | 92 | |
93 | - return false; |
|
94 | - } |
|
93 | + return false; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @param string $resourceTable |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return array|bool |
100 | 100 | */ |
101 | 101 | public function queryResources($resourceTable, $nameField = 'name') { |
102 | - global $modx, $_lang; |
|
102 | + global $modx, $_lang; |
|
103 | 103 | |
104 | 104 | $allowed = array( |
105 | 105 | 'site_htmlsnippets', |
@@ -107,59 +107,59 @@ discard block |
||
107 | 107 | 'site_plugins', |
108 | 108 | 'site_modules' |
109 | 109 | ); |
110 | - $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : ''; |
|
111 | - |
|
112 | - $tvsql = ''; |
|
113 | - $tvjoin = ''; |
|
114 | - if ($resourceTable === 'site_tmplvars') { |
|
115 | - $tvsql = 'site_tmplvars.caption, '; |
|
116 | - $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
|
117 | - $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
|
118 | - } |
|
119 | - else $sttfield = ''; |
|
120 | - |
|
121 | - $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
|
122 | - |
|
123 | - $rs = $modx->db->select( |
|
124 | - "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid", |
|
125 | - $modx->getFullTableName($resourceTable) . " AS {$resourceTable} |
|
110 | + $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : ''; |
|
111 | + |
|
112 | + $tvsql = ''; |
|
113 | + $tvjoin = ''; |
|
114 | + if ($resourceTable === 'site_tmplvars') { |
|
115 | + $tvsql = 'site_tmplvars.caption, '; |
|
116 | + $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
|
117 | + $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
|
118 | + } |
|
119 | + else $sttfield = ''; |
|
120 | + |
|
121 | + $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
|
122 | + |
|
123 | + $rs = $modx->db->select( |
|
124 | + "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid", |
|
125 | + $modx->getFullTableName($resourceTable) . " AS {$resourceTable} |
|
126 | 126 | LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
127 | - "", |
|
128 | - "category,name" |
|
129 | - ); |
|
130 | - $limit = $modx->db->getRecordCount($rs); |
|
127 | + "", |
|
128 | + "category,name" |
|
129 | + ); |
|
130 | + $limit = $modx->db->getRecordCount($rs); |
|
131 | 131 | |
132 | - if($limit < 1) return false; |
|
132 | + if($limit < 1) return false; |
|
133 | 133 | |
134 | - $result = array(); |
|
135 | - while ($row = $modx->db->getRow($rs)) { |
|
136 | - $result[] = $row; |
|
137 | - } |
|
138 | - return $result; |
|
139 | - } |
|
134 | + $result = array(); |
|
135 | + while ($row = $modx->db->getRow($rs)) { |
|
136 | + $result[] = $row; |
|
137 | + } |
|
138 | + return $result; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * @return void |
143 | 143 | */ |
144 | 144 | public function prepareCategoryArrays() { |
145 | - foreach($this->items as $type=>$items) { |
|
146 | - foreach((array)$items as $item) { |
|
147 | - $catid = $item['catid'] ? $item['catid'] : 0; |
|
148 | - $this->categories[$catid] = $item['category']; |
|
149 | - |
|
150 | - $item['type'] = $type; |
|
151 | - $this->itemsPerCategory[$catid][] = $item; |
|
152 | - } |
|
153 | - } |
|
154 | - |
|
155 | - // Sort categories by name |
|
156 | - natcasesort($this->categories); |
|
157 | - |
|
158 | - // Now sort by name |
|
159 | - foreach($this->itemsPerCategory as $catid=>$items) { |
|
160 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
161 | - return strcasecmp($a['name'], $b['name']); |
|
162 | - }); |
|
163 | - } |
|
164 | - } |
|
145 | + foreach($this->items as $type=>$items) { |
|
146 | + foreach((array)$items as $item) { |
|
147 | + $catid = $item['catid'] ? $item['catid'] : 0; |
|
148 | + $this->categories[$catid] = $item['category']; |
|
149 | + |
|
150 | + $item['type'] = $type; |
|
151 | + $this->itemsPerCategory[$catid][] = $item; |
|
152 | + } |
|
153 | + } |
|
154 | + |
|
155 | + // Sort categories by name |
|
156 | + natcasesort($this->categories); |
|
157 | + |
|
158 | + // Now sort by name |
|
159 | + foreach($this->itemsPerCategory as $catid=>$items) { |
|
160 | + usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
161 | + return strcasecmp($a['name'], $b['name']); |
|
162 | + }); |
|
163 | + } |
|
164 | + } |
|
165 | 165 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | -class mgrResources { |
|
6 | +class mgrResources{ |
|
7 | 7 | /** |
8 | 8 | * @var array |
9 | 9 | */ |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * mgrResources constructor. |
26 | 26 | */ |
27 | - public function __construct() { |
|
27 | + public function __construct(){ |
|
28 | 28 | $this->setTypes(); |
29 | 29 | $this->queryItemsFromDB(); |
30 | 30 | $this->prepareCategoryArrays(); |
@@ -33,47 +33,47 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - public function setTypes() { |
|
36 | + public function setTypes(){ |
|
37 | 37 | global $_lang; |
38 | - $this->types['site_templates'] = array( |
|
38 | + $this->types['site_templates'] = array( |
|
39 | 39 | 'title'=>$_lang["manage_templates"], |
40 | - 'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ), |
|
41 | - 'permissions'=>array('new_template','edit_template'), |
|
40 | + 'actions'=>array('edit'=>array(16, 'edit_template'), 'duplicate'=>array(96, 'new_template'), 'remove'=>array(21, 'delete_template')), |
|
41 | + 'permissions'=>array('new_template', 'edit_template'), |
|
42 | 42 | 'name'=>'templatename' |
43 | 43 | ); |
44 | - $this->types['site_tmplvars'] = array( |
|
44 | + $this->types['site_tmplvars'] = array( |
|
45 | 45 | 'title'=>$_lang["tmplvars"], |
46 | - 'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')), |
|
47 | - 'permissions'=>array('new_template','edit_template'), |
|
46 | + 'actions'=>array('edit'=>array(301, 'edit_template'), 'duplicate'=>array(304, 'edit_template'), 'remove'=>array(303, 'edit_template')), |
|
47 | + 'permissions'=>array('new_template', 'edit_template'), |
|
48 | 48 | ); |
49 | 49 | $this->types['site_htmlsnippets'] = array( |
50 | 50 | 'title'=>$_lang["manage_htmlsnippets"], |
51 | - 'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')), |
|
52 | - 'permissions'=>array('new_chunk','edit_chunk'), |
|
51 | + 'actions'=>array('edit'=>array(78, 'edit_chunk'), 'duplicate'=>array(97, 'new_chunk'), 'remove'=>array(80, 'delete_chunk')), |
|
52 | + 'permissions'=>array('new_chunk', 'edit_chunk'), |
|
53 | 53 | ); |
54 | - $this->types['site_snippets'] = array( |
|
54 | + $this->types['site_snippets'] = array( |
|
55 | 55 | 'title'=>$_lang["manage_snippets"], |
56 | - 'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')), |
|
57 | - 'permissions'=>array('new_snippet','edit_snippet'), |
|
56 | + 'actions'=>array('edit'=>array(22, 'edit_snippet'), 'duplicate'=>array(98, 'new_snippet'), 'remove'=>array(25, 'delete_snippet')), |
|
57 | + 'permissions'=>array('new_snippet', 'edit_snippet'), |
|
58 | 58 | ); |
59 | - $this->types['site_plugins'] = array( |
|
59 | + $this->types['site_plugins'] = array( |
|
60 | 60 | 'title'=>$_lang["manage_plugins"], |
61 | - 'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')), |
|
62 | - 'permissions'=>array('new_plugin','edit_plugin'), |
|
61 | + 'actions'=>array('edit'=>array(102, 'edit_plugin'), 'duplicate'=>array(105, 'new_plugin'), 'remove'=>array(104, 'delete_plugin')), |
|
62 | + 'permissions'=>array('new_plugin', 'edit_plugin'), |
|
63 | 63 | ); |
64 | - $this->types['site_modules'] = array( |
|
64 | + $this->types['site_modules'] = array( |
|
65 | 65 | 'title'=>$_lang["manage_modules"], |
66 | - 'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')), |
|
67 | - 'permissions'=>array('new_module','edit_module'), |
|
66 | + 'actions'=>array('edit'=>array(108, 'edit_module'), 'duplicate'=>array(111, 'new_module'), 'remove'=>array(110, 'delete_module')), |
|
67 | + 'permissions'=>array('new_module', 'edit_module'), |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @return void |
73 | 73 | */ |
74 | - public function queryItemsFromDB() { |
|
75 | - foreach($this->types as $resourceTable=>$type) { |
|
76 | - if($this->hasAnyPermissions($type['permissions'])) { |
|
74 | + public function queryItemsFromDB(){ |
|
75 | + foreach ($this->types as $resourceTable=>$type) { |
|
76 | + if ($this->hasAnyPermissions($type['permissions'])) { |
|
77 | 77 | $nameField = isset($type['name']) ? $type['name'] : 'name'; |
78 | 78 | $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField); |
79 | 79 | } |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | * @param array $permissions |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function hasAnyPermissions($permissions) { |
|
87 | + public function hasAnyPermissions($permissions){ |
|
88 | 88 | global $modx; |
89 | 89 | |
90 | - foreach($permissions as $p) |
|
91 | - if($modx->hasPermission($p)) return true; |
|
90 | + foreach ($permissions as $p) |
|
91 | + if ($modx->hasPermission($p)) return true; |
|
92 | 92 | |
93 | 93 | return false; |
94 | 94 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param string $nameField |
99 | 99 | * @return array|bool |
100 | 100 | */ |
101 | - public function queryResources($resourceTable, $nameField = 'name') { |
|
101 | + public function queryResources($resourceTable, $nameField = 'name'){ |
|
102 | 102 | global $modx, $_lang; |
103 | 103 | |
104 | 104 | $allowed = array( |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'site_plugins', |
108 | 108 | 'site_modules' |
109 | 109 | ); |
110 | - $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : ''; |
|
110 | + $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable.'.disabled, ' : ''; |
|
111 | 111 | |
112 | 112 | $tvsql = ''; |
113 | 113 | $tvjoin = ''; |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | |
123 | 123 | $rs = $modx->db->select( |
124 | 124 | "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid", |
125 | - $modx->getFullTableName($resourceTable) . " AS {$resourceTable} |
|
126 | - LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
|
125 | + $modx->getFullTableName($resourceTable)." AS {$resourceTable} |
|
126 | + LEFT JOIN ".$modx->getFullTableName('categories')." AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
|
127 | 127 | "", |
128 | 128 | "category,name" |
129 | 129 | ); |
130 | 130 | $limit = $modx->db->getRecordCount($rs); |
131 | 131 | |
132 | - if($limit < 1) return false; |
|
132 | + if ($limit < 1) return false; |
|
133 | 133 | |
134 | 134 | $result = array(); |
135 | 135 | while ($row = $modx->db->getRow($rs)) { |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * @return void |
143 | 143 | */ |
144 | - public function prepareCategoryArrays() { |
|
145 | - foreach($this->items as $type=>$items) { |
|
146 | - foreach((array)$items as $item) { |
|
144 | + public function prepareCategoryArrays(){ |
|
145 | + foreach ($this->items as $type=>$items) { |
|
146 | + foreach ((array) $items as $item) { |
|
147 | 147 | $catid = $item['catid'] ? $item['catid'] : 0; |
148 | 148 | $this->categories[$catid] = $item['category']; |
149 | 149 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | natcasesort($this->categories); |
157 | 157 | |
158 | 158 | // Now sort by name |
159 | - foreach($this->itemsPerCategory as $catid=>$items) { |
|
160 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
159 | + foreach ($this->itemsPerCategory as $catid=>$items) { |
|
160 | + usort($this->itemsPerCategory[$catid], function($a, $b){ |
|
161 | 161 | return strcasecmp($a['name'], $b['name']); |
162 | 162 | }); |
163 | 163 | } |
@@ -3,7 +3,8 @@ discard block |
||
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | |
6 | -class mgrResources { |
|
6 | +class mgrResources |
|
7 | +{ |
|
7 | 8 | /** |
8 | 9 | * @var array |
9 | 10 | */ |
@@ -24,7 +25,8 @@ discard block |
||
24 | 25 | /** |
25 | 26 | * mgrResources constructor. |
26 | 27 | */ |
27 | - public function __construct() { |
|
28 | + public function __construct() |
|
29 | + { |
|
28 | 30 | $this->setTypes(); |
29 | 31 | $this->queryItemsFromDB(); |
30 | 32 | $this->prepareCategoryArrays(); |
@@ -33,7 +35,8 @@ discard block |
||
33 | 35 | /** |
34 | 36 | * @return void |
35 | 37 | */ |
36 | - public function setTypes() { |
|
38 | + public function setTypes() |
|
39 | + { |
|
37 | 40 | global $_lang; |
38 | 41 | $this->types['site_templates'] = array( |
39 | 42 | 'title'=>$_lang["manage_templates"], |
@@ -71,7 +74,8 @@ discard block |
||
71 | 74 | /** |
72 | 75 | * @return void |
73 | 76 | */ |
74 | - public function queryItemsFromDB() { |
|
77 | + public function queryItemsFromDB() |
|
78 | + { |
|
75 | 79 | foreach($this->types as $resourceTable=>$type) { |
76 | 80 | if($this->hasAnyPermissions($type['permissions'])) { |
77 | 81 | $nameField = isset($type['name']) ? $type['name'] : 'name'; |
@@ -84,11 +88,13 @@ discard block |
||
84 | 88 | * @param array $permissions |
85 | 89 | * @return bool |
86 | 90 | */ |
87 | - public function hasAnyPermissions($permissions) { |
|
91 | + public function hasAnyPermissions($permissions) |
|
92 | + { |
|
88 | 93 | global $modx; |
89 | 94 | |
90 | - foreach($permissions as $p) |
|
91 | - if($modx->hasPermission($p)) return true; |
|
95 | + foreach($permissions as $p) { |
|
96 | + if($modx->hasPermission($p)) return true; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | return false; |
94 | 100 | } |
@@ -98,7 +104,8 @@ discard block |
||
98 | 104 | * @param string $nameField |
99 | 105 | * @return array|bool |
100 | 106 | */ |
101 | - public function queryResources($resourceTable, $nameField = 'name') { |
|
107 | + public function queryResources($resourceTable, $nameField = 'name') |
|
108 | + { |
|
102 | 109 | global $modx, $_lang; |
103 | 110 | |
104 | 111 | $allowed = array( |
@@ -115,8 +122,9 @@ discard block |
||
115 | 122 | $tvsql = 'site_tmplvars.caption, '; |
116 | 123 | $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
117 | 124 | $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
125 | + } else { |
|
126 | + $sttfield = ''; |
|
118 | 127 | } |
119 | - else $sttfield = ''; |
|
120 | 128 | |
121 | 129 | $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
122 | 130 | |
@@ -129,7 +137,9 @@ discard block |
||
129 | 137 | ); |
130 | 138 | $limit = $modx->db->getRecordCount($rs); |
131 | 139 | |
132 | - if($limit < 1) return false; |
|
140 | + if($limit < 1) { |
|
141 | + return false; |
|
142 | + } |
|
133 | 143 | |
134 | 144 | $result = array(); |
135 | 145 | while ($row = $modx->db->getRow($rs)) { |
@@ -141,7 +151,8 @@ discard block |
||
141 | 151 | /** |
142 | 152 | * @return void |
143 | 153 | */ |
144 | - public function prepareCategoryArrays() { |
|
154 | + public function prepareCategoryArrays() |
|
155 | + { |
|
145 | 156 | foreach($this->items as $type=>$items) { |
146 | 157 | foreach((array)$items as $item) { |
147 | 158 | $catid = $item['catid'] ? $item['catid'] : 0; |
@@ -157,7 +168,7 @@ discard block |
||
157 | 168 | |
158 | 169 | // Now sort by name |
159 | 170 | foreach($this->itemsPerCategory as $catid=>$items) { |
160 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
171 | + usort($this->itemsPerCategory[$catid], function ($a, $b){ |
|
161 | 172 | return strcasecmp($a['name'], $b['name']); |
162 | 173 | }); |
163 | 174 | } |