Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / web / public_php / webtt / app / models / translation.php
blobfd481f1e9e79e42829c7d68656b20d3d2d00dd0a
1 <?php
2 /*
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/>.
20 <?php
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',
32 'conditions' => '',
33 'fields' => '',
34 'order' => ''
36 'IdentifierColumn' => array(
37 'className' => 'IdentifierColumn',
38 'foreignKey' => 'identifier_column_id',
39 'conditions' => '',
40 'fields' => '',
41 'order' => ''
43 'User' => array(
44 'className' => 'User',
45 'foreignKey' => 'user_id',
46 'conditions' => '',
47 'fields' => '',
48 'order' => ''
50 'ParentTranslation' => array(
51 'className' => 'Translation',
52 'foreignKey' => 'parent_id',
53 'conditions' => '',
54 'fields' => '',
55 'order' => ''
59 var $hasMany = array(
60 'Vote' => array(
61 'className' => 'Vote',
62 'foreignKey' => 'translation_id',
63 'dependent' => false,
64 'conditions' => '',
65 'fields' => '',
66 'order' => '',
67 'limit' => '',
68 'offset' => '',
69 'exclusive' => '',
70 'finderQuery' => '',
71 'counterQuery' => ''
73 /* 'Comment' => array(
74 'className' => 'Comment',
75 'foreignKey' => 'translation_id',
76 'dependent' => false,
77 'conditions' => '',
78 'fields' => '',
79 'order' => '',
80 'limit' => '',
81 'offset' => '',
82 'exclusive' => '',
83 'finderQuery' => '',
84 'counterQuery' => ''
85 ),*/
86 'ChildTranslation' => array(
87 'className' => 'Translation',
88 'foreignKey' => 'parent_id',
89 'dependent' => false,
90 'conditions' => '',
91 'fields' => '',
92 'order' => '',
93 'limit' => '',
94 'offset' => '',
95 'exclusive' => '',
96 'finderQuery' => '',
97 'counterQuery' => ''
101 function setBest()
103 if (!$this->id)
104 return false;
105 $this->read();
106 if (!isset($this->data['Translation']['identifier_id']))
107 return false;
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(
115 'AND' => array(
116 'Translation.identifier_id' => $ret['Translation']['identifier_id'],
117 'Translation.id !=' => $best_id,
120 $this->log($ret);
122 return $this->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']);