2012-10-17 16:23:22 -04:00
|
|
|
<?php
|
2017-02-15 16:26:02 +00:00
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
try {
|
2015-03-18 17:12:38 -04:00
|
|
|
$filter = new InputFilter();
|
|
|
|
|
$_POST = $filter->xssFilterHard($_POST);
|
2017-01-11 17:56:46 -04:00
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
if (isset($_POST['form'])) {
|
2012-10-17 16:23:22 -04:00
|
|
|
$_POST = $_POST['form'];
|
|
|
|
|
}
|
2017-09-12 16:59:06 -04:00
|
|
|
$_POST['function'] = get_ajax_value('function');
|
2015-03-18 17:12:38 -04:00
|
|
|
$_POST['function'] = $filter->xssFilterHard($_POST['function']);
|
2012-10-17 16:23:22 -04:00
|
|
|
switch ($_POST['function']) {
|
|
|
|
|
case 'savePredetermined':
|
|
|
|
|
$tranlationsList = Translation::getTranslationEnvironments();
|
2017-09-12 16:59:06 -04:00
|
|
|
G::pr($tranlationsList);
|
|
|
|
|
if (isset($meta['LAN_ID']) && $meta['LAN_ID'] == $_POST['lang']) {
|
2012-10-17 16:23:22 -04:00
|
|
|
echo 'The Setting was saved successfully!';
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Some error occured while the setting was being save, try later please.';
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'languagesList':
|
2017-08-04 17:44:29 -04:00
|
|
|
$isoCountry = new IsoCountry();
|
2012-10-17 16:23:22 -04:00
|
|
|
$translationRow = new Translation();
|
|
|
|
|
$response = new stdClass();
|
|
|
|
|
$translationsEnvList = $translationRow->getTranslationEnvironments();
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($translationsEnvList as $locale => $translationRow) {
|
2017-09-12 16:59:06 -04:00
|
|
|
$countryId = $translationRow['IC_UID'];
|
|
|
|
|
if ($countryId != '') {
|
|
|
|
|
$isoCountryRecord = $isoCountry->findById(strtoupper($countryId));
|
|
|
|
|
$flag = strtolower($isoCountryRecord['IC_UID']);
|
2012-10-17 16:23:22 -04:00
|
|
|
$countryName = $translationRow['HEADERS']['X-Poedit-Country'];
|
|
|
|
|
} else {
|
|
|
|
|
$flag = 'international';
|
2017-09-12 16:59:06 -04:00
|
|
|
$countryName = G::LoadTranslation('ID_INTERNATIONAL');
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$conf = new Configurations();
|
2017-09-12 16:59:06 -04:00
|
|
|
$confCasesList = $conf->getConfiguration('casesList', 'todo');
|
2012-10-17 16:23:22 -04:00
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
if (isset($confCasesList['dateformat'])) {
|
|
|
|
|
$datetime = explode(' ', $translationRow['DATE']);
|
|
|
|
|
$date = explode('-', $datetime[0]);
|
|
|
|
|
if (count($datetime) == 2) {
|
|
|
|
|
$time = explode(':', $datetime[1]);
|
|
|
|
|
}
|
2012-10-17 16:23:22 -04:00
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
if (count($date) == 3) {
|
|
|
|
|
if (count($time) >= 2) {
|
|
|
|
|
$dateFormat = date($confCasesList['dateformat'],
|
|
|
|
|
mktime($time[0], $time[1], 0, $date[1], $date[2], $date[0]));
|
2012-10-17 16:23:22 -04:00
|
|
|
} else {
|
2017-09-12 16:59:06 -04:00
|
|
|
$dateFormat = date($confCasesList['dateformat'], mktime(0, 0, 0, $date[1], $date[2], $date[0]));
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2017-09-12 16:59:06 -04:00
|
|
|
$dateFormat = $translationRow['DATE'];
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
$datetime = explode(' ', $translationRow['HEADERS']['PO-Revision-Date']);
|
2012-10-17 16:23:22 -04:00
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
$date = explode('-', $datetime[0]);
|
|
|
|
|
if (count($datetime) == 2) {
|
|
|
|
|
$time = explode(':', $datetime[1]);
|
|
|
|
|
}
|
2012-10-17 16:23:22 -04:00
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
if (count($date) == 3) {
|
|
|
|
|
if (count($time) >= 2) {
|
|
|
|
|
$revDate = date($confCasesList['dateformat'],
|
|
|
|
|
mktime($time[0], substr($time[1], 0, 2), 0, $date[1], $date[2], $date[0]));
|
2012-10-17 16:23:22 -04:00
|
|
|
} else {
|
2017-09-12 16:59:06 -04:00
|
|
|
$revDate = date($confCasesList['dateformat'],
|
|
|
|
|
mktime(0, 0, 0, $date[1], $date[2], $date[0]));
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2017-09-12 16:59:06 -04:00
|
|
|
$revDate = $translationRow['HEADERS']['PO-Revision-Date'];
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2017-09-12 16:59:06 -04:00
|
|
|
$dateFormat = $translationRow['DATE'];
|
|
|
|
|
$revDate = $translationRow['HEADERS']['PO-Revision-Date'];
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$languagesList[$i]['LAN_ID'] = $translationRow['LAN_ID'];
|
|
|
|
|
$languagesList[$i]['LOCALE'] = $translationRow['LOCALE'];
|
|
|
|
|
$languagesList[$i]['LAN_FLAG'] = $flag;
|
|
|
|
|
$languagesList[$i]['NUM_RECORDS'] = $translationRow['NUM_RECORDS'];
|
2017-09-12 16:59:06 -04:00
|
|
|
$languagesList[$i]['DATE'] = $dateFormat;
|
2012-10-17 16:23:22 -04:00
|
|
|
$languagesList[$i]['LAN_NAME'] = $translationRow['HEADERS']['X-Poedit-Language'];
|
|
|
|
|
$languagesList[$i]['COUNTRY_NAME'] = $countryName;
|
2017-09-12 16:59:06 -04:00
|
|
|
$languagesList[$i]['TRANSLATOR'] = htmlentities($translationRow['HEADERS']['Last-Translator']);
|
|
|
|
|
$languagesList[$i]['REV_DATE'] = $revDate;
|
2012-10-17 16:23:22 -04:00
|
|
|
$languagesList[$i]['VERSION'] = $translationRow['HEADERS']['Project-Id-Version'];
|
|
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
$i++;
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
$translationRow = new Translation();
|
|
|
|
|
$response->data = $languagesList;
|
2017-09-12 16:59:06 -04:00
|
|
|
print (G::json_encode($response));
|
2012-10-17 16:23:22 -04:00
|
|
|
break;
|
|
|
|
|
case 'delete':
|
|
|
|
|
include_once 'classes/model/Translation.php';
|
|
|
|
|
include_once 'classes/model/Content.php';
|
|
|
|
|
$locale = $_POST['LOCALE'];
|
|
|
|
|
$trn = new Translation();
|
|
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
if (strpos($locale, Translation::$localeSeparator)) {
|
|
|
|
|
list ($LAN_ID, $IC_UID) = explode(Translation::$localeSeparator, $locale);
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
|
2017-09-12 16:59:06 -04:00
|
|
|
//Verify if is the default language 'en'
|
|
|
|
|
if ($locale != "en") {
|
|
|
|
|
//Verify if is the current language
|
|
|
|
|
if ($locale != SYS_LANG) {
|
|
|
|
|
try {
|
|
|
|
|
Content::removeLanguageContent($locale);
|
|
|
|
|
$trn->removeTranslationEnvironment($locale);
|
|
|
|
|
echo G::LoadTranslation('ID_LANGUAGE_DELETED_SUCCESSFULLY');
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$token = strtotime("now");
|
|
|
|
|
PMException::registerErrorLog($e, $token);
|
|
|
|
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
|
2017-03-21 17:04:22 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2017-09-12 16:59:06 -04:00
|
|
|
echo G::LoadTranslation('ID_LANGUAGE_CANT_DELETE_CURRENTLY');
|
2017-03-21 17:04:22 -04:00
|
|
|
}
|
2012-10-17 16:23:22 -04:00
|
|
|
} else {
|
2017-09-12 16:59:06 -04:00
|
|
|
echo G::LoadTranslation('ID_LANGUAGE_CANT_DELETE_DEFAULT');
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oException) {
|
2016-07-27 16:37:21 -04:00
|
|
|
$token = strtotime("now");
|
|
|
|
|
PMException::registerErrorLog($oException, $token);
|
2017-09-12 16:59:06 -04:00
|
|
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
|
2012-10-17 16:23:22 -04:00
|
|
|
}
|
|
|
|
|
|