Subversion-Projekte lars-tiefland.ci

Revision

Revision 305 | Revision 307 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

    /**
     * @author Lars Tiefland
     * @copyright 2016
     */

    class Category_model extends CI_Model
    {
        public function __construct()
        {
            parent::__construct();
            $this->load->model( 'artikel_model', 'artikel' );
            $this->load->model( 'alias_model', 'alias' );
            $this->load->model( 'preise_model', 'preise' );
        }

        public function get_dir_items( $father )
        {
            if ( is_numeric( $father ) && $father > 0 )
            {
                $link = $this->get_link( $father );
                header( "Location: " . $link );
            }
            elseif ( !is_numeric( $father ) )
            {
                $query = $this->db->get_where( 'alias', array(
                    "alias" => $father . '.html',
                    "type_id" => 2,
                    ) );
                $row = $query->row_array();
                $father = $row["id"];
            }
            $d_res = $this->db->get_where( 'directory', array(
                'id' => $father,
                'language' => 'DE',
                'status' => 0,
                ) );
            $dir_info = $d_res->row_array();
            $this->db->select( 'templateValue' );
            $this->db->join( 'templates t', 'td.templates_id=t.id' );
            $res = $this->db->get_where( 'templates_to_directory td', array(
                'directory_id' => $father,
                'shops_id' => $GLOBALS['INI']['shops_ID'],
                'typ' => 'directory',
                ) );
            $t_row = $res->result_array();
            echo $this->db->last_query();
            $folder = substr( $t_row['templateValue'], 7 );
            $dir_info['template_folder'] = $folder;
            $dir_info['KategoriebildTag'] = $dir_info['Name'];
            $dir_info["shopPosition"] = $this->shop_position->get_position( $father );
            $dir_info['items'] = $this->artikel->list_artikel( $father );
            $dir_info['subdirs'] = $this->list_directory( $father );
            $dir_info['medien'] = $this->medien->get_category_medien( $father );
            $medien = $dir_info['medien'];
            if ( count( $medien ) > 1 )
            {
                $dir_info['Kategoriebild'] = $medien[1]['bild_url_ba'];
                if ( $medien[1]["beschreibung"] != '' )
                {
                    $dir_info['KategoriebildTag'] = $medien[1]['beschreibung'];
                }
            }
            elseif ( count( $medien ) )
            {
                $dir_info['Kategoriebild'] = $medien[0]['bild_url_ba'];
                if ( $medien[0]["beschreibung"] != '' )
                {
                    $dir_info['KategoriebildTag'] = $medien[0]['beschreibung'];
                }
            }
            return $dir_info;
        }

        public function list_directory( $father )
        {
            $subdirs = array();
            $this->db->order_by( 'kennung', 'ASC' );
            $query = $this->db->get_where( 'directory', array(
                "father" => $father,
                "language" => "DE",
                "status" => 0,
                ) );
            while ( $row = $query->unbuffered_row( 'array' ) )
            {
                $row["dirLink"] = $this->get_link( $row["ID"] );
                $row["medien"] = $this->medien->get_category_medien( $row["ID"] );
                $subdirs[] = $row;
            }
            return $subdirs;
        }
        public function get_dir( $id )
        {
            if ( is_numeric( $id ) )
            {
                $link = $this->get_link( $id );
                header( "Location: " . $link );
            }
            else
            {
                $query = $this->db->get_where( 'alias', array(
                    "alias" => $id . '.html',
                    "type_id" => 2,
                    ) );
                $row = $query->row_array();
                $id = $row["id"];
                $query = $this->db->get_where( 'directory', array(
                    'id' => $id,
                    "language" => "DE",
                    ) );
                $row = $query->row_array();
                return $row;
            }
        }

        public function get_link( $id )
        {
            $link = $this->alias->get_link( $id, 2 );
            return "/category/view/" . $link;
        }
    }
?>