mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 09:32:15 +09:00
Move remainder of usable actions to respective controller classes
This commit is contained in:
parent
01b408fb6b
commit
7f0753454f
7 changed files with 310 additions and 330 deletions
|
|
@ -1,22 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
/* Copyright (C) NAVER <http://www.navercorp.com> */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adminAdminController class
|
* Preserved for backward compatibility
|
||||||
* admin controller class of admin module
|
*
|
||||||
* @author NAVER (developers@xpressengine.com)
|
* @deprecated
|
||||||
* @package /modules/admin
|
|
||||||
* @version 0.1
|
|
||||||
*/
|
*/
|
||||||
class AdminAdminController extends Admin
|
class AdminAdminController extends Admin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* initialization
|
* Initialization
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
// forbit access if the user is not an administrator
|
|
||||||
if (!$this->user->isAdmin())
|
if (!$this->user->isAdmin())
|
||||||
{
|
{
|
||||||
throw new Rhymix\Framework\Exceptions\NotPermitted('admin.msg_is_not_administrator');
|
throw new Rhymix\Framework\Exceptions\NotPermitted('admin.msg_is_not_administrator');
|
||||||
|
|
@ -24,335 +19,102 @@ class AdminAdminController extends Admin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin menu reset
|
* Remove an icon.
|
||||||
* @return void
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function procAdminMenuReset()
|
public function procAdminRemoveIcons()
|
||||||
{
|
{
|
||||||
$oMenuAdminModel = getAdminModel('menu');
|
$site_info = Context::get('site_module_info');
|
||||||
$oMenuAdminController = getAdminController('menu');
|
$icon_name = Rhymix\Framework\Filters\FilenameFilter::clean(Context::get('iconname'));
|
||||||
for ($i = 0; $i < 100; $i++)
|
if (Rhymix\Modules\Admin\Models\Icon::deleteIcon($site_info->domain_srl, $icon_name))
|
||||||
{
|
{
|
||||||
$output = $oMenuAdminModel->getMenuByTitle($this->getAdminMenuName());
|
$this->setMessage('success_deleted');
|
||||||
$admin_menu_srl = $output->menu_srl ?? 0;
|
|
||||||
if ($admin_menu_srl)
|
|
||||||
{
|
|
||||||
$output = $oMenuAdminController->deleteMenu($admin_menu_srl);
|
|
||||||
if (!$output->toBool())
|
|
||||||
{
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rhymix\Framework\Cache::delete('admin_menu_langs:' . Context::getLangType());
|
|
||||||
Rhymix\Framework\Storage::deleteDirectory(\RX_BASEDIR . 'files/cache/menu/admin_lang/');
|
|
||||||
|
|
||||||
$this->setRedirectUrl(Context::get('error_return_url'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function procAdminInsertDefaultDesignInfo()
|
|
||||||
{
|
|
||||||
$vars = Context::getRequestVars();
|
|
||||||
|
|
||||||
// create a DesignInfo file
|
|
||||||
$this->updateDefaultDesignInfo($vars);
|
|
||||||
$this->setRedirectUrl(Context::get('error_return_url'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateDefaultDesignInfo($vars)
|
|
||||||
{
|
|
||||||
$siteDesignPath = RX_BASEDIR . 'files/site_design/';
|
|
||||||
|
|
||||||
$vars->module_skin = json_decode($vars->module_skin);
|
|
||||||
|
|
||||||
if(!is_dir($siteDesignPath))
|
|
||||||
{
|
|
||||||
FileHandler::makeDir($siteDesignPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
$siteDesignFile = RX_BASEDIR . 'files/site_design/design_0.php';
|
|
||||||
|
|
||||||
$layoutTarget = 'layout_srl';
|
|
||||||
$skinTarget = 'skin';
|
|
||||||
|
|
||||||
if($vars->target_type == 'M')
|
|
||||||
{
|
|
||||||
$layoutTarget = 'mlayout_srl';
|
|
||||||
$skinTarget = 'mskin';
|
|
||||||
}
|
|
||||||
|
|
||||||
if(is_readable($siteDesignFile))
|
|
||||||
{
|
|
||||||
include($siteDesignFile);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$designInfo = new stdClass();
|
throw new Exception('fail_to_delete');
|
||||||
}
|
|
||||||
|
|
||||||
$layoutSrl = (!$vars->layout_srl) ? 0 : $vars->layout_srl;
|
|
||||||
|
|
||||||
$designInfo->{$layoutTarget} = $layoutSrl;
|
|
||||||
|
|
||||||
foreach($vars->module_skin as $moduleName => $skinName)
|
|
||||||
{
|
|
||||||
if($moduleName == 'ARTICLE')
|
|
||||||
{
|
|
||||||
$moduleName = 'page';
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($designInfo->module->{$moduleName})) $designInfo->module->{$moduleName} = new stdClass();
|
|
||||||
$designInfo->module->{$moduleName}->{$skinTarget} = $skinName;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->makeDefaultDesignFile($designInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function makeDefaultDesignFile($designInfo)
|
|
||||||
{
|
|
||||||
$buff = array();
|
|
||||||
$buff[] = '<?php if(!defined("__XE__")) exit();';
|
|
||||||
$buff[] = '$designInfo = new stdClass;';
|
|
||||||
|
|
||||||
if($designInfo->layout_srl)
|
|
||||||
{
|
|
||||||
$buff[] = sprintf('$designInfo->layout_srl = %s; ', var_export(intval($designInfo->layout_srl), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
if($designInfo->mlayout_srl)
|
|
||||||
{
|
|
||||||
$buff[] = sprintf('$designInfo->mlayout_srl = %s;', var_export(intval($designInfo->mlayout_srl), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
$buff[] = '$designInfo->module = new stdClass;';
|
|
||||||
|
|
||||||
foreach($designInfo->module as $moduleName => $skinInfo)
|
|
||||||
{
|
|
||||||
$buff[] = sprintf('$designInfo->module->{%s} = new stdClass;', var_export(strval($moduleName), true));
|
|
||||||
foreach($skinInfo as $target => $skinName)
|
|
||||||
{
|
|
||||||
$buff[] = sprintf('$designInfo->module->{%s}->{%s} = %s;', var_export(strval($moduleName), true), var_export(strval($target), true), var_export(strval($skinName), true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$siteDesignFile = RX_BASEDIR . 'files/site_design/design_0.php';
|
|
||||||
FileHandler::writeFile($siteDesignFile, implode(PHP_EOL, $buff));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggle favorite
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function procAdminToggleFavorite()
|
|
||||||
{
|
|
||||||
$moduleName = Context::get('module_name');
|
|
||||||
|
|
||||||
// check favorite exists
|
|
||||||
$output = Rhymix\Modules\Admin\Models\Favorite::isFavorite($moduleName);
|
|
||||||
if(!$output->toBool())
|
|
||||||
{
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if exists, delete favorite
|
|
||||||
if($output->get('result'))
|
|
||||||
{
|
|
||||||
$favoriteSrl = $output->get('favoriteSrl');
|
|
||||||
$output = $this->_deleteFavorite($favoriteSrl);
|
|
||||||
$result = 'off';
|
|
||||||
}
|
|
||||||
// if not exists, insert favorite
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$output = $this->_insertFavorite(0, $moduleName);
|
|
||||||
$result = 'on';
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$output->toBool())
|
|
||||||
{
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->add('result', $result);
|
|
||||||
|
|
||||||
return $this->setRedirectUrl(Context::get('error_return_url'), $output);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleanning favorite
|
|
||||||
* @return object|void
|
|
||||||
*/
|
|
||||||
public function cleanFavorite()
|
|
||||||
{
|
|
||||||
$output = Rhymix\Modules\Admin\Models\Favorite::getFavorites();
|
|
||||||
if(!$output->toBool())
|
|
||||||
{
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
$favoriteList = $output->get('favoriteList');
|
|
||||||
if(!$favoriteList)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$deleteTargets = array();
|
|
||||||
foreach($favoriteList as $favorite)
|
|
||||||
{
|
|
||||||
if($favorite->type == 'module')
|
|
||||||
{
|
|
||||||
$modulePath = RX_BASEDIR . 'modules/' . $favorite->module;
|
|
||||||
if(!is_dir($modulePath))
|
|
||||||
{
|
|
||||||
$deleteTargets[] = $favorite->admin_favorite_srl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!count($deleteTargets))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = new stdClass();
|
|
||||||
$args->admin_favorite_srls = $deleteTargets;
|
|
||||||
$output = executeQuery('admin.deleteFavorites', $args);
|
|
||||||
if(!$output->toBool())
|
|
||||||
{
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin logo delete
|
* Delete the admin logo.
|
||||||
* @return void
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function procAdminDeleteLogo()
|
public function procAdminDeleteLogo()
|
||||||
{
|
{
|
||||||
$oModuleModel = getModel('module');
|
$config = ModuleModel::getModuleConfig('admin');
|
||||||
$oAdminConfig = $oModuleModel->getModuleConfig('admin');
|
if (!empty($config->adminLogo))
|
||||||
|
{
|
||||||
|
Rhymix\Framework\Storage::delete(RX_BASEDIR . $config->adminLogo);
|
||||||
|
unset($config->adminLogo);
|
||||||
|
}
|
||||||
|
|
||||||
Rhymix\Framework\Storage::delete(RX_BASEDIR . $oAdminConfig->adminLogo);
|
ModuleController::getInstance()->insertModuleConfig('admin', $config);
|
||||||
unset($oAdminConfig->adminLogo);
|
$this->setMessage('success_deleted');
|
||||||
|
|
||||||
$oModuleController = getController('module');
|
|
||||||
$oModuleController->insertModuleConfig('admin', $oAdminConfig);
|
|
||||||
|
|
||||||
$this->setMessage('success_deleted', 'info');
|
|
||||||
|
|
||||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminSetup');
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminSetup');
|
||||||
$this->setRedirectUrl($returnUrl);
|
$this->setRedirectUrl($returnUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove admin icon
|
* Aliases for backward compatibility.
|
||||||
* @return object|void
|
|
||||||
*/
|
*/
|
||||||
public function procAdminRemoveIcons()
|
public function procAdminInsertDefaultDesignInfo()
|
||||||
{
|
{
|
||||||
$site_info = Context::get('site_module_info');
|
$vars = Context::getRequestVars();
|
||||||
$virtual_site = '';
|
Rhymix\Modules\Admin\Controllers\Design::getInstance()->updateDefaultDesignInfo($vars);
|
||||||
if($site_info->site_srl)
|
$this->setRedirectUrl(Context::get('error_return_url'));
|
||||||
{
|
|
||||||
$virtual_site = $site_info->site_srl . '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
$iconname = Context::get('iconname');
|
|
||||||
$file_exist = FileHandler::readFile(RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . $iconname);
|
|
||||||
if($file_exist)
|
|
||||||
{
|
|
||||||
@Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . $iconname);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception('fail_to_delete');
|
|
||||||
}
|
|
||||||
$this->setMessage('success_deleted');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function updateDefaultDesignInfo($vars)
|
||||||
* Update FTP configuration.
|
{
|
||||||
*
|
return Rhymix\Modules\Admin\Controllers\Design::getInstance()->updateDefaultDesignInfo($vars);
|
||||||
* @deprecated
|
}
|
||||||
*/
|
|
||||||
|
public function makeDefaultDesignFile($designInfo)
|
||||||
|
{
|
||||||
|
return Rhymix\Modules\Admin\Controllers\Design::getInstance()->makeDefaultDesignFile($designInfo);
|
||||||
|
}
|
||||||
|
|
||||||
public function procAdminUpdateFTPInfo()
|
public function procAdminUpdateFTPInfo()
|
||||||
{
|
{
|
||||||
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove FTP configuration.
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function procAdminRemoveFTPInfo()
|
public function procAdminRemoveFTPInfo()
|
||||||
{
|
{
|
||||||
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enviroment gathering agreement
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function procAdminEnviromentGatheringAgreement()
|
|
||||||
{
|
|
||||||
$redirectUrl = getNotEncodedUrl('', 'module', 'admin');
|
|
||||||
$this->setRedirectUrl($redirectUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset cache
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function procAdminRecompileCacheFile()
|
|
||||||
{
|
|
||||||
return Rhymix\Modules\Admin\Controllers\CacheReset::getInstance()->procAdminRecompileCacheFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update admin module config
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function procAdminUpdateConfig()
|
public function procAdminUpdateConfig()
|
||||||
{
|
{
|
||||||
return new BaseObject;
|
return new BaseObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function procAdminRecompileCacheFile()
|
||||||
* Insert favorite.
|
{
|
||||||
*
|
return Rhymix\Modules\Admin\Controllers\CacheReset::getInstance()->procAdminRecompileCacheFile();
|
||||||
* @deprecated
|
}
|
||||||
*/
|
|
||||||
public function _insertFavorite($site_srl, $module, $type = 'module')
|
public function _insertFavorite($site_srl, $module, $type = 'module')
|
||||||
{
|
{
|
||||||
return Rhymix\Modules\Admin\Models\Favorite::insertFavorite($module, $type);
|
return Rhymix\Modules\Admin\Models\Favorite::insertFavorite($module, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete favorite.
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function _deleteFavorite($favoriteSrl)
|
public function _deleteFavorite($favoriteSrl)
|
||||||
{
|
{
|
||||||
return Rhymix\Modules\Admin\Models\Favorite::deleteFavorite($favoriteSrl);
|
return Rhymix\Modules\Admin\Models\Favorite::deleteFavorite($favoriteSrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all favorites.
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function _deleteAllFavorite()
|
public function _deleteAllFavorite()
|
||||||
{
|
{
|
||||||
return Rhymix\Modules\Admin\Models\Favorite::deleteAllFavorites();
|
return Rhymix\Modules\Admin\Models\Favorite::deleteAllFavorites();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cleanFavorite()
|
||||||
|
{
|
||||||
|
return Rhymix\Modules\Admin\Models\Favorite::deleteInvalidFavorites();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
/* Copyright (C) NAVER <http://www.navercorp.com> */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adminAdminView class
|
* Preserved for backward compatibility
|
||||||
* Admin view class of admin module
|
*
|
||||||
*
|
* @deprecated
|
||||||
* @author NAVER (developers@xpressengine.com)
|
|
||||||
* @package /modules/admin
|
|
||||||
* @version 0.1
|
|
||||||
*/
|
*/
|
||||||
class AdminAdminView extends Admin
|
class AdminAdminView extends Admin
|
||||||
{
|
{
|
||||||
|
|
@ -30,17 +26,4 @@ class AdminAdminView extends Admin
|
||||||
{
|
{
|
||||||
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display Admin Menu Configuration(settings) page
|
|
||||||
*/
|
|
||||||
public function dispAdminSetup()
|
|
||||||
{
|
|
||||||
$oMenuAdminModel = getAdminModel('menu');
|
|
||||||
$output = $oMenuAdminModel->getMenuByTitle($this->getAdminMenuName());
|
|
||||||
|
|
||||||
Context::set('menu_srl', $output->menu_srl);
|
|
||||||
Context::set('menu_title', $output->title);
|
|
||||||
$this->setTemplateFile('admin_setup');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,22 +31,19 @@
|
||||||
<action name="procAdminUpdateSEO" class="Controllers\SystemConfig\SEO" />
|
<action name="procAdminUpdateSEO" class="Controllers\SystemConfig\SEO" />
|
||||||
<action name="dispAdminConfigSitelock" class="Controllers\SystemConfig\SiteLock" menu_name="adminConfigurationGeneral" />
|
<action name="dispAdminConfigSitelock" class="Controllers\SystemConfig\SiteLock" menu_name="adminConfigurationGeneral" />
|
||||||
<action name="procAdminUpdateSitelock" class="Controllers\SystemConfig\SiteLock" />
|
<action name="procAdminUpdateSitelock" class="Controllers\SystemConfig\SiteLock" />
|
||||||
|
|
||||||
<action name="procAdminRemoveIcons" type="controller" />
|
|
||||||
<action name="procAdminRecompileCacheFile" type="controller" />
|
|
||||||
<action name="procAdminInsertDefaultDesignInfo" type="controller" />
|
|
||||||
<action name="procAdminToggleFavorite" type="controller" />
|
|
||||||
<action name="procAdminFaviconUpload" type="controller" />
|
|
||||||
<!-- Admin Interface Config -->
|
<!-- Admin Interface Config -->
|
||||||
<action name="dispAdminSetup" type="view" menu_name="adminMenuSetup" menu_index="true" />
|
<action name="dispAdminSetup" class="Controllers\AdminMenu" menu_name="adminMenuSetup" menu_index="true" />
|
||||||
<action name="procAdminDeleteLogo" type="controller" />
|
<action name="procAdminMenuReset" class="Controllers\AdminMenu" />
|
||||||
<action name="procAdminMenuReset" type="controller" />
|
<action name="procAdminToggleFavorite" class="Controllers\AdminMenu" />
|
||||||
|
<!-- Design Config -->
|
||||||
|
<action name="procAdminInsertDefaultDesignInfo" class="Controllers\Design" />
|
||||||
<!-- Legacy API -->
|
<!-- Legacy API -->
|
||||||
<action name="dispAdminConfigFtp" type="view" menu_name="adminConfigurationFtp" menu_index="true" />
|
<action name="dispAdminConfigFtp" type="view" menu_name="adminConfigurationFtp" menu_index="true" />
|
||||||
<action name="procAdminUpdateFTPInfo" type="controller" />
|
<action name="procAdminUpdateFTPInfo" type="controller" />
|
||||||
<action name="procAdminRemoveFTPInfo" type="controller" />
|
<action name="procAdminRemoveFTPInfo" type="controller" />
|
||||||
<action name="procAdminEnviromentGatheringAgreement" type="controller" />
|
|
||||||
<action name="procAdminUpdateConfig" type="controller" />
|
<action name="procAdminUpdateConfig" type="controller" />
|
||||||
|
<action name="procAdminRemoveIcons" type="controller" />
|
||||||
|
<action name="procAdminDeleteLogo" type="controller" />
|
||||||
<action name="getSiteAllList" type="model" permission="root" />
|
<action name="getSiteAllList" type="model" permission="root" />
|
||||||
</actions>
|
</actions>
|
||||||
<menus>
|
<menus>
|
||||||
|
|
|
||||||
95
modules/admin/controllers/AdminMenu.php
Normal file
95
modules/admin/controllers/AdminMenu.php
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rhymix\Modules\Admin\Controllers;
|
||||||
|
|
||||||
|
use Context;
|
||||||
|
use MenuAdminController;
|
||||||
|
use MenuAdminModel;
|
||||||
|
use Rhymix\Framework\Cache;
|
||||||
|
use Rhymix\Framework\Storage;
|
||||||
|
use Rhymix\Modules\Admin\Models\AdminMenu as AdminMenuModel;
|
||||||
|
use Rhymix\Modules\Admin\Models\Favorite as FavoriteModel;
|
||||||
|
|
||||||
|
class AdminMenu extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display Admin Menu configuration page.
|
||||||
|
*/
|
||||||
|
public function dispAdminSetup()
|
||||||
|
{
|
||||||
|
$oMenuAdminModel = MenuAdminModel::getInstance();
|
||||||
|
$output = $oMenuAdminModel->getMenuByTitle(AdminMenuModel::getAdminMenuName());
|
||||||
|
|
||||||
|
Context::set('menu_srl', $output->menu_srl);
|
||||||
|
Context::set('menu_title', $output->title);
|
||||||
|
|
||||||
|
$this->setTemplateFile('admin_setup');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the admin menu to the default configuration.
|
||||||
|
*/
|
||||||
|
public function procAdminMenuReset()
|
||||||
|
{
|
||||||
|
$oMenuAdminController = MenuAdminController::getInstance();
|
||||||
|
$oMenuAdminModel = MenuAdminModel::getInstance();
|
||||||
|
for ($i = 0; $i < 100; $i++)
|
||||||
|
{
|
||||||
|
$output = $oMenuAdminModel->getMenuByTitle(AdminMenuModel::getAdminMenuName());
|
||||||
|
$admin_menu_srl = $output->menu_srl ?? 0;
|
||||||
|
if ($admin_menu_srl)
|
||||||
|
{
|
||||||
|
$output = $oMenuAdminController->deleteMenu($admin_menu_srl);
|
||||||
|
if (!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache::delete('admin_menu_langs:' . Context::getLangType());
|
||||||
|
Storage::deleteDirectory(\RX_BASEDIR . 'files/cache/menu/admin_lang/');
|
||||||
|
|
||||||
|
$this->setRedirectUrl(Context::get('error_return_url'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert or delete a module as favorite.
|
||||||
|
*/
|
||||||
|
public function procAdminToggleFavorite()
|
||||||
|
{
|
||||||
|
// Check if favorite exists.
|
||||||
|
$module_name = Context::get('module_name');
|
||||||
|
$output = FavoriteModel::isFavorite($module_name);
|
||||||
|
if(!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert or delete.
|
||||||
|
if($output->get('result') && $output->get('favoriteSrl'))
|
||||||
|
{
|
||||||
|
$favorite_srl = $output->get('favoriteSrl');
|
||||||
|
$output = FavoriteModel::deleteFavorite($favorite_srl);
|
||||||
|
$result = 'off';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output = FavoriteModel::insertFavorite($module_name);
|
||||||
|
$result = 'on';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->add('result', $result);
|
||||||
|
|
||||||
|
return $this->setRedirectUrl(Context::get('error_return_url'), $output);
|
||||||
|
}
|
||||||
|
}
|
||||||
114
modules/admin/controllers/Design.php
Normal file
114
modules/admin/controllers/Design.php
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rhymix\Modules\Admin\Controllers;
|
||||||
|
|
||||||
|
use Context;
|
||||||
|
use FileHandler;
|
||||||
|
use Rhymix\Framework\DB;
|
||||||
|
|
||||||
|
class Design extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Save the default design configuration.
|
||||||
|
*/
|
||||||
|
public function procAdminInsertDefaultDesignInfo()
|
||||||
|
{
|
||||||
|
$vars = Context::getRequestVars();
|
||||||
|
$this->updateDefaultDesignInfo($vars);
|
||||||
|
$this->setRedirectUrl(Context::get('error_return_url'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subroutine for the above.
|
||||||
|
*
|
||||||
|
* @param object $vars
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function updateDefaultDesignInfo(object $vars): void
|
||||||
|
{
|
||||||
|
$vars->module_skin = json_decode($vars->module_skin);
|
||||||
|
|
||||||
|
$siteDesignPath = \RX_BASEDIR . 'files/site_design/';
|
||||||
|
if (!is_dir($siteDesignPath))
|
||||||
|
{
|
||||||
|
FileHandler::makeDir($siteDesignPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$siteDesignFile = \RX_BASEDIR . 'files/site_design/design_0.php';
|
||||||
|
$layoutTarget = 'layout_srl';
|
||||||
|
$skinTarget = 'skin';
|
||||||
|
if ($vars->target_type == 'M')
|
||||||
|
{
|
||||||
|
$layoutTarget = 'mlayout_srl';
|
||||||
|
$skinTarget = 'mskin';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_readable($siteDesignFile))
|
||||||
|
{
|
||||||
|
include $siteDesignFile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$designInfo = new \stdClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
$layoutSrl = (!$vars->layout_srl) ? 0 : $vars->layout_srl;
|
||||||
|
$designInfo->{$layoutTarget} = $layoutSrl;
|
||||||
|
|
||||||
|
foreach ($vars->module_skin as $moduleName => $skinName)
|
||||||
|
{
|
||||||
|
if ($moduleName == 'ARTICLE')
|
||||||
|
{
|
||||||
|
$moduleName = 'page';
|
||||||
|
}
|
||||||
|
if (!isset($designInfo->module))
|
||||||
|
{
|
||||||
|
$designInfo->module = new \stdClass;
|
||||||
|
}
|
||||||
|
if (!isset($designInfo->module->{$moduleName}))
|
||||||
|
{
|
||||||
|
$designInfo->module->{$moduleName} = new \stdClass;
|
||||||
|
}
|
||||||
|
$designInfo->module->{$moduleName}->{$skinTarget} = $skinName;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->makeDefaultDesignFile($designInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subroutine for the above;
|
||||||
|
*
|
||||||
|
* @param object $designInfo
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function makeDefaultDesignFile(object $designInfo): void
|
||||||
|
{
|
||||||
|
$buff = array();
|
||||||
|
$buff[] = '<?php if(!defined("__XE__")) exit();';
|
||||||
|
$buff[] = '$designInfo = new stdClass;';
|
||||||
|
|
||||||
|
if($designInfo->layout_srl)
|
||||||
|
{
|
||||||
|
$buff[] = sprintf('$designInfo->layout_srl = %d; ', intval($designInfo->layout_srl));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($designInfo->mlayout_srl)
|
||||||
|
{
|
||||||
|
$buff[] = sprintf('$designInfo->mlayout_srl = %d;', intval($designInfo->mlayout_srl));
|
||||||
|
}
|
||||||
|
|
||||||
|
$buff[] = '$designInfo->module = new stdClass;';
|
||||||
|
|
||||||
|
foreach($designInfo->module as $moduleName => $skinInfo)
|
||||||
|
{
|
||||||
|
$buff[] = sprintf('$designInfo->module->{%s} = new stdClass;', var_export(strval($moduleName), true));
|
||||||
|
foreach($skinInfo as $target => $skinName)
|
||||||
|
{
|
||||||
|
$buff[] = sprintf('$designInfo->module->{%s}->{%s} = %s;', var_export(strval($moduleName), true), var_export(strval($target), true), var_export(strval($skinName), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$siteDesignFile = \RX_BASEDIR . 'files/site_design/design_0.php';
|
||||||
|
FileHandler::writeFile($siteDesignFile, implode(\PHP_EOL, $buff));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Rhymix\Modules\Admin\Controllers;
|
|
||||||
|
|
||||||
use Rhymix\Framework\DB;
|
|
||||||
|
|
||||||
class Update extends Base
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Rhymix\Modules\Admin\Models;
|
||||||
|
|
||||||
use BaseObject;
|
use BaseObject;
|
||||||
use ModuleModel;
|
use ModuleModel;
|
||||||
|
use Rhymix\Framework\Storage;
|
||||||
use Rhymix\Framework\Helpers\DBResultHelper;
|
use Rhymix\Framework\Helpers\DBResultHelper;
|
||||||
|
|
||||||
class Favorite
|
class Favorite
|
||||||
|
|
@ -14,7 +15,7 @@ class Favorite
|
||||||
* @param bool $add_module_info
|
* @param bool $add_module_info
|
||||||
* @return BaseObject
|
* @return BaseObject
|
||||||
*/
|
*/
|
||||||
public static function getFavorites($add_module_info = false)
|
public static function getFavorites(bool $add_module_info = false): BaseObject
|
||||||
{
|
{
|
||||||
$output = executeQueryArray('admin.getFavoriteList', []);
|
$output = executeQueryArray('admin.getFavoriteList', []);
|
||||||
if (!$output->toBool())
|
if (!$output->toBool())
|
||||||
|
|
@ -47,7 +48,7 @@ class Favorite
|
||||||
* @param string $module
|
* @param string $module
|
||||||
* @return BaseObject
|
* @return BaseObject
|
||||||
*/
|
*/
|
||||||
public static function isFavorite($module)
|
public static function isFavorite(string $module): BaseObject
|
||||||
{
|
{
|
||||||
$output = executeQuery('admin.getFavorite', ['module' => $module]);
|
$output = executeQuery('admin.getFavorite', ['module' => $module]);
|
||||||
if(!$output->toBool())
|
if(!$output->toBool())
|
||||||
|
|
@ -111,4 +112,42 @@ class Favorite
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all favorites that don't point to an existing module.
|
||||||
|
*
|
||||||
|
* @return BaseObject
|
||||||
|
*/
|
||||||
|
public static function deleteInvalidFavorites(): BaseObject
|
||||||
|
{
|
||||||
|
$output = self::getFavorites();
|
||||||
|
if (!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$favorites = $output->get('favoriteList');
|
||||||
|
if (!$favorites)
|
||||||
|
{
|
||||||
|
return new BaseObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
$delete_favorite_srls = array();
|
||||||
|
foreach ($favorites as $favorite)
|
||||||
|
{
|
||||||
|
if ($favorite->type === 'module' && !Storage::isDirectory(\RX_BASEDIR . 'modules/' . $favorite->module))
|
||||||
|
{
|
||||||
|
$delete_favorite_srls[] = $favorite->admin_favorite_srl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !count($delete_favorite_srls))
|
||||||
|
{
|
||||||
|
return new BaseObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
$args = new \stdClass;
|
||||||
|
$args->admin_favorite_srls = $delete_favorite_srls;
|
||||||
|
$output = executeQuery('admin.deleteFavorites', $args);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue