Changeset 933

Show
Ignore:
Timestamp:
06/06/10 02:16:31 (20 months ago)
Author:
ort
Message:

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

Location:
trunk/plugins/page
Files:
9 added
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/page/classes/actions/ActionPage.class.php

    r881 r933  
    117117                                        $_REQUEST['page_seo_description']=$oPageEdit->getSeoDescription(); 
    118118                                        $_REQUEST['page_active']=$oPageEdit->getActive();        
     119                                        $_REQUEST['page_main']=$oPageEdit->getMain();    
     120                                        $_REQUEST['page_sort']=$oPageEdit->getSort();    
    119121                                        $_REQUEST['page_id']=$oPageEdit->getId();                                                
    120122                                }       else { 
     
    143145                } 
    144146                /** 
     147                 * Обработка изменения сортировки страницы 
     148                 */ 
     149                if ($this->GetParam(0)=='sort' and $oPage=$this->PluginPage_Page_GetPageById($this->GetParam(1))) { 
     150                        $this->Security_ValidateSendForm(); 
     151                        $sWay=$this->GetParam(2)=='down' ? 'down' : 'up'; 
     152                        $iSortOld=$oPage->getSort(); 
     153                        if ($oPagePrev=$this->PluginPage_Page_GetNextPageBySort($iSortOld,$oPage->getPid(),$sWay)) { 
     154                                $iSortNew=$oPagePrev->getSort(); 
     155                                $oPagePrev->setSort($iSortOld); 
     156                                $this->PluginPage_Page_UpdatePage($oPagePrev); 
     157                        } else { 
     158                                if ($sWay=='down') { 
     159                                        $iSortNew=$iSortOld-1; 
     160                                } else { 
     161                                        $iSortNew=$iSortOld+1; 
     162                                }                                
     163                        } 
     164                        /** 
     165                         * Меняем значения сортировки местами 
     166                         */ 
     167                        $oPage->setSort($iSortNew); 
     168                        $this->PluginPage_Page_UpdatePage($oPage); 
     169                } 
     170                /** 
    145171                 * Получаем и загружаем список всех страниц 
    146172                 */ 
     
    173199                 */              
    174200                $oPageEdit->setActive(getRequest('page_active') ? 1 : 0); 
     201                $oPageEdit->setMain(getRequest('page_main') ? 1 : 0); 
    175202                $oPageEdit->setDateEdit(date("Y-m-d H:i:s")); 
    176203                if (getRequest('page_pid')==0) { 
     
    187214                $oPageEdit->setTitle(getRequest('page_title')); 
    188215                $oPageEdit->setUrl(getRequest('page_url')); 
     216                $oPageEdit->setSort(getRequest('page_sort')); 
    189217                /** 
    190218                 * Обновляем страницу 
     
    215243                $oPage=Engine::GetEntity('PluginPage_Page'); 
    216244                $oPage->setActive(getRequest('page_active') ? 1 : 0); 
     245                $oPage->setMain(getRequest('page_main') ? 1 : 0); 
    217246                $oPage->setDateAdd(date("Y-m-d H:i:s")); 
    218247                if (getRequest('page_pid')==0) { 
     
    229258                $oPage->setTitle(getRequest('page_title')); 
    230259                $oPage->setUrl(getRequest('page_url')); 
     260                $oPage->setSort(getRequest('page_sort')); 
    231261                /** 
    232262                 * Добавляем страницу 
     
    286316                }                
    287317                /** 
     318                 * Проверяем сортировку 
     319                 */ 
     320                if (getRequest('page_sort') and !is_numeric(getRequest('page_sort'))) { 
     321                        $this->Message_AddError($this->Lang_Get('page_create_sort_error'),$this->Lang_Get('error')); 
     322                        $bOk=false; 
     323                } 
     324                /** 
    288325                 * Выполнение хуков 
    289326                 */ 
  • trunk/plugins/page/classes/modules/page/Page.class.php

    r929 r933  
    187187                return $this->oMapper->SetPagesPidToNull(); 
    188188        } 
     189        /** 
     190         * Получает слудующую по сортировке страницу 
     191         * 
     192         * @param unknown_type $iSort 
     193         * @param unknown_type $sWay 
     194         * @return unknown 
     195         */ 
     196        public function GetNextPageBySort($iSort,$sPid,$sWay='up') { 
     197                return $this->oMapper->GetNextPageBySort($iSort,$sPid,$sWay); 
     198        } 
     199        /** 
     200         * Получает значение максимальной сртировки 
     201         * 
     202         * @return unknown 
     203         */ 
     204        public function GetMaxSortByPid($sPid) { 
     205                return $this->oMapper->GetMaxSortByPid($sPid); 
     206        } 
    189207} 
    190208?> 
  • trunk/plugins/page/classes/modules/page/entity/Page.entity.class.php

    r892 r933  
    5050    public function getActive() { 
    5151        return $this->_aData['page_active']; 
     52    } 
     53    public function getMain() { 
     54        return $this->_aData['page_main']; 
     55    } 
     56    public function getSort() { 
     57        return $this->_aData['page_sort']; 
    5258    }      
    5359     
     
    9298        $this->_aData['page_active']=$data; 
    9399    } 
     100    public function setMain($data) { 
     101        $this->_aData['page_main']=$data; 
     102    } 
     103    public function setSort($data) { 
     104        $this->_aData['page_sort']=$data; 
     105    } 
    94106} 
    95107?> 
  • trunk/plugins/page/classes/modules/page/mapper/Page.mapper.class.php

    r894 r933  
    2828                        page_seo_keywords, 
    2929                        page_seo_description, 
    30                         page_active                      
     30                        page_active,                     
     31                        page_main,                       
     32                        page_sort                        
    3133                        ) 
    32                         VALUES(?, ?,    ?,      ?,  ?,  ?,  ?,  ?,  ?d) 
     34                        VALUES(?, ?,    ?,      ?,  ?,  ?,  ?,  ?,  ?d,  ?d,  ?d) 
    3335                ";                       
    34                 if ($iId=$this->oDb->query($sql,$oPage->getPid(),$oPage->getUrl(),$oPage->getUrlFull(),$oPage->getTitle(),$oPage->getText(),$oPage->getDateAdd(),$oPage->getSeoKeywords(),$oPage->getSeoDescription(),$oPage->getActive()))  
     36                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()))  
    3537                { 
    3638                        return $iId; 
     
    4951                        page_seo_keywords = ? , 
    5052                        page_seo_description = ? , 
    51                         page_active      = ?             
     53                        page_active      = ?,            
     54                        page_main        = ?,            
     55                        page_sort        = ?             
    5256                        WHERE page_id = ?d 
    5357                ";                       
    54                 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()))  
     58                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()))  
    5559                { 
    5660                        return true; 
     
    103107                                FROM  
    104108                                        ".Config::Get('plugin.page.table.page')."                                
    105                                 ORDER by page_title asc;         
     109                                ORDER by page_sort desc;         
    106110                                        "; 
    107111                if ($aRows=$this->oDb->select($sql)) { 
     
    134138                return $aResult; 
    135139        } 
     140         
     141        public function GetNextPageBySort($iSort,$sPid,$sWay) { 
     142                if ($sWay=='up') { 
     143                        $sWay='>'; 
     144                        $sOrder='asc'; 
     145                } else { 
     146                        $sWay='<'; 
     147                        $sOrder='desc'; 
     148                } 
     149                $sPidNULL=''; 
     150                if (is_null($sPid)) { 
     151                        $sPidNULL='page_pid IS NULL and'; 
     152                } 
     153                $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"; 
     154                if ($aRow=$this->oDb->selectRow($sql,is_null($sPid) ? DBSIMPLE_SKIP : $sPid, $iSort)) { 
     155                        return Engine::GetEntity('PluginPage_Page',$aRow); 
     156                } 
     157                return null; 
     158        } 
     159         
     160        public function GetMaxSortByPid($sPid) { 
     161                $sPidNULL=''; 
     162                if (is_null($sPid)) { 
     163                        $sPidNULL='and page_pid IS NULL'; 
     164                } 
     165                $sql = "SELECT max(page_sort) as max_sort FROM ".Config::Get('plugin.page.table.page')." WHERE 1=1 { and page_pid = ? } {$sPidNULL} "; 
     166                if ($aRow=$this->oDb->selectRow($sql,is_null($sPid) ? DBSIMPLE_SKIP : $sPid)) { 
     167                        return $aRow['max_sort']; 
     168                } 
     169                return null; 
     170        } 
    136171} 
    137172?> 
  • trunk/plugins/page/plugin.xml

    r925 r933  
    88        </author> 
    99        <homepage>http://livestreet.ru</homepage> 
    10         <version>1.0.2</version> 
     10        <version>1.1.0</version> 
    1111        <requires> 
    1212                <livestreet>0.4.1</livestreet> 
  • trunk/plugins/page/templates/language/english.php

    r900 r933  
    4343        'page_create_seo_description' => 'SEO description', 
    4444        'page_create_seo_description_notice' => 'SEO optimization description', 
     45        'page_create_sort' => 'Sort', 
     46        'page_create_sort_notice' => 'Sets the sorting when displaying', 
     47        'page_create_sort_error' => 'Sorting must be a number', 
    4548        'page_create_active' => 'Show active page',      
     49        'page_create_main' => 'display on the main page', 
    4650        'page_create_submit_save' => 'Save', 
    4751        'page_create_submit_save_ok' => 'New page has been created', 
     
    5256        'page_admin_url' => 'URL', 
    5357        'page_admin_active' => 'Active', 
     58        'page_admin_main' => 'On main', 
     59        'page_admin_sort_up' => 'Move up', 
     60        'page_admin_sort_down' => 'Move down', 
    5461        'page_admin_active_yes' => 'Yes', 
    5562        'page_admin_active_no' => 'No', 
  • trunk/plugins/page/templates/language/russian.php

    r858 r933  
    4141        'page_create_seo_keywords' => 'SEO keywords', 
    4242        'page_create_seo_keywords_notice' => 'Ключевые слова для SEO-оптимизации', 
    43         'page_create_seo_description' => 'SEO description', 
     43        'page_create_seo_description' => 'SEO description',      
    4444        'page_create_seo_description_notice' => 'Описание для SEO-оптимизации', 
     45        'page_create_sort' => 'Сортировка', 
     46        'page_create_sort_notice' => 'Устанавливает сортировку при отображении', 
     47        'page_create_sort_error' => 'Сортировка должна быть числом', 
    4548        'page_create_active' => 'показывать страницу',   
     49        'page_create_main' => 'отображать на главной странице',  
    4650        'page_create_submit_save' => 'сохранить', 
    4751        'page_create_submit_save_ok' => 'Новая страница добавлена', 
     
    5256        'page_admin_url' => 'URL', 
    5357        'page_admin_active' => 'Активна', 
     58        'page_admin_main' => 'На главной', 
     59        'page_admin_sort_up' => 'Переместить выше', 
     60        'page_admin_sort_down' => 'Переместить ниже', 
    5461        'page_admin_active_yes' => 'да', 
    5562        'page_admin_active_no' => 'нет', 
  • trunk/plugins/page/templates/skin/default/actions/ActionPage/add.tpl

    r858 r933  
    7979                                </p> 
    8080 
     81                                <p><label for="page_sort">{$aLang.page_create_sort}:</label><br /> 
     82                                        <input type="text" id="page_sort" name="page_sort" value="{$_aRequest.page_sort}" class="w100p" /> 
     83                                        <span class="form_note">{$aLang.page_create_sort_notice}</span></p> 
     84                                 
    8185                                <p><input type="checkbox" id="page_active" name="page_active" value="1" {if $_aRequest.page_active==1}checked{/if}/> 
    8286                                <label for="page_active"> &mdash; {$aLang.page_create_active}</label>                                                
     87                                </p> 
     88                                 
     89                                <p><input type="checkbox" id="page_main" name="page_main" value="1" {if $_aRequest.page_main==1}checked{/if}/> 
     90                                <label for="page_main"> &mdash; {$aLang.page_create_main}</label>                                                    
    8391                                </p> 
    8492                                         
  • trunk/plugins/page/templates/skin/default/actions/ActionPage/admin.tpl

    r858 r933  
    2222        <th align="left">{$aLang.page_admin_title}</th> 
    2323        <th align="center" width="250px">{$aLang.page_admin_url}</th>            
    24         <th align="center" width="50px">{$aLang.page_admin_active}</th>                  
     24        <th align="center" width="50px">{$aLang.page_admin_active}</th> 
     25        <th align="center" width="70px">{$aLang.page_admin_main}</th>                    
    2526        <th align="center" width="80px">{$aLang.page_admin_action}</th>                  
    2627        </tr> 
     
    3536  <tr class="{$className}" onmouseover="this.className='colored_sel';" onmouseout="this.className='{$className}';">   
    3637    <td align="left" valign="middle"> 
    37         <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;"/> 
     38        <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;"/> 
    3839        <a href="{router page='page'}{$oPage->getUrlFull()}/">{$oPage->getTitle()}</a> 
    3940    </td> 
     
    4849    {/if} 
    4950    </td> 
     51    <td align="center"> 
     52                {if $oPage->getMain()} 
     53                        {$aLang.page_admin_active_yes} 
     54                {else} 
     55                        {$aLang.page_admin_active_no} 
     56                {/if} 
     57        </td> 
    5058    <td align="center">   
    51         <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>              
     59        <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>           
    5260        &nbsp; 
    53         <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>                
     61        <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>                     
     62        <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> 
     63                <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>                                   
    5464    </td>    
    5565  </tr> 
  • trunk/plugins/page/templates/skin/developer/actions/ActionPage/add.tpl

    r925 r933  
    8080        <input type="text" id="page_seo_description" name="page_seo_description" value="{$_aRequest.page_seo_description}" class="input-wide" /> 
    8181        <span class="note">{$aLang.page_create_seo_description_notice}</span></p> 
     82         
     83        <p><label for="page_sort">{$aLang.page_create_sort}:</label><br /> 
     84        <input type="text" id="page_sort" name="page_sort" value="{$_aRequest.page_sort}" class="input-wide" /> 
     85        <span class="note">{$aLang.page_create_sort_notice}</span></p> 
    8286 
    8387        <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> 
     88         
     89        <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> 
    8490         
    8591        <p>                                      
  • trunk/plugins/page/templates/skin/developer/actions/ActionPage/admin.tpl

    r925 r933  
    2525                                <td align="center" width="250px">{$aLang.page_admin_url}</td>            
    2626                                <td align="center" width="50px">{$aLang.page_admin_active}</td>                  
    27                                 <td align="center" width="80px">{$aLang.page_admin_action}</td>                  
     27                                <td align="center" width="70px">{$aLang.page_admin_main}</td>                    
     28                                <td align="center" width="80px">{$aLang.page_admin_action}</td> 
    2829                        </tr> 
    2930                </thead> 
     
    4647                                                {/if} 
    4748                                        </td> 
     49                                        <td align="center"> 
     50                                                {if $oPage->getMain()} 
     51                                                        {$aLang.page_admin_active_yes} 
     52                                                {else} 
     53                                                        {$aLang.page_admin_active_no} 
     54                                                {/if} 
     55                                        </td> 
    4856                                        <td align="center">   
    4957                                                <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>        
    5058                                                <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>                  
    51                                         </td>    
     59                                                <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> 
     60                                                <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> 
     61                                        </td> 
    5262                                </tr> 
    5363                        {/foreach}