Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

[Ошибка] Модуль опросов


spk

Recommended Posts

Начал переделывать модуль под 1.4.7, но видимо не до конца разобрался. Вроде все получилось, кроме контроллеров в catalog/ (см. скрин)

<?phpclass ControllerCatalogPoll extends Controller {	private $error = array();	public function index() {		$this->load->language('catalog/poll');		$this->document->title = $this->language->get('heading_title');		$this->load->model('catalog/poll');		$this->getList();	}	public function insert() {		$this->load->language('catalog/poll');		$this->document->title = $this->language->get('heading_title');		$this->load->model('catalog/poll');		if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validateForm())) {			$this->model_catalog_poll->addPoll($this->request->post);			$this->session->data['success'] = $this->language->get('text_success');			$this->redirect(HTTPS_SERVER .'index.php?route=catalog/poll' . $url);		}		$this->getForm();	}	public function update() {		$this->load->language('catalog/poll');		$this->document->title = $this->language->get('heading_title');		$this->load->model('catalog/poll');		if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validateForm())) {			$this->model_catalog_poll->editPoll($this->request->get['poll_id'], $this->request->post);			$this->session->data['success'] = $this->language->get('text_success');			$this->redirect(HTTPS_SERVER .'index.php?route=catalog/poll' . $url);		}		$this->getForm();	}	public function delete() {		$this->load->language('catalog/poll');		$this->document->title = $this->language->get('heading_title');		$this->load->model('catalog/poll');		if ((isset($this->request->post['selected'])) && ($this->validateDelete())) {			foreach ($this->request->post['selected'] as $poll_id) {				$this->model_catalog_poll->deletePoll($poll_id);			}			$this->session->data['success'] = $this->language->get('text_success');			$this->redirect(HTTPS_SERVER .'index.php?route=catalog/poll' . $url);		}		$this->getList();	}	private function getList() {  		$this->document->breadcrumbs = array();  		$this->document->breadcrumbs[] = array(     		'href'      => HTTPS_SERVER . 'index.php?route=common/home',     		'text'      => $this->language->get('text_home'),     		'separator' => FALSE  		);  		$this->document->breadcrumbs[] = array(     		'href'      => HTTPS_SERVER . 'index.php?route=catalog/poll' . $url,     		'text'      => $this->language->get('heading_title'),    		'separator' => ' :: '  		);		$this->data['insert'] = HTTPS_SERVER . 'index.php?route=catalog/poll/insert' . $url;		$this->data['delete'] = HTTPS_SERVER . 'index.php?route=catalog/poll/delete' . $url;		$this->data['questions'] = array();		$results = $this->model_catalog_poll->getPolls();		foreach ($results as $result) {			$action = array();			$action[] = array(				'text' => $this->language->get('text_edit'),				'href' => HTTPS_SERVER . 'index.php?route=catalog/poll/update&poll_id=' . $result['poll_id'] . $url			);			$this->data['questions'][] = array(				'poll_id'    => $result['poll_id'],				'question'   => $result['question'],				'status'		 => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),				'active'		 => ($result['active'] ? $this->language->get('text_active') : $this->language->get('text_inactive')),				'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),				'selected'   => isset($this->request->post['selected']) && in_array($result['poll_id'], $this->request->post['selected']),				'action'     => $action			);		}		$this->data['heading_title'] = $this->language->get('heading_title');		$this->data['text_date_added'] = $this->language->get('text_date_added');		$this->data['text_enabled'] = $this->language->get('text_enabled');		$this->data['text_disabled'] = $this->language->get('text_disabled');		$this->data['text_no_results'] = $this->language->get('text_no_results');		$this->data['column_question'] = $this->language->get('column_question');		$this->data['column_status'] = $this->language->get('column_status');		$this->data['column_active'] = $this->language->get('column_active');		$this->data['column_date_added'] = $this->language->get('column_date_added');		$this->data['column_action'] = $this->language->get('column_action');		$this->data['button_insert'] = $this->language->get('button_insert');		$this->data['button_delete'] = $this->language->get('button_delete'); 		if (isset($this->error['warning'])) {			$this->data['error_warning'] = $this->error['warning'];		} else {			$this->data['error_warning'] = '';		}		if (isset($this->session->data['success'])) {			$this->data['success'] = $this->session->data['success'];			unset($this->session->data['success']);		} else {			$this->data['success'] = '';		}		$this->template = 'catalog/poll_list.tpl';		$this->children = array(			'common/header',			'common/footer'		);		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));	}	private function getForm() {		$this->data['heading_title'] = $this->language->get('heading_title');		$this->data['text_enabled'] = $this->language->get('text_enabled');		$this->data['text_disabled'] = $this->language->get('text_disabled');		$this->data['text_active'] = $this->language->get('text_active');		$this->data['text_inactive'] = $this->language->get('text_inactive');		$this->data['text_none'] = $this->language->get('text_none');		$this->data['text_new_poll'] = $this->language->get('text_new_poll');		$this->data['text_no_votes'] = $this->language->get('text_no_votes');		$this->data['entry_question'] = $this->language->get('entry_question');		for ($i = 1; $i <= 8; $i++) {			$this->data['entry_answer_' . $i] = $this->language->get('entry_answer_' . $i);		}		$this->data['entry_status'] = $this->language->get('entry_status');		$this->data['entry_active'] = $this->language->get('entry_active');		$this->data['button_save'] = $this->language->get('button_save');		$this->data['button_cancel'] = $this->language->get('button_cancel');		$this->data['tab_general'] = $this->language->get('tab_general');		$this->data['tab_data'] = $this->language->get('tab_data');		$this->data['tab_results'] = $this->language->get('tab_results');		// Extract results		if (isset($this->request->get['poll_id'])) {			$poll_id = $this->request->get['poll_id'];			$poll_data = $this->model_catalog_poll->getPollData($poll_id);			$reactions = $this->model_catalog_poll->getPollResults($poll_id);			$total_votes = $this->model_catalog_poll->getTotalResults($poll_id);			if ($reactions) {				$this->data['reactions'] = TRUE;				$percent = array(0, 0, 0, 0, 0, 0, 0, 0);				$totals  = array(0, 0, 0, 0, 0, 0, 0, 0);				foreach($reactions as $reaction) {					$totals[$reaction['answer'] - 1]++;				}				for($i = 0; $i < 8; $i++) {					$percent[$i] = round(100 * ($totals[$i]/$total_votes));				}				$this->data['poll_data'] = $poll_data;				$this->data['percent'] = $percent;				$this->data['total_votes'] = $total_votes;				$this->data['text_poll_results'] = $this->language->get('text_poll_results');				$this->data['text_percent'] = $this->language->get('text_percent');				$this->data['text_answer'] = $this->language->get('text_answer');			}		}		// End extraction of results		if (isset($this->error['warning'])) {			$this->data['error_warning'] = $this->error['warning'];		} else {			$this->data['error_warning'] = '';		}		if (isset($this->error['question'])) {			$this->data['error_question'] = $this->error['question'];		} else {			$this->data['error_question'] = '';		}		for ($i = 1; $i <= 8; $i++) {			if (isset($this->error['answer_' . $i])) {				$this->data['error_answer_' . $i] = $this->error['answer_' . $i];			} else {				$this->data['error_answer_' . $i] = '';			}		}		if (isset($this->error['active_poll'])) {			$this->data['error_active_poll'] = $this->error['active_poll'];		} else {			$this->data['error_active_poll'] = '';		}  		$this->document->breadcrumbs = array();  		$this->document->breadcrumbs[] = array(     		'href'      => HTTPS_SERVER . 'index.php?route=common/home',     		'text'      => $this->language->get('text_home'),     		'separator' => FALSE  		);  		$this->document->breadcrumbs[] = array(     		'href'      => HTTPS_SERVER . 'index.php?route=catalog/poll',     		'text'      => $this->language->get('heading_title'),     		'separator' => ' :: '  		);		if (!isset($this->request->get['poll_id'])) {    		$this->data['new_poll'] = TRUE;			$this->data['action'] = HTTPS_SERVER .'index.php?route=catalog/poll/insert';		} else {			$this->data['action'] = HTTPS_SERVER . 'index.php?route=catalog/poll/update&poll_id=' . $this->request->get['poll_id'] . $url;		}		$this->data['cancel'] = HTTPS_SERVER . 'index.php?route=catalog/poll' . $url;		if ((isset($this->request->get['poll_id'])) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {     		$poll_info = $this->model_catalog_poll->getPoll($this->request->get['poll_id']);    	}		$this->load->model('localisation/language');		$this->data['languages'] = $this->model_localisation_language->getLanguages();		if (isset($this->request->post['poll_description'])) {			$this->data['poll_description'] = $this->request->post['poll_description'];		} elseif (isset($poll_info)) {			$this->data['poll_description'] = $this->model_catalog_poll->getPollDescriptions($this->request->get['poll_id']);		} else {			$this->data['poll_description'] = array();		}		if (isset($this->request->post['status'])) {			$this->data['status'] = $this->request->post['status'];		} elseif (isset($poll_info)) {			$this->data['status'] = $poll_info['status'];		} else {			$this->data['status'] = '';		}		if (isset($this->request->post['active'])) {			$this->data['active'] = $this->request->post['active'];		} elseif (isset($poll_info)) {			$this->data['active'] = $poll_info['active'];		} else {			$this->data['active'] = '';		}		$this->template = 'catalog/poll_form.tpl';		$this->children = array(			'common/header',			'common/footer'		);		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));	}	private function validateForm() {		if (!$this->user->hasPermission('modify', 'catalog/poll')) {			$this->error['warning'] = $this->language->get('error_permission');		}		foreach ($this->request->post['poll_description'] as $language_id => $value) {			if ((strlen(utf8_decode($value['question'])) < 2) || (strlen(utf8_decode($value['question'])) > 255)) {				$this->error['question'][$language_id] = $this->language->get('error_question');			}			for ($i = 1; $i <= 8; $i++) {				if ((strlen(utf8_decode($value['answer_' . $i])) > 0) && ((strlen(utf8_decode($value['answer_' . $i])) < 2) || (strlen(utf8_decode($value['answer_' . $i])) > 255))) {					$this->error['answer_' . $i][$language_id] = $this->language->get('error_answer');				}			}			if ($this->request->post['active'] == 1) {				$check_active_poll = $this->model_catalog_poll->checkActivePoll();				if ($check_active_poll) {					$active_poll = $this->model_catalog_poll->getActivePoll();					if ($active_poll['poll_id'] != $this->request->get['poll_id']) {						$this->error['active_poll'][$language_id] = $this->language->get('error_active_poll');					}				}			}		}		if (!$this->error) {			return TRUE;		} else {			return FALSE;		}	}	private function validateDelete() {		if (!$this->user->hasPermission('modify', 'catalog/poll')) {			$this->error['warning'] = $this->language->get('error_permission');		}		if (!$this->error) {			return TRUE; 		} else {			return FALSE;		}	}}?>

post-384-1293741785,8704_thumb.png

Надіслати
Поділитися на інших сайтах


Створіть аккаунт або увійдіть для коментування

Ви повинні бути користувачем, щоб залишити коментар

Створити обліковий запис

Зареєструйтеся для отримання облікового запису. Це просто!

Зареєструвати аккаунт

Вхід

Уже зареєстровані? Увійдіть тут.

Вхід зараз
  • Зараз на сторінці   0 користувачів

    • Ні користувачів, які переглядиють цю сторінку

×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.