Skip to content

Commit 6fc3a65

Browse files
committed
fix for blocks options
mambax7#15
1 parent 1dd55cc commit 6fc3a65

2 files changed

Lines changed: 27 additions & 25 deletions

File tree

blocks/block.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function tag_block_cloud_show(array $options, string $dirname = '', int $catid =
124124
$criteria->add(new \Criteria('l.tag_catid', (string)$catid));
125125
}
126126
}
127-
if (!$tags_array = $tagHandler->getByLimit($options[0], Constants::BEGINNING, $criteria, null, empty($options[1]))) {
127+
if (!$tags_array = $tagHandler->getByLimit((int)$options[0], Constants::BEGINNING, $criteria, null, empty($options[1]))) {
128128
return $block;
129129
}
130130

@@ -281,7 +281,7 @@ function tag_block_top_show(array $options, string $dirname = '', int $catid = 0
281281
$criteria->add(new \Criteria('l.tag_catid', (string)$catid));
282282
}
283283
}
284-
if (!$tags_array = $tagHandler->getByLimit(0, 0, $criteria, null, false)) {
284+
if (!$tags_array = $tagHandler->getByLimit((int)$options[0], Constants::BEGINNING, $criteria, null, false)) {
285285
return $block;
286286
}
287287

@@ -326,28 +326,28 @@ function tag_block_top_show(array $options, string $dirname = '', int $catid = 0
326326

327327
//-------------------------------------------
328328

329-
$sql = 'SELECT o.tag_id, COUNT(o.tag_id) AS count_tag, l.tag_term
330-
FROM ' . $GLOBALS['xoopsDB']->prefix('tag_link') . ' AS o
331-
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('tag_tag') . ' AS l ON l.tag_id = o.tag_id
332-
GROUP BY o.tag_id
333-
ORDER BY count_tag DESC';
334-
$result = $GLOBALS['xoopsDB']->query($sql);
335-
if ($result instanceof \mysqli_result) {
336-
$tags_array2 = [];
337-
$tags_data_array = [];
338-
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
339-
$tags_array2[] = $myrow;
340-
}
341-
foreach ($tags_array2 as $tag) {
342-
$tags_data_array[] = [
343-
'id' => $tag['tag_id'],
344-
'term' => $tag['tag_term'],
345-
'count' => $tag['count_tag'],
346-
];
347-
}
348-
} else {
349-
\trigger_error($GLOBALS['xoopsDB']->error());
350-
}
329+
// $sql = 'SELECT o.tag_id, COUNT(o.tag_id) AS count_tag, l.tag_term
330+
//FROM ' . $GLOBALS['xoopsDB']->prefix('tag_link') . ' AS o
331+
//LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('tag_tag') . ' AS l ON l.tag_id = o.tag_id
332+
//GROUP BY o.tag_id
333+
//ORDER BY count_tag DESC' . ' LIMIT ' . $options[0];
334+
// $result = $GLOBALS['xoopsDB']->query($sql);
335+
// if ($result instanceof \mysqli_result) {
336+
// $tags_array2 = [];
337+
// $tags_data_array2 = [];
338+
// while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
339+
// $tags_array2[] = $myrow;
340+
// }
341+
// foreach ($tags_array2 as $tag) {
342+
// $tags_data_array2[] = [
343+
// 'id' => $tag['tag_id'],
344+
// 'term' => $tag['tag_term'],
345+
// 'count' => $tag['count_tag'],
346+
// ];
347+
// }
348+
// } else {
349+
// \trigger_error($GLOBALS['xoopsDB']->error());
350+
// }
351351

352352
//-------------------------------------------
353353

class/TagHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ public function &getByLimit($limit = Constants::UNLIMITED, $start = Constants::B
320320
switch ($sort) {
321321
case 'a':
322322
case 'alphabet':
323-
$sql .= " ORDER BY o.tag_term {$order}";
323+
$order = 'ASC';
324+
$sql .= " ORDER BY o.tag_term {$order}";
324325
break;
325326
case 'id':
326327
case 'time':
@@ -329,6 +330,7 @@ public function &getByLimit($limit = Constants::UNLIMITED, $start = Constants::B
329330
case 'c':
330331
case 'count':
331332
default:
333+
$order = 'DESC';
332334
$sql .= " ORDER BY count {$order}";
333335
break;
334336
}

0 commit comments

Comments
 (0)