From 2d9b20157957a55bd83875775085ed31c9062577 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 15 Mar 2014 14:58:52 -0300 Subject: Squashed 'mod/translation_editor/' content from commit 9d86955 git-subtree-dir: mod/translation_editor git-subtree-split: 9d86955e6d8b6807578f5a9da0346ac1a146881c --- actions/add_custom_key.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 actions/add_custom_key.php (limited to 'actions/add_custom_key.php') diff --git a/actions/add_custom_key.php b/actions/add_custom_key.php new file mode 100644 index 000000000..47269dfd2 --- /dev/null +++ b/actions/add_custom_key.php @@ -0,0 +1,64 @@ +translations["en"])){ + $exists = true; + } + + if(!$exists){ + // save + + $custom_translations = array(); + + if($custom_translations = translation_editor_get_plugin("en", "custom_keys")){ + $custom_translations = $custom_translations["en"]; + } + + $custom_translations[$key] = $translation; + + $base_dir = elgg_get_data_path() . "translation_editor" . DIRECTORY_SEPARATOR; + if(!file_exists($base_dir)){ + mkdir($base_dir); + } + + $location = $base_dir . "custom_keys" . DIRECTORY_SEPARATOR; + if(!file_exists($location)){ + mkdir($location); + } + + $file_contents = ""; + + if(file_put_contents($location . "en.php", $file_contents)){ + + system_message(elgg_echo("translation_editor:action:add_custom_key:success")); + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:file_error")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:exists")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:invalid_chars")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:key_numeric")); + } + } else { + register_error(elgg_echo("translation_editor:action:add_custom_key:missing_input")); + } + + forward(REFERER); \ No newline at end of file -- cgit v1.2.3