Exemplo n.º 1
0
 /**
  * Download database translations into a php file
  * @param $input
  * @return language.php file
  */
 function action_download_db_translations($input)
 {
     //check preference
     Services_Exception_Disabled::check('lang_use_db');
     //check permissions
     $perms = Perms::get('tiki');
     if (!$perms->tiki_p_edit_languages) {
         throw new Services_Exception_Denied(tr('Permission denied'));
     }
     //get input
     $language = $input->language->text();
     if ($language) {
         //set export language
         $export_language = new LanguageTranslations($language);
         //get translation data from database
         $data = $export_language->createCustomFile();
         //create file for download
         header("Content-type: application/unknown");
         header("Content-Disposition: inline; filename=language.php");
         header("Content-encoding: UTF-8");
         echo $data;
         die;
     } else {
         throw new Services_Exception_Denied(tr('No language provided'));
     }
 }
	$smarty->assign('total', $data['total']);
	$smarty->assign('hasDbTranslations', $translations->hasDbTranslations);
}

if (isset($_REQUEST["exp_language"])) {
	$exp_language = $_REQUEST["exp_language"];
	$export_language = new LanguageTranslations($exp_language);
	$smarty->assign('exp_language', $exp_language);
} else {
	$smarty->assign('exp_language', $prefs['language']);
}

// Export
if (isset($_REQUEST['downloadFile'])) {
	check_ticket('edit-languages');
	$data = $export_language->createCustomFile();
	header("Content-type: application/unknown");
	header("Content-Disposition: inline; filename=language.php");
	header("Content-encoding: UTF-8");
	echo $data;
	exit (0);
}

// Write to language.php
if (isset($_REQUEST['exportToLanguage']) && $tiki_p_admin == 'y') {
	try {
		$stats = $export_language->writeLanguageFile();
	} catch (Exception $e) {
		$smarty->assign('msg', $e->getMessage());
		$smarty->display('error.tpl');
		die;