Merge: From default to build_pipeline_v3

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
commit fa22fa3ae5

@ -245,7 +245,8 @@ code/ryzom/tools/build_gamedata/workspace/continents/crater/properties_final.cfg
code/ryzom/tools/build_gamedata/workspace/ecosystems/rocky/directories.py code/ryzom/tools/build_gamedata/workspace/ecosystems/rocky/directories.py
code/ryzom/tools/build_gamedata/workspace/ecosystems/rocky/process.py code/ryzom/tools/build_gamedata/workspace/ecosystems/rocky/process.py
# WebTT temp dir
code/ryzom/tools/server/www/webtt/app/tmp

@ -66,6 +66,7 @@ else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
/usr/lib64/glib-2.0/include /usr/lib64/glib-2.0/include
/usr/lib/glib-2.0/include /usr/lib/glib-2.0/include
/sw/lib/glib-2.0/include /sw/lib/glib-2.0/include
/usr/lib/x86_64-linux-gnu/glib-2.0/include
) )
gtk2_debug_message("GTK2_GLIBCONFIG_INCLUDE_DIR is ${GTK2_GLIBCONFIG_INCLUDE_DIR}") gtk2_debug_message("GTK2_GLIBCONFIG_INCLUDE_DIR is ${GTK2_GLIBCONFIG_INCLUDE_DIR}")
@ -95,9 +96,25 @@ else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
/usr/lib/gtk-2.0/include /usr/lib/gtk-2.0/include
/usr/lib64/gtk-2.0/include /usr/lib64/gtk-2.0/include
/sw/lib/gtk-2.0/include /sw/lib/gtk-2.0/include
/usr/lib/x86_64-linux-gnu/gtk-2.0/include
) )
gtk2_debug_message("GTK2_GDK_INCLUDE_DIR is ${GTK2_GDK_INCLUDE_DIR}") gtk2_debug_message("GTK2_GDK_INCLUDE_DIR is ${GTK2_GDK_INCLUDE_DIR}")
find_path(GTK2_GDK_PIXBUF_INCLUDE_DIR
NAMES
gdk-pixbuf/gdk-pixbuf.h
PATHS
${_GDK2IncDir}
/opt/gnome/lib/gtk-2.0/include
/opt/gnome/lib64/gtk-2.0/include
/opt/lib/gtk-2.0/include
/usr/lib/gtk-2.0/include
/usr/lib64/gtk-2.0/include
/sw/lib/gtk-2.0/include
/usr/include/gdk-pixbuf-2.0
)
gtk2_debug_message("GTK2_GDK_PIXBUF_INCLUDE_DIR is ${GTK2_GDK_PIXBUF_INCLUDE_DIR}")
find_path(GTK2_GTKGL_INCLUDE_DIR find_path(GTK2_GTKGL_INCLUDE_DIR
NAMES NAMES
gtkgl/gtkglarea.h gtkgl/gtkglarea.h
@ -357,6 +374,7 @@ else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
${GTK2_GLIBCONFIG_INCLUDE_DIR} ${GTK2_GLIBCONFIG_INCLUDE_DIR}
${GTK2_GLIB_INCLUDE_DIR} ${GTK2_GLIB_INCLUDE_DIR}
${GTK2_GDK_INCLUDE_DIR} ${GTK2_GDK_INCLUDE_DIR}
${GTK2_GDK_PIXBUF_INCLUDE_DIR}
${GTK2_GLADE_INCLUDE_DIR} ${GTK2_GLADE_INCLUDE_DIR}
${GTK2_PANGO_INCLUDE_DIR} ${GTK2_PANGO_INCLUDE_DIR}
${GTK2_CAIRO_INCLUDE_DIR} ${GTK2_CAIRO_INCLUDE_DIR}
@ -364,7 +382,7 @@ else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
) )
if (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR) if (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
if (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR) if (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR AND GTK2_GDK_PIXBUF_INCLUDE_DIR)
if (GTK2_GMODULE_LIBRARY) if (GTK2_GMODULE_LIBRARY)
if (GTK2_GTHREAD_LIBRARY) if (GTK2_GTHREAD_LIBRARY)
if (GTK2_GOBJECT_LIBRARY) if (GTK2_GOBJECT_LIBRARY)
@ -423,9 +441,9 @@ else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
else (GTK2_GMODULE_LIBRARY) else (GTK2_GMODULE_LIBRARY)
message(SEND_ERROR "Could not find GMODULE") message(SEND_ERROR "Could not find GMODULE")
endif (GTK2_GMODULE_LIBRARY) endif (GTK2_GMODULE_LIBRARY)
else (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR) else (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR AND GTK2_GDK_PIXBUF_INCLUDE_DIR)
message(SEND_ERROR "Could not find GDK (GDK_PIXBUF)") message(SEND_ERROR "Could not find GDK (GDK_PIXBUF)")
endif (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR) endif (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR AND GTK2_GDK_PIXBUF_INCLUDE_DIR)
else (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR) else (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
message(SEND_ERROR "Could not find GTK2-X11") message(SEND_ERROR "Could not find GTK2-X11")
endif (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR) endif (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)

@ -3,17 +3,32 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory) # ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory)
# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt) # SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt)
SET(CMAKE_MODULE_PATH "${SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") # Replace spaces by semi-columns
IF(CMAKE_MODULE_PATH)
STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
ENDIF(CMAKE_MODULE_PATH)
SET(CMAKE_MODULE_PATH ${SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH})
IF(NOT ROOT_DIR AND SOURCE_DIR)
SET(ROOT_DIR ${SOURCE_DIR})
ENDIF(NOT ROOT_DIR AND SOURCE_DIR)
IF(NOT SOURCE_DIR AND ROOT_DIR)
SET(SOURCE_DIR ${ROOT_DIR})
ENDIF(NOT SOURCE_DIR AND ROOT_DIR)
MACRO(NOW RESULT) MACRO(NOW RESULT)
IF (WIN32) IF (WIN32)
EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME) EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME)
STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} ${DATETIME}) IF(NOT DATETIME MATCHES "ERROR")
STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}")
ENDIF(NOT DATETIME MATCHES "ERROR")
ELSEIF(UNIX) ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+'%Y-%m-%d %H:%M:%S'" OUTPUT_VARIABLE ${RESULT}) EXECUTE_PROCESS(COMMAND "date" "+'%Y-%m-%d %H:%M:%S'" OUTPUT_VARIABLE ${RESULT})
ELSE (WIN32) ELSE (WIN32)
MESSAGE(SEND_ERROR "date not implemented") MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} 000000) SET(${RESULT} "0000-00-00 00:00:00")
ENDIF (WIN32) ENDIF (WIN32)
ENDMACRO(NOW) ENDMACRO(NOW)

@ -40,11 +40,12 @@ CBnpDirTreeDialog::CBnpDirTreeDialog(QString bnpPath, QWidget *parent)
// Bnp file: opened and displayed // Bnp file: opened and displayed
// all other files: added to the currently opened bnp file // all other files: added to the currently opened bnp file
QStringList filter; QStringList filter;
//filter << tr("*.bnp"); filter << tr("*.bnp");
// Setup the directory tree model // Setup the directory tree model
m_dirModel= new BNPFileSystemModel(); m_dirModel= new BNPFileSystemModel();
m_proxyModel = new BNPSortProxyModel(); m_proxyModel = new BNPSortProxyModel();
m_ui.dirTree->setSortingEnabled(true);
m_dirModel->setRootPath(m_DataPath); m_dirModel->setRootPath(m_DataPath);
m_dirModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::AllEntries); m_dirModel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::AllEntries);
m_dirModel->setNameFilters(filter); m_dirModel->setNameFilters(filter);
@ -55,7 +56,6 @@ CBnpDirTreeDialog::CBnpDirTreeDialog(QString bnpPath, QWidget *parent)
m_ui.dirTree->setModel(m_proxyModel); m_ui.dirTree->setModel(m_proxyModel);
m_ui.dirTree->setRootIndex( m_proxyModel->mapFromSource (m_dirModel->index(m_DataPath) ) ); m_ui.dirTree->setRootIndex( m_proxyModel->mapFromSource (m_dirModel->index(m_DataPath) ) );
m_ui.dirTree->setSortingEnabled(true);
// Trigger if one filename is activated // Trigger if one filename is activated
// In future drag&drop should be also possible // In future drag&drop should be also possible

@ -44,6 +44,9 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

@ -62,6 +62,15 @@ void BNPFileHandle::releaseInstance()
} }
} }
// *************************************************************************** // ***************************************************************************
void BNPFileHandle::createFile(string filePath)
{
// Only set the filepath. Header will be created after files have been added
m_openedBNPFile = filePath;
m_packedFiles.clear();
nlinfo("Created file %s.", filePath.c_str() );
}
// ***************************************************************************
bool BNPFileHandle::unpack(const string &dirName, const vector<string>& fileList) bool BNPFileHandle::unpack(const string &dirName, const vector<string>& fileList)
{ {
CIFile bnp; CIFile bnp;
@ -232,6 +241,8 @@ void BNPFileHandle::addFiles( const vector<string> &filePathes)
writeHeader(m_openedBNPFile + ".tmp", OffsetFromBegining); writeHeader(m_openedBNPFile + ".tmp", OffsetFromBegining);
// Delete any previous existing file
if (CFile::fileExists( m_openedBNPFile ))
CFile::deleteFile( m_openedBNPFile ); CFile::deleteFile( m_openedBNPFile );
string src = m_openedBNPFile + ".tmp"; string src = m_openedBNPFile + ".tmp";
CFile::moveFile( m_openedBNPFile.c_str(), src.c_str() ); CFile::moveFile( m_openedBNPFile.c_str(), src.c_str() );

@ -88,6 +88,12 @@ public:
*/ */
void fileNames( std::vector<std::string>& fileNames ); void fileNames( std::vector<std::string>& fileNames );
/**
* Create a new bnp file
* \param string file path
*/
void createFile( std::string filePath );
/** /**
* Add files to the current aktive bnp file * Add files to the current aktive bnp file
* \param vector of file pathes to add * \param vector of file pathes to add

@ -20,10 +20,6 @@
// Qt includes // Qt includes
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QDragEnterEvent>
#include <QMimeData>
#include <QUrl>
#include <QEvent>
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
@ -38,7 +34,6 @@ BnpFileListDialog::BnpFileListDialog(QString bnpPath, QWidget *parent)
m_DataPath(bnpPath) m_DataPath(bnpPath)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
setAcceptDrops(true);
} }
// *************************************************************************** // ***************************************************************************
BnpFileListDialog::~BnpFileListDialog() BnpFileListDialog::~BnpFileListDialog()
@ -111,6 +106,14 @@ bool BnpFileListDialog::loadTable(const QString filePath)
return true; return true;
} }
// *************************************************************************** // ***************************************************************************
void BnpFileListDialog::clearTable()
{
// create emtpy table
setupTable(0);
setWindowTitle("BNP File List");
}
// ***************************************************************************
void BnpFileListDialog::getSelections(TSelectionList& SelectionList) void BnpFileListDialog::getSelections(TSelectionList& SelectionList)
{ {
QModelIndex index; QModelIndex index;
@ -125,21 +128,5 @@ void BnpFileListDialog::getSelections(TSelectionList& SelectionList)
SelectionList.push_back( filename.toStdString() ); SelectionList.push_back( filename.toStdString() );
} }
} }
// ***************************************************************************
void BnpFileListDialog::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only one file
// In the future a tabbed FileListDialog would accept more
if ( event->mimeData()->hasUrls() && event->mimeData()->urls().count() == 1)
event->acceptProposedAction();
}
// ***************************************************************************
void BnpFileListDialog::dropEvent(QDropEvent *event)
{
// Excraft the local file url from the drop object and fill the table
const QMimeData *mimeData = event->mimeData();
QList<QUrl> urlList = mimeData->urls();
loadTable( urlList.first().toLocalFile() );
}
} // namespace BNPManager } // namespace BNPManager

@ -59,6 +59,11 @@ public:
*/ */
void setupTable(int nbrows); void setupTable(int nbrows);
/**
* When BNP files is closed, clear the filelist table
*/
void clearTable();
/** /**
* Fill the files selected in the table view to * Fill the files selected in the table view to
* unpack them. * unpack them.
@ -67,9 +72,6 @@ public:
*/ */
void getSelections(TSelectionList& SelectionList); void getSelections(TSelectionList& SelectionList);
protected:
void dragEnterEvent (QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
private: private:
Ui::BnpFileListDialog m_ui; Ui::BnpFileListDialog m_ui;

@ -25,6 +25,7 @@ namespace Constants
const char * const BNP_MANAGER_SECTION = "BNPManager"; const char * const BNP_MANAGER_SECTION = "BNPManager";
//resources //resources
const char *const ICON_NEW = ":/images/ic_nel_new.png";
const char *const ICON_ADD = ":/images/ic_nel_add_item.png"; const char *const ICON_ADD = ":/images/ic_nel_add_item.png";
const char *const ICON_DELETE = ":/images/ic_nel_delete_item.png"; const char *const ICON_DELETE = ":/images/ic_nel_delete_item.png";
const char *const ICON_UNPACK = ":/images/ic_nel_export.png"; const char *const ICON_UNPACK = ":/images/ic_nel_export.png";

@ -30,6 +30,10 @@
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
#include <nel/misc/path.h> #include <nel/misc/path.h>
// STL includes
#include <vector>
#include <string>
// Qt includes // Qt includes
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
@ -37,6 +41,11 @@
#include <QTableWidget> #include <QTableWidget>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QDragEnterEvent>
#include <QMimeData>
#include <QUrl>
#include <QEvent>
#include <QInputDialog>
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -53,6 +62,8 @@ BNPManagerWindow::BNPManagerWindow(QWidget *parent)
setCentralWidget(hideWidget); setCentralWidget(hideWidget);
hideWidget->hide(); hideWidget->hide();
setAcceptDrops(true);
// Read the settings // Read the settings
readSettings(); readSettings();
@ -98,6 +109,12 @@ void BNPManagerWindow::createDialogs()
// *************************************************************************** // ***************************************************************************
void BNPManagerWindow::createActions() void BNPManagerWindow::createActions()
{ {
// new action
m_newAction = new QAction(tr("&New..."), this);
m_newAction->setIcon(QIcon(Core::Constants::ICON_NEW));
m_newAction->setStatusTip(tr("New file"));
connect(m_newAction, SIGNAL(triggered()), this, SLOT( newFile() ));
// open action // open action
m_openAction = new QAction(tr("&Open..."), this); m_openAction = new QAction(tr("&Open..."), this);
m_openAction->setIcon(QIcon(Core::Constants::ICON_OPEN)); m_openAction->setIcon(QIcon(Core::Constants::ICON_OPEN));
@ -132,6 +149,7 @@ void BNPManagerWindow::createActions()
void BNPManagerWindow::createToolBars() void BNPManagerWindow::createToolBars()
{ {
m_fileToolBar = addToolBar(tr("&File")); m_fileToolBar = addToolBar(tr("&File"));
m_fileToolBar->addAction(m_newAction);
m_fileToolBar->addAction(m_openAction); m_fileToolBar->addAction(m_openAction);
m_fileToolBar->addAction(m_closeAction); m_fileToolBar->addAction(m_closeAction);
@ -143,10 +161,36 @@ void BNPManagerWindow::createToolBars()
// *************************************************************************** // ***************************************************************************
bool BNPManagerWindow::loadFile(const QString fileName) bool BNPManagerWindow::loadFile(const QString fileName)
{ {
// Store the filename for later use
m_openedBNPFile = fileName;
m_BnpFileListDialog->loadTable(fileName); m_BnpFileListDialog->loadTable(fileName);
return true; return true;
} }
// *************************************************************************** // ***************************************************************************
void BNPManagerWindow::newFile()
{
// reference to the BNPFileHandle singletone instance
BNPFileHandle& myBNPFileHandle = BNPFileHandle::getInstance();
m_openedBNPFile = "";
m_BnpFileListDialog->clearTable();
QString filePath = QFileDialog::getSaveFileName(this, tr("Create File"),QDir::currentPath(),
tr("BNP File (*.bnp)"));
if (filePath.isEmpty() )
return;
if ( !filePath.endsWith(".bnp", Qt::CaseInsensitive) )
filePath.append(".bnp");
m_openedBNPFile = filePath;
m_BnpFileListDialog->setWindowTitle (filePath);
myBNPFileHandle.createFile ( filePath.toStdString() );
}
// ***************************************************************************
void BNPManagerWindow::open() void BNPManagerWindow::open()
{ {
QString fileName; QString fileName;
@ -158,13 +202,13 @@ void BNPManagerWindow::open()
if (fileName.isNull()) if (fileName.isNull())
return; return;
m_openedBNPFile = fileName;
loadFile(fileName); loadFile(fileName);
} }
// *************************************************************************** // ***************************************************************************
void BNPManagerWindow::close() void BNPManagerWindow::close()
{ {
//TODO m_openedBNPFile = "";
m_BnpFileListDialog->clearTable();
} }
// *************************************************************************** // ***************************************************************************
void BNPManagerWindow::addFiles() void BNPManagerWindow::addFiles()
@ -216,6 +260,49 @@ void BNPManagerWindow::addFiles()
loadFile(m_openedBNPFile); loadFile(m_openedBNPFile);
} }
// *************************************************************************** // ***************************************************************************
void BNPManagerWindow::addFiles( QStringList FileList )
{
// reference to the BNPFileHandle singletone instance
BNPFileHandle& myBNPFileHandle = BNPFileHandle::getInstance();
// vector of all current packed filenames
vector<string> currentFiles;
// vector of files to add
vector<string> addFiles;
// get all current filenames from the opened bnp file
myBNPFileHandle.fileNames(currentFiles);
QStringList::iterator it_list = FileList.begin();
while (it_list != FileList.end() )
{
string fileName = CFile::getFilename (it_list->toStdString() );
if ( std::find(currentFiles.begin(), currentFiles.end(), fileName ) != currentFiles.end() )
{
// Ask the user if he wants to override the existing file
// atm only warn the user and do not override
QMessageBox::warning(this, tr("BNP Manager"),
tr("File is already in the list!"),
QMessageBox::Ok,
QMessageBox::Ok);
}
else
{
addFiles.push_back( it_list->toStdString() );
// log it
nlinfo("Add file %s", fileName.c_str() );
}
it_list++;
}
if ( !addFiles.empty() )
{
myBNPFileHandle.addFiles( addFiles );
}
loadFile(m_openedBNPFile);
}
// ***************************************************************************
void BNPManagerWindow::deleteFiles() void BNPManagerWindow::deleteFiles()
{ {
QFileDialog filedialog(this); QFileDialog filedialog(this);
@ -288,4 +375,70 @@ void BNPManagerWindow::readSettings()
void BNPManagerWindow::writeSettings() void BNPManagerWindow::writeSettings()
{ {
} }
// ***************************************************************************
void BNPManagerWindow::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only one file
// In the future a tabbed FileListDialog would accept more
if ( event->mimeData()->hasUrls() )
event->acceptProposedAction();
}
// ***************************************************************************
void BNPManagerWindow::dropEvent(QDropEvent *event)
{
// reference to the BNPFileHandle singletone instance
BNPFileHandle& myBNPFileHandle = BNPFileHandle::getInstance();
// Excraft the local file url from the drop object and fill the table
const QMimeData *mimeData = event->mimeData();
QList<QUrl> urlList = mimeData->urls();
QString filePath;
QStringList fileList;
if ( urlList.count() == 1 )
{
// If it is a bnp file, open it
// If it is not a bnp file add it
filePath = urlList.first().toLocalFile();
if ( filePath.endsWith(".bnp", Qt::CaseInsensitive) )
{
loadFile(filePath);
}
else
{
if ( m_openedBNPFile == "")
newFile();
// Create a QStringList and pass it to addfiles
fileList.push_back( filePath );
addFiles( fileList );
// Reload current bnp
loadFile(m_openedBNPFile);
}
}
else if ( urlList.count() > 1 )
{
// Dont accept any bnp file
QList<QUrl>::iterator it = urlList.begin();
while ( it != urlList.end() )
{
filePath = it->toLocalFile();
if ( filePath.endsWith(".bnp") )
{
nlwarning("Could not add a bnp file!", filePath.toStdString().c_str() );
}
else
{
fileList.push_back( filePath );
}
++it;
}
if ( m_openedBNPFile == "")
newFile();
addFiles( fileList );
// Reload current bnp
loadFile(m_openedBNPFile);
}
}
} // namespace BNPManager } // namespace BNPManager

@ -59,9 +59,14 @@ public:
public Q_SLOTS: public Q_SLOTS:
/** /**
* Open a file dialog to choose which file should be opened. * Create a new file
* \return Filename string * \return Filename string
*/ */
void newFile();
/**
* Open a file dialog to choose which file should be opened.
*/
void open(); void open();
/** /**
@ -81,6 +86,7 @@ public Q_SLOTS:
* \param Filelist * \param Filelist
*/ */
void addFiles(); void addFiles();
void addFiles( QStringList FileList );
/** /**
* Unpack the files marked in the filelist dialog into user defined * Unpack the files marked in the filelist dialog into user defined
@ -96,6 +102,10 @@ public Q_SLOTS:
*/ */
void deleteFiles(); void deleteFiles();
protected:
void dragEnterEvent (QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
private: private:
/** /**
@ -126,6 +136,7 @@ private:
QToolBar *m_fileToolBar; QToolBar *m_fileToolBar;
QToolBar *m_toolsBar; QToolBar *m_toolsBar;
QAction *m_newAction;
QAction *m_openAction; QAction *m_openAction;
QAction *m_closeAction; QAction *m_closeAction;
QAction *m_addFilesAction; QAction *m_addFilesAction;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

@ -78,6 +78,18 @@ Core::IContext *ContextManager::context(const QString &id) const
return 0; return 0;
} }
void ContextManager::registerUndoStack(QUndoStack *stack)
{
nlassert(stack);
d->m_mainWindow->undoGroup()->addStack(stack);
}
void ContextManager::unregisterUndoStack(QUndoStack *stack)
{
nlassert(stack);
d->m_mainWindow->undoGroup()->removeStack(stack);
}
void ContextManager::activateContext(const QString &id) void ContextManager::activateContext(const QString &id)
{ {
const int index = indexOf(id); const int index = indexOf(id);
@ -85,6 +97,11 @@ void ContextManager::activateContext(const QString &id)
d->m_tabWidget->setCurrentIndex(index); d->m_tabWidget->setCurrentIndex(index);
} }
void ContextManager::updateCurrentContext()
{
d->m_mainWindow->updateContext(currentContext());
}
void ContextManager::objectAdded(QObject *obj) void ContextManager::objectAdded(QObject *obj)
{ {
IContext *context = qobject_cast<IContext *>(obj); IContext *context = qobject_cast<IContext *>(obj);

@ -26,6 +26,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTabWidget; class QTabWidget;
class QUndoStack;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core namespace Core
@ -45,12 +46,17 @@ public:
Core::IContext *currentContext() const; Core::IContext *currentContext() const;
Core::IContext *context(const QString &id) const; Core::IContext *context(const QString &id) const;
// temporary solution for multiple undo stacks per context
void registerUndoStack(QUndoStack *stack);
void unregisterUndoStack(QUndoStack *stack);
Q_SIGNALS: Q_SIGNALS:
// the default argument '=0' is important for connects without the oldContext argument. // the default argument '=0' is important for connects without the oldContext argument.
void currentContextChanged(Core::IContext *context, Core::IContext *oldContext = 0); void currentContextChanged(Core::IContext *context, Core::IContext *oldContext = 0);
public Q_SLOTS: public Q_SLOTS:
void activateContext(const QString &id); void activateContext(const QString &id);
void updateCurrentContext();
private Q_SLOTS: private Q_SLOTS:
void objectAdded(QObject *obj); void objectAdded(QObject *obj);

@ -92,7 +92,7 @@ const char *const SEARCH_PATHS = "SearchPaths";
const char *const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; const char *const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
const char *const LEVELDESIGN_PATH = "LevelDesignPath"; const char *const LEVELDESIGN_PATH = "LevelDesignPath";
const char *const PRIMITIVES_PATH = "PrimitivesPath"; const char *const PRIMITIVES_PATH = "PrimitivesPath";
const char * const ASSETS_PATH = "AssetsPath"; const char *const ASSETS_PATH = "AssetsPath";
const char *const LIGOCONFIG_FILE = "LigoConfigFile"; const char *const LIGOCONFIG_FILE = "LigoConfigFile";
const char *const REMAP_EXTENSIONS = "RemapExtensions"; const char *const REMAP_EXTENSIONS = "RemapExtensions";

@ -128,6 +128,11 @@ QSettings *MainWindow::settings() const
return m_settings; return m_settings;
} }
QUndoGroup *MainWindow::undoGroup() const
{
return m_undoGroup;
}
ExtensionSystem::IPluginManager *MainWindow::pluginManager() const ExtensionSystem::IPluginManager *MainWindow::pluginManager() const
{ {
return m_pluginManager; return m_pluginManager;
@ -135,12 +140,16 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const
void MainWindow::addContextObject(IContext *context) void MainWindow::addContextObject(IContext *context)
{ {
m_undoGroup->addStack(context->undoStack()); QUndoStack *stack = context->undoStack();
if (stack)
m_undoGroup->addStack(stack);
} }
void MainWindow::removeContextObject(IContext *context) void MainWindow::removeContextObject(IContext *context)
{ {
m_undoGroup->removeStack(context->undoStack()); QUndoStack *stack = context->undoStack();
if (stack)
m_undoGroup->removeStack(stack);
} }
void MainWindow::open() void MainWindow::open()

@ -52,6 +52,7 @@ public:
MenuManager *menuManager() const; MenuManager *menuManager() const;
ContextManager *contextManager() const; ContextManager *contextManager() const;
QSettings *settings() const; QSettings *settings() const;
QUndoGroup *undoGroup() const;
ExtensionSystem::IPluginManager *pluginManager() const; ExtensionSystem::IPluginManager *pluginManager() const;
@ -62,6 +63,7 @@ public Q_SLOTS:
bool showOptionsDialog(const QString &group = QString(), bool showOptionsDialog(const QString &group = QString(),
const QString &page = QString(), const QString &page = QString(),
QWidget *parent = 0); QWidget *parent = 0);
void updateContext(Core::IContext *context);
private Q_SLOTS: private Q_SLOTS:
void open(); void open();
@ -77,7 +79,6 @@ private Q_SLOTS:
void gotoPos(); void gotoPos();
void setFullScreen(bool enabled); void setFullScreen(bool enabled);
void about(); void about();
void updateContext(Core::IContext *context);
protected: protected:
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);

@ -1878,6 +1878,8 @@ void CCharacterCL::updateVisualPropertyPvpClan(const NLMISC::TGameCycle &/* game
{ {
_LeagueId = uint32(prop); _LeagueId = uint32(prop);
buildInSceneInterface();
if (isUser()) if (isUser())
{ {
uint i; uint i;

@ -2571,7 +2571,9 @@ class CAHAddShape : public IActionHandler
skel.setPos(CVector((float)x, (float)y, (float)z)); skel.setPos(CVector((float)x, (float)y, (float)z));
skel.setRotQuat(dir.getRot()); skel.setRotQuat(dir.getRot());
} }
} else { }
else
{
instance.setScale(instance.getScale()*s); instance.setScale(instance.getScale()*s);
instance.setPos(CVector((float)x, (float)y, (float)z)); instance.setPos(CVector((float)x, (float)y, (float)z));
instance.setRotQuat(dir.getRot()); instance.setRotQuat(dir.getRot());
@ -3168,7 +3170,6 @@ class CHandlerGameConfigFullscreen : public IActionHandler
// hide frequencies combo // hide frequencies combo
pCB= dynamic_cast<CDBGroupComboBox*>(pIM->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); pCB= dynamic_cast<CDBGroupComboBox*>(pIM->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO ));
if (pCB) pCB->setActive(false); if (pCB) pCB->setActive(false);
} }
// **** dirt the apply button of the DDX // **** dirt the apply button of the DDX

@ -361,7 +361,6 @@ void CGroupHTML::checkDownloads()
CFile::moveFile(file.c_str(), (file+".tmp").c_str()); CFile::moveFile(file.c_str(), (file+".tmp").c_str());
if (lookupLocalFile (finalUrl, file.c_str(), false)) if (lookupLocalFile (finalUrl, file.c_str(), false))
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->executeLuaScript(it->luaScript, true); pIM->executeLuaScript(it->luaScript, true);
} }

@ -4392,7 +4392,7 @@ bool CEditor::doLuaScript(const char *filename, const char *fileDescText)
return false; return false;
} }
if( 0 && FINAL_VERSION == 1) // deactivated for the moment because there are lua file that must be loaded from example if( 0 && FINAL_VERSION == 1) // disabled for the moment because there are lua file that must be loaded from example
{ {
const static std::string path = "data_common.bnp@"; const static std::string path = "data_common.bnp@";
const static std::string::size_type len= path.size(); const static std::string::size_type len= path.size();

@ -1,6 +1,18 @@
/** \file deployment_configuration.cpp // 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/>.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// include // include

@ -1,8 +1,18 @@
/** \file deployment_configuration.h // 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 DEPLOYMENT_CONFIGURATION_H #ifndef DEPLOYMENT_CONFIGURATION_H
#define DEPLOYMENT_CONFIGURATION_H #define DEPLOYMENT_CONFIGURATION_H

@ -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

@ -34,7 +34,7 @@ ADD_SUBDIRECTORY(patchman_service)
#ADD_SUBDIRECTORY(ags_test) #ADD_SUBDIRECTORY(ags_test)
#ADD_SUBDIRECTORY(ai_data_service) #ADD_SUBDIRECTORY(ai_data_service)
#ADD_SUBDIRECTORY(entity_view_service) #ADD_SUBDIRECTORY(entity_view_service)
#ADD_SUBDIRECTORY(general_utilities_service) ADD_SUBDIRECTORY(general_utilities_service)
# Not sure, no longer used maybe? # Not sure, no longer used maybe?
#sabrina #sabrina

@ -11,9 +11,120 @@ LIST(REMOVE_ITEM SRC
${CMAKE_CURRENT_SOURCE_DIR}/re_repository_emitter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/re_repository_emitter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.h ${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.h
${CMAKE_CURRENT_SOURCE_DIR}/rr_repository_reciever.cpp) ${CMAKE_CURRENT_SOURCE_DIR}/rr_repository_reciever.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mfc/*)
ADD_EXECUTABLE(ryzom_general_utilities_service ${SRC})
SOURCE_GROUP("Documentation" FILES ss_notes.txt
ce_notes.txt
ec_notes.txt
ee_notes.txt
em_notes.txt
merge_notes.txt
gus_module_notes.txt
gus_net_notes.txt
saves_notes.txt
rs_notes.txt
rsaves_notes.txt
stats_notes.txt
server control module notes.txt)
SOURCE_GROUP("GUS Modules\\Contest Control (CC)" FILES cc_commands.cpp cc_contest_ctrl_script.cpp cc_contest_ctrl_script.h cc_module_messages.h)
SOURCE_GROUP("GUS Modules\\Contest Executor (CE)" FILES ce_commands.cpp ce_contest_executor.cpp ce_module_messages.h ce_contest_executor.h)
SOURCE_GROUP("GUS Modules\\Contest Logger (CL)" FILES cl_contest_logger.cpp cl_module_messages.h)
SOURCE_GROUP("GUS Modules\\Event Chat (EC)" FILES ec_channel.cpp
ec_channel.h
ec_ctrl_channel.cpp
ec_ctrl_channel.h
ec_event_chat.cpp
ec_event_chat_module.cpp
ec_event_chat_module.h
ec_faction_channel.cpp
ec_faction_channel.h
ec_party_channel.cpp
ec_party_channel.h
ec_types.h)
SOURCE_GROUP("GUS Modules\\Event Executor (EE)" FILES ee_event_executor.cpp ee_event_executor.h ee_module_messages.h)
SOURCE_GROUP("GUS Modules\\Event Executor (EE)" FILES em_commands.cpp em_event_manager.cpp em_event_manager.h em_module_messages.h)
SOURCE_GROUP("GUS Modules\\Shard Merge (MERGE)" FILES merge_commands.cpp merge_shard_merger.cpp)
SOURCE_GROUP("GUS Modules\\Remote Saves (RSAVES)" FILES remote_saves_interface.cpp remote_saves_interface.h rs_remote_saves.cpp rs_remote_saves.h rs_module_messages.h)
SOURCE_GROUP("GUS Modules\\Shard Saves (SAVES)" FILES saves_module_messages.h saves_shard_saves.cpp saves_unit.cpp saves_unit.h)
SOURCE_GROUP("GUS Modules\\Shard Script (SS)" FILES ss_command_executor.cpp
ss_command_executor.h
ss_script_manager.cpp
ss_commands.cpp
ss_script_manager.h
ss_service_comms_manager.cpp
ss_service_comms_manager.h
ss_state_manager.cpp
ss_state_manager.h)
SOURCE_GROUP("GUS Modules\\Stats Scan (STATS)" FILES stats_guild_commands.cpp
stats_guild_scan_job.cpp
stats_guild_scan_job.h
stat_character.cpp
stat_character.h
stat_character_scan_job.cpp
stat_character_scan_job.h
stat_char_commands.cpp
stat_char_filter_factory.cpp
stat_char_filter_factory.h
stat_char_info_extractor_factory.cpp
stat_char_info_extractor_factory.h
stat_char_scan_script.cpp
stat_char_scan_script.h
stat_file_list_builder_factory.cpp
stat_file_list_builder_factory.h
stat_globals.cpp stat_globals.h
stat_guild_container.cp
stat_guild_container.h
stat_job_manager.cpp
stat_job_manager.h
stat_user_char_filters.cpp
stat_user_char_info_extractors.cpp
stat_user_file_list_builders.cpp)
SOURCE_GROUP("GUS Modules\\GUS Networking" FILES gus_net.cpp
gus_net.h
gus_net_commands.cpp
gus_net_connection.cpp
gus_net_connection.h
gus_net_hub.cpp
gus_net_hub.h
gus_net_implementation.cpp
gus_net_implementation.h
gus_net_messages.cpp
gus_net_messages.h
gus_net_remote_module.cpp
gus_net_remote_module.h
gus_net_types.h)
SOURCE_GROUP("GUS Modules" FILES gus_module.cpp gus_module.h gus_module_commands.cpp gus_module_factory.cpp gus_module_factory.h gus_module_manager.cpp gus_module_manager.h)
SOURCE_GROUP("GUS Core" FILES gus_chat.cpp
gus_chat.h
gus_client_manager.cpp
gus_client_manager.h
gus_mirror.cpp
gus_mirror.h
gus_text.cpp
gus_text.h
gus_utils.cpp
gus_utils.h
gus_util_commands.cpp)
ADD_EXECUTABLE(ryzom_general_utilities_service WIN32 ${SRC})
INCLUDE_DIRECTORIES(${RZ_SERVER_SRC_DIR} ${LIBXML2_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${NEL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${RZ_SERVER_SRC_DIR} ${LIBXML2_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${NEL_INCLUDE_DIR})
@ -26,7 +137,7 @@ TARGET_LINK_LIBRARIES(ryzom_general_utilities_service
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
nelmisc nelmisc
nelnet nelnet
nelgeorges} nelgeorges
nelligo) nelligo)
NL_DEFAULT_PROPS(ryzom_general_utilities_service "Ryzom, Services: General Utilities Service (GUS)") NL_DEFAULT_PROPS(ryzom_general_utilities_service "Ryzom, Services: General Utilities Service (GUS)")

@ -312,7 +312,8 @@ NLMISC_CATEGORISED_COMMAND(EventManager,emUpdateTools,"update tools installed on
// Extra commands that open MFC windows // Extra commands that open MFC windows
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifdef _WINDOWS //#ifdef _WINDOWS
#if 0
#include "mfc/stdafx.h" #include "mfc/stdafx.h"
#include "nel/misc/win_displayer.h" #include "nel/misc/win_displayer.h"

@ -358,7 +358,7 @@ void CEventManagerImplementation::displayModule() const
for (TShards::const_iterator it=_Shards.begin(); it!=_Shards.end(); ++it) for (TShards::const_iterator it=_Shards.begin(); it!=_Shards.end(); ++it)
{ {
CSString s= (*it).first+ ": "; CSString s= (*it).first+ ": ";
for (TShardsMapEntry::iterator it2= (*it).second.begin(); it2!=(*it).second.end(); ++it2) for (TShardsMapEntry::const_iterator it2= (*it).second.begin(); it2!=(*it).second.end(); ++it2)
{ {
s+= NLMISC::toString((*it2))+" "; s+= NLMISC::toString((*it2))+" ";
} }
@ -478,7 +478,7 @@ void CEventManagerImplementation::startEvent(const NLMISC::CSString& shardName)
// build vector of destinations to send the module message to // build vector of destinations to send the module message to
TModuleIdVector moduleIds; TModuleIdVector moduleIds;
for (TShardsMapEntry::iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it) for (TShardsMapEntry::const_iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
{ {
nlinfo("Sending event start request to event executor: %d",(*it)); nlinfo("Sending event start request to event executor: %d",(*it));
moduleIds.push_back(*it); moduleIds.push_back(*it);
@ -502,7 +502,7 @@ void CEventManagerImplementation::stopEvent(const NLMISC::CSString& shardName)
// build vector of destinations to send the module message to // build vector of destinations to send the module message to
TModuleIdVector moduleIds; TModuleIdVector moduleIds;
for (TShardsMapEntry::iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it) for (TShardsMapEntry::const_iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
{ {
nlinfo("Sending event stop request to event executor: %d",(*it)); nlinfo("Sending event stop request to event executor: %d",(*it));
moduleIds.push_back(*it); moduleIds.push_back(*it);
@ -569,7 +569,7 @@ void CEventManagerImplementation::peekInstalledEvent(const NLMISC::CSString& sha
// build vector of destinations to send the module message to // build vector of destinations to send the module message to
TModuleIdVector moduleIds; TModuleIdVector moduleIds;
for (TShardsMapEntry::iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it) for (TShardsMapEntry::const_iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
{ {
nlinfo("Sending history request to event executor: %d",(*it)); nlinfo("Sending history request to event executor: %d",(*it));
moduleIds.push_back(*it); moduleIds.push_back(*it);

@ -45,74 +45,6 @@ using namespace NLNET;
namespace GUS namespace GUS
{ {
//-----------------------------------------------------------------------------
// cleanPath - convert a path to standardised format
//-----------------------------------------------------------------------------
CSString cleanPath(const CSString& path,bool addTrailingSlash)
{
CSString result;
// split the path up into its component elements
CVectorSString pathComponents;
path.unquoteIfQuoted().splitByOneOfSeparators("/\\",pathComponents,false,false,true,false,true);
// iterate over path components collapsing '.' and '..' entries
for (uint32 i=0;i<pathComponents.size();++i)
{
// skip "." entries
if (pathComponents[i]==".")
{
pathComponents[i].clear();
continue;
}
// deal with ".."
if (pathComponents[i]=="..")
{
// run back through our component list looking for an element to remove
uint32 j;
for (j=i;j--;)
{
if (!pathComponents[j].empty())
break;
}
// if we found an element then remove it and the '..' as well
if (j!=~0u)
{
pathComponents[j].clear();
pathComponents[i].clear();
}
continue;
}
}
// treat the special case where oriinal path started with a '/' or '//'
if (path.left(1)=="/" || path.left(1)=="\\")
{
result= (path.left(2).right(1)=="/" || path.left(2).right(1)=="\\")? "//": "/";
}
// concatenate the path bits
for (uint32 i=0;i<pathComponents.size();++i)
{
if (!pathComponents[i].empty())
{
result+= pathComponents[i];
result+= '/';
}
}
// if we're not supposed to have a trailing slash then get rid of the one that's added by default
if (addTrailingSlash==false && path.right(1)!='/' && path.right(1)!='\\')
{
result.resize(result.size()-1);
}
return result;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// private routines for layer 5 service tracking // private routines for layer 5 service tracking
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

@ -39,27 +39,6 @@ namespace GUS
// handy utilities // handy utilities
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Clean a path performing the following operations:
// - convert '\\' characters to '/'
// - replace '//' strings in the middle of the path with '/'
// - remove '.' directory entries
// - colapse '..' directory entries (removing parent entries)
// - append a final '/' (optionally)
//
// examples:
// - a:/bcd/efg/ => a:/bcd/efg/ (no change)
// - a:\bcd\efg => a:/bcd/efg/
// - \bcd\\efg => /bcd/efg/
// - \\bcd\efg => //bcd/efg/
// - \bcd\.\efg => /bcd/efg/
// - \bcd\..\efg => /efg/
// - bcd\..\efg => efg/
// - bcd\..\..\efg => ../efg/
// - \bcd\..\..\efg => /efg/ (NOTE: the redundant '..' entry is lost due to leading '\')
//
NLMISC::CSString cleanPath(const NLMISC::CSString& path,bool addTrailingSlash);
// execute a command on a remote service // execute a command on a remote service
void executeRemoteCommand(NLNET::TServiceId sid,const NLMISC::CSString& cmdLine); void executeRemoteCommand(NLNET::TServiceId sid,const NLMISC::CSString& cmdLine);
void executeRemoteCommand(const char* serviceName,const NLMISC::CSString& cmdLine); void executeRemoteCommand(const char* serviceName,const NLMISC::CSString& cmdLine);

@ -28,11 +28,15 @@
#include "game_share/ryzom_version.h" #include "game_share/ryzom_version.h"
#include "game_share/tick_event_handler.h" #include "game_share/tick_event_handler.h"
#include "game_share/singleton_registry.h" #include "game_share/singleton_registry.h"
#include "game_share/handy_commands.h" #include "server_share/handy_commands.h"
// local // local
#include "service_main.h" #include "service_main.h"
#ifdef NL_OS_WINDOWS
# define NOMINMAX
# include <windows.h>
#endif // NL_OS_WINDOWS
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// namespaces // namespaces

@ -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…
Cancel
Save