PageRenderTime 105ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

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

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