ElixirVault/www/system-brs-core/sys/sysSiteMap/sysSiteMap.php

148 lines
6.3 KiB
PHP

<?php
namespace BRSystems\Core\Sys\sysSiteMap;
use BRSystems\Core\Library\cJSON\cJSON;
use BRSystems\Core\Sys\sysSiteMap\inc\sysSiteMapController;
/**
* sysSiteMap
*
* @category sysSiteMap
* @author Aivars Žukovskis <mareks.keiss@brsystems.lv>
* @since Version 2.0
*/
class sysSiteMap
{
public $DIR;
public $uriData;
public $controller;
/**
* Class constructor
*/
public function __construct($uriData)
{
$this->uriData = $uriData;
$this->DIR = __DIR__ ? __DIR__ : dirname(__FILE__);
$this->controller = new sysSiteMapController($this->uriData, $this->DIR, basename($this->DIR));
}
/**
* Default function to run
* Skip if other callback defined
*/
public function run()
{
$action = getV('action');
if ($action) {
switch ($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 'cloneBlank':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_ADD_NEW'))
cJSON::sendOk($this->controller->cloneBlank(getV('id')));
break;
case 'selfSave':
if(getV('id')){
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT', false, false)){
cJSON::sendOk($this->controller->saveRecordData(getV('fields')));
}else{
cJSON::sendError();
}
}else{
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_ADD_NEW', false, false)){
cJSON::sendOk($this->controller->saveRecordData(getV('fields')));
}else{
cJSON::sendError();
}
}
break;
case 'deleteRecords':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_DELETE')){
cJSON::sendOk($this->controller->delete(getP('fields')));
}
break;
case 'changeRecordsStatus':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT')){
cJSON::sendOk($this->controller->changeEnumFields(getP('baseField'), getP('fields')));
}
break;
case 'getParentsByLanguageId':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT')){
cJSON::sendOk($this->controller->getParentsByLanguageId(getV('data')));
}
break;
case 'getModules':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT'))
cJSON::sendOk($this->controller->getModules(getV('id'), getV('language'), getV('reload')));
break;
case 'getPermissions':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT'))
cJSON::sendOk($this->controller->getPermissions());
break;
case 'getMenus':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT'))
cJSON::sendOk($this->controller->getMenus());
break;
case 'getPageUsedModules':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT'))
cJSON::sendOk($this->controller->getPageUsedModules(getV('id'), getV('data')));
break;
case 'cache':
if($this->controller->oUser->chkPermission(($this->controller->PUB_SIDE? 'CMS_APP_' : 'SYS_') . 'SITE_MAP_EDIT'))
cJSON::sendOk(array('data' => $this->controller->treeCacheActions(getP('data'))));
break;
case 'changeAdministrationFolder':
if($this->controller->oUser->chkPermission('SYS_SITE_MAP_ADMIN_FOLDER_CHANGE'))
cJSON::sendOk($this->controller->changeAdministrationFolder(getV("val")));
break;
case 'getAllUnusedSiteMapModules':
cJSON::sendOk($this->controller->getAllSiteMapUnusedModules());
break;
case 'deleteUnusedModules':
cJSON::sendOk($this->controller->deleteUnusedModules(getV("data")));
break;
case 'iDeleteTempTables':
cJSON::sendOk($this->controller->deleteTemporaryDbTableData());
break;
case 'generateInsertSql':
cJSON::sendOk($this->controller->generateInsertSql(getV('ids')));
break;
case 'generateSiteMapXML':
cJSON::sendOk($this->controller->generateSiteMapXML());
break;
case 'gatherIds':
cJSON::sendOk($this->controller->gatherIds());
break;
default:
$this->controller->run();
break;
}
}else{
$this->controller->run();
}
}
/**
*
* Divide site map PUB and CMS
*
*/
public function pubSideCmsAction(){
$this->controller->PUB_SIDE = true;
$this->run();
}
}