From 1dddb4e8e56a07f8523583608f979b4772eec0fd Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 29 Feb 2024 13:23:49 +0800 Subject: [PATCH 01/16] add missing jsencode --- JsonOutputTrait.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/JsonOutputTrait.php b/JsonOutputTrait.php index 0c1e7a4b..92a313f9 100644 --- a/JsonOutputTrait.php +++ b/JsonOutputTrait.php @@ -278,4 +278,23 @@ trait Pman_Core_JsonOutputTrait { } + function jsencode($v, $header = false) + { + if ($header) { + header("Content-type: text/javascript"); + } + if (function_exists("json_encode")) { + $ret= json_encode($v); + if ($ret !== false) { + return $ret; + } + } + require_once 'Services/JSON.php'; + $js = new Services_JSON(); + return $js->encodeUnsafe($v); + + + + } + } \ No newline at end of file -- 2.39.2 From 232a36d1e92b1f39e7af6b270feb46ef05ce0c94 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 29 Feb 2024 14:19:46 +0800 Subject: [PATCH 02/16] transaction object support --- JsonOutputTrait.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/JsonOutputTrait.php b/JsonOutputTrait.php index 92a313f9..394eaf85 100644 --- a/JsonOutputTrait.php +++ b/JsonOutputTrait.php @@ -2,6 +2,8 @@ trait Pman_Core_JsonOutputTrait { + var $transObj = false; + function jok($str) { if ($this->transObj ) { -- 2.39.2 From cb6a5438ba9d1873212d6c156dddc6dc8aa07c13 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 4 Mar 2024 11:47:51 +0800 Subject: [PATCH 03/16] update blacklist filters --- DataObjects/Core_notify_blacklist.php | 7 ++++++- DataObjects/Core_notify_sender_blacklist.php | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/DataObjects/Core_notify_blacklist.php b/DataObjects/Core_notify_blacklist.php index e12ba860..305f0afc 100644 --- a/DataObjects/Core_notify_blacklist.php +++ b/DataObjects/Core_notify_blacklist.php @@ -37,7 +37,7 @@ class Pman_Core_DataObjects_Core_notify_blacklist extends DB_DataObject 'poor reputation', 'AntiSpam', 'ip address in rbl', - 'IP address blacklisted', + 'blacklisted', 'spamauditor.org', 'detect spam', 'message as spam', @@ -46,6 +46,11 @@ class Pman_Core_DataObjects_Core_notify_blacklist extends DB_DataObject 'blocked by sbl-xbl.spam', 'Sophos Anti Spam Engine', 'spam filters', + 'JunkMail', + 'block list', + 'Cloudmark Sender Intelligence', + 'Blocked by CSI', + ); foreach($match as $str) { diff --git a/DataObjects/Core_notify_sender_blacklist.php b/DataObjects/Core_notify_sender_blacklist.php index d60cfc5f..7ada6439 100644 --- a/DataObjects/Core_notify_sender_blacklist.php +++ b/DataObjects/Core_notify_sender_blacklist.php @@ -20,7 +20,8 @@ class Pman_Core_DataObjects_Core_notify_sender_blacklist extends DB_DataObject { $match = array( 'BLOCK-SEND-ER', - 'sender is listed on the block mail' // 'sniper? + 'sender is listed on the block mail', // 'sniper? + 'sender is in my black list', ); foreach($match as $str) { if (strpos($err, $str) !== false) { -- 2.39.2 From 0c9ec158754ed1a44c9af5c0ede778e857540fc6 Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 3 Apr 2024 11:30:54 +0800 Subject: [PATCH 04/16] database lock for frequent processes --- Heartbeat.php | 8 ++++++++ Notify.php | 6 ++++++ NotifySend.php | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Heartbeat.php b/Heartbeat.php index 6a49092f..27c1bf87 100644 --- a/Heartbeat.php +++ b/Heartbeat.php @@ -20,6 +20,12 @@ class Pman_Core_Heartbeat extends Pman function post($req) { $this->initErrorHandling(); + + if ($this->database_is_locked()) { + die("FAILED"); + } + + $cd = DB_DataObject::Factory('core_enum'); $cd->setFrom(array( 'etype' => 'heartbeat', @@ -48,4 +54,6 @@ class Pman_Core_Heartbeat extends Pman // print_r($err); die("FAILED"); } + + } \ No newline at end of file diff --git a/Notify.php b/Notify.php index f524ff2f..55047c7a 100644 --- a/Notify.php +++ b/Notify.php @@ -178,6 +178,12 @@ class Pman_Core_Notify extends Pman function get($r,$opts=array()) { + + if ($this->database_is_locked()) { + die("LATER - DATABASE IS LOCKED"); + } + + $this->parseArgs($opts); //date_default_timezone_set('UTC'); diff --git a/NotifySend.php b/NotifySend.php index 0ba7692e..a7b68742 100644 --- a/NotifySend.php +++ b/NotifySend.php @@ -87,7 +87,9 @@ class Pman_Core_NotifySend extends Pman function get($id,$opts=array()) { - + if ($this->database_is_locked()) { + die("LATER - DATABASE IS LOCKED"); + } //print_r($opts); if (!empty($opts['DB_DataObject-debug'])) { DB_DataObject::debugLevel($opts['DB_DataObject-debug']); -- 2.39.2 From 30edf7ef98f7b5e984929445b83a2a1c521f8bb2 Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 3 Apr 2024 14:40:03 +0800 Subject: [PATCH 05/16] add chinese new year to generic import --- DataObjects/Core_holiday.php | 3 ++- Import/Core_holiday.php | 2 +- SimpleExcel.php | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DataObjects/Core_holiday.php b/DataObjects/Core_holiday.php index 52a13c54..742a2406 100644 --- a/DataObjects/Core_holiday.php +++ b/DataObjects/Core_holiday.php @@ -20,7 +20,8 @@ class Pman_Core_DataObjects_Core_holiday extends DB_DataObject static $map = array( - 'hk' => 'http://www.1823.gov.hk/common/ical/gc/en.ics' + 'hk' => 'http://www.1823.gov.hk/common/ical/gc/en.ics', + 'cny' => 'https://raw.githubusercontent.com/andrewlkho/cny.ics/master/cny.ics', // CNY ); diff --git a/Import/Core_holiday.php b/Import/Core_holiday.php index d52306b7..e01c11c3 100644 --- a/Import/Core_holiday.php +++ b/Import/Core_holiday.php @@ -27,7 +27,7 @@ class Pman_Core_Import_Core_holiday extends Pman_Core_Cli DB_DAtaObject::debugLevel(1); $d = DB_DataObject::factory('core_holiday'); $d->updateHolidays('hk'); - + $d->updateHolidays('cny'); } function log($str) diff --git a/SimpleExcel.php b/SimpleExcel.php index c14257c6..0ca12fc6 100644 --- a/SimpleExcel.php +++ b/SimpleExcel.php @@ -410,9 +410,10 @@ class Pman_Core_SimpleExcel extends Pman if ( (is_numeric($v) && strlen($v) > 1 && substr($v,0,1) == '0' && substr($v,1,1) != '.' ) || $dataFormat == 'string' ) { + //var_dump("Write ( {$r}, {$c} ) = " . $v); $worksheet->writeString($start_row+$r, $c, $v, $format); } else { - + //var_dump("Write String ( {$r}, {$c} ) = " . $v); $worksheet->write($start_row+$r, $c, $v, $format); } -- 2.39.2 From 64105dd74162bc661edb55f10b6811d070e78cbe Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 5 Apr 2024 12:05:59 +0800 Subject: [PATCH 06/16] fix merge --- .roobuilder.jcfg | 13 +++++++++++++ DataObjects/Core_holiday.php | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .roobuilder.jcfg diff --git a/.roobuilder.jcfg b/.roobuilder.jcfg new file mode 100644 index 00000000..b1099f66 --- /dev/null +++ b/.roobuilder.jcfg @@ -0,0 +1,13 @@ +{ + "name" : "Pman.Core", + "xtype" : "Roo", + "fn" : "3ab3f691edabeed20ba58b844cde0cc6", + "runhtml" : "", + "rootURL" : "http://localhost/web.Texon/", + "base_template" : "roo.builder.html", + "html_gen" : "", + "DBTYPE" : "", + "DBNAME" : "", + "DBUSERNAME" : "", + "DBPASSWORD" : "" +} \ No newline at end of file diff --git a/DataObjects/Core_holiday.php b/DataObjects/Core_holiday.php index 742a2406..3a2e9d50 100644 --- a/DataObjects/Core_holiday.php +++ b/DataObjects/Core_holiday.php @@ -73,13 +73,19 @@ class Pman_Core_DataObjects_Core_holiday extends DB_DataObject $fmt = substr($matches[1], 0, 4) . "-" . substr($matches[1], 4, 2) . "-" . substr($matches[1], 6, 2); $end_dt = date('Y-m-d', strtotime($fmt)); } +<<<<<<< Updated upstream +======= + if(preg_match('/^SUMMARY[^:]*:(.*)/', $line, $matches)){ + $name = trim($matches[1]); + } +>>>>>>> Stashed changes } if(empty($start_dt) || empty($end_dt)){ continue; } - + //DB_DataObject::DebugLevel(1); //var_dump($start_dt); var_dump($end_dt); exit; for ($i = strtotime($start_dt); $i < strtotime($end_dt) ; $i += (60 * 60 * 24)) { @@ -89,6 +95,14 @@ class Pman_Core_DataObjects_Core_holiday extends DB_DataObject $d->holiday_date = date('Y-m-d', $i); if (!$d->count()) { $d->insert(); +<<<<<<< Updated upstream +======= + } else { + $d->find(true); + $dd = clone($d); + $d->name = $name; + $d->update($dd); +>>>>>>> Stashed changes } -- 2.39.2 From d03e79a2aa9748aa8055bb8e8b95d7c42829e25c Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 5 Apr 2024 15:22:32 +0800 Subject: [PATCH 07/16] remove lockign check --- Notify.php | 6 +++--- NotifySend.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Notify.php b/Notify.php index 55047c7a..3fd4c5b4 100644 --- a/Notify.php +++ b/Notify.php @@ -179,9 +179,9 @@ class Pman_Core_Notify extends Pman function get($r,$opts=array()) { - if ($this->database_is_locked()) { - die("LATER - DATABASE IS LOCKED"); - } + // if ($this->database_is_locked()) { + // die("LATER - DATABASE IS LOCKED"); + //} $this->parseArgs($opts); diff --git a/NotifySend.php b/NotifySend.php index a7b68742..f94ff33d 100644 --- a/NotifySend.php +++ b/NotifySend.php @@ -87,9 +87,9 @@ class Pman_Core_NotifySend extends Pman function get($id,$opts=array()) { - if ($this->database_is_locked()) { - die("LATER - DATABASE IS LOCKED"); - } + //if ($this->database_is_locked()) { + // die("LATER - DATABASE IS LOCKED"); + // } //print_r($opts); if (!empty($opts['DB_DataObject-debug'])) { DB_DataObject::debugLevel($opts['DB_DataObject-debug']); -- 2.39.2 From e7de390be9d57ea19985f163f00d514fee7e80db Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 9 Apr 2024 14:43:19 +0800 Subject: [PATCH 08/16] fix holiday --- DataObjects/Core_holiday.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/DataObjects/Core_holiday.php b/DataObjects/Core_holiday.php index 3a2e9d50..76e0b8ba 100644 --- a/DataObjects/Core_holiday.php +++ b/DataObjects/Core_holiday.php @@ -73,13 +73,9 @@ class Pman_Core_DataObjects_Core_holiday extends DB_DataObject $fmt = substr($matches[1], 0, 4) . "-" . substr($matches[1], 4, 2) . "-" . substr($matches[1], 6, 2); $end_dt = date('Y-m-d', strtotime($fmt)); } -<<<<<<< Updated upstream - -======= if(preg_match('/^SUMMARY[^:]*:(.*)/', $line, $matches)){ $name = trim($matches[1]); } ->>>>>>> Stashed changes } if(empty($start_dt) || empty($end_dt)){ @@ -95,15 +91,13 @@ class Pman_Core_DataObjects_Core_holiday extends DB_DataObject $d->holiday_date = date('Y-m-d', $i); if (!$d->count()) { $d->insert(); -<<<<<<< Updated upstream -======= + } else { $d->find(true); $dd = clone($d); $d->name = $name; $d->update($dd); ->>>>>>> Stashed changes - } + } } -- 2.39.2 From 502802cc2709b55220ae7e557f43e81a2e08d14c Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 9 Apr 2024 14:47:04 +0800 Subject: [PATCH 09/16] allow filtering of holiday dates --- DataObjects/Core_holiday.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/DataObjects/Core_holiday.php b/DataObjects/Core_holiday.php index 76e0b8ba..9867e505 100644 --- a/DataObjects/Core_holiday.php +++ b/DataObjects/Core_holiday.php @@ -24,6 +24,22 @@ class Pman_Core_DataObjects_Core_holiday extends DB_DataObject 'cny' => 'https://raw.githubusercontent.com/andrewlkho/cny.ics/master/cny.ics', // CNY ); + + function apply_filters($q, $au, $roo) + { + if (isset($q['date_from'])) { + $dt = date("Y-m-d",strtotime($q['date_from'])); + $this->whereAdd("holiday_date > '$dt'"); + } + if (isset($q['date_to'])) { + $dt = date("Y-m-d",strtotime($q['date_to'])); + $this->whereAdd("holiday_date < '$dt'"); + } + + + } + + function updateHolidays($country) { -- 2.39.2 From 2352c58e5c0a67107126f2ab2b9de4d74f6503fd Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 9 Apr 2024 14:47:44 +0800 Subject: [PATCH 10/16] typo --- DataObjects/Core_holiday.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataObjects/Core_holiday.php b/DataObjects/Core_holiday.php index 9867e505..cd26445d 100644 --- a/DataObjects/Core_holiday.php +++ b/DataObjects/Core_holiday.php @@ -25,7 +25,7 @@ class Pman_Core_DataObjects_Core_holiday extends DB_DataObject ); - function apply_filters($q, $au, $roo) + function applyFilters($q, $au, $roo) { if (isset($q['date_from'])) { $dt = date("Y-m-d",strtotime($q['date_from'])); -- 2.39.2 From 3369d275c326047c3a914ff6ac5afa520385a825 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 15 Apr 2024 15:46:23 +0800 Subject: [PATCH 11/16] upgrade id --- sql/events.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/events.sql b/sql/events.sql index 7998e173..b81c281b 100644 --- a/sql/events.sql +++ b/sql/events.sql @@ -1,6 +1,6 @@ CREATE TABLE Events ( - id int(11) NOT NULL auto_increment, + id bigint NOT NULL auto_increment, PRIMARY KEY (id) ) ; @@ -36,6 +36,11 @@ ALTER TABLE Events CHANGE COLUMN Container on_table VARCHAR(64); -- make action larger.. ALTER TABLE Events CHANGE COLUMN action action varchar(64) default NULL; +-- id needs more space.. +ALTER TABLE Events change COLUMN id id bigint NOT NULL AUTO_INCREMENT; + + + ALTER TABLE Events ADD INDEX lookupf (on_id, action, on_table, person_id, event_when, person_table); ALTER TABLE Events ADD INDEX lookup_person_id (person_id); -- 2.39.2 From 29a31647d9d95c567c0ce69e0ee085ea0bd4dbfe Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 16 Apr 2024 10:33:27 +0800 Subject: [PATCH 12/16] reduce frequency of heatbeat --- Heartbeat.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Heartbeat.php b/Heartbeat.php index 27c1bf87..b95c3be9 100644 --- a/Heartbeat.php +++ b/Heartbeat.php @@ -38,6 +38,10 @@ class Pman_Core_Heartbeat extends Pman } $cd->find(true); $cc = clone($cd); + if ( (time() - strtotime($cc->display_name)) < 30) { + die("OK - HEATBEAT TO FREQUENT"); + } + $cd->display_name = date("Y-m-d H:i:s"); $cd->update($cc); die("OK - HEARTBEAT WORKING"); -- 2.39.2 From 745711924a2634d7a3e41df56e1684664d921889 Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 16 Apr 2024 11:09:30 +0800 Subject: [PATCH 13/16] flag as working even though we dont do update --- Heartbeat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Heartbeat.php b/Heartbeat.php index b95c3be9..3ef9acfa 100644 --- a/Heartbeat.php +++ b/Heartbeat.php @@ -39,7 +39,7 @@ class Pman_Core_Heartbeat extends Pman $cd->find(true); $cc = clone($cd); if ( (time() - strtotime($cc->display_name)) < 30) { - die("OK - HEATBEAT TO FREQUENT"); + die("OK - HEATBEAT WORKING"); } $cd->display_name = date("Y-m-d H:i:s"); -- 2.39.2 From 93a9f30f80b40a5016a5bcf99339f42917ee2ef7 Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 16 Apr 2024 11:13:31 +0800 Subject: [PATCH 14/16] typo --- Heartbeat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Heartbeat.php b/Heartbeat.php index 3ef9acfa..88d46074 100644 --- a/Heartbeat.php +++ b/Heartbeat.php @@ -39,7 +39,7 @@ class Pman_Core_Heartbeat extends Pman $cd->find(true); $cc = clone($cd); if ( (time() - strtotime($cc->display_name)) < 30) { - die("OK - HEATBEAT WORKING"); + die("OK - HEARTBEAT WORKING"); } $cd->display_name = date("Y-m-d H:i:s"); -- 2.39.2 From ea2034c963455e205fa67f20af44281457974352 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 18 Apr 2024 12:18:34 +0800 Subject: [PATCH 15/16] fix #8131 - chinese translations --- TimeZone.php | 117 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 107 insertions(+), 10 deletions(-) diff --git a/TimeZone.php b/TimeZone.php index 72a629fb..bdad4cf4 100644 --- a/TimeZone.php +++ b/TimeZone.php @@ -16,7 +16,8 @@ class Pman_Core_TimeZone extends Pman function get($base, $opts=array()) { - self::getTimezones(); + $this->lang = !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], array('en', 'zh_CN')) ? $_REQUEST['lang'] : 'en'; + self::getTimezones($this->lang); $data = array(); @@ -35,6 +36,7 @@ class Pman_Core_TimeZone extends Pman $data[] = array( 'region' => $o['region'], 'area' => $o['area'], + 'displayRegion' => $o['displayRegion'], 'displayArea' => $o['displayArea'] ); } @@ -48,6 +50,7 @@ class Pman_Core_TimeZone extends Pman 'fields' => array( 'region', 'area', + 'displayRegion', 'displayArea' ) ), @@ -64,7 +67,7 @@ class Pman_Core_TimeZone extends Pman static $timezones = array(); - static function getTimezones() + static function getTimezones($lang) { if(!empty(self::$timezones)) { return self::$timezones; @@ -91,23 +94,61 @@ class Pman_Core_TimeZone extends Pman Name ASC "); + $regions = DB_DataObject::factory('core_enum'); + $regions->setFrom(array( + 'etype' => 'Timezone.Region', + 'active' => 1 + )); + $regionIds = $regions->fetchAll('display_name', 'id'); + + $areas = DB_DataObject::factory('core_enum'); + $areas->setFrom(array( + 'etype' => 'Timezone.Area', + 'active' => 1 + )); + $areaIds = $areas->fetchAll('display_name', 'id'); + + + $ct = DB_DataObject::factory('core_templatestr'); + $ct->lang = $lang; + $ct->on_table = 'core_enum'; + $ct->active = 1; + $translations = array(); + foreach($ct->fetchAll() as $t) { + if(empty($t->txt)) { + continue; + } + $translations[$t->on_id][$t->on_col] = $t->txt; + } + while($ce->fetch()) { // ignroe timezone such as 'CET' and 'America/Argentina/Buenos_Aires' $ar = explode('/', $ce->Name); // ignore timezone such as 'Etc/GMT+8' - - $displayArea = str_replace('_', ' ', $ar[1]); + $region = $displayRegion = $ar[0]; + + if(!empty($translations[$regionIds[$region]]['display_name'])) { + $displayRegion = $translations[$regionIds[$region]]['display_name']; + } + + $area = $ar[1]; + $displayArea = str_replace('_', ' ', $area); + + if(!empty($translations[$areaIds[$displayArea]]['display_name'])) { + $displayArea = $translations[$areaIds[$displayArea]]['display_name']; + } $timeOffset = ((substr($ce->timeOffset, 0, 1) == '-') ? '' : '+') . $ce->timeOffset; $displayOffset = '(GMT ' . $timeOffset . ')'; self::$timezones[$ce->Name] = array( - 'region' => $ar[0], - 'area' => $ar[1], + 'region' => $region, + 'area' => $area, 'displayName' => $ar[0] . '/' . $displayArea . ' ' . $displayOffset, + 'displayRegion' => $displayRegion, 'displayArea' => $displayArea . ' ' . $displayOffset ); } @@ -158,14 +199,70 @@ class Pman_Core_TimeZone extends Pman return $date->format('P'); } - static function toDisplayArea($dt, $tz) + static function toDisplayRegion($lang, $tz) + { + $region = explode('/', $tz)[0]; + + $ce = DB_DataObject::factory('core_enum'); + $ce->setFrom(array( + 'etype' => 'Timezone.Region', + 'active' => 1, + 'name' => $region, + 'display_name' => $region + )); + if(!$ce->find(true)) { + return $region; + } + + $ct = DB_DataObject::factory('core_templatestr'); + $ct->setFrom(array( + 'lang' => $lang, + 'on_table' => 'core_enum', + 'on_id' => $ce->id, + 'on_col' => 'display_name', + 'active' => 1 + )); + if(!$ct->find(true) || empty($ct->txt)) { + return $region; + } + return $ct->txt; + } + + static function toDisplayArea($lang, $dt, $tz) { - return str_replace('_', ' ', self::toArea($tz)) . ' (GMT ' . self::toTimeOffset($dt,$tz) . ')'; + $displayArea = str_replace('_', ' ', self::toArea($tz)); + $displayOffset = '(GMT ' . self::toTimeOffset($dt,$tz) . ')'; + + $ce = DB_DataObject::factory('core_enum'); + $ce->setFrom(array( + 'etype' => 'Timezone.Area', + 'active' => 1, + 'name' => $displayArea, + 'display_name' => $displayArea + )); + + if(!$ce->find(true)) { + return $displayArea . ' ' . $displayOffset; + } + + $ct = DB_DataObject::factory('core_templatestr'); + $ct->setFrom(array( + 'lang' => $lang, + 'on_table' => 'core_enum', + 'on_id' => $ce->id, + 'on_col' => 'display_name', + 'active' => 1 + )); + if(!$ct->find(true) || empty($ct->txt)) { + return $displayArea . ' ' . $displayOffset; + } + + return $ct->txt . ' ' . $displayOffset; } - static function toDisplayName($dt, $tz) + static function toDisplayName($lang, $dt, $tz) { - return self::toRegion($tz) . '/' . self::toDisplayArea($dt, $tz); + return self::toDisplayRegion($lang, $tz) . '/' . self::toDisplayArea($lang, $dt, $tz); } } \ No newline at end of file -- 2.39.2 From d9b52d97e6a826ac6c5f8e91a881b8d5d862ba7b Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 18 Apr 2024 12:19:57 +0800 Subject: [PATCH 16/16] fix #8131 - chinese translations --- Import/Timezone.php | 79 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Import/Timezone.php diff --git a/Import/Timezone.php b/Import/Timezone.php new file mode 100644 index 00000000..5c0f4b98 --- /dev/null +++ b/Import/Timezone.php @@ -0,0 +1,79 @@ +cli) { + die("cli only"); + } + } + + function get($part = '', $opts=array()) + { + $ce = DB_DataObject::factory('core_enum'); + $ce->query(" + SELECT + *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, 'UTC')), '%H:%i') as timeOffset + FROM + mysql.time_zone_name + WHERE + Name LIKE '%/%' + AND + Name NOT LIKE '%/%/%' + AND + Name NOT LIKE 'right%' + AND + Name NOT LIKE 'posix%' + AND + Name NOT LIKE 'Etc%' + ORDER BY + SUBSTRING_INDEX(Name, '/', 1) ASC, + timeoffset ASC, + Name ASC + "); + + $values = array(); + + $regions = array(); + $areas = array(); + + while($ce->fetch()) { + $ar = explode('/', $ce->Name); + $region = $ar[0]; + $area = str_replace('_', ' ', $ar[1]); + + if(!in_array($region, $regions)) { + $regions[] = $region; + $values[] = "('Timezone.Region', '" . $region . "', 1, 0, 0, '" . $region . "', 0)"; + } + + if(!in_array($area, $areas)) { + $areas[] = $area; + $values[] = "('Timezone.Area', '" . $area . "', 1, 0, 0, '" . $area . "', 0)"; + } + } + + $sql = " + INSERT INTO + core_enum (etype, name, active, seqid, seqmax, display_name, is_system_enum) + VALUES + " . implode(", \n", $values) . " + "; + + $ce = DB_DataObject::factory('core_enum'); + $ce->query($sql); + + $this->jok('DONE'); + } +} \ No newline at end of file -- 2.39.2