1
0

Fix a lot of single issues and overhaul the language settings

see docs/NEWS and the plugin/changelog files for details
This commit is contained in:
Stephan Brunker
2019-10-13 22:49:03 +02:00
parent b10bbcc2e1
commit 502b837dd6
18 changed files with 730 additions and 596 deletions

View File

@ -146,10 +146,15 @@ function &serendipity_fetchEntryCategories($entryid) {
ORDER BY c.category_name ASC";
$cat =& serendipity_db_query($query);
if (!is_array($cat)) {
$arr = array();
return $arr;
} else {
foreach ($cat as $key => $catdata) {
serendipity_plugin_api::hook_event('multilingual_strip_langs',$cat[$key]['category_name']);
serendipity_plugin_api::hook_event('multilingual_strip_langs',$cat[$key]['category_description']);
}
return $cat;
}
}
@ -511,6 +516,8 @@ function serendipity_fetchEntryData(&$ret) {
if (is_array($search_ret)) {
foreach($search_ret AS $i => $entry) {
serendipity_plugin_api::hook_event('multilingual_strip_langs',$entry['category_name']);
serendipity_plugin_api::hook_event('multilingual_strip_langs',$entry['category_description']);
$ret[$assoc_ids[$entry['entryid']]]['categories'][] = $entry;
}
}
@ -722,9 +729,16 @@ function &serendipity_fetchCategories($authorid = null, $name = null, $order = n
$flat_cats = array();
$flat_cats[0] = NO_CATEGORY;
foreach($cats AS $catidx => $catdata) {
serendipity_plugin_api::hook_event('multilingual_strip_langs', $catdata['category_name']);
$flat_cats[$catdata['categoryid']] = str_repeat(' ', $catdata['depth']*2) . serendipity_specialchars($catdata['category_name']);
}
return $flat_cats;
} else {
foreach ($ret as $key => $catdata) {
serendipity_plugin_api::hook_event('multilingual_strip_langs',$ret[$key]['category_name']);
serendipity_plugin_api::hook_event('multilingual_strip_langs',$ret[$key]['category_description']);
}
return $ret;
}
}
return $ret;
@ -1659,18 +1673,25 @@ function serendipity_printArchives() {
$distinct = '';
}
// if another language than default is selected and hide option is set, hide untranslated articles
$sql_condition = array();
serendipity_plugin_api::hook_event('frontend_fetchentries', $sql_condition);
$q = "SELECT $distinct e.timestamp
FROM {$serendipity['dbPrefix']}entries e
" . (!empty($cat_sql) ? "
LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
ON e.id = ec.entryid
LEFT JOIN {$serendipity['dbPrefix']}category c
ON ec.categoryid = c.categoryid" : "") . "
WHERE isdraft = 'false'"
ON ec.categoryid = c.categoryid" : "") .
$sql_condition['joins'] .
" WHERE isdraft = 'false'"
. $sql_condition['and']
. (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : '')
. (!empty($cat_sql) ? ' AND ' . $cat_sql : '')
. (!empty($serendipity['GET']['viewAuthor']) ? ' AND e.authorid = ' . (int)$serendipity['GET']['viewAuthor'] : '')
. (!empty($cat_sql) ? " GROUP BY e.id, e.timestamp" : '');
$entries =& serendipity_db_query($q, false, 'assoc');
$group = array();
@ -1682,7 +1703,7 @@ function serendipity_printArchives() {
$output = array();
for ($y = $thisYear; $y >= $lastYear; $y--) {
$output[$y]['year'] = $y;
for ($m = 12; $m >= 1; $m--) {
/* If the month we are checking are in the future, we drop it */
@ -1710,6 +1731,10 @@ function serendipity_printArchives() {
$entry_count = (int)$group[$y . (strlen($m) == 1 ? '0' : '') . $m];
if ($entry_count > 0) {
if (!array_key_exists($y,$output)) $output[$y]['year'] = $y;
/* A silly hack to get the maximum amount of entries per month */
if ($entry_count > $max) {
$max = $entry_count;
@ -1721,6 +1746,7 @@ function serendipity_printArchives() {
$data['link_summary'] = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m) . $cat_get . $author_get, true);
$data['date'] = $s;
$output[$y]['months'][] = $data;
}
}
}