Merge: From default to build_pipeline_v3
--HG-- branch : build_pipeline_v3hg/feature/build_pipeline_v3
commit
fa22fa3ae5
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
@ -0,0 +1,174 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#ifndef TXT_COMMAND_H
|
||||
#define TXT_COMMAND_H
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// includes
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/sstring.h"
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// MACRO TXT_COMMAND_SET
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
#define TXT_COMMAND_SET(setName,CONTEXT_CLASS)\
|
||||
class __CTxtCommandSet_##setName: public ITxtCommandSet<CONTEXT_CLASS>\
|
||||
{\
|
||||
public:\
|
||||
static __CTxtCommandSet_##setName* getInstance()\
|
||||
{\
|
||||
static __CTxtCommandSet_##setName *p=NULL;\
|
||||
if (p==NULL) p= new __CTxtCommandSet_##setName;\
|
||||
return p;\
|
||||
}\
|
||||
};\
|
||||
static CTxtCommandSetPtr<__CTxtCommandSet_##setName> setName;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// MACRO TXT_COMMAND
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
#define TXT_COMMAND(cmdName,setName,CONTEXT_CLASS)\
|
||||
struct __CTxtCommand_##cmdName: public ITxtCommand<CONTEXT_CLASS>\
|
||||
{\
|
||||
static __CTxtCommand_##cmdName* getInstance()\
|
||||
{\
|
||||
static __CTxtCommand_##cmdName *p=NULL;\
|
||||
if (p==NULL) p= new __CTxtCommand_##cmdName;\
|
||||
return p;\
|
||||
}\
|
||||
virtual const char* getName() const {return #cmdName;}\
|
||||
virtual CTxtCommandResult execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine);\
|
||||
private:\
|
||||
__CTxtCommand_##cmdName() {}\
|
||||
};\
|
||||
static ITxtCommandRegisterer<__CTxtCommand_##cmdName,__CTxtCommandSet_##setName> __CTxtCommand_##cmdName##_Registerer;\
|
||||
CTxtCommandResult __CTxtCommand_##cmdName::execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine)
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// class CTxtCommandResult
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
class CTxtCommandResult
|
||||
{
|
||||
public:
|
||||
enum TType
|
||||
{
|
||||
SUCCESS, // command execution was successful
|
||||
SYNTAX_ERROR, // there was a syntax error in the command line
|
||||
BAD_PERMISSION, // the user doesn't have the right to run the given command
|
||||
UNKNOWN_COMMAND, // behave as if the command was not recognised
|
||||
EXECUTION_ERROR // there was an error during execution of the command
|
||||
};
|
||||
CTxtCommandResult(const bool& success): _Type(success?SUCCESS:SYNTAX_ERROR) {}
|
||||
CTxtCommandResult(const TType& type): _Type(type) {}
|
||||
CTxtCommandResult(const TType& type,const NLMISC::CSString& reason): _Type(type), _Reason(reason) {}
|
||||
TType getType() const { return _Type; }
|
||||
const NLMISC::CSString& getReason() const { return _Reason; }
|
||||
private:
|
||||
TType _Type;
|
||||
NLMISC::CSString _Reason;
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// class ITxtCommand
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
template <class CONTEXT_CLASS> class ITxtCommand
|
||||
{
|
||||
public:
|
||||
virtual const char* getName() const =0;
|
||||
virtual CTxtCommandResult execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine) =0;
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// class ITxtCommandRegisterer
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
template <class CMD,class SET> struct ITxtCommandRegisterer
|
||||
{
|
||||
ITxtCommandRegisterer()
|
||||
{
|
||||
SET::getInstance()->registerTxtCommand(CMD::getInstance());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// class ITxtCommandSet
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
template <class CONTEXT_CLASS> class ITxtCommandSet
|
||||
{
|
||||
public:
|
||||
void registerTxtCommand(ITxtCommand<CONTEXT_CLASS>* txtCommand)
|
||||
{
|
||||
nlassert(_TxtCommands.find(txtCommand->getName())==_TxtCommands.end());
|
||||
_TxtCommands[txtCommand->getName()]= txtCommand;
|
||||
}
|
||||
CTxtCommandResult execute(CONTEXT_CLASS& context,const NLMISC::CSString& cmdLine)
|
||||
{
|
||||
NLMISC::CSString cmdTail=cmdLine;
|
||||
NLMISC::CSString keyword=cmdTail.firstWord(true);
|
||||
typename TTxtCommands::iterator it= _TxtCommands.find(keyword);
|
||||
if (it==_TxtCommands.end()) return CTxtCommandResult::UNKNOWN_COMMAND;
|
||||
NLMISC::CVectorSString args;
|
||||
cmdTail.splitWords(args);
|
||||
return it->second->execute(context,args,cmdTail,cmdLine);
|
||||
}
|
||||
private:
|
||||
typedef ITxtCommand<CONTEXT_CLASS> TTxtCommand;
|
||||
typedef std::map<NLMISC::CSString,TTxtCommand*> TTxtCommands;
|
||||
TTxtCommands _TxtCommands;
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// class ITxtCommandRegisterer
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
template <class SET> struct CTxtCommandSetPtr
|
||||
{
|
||||
CTxtCommandSetPtr()
|
||||
{
|
||||
SET::getInstance();
|
||||
}
|
||||
|
||||
SET& operator*()
|
||||
{
|
||||
return *SET::getInstance();
|
||||
}
|
||||
|
||||
SET* operator->()
|
||||
{
|
||||
return SET::getInstance();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
#endif
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
require_once 'lib/functions.php';
|
||||
|
||||
$user = app_authenticate();
|
||||
if(empty($user)){
|
||||
// redirect to login page
|
||||
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
header('Location: index.php?redirect='.urlencode($url));
|
||||
exit;
|
||||
}
|
||||
|
||||
// get more info about character - race, civlization, cult, guild, etc
|
||||
$character = webig_load_character($user['cid']);
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>App Hello World!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>APP Hello World!</h1>
|
||||
|
||||
<a href="index.php">index</a><?=(!isWEBIG ? '| <a href="?logout">logout</a>' : '')?>
|
||||
|
||||
<h2>Character</h2>
|
||||
<pre><?php print_r($character);?></pre>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
$__start = microtime(true);
|
||||
require_once 'lib/functions.php';
|
||||
|
||||
session_start();
|
||||
|
||||
// do user login
|
||||
$user = app_authenticate();
|
||||
|
||||
if(empty($user)){
|
||||
// user not verified
|
||||
//
|
||||
$error = is($_SESSION['login']['error'], '');
|
||||
if(!empty($error)){
|
||||
$error = '<p style="color: red;">login error</p>';
|
||||
}
|
||||
echo '
|
||||
<html>
|
||||
<head>
|
||||
<title>WebIG - Login</title>
|
||||
</head>
|
||||
<body
|
||||
<h1>Login</h1>
|
||||
<form method="post" action="">
|
||||
<input type="hidden" name="login[shardid]" value="302" />
|
||||
Char name <input type="text" name="login[name]" value="" /><br />
|
||||
Password <input type="password" name="login[passwd]" value="" /><br />
|
||||
<input type="submit" name="login[submit]" value="Login" />
|
||||
</form>
|
||||
</body>
|
||||
</html>';
|
||||
exit;
|
||||
}
|
||||
|
||||
// if this was login request from app, then redirect back there
|
||||
$redirect = is($_GET['redirect'], '');
|
||||
if(!empty($redirect)){
|
||||
header('Location: '.$redirect);
|
||||
exit;
|
||||
}
|
||||
|
||||
// check user privileges
|
||||
$is_admin = webig_is_admin($user['cid']>>4);
|
||||
|
||||
// get more info about character - race, civlization, cult, guild, etc
|
||||
$character = webig_load_character($user['cid']);
|
||||
|
||||
// user is verified
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>App Index</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello "<?=h($user['name'])?>"!</h1>
|
||||
|
||||
<a href="index.php">index</a> | <a href="app_hello.php">Hello APP</a><?=(!isWEBIG ? '| <a href="?logout">logout</a>' : '')?>
|
||||
|
||||
<?php
|
||||
if($is_admin){
|
||||
if(isWEBIG){
|
||||
display_teleport_list();
|
||||
}
|
||||
}
|
||||
|
||||
echo '<h2>User info</h2>';
|
||||
echo 'USER:'.dump_array($user);
|
||||
echo 'CHARACTER:'.dump_array($character);
|
||||
|
||||
$__end = microtime(true);
|
||||
echo "<pre>\n---\npage created ".sprintf("%.5fsec", $__end - $__start).'</pre>';
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
function dump_array($array){
|
||||
ob_start();
|
||||
|
||||
echo '
|
||||
<table cellspacing="2" cellpadding="0" bgcolor="#4f4f4f">
|
||||
<tr><td>
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
';
|
||||
$c=0;
|
||||
foreach($array as $k => $v){
|
||||
if(is_array($v)){
|
||||
$v = dump_array($v);
|
||||
}else{
|
||||
// make value safe for html
|
||||
$v = h($v);
|
||||
}
|
||||
echo '
|
||||
<tr valign="middle" bgcolor="'.($c%2 ? '#9f9f9f' : '#909090').'">
|
||||
<td height="20">'.h($k).'</td><td>'.$v.'</td>
|
||||
</tr>
|
||||
';
|
||||
$c++;
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
';
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function display_teleport_list(){
|
||||
$places = array(
|
||||
'Ranger Camp' => array(10314,-11734),
|
||||
'Shining Lake' => array(9056, -10822),
|
||||
);
|
||||
?>
|
||||
<h2>Teleport destinations</h2>
|
||||
<table cellspacing="2" cellpadding="0" bgcolor="#4f4f4f">
|
||||
<tr><td>
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<?php $c=0; foreach($places as $txt => $xyz){
|
||||
echo '
|
||||
<tr valign="middle" bgcolor="'.($c%2 ? '#3f3f3f' : '#303030').'">
|
||||
<td height="20">'.h($txt).'</td><td><a href="ah:command&a&Position&'.join(',', $xyz).'">'.join(',', $xyz).'</a></td>
|
||||
</tr>
|
||||
';
|
||||
$c++;
|
||||
} ?>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Variables for PdrUtil class
|
||||
// ----------------------------------------------------------------------------------------
|
||||
define('CMD_PDR_UTIL', 'C:/RyzomCore/ryzom_core_server/ryzom/tools/pdr_util');
|
||||
define('SHARD_SAVE', 'C:/RyzomCore/ryzom_core_server/ryzom/server/save_shard');
|
||||
define('SHEETID_DIR', 'C:/RyzomCore/ryzom_core_server/ryzom/common/data_leveldesign/leveldesign/Game_elem');
|
||||
define('TEMP_UNPACK', 'c:/temp');
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Variables for nel database access
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
// where we can find the mysql database
|
||||
$DBHost = 'localhost';
|
||||
$DBUserName = 'shard';
|
||||
$DBPassword = '';
|
||||
$DBName = 'nel';
|
||||
|
||||
//
|
||||
$RingDBUserName = 'shard';
|
||||
$RingDBName = 'ring_open';
|
||||
$RingDBPassword = '';
|
@ -0,0 +1,394 @@
|
||||
<?php
|
||||
|
||||
if(strstr($_SERVER['HTTP_USER_AGENT'], 'Ryzom')){
|
||||
define('isWEBIG', true);
|
||||
}else{
|
||||
define('isWEBIG', false);
|
||||
}
|
||||
|
||||
|
||||
require_once 'config.php';
|
||||
require_once 'pdr_util.php';
|
||||
require_once 'pdr_util_character.php';
|
||||
require_once 'pdr_util_guild.php';
|
||||
|
||||
/**
|
||||
* Singleton wrapper class for PDO database connection
|
||||
*/
|
||||
class DB {
|
||||
private $_pdo = null;
|
||||
|
||||
private function __construct(){
|
||||
$this->_pdo = new PDO('mysql:host='.$GLOBALS['DBHost'].';dbname='.$GLOBALS['DBName'].';charset=utf-8', $GLOBALS['DBUserName'], $GLOBALS['DBPassword'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'set names utf8'));
|
||||
$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
public function getInstance(){
|
||||
static $instance = null;
|
||||
if($instance === null){
|
||||
$instance = new DB();
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sql
|
||||
* @param array $params (optional)
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function query($sql, $params=array()){
|
||||
if(empty($params)){
|
||||
$stmt = $this->_pdo->query($sql);
|
||||
}else{
|
||||
$stmt = $this->_pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
return $stmt;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify and log-in user
|
||||
*
|
||||
* @return mixed user info array or boolean FALSE when user was not verified
|
||||
*/
|
||||
function app_authenticate(){
|
||||
// mask possible double session_start() warning
|
||||
@session_start();
|
||||
|
||||
if(isWEBIG){
|
||||
// ingame login
|
||||
|
||||
// gather user from $_GET or $_POST variables
|
||||
$user = webig_user();
|
||||
|
||||
// verify it against database
|
||||
$user = webig_auth($user);
|
||||
}else{
|
||||
// outgame login
|
||||
|
||||
if(isset($_POST['login'])){
|
||||
// login request
|
||||
$shardid = is($_POST['login']['shardid'], '');
|
||||
$name = is($_POST['login']['name'], '');
|
||||
$passwd = is($_POST['login']['passwd'], '');
|
||||
|
||||
// verify character and password against database and populate $_GET with user info
|
||||
$user = login_auth($shardid, $name, $passwd);
|
||||
$_SESSION['login']['error'] = ($user === false);
|
||||
}elseif(isset($_GET['logout'])){
|
||||
// logout request
|
||||
unset($_SESSION['user']);
|
||||
unset($_SESSION['authkey']);
|
||||
|
||||
// redirect to self without URL parameters
|
||||
header('Location: '.$_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
}else{
|
||||
// continue session
|
||||
$user = is($_SESSION['user'], false);
|
||||
|
||||
// verify user in session against database (e.g. user might be deleted)
|
||||
$user = load_user($user['shardid'], null, $user['cid']);
|
||||
}
|
||||
}
|
||||
|
||||
// auth failed?
|
||||
if(empty($user)){
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove values we do not need to keep in session
|
||||
unset($user['password']);
|
||||
unset($user['cookie']);
|
||||
|
||||
// return user info array on success
|
||||
$_SESSION['user'] = $user;
|
||||
return $user;
|
||||
}
|
||||
|
||||
// get user info that WebIG sends us
|
||||
function webig_user(){
|
||||
$user = array();
|
||||
|
||||
// shard id (302)
|
||||
$user['shardid'] = ryzom_get_param('shardid');
|
||||
|
||||
// character name (User)
|
||||
$user['name'] = ryzom_get_param('name');
|
||||
|
||||
// character id (16), user id is calculated as 'uid = cid >> 4';
|
||||
$user['cid'] = ryzom_get_param('cid');
|
||||
|
||||
// language
|
||||
$user['lang'] = ryzom_get_param('lang');
|
||||
|
||||
$user['authkey'] = ryzom_get_param('authkey');
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify character using info from ig browser
|
||||
*
|
||||
* @param array $user
|
||||
* @return bool return user info array on success and FALSE on error
|
||||
*/
|
||||
function webig_auth($user){
|
||||
// find user by shard and character id (name might be temporarily changed in game)
|
||||
$result = load_user($user['shardid'], null, $user['cid']);
|
||||
if(empty($result)){
|
||||
// should not happen, but user was not found
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create auth key by using cookie from DB and user info from user
|
||||
$authkey = webig_create_authkey($user, $result['cookie']);
|
||||
if($user['authkey'] !== $authkey){
|
||||
// something is out of sync - either user info or cookie
|
||||
return false;
|
||||
}
|
||||
|
||||
// return result from DB
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify character
|
||||
*
|
||||
* @param int $shardid character shard id
|
||||
* @param string $name character name
|
||||
* @param string $passwd plain text password
|
||||
* @return mixed return user info array on success or boolean false on error
|
||||
*/
|
||||
function login_auth($shardid, $name, $passwd){
|
||||
// get character from db
|
||||
$user = load_user($shardid, $name);
|
||||
if(empty($user)){
|
||||
// user was not found
|
||||
return false;
|
||||
}
|
||||
|
||||
$passwd = crypt($passwd, substr($user['password'], 0, 2));
|
||||
if($passwd !== $user['password']){
|
||||
// password failed
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch user info from db
|
||||
*
|
||||
* If name is NULL, then $cid is used
|
||||
*
|
||||
* @param int $shardid
|
||||
* @param string $name
|
||||
* @param int $cid
|
||||
* @return array
|
||||
*/
|
||||
function load_user($shardid, $name, $cid = null){
|
||||
// `nel`.`user` has password
|
||||
// `ring_open`.`ring_users` has cookie
|
||||
// `ring_open`.`characters` has char_id, char_name, home_mainland_session_id(==shardid)
|
||||
|
||||
$sql = 'SELECT c.`char_id` cid, c.`char_name` name, c.`home_mainland_session_id` shardid, n.`password`, u.`cookie`
|
||||
FROM `ring_open`.`characters` c
|
||||
JOIN `ring_open`.`ring_users` u on u.`user_id` = c.`user_id`
|
||||
JOIN `nel`.`user` n on n.`uid` = c.`user_id`
|
||||
WHERE c.`home_mainland_session_id` = :shardid';
|
||||
$params = array('shardid' => $shardid);
|
||||
if($name !== null){
|
||||
$sql .= ' AND c.`char_name` = :name';
|
||||
$params['name'] = $name;
|
||||
}elseif($cid !== null){
|
||||
$sql .= ' AND c.`char_id` = :cid';
|
||||
$params['cid'] = $cid;
|
||||
}else{
|
||||
// $name or $cid both empty
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = DB::getInstance()->query($sql, $params)->fetch(PDO::FETCH_ASSOC);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify user info that ig browser sent us using cookie from database
|
||||
*
|
||||
* @param array $user user info array
|
||||
* @param string $cookie User login cookie from database
|
||||
* @return string md5 hash
|
||||
*/
|
||||
function webig_create_authkey($user, $cookie){
|
||||
return md5($user['shardid'].$user['name'].$user['cid'].'\''.$cookie.'\'');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user privileges from DB
|
||||
*
|
||||
* @param int $uid user id (uid = cid >> 4)
|
||||
* @return mixed array of user privileges or boolean FALSE when user was not found
|
||||
*/
|
||||
function webig_get_privileges($uid){
|
||||
$sql = 'select `privilege` from `nel`.`user` where `uid` = :id';
|
||||
$params = array('id' => $uid);
|
||||
|
||||
$result = DB::getInstance()->query($sql, $params)->fetchColumn(0);
|
||||
|
||||
if($result !== false){
|
||||
$result = explode(':', $result);
|
||||
$ret = array();
|
||||
foreach($result as $k=>$v){
|
||||
if($v != ''){
|
||||
$ret[]=$v;
|
||||
}
|
||||
}
|
||||
$result = $ret;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user privileges
|
||||
*
|
||||
* @param int $uid user id
|
||||
* @param array $priv array of privileges, like array('DEV', 'GM')
|
||||
* @return bool
|
||||
*/
|
||||
function webig_has_privileges($uid, $priv){
|
||||
$userpriv = webig_get_privileges($uid);
|
||||
$result = array_intersect($priv, $userpriv);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user privileges against (DEV, SGM, GM)
|
||||
*
|
||||
* @param int $uid user id
|
||||
* @return bool
|
||||
*/
|
||||
function webig_is_admin($uid){
|
||||
// entities_game_service/player_manager/player_manager.cpp defines order
|
||||
// DEV > SGM > EM > GM > EG > VG > SG > G > OBSERVER > PR
|
||||
return webig_has_privileges($uid, array('DEV', 'SGM', 'EM', 'GM'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load character from shard save binary file
|
||||
*
|
||||
* @param int $cid
|
||||
* @return mixed array with character info or boolean FALSE on error
|
||||
*/
|
||||
function webig_load_character($cid){
|
||||
$pdr = CharacterPdr::createDefault();
|
||||
$char = $pdr->load($cid);
|
||||
if(empty($char)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'id' => (int) $cid,
|
||||
'name' => (string) $char->EntityBase->_Name['value'],
|
||||
'title' => (string) $char->_Title['value'],
|
||||
'race' => (string) $char->EntityBase->_Race['value'],
|
||||
'gender' => (int) $char->EntityBase->_Gender['value'] == '0' ? 'male' : 'female',
|
||||
'cult' => (string) $char->DeclaredCult['value'],
|
||||
'civ' => (string) $char->DeclaredCiv['value'],
|
||||
'guild' => false,
|
||||
);
|
||||
|
||||
$guild_id = (int) $char->_GuildId['value'];
|
||||
if($guild_id>0){
|
||||
// if char is in guild, then also get guild info
|
||||
$result['guild'] = webig_load_guild($guild_id);
|
||||
|
||||
// get guild rank (also from guild file)
|
||||
$result['guild_membership'] = webig_load_guild_membership($guild_id, $cid);
|
||||
}
|
||||
unset($char);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load basic guild info (name, description, motd, culv, civ)
|
||||
*
|
||||
* @param int $guild_id
|
||||
* @return mixed array with guild info or boolean FALSE on error
|
||||
*/
|
||||
function webig_load_guild($guild_id){
|
||||
$pdr = GuildPdr::createDefault();
|
||||
$guild = $pdr->load($guild_id);
|
||||
if(empty($guild)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'id' => (int) $guild_id,
|
||||
'icon' => (string) $guild->Icon['value'],
|
||||
'name' => (string) $guild->_Name['value'],
|
||||
'description' => (string) $guild->_Description['value'],
|
||||
'motd' => (string) $guild->_MessageOfTheDay['value'],
|
||||
'cult' => (string) $guild->DeclaredCult['value'],
|
||||
'civ' => (string) $guild->DeclaredCiv['value'],
|
||||
);
|
||||
unset($guild);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load guild member info
|
||||
*
|
||||
* @param int $guild_id
|
||||
* @param int $char_id
|
||||
* @return mixed array with guild member info or boolean FALSE if guild or character not found
|
||||
*/
|
||||
function webig_load_guild_membership($guild_id, $char_id){
|
||||
$pdr = GuildPdr::createDefault();
|
||||
$guild = $pdr->load($guild_id);
|
||||
if(empty($guild)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = false;
|
||||
|
||||
// test for 'id' and type (CHAR == 0), ignore creator (should be 0x00) and dynamic
|
||||
// 0x0000000013:00:00:87
|
||||
$eid = sprintf('0x%010x:00:', $char_id);
|
||||
$i = 0;
|
||||
while(isset($guild->Members->__Key__[$i])){
|
||||
$key = $guild->Members->__Key__[$i];
|
||||
$pos = strpos((string)$key['value'], $eid);
|
||||
if($pos === 1){
|
||||
$val = $guild->Members->__Val__[$i];
|
||||
$result = array(
|
||||
'grade' => (string) $val->Members->Grade['value'],
|
||||
'joined' => (int) $val->Members->EnterTime['value'],
|
||||
);
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
unset($guild);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// shortcut for 'isset() ? .. : ..'
|
||||
function is(&$var, $default = null){
|
||||
return isset($var) ? $var : $default;
|
||||
}
|
||||
|
||||
// escape string so it's safe for HTML
|
||||
function h($str){
|
||||
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
// return $_GET[var] or $_POST[var] or $default
|
||||
function ryzom_get_param($var, $default=''){
|
||||
return is($_GET[$var], is($_POST[$var], $default));
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
class PdrUtil {
|
||||
/**
|
||||
* Shard seems to be saving guild file every few seconds.
|
||||
* Increase cache valid timer a bit.
|
||||
*
|
||||
* @const int cache expire in seconds
|
||||
*/
|
||||
const CACHE_MIN_TIME = 15;
|
||||
|
||||
/**
|
||||
* Where does shard keep it's character, guild files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_shard_save;
|
||||
|
||||
/**
|
||||
* Directory where sheet_id.bin is
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_sheetid_dir;
|
||||
|
||||
/**
|
||||
* Directory for extracted character, guild xml files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_unpack_dir;
|
||||
|
||||
/**
|
||||
* Public Constructor for PdrUtil
|
||||
*
|
||||
* @param string $save_path
|
||||
* @param string $unpack temp unpack directory, default is /tmp/
|
||||
*/
|
||||
function __construct($shard_save, $sheetid_dir, $unpack = '/tmp/'){
|
||||
$this->_shard_save = $shard_save;
|
||||
$this->_sheetid_dir = $sheetid_dir;
|
||||
|
||||
$this->_unpack_dir = $unpack;
|
||||
}
|
||||
|
||||
function setShardSaveDirectory($dir){
|
||||
$this->_shard_save = $dir;
|
||||
}
|
||||
function getShardSaveDirectory(){
|
||||
return $this->_shard_save;
|
||||
}
|
||||
|
||||
function setSheetIdDirectory($dir){
|
||||
$this->_sheetid_dir = $dir;
|
||||
}
|
||||
function getSheetIdDirectory(){
|
||||
return $this->_sheetid_dir;
|
||||
}
|
||||
|
||||
function setUnpackDirectory($dir){
|
||||
$this->_unpack_dir = $dir;
|
||||
}
|
||||
function getUnpackDirectory(){
|
||||
return $this->_unpack_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract $pdr file to $xml file
|
||||
*
|
||||
* @param string $pdr
|
||||
* @param string $xml
|
||||
* @return bool
|
||||
*/
|
||||
function extract($pdr, $xml){
|
||||
if(!file_exists($pdr)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$pdr_mtime = filemtime($pdr);
|
||||
if(file_exists($xml)){
|
||||
$xml_mtime = filemtime($xml);
|
||||
}else{
|
||||
$xml_mtime = 0;
|
||||
}
|
||||
|
||||
$diff = $pdr_mtime - $xml_mtime;
|
||||
if($diff > self::CACHE_MIN_TIME){
|
||||
// remove expired xml file
|
||||
@unlink($xml);
|
||||
|
||||
// change working directory to unpack directory to keep pdr_util log file in one place
|
||||
$pwd = getcwd();
|
||||
chdir($this->_unpack_dir);
|
||||
|
||||
// run pdr_util
|
||||
$cmd = sprintf(' -s%s -x -o%s %s', $this->_sheetid_dir, $xml, $pdr);
|
||||
exec(CMD_PDR_UTIL.' '.$cmd);
|
||||
|
||||
// change working directory back what it was before
|
||||
chdir($pwd);
|
||||
}
|
||||
|
||||
// if pdr_util failed, then there is no xml file
|
||||
return file_exists($xml);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fname
|
||||
* @return string ShardSaveDirectory + fname
|
||||
*/
|
||||
function getSaveFileName($fname){
|
||||
return $this->getShardSaveDirectory().'/'.$fname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fname
|
||||
* return string TempDirectory + $fname
|
||||
*/
|
||||
function getXmlFileName($fname){
|
||||
return $this->getUnpackDirectory().'/'.$fname;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class CharacterPdr extends PdrUtil {
|
||||
|
||||
/**
|
||||
* Factory method to create new instance using default path values from config.php
|
||||
*/
|
||||
static public function createDefault(){
|
||||
return new self(SHARD_SAVE, SHEETID_DIR, TEMP_UNPACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load character from shard binary file
|
||||
*
|
||||
* @param int $char_id
|
||||
* @return SimpleXML object or boolean FALSE on error
|
||||
*/
|
||||
function load($char_id){
|
||||
$char_save = $this->getSaveFileName($char_id >> 4, $char_id & 0x0F);
|
||||
$xml_file = $this->getXmlFileName($char_id);
|
||||
|
||||
if($this->extract($char_save, $xml_file)){
|
||||
return simplexml_load_file($xml_file);
|
||||
}
|
||||
|
||||
// extract failed
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid user id
|
||||
* @param int $slot character slot, starting from 0
|
||||
* @return string character save path + filename
|
||||
*/
|
||||
function getSaveFileName($uid, $slot){
|
||||
return parent::getSaveFileName(sprintf('characters/%03d/account_%d_%d_pdr.bin', $uid, $uid, $slot));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $char_id
|
||||
* return string character xml file in unpack directory
|
||||
*/
|
||||
function getXmlFileName($char_id){
|
||||
return parent::getXmlFileName(sprintf('character_%d.xml', $char_id));
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class GuildPdr extends PdrUtil {
|
||||
|
||||
/**
|
||||
* Factory method to create new instance using default path values from config.php
|
||||
*/
|
||||
static public function createDefault(){
|
||||
return new self(SHARD_SAVE, SHEETID_DIR, TEMP_UNPACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load guild info from shard binary file
|
||||
*
|
||||
* @param int $guild_id
|
||||
* @return SimpleXML object or boolean FALSE on error
|
||||
*/
|
||||
function load($guild_id){
|
||||
$guild_save = $this->getSaveFileName($guild_id);
|
||||
$xml_file = $this->getXmlFileName($guild_id);
|
||||
|
||||
if($this->extract($guild_save, $xml_file)){
|
||||
return simplexml_load_file($xml_file);
|
||||
}
|
||||
|
||||
// extract failed
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $guild_id
|
||||
* @return string full path to guild binary file
|
||||
*/
|
||||
function getSaveFileName($guild_id){
|
||||
// chop off shard component from guild id
|
||||
return parent::getSaveFileName(sprintf('guilds/guild_%05d.bin', $guild_id & 0xFFFFF));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $guild_id
|
||||
* return string full path to extracted guild xml file
|
||||
*/
|
||||
function getXmlFileName($guild_id){
|
||||
return parent::getXmlFileName(sprintf('guild_%d.xml', $guild_id));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
/app/config
|
||||
/app/tmp
|
||||
/plugins
|
||||
/vendors
|
@ -0,0 +1,5 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ app/webroot/ [L]
|
||||
RewriteRule (.*) app/webroot/$1 [L]
|
||||
</IfModule>
|
@ -0,0 +1,28 @@
|
||||
CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.
|
||||
|
||||
The Cake Software Foundation - promoting development related to CakePHP
|
||||
http://cakefoundation.org/
|
||||
|
||||
CakePHP - the rapid development PHP framework
|
||||
http://www.cakephp.org
|
||||
|
||||
Cookbook - user documentation for learning about CakePHP
|
||||
http://book.cakephp.org
|
||||
|
||||
API - quick reference to CakePHP
|
||||
http://api.cakephp.org
|
||||
|
||||
The Bakery - everything CakePHP
|
||||
http://bakery.cakephp.org
|
||||
|
||||
The Show - live and archived podcasts about CakePHP and more
|
||||
http://live.cakephp.org
|
||||
|
||||
CakePHP TV - screen casts from events and video tutorials
|
||||
http://tv.cakephp.org
|
||||
|
||||
CakePHP Google Group - community mailing list and forum
|
||||
http://groups.google.com/group/cake-php
|
||||
|
||||
#cakephp on irc.freenode.net - chat with CakePHP developers
|
||||
irc://irc.freenode.net/cakephp
|
@ -0,0 +1,5 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
</IfModule>
|
@ -0,0 +1,70 @@
|
||||
;<?php die() ?>
|
||||
; SVN FILE: $Id$
|
||||
;/**
|
||||
; * ACL configuration
|
||||
; *
|
||||
; *
|
||||
; * PHP versions 4 and 5
|
||||
; *
|
||||
; * CakePHP(tm) : Rapid Development Framework http://cakephp.org
|
||||
; * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
; *
|
||||
; * Licensed under The MIT License
|
||||
; * Redistributions of files must retain the above copyright notice.
|
||||
; *
|
||||
; * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
; * @link http://cakephp.org CakePHP(tm) Project
|
||||
; * @package cake
|
||||
; * @subpackage cake.app.config
|
||||
; * @since CakePHP(tm) v 0.10.0.1076
|
||||
; * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
; */
|
||||
|
||||
; acl.ini.php - Cake ACL Configuration
|
||||
; ---------------------------------------------------------------------
|
||||
; Use this file to specify user permissions.
|
||||
; aco = access control object (something in your application)
|
||||
; aro = access request object (something requesting access)
|
||||
;
|
||||
; User records are added as follows:
|
||||
;
|
||||
; [uid]
|
||||
; groups = group1, group2, group3
|
||||
; allow = aco1, aco2, aco3
|
||||
; deny = aco4, aco5, aco6
|
||||
;
|
||||
; Group records are added in a similar manner:
|
||||
;
|
||||
; [gid]
|
||||
; allow = aco1, aco2, aco3
|
||||
; deny = aco4, aco5, aco6
|
||||
;
|
||||
; The allow, deny, and groups sections are all optional.
|
||||
; NOTE: groups names *cannot* ever be the same as usernames!
|
||||
;
|
||||
; ACL permissions are checked in the following order:
|
||||
; 1. Check for user denies (and DENY if specified)
|
||||
; 2. Check for user allows (and ALLOW if specified)
|
||||
; 3. Gather user's groups
|
||||
; 4. Check group denies (and DENY if specified)
|
||||
; 5. Check group allows (and ALLOW if specified)
|
||||
; 6. If no aro, aco, or group information is found, DENY
|
||||
;
|
||||
; ---------------------------------------------------------------------
|
||||
|
||||
;-------------------------------------
|
||||
;Users
|
||||
;-------------------------------------
|
||||
|
||||
[username-goes-here]
|
||||
groups = group1, group2
|
||||
deny = aco1, aco2
|
||||
allow = aco3, aco4
|
||||
|
||||
;-------------------------------------
|
||||
;Groups
|
||||
;-------------------------------------
|
||||
|
||||
[groupname-goes-here]
|
||||
deny = aco5, aco6
|
||||
allow = aco7, aco8
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php
|
||||
*
|
||||
* This is an application wide file to load any function that is not used within a class
|
||||
* define. You can also use this to include or require any files in your application.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP(tm) v 0.10.8.2117
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* The settings below can be used to set additional paths to models, views and controllers.
|
||||
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
|
||||
*
|
||||
* App::build(array(
|
||||
* 'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
|
||||
* 'models' => array('/full/path/to/models/', '/next/full/path/to/models/'),
|
||||
* 'views' => array('/full/path/to/views/', '/next/full/path/to/views/'),
|
||||
* 'controllers' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'),
|
||||
* 'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'),
|
||||
* 'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'),
|
||||
* 'components' => array('/full/path/to/components/', '/next/full/path/to/components/'),
|
||||
* 'helpers' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'),
|
||||
* 'vendors' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'),
|
||||
* 'shells' => array('/full/path/to/shells/', '/next/full/path/to/shells/'),
|
||||
* 'locales' => array('/full/path/to/locale/', '/next/full/path/to/locale/')
|
||||
* ));
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* As of 1.3, additional rules for the inflector are added below
|
||||
*
|
||||
* Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
|
||||
* Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
|
||||
*
|
||||
*/
|
@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* This is core configuration file.
|
||||
*
|
||||
* Use it to configure core behavior of Cake.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* CakePHP Debug Level:
|
||||
*
|
||||
* Production Mode:
|
||||
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
|
||||
*
|
||||
* Development Mode:
|
||||
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
|
||||
* 2: As in 1, but also with full debug messages and SQL output.
|
||||
*
|
||||
* In production mode, flash messages redirect after a time interval.
|
||||
* In development mode, you need to click the flash message to continue.
|
||||
*/
|
||||
Configure::write('debug', 2);
|
||||
|
||||
/**
|
||||
* CakePHP Log Level:
|
||||
*
|
||||
* In case of Production Mode CakePHP gives you the possibility to continue logging errors.
|
||||
*
|
||||
* The following parameters can be used:
|
||||
* Boolean: Set true/false to activate/deactivate logging
|
||||
* Configure::write('log', true);
|
||||
*
|
||||
* Integer: Use built-in PHP constants to set the error level (see error_reporting)
|
||||
* Configure::write('log', E_ERROR | E_WARNING);
|
||||
* Configure::write('log', E_ALL ^ E_NOTICE);
|
||||
*/
|
||||
Configure::write('log', true);
|
||||
|
||||
/**
|
||||
* Application wide charset encoding
|
||||
*/
|
||||
Configure::write('App.encoding', 'UTF-8');
|
||||
|
||||
/**
|
||||
* To configure CakePHP *not* to use mod_rewrite and to
|
||||
* use CakePHP pretty URLs, remove these .htaccess
|
||||
* files:
|
||||
*
|
||||
* /.htaccess
|
||||
* /app/.htaccess
|
||||
* /app/webroot/.htaccess
|
||||
*
|
||||
* And uncomment the App.baseUrl below:
|
||||
*/
|
||||
//Configure::write('App.baseUrl', env('SCRIPT_NAME'));
|
||||
|
||||
/**
|
||||
* Uncomment the define below to use CakePHP prefix routes.
|
||||
*
|
||||
* The value of the define determines the names of the routes
|
||||
* and their associated controller actions:
|
||||
*
|
||||
* Set to an array of prefixes you want to use in your application. Use for
|
||||
* admin or other prefixed routes.
|
||||
*
|
||||
* Routing.prefixes = array('admin', 'manager');
|
||||
*
|
||||
* Enables:
|
||||
* `admin_index()` and `/admin/controller/index`
|
||||
* `manager_index()` and `/manager/controller/index`
|
||||
*
|
||||
* [Note Routing.admin is deprecated in 1.3. Use Routing.prefixes instead]
|
||||
*/
|
||||
Configure::write('Routing.prefixes', array('admin'));
|
||||
|
||||
/**
|
||||
* Turn off all caching application-wide.
|
||||
*
|
||||
*/
|
||||
//Configure::write('Cache.disable', true);
|
||||
|
||||
/**
|
||||
* Enable cache checking.
|
||||
*
|
||||
* If set to true, for view caching you must still use the controller
|
||||
* var $cacheAction inside your controllers to define caching settings.
|
||||
* You can either set it controller-wide by setting var $cacheAction = true,
|
||||
* or in each action using $this->cacheAction = true.
|
||||
*
|
||||
*/
|
||||
//Configure::write('Cache.check', true);
|
||||
|
||||
/**
|
||||
* Defines the default error type when using the log() function. Used for
|
||||
* differentiating error logging and debugging. Currently PHP supports LOG_DEBUG.
|
||||
*/
|
||||
define('LOG_ERROR', 2);
|
||||
|
||||
/**
|
||||
* The preferred session handling method. Valid values:
|
||||
*
|
||||
* 'php' Uses settings defined in your php.ini.
|
||||
* 'cake' Saves session files in CakePHP's /tmp directory.
|
||||
* 'database' Uses CakePHP's database sessions.
|
||||
*
|
||||
* To define a custom session handler, save it at /app/config/<name>.php.
|
||||
* Set the value of 'Session.save' to <name> to utilize it in CakePHP.
|
||||
*
|
||||
* To use database sessions, run the app/config/schema/sessions.php schema using
|
||||
* the cake shell command: cake schema create Sessions
|
||||
*
|
||||
*/
|
||||
Configure::write('Session.save', 'php');
|
||||
|
||||
/**
|
||||
* The model name to be used for the session model.
|
||||
*
|
||||
* 'Session.save' must be set to 'database' in order to utilize this constant.
|
||||
*
|
||||
* The model name set here should *not* be used elsewhere in your application.
|
||||
*/
|
||||
//Configure::write('Session.model', 'Session');
|
||||
|
||||
/**
|
||||
* The name of the table used to store CakePHP database sessions.
|
||||
*
|
||||
* 'Session.save' must be set to 'database' in order to utilize this constant.
|
||||
*
|
||||
* The table name set here should *not* include any table prefix defined elsewhere.
|
||||
*
|
||||
* Please note that if you set a value for Session.model (above), any value set for
|
||||
* Session.table will be ignored.
|
||||
*
|
||||
* [Note: Session.table is deprecated as of CakePHP 1.3]
|
||||
*/
|
||||
//Configure::write('Session.table', 'cake_sessions');
|
||||
|
||||
/**
|
||||
* The DATABASE_CONFIG::$var to use for database session handling.
|
||||
*
|
||||
* 'Session.save' must be set to 'database' in order to utilize this constant.
|
||||
*/
|
||||
//Configure::write('Session.database', 'default');
|
||||
|
||||
/**
|
||||
* The name of CakePHP's session cookie.
|
||||
*
|
||||
* Note the guidelines for Session names states: "The session name references
|
||||
* the session id in cookies and URLs. It should contain only alphanumeric
|
||||
* characters."
|
||||
* @link http://php.net/session_name
|
||||
*/
|
||||
Configure::write('Session.cookie', 'CAKEPHP');
|
||||
|
||||
/**
|
||||
* Session time out time (in seconds).
|
||||
* Actual value depends on 'Security.level' setting.
|
||||
*/
|
||||
Configure::write('Session.timeout', '120');
|
||||
|
||||
/**
|
||||
* If set to false, sessions are not automatically started.
|
||||
*/
|
||||
Configure::write('Session.start', true);
|
||||
|
||||
/**
|
||||
* When set to false, HTTP_USER_AGENT will not be checked
|
||||
* in the session. You might want to set the value to false, when dealing with
|
||||
* older versions of IE, Chrome Frame or certain web-browsing devices and AJAX
|
||||
*/
|
||||
Configure::write('Session.checkAgent', true);
|
||||
|
||||
/**
|
||||
* The level of CakePHP security. The session timeout time defined
|
||||
* in 'Session.timeout' is multiplied according to the settings here.
|
||||
* Valid values:
|
||||
*
|
||||
* 'high' Session timeout in 'Session.timeout' x 10
|
||||
* 'medium' Session timeout in 'Session.timeout' x 100
|
||||
* 'low' Session timeout in 'Session.timeout' x 300
|
||||
*
|
||||
* CakePHP session IDs are also regenerated between requests if
|
||||
* 'Security.level' is set to 'high'.
|
||||
*/
|
||||
Configure::write('Security.level', 'medium');
|
||||
|
||||
/**
|
||||
* A random string used in security hashing methods.
|
||||
*/
|
||||
Configure::write('Security.salt', '3928c5uM398u4R39m4u8c3m493U49');
|
||||
|
||||
/**
|
||||
* A random numeric string (digits only) used to encrypt/decrypt strings.
|
||||
*/
|
||||
Configure::write('Security.cipherSeed', '849713027853098175087095830289');
|
||||
|
||||
/**
|
||||
* Apply timestamps with the last modified time to static assets (js, css, images).
|
||||
* Will append a querystring parameter containing the time the file was modified. This is
|
||||
* useful for invalidating browser caches.
|
||||
*
|
||||
* Set to `true` to apply timestamps, when debug = 0, or set to 'force' to always enable
|
||||
* timestamping.
|
||||
*/
|
||||
//Configure::write('Asset.timestamp', true);
|
||||
/**
|
||||
* Compress CSS output by removing comments, whitespace, repeating tags, etc.
|
||||
* This requires a/var/cache directory to be writable by the web server for caching.
|
||||
* and /vendors/csspp/csspp.php
|
||||
*
|
||||
* To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css().
|
||||
*/
|
||||
//Configure::write('Asset.filter.css', 'css.php');
|
||||
|
||||
/**
|
||||
* Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the
|
||||
* output, and setting the config below to the name of the script.
|
||||
*
|
||||
* To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link().
|
||||
*/
|
||||
//Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php');
|
||||
|
||||
/**
|
||||
* The classname and database used in CakePHP's
|
||||
* access control lists.
|
||||
*/
|
||||
Configure::write('Acl.classname', 'DbAcl');
|
||||
Configure::write('Acl.database', 'default');
|
||||
|
||||
/**
|
||||
* If you are on PHP 5.3 uncomment this line and correct your server timezone
|
||||
* to fix the date & time related errors.
|
||||
*/
|
||||
//date_default_timezone_set('UTC');
|
||||
|
||||
/**
|
||||
*
|
||||
* Cache Engine Configuration
|
||||
* Default settings provided below
|
||||
*
|
||||
* File storage engine.
|
||||
*
|
||||
* Cache::config('default', array(
|
||||
* 'engine' => 'File', //[required]
|
||||
* 'duration'=> 3600, //[optional]
|
||||
* 'probability'=> 100, //[optional]
|
||||
* 'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
|
||||
* 'prefix' => 'cake_', //[optional] prefix every cache file with this string
|
||||
* 'lock' => false, //[optional] use file locking
|
||||
* 'serialize' => true, [optional]
|
||||
* ));
|
||||
*
|
||||
*
|
||||
* APC (http://pecl.php.net/package/APC)
|
||||
*
|
||||
* Cache::config('default', array(
|
||||
* 'engine' => 'Apc', //[required]
|
||||
* 'duration'=> 3600, //[optional]
|
||||
* 'probability'=> 100, //[optional]
|
||||
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
|
||||
* ));
|
||||
*
|
||||
* Xcache (http://xcache.lighttpd.net/)
|
||||
*
|
||||
* Cache::config('default', array(
|
||||
* 'engine' => 'Xcache', //[required]
|
||||
* 'duration'=> 3600, //[optional]
|
||||
* 'probability'=> 100, //[optional]
|
||||
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
|
||||
* 'user' => 'user', //user from xcache.admin.user settings
|
||||
* 'password' => 'password', //plaintext password (xcache.admin.pass)
|
||||
* ));
|
||||
*
|
||||
*
|
||||
* Memcache (http://www.danga.com/memcached/)
|
||||
*
|
||||
* Cache::config('default', array(
|
||||
* 'engine' => 'Memcache', //[required]
|
||||
* 'duration'=> 3600, //[optional]
|
||||
* 'probability'=> 100, //[optional]
|
||||
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
|
||||
* 'servers' => array(
|
||||
* '127.0.0.1:11211' // localhost, default port 11211
|
||||
* ), //[optional]
|
||||
* 'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
|
||||
* 'persistent' => true, // [optional] set this to false for non-persistent connections
|
||||
* ));
|
||||
*
|
||||
*/
|
||||
Cache::config('default', array('engine' => 'File'));
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
class DATABASE_CONFIG {
|
||||
|
||||
var $default = array(
|
||||
'driver' => 'mysqli',
|
||||
'persistent' => false,
|
||||
'host' => 'localhost',
|
||||
'login' => 'webtt',
|
||||
'password' => 'webtt77',
|
||||
'database' => 'webtt2',
|
||||
'encoding' => 'utf8'
|
||||
);
|
||||
var $raw_files = array(
|
||||
'datasource' => 'RawFilesSource',
|
||||
'path' => '/path/to/translation',
|
||||
'extension' => '(uxt|txt)',
|
||||
'readonly' => true,
|
||||
'recursive' => true,
|
||||
);
|
||||
}
|
||||
?>
|
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* This is core configuration file.
|
||||
*
|
||||
* Use it to configure core behaviour ofCake.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
/**
|
||||
* In this file you set up your database connection details.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.config
|
||||
*/
|
||||
/**
|
||||
* Database configuration class.
|
||||
* You can specify multiple configurations for production, development and testing.
|
||||
*
|
||||
* driver => The name of a supported driver; valid options are as follows:
|
||||
* mysql - MySQL 4 & 5,
|
||||
* mysqli - MySQL 4 & 5 Improved Interface (PHP5 only),
|
||||
* sqlite - SQLite (PHP5 only),
|
||||
* postgres - PostgreSQL 7 and higher,
|
||||
* mssql - Microsoft SQL Server 2000 and higher,
|
||||
* db2 - IBM DB2, Cloudscape, and Apache Derby (http://php.net/ibm-db2)
|
||||
* oracle - Oracle 8 and higher
|
||||
* firebird - Firebird/Interbase
|
||||
* sybase - Sybase ASE
|
||||
* adodb-[drivername] - ADOdb interface wrapper (see below),
|
||||
* odbc - ODBC DBO driver
|
||||
*
|
||||
* You can add custom database drivers (or override existing drivers) by adding the
|
||||
* appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php',
|
||||
* where 'x' is the name of the database.
|
||||
*
|
||||
* persistent => true / false
|
||||
* Determines whether or not the database should use a persistent connection
|
||||
*
|
||||
* connect =>
|
||||
* ADOdb set the connect to one of these
|
||||
* (http://phplens.com/adodb/supported.databases.html) and
|
||||
* append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent)
|
||||
* For all other databases, this setting is deprecated.
|
||||
*
|
||||
* host =>
|
||||
* the host you connect to the database. To add a socket or port number, use 'port' => #
|
||||
*
|
||||
* prefix =>
|
||||
* Uses the given prefix for all the tables in this database. This setting can be overridden
|
||||
* on a per-table basis with the Model::$tablePrefix property.
|
||||
*
|
||||
* schema =>
|
||||
* For Postgres and DB2, specifies which schema you would like to use the tables in. Postgres defaults to
|
||||
* 'public', DB2 defaults to empty.
|
||||
*
|
||||
* encoding =>
|
||||
* For MySQL, MySQLi, Postgres and DB2, specifies the character encoding to use when connecting to the
|
||||
* database. Uses database default.
|
||||
*
|
||||
*/
|
||||
class DATABASE_CONFIG {
|
||||
|
||||
var $default = array(
|
||||
'driver' => 'mysql',
|
||||
'persistent' => false,
|
||||
'host' => 'localhost',
|
||||
'login' => 'user',
|
||||
'password' => 'password',
|
||||
'database' => 'database_name',
|
||||
'prefix' => '',
|
||||
);
|
||||
|
||||
var $test = array(
|
||||
'driver' => 'mysql',
|
||||
'persistent' => false,
|
||||
'host' => 'localhost',
|
||||
'login' => 'user',
|
||||
'password' => 'password',
|
||||
'database' => 'test_database_name',
|
||||
'prefix' => '',
|
||||
);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Routes configuration
|
||||
*
|
||||
* In this file, you set up routes to your controllers and their actions.
|
||||
* Routes are very important mechanism that allows you to freely connect
|
||||
* different urls to chosen controllers and their actions (functions).
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
/**
|
||||
* Here, we are connecting '/' (base path) to controller called 'Pages',
|
||||
* its action called 'display', and we pass a param to select the view file
|
||||
* to use (in this case, /app/views/pages/home.ctp)...
|
||||
*/
|
||||
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||
/**
|
||||
* ...and connect the rest of 'Pages' controller's urls.
|
||||
*/
|
||||
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
|
||||
/**
|
||||
* Connect 'Pages' controller's urls for admin prefix.
|
||||
*/
|
||||
Router::connect('/admin/pages/*', array('controller' => 'pages', 'action' => 'display', 'admin' => true));
|
||||
Router::connect('/admin/pages', array('controller' => 'pages', 'action' => 'display', 'admin' => true, 'home'));
|
||||
Router::connect('/admin', array('controller' => 'pages', 'action' => 'display', 'admin' => true, 'home'));
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/*DbAcl schema generated on: 2007-11-24 15:11:13 : 1195945453*/
|
||||
/**
|
||||
* This is Acl Schema file
|
||||
*
|
||||
* Use it to configure database for ACL
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config.sql
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Using the Schema command line utility
|
||||
* cake schema run create DbAcl
|
||||
*
|
||||
*/
|
||||
class DbAclSchema extends CakeSchema {
|
||||
|
||||
var $name = 'DbAcl';
|
||||
|
||||
function before($event = array()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function after($event = array()) {
|
||||
}
|
||||
|
||||
var $acos = array(
|
||||
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
|
||||
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'model' => array('type'=>'string', 'null' => true),
|
||||
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'alias' => array('type'=>'string', 'null' => true),
|
||||
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
|
||||
);
|
||||
|
||||
var $aros = array(
|
||||
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
|
||||
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'model' => array('type'=>'string', 'null' => true),
|
||||
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'alias' => array('type'=>'string', 'null' => true),
|
||||
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
|
||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
|
||||
);
|
||||
|
||||
var $aros_acos = array(
|
||||
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
|
||||
'aro_id' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
|
||||
'aco_id' => array('type'=>'integer', 'null' => false, 'length' => 10),
|
||||
'_create' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
|
||||
'_read' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
|
||||
'_update' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
|
||||
'_delete' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
|
||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1))
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*i18n schema generated on: 2007-11-25 07:11:25 : 1196004805*/
|
||||
/**
|
||||
* This is i18n Schema file
|
||||
*
|
||||
* Use it to configure database for i18n
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config.sql
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Using the Schema command line utility
|
||||
* cake schema run create i18n
|
||||
*
|
||||
*/
|
||||
class i18nSchema extends CakeSchema {
|
||||
|
||||
var $name = 'i18n';
|
||||
|
||||
function before($event = array()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function after($event = array()) {
|
||||
}
|
||||
|
||||
var $i18n = array(
|
||||
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
|
||||
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
|
||||
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||
'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
|
||||
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||
'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
|
||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*Sessions schema generated on: 2007-11-25 07:11:54 : 1196004714*/
|
||||
/**
|
||||
* This is Sessions Schema file
|
||||
*
|
||||
* Use it to configure database for Sessions
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config.sql
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Using the Schema command line utility
|
||||
* cake schema run create Sessions
|
||||
*
|
||||
*/
|
||||
class SessionsSchema extends CakeSchema {
|
||||
|
||||
var $name = 'Sessions';
|
||||
|
||||
function before($event = array()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function after($event = array()) {
|
||||
}
|
||||
|
||||
var $cake_sessions = array(
|
||||
'id' => array('type'=>'string', 'null' => false, 'key' => 'primary'),
|
||||
'data' => array('type'=>'text', 'null' => true, 'default' => NULL),
|
||||
'expires' => array('type'=>'integer', 'null' => true, 'default' => NULL),
|
||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Application level Controller
|
||||
*
|
||||
* This file is application-wide controller file. You can put all
|
||||
* application-wide controller-related methods here.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a placeholder class.
|
||||
* Create the same file in app/app_controller.php
|
||||
*
|
||||
* Add your application-wide methods in the class below, your controllers
|
||||
* will inherit them.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller
|
||||
* @link http://book.cakephp.org/view/957/The-App-Controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
var $components = array('DebugKit.Toolbar' => array(
|
||||
// 'panels' => array('variables'=>false)
|
||||
), 'Session', 'PathResolver', 'Auth');
|
||||
var $layout = "new";
|
||||
|
||||
function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$this->Auth->autoRedirect = false;
|
||||
$this->Auth->authorize = 'controller';
|
||||
$this->Auth->userScope = array('User.activated' => true, 'User.confirm_hash' => null);
|
||||
$this->Auth->loginAction = array('admin' => false, 'controller' => 'users', 'action' => 'login');
|
||||
|
||||
if ($this->Auth->user('role') == "admin")
|
||||
$this->Auth->allow("*");
|
||||
else if ($this->Auth->user())
|
||||
{
|
||||
// $this->Auth->allow('index', 'view', 'add', 'delete', 'edit');
|
||||
foreach ($this->methods as $method)
|
||||
if (mb_strpos($method, 'admin_') !== 0)
|
||||
$this->Auth->allow($method);
|
||||
}
|
||||
}
|
||||
|
||||
function isAuthorized() {
|
||||
/* if (isset($this->params['prefix']) && $this->params['prefix'] == "admin" && $this->Auth->user('role') != "admin")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;*/
|
||||
$action = $this->params['action'];
|
||||
$allowedActions = array_map('strtolower', $this->Auth->allowedActions);
|
||||
$isAllowed = (
|
||||
$this->Auth->allowedActions == array('*') ||
|
||||
in_array($action, $allowedActions)
|
||||
);
|
||||
// $this->log($isAllowed);
|
||||
return $isAllowed;
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class CommentsController extends AppController {
|
||||
|
||||
var $name = 'Comments';
|
||||
|
||||
function index() {
|
||||
$this->Comment->recursive = 0;
|
||||
$this->set('comments', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid comment', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('comment', $this->Comment->read(null, $id));
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Comment->create();
|
||||
if ($this->Comment->save($this->data)) {
|
||||
$this->Session->setFlash(__('The comment has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The comment could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->passedArgs['identifier_id']))
|
||||
{
|
||||
$this->Session->setFlash(__('You need to choose identifier to comment', true));
|
||||
$this->redirect(array('controller' => 'identifiers', 'action' => 'index'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$identifier_id = $this->passedArgs['identifier_id'];
|
||||
$this->set('identifier', $identifier = $this->Comment->Identifier->read(null, $identifier_id));
|
||||
// $this->data['Translation.identifier_id'] = $identifier_id;
|
||||
}
|
||||
// $translations = $this->Comment->Translation->find('list');
|
||||
$identifiers = $this->Comment->Identifier->find('list');
|
||||
$users = $this->Comment->User->find('list');
|
||||
$this->set(compact('translations', 'identifiers', 'users'));
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid comment', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Comment->save($this->data)) {
|
||||
$this->Session->setFlash(__('The comment has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The comment could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('comment', $comment_data = $this->Comment->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $comment_data;
|
||||
}
|
||||
$translations = $this->Comment->Translation->find('list');
|
||||
$identifiers = $this->Comment->Identifier->find('list');
|
||||
$users = $this->Comment->User->find('list');
|
||||
$this->set(compact('translations', 'identifiers', 'users'));
|
||||
}
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for comment', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Comment->delete($id)) {
|
||||
$this->Session->setFlash(__('Comment deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Comment was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
function admin_index() {
|
||||
$this->Comment->recursive = 0;
|
||||
$this->set('comments', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid comment', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('comment', $this->Comment->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Comment->create();
|
||||
if ($this->Comment->save($this->data)) {
|
||||
$this->Session->setFlash(__('The comment has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The comment could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$translations = $this->Comment->Translation->find('list');
|
||||
$identifiers = $this->Comment->Identifier->find('list');
|
||||
$users = $this->Comment->User->find('list');
|
||||
$this->set(compact('translations', 'identifiers', 'users'));
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid comment', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Comment->save($this->data)) {
|
||||
$this->Session->setFlash(__('The comment has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The comment could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('comment', $comment_data = $this->Comment->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $comment_data;
|
||||
}
|
||||
$translations = $this->Comment->Translation->find('list');
|
||||
$identifiers = $this->Comment->Identifier->find('list');
|
||||
$users = $this->Comment->User->find('list');
|
||||
$this->set(compact('translations', 'identifiers', 'users'));
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for comment', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Comment->delete($id)) {
|
||||
$this->Session->setFlash(__('Comment deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Comment was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class PathResolverComponent extends Object {
|
||||
function getAssociationsTree($model)
|
||||
{
|
||||
$names = array();
|
||||
foreach ($model->belongsTo as $childModel => $junk)
|
||||
{
|
||||
if ($model->alias != $model->{$childModel}->alias)
|
||||
$names[] = $this->getAssociationsTree($model->{$childModel});
|
||||
}
|
||||
return array($model->alias => $names);
|
||||
}
|
||||
|
||||
function t($i)
|
||||
{
|
||||
return str_repeat("\t",$i);
|
||||
}
|
||||
|
||||
function findModelPath($name, $assocTree, $path = null)
|
||||
{
|
||||
foreach ($assocTree as $model => $childs)
|
||||
{
|
||||
if (!isset($path))
|
||||
$path = array($model => "");
|
||||
foreach ($childs as $childModelArray)
|
||||
{
|
||||
foreach ($childModelArray as $childModel => $newAssocTree)
|
||||
{
|
||||
$newPath[$childModel] = $path;
|
||||
if ($name == $childModel)
|
||||
{
|
||||
return $newPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($ret = $this->findModelPath($name, array($childModel => $newAssocTree), $newPath))
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function beforeRender($controller)
|
||||
{
|
||||
if (!isset($controller->{$controller->modelClass}))
|
||||
return 0;
|
||||
$model = $controller->{$controller->modelClass};
|
||||
if (!isset($model->belongsTo))
|
||||
return 0;
|
||||
$assocTree = $this->getAssociationsTree($model);
|
||||
$rootModel = 'Language';
|
||||
$path = $this->findModelPath($rootModel, $assocTree);
|
||||
if (!$path && $model->alias == $rootModel)
|
||||
$path = array($rootModel => array());
|
||||
$controller->set('assocPath', $path);
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class FileIdentifiersController extends AppController {
|
||||
|
||||
var $name = 'FileIdentifiers';
|
||||
|
||||
function index() {
|
||||
$this->FileIdentifier->recursive = 0;
|
||||
$this->set('fileIdentifiers', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid file identifier', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('fileIdentifier', $this->FileIdentifier->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid file identifier', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('fileIdentifier', $this->FileIdentifier->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->FileIdentifier->create();
|
||||
if ($this->FileIdentifier->save($this->data)) {
|
||||
$this->Session->setFlash(__('The file identifier has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The file identifier could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$importedTranslationFiles = $this->FileIdentifier->ImportedTranslationFile->find('list');
|
||||
$identifiers = $this->FileIdentifier->Identifier->find('list');
|
||||
$this->set(compact('importedTranslationFiles', 'identifiers'));
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid file identifier', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->FileIdentifier->save($this->data)) {
|
||||
$this->Session->setFlash(__('The file identifier has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The file identifier could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('fileIdentifier', $fileIdentifier_data = $this->FileIdentifier->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $fileIdentifier_data;
|
||||
}
|
||||
$importedTranslationFiles = $this->FileIdentifier->ImportedTranslationFile->find('list');
|
||||
$identifiers = $this->FileIdentifier->Identifier->find('list');
|
||||
$this->set(compact('importedTranslationFiles', 'identifiers'));
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for file identifier', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->FileIdentifier->delete($id)) {
|
||||
$this->Session->setFlash(__('File identifier deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('File identifier was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class IdentifierColumnsController extends AppController {
|
||||
|
||||
var $name = 'IdentifierColumns';
|
||||
|
||||
function index() {
|
||||
$this->IdentifierColumn->recursive = 0;
|
||||
$this->set('identifierColumns', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid identifier column', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('identifierColumn', $this->IdentifierColumn->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_index() {
|
||||
$this->IdentifierColumn->recursive = 0;
|
||||
$this->set('identifierColumns', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid identifier column', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('identifierColumn', $this->IdentifierColumn->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->IdentifierColumn->create();
|
||||
if ($this->IdentifierColumn->save($this->data)) {
|
||||
$this->Session->setFlash(__('The identifier column has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The identifier column could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$identifiers = $this->IdentifierColumn->Identifier->find('list');
|
||||
$this->set(compact('identifiers'));
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid identifier column', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->IdentifierColumn->save($this->data)) {
|
||||
$this->Session->setFlash(__('The identifier column has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The identifier column could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('identifierColumn', $identifierColumn_data = $this->IdentifierColumn->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $identifierColumn_data;
|
||||
}
|
||||
$identifiers = $this->IdentifierColumn->Identifier->find('list');
|
||||
$this->set(compact('identifiers'));
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for identifier column', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->IdentifierColumn->delete($id)) {
|
||||
$this->Session->setFlash(__('Identifier column deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Identifier column was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class IdentifiersController extends AppController {
|
||||
var $name = 'Identifiers';
|
||||
function index() {
|
||||
$this->Identifier->recursive = 0;
|
||||
$conditions = null;
|
||||
if (isset($this->passedArgs['language']) && $lang = $this->passedArgs['language'])
|
||||
$conditions = array('Identifier.language_id' => $lang);
|
||||
if (isset($this->passedArgs['translation_file_id']) && $translation_file_id = $this->passedArgs['translation_file_id'])
|
||||
$conditions = array('Identifier.translation_file_id' => $translation_file_id);
|
||||
$this->set('identifiers', $this->paginate($conditions));
|
||||
}
|
||||
|
||||
function admin_withoutBestTranslation()
|
||||
{
|
||||
if (isset($this->passedArgs['imported_translation_file_id']) && $imported_translation_file_id = $this->passedArgs['imported_translation_file_id'])
|
||||
{
|
||||
$identifier_ids = $this->Identifier->withoutBestTranslation(array('ImportedTranslationFile.id' => $this->passedArgs['imported_translation_file_id']));
|
||||
if ($identifier_ids === false)
|
||||
{
|
||||
$this->Session->setFlash(__('Error: no conditions specified', true));
|
||||
}
|
||||
else
|
||||
{
|
||||
$conditions = array('Identifier.id' => $identifier_ids, 'BestTranslation.id' => NULL);
|
||||
$this->set('identifiers', $this->paginate($conditions));
|
||||
}
|
||||
// $this->log($this->Identifier->withoutBestTranslation(array('ImportedTranslationFile.id' => $this->passedArgs['imported_translation_file_id'])));
|
||||
// TOTHINK: try to achieve that with custom find with pagination
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Session->setFlash(__('No imported file specified', true));
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid identifier', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('identifier', $identifier = $this->Identifier->read(null, $id));
|
||||
if ($identifier)
|
||||
$this->set('identifierNeighbours', $this->Identifier->getNeighbours($id));
|
||||
}
|
||||
|
||||
function admin_index() {
|
||||
$this->Identifier->recursive = 0;
|
||||
$this->set('identifiers', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid identifier', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('identifier', $identifier = $this->Identifier->read(null, $id));
|
||||
if ($identifier)
|
||||
$this->set('identifierNeighbours', $this->Identifier->getNeighbours($id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Identifier->create();
|
||||
if ($this->Identifier->save($this->data)) {
|
||||
$this->Session->setFlash(__('The identifier has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The identifier could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$languages = $this->Identifier->Language->find('list');
|
||||
$this->set(compact('languages'));
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid identifier', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Identifier->save($this->data)) {
|
||||
$this->Session->setFlash(__('The identifier has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The identifier could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('identifier', $identifier_data = $this->Identifier->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $identifier_data;
|
||||
}
|
||||
$languages = $this->Identifier->Language->find('list');
|
||||
$this->set(compact('languages'));
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for identifier', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Identifier->delete($id)) {
|
||||
$this->Session->setFlash(__('Identifier deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Identifier was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class ImportedTranslationFilesController extends AppController {
|
||||
|
||||
var $name = 'ImportedTranslationFiles';
|
||||
function index() {
|
||||
$this->ImportedTranslationFile->recursive = 0;
|
||||
$this->set('importedTranslationFiles', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid translation file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('importedTranslationFile', $this->ImportedTranslationFile->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_index() {
|
||||
$this->ImportedTranslationFile->recursive = 0;
|
||||
$this->set('importedTranslationFiles', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid translation file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('importedTranslationFile', $this->ImportedTranslationFile->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->ImportedTranslationFile->create();
|
||||
if ($this->ImportedTranslationFile->save($this->data)) {
|
||||
$this->Session->setFlash(__('The translation file has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$languages = $this->ImportedTranslationFile->Language->find('list');
|
||||
$this->set(compact('languages'));
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid translation file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->ImportedTranslationFile->save($this->data)) {
|
||||
$this->Session->setFlash(__('The translation file has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('importedTranslationFile', $importedTranslationFile_data = $this->ImportedTranslationFile->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $importedTranslationFile_data;
|
||||
}
|
||||
$languages = $this->ImportedTranslationFile->Language->find('list');
|
||||
$this->set(compact('languages'));
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for translation file', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->ImportedTranslationFile->delete($id)) {
|
||||
$this->Session->setFlash(__('Translation file deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Translation file was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class LanguagesController extends AppController {
|
||||
|
||||
var $name = 'Languages';
|
||||
var $layout="new";
|
||||
|
||||
function index() {
|
||||
App::import("Vendor","functions_render");
|
||||
$this->Language->recursive = 0;
|
||||
$this->set('languages', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('language', $this->Language->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_index() {
|
||||
$this->Language->recursive = 0;
|
||||
$this->set('languages', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('language', $this->Language->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Language->create();
|
||||
if ($this->Language->save($this->data)) {
|
||||
$this->Session->setFlash(__('The language has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The language could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Language->save($this->data)) {
|
||||
$this->Session->setFlash(__('The language has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The language could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('language', $language_data = $this->Language->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $language_data;
|
||||
}
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for language', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Language->delete($id)) {
|
||||
$this->Session->setFlash(__('Language deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Language was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
class LanguagesController extends AppController {
|
||||
|
||||
var $name = 'Languages';
|
||||
|
||||
function index() {
|
||||
$this->Language->recursive = 0;
|
||||
$this->set('languages', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('language', $this->Language->read(null, $id));
|
||||
/* $options = array('Language.id' => $id, 'recursive' => 1,
|
||||
"joins" => array(
|
||||
array('table' => '
|
||||
),
|
||||
);
|
||||
var_dump($this);
|
||||
$this->set('language', $bumz = $this->Language->find('first', $options));
|
||||
var_dump($bumz);*/
|
||||
// $this->set('identifier', $this->Language->TranslationFile->read(null, $id));
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Language->create();
|
||||
if ($this->Language->save($this->data)) {
|
||||
$this->Session->setFlash(__('The language has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The language could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Language->save($this->data)) {
|
||||
$this->Session->setFlash(__('The language has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The language could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$this->data = $this->Language->read(null, $id);
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for language', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Language->delete($id)) {
|
||||
$this->Session->setFlash(__('Language deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Language was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
function admin_index() {
|
||||
$this->Language->recursive = 0;
|
||||
$this->set('languages', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('language', $this->Language->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Language->create();
|
||||
if ($this->Language->save($this->data)) {
|
||||
$this->Session->setFlash(__('The language has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The language could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Language->save($this->data)) {
|
||||
$this->Session->setFlash(__('The language has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The language could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$this->data = $this->Language->read(null, $id);
|
||||
}
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for language', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Language->delete($id)) {
|
||||
$this->Session->setFlash(__('Language deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Language was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Static content controller.
|
||||
*
|
||||
* This file will render views from views/pages/
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Static content controller
|
||||
*
|
||||
* Override this controller by placing a copy in controllers directory of an application
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller
|
||||
* @link http://book.cakephp.org/view/958/The-Pages-Controller
|
||||
*/
|
||||
class PagesController extends AppController {
|
||||
|
||||
/**
|
||||
* Controller name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $name = 'Pages';
|
||||
|
||||
/**
|
||||
* Default helper
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $helpers = array('Html', 'Session');
|
||||
|
||||
/**
|
||||
* This controller does not use a model
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $uses = array();
|
||||
|
||||
/**
|
||||
* Displays a view
|
||||
*
|
||||
* @param mixed What page to display
|
||||
* @access public
|
||||
*/
|
||||
function display() {
|
||||
$path = func_get_args();
|
||||
|
||||
|
||||
$count = count($path);
|
||||
if (!$count) {
|
||||
$this->redirect('/');
|
||||
}
|
||||
$page = $subpage = $title_for_layout = null;
|
||||
|
||||
if (!empty($path[0])) {
|
||||
$page = $path[0];
|
||||
}
|
||||
if (!empty($path[1])) {
|
||||
$subpage = $path[1];
|
||||
}
|
||||
if (!empty($path[$count - 1])) {
|
||||
$title_for_layout = Inflector::humanize($path[$count - 1]);
|
||||
}
|
||||
$this->set(compact('page', 'subpage', 'title_for_layout'));
|
||||
$this->render(implode('/', $path));
|
||||
}
|
||||
|
||||
function admin_display() {
|
||||
$path = func_get_args();
|
||||
|
||||
/* if (isset($this->params['admin']))
|
||||
array_shift($path);*/
|
||||
if (!isset($path[0]) || $path[0] != 'admin') {
|
||||
//This adds admin to the beginning of the path so the pages controller will look in the 'admin' folder in pages directory
|
||||
$path = array_merge((array)'admin', $path);
|
||||
}
|
||||
$count = count($path);
|
||||
if (!$count) {
|
||||
$this->redirect('/');
|
||||
}
|
||||
$page = $subpage = $title_for_layout = null;
|
||||
|
||||
if (!empty($path[0])) {
|
||||
$page = $path[0];
|
||||
}
|
||||
if (!empty($path[1])) {
|
||||
$subpage = $path[1];
|
||||
}
|
||||
if (!empty($path[$count - 1])) {
|
||||
$title_for_layout = Inflector::humanize($path[$count - 1]);
|
||||
}
|
||||
$this->set(compact('page', 'subpage', 'title_for_layout'));
|
||||
$this->render(implode('/', $path));
|
||||
}
|
||||
|
||||
function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$this->Auth->allow(array('display'));
|
||||
}
|
||||
}
|
@ -0,0 +1,476 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class RawFilesController extends AppController {
|
||||
|
||||
var $name = 'RawFiles';
|
||||
var $helpers = array('Paginator', 'Time', 'Session');
|
||||
var $components = array('Session');
|
||||
|
||||
function admin_index() {
|
||||
$this->RawFile->recursive = 1;
|
||||
$conditions['RawFile.dir'] = array("diff","translated");
|
||||
$this->set('rawFiles', $this->paginate($conditions));
|
||||
}
|
||||
|
||||
function admin_listdir($extension = null) {
|
||||
$this->RawFile->recursive = 0;
|
||||
$this->set('rawFiles', $this->paginate(array("RawFile.extension" => $extension)));
|
||||
$this->rendeR("admin_index");
|
||||
}
|
||||
|
||||
function admin_view($dir = null, $filename = null) {
|
||||
if (!$filename) {
|
||||
$this->Session->setFlash(__('Invalid raw file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!$this->RawFile->open($dir, $filename))
|
||||
{
|
||||
$this->Session->setFlash(__('Can\'t open file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
$this->set('rawFile', $rawFile = $this->RawFile->find('first', array(
|
||||
"conditions" => array(
|
||||
"RawFile.dir" => $dir,
|
||||
"RawFile.filename" => $filename,
|
||||
),
|
||||
)));
|
||||
|
||||
$this->set('fileContent', $this->RawFile->_currentFile->read());
|
||||
}
|
||||
|
||||
function admin_import($dir = null, $filename = null) {
|
||||
if (!$filename) {
|
||||
$this->Session->setFlash(__('Invalid file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
if (!$this->RawFile->open($dir, $filename))
|
||||
{
|
||||
$this->Session->setFlash(__('Can\'t open file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
$importedTranslationFileModel = $this->RawFile->ImportedTranslationFile;
|
||||
$translationFileModel = $importedTranslationFileModel->TranslationFile;
|
||||
$languageModel = $translationFileModel->Language;
|
||||
$identifierModel = $translationFileModel->Identifier;
|
||||
$identifierColumnModel = $identifierModel->IdentifierColumn;
|
||||
$translationModel = $identifierModel->Translation;
|
||||
$fileIdentifierModel = $importedTranslationFileModel->FileIdentifier;
|
||||
|
||||
$importedTranslationFile = $importedTranslationFileModel->find('first', array('conditions' => array('ImportedTranslationFile.filename' => $dir . DS . $filename), "recursive" => -1));
|
||||
if ($importedTranslationFile)
|
||||
{
|
||||
$this->Session->setFlash(__('Translation file already imported', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
$languageCode = $this->RawFile->getLanguageCode($filename);
|
||||
if (!$languageCode)
|
||||
{
|
||||
$this->Session->setFlash(__('Can\'t identify language', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
$language = $languageModel->find('first', array('conditions' => array('code' => $languageCode), "recursive" => -1));
|
||||
$language_id = $language['Language']['id'];
|
||||
if (!$language_id)
|
||||
{
|
||||
$this->Session->setFlash(__('Can\'t find language in database', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
$filename_template = preg_replace('/_diff/', '', $filename);
|
||||
$filename_template = preg_replace('/_[A-F0-9]{8}/', '', $filename_template);
|
||||
|
||||
// for global identifiers
|
||||
/* if (preg_match('|^.*_' . $language['Language']['code'] . '.*$|', $filename_template, $matches))
|
||||
$filename_template = preg_replace('/_' . $language['Language']['code'] . '/', '_LC', $filename_template);
|
||||
else if (preg_match('|^.*' . $language['Language']['code'] . '.*$|', $filename_template, $matches))
|
||||
$filename_template = preg_replace('/' . $language['Language']['code'] . '/', 'LC', $filename_template);
|
||||
else
|
||||
{
|
||||
$this->Session->setFlash(__('Can\'t create master translation filename template from current filename', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
$translationFile = $translationFileModel->find('first', array('conditions' => array('filename_template' => $filename_template), "recursive" => -1));
|
||||
if (!$translationFile)
|
||||
{
|
||||
$tf_data['filename_template'] = $filename_template;
|
||||
$tf_data['language_id'] = $language_id;
|
||||
}
|
||||
else
|
||||
$tf_data['id'] = $translationFile['TranslationFile']['id'];
|
||||
|
||||
$res = $translationFileModel->saveAll(array('TranslationFile' => $tf_data));
|
||||
$translation_file_id = $translationFileModel->id;
|
||||
|
||||
$parsedFile = $this->RawFile->parseFile();
|
||||
if (!$parsedFile)
|
||||
{
|
||||
$this->Session->setFlash(__('Error importing file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ini_set('max_execution_time',0);
|
||||
|
||||
$processedEntities = 0;
|
||||
|
||||
$importedTranslationFileModel->create();
|
||||
$data['ImportedTranslationFile']['language_id'] = $language_id;
|
||||
$data['ImportedTranslationFile']['translation_file_id'] = $translation_file_id;
|
||||
$data['ImportedTranslationFile']['filename'] = $dir . DS . $filename;
|
||||
$data['ImportedTranslationFile']['file_last_modified_date'] = $this->RawFile->_currentFileLastChange;
|
||||
|
||||
$importedTranslationFileModel->saveAll($data);
|
||||
$importedTranslationFile_id = $importedTranslationFileModel->id;
|
||||
|
||||
foreach ($parsedFile as $ent)
|
||||
{
|
||||
if (!isset($ent['type']))
|
||||
var_dump($ent);
|
||||
|
||||
if ($ent['type'] == 'sheet_description')
|
||||
{
|
||||
$_columns = $ent['columns'];
|
||||
$_sheet_id_column = $ent['sheet_id_column'];
|
||||
}
|
||||
|
||||
if ($ent['type'] != "string" && $ent['type'] != "phrase" && $ent['type'] != 'sheet')
|
||||
continue;
|
||||
|
||||
$newIdentifier = false;
|
||||
$i_data = array();
|
||||
$i_data['language_id'] = $language_id;
|
||||
$i_data['translation_file_id'] = $translation_file_id;
|
||||
if (isset($ent['index']))
|
||||
$i_data['translation_index'] = $ent['index'];
|
||||
if (isset($ent['arguments']))
|
||||
$i_data['arguments'] = $ent['arguments'];
|
||||
|
||||
if (isset($ent['columns']) && is_array($ent['columns']) && !isset($ent['string']))
|
||||
{
|
||||
foreach ($ent['columns'] as $column_no => $value)
|
||||
{
|
||||
$ent['string'] .= $value . "\t";
|
||||
}
|
||||
$ent['string'] = substr($ent['string'], 0, -1);
|
||||
}
|
||||
|
||||
if (isset($ent['diff']))
|
||||
{
|
||||
$i_data['reference_string'] = $ent['string'];
|
||||
}
|
||||
|
||||
unset($identifierModel->id);
|
||||
$identifier = $identifierModel->find('first',array('conditions' => array('Identifier.identifier' => $ent['identifier'], 'Identifier.translation_file_id' => $translation_file_id), 'contain' => 'IdentifierColumn'));
|
||||
if ($identifier)
|
||||
{
|
||||
$i_data['id']=$identifier['Identifier']['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$identifierModel->create();
|
||||
$i_data['identifier'] = $ent['identifier'];
|
||||
if (isset($ent['diff']))
|
||||
$i_data['translated'] = false;
|
||||
$newIdentifier = true;
|
||||
}
|
||||
$res = $identifierModel->saveAll($tarr = array('Identifier' => $i_data));
|
||||
$identifier_id = $identifierModel->id;
|
||||
|
||||
if (!isset($ent['diff'])) // it is translated file and we add translation
|
||||
{
|
||||
unset($translationModel->id);
|
||||
unset($t_data);
|
||||
$translationHash = $translationModel->makeHash($ent);
|
||||
|
||||
if ($newIdentifier) // ovbiously there's no translation for identifier we just created
|
||||
$translation = array();
|
||||
else
|
||||
{
|
||||
$this->log('new translation check');
|
||||
$this->log($translationHash);
|
||||
$translation = $translationModel->find('first',array('conditions' => array('Translation.identifier_id' => $identifier_id, 'Translation.translation_text' => $ent["string"], 'Translation.translation_hash' => NULL), "recursive" => -1));
|
||||
$this->log($translation);
|
||||
if (!$translation)
|
||||
{
|
||||
$translation = $translationModel->find('first',array('conditions' => array('Translation.identifier_id' => $identifier_id, 'Translation.translation_hash' => $translationHash), "recursive" => -1));
|
||||
$this->log($translation);
|
||||
}
|
||||
$this->log('new translation check end');
|
||||
}
|
||||
|
||||
if (!$translation)
|
||||
{
|
||||
$this->log('new translation');
|
||||
$t_data['identifier_id'] = $identifier_id;
|
||||
$t_data['translation_text'] = $ent['string'];
|
||||
$t_data['user_id'] = $this->Auth->user('id');
|
||||
$t_data['translation_hash'] = $translationHash;
|
||||
$translationModel->save(array('Translation' => $t_data));
|
||||
}
|
||||
/* else
|
||||
$t_data['id'] = $translation['Translation']['id'];*/
|
||||
if ($translation)
|
||||
$parentTranslation_id = $translation['Translation']['id'];
|
||||
else
|
||||
$parentTranslation_id = $translationModel->id;
|
||||
}
|
||||
|
||||
if (isset($ent['columns']) && is_array($ent['columns']))
|
||||
{
|
||||
$ic_data = array();
|
||||
foreach ($ent['columns'] as $column_no => $value)
|
||||
{
|
||||
unset($identifierColumnModel->id);
|
||||
$ic_arr = array();
|
||||
$ic_arr['identifier_id'] = $identifier_id;
|
||||
$column_name = $_columns[$column_no];
|
||||
if (!$newIdentifier)
|
||||
{
|
||||
foreach ($identifier['IdentifierColumn'] as $identifierColumn_no => $identifierColumn)
|
||||
{
|
||||
if ($identifierColumn['column_name'] == $column_name)
|
||||
{
|
||||
$ic_arr['id'] = $identifierColumn['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ic_arr['column_name'] = $column_name;
|
||||
if (isset($ent['diff']))
|
||||
$ic_arr['reference_string'] = $value;
|
||||
$ic_data[] = $ic_arr;
|
||||
$res = $identifierColumnModel->save($ic_arr);
|
||||
$identifierColumn_id = $identifierColumnModel->id;
|
||||
|
||||
if (!isset($ent['diff'])) // it is translated file and we add translation
|
||||
{
|
||||
unset($translationModel->id);
|
||||
unset($t_data);
|
||||
if ($newIdentifier) // ovbiously there's no translation for identifier we just created
|
||||
$translation = array();
|
||||
else
|
||||
$translation = $translationModel->find('first',array('conditions' => array('Translation.identifier_column_id' => $identifierColumn_id, 'Translation.translation_text' => $value, 'Translation.parent_id' => $parentTranslation_id), "recursive" => -1));
|
||||
|
||||
if (!$translation)
|
||||
{
|
||||
$t_data['identifier_column_id'] = $identifierColumn_id;
|
||||
$t_data['translation_text'] = $value;
|
||||
$t_data['user_id'] = $this->Auth->user('id');
|
||||
$t_data['parent_id'] = $parentTranslation_id;
|
||||
$translationModel->save(array('Translation' => $t_data));
|
||||
}
|
||||
/* else
|
||||
$t_data['id'] = $translation['Translation']['id'];*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($fileIdentifierModel->id);
|
||||
$fi_data = array();
|
||||
$fi_data['imported_translation_file_id'] = $importedTranslationFile_id;
|
||||
// TOTHINK - set FileIdentifier['id'] if we import already imported file (not supporting importing imported file)
|
||||
// $identifier = $this->ImportedTranslationFile->FileIdentifier->find('first',array('conditions' => array('FileIdentifier.identifier' => $ent['identifier'], 'FileIdentifier.translation_file_id' => $)));
|
||||
// $data['FileIdentifier']['translation_file_id'] = $this->ImportedTranslationFile->id;
|
||||
if (isset($ent['arguments']))
|
||||
$fi_data['arguments'] = $ent['arguments'];
|
||||
|
||||
if (isset($_sheet_id_column))
|
||||
$fi_data['arguments'] = $_sheet_id_column;
|
||||
|
||||
if (isset($ent['diff'])) // it is diff file
|
||||
{
|
||||
if (isset($ent['command']))
|
||||
$fi_data['command'] = $ent['command'];
|
||||
else
|
||||
$fi_data['command'] = "DIFF " . mb_strtoupper($ent['diff']);
|
||||
|
||||
if (isset($ent['string']))
|
||||
$fi_data['reference_string'] = $ent['string'];
|
||||
|
||||
if (isset($ent['index']))
|
||||
$fi_data['translation_index'] = $ent['index'];
|
||||
$fi_data['identifier_id'] = $identifier_id;
|
||||
|
||||
$res = $fileIdentifierModel->saveAll($tarr = array('FileIdentifier' => $fi_data));
|
||||
$fileIdentifier_id = $fileIdentifierModel->id;
|
||||
}
|
||||
|
||||
$processedEntities++;
|
||||
|
||||
}
|
||||
if ($processedEntities == 0)
|
||||
{
|
||||
$importedTranslationFileModel->delete($importedTranslationFile_id);
|
||||
$this->Session->setFlash(__('File was not imported because it seems empty', true));
|
||||
$this->redirect($this->referer());
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Session->setFlash(__('Translation file imported into database successfully. Processed entities: ' . $processedEntities, true));
|
||||
$this->redirect(array('controller' => 'imported_translation_files', 'action' => 'view', $importedTranslationFileModel->id));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function admin_export($dir = null, $filename = null, $importedTranslationFileId = null) {
|
||||
if (!$filename) {
|
||||
$this->Session->setFlash(__('Invalid file', true));
|
||||
$this->redirect($this->referer());
|
||||
return 0;
|
||||
}
|
||||
if (!$this->RawFile->open($dir, $filename, $writable = true))
|
||||
{
|
||||
$this->Session->setFlash(__('Can\'t open file for writing', true));
|
||||
$this->redirect($this->referer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
$importedTranslationFileModel = $this->RawFile->ImportedTranslationFile;
|
||||
|
||||
$importedTranslationFileModel->contain(array(
|
||||
'TranslationFile',
|
||||
'FileIdentifier' => array('Identifier' => array(
|
||||
'Translation',
|
||||
'IdentifierColumn' => 'Translation',
|
||||
)),
|
||||
));
|
||||
|
||||
$importedTranslationFile = $importedTranslationFileModel->find('first', array(
|
||||
'conditions' => array(
|
||||
'ImportedTranslationFile.filename' => $dir . DS . $filename
|
||||
),
|
||||
)
|
||||
);
|
||||
if (!$importedTranslationFile)
|
||||
{
|
||||
$this->Session->setFlash(__('No imported translation file found for chosen file', true));
|
||||
$this->redirect($this->referer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
$translationFileModel = $importedTranslationFileModel->TranslationFile;
|
||||
$identifierModel = $translationFileModel->Identifier;
|
||||
|
||||
// check if all identifiers have "best" translation
|
||||
$identifier_ids = $identifierModel->withoutBestTranslation(array('ImportedTranslationFile.id' => $importedTranslationFile['ImportedTranslationFile']['id']));
|
||||
if ($identifier_ids === false)
|
||||
{
|
||||
$this->Session->setFlash(__('Error: no conditions specified', true));
|
||||
$this->redirect($this->referer());
|
||||
return 0;
|
||||
}
|
||||
else if (count($identifier_ids) > 0)
|
||||
{
|
||||
$this->Session->setFlash(__('Best translation is not set for some of the identifiers in this file. Set best translation before export.', true));
|
||||
$this->redirect(array('controller' => 'identifiers', 'action' => 'withoutBestTranslation', 'imported_translation_file_id' => $importedTranslationFile['ImportedTranslationFile']['id']));
|
||||
return 0;
|
||||
}
|
||||
|
||||
$translationFile_id = $importedTranslationFile['ImportedTranslationFile']['translation_file_id'];
|
||||
|
||||
$i=0;
|
||||
$sortResult = Set::sort($importedTranslationFile['FileIdentifier'], '{n}.translation_index', 'asc');
|
||||
if (!$sortResult)
|
||||
{
|
||||
$this->Session->setFlash(__('Sorting error', true));
|
||||
$this->redirect($this->referer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($sortResult as $fileIdentifier)
|
||||
{
|
||||
if ($fileIdentifier['Identifier']['IdentifierColumn'] && !isset($entities[0]))
|
||||
{
|
||||
foreach ($fileIdentifier['Identifier']['IdentifierColumn'] as $column_no => $identifierColumn)
|
||||
$_columns[$column_no] = $identifierColumn['column_name'];
|
||||
$ent['columns'] = $_columns;
|
||||
$ent['type'] = 'sheet_description';
|
||||
$ent['sheet_id_column'] = $fileIdentifier['arguments'];
|
||||
$ent['diff'] = ((isset($fileIdentifier['command']) && !empty($fileIdentifier['command'])) ? true : null);
|
||||
$entities[] = $ent;
|
||||
$ent = array();
|
||||
}
|
||||
$ent = array(
|
||||
'diff' => ((isset($fileIdentifier['command']) && !empty($fileIdentifier['command'])) ? $fileIdentifier['command'] : null),
|
||||
'command' => ((isset($fileIdentifier['command']) && !empty($fileIdentifier['command'])) ? $fileIdentifier['command'] : null),
|
||||
'index' => ((isset($fileIdentifier['translation_index']) && !empty($fileIdentifier['translation_index'])) ? $fileIdentifier['translation_index'] : null),
|
||||
'internal_index' => $i++,
|
||||
'type' => ((count($fileIdentifier['Identifier']['IdentifierColumn']) > 0) ? 'sheet' : 'string'),
|
||||
'identifier' => $fileIdentifier['Identifier']['identifier'],
|
||||
'arguments' => ((isset($fileIdentifier['arguments']) && !empty($fileIdentifier['arguments'])) ? $fileIdentifier['arguments'] : null),
|
||||
);
|
||||
if (isset($fileIdentifier['Identifier']['Translation'][0]))
|
||||
{
|
||||
$ent['string'] = $fileIdentifier['Identifier']['Translation'][0]['translation_text'];
|
||||
}
|
||||
else if (isset($fileIdentifier['Identifier']['Translation']['translation_text']))
|
||||
$ent['string'] = $fileIdentifier['Identifier']['Translation']['translation_text'];
|
||||
|
||||
if (isset($fileIdentifier['Identifier']['BestTranslation']['translation_text']))
|
||||
$ent['string'] = $fileIdentifier['Identifier']['BestTranslation']['translation_text'];
|
||||
|
||||
if (($export_reference_if_empty_translation = true) && !isset($ent['string']))
|
||||
$ent['string'] = $fileIdentifier['Identifier']['reference_string'];
|
||||
else if (!isset($ent['string']))
|
||||
$ent['string'] = '';
|
||||
|
||||
foreach ($fileIdentifier['Identifier']['IdentifierColumn'] as $column_no => $identifierColumn)
|
||||
{
|
||||
if (isset($identifierColumn['Translation'][0]))
|
||||
$ent['columns'][$column_no] = $identifierColumn['Translation'][0]['translation_text'];
|
||||
else if (isset($identifierColumn['Translation']['translation_text']))
|
||||
$ent['columns'][$column_no] = $identifierColumn['Translation']['translation_text'];
|
||||
|
||||
if (isset($identifierColumn['BestTranslation']['translation_text']))
|
||||
$ent['columns'][$column_no] = $identifierColumn['BestTranslation']['translation_text'];
|
||||
|
||||
if ($export_reference_if_empty_translation && !isset($ent['columns'][$column_no]))
|
||||
$ent['columns'][$column_no] = $identifierColumn['reference_string'];
|
||||
else if (!isset($ent['columns'][$column_no]))
|
||||
$ent['columns'][$column_no] = '';
|
||||
}
|
||||
if ($fileIdentifier['command'])
|
||||
$ent['command'] = $ent['diff'] = $fileIdentifier['command'];
|
||||
|
||||
$entities[] = $ent;
|
||||
}
|
||||
|
||||
ini_set('max_execution_time',0);
|
||||
|
||||
$result = $this->RawFile->buildFile($entities);
|
||||
if (!$result)
|
||||
{
|
||||
$this->Session->setFlash(__('Error exporting file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class TranslationFilesController extends AppController {
|
||||
|
||||
var $name = 'TranslationFiles';
|
||||
|
||||
function index() {
|
||||
$this->TranslationFile->recursive = 0;
|
||||
|
||||
$conditions = null;
|
||||
if (isset($this->passedArgs['language_id']) && $language_id = $this->passedArgs['language_id'])
|
||||
$conditions = array('TranslationFile.language_id' => $language_id);
|
||||
$this->set('translationFiles', $this->paginate($conditions));
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid translation file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('translationFile', $this->TranslationFile->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_index() {
|
||||
$this->TranslationFile->recursive = 0;
|
||||
$this->set('translationFiles', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid translation file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('translationFile', $this->TranslationFile->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->TranslationFile->create();
|
||||
if ($this->TranslationFile->save($this->data)) {
|
||||
$this->Session->setFlash(__('The translation file has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$languages = $this->TranslationFile->Language->find('list');
|
||||
$this->set(compact('languages'));
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid translation file', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->TranslationFile->save($this->data)) {
|
||||
$this->Session->setFlash(__('The translation file has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The translation file could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('translationFile', $translationFile_data = $this->TranslationFile->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $translationFile_data;
|
||||
}
|
||||
$languages = $this->TranslationFile->Language->find('list');
|
||||
$this->set(compact('languages'));
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for translation file', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->TranslationFile->delete($id)) {
|
||||
$this->Session->setFlash(__('Translation file deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Translation file was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class TranslationsController extends AppController {
|
||||
|
||||
var $name = 'Translations';
|
||||
|
||||
function index() {
|
||||
$this->Translation->recursive = 0;
|
||||
$conditions = null;
|
||||
if (isset($this->passedArgs['identifier_id']) && $identifier = $this->passedArgs['identifier_id'])
|
||||
$conditions = array('Translation.identifier_id' => $identifier);
|
||||
$this->set('translations', $this->paginate($conditions));
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid translation', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('translation', $translation = $this->Translation->read(null, $id));
|
||||
if (isset($translation['Translation']['identifier_id']))
|
||||
{
|
||||
$this->set('identifier', $identifier = $this->Translation->Identifier->read(null, $translation['Translation']['identifier_id']));
|
||||
$this->set('columnTranslations', $columnTranslations = $this->Translation->find('all', array('conditions' => array('Translation.parent_id' => $translation['Translation']['id']), 'order' => 'Translation.id')));
|
||||
}
|
||||
if ($identifier_id = $translation['Translation']['identifier_id'])
|
||||
$this->set('identifierNeighbours', $this->Translation->Identifier->getNeighbours($identifier_id));
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Translation->create();
|
||||
if ($this->data['ChildTranslation'])
|
||||
{
|
||||
unset($translationText);
|
||||
foreach ($this->data['ChildTranslation'] as $num => $childTranslation)
|
||||
{
|
||||
$ent['columns'][] = $childTranslation['translation_text'];
|
||||
$translationText .= $childTranslation['translation_text'] . "\t";
|
||||
}
|
||||
$this->data['Translation']['translation_text'] = substr($translationText, 0, -1);
|
||||
}
|
||||
else
|
||||
$ent['string'] = $this->data['Translation']['translation_text'];
|
||||
sort($ent['columns']);
|
||||
$this->data['Translation']['translation_hash'] = $this->Translation->makeHash($ent);
|
||||
$this->data['Identifier']['id'] = $this->data['Translation']['identifier_id'];
|
||||
$this->data['Identifier']['translated'] = 1;
|
||||
$res = $this->Translation->saveAll($this->data);
|
||||
$this->log($this->data);
|
||||
if ($res) {
|
||||
$this->Session->setFlash(__('The translation has been saved', true));
|
||||
if ($this->params['form']['Next'])
|
||||
{
|
||||
$identifier_id = $this->data['Translation']['identifier_id'];
|
||||
$identifier = $this->Translation->Identifier->read(null, $identifier_id);
|
||||
$identifierNeighbors = $this->Translation->Identifier->find('neighbors', array('field' => 'id', 'value' => $identifier_id, 'conditions' => array('translation_file_id' => $identifier['Identifier']['translation_file_id'])));
|
||||
if ($nextIdentifier = $identifierNeighbors['next'])
|
||||
$this->redirect(array('action' => 'add', 'identifier_id' => $nextIdentifier['Identifier']['id']));
|
||||
else
|
||||
$this->redirect(array('controller' => 'identifiers', 'action' => 'index', 'translation_file_id' => $identifier['Identifier']['translation_file_id']));
|
||||
}
|
||||
else
|
||||
$this->redirect(array('controller' => 'identifiers', 'action' => 'view', $this->data['Translation']['identifier_id']));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The translation could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->passedArgs['identifier_id']))
|
||||
{
|
||||
$this->Session->setFlash(__('You need to choose identifier for translation', true));
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
else
|
||||
{
|
||||
$identifier_id = $this->passedArgs['identifier_id'];
|
||||
$this->set('identifier', $identifier = $this->Translation->Identifier->read(null, $identifier_id));
|
||||
$this->set('identifierNeighbours', $this->Translation->Identifier->getNeighbours($identifier_id));
|
||||
$this->set('identifierColumns', $identifierColumns = $this->Translation->IdentifierColumn->find('list', array('conditions' => array('identifier_id' => $identifier_id), 'order' => 'IdentifierColumn.id')));
|
||||
if ($identifierColumns)
|
||||
$this->set('identifierColumnsDetails', Set::combine($this->Translation->IdentifierColumn->find('all', array('conditions' => array('identifier_id' => $identifier_id), 'order' => 'IdentifierColumn.id')), '{n}.IdentifierColumn.id', '{n}.IdentifierColumn'));
|
||||
}
|
||||
$users = $this->Translation->User->find('list');
|
||||
$this->set(compact('identifiers', 'users'));
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid translation', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->data['ChildTranslation'])
|
||||
{
|
||||
unset($translationText);
|
||||
foreach ($this->data['ChildTranslation'] as $num => $childTranslation)
|
||||
{
|
||||
$ent['columns'][] = $childTranslation['translation_text'];
|
||||
$translationText .= $childTranslation['translation_text'] . "\t";
|
||||
}
|
||||
$this->data['Translation']['translation_text'] = substr($translationText, 0, -1);
|
||||
}
|
||||
else
|
||||
$ent['string'] = $this->data['Translation']['translation_text'];
|
||||
$this->data['Translation']['translation_hash'] = $this->Translation->makeHash($ent);
|
||||
$this->data['Identifier']['id'] = $this->data['Translation']['identifier_id'];
|
||||
$this->data['Identifier']['translated'] = 1;
|
||||
if ($this->Translation->saveAll($this->data)) {
|
||||
$this->Session->setFlash(__('The translation has been saved', true));
|
||||
$this->redirect(array('controller' => 'identifiers', 'action' => 'view', $this->data['Translation']['identifier_id']));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The translation could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('translation', $translation_data = $this->Translation->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $translation_data;
|
||||
}
|
||||
$identifier_id= $translation_data['Translation']['identifier_id'];
|
||||
$this->set('identifierNeighbours', $this->Translation->Identifier->getNeighbours($identifier_id));
|
||||
$this->set('identifierColumns', $identifierColumns = $this->Translation->IdentifierColumn->find('list', array('conditions' => array('identifier_id' => $identifier_id), 'order' => 'IdentifierColumn.id')));
|
||||
if ($identifierColumns)
|
||||
{
|
||||
$contain = array('Translation' => array(
|
||||
'conditions' => array('Translation.parent_id' => $translation_data['Translation']['id']),
|
||||
));
|
||||
$identifierColumnsAll = $this->Translation->IdentifierColumn->find('all', array('conditions' => array('identifier_id' => $identifier_id), 'order' => 'IdentifierColumn.id', 'contain' => $contain));
|
||||
foreach ($translation_data['ChildTranslation'] as $childTranslationKey => $childTranslation)
|
||||
{
|
||||
$mapChildTranslationsColumns[$childTranslation['identifier_column_id']] = $childTranslationKey;
|
||||
|
||||
}
|
||||
$this->set(compact('mapChildTranslationsColumns'));
|
||||
$this->set('identifierColumnsDetails', Set::combine($identifierColumnsAll, '{n}.IdentifierColumn.id', '{n}.IdentifierColumn'));
|
||||
$this->set('identifierColumnTranslations', Set::combine($translation_data['ChildTranslation'], '{n}.identifier_column_id'));//, '{n}.identifier_column_id'));
|
||||
}
|
||||
$identifier = $this->Translation->Identifier->read(null, $this->data['Translation']['identifier_id']);
|
||||
$users = $this->Translation->User->find('list');
|
||||
$this->set(compact('identifiers', 'users', 'identifier'));
|
||||
}
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for translation', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Translation->delete($id)) {
|
||||
$this->Session->setFlash(__('Translation deleted', true));
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
$this->Session->setFlash(__('Translation was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
function admin_index() {
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
function admin_setBest($id) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for translation', true));
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
if ($this->Translation->setBest($id))
|
||||
$this->Session->setFlash(__('Set successful', true));
|
||||
else
|
||||
$this->Session->setFlash(__('Set error', true));
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
return $this->view($id);
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
return $this->edit($id);
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for translation', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Translation->delete($id)) {
|
||||
$this->Session->setFlash(__('Translation deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Translation was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class UsersController extends AppController {
|
||||
|
||||
var $name = 'Users';
|
||||
|
||||
var $components = array('Email');
|
||||
|
||||
function index() {
|
||||
$this->User->recursive = 0;
|
||||
$this->set('users', $this->paginate());
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid user', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('user', $this->User->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_index() {
|
||||
$this->User->recursive = 0;
|
||||
$this->set('users', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid user', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('user', $this->User->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->User->create();
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash(__('The user has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The user could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid user', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash(__('The user has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The user could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$this->set('user', $user_data = $this->User->read(null, $id));
|
||||
if (empty($this->data)) {
|
||||
$this->data = $user_data;
|
||||
}
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for user', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->User->delete($id)) {
|
||||
$this->Session->setFlash(__('User deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('User was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
|
||||
function login() {
|
||||
if (!empty($this->data))
|
||||
{
|
||||
$user = $this->User->find('first', array('conditions' => array('User.username' => $this->data['User']['username'])));
|
||||
$this->log($user);
|
||||
if ($user['User']['confirm_hash'])
|
||||
{
|
||||
$this->Session->delete('Message.auth');
|
||||
$this->Session->setFlash('This account is not yet confirmed. Please use confirmation link from email to finalize registration.');
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
if (!$user['User']['activated'])
|
||||
{
|
||||
$this->Session->delete('Message.auth');
|
||||
$this->Session->setFlash('This account is not yet activated. Please wait until administrator activates your account.');
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
|
||||
}
|
||||
if (!(empty($this->data)) && $this->Auth->user())
|
||||
{
|
||||
$this->log('a');
|
||||
$this->User->id = $this->Auth->user('id');
|
||||
$this->User->saveField('last_login', date('Y-m-d H:i:s'));
|
||||
$this->redirect($this->Auth->redirect());
|
||||
}
|
||||
$this->log('b');
|
||||
}
|
||||
|
||||
function logout() {
|
||||
$this->redirect($this->Auth->logout());
|
||||
}
|
||||
|
||||
function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
$this->Auth->allow(array('register', 'login', 'logout', 'confirm'));
|
||||
}
|
||||
|
||||
function register() {
|
||||
if(!empty($this->data)) {
|
||||
$this->User->create();
|
||||
$this->data['User']['password'] = $this->Auth->password($this->data['User']['passwd']);
|
||||
$this->data['User']['confirm_hash'] = $this->Auth->password($this->data['User']['name'] . time());
|
||||
if($user = $this->User->save($this->data)) {
|
||||
// send signup email containing password to the user
|
||||
$this->Email->from = 'webtt-noreply@openlink.pl';
|
||||
$this->Email->to = $user['User']['email'];
|
||||
$this->Email->subject = 'WebTT registration';
|
||||
$this->Email->sendAs = 'text';
|
||||
$this->Email->template = 'registration';
|
||||
$this->set('user', $this->data);
|
||||
$this->set('serverName', $_SERVER['SERVER_NAME']);
|
||||
$this->params['url']['ext'] = 'no_debug';
|
||||
unset($this->helpers['DebugKit.Toolbar']);
|
||||
$this->Email->send();
|
||||
$this->Session->setFlash('Thank you for registrating. Please use confirmation link from email to finalize registration.');
|
||||
$this->redirect('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function confirm($confirm_hash)
|
||||
{
|
||||
$user = $this->User->find('first', array('conditions' => array('User.confirm_hash' => $confirm_hash)));
|
||||
if (!$user)
|
||||
{
|
||||
$this->Session->setFlash('No user found. Please register again.');
|
||||
$this->redirect('/');
|
||||
}
|
||||
$this->User->id = $user['User']['id'];
|
||||
$this->User->save(array('confirm_hash' => null));
|
||||
$this->Session->setFlash('Thank you for registrating. You will be able to log in after your account is activated by administrator.');
|
||||
$this->redirect('/');
|
||||
}
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class VotesController extends AppController {
|
||||
|
||||
var $name = 'Votes';
|
||||
|
||||
function index() {
|
||||
$this->Vote->recursive = 0;
|
||||
$conditions = null;
|
||||
if (isset($this->passedArgs['translation_id']) && $translation_id = $this->passedArgs['translation_id'])
|
||||
$conditions = array('Vote.translation_id' => $translation_id);
|
||||
$this->set('votes', $this->paginate($conditions));
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid vote', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('vote', $this->Vote->read(null, $id));
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Vote->create();
|
||||
if ($this->Vote->save($this->data)) {
|
||||
$this->Session->setFlash(__('The vote has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The vote could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$translations = $this->Vote->Translation->find('list');
|
||||
$users = $this->Vote->User->find('list');
|
||||
$this->set(compact('translations', 'users'));
|
||||
}
|
||||
|
||||
function vote() {
|
||||
if (empty($this->passedArgs['translation_id']))
|
||||
{
|
||||
$this->Session->setFlash(__('You need to choose translation for your vote', true));
|
||||
$this->redirect(array('controller' => 'translations', 'action' => 'index'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$translation_id = $this->passedArgs['translation_id'];
|
||||
$translation = $this->Vote->Translation->read(null, $translation_id);
|
||||
if (!$translation)
|
||||
{
|
||||
$this->Session->setFlash(__("Translation doesn't exist.", true));
|
||||
$this->redirect(array('controller' => 'translations', 'action' => 'index'));
|
||||
}
|
||||
$vote = array("Vote" => array(
|
||||
'translation_id' => $translation_id,
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
),
|
||||
);
|
||||
$this->Vote->create();
|
||||
$this->Vote->save($vote);
|
||||
$this->Session->setFlash(__('Vote added', true));
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid vote', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Vote->save($this->data)) {
|
||||
$this->Session->setFlash(__('The vote has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The vote could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$this->data = $this->Vote->read(null, $id);
|
||||
}
|
||||
$translations = $this->Vote->Translation->find('list');
|
||||
$users = $this->Vote->User->find('list');
|
||||
$this->set(compact('translations', 'users'));
|
||||
}
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for vote', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Vote->delete($id)) {
|
||||
$this->Session->setFlash(__('Vote deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Vote was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
function admin_index() {
|
||||
$this->Vote->recursive = 0;
|
||||
$this->set('votes', $this->paginate());
|
||||
}
|
||||
|
||||
function admin_view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid vote', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
$this->set('vote', $this->Vote->read(null, $id));
|
||||
}
|
||||
|
||||
function admin_add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Vote->create();
|
||||
if ($this->Vote->save($this->data)) {
|
||||
$this->Session->setFlash(__('The vote has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The vote could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
$translations = $this->Vote->Translation->find('list');
|
||||
$users = $this->Vote->User->find('list');
|
||||
$this->set(compact('translations', 'users'));
|
||||
}
|
||||
|
||||
function admin_edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid vote', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Vote->save($this->data)) {
|
||||
$this->Session->setFlash(__('The vote has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The vote could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$this->data = $this->Vote->read(null, $id);
|
||||
}
|
||||
$translations = $this->Vote->Translation->find('list');
|
||||
$users = $this->Vote->User->find('list');
|
||||
$this->set(compact('translations', 'users'));
|
||||
}
|
||||
|
||||
function admin_delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for vote', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->Vote->delete($id)) {
|
||||
$this->Session->setFlash(__('Vote deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->Session->setFlash(__('Vote was not deleted', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Application model for Cake.
|
||||
*
|
||||
* This file is application-wide model file. You can put all
|
||||
* application-wide model-related methods here.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.model
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Application model for Cake.
|
||||
*
|
||||
* This is a placeholder class.
|
||||
* Create the same file in app/app_model.php
|
||||
* Add your application-wide methods to the class, your models will inherit them.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.model
|
||||
*/
|
||||
class AppModel extends Model {
|
||||
// var $recursive = 0;
|
||||
|
||||
var $scaffoldForbiddenActions = null;
|
||||
var $scaffoldActions = null;
|
||||
var $scaffoldForbiddenFields = null;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
http://bakery.cakephp.org/articles/Jippi/2007/03/25/null-behavior
|
||||
*/
|
||||
class NullBehavior extends ModelBehavior {
|
||||
var $settings = array();
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param AppModel $model
|
||||
* @param unknown_type $config
|
||||
*/
|
||||
function setup(&$model, $config = array())
|
||||
{
|
||||
$this->settings[$model->name] = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param AppModel $model
|
||||
*/
|
||||
function beforeSave(&$model)
|
||||
{
|
||||
foreach ($this->settings[$model->name] as $field)
|
||||
{
|
||||
if(
|
||||
true === array_key_exists($field,$model->data[$model->name]) &&
|
||||
true === empty($model->data[$model->name][$field]) &&
|
||||
0 === strlen($model->data[$model->name][$field]) )
|
||||
{
|
||||
$model->data[$model->name][$field] = null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class Comment extends AppModel {
|
||||
var $name = 'Comment';
|
||||
var $displayField = 'id';
|
||||
|
||||
var $scaffoldActions = array("add" => "fk");
|
||||
|
||||
var $belongsTo = array(
|
||||
/* 'Translation' => array(
|
||||
'className' => 'Translation',
|
||||
'foreignKey' => 'translation_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),*/
|
||||
'Identifier' => array(
|
||||
'className' => 'Identifier',
|
||||
'foreignKey' => 'identifier_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
'User' => array(
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'user_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
)
|
||||
);
|
||||
}
|
@ -0,0 +1,275 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
if (!class_exists('Folder')) {
|
||||
App::import('Core', 'Folder');
|
||||
}
|
||||
|
||||
if (!class_exists('File')) {
|
||||
App::import('Core', 'File');
|
||||
}
|
||||
|
||||
/**
|
||||
* CSVSource Datasource
|
||||
*
|
||||
* @package datasources
|
||||
* @subpackage datasources.models.datasources
|
||||
*/
|
||||
class RawFilesSource extends DataSource {
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $description = 'Directory Contents Data Source';
|
||||
|
||||
/**
|
||||
* File Handle
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $handle = false;
|
||||
|
||||
/**
|
||||
* Default configuration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $_baseConfig = array(
|
||||
'datasource' => 'Datasources.RawFilesSource',
|
||||
'path' => '.',
|
||||
'extension' => 'txt',
|
||||
'readonly' => true,
|
||||
'recursive' => false);
|
||||
|
||||
var $_schema = array(
|
||||
// 'files' => array(
|
||||
'filename' => array(
|
||||
'type' => 'string',
|
||||
'null' => false,
|
||||
'key' => 'primary',
|
||||
'length' => 255
|
||||
),
|
||||
'size' => array(
|
||||
'type' => 'string',
|
||||
'null' => false,
|
||||
'length' => 40,
|
||||
),
|
||||
'modified' => array(
|
||||
'type' => 'string',
|
||||
'null' => false,
|
||||
'length' => 40,
|
||||
),
|
||||
// )
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $config Configuration array
|
||||
* @param boolean $autoConnect Automatically connect to / open the file
|
||||
*/
|
||||
public function __construct($config = null, $autoConnect = true) {
|
||||
$this->debug = Configure::read('debug') > 0;
|
||||
$this->fullDebug = Configure::read('debug') > 1;
|
||||
parent::__construct($config);
|
||||
if ($autoConnect) {
|
||||
$this->connect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the directory using options in the given configuration array.
|
||||
*
|
||||
* @return boolean True if the file could be opened.
|
||||
*/
|
||||
public function connect() {
|
||||
$this->connected = false;
|
||||
|
||||
if ($this->config['readonly']) {
|
||||
$create = false;
|
||||
$mode = 0;
|
||||
} else {
|
||||
$create = true;
|
||||
$mode = 0777;
|
||||
}
|
||||
|
||||
$this->connection =& new Folder($this->config['path'], $create, $mode);
|
||||
if ($this->connection) {
|
||||
$this->handle = array();
|
||||
$this->connected = true;
|
||||
}
|
||||
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* List available sources
|
||||
*
|
||||
* @return array of available files
|
||||
*/
|
||||
public function listSources() {
|
||||
return array('raw_files');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Model description (metadata).
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function describe($model) {
|
||||
return $this->_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close file handle
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function close() {
|
||||
if ($this->connected) {
|
||||
if ($this->handle) {
|
||||
foreach($this->handle as $h) {
|
||||
@fclose($h);
|
||||
}
|
||||
$this->handle = false;
|
||||
}
|
||||
$this->connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method to determine if file is in one of given directories
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function fileInDir($filepath, $dirs)
|
||||
{
|
||||
foreach ($dirs as $dir)
|
||||
{
|
||||
$dir = $this->connection->realpath($this->config['path']) . DS . $dir;
|
||||
if ($dir . DS . basename($filepath) === $filepath)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Data
|
||||
*
|
||||
* @param Model $model
|
||||
* @param array $queryData
|
||||
* @param integer $recursive Number of levels of association
|
||||
* @return mixed
|
||||
*/
|
||||
public function read(&$model, $queryData = array(), $recursive = null) {
|
||||
if (isset($queryData["conditions"][$model->alias . ".extension"]))
|
||||
$extension = preg_quote($queryData["conditions"][$model->alias . ".extension"]);
|
||||
else
|
||||
$extension = $this->config['extension'];
|
||||
|
||||
if (isset($queryData["conditions"][$model->alias . ".filename"]))
|
||||
{
|
||||
$filename = $queryData["conditions"][$model->alias .".filename"];
|
||||
$searchPattern = preg_quote($queryData["conditions"][$model->alias .".filename"], '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
// $searchPattern = '.*' . '\.' . preg_quote($extension);
|
||||
$searchPattern = '.*' . '\.' . $extension;
|
||||
}
|
||||
|
||||
if (isset($queryData["conditions"][$model->alias . ".dir"]))
|
||||
{
|
||||
// $dir = $this->connection->realpath($this->config['path']) . DS . $queryData["conditions"][$model->alias . ".dir"];
|
||||
$dir = is_array($dir = $queryData["conditions"][$model->alias . ".dir"]) ? $dir : array($dir);
|
||||
}
|
||||
|
||||
/* var_dump($queryData);*/
|
||||
// var_dump($searchPattern);
|
||||
|
||||
if ($this->config['recursive']) {
|
||||
$list = $this->connection->findRecursive($searchPattern, true);
|
||||
/* $this->log($list);
|
||||
echo "list#\n";
|
||||
var_dump($list);*/
|
||||
foreach($list as &$item) {
|
||||
$temp = $item;
|
||||
$item = array();
|
||||
$item["full"] = $temp;
|
||||
$item["short"] = mb_substr($temp, mb_strlen($this->connection->realpath($this->config['path']) . DS));
|
||||
}
|
||||
unset($item);
|
||||
} else {
|
||||
$list = $this->connection->find($searchPattern, true);
|
||||
foreach($list as &$item) {
|
||||
$temp = $item;
|
||||
$item = array();
|
||||
$item["full"] = $this->config['path'] . DS .$temp;
|
||||
$item["short"] = $temp;
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
|
||||
$resultSet = array();
|
||||
foreach ($list as $item) {
|
||||
/* if (isset($dir) && isset($filename))
|
||||
{
|
||||
echo "dirconcat#\n";
|
||||
var_dump($dir . DS . $filename);
|
||||
echo "itemfull#\n";
|
||||
var_dump($item["full"]);
|
||||
if ($dir . DS . $filename === $item["full"])
|
||||
continue;
|
||||
}*/
|
||||
if (isset($dir))
|
||||
if (!$this->fileInDir($item["full"], $dir))
|
||||
continue;
|
||||
$file = new File($path = $this->config['path'] . DS . $item["short"], false);
|
||||
// var_dump($item);
|
||||
// $item = preg_replace('/' . $extPattern . '$/i', '', $item);
|
||||
$resultSet[] = array(
|
||||
$model->alias => array(
|
||||
'filename' => $item["short"],
|
||||
'size' => $file->size(),
|
||||
'modified' => $file->lastChange(),
|
||||
),
|
||||
);
|
||||
}
|
||||
if ($model->findQueryType === 'count') {
|
||||
return array(array(array('count' => count($resultSet))));
|
||||
}
|
||||
|
||||
return $resultSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate
|
||||
*
|
||||
* @param Model $model
|
||||
* @param mixed $func
|
||||
* @param array $params
|
||||
* @return array with the field name with records count
|
||||
*/
|
||||
public function calculate(&$model, $func, $params = array()) {
|
||||
return array('count');
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class FileIdentifier extends AppModel {
|
||||
var $name = 'FileIdentifier';
|
||||
var $displayField = 'command';
|
||||
var $order = 'FileIdentifier.id';
|
||||
|
||||
var $scaffoldForbiddenActions = array("index", "add", "admin_add", "edit", "admin_edit", "delete", "admin_delete");
|
||||
|
||||
var $belongsTo = array(
|
||||
'ImportedTranslationFile' => array(
|
||||
'className' => 'ImportedTranslationFile',
|
||||
'foreignKey' => 'imported_translation_file_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
// 'order' => ''
|
||||
),
|
||||
'Identifier' => array(
|
||||
'className' => 'Identifier',
|
||||
'foreignKey' => 'identifier_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
// 'order' => ''
|
||||
)
|
||||
);
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class Identifier extends AppModel {
|
||||
var $name = 'Identifier';
|
||||
var $displayField = 'identifier';
|
||||
var $actsAs = array('Containable');
|
||||
|
||||
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
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
var $scaffoldForbiddenActions = array("add", "admin_add", "edit", "admin_edit", "delete", "admin_delete");
|
||||
|
||||
var $belongsTo = array(
|
||||
'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' => '',
|
||||
),
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
'Translation' => array(
|
||||
'className' => 'Translation',
|
||||
'foreignKey' => 'identifier_id',
|
||||
'dependent' => true,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
'Comment' => array(
|
||||
'className' => 'Comment',
|
||||
'foreignKey' => 'identifier_id',
|
||||
'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' => ''
|
||||
),
|
||||
'IdentifierColumn' => array(
|
||||
'className' => 'IdentifierColumn',
|
||||
'foreignKey' => 'identifier_id',
|
||||
'dependent' => true,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
);
|
||||
|
||||
function withoutBestTranslation($conditions = array())
|
||||
{
|
||||
/* $this->contain(array(
|
||||
'FileIdentifier' => array('ImportedTranslationFile' => array(
|
||||
'conditions' => array('ImportedTranslationFile.id' => 248)
|
||||
)),
|
||||
));
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class IdentifierColumn extends AppModel {
|
||||
var $name = 'IdentifierColumn';
|
||||
var $displayField = 'column_name';
|
||||
var $actsAs = array('Containable');
|
||||
|
||||
var $scaffoldForbiddenActions = array("add", "admin_add", "edit", "admin_edit", "delete", "admin_delete");
|
||||
|
||||
var $belongsTo = array(
|
||||
'Identifier' => array(
|
||||
'className' => 'Identifier',
|
||||
'foreignKey' => 'identifier_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
)
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
'Translation' => array(
|
||||
'className' => 'Translation',
|
||||
'foreignKey' => 'identifier_column_id',
|
||||
'dependent' => true,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
);
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class ImportedTranslationFile extends AppModel {
|
||||
var $name = 'ImportedTranslationFile';
|
||||
var $displayField = 'filename';
|
||||
|
||||
var $scaffoldForbiddenActions = array("index", "add", "admin_add", "edit", "admin_edit", "delete", "admin_delete");
|
||||
|
||||
var $actsAs = array('Containable');
|
||||
|
||||
var $belongsTo = array(
|
||||
'TranslationFile' => array(
|
||||
'className' => 'TranslationFile',
|
||||
'foreignKey' => 'translation_file_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
'FileIdentifier' => array(
|
||||
'className' => 'FileIdentifier',
|
||||
'foreignKey' => 'imported_translation_file_id',
|
||||
'dependent' => true,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => 'FileIdentifier.id',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
)
|
||||
);
|
||||
|
||||
var $hasOne = array(
|
||||
'RawFile' => array(
|
||||
'className' => 'RawFile',
|
||||
'foreignKey' => 'filename',
|
||||
'dependand' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
),
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class Language extends AppModel {
|
||||
var $name = 'Language';
|
||||
var $displayField = 'name';
|
||||
|
||||
var $scaffoldForbiddenActions = array("add", "edit", "delete");
|
||||
|
||||
var $hasMany = array(
|
||||
'TranslationFile' => array(
|
||||
'className' => 'TranslationFile',
|
||||
'foreignKey' => 'language_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
);
|
||||
}
|
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class RawFile extends AppModel {
|
||||
var $name = 'RawFile';
|
||||
var $useDbConfig = 'raw_files';
|
||||
var $displayField = 'filename';
|
||||
// var $useTable = false;
|
||||
var $primaryKey = 'filename';
|
||||
|
||||
var $_parser;
|
||||
|
||||
var $belongsTo = array(
|
||||
'ImportedTranslationFile' => array(
|
||||
'className' => 'ImportedTranslationFile',
|
||||
'foreignKey' => 'filename',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
);
|
||||
|
||||
public function open($dir, $filename, $write = false)
|
||||
{
|
||||
$this->_currentFile = null;
|
||||
$this->_currentFileLastModified = null;
|
||||
|
||||
$ds = $this->getDataSource();
|
||||
$file = new File($filepath = $ds->config['path'] . DS . $dir . DS . $filename, false);
|
||||
if (!$file)
|
||||
return false;
|
||||
if (!$file->readable())
|
||||
return false;
|
||||
if ($write && !$file->writable())
|
||||
return false;
|
||||
$this->_currentFile = $file;
|
||||
$this->_currentFileLastChange = $file->lastChange();
|
||||
return $file;
|
||||
}
|
||||
|
||||
public function parseFile()
|
||||
{
|
||||
if (!$this->_currentFile)
|
||||
return false;
|
||||
|
||||
// TODO: file types array with filenames regex
|
||||
if (
|
||||
preg_match('|^([a-z]{2})_diff_[A-F0-9]{8}\.uxt$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^([a-z]{2})\.uxt$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^r2_([a-z]{2})\.uxt$|', $this->_currentFile->name, $matches)
|
||||
)
|
||||
{
|
||||
App::import("Vendor","StringParser", array("file" => 'StringParser.php'));
|
||||
$parser = $this->_parser = new StringParser();
|
||||
}
|
||||
else if (
|
||||
preg_match('|^phrase_([a-z]{2})_diff_[A-F0-9]{8}\.txt$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^phrase_([a-z]{2})\.txt$|', $this->_currentFile->name, $matches)
|
||||
)
|
||||
{
|
||||
App::import("Vendor","PhraseParser", array("file" => 'PhraseParser.php'));
|
||||
$parser = $this->_parser = new PhraseParser();
|
||||
}
|
||||
else if (preg_match('|^.*_words_([a-z]{2})_diff_[A-F0-9]{8}\..*$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^.*_words_([a-z]{2})\..*$|', $this->_currentFile->name, $matches))
|
||||
{
|
||||
App::import("Vendor","SheetParser", array("file" => 'SheetParser.php'));
|
||||
$parser = $this->_parser = new SheetParser();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$entities = $parser->parseFile($this->_currentFile->read());
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function buildFile($entities)
|
||||
{
|
||||
if (!$this->_currentFile)
|
||||
return false;
|
||||
|
||||
// TODO: file types array with filenames regex
|
||||
if (
|
||||
preg_match('|^([a-z]{2})_diff_[A-F0-9]{8}\.uxt$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^([a-z]{2})\.uxt$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^r2_([a-z]{2})\.uxt$|', $this->_currentFile->name, $matches)
|
||||
)
|
||||
{
|
||||
App::import("Vendor","StringParser", array("file" => 'StringParser.php'));
|
||||
$parser = $this->_parser = new StringParser();
|
||||
}
|
||||
else if (
|
||||
preg_match('|^phrase_([a-z]{2})_diff_[A-F0-9]{8}\.txt$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^phrase_([a-z]{2})\.txt$|', $this->_currentFile->name, $matches)
|
||||
)
|
||||
{
|
||||
App::import("Vendor","PhraseParser", array("file" => 'PhraseParser.php'));
|
||||
$parser = $this->_parser = new PhraseParser();
|
||||
}
|
||||
else if (preg_match('|^.*_words_([a-z]{2})_diff_[A-F0-9]{8}\..*$|', $this->_currentFile->name, $matches)
|
||||
|| preg_match('|^.*_words_([a-z]{2})\..*$|', $this->_currentFile->name, $matches))
|
||||
{
|
||||
App::import("Vendor","SheetParser", array("file" => 'SheetParser.php'));
|
||||
$parser = $this->_parser = new SheetParser();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$content = $parser->buildFile($entities);
|
||||
$ret = $this->_currentFile->write($content);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public function getLanguageCode($filename)
|
||||
{
|
||||
if (preg_match('|^([a-z]{2})_diff_[A-F0-9]{8}\.uxt$|', $filename, $matches))
|
||||
return $matches[1];
|
||||
else if (preg_match('|^([a-z]{2})\.uxt$|', $filename, $matches))
|
||||
return $matches[1];
|
||||
else if (preg_match('|^r2_([a-z]{2})\.uxt$|', $filename, $matches))
|
||||
return $matches[1];
|
||||
else if (preg_match('|^phrase_([a-z]{2})_diff_[A-F0-9]{8}\..*$|', $filename, $matches))
|
||||
return $matches[1];
|
||||
else if (preg_match('|^phrase_([a-z]{2})\..*$|', $filename, $matches))
|
||||
return $matches[1];
|
||||
else if (preg_match('|^.*_words_([a-z]{2})_diff_[A-F0-9]{8}\..*$|', $filename, $matches))
|
||||
return $matches[1];
|
||||
else if (preg_match('|^.*_words_([a-z]{2})\..*$|', $filename, $matches))
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class Translation extends AppModel {
|
||||
var $name = 'Translation';
|
||||
var $displayField = 'translation_text';
|
||||
|
||||
var $scaffoldForbiddenActions = array();
|
||||
var $scaffoldActions = array("add" => "fk", "index" => "fk");
|
||||
|
||||
var $belongsTo = array(
|
||||
'Identifier' => array(
|
||||
'className' => 'Identifier',
|
||||
'foreignKey' => 'identifier_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
'IdentifierColumn' => array(
|
||||
'className' => 'IdentifierColumn',
|
||||
'foreignKey' => 'identifier_column_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
'User' => array(
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'user_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
'ParentTranslation' => array(
|
||||
'className' => 'Translation',
|
||||
'foreignKey' => 'parent_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
'Vote' => array(
|
||||
'className' => 'Vote',
|
||||
'foreignKey' => 'translation_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
/* 'Comment' => array(
|
||||
'className' => 'Comment',
|
||||
'foreignKey' => 'translation_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),*/
|
||||
'ChildTranslation' => array(
|
||||
'className' => 'Translation',
|
||||
'foreignKey' => 'parent_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
);
|
||||
|
||||
function setBest()
|
||||
{
|
||||
if (!$this->id)
|
||||
return false;
|
||||
$this->read();
|
||||
if (!isset($this->data['Translation']['identifier_id']))
|
||||
return false;
|
||||
|
||||
// set best on chosen translation
|
||||
$ret = $this->save(array('best' => 1));
|
||||
$best_id = $this->id;
|
||||
|
||||
// reset best on other translations
|
||||
$ret = $this->updateAll(array('Translation.best' => 0), array(
|
||||
'AND' => array(
|
||||
'Translation.identifier_id' => $ret['Translation']['identifier_id'],
|
||||
'Translation.id !=' => $best_id,
|
||||
),
|
||||
));
|
||||
$this->log($ret);
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
function makeHash($ent)
|
||||
{
|
||||
if (isset($ent['columns']) && is_array($ent['columns']))
|
||||
{
|
||||
sort($ent['columns']);
|
||||
return md5(serialize($ent['columns']));
|
||||
}
|
||||
else if (isset($ent['string']))
|
||||
return md5($ent['string']);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class TranslationFile extends AppModel {
|
||||
var $name = 'TranslationFile';
|
||||
var $displayField = 'filename_template';
|
||||
|
||||
var $scaffoldForbiddenActions = array("add", "admin_add", "edit", "admin_edit", "delete", "admin_delete");
|
||||
|
||||
var $belongsTo = array(
|
||||
'Language' => array(
|
||||
'className' => 'Language',
|
||||
'foreignKey' => 'language_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
)
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
'ImportedTranslationFile' => array(
|
||||
'className' => 'ImportedTranslationFile',
|
||||
'foreignKey' => 'translation_file_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
'Identifier' => array(
|
||||
'className' => 'Identifier',
|
||||
'foreignKey' => 'translation_file_id',
|
||||
'dependent' => true,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class User extends AppModel {
|
||||
var $name = 'User';
|
||||
var $displayField = 'name';
|
||||
|
||||
var $actsAs = array('Null' => array('confirm_hash'));
|
||||
|
||||
var $recursive = 0;
|
||||
|
||||
var $validate = array(
|
||||
'username' => array(
|
||||
'alphaNumeric',
|
||||
'uniqueCheck' => array(
|
||||
'rule' => 'isUnique',
|
||||
'message' => 'That username has already been taken.',
|
||||
),
|
||||
),
|
||||
'email' => array('rule' => 'email', 'message' => 'Wrong format'),
|
||||
'name' => array('rule' => 'notEmpty'),
|
||||
// 'password' => array('rule' => 'notEmpty'),
|
||||
'passwd' => array('rule' => 'notEmpty'),
|
||||
);
|
||||
|
||||
var $scaffoldForbiddenActions = array("add", "edit", "delete");
|
||||
var $scaffoldForbiddenFields = array("" => array("activated","password","confirm_hash","created","modified"),/* "admin_" => array("password")*/);
|
||||
|
||||
var $hasMany = array(
|
||||
'Translation' => array(
|
||||
'className' => 'Translation',
|
||||
'foreignKey' => 'user_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
'Vote' => array(
|
||||
'className' => 'Vote',
|
||||
'foreignKey' => 'user_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
'Comment' => array(
|
||||
'className' => 'Comment',
|
||||
'foreignKey' => 'user_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
);
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
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
|
||||
class Vote extends AppModel {
|
||||
var $name = 'Vote';
|
||||
var $displayField = 'translation_id';
|
||||
|
||||
var $scaffoldForbiddenActions = array("delete");
|
||||
|
||||
var $belongsTo = array(
|
||||
'Translation' => array(
|
||||
'className' => 'Translation',
|
||||
'foreignKey' => 'translation_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
),
|
||||
'User' => array(
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'user_id',
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => ''
|
||||
)
|
||||
);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue