CMXX - Product attributes and initial multi languagal product support

This commit is contained in:
“VeLiTi”
2025-01-14 14:40:01 +01:00
parent 906ce7b843
commit 05b0c2bdb1
18 changed files with 234 additions and 202 deletions

View File

@@ -2,12 +2,12 @@
defined(page_security_key) or exit;
$page = 'translation_manage';
/*Check if allowed
//Check if allowed
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
header('location: index.php');
exit;
}
*/
//PAGE Security
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
@@ -56,7 +56,7 @@ if (isset($_GET['rowID'])) {
}
}
if (isset($_POST['update']) || isset($_POST['add'])) {
if (isset($_POST['add'])) {
//GET ALL POST DATA
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
@@ -66,11 +66,42 @@ if (isset($_GET['rowID'])) {
if ($responses === 'NOK'){
} else {
header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].'');
generateLanguageFile($_POST['language_key'],$_SESSION['userkey']);
header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].'');
exit;
}
}
if (isset($_POST['update']) && isset($_POST['item'])) {
//Indicator if update has errors
$NOK_error = 0;
//RUN through all POST items
foreach ($_POST['item'] as $attr){
//GET ALL POST DATA
$payload = json_encode($attr, JSON_UNESCAPED_UNICODE);
//API call
$responses = ioServer('/v2/translations_details', $payload);
if ($responses === 'NOK'){
//NOT correct exit procedure
$NOK_error++;
exit;
} else {
$attr_language = $attr['language_key'];
}
}
if ($NOK_error == 0){
//NO errors generatelanguagefile
generateLanguageFile($attr_language,$_SESSION['userkey']);
}
header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].'');
exit;
}
}
if ($delete_allowed === 1){
@@ -207,16 +238,16 @@ $view .= '
<tr>
<td>
<select form="update" id="language" name="language_key">';
<select form="update" id="language" name="item['.$translation['rowID'].'][language_key]">';
foreach ($supportedLanguages as $language){
$view .='<option value="'.$language.'" '.(($translation['language_key'] == $language)?' selected':'').'>'.$language.'</option>';
}
$view .='</select></td>
<td><input form="update" type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" value="'.$translation['translation'].'"></td>
<td><input form="update" type="text" name="item['.$translation['rowID'].'][translation]" placeholder="'.($text_variable_translation_translation ?? '').'" value="'.$translation['translation'].'"></td>
<td>'.getRelativeTime($translation['created']).'</td>
<td><input form="update" type="submit" name="update" value="&" class="btn"></td>
<input form="update" type="hidden" name="rowID" value="'.$translation['rowID'].'" readonly>
<input form="update" type="hidden" name="variable_ID" value="'.$text_variable['rowID'].'" readonly>
<input form="update" type="hidden" name="item['.$translation['rowID'].'][rowID]" value="'.$translation['rowID'].'" readonly>
<input form="update" type="hidden" name="item['.$translation['rowID'].'][variable_ID]" value="'.$text_variable['rowID'].'" readonly>
</tr>
</form>';
}
@@ -248,42 +279,6 @@ $view .= '
tbody.appendChild(newRow);
}
function addRow() {
// Get reference to the table body
const tbody = document.querySelector(\'#textTable tbody\');
console.log("test");
// Create new row
const newRow = document.createElement(\'tr\');
// Create three cells for the row
const oneCell = document.createElement(\'td\');
const twoCell = document.createElement(\'td\');
const threeCell = document.createElement(\'td\');
const fourCell = document.createElement(\'td\');
// Add content to cells
oneCell.innerHTML = \'<form action="" method="post"><select id="language" name="language_key">';
foreach ($supportedLanguages as $language){
$view .= '<option value="'.$language.'">'.$language.'</option>';
}
$view .= ' </select>\'
twoCell.innerHTML = \'<input type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" value="">\'
fourCell.innerHTML = \'<input type="submit" name="add" value="+" class="btn"></form>\'
// Append cells to the row
newRow.appendChild(oneCell);
newRow.appendChild(twoCell);
newRow.appendChild(threeCell);
newRow.appendChild(fourCell);
// Append row to table body
tbody.appendChild(newRow);
// Increment counter for next row
rowCounter++;
}
</script>
</div>
</div>