3 Ryzom Core Web-Based Translation Tool
4 Copyright (C) 2011 Piotr Kaczmarek <p.kaczmarek@openlink.pl>
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 class LanguagesController
extends AppController
{
23 var $name = 'Languages';
27 App
::import("Vendor","functions_render");
28 $this->Language
->recursive
= 0;
29 $this->set('languages', $this->paginate());
32 function view($id = null) {
34 $this->Session
->setFlash(__('Invalid language', true));
35 $this->redirect(array('action' => 'index'));
37 $this->set('language', $this->Language
->read(null, $id));
40 function admin_index() {
41 $this->Language
->recursive
= 0;
42 $this->set('languages', $this->paginate());
45 function admin_view($id = null) {
47 $this->Session
->setFlash(__('Invalid language', true));
48 $this->redirect(array('action' => 'index'));
50 $this->set('language', $this->Language
->read(null, $id));
53 function admin_add() {
54 if (!empty($this->data
)) {
55 $this->Language
->create();
56 if ($this->Language
->save($this->data
)) {
57 $this->Session
->setFlash(__('The language has been saved', true));
58 $this->redirect(array('action' => 'index'));
60 $this->Session
->setFlash(__('The language could not be saved. Please, try again.', true));
65 function admin_edit($id = null) {
66 if (!$id && empty($this->data
)) {
67 $this->Session
->setFlash(__('Invalid language', true));
68 $this->redirect(array('action' => 'index'));
70 if (!empty($this->data
)) {
71 if ($this->Language
->save($this->data
)) {
72 $this->Session
->setFlash(__('The language has been saved', true));
73 $this->redirect(array('action' => 'index'));
75 $this->Session
->setFlash(__('The language could not be saved. Please, try again.', true));
78 $this->set('language', $language_data = $this->Language
->read(null, $id));
79 if (empty($this->data
)) {
80 $this->data
= $language_data;
84 function admin_delete($id = null) {
86 $this->Session
->setFlash(__('Invalid id for language', true));
87 $this->redirect(array('action'=>'index'));
89 if ($this->Language
->delete($id)) {
90 $this->Session
->setFlash(__('Language deleted', true));
91 $this->redirect(array('action'=>'index'));
93 $this->Session
->setFlash(__('Language was not deleted', true));
94 $this->redirect(array('action' => 'index'));