Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
Исправлен вывод тега {count}, {name}, {value}
Исправлена проблема с перекрёстными ссылками
  • Loading branch information
Gokujo committed Mar 23, 2021
1 parent 65d42f2 commit c342f72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
21 changes: 12 additions & 9 deletions xf_list_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author: Maxim Harder
* @link: https://devcraft.club
* @description: Автоматический генератор списков для вывода доп. полей
* @version: 1.1.0
* @version: 1.1.1
*
*/

Expand All @@ -20,7 +20,7 @@

$limit = (isset($limit) && (int)$limit && (int) $limit !== 0) ? (int)$limit : '18446744073709551615';
$skip = (isset($skip) && (int)$skip && (int) $skip !== 0) ? (int)($skip+1) : 1;
$cprefix = "xf_gen_".$xffield;
$cprefix = "news_xf_gen_".$xffield;
$db_prefix = PREFIX;
$sort = (isset($sort) && in_array($sort, ['asc', 'desc', 'ASC', 'DESC'])) ? $sort : 'ASC';

Expand Down Expand Up @@ -108,11 +108,11 @@ function gen_xfields()
'value' => $buf_split[1],
'type' => $buf_split[3],
'splitter' => empty($buf_split[21]) ? ', ' : $buf_split[21],
'search' => (1 === $buf_split[6]) ? true : false,
'search' => ($buf_split[6] == 1) ? true : false,
'default' => [],
];

if ('select' == $buf_split[3]) {
if ('select' === $buf_split[3]) {
$default_values = explode('__NEWL__', $buf_split[4]);
foreach ($default_values as $val) {
$vals = explode('|', $val);
Expand Down Expand Up @@ -148,8 +148,8 @@ function gen_xfields()
while($gen = $db->get_row()) {
$l++;
$xf = $gen['x'];
if (!in_array($xf, $all_xfs)) {
if ('select' == $xf_chosen['type']) {
if (!in_array($xf, $all_xfs, true)) {
if ('select' === $xf_chosen['type']) {
$value = $xffields[$xffield]['default'][$xf];
} else {
$value = $xf;
Expand All @@ -171,10 +171,13 @@ function gen_xfields()
$min_max_value[] = (int) $xf;
}

// $count = $db->super_query( "SELECT count(*) as total from {$dbprefix}_post WHERE xfields LIKE '%{$xffield}|{$xf}%'");

$gen_tpl->set('{link}', $link);
$gen_tpl->set('{name}', $value);
$gen_tpl->set('{value}', $xf);
$gen_tpl->set('{count}', ((int) $gen['total']/6));
$gen_tpl->set('{name}', $xffield);
$gen_tpl->set('{value}', $value);
// $gen_tpl->set('{count}', (int) $count['total']);
$gen_tpl->set('{count}', (int) ceil(((int) $gen['total']/6)));

$all_xfs[] = $xf;
} else {
Expand Down
17 changes: 10 additions & 7 deletions xfield-list-generator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<name>Xfield List Generator</name>
<description>Создаёт списки доп. полей на основе шаблона.</description>
<icon></icon>
<version>1.1.0</version>
<version>1.1.1</version>
<dleversion>13</dleversion>
<versioncompare>greater</versioncompare>
<upgradeurl></upgradeurl>
Expand Down Expand Up @@ -45,7 +45,7 @@ $where = ["p.xfields LIKE '%{$xffield}|%'"];
$limit = (isset($limit) && (int)$limit && (int) $limit !== 0) ? (int)$limit : '18446744073709551615';
$skip = (isset($skip) && (int)$skip && (int) $skip !== 0) ? (int)($skip+1) : 1;
$cprefix = "xf_gen_".$xffield;
$cprefix = "news_xf_gen_".$xffield;
$db_prefix = PREFIX;
$sort = (isset($sort) && in_array($sort, ['asc', 'desc', 'ASC', 'DESC'])) ? $sort : 'ASC';
Expand Down Expand Up @@ -133,11 +133,11 @@ if (!function_exists('gen_xfields')) {
'value' => $buf_split[1],
'type' => $buf_split[3],
'splitter' => empty($buf_split[21]) ? ', ' : $buf_split[21],
'search' => (1 === $buf_split[6]) ? true : false,
'search' => ($buf_split[6] == 1) ? true : false,
'default' => [],
];
if ('select' == $buf_split[3]) {
if ('select' === $buf_split[3]) {
$default_values = explode('__NEWL__', $buf_split[4]);
foreach ($default_values as $val) {
$vals = explode('&#124;', $val);
Expand Down Expand Up @@ -173,8 +173,8 @@ if( $gen ) {
while($gen = $db->get_row()) {
$l++;
$xf = $gen['x'];
if (!in_array($xf, $all_xfs)) {
if ('select' == $xf_chosen['type']) {
if (!in_array($xf, $all_xfs, true)) {
if ('select' === $xf_chosen['type']) {
$value = $xffields[$xffield]['default'][$xf];
} else {
$value = $xf;
Expand All @@ -196,10 +196,13 @@ if( $gen ) {
$min_max_value[] = (int) $xf;
}
// $count = $db->super_query( "SELECT count(*) as total from {$dbprefix}_post WHERE xfields LIKE '%{$xffield}|{$xf}%'");
$gen_tpl->set('{link}', $link);
$gen_tpl->set('{name}', $value);
$gen_tpl->set('{value}', $xf);
$gen_tpl->set('{count}', ((int) $gen['total']/6));
// $gen_tpl->set('{count}', (int) $count['total']);
$gen_tpl->set('{count}', (int) ceil(((int) $gen['total']/6)));
$all_xfs[] = $xf;
} else {
Expand Down

0 comments on commit c342f72

Please sign in to comment.