@@ -32,6 +32,9 @@ |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | +/** |
|
36 | + * @param string $src |
|
37 | + */ |
|
35 | 38 | function parse($src,$ph,$left='[+',$right='+]') |
36 | 39 | { |
37 | 40 | foreach($ph as $k=>$v) |
@@ -4,10 +4,8 @@ discard block |
||
4 | 4 | global $_lang; |
5 | 5 | |
6 | 6 | // session loop-back tester |
7 | - if(!isset($_GET['action']) || $_GET['action']!=='mode') |
|
8 | - { |
|
9 | - if(!isset($_SESSION['test']) || $_SESSION['test']!=1) |
|
10 | - { |
|
7 | + if(!isset($_GET['action']) || $_GET['action']!=='mode') { |
|
8 | + if(!isset($_SESSION['test']) || $_SESSION['test']!=1) { |
|
11 | 9 | echo ' |
12 | 10 | <html> |
13 | 11 | <head> |
@@ -34,8 +32,7 @@ discard block |
||
34 | 32 | |
35 | 33 | function parse($src,$ph,$left='[+',$right='+]') |
36 | 34 | { |
37 | - foreach($ph as $k=>$v) |
|
38 | - { |
|
35 | + foreach($ph as $k=>$v) { |
|
39 | 36 | $k = $left . $k . $right; |
40 | 37 | $src = str_replace($k,$v,$src); |
41 | 38 | } |
@@ -46,8 +43,11 @@ discard block |
||
46 | 43 | { |
47 | 44 | global $_lang,$moduleName,$moduleVersion,$modx_textdir,$modx_release_date; |
48 | 45 | |
49 | - if(isset($_SESSION['installmode'])) $installmode = $_SESSION['installmode']; |
|
50 | - else $installmode = get_installmode(); |
|
46 | + if(isset($_SESSION['installmode'])) { |
|
47 | + $installmode = $_SESSION['installmode']; |
|
48 | + } else { |
|
49 | + $installmode = get_installmode(); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | $ph['pagetitle'] = $_lang['modx_install']; |
53 | 53 | $ph['textdir'] = $modx_textdir ? ' id="rtl"':''; |
@@ -65,29 +65,29 @@ discard block |
||
65 | 65 | global $base_path,$database_server, $database_user, $database_password, $dbase, $table_prefix; |
66 | 66 | |
67 | 67 | $conf_path = "{$base_path}manager/includes/config.inc.php"; |
68 | - if (!is_file($conf_path)) $installmode = 0; |
|
69 | - elseif(isset($_POST['installmode'])) $installmode = $_POST['installmode']; |
|
70 | - else |
|
71 | - { |
|
68 | + if (!is_file($conf_path)) { |
|
69 | + $installmode = 0; |
|
70 | + } elseif(isset($_POST['installmode'])) { |
|
71 | + $installmode = $_POST['installmode']; |
|
72 | + } else { |
|
72 | 73 | include_once("{$base_path}manager/includes/config.inc.php"); |
73 | 74 | |
74 | - if(!isset($dbase) || empty($dbase)) $installmode = 0; |
|
75 | - else |
|
76 | - { |
|
75 | + if(!isset($dbase) || empty($dbase)) { |
|
76 | + $installmode = 0; |
|
77 | + } else { |
|
77 | 78 | $conn = mysqli_connect($database_server, $database_user, $database_password); |
78 | - if($conn) |
|
79 | - { |
|
79 | + if($conn) { |
|
80 | 80 | $_SESSION['database_server'] = $database_server; |
81 | 81 | $_SESSION['database_user'] = $database_user; |
82 | 82 | $_SESSION['database_password'] = $database_password; |
83 | 83 | |
84 | 84 | $dbase = trim($dbase, '`'); |
85 | 85 | $rs = mysqli_select_db($conn, $dbase); |
86 | + } else { |
|
87 | + $rs = false; |
|
86 | 88 | } |
87 | - else $rs = false; |
|
88 | 89 | |
89 | - if($rs) |
|
90 | - { |
|
90 | + if($rs) { |
|
91 | 91 | $_SESSION['dbase'] = $dbase; |
92 | 92 | $_SESSION['table_prefix'] = $table_prefix; |
93 | 93 | $_SESSION['database_collation'] = 'utf8_general_ci'; |
@@ -95,17 +95,21 @@ discard block |
||
95 | 95 | |
96 | 96 | $tbl_system_settings = "`{$dbase}`.`{$table_prefix}system_settings`"; |
97 | 97 | $rs = mysqli_query($conn, "SELECT setting_value FROM {$tbl_system_settings} WHERE setting_name='settings_version'"); |
98 | - if($rs) |
|
99 | - { |
|
98 | + if($rs) { |
|
100 | 99 | $row = mysqli_fetch_assoc($rs); |
101 | 100 | $settings_version = $row['setting_value']; |
101 | + } else { |
|
102 | + $settings_version = ''; |
|
102 | 103 | } |
103 | - else $settings_version = ''; |
|
104 | 104 | |
105 | - if (empty($settings_version)) $installmode = 0; |
|
106 | - else $installmode = 1; |
|
105 | + if (empty($settings_version)) { |
|
106 | + $installmode = 0; |
|
107 | + } else { |
|
108 | + $installmode = 1; |
|
109 | + } |
|
110 | + } else { |
|
111 | + $installmode = 1; |
|
107 | 112 | } |
108 | - else $installmode = 1; |
|
109 | 113 | } |
110 | 114 | } |
111 | 115 | return $installmode; |
@@ -520,6 +520,9 @@ discard block |
||
520 | 520 | $this->setDroptables(false); |
521 | 521 | } |
522 | 522 | |
523 | + /** |
|
524 | + * @param boolean $state |
|
525 | + */ |
|
523 | 526 | function setDroptables($state) |
524 | 527 | { |
525 | 528 | $this->_isDroptables = $state; |
@@ -734,6 +737,9 @@ discard block |
||
734 | 737 | $_SESSION['result_msg'] = $result_code; |
735 | 738 | } |
736 | 739 | |
740 | +/** |
|
741 | + * @param string $dumpstring |
|
742 | + */ |
|
737 | 743 | function dumpSql(&$dumpstring) |
738 | 744 | { |
739 | 745 | global $modx; |
@@ -753,6 +759,9 @@ discard block |
||
753 | 759 | return true; |
754 | 760 | } |
755 | 761 | |
762 | +/** |
|
763 | + * @param string $dumpstring |
|
764 | + */ |
|
756 | 765 | function snapshot(&$dumpstring) |
757 | 766 | { |
758 | 767 | global $path; |
@@ -565,6 +565,9 @@ discard block |
||
565 | 565 | |
566 | 566 | } |
567 | 567 | |
568 | +/** |
|
569 | + * @param string $file |
|
570 | + */ |
|
568 | 571 | function determineIcon($file, $selFile, $mode) |
569 | 572 | { |
570 | 573 | $icons = array( |
@@ -709,6 +712,9 @@ discard block |
||
709 | 712 | return $path; |
710 | 713 | } |
711 | 714 | |
715 | +/** |
|
716 | + * @param string $string |
|
717 | + */ |
|
712 | 718 | function getExtension($string) |
713 | 719 | { |
714 | 720 | $pos = strrpos($string, '.'); |
@@ -744,6 +750,9 @@ discard block |
||
744 | 750 | return @mkdir($strPath); |
745 | 751 | } |
746 | 752 | |
753 | +/** |
|
754 | + * @param string $type |
|
755 | + */ |
|
747 | 756 | function logFileChange($type, $filename) |
748 | 757 | { |
749 | 758 | //global $_lang; |
@@ -733,7 +733,8 @@ |
||
733 | 733 | } |
734 | 734 | |
735 | 735 | function mkdirs($strPath, $mode) |
736 | -{ // recursive mkdir function |
|
736 | +{ |
|
737 | +// recursive mkdir function |
|
737 | 738 | if (is_dir($strPath)) { |
738 | 739 | return true; |
739 | 740 | } |
@@ -160,6 +160,11 @@ discard block |
||
160 | 160 | return $output; |
161 | 161 | } |
162 | 162 | |
163 | +/** |
|
164 | + * @param integer $parent |
|
165 | + * @param string $filedir |
|
166 | + * @param string $mode |
|
167 | + */ |
|
163 | 168 | function importFiles($parent, $filedir, $files, $mode) { |
164 | 169 | global $modx; |
165 | 170 | global $_lang, $allowedfiles; |
@@ -302,6 +307,9 @@ discard block |
||
302 | 307 | } |
303 | 308 | } |
304 | 309 | |
310 | +/** |
|
311 | + * @param string $directory |
|
312 | + */ |
|
305 | 313 | function getFiles($directory, $listing = array(), $count = 0) { |
306 | 314 | global $_lang; |
307 | 315 | global $filesfound; |
@@ -326,6 +334,9 @@ discard block |
||
326 | 334 | return ($listing); |
327 | 335 | } |
328 | 336 | |
337 | +/** |
|
338 | + * @param string $filepath |
|
339 | + */ |
|
329 | 340 | function getFileContent($filepath) { |
330 | 341 | global $_lang; |
331 | 342 | // get the file |
@@ -353,6 +364,9 @@ discard block |
||
353 | 364 | return $new_array; |
354 | 365 | } |
355 | 366 | |
367 | +/** |
|
368 | + * @param null|string $src |
|
369 | + */ |
|
356 | 370 | function treatContent($src, $filename, $alias) { |
357 | 371 | global $modx; |
358 | 372 |
@@ -101,7 +101,8 @@ discard block |
||
101 | 101 | </div> |
102 | 102 | |
103 | 103 | <?php |
104 | -function run() { |
|
104 | +function run() |
|
105 | +{ |
|
105 | 106 | global $modx; |
106 | 107 | |
107 | 108 | $tbl_site_content = $modx->getFullTableName('site_content'); |
@@ -160,7 +161,8 @@ discard block |
||
160 | 161 | return $output; |
161 | 162 | } |
162 | 163 | |
163 | -function importFiles($parent, $filedir, $files, $mode) { |
|
164 | +function importFiles($parent, $filedir, $files, $mode) |
|
165 | +{ |
|
164 | 166 | global $modx; |
165 | 167 | global $_lang, $allowedfiles; |
166 | 168 | global $search_default, $cache_default, $publish_default; |
@@ -302,7 +304,8 @@ discard block |
||
302 | 304 | } |
303 | 305 | } |
304 | 306 | |
305 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
307 | +function getFiles($directory, $listing = array(), $count = 0) |
|
308 | +{ |
|
306 | 309 | global $_lang; |
307 | 310 | global $filesfound; |
308 | 311 | $dummy = $count; |
@@ -326,7 +329,8 @@ discard block |
||
326 | 329 | return ($listing); |
327 | 330 | } |
328 | 331 | |
329 | -function getFileContent($filepath) { |
|
332 | +function getFileContent($filepath) |
|
333 | +{ |
|
330 | 334 | global $_lang; |
331 | 335 | // get the file |
332 | 336 | if(!$buffer = file_get_contents($filepath)) { |
@@ -336,7 +340,8 @@ discard block |
||
336 | 340 | } |
337 | 341 | } |
338 | 342 | |
339 | -function pop_index($array) { |
|
343 | +function pop_index($array) |
|
344 | +{ |
|
340 | 345 | $new_array = array(); |
341 | 346 | foreach($array as $k => $v) { |
342 | 347 | if($v !== 'index.html' && $v !== 'index.htm') { |
@@ -353,7 +358,8 @@ discard block |
||
353 | 358 | return $new_array; |
354 | 359 | } |
355 | 360 | |
356 | -function treatContent($src, $filename, $alias) { |
|
361 | +function treatContent($src, $filename, $alias) |
|
362 | +{ |
|
357 | 363 | global $modx; |
358 | 364 | |
359 | 365 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
@@ -394,7 +400,8 @@ discard block |
||
394 | 400 | ); |
395 | 401 | } |
396 | 402 | |
397 | -function convertLink() { |
|
403 | +function convertLink() |
|
404 | +{ |
|
398 | 405 | global $modx; |
399 | 406 | $tbl_site_content = $modx->getFullTableName('site_content'); |
400 | 407 |
@@ -16,6 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * get_langs_by_key |
18 | 18 | * |
19 | + * @param string $key |
|
19 | 20 | * @return array of languages that define the key in their file |
20 | 21 | */ |
21 | 22 | function get_langs_by_key($key) { |
@@ -36,7 +37,7 @@ discard block |
||
36 | 37 | * |
37 | 38 | * @param string $key specify language key to return options of langauges that override it, default return all languages |
38 | 39 | * @param string $selected_lang specify language to select in option list, default none |
39 | - * @return html option list |
|
40 | + * @return string option list |
|
40 | 41 | */ |
41 | 42 | function get_lang_options($key=null, $selected_lang=null) { |
42 | 43 | global $lang_keys, $_lang; |
@@ -4,12 +4,13 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @return array of keys from a language file |
6 | 6 | */ |
7 | -function get_lang_keys($filename) { |
|
7 | +function get_lang_keys($filename) |
|
8 | +{ |
|
8 | 9 | $file = MODX_MANAGER_PATH.'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
9 | - if(is_file($file) && is_readable($file)) { |
|
10 | + if(is_file($file) && is_readable($file)) { |
|
10 | 11 | include($file); |
11 | 12 | return array_keys($_lang); |
12 | - } else { |
|
13 | + } else { |
|
13 | 14 | return array(); |
14 | 15 | } |
15 | 16 | } |
@@ -18,11 +19,12 @@ discard block |
||
18 | 19 | * |
19 | 20 | * @return array of languages that define the key in their file |
20 | 21 | */ |
21 | -function get_langs_by_key($key) { |
|
22 | +function get_langs_by_key($key) |
|
23 | +{ |
|
22 | 24 | global $lang_keys; |
23 | 25 | $lang_return = array(); |
24 | - foreach($lang_keys as $lang=>$keys) { |
|
25 | - if(in_array($key, $keys)) { |
|
26 | + foreach($lang_keys as $lang=>$keys) { |
|
27 | + if(in_array($key, $keys)) { |
|
26 | 28 | $lang_return[] = $lang; |
27 | 29 | } |
28 | 30 | } |
@@ -38,23 +40,24 @@ discard block |
||
38 | 40 | * @param string $selected_lang specify language to select in option list, default none |
39 | 41 | * @return html option list |
40 | 42 | */ |
41 | -function get_lang_options($key=null, $selected_lang=null) { |
|
43 | +function get_lang_options($key=null, $selected_lang=null) |
|
44 | +{ |
|
42 | 45 | global $lang_keys, $_lang; |
43 | 46 | $lang_options = ''; |
44 | - if($key) { |
|
47 | + if($key) { |
|
45 | 48 | $languages = get_langs_by_key($key); |
46 | 49 | sort($languages); |
47 | 50 | $lang_options .= '<option value="">'.$_lang['language_title'].'</option>'; |
48 | 51 | |
49 | - foreach($languages as $language_name) { |
|
52 | + foreach($languages as $language_name) { |
|
50 | 53 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
51 | 54 | $lang_options .= '<option value="'.$language_name.'">'.$uclanguage_name.'</option>'; |
52 | 55 | } |
53 | 56 | return $lang_options; |
54 | - } else { |
|
57 | + } else { |
|
55 | 58 | $languages = array_keys($lang_keys); |
56 | 59 | sort($languages); |
57 | - foreach($languages as $language_name) { |
|
60 | + foreach($languages as $language_name) { |
|
58 | 61 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
59 | 62 | $sel = $language_name == $selected_lang ? ' selected="selected"' : ''; |
60 | 63 | $lang_options .= '<option value="'.$language_name.'" '.$sel.'>'.$uclanguage_name.'</option>'; |
@@ -63,31 +66,42 @@ discard block |
||
63 | 66 | } |
64 | 67 | } |
65 | 68 | |
66 | -function form_radio($name,$value,$add='',$disabled=false) { |
|
69 | +function form_radio($name,$value,$add='',$disabled=false) |
|
70 | +{ |
|
67 | 71 | global ${$name}; |
68 | 72 | $var = ${$name}; |
69 | 73 | $checked = ($var==$value) ? ' checked="checked"' : ''; |
70 | - if($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
71 | - if($add) $add = ' ' . $add; |
|
74 | + if($disabled) { |
|
75 | + $disabled = ' disabled'; |
|
76 | + } else { |
|
77 | + $disabled = ''; |
|
78 | + } |
|
79 | + if($add) { |
|
80 | + $add = ' ' . $add; |
|
81 | + } |
|
72 | 82 | return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add); |
73 | 83 | } |
74 | 84 | |
75 | -function wrap_label($str='',$object) { |
|
85 | +function wrap_label($str='',$object) |
|
86 | +{ |
|
76 | 87 | return "<label>{$object}\n{$str}</label>"; |
77 | 88 | } |
78 | 89 | |
79 | -function parseText($tpl='', $ph=array()) { |
|
80 | - if(empty($ph) || empty($tpl)) return $tpl; |
|
90 | +function parseText($tpl='', $ph=array()) |
|
91 | +{ |
|
92 | + if(empty($ph) || empty($tpl)) { |
|
93 | + return $tpl; |
|
94 | + } |
|
81 | 95 | |
82 | - foreach($ph as $k=>$v) |
|
83 | - { |
|
96 | + foreach($ph as $k=>$v) { |
|
84 | 97 | $k = "[+{$k}+]"; |
85 | 98 | $tpl = str_replace($k, $v, $tpl); |
86 | 99 | } |
87 | 100 | return $tpl; |
88 | 101 | } |
89 | 102 | |
90 | -function showHide($cond=true) { |
|
103 | +function showHide($cond=true) |
|
104 | +{ |
|
91 | 105 | global $displayStyle; |
92 | 106 | $showHide = $cond ? $displayStyle : 'none'; |
93 | 107 | return sprintf('style="display:%s"', $showHide); |
@@ -504,6 +504,9 @@ |
||
504 | 504 | return $iconsPrivate; |
505 | 505 | } |
506 | 506 | |
507 | +/** |
|
508 | + * @return string |
|
509 | + */ |
|
507 | 510 | function getNodeTitle($nodeNameSource, $row) { |
508 | 511 | global $modx; |
509 | 512 |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | * @param $theme |
11 | 11 | * @param string $hereid |
12 | 12 | */ |
13 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
13 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') |
|
14 | +{ |
|
14 | 15 | global $modx; |
15 | 16 | global $icons, $iconsPrivate, $_style; |
16 | 17 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -450,7 +451,8 @@ discard block |
||
450 | 451 | return $output; |
451 | 452 | } |
452 | 453 | |
453 | -function getIconInfo($_style) { |
|
454 | +function getIconInfo($_style) |
|
455 | +{ |
|
454 | 456 | if(!isset($_style['tree_page_gif'])) { |
455 | 457 | $_style['tree_page_gif'] = $_style['tree_page']; |
456 | 458 | } |
@@ -477,7 +479,8 @@ discard block |
||
477 | 479 | return $icons; |
478 | 480 | } |
479 | 481 | |
480 | -function getPrivateIconInfo($_style) { |
|
482 | +function getPrivateIconInfo($_style) |
|
483 | +{ |
|
481 | 484 | if(!isset($_style['tree_page_gif_secure'])) { |
482 | 485 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
483 | 486 | } |
@@ -504,7 +507,8 @@ discard block |
||
504 | 507 | return $iconsPrivate; |
505 | 508 | } |
506 | 509 | |
507 | -function getNodeTitle($nodeNameSource, $row) { |
|
510 | +function getNodeTitle($nodeNameSource, $row) |
|
511 | +{ |
|
508 | 512 | global $modx; |
509 | 513 | |
510 | 514 | switch($nodeNameSource) { |
@@ -550,7 +554,8 @@ discard block |
||
550 | 554 | return $nodetitle; |
551 | 555 | } |
552 | 556 | |
553 | -function isDateNode($nodeNameSource) { |
|
557 | +function isDateNode($nodeNameSource) |
|
558 | +{ |
|
554 | 559 | switch($nodeNameSource) { |
555 | 560 | case 'createdon': |
556 | 561 | case 'editedon': |
@@ -563,13 +568,15 @@ discard block |
||
563 | 568 | } |
564 | 569 | } |
565 | 570 | |
566 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
571 | +function checkIsFolder($parent = 0, $isfolder = 1) |
|
572 | +{ |
|
567 | 573 | global $modx; |
568 | 574 | |
569 | 575 | return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
570 | 576 | } |
571 | 577 | |
572 | -function _htmlentities($array) { |
|
578 | +function _htmlentities($array) |
|
579 | +{ |
|
573 | 580 | global $modx; |
574 | 581 | |
575 | 582 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -578,7 +585,8 @@ discard block |
||
578 | 585 | return $array; |
579 | 586 | } |
580 | 587 | |
581 | -function getTplSingleNode() { |
|
588 | +function getTplSingleNode() |
|
589 | +{ |
|
582 | 590 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
583 | 591 | onclick="modx.tree.treeAction(event,[+id+]);" |
584 | 592 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -602,7 +610,8 @@ discard block |
||
602 | 610 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a></div>'; |
603 | 611 | } |
604 | 612 | |
605 | -function getTplFolderNode() { |
|
613 | +function getTplFolderNode() |
|
614 | +{ |
|
606 | 615 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
607 | 616 | onclick="modx.tree.treeAction(event,[+id+]);" |
608 | 617 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -638,7 +647,8 @@ discard block |
||
638 | 647 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
639 | 648 | } |
640 | 649 | |
641 | -function getTplFolderNodeNotChildren() { |
|
650 | +function getTplFolderNodeNotChildren() |
|
651 | +{ |
|
642 | 652 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
643 | 653 | onclick="modx.tree.treeAction(event,[+id+]);" |
644 | 654 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -670,7 +680,8 @@ discard block |
||
670 | 680 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
671 | 681 | } |
672 | 682 | |
673 | -function dbug($str, $flag = false) { |
|
683 | +function dbug($str, $flag = false) |
|
684 | +{ |
|
674 | 685 | print('<pre>'); |
675 | 686 | print_r($str); |
676 | 687 | print('</pre>'); |
@@ -3,6 +3,9 @@ |
||
3 | 3 | //Kyle Jaebker - 08/07/06 |
4 | 4 | |
5 | 5 | //Create a new category |
6 | +/** |
|
7 | + * @param string $newCat |
|
8 | + */ |
|
6 | 9 | function newCategory($newCat) { |
7 | 10 | global $modx; |
8 | 11 | $useTable = $modx->getFullTableName('categories'); |
@@ -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'); |
@@ -52,6 +52,9 @@ discard block |
||
52 | 52 | var $selPageClass; |
53 | 53 | var $noRecordMsg = "No records found."; |
54 | 54 | |
55 | + /** |
|
56 | + * @param string $id |
|
57 | + */ |
|
55 | 58 | function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
56 | 59 | global $__DataGridCnt; |
57 | 60 | |
@@ -187,6 +190,9 @@ discard block |
||
187 | 190 | |
188 | 191 | // format column values |
189 | 192 | |
193 | + /** |
|
194 | + * @param integer $n |
|
195 | + */ |
|
190 | 196 | function RenderRowFnc($n, $row) { |
191 | 197 | if($this->_alt == 0) { |
192 | 198 | $Style = $this->_itemStyle; |
@@ -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 | } |
@@ -73,6 +73,9 @@ |
||
73 | 73 | $this->pageSize = $ps; |
74 | 74 | } |
75 | 75 | |
76 | + /** |
|
77 | + * @param DataGrid $fncName |
|
78 | + */ |
|
76 | 79 | function setRenderRowFnc($fncName, $args = "") { |
77 | 80 | $this->renderRowFnc = &$fncName; |
78 | 81 | $this->renderRowFncArgs = $args; // extra agruments |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | var $ds; // datasource |
16 | 17 | var $pageSize; |
@@ -27,7 +28,8 @@ discard block |
||
27 | 28 | var $selPageStyle; |
28 | 29 | var $selPageClass; |
29 | 30 | |
30 | - function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
31 | + function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
32 | + { |
|
31 | 33 | global $_PAGE; // use view state object |
32 | 34 | |
33 | 35 | global $__DataSetPagerCnt; |
@@ -57,35 +59,42 @@ discard block |
||
57 | 59 | $this->pager = ''; |
58 | 60 | } |
59 | 61 | |
60 | - function getRenderedPager() { |
|
62 | + function getRenderedPager() |
|
63 | + { |
|
61 | 64 | return $this->pager; |
62 | 65 | } |
63 | 66 | |
64 | - function getRenderedRows() { |
|
67 | + function getRenderedRows() |
|
68 | + { |
|
65 | 69 | return $this->rows; |
66 | 70 | } |
67 | 71 | |
68 | - function setDataSource($ds) { |
|
72 | + function setDataSource($ds) |
|
73 | + { |
|
69 | 74 | $this->ds = $ds; |
70 | 75 | } |
71 | 76 | |
72 | - function setPageSize($ps) { |
|
77 | + function setPageSize($ps) |
|
78 | + { |
|
73 | 79 | $this->pageSize = $ps; |
74 | 80 | } |
75 | 81 | |
76 | - function setRenderRowFnc($fncName, $args = "") { |
|
82 | + function setRenderRowFnc($fncName, $args = "") |
|
83 | + { |
|
77 | 84 | $this->renderRowFnc = &$fncName; |
78 | 85 | $this->renderRowFncArgs = $args; // extra agruments |
79 | 86 | |
80 | 87 | |
81 | 88 | } |
82 | 89 | |
83 | - function setRenderPagerFnc($fncName, $args = "") { |
|
90 | + function setRenderPagerFnc($fncName, $args = "") |
|
91 | + { |
|
84 | 92 | $this->renderPagerFnc = $fncName; |
85 | 93 | $this->renderPagerFncArgs = $args; // extra agruments |
86 | 94 | } |
87 | 95 | |
88 | - function render() { |
|
96 | + function render() |
|
97 | + { |
|
89 | 98 | global $modx, $_PAGE; |
90 | 99 | |
91 | 100 | $isDataset = $modx->db->isResult($this->ds); |
@@ -137,8 +146,10 @@ discard block |
||
137 | 146 | $url = $_SERVER['PHP_SELF'] . '?'; |
138 | 147 | } |
139 | 148 | $i = 0; |
140 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
149 | + foreach($_GET as $n => $v) { |
|
150 | + if($n != 'dpgn' . $this->id) { |
|
141 | 151 | $i++; |
152 | + } |
|
142 | 153 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
143 | 154 | } |
144 | 155 | if($i >= 1) { |