mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Рефакторинг категорий и дополнительных полей
This commit is contained in:
parent
018e2a2d36
commit
4950b92c5a
|
@ -1,19 +1,23 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LiveStreet CMS
|
||||
* Copyright © 2013 OOO "ЛС-СОФТ"
|
||||
*
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreetcms.com
|
||||
* Contact e-mail: office@livestreetcms.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* @link http://www.livestreetcms.com
|
||||
* @copyright 2013 OOO "ЛС-СОФТ"
|
||||
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Обработка блока с редактированием категорий объекта
|
||||
|
@ -28,30 +32,35 @@ class BlockCategoryUpdate extends Block {
|
|||
public function Exec() {
|
||||
$sEntity = $this->GetParam('entity');
|
||||
$oTarget = $this->GetParam('target');
|
||||
$sTargetType = $this->GetParam('target_type');
|
||||
|
||||
if (!$oTarget) {
|
||||
$oTarget=Engine::GetEntity($sEntity);
|
||||
}
|
||||
|
||||
if ($oTarget) {
|
||||
$aBehaviors=$oTarget->GetBehaviors();
|
||||
foreach($aBehaviors as $oBehavior) {
|
||||
if ($oBehavior instanceof ModuleCategory_BehaviorEntity) {
|
||||
/**
|
||||
* Нужное нам поведение - получаем список текущих категорий
|
||||
*/
|
||||
$this->Viewer_Assign('categoriesSelected', $oBehavior->getCategories(), true);
|
||||
/**
|
||||
* Загружаем параметры
|
||||
*/
|
||||
$aParams=$oBehavior->getParams();
|
||||
$this->Viewer_Assign('params', $aParams, true);
|
||||
/**
|
||||
* Загружаем список доступных категорий
|
||||
*/
|
||||
$this->Viewer_Assign('categories', $this->Category_GetCategoriesTreeByTargetType($aParams['target_type']), true);
|
||||
break;
|
||||
$aBehaviors=$oTarget->GetBehaviors();
|
||||
foreach($aBehaviors as $oBehavior) {
|
||||
if ($oBehavior instanceof ModuleCategory_BehaviorEntity) {
|
||||
/**
|
||||
* Если в параметрах был тип, то переопределяем значение. Это необходимо для корректной работы, когда тип динамический.
|
||||
*/
|
||||
if ($sTargetType) {
|
||||
$oBehavior->setParam('target_type',$sTargetType);
|
||||
}
|
||||
/**
|
||||
* Нужное нам поведение - получаем список текущих категорий
|
||||
*/
|
||||
$this->Viewer_Assign('categoriesSelected', $oBehavior->getCategories(), true);
|
||||
/**
|
||||
* Загружаем параметры
|
||||
*/
|
||||
$aParams=$oBehavior->getParams();
|
||||
$this->Viewer_Assign('params', $aParams, true);
|
||||
/**
|
||||
* Загружаем список доступных категорий
|
||||
*/
|
||||
$this->Viewer_Assign('categories', $this->Category_GetCategoriesTreeByTargetType($oBehavior->getCategoryTargetType()), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,59 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LiveStreet CMS
|
||||
* Copyright © 2013 OOO "ЛС-СОФТ"
|
||||
*
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreetcms.com
|
||||
* Contact e-mail: office@livestreetcms.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* @link http://www.livestreetcms.com
|
||||
* @copyright 2013 OOO "ЛС-СОФТ"
|
||||
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Обработка блока с редактированием свойств объекта
|
||||
*
|
||||
* @package blocks
|
||||
* @since 1.0
|
||||
* @since 2.0
|
||||
*/
|
||||
class BlockPropertyUpdate extends Block {
|
||||
/**
|
||||
* Запуск обработки
|
||||
*/
|
||||
public function Exec() {
|
||||
$sTargetType=$this->GetParam('target_type');
|
||||
$iTargetId=$this->GetParam('target_id');
|
||||
/**
|
||||
* Получаем набор свойств
|
||||
*/
|
||||
$aProperties=$this->Property_GetPropertiesForUpdate($sTargetType,$iTargetId);
|
||||
$this->Viewer_Assign('aProperties',$aProperties);
|
||||
$sEntity = $this->GetParam('entity');
|
||||
$oTarget = $this->GetParam('target');
|
||||
$sTargetType = $this->GetParam('target_type');
|
||||
|
||||
if (!$oTarget) {
|
||||
$oTarget=Engine::GetEntity($sEntity);
|
||||
}
|
||||
|
||||
$aBehaviors=$oTarget->GetBehaviors();
|
||||
foreach($aBehaviors as $oBehavior) {
|
||||
/**
|
||||
* Определяем нужное нам поведение
|
||||
*/
|
||||
if ($oBehavior instanceof ModuleProperty_BehaviorEntity) {
|
||||
/**
|
||||
* Если в параметрах был тип, то переопределяем значение. Это необходимо для корректной работы, когда тип динамический.
|
||||
*/
|
||||
if ($sTargetType) {
|
||||
$oBehavior->setParam('target_type',$sTargetType);
|
||||
}
|
||||
$aProperties = $this->Property_GetPropertiesForUpdate($oBehavior->getPropertyTargetType(),$oTarget->getId());
|
||||
$this->Viewer_Assign('aProperties',$aProperties);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
class ModuleProperty_BehaviorPropertyEntity extends Behavior {
|
||||
class ModuleProperty_BehaviorEntity extends Behavior {
|
||||
/**
|
||||
* Дефолтные параметры
|
||||
*
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
class ModuleProperty_BehaviorPropertyModule extends Behavior {
|
||||
class ModuleProperty_BehaviorModule extends Behavior {
|
||||
/**
|
||||
* Список хуков
|
||||
*
|
|
@ -37,7 +37,7 @@ class ModuleTopic_EntityTopic extends Entity {
|
|||
/**
|
||||
* Дополнительные поля
|
||||
*/
|
||||
'property'=>'ModuleProperty_BehaviorPropertyEntity',
|
||||
'property'=>'ModuleProperty_BehaviorEntity',
|
||||
);
|
||||
/**
|
||||
* Определяем правила валидации
|
||||
|
|
|
@ -82,13 +82,8 @@
|
|||
|
||||
|
||||
{* Показывает дополнительные поля *}
|
||||
{$params = [ 'target_type' => 'topic_'|cat:$type->getCode() ] }
|
||||
{insert name="block" block="propertyUpdate" params=[ 'target' => $topic, 'entity' => 'ModuleTopic_EntityTopic', 'target_type' => 'topic_'|cat:$type->getCode() ]}
|
||||
|
||||
{if $topic}
|
||||
{$params.target_id = $topic->getId()}
|
||||
{/if}
|
||||
|
||||
{insert name="block" block="propertyUpdate" params=$params}
|
||||
|
||||
|
||||
{* Вставка опросов *}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 466bc844b776fc3ab761f113036c2c2d75f6f081
|
||||
Subproject commit 11045a0b006c92c34dd8dc42b9bd9257e7274480
|
Loading…
Reference in a new issue