tweak archive widget for articles
This commit is contained in:
parent
b25192332b
commit
6ecd31a715
@ -51,6 +51,8 @@ class Articles extends \Zotlabs\Web\Controller {
|
|||||||
$sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY));
|
$sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
|
||||||
|
$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : '');
|
||||||
|
|
||||||
$which = argv(1);
|
$which = argv(1);
|
||||||
|
|
||||||
@ -143,10 +145,21 @@ class Articles extends \Zotlabs\Web\Controller {
|
|||||||
$sql_item = "and item.id = " . intval($r[0]['iid']) . " ";
|
$sql_item = "and item.id = " . intval($r[0]['iid']) . " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($datequery) {
|
||||||
|
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
|
||||||
|
$order = 'post';
|
||||||
|
}
|
||||||
|
if($datequery2) {
|
||||||
|
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($datequery || $datequery2) {
|
||||||
|
$sql_extra2 .= " and item.item_thread_top != 0 ";
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("select * from item
|
$r = q("select * from item
|
||||||
where item.uid = %d and item_type = %d
|
where item.uid = %d and item_type = %d
|
||||||
$sql_extra $sql_item order by item.created desc $pager_sql",
|
$sql_extra $sql_extra2 $sql_item order by item.created desc $pager_sql",
|
||||||
intval($owner),
|
intval($owner),
|
||||||
intval(ITEM_TYPE_ARTICLE)
|
intval(ITEM_TYPE_ARTICLE)
|
||||||
);
|
);
|
||||||
|
@ -22,12 +22,12 @@ class Archive {
|
|||||||
return '';
|
return '';
|
||||||
|
|
||||||
$wall = ((array_key_exists('wall', $arr)) ? intval($arr['wall']) : 0);
|
$wall = ((array_key_exists('wall', $arr)) ? intval($arr['wall']) : 0);
|
||||||
|
$wall = ((array_key_exists('articles', $arr)) ? 2 : $wall);
|
||||||
|
|
||||||
$style = ((array_key_exists('style', $arr)) ? $arr['style'] : 'select');
|
$style = ((array_key_exists('style', $arr)) ? $arr['style'] : 'select');
|
||||||
$showend = ((get_pconfig($uid,'system','archive_show_end_date')) ? true : false);
|
$showend = ((get_pconfig($uid,'system','archive_show_end_date')) ? true : false);
|
||||||
$mindate = get_pconfig($uid,'system','archive_mindate');
|
$mindate = get_pconfig($uid,'system','archive_mindate');
|
||||||
$visible_years = get_pconfig($uid,'system','archive_visible_years');
|
$visible_years = get_pconfig($uid,'system','archive_visible_years',5);
|
||||||
if(! $visible_years)
|
|
||||||
$visible_years = 5;
|
|
||||||
|
|
||||||
$url = z_root() . '/' . \App::$cmd;
|
$url = z_root() . '/' . \App::$cmd;
|
||||||
|
|
||||||
|
@ -3782,18 +3782,30 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
|
|||||||
*
|
*
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* @param boolean $wall (optional) default false
|
* @param boolean $wall (optional) default false
|
||||||
|
* hack: $wall = 2 selects articles
|
||||||
* @return string|boolean date string, otherwise false
|
* @return string|boolean date string, otherwise false
|
||||||
*/
|
*/
|
||||||
function first_post_date($uid, $wall = false) {
|
function first_post_date($uid, $wall = false) {
|
||||||
|
|
||||||
$wall_sql = (($wall) ? " and item_wall = 1 " : "" );
|
$wall_sql = (($wall === 1) ? " and item_wall = 1 " : "" );
|
||||||
|
if($wall === 2) {
|
||||||
|
$wall_sql = " and item_type = 7 ";
|
||||||
|
$item_normal = " and item.item_hidden = 0 and item.item_type = 7 and item.item_deleted = 0
|
||||||
|
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
|
||||||
|
and item.item_blocked = 0 ";
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
$item_normal = item_normal();
|
$item_normal = item_normal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$r = q("select id, created from item
|
$r = q("select id, created from item
|
||||||
where uid = %d and id = parent $item_normal $wall_sql
|
where uid = %d and id = parent $item_normal $wall_sql
|
||||||
order by created asc limit 1",
|
order by created asc limit 1",
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
|
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
|
||||||
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
|
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
[region=aside]
|
[region=aside]
|
||||||
|
[widget=archive][var=articles]1[/var][/widget]
|
||||||
[widget=categories][var=articles]1[/var][/widget]
|
[widget=categories][var=articles]1[/var][/widget]
|
||||||
[widget=tasklist][/widget]
|
[widget=tasklist][/widget]
|
||||||
[widget=notes][/widget]
|
[widget=notes][/widget]
|
||||||
|
Reference in New Issue
Block a user