PHP Classes

File: ajax/ajax.back.office.display.list.php

Recommend this page to a friend!
  Classes of Johan Barbier   oLoc   ajax/ajax.back.office.display.list.php   Download  
File: ajax/ajax.back.office.display.list.php
Role: Application script
Content type: text/plain
Description: Ajax script
Class: oLoc
Retrieve and edit internationalized texts
Author: By
Last change: Added a button to delete a translation in all the languages
Date: 16 years ago
Size: 3,008 bytes
 

Contents

Class file image Download
<?php
require_once '../inc/inc.main.php';

try {
    if(!isset(
$_POST['LNG']) || !isset($_POST['MOD']) || !isset($_POST['REF']) || !isset($_POST['WEB'])) {
        throw new
genericExceptions(genericExceptions::_MISSING_PARAMETER_);
    }
   
    function
returnNull($v) {
        if(
"0" === $v) {
            return
null;
        }
        return
$v;
    }
   
   
$_POST = array_map('returnNull', $_POST);
   
$oBO = new backoffice($_POST['WEB']);
    if(
is_null($_POST['LNG']) || is_null($_POST['REF'])) {
        throw new
boException(boException::_MISSING_CHOICE_);
    }
   
$aTrans = $oBO->getTranslationsList($_POST['MOD'], $_POST['LNG'], $_POST['REF']);
   
$sHtml = '';
   
$iCptClass = 0;
    foreach(
$aTrans['REF'] as $sRefLng => $aTranslations) {
        foreach(
$aTranslations as $sMod => $aTrRef) {
            foreach(
$aTrRef as $sConst => $sConstTranslation) {
               
$sHtml .= '<tr>';
               
$sClassName = ($iCptClass%2 === 0)?'_C0':'_C1';
               
$sHtml .= '<td class="'.$sClassName.'">'.$sConst.'</td>';
                if(!empty(
$sConstTranslation)) {
                   
$sHtml .= '<td class="'.$sClassName.'"><span title="Click to modify" class="transformable">'.$sConstTranslation.'</span><textarea id="'.$sConst.'@'.$sRefLng.'@REF" name="'.$sConst.'@'.$sRefLng.'@REF" style="display: none;" class="magicalInput">'.$sConstTranslation.'</textarea></td>';
                } else {
                   
$sHtml .= '<td class="'.$sClassName.'"><span title="Click to modify" class="transformable">NO TRANSLATION FOUND</span><textarea id="'.$sConst.'@'.$sRefLng.'@REF" name="'.$sConst.'@'.$sRefLng.'@REF" style="display: none;" class="magicalInput">NO TRANSLATION FOUND</textarea></td></td>';
                }
                foreach(
$aTrans['LNG'] as $sLng => $aTr) {
                    if(!empty(
$aTr[$sMod][$sConst])) {
                       
$sHtml .= '<td class="'.$sClassName.'"><span title="Click to modify" class="transformable">'.$aTr[$sMod][$sConst].'</span><textarea id="'.$sConst.'@'.$sLng.'@BASE" name="'.$sConst.'_'.$sLng.'" style="display: none;" class="magicalInput">'.$aTr[$sMod][$sConst].'</textarea></td><td><img src="'.PATH_IMG.'delete16.png" id="delConstantBtn_'.$sConst.'" title="Delete the constant" alt="Delete the constant" class="delConstantBtn" /></td>';
                    } else {
                       
$sHtml .= '<td class="'.$sClassName.'"><span title="Click to modify" class="transformable">NO TRANSLATION FOUND</span><textarea id="'.$sConst.'@'.$sLng.'@BASE" name="'.$sConst.'_'.$sLng.'" style="display: none;" class="magicalInput">NO TRANSLATION FOUND</textarea></td></td><td><img src="'.PATH_IMG.'delete16.png" id="delConstantBtn_'.$sConst.'" title="Delete the constant" alt="Delete the constant" class="delConstantBtn" /></td>';
                    }
                   
                }
               
$sHtml .= '</tr>';
               
$iCptClass ++;
            }
        }
    }
   
$sHtml .= '<tr><td colspan="4"><input title="Add a new constant" type="text" value="" name="addNewConstant" id="addNewConstant" />&nbsp;<img src="'.PATH_IMG.'add16.png" id="addConstantBtn" title="Add a new constant" alt="Add a new constant" class="button" /></td></tr>';
    echo
$sHtml;
} catch(
Exception $e) {
    echo
utf8_encode('ERR_'.$e);
}
?>