1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Возможность выбрать в меню отображение всех новых топиков без ограничения по дате "новизны"

This commit is contained in:
Mzhelskiy Maxim 2012-06-16 16:02:20 +04:00
parent f0963ab257
commit a5908a3a84
9 changed files with 91 additions and 14 deletions

View file

@ -120,6 +120,7 @@ class ActionBlog extends Action {
$this->AddEvent('good',array('EventTopics','topics'));
$this->AddEventPreg('/^bad$/i','/^(page(\d+))?$/i',array('EventTopics','topics'));
$this->AddEventPreg('/^new$/i','/^(page(\d+))?$/i',array('EventTopics','topics'));
$this->AddEventPreg('/^newall$/i','/^(page(\d+))?$/i',array('EventTopics','topics'));
$this->AddEventPreg('/^discussed$/i','/^(page(\d+))?$/i',array('EventTopics','topics'));
$this->AddEventPreg('/^top$/i','/^(page(\d+))?$/i',array('EventTopics','topics'));
@ -142,6 +143,7 @@ class ActionBlog extends Action {
$this->AddEventPreg('/^[\w\-\_]+$/i','/^(page(\d+))?$/i',array('EventShowBlog','blog'));
$this->AddEventPreg('/^[\w\-\_]+$/i','/^bad$/i','/^(page(\d+))?$/i',array('EventShowBlog','blog'));
$this->AddEventPreg('/^[\w\-\_]+$/i','/^new$/i','/^(page(\d+))?$/i',array('EventShowBlog','blog'));
$this->AddEventPreg('/^[\w\-\_]+$/i','/^newall$/i','/^(page(\d+))?$/i',array('EventShowBlog','blog'));
$this->AddEventPreg('/^[\w\-\_]+$/i','/^discussed$/i','/^(page(\d+))?$/i',array('EventShowBlog','blog'));
$this->AddEventPreg('/^[\w\-\_]+$/i','/^top$/i','/^(page(\d+))?$/i',array('EventShowBlog','blog'));
@ -578,7 +580,7 @@ class ActionBlog extends Action {
/**
* Меню
*/
$this->sMenuSubItemSelect=$sShowType;
$this->sMenuSubItemSelect=$sShowType=='newall' ? 'new' : $sShowType;
/**
* Передан ли номер страницы
*/
@ -811,7 +813,7 @@ class ActionBlog extends Action {
$sPeriod=getRequest('period');
}
$sBlogUrl=$this->sCurrentEvent;
$sShowType=in_array($this->GetParamEventMatch(0,0),array('bad','new','discussed','top')) ? $this->GetParamEventMatch(0,0) : 'good';
$sShowType=in_array($this->GetParamEventMatch(0,0),array('bad','new','newall','discussed','top')) ? $this->GetParamEventMatch(0,0) : 'good';
if (!in_array($sShowType,array('discussed','top'))) {
$sPeriod='all';
}
@ -839,7 +841,7 @@ class ActionBlog extends Action {
/**
* Меню
*/
$this->sMenuSubItemSelect=$sShowType;
$this->sMenuSubItemSelect=$sShowType=='newall' ? 'new' : $sShowType;
$this->sMenuSubBlogUrl=$oBlog->getUrlFull();
/**
* Передан ли номер страницы

View file

@ -78,6 +78,7 @@ class ActionIndex extends Action {
protected function RegisterEvent() {
$this->AddEventPreg('/^(page(\d+))?$/i','EventIndex');
$this->AddEventPreg('/^new$/i','/^(page(\d+))?$/i','EventNew');
$this->AddEventPreg('/^newall$/i','/^(page(\d+))?$/i','EventNewAll');
$this->AddEventPreg('/^discussed/i','/^(page(\d+))?$/i','EventDiscussed');
$this->AddEventPreg('/^top/i','/^(page(\d+))?$/i','EventTop');
}
@ -226,6 +227,42 @@ class ActionIndex extends Action {
*/
$this->SetTemplateAction('index');
}
/**
* Вывод ВСЕХ новых топиков
*/
protected function EventNewAll() {
$this->Viewer_SetHtmlRssAlternate(Router::GetPath('rss').'new/',Config::Get('view.name'));
/**
* Меню
*/
$this->sMenuSubItemSelect='new';
/**
* Передан ли номер страницы
*/
$iPage=$this->GetParamEventMatch(0,2) ? $this->GetParamEventMatch(0,2) : 1;
/**
* Получаем список топиков
*/
$aResult=$this->Topic_GetTopicsNewAll($iPage,Config::Get('module.topic.per_page'));
$aTopics=$aResult['collection'];
/**
* Вызов хуков
*/
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('index').'newall');
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aTopics',$aTopics);
$this->Viewer_Assign('aPaging',$aPaging);
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('index');
}
/**
* Вывод интересных на главную
*

View file

@ -57,6 +57,7 @@ class ActionPersonalBlog extends Action {
$this->AddEvent('good','EventTopics');
$this->AddEventPreg('/^bad$/i','/^(page(\d+))?$/i','EventTopics');
$this->AddEventPreg('/^new$/i','/^(page(\d+))?$/i','EventTopics');
$this->AddEventPreg('/^newall$/i','/^(page(\d+))?$/i','EventTopics');
$this->AddEventPreg('/^discussed/i','/^(page(\d+))?$/i','EventTopics');
$this->AddEventPreg('/^top/i','/^(page(\d+))?$/i','EventTopics');
}
@ -83,7 +84,7 @@ class ActionPersonalBlog extends Action {
/**
* Меню
*/
$this->sMenuSubItemSelect=$sShowType;
$this->sMenuSubItemSelect=$sShowType=='newall' ? 'new' : $sShowType;
/**
* Передан ли номер страницы
*/

View file

@ -571,7 +571,7 @@ class ModuleTopic extends Module {
return $this->GetTopicsByFilter($aFilter,$iPage,$iPerPage);
}
/**
* Получает список ВСЕХ новых топиков
* Получает список новых топиков, ограничение новизны по дате из конфига
*
* @param int $iPage
* @param int $iPerPage
@ -600,6 +600,34 @@ class ModuleTopic extends Module {
}
return $this->GetTopicsByFilter($aFilter,$iPage,$iPerPage);
}
/**
* Получает список ВСЕХ новых топиков
*
* @param int $iPage
* @param int $iPerPage
* @param bool $bAddAccessible Указывает на необходимость добавить в выдачу топики,
* из блогов доступных пользователю. При указании false,
* в выдачу будут переданы только топики из общедоступных блогов.
* @return array
*/
public function GetTopicsNewAll($iPage,$iPerPage,$bAddAccessible=true) {
$aFilter=array(
'blog_type' => array(
'personal',
'open',
),
'topic_publish' => 1,
);
/**
* Если пользователь авторизирован, то добавляем в выдачу
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent && $bAddAccessible) {
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
if(count($aOpenBlogs)) $aFilter['blog_type']['close'] = $aOpenBlogs;
}
return $this->GetTopicsByFilter($aFilter,$iPage,$iPerPage);
}
/**
* Получает список ВСЕХ обсуждаемых топиков
*
@ -742,6 +770,9 @@ class ModuleTopic extends Module {
case 'new':
$aFilter['topic_new']=date("Y-m-d H:00:00",time()-Config::Get('module.topic.new_time'));
break;
case 'newall':
// нет доп фильтра
break;
case 'discussed':
$aFilter['order']=array('t.topic_count_comment desc','t.topic_id desc');
break;
@ -907,6 +938,9 @@ class ModuleTopic extends Module {
case 'new':
$aFilter['topic_new']=date("Y-m-d H:00:00",time()-Config::Get('module.topic.new_time'));
break;
case 'newall':
// нет доп фильтра
break;
case 'discussed':
$aFilter['order']=array('t.topic_count_comment desc','t.topic_id desc');
break;
@ -1011,6 +1045,9 @@ class ModuleTopic extends Module {
case 'new':
$aFilter['topic_new']=date("Y-m-d H:00:00",time()-Config::Get('module.topic.new_time'));
break;
case 'newall':
// нет доп фильтра
break;
case 'discussed':
$aFilter['order']=array('t.topic_count_comment desc','t.topic_id desc');
break;

View file

@ -128,7 +128,7 @@
<div class="nav-filter-wrapper">
<ul class="nav nav-filter">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{$sMenuSubBlogUrl}">{$aLang.blog_menu_collective_good}</a></li>
{if $iCountTopicsBlogNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}new/">{$aLang.blog_menu_collective_new} +{$iCountTopicsBlogNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}newall/">{$aLang.blog_menu_collective_new}</a>{if $iCountTopicsBlogNew>0} <a href="{$sMenuSubBlogUrl}new/">+{$iCountTopicsBlogNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{$sMenuSubBlogUrl}discussed/">{$aLang.blog_menu_collective_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{$sMenuSubBlogUrl}top/">{$aLang.blog_menu_collective_top}</a></li>
{hook run='menu_blog_blog_item'}

View file

@ -26,7 +26,7 @@
{if $sMenuItemSelect=='index'}
<ul class="nav nav-filter nav-filter-sub">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{cfg name='path.root.web'}/">{$aLang.blog_menu_all_good}</a></li>
{if $iCountTopicsNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='index'}new/">{$aLang.blog_menu_all_new} +{$iCountTopicsNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='index'}newall/">{$aLang.blog_menu_all_new}</a>{if $iCountTopicsNew>0} <a href="{router page='index'}new/">+{$iCountTopicsNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{router page='index'}discussed/">{$aLang.blog_menu_all_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{router page='index'}top/">{$aLang.blog_menu_all_top}</a></li>
{hook run='menu_blog_index_item'}
@ -36,7 +36,7 @@
{if $sMenuItemSelect=='blog'}
<ul class="nav nav-filter nav-filter-sub">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{$sMenuSubBlogUrl}">{$aLang.blog_menu_collective_good}</a></li>
{if $iCountTopicsBlogNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}new/">{$aLang.blog_menu_collective_new} +{$iCountTopicsBlogNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}newall/">{$aLang.blog_menu_collective_new}</a>{if $iCountTopicsBlogNew>0} <a href="{$sMenuSubBlogUrl}new/">+{$iCountTopicsBlogNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{$sMenuSubBlogUrl}discussed/">{$aLang.blog_menu_collective_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{$sMenuSubBlogUrl}top/">{$aLang.blog_menu_collective_top}</a></li>
{hook run='menu_blog_blog_item'}
@ -46,7 +46,7 @@
{if $sMenuItemSelect=='log'}
<ul class="nav nav-filter nav-filter-sub">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{router page='personal_blog'}">{$aLang.blog_menu_personal_good}</a></li>
{if $iCountTopicsPersonalNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='personal_blog'}new/">{$aLang.blog_menu_personal_new} +{$iCountTopicsPersonalNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='personal_blog'}newall/">{$aLang.blog_menu_personal_new}</a>{if $iCountTopicsPersonalNew>0} <a href="{router page='personal_blog'}new/">+{$iCountTopicsPersonalNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{router page='personal_blog'}discussed/">{$aLang.blog_menu_personal_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{router page='personal_blog'}top/">{$aLang.blog_menu_personal_top}</a></li>
{hook run='menu_blog_log_item'}

View file

@ -171,7 +171,7 @@
<div class="nav-menu-wrapper">
<ul class="nav nav-pills">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{$sMenuSubBlogUrl}">{$aLang.blog_menu_collective_good}</a></li>
{if $iCountTopicsBlogNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}new/">{$aLang.blog_menu_collective_new} +{$iCountTopicsBlogNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}newall/">{$aLang.blog_menu_collective_new}</a>{if $iCountTopicsBlogNew>0} <a href="{$sMenuSubBlogUrl}new/">+{$iCountTopicsBlogNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{$sMenuSubBlogUrl}discussed/">{$aLang.blog_menu_collective_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{$sMenuSubBlogUrl}top/">{$aLang.blog_menu_collective_top}</a></li>
{hook run='menu_blog_blog_item'}

View file

@ -1,3 +1,3 @@
{include file='header.tpl' menu='blog'}
{include file='header.tpl' menu='blog' menu_content='blog'}
{include file='topic_list.tpl'}
{include file='footer.tpl'}

View file

@ -1,7 +1,7 @@
{if $sMenuItemSelect=='index'}
<ul class="nav nav-pills mb-30">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{cfg name='path.root.web'}/">{$aLang.blog_menu_all_good}</a></li>
{if $iCountTopicsNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='index'}new/">{$aLang.blog_menu_all_new} +{$iCountTopicsNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='index'}newall/">{$aLang.blog_menu_all_new}</a>{if $iCountTopicsNew>0} <a href="{router page='index'}new/">+{$iCountTopicsNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{router page='index'}discussed/">{$aLang.blog_menu_all_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{router page='index'}top/">{$aLang.blog_menu_all_top}</a></li>
{hook run='menu_blog_index_item'}
@ -11,7 +11,7 @@
{if $sMenuItemSelect=='blog'}
<ul class="nav nav-pills mb-30">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{$sMenuSubBlogUrl}">{$aLang.blog_menu_collective_good}</a></li>
{if $iCountTopicsBlogNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}new/">{$aLang.blog_menu_collective_new} +{$iCountTopicsBlogNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{$sMenuSubBlogUrl}newall/">{$aLang.blog_menu_collective_new}</a>{if $iCountTopicsBlogNew>0} <a href="{$sMenuSubBlogUrl}new/">+{$iCountTopicsBlogNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{$sMenuSubBlogUrl}discussed/">{$aLang.blog_menu_collective_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{$sMenuSubBlogUrl}top/">{$aLang.blog_menu_collective_top}</a></li>
{hook run='menu_blog_blog_item'}
@ -21,7 +21,7 @@
{if $sMenuItemSelect=='log'}
<ul class="nav nav-pills mb-30">
<li {if $sMenuSubItemSelect=='good'}class="active"{/if}><a href="{router page='personal_blog'}">{$aLang.blog_menu_personal_good}</a></li>
{if $iCountTopicsPersonalNew>0}<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='personal_blog'}new/">{$aLang.blog_menu_personal_new} +{$iCountTopicsPersonalNew}</a></li>{/if}
<li {if $sMenuSubItemSelect=='new'}class="active"{/if}><a href="{router page='personal_blog'}newall/">{$aLang.blog_menu_personal_new}</a>{if $iCountTopicsPersonalNew>0} <a href="{router page='personal_blog'}new/">+{$iCountTopicsPersonalNew}</a>{/if}</li>
<li {if $sMenuSubItemSelect=='discussed'}class="active"{/if}><a href="{router page='personal_blog'}discussed/">{$aLang.blog_menu_personal_discussed}</a></li>
<li {if $sMenuSubItemSelect=='top'}class="active"{/if}><a href="{router page='personal_blog'}top/">{$aLang.blog_menu_personal_top}</a></li>
{hook run='menu_blog_log_item'}