Compare commits

...

2 Commits

Author SHA1 Message Date
Clemens Schwaighofer
ba89b188d9 Mo create script update, phpstan fixes, document updates
create_mo:
set auto base folder bases on current location so we do not need do
adjust paths in script

phpstan fixes:
edit_base.php
CoreLibs/Basci.php
CoreLibs/DB/SQL/PgSQL.php

Update documentation in method headers
CoreLibs/Combined/DateTime.php
2022-10-12 09:48:22 +09:00
Clemens Schwaighofer
d15618cde4 Add JS_TRANSLATE file to smart template flow 2022-10-04 17:35:46 +09:00
8 changed files with 58 additions and 24 deletions

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env bash
base_folder='/var/www/html/developers/clemens/core_data/php_libraries/trunk/www/';
BASE_FOLDER=$(dirname $(readlink -f $0))"/";
# Assume script is in 4dev/bin
base_folder="${BASE_FOLDER}../../www/";
# locale gettext po to mo translator master
for file in $(ls -1 ${base_folder}../4dev/locale/*.po); do

View File

@@ -19,5 +19,4 @@ lib/CoreLibs/DB/Extended/ArrayIO.php
lib/CoreLibs/Convert/MimeEncode.php
lib/CoreLibs/Create/Email.php
lib/CoreLibs/Output/Form/Generate.php
```

View File

@@ -457,6 +457,8 @@ if ($form->my_page_name == 'edit_order') {
$pathinfo = pathinfo($output_file);
if (!empty($pathinfo['dirname'])) {
$pathinfo['dirname'] .= DIRECTORY_SEPARATOR;
} else {
$pathinfo['dirname'] = '';
}
if ($t_q) {
$t_q .= ', ';

View File

@@ -1329,11 +1329,12 @@ function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disabl
}
// clear out just in case for first entry
// fill with div name & login/logout button
$('#loginRow').html(phfo(cel('div', '', login_string)));
$('#loginRow').html(phfo(cel('div', 'loginRow-name', login_string)));
$('#loginRow').append(phfo(cel('div', 'loginRow-info', '')));
$('#loginRow').append(phfo(
aelx(
// outer div
cel('div'),
cel('div', 'loginRow-logout'),
// inner element
cel('input', 'logout', '', [], {
value: __('Logout'),
@@ -1386,6 +1387,8 @@ function createNavMenu(nav_menu, header_id = 'mainHeader') // eslint-disable-lin
}
});
$('#menuRow').html(content.join(''));
} else {
$('#menuRow').hide();
}
}

View File

@@ -66,7 +66,7 @@ class Basic
// logging interface, Debug\Logging class
/** @var \CoreLibs\Debug\Logging */
public $log;
/** @var\CoreLibs\Create\Session */
/** @var \CoreLibs\Create\Session */
public $session;
// email valid checks

View File

@@ -312,16 +312,17 @@ class DateTime
}
/**
* plits & checks date, wrap around for check_date function
* returns int in:
* -1 if the first date is smaller the last
* 0 if both are equal
* 1 if the first date is bigger than the last
* false (bool): error
* compares two dates, tries to convert them via strtotime to timestamps
* returns int/bool in:
* -1 if the first date is smaller the last
* 0 if both are equal
* 1 if the first date is bigger than the last
* false if date validation/conversion failed
*
* @param string $start_date start date string in YYYY-MM-DD
* @param string $end_date end date string in YYYY-MM-DD
* @return int|bool false on error, or int -1/0/1 as difference
* @return int|bool false on error
* or int -1 (s<e)/0 (s=e)/1 (s>e) as difference
*/
public static function compareDate($start_date, $end_date)
{
@@ -354,16 +355,17 @@ class DateTime
/**
* compares the two dates + times. if seconds missing in one set,
* add :00, converts / to -
* adds :00, converts date + times via strtotime to timestamps
* returns int/bool in:
* -1 if the first date is smaller the last
* 0 if both are equal
* 1 if the first date is bigger than the last
* false if no valid date/times chould be found
* -1 if the first date is smaller the last
* 0 if both are equal
* 1 if the first date is bigger than the last
* false if date/times validation/conversion failed
*
* @param string $start_datetime start date/time in YYYY-MM-DD HH:mm:ss
* @param string $end_datetime end date/time in YYYY-MM-DD HH:mm:ss
* @return int|bool false for error or -1/0/1 as difference
* @return int|bool false for error
* or -1 (s<e)/0 (s=e)/1 (s>e) as difference
*/
public static function compareDateTime($start_datetime, $end_datetime)
{

View File

@@ -779,7 +779,6 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions
}
// get result
$db_schema = $this->__dbFetchArray($cursor, PGSQL_ASSOC);
/** @phpstan-ignore-next-line Cannot access offset string on array|bool */
return $db_schema[$show_string] ?? '';
}
@@ -806,7 +805,6 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions
}
// check if schema does not exists
$row = $this->__dbFetchArray($cursor, PGSQL_ASSOC);
/** @phpstan-ignore-next-line */
if (empty($row['exists']) || $row['exists'] == 'f') {
return 2;
}

View File

@@ -105,6 +105,8 @@ class SmartyExtend extends \Smarty
public $CSS_TEMPLATE_NAME;
/** @var string|null */
public $TEMPLATE_TRANSLATE;
/** @var string|null */
public $JS_TRANSLATE;
// core group
/** @var string */
public $JS_CORE_TEMPLATE_NAME;
@@ -317,14 +319,14 @@ class SmartyExtend extends \Smarty
}
// javascript translate data as template for auto translate
if (empty($this->TEMPLATE_TRANSLATE)) {
$this->TEMPLATE_TRANSLATE = 'jsTranslate_'
$this->TEMPLATE_TRANSLATE = 'jsTranslate-'
. $this->locale_set . '.' . $this->encoding
. '.tpl';
} else {
// we assume we have some fixed set
// we must add _<$this->lang>
// we must add _<locale>.<encoding>
// if .tpl, put before .tpl
// if not .tpl, add _<$this->lang>.tpl
// if not .tpl, add _<locale>.<encoding>.tpl
if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) {
$this->TEMPLATE_TRANSLATE = str_replace(
'.tpl',
@@ -332,7 +334,7 @@ class SmartyExtend extends \Smarty
$this->TEMPLATE_TRANSLATE
);
} else {
$this->TEMPLATE_TRANSLATE .= '_'
$this->TEMPLATE_TRANSLATE .= '-'
. $this->locale_set . '.' . $this->encoding
. '.tpl';
}
@@ -341,6 +343,31 @@ class SmartyExtend extends \Smarty
if (!file_exists($this->getTemplateDir()[0] . DIRECTORY_SEPARATOR . $this->TEMPLATE_TRANSLATE)) {
$this->TEMPLATE_TRANSLATE = null;
}
if (empty($this->JS_TRANSLATE)) {
$this->JS_TRANSLATE = 'translate-'
. $this->locale_set . '.' . $this->encoding . '.js';
} else {
// we assume we have some fixed set
// we must add _<locale>.<encoding>
// if .js, put before .js
// if not .js, add _<locale>.<encoding>.js
if (strpos($this->JS_TRANSLATE, '.js')) {
$this->JS_TRANSLATE = str_replace(
'.js',
'-' . $this->locale_set . '.' . $this->encoding . '.js',
$this->JS_TRANSLATE
);
} else {
$this->JS_TRANSLATE .= '-'
. $this->locale_set . '.' . $this->encoding
. '.js';
}
}
if (!file_exists($this->JAVASCRIPT . $this->JS_TRANSLATE)) {
$this->JS_TRANSLATE = null;
} else {
$this->JS_TRANSLATE = $this->JAVASCRIPT . $this->JS_TRANSLATE;
}
}
/**
@@ -469,6 +496,7 @@ class SmartyExtend extends \Smarty
$this->DATA['TEMPLATE_NAME'] = $this->TEMPLATE_NAME;
$this->DATA['CONTENT_INCLUDE'] = $this->CONTENT_INCLUDE;
$this->DATA['TEMPLATE_TRANSLATE'] = $this->TEMPLATE_TRANSLATE ?? null;
$this->DATA['JS_TRANSLATE'] = $this->JS_TRANSLATE ?? null;
$this->DATA['PAGE_FILE_NAME'] = str_replace('.php', '', $this->page_name) . '.tpl';
// render page
$this->renderSmarty();