<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Recommend extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */
         var $menu;
         var $default = '趙哲妤小姐';
         var $recommendlist;

        public function __construct()
        {
            parent::__construct();
            $this->load->model('Section', 'section_model');
            $this->menu = $this->section_model->buildTopMenuItem();
            $this->breadcrumbs = [];
            $this->load->model('RecommendContent', 'recommend_model');
            $this->recommendlist = $this->recommend_model->getRecommendcontentsAll();
        }

        public function index()
	{
		//$this->load->view('welcome_message');
            $this->breadcrumbs[] = array (
                'label' => '星級推薦',
                'link' => ''
            );
            $this->twig->display('main', array(
                'path' => array(
                    'vendor' => $this->config->item('vendor_path'),
                    'script' => $this->config->item('script_path'),
                    'css' => $this->config->item('css_path'),
                    'image' => $this->config->item('image_path')
                ),
                'breadcrumbs' => $this->breadcrumbs,
                'menus' => $this->menu,
                'session' => 'recommend',
                'recommendlist' => $this->recommendlist,
                'page' => 'index'
            ));
        }

        public function details()
	{
            if (! $this->uri->segment(3)) {
                redirect('/recommend', 'refresh');
            }
            
            $professors = array (
                '趙哲妤小姐' => array(
                    'featureImage' => 'recommend-01.png',
                    'name' => '趙哲妤小姐',
                    'title' => '英語實戰專家',
                    'description' => '「系統化學習模式，定時提供各卷評估和家課，讓同學了解其水平，亦讓老師掌握同學的學習進度。」'
                ),
                'Amy Smith' => array(
                    'featureImage' => 'recommend-02.png',
                    'name' => 'Amy Smith',
                    'title' => '英語實戰專家',
                    'description' => 'Plan specific educational goals and objectives for each class that relate to your overall goals and objectives. Develop your goals and objectives around a variety of activities: demonstrations, experiential activities.'
                ),
                'Dr. Jean Rash' => array(
                    'featureImage' => 'recommend-03.png',
                    'name' => 'Dr. Jean Rash',
                    'title' => '英語實戰專家',
                    'description' => 'Plan specific educational goals and objectives for each class that relate to your overall goals and objectives. Develop your goals and objectives around a variety of activities: demonstrations, experiential activities.'
                ),
            );

            $param = urldecode($this->uri->segment(3));
            // if (! array_key_exists($param, $professors)) {
            //     $param = $default;
            // }

            $recommendcontent=$this->recommend_model->getRecommendcontents($param);
                //$this->load->view('welcome_message');
            $this->breadcrumbs[] = array (
                'label' => '星級推薦',
                'link' => '/recommend'
            );
            $this->breadcrumbs[] = array (
                'label' => $param,
                'link' => ''
            );
            
            $this->twig->display('main', array(
                'path' => array(
                    'vendor' => $this->config->item('vendor_path'),
                    'script' => $this->config->item('script_path'),
                    'css' => $this->config->item('css_path'),
                    'image' => $this->config->item('image_path')
                ),
                'breadcrumbs' => $this->breadcrumbs,
                'menus' => $this->menu,
                'session' => 'recommend',
                'recommendcontent' => $recommendcontent,
                'page' => 'details'
                // 'record' => $professors[$param]
            ));
        }
        
}
