@@ -3,13 +3,15 @@ discard block |
||
3 | 3 | global $site_sessionname; |
4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
5 | 5 | |
6 | -function genEvoSessionName() { |
|
6 | +function genEvoSessionName() |
|
7 | +{ |
|
7 | 8 | $_ = crc32(__FILE__); |
8 | 9 | $_ = sprintf('%u', $_); |
9 | 10 | return 'evo' . base_convert($_,10,36); |
10 | 11 | } |
11 | 12 | |
12 | -function startCMSSession(){ |
|
13 | +function startCMSSession() |
|
14 | +{ |
|
13 | 15 | |
14 | 16 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
15 | 17 | |
@@ -23,24 +25,27 @@ discard block |
||
23 | 25 | session_start(); |
24 | 26 | |
25 | 27 | $key = "modx.{$context}.session.cookie.lifetime"; |
26 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
28 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
27 | 29 | $cookieLifetime= intval($_SESSION[$key]); |
28 | - if($cookieLifetime) $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime; |
|
30 | + if($cookieLifetime) { |
|
31 | + $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime; |
|
32 | + } |
|
29 | 33 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
30 | 34 | } |
31 | - if (!isset($_SESSION['modx.session.created.time'])) { |
|
35 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
32 | 36 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
33 | 37 | } |
34 | 38 | } |
35 | 39 | |
36 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) { |
|
37 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) |
|
38 | - { |
|
40 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
41 | +{ |
|
42 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
39 | 43 | unset($storage[$session_name]); |
40 | 44 | } |
41 | 45 | } |
42 | 46 | |
43 | -function removeInvalidCmsSessionIds($session_name) { |
|
47 | +function removeInvalidCmsSessionIds($session_name) |
|
48 | +{ |
|
44 | 49 | // session ids is invalid iff it is empty string |
45 | 50 | // storage priorioty can see in PHP source ext/session/session.c |
46 | 51 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |
@@ -3,18 +3,22 @@ discard block |
||
3 | 3 | //Kyle Jaebker - 08/07/06 |
4 | 4 | |
5 | 5 | //Create a new category |
6 | -function newCategory($newCat) { |
|
6 | +function newCategory($newCat) |
|
7 | +{ |
|
7 | 8 | global $modx; |
8 | 9 | $useTable = $modx->getFullTableName('categories'); |
9 | 10 | $categoryId = $modx->db->insert( |
10 | 11 | array( |
11 | 12 | 'category' => $modx->db->escape($newCat), |
12 | 13 | ), $useTable); |
13 | - if (!$categoryId) $categoryId = 0; |
|
14 | + if (!$categoryId) { |
|
15 | + $categoryId = 0; |
|
16 | + } |
|
14 | 17 | return $categoryId; |
15 | 18 | } |
16 | 19 | //check if new category already exists |
17 | -function checkCategory($newCat = '') { |
|
20 | +function checkCategory($newCat = '') |
|
21 | +{ |
|
18 | 22 | global $modx; |
19 | 23 | $useTable = $modx->getFullTableName('categories'); |
20 | 24 | $newCat = $modx->db->escape($newCat); |
@@ -25,13 +29,17 @@ discard block |
||
25 | 29 | return 0; |
26 | 30 | } |
27 | 31 | //Check for category, create new if not exists |
28 | -function getCategory($category='') { |
|
32 | +function getCategory($category='') |
|
33 | +{ |
|
29 | 34 | $categoryId = checkCategory($category); |
30 | - if(!$categoryId) $categoryId = newCategory($category); |
|
35 | + if(!$categoryId) { |
|
36 | + $categoryId = newCategory($category); |
|
37 | + } |
|
31 | 38 | return $categoryId; |
32 | 39 | } |
33 | 40 | //Get all categories |
34 | -function getCategories() { |
|
41 | +function getCategories() |
|
42 | +{ |
|
35 | 43 | global $modx; |
36 | 44 | $useTable = $modx->getFullTableName('categories'); |
37 | 45 | $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category'); |
@@ -43,7 +51,8 @@ discard block |
||
43 | 51 | return $resourceArray; |
44 | 52 | } |
45 | 53 | //Delete category & associations |
46 | -function deleteCategory($catId=0) { |
|
54 | +function deleteCategory($catId=0) |
|
55 | +{ |
|
47 | 56 | global $modx; |
48 | 57 | if ($catId) { |
49 | 58 | $resetTables = array('site_plugins', 'site_snippets', 'site_htmlsnippets', 'site_templates', 'site_tmplvars', 'site_modules'); |
@@ -6,37 +6,50 @@ |
||
6 | 6 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); |
7 | 7 | |
8 | 8 | // Null is evil |
9 | -if (isset($_SERVER['QUERY_STRING']) && strpos(urldecode($_SERVER['QUERY_STRING']), chr(0)) !== false) |
|
9 | +if (isset($_SERVER['QUERY_STRING']) && strpos(urldecode($_SERVER['QUERY_STRING']), chr(0)) !== false) { |
|
10 | 10 | die(); |
11 | +} |
|
11 | 12 | |
12 | 13 | global $sanitize_seed; |
13 | 14 | $sanitize_seed = 'sanitize_seed_' . base_convert(md5(__FILE__),16,36); |
14 | 15 | |
15 | 16 | // sanitize array |
16 | 17 | if (!function_exists('modx_sanitize_gpc')) { |
17 | - function modx_sanitize_gpc(& $values, $depth=0) { |
|
18 | - if(200 < $depth) exit('GPC Array nested too deep!'); |
|
18 | + function modx_sanitize_gpc(& $values, $depth=0) |
|
19 | + { |
|
20 | + if(200 < $depth) { |
|
21 | + exit('GPC Array nested too deep!'); |
|
22 | + } |
|
19 | 23 | if(is_array($values)) { |
20 | 24 | $depth++; |
21 | 25 | foreach ($values as $key => $value) { |
22 | - if (is_array($value)) modx_sanitize_gpc($value, $depth); |
|
23 | - else $values[$key] = getSanitizedValue($value); |
|
26 | + if (is_array($value)) { |
|
27 | + modx_sanitize_gpc($value, $depth); |
|
28 | + } else { |
|
29 | + $values[$key] = getSanitizedValue($value); |
|
30 | + } |
|
24 | 31 | } |
32 | + } else { |
|
33 | + $values = getSanitizedValue($values); |
|
25 | 34 | } |
26 | - else $values = getSanitizedValue($values); |
|
27 | 35 | |
28 | 36 | return $values; |
29 | 37 | } |
30 | 38 | } |
31 | 39 | |
32 | -function getSanitizedValue($value='') { |
|
40 | +function getSanitizedValue($value='') |
|
41 | +{ |
|
33 | 42 | global $sanitize_seed; |
34 | 43 | |
35 | - if(!$value) return $value; |
|
44 | + if(!$value) { |
|
45 | + return $value; |
|
46 | + } |
|
36 | 47 | |
37 | 48 | $brackets = explode(' ', '[[ ]] [! !] [* *] [( )] {{ }} [+ +] [~ ~] [^ ^]'); |
38 | 49 | foreach($brackets as $bracket) { |
39 | - if(strpos($value,$bracket)===false) continue; |
|
50 | + if(strpos($value,$bracket)===false) { |
|
51 | + continue; |
|
52 | + } |
|
40 | 53 | $sanitizedBracket = str_replace('#', $sanitize_seed, sprintf('#%s#%s#', substr($bracket,0,1), substr($bracket,1,1))); |
41 | 54 | $value = str_replace($bracket,$sanitizedBracket,$value); |
42 | 55 | } |
@@ -1,11 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // this is the old error handler. Here for legacy, until i replace all the old errors. |
3 | -class errorHandler{ |
|
3 | +class errorHandler |
|
4 | +{ |
|
4 | 5 | |
5 | 6 | var $errorcode; |
6 | 7 | var $errors = array(); |
7 | 8 | |
8 | - function __construct() { |
|
9 | + function __construct() |
|
10 | + { |
|
9 | 11 | |
10 | 12 | $_lang = $this->include_lang('errormsg'); |
11 | 13 | |
@@ -40,25 +42,31 @@ discard block |
||
40 | 42 | ); |
41 | 43 | } |
42 | 44 | |
43 | - function include_lang($context='common') { |
|
45 | + function include_lang($context='common') |
|
46 | + { |
|
44 | 47 | global $modx; |
45 | 48 | $_lang = array(); |
46 | 49 | |
47 | 50 | $context = trim($context,'/'); |
48 | - if(strpos($context,'..')!==false) return; |
|
51 | + if(strpos($context,'..')!==false) { |
|
52 | + return; |
|
53 | + } |
|
49 | 54 | |
50 | - if($context === 'common') |
|
51 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/'; |
|
52 | - else |
|
53 | - $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/"; |
|
55 | + if($context === 'common') { |
|
56 | + $lang_path = MODX_MANAGER_PATH . 'includes/lang/'; |
|
57 | + } else { |
|
58 | + $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/"; |
|
59 | + } |
|
54 | 60 | include_once($lang_path . 'english.inc.php'); |
55 | 61 | $manager_language = $modx->config['manager_language']; |
56 | - if(is_file("{$lang_path}{$manager_language}.inc.php")) |
|
57 | - include_once("{$lang_path}{$manager_language}.inc.php"); |
|
62 | + if(is_file("{$lang_path}{$manager_language}.inc.php")) { |
|
63 | + include_once("{$lang_path}{$manager_language}.inc.php"); |
|
64 | + } |
|
58 | 65 | return $_lang; |
59 | 66 | } |
60 | 67 | |
61 | - function setError($errorcode, $custommessage=""){ |
|
68 | + function setError($errorcode, $custommessage="") |
|
69 | + { |
|
62 | 70 | $this->errorcode=$errorcode; |
63 | 71 | $this->errormessage=$this->errors[$errorcode]; |
64 | 72 | if($custommessage!="") { |
@@ -66,11 +74,13 @@ discard block |
||
66 | 74 | } |
67 | 75 | } |
68 | 76 | |
69 | - function getError() { |
|
77 | + function getError() |
|
78 | + { |
|
70 | 79 | return $this->errorcode; |
71 | 80 | } |
72 | 81 | |
73 | - function dumpError(){ |
|
82 | + function dumpError() |
|
83 | + { |
|
74 | 84 | ?> |
75 | 85 | <html> |
76 | 86 | <head> |
@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | 'DIRECTORY' |
15 | 15 | ); |
16 | 16 | |
17 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
17 | +function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) |
|
18 | +{ |
|
18 | 19 | global $modx; |
19 | 20 | $docid = intval($docid) ? intval($docid) : $modx->documentIdentifier; |
20 | 21 | $nvalue = trim($value); |
21 | - if (substr($nvalue, 0, 1) != '@') |
|
22 | - return $value; |
|
23 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
22 | + if (substr($nvalue, 0, 1) != '@') { |
|
23 | + return $value; |
|
24 | + } elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
24 | 25 | return '@Bindings is disabled.'; |
25 | - } |
|
26 | - else { |
|
26 | + } else { |
|
27 | 27 | list ($cmd, $param) = ParseCommand($nvalue); |
28 | 28 | $cmd = trim($cmd); |
29 | 29 | $param = parseTvValues($param, $tvsArray); |
@@ -39,10 +39,11 @@ discard block |
||
39 | 39 | |
40 | 40 | case "DOCUMENT" : // retrieve a document and process it's content |
41 | 41 | $rs = $modx->getDocument($param); |
42 | - if (is_array($rs)) |
|
43 | - $output = $rs['content']; |
|
44 | - else |
|
45 | - $output = "Unable to locate document $param"; |
|
42 | + if (is_array($rs)) { |
|
43 | + $output = $rs['content']; |
|
44 | + } else { |
|
45 | + $output = "Unable to locate document $param"; |
|
46 | + } |
|
46 | 47 | break; |
47 | 48 | |
48 | 49 | case "SELECT" : // selects a record from the cms database |
@@ -72,8 +73,10 @@ discard block |
||
72 | 73 | |
73 | 74 | // Grab document regardless of publish status |
74 | 75 | $doc = $modx->getPageInfo($parent_id, 0, 'id,parent,published'); |
75 | - if ($doc['parent'] != 0 && !$doc['published']) |
|
76 | - continue; // hide unpublished docs if we're not at the top |
|
76 | + if ($doc['parent'] != 0 && !$doc['published']) { |
|
77 | + continue; |
|
78 | + } |
|
79 | + // hide unpublished docs if we're not at the top |
|
77 | 80 | |
78 | 81 | $tv = $modx->getTemplateVar($name, '*', $doc['id'], $doc['published']); |
79 | 82 | |
@@ -117,10 +120,13 @@ discard block |
||
117 | 120 | } |
118 | 121 | } |
119 | 122 | |
120 | -function ProcessFile($file) { |
|
123 | +function ProcessFile($file) |
|
124 | +{ |
|
121 | 125 | // get the file |
122 | 126 | $buffer = @file_get_contents($file); |
123 | - if ($buffer===false) $buffer = " Could not retrieve document '$file'."; |
|
127 | + if ($buffer===false) { |
|
128 | + $buffer = " Could not retrieve document '$file'."; |
|
129 | + } |
|
124 | 130 | return $buffer; |
125 | 131 | } |
126 | 132 | |
@@ -129,10 +135,8 @@ discard block |
||
129 | 135 | { |
130 | 136 | global $BINDINGS; |
131 | 137 | $binding_array = array(); |
132 | - foreach($BINDINGS as $cmd) |
|
133 | - { |
|
134 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
135 | - { |
|
138 | + foreach($BINDINGS as $cmd) { |
|
139 | + if(strpos($binding_string,'@'.$cmd)===0) { |
|
136 | 140 | $code = substr($binding_string,strlen($cmd)+1); |
137 | 141 | $binding_array = array($cmd,trim($code)); |
138 | 142 | break; |
@@ -12,11 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | */ |
14 | 14 | |
15 | -class logHandler { |
|
15 | +class logHandler |
|
16 | +{ |
|
16 | 17 | // Single variable for a log entry |
17 | 18 | var $entry = array(); |
18 | 19 | |
19 | - function initAndWriteLog($msg="", $internalKey="", $username="", $action="", $itemid="", $itemname="") { |
|
20 | + function initAndWriteLog($msg="", $internalKey="", $username="", $action="", $itemid="", $itemname="") |
|
21 | + { |
|
20 | 22 | global $modx; |
21 | 23 | $this->entry['msg'] = $msg; // writes testmessage to the object |
22 | 24 | $this->entry['action'] = empty($action)? $modx->manager->action : $action; // writes the action to the object |
@@ -26,10 +28,16 @@ discard block |
||
26 | 28 | $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username; |
27 | 29 | |
28 | 30 | $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid; // writes the id to the object |
29 | - if($this->entry['itemId'] == 0) $this->entry['itemId'] = "-"; // to stop items having id 0 |
|
31 | + if($this->entry['itemId'] == 0) { |
|
32 | + $this->entry['itemId'] = "-"; |
|
33 | + } |
|
34 | + // to stop items having id 0 |
|
30 | 35 | |
31 | 36 | $this->entry['itemName'] = ($itemname == "" && isset($_SESSION['itemname']))? $_SESSION['itemname'] : $itemname; // writes the id to the object |
32 | - if($this->entry['itemName'] == "") $this->entry['itemName'] = "-"; // to stop item name being empty |
|
37 | + if($this->entry['itemName'] == "") { |
|
38 | + $this->entry['itemName'] = "-"; |
|
39 | + } |
|
40 | + // to stop item name being empty |
|
33 | 41 | |
34 | 42 | $this->writeToLog(); |
35 | 43 | return; |
@@ -38,7 +46,8 @@ discard block |
||
38 | 46 | // function to write to the log |
39 | 47 | // collects all required info, and |
40 | 48 | // writes it to the logging table |
41 | - function writeToLog() { |
|
49 | + function writeToLog() |
|
50 | + { |
|
42 | 51 | global $modx; |
43 | 52 | $tbl_manager_log = $modx->getFullTableName('manager_log'); |
44 | 53 |
@@ -7,9 +7,11 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -Class TemplateParser { |
|
10 | +Class TemplateParser |
|
11 | +{ |
|
11 | 12 | |
12 | - function __construct() { |
|
13 | + function __construct() |
|
14 | + { |
|
13 | 15 | } |
14 | 16 | |
15 | 17 | /** |
@@ -17,46 +19,47 @@ discard block |
||
17 | 19 | * @param array $data |
18 | 20 | * @return string |
19 | 21 | */ |
20 | - public function output($config = array(), $data = array()) { |
|
22 | + public function output($config = array(), $data = array()) |
|
23 | + { |
|
21 | 24 | global $modx; |
22 | 25 | |
23 | 26 | $output = ''; |
24 | 27 | $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
25 | 28 | $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : ''; |
26 | 29 | |
27 | - if($action) { |
|
30 | + if($action) { |
|
28 | 31 | $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name |
29 | 32 | FROM ' . $modx->getFullTableName('system_templates') . ' AS t1 |
30 | 33 | INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category |
31 | 34 | WHERE t1.action IN(' . $action . ') ' . $tab . ' |
32 | 35 | ORDER BY t1.tab ASC, t1.rank ASC'); |
33 | 36 | |
34 | - if($modx->db->getRecordCount($sql)) { |
|
37 | + if($modx->db->getRecordCount($sql)) { |
|
35 | 38 | $tabs = array(); |
36 | - while($row = $modx->db->getRow($sql)) { |
|
37 | - if(!$row['value'] && !empty($data[$row['name']])) { |
|
39 | + while($row = $modx->db->getRow($sql)) { |
|
40 | + if(!$row['value'] && !empty($data[$row['name']])) { |
|
38 | 41 | $row['value'] = $data[$row['name']]; |
39 | 42 | } |
40 | 43 | $tabs[$row['tab']]['category_name'] = $row['category_name']; |
41 | 44 | $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
42 | 45 | } |
43 | 46 | |
44 | - if(!empty($config['toArray'])) { |
|
47 | + if(!empty($config['toArray'])) { |
|
45 | 48 | $output = $tabs; |
46 | - } else { |
|
49 | + } else { |
|
47 | 50 | $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
48 | 51 | $output .= ' |
49 | 52 | <script type="text/javascript"> |
50 | 53 | var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
51 | 54 | </script>'; |
52 | 55 | |
53 | - foreach($tabs as $idTab => $tab) { |
|
56 | + foreach($tabs as $idTab => $tab) { |
|
54 | 57 | $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
55 | 58 | $output .= ' |
56 | 59 | <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
57 | 60 | <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>'; |
58 | 61 | unset($tab['category_name']); |
59 | - foreach($tab as $item) { |
|
62 | + foreach($tab as $item) { |
|
60 | 63 | $output .= $item; |
61 | 64 | } |
62 | 65 | $output .= '</div>'; |
@@ -69,7 +72,8 @@ discard block |
||
69 | 72 | return $output; |
70 | 73 | } |
71 | 74 | |
72 | - private function render($data) { |
|
75 | + private function render($data) |
|
76 | + { |
|
73 | 77 | global $modx, $_lang, $_country_lang; |
74 | 78 | |
75 | 79 | $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
@@ -79,7 +83,7 @@ discard block |
||
79 | 83 | $output = ''; |
80 | 84 | $output .= '<div class="form-group row">'; |
81 | 85 | |
82 | - switch($data['type']) { |
|
86 | + switch($data['type']) { |
|
83 | 87 | |
84 | 88 | case 'text': |
85 | 89 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
@@ -113,16 +117,16 @@ discard block |
||
113 | 117 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
114 | 118 | $output .= '<div class="col-sm-7">'; |
115 | 119 | $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
116 | - if($data['name'] == 'country' && isset($_country_lang)) { |
|
120 | + if($data['name'] == 'country' && isset($_country_lang)) { |
|
117 | 121 | $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
118 | 122 | $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
119 | - foreach($_country_lang as $key => $value) { |
|
123 | + foreach($_country_lang as $key => $value) { |
|
120 | 124 | $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
121 | 125 | } |
122 | - } else { |
|
123 | - if($data['elements']) { |
|
126 | + } else { |
|
127 | + if($data['elements']) { |
|
124 | 128 | $elements = explode('||', $data['elements']); |
125 | - foreach($elements as $key => $value) { |
|
129 | + foreach($elements as $key => $value) { |
|
126 | 130 | $value = explode('==', $value); |
127 | 131 | $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
128 | 132 | } |
@@ -138,9 +142,9 @@ discard block |
||
138 | 142 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
139 | 143 | $output .= '<div class="col-sm-7">'; |
140 | 144 | $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
141 | - if($data['elements']) { |
|
145 | + if($data['elements']) { |
|
142 | 146 | $elements = explode('||', $data['elements']); |
143 | - foreach($elements as $key => $value) { |
|
147 | + foreach($elements as $key => $value) { |
|
144 | 148 | $value = explode('==', $value); |
145 | 149 | $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 | 150 | } |
@@ -154,9 +158,9 @@ discard block |
||
154 | 158 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
155 | 159 | $output .= '<div class="col-sm-7">'; |
156 | 160 | $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
157 | - if($data['elements']) { |
|
161 | + if($data['elements']) { |
|
158 | 162 | $elements = explode('||', $data['elements']); |
159 | - foreach($elements as $key => $value) { |
|
163 | + foreach($elements as $key => $value) { |
|
160 | 164 | $value = explode('==', $value); |
161 | 165 | $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 | 166 | } |
@@ -3,10 +3,12 @@ discard block |
||
3 | 3 | global $ContextMenuCnt; |
4 | 4 | $ContextMenuCnt = 0; |
5 | 5 | |
6 | -class ContextMenu { |
|
6 | +class ContextMenu |
|
7 | +{ |
|
7 | 8 | var $id; |
8 | 9 | |
9 | - function __construct($id = '', $width = 120, $visible = false) { |
|
10 | + function __construct($id = '', $width = 120, $visible = false) |
|
11 | + { |
|
10 | 12 | global $ContextMenuCnt; |
11 | 13 | $ContextMenuCnt++; |
12 | 14 | $this->html = ""; |
@@ -15,7 +17,8 @@ discard block |
||
15 | 17 | $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt; // set id |
16 | 18 | } |
17 | 19 | |
18 | - function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
20 | + function addItem($text, $action = "", $img = "", $disabled = 0) |
|
21 | + { |
|
19 | 22 | global $base_url, $_style; |
20 | 23 | if($disabled) { |
21 | 24 | return; |
@@ -40,13 +43,15 @@ discard block |
||
40 | 43 | $this->html .= $img . ' ' . $text . '</div>'; |
41 | 44 | } |
42 | 45 | |
43 | - function addSeparator() { |
|
46 | + function addSeparator() |
|
47 | + { |
|
44 | 48 | $this->html .= " |
45 | 49 | <div class='cntxMnuSeparator'></div> |
46 | 50 | "; |
47 | 51 | } |
48 | 52 | |
49 | - function render() { |
|
53 | + function render() |
|
54 | + { |
|
50 | 55 | global $ContextMenuScript; |
51 | 56 | |
52 | 57 | $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>"; |
@@ -54,7 +59,8 @@ discard block |
||
54 | 59 | return $html; |
55 | 60 | } |
56 | 61 | |
57 | - function getClientScriptObject() { |
|
62 | + function getClientScriptObject() |
|
63 | + { |
|
58 | 64 | return "getCntxMenu('" . $this->id . "')"; |
59 | 65 | } |
60 | 66 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | var $ds; // datasource |
16 | 17 | var $id; |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | var $selPageClass; |
53 | 54 | var $noRecordMsg = "No records found."; |
54 | 55 | |
55 | - function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
56 | + function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) |
|
57 | + { |
|
56 | 58 | global $__DataGridCnt; |
57 | 59 | |
58 | 60 | // set id |
@@ -68,11 +70,13 @@ discard block |
||
68 | 70 | $this->pagerLocation = 'top-right'; |
69 | 71 | } |
70 | 72 | |
71 | - function setDataSource($ds) { |
|
73 | + function setDataSource($ds) |
|
74 | + { |
|
72 | 75 | $this->ds = $ds; |
73 | 76 | } |
74 | 77 | |
75 | - function render() { |
|
78 | + function render() |
|
79 | + { |
|
76 | 80 | global $modx; |
77 | 81 | $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
78 | 82 | $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | |
108 | 112 | if($this->_isDataset && !$this->columns) { |
109 | 113 | $cols = $modx->db->numFields($this->ds); |
110 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
114 | + for($i = 0; $i < $cols; $i++) { |
|
115 | + $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
116 | + } |
|
111 | 117 | } |
112 | 118 | |
113 | 119 | // start grid |
@@ -187,7 +193,8 @@ discard block |
||
187 | 193 | |
188 | 194 | // format column values |
189 | 195 | |
190 | - function RenderRowFnc($n, $row) { |
|
196 | + function RenderRowFnc($n, $row) |
|
197 | + { |
|
191 | 198 | if($this->_alt == 0) { |
192 | 199 | $Style = $this->_itemStyle; |
193 | 200 | $Class = $this->_itemClass; |
@@ -217,7 +224,8 @@ discard block |
||
217 | 224 | return $o; |
218 | 225 | } |
219 | 226 | |
220 | - function formatColumnValue($row, $value, $type, &$align) { |
|
227 | + function formatColumnValue($row, $value, $type, &$align) |
|
228 | + { |
|
221 | 229 | if(strpos($type, ":") !== false) { |
222 | 230 | list($type, $type_format) = explode(":", $type, 2); |
223 | 231 | } |