diff --git a/plugins/page/classes/actions/ActionPage.class.php b/plugins/page/classes/actions/ActionPage.class.php index b4e9535b..26b11962 100644 --- a/plugins/page/classes/actions/ActionPage.class.php +++ b/plugins/page/classes/actions/ActionPage.class.php @@ -116,6 +116,8 @@ class PluginPage_ActionPage extends ActionPlugin { $_REQUEST['page_seo_keywords']=$oPageEdit->getSeoKeywords(); $_REQUEST['page_seo_description']=$oPageEdit->getSeoDescription(); $_REQUEST['page_active']=$oPageEdit->getActive(); + $_REQUEST['page_main']=$oPageEdit->getMain(); + $_REQUEST['page_sort']=$oPageEdit->getSort(); $_REQUEST['page_id']=$oPageEdit->getId(); } else { /** @@ -141,6 +143,30 @@ class PluginPage_ActionPage extends ActionPlugin { $this->Message_AddError($this->Lang_Get('page_admin_action_delete_error'),$this->Lang_Get('error')); } } + /** + * Обработка изменения сортировки страницы + */ + if ($this->GetParam(0)=='sort' and $oPage=$this->PluginPage_Page_GetPageById($this->GetParam(1))) { + $this->Security_ValidateSendForm(); + $sWay=$this->GetParam(2)=='down' ? 'down' : 'up'; + $iSortOld=$oPage->getSort(); + if ($oPagePrev=$this->PluginPage_Page_GetNextPageBySort($iSortOld,$oPage->getPid(),$sWay)) { + $iSortNew=$oPagePrev->getSort(); + $oPagePrev->setSort($iSortOld); + $this->PluginPage_Page_UpdatePage($oPagePrev); + } else { + if ($sWay=='down') { + $iSortNew=$iSortOld-1; + } else { + $iSortNew=$iSortOld+1; + } + } + /** + * Меняем значения сортировки местами + */ + $oPage->setSort($iSortNew); + $this->PluginPage_Page_UpdatePage($oPage); + } /** * Получаем и загружаем список всех страниц */ @@ -172,6 +198,7 @@ class PluginPage_ActionPage extends ActionPlugin { * Обновляем свойства страницы */ $oPageEdit->setActive(getRequest('page_active') ? 1 : 0); + $oPageEdit->setMain(getRequest('page_main') ? 1 : 0); $oPageEdit->setDateEdit(date("Y-m-d H:i:s")); if (getRequest('page_pid')==0) { $oPageEdit->setUrlFull(getRequest('page_url')); @@ -186,6 +213,7 @@ class PluginPage_ActionPage extends ActionPlugin { $oPageEdit->setText(getRequest('page_text')); $oPageEdit->setTitle(getRequest('page_title')); $oPageEdit->setUrl(getRequest('page_url')); + $oPageEdit->setSort(getRequest('page_sort')); /** * Обновляем страницу */ @@ -214,6 +242,7 @@ class PluginPage_ActionPage extends ActionPlugin { */ $oPage=Engine::GetEntity('PluginPage_Page'); $oPage->setActive(getRequest('page_active') ? 1 : 0); + $oPage->setMain(getRequest('page_main') ? 1 : 0); $oPage->setDateAdd(date("Y-m-d H:i:s")); if (getRequest('page_pid')==0) { $oPage->setUrlFull(getRequest('page_url')); @@ -228,6 +257,7 @@ class PluginPage_ActionPage extends ActionPlugin { $oPage->setText(getRequest('page_text')); $oPage->setTitle(getRequest('page_title')); $oPage->setUrl(getRequest('page_url')); + $oPage->setSort(getRequest('page_sort')); /** * Добавляем страницу */ @@ -284,6 +314,13 @@ class PluginPage_ActionPage extends ActionPlugin { $this->Message_AddError($this->Lang_Get('page_create_parent_page_error'),$this->Lang_Get('error')); $bOk=false; } + /** + * Проверяем сортировку + */ + if (getRequest('page_sort') and !is_numeric(getRequest('page_sort'))) { + $this->Message_AddError($this->Lang_Get('page_create_sort_error'),$this->Lang_Get('error')); + $bOk=false; + } /** * Выполнение хуков */ diff --git a/plugins/page/classes/modules/page/Page.class.php b/plugins/page/classes/modules/page/Page.class.php index c65c91ad..7d66c61f 100644 --- a/plugins/page/classes/modules/page/Page.class.php +++ b/plugins/page/classes/modules/page/Page.class.php @@ -186,5 +186,23 @@ class PluginPage_ModulePage extends Module { public function SetPagesPidToNull() { return $this->oMapper->SetPagesPidToNull(); } + /** + * Получает слудующую по сортировке страницу + * + * @param unknown_type $iSort + * @param unknown_type $sWay + * @return unknown + */ + public function GetNextPageBySort($iSort,$sPid,$sWay='up') { + return $this->oMapper->GetNextPageBySort($iSort,$sPid,$sWay); + } + /** + * Получает значение максимальной сртировки + * + * @return unknown + */ + public function GetMaxSortByPid($sPid) { + return $this->oMapper->GetMaxSortByPid($sPid); + } } ?> \ No newline at end of file diff --git a/plugins/page/classes/modules/page/entity/Page.entity.class.php b/plugins/page/classes/modules/page/entity/Page.entity.class.php index 9021a087..70a6063f 100644 --- a/plugins/page/classes/modules/page/entity/Page.entity.class.php +++ b/plugins/page/classes/modules/page/entity/Page.entity.class.php @@ -49,6 +49,12 @@ class PluginPage_ModulePage_EntityPage extends Entity } public function getActive() { return $this->_aData['page_active']; + } + public function getMain() { + return $this->_aData['page_main']; + } + public function getSort() { + return $this->_aData['page_sort']; } public function getLevel() { @@ -91,5 +97,11 @@ class PluginPage_ModulePage_EntityPage extends Entity public function setActive($data) { $this->_aData['page_active']=$data; } + public function setMain($data) { + $this->_aData['page_main']=$data; + } + public function setSort($data) { + $this->_aData['page_sort']=$data; + } } ?> \ No newline at end of file diff --git a/plugins/page/classes/modules/page/mapper/Page.mapper.class.php b/plugins/page/classes/modules/page/mapper/Page.mapper.class.php index bc764e77..e721c588 100644 --- a/plugins/page/classes/modules/page/mapper/Page.mapper.class.php +++ b/plugins/page/classes/modules/page/mapper/Page.mapper.class.php @@ -27,11 +27,13 @@ class PluginPage_ModulePage_MapperPage extends Mapper { page_date_add, page_seo_keywords, page_seo_description, - page_active + page_active, + page_main, + page_sort ) - VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?d) + VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?d, ?d, ?d) "; - if ($iId=$this->oDb->query($sql,$oPage->getPid(),$oPage->getUrl(),$oPage->getUrlFull(),$oPage->getTitle(),$oPage->getText(),$oPage->getDateAdd(),$oPage->getSeoKeywords(),$oPage->getSeoDescription(),$oPage->getActive())) + if ($iId=$this->oDb->query($sql,$oPage->getPid(),$oPage->getUrl(),$oPage->getUrlFull(),$oPage->getTitle(),$oPage->getText(),$oPage->getDateAdd(),$oPage->getSeoKeywords(),$oPage->getSeoDescription(),$oPage->getActive(),$oPage->getMain(),$oPage->getSort())) { return $iId; } @@ -48,10 +50,12 @@ class PluginPage_ModulePage_MapperPage extends Mapper { page_date_edit = ? , page_seo_keywords = ? , page_seo_description = ? , - page_active = ? + page_active = ?, + page_main = ?, + page_sort = ? WHERE page_id = ?d "; - if ($this->oDb->query($sql,$oPage->getPid(),$oPage->getUrl(),$oPage->getUrlFull(),$oPage->getTitle(),$oPage->getText(),$oPage->getDateEdit(),$oPage->getSeoKeywords(),$oPage->getSeoDescription(),$oPage->getActive(),$oPage->getId())) + if ($this->oDb->query($sql,$oPage->getPid(),$oPage->getUrl(),$oPage->getUrlFull(),$oPage->getTitle(),$oPage->getText(),$oPage->getDateEdit(),$oPage->getSeoKeywords(),$oPage->getSeoDescription(),$oPage->getActive(),$oPage->getMain(),$oPage->getSort(),$oPage->getId())) { return true; } @@ -102,7 +106,7 @@ class PluginPage_ModulePage_MapperPage extends Mapper { page_pid as PARENT_KEY FROM ".Config::Get('plugin.page.table.page')." - ORDER by page_title asc; + ORDER by page_sort desc; "; if ($aRows=$this->oDb->select($sql)) { return $aRows; @@ -133,5 +137,36 @@ class PluginPage_ModulePage_MapperPage extends Mapper { } return $aResult; } + + public function GetNextPageBySort($iSort,$sPid,$sWay) { + if ($sWay=='up') { + $sWay='>'; + $sOrder='asc'; + } else { + $sWay='<'; + $sOrder='desc'; + } + $sPidNULL=''; + if (is_null($sPid)) { + $sPidNULL='page_pid IS NULL and'; + } + $sql = "SELECT * FROM ".Config::Get('plugin.page.table.page')." WHERE { page_pid = ? and } {$sPidNULL} page_sort {$sWay} ? order by page_sort {$sOrder} limit 0,1"; + if ($aRow=$this->oDb->selectRow($sql,is_null($sPid) ? DBSIMPLE_SKIP : $sPid, $iSort)) { + return Engine::GetEntity('PluginPage_Page',$aRow); + } + return null; + } + + public function GetMaxSortByPid($sPid) { + $sPidNULL=''; + if (is_null($sPid)) { + $sPidNULL='and page_pid IS NULL'; + } + $sql = "SELECT max(page_sort) as max_sort FROM ".Config::Get('plugin.page.table.page')." WHERE 1=1 { and page_pid = ? } {$sPidNULL} "; + if ($aRow=$this->oDb->selectRow($sql,is_null($sPid) ? DBSIMPLE_SKIP : $sPid)) { + return $aRow['max_sort']; + } + return null; + } } ?> \ No newline at end of file diff --git a/plugins/page/plugin.xml b/plugins/page/plugin.xml index cb56c6f7..83abab22 100644 --- a/plugins/page/plugin.xml +++ b/plugins/page/plugin.xml @@ -7,7 +7,7 @@ LiveStreet Developers Team http://livestreet.ru - 1.0.2 + 1.1.0 0.4.1 diff --git a/plugins/page/templates/language/english.php b/plugins/page/templates/language/english.php index aa3912f6..08cf41da 100644 --- a/plugins/page/templates/language/english.php +++ b/plugins/page/templates/language/english.php @@ -42,7 +42,11 @@ return array( 'page_create_seo_keywords_notice' => 'SEO optimization keywords', 'page_create_seo_description' => 'SEO description', 'page_create_seo_description_notice' => 'SEO optimization description', + 'page_create_sort' => 'Sort', + 'page_create_sort_notice' => 'Sets the sorting when displaying', + 'page_create_sort_error' => 'Sorting must be a number', 'page_create_active' => 'Show active page', + 'page_create_main' => 'display on the main page', 'page_create_submit_save' => 'Save', 'page_create_submit_save_ok' => 'New page has been created', 'page_create_submit_cancel' => 'Cancel', @@ -51,6 +55,9 @@ return array( 'page_admin_title' => 'Title', 'page_admin_url' => 'URL', 'page_admin_active' => 'Active', + 'page_admin_main' => 'On main', + 'page_admin_sort_up' => 'Move up', + 'page_admin_sort_down' => 'Move down', 'page_admin_active_yes' => 'Yes', 'page_admin_active_no' => 'No', 'page_admin_action' => 'Action', diff --git a/plugins/page/templates/language/russian.php b/plugins/page/templates/language/russian.php index 551d81d1..5522d020 100644 --- a/plugins/page/templates/language/russian.php +++ b/plugins/page/templates/language/russian.php @@ -40,9 +40,13 @@ return array( 'page_create_text_error' => 'Текст страницы должен быть от 1 до 50000 символов', 'page_create_seo_keywords' => 'SEO keywords', 'page_create_seo_keywords_notice' => 'Ключевые слова для SEO-оптимизации', - 'page_create_seo_description' => 'SEO description', + 'page_create_seo_description' => 'SEO description', 'page_create_seo_description_notice' => 'Описание для SEO-оптимизации', + 'page_create_sort' => 'Сортировка', + 'page_create_sort_notice' => 'Устанавливает сортировку при отображении', + 'page_create_sort_error' => 'Сортировка должна быть числом', 'page_create_active' => 'показывать страницу', + 'page_create_main' => 'отображать на главной странице', 'page_create_submit_save' => 'сохранить', 'page_create_submit_save_ok' => 'Новая страница добавлена', 'page_create_submit_cancel' => 'отмена', @@ -51,6 +55,9 @@ return array( 'page_admin_title' => 'Название', 'page_admin_url' => 'URL', 'page_admin_active' => 'Активна', + 'page_admin_main' => 'На главной', + 'page_admin_sort_up' => 'Переместить выше', + 'page_admin_sort_down' => 'Переместить ниже', 'page_admin_active_yes' => 'да', 'page_admin_active_no' => 'нет', 'page_admin_action' => 'Действие', diff --git a/plugins/page/templates/skin/default/actions/ActionPage/add.tpl b/plugins/page/templates/skin/default/actions/ActionPage/add.tpl index 2491cf46..456dd6d5 100644 --- a/plugins/page/templates/skin/default/actions/ActionPage/add.tpl +++ b/plugins/page/templates/skin/default/actions/ActionPage/add.tpl @@ -78,9 +78,17 @@ tinyMCE.init({ {$aLang.page_create_seo_description_notice}

+


+ + {$aLang.page_create_sort_notice}

+

+ +

+ +

diff --git a/plugins/page/templates/skin/default/actions/ActionPage/admin.tpl b/plugins/page/templates/skin/default/actions/ActionPage/admin.tpl index 142f364c..1f6941e9 100644 --- a/plugins/page/templates/skin/default/actions/ActionPage/admin.tpl +++ b/plugins/page/templates/skin/default/actions/ActionPage/admin.tpl @@ -21,7 +21,8 @@ {$aLang.page_admin_title} {$aLang.page_admin_url} - {$aLang.page_admin_active} + {$aLang.page_admin_active} + {$aLang.page_admin_main} {$aLang.page_admin_action} @@ -34,7 +35,7 @@ {/if} - + {$oPage->getTitle()} @@ -47,10 +48,19 @@ {$aLang.page_admin_active_no} {/if} + + {if $oPage->getMain()} + {$aLang.page_admin_active_yes} + {else} + {$aLang.page_admin_active_no} + {/if} + - {$aLang.page_admin_action_edit} + {$aLang.page_admin_action_edit}   - {$aLang.page_admin_action_delete} + {$aLang.page_admin_action_delete} + {$aLang.page_admin_sort_up} + {$aLang.page_admin_sort_down} {/foreach} diff --git a/plugins/page/templates/skin/default/images/delete.gif b/plugins/page/templates/skin/default/images/delete.gif new file mode 100644 index 00000000..772d7ba0 Binary files /dev/null and b/plugins/page/templates/skin/default/images/delete.gif differ diff --git a/plugins/page/templates/skin/default/images/down.png b/plugins/page/templates/skin/default/images/down.png new file mode 100644 index 00000000..dcfc08b8 Binary files /dev/null and b/plugins/page/templates/skin/default/images/down.png differ diff --git a/plugins/page/templates/skin/default/images/edit.gif b/plugins/page/templates/skin/default/images/edit.gif new file mode 100644 index 00000000..6e3f4d1c Binary files /dev/null and b/plugins/page/templates/skin/default/images/edit.gif differ diff --git a/plugins/page/templates/skin/default/images/folder_16x16.gif b/plugins/page/templates/skin/default/images/folder_16x16.gif new file mode 100644 index 00000000..039902d5 Binary files /dev/null and b/plugins/page/templates/skin/default/images/folder_16x16.gif differ diff --git a/plugins/page/templates/skin/default/images/new_16x16.gif b/plugins/page/templates/skin/default/images/new_16x16.gif new file mode 100644 index 00000000..9b511d9a Binary files /dev/null and b/plugins/page/templates/skin/default/images/new_16x16.gif differ diff --git a/plugins/page/templates/skin/default/images/up.png b/plugins/page/templates/skin/default/images/up.png new file mode 100644 index 00000000..3fc4be7c Binary files /dev/null and b/plugins/page/templates/skin/default/images/up.png differ diff --git a/plugins/page/templates/skin/developer/actions/ActionPage/add.tpl b/plugins/page/templates/skin/developer/actions/ActionPage/add.tpl index 23201340..4dd06418 100644 --- a/plugins/page/templates/skin/developer/actions/ActionPage/add.tpl +++ b/plugins/page/templates/skin/developer/actions/ActionPage/add.tpl @@ -79,9 +79,15 @@


{$aLang.page_create_seo_description_notice}

+ +


+ + {$aLang.page_create_sort_notice}

+

+

diff --git a/plugins/page/templates/skin/developer/actions/ActionPage/admin.tpl b/plugins/page/templates/skin/developer/actions/ActionPage/admin.tpl index 2c95aa8d..bc6d686c 100644 --- a/plugins/page/templates/skin/developer/actions/ActionPage/admin.tpl +++ b/plugins/page/templates/skin/developer/actions/ActionPage/admin.tpl @@ -24,7 +24,8 @@ {$aLang.page_admin_title} {$aLang.page_admin_url} {$aLang.page_admin_active} - {$aLang.page_admin_action} + {$aLang.page_admin_main} + {$aLang.page_admin_action} @@ -45,10 +46,19 @@ {$aLang.page_admin_active_no} {/if} + + {if $oPage->getMain()} + {$aLang.page_admin_active_yes} + {else} + {$aLang.page_admin_active_no} + {/if} + {$aLang.page_admin_action_edit} {$aLang.page_admin_action_delete} - + {$aLang.page_admin_sort_up} + {$aLang.page_admin_sort_down} + {/foreach} diff --git a/plugins/page/templates/skin/developer/images/down.png b/plugins/page/templates/skin/developer/images/down.png new file mode 100644 index 00000000..dcfc08b8 Binary files /dev/null and b/plugins/page/templates/skin/developer/images/down.png differ diff --git a/plugins/page/templates/skin/developer/images/up.png b/plugins/page/templates/skin/developer/images/up.png new file mode 100644 index 00000000..3fc4be7c Binary files /dev/null and b/plugins/page/templates/skin/developer/images/up.png differ