/** * Generates a sitemap tree for the vendors model based on the vendors table * * @param int $limit * @param int $offset * @return ISC_SITEMAP_NODE */ public function getTree($limit = null, $offset = null) { $root = new ISC_SITEMAP_ROOT(); if (!gzte11(ISC_HUGEPRINT)) { return $root; } $sql = "SELECT vendorid, vendorname, vendorfriendlyname FROM `[|PREFIX|]vendors` ORDER BY vendorname ASC"; if ($limit && $offset) { $sql .= " LIMIT " . $offset . "," . $limit; } else if ($limit) { $sql .= " LIMIT " . $limit; } $result = $GLOBALS['ISC_CLASS_DB']->Query($sql); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $label = $row['vendorname']; $url = VendorLink($row); $node = new ISC_SITEMAP_NODE($url, $label); $root->appendChild($node); } return $root; }
/** * Generates a sitemap tree for the pages model based on the pages nested set * * @param int $limit * @param int $offset * @return ISC_SITEMAP_NODE */ public function getTree($limit = null, $offset = null) { $root = new ISC_SITEMAP_ROOT(); $home = new ISC_SITEMAP_NODE(GetConfig('ShopPathNormal') . '/', GetLang('Home')); $root->appendChild($home); $set = new ISC_NESTEDSET_PAGES(); $sql = $set->generateGetTreeSql(array('pageid', 'pagetitle', 'pagetype', 'pagelink'), ISC_NESTEDSET_START_ROOT, $this->getMaximumDepth(), $limit, $offset, true, $this->_getRestrictions()); $result = $GLOBALS['ISC_CLASS_DB']->Query($sql); $previousDepth = -1; $node = $root; while ($page = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $depth = (int)$page['pagedepth']; if ($depth > $previousDepth) { $parent = $node; } else if ($depth < $previousDepth) { for ($depthCounter = $previousDepth - $depth; $depthCounter > 0; $depthCounter--) { $parent = $parent->getParent(); } } $title = $page['pagetitle']; switch ($page['pagetype']) { case '1': $url = $page['pagelink']; break; default: $url = PageLink((int)$page['pageid'], $title); break; } $node = new ISC_SITEMAP_NODE($url, $title); $parent->appendChild($node); $previousDepth = $depth; } return $root; }
/** * Generates a sitemap tree for the brands model based on the brands table * * @param int $limit * @param int $offset * @return ISC_SITEMAP_NODE */ public function getTree($limit = null, $offset = null) { $root = new ISC_SITEMAP_ROOT(); $sql = "SELECT brandname FROM `[|PREFIX|]brands` ORDER BY brandname ASC"; if ($limit && $offset) { $sql .= " LIMIT " . $offset . "," . $limit; } else if ($limit) { $sql .= " LIMIT " . $limit; } $result = $GLOBALS['ISC_CLASS_DB']->Query($sql); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $label = $row['brandname']; $url = BrandLink($label); $node = new ISC_SITEMAP_NODE($url, $label); $root->appendChild($node); } return $root; }