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 Translation
extends AppModel
{
22 var $name = 'Translation';
23 var $displayField = 'translation_text';
25 var $scaffoldForbiddenActions = array();
26 var $scaffoldActions = array("add" => "fk", "index" => "fk");
28 var $belongsTo = array(
29 'Identifier' => array(
30 'className' => 'Identifier',
31 'foreignKey' => 'identifier_id',
36 'IdentifierColumn' => array(
37 'className' => 'IdentifierColumn',
38 'foreignKey' => 'identifier_column_id',
44 'className' => 'User',
45 'foreignKey' => 'user_id',
50 'ParentTranslation' => array(
51 'className' => 'Translation',
52 'foreignKey' => 'parent_id',
61 'className' => 'Vote',
62 'foreignKey' => 'translation_id',
73 /* 'Comment' => array(
74 'className' => 'Comment',
75 'foreignKey' => 'translation_id',
86 'ChildTranslation' => array(
87 'className' => 'Translation',
88 'foreignKey' => 'parent_id',
106 if (!isset($this->data
['Translation']['identifier_id']))
109 // set best on chosen translation
110 $ret = $this->save(array('best' => 1));
111 $best_id = $this->id
;
113 // reset best on other translations
114 $ret = $this->updateAll(array('Translation.best' => 0), array(
116 'Translation.identifier_id' => $ret['Translation']['identifier_id'],
117 'Translation.id !=' => $best_id,
125 function makeHash($ent)
127 if (isset($ent['columns']) && is_array($ent['columns']))
129 sort($ent['columns']);
130 return md5(serialize($ent['columns']));
132 else if (isset($ent['string']))
133 return md5($ent['string']);