XoopsModules25x /
oledrion
| 1 | <?php |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * oledrion |
||
| 14 | * |
||
| 15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
| 17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
| 18 | */ |
||
| 19 | |||
| 20 | use XoopsModules\Oledrion; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @return array |
||
| 24 | */ |
||
| 25 | function b_sitemap_oledrion() |
||
| 26 | { |
||
| 27 | require_once dirname(__DIR__) . '/oledrion/header.php'; |
||
| 28 | global $sitemap_configs; |
||
| 29 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 30 | $table = $xoopsDB->prefix('oledrion_cat'); |
||
| 31 | $id_name = 'cat_cid'; |
||
| 32 | $pid_name = 'cat_pid'; |
||
| 33 | $title_name = 'cat_title'; |
||
| 34 | $url = 'category.php?cat_cid='; |
||
| 35 | $order = 'cat_title'; |
||
| 36 | |||
| 37 | require_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; |
||
| 38 | $mytree = new \XoopsTree($table, $id_name, $pid_name); |
||
| 39 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 40 | |||
| 41 | $sitemap = []; |
||
| 42 | $myts = \MyTextSanitizer::getInstance(); |
||
| 43 | |||
| 44 | $i = 0; |
||
| 45 | $sql = "SELECT `$id_name`,`$title_name` FROM `$table` WHERE `$pid_name`=0"; |
||
| 46 | if ('' !== $order) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 47 | $sql .= " ORDER BY `$order`"; |
||
| 48 | } |
||
| 49 | $result = $xoopsDB->query($sql); |
||
| 50 | while (list($catid, $name) = $xoopsDB->fetchRow($result)) { |
||
| 51 | $sitemap['parent'][$i]['id'] = $catid; |
||
| 52 | $sitemap['parent'][$i]['title'] = $myts->htmlSpecialChars($name); |
||
| 53 | if (1 == Oledrion\Utility::getModuleOption('urlrewriting')) { |
||
| 54 | // On utilise l'url rewriting |
||
| 55 | $url = 'category' . '-' . (int)$catid . Oledrion\Utility::makeSeoUrl($name) . '.html'; |
||
| 56 | } else { |
||
| 57 | // Pas d'utilisation de l'url rewriting |
||
| 58 | $url = 'category.php?cat_cid=' . (int)$catid; |
||
| 59 | } |
||
| 60 | $sitemap['parent'][$i]['url'] = $url; |
||
| 61 | |||
| 62 | if (@$sitemap_configs['show_subcategoris']) { |
||
| 63 | $j = 0; |
||
| 64 | $child_ary = $mytree->getChildTreeArray($catid, $order); |
||
| 65 | foreach ($child_ary as $child) { |
||
| 66 | $count = mb_strlen($child['prefix']) + 1; |
||
| 67 | $sitemap['parent'][$i]['child'][$j]['id'] = $child[$id_name]; |
||
| 68 | $sitemap['parent'][$i]['child'][$j]['title'] = $myts->htmlSpecialChars($child[$title_name]); |
||
| 69 | $sitemap['parent'][$i]['child'][$j]['image'] = (($count > 3) ? 4 : $count); |
||
| 70 | if (1 == Oledrion\Utility::getModuleOption('urlrewriting')) { |
||
| 71 | // On utilise l'url rewriting |
||
| 72 | $url = 'category' . '-' . (int)$child[$id_name] . Oledrion\Utility::makeSeoUrl($child[$title_name]) . '.html'; |
||
| 73 | } else { |
||
| 74 | // Pas d'utilisation de l'url rewriting |
||
| 75 | $url = 'category.php?cat_cid=' . (int)$child[$id_name]; |
||
| 76 | } |
||
| 77 | $sitemap['parent'][$i]['child'][$j]['url'] = $url; |
||
| 78 | |||
| 79 | ++$j; |
||
| 80 | } |
||
| 81 | } |
||
| 82 | ++$i; |
||
| 83 | } |
||
| 84 | |||
| 85 | return $sitemap; |
||
| 86 | } |
||
| 87 |