2011-06-09 16:23:29 +00:00
|
|
|
<?php
|
2011-08-21 00:54:22 +00:00
|
|
|
/*
|
|
|
|
Ryzom Core Web-Based Translation Tool
|
|
|
|
Copyright (C) 2011 Piotr Kaczmarek <p.kaczmarek@openlink.pl>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
<?php
|
2011-06-09 16:23:29 +00:00
|
|
|
class Identifier extends AppModel {
|
|
|
|
var $name = 'Identifier';
|
|
|
|
var $displayField = 'identifier';
|
|
|
|
var $actsAs = array('Containable');
|
2011-07-14 14:49:25 +00:00
|
|
|
|
2011-06-09 16:23:29 +00:00
|
|
|
var $validate = array(
|
|
|
|
'identifier' => array(
|
|
|
|
'A_Za_z0_9' => array(
|
|
|
|
'rule' => '/[A-Za-z0-9_@]+/',
|
|
|
|
'message' => 'Identifier must consist only of the following caracteres: "A-Z", "a-z", "0-9", "@" and "_"',
|
|
|
|
//'allowEmpty' => false,
|
|
|
|
//'required' => false,
|
|
|
|
//'last' => false, // Stop validation after this rule
|
|
|
|
//'on' => 'create', // Limit validation to 'create' or 'update' operations
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2011-07-14 14:49:25 +00:00
|
|
|
|
|
|
|
var $scaffoldForbiddenActions = array("add", "admin_add", "edit", "admin_edit", "delete", "admin_delete");
|
|
|
|
|
2011-06-09 16:23:29 +00:00
|
|
|
var $belongsTo = array(
|
2011-07-14 14:49:25 +00:00
|
|
|
'TranslationFile' => array(
|
|
|
|
'className' => 'TranslationFile',
|
|
|
|
'foreignKey' => 'translation_file_id',
|
|
|
|
'conditions' => '',
|
|
|
|
'fields' => '',
|
|
|
|
'order' => ''
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
var $hasOne = array(
|
|
|
|
'BestTranslation' => array(
|
|
|
|
'className' => 'Translation',
|
|
|
|
'foreignKey' => 'identifier_id',
|
|
|
|
'dependent' => false,
|
|
|
|
'conditions' => array('BestTranslation.best' => true),
|
|
|
|
'fields' => '',
|
|
|
|
'order' => '',
|
|
|
|
),
|
2011-06-09 16:23:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
var $hasMany = array(
|
|
|
|
'Translation' => array(
|
|
|
|
'className' => 'Translation',
|
|
|
|
'foreignKey' => 'identifier_id',
|
2011-07-14 14:49:25 +00:00
|
|
|
'dependent' => true,
|
|
|
|
'conditions' => '',
|
|
|
|
'fields' => '',
|
|
|
|
'order' => '',
|
|
|
|
'limit' => '',
|
|
|
|
'offset' => '',
|
|
|
|
'exclusive' => '',
|
|
|
|
'finderQuery' => '',
|
|
|
|
'counterQuery' => ''
|
|
|
|
),
|
|
|
|
'Comment' => array(
|
|
|
|
'className' => 'Comment',
|
|
|
|
'foreignKey' => 'identifier_id',
|
2011-06-09 16:23:29 +00:00
|
|
|
'dependent' => false,
|
|
|
|
'conditions' => '',
|
|
|
|
'fields' => '',
|
|
|
|
'order' => '',
|
|
|
|
'limit' => '',
|
|
|
|
'offset' => '',
|
|
|
|
'exclusive' => '',
|
|
|
|
'finderQuery' => '',
|
|
|
|
'counterQuery' => ''
|
|
|
|
),
|
|
|
|
'FileIdentifier' => array(
|
|
|
|
'className' => 'FileIdentifier',
|
|
|
|
'foreignKey' => 'identifier_id',
|
|
|
|
'dependent' => false,
|
|
|
|
'conditions' => '',
|
|
|
|
'fields' => '',
|
|
|
|
'order' => '',
|
|
|
|
'limit' => '',
|
|
|
|
'offset' => '',
|
|
|
|
'exclusive' => '',
|
|
|
|
'finderQuery' => '',
|
|
|
|
'counterQuery' => ''
|
2011-07-14 14:49:25 +00:00
|
|
|
),
|
|
|
|
'IdentifierColumn' => array(
|
|
|
|
'className' => 'IdentifierColumn',
|
|
|
|
'foreignKey' => 'identifier_id',
|
|
|
|
'dependent' => true,
|
|
|
|
'conditions' => '',
|
|
|
|
'fields' => '',
|
|
|
|
'order' => '',
|
|
|
|
'limit' => '',
|
|
|
|
'offset' => '',
|
|
|
|
'exclusive' => '',
|
|
|
|
'finderQuery' => '',
|
|
|
|
'counterQuery' => ''
|
|
|
|
),
|
2011-06-09 16:23:29 +00:00
|
|
|
);
|
2011-07-14 14:49:25 +00:00
|
|
|
|
|
|
|
function withoutBestTranslation($conditions = array())
|
|
|
|
{
|
|
|
|
/* $this->contain(array(
|
|
|
|
'FileIdentifier' => array('ImportedTranslationFile' => array(
|
|
|
|
'conditions' => array('ImportedTranslationFile.id' => 248)
|
|
|
|
)),
|
|
|
|
));
|
2011-06-09 16:23:29 +00:00
|
|
|
|
2011-07-14 14:49:25 +00:00
|
|
|
$res = $this->find('all', array('conditions' => array('Identifier.id' => array(125219, 131609, 67133))));*/
|
|
|
|
// $fileIdentifier_ids = $this->FileIdentifier->find('list', array('fields' => array('FileIdentifier.id', 'FileIdentifier.id'), 'conditions' => array('FileIdentifier.imported_translation_file_id' => 248)));
|
|
|
|
// TOTHINK: try to achieve that with Linkable behaviour
|
|
|
|
if (isset($conditions['ImportedTranslationFile.id']))
|
|
|
|
return $identifier_ids = $this->FileIdentifier->find('list', array('fields' => array('Identifier.id', 'Identifier.id'), 'conditions' => array('FileIdentifier.imported_translation_file_id' => $conditions['ImportedTranslationFile.id']), 'recursive' => 1));
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-21 00:54:22 +00:00
|
|
|
|
|
|
|
function getNeighbours($id)
|
|
|
|
{
|
|
|
|
$identifierNeighbours['current'][] = $this->read(null, $id);
|
|
|
|
if ($identifierNeighbours['current'])
|
|
|
|
{
|
|
|
|
$identifierNeighbours['prev'] = $this->find('all', array('order' => 'Identifier.id DESC', 'limit' => 5, 'conditions' => array('Identifier.translation_file_id' => $identifierNeighbours['current'][0]['Identifier']['translation_file_id'], 'Identifier.id <' => $identifierNeighbours['current'][0]['Identifier']['id'])));
|
|
|
|
$identifierNeighbours['next'] = $this->find('all', array('order' => 'Identifier.id ASC', 'limit' => 5, 'conditions' => array('Identifier.translation_file_id' => $identifierNeighbours['current'][0]['Identifier']['translation_file_id'], 'Identifier.id >' => $identifierNeighbours['current'][0]['Identifier']['id'])));
|
|
|
|
}
|
|
|
|
return $identifierNeighbours;
|
|
|
|
}
|
2011-06-09 16:23:29 +00:00
|
|
|
}
|