HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/tops.komma.pro/wwwroot/lib/content/sitemap_xml.class.php
<?php
/**
 * submenu.class.php
 * Created by Komma Mediadesign.
 * Author: mike
 * Date: 10/04/14
 */

class Sitemap_Xml
{
    private $_name;
    /*
     * Filter array
     */
    private $_items;

    /*
     * Filters that have sub filter
     */
    private $_hasSubItem;

    /*
     * Sub filter array
     */
    private $_subItem;

    private $_lang = array();
    private $_urls = array();
    private $_pages = array();

    public function __construct($lang)
    {
        // Set language and url for conversion
        $Translator = new Translator($lang);
        $this->_lang = $Translator->get();
        $this->_urls = $Translator->getUrls();
        $this->_pages = $Translator->getPages();
    }

    public function set($name, $item, $hasSub=array(), $sub=array())
    {
        $this->_name = $name;
        $this->_items = $item;
        $this->_hasSubItem = $hasSub;
        $this->_subItem = $sub;
    }

    /*
     * Create mobile menu
     */
    public function create($root)
    {
        $output = '';

        // Generate list
        foreach($this->_items as $item)
        {
            // Get URL
            $itemUrl = $this->_pages[$item];

            // Add main title to list
            $output .= '<url>
                            <loc>' .  $root . $this->_urls[$this->_name] . '/' . $itemUrl . '</loc>
                            <lastmod>' .  date('Y-m-d') . '</lastmod>
                            <changefreq>weekly</changefreq>
                            <priority>0.5</priority>
                        </url>';

            // Check for submenu
            if( in_array($item,$this->_hasSubItem))
            {
                // Add sub filters
                foreach($this->_subItem[$item] as $subFilter)
                {
                    // Get URL
                    $subFilterUrl = $this->_pages[$subFilter];

                    $output .= '<url>
                                <loc>' .  $root . $this->_urls[$this->_name] . '/' . $itemUrl . '/' . $subFilterUrl . '</loc>
                                <lastmod>' .  date('Y-m-d') . '</lastmod>
                                <changefreq>weekly</changefreq>
                                <priority>0.5</priority>
                            </url>';
                }
            }
        }

        return $output;
    }
}