PHP Classes

File: ajax/ajax.back.office.update.toolz.menu.php

Recommend this page to a friend!
  Classes of Johan Barbier   oLoc   ajax/ajax.back.office.update.toolz.menu.php   Download  
File: ajax/ajax.back.office.update.toolz.menu.php
Role: Application script
Content type: text/plain
Description: Ajax script
Class: oLoc
Retrieve and edit internationalized texts
Author: By
Last change: Added encoding choice
Date: 17 years ago
Size: 2,153 bytes
 

Contents

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

try {
    if(empty(
$_POST['TYPE']) || !isset($_POST['WEB'])) {
        throw new
genericExceptions(genericExceptions::_MISSING_PARAMETER_);
    }
    if(
'0' === $_POST['WEB']) {
       
$_POST['WEB'] = null;
    }
    if(
$_POST['TYPE'] !== 'addWebsite') {
       
$oBO = new backoffice($_POST['WEB']);
    } else {
       
$oBO = new backoffice;
    }
   
$sHtml = '';
   
    if(
$_POST['TYPE'] === 'language') {
       
$oStoredLanguages = $oBO->getLanguages();
       
$oStoredLanguages->natcasesort();
       
$sHtml = '<select id="availableLanguages">';
       
$sHtml .= '<option value="0">Select a language</option>';
        foreach(
$oStoredLanguages as $sLanguage) {
           
$sHtml .= '<option value="'.$sLanguage.'">'.$sLanguage.'</option>';
        }
       
$sHtml .= '</select>';
    } elseif(
$_POST['TYPE'] === 'languageRef') {
       
$oStoredLanguages = $oBO->getLanguages();
       
$oStoredLanguages->natcasesort();
       
$sHtml = '<select id="availableLanguageRef">';
       
$sHtml .= '<option value="0">Select a ref. language</option>';
        foreach(
$oStoredLanguages as $sLanguage) {
           
$sHtml .= '<option value="'.$sLanguage.'">'.$sLanguage.'</option>';
        }
       
$sHtml .= '</select>';
       
    } elseif(
$_POST['TYPE'] === 'module') {
       
$oStoredModules = $oBO->getModules();
       
$oStoredModules->natcasesort();
       
$sHtml = '<select id="availableModules">';
       
$sHtml .= '<option value="0">Select a module</option>';
        foreach(
$oStoredModules as $sModule) {
           
$sHtml .= '<option value="'.$sModule.'">'.$sModule.'</option>';
        }
       
$sHtml .= '</select>';
       
    } elseif(
$_POST['TYPE'] === 'addLanguage') {
       
$oBO->addLanguage($_POST['LNG']);
       
$sHtml = 'Language '.$_POST['LNG'].' successfully created';
       
    } elseif(
$_POST['TYPE'] === 'addModule') {
        if(empty(
$_POST['ENCODING'])) {
           
$_POST['ENCODING'] = 'UTF-8';
        }
       
$oBO->addModule($_POST['MOD'], $_POST['ENCODING']);
       
$sHtml = 'Module '.$_POST['MOD'].' successfully created';
    } elseif(
$_POST['TYPE'] === 'addWebsite') {
       
$oBO->addWebsite($_POST['WEB']);
       
$sHtml = 'Website '.$_POST['WEB'].' successfully created';
    }
   
    echo
utf8_encode($sHtml);
} catch(
Exception $e) {
    echo
utf8_encode('ERR_'.$e);
}
?>