@@ -149,7 +149,7 @@ |
||
| 149 | 149 | /** |
| 150 | 150 | * This function returns the current page number. |
| 151 | 151 | * |
| 152 | - * @return int |
|
| 152 | + * @return string |
|
| 153 | 153 | */ |
| 154 | 154 | public function getCurrentPage() |
| 155 | 155 | { |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | $array_paging['total'] = $this->int_nbr_row; |
| 102 | 102 | |
| 103 | 103 | if ($this->int_cur_position != 0) { |
| 104 | - $array_paging['first_link'] = "<a href=\"$PHP_SELF?int_cur_position=0" . $this->str_ext_argv . "\">"; |
|
| 105 | - $array_paging['previous_link'] = "<a href=\"$PHP_SELF?int_cur_position=" . ($this->int_cur_position - $this->int_num_result) . $this->str_ext_argv . "\">"; |
|
| 104 | + $array_paging['first_link'] = "<a href=\"$PHP_SELF?int_cur_position=0".$this->str_ext_argv."\">"; |
|
| 105 | + $array_paging['previous_link'] = "<a href=\"$PHP_SELF?int_cur_position=".($this->int_cur_position - $this->int_num_result).$this->str_ext_argv."\">"; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if (($this->int_nbr_row - $this->int_cur_position) > $this->int_num_result) { |
| 109 | 109 | $int_new_position = $this->int_cur_position + $this->int_num_result; |
| 110 | - $array_paging['last_link'] = "<a href=\"$PHP_SELF?int_cur_position=" . $this->int_nbr_row . $this->str_ext_argv . "\">"; |
|
| 111 | - $array_paging['next_link'] = "<a href=\"$PHP_SELF?int_cur_position=$int_new_position" . $this->str_ext_argv . "\">"; |
|
| 110 | + $array_paging['last_link'] = "<a href=\"$PHP_SELF?int_cur_position=".$this->int_nbr_row.$this->str_ext_argv."\">"; |
|
| 111 | + $array_paging['next_link'] = "<a href=\"$PHP_SELF?int_cur_position=$int_new_position".$this->str_ext_argv."\">"; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | return $array_paging; |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | for ($i = 0; $i < $this->getNumberOfPage(); $i++) { |
| 127 | 127 | // if current page, do not make a link |
| 128 | 128 | if ($i == $this->getCurrentPage()) { |
| 129 | - $array_all_page[$i] = "<b>" . ($i + 1) . "</b> "; |
|
| 129 | + $array_all_page[$i] = "<b>".($i + 1)."</b> "; |
|
| 130 | 130 | } else { |
| 131 | 131 | $int_new_position = ($i * $this->int_num_result); |
| 132 | - $array_all_page[$i] = "<a href=\"" . $PHP_SELF . "?int_cur_position=$int_new_position$this->str_ext_argv\">" . ($i + 1) . "</a> "; |
|
| 132 | + $array_all_page[$i] = "<a href=\"".$PHP_SELF."?int_cur_position=$int_new_position$this->str_ext_argv\">".($i + 1)."</a> "; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | * @deprecated EvolutionCMS\Legacy\ErrorHandler |
| 6 | 6 | * @todo could be unnecessary |
| 7 | 7 | */ |
| 8 | -class errorHandler extends EvolutionCMS\Legacy\ErrorHandler { |
|
| 8 | +class errorHandler extends EvolutionCMS\Legacy\ErrorHandler{ |
|
| 9 | 9 | public function include_lang($context = 'common') |
| 10 | 10 | { |
| 11 | 11 | parent::includeLang($context); |
@@ -5,7 +5,8 @@ |
||
| 5 | 5 | * @deprecated EvolutionCMS\Legacy\ErrorHandler |
| 6 | 6 | * @todo could be unnecessary |
| 7 | 7 | */ |
| 8 | -class errorHandler extends EvolutionCMS\Legacy\ErrorHandler { |
|
| 8 | +class errorHandler extends EvolutionCMS\Legacy\ErrorHandler |
|
| 9 | +{ |
|
| 9 | 10 | public function include_lang($context = 'common') |
| 10 | 11 | { |
| 11 | 12 | parent::includeLang($context); |
@@ -3,4 +3,6 @@ |
||
| 3 | 3 | /** |
| 4 | 4 | * @deprecated use EvolutionCMS\Legacy\LogHandler |
| 5 | 5 | */ |
| 6 | -class logHandler extends EvolutionCMS\Legacy\LogHandler{} |
|
| 6 | +class logHandler extends EvolutionCMS\Legacy\LogHandler |
|
| 7 | +{ |
|
| 8 | +} |
|
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $role = $this->role; |
| 37 | 37 | |
| 38 | 38 | if ($role == 1) { |
| 39 | - return true; // administrator - grant all document permissions |
|
| 39 | + return true; // administrator - grant all document permissions |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | if ($modx->config['use_udperms'] == 0 || $modx->config['use_udperms'] == "" || !isset($modx->config['use_udperms'])) { |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | are private to the manager users will not be private to web users if the |
| 64 | 64 | document group is not assigned to a web user group and visa versa. |
| 65 | 65 | */ |
| 66 | - $permissionsok = false; // set permissions to false |
|
| 66 | + $permissionsok = false; // set permissions to false |
|
| 67 | 67 | |
| 68 | 68 | $rs = $modx->db->select( |
| 69 | 69 | 'count(DISTINCT sc.id)', |
| 70 | 70 | "{$tblsc} AS sc |
| 71 | 71 | LEFT JOIN {$tbldg} AS dg on dg.document = sc.id |
| 72 | 72 | LEFT JOIN {$tbldgn} dgn ON dgn.id = dg.document_group", |
| 73 | - "sc.id='{$this->document}' AND (" . (empty($docgrp) ? '' : "dg.document_group = " . $docgrp . " ||") . " sc.privatemgr = 0)" |
|
| 73 | + "sc.id='{$this->document}' AND (".(empty($docgrp) ? '' : "dg.document_group = ".$docgrp." ||")." sc.privatemgr = 0)" |
|
| 74 | 74 | ); |
| 75 | 75 | $limit = $modx->db->getValue($rs); |
| 76 | 76 | if ($limit == 1) { |
@@ -71,11 +71,11 @@ |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | if ($context === 'common') { |
| 74 | - $lang_path = MODX_MANAGER_PATH . 'includes/lang/'; |
|
| 74 | + $lang_path = MODX_MANAGER_PATH.'includes/lang/'; |
|
| 75 | 75 | } else { |
| 76 | - $lang_path = MODX_MANAGER_PATH . "includes/lang/{$context}/"; |
|
| 76 | + $lang_path = MODX_MANAGER_PATH."includes/lang/{$context}/"; |
|
| 77 | 77 | } |
| 78 | - include_once($lang_path . 'english.inc.php'); |
|
| 78 | + include_once($lang_path.'english.inc.php'); |
|
| 79 | 79 | $manager_language = $modx->config['manager_language']; |
| 80 | 80 | if (is_file("{$lang_path}{$manager_language}.inc.php")) { |
| 81 | 81 | include_once("{$lang_path}{$manager_language}.inc.php"); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $this->db_tbl['categories'] = $modx->getFullTableName('categories'); |
| 21 | 21 | |
| 22 | 22 | foreach ($this->elements as $element) { |
| 23 | - $this->db_tbl[$element] = $modx->getFullTableName('site_' . $element); |
|
| 23 | + $this->db_tbl[$element] = $modx->getFullTableName('site_'.$element); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $this->db->select( |
| 55 | 55 | '*', |
| 56 | 56 | $this->db_tbl['categories'], |
| 57 | - "`" . $where . "` = '" . $this->db->escape($search) . "'" |
|
| 57 | + "`".$where."` = '".$this->db->escape($search)."'" |
|
| 58 | 58 | ) |
| 59 | 59 | ); |
| 60 | 60 | |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $_value = $this->db->getValue( |
| 73 | 73 | $this->db->select( |
| 74 | - '`' . $value . '`', |
|
| 74 | + '`'.$value.'`', |
|
| 75 | 75 | $this->db_tbl['categories'], |
| 76 | - "`" . $where . "` = '" . $this->db->escape($search) . "'" |
|
| 76 | + "`".$where."` = '".$this->db->escape($search)."'" |
|
| 77 | 77 | ) |
| 78 | 78 | ); |
| 79 | 79 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $this->db->select( |
| 93 | 93 | '*', |
| 94 | 94 | $this->db_tbl[$element], |
| 95 | - "`category` = '" . (int)$category_id . "'" |
|
| 95 | + "`category` = '".(int) $category_id."'" |
|
| 96 | 96 | ) |
| 97 | 97 | ); |
| 98 | 98 | |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | $this->db->update( |
| 136 | 136 | $_update, |
| 137 | 137 | $this->db_tbl[$element], |
| 138 | - "`category` = '" . (int)$category_id . "'" |
|
| 138 | + "`category` = '".(int) $category_id."'" |
|
| 139 | 139 | ); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $this->db->delete( |
| 143 | 143 | $this->db_tbl['categories'], |
| 144 | - "`id` = '" . (int)$category_id . "'" |
|
| 144 | + "`id` = '".(int) $category_id."'" |
|
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | 147 | return $this->db->getAffectedRows() === 1; |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $_update = array( |
| 162 | 162 | 'category' => $this->db->escape($data['category']), |
| 163 | - 'rank' => (int)$data['rank'] |
|
| 163 | + 'rank' => (int) $data['rank'] |
|
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | $this->db->update( |
| 167 | 167 | $_update, |
| 168 | 168 | $this->db_tbl['categories'], |
| 169 | - "`id` = '" . (int)$category_id . "'" |
|
| 169 | + "`id` = '".(int) $category_id."'" |
|
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | if ($this->db->getAffectedRows() === 1) { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $_insert = array( |
| 191 | 191 | 'category' => $this->db->escape($category_name), |
| 192 | - 'rank' => (int)$category_rank |
|
| 192 | + 'rank' => (int) $category_rank |
|
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | 195 | $this->db->insert( |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $this->db->select( |
| 217 | 217 | '`id`', |
| 218 | 218 | $this->db_tbl['categories'], |
| 219 | - "`category` = '" . $category . "'" |
|
| 219 | + "`category` = '".$category."'" |
|
| 220 | 220 | ) |
| 221 | 221 | ); |
| 222 | 222 | |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | $action = "", |
| 37 | 37 | $itemid = "", |
| 38 | 38 | $itemname = "" |
| 39 | - ) { |
|
| 39 | + ){ |
|
| 40 | 40 | $modx = evolutionCMS(); |
| 41 | 41 | $this->entry['msg'] = $msg; // writes testmessage to the object |
| 42 | - $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
| 42 | + $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
| 43 | 43 | |
| 44 | 44 | // User Credentials |
| 45 | 45 | $this->entry['internalKey'] = $internalKey == "" ? $modx->getLoginUserID() : $internalKey; |
| 46 | 46 | $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username; |
| 47 | 47 | |
| 48 | - $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 48 | + $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int) $_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 49 | 49 | if ($this->entry['itemId'] == 0) { |
| 50 | 50 | $this->entry['itemId'] = "-"; |
| 51 | 51 | } // to stop items having id 0 |
@@ -96,20 +96,20 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $insert_id = $modx->db->insert($fields, $tbl_manager_log); |
| 98 | 98 | if (!$insert_id) { |
| 99 | - $modx->messageQuit("Logging error: couldn't save log to table! Error code: " . $modx->db->getLastError()); |
|
| 99 | + $modx->messageQuit("Logging error: couldn't save log to table! Error code: ".$modx->db->getLastError()); |
|
| 100 | 100 | } else { |
| 101 | - $limit = (isset($modx->config['manager_log_limit'])) ? (int)$modx->config['manager_log_limit'] : 3000; |
|
| 102 | - $trim = (isset($modx->config['manager_log_trim'])) ? (int)$modx->config['manager_log_trim'] : 100; |
|
| 101 | + $limit = (isset($modx->config['manager_log_limit'])) ? (int) $modx->config['manager_log_limit'] : 3000; |
|
| 102 | + $trim = (isset($modx->config['manager_log_trim'])) ? (int) $modx->config['manager_log_trim'] : 100; |
|
| 103 | 103 | if (($insert_id % $trim) === 0) { |
| 104 | 104 | $modx->rotate_log('manager_log', $limit, $trim); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - private function getUserIP() { |
|
| 110 | - if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) { |
|
| 111 | - if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) { |
|
| 112 | - $addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 109 | + private function getUserIP(){ |
|
| 110 | + if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 111 | + if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') > 0) { |
|
| 112 | + $addr = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 113 | 113 | return trim($addr[0]); |
| 114 | 114 | } else { |
| 115 | 115 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
@@ -105,7 +105,8 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - private function getUserIP() { |
|
| 108 | + private function getUserIP() |
|
| 109 | + { |
|
| 109 | 110 | if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) { |
| 110 | 111 | if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) { |
| 111 | 112 | $addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']); |
@@ -113,8 +114,7 @@ discard block |
||
| 113 | 114 | } else { |
| 114 | 115 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 115 | 116 | } |
| 116 | - } |
|
| 117 | - else { |
|
| 117 | + } else { |
|
| 118 | 118 | return $_SERVER['REMOTE_ADDR']; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php namespace EvolutionCMS\Legacy; |
| 2 | 2 | |
| 3 | -class mgrResources { |
|
| 3 | +class mgrResources{ |
|
| 4 | 4 | /** |
| 5 | 5 | * @var array |
| 6 | 6 | */ |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * mgrResources constructor. |
| 23 | 23 | */ |
| 24 | - public function __construct() { |
|
| 24 | + public function __construct(){ |
|
| 25 | 25 | $this->setTypes(); |
| 26 | 26 | $this->queryItemsFromDB(); |
| 27 | 27 | $this->prepareCategoryArrays(); |
@@ -30,47 +30,47 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * @return void |
| 32 | 32 | */ |
| 33 | - public function setTypes() { |
|
| 33 | + public function setTypes(){ |
|
| 34 | 34 | global $_lang; |
| 35 | - $this->types['site_templates'] = array( |
|
| 35 | + $this->types['site_templates'] = array( |
|
| 36 | 36 | 'title'=>$_lang["manage_templates"], |
| 37 | - 'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ), |
|
| 38 | - 'permissions'=>array('new_template','edit_template'), |
|
| 37 | + 'actions'=>array('edit'=>array(16, 'edit_template'), 'duplicate'=>array(96, 'new_template'), 'remove'=>array(21, 'delete_template')), |
|
| 38 | + 'permissions'=>array('new_template', 'edit_template'), |
|
| 39 | 39 | 'name'=>'templatename' |
| 40 | 40 | ); |
| 41 | - $this->types['site_tmplvars'] = array( |
|
| 41 | + $this->types['site_tmplvars'] = array( |
|
| 42 | 42 | 'title'=>$_lang["tmplvars"], |
| 43 | - 'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')), |
|
| 44 | - 'permissions'=>array('new_template','edit_template'), |
|
| 43 | + 'actions'=>array('edit'=>array(301, 'edit_template'), 'duplicate'=>array(304, 'edit_template'), 'remove'=>array(303, 'edit_template')), |
|
| 44 | + 'permissions'=>array('new_template', 'edit_template'), |
|
| 45 | 45 | ); |
| 46 | 46 | $this->types['site_htmlsnippets'] = array( |
| 47 | 47 | 'title'=>$_lang["manage_htmlsnippets"], |
| 48 | - 'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')), |
|
| 49 | - 'permissions'=>array('new_chunk','edit_chunk'), |
|
| 48 | + 'actions'=>array('edit'=>array(78, 'edit_chunk'), 'duplicate'=>array(97, 'new_chunk'), 'remove'=>array(80, 'delete_chunk')), |
|
| 49 | + 'permissions'=>array('new_chunk', 'edit_chunk'), |
|
| 50 | 50 | ); |
| 51 | - $this->types['site_snippets'] = array( |
|
| 51 | + $this->types['site_snippets'] = array( |
|
| 52 | 52 | 'title'=>$_lang["manage_snippets"], |
| 53 | - 'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')), |
|
| 54 | - 'permissions'=>array('new_snippet','edit_snippet'), |
|
| 53 | + 'actions'=>array('edit'=>array(22, 'edit_snippet'), 'duplicate'=>array(98, 'new_snippet'), 'remove'=>array(25, 'delete_snippet')), |
|
| 54 | + 'permissions'=>array('new_snippet', 'edit_snippet'), |
|
| 55 | 55 | ); |
| 56 | - $this->types['site_plugins'] = array( |
|
| 56 | + $this->types['site_plugins'] = array( |
|
| 57 | 57 | 'title'=>$_lang["manage_plugins"], |
| 58 | - 'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')), |
|
| 59 | - 'permissions'=>array('new_plugin','edit_plugin'), |
|
| 58 | + 'actions'=>array('edit'=>array(102, 'edit_plugin'), 'duplicate'=>array(105, 'new_plugin'), 'remove'=>array(104, 'delete_plugin')), |
|
| 59 | + 'permissions'=>array('new_plugin', 'edit_plugin'), |
|
| 60 | 60 | ); |
| 61 | - $this->types['site_modules'] = array( |
|
| 61 | + $this->types['site_modules'] = array( |
|
| 62 | 62 | 'title'=>$_lang["manage_modules"], |
| 63 | - 'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')), |
|
| 64 | - 'permissions'=>array('new_module','edit_module'), |
|
| 63 | + 'actions'=>array('edit'=>array(108, 'edit_module'), 'duplicate'=>array(111, 'new_module'), 'remove'=>array(110, 'delete_module')), |
|
| 64 | + 'permissions'=>array('new_module', 'edit_module'), |
|
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | - public function queryItemsFromDB() { |
|
| 72 | - foreach($this->types as $resourceTable=>$type) { |
|
| 73 | - if($this->hasAnyPermissions($type['permissions'])) { |
|
| 71 | + public function queryItemsFromDB(){ |
|
| 72 | + foreach ($this->types as $resourceTable=>$type) { |
|
| 73 | + if ($this->hasAnyPermissions($type['permissions'])) { |
|
| 74 | 74 | $nameField = isset($type['name']) ? $type['name'] : 'name'; |
| 75 | 75 | $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField); |
| 76 | 76 | } |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | * @param array $permissions |
| 82 | 82 | * @return bool |
| 83 | 83 | */ |
| 84 | - public function hasAnyPermissions($permissions) { |
|
| 84 | + public function hasAnyPermissions($permissions){ |
|
| 85 | 85 | $modx = evolutionCMS(); |
| 86 | 86 | |
| 87 | - foreach($permissions as $p) |
|
| 88 | - if($modx->hasPermission($p)) return true; |
|
| 87 | + foreach ($permissions as $p) |
|
| 88 | + if ($modx->hasPermission($p)) return true; |
|
| 89 | 89 | |
| 90 | 90 | return false; |
| 91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $nameField |
| 96 | 96 | * @return array|bool |
| 97 | 97 | */ |
| 98 | - public function queryResources($resourceTable, $nameField = 'name') { |
|
| 98 | + public function queryResources($resourceTable, $nameField = 'name'){ |
|
| 99 | 99 | $modx = evolutionCMS(); global $_lang; |
| 100 | 100 | |
| 101 | 101 | $allowed = array( |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | 'site_plugins', |
| 105 | 105 | 'site_modules' |
| 106 | 106 | ); |
| 107 | - $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : ''; |
|
| 107 | + $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable.'.disabled, ' : ''; |
|
| 108 | 108 | |
| 109 | 109 | $tvsql = ''; |
| 110 | 110 | $tvjoin = ''; |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $rs = $modx->db->select( |
| 121 | 121 | "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid", |
| 122 | - $modx->getFullTableName($resourceTable) . " AS {$resourceTable} |
|
| 123 | - LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
|
| 122 | + $modx->getFullTableName($resourceTable)." AS {$resourceTable} |
|
| 123 | + LEFT JOIN ".$modx->getFullTableName('categories')." AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
|
| 124 | 124 | "", |
| 125 | 125 | "category,name" |
| 126 | 126 | ); |
| 127 | 127 | $limit = $modx->db->getRecordCount($rs); |
| 128 | 128 | |
| 129 | - if($limit < 1) return false; |
|
| 129 | + if ($limit < 1) return false; |
|
| 130 | 130 | |
| 131 | 131 | $result = array(); |
| 132 | 132 | while ($row = $modx->db->getRow($rs)) { |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | /** |
| 139 | 139 | * @return void |
| 140 | 140 | */ |
| 141 | - public function prepareCategoryArrays() { |
|
| 142 | - foreach($this->items as $type=>$items) { |
|
| 143 | - foreach((array)$items as $item) { |
|
| 141 | + public function prepareCategoryArrays(){ |
|
| 142 | + foreach ($this->items as $type=>$items) { |
|
| 143 | + foreach ((array) $items as $item) { |
|
| 144 | 144 | $catid = $item['catid'] ? $item['catid'] : 0; |
| 145 | 145 | $this->categories[$catid] = $item['category']; |
| 146 | 146 | |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | natcasesort($this->categories); |
| 154 | 154 | |
| 155 | 155 | // Now sort by name |
| 156 | - foreach($this->itemsPerCategory as $catid=>$items) { |
|
| 157 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
| 156 | + foreach ($this->itemsPerCategory as $catid=>$items) { |
|
| 157 | + usort($this->itemsPerCategory[$catid], function($a, $b){ |
|
| 158 | 158 | return strcasecmp($a['name'], $b['name']); |
| 159 | 159 | }); |
| 160 | 160 | } |
@@ -1,6 +1,7 @@ discard block |
||
| 1 | 1 | <?php namespace EvolutionCMS\Legacy; |
| 2 | 2 | |
| 3 | -class mgrResources { |
|
| 3 | +class mgrResources |
|
| 4 | +{ |
|
| 4 | 5 | /** |
| 5 | 6 | * @var array |
| 6 | 7 | */ |
@@ -21,7 +22,8 @@ discard block |
||
| 21 | 22 | /** |
| 22 | 23 | * mgrResources constructor. |
| 23 | 24 | */ |
| 24 | - public function __construct() { |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 25 | 27 | $this->setTypes(); |
| 26 | 28 | $this->queryItemsFromDB(); |
| 27 | 29 | $this->prepareCategoryArrays(); |
@@ -30,7 +32,8 @@ discard block |
||
| 30 | 32 | /** |
| 31 | 33 | * @return void |
| 32 | 34 | */ |
| 33 | - public function setTypes() { |
|
| 35 | + public function setTypes() |
|
| 36 | + { |
|
| 34 | 37 | global $_lang; |
| 35 | 38 | $this->types['site_templates'] = array( |
| 36 | 39 | 'title'=>$_lang["manage_templates"], |
@@ -68,7 +71,8 @@ discard block |
||
| 68 | 71 | /** |
| 69 | 72 | * @return void |
| 70 | 73 | */ |
| 71 | - public function queryItemsFromDB() { |
|
| 74 | + public function queryItemsFromDB() |
|
| 75 | + { |
|
| 72 | 76 | foreach($this->types as $resourceTable=>$type) { |
| 73 | 77 | if($this->hasAnyPermissions($type['permissions'])) { |
| 74 | 78 | $nameField = isset($type['name']) ? $type['name'] : 'name'; |
@@ -81,11 +85,13 @@ discard block |
||
| 81 | 85 | * @param array $permissions |
| 82 | 86 | * @return bool |
| 83 | 87 | */ |
| 84 | - public function hasAnyPermissions($permissions) { |
|
| 88 | + public function hasAnyPermissions($permissions) |
|
| 89 | + { |
|
| 85 | 90 | $modx = evolutionCMS(); |
| 86 | 91 | |
| 87 | - foreach($permissions as $p) |
|
| 88 | - if($modx->hasPermission($p)) return true; |
|
| 92 | + foreach($permissions as $p) { |
|
| 93 | + if($modx->hasPermission($p)) return true; |
|
| 94 | + } |
|
| 89 | 95 | |
| 90 | 96 | return false; |
| 91 | 97 | } |
@@ -95,7 +101,8 @@ discard block |
||
| 95 | 101 | * @param string $nameField |
| 96 | 102 | * @return array|bool |
| 97 | 103 | */ |
| 98 | - public function queryResources($resourceTable, $nameField = 'name') { |
|
| 104 | + public function queryResources($resourceTable, $nameField = 'name') |
|
| 105 | + { |
|
| 99 | 106 | $modx = evolutionCMS(); global $_lang; |
| 100 | 107 | |
| 101 | 108 | $allowed = array( |
@@ -112,8 +119,9 @@ discard block |
||
| 112 | 119 | $tvsql = 'site_tmplvars.caption, '; |
| 113 | 120 | $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
| 114 | 121 | $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
| 122 | + } else { |
|
| 123 | + $sttfield = ''; |
|
| 115 | 124 | } |
| 116 | - else $sttfield = ''; |
|
| 117 | 125 | |
| 118 | 126 | $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
| 119 | 127 | |
@@ -126,7 +134,9 @@ discard block |
||
| 126 | 134 | ); |
| 127 | 135 | $limit = $modx->db->getRecordCount($rs); |
| 128 | 136 | |
| 129 | - if($limit < 1) return false; |
|
| 137 | + if($limit < 1) { |
|
| 138 | + return false; |
|
| 139 | + } |
|
| 130 | 140 | |
| 131 | 141 | $result = array(); |
| 132 | 142 | while ($row = $modx->db->getRow($rs)) { |
@@ -138,7 +148,8 @@ discard block |
||
| 138 | 148 | /** |
| 139 | 149 | * @return void |
| 140 | 150 | */ |
| 141 | - public function prepareCategoryArrays() { |
|
| 151 | + public function prepareCategoryArrays() |
|
| 152 | + { |
|
| 142 | 153 | foreach($this->items as $type=>$items) { |
| 143 | 154 | foreach((array)$items as $item) { |
| 144 | 155 | $catid = $item['catid'] ? $item['catid'] : 0; |
@@ -154,7 +165,7 @@ discard block |
||
| 154 | 165 | |
| 155 | 166 | // Now sort by name |
| 156 | 167 | foreach($this->itemsPerCategory as $catid=>$items) { |
| 157 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
| 168 | + usort($this->itemsPerCategory[$catid], function ($a, $b){ |
|
| 158 | 169 | return strcasecmp($a['name'], $b['name']); |
| 159 | 170 | }); |
| 160 | 171 | } |
@@ -8,46 +8,46 @@ discard block |
||
| 8 | 8 | * @param array $data |
| 9 | 9 | * @return string |
| 10 | 10 | */ |
| 11 | - public function output($config = array(), $data = array()) { |
|
| 11 | + public function output($config = array(), $data = array()){ |
|
| 12 | 12 | $modx = evolutionCMS(); |
| 13 | 13 | |
| 14 | 14 | $output = ''; |
| 15 | 15 | $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
| 16 | - $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : ''; |
|
| 16 | + $tab = isset($config['tab']) ? ' AND tab IN('.$config['tab'].')' : ''; |
|
| 17 | 17 | |
| 18 | - if($action) { |
|
| 18 | + if ($action) { |
|
| 19 | 19 | $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name |
| 20 | - FROM ' . $modx->getFullTableName('system_templates') . ' AS t1 |
|
| 21 | - INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category |
|
| 22 | - WHERE t1.action IN(' . $action . ') ' . $tab . ' |
|
| 20 | + FROM ' . $modx->getFullTableName('system_templates').' AS t1 |
|
| 21 | + INNER JOIN ' . $modx->getFullTableName('categories').' AS t2 ON t2.id=t1.category |
|
| 22 | + WHERE t1.action IN(' . $action.') '.$tab.' |
|
| 23 | 23 | ORDER BY t1.tab ASC, t1.rank ASC'); |
| 24 | 24 | |
| 25 | - if($modx->db->getRecordCount($sql)) { |
|
| 25 | + if ($modx->db->getRecordCount($sql)) { |
|
| 26 | 26 | $tabs = array(); |
| 27 | - while($row = $modx->db->getRow($sql)) { |
|
| 28 | - if(!$row['value'] && !empty($data[$row['name']])) { |
|
| 27 | + while ($row = $modx->db->getRow($sql)) { |
|
| 28 | + if (!$row['value'] && !empty($data[$row['name']])) { |
|
| 29 | 29 | $row['value'] = $data[$row['name']]; |
| 30 | 30 | } |
| 31 | 31 | $tabs[$row['tab']]['category_name'] = $row['category_name']; |
| 32 | 32 | $tabs[$row['tab']][$row['name']] = $this->render($row); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(!empty($config['toArray'])) { |
|
| 35 | + if (!empty($config['toArray'])) { |
|
| 36 | 36 | $output = $tabs; |
| 37 | 37 | } else { |
| 38 | - $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
| 38 | + $output .= '<div class="tab-pane" id="pane_'.$action.'">'; |
|
| 39 | 39 | $output .= ' |
| 40 | 40 | <script type="text/javascript"> |
| 41 | - var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
|
| 41 | + var pane_' . $action.' = new WebFXTabPane(document.getElementById("pane_'.$action.'"), '.($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').'); |
|
| 42 | 42 | </script>'; |
| 43 | 43 | |
| 44 | - foreach($tabs as $idTab => $tab) { |
|
| 45 | - $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
| 44 | + foreach ($tabs as $idTab => $tab) { |
|
| 45 | + $output .= '<div class="tab-page" id="tab_'.$action.'_'.$idTab.'">'; |
|
| 46 | 46 | $output .= ' |
| 47 | - <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
|
| 48 | - <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>'; |
|
| 47 | + <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']).'</h2> |
|
| 48 | + <script type="text/javascript">pane_' . $action.'.addTabPage(document.getElementById("tab_'.$action.'_'.$idTab.'"));</script>'; |
|
| 49 | 49 | unset($tab['category_name']); |
| 50 | - foreach($tab as $item) { |
|
| 50 | + foreach ($tab as $item) { |
|
| 51 | 51 | $output .= $item; |
| 52 | 52 | } |
| 53 | 53 | $output .= '</div>'; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param array $data |
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | - private function render($data) { |
|
| 67 | + private function render($data){ |
|
| 68 | 68 | $modx = evolutionCMS(); global $_lang, $_country_lang; |
| 69 | 69 | |
| 70 | 70 | $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $output = ''; |
| 75 | 75 | $output .= '<div class="form-group row">'; |
| 76 | 76 | |
| 77 | - switch($data['type']) { |
|
| 77 | + switch ($data['type']) { |
|
| 78 | 78 | |
| 79 | 79 | case 'text': |
| 80 | 80 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
@@ -108,18 +108,18 @@ discard block |
||
| 108 | 108 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 109 | 109 | $output .= '<div class="col-sm-7">'; |
| 110 | 110 | $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
| 111 | - if($data['name'] == 'country' && isset($_country_lang)) { |
|
| 111 | + if ($data['name'] == 'country' && isset($_country_lang)) { |
|
| 112 | 112 | $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
| 113 | - $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
| 114 | - foreach($_country_lang as $key => $value) { |
|
| 115 | - $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
| 113 | + $output .= '<option value=""'.(!isset($chosenCountry) ? ' selected' : '').'> </option>'; |
|
| 114 | + foreach ($_country_lang as $key => $value) { |
|
| 115 | + $output .= '<option value="'.$key.'"'.(isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '').'>'.$value.'</option>'; |
|
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - if($data['elements']) { |
|
| 118 | + if ($data['elements']) { |
|
| 119 | 119 | $elements = explode('||', $data['elements']); |
| 120 | - foreach($elements as $key => $value) { |
|
| 120 | + foreach ($elements as $key => $value) { |
|
| 121 | 121 | $value = explode('==', $value); |
| 122 | - $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
| 122 | + $output .= '<option value="'.$value[1].'">'.(isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]).'</option>'; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 134 | 134 | $output .= '<div class="col-sm-7">'; |
| 135 | 135 | $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 136 | - if($data['elements']) { |
|
| 136 | + if ($data['elements']) { |
|
| 137 | 137 | $elements = explode('||', $data['elements']); |
| 138 | - foreach($elements as $key => $value) { |
|
| 138 | + foreach ($elements as $key => $value) { |
|
| 139 | 139 | $value = explode('==', $value); |
| 140 | - $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]); |
|
| 140 | + $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]); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | $output .= $data['content']; |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
| 150 | 150 | $output .= '<div class="col-sm-7">'; |
| 151 | 151 | $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 152 | - if($data['elements']) { |
|
| 152 | + if ($data['elements']) { |
|
| 153 | 153 | $elements = explode('||', $data['elements']); |
| 154 | - foreach($elements as $key => $value) { |
|
| 154 | + foreach ($elements as $key => $value) { |
|
| 155 | 155 | $value = explode('==', $value); |
| 156 | - $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]); |
|
| 156 | + $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]); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | $output .= $data['content']; |
@@ -8,7 +8,8 @@ discard block |
||
| 8 | 8 | * @param array $data |
| 9 | 9 | * @return string |
| 10 | 10 | */ |
| 11 | - public function output($config = array(), $data = array()) { |
|
| 11 | + public function output($config = array(), $data = array()) |
|
| 12 | + { |
|
| 12 | 13 | $modx = evolutionCMS(); |
| 13 | 14 | |
| 14 | 15 | $output = ''; |
@@ -64,7 +65,8 @@ discard block |
||
| 64 | 65 | * @param array $data |
| 65 | 66 | * @return string |
| 66 | 67 | */ |
| 67 | - private function render($data) { |
|
| 68 | + private function render($data) |
|
| 69 | + { |
|
| 68 | 70 | $modx = evolutionCMS(); global $_lang, $_country_lang; |
| 69 | 71 | |
| 70 | 72 | $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php namespace EvolutionCMS\Legacy; |
| 2 | 2 | |
| 3 | -Class TemplateParser |
|
| 3 | +class TemplateParser |
|
| 4 | 4 | { |
| 5 | 5 | |
| 6 | 6 | /** |