コード例 #1
0
<?php

/************************************************************************/
/* AContent                                                             */
/************************************************************************/
/* Copyright (c) 2010                                                   */
/* Inclusive Design Institute                                           */
/*                                                                      */
/* This program is free software. You can redistribute it and/or        */
/* modify it under the terms of the GNU General Public License          */
/* as published by the Free Software Foundation.                        */
/************************************************************************/
define('TR_INCLUDE_PATH', '../include/');
include TR_INCLUDE_PATH . 'vitals.inc.php';
include_once TR_INCLUDE_PATH . 'classes/DAO/LanguagesDAO.class.php';
if ($_POST['value'] == '') {
    $rtn['status'] = 'fail';
    $rtn['error'][] = _AT('TR_ERROR_EMPTY_FIELD');
}
if (isset($_POST['field']) && isset($_POST['value']) && $_POST['value'] != '') {
    $languagesDAO = new LanguagesDAO();
    // Format of $_POST['field']: [fieldName]|[language_code]|[charset]
    $pieces = explode(':', $_POST['field']);
    $languagesDAO->UpdateField($pieces[1], $pieces[0], $_POST['value']);
    $rtn['status'] = 'success';
    $rtn['success'][] = _AT('TR_FEEDBACK_ACTION_COMPLETED_SUCCESSFULLY');
}
echo json_encode($rtn);
コード例 #2
0
 function import($filename)
 {
     require_once TR_INCLUDE_PATH . 'lib/pclzip.lib.php';
     require_once TR_INCLUDE_PATH . 'classes/Language/LanguageParser.class.php';
     require_once TR_INCLUDE_PATH . 'classes/DAO/LanguagesDAO.class.php';
     global $languageManager, $msg;
     $import_path = TR_CONTENT_DIR . 'import/';
     $archive = new PclZip($filename);
     if ($archive->extract(PCLZIP_OPT_PATH, $import_path) == 0) {
         exit('Error : ' . $archive->errorInfo(true));
     }
     $language_xml = @file_get_contents($import_path . 'language.xml');
     $languageParser = new LanguageParser();
     $languageParser->parse($language_xml);
     $languageEditor =& $languageParser->getLanguageEditor(0);
     $lang_code = $languageEditor->getCode();
     if ($languageManager->exists($lang_code)) {
         $msg->addError('LANG_EXISTS');
     }
     if (!$msg->containsErrors()) {
         $languageEditor->import($import_path . 'language_text.sql');
         $languagesDAO = new LanguagesDAO();
         $languagesDAO->UpdateField($lang_code, "status", TR_STATUS_ENABLED);
         $msg->addFeedback('IMPORT_LANG_SUCCESS');
         $version_in_pack = $languageEditor->getTransformableVersion();
         if ($version_in_pack != VERSION) {
             $msg->addFEEDBACK(array('LANG_MISMATCH_VERSION', $version_in_pack, VERSION));
         }
     }
     // remove the files:
     @unlink($import_path . 'language.xml');
     @unlink($import_path . 'language_text.sql');
     @unlink($import_path . 'readme.txt');
     @unlink($filename);
 }