From 114ca6c24a5d5bfa8f474561c327dbbb9d5ec2ca Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 24 Jan 2020 17:52:38 +0900 Subject: [PATCH] Update all isset()? to ?? All the old isset($var) ? $var : have been changed to $var ?? --- .phan/config.php | 2 +- www/admin/phan_test.php | 9 ++++ www/configs/config.master.php | 2 +- www/includes/admin_header.php | 2 - www/includes/edit_base.php | 12 ++--- www/lib/CoreLibs/ACL/Login.php | 26 +++++----- www/lib/CoreLibs/Admin/Backend.php | 24 ++++----- www/lib/CoreLibs/Basic.php | 55 +++++++++++--------- www/lib/CoreLibs/DB/IO.php | 20 ++++---- www/lib/CoreLibs/DB/SQL/PgSQL.php | 2 +- www/lib/CoreLibs/Output/Form/Generate.php | 60 +++++++++++----------- www/lib/CoreLibs/Output/Progressbar.php | 3 ++ www/lib/CoreLibs/Template/SmartyExtend.php | 8 +-- 13 files changed, 120 insertions(+), 105 deletions(-) create mode 100755 www/admin/phan_test.php diff --git a/.phan/config.php b/.phan/config.php index f0f86bf8..c5e89d56 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -84,7 +84,7 @@ return [ // to parse, but not analyze "exclude_analysis_directory_list" => [ 'www/vendor', - 'www/lib/FileUpload', + // 'www/lib/FileUpload', 'www/lib/pChart', 'www/lib/pChart2.1.4', 'www/lib/Smarty', diff --git a/www/admin/phan_test.php b/www/admin/phan_test.php new file mode 100755 index 00000000..90b8e0e3 --- /dev/null +++ b/www/admin/phan_test.php @@ -0,0 +1,9 @@ +my_page_name == 'edit_order') { // get is for "table_name" and "where" only - $table_name = isset($_GET['table_name']) ? $_GET['table_name'] : ''; - // $where = isset($_GET['where']) ? $_GET['where'] : ''; + $table_name = $_GET['table_name'] ?? ''; + // $where = $_GET['where'] ?? ''; // order name is _always_ order_number for the edit interface // follwing arrays do exist here: @@ -208,7 +208,7 @@ if ($form->my_page_name == 'edit_order') { // hidden names for the table & where string $DATA['table_name'] = $table_name; - $DATA['where_string'] = isset($where_string) ? $where_string : ''; + $DATA['where_string'] = $where_string ?? ''; $EDIT_TEMPLATE = 'edit_order.tpl'; } else { @@ -282,7 +282,7 @@ if ($form->my_page_name == 'edit_order') { '' ). // filename - (isset($data['filename']) ? $data['filename'] : ''). + ($data['filename'] ?? ''). // query string (isset($data['query_string']) && $data['query_string'] ? $data['query_string'] : @@ -477,7 +477,7 @@ if ($form->my_page_name == 'edit_order') { } // debug data, if DEBUG flag is on, this data is print out -$DEBUG_DATA['DEBUG'] = isset($DEBUG_TMPL) ? $DEBUG_TMPL : ''; +$DEBUG_DATA['DEBUG'] = $DEBUG_TMPL ?? ''; // create main data array $CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA); diff --git a/www/lib/CoreLibs/ACL/Login.php b/www/lib/CoreLibs/ACL/Login.php index 03932fee..ca3ce821 100644 --- a/www/lib/CoreLibs/ACL/Login.php +++ b/www/lib/CoreLibs/ACL/Login.php @@ -179,16 +179,16 @@ class Login extends \CoreLibs\DB\IO // get login vars, are so, can't be changed // prepare // pass on vars to Object vars - $this->login = isset($_POST['login_login']) ? $_POST['login_login'] : ''; - $this->username = isset($_POST['login_username']) ? $_POST['login_username'] : ''; - $this->password = isset($_POST['login_password']) ? $_POST['login_password'] : ''; - $this->logout = isset($_POST['login_logout']) ? $_POST['login_logout'] : ''; + $this->login = $_POST['login_login'] ?? ''; + $this->username = $_POST['login_username'] ?? ''; + $this->password = $_POST['login_password'] ?? ''; + $this->logout = $_POST['login_logout'] ?? ''; // password change vars - $this->change_password = isset($_POST['change_password']) ? $_POST['change_password'] : ''; - $this->pw_username = isset($_POST['pw_username']) ? $_POST['pw_username'] : ''; - $this->pw_old_password = isset($_POST['pw_old_password']) ? $_POST['pw_old_password'] : ''; - $this->pw_new_password = isset($_POST['pw_new_password']) ? $_POST['pw_new_password'] : ''; - $this->pw_new_password_confirm = isset($_POST['pw_new_password_confirm']) ? $_POST['pw_new_password_confirm'] : ''; + $this->change_password = $_POST['change_password'] ?? ''; + $this->pw_username = $_POST['pw_username'] ?? ''; + $this->pw_old_password = $_POST['pw_old_password'] ?? ''; + $this->pw_new_password = $_POST['pw_new_password'] ?? ''; + $this->pw_new_password_confirm = $_POST['pw_new_password_confirm'] ?? ''; // logout target (from config) $this->logout_target = LOGOUT_TARGET; // disallow user list for password change @@ -418,8 +418,8 @@ class Login extends \CoreLibs\DB\IO $_SESSION['GROUP_ACL_LEVEL'] = $res['group_level']; $_SESSION['GROUP_ACL_TYPE'] = $res['group_type']; // deprecated TEMPLATE setting - $_SESSION['TEMPLATE'] = ($res['template']) ? $res['template'] : ''; - $_SESSION['HEADER_COLOR'] = ($res['second_header_color']) ? $res['second_header_color'] : $res['first_header_color']; + $_SESSION['TEMPLATE'] = $res['template'] ? $res['template'] : ''; + $_SESSION['HEADER_COLOR'] = $res['second_header_color'] ? $res['second_header_color'] : $res['first_header_color']; $_SESSION['LANG'] = $res['lang_short']; $_SESSION['DEFAULT_CHARSET'] = $res['lang_iso']; $_SESSION['DEFAULT_LANG'] = $res['lang_short'].'_'.strtolower(str_replace('-', '', $res['lang_iso'])); @@ -1194,7 +1194,7 @@ EOM; $q .= "(username, password, euid, event_date, event, error, data, data_binary, page, "; $q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, "; $q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) "; - $q .= "VALUES ('".$this->dbEscapeString($username)."', 'PASSWORD', ".(($this->euid) ? $this->euid : 'NULL').", "; + $q .= "VALUES ('".$this->dbEscapeString($username)."', 'PASSWORD', ".($this->euid ? $this->euid : 'NULL').", "; $q .= "NOW(), '".$this->dbEscapeString($event)."', '".$this->dbEscapeString((string)$error)."', '".$this->dbEscapeString($data)."', '".$data_binary."', '".$this->page_name."', "; foreach (array( 'REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'SCRIPT_FILENAME', 'QUERY_STRING', 'SERVER_NAME', 'HTTP_HOST', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING' @@ -1228,7 +1228,7 @@ EOM; is_array($_SESSION['UNIT']) && !array_key_exists($edit_access_id, $_SESSION['UNIT']) ) { - return $_SESSION['UNIT_DEFAULT']; + return (int)$_SESSION['UNIT_DEFAULT']; } else { return $edit_access_id; } diff --git a/www/lib/CoreLibs/Admin/Backend.php b/www/lib/CoreLibs/Admin/Backend.php index 853b3957..f4a65bcb 100644 --- a/www/lib/CoreLibs/Admin/Backend.php +++ b/www/lib/CoreLibs/Admin/Backend.php @@ -82,7 +82,7 @@ class Backend extends \CoreLibs\DB\IO // set the action ids foreach ($this->action_list as $_action) { - $this->$_action = (isset($_POST[$_action])) ? $_POST[$_action] : ''; + $this->$_action = $_POST[$_action] ?? ''; } $this->default_acl = DEFAULT_ACL_LEVEL; @@ -189,14 +189,14 @@ class Backend extends \CoreLibs\DB\IO $q .= "NOW(), "; $q .= "'".$this->dbEscapeString((string)$event)."', '".$data."', '".$data_binary."', '".$this->dbEscapeString((string)$this->page_name)."', "; $q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->dbEscapeString(@$_SERVER['HTTP_USER_AGENT'])."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '')."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '')."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '')."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '')."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : '')."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['HTTP_ACCEPT_CHARSET']) ? $_SERVER['HTTP_ACCEPT_CHARSET'] : '')."', "; - $q .= "'".$this->dbEscapeString(isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['HTTP_REFERER'] ?? '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['SCRIPT_FILENAME'] ?? '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['QUERY_STRING'] ?? '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['SERVER_NAME'] ?? '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['HTTP_HOST'] ?? '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['HTTP_ACCEPT'] ?? '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['HTTP_ACCEPT_CHARSET'] ?? '')."', "; + $q .= "'".$this->dbEscapeString($_SERVER['HTTP_ACCEPT_ENCODING'] ?? '')."', "; $q .= "'".session_id()."', "; $q .= "'".$this->dbEscapeString($this->action)."', "; $q .= "'".$this->dbEscapeString($this->action_id)."', "; @@ -221,7 +221,7 @@ class Backend extends \CoreLibs\DB\IO } // get the session pages array - $PAGES = isset($_SESSION['PAGES']) ? $_SESSION['PAGES'] : null; + $PAGES = $_SESSION['PAGES'] ?? null; if (!isset($PAGES) || !is_array($PAGES)) { $PAGES = array(); } @@ -292,11 +292,11 @@ class Backend extends \CoreLibs\DB\IO if (isset($data['hostname']) && $data['hostname']) { $url .= $data['hostname']; } - $url .= isset($data['filename']) ? $data['filename'] : ''; + $url .= $data['filename'] ?? ''; if (strlen($query_string)) { $url .= '?'.$query_string; } - $name = isset($data['page_name']) ? $data['page_name'] : ''; + $name = $data['page_name'] ?? ''; // if page name matchs -> set selected flag $selected = 0; if (isset($data['filename']) && diff --git a/www/lib/CoreLibs/Basic.php b/www/lib/CoreLibs/Basic.php index 8be2aa36..9a9220ed 100644 --- a/www/lib/CoreLibs/Basic.php +++ b/www/lib/CoreLibs/Basic.php @@ -841,7 +841,7 @@ class Basic foreach ($this->error_msg as $level => $temp_debug_output) { if ($this->doDebugTrigger('debug', $level)) { if ($this->doDebugTrigger('echo', $level)) { - $string_output .= '
['.$level.'] '.(($string) ? "**** ".$this->htmlent($string)." ****\n" : "").'
'; + $string_output .= '
['.$level.'] '.($string ? "**** ".$this->htmlent($string)." ****\n" : "").'
'; $string_output .= $temp_debug_output; } // echo it out } // do printout @@ -1087,11 +1087,11 @@ class Basic { if (is_array($haystack)) { if (in_array((string)$needle, $haystack)) { - return (($type) ? "checked" : "selected"); + return $type ? 'checked' : 'selected'; } } else { if ($haystack == $needle) { - return (($type) ? "checked" : "selected"); + return $type ? 'checked' : 'selected'; } } return null; @@ -1192,7 +1192,7 @@ class Basic } // if it is a link already just return the original link do not touch anything if (!$href && !$atag) { - return "##LT##a href=##QUOT##".$_1.$_2.$_3."##QUOT##".(($class) ? ' class=##QUOT##'.$class.'##QUOT##' : '').(($target) ? " target=##QUOT##".$target."##QUOT##" : '')."##GT##".(($name) ? $name : $_2.$_3)."##LT##/a##GT##"; + return "##LT##a href=##QUOT##".$_1.$_2.$_3."##QUOT##".($class ? ' class=##QUOT##'.$class.'##QUOT##' : '').($target ? " target=##QUOT##".$target."##QUOT##" : '')."##GT##".($name ? $name : $_2.$_3)."##LT##/a##GT##"; } elseif ($href && !$atag) { return "href=##QUOT##$_1$_2$_3##QUOT##"; } elseif ($atag) { @@ -1217,7 +1217,7 @@ class Basic { $email = $_1."@".$_2.".".$_3; if (!$mailto && !$atag) { - return "##LT##a href=##QUOT##mailto:".$email."##QUOT##".(($class) ? ' class=##QUOT##'.$class.'##QUOT##' : '')."##GT##".(($title) ? $title : $email)."##LT##/a##GT##"; + return "##LT##a href=##QUOT##mailto:".$email."##QUOT##".($class ? ' class=##QUOT##'.$class.'##QUOT##' : '')."##GT##".($title ? $title : $email)."##LT##/a##GT##"; } elseif ($mailto && !$atag) { return "mailto:".$email; } elseif ($atag) { @@ -1273,7 +1273,7 @@ class Basic public static function getFilenameEnding(string $filename): string { $page_temp = pathinfo($filename); - return isset($page_temp['extension']) ? $page_temp['extension'] : ''; + return $page_temp['extension'] ?? ''; } /** @@ -1313,7 +1313,12 @@ class Basic $path[] = $key; break; } elseif (is_array($val) && - $path = Basic::arraySearchRecursive($needle, $val, $key_lookin) + $path = Basic::arraySearchRecursive( + $needle, + (array)$val, + // to avoid PhanTypeMismatchArgumentNullable + ($key_lookin === null ? $key_lookin : (string)$key_lookin) + ) ) { array_unshift($path, $key); break; @@ -1328,10 +1333,10 @@ class Basic * @param string|int $needle needle (search for) * @param array $haystack haystack (search in) * @param string|int $key the key to look for in - * @param array $path recursive call for previous path + * @param array|null $path recursive call for previous path * @return ?array all array elements paths where the element was found */ - public static function arraySearchRecursiveAll($needle, array $haystack, $key, $path = null): ?array + public static function arraySearchRecursiveAll($needle, array $haystack, $key, ?array $path = null): ?array { // init if not set on null if ($path === null) { @@ -1780,7 +1785,7 @@ class Basic $exp ++; } // label name, including leading space if flagged - $pre = ($space ? ' ' : '').(isset($labels[$exp]) ? $labels[$exp] : '>E').($si ? 'i' : '').'B'; + $pre = ($space ? ' ' : '').($labels[$exp] ?? '>E').($si ? 'i' : '').'B'; $bytes_calc = $abs_bytes / pow($unit, $exp); if ($adjust) { return sprintf("%.2f%sB", $bytes_calc, $pre); @@ -2995,7 +3000,7 @@ class Basic // convert to HEX value $$color = dechex($$color); // prefix with 0 if only one char - $$color = ((strlen($$color) < 2) ? '0' : '').$$color; + $$color = (strlen($$color) < 2 ? '0' : '').$$color; } // prefix hex parts with 0 if they are just one char long and return the html color string return '#'.$red.$green.$blue; @@ -3167,7 +3172,7 @@ class Basic // S= L <= 0.5 ? C/2L : C/2 - 2L return array( (int)round($HUE), - (int)round((($MAX - $MIN) / (($L <= 0.5) ? ($MAX + $MIN) : (2 - $MAX - $MIN))) * 100), + (int)round((($MAX - $MIN) / ($L <= 0.5 ? ($MAX + $MIN) : (2 - $MAX - $MIN))) * 100), (int)$L ); } @@ -3187,11 +3192,11 @@ class Basic if ($s == 0) { return array($l * 255, $l * 255, $l * 255); } else { - $m2 = ($l < 0.5) ? $l * ($s + 1) : ($l + $s) - ($l * $s); + $m2 = $l < 0.5 ? $l * ($s + 1) : ($l + $s) - ($l * $s); $m1 = $l * 2 - $m2; $hue = function ($base) use ($m1, $m2) { // base = hue, hue > 360 (1) - 360 (1), else < 0 + 360 (1) - $base = ($base < 0) ? $base + 1 : (($base > 1) ? $base - 1 : $base); + $base = $base < 0 ? $base + 1 : ($base > 1 ? $base - 1 : $base); // 6: 60, 2: 180, 3: 240 // 2/3 = 240 // 1/3 = 120 (all from 360) @@ -3295,13 +3300,13 @@ class Basic $max_year = (int)date("Y", $timestamp) + 1; // preset year, month, ... - $year = (!$year) ? date("Y", $timestamp) : $year; - $month = (!$month) ? date("m", $timestamp) : $month; - $day = (!$day) ? date("d", $timestamp) : $day; - $hour = (!$hour) ? date("H", $timestamp) : $hour; - $min = (!$min) ? date("i", $timestamp) : $min; // add to five min? + $year = !$year ? date('Y', $timestamp) : $year; + $month = !$month ? date('m', $timestamp) : $month; + $day = !$day ? date('d', $timestamp) : $day; + $hour = !$hour ? date('H', $timestamp) : $hour; + $min = !$min ? date('i', $timestamp) : $min; // add to five min? // max days in selected month - $days_in_month = date("t", strtotime($year."-".$month."-".$day." ".$hour.":".$min.":0")); + $days_in_month = date('t', strtotime($year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':0')); $string = ''; // from now to ? if ($name_pos_back === false) { @@ -3309,7 +3314,7 @@ class Basic } $string .= ' '; if ($name_pos_back === true) { @@ -3320,7 +3325,7 @@ class Basic } $string .= ' '; if ($name_pos_back === true) { @@ -3332,7 +3337,7 @@ class Basic $string .= ' '; if ($name_pos_back === true) { @@ -3343,7 +3348,7 @@ class Basic } $string .= ' '; if ($name_pos_back === true) { @@ -3354,7 +3359,7 @@ class Basic } $string .= ''; if ($name_pos_back === true) { diff --git a/www/lib/CoreLibs/DB/IO.php b/www/lib/CoreLibs/DB/IO.php index 0202b435..874a71e9 100644 --- a/www/lib/CoreLibs/DB/IO.php +++ b/www/lib/CoreLibs/DB/IO.php @@ -994,7 +994,7 @@ class IO extends \CoreLibs\Basic $string .= 'at host \''.$this->db_host.'\' '; $string .= 'on port \''.$this->db_port.'\' '; $string .= 'with ssl mode \''.$this->db_ssl.'\'
'; - $string .= '-DB-info-> DB IO Class debug output: '.(($this->db_debug) ? 'Yes' : 'No').''; + $string .= '-DB-info-> DB IO Class debug output: '.($this->db_debug ? 'Yes' : 'No').''; if ($show === true) { $this->__dbDebug('db', $string, 'dbInfo'); } else { @@ -1407,7 +1407,7 @@ class IO extends \CoreLibs\Basic return false; } $md5 = md5($query); - return $this->cursor_ext[$md5]['pos']; + return (int)$this->cursor_ext[$md5]['pos']; } /** @@ -1423,7 +1423,7 @@ class IO extends \CoreLibs\Basic return false; } $md5 = md5($query); - return $this->cursor_ext[$md5]['num_rows']; + return (int)$this->cursor_ext[$md5]['num_rows']; } /** @@ -1868,7 +1868,7 @@ class IO extends \CoreLibs\Basic } // write data into sql string if (strstr($table_data[$field]['type'], 'int')) { - $q_sub_data .= (is_numeric($_data)) ? $_data : 'NULL'; + $q_sub_data .= is_numeric($_data) ? $_data : 'NULL'; } else { // if bool -> set bool, else write data $q_sub_data .= isset($_data) ? "'".($is_bool ? $this->dbBoolean($_data, true) : $this->dbEscapeString($_data))."'" : 'NULL'; @@ -1898,7 +1898,7 @@ class IO extends \CoreLibs\Basic $primary_key['value'] = $this->insert_id; } // if there is not priamry key value field return false - return isset($primary_key['value']) ? $primary_key['value'] : false; + return $primary_key['value'] ?? false; } /** @@ -1951,19 +1951,19 @@ class IO extends \CoreLibs\Basic { switch ($kbn) { case 'i': - $value = ($value === '') ? "NULL" : intval($value); + $value = $value === '' ? "NULL" : intval($value); break; case 'f': - $value = ($value === '') ? "NULL" : floatval($value); + $value = $value === '' ? "NULL" : floatval($value); break; case 't': - $value = ($value === '') ? "NULL" : "'".$this->dbEscapeString($value)."'"; + $value = $value === '' ? "NULL" : "'".$this->dbEscapeString($value)."'"; break; case 'd': - $value = ($value === '') ? "NULL" : "'".$this->dbEscapeString($value)."'"; + $value = $value === '' ? "NULL" : "'".$this->dbEscapeString($value)."'"; break; case 'i2': - $value = ($value === '') ? 0 : intval($value); + $value = $value === '' ? 0 : intval($value); break; } return $value; diff --git a/www/lib/CoreLibs/DB/SQL/PgSQL.php b/www/lib/CoreLibs/DB/SQL/PgSQL.php index a69a2d16..925bb693 100644 --- a/www/lib/CoreLibs/DB/SQL/PgSQL.php +++ b/www/lib/CoreLibs/DB/SQL/PgSQL.php @@ -260,7 +260,7 @@ class PgSQL // set pk_name to "id" $pk_name = $table."_id"; } - $seq = (($schema) ? $schema.'.' : '').$table."_".$pk_name."_seq"; + $seq = ($schema ? $schema.'.' : '').$table."_".$pk_name."_seq"; $q = "SELECT CURRVAL('$seq') AS insert_id"; // I have to do manually or I overwrite the original insert internal vars ... if ($q = $this->__dbQuery($q)) { diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php index 5b9a96b2..1b47187c 100644 --- a/www/lib/CoreLibs/Output/Form/Generate.php +++ b/www/lib/CoreLibs/Output/Form/Generate.php @@ -316,16 +316,16 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $this->table_width = $table_width; // set button vars - $this->archive = isset($_POST['archive']) ? $_POST['archive'] : ''; - $this->new = isset($_POST['new']) ? $_POST['new'] : ''; - $this->really_new = isset($_POST['really_new']) ? $_POST['really_new'] : ''; - $this->delete = isset($_POST['delete']) ? $_POST['delete'] : ''; - $this->really_delete = isset($_POST['really_delete']) ? $_POST['really_delete'] : ''; - $this->save = isset($_POST['save']) ? $_POST['save'] : ''; - $this->remove_button = isset($_POST['remove_button']) ? $_POST['remove_button'] : ''; + $this->archive = $_POST['archive'] ?? ''; + $this->new = $_POST['new'] ?? ''; + $this->really_new = $_POST['really_new'] ?? ''; + $this->delete = $_POST['delete'] ?? ''; + $this->really_delete = $_POST['really_delete'] ?? ''; + $this->save = $_POST['save'] ?? ''; + $this->remove_button = $_POST['remove_button'] ?? ''; // security settings - $this->base_acl_level = isset($_SESSION['BASE_ACL_LEVEL']) ? $_SESSION['BASE_ACL_LEVEL'] : 0; + $this->base_acl_level = $_SESSION['BASE_ACL_LEVEL'] ?? 0; // security levels for buttons/actions // if array does not exists create basic if (!isset($config_array['security_level']) || @@ -852,16 +852,16 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO // normal text element if ($this->table_array[$element_name]['type'] == 'text') { $data['name'] = $element_name; - $data['value'] = isset($this->table_array[$element_name]['value']) ? $this->table_array[$element_name]['value'] : ''; - $data['size'] = isset($this->table_array[$element_name]['size']) ? $this->table_array[$element_name]['size'] : ''; - $data['length'] = isset($this->table_array[$element_name]['length']) ? $this->table_array[$element_name]['length'] : ''; + $data['value'] = $this->table_array[$element_name]['value'] ?? ''; + $data['size'] = $this->table_array[$element_name]['size'] ?? ''; + $data['length'] = $this->table_array[$element_name]['length'] ?? ''; } // password element, does not write back the value if ($this->table_array[$element_name]['type'] == 'password') { $data['name'] = $element_name; $data['HIDDEN_value'] = $this->table_array[$element_name]['HIDDEN_value']; - $data['size'] = isset($this->table_array[$element_name]['size']) ? $this->table_array[$element_name]['size'] : ''; - $data['length'] = isset($this->table_array[$element_name]['length']) ? $this->table_array[$element_name]['length'] : ''; + $data['size'] = $this->table_array[$element_name]['size'] ?? ''; + $data['length'] = $this->table_array[$element_name]['length'] ?? ''; } // date (YYYY-MM-DD) if ($this->table_array[$element_name]['type'] == 'date') { @@ -874,9 +874,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO // textarea if ($this->table_array[$element_name]['type'] == 'textarea') { $data['name'] = $element_name; - $data['value'] = isset($this->table_array[$element_name]['value']) ? $this->table_array[$element_name]['value'] : ''; - $data['rows'] = isset($this->table_array[$element_name]['rows']) ? $this->table_array[$element_name]['rows'] : ''; - $data['cols'] = isset($this->table_array[$element_name]['cols']) ? $this->table_array[$element_name]['cols'] : ''; + $data['value'] = $this->table_array[$element_name]['value'] ?? ''; + $data['rows'] = $this->table_array[$element_name]['rows'] ?? ''; + $data['cols'] = $this->table_array[$element_name]['cols'] ?? ''; } // for drop_down_* if (preg_match("/^drop_down_/", $this->table_array[$element_name]['type'])) { @@ -982,7 +982,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO if ($this->table_array[$element_name]['type'] == 'order') { $data['output_name'] = $this->table_array[$element_name]['output_name']; $data['name'] = $element_name; - $data['value'] = isset($this->table_array[$element_name]['value']) ? $this->table_array[$element_name]['value'] : 0; + $data['value'] = $this->table_array[$element_name]['value'] ?? 0; $data['col_name'] = $this->col_name; $data['table_name'] = $this->table_name; $data['query'] = $query !== null ? urlencode($query) : ''; @@ -1185,7 +1185,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO // get the leasy of keys from the elements array $keys = array_keys($reference_array['elements']); // prefix - $prfx = ($reference_array['prefix']) ? $reference_array['prefix'].'_' : ''; + $prfx = $reference_array['prefix'] ? $reference_array['prefix'].'_' : ''; // get max elements $max = 0; foreach ($keys as $key) { @@ -1547,7 +1547,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO // get the number of keys from the elements array $keys = array_keys($reference_array['elements']); // element prefix name - $prfx = ($reference_array['prefix']) ? $reference_array['prefix'].'_' : ''; + $prfx = $reference_array['prefix'] ? $reference_array['prefix'].'_' : ''; // get max elements $max = 0; foreach ($keys as $key) { @@ -1652,7 +1652,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $_value = 'NULL'; } } else { - $_value = isset($_POST[$prfx.$el_name][$i]) ? $_POST[$prfx.$el_name][$i] : ''; + $_value = $_POST[$prfx.$el_name][$i] ?? ''; } // pre write data set. if int value, unset flagged need to be set null or 0 depending on settings if (isset($data_array['int']) || isset($data_array['int_null'])) { @@ -1685,15 +1685,15 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO // if tpye is update if (isset($type[$i]) && $type[$i] == 'update') { $q = $q_begin[$i]. - (isset($q_data[$i]) ? $q_data[$i] : ''). + ($q_data[$i] ?? ''). $q_end[$i]; // or if we have block write, then it is insert (new) } elseif (isset($block_write[$i]) && $block_write[$i]) { $q = $q_begin[$i]. - (isset($q_names[$i]) ? $q_names[$i] : '').', '. + ($q_names[$i] ?? '').', '. $this->int_pk_name. - (isset($q_middle[$i]) ? $q_middle[$i] : ''). - (isset($q_values[$i]) ? $q_values[$i] : '').', '. + ($q_middle[$i] ?? ''). + ($q_values[$i] ?? '').', '. $this->table_array[$this->int_pk_name]['value']. $q_end[$i]; } @@ -1772,7 +1772,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $this->table_array[$key]['type'] == 'hidden' ) { if (array_key_exists($key, $this->table_array)) { - $hidden_array[$key] = isset($this->table_array[$key]['value']) ? $this->table_array[$key]['value'] : ''; + $hidden_array[$key] = $this->table_array[$key]['value'] ?? ''; } else { $hidden_array[$key] = ''; } @@ -1807,7 +1807,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $data['value'][] = $res[0]; $data['output'][] = $res[1]; $data['selected'][] = ($this->checked( - isset($this->reference_array[$table_name]['selected']) ? $this->reference_array[$table_name]['selected'] : '', + $this->reference_array[$table_name]['selected'] ?? '', $res[0] )) ? $res[0] : ''; } @@ -1882,9 +1882,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO // prefix the name for any further data parts $el_name = $data['prefix'].$el_name; // this are the output names (if given) - $data['output_name'][$el_name] = isset($data_array['output_name']) ? $data_array['output_name'] : ''; + $data['output_name'][$el_name] = $data_array['output_name'] ?? ''; // this is the type of the field - $data['type'][$el_name] = isset($data_array['type']) ? $data_array['type'] : ''; + $data['type'][$el_name] = $data_array['type'] ?? ''; // set the primary key name if (isset($data_array['pk_id'])) { $data['pk_name'] = $el_name; @@ -1898,7 +1898,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $md_q = md5($data_array['query']); while ($res = $this->dbReturn($data_array['query'])) { /** @phan-suppress-next-line PhanTypeInvalidDimOffset */ - $this->debug('edit', 'Q['.$md_q.'] pos: '.$this->cursor_ext[$md_q]['pos'].' | want: '.(isset($data_array['preset']) ? $data_array['preset'] : '-').' | set: '.(isset($data['preset'][$el_name]) ? $data['preset'][$el_name] : '-')); + $this->debug('edit', 'Q['.$md_q.'] pos: '.$this->cursor_ext[$md_q]['pos'].' | want: '.($data_array['preset'] ?? '-').' | set: '.($data['preset'][$el_name] ?? '-')); // first is default for this element if (isset($data_array['preset']) && (!isset($data['preset'][$el_name]) || empty($data['preset'][$el_name])) && @@ -1920,7 +1920,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO if ($this->error) { if (isset($_POST[$el_name]) && is_array($_POST[$el_name])) { // this is for the new line - $proto[$el_name] = isset($_POST[$el_name][(count($_POST[$el_name]) - 1)]) ? $_POST[$el_name][(count($_POST[$el_name]) - 1)] : 0; + $proto[$el_name] = $_POST[$el_name][(count($_POST[$el_name]) - 1)] ?? 0; } else { $proto[$el_name] = 0; } diff --git a/www/lib/CoreLibs/Output/Progressbar.php b/www/lib/CoreLibs/Output/Progressbar.php index 53a41441..c3d90cd4 100644 --- a/www/lib/CoreLibs/Output/Progressbar.php +++ b/www/lib/CoreLibs/Output/Progressbar.php @@ -78,6 +78,9 @@ class ProgressBar ) */ + // output strings + public $prefix_message = ''; + /** * progress bar constructor * @param integer $width progress bar width, default 0 diff --git a/www/lib/CoreLibs/Template/SmartyExtend.php b/www/lib/CoreLibs/Template/SmartyExtend.php index 20b15010..be58cf4b 100644 --- a/www/lib/CoreLibs/Template/SmartyExtend.php +++ b/www/lib/CoreLibs/Template/SmartyExtend.php @@ -345,7 +345,7 @@ class SmartyExtend extends SmartyBC // special for admin if ($admin_call === true) { // set ACL extra show - $this->DATA['show_ea_extra'] = isset($cms->acl['show_ea_extra']) ? $cms->acl['show_ea_extra'] : false; + $this->DATA['show_ea_extra'] = $cms->acl['show_ea_extra'] ?? false; $this->DATA['ADMIN'] = !empty($cms->acl['admin']) ? $cms->acl['admin'] : 0; // set style sheets $this->HEADER['STYLESHEET'] = $this->ADMIN_STYLESHEET ? $this->ADMIN_STYLESHEET : ADMIN_STYLESHEET; @@ -354,10 +354,10 @@ class SmartyExtend extends SmartyBC $this->DATA['nav_menu'] = $cms->adbTopMenu(); $this->DATA['nav_menu_count'] = is_array($this->DATA['nav_menu']) ? count($this->DATA['nav_menu']) : 0; // messages = array('msg' =>, 'class' => 'error/warning/...') - $this->DATA['messages'] = isset($cms->messages) ? $cms->messages : $cms->messages; + $this->DATA['messages'] = $cms->messages ?? array(); // the page name $this->DATA['page_name'] = $this->page_name; - $this->DATA['table_width'] = isset($this->PAGE_WIDTH) ? $this->PAGE_WIDTH : PAGE_WIDTH; + $this->DATA['table_width'] = $this->PAGE_WIDTH ?? PAGE_WIDTH; // for tinymce special $this->DATA['TINYMCE_LANG'] = $this->lang_short; // include flags @@ -390,7 +390,7 @@ class SmartyExtend extends SmartyBC // the template part to include into the body $this->DATA['TEMPLATE_NAME'] = $this->TEMPLATE_NAME; $this->DATA['CONTENT_INCLUDE'] = $this->CONTENT_INCLUDE; - $this->DATA['TEMPLATE_TRANSLATE'] = isset($this->TEMPLATE_TRANSLATE) ? $this->TEMPLATE_TRANSLATE : null; + $this->DATA['TEMPLATE_TRANSLATE'] = $this->TEMPLATE_TRANSLATE ?? null; $this->DATA['PAGE_FILE_NAME'] = str_replace('.php', '', $this->page_name).'.tpl'; // render page $this->renderSmarty();