| Server IP : 162.214.74.102 / Your IP : 216.73.217.114 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/hering/application/plugins/module_cms/controllers/ |
Upload File : |
<?php
include_once "Controller.php";
include_once __DIR__ . "/../models/PollModel.php";
class PollController extends Controller
{
/**
* @var PollModel
*/
protected $model;
/**
* @param $ui
* @param array $_L
* @param array $config
* @param $_pd
*/
public function __construct($ui, $_L, $config, $_pd)
{
parent::__construct($ui, $_L, $config, $_pd);
$this->ui->assign('_title', $this->_L['CMS_Module'] . ' - ' . $this->config['CompanyName']);
$this->model = new PollModel();
}
/**
* Show form to add poll
*/
public function add()
{
$this->ui->assign('_st', $this->_L['CMS_New_Poll']);
$this->ui->assign('_include', 'poll/' . __FUNCTION__);
$js = Asset::js_external($this->_pd . '/assets/js/default.js');
$this->ui->assign('xfooter', $js);
$this->ui->display('wrapper.tpl');
}
public function create()
{
$data = $_POST;
$data['status'] = (int) !empty($data['status']) && $data['status'] == 'on';
$this->model->createPoll($data);
$this->ui->assign('_st', $this->_L['CMS_New_Article']);
r2(U . 'module_cms/poll/listPolls', 's', $this->_L['CMS_Poll_Save']);
}
public function update()
{
$poll = $this->validatePoll();
$this->data['status'] = (int) !empty($this->data['status']) && $this->data['status'] == 'on';
$this->model->updatePoll($this->data, $poll);
$this->ui->assign('_st', $this->_L['CMS_Edit_Poll']);
r2(U . 'module_cms/poll/listPolls', 's', $this->_L['CMS_Poll_Edit']);
$this->ui->display('wrapper.tpl');
}
public function delete()
{
$poll = $this->validatePoll();
$this->model->deletePoll($poll);
$this->ui->assign('_st', $this->_L['CMS_Edit_Poll']);
r2(U . 'module_cms/poll/listPolls', 's', $this->_L['CMS_Poll_Delete']);
$this->ui->display('wrapper.tpl');
}
/**
* Show form to edit category
*/
public function edit()
{
if (empty($this->routes[3]) || !is_numeric($this->routes[3])) {
die($this->_L['Id_Required']);
}
$poll = $this->model->getOne($this->routes[3]);
if (!$poll) {
die($this->_L['Not_Found']);
}
$this->ui->assign('poll', $poll);
$this->ui->assign('_st', $this->_L['CMS_Module'] . ' - ' . $this->_L['CMS_Edit_Poll']);
$this->ui->assign('_include', 'poll/add');
$js = Asset::js_external($this->_pd . '/assets/js/default.js');
$this->ui->assign('xfooter', $js);
$this->ui->display('wrapper.tpl');
}
/**
* @return ORM
*/
protected function validatePoll()
{
$this->data = $_POST;
if (empty($this->data['id']) || !is_numeric($this->data['id'])) {
die($this->_L['Id_Required']);
}
$poll = $this->model->getOne($this->data['id']);
if (!$poll) {
die($this->_L['Not_Found']);
}
return $poll;
}
/**
* List categories
*/
public function listPolls()
{
$polls = $this->model->all('id', true);
$this->ui->assign('polls', $polls);
$this->ui->assign('_st', $this->_L['CMS_Polls']);
$this->ui->assign('_include', 'poll/' . __FUNCTION__);
$this->ui->display('wrapper.tpl');
}
}