1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-10 12:58:21 +03:00

доработка плагина Page - появилась сортировка и вывод на главную

This commit is contained in:
Mzhelskiy Maxim 2010-06-05 22:16:31 +00:00
parent ce1cee6bce
commit 96cc8d1f5f
19 changed files with 164 additions and 14 deletions

View file

@ -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;
}
/**
* Выполнение хуков
*/

View file

@ -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);
}
}
?>

View file

@ -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;
}
}
?>

View file

@ -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;
}
}
?>

View file

@ -7,7 +7,7 @@
<lang name="default">LiveStreet Developers Team</lang>
</author>
<homepage>http://livestreet.ru</homepage>
<version>1.0.2</version>
<version>1.1.0</version>
<requires>
<livestreet>0.4.1</livestreet>
<plugins>

View file

@ -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',

View file

@ -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' => 'Действие',

View file

@ -78,9 +78,17 @@ tinyMCE.init({
<span class="form_note">{$aLang.page_create_seo_description_notice}</span>
</p>
<p><label for="page_sort">{$aLang.page_create_sort}:</label><br />
<input type="text" id="page_sort" name="page_sort" value="{$_aRequest.page_sort}" class="w100p" />
<span class="form_note">{$aLang.page_create_sort_notice}</span></p>
<p><input type="checkbox" id="page_active" name="page_active" value="1" {if $_aRequest.page_active==1}checked{/if}/>
<label for="page_active"> &mdash; {$aLang.page_create_active}</label>
</p>
<p><input type="checkbox" id="page_main" name="page_main" value="1" {if $_aRequest.page_main==1}checked{/if}/>
<label for="page_main"> &mdash; {$aLang.page_create_main}</label>
</p>
<p class="buttons">

View file

@ -21,7 +21,8 @@
<tr>
<th align="left">{$aLang.page_admin_title}</th>
<th align="center" width="250px">{$aLang.page_admin_url}</th>
<th align="center" width="50px">{$aLang.page_admin_active}</th>
<th align="center" width="50px">{$aLang.page_admin_active}</th>
<th align="center" width="70px">{$aLang.page_admin_main}</th>
<th align="center" width="80px">{$aLang.page_admin_action}</th>
</tr>
@ -34,7 +35,7 @@
{/if}
<tr class="{$className}" onmouseover="this.className='colored_sel';" onmouseout="this.className='{$className}';">
<td align="left" valign="middle">
<img src="{cfg name='path.static.skin'}/images/{if $oPage->getLevel()==0}folder{else}new{/if}_16x16.gif" alt="" title="" border="0" style="margin-left: {$oPage->getLevel()*20}px;"/>
<img src="{$sTemplateWebPathPlugin}images/{if $oPage->getLevel()==0}folder{else}new{/if}_16x16.gif" alt="" title="" border="0" style="margin-left: {$oPage->getLevel()*20}px;"/>
<a href="{router page='page'}{$oPage->getUrlFull()}/">{$oPage->getTitle()}</a>
</td>
<td align="left">
@ -47,10 +48,19 @@
{$aLang.page_admin_active_no}
{/if}
</td>
<td align="center">
{if $oPage->getMain()}
{$aLang.page_admin_active_yes}
{else}
{$aLang.page_admin_active_no}
{/if}
</td>
<td align="center">
<a href="{router page='page'}admin/edit/{$oPage->getId()}/"><img src="{cfg name='path.static.skin'}/images/edit.gif" alt="{$aLang.page_admin_action_edit}" title="{$aLang.page_admin_action_edit}" border="0"/></a>
<a href="{router page='page'}admin/edit/{$oPage->getId()}/"><img src="{$sTemplateWebPathPlugin}images/edit.gif" alt="{$aLang.page_admin_action_edit}" title="{$aLang.page_admin_action_edit}" border="0"/></a>
&nbsp;
<a href="{router page='page'}admin/delete/{$oPage->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" onclick="return confirm('«{$oPage->getTitle()}»: {$aLang.page_admin_action_delete_confirm}');"><img src="{cfg name='path.static.skin'}/images/delete.gif" alt="{$aLang.page_admin_action_delete}" title="{$aLang.page_admin_action_delete}" border="0"/></a>
<a href="{router page='page'}admin/delete/{$oPage->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" onclick="return confirm('«{$oPage->getTitle()}»: {$aLang.page_admin_action_delete_confirm}');"><img src="{$sTemplateWebPathPlugin}images/delete.gif" alt="{$aLang.page_admin_action_delete}" title="{$aLang.page_admin_action_delete}" border="0"/></a>
<a href="{router page='page'}admin/sort/{$oPage->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$sTemplateWebPathPlugin}images/up.png" alt="{$aLang.page_admin_sort_up}" title="{$aLang.page_admin_sort_up} ({$oPage->getSort()})" /></a>
<a href="{router page='page'}admin/sort/{$oPage->getId()}/down/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$sTemplateWebPathPlugin}images/down.png" alt="{$aLang.page_admin_sort_down}" title="{$aLang.page_admin_sort_down} ({$oPage->getSort()})" /></a>
</td>
</tr>
{/foreach}

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

View file

@ -79,9 +79,15 @@
<p><label for="page_seo_description">{$aLang.page_create_seo_description}:</label><br />
<input type="text" id="page_seo_description" name="page_seo_description" value="{$_aRequest.page_seo_description}" class="input-wide" />
<span class="note">{$aLang.page_create_seo_description_notice}</span></p>
<p><label for="page_sort">{$aLang.page_create_sort}:</label><br />
<input type="text" id="page_sort" name="page_sort" value="{$_aRequest.page_sort}" class="input-wide" />
<span class="note">{$aLang.page_create_sort_notice}</span></p>
<p><label><input type="checkbox" id="page_active" name="page_active" value="1" class="checkbox" {if $_aRequest.page_active==1}checked{/if} />{$aLang.page_create_active}</label></p>
<p><label><input type="checkbox" id="page_main" name="page_main" value="1" class="checkbox" {if $_aRequest.page_main==1}checked{/if} />{$aLang.page_create_main}</label></p>
<p>
<input type="submit" name="submit_page_save" value="{$aLang.page_create_submit_save}" />
<input type="submit" name="submit_page_cancel" value="{$aLang.page_create_submit_cancel}" onclick="window.location='{router page='page'}admin/'; return false;" />

View file

@ -24,7 +24,8 @@
<td>{$aLang.page_admin_title}</td>
<td align="center" width="250px">{$aLang.page_admin_url}</td>
<td align="center" width="50px">{$aLang.page_admin_active}</td>
<td align="center" width="80px">{$aLang.page_admin_action}</td>
<td align="center" width="70px">{$aLang.page_admin_main}</td>
<td align="center" width="80px">{$aLang.page_admin_action}</td>
</tr>
</thead>
@ -45,10 +46,19 @@
{$aLang.page_admin_active_no}
{/if}
</td>
<td align="center">
{if $oPage->getMain()}
{$aLang.page_admin_active_yes}
{else}
{$aLang.page_admin_active_no}
{/if}
</td>
<td align="center">
<a href="{router page='page'}admin/edit/{$oPage->getId()}/"><img src="{cfg name='path.static.skin'}/images/edit.png" alt="{$aLang.page_admin_action_edit}" title="{$aLang.page_admin_action_edit}" /></a>
<a href="{router page='page'}admin/delete/{$oPage->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" onclick="return confirm('«{$oPage->getTitle()}»: {$aLang.page_admin_action_delete_confirm}');"><img src="{cfg name='path.static.skin'}/images/delete.png" alt="{$aLang.page_admin_action_delete}" title="{$aLang.page_admin_action_delete}" /></a>
</td>
<a href="{router page='page'}admin/sort/{$oPage->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$sTemplateWebPathPlugin}images/up.png" alt="{$aLang.page_admin_sort_up}" title="{$aLang.page_admin_sort_up} ({$oPage->getSort()})" /></a>
<a href="{router page='page'}admin/sort/{$oPage->getId()}/down/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$sTemplateWebPathPlugin}images/down.png" alt="{$aLang.page_admin_sort_down}" title="{$aLang.page_admin_sort_down} ({$oPage->getSort()})" /></a>
</td>
</tr>
{/foreach}
</tbody>

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B