public function import_from_path($import_path, $ignore_version = false)
 {
     require_once AC_INCLUDE_PATH . 'classes/Language/LanguageParser.class.php';
     global $languageManager, $msg;
     $language_xml = @file_get_contents($import_path . 'language.xml');
     $languageParser = new LanguageParser();
     $languageParser->parse($language_xml);
     $languageEditor = $languageParser->getLanguageEditor(0);
     $import_version = $languageEditor->getACheckerVersion();
     if ($import_version != VERSION && !$ignore_version) {
         return array('version' => $import_version, "import_path" => $import_path);
     }
     if ($languageManager->exists($languageEditor->getCode())) {
         $msg->addError('LANG_EXISTS');
     }
     if (!$msg->containsErrors()) {
         $languageEditor->import($import_path . 'language_text.sql');
         $msg->addFeedback('IMPORT_LANG_SUCCESS');
     }
     $this->cleanup_language_files($import_path);
     return true;
 }
Ejemplo n.º 2
0
 function import($filename)
 {
     global $languageManager, $msg;
     require_once AT_INCLUDE_PATH . 'classes/pclzip.lib.php';
     require_once AT_INCLUDE_PATH . '../mods/_core/languages/classes/LanguagesParser.class.php';
     $import_path = AT_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);
     if ($languageEditor->getAtutorVersion() != VERSION && (!defined('AT_DEVEL_TRANSLATE') || !AT_DEVEL_TRANSLATE)) {
         $msg->addError('LANG_WRONG_VERSION');
     }
     if ($languageEditor->getStatus() != AT_LANG_STATUS_PUBLISHED && $languageEditor->getStatus() != AT_LANG_STATUS_COMPLETE && (!defined('AT_DEVEL_TRANSLATE') || !AT_DEVEL_TRANSLATE)) {
         $msg->addError('LANG_NOT_COMPLETE');
     }
     if ($languageManager->exists($languageEditor->getCode())) {
         $msg->addError('LANG_EXISTS');
     }
     if (!$msg->containsErrors()) {
         $languageEditor->import($import_path . 'language_text.sql');
         $msg->addFeedback('IMPORT_LANG_SUCCESS');
     }
     // remove the files:
     @unlink($import_path . 'language.xml');
     @unlink($import_path . 'language_text.sql');
     @unlink($import_path . 'readme.txt');
     @unlink($filename);
 }
Ejemplo n.º 3
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);
 }