<?php
class ControllerModuleListaescolar extends Controller {
	protected function index($setting) {
		static $module = 0;

		$this->load->model('design/banner');
    $this->load->dmodel('tool/image');
    $this->load->dmodel('listaescolar/listaescolar');
    $school_info = $this->dmodel_listaescolar_listaescolar->getInfosLista($this->request->get['lista_id']);

    if (!isset($setting['school_id']) || ($school_info['id_escola'] != $setting['school_id']) ){
      return false;
    }

    $this->data['type']    = isset($setting['type']) ? $setting['type'] : false;
		$this->data['banners'] = array();

		$results = $this->model_design_banner->getBanner($setting['banner_id']);

		foreach ($results as $result) {
			if (file_exists(DIR_IMAGE . $result['image'])) {
				$this->data['banners'][] = array(
					'title' => $result['title'],
					'link'  => $result['link'],
					'image' => $this->dmodel_tool_image->resize($result['image'], $setting['width'], $setting['height']),
					'tamanho' => isset($setting['tamanho']) ? $setting['tamanho'] : 4
 				);
			}
		}

		$this->data['module'] = $module++;

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/banner.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/banner.tpl';
		} else {
			$this->template = 'default/template/module/banner.tpl';
		}

		$this->render('module/banner');
	}
}
