PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/mattraykowski/ryzomcore_demoshard
PHP | 102 lines | 76 code | 9 blank | 17 comment | 15 complexity | 6339d58126d7581b0e688bed2eca55c7 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 TranslationFilesController extends AppController {
  19. var $name = 'TranslationFiles';
  20. function index() {
  21. $this->TranslationFile->recursive = 0;
  22. $conditions = null;
  23. if (isset($this->passedArgs['language_id']) && $language_id = $this->passedArgs['language_id'])
  24. $conditions = array('TranslationFile.language_id' => $language_id);
  25. $this->set('translationFiles', $this->paginate($conditions));
  26. }
  27. function view($id = null) {
  28. if (!$id) {
  29. $this->Session->setFlash(__('Invalid translation file', true));
  30. $this->redirect(array('action' => 'index'));
  31. }
  32. $this->set('translationFile', $this->TranslationFile->read(null, $id));
  33. }
  34. function admin_index() {
  35. $this->TranslationFile->recursive = 0;
  36. $this->set('translationFiles', $this->paginate());
  37. }
  38. function admin_view($id = null) {
  39. if (!$id) {
  40. $this->Session->setFlash(__('Invalid translation file', true));
  41. $this->redirect(array('action' => 'index'));
  42. }
  43. $this->set('translationFile', $this->TranslationFile->read(null, $id));
  44. }
  45. function admin_add() {
  46. if (!empty($this->data)) {
  47. $this->TranslationFile->create();
  48. if ($this->TranslationFile->save($this->data)) {
  49. $this->Session->setFlash(__('The translation file has been saved', true));
  50. $this->redirect(array('action' => 'index'));
  51. } else {
  52. $this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
  53. }
  54. }
  55. $languages = $this->TranslationFile->Language->find('list');
  56. $this->set(compact('languages'));
  57. }
  58. function admin_edit($id = null) {
  59. if (!$id && empty($this->data)) {
  60. $this->Session->setFlash(__('Invalid translation file', true));
  61. $this->redirect(array('action' => 'index'));
  62. }
  63. if (!empty($this->data)) {
  64. if ($this->TranslationFile->save($this->data)) {
  65. $this->Session->setFlash(__('The translation file has been saved', true));
  66. $this->redirect(array('action' => 'index'));
  67. } else {
  68. $this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
  69. }
  70. }
  71. $this->set('translationFile', $translationFile_data = $this->TranslationFile->read(null, $id));
  72. if (empty($this->data)) {
  73. $this->data = $translationFile_data;
  74. }
  75. $languages = $this->TranslationFile->Language->find('list');
  76. $this->set(compact('languages'));
  77. }
  78. function admin_delete($id = null) {
  79. if (!$id) {
  80. $this->Session->setFlash(__('Invalid id for translation file', true));
  81. $this->redirect(array('action'=>'index'));
  82. }
  83. if ($this->TranslationFile->delete($id)) {
  84. $this->Session->setFlash(__('Translation file deleted', true));
  85. $this->redirect(array('action'=>'index'));
  86. }
  87. $this->Session->setFlash(__('Translation file was not deleted', true));
  88. $this->redirect(array('action' => 'index'));
  89. }
  90. }