dispaly between dates
This commit is contained in:
parent
58637c0d86
commit
ff0d65a600
5 changed files with 24 additions and 11 deletions
|
@ -121,7 +121,9 @@ To check if your server is set up correctly, turn on a debug mode (in config add
|
|||
* Highlight your goal using `[goal]Text of your goal.[/goal]`.
|
||||
* Use tags in posts (allowed characters `A-Za-z0-9-_` terminated by space or EOL): `#song`
|
||||
* Sort posts by hashtags: `http://blog/#tag=songs`
|
||||
* Sort posts by time in url using (format YYYY-MM-DD): `http://blog/#until=2017-06-01`.
|
||||
* Sort posts by location in url using: `http://blog/#loc=Vienna`.
|
||||
* Display posts from chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#from=2017-06`.
|
||||
* Display posts to chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#to=2017-06`.
|
||||
* Combine parameters in url using `&`, e.g. show posts between dates: `http://blog/#from=2017-06&to=2017-08`.
|
||||
|
||||

|
||||
|
|
|
@ -284,13 +284,22 @@ class Post
|
|||
}
|
||||
|
||||
public static function load($r){
|
||||
$until = [];
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}$/", @$r["filter"]["until"])){
|
||||
$until = $r["filter"]["until"]."-01 00:00";
|
||||
$from = [];
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}$/", @$r["filter"]["from"])){
|
||||
$from = $r["filter"]["from"]."-01 00:00";
|
||||
}
|
||||
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", @$r["filter"]["until"])){
|
||||
$until = $r["filter"]["until"]." 23:59";
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", @$r["filter"]["from"])){
|
||||
$from = $r["filter"]["from"]." 00:00";
|
||||
}
|
||||
|
||||
$to = [];
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}$/", @$r["filter"]["to"])){
|
||||
$to = $r["filter"]["to"]."-01 00:00";
|
||||
}
|
||||
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", @$r["filter"]["to"])){
|
||||
$to = $r["filter"]["to"]." 00:00";
|
||||
}
|
||||
|
||||
$id = [];
|
||||
|
@ -318,14 +327,15 @@ class Post
|
|||
"FROM `posts` ".
|
||||
"WHERE ".
|
||||
(!User::is_logged_in() ? (User::is_visitor() ? "`privacy` IN ('public', 'friends') AND " : "`privacy` = 'public' AND ") : "").
|
||||
($until ? "`posts`.`datetime` < DATE_ADD(?, INTERVAL +1 MONTH) AND " : "").
|
||||
($from ? "`posts`.`datetime` > ? AND " : "").
|
||||
($to ? "`posts`.`datetime` < ? AND " : "").
|
||||
($id ? "`id` = ? AND " : "").
|
||||
($tag ? "`plain_text` LIKE CONCAT('%', ?, '%') AND " : "").
|
||||
($loc ? "`location` LIKE CONCAT('%', ?, '%') AND " : "").
|
||||
($person ? "`persons` LIKE CONCAT('%', ?, '%') AND " : "").
|
||||
"`status` = 1 ".
|
||||
"ORDER BY `posts`.`datetime` DESC ".
|
||||
"LIMIT ? OFFSET ?", $until, $id, $tag, $loc, $person, $r["limit"], $r["offset"]
|
||||
"LIMIT ? OFFSET ?", $from, $to, $id, $tag, $loc, $person, $r["limit"], $r["offset"]
|
||||
)->all();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,6 @@ logs_path = data/logs/
|
|||
|
||||
[system]
|
||||
system_name = blog
|
||||
version = 1.23
|
||||
version = 1.231
|
||||
debug = false
|
||||
logs = false
|
|
@ -322,7 +322,7 @@ if(!empty($scripts)){
|
|||
|
||||
<div id="eof_feed">
|
||||
<img src="static/images/zpEYXu5Wdu6.png">
|
||||
<p><?php echo Config::get("version"); ?> © 2016-2019 <br>Miroslav Šedivý</p>
|
||||
<p><?php echo Config::get("version"); ?> © 2016-2020 <br>Miroslav Šedivý</p>
|
||||
</div>
|
||||
<script src="static/scripts/jquery.min.js"></script>
|
||||
<script>$["\x61\x6A\x61\x78\x53\x65\x74\x75\x70"]({"\x68\x65\x61\x64\x65\x72\x73":{"\x43\x73\x72\x66-\x54\x6F\x6B\x65\x6E":"<?php echo $_SESSION['token'];?>"}});</script>
|
||||
|
|
|
@ -14,7 +14,8 @@ var posts = {
|
|||
offset: 0, // Current offset
|
||||
|
||||
filter: {
|
||||
until: null, // Show posts until specified date
|
||||
from: null, // Show posts from specified date
|
||||
to: null, // Show posts to specified date
|
||||
id: null, // Show only one post with specified id
|
||||
tag: null, // Show posts that contains specified tag
|
||||
loc: null, // Show posts that location contains specified location
|
||||
|
|
Loading…
Add table
Reference in a new issue