mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +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
|
||||
/* Copyright (C) NAVER <http://www.navercorp.com> */
|
||||
|
||||
/**
|
||||
* adminAdminController class
|
||||
* admin controller class of admin module
|
||||
* @author NAVER (developers@xpressengine.com)
|
||||
* @package /modules/admin
|
||||
* @version 0.1
|
||||
* Preserved for backward compatibility
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class AdminAdminController extends Admin
|
||||
{
|
||||
/**
|
||||
* initialization
|
||||
* @return void
|
||||
* Initialization
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
// forbit access if the user is not an administrator
|
||||
if (!$this->user->isAdmin())
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted('admin.msg_is_not_administrator');
|
||||
|
|
@ -24,335 +19,102 @@ class AdminAdminController extends Admin
|
|||
}
|
||||
|
||||
/**
|
||||
* Admin menu reset
|
||||
* @return void
|
||||
* Remove an icon.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminMenuReset()
|
||||
public function procAdminRemoveIcons()
|
||||
{
|
||||
$oMenuAdminModel = getAdminModel('menu');
|
||||
$oMenuAdminController = getAdminController('menu');
|
||||
for ($i = 0; $i < 100; $i++)
|
||||
$site_info = Context::get('site_module_info');
|
||||
$icon_name = Rhymix\Framework\Filters\FilenameFilter::clean(Context::get('iconname'));
|
||||
if (Rhymix\Modules\Admin\Models\Icon::deleteIcon($site_info->domain_srl, $icon_name))
|
||||
{
|
||||
$output = $oMenuAdminModel->getMenuByTitle($this->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;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
$this->setMessage('success_deleted');
|
||||
}
|
||||
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->{$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;
|
||||
throw new Exception('fail_to_delete');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin logo delete
|
||||
* @return void
|
||||
* Delete the admin logo.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminDeleteLogo()
|
||||
{
|
||||
$oModuleModel = getModel('module');
|
||||
$oAdminConfig = $oModuleModel->getModuleConfig('admin');
|
||||
$config = ModuleModel::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);
|
||||
unset($oAdminConfig->adminLogo);
|
||||
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->insertModuleConfig('admin', $oAdminConfig);
|
||||
|
||||
$this->setMessage('success_deleted', 'info');
|
||||
ModuleController::getInstance()->insertModuleConfig('admin', $config);
|
||||
$this->setMessage('success_deleted');
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminSetup');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove admin icon
|
||||
* @return object|void
|
||||
* Aliases for backward compatibility.
|
||||
*/
|
||||
public function procAdminRemoveIcons()
|
||||
public function procAdminInsertDefaultDesignInfo()
|
||||
{
|
||||
$site_info = Context::get('site_module_info');
|
||||
$virtual_site = '';
|
||||
if($site_info->site_srl)
|
||||
{
|
||||
$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');
|
||||
$vars = Context::getRequestVars();
|
||||
Rhymix\Modules\Admin\Controllers\Design::getInstance()->updateDefaultDesignInfo($vars);
|
||||
$this->setRedirectUrl(Context::get('error_return_url'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update FTP configuration.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
public function updateDefaultDesignInfo($vars)
|
||||
{
|
||||
return Rhymix\Modules\Admin\Controllers\Design::getInstance()->updateDefaultDesignInfo($vars);
|
||||
}
|
||||
|
||||
public function makeDefaultDesignFile($designInfo)
|
||||
{
|
||||
return Rhymix\Modules\Admin\Controllers\Design::getInstance()->makeDefaultDesignFile($designInfo);
|
||||
}
|
||||
|
||||
public function procAdminUpdateFTPInfo()
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove FTP configuration.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminRemoveFTPInfo()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return new BaseObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert favorite.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminRecompileCacheFile()
|
||||
{
|
||||
return Rhymix\Modules\Admin\Controllers\CacheReset::getInstance()->procAdminRecompileCacheFile();
|
||||
}
|
||||
|
||||
public function _insertFavorite($site_srl, $module, $type = 'module')
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::insertFavorite($module, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete favorite.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function _deleteFavorite($favoriteSrl)
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::deleteFavorite($favoriteSrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all favorites.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function _deleteAllFavorite()
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::deleteAllFavorites();
|
||||
}
|
||||
|
||||
public function cleanFavorite()
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::deleteInvalidFavorites();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/* Copyright (C) NAVER <http://www.navercorp.com> */
|
||||
|
||||
/**
|
||||
* adminAdminView class
|
||||
* Admin view class of admin module
|
||||
*
|
||||
* @author NAVER (developers@xpressengine.com)
|
||||
* @package /modules/admin
|
||||
* @version 0.1
|
||||
* Preserved for backward compatibility
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class AdminAdminView extends Admin
|
||||
{
|
||||
|
|
@ -30,17 +26,4 @@ class AdminAdminView extends Admin
|
|||
{
|
||||
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="dispAdminConfigSitelock" class="Controllers\SystemConfig\SiteLock" menu_name="adminConfigurationGeneral" />
|
||||
<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 -->
|
||||
<action name="dispAdminSetup" type="view" menu_name="adminMenuSetup" menu_index="true" />
|
||||
<action name="procAdminDeleteLogo" type="controller" />
|
||||
<action name="procAdminMenuReset" type="controller" />
|
||||
<action name="dispAdminSetup" class="Controllers\AdminMenu" menu_name="adminMenuSetup" menu_index="true" />
|
||||
<action name="procAdminMenuReset" class="Controllers\AdminMenu" />
|
||||
<action name="procAdminToggleFavorite" class="Controllers\AdminMenu" />
|
||||
<!-- Design Config -->
|
||||
<action name="procAdminInsertDefaultDesignInfo" class="Controllers\Design" />
|
||||
<!-- Legacy API -->
|
||||
<action name="dispAdminConfigFtp" type="view" menu_name="adminConfigurationFtp" menu_index="true" />
|
||||
<action name="procAdminUpdateFTPInfo" type="controller" />
|
||||
<action name="procAdminRemoveFTPInfo" type="controller" />
|
||||
<action name="procAdminEnviromentGatheringAgreement" type="controller" />
|
||||
<action name="procAdminUpdateConfig" type="controller" />
|
||||
<action name="procAdminRemoveIcons" type="controller" />
|
||||
<action name="procAdminDeleteLogo" type="controller" />
|
||||
<action name="getSiteAllList" type="model" permission="root" />
|
||||
</actions>
|
||||
<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 ModuleModel;
|
||||
use Rhymix\Framework\Storage;
|
||||
use Rhymix\Framework\Helpers\DBResultHelper;
|
||||
|
||||
class Favorite
|
||||
|
|
@ -14,7 +15,7 @@ class Favorite
|
|||
* @param bool $add_module_info
|
||||
* @return BaseObject
|
||||
*/
|
||||
public static function getFavorites($add_module_info = false)
|
||||
public static function getFavorites(bool $add_module_info = false): BaseObject
|
||||
{
|
||||
$output = executeQueryArray('admin.getFavoriteList', []);
|
||||
if (!$output->toBool())
|
||||
|
|
@ -47,7 +48,7 @@ class Favorite
|
|||
* @param string $module
|
||||
* @return BaseObject
|
||||
*/
|
||||
public static function isFavorite($module)
|
||||
public static function isFavorite(string $module): BaseObject
|
||||
{
|
||||
$output = executeQuery('admin.getFavorite', ['module' => $module]);
|
||||
if(!$output->toBool())
|
||||
|
|
@ -111,4 +112,42 @@ class Favorite
|
|||
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