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 IdentifiersController
extends AppController
{
22 var $name = 'Identifiers';
24 $this->Identifier
->recursive
= 0;
26 if (isset($this->passedArgs
['language']) && $lang = $this->passedArgs
['language'])
27 $conditions = array('Identifier.language_id' => $lang);
28 if (isset($this->passedArgs
['translation_file_id']) && $translation_file_id = $this->passedArgs
['translation_file_id'])
29 $conditions = array('Identifier.translation_file_id' => $translation_file_id);
30 $this->set('identifiers', $this->paginate($conditions));
33 function admin_withoutBestTranslation()
35 if (isset($this->passedArgs
['imported_translation_file_id']) && $imported_translation_file_id = $this->passedArgs
['imported_translation_file_id'])
37 $identifier_ids = $this->Identifier
->withoutBestTranslation(array('ImportedTranslationFile.id' => $this->passedArgs
['imported_translation_file_id']));
38 if ($identifier_ids === false)
40 $this->Session
->setFlash(__('Error: no conditions specified', true));
44 $conditions = array('Identifier.id' => $identifier_ids, 'BestTranslation.id' => NULL);
45 $this->set('identifiers', $this->paginate($conditions));
47 // $this->log($this->Identifier->withoutBestTranslation(array('ImportedTranslationFile.id' => $this->passedArgs['imported_translation_file_id'])));
48 // TOTHINK: try to achieve that with custom find with pagination
52 $this->Session
->setFlash(__('No imported file specified', true));
53 $this->redirect($this->referer());
55 $this->render('index');
58 function view($id = null) {
60 $this->Session
->setFlash(__('Invalid identifier', true));
61 $this->redirect(array('action' => 'index'));
63 $this->set('identifier', $identifier = $this->Identifier
->read(null, $id));
65 $this->set('identifierNeighbours', $this->Identifier
->getNeighbours($id));
68 function admin_index() {
69 $this->Identifier
->recursive
= 0;
70 $this->set('identifiers', $this->paginate());
73 function admin_view($id = null) {
75 $this->Session
->setFlash(__('Invalid identifier', true));
76 $this->redirect(array('action' => 'index'));
78 $this->set('identifier', $identifier = $this->Identifier
->read(null, $id));
80 $this->set('identifierNeighbours', $this->Identifier
->getNeighbours($id));
83 function admin_add() {
84 if (!empty($this->data
)) {
85 $this->Identifier
->create();
86 if ($this->Identifier
->save($this->data
)) {
87 $this->Session
->setFlash(__('The identifier has been saved', true));
88 $this->redirect(array('action' => 'index'));
90 $this->Session
->setFlash(__('The identifier could not be saved. Please, try again.', true));
93 $languages = $this->Identifier
->Language
->find('list');
94 $this->set(compact('languages'));
97 function admin_edit($id = null) {
98 if (!$id && empty($this->data
)) {
99 $this->Session
->setFlash(__('Invalid identifier', true));
100 $this->redirect(array('action' => 'index'));
102 if (!empty($this->data
)) {
103 if ($this->Identifier
->save($this->data
)) {
104 $this->Session
->setFlash(__('The identifier has been saved', true));
105 $this->redirect(array('action' => 'index'));
107 $this->Session
->setFlash(__('The identifier could not be saved. Please, try again.', true));
110 $this->set('identifier', $identifier_data = $this->Identifier
->read(null, $id));
111 if (empty($this->data
)) {
112 $this->data
= $identifier_data;
114 $languages = $this->Identifier
->Language
->find('list');
115 $this->set(compact('languages'));
118 function admin_delete($id = null) {
120 $this->Session
->setFlash(__('Invalid id for identifier', true));
121 $this->redirect(array('action'=>'index'));
123 if ($this->Identifier
->delete($id)) {
124 $this->Session
->setFlash(__('Identifier deleted', true));
125 $this->redirect(array('action'=>'index'));
127 $this->Session
->setFlash(__('Identifier was not deleted', true));
128 $this->redirect(array('action' => 'index'));