Files
zurawik.pl/controller/IndexController.php
2026-05-15 20:23:25 +02:00

305 lines
10 KiB
PHP

<?php
/**
* $Id: IndexController.php 1254 2008-09-09 08:39:51Z lule $
* Modul strony glownej
*
*/
class IndexController extends MainController implements ControllerInterface {
/**
* Strona glowna
*
*/
public function IndexAction($param) {
$this->smarty->assign('showNews', false);
$dalData = MfHomeSiteDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition('location', $param['idLocation']);
$dalData->setLimit(6);
$arrayObjHome = MfHomeSiteDAL::GetResult($dalData);
$this->smarty->assign('arrayObjHome', $arrayObjHome);
//Utils::arrayDisplay($arrayObjHome);
$this->smarty->assign('objBox1', $arrayObjHome[0]);
$this->smarty->assign('objBox2', $arrayObjHome[1]);
$this->smarty->assign('objBox3', $arrayObjHome[2]);
$this->smarty->assign('objBox4', $arrayObjHome[3]);
$this->smarty->assign('objBox5', $arrayObjHome[4]);
$this->smarty->assign('objBox6', $arrayObjHome[5]);
// $showNews = true;
//
$dalDataHome = MfArticleBoxDAL::GetDalDataObj();
$dalDataHome->setCondition(array('lang' => $param['lang'], 'publication' => 1));
$dalDataHome->setSortBy('weight');
$arrayObj = MfArticleBoxDAL::GetResult($dalDataHome);
$this->smarty->assign('arrayObjHomeArticle', $arrayObj);
//Utils::ArrayDisplay($arrayObj);
//
// $arrayIdLang = array('pl' => 1, 'en' => 2);
// $lang = $param['lang'];
// if (isset($arrayIdLang[$param['lang']])) {
// $id = $arrayIdLang[$param['lang']];
// $obj = MfArticleBoxDAL::GetById($id);
// $this->smarty->assign('objArticleSG', $obj);
// } else {
// $obj = MfArticleBoxDAL::GetEmptyObj();
// $this->smarty->assign('objArticleSG', $obj);
// }
}
public function AjaxFormAction($param) {
$this->SetAjaxRender();
$type = Request::GetPost('type');
$dalData = MfParametersDAL::GetDalDataObj();
$dalData->addCondition('type', $type);
$dalData->addCondition('publication', 1);
$dalData->setSortBy('sort');
$arrayObjParameters = MfParametersDAL::GetResult($dalData);
//Utils::ArrayDisplay($arrayObjParameters);
//===grupowanie====
$arrayParam = array();
$arrayGroupParam = array();
foreach ($arrayObjParameters as $objParam) {
$idLink = $objParam->GetLinkId();
$arrayGroupParam[$objParam->GetLinkId()][] = $objParam;
}
$this->smarty->assign('arrayObjParameters', $arrayObjParameters);
$this->smarty->assign('arrayGroupParam', $arrayGroupParam);
$this->smarty->assign('type', $type);
}
public function SearchAction($param) {
//Art
$search = trim(Request::GetPost('search'));
$arraySearch = explode(' ', $search);
$dalDataArt = SimpleArticle_MfArticleDAL::GetDalDataObj();
if (count($arraySearch) > 0) {
$where = ' ( ';
foreach ($arraySearch as $key => $search) {
$where .= $key == 0 ? '' : ' OR ';
$where .= ' mf_article_description.title LIKE "%' . Utils::AddSlashes($search) . '%" ';
$where .= ' OR mf_article_description.description LIKE "%' . Utils::AddSlashes($search) . '%" ';
}
$where .= ' ) ';
//Utils::ArrayDisplay($where);
$dalDataArt->addCondition(' ', $where, ' ');
}
$dalDataArt->setJoin(array('SimpleArticle_MfArticleDescription' => ' LEFT JOIN mf_article_description ON mf_article.id_mf_article=mf_article_description.id_mf_article'));
$arrayObjArt = SimpleArticle_MfArticleDAL::GetResult($dalDataArt);
$arrayObjArtStr = array();
foreach ($arrayObjArt as $objArt) {
$dalDataStr = StructureDAL::GetDalDataObj();
$dalDataStr->addCondition('id_content', $objArt->GetId());
$obStr = StructureDAL::GetResult($dalDataStr);
if (isset($obStr[0])) {
$objArt->setStructure($obStr[0]);
$arrayObjArtStr[] = $objArt;
}
}
$this->smarty->assign('arrayObjArtStr', $arrayObjArtStr);
//Utils::ArrayDisplay($arrayObjArtStr);
}
/**
* Wysyłka
*
* @param array $param
*/
public function AjaxSendMessageAction($param) {
header('Content-Type: text/html; charset=utf-8');
$this->SetAjaxRender();
$this->smarty->assign('error', '');
$this->smarty->assign('wrongPhone', '');
$this->smarty->assign('wrongEmail', '');
$this->smarty->assign('success', '');
//Utils::ArrayDisplay($_POST);
$validator = new Validator($_POST);
$errorList = '';
$error = '';
$empty = '';
$wrongEmail = '';
$wrongPhone = '';
if (!$validator->IsEmpty('name', '')) {
$empty = " Podpis </ br>";
}
if (!$validator->IsEmpty('temat', '')) {
$empty = " Temat </ br>";
}
if (!$validator->IsEmpty('email', '')) {
$empty .= " Email ";
} else {
if (!$validator->IsEmailAddress('email', '')) {
$wrongEmail = " Podany adres email jest niepoprawny.";
$this->smarty->assign('wrongEmail', $wrongEmail);
}
}
// if (!$validator->CheckCaptcha('captcha', '')) {
// $empty .= " Treść Captcha </ br>";
// }
if ($empty) {
$errorList = true;
}
//Utils::ArrayDisplay($empty);
//Utils::ArrayDisplay($errorList);
if ($errorList) {
$this->smarty->assign('error', "Wymagane pola muszą być wypełnione.");
} elseif ($wrongEmail) {
} elseif ($wrongPhone) {
} else {
$this->smarty->assign('content', $_POST['content']);
$this->smarty->assign('email', $_POST['email']);
$this->smarty->assign('temat', $_POST['temat']);
$this->smarty->assign('name', $_POST['name']);
//$this->smarty->assign('typ', $_POST['typ']);
//$this->smarty->assign('city', $_POST['city']);
$txtmessage = $this->smarty->fetch('partial/Index/MailTxt.tpl');
$mail = new PHPMailer();
$mail->CharSet = "utf-8";
$mail->Subject = FROM_NAME_MAIL . " - " . $_POST['temat'];
$mail->SMTPAuth = true;
$mail->Mailer = 'smtp';
$mail->Host = HOST_MAIL;
$mail->Port = 25;
$mail->From = FROM_MAIL;
$mail->FromName = FROM_NAME_MAIL;
$mail->Username = USER_MAIL;
$mail->Password = PASS_MAIL;
$mail->IsHTML(true);
//$mail -> AddAddress(FORM_MAIL, FROM_NAME_MAIL);
$mail->AddBCC("maciek@formix.pl", "BOK - Mediaflex");
$mail->Body = $txtmessage;
$mail->Send();
$this->smarty->assign('success', 'Wiadomość została wysłana');
}
}
/**
* Wyswietlanie obrazka captcha
*/
public function CaptchaAction() {
//$this->disableTemplates = true;
$this->SetAjaxRender();
include(PATH_CORE . '/plugins/Captcha.php');
$word = rand(2, 9) . rand(2, 9) . rand(2, 9) . rand(2, 9) . rand(2, 9);
setcookie(CAPTCHA_COOKIE_NAME, (md5(strtolower($word) . CAPTCHA_SEED)));
//session_start();
//$_SESSION['captcha'] = $word;
$image = confirm($word);
$this->content = $image;
//die();
}
public function AjaxRegisterCaptchaCheckAction($param) {
$this->setAjaxRender();
$data = array('captcha' => Request::GetGet('captcha', true));
$validator = new Validator($data);
$validator->CheckCaptcha('captcha', '');
$errors = $validator->GetErrorList();
$this->content = empty($errors) ? "true" : "false";
}
public function NewsletterAction($param) {
//$this->setAjaxRender();
if (isset($_POST['send'])) {
$dalData = MfSubscriptionDAL::GetDalDataObj();
$objSubscripton = new MfSubscription();
$objSubscripton->setEmail($_POST['email_newsletter']);
$objSubscripton->setDateAdd(Utils::GetNowDate());
$dalData->setObj($objSubscripton);
MfSubscriptionDAL::Save($objSubscripton);
$this->addRedirectInfo(Dictionary::Translate('Email has been added'), null, $_POST['urlFrom'], 0);
} else {
// $this->addRedirectInfo(Dictionary::Translate('message_sent'), null, $_POST['urlFrom'], 0);
}
}
public function SubsiteAction($param) {
try {
$dalData = StructureDAL::GetDalDataObj();
$dalData->setCondition(array('mf_structure.lang' => $param['lang'], 'mf_structure.publication' => '1', 'id_parent' => $param['idStructure']));
$dalData->setSortBy('sort');
$dalData->setJoin(array('SimpleArticle_MfArticleDescription' => ' LEFT JOIN mf_article_description ON mf_article_description.id_mf_article=mf_structure.id_content'));
$arrayObjSubsite = StructureDAL::GetResult($dalData);
$this->smarty->assign('arrayObjSubsite', $arrayObjSubsite);
//Utils::ArrayDisplay($arrayObjSubsite);
} catch (Exception $e) {
Utils::ArrayDisplay($e);
}
}
public function PlayerAction($param) {
$this->SetAjaxRender();
}
public function MapsAction($param) {
//$this->SetAjaxRender();
}
public function TestAction($param) {
Utils::ArrayDisplay('test');
$this->smarty->assign('indexSG', false);
//$this->SetAjaxRender();
}
/**
* Czesc wspolna wszystkich podstron
*
*/
public function PreDispatch($param) {
//$this->AddScript('swfobject.js');
if(!is_array($param)) {
$param = array();
}
if(!isset($param['lang'])) {
$param['lang'] = 'pl';
}
$this->smarty->assign('lang', $param['lang']);
$this->smarty->assign('indexSG', true);
$this->Run($param);
$this->RunShared('MenuBox', $param);
//$this->RunShared('TagCloudBox', $param);
//$this->RunShared('News', $param);
//$this->RunShared('CustomerBox', $param);
//$this->RunShared('LinksBox', $param);
}
public function PostDispatch($param) {
}
}
?>