<?php
namespace DynCom\mysyde\common\classes;
/**
 * Class Siteparts
 * @package DynCom\mysyde\common\classes
 */
class Siteparts {

    private static $siteparts = NULL;

    /**
     * Siteparts constructor.
     */
    private function __construct() {
    }

    /**
     * @return array|null
     */
    public static function get() {
        if (self::$siteparts === NULL) {
            $translation = \DynCom\mysyde\common\classes\Registry::get('translation');

            self::$siteparts = array(
                1  => array( // textcontent
                    'header_table' => 'textcontent_header',
                    'line_table'   => '',
                    'description'  => $translation->get('left_text'),
                    'class'        => 'inhalt_text',
                    'code'         => 'textcontent',
                    'folder'       => 'textcontent',
                    'is_collection'=> TRUE
                ),

                4  => array( // Bild
                    'header_table' => 'image_header',
                    'description'  => $translation->get('left_image'),
                    'class'        => 'inhalt_image',
                    'code'         => 'image',
                    'folder'       => 'image'
                ),

                15  => array( // Intranet
                    'header_table' => 'main_intranet_sitepart',
                    'line_table'   => '',
                    'description'  => $translation->get('top_intranet'),
                    'class'        => 'intranet',
                    'folder' => 'intranet/siteparts',
                    'code' => 'intranet'
                ),

                // 2  => array( // slideshow
                //     'header_table' => 'slideshow_header',
                //     'line_table'   => 'slideshow_line',
                //     'description'  => $translation->get('left_slideshows'),
                //     'class'        => 'inhalt_slideshow',
                //     'code'         => 'slideshow',
                //     'folder'       => 'slideshow',
                //     'is_collection'=> TRUE
                // ),



                // 4  => array( // Accordion
                //     'header_table' => 'slidecontent_header',
                //     'line_table'   => 'slidecontent_line',
                //     'description'  => $translation->get('left_slidecontent'),
                //     'class'        => 'inhalt_accordion',
                //     'code'         => 'slidecontent',
                //     'folder'       => 'slidecontent'
                // ),

                5  => array( // Dateigalerie
                    'header_table' => 'filegallery_header',
                    'line_table'   => 'filegallery_line',
                    'description'  => $translation->get('left_filecontent'),
                    'class'        => 'inhalt_files',
                    'code'         => 'filegallery',
                    'folder'       => 'filegallery',
                    'is_collection'=> TRUE
                ),

                6  => array( // Bildergalerie
                    'header_table' => 'gallery_header',
                    'line_table'   => 'gallery_line',
                    'description'  => $translation->get('left_imagegallery'),
                    'class'        => 'inhalt_bildergalerie',
                    'code'         => 'gallery',
                    'folder'       => 'gallery',
                    'is_collection'=> TRUE
                ),

                // 7  => array( // scrollleiste
                //     'header_table' => 'scrollbar_header',
                //     'line_table'   => 'scrollbar_line',
                //     'description'  => $translation->get('left_scrollbars'),
                //     'class'        => 'inhalt_scrollbar',
                //     'code'         => 'magicscroll',
                //     'folder'       => 'magicscroll'
                // ),

                // 8  => array( // Google maps
                //     'header_table' => 'google_maps_header',
                //     'line_table'   => 'google_maps_line',
                //     'description'  => $translation->get('left_googlemaps'),
                //     'class'        => 'inhalt_maps',
                //     'code'         => 'googlemaps',
                //     'folder'       => 'googlemaps'
                // ),

                // 9  => array( // Facebook Inhalte
                //     'header_table' => 'facebook_header',
                //     'line_table'   => '',
                //     'description'  => $translation->get('left_facebook'),
                //     'class'        => 'inhalt_facebook',
                //     'code'         => 'facebook',
                //     'folder'       => 'facebook'
                // ),

                10 => array( // Youtube Inhalte
                    'header_table' => 'youtube_header',
                    'line_table'   => '',
                    'description'  => $translation->get('left_youtube'),
                    'class'        => 'inhalt_youtube',
                    'code'         => 'youtube',
                    'folder'       => 'youtube',
                    'is_collection'=> TRUE
                ),

                // 11 => array( // Externe inhalte
                //     'header_table' => 'iframe_header',
                //     'line_table'   => '',
                //     'description'  => $translation->get('left_extern'),
                //     'class'        => 'inhalt_iframe',
                //     'code'         => 'iframe',
                //     'folder'       => 'iframe'
                // ),



                //FAQ Modul
                16 => array(
                    'header_table' => 'main_faq_header',
                    'line_table'   => '',
                    'description'  => $translation->get('faq'),
                    'class'        => 'inhalt_faq',
                    'folder'       => 'faq',
                    'code'         => 'faq',
                    'is_collection'=> TRUE
                ),
                //Forwarding/Weiterleitung
                17 => array(
                    'header_table' => 'forwarding_header',
                    'line_table'   => '',
                    'description'  => $translation->get('left_forwarding'),
                    'folder'       => 'forwarding',
                    'class'        => 'inhalt_forwarding',
                    'code'         => 'forwarding'
                ),
                // 18  => array( // Kontaktformular
                //     'header_table' => 'contactform_header',
                //     'line_table'   => 'contactform_line',
                //     'description'  => $translation->get('left_multistep_contactforms'),
                //     'class'        => 'inhalt_contact',
                //     'code'         => 'multistep_forms',
                //     'folder'       => 'contactform'
                // )

                3  => array( // Kontaktformular
                    'header_table' => 'contactform_header',
                    'line_table'   => 'contactform_line',
                    'description'  => $translation->get('left_contactforms'),
                    'class'        => 'inhalt_contact',
                    'code'         => 'contactform',
                    'folder'       => 'contactform',
                    'is_collection'=> TRUE
                ),
            );
        }

        // Shopmenu
        static $instance;
        if ($instance === null) {
            $instance = new self();
        }

        // self::create_module_siteparts(19);

        return self::$siteparts;
    }
    public static function getCustom()
    {
         
            $translation = \DynCom\mysyde\common\classes\Registry::get('translation');

            self::$siteparts = array(
                1  => array( // textcontent
                    'header_table' => 'textcontent_header',
                    'line_table'   => '',
                    'description'  => $translation->get('left_text'),
                    'class'        => 'inhalt_text',
                    'code'         => 'textcontent',
                    'folder'       => 'textcontent'
                ),

                // 2  => array( // slideshow
                //     'header_table' => 'slideshow_header',
                //     'line_table'   => 'slideshow_line',
                //     'description'  => $translation->get('left_slideshows'),
                //     'class'        => 'inhalt_slideshow',
                //     'code'         => 'slideshow',
                //     'folder'       => 'slideshow'
                // ),

                // 3  => array( // Kontaktformular
                //     'header_table' => 'contactform_header',
                //     'line_table'   => 'contactform_line',
                //     'description'  => $translation->get('left_contactforms'),
                //     'class'        => 'inhalt_contact',
                //     'code'         => 'contactform',
                //     'folder'       => 'contactform'
                // ),

                // 4  => array( // Accordion
                //     'header_table' => 'slidecontent_header',
                //     'line_table'   => 'slidecontent_line',
                //     'description'  => $translation->get('left_slidecontent'),
                //     'class'        => 'inhalt_accordion',
                //     'code'         => 'slidecontent',
                //     'folder'       => 'slidecontent'
                // ),

                5  => array( // Dateigalerie
                    'header_table' => 'filegallery_header',
                    'line_table'   => 'filegallery_line',
                    'description'  => $translation->get('left_filecontent'),
                    'class'        => 'inhalt_files',
                    'code'         => 'filegallery',
                    'folder'       => 'filegallery'
                ),

                6  => array( // Bildergalerie
                    'header_table' => 'gallery_header',
                    'line_table'   => 'gallery_line',
                    'description'  => $translation->get('left_imagegallery'),
                    'class'        => 'inhalt_bildergalerie',
                    'code'         => 'gallery',
                    'folder'       => 'gallery'
                ),

                 

                // 9  => array( // Facebook Inhalte
                //     'header_table' => 'facebook_header',
                //     'line_table'   => '',
                //     'description'  => $translation->get('left_facebook'),
                //     'class'        => 'inhalt_facebook',
                //     'code'         => 'facebook',
                //     'folder'       => 'facebook'
                // ),

                10 => array( // Youtube Inhalte
                    'header_table' => 'youtube_header',
                    'line_table'   => '',
                    'description'  => $translation->get('left_youtube'),
                    'class'        => 'inhalt_youtube',
                    'code'         => 'youtube',
                    'folder'       => 'youtube'
                ),

                // 11 => array( // Externe inhalte
                //     'header_table' => 'iframe_header',
                //     'line_table'   => '',
                //     'description'  => $translation->get('left_extern'),
                //     'class'        => 'inhalt_iframe',
                //     'code'         => 'iframe',
                //     'folder'       => 'iframe'
                // ),

                // 15 => array( // Newsletter
                //     'header_table' => 'newsletter_sitepart',
                //     'line_table'   => '',
                //     'description'  => $translation->get('left_newsletter_sitepart'),
                //     'class'        => 'newsletter_sitepart',
                //     'code'         => 'newsletter_sitepart',
                //     'folder'       => 'newsletter'
                // ),
  
            );
        
        return self::$siteparts;
    }

    public function create_module_siteparts($nr){
        $translation = \DynCom\mysyde\common\classes\Registry::get('translation');

        $query = "SELECT * FROM main_module WHERE has_sitepart = 1 AND active = 1";
        $result = @mysqli_query($GLOBALS['mysql_con'], $query);

        while ($row = @mysqli_fetch_assoc($result)) {
            $code = $row['code'];

            self::$siteparts[$nr] = array(
                // $nr  => array( // Custom Modules
                    'header_table' => $code.'_header',
                    'line_table'   => '',
                    'description'  => $translation->get('left_'.$code),
                    'class'        => 'inhalt_'.$code,
                    'code'         => $code,
                    'folder'       => $code
                );
            // );
            $nr++;
        }
    }
}