@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Created by Raymond Irving Feb, 2005 |
5 | 5 | */ |
6 | 6 | global $BINDINGS; // Array of supported bindings. must be upper case |
7 | -$BINDINGS = array ( |
|
7 | +$BINDINGS = array( |
|
8 | 8 | 'FILE', |
9 | 9 | 'CHUNK', |
10 | 10 | 'DOCUMENT', |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * @param array $tvsArray |
23 | 23 | * @return string |
24 | 24 | */ |
25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src = 'docform', $tvsArray = array()){ |
|
26 | 26 | $modx = evolutionCMS(); |
27 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
27 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
28 | 28 | $nvalue = trim($value); |
29 | 29 | if (substr($nvalue, 0, 1) != '@') |
30 | 30 | return $value; |
31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
31 | + elseif (isset($modx->config['enable_bindings']) && $modx->config['enable_bindings'] != 1 && $src === 'docform') { |
|
32 | 32 | return '@Bindings is disabled.'; |
33 | 33 | } |
34 | 34 | else { |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | break; |
55 | 55 | |
56 | 56 | case "SELECT" : // selects a record from the cms database |
57 | - $rt = array (); |
|
58 | - $replacementVars = array ( |
|
57 | + $rt = array(); |
|
58 | + $replacementVars = array( |
|
59 | 59 | 'DBASE' => $modx->db->config['dbase'], |
60 | 60 | 'PREFIX' => $modx->db->config['table_prefix'] |
61 | 61 | ); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | break; |
97 | 97 | |
98 | 98 | case 'DIRECTORY' : |
99 | - $files = array (); |
|
100 | - $path = $modx->config['base_path'] . $param; |
|
99 | + $files = array(); |
|
100 | + $path = $modx->config['base_path'].$param; |
|
101 | 101 | if (substr($path, -1, 1) != '/') { |
102 | 102 | $path .= '/'; |
103 | 103 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param $file |
130 | 130 | * @return string |
131 | 131 | */ |
132 | -function ProcessFile($file) { |
|
132 | +function ProcessFile($file){ |
|
133 | 133 | // get the file |
134 | 134 | $buffer = @file_get_contents($file); |
135 | 135 | if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | { |
147 | 147 | global $BINDINGS; |
148 | 148 | $binding_array = array(); |
149 | - foreach($BINDINGS as $cmd) |
|
149 | + foreach ($BINDINGS as $cmd) |
|
150 | 150 | { |
151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
151 | + if (strpos($binding_string, '@'.$cmd) === 0) |
|
152 | 152 | { |
153 | - $code = substr($binding_string,strlen($cmd)+1); |
|
154 | - $binding_array = array($cmd,trim($code)); |
|
153 | + $code = substr($binding_string, strlen($cmd) + 1); |
|
154 | + $binding_array = array($cmd, trim($code)); |
|
155 | 155 | break; |
156 | 156 | } |
157 | 157 | } |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | if (strpos($param, '[*') !== false) { |
173 | 173 | $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
174 | 174 | foreach ($matches[0] as $i=>$match) { |
175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
175 | + if (isset($tvsArray[$matches[1][$i]])) { |
|
176 | + if (is_array($tvsArray[$matches[1][$i]])) { |
|
177 | 177 | $value = $tvsArray[$matches[1][$i]]['value']; |
178 | 178 | $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
179 | 179 | } else { |
180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
180 | + $value = $tvsArray[$matches[1][$i]]; |
|
181 | 181 | } |
182 | 182 | $param = str_replace($match, $value, $param); |
183 | 183 | } |
@@ -7,53 +7,53 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -Class TemplateParser { |
|
10 | +Class TemplateParser{ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param array $config [action, tabs, toArray] |
14 | 14 | * @param array $data |
15 | 15 | * @return string |
16 | 16 | */ |
17 | - public function output($config = array(), $data = array()) { |
|
17 | + public function output($config = array(), $data = array()){ |
|
18 | 18 | $modx = evolutionCMS(); |
19 | 19 | |
20 | 20 | $output = ''; |
21 | 21 | $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
22 | - $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : ''; |
|
22 | + $tab = isset($config['tab']) ? ' AND tab IN('.$config['tab'].')' : ''; |
|
23 | 23 | |
24 | - if($action) { |
|
24 | + if ($action) { |
|
25 | 25 | $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name |
26 | - FROM ' . $modx->getFullTableName('system_templates') . ' AS t1 |
|
27 | - INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category |
|
28 | - WHERE t1.action IN(' . $action . ') ' . $tab . ' |
|
26 | + FROM ' . $modx->getFullTableName('system_templates').' AS t1 |
|
27 | + INNER JOIN ' . $modx->getFullTableName('categories').' AS t2 ON t2.id=t1.category |
|
28 | + WHERE t1.action IN(' . $action.') '.$tab.' |
|
29 | 29 | ORDER BY t1.tab ASC, t1.rank ASC'); |
30 | 30 | |
31 | - if($modx->db->getRecordCount($sql)) { |
|
31 | + if ($modx->db->getRecordCount($sql)) { |
|
32 | 32 | $tabs = array(); |
33 | - while($row = $modx->db->getRow($sql)) { |
|
34 | - if(!$row['value'] && !empty($data[$row['name']])) { |
|
33 | + while ($row = $modx->db->getRow($sql)) { |
|
34 | + if (!$row['value'] && !empty($data[$row['name']])) { |
|
35 | 35 | $row['value'] = $data[$row['name']]; |
36 | 36 | } |
37 | 37 | $tabs[$row['tab']]['category_name'] = $row['category_name']; |
38 | 38 | $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
39 | 39 | } |
40 | 40 | |
41 | - if(!empty($config['toArray'])) { |
|
41 | + if (!empty($config['toArray'])) { |
|
42 | 42 | $output = $tabs; |
43 | 43 | } else { |
44 | - $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
44 | + $output .= '<div class="tab-pane" id="pane_'.$action.'">'; |
|
45 | 45 | $output .= ' |
46 | 46 | <script type="text/javascript"> |
47 | - var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
|
47 | + var pane_' . $action.' = new WebFXTabPane(document.getElementById("pane_'.$action.'"), '.($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').'); |
|
48 | 48 | </script>'; |
49 | 49 | |
50 | - foreach($tabs as $idTab => $tab) { |
|
51 | - $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
50 | + foreach ($tabs as $idTab => $tab) { |
|
51 | + $output .= '<div class="tab-page" id="tab_'.$action.'_'.$idTab.'">'; |
|
52 | 52 | $output .= ' |
53 | - <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
|
54 | - <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>'; |
|
53 | + <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']).'</h2> |
|
54 | + <script type="text/javascript">pane_' . $action.'.addTabPage(document.getElementById("tab_'.$action.'_'.$idTab.'"));</script>'; |
|
55 | 55 | unset($tab['category_name']); |
56 | - foreach($tab as $item) { |
|
56 | + foreach ($tab as $item) { |
|
57 | 57 | $output .= $item; |
58 | 58 | } |
59 | 59 | $output .= '</div>'; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param array $data |
71 | 71 | * @return string |
72 | 72 | */ |
73 | - private function render($data) { |
|
73 | + private function render($data){ |
|
74 | 74 | $modx = evolutionCMS(); global $_lang, $_country_lang; |
75 | 75 | |
76 | 76 | $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $output = ''; |
81 | 81 | $output .= '<div class="form-group row">'; |
82 | 82 | |
83 | - switch($data['type']) { |
|
83 | + switch ($data['type']) { |
|
84 | 84 | |
85 | 85 | case 'text': |
86 | 86 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
115 | 115 | $output .= '<div class="col-sm-7">'; |
116 | 116 | $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
117 | - if($data['name'] == 'country' && isset($_country_lang)) { |
|
117 | + if ($data['name'] == 'country' && isset($_country_lang)) { |
|
118 | 118 | $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
119 | - $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
120 | - foreach($_country_lang as $key => $value) { |
|
121 | - $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
119 | + $output .= '<option value=""'.(!isset($chosenCountry) ? ' selected' : '').'> </option>'; |
|
120 | + foreach ($_country_lang as $key => $value) { |
|
121 | + $output .= '<option value="'.$key.'"'.(isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '').'>'.$value.'</option>'; |
|
122 | 122 | } |
123 | 123 | } else { |
124 | - if($data['elements']) { |
|
124 | + if ($data['elements']) { |
|
125 | 125 | $elements = explode('||', $data['elements']); |
126 | - foreach($elements as $key => $value) { |
|
126 | + foreach ($elements as $key => $value) { |
|
127 | 127 | $value = explode('==', $value); |
128 | - $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
128 | + $output .= '<option value="'.$value[1].'">'.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]).'</option>'; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
140 | 140 | $output .= '<div class="col-sm-7">'; |
141 | 141 | $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
142 | - if($data['elements']) { |
|
142 | + if ($data['elements']) { |
|
143 | 143 | $elements = explode('||', $data['elements']); |
144 | - foreach($elements as $key => $value) { |
|
144 | + foreach ($elements as $key => $value) { |
|
145 | 145 | $value = explode('==', $value); |
146 | - $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
146 | + $output .= '<br /><input type="checkbox" name="'.$value[0].'" class="form-control" id="'.$value[0].'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | $output .= $data['content']; |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
156 | 156 | $output .= '<div class="col-sm-7">'; |
157 | 157 | $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
158 | - if($data['elements']) { |
|
158 | + if ($data['elements']) { |
|
159 | 159 | $elements = explode('||', $data['elements']); |
160 | - foreach($elements as $key => $value) { |
|
160 | + foreach ($elements as $key => $value) { |
|
161 | 161 | $value = explode('==', $value); |
162 | - $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
162 | + $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_'.$key.'" value="'.$value[1].'" onChange="documentDirty=true;"[+readonly+] /> '.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | $output .= $data['content']; |
@@ -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 | $modx = evolutionCMS(); |
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 | $modx = evolutionCMS(); |
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; |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class DATEPICKER { |
|
4 | - function __construct() { |
|
3 | +class DATEPICKER{ |
|
4 | + function __construct(){ |
|
5 | 5 | } |
6 | 6 | |
7 | - function getDP() { |
|
7 | + function getDP(){ |
|
8 | 8 | $modx = evolutionCMS(); global $_lang; |
9 | 9 | |
10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
10 | + $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
|
11 | 11 | return $modx->parseText($tpl, $_lang, '[%', '%]'); |
12 | 12 | } |
13 | 13 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | -class DATEPICKER { |
|
3 | - function __construct() { |
|
2 | +class DATEPICKER{ |
|
3 | + function __construct(){ |
|
4 | 4 | } |
5 | - function getDP() { |
|
5 | + function getDP(){ |
|
6 | 6 | $modx = evolutionCMS(); global$_lang; |
7 | 7 | |
8 | 8 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
9 | - return $modx->parseText($tpl,$_lang,'[%','%]'); |
|
9 | + return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
10 | 10 | } |
11 | 11 | } |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | -class DATEPICKER { |
|
2 | +class DATEPICKER{ |
|
3 | 3 | /** |
4 | 4 | * @return string |
5 | 5 | */ |
6 | - public function getDP() { |
|
6 | + public function getDP(){ |
|
7 | 7 | $modx = evolutionCMS(); |
8 | 8 | |
9 | 9 | $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
10 | - if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
10 | + if (!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode(); |
|
11 | 11 | $modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy'; |
12 | 12 | return $modx->mergeSettingsContent($load_script); |
13 | 13 | } |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - public function getLangCode() { |
|
18 | + public function getLangCode(){ |
|
19 | 19 | $modx = evolutionCMS(); global $modx_lang_attribute; |
20 | 20 | |
21 | - if(!$modx_lang_attribute) return 'en'; |
|
21 | + if (!$modx_lang_attribute) return 'en'; |
|
22 | 22 | |
23 | 23 | $lc = $modx_lang_attribute; |
24 | - if($lc === 'uk') return 'ru'; |
|
25 | - $dp_path = str_replace('\\','/',dirname(__FILE__)); |
|
24 | + if ($lc === 'uk') return 'ru'; |
|
25 | + $dp_path = str_replace('\\', '/', dirname(__FILE__)); |
|
26 | 26 | |
27 | 27 | return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en'; |
28 | 28 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class uploader { |
|
15 | +class uploader{ |
|
16 | 16 | |
17 | 17 | /** Release version */ |
18 | 18 | const VERSION = "2.54"; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | |
73 | 73 | /** Next three properties are got from the current language file |
74 | 74 | * @var string */ |
75 | - protected $dateTimeFull; // Currently not used |
|
76 | - protected $dateTimeMid; // Currently not used |
|
75 | + protected $dateTimeFull; // Currently not used |
|
76 | + protected $dateTimeMid; // Currently not used |
|
77 | 77 | protected $dateTimeSmall; |
78 | 78 | |
79 | 79 | /** Contain Specified language labels |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | /** Magic method which allows read-only access to protected or private class properties |
105 | 105 | * @param string $property |
106 | 106 | * @return mixed */ |
107 | - public function __get($property) { |
|
107 | + public function __get($property){ |
|
108 | 108 | return property_exists($this, $property) ? $this->$property : null; |
109 | 109 | } |
110 | 110 | |
111 | - public function __construct($modx) { |
|
111 | + public function __construct($modx){ |
|
112 | 112 | |
113 | 113 | //MODX |
114 | 114 | try { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | // COOKIES INIT |
208 | 208 | $ip = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; |
209 | - $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/'; |
|
209 | + $ip = '/^'.implode('\.', array($ip, $ip, $ip, $ip)).'$/'; |
|
210 | 210 | if (preg_match($ip, $_SERVER['HTTP_HOST']) || |
211 | 211 | preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST']) |
212 | 212 | ) |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | ) { |
225 | 225 | list($unused, $protocol, $domain, $unused, $port, $path) = $patt; |
226 | 226 | $path = path::normalize($path); |
227 | - $this->config['uploadURL'] = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/$path"; |
|
227 | + $this->config['uploadURL'] = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/$path"; |
|
228 | 228 | $this->config['uploadDir'] = strlen($this->config['uploadDir']) |
229 | 229 | ? path::normalize($this->config['uploadDir']) |
230 | 230 | : path::url2fullPath("/$path"); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | foreach ($this->langInputNames as $key) |
268 | 268 | if (isset($this->get[$key]) && |
269 | 269 | preg_match('/^[a-z][a-z\._\-]*$/i', $this->get[$key]) && |
270 | - file_exists("lang/" . strtolower($this->get[$key]) . ".php") |
|
270 | + file_exists("lang/".strtolower($this->get[$key]).".php") |
|
271 | 271 | ) { |
272 | 272 | $this->lang = $this->get[$key]; |
273 | 273 | break; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $this->backMsg("Cannot read upload folder."); |
299 | 299 | } |
300 | 300 | |
301 | - public function upload() { |
|
301 | + public function upload(){ |
|
302 | 302 | $config = &$this->config; |
303 | 303 | $file = &$this->file; |
304 | 304 | $url = $message = ""; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | @mkdir(path::normalize($dir), $this->config['dirPerms'], true); |
330 | 330 | |
331 | 331 | $filename = $this->normalizeFilename($file['name']); |
332 | - $target = file::getInexistantFilename($dir . $filename); |
|
332 | + $target = file::getInexistantFilename($dir.$filename); |
|
333 | 333 | |
334 | 334 | if (!@move_uploaded_file($file['tmp_name'], $target) && |
335 | 335 | !@rename($file['tmp_name'], $target) && |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | $this->makeThumb($target); |
343 | 343 | $url = $this->typeURL; |
344 | 344 | if (isset($udir)) $url .= "/$udir"; |
345 | - $url .= "/" . basename($target); |
|
345 | + $url .= "/".basename($target); |
|
346 | 346 | if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/', $url, $patt)) { |
347 | 347 | list($unused, $protocol, $domain, $unused, $port, $path) = $patt; |
348 | - $base = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/"; |
|
349 | - $url = $base . path::urlPathEncode($path); |
|
348 | + $base = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/"; |
|
349 | + $url = $base.path::urlPathEncode($path); |
|
350 | 350 | } else |
351 | 351 | $url = path::urlPathEncode($url); |
352 | 352 | } |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | - protected function getTransaliasSettings() { |
|
368 | + protected function getTransaliasSettings(){ |
|
369 | 369 | $modx = evolutionCMS(); |
370 | 370 | |
371 | 371 | // Cleaning uploaded filename? |
372 | 372 | $setting = $modx->db->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1'); |
373 | - if ($modx->db->getValue($setting)>0) { |
|
373 | + if ($modx->db->getValue($setting) > 0) { |
|
374 | 374 | // Transalias plugin active? |
375 | 375 | $res = $modx->db->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0'); |
376 | 376 | if ($properties = $modx->db->getValue($res)) { |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | |
388 | - protected function normalizeFilename($filename) { |
|
388 | + protected function normalizeFilename($filename){ |
|
389 | 389 | if ($this->getTransaliasSettings()) { |
390 | 390 | $format = strrchr($filename, "."); |
391 | 391 | $filename = str_replace($format, "", $filename); |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | return $filename; |
395 | 395 | } |
396 | 396 | |
397 | - protected function normalizeDirname($dirname) { |
|
397 | + protected function normalizeDirname($dirname){ |
|
398 | 398 | return $this->modx->stripAlias($dirname); |
399 | 399 | } |
400 | 400 | |
401 | - protected function checkUploadedFile(array $aFile=null) { |
|
401 | + protected function checkUploadedFile(array $aFile = null){ |
|
402 | 402 | $config = &$this->config; |
403 | 403 | $file = ($aFile === null) ? $this->file : $aFile; |
404 | 404 | |
@@ -437,8 +437,7 @@ discard block |
||
437 | 437 | ($file['error'] == UPLOAD_ERR_NO_TMP_DIR) ? |
438 | 438 | $this->label("Missing a temporary folder.") : ( |
439 | 439 | ($file['error'] == UPLOAD_ERR_CANT_WRITE) ? |
440 | - $this->label("Failed to write file.") : |
|
441 | - $this->label("Unknown error.") |
|
440 | + $this->label("Failed to write file.") : $this->label("Unknown error.") |
|
442 | 441 | ))))); |
443 | 442 | |
444 | 443 | // HIDDEN FILENAMES CHECK |
@@ -473,14 +472,14 @@ discard block |
||
473 | 472 | |
474 | 473 | |
475 | 474 | // CHECK FOR MODX MAX FILE SIZE |
476 | - $actualfilesize=filesize($file['tmp_name']); |
|
475 | + $actualfilesize = filesize($file['tmp_name']); |
|
477 | 476 | if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) |
478 | 477 | return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)"); |
479 | 478 | |
480 | 479 | return true; |
481 | 480 | } |
482 | 481 | |
483 | - protected function checkInputDir($dir, $inclType=true, $existing=true) { |
|
482 | + protected function checkInputDir($dir, $inclType = true, $existing = true){ |
|
484 | 483 | $dir = path::normalize($dir); |
485 | 484 | if (substr($dir, 0, 1) == "/") |
486 | 485 | $dir = substr($dir, 1); |
@@ -506,7 +505,7 @@ discard block |
||
506 | 505 | return (is_dir($path) && is_readable($path)) ? $return : false; |
507 | 506 | } |
508 | 507 | |
509 | - protected function validateExtension($ext, $type) { |
|
508 | + protected function validateExtension($ext, $type){ |
|
510 | 509 | $ext = trim(strtolower($ext)); |
511 | 510 | if (!isset($this->types[$type])) |
512 | 511 | return false; |
@@ -531,17 +530,17 @@ discard block |
||
531 | 530 | return in_array($ext, $exts); |
532 | 531 | } |
533 | 532 | |
534 | - protected function getTypeFromPath($path) { |
|
533 | + protected function getTypeFromPath($path){ |
|
535 | 534 | return preg_match('/^([^\/]*)\/.*$/', $path, $patt) |
536 | 535 | ? $patt[1] : $path; |
537 | 536 | } |
538 | 537 | |
539 | - protected function removeTypeFromPath($path) { |
|
538 | + protected function removeTypeFromPath($path){ |
|
540 | 539 | return preg_match('/^[^\/]*\/(.*)$/', $path, $patt) |
541 | 540 | ? $patt[1] : ""; |
542 | 541 | } |
543 | 542 | |
544 | - protected function imageResize($image, $file=null) { |
|
543 | + protected function imageResize($image, $file = null){ |
|
545 | 544 | |
546 | 545 | if (!($image instanceof image)) { |
547 | 546 | $img = image::factory($this->imageDriver, $image); |
@@ -629,24 +628,24 @@ discard block |
||
629 | 628 | $img->watermark($this->config['watermark']['file'], $left, $top); |
630 | 629 | } |
631 | 630 | |
632 | - $options = array( 'file' => $file ); |
|
631 | + $options = array('file' => $file); |
|
633 | 632 | |
634 | - $type = exif_imagetype( $file ); |
|
633 | + $type = exif_imagetype($file); |
|
635 | 634 | |
636 | - switch ( $type ) { |
|
635 | + switch ($type) { |
|
637 | 636 | case IMAGETYPE_GIF: |
638 | - return $img->output( 'gif', $options ); |
|
637 | + return $img->output('gif', $options); |
|
639 | 638 | |
640 | 639 | case IMAGETYPE_PNG: |
641 | - return $img->output( 'png', $options ); |
|
640 | + return $img->output('png', $options); |
|
642 | 641 | |
643 | 642 | default: |
644 | - return $img->output( 'jpeg', array_merge( $options, array( 'quality' => $this->config['jpegQuality'] ) ) ); |
|
643 | + return $img->output('jpeg', array_merge($options, array('quality' => $this->config['jpegQuality']))); |
|
645 | 644 | } |
646 | 645 | |
647 | 646 | } |
648 | 647 | |
649 | - protected function makeThumb($file, $overwrite=true) { |
|
648 | + protected function makeThumb($file, $overwrite = true){ |
|
650 | 649 | $img = image::factory($this->imageDriver, $file); |
651 | 650 | |
652 | 651 | // Drop files which are not images |
@@ -654,7 +653,7 @@ discard block |
||
654 | 653 | return true; |
655 | 654 | |
656 | 655 | $thumb = substr($file, strlen($this->config['uploadDir'])); |
657 | - $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb; |
|
656 | + $thumb = $this->config['uploadDir']."/".$this->config['thumbsDir']."/".$thumb; |
|
658 | 657 | $thumb = path::normalize($thumb); |
659 | 658 | $thumbDir = dirname($thumb); |
660 | 659 | if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) |
@@ -677,15 +676,15 @@ discard block |
||
677 | 676 | if (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) |
678 | 677 | return false; |
679 | 678 | |
680 | - if ( $this->imageDriver == 'gd' ) { |
|
681 | - $width = imagesx( $img->image ); |
|
682 | - $height = imagesy( $img->image ); |
|
683 | - $back = image::factory( $this->imageDriver, array( $width, $height ) ); |
|
684 | - $tile = image::factory( $this->imageDriver, __DIR__ . '/../themes/' . $this->config['theme'] . '/img/bg_transparent.png' ); |
|
679 | + if ($this->imageDriver == 'gd') { |
|
680 | + $width = imagesx($img->image); |
|
681 | + $height = imagesy($img->image); |
|
682 | + $back = image::factory($this->imageDriver, array($width, $height)); |
|
683 | + $tile = image::factory($this->imageDriver, __DIR__.'/../themes/'.$this->config['theme'].'/img/bg_transparent.png'); |
|
685 | 684 | |
686 | - imagesettile( $back->image, $tile->image ); |
|
687 | - imagefilledrectangle( $back->image, 0, 0, $width, $height, IMG_COLOR_TILED ); |
|
688 | - imagecopy( $back->image, $img->image, 0, 0, 0, 0, $width, $height ); |
|
685 | + imagesettile($back->image, $tile->image); |
|
686 | + imagefilledrectangle($back->image, 0, 0, $width, $height, IMG_COLOR_TILED); |
|
687 | + imagecopy($back->image, $img->image, 0, 0, 0, 0, $width, $height); |
|
689 | 688 | |
690 | 689 | $img = $back; |
691 | 690 | } |
@@ -697,7 +696,7 @@ discard block |
||
697 | 696 | )); |
698 | 697 | } |
699 | 698 | |
700 | - protected function localize($langCode) { |
|
699 | + protected function localize($langCode){ |
|
701 | 700 | require "lang/{$langCode}.php"; |
702 | 701 | setlocale(LC_ALL, $lang['_locale']); |
703 | 702 | $this->charset = $lang['_charset']; |
@@ -712,7 +711,7 @@ discard block |
||
712 | 711 | $this->labels = $lang; |
713 | 712 | } |
714 | 713 | |
715 | - protected function label($string, array $data=null) { |
|
714 | + protected function label($string, array $data = null){ |
|
716 | 715 | $return = isset($this->labels[$string]) ? $this->labels[$string] : $string; |
717 | 716 | if (is_array($data)) |
718 | 717 | foreach ($data as $key => $val) |
@@ -720,7 +719,7 @@ discard block |
||
720 | 719 | return $return; |
721 | 720 | } |
722 | 721 | |
723 | - protected function backMsg($message, array $data=null) { |
|
722 | + protected function backMsg($message, array $data = null){ |
|
724 | 723 | $message = $this->label($message, $data); |
725 | 724 | if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) |
726 | 725 | @unlink($this->file['tmp_name']); |
@@ -728,7 +727,7 @@ discard block |
||
728 | 727 | die; |
729 | 728 | } |
730 | 729 | |
731 | - protected function callBack($url, $message="") { |
|
730 | + protected function callBack($url, $message = ""){ |
|
732 | 731 | $message = text::jsValue($message); |
733 | 732 | $CKfuncNum = isset($this->opener['CKEditor']['funcNum']) |
734 | 733 | ? $this->opener['CKEditor']['funcNum'] : 0; |
@@ -769,7 +768,7 @@ discard block |
||
769 | 768 | |
770 | 769 | } |
771 | 770 | |
772 | - protected function get_htaccess() { |
|
771 | + protected function get_htaccess(){ |
|
773 | 772 | return "<IfModule mod_php4.c> |
774 | 773 | php_value engine off |
775 | 774 | </IfModule> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $modx = evolutionCMS(); |
27 | 27 | $modx->db->connect(); |
28 | 28 | startCMSSession(); |
29 | -if(!isset($_SESSION['mgrValidated'])) { |
|
29 | +if (!isset($_SESSION['mgrValidated'])) { |
|
30 | 30 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
31 | 31 | } |
32 | 32 | define('IN_MANAGER_MODE', true); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $manager_language = $modx->config['manager_language']; |
36 | 36 | // Pass language code from MODX to KCFinder |
37 | -if(!file_exists("../../../includes/lang/".$manager_language.".inc.php")) { |
|
37 | +if (!file_exists("../../../includes/lang/".$manager_language.".inc.php")) { |
|
38 | 38 | $manager_language = "english"; // if not set, get the english language file. |
39 | 39 | } |
40 | 40 | include_once "../../../includes/lang/".$manager_language.".inc.php"; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | // PHP VERSION CHECK |
44 | 44 | if (substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.')) < 5) |
45 | - die("You are using PHP " . PHP_VERSION . " when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution."); |
|
45 | + die("You are using PHP ".PHP_VERSION." when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution."); |
|
46 | 46 | |
47 | 47 | |
48 | 48 | // SAFE MODE CHECK |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | |
53 | 53 | // MAGIC AUTOLOAD CLASSES FUNCTION |
54 | -function autoloadda9d06472ccb71b84928677ce2a6ca89($class) { |
|
54 | +function autoloadda9d06472ccb71b84928677ce2a6ca89($class){ |
|
55 | 55 | static $classes = null; |
56 | 56 | if ($classes === null) { |
57 | 57 | $classes = array( |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ); |
76 | 76 | } |
77 | 77 | if (isset($classes[$class])) { |
78 | - require dirname(__FILE__) . $classes[$class]; |
|
78 | + require dirname(__FILE__).$classes[$class]; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | spl_autoload_register('autoloadda9d06472ccb71b84928677ce2a6ca89', true); |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | // json_encode() IMPLEMENTATION IF JSON EXTENSION IS MISSING |
85 | 85 | if (!function_exists("json_encode")) { |
86 | 86 | |
87 | - function kcfinder_json_string_encode($string) { |
|
88 | - return '"' . |
|
87 | + function kcfinder_json_string_encode($string){ |
|
88 | + return '"'. |
|
89 | 89 | str_replace('/', "\\/", |
90 | 90 | str_replace("\t", "\\t", |
91 | 91 | str_replace("\r", "\\r", |
92 | 92 | str_replace("\n", "\\n", |
93 | 93 | str_replace('"', "\\\"", |
94 | 94 | str_replace("\\", "\\\\", |
95 | - $string)))))) . '"'; |
|
95 | + $string)))))).'"'; |
|
96 | 96 | } |
97 | 97 | |
98 | - function json_encode($data) { |
|
98 | + function json_encode($data){ |
|
99 | 99 | |
100 | 100 | if (is_array($data)) { |
101 | 101 | $ret = array(); |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | // OBJECT |
104 | 104 | if (array_keys($data) !== range(0, count($data) - 1)) { |
105 | 105 | foreach ($data as $key => $val) |
106 | - $ret[] = kcfinder_json_string_encode($key) . ':' . json_encode($val); |
|
107 | - return "{" . implode(",", $ret) . "}"; |
|
106 | + $ret[] = kcfinder_json_string_encode($key).':'.json_encode($val); |
|
107 | + return "{".implode(",", $ret)."}"; |
|
108 | 108 | |
109 | 109 | // ARRAY |
110 | 110 | } else { |
111 | 111 | foreach ($data as $val) |
112 | 112 | $ret[] = json_encode($val); |
113 | - return "[" . implode(",", $ret) . "]"; |
|
113 | + return "[".implode(",", $ret)."]"; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // BOOLEAN OR NULL |
@@ -1,44 +1,44 @@ 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 | -if(!$modx->hasPermission('delete_document')) { |
|
5 | +if (!$modx->hasPermission('delete_document')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | /************ webber ********/ |
15 | -$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
15 | +$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | +$pid = ($content['parent'] == 0 ? $id : $content['parent']); |
|
17 | 17 | |
18 | 18 | /************** webber *************/ |
19 | -$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; |
|
20 | -$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; |
|
21 | -$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; |
|
22 | -$add_path=$sd.$sb.$pg; |
|
19 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
20 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
21 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
22 | +$add_path = $sd.$sb.$pg; |
|
23 | 23 | |
24 | 24 | /***********************************/ |
25 | 25 | |
26 | 26 | |
27 | 27 | // check permissions on the document |
28 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
28 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
29 | 29 | $udperms = new udperms(); |
30 | 30 | $udperms->user = $modx->getLoginUserID(); |
31 | 31 | $udperms->document = $id; |
32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
33 | 33 | |
34 | -if(!$udperms->checkPermissions()) { |
|
34 | +if (!$udperms->checkPermissions()) { |
|
35 | 35 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
36 | 36 | } |
37 | 37 | |
38 | 38 | // get the timestamp on which the document was deleted. |
39 | 39 | $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1"); |
40 | 40 | $deltime = $modx->db->getValue($rs); |
41 | -if(!$deltime) { |
|
41 | +if (!$deltime) { |
|
42 | 42 | $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!"); |
43 | 43 | } |
44 | 44 | |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @param int $parent |
49 | 49 | */ |
50 | -function getChildren($parent) { |
|
50 | +function getChildren($parent){ |
|
51 | 51 | |
52 | 52 | $modx = evolutionCMS(); |
53 | 53 | global $children; |
54 | 54 | global $deltime; |
55 | 55 | |
56 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'"); |
|
56 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int) $parent."' AND deleted=1 AND deletedon='".(int) $deltime."'"); |
|
57 | 57 | // the document has children documents, we'll need to delete those too |
58 | - while ($row=$modx->db->getRow($rs)) { |
|
58 | + while ($row = $modx->db->getRow($rs)) { |
|
59 | 59 | $children[] = $row['id']; |
60 | 60 | getChildren($row['id']); |
61 | 61 | //echo "Found childNode of parentNode $parent: ".$row['id']."<br />"; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | getChildren($id); |
66 | 66 | |
67 | -if(count($children)>0) { |
|
67 | +if (count($children) > 0) { |
|
68 | 68 | $modx->db->update( |
69 | 69 | array( |
70 | 70 | 'deleted' => 0, |
@@ -93,5 +93,5 @@ discard block |
||
93 | 93 | $modx->clearCache('full'); |
94 | 94 | |
95 | 95 | // finished emptying cache - redirect |
96 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
96 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
97 | 97 | header($header); |