PageRenderTime 56ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/mattraykowski/ryzomcore_demoshard
PHP | 95 lines | 71 code | 7 blank | 17 comment | 13 complexity | 179b17515732e6aa905bf710b3d92e45 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 FileIdentifiersController extends AppController {
  19. var $name = 'FileIdentifiers';
  20. function index() {
  21. $this->FileIdentifier->recursive = 0;
  22. $this->set('fileIdentifiers', $this->paginate());
  23. }
  24. function view($id = null) {
  25. if (!$id) {
  26. $this->Session->setFlash(__('Invalid file identifier', true));
  27. $this->redirect(array('action' => 'index'));
  28. }
  29. $this->set('fileIdentifier', $this->FileIdentifier->read(null, $id));
  30. }
  31. function admin_view($id = null) {
  32. if (!$id) {
  33. $this->Session->setFlash(__('Invalid file identifier', true));
  34. $this->redirect(array('action' => 'index'));
  35. }
  36. $this->set('fileIdentifier', $this->FileIdentifier->read(null, $id));
  37. }
  38. function admin_add() {
  39. if (!empty($this->data)) {
  40. $this->FileIdentifier->create();
  41. if ($this->FileIdentifier->save($this->data)) {
  42. $this->Session->setFlash(__('The file identifier has been saved', true));
  43. $this->redirect(array('action' => 'index'));
  44. } else {
  45. $this->Session->setFlash(__('The file identifier could not be saved. Please, try again.', true));
  46. }
  47. }
  48. $importedTranslationFiles = $this->FileIdentifier->ImportedTranslationFile->find('list');
  49. $identifiers = $this->FileIdentifier->Identifier->find('list');
  50. $this->set(compact('importedTranslationFiles', 'identifiers'));
  51. }
  52. function admin_edit($id = null) {
  53. if (!$id && empty($this->data)) {
  54. $this->Session->setFlash(__('Invalid file identifier', true));
  55. $this->redirect(array('action' => 'index'));
  56. }
  57. if (!empty($this->data)) {
  58. if ($this->FileIdentifier->save($this->data)) {
  59. $this->Session->setFlash(__('The file identifier has been saved', true));
  60. $this->redirect(array('action' => 'index'));
  61. } else {
  62. $this->Session->setFlash(__('The file identifier could not be saved. Please, try again.', true));
  63. }
  64. }
  65. $this->set('fileIdentifier', $fileIdentifier_data = $this->FileIdentifier->read(null, $id));
  66. if (empty($this->data)) {
  67. $this->data = $fileIdentifier_data;
  68. }
  69. $importedTranslationFiles = $this->FileIdentifier->ImportedTranslationFile->find('list');
  70. $identifiers = $this->FileIdentifier->Identifier->find('list');
  71. $this->set(compact('importedTranslationFiles', 'identifiers'));
  72. }
  73. function admin_delete($id = null) {
  74. if (!$id) {
  75. $this->Session->setFlash(__('Invalid id for file identifier', true));
  76. $this->redirect(array('action'=>'index'));
  77. }
  78. if ($this->FileIdentifier->delete($id)) {
  79. $this->Session->setFlash(__('File identifier deleted', true));
  80. $this->redirect(array('action'=>'index'));
  81. }
  82. $this->Session->setFlash(__('File identifier was not deleted', true));
  83. $this->redirect(array('action' => 'index'));
  84. }
  85. }