fix search blog - refs BT#12324

pull/2487/head
Alex Aragon 8 years ago
parent c1e03c9443
commit bea616652e
  1. 46
      main/blog/blog.php
  2. 16
      main/inc/lib/blog.lib.php
  3. 6
      main/template/default/blog/blog.tpl

@ -400,27 +400,26 @@ switch ($action) {
break;
case 'edit_post' :
$task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0;
if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) {
// we show the form if
// 1. no post data
// 2. there is post data and the required field is empty
if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title']))) {
// if there is post data there is certainly an error in the form
if ($_POST) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}
$formEdit = Blog::display_form_edit_post($blog_id, intval($_GET['post_id']));
} else {
if (isset ($_GET['filter']) && !empty ($_GET['filter'])) {
Blog::display_day_results($blog_id, Database::escape_string($_GET['filter']));
} else {
Blog::display_blog_posts($blog_id);
}
}
// we show the form if
// 1. no post data
// 2. there is post data and the required field is empty
if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title']))) {
// if there is post data there is certainly an error in the form
if ($_POST) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}
} else {
if (isset ($_GET['filter']) && !empty ($_GET['filter'])) {
Blog::display_day_results($blog_id, Database::escape_string($_GET['filter']));
} else {
Blog::display_blog_posts($blog_id);
}
}
} else {
api_not_allowed();
}
$formEdit = Blog::display_form_edit_post($blog_id, intval($_GET['post_id']));
$tpl->assign('content', $formEdit);
$blogLayout = $tpl->get_template('blog/layout.tpl');
break;
@ -479,12 +478,21 @@ switch ($action) {
}
break;
case 'view_search_result' :
Blog :: display_search_results($blog_id, Database::escape_string($_GET['q']));
$listArticles = Blog :: display_search_results($blog_id, Database::escape_string($_GET['q']));
$titleSearch = get_lang('SearchResults');
$tpl->assign('search', $titleSearch);
$tpl->assign('articles', $listArticles);
$blogLayout = $tpl->get_template('blog/blog.tpl');
break;
case '':
default:
if (isset ($_GET['filter']) && !empty ($_GET['filter'])) {
Blog::display_day_results($blog_id, Database::escape_string($_GET['filter']));
$listArticles = Blog::display_day_results($blog_id, Database::escape_string($_GET['filter']));
$dateSearch = api_format_date($_GET['filter'], DATE_FORMAT_LONG);
$titleSearch = get_lang('PostsOf') . ' ' . $dateSearch;
$tpl->assign('search', $titleSearch);
$tpl->assign('articles', $listArticles);
$blogLayout = $tpl->get_template('blog/blog.tpl');
} else {
$listArticles = Blog::display_blog_posts($blog_id);
$tpl->assign('articles', $listArticles);

@ -923,8 +923,8 @@ class Blog
$query_string = '('.implode('OR',$query_string) . ')';
// Display the posts
echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
Blog::display_blog_posts($blog_id, $query_string);
//echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
return Blog::display_blog_posts($blog_id, $query_string);
}
/**
@ -935,16 +935,16 @@ class Blog
*/
public static function display_day_results($blog_id, $query_string)
{
$date_output = $query_string;
//$date_output = $query_string;
$date = explode('-',$query_string);
$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
// Put date in correct output format
$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
//$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
// Display the posts
echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
Blog::display_blog_posts($blog_id, $query_string);
//echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
$list = Blog::display_blog_posts($blog_id, $query_string);
return $list;
}
/**

@ -40,12 +40,18 @@
<div class="col-md-9">
<div class="blog">
<div id="blog-header">
{% if not search %}
<div class="title">
<h1>{{ title }}</h1>
</div>
<div class="description">
{{ description }}
</div>
{% else %}
<div class="title">
<h1>{{ search }}</h1>
</div>
{% endif %}
</div>
<div id="list-articles">
{% for item in articles %}

Loading…
Cancel
Save