PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/code/ryzom/tools/server/www/webtt/app/controllers/imported_translation_files_controller.php

https://bitbucket.org/mattraykowski/ryzomcore_demoshard
PHP | 97 lines | 73 code | 7 blank | 17 comment | 13 complexity | 258aaf6101a9601783dbc6b1870353d7 MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, LGPL-2.1
  1. <?php
  2. /*
  3. Ryzom Core Web-Based Translation Tool
  4. Copyright (C) 2011 Piotr Kaczmarek <p.kaczmarek@openlink.pl>
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. ?>
  17. <?php
  18. class ImportedTranslationFilesController extends AppController {
  19. var $name = 'ImportedTranslationFiles';
  20. function index() {
  21. $this->ImportedTranslationFile->recursive = 0;
  22. $this->set('importedTranslationFiles', $this->paginate());
  23. }
  24. function view($id = null) {
  25. if (!$id) {
  26. $this->Session->setFlash(__('Invalid translation file', true));
  27. $this->redirect(array('action' => 'index'));
  28. }
  29. $this->set('importedTranslationFile', $this->ImportedTranslationFile->read(null, $id));
  30. }
  31. function admin_index() {
  32. $this->ImportedTranslationFile->recursive = 0;
  33. $this->set('importedTranslationFiles', $this->paginate());
  34. }
  35. function admin_view($id = null) {
  36. if (!$id) {
  37. $this->Session->setFlash(__('Invalid translation file', true));
  38. $this->redirect(array('action' => 'index'));
  39. }
  40. $this->set('importedTranslationFile', $this->ImportedTranslationFile->read(null, $id));
  41. }
  42. function admin_add() {
  43. if (!empty($this->data)) {
  44. $this->ImportedTranslationFile->create();
  45. if ($this->ImportedTranslationFile->save($this->data)) {
  46. $this->Session->setFlash(__('The translation file has been saved', true));
  47. $this->redirect(array('action' => 'index'));
  48. } else {
  49. $this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
  50. }
  51. }
  52. $languages = $this->ImportedTranslationFile->Language->find('list');
  53. $this->set(compact('languages'));
  54. }
  55. function admin_edit($id = null) {
  56. if (!$id && empty($this->data)) {
  57. $this->Session->setFlash(__('Invalid translation file', true));
  58. $this->redirect(array('action' => 'index'));
  59. }
  60. if (!empty($this->data)) {
  61. if ($this->ImportedTranslationFile->save($this->data)) {
  62. $this->Session->setFlash(__('The translation file has been saved', true));
  63. $this->redirect(array('action' => 'index'));
  64. } else {
  65. $this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
  66. }
  67. }
  68. $this->set('importedTranslationFile', $importedTranslationFile_data = $this->ImportedTranslationFile->read(null, $id));
  69. if (empty($this->data)) {
  70. $this->data = $importedTranslationFile_data;
  71. }
  72. $languages = $this->ImportedTranslationFile->Language->find('list');
  73. $this->set(compact('languages'));
  74. }
  75. function admin_delete($id = null) {
  76. if (!$id) {
  77. $this->Session->setFlash(__('Invalid id for translation file', true));
  78. $this->redirect(array('action'=>'index'));
  79. }
  80. if ($this->ImportedTranslationFile->delete($id)) {
  81. $this->Session->setFlash(__('Translation file deleted', true));
  82. $this->redirect(array('action'=>'index'));
  83. }
  84. $this->Session->setFlash(__('Translation file was not deleted', true));
  85. $this->redirect(array('action' => 'index'));
  86. }
  87. }