maison_alexandra/www/system-brs-core/sys/sysTranslationsPub/sysTranslationsPub.php

80 lines
3.0 KiB
PHP

<?php
namespace BRSystems\Core\Sys\sysTranslationsPub;
use BRSystems\Core\Library\cJSON\cJSON;
use BRSystems\Core\Sys\sysTranslationsPub\inc\sysTranslationsPubController;
use BRSystems\Core\Sys\sysTranslationsPub\inc\sysTranslationsPubManager;
class sysTranslationsPub
{
public $DIR;
public $uriData;
public $controller;
public function __construct($uriData)
{
$this->uriData = $uriData;
$this->DIR = __DIR__ ?: dirname(__FILE__);
$this->controller = new sysTranslationsPubController($this->uriData, $this->DIR, basename($this->DIR));
}
public function run()
{
switch (getV('action')) {
case 'edit':
$this->controller->run(true);
break;
case 'filter_table':
cJSON::sendOk($this->controller->createCmsTable(getP('page'), getP('filter'), getP('headers')));
break;
case 'selfLoad':
cJSON::sendOk($this->controller->editCmsTableRecord(getV('id')));
break;
case 'selfSave':
if(getV('id')){
if($this->controller->oUser->chkPermission('SYS_PUB_TRANSLATIONS_EDIT', false, false)){
cJSON::sendOk($this->controller->saveRecordData(getV('id'), getP('fields')));
}else{
cJSON::sendError();
}
}else{
if($this->controller->oUser->chkPermission('SYS_PUB_TRANSLATIONS_ADD_NEW', false, false)){
cJSON::sendOk($this->controller->saveRecordData(getV('id'), getP('fields')));
}else{
cJSON::sendError();
}
}
break;
case 'deleteRecords':
if($this->controller->oUser->chkPermission('SYS_PUB_TRANSLATIONS_DELETE')){
cJSON::sendOk($this->controller->delete(getP('fields')));
}
break;
case 'clearAll':
if($this->controller->oUser->chkPermission('SYS_PUB_TRANSLATIONS_DELETE_ALL')){
cJSON::sendOk($this->controller->clearAll());
}
break;
case 'cleanupAll':
if($this->controller->oUser->chkPermission('SYS_PUB_TRANSLATIONS_DELETE_ALL')){
cJSON::sendOk($this->controller->cleanupAll());
}
break;
case 'fileExport':
cJSON::sendOk($this->controller->saveExcelDoc());
break;
case 'importData':
$manager = new sysTranslationsPubManager($this->controller);
cJSON::sendOk($manager->importDocDataFromFile(getV('file')));
break;
case 'dl':
cJSON::sendOk($this->controller->downloadFile(getV('file'), '/temp_export_msg/' . date('Y-m') . '/'));
break;
default:
$this->controller->run();
break;
}
}
}