-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
366 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<?php | ||
|
||
/* | ||
* LiveStreet CMS | ||
* Copyright © 2018 OOO "ЛС-СОФТ" | ||
* | ||
* ------------------------------------------------------ | ||
* | ||
* Official site: www.livestreetcms.com | ||
* Contact e-mail: [email protected] | ||
* | ||
* 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 Oleg Demodov <[email protected]> | ||
* | ||
*/ | ||
|
||
/** | ||
* Редактирование меню | ||
* | ||
* @author oleg | ||
*/ | ||
class PluginAdmin_ActionAdmin_EventMenu extends Event{ | ||
|
||
public function EventList() { | ||
$oMenu = $this->Menu_GetMenuByFilter(['name' => $this->GetParam(0)]); | ||
if(!$oMenu){ | ||
return $this->EventNotFound(); | ||
} | ||
|
||
$aItems = $this->Menu_LoadTreeOfItem([ | ||
'menu_id' => $oMenu->getId(), | ||
'#order' => array('priority' => 'desc') | ||
]); | ||
|
||
$aItems = ModuleORM::buildTree($aItems); | ||
|
||
$this->Viewer_Assign('aItems', $aItems); | ||
$this->Viewer_Assign('oMenu', $oMenu); | ||
|
||
$this->SetTemplateAction('menu/list'); | ||
} | ||
|
||
public function EventItemCreate() | ||
{ | ||
$oMenu = $this->Menu_GetMenuByFilter(['name' => $this->GetParam(0)]); | ||
if(!$oMenu){ | ||
return $this->EventNotFound(); | ||
} | ||
|
||
if (getRequest('item_submit')) { | ||
$this->Security_ValidateSendForm(); | ||
|
||
$oItem = Engine::GetEntity('ModuleMenu_EntityItem'); | ||
$oItem->_setDataSafe(getRequest('item')); | ||
|
||
$oItem->setMenuId($oMenu->getId()); | ||
|
||
if ($oItem->_Validate()) { | ||
$oItem->setTitle(htmlspecialchars($oItem->getTitle())); | ||
|
||
if ($oItem->Add()) { | ||
$this->Message_AddNotice('Добавление прошло успешно', $this->Lang_Get('common.attention'), true); | ||
Router::LocationAction("admin/menu/" . $oMenu->getName()); | ||
} else { | ||
$this->Message_AddError('Возникла ошибка при добавлении', $this->Lang_Get('common.error.error')); | ||
} | ||
} else { | ||
$this->Message_AddError($oItem->_getValidateError(), $this->Lang_Get('common.error.error')); | ||
} | ||
} | ||
/** | ||
* Получаем список пупнктов для данного меню | ||
*/ | ||
$aItems = $this->Menu_LoadTreeOfItem([ | ||
'menu_id' => $oMenu->getId(), | ||
'#order' => array('priority' => 'desc') | ||
]); | ||
|
||
$aItems = ModuleORM::buildTree($aItems); | ||
|
||
$this->Viewer_Assign('aItems', $aItems); | ||
$this->Viewer_Assign('oMenu', $oMenu); | ||
$this->SetTemplateAction('menu/create'); | ||
} | ||
|
||
public function EventCategoryUpdate() | ||
{ | ||
$oMenu = $this->Menu_GetMenuByFilter(['name' => $this->GetParam(0)]); | ||
if(!$oMenu){ | ||
return $this->EventNotFound(); | ||
} | ||
if (!($oItem = $this->Menu_GetItemById($this->GetParam(2)))) { | ||
return $this->EventNotFound(); | ||
} | ||
|
||
/** | ||
* Получаем список пупнктов для данного меню | ||
*/ | ||
$aItems = $this->Menu_LoadTreeOfItem([ | ||
'menu_id' => $oMenu->getId(), | ||
'#order' => array('priority' => 'desc') | ||
]); | ||
|
||
$aItems = ModuleORM::buildTree($aItems); | ||
|
||
if (getRequest('item_submit')) { | ||
$this->Security_ValidateSendForm(); | ||
$oItem->_setDataSafe(getRequest('item')); | ||
|
||
if ($oItem->_Validate()) { | ||
$oItem->setTitle(htmlspecialchars($oItem->getTitle())); | ||
|
||
if ($oItem->Save()) { | ||
$this->Message_AddNotice('Сохранение прошло успешно', $this->Lang_Get('common.attention'), true); | ||
Router::LocationAction("admin/menu/" . $oMenu->getName()); | ||
} else { | ||
$this->Message_AddError('Возникла ошибка при сохранении', $this->Lang_Get('common.error.error')); | ||
} | ||
} else { | ||
$this->Message_AddError($oItem->_getValidateError(), $this->Lang_Get('common.error.error')); | ||
} | ||
} else { | ||
$_REQUEST['item'] = array( | ||
'pid' => $oItem->getPid(), | ||
'title' => htmlspecialchars_decode($oItem->getTitle()), | ||
'name' => $oItem->getName(), | ||
'url' => $oItem->getUrl(), | ||
'priority' => $oItem->getPriority(), | ||
'enable' => $oItem->getEnable(), | ||
'active' => $oItem->getActive(), | ||
); | ||
} | ||
|
||
$this->Viewer_Assign('oItem', $oItem); | ||
$this->Viewer_Assign('aItems', $aItems); | ||
$this->Viewer_Assign('oMenu', $oMenu); | ||
$this->SetTemplateAction('menu/create'); | ||
} | ||
|
||
public function EventCategoryRemove() | ||
{ | ||
$oMenu = $this->Menu_GetMenuByFilter(['name' => $this->GetParam(0)]); | ||
if(!$oMenu){ | ||
return $this->EventNotFound(); | ||
} | ||
if (!($oItem = $this->Menu_GetItemById($this->GetParam(2)))) { | ||
return $this->EventNotFound(); | ||
} | ||
|
||
/** | ||
* Удаляем | ||
*/ | ||
if ($oItem->Delete()) { | ||
$this->Message_AddNotice('Удаление прошло успешно', null, true); | ||
} else { | ||
$this->Message_AddError('Возникла ошибка при удалении', null, true); | ||
} | ||
|
||
Router::LocationAction("admin/menu/{$oMenu->getName()}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* LiveStreet CMS | ||
* Copyright © 2018 OOO "ЛС-СОФТ" | ||
* | ||
* ------------------------------------------------------ | ||
* | ||
* Official site: www.livestreetcms.com | ||
* Contact e-mail: [email protected] | ||
* | ||
* 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 Oleg Demodov <[email protected]> | ||
* | ||
*/ | ||
|
||
/** | ||
* Description of HookMenu | ||
* | ||
* @author oleg | ||
*/ | ||
class PluginAdmin_HookMenu extends Hook { | ||
|
||
public function RegisterHook() { | ||
$this->AddHook('init_admin_menu', 'InitActionAdmin'); | ||
} | ||
|
||
public function InitActionAdmin() { | ||
|
||
$aMenus = $this->Menu_GetMenuItemsAll(); | ||
$oSection = Engine::GetEntity('PluginAdmin_Ui_MenuSection')->SetCaption('Меню')->SetName('menu')->SetUrl('menu')->setIcon('bars'); | ||
foreach ($aMenus as $oMenu) { | ||
$oSection->AddItem(Engine::GetEntity('PluginAdmin_Ui_MenuItem')->SetCaption(htmlspecialchars($oMenu->getTitle()))->SetUrl($oMenu->getName())); | ||
} | ||
|
||
$oMenu = $this->PluginAdmin_Ui_GetMenuMain(); | ||
$oMenu->AddSection($oSection); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "p-menus", | ||
"version": "1.0.0", | ||
"templates": { | ||
"form": "form.tpl", | ||
"list": "list.tpl" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{** | ||
* Форма добавления/редактирования категории | ||
*} | ||
|
||
{$component = 'p-cron-form'} | ||
{component_define_params params=[ 'menuItems' ]} | ||
|
||
<form method="post"> | ||
{component 'admin:field' template='hidden.security-key'} | ||
|
||
{$items = [[ | ||
'value' => '', | ||
'text' => '' | ||
]]} | ||
|
||
{foreach $menuItems as $menuItem} | ||
{$items[] = [ | ||
'text' => ''|str_pad:(2 * $menuItem.level):'-'|cat:{lang name=$menuItem['entity']->getTitle()}, | ||
'value' => $menuItem['entity']->getId() | ||
]} | ||
{/foreach} | ||
|
||
{component 'admin:field' template='select' name='item[pid]' label='Вложить в' items=$items} | ||
|
||
{* Код *} | ||
{component 'admin:field' template='text' name='item[name]' label='Код'} | ||
|
||
{* Название *} | ||
{component 'admin:field' template='text' name='item[title]' label='Название'} | ||
|
||
{* URL *} | ||
{component 'admin:field' template='text' name='item[url]' label='Url'} | ||
|
||
{* Сортировка *} | ||
{component 'admin:field' template='text' name='item[priority]' label='Приоритет'} | ||
|
||
{* Статус *} | ||
{component 'admin:field' template='checkbox' name='item[enable]' label='Включен'} | ||
|
||
{* Активный *} | ||
{component 'admin:field' template='checkbox' name='item[active]' label='Активный'} | ||
|
||
{* Кнопки *} | ||
{component 'admin:button' name='item_submit' text="{($_aRequest) ? $aLang.plugin.admin.save : $aLang.plugin.admin.add}" value=1 mods='primary'} | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{** | ||
* Список категорий | ||
*} | ||
|
||
{$component = 'p-menu-list'} | ||
{component_define_params params=[ 'items' ]} | ||
|
||
{if $items} | ||
<table class="ls-table"> | ||
<thead> | ||
<tr> | ||
<th>Название</th> | ||
<th>URL</th> | ||
<th>Элементов</th> | ||
<th>Включен</th> | ||
<th>Активный</th> | ||
<th class="ls-table-cell-actions">Действие</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{foreach $items as $itemWrapper} | ||
{$item = $itemWrapper['entity']} | ||
{$level = $itemWrapper['level']} | ||
|
||
<tr data-id="{$item->getId()}"> | ||
<td> | ||
<i class="fa fa-file" style="margin-left: {$level * 20}px;"></i> | ||
|
||
{if $item->getUrl()} | ||
<a href="{$item->getUrl()}" border="0">{lang name=$item->getTitle()} ({$item->getTitle()})</a> | ||
{else} | ||
{lang name=$item->getTitle()} ({$item->getTitle()}) | ||
{/if} | ||
</td> | ||
<td>{$item->getUrl()}</td> | ||
<td>{$item->getCountTargetOfDescendants()}</td> | ||
<td>{$item->getEnable()}</td> | ||
<td>{$item->getActive()}</td> | ||
<td class="ls-table-cell-actions"> | ||
<a href="{router page="admin/menu/{$oMenu->getName()}/update/{$item->getId()}"}" class="fa fa-edit" title="{$aLang.plugin.admin.edit}"></a> | ||
<a href="{router page="admin/menu/{$oMenu->getName()}/remove/{$item->getId()}"}?security_ls_key={$LIVESTREET_SECURITY_KEY}" class="fa fa-trash-o js-confirm-remove" title="{$aLang.plugin.admin.delete}"></a> | ||
</td> | ||
</tr> | ||
{/foreach} | ||
</tbody> | ||
</table> | ||
{else} | ||
{component 'admin:blankslate' text='Нет пунктов. Вы можете добавить.'} | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{** | ||
* Добавление категории | ||
* | ||
*} | ||
|
||
{extends "{$aTemplatePathPlugin.admin}layouts/layout.base.tpl"} | ||
|
||
{block 'layout_options' append} | ||
{$layoutBackUrl = {router page="admin/menu/{$oMenu->getName()}"}} | ||
{/block} | ||
|
||
{block 'layout_page_title'} | ||
{if $_aRequest} | ||
Редактирование пункта для меню «{$oMenu->getTitle()|escape}» | ||
{else} | ||
Добавление пункта для меню «{$oMenu->getTitle()|escape}» | ||
{/if} | ||
{/block} | ||
|
||
{block 'layout_content'} | ||
{component 'admin:p-menus' template='form' menuItems=$aItems} | ||
{/block} |
Oops, something went wrong.