first commit

This commit is contained in:
2026-04-24 15:32:21 +02:00
commit 20d40fead4
5046 changed files with 641038 additions and 0 deletions

View File

@@ -0,0 +1,163 @@
<?php
/**
* $Id$
* klient
*
*/
class BoxController extends MainController implements ControllerInterface {
const PATH_BANER = '/upload/home';
const COUNT_BOX = 4;
const AVATAR_DEST_DIR = '/upload/home';
const AVATAR_TEMP_DIR = '/upload/temp';
const MAX_AVATAR_FILE_SIZE = 5; //Rozmiar w mb
const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
//const PHOTO_WIDTH = 288;
//const PHOTO_HEIGHT = 127;
const IMAGE_MINI_WIDTH = 170;
const IMAGE_MINI_HEIGHT = 130;
//const IMAGE_NORMAL_WIDTH = 627;
//const IMAGE_NORMAL_HEIGHT = 219;
/**
* 170px × 130px
* Domyslna metoda
*
*/
public function IndexAction($param) {
//Utils::ArrayDisplay($param);
$lang = SessionProxy::GetValue('lang');
$countArray = range(0, 3);
//Utils::ArrayDisplay($param);
$dalData = MfHomeSiteDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
$dalData->setCondition(array('lang' =>$lang));
$dalData->setLimit(4);
$arrayObjHome = MfHomeSiteDAL::GetResult($dalData);
//Utils::ArrayDisplay($countArray);
$arrayToEdit = array();
foreach ($countArray as $key => $element) {
if (key_exists($key, $arrayObjHome)) {
$arrayToEdit[] = $arrayObjHome[$key];
} else {
$arrayToEdit[] = MfHomeSiteDAL::GetEmptyObj();
}
}
//Utils::ArrayDisplay($arrayToEdit);
$this->smarty->assign('arrayToEdit', $arrayToEdit);
$this->smarty->assign('lang', $lang);
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditAction($param) {
$countArray = range(0, 3);
$post = Request::GetAllPost();
foreach ($countArray as $key => $element) {
$objHomeElement = MfHomeSiteDAL::GetById($post['elementId'][$key]);
//$objHomeElement = new MfHomeSite();
$objHomeElement->SetName($post['elementName'][$key]);
$objHomeElement->SetSourceUrl($post['elementUrl'][$key]);
$objHomeElement->SetDescription($post['elementText'][$key]);
if($_FILES['elementImg_'.$key]['tmp_name']) {
$photoSize = getimagesize($_FILES['elementImg_'.$key]['tmp_name']);
$photoProp = $photoSize[0] / $photoSize[1];
$photoWidth = $photoSize[0];
$photoHeight = $photoSize[1];
if ($photoWidth > self::CROPPER_BIG_PHOTO_MAX_WIDTH) {
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_WIDTH / $photoProp;
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_WIDTH;
}
if ($photoHeight > self::CROPPER_BIG_PHOTO_MAX_HEIGHT) {
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_HEIGHT * $photoProp;
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_HEIGHT;
}
$photoFile = PhotoDAL::SimplePhotoUpload($_FILES['elementImg_'.$key], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
$destName = md5('photo' . microtime());
if(file_exists(PATH_STATIC_CONTENT.'upload/home/'.$destName.'.jpg'))
unlink(PATH_STATIC_CONTENT.'upload/home/'.$destName.'.jpg');
$propW = $photoWidth/self::IMAGE_MINI_WIDTH;
$propH = $photoHeight/self::IMAGE_MINI_HEIGHT;
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
$photoMini = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/home', 0, 0, self::IMAGE_MINI_WIDTH*$prop, self::IMAGE_MINI_HEIGHT*$prop, self::IMAGE_MINI_WIDTH, self::IMAGE_MINI_HEIGHT);
$objHomeElement->SetPhoto($photoMini);
}
MfHomeSiteDAL::Save($objHomeElement);
//Utils::ArrayDisplay($objHomeElement);
}
$this->AddRedirect(Router::GenerateUrl('editBox', array('_value' => 'Box')), 0);
//Utils::ArrayDisplay($_POST);
//Utils::ArrayDisplay($_FILES);
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->Run($param);
//$admin = AuthDAL::GetAdmin();
$this->RunShared('Auth', array());
$this->smarty->assign('titleAdmin', 'Strona główna');
$this->smarty->assign('lang', $param['lang']);
// $struct = array(
// 'User' => array('User' => 'Index'),
// 'Słowniki' => array('Dictionary' => 'Index'),
// //'Role' => array('Acl' => 'Index'),
// //'Uprawnienia' => array('Acl' => 'Rules'),
// 'Zmienne serwisu' => array('Setup' => 'Index')
//
//
// );
$this->smarty->assign('structure','');
}
private function renderStruct($struct){
$return = array();
foreach($struct AS $k => $row){
$return[] = '<a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a>';
}
return implode("<br />",$return);
}
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,322 @@
<?php
/**
* $Id$
* Słownki
*
*/
class CalcController extends MainController implements ControllerInterface {
const CONTENT_PER_PAGE = 50;
/**
* Domyślna metoda
*
*/
public function IndexAction($param) {
if (isset($param['type'])) {
SessionProxy::SetValue('typeCalc', $param['type']);
} else {
$param['type'] = 1;
}
SessionProxy::SetValue('typeCalc', $param['type']);
$dalData = MfParametersDAL::GetDalDataObj();
$dalData->addCondition('type', $param['type']);
$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('arrayObj', $arrayObjParameters);
$this->smarty->assign('arrayGroupParam', $arrayGroupParam);
}
public function AddAction($param) {
$objParameters = new MfParameters();
$objParameters->setType(SessionProxy::GetValue('typeCalc'));
$this->smarty->assign('obj', $objParameters);
if (Request::GetPost('doCategoryEdit')) {
Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$priceProgres = Request::Get('price_progres');
$priceProgres ? $priceProgres = 1 : $priceProgres = '0';
$objParameters->setPublication($publication);
$objParameters->setPrice($data['price']);
$objParameters->setLinkId($data['link_id']);
$objParameters->setName($data['name']);
$objParameters->setOpis($data['opis']);
$objParameters->setPriceProgres($priceProgres);
$objParameters->setCountProgres($data['count_progres']);
$objParameters->setUnit($data['unit']);
if(empty($out)) {
//Utils::ArrayDisplay($objParameters);
$idParameters = MfParametersDAL::Save($objParameters);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Calc' => 'Index', 'type' => $objParameters->getType())));
} else {
$this->smarty->assign('obj',$objParameters);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function EditAction($param) {
$objParameters = MfParametersDAL::GetById($param['id']);
$this->smarty->assign('obj', $objParameters);
if (Request::GetPost('doCategoryEdit')) {
Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$priceProgres = Request::Get('price_progres');
$priceProgres ? $priceProgres = 1 : $priceProgres = '0';
$objParameters->setPublication($publication);
$objParameters->setPrice($data['price']);
$objParameters->setLinkId($data['link_id']);
$objParameters->setName($data['name']);
$objParameters->setOpis($data['opis']);
$objParameters->setCountProgres($data['count_progres']);
$objParameters->setPriceProgres($priceProgres);
$objParameters->setUnit($data['unit']);
if(empty($out)) {
//Utils::ArrayDisplay($objParameters);
$idParameters = MfParametersDAL::Save($objParameters);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Calc' => 'Index', 'type' => $objParameters->getType())));
} else {
$this->smarty->assign('obj',$objParameters);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function DeleteAction($param) {
$arrayObjDict = MfDictionaryDAL::GetResult(array('id_mf_dictionary' => $param['id']), array(), 1, 'mf_dictionary.keyword ASC');
if (count($arrayObjDict) > 0) {
MfDictionaryDAL::DeleteByKey($arrayObjDict[0]->GetKeyword());
}
$this->AddRedirect(Router::GenerateUrl('DictLabel', array("Dictionary" => 'Index')), 0);
}
public function RegDeleteAction($param) {
$id = $param['id'];
if ($id) {
try {
$obj = MfParticipantDAL::GetById($id);
$dalData = MfParticipantDAL::GetDalDataObj();
$dalData->setId($id);
$dalData->setObj($obj);
MfParametersDAL::Delete($dalData);
} catch (Exception $e) {
//Utils::ArrayDisplay($e);
$logger->error('bład usunięcia wpisu o id: '.$id);
}
}
$this->AddRedirect(Router::GenerateUrl('red', array('Calc' => 'Reg', 'location' => $param['location'])), 0);
}
public function RegEditAction($param) {
$id = isset($param['id']) ? $param['id'] : Request::GetPost('id');
$objParticipant = MfParticipantDAL::GetById($id);
if (Request::GetPost('doCategoryEdit')) {
$objParticipant->setStatus(Request::GetPost('payment_status'));
MfParticipantDAL::Save($objParticipant);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('red', array('Calc' => 'Reg', 'location' => $objParticipant->getLocation() ? $objParticipant->getLocation() : 1)), 0);
}
$arrayFee = $objParticipant->getFeeFullUnserialize();
if (!is_array($arrayFee)) {
$arrayFee = array();
}
$discPrice = isset($arrayFee['disc']) ? $arrayFee['disc'] : 1;
$dalData = MfParametersDAL::GetDalDataObj();
$dalData->addCondition('publication', 1);
$dalData->setSortBy('sort');
$arrayObjParameters = MfParametersDAL::GetResult($dalData);
$this->smarty->assign('obj', $objParticipant);
$this->smarty->assign('objParticipant', $objParticipant);
$this->smarty->assign('arrayFee', $arrayFee);
$this->smarty->assign('discPrice', $discPrice);
$this->smarty->assign('arrayObjParameters', $arrayObjParameters);
}
public function RegAction($param) {
$location = 1;
if (isset($param['location'])) {
$location = $param['location'];
}
if ($location == 2) {
$this->partialTemplate = 'RegPAN.tpl';
}
$dalData = MfParticipantDAL::GetDalDataObj();
$dalData->addCondition('location', $location);
//$dalData->setSortBy();
$arrayObjReg = MfParticipantDAL::GetResult($dalData);
//Utils::ArrayDisplay($arrayObjReg);
$dalData = MfParametersDAL::GetDalDataObj();
$dalData->addCondition('publication', 1);
$dalData->setSortBy('sort');
$arrayObjParameters = MfParametersDAL::GetResult($dalData);
$this->smarty->assign('arrayObjParameters', $arrayObjParameters);
$this->smarty->assign('arrayObj', $arrayObjReg);
$this->smarty->assign('location', $location);
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Formularz');
$struct = array(
//'User' => array('User' => 'Index'),
'Rejestracja - aktualia' => array('Calc' => 'Reg', 'location' => 1),
//'Rejestracja - NAWA' => array('Calc' => 'Reg', 'location' => 2),
// 'Parametry' => array('Calc' => 'Index', 'type' => 1),
//'Parametry mieszkanie' => array('Calc' => 'Index', 'type' => 2),
'Treści - aktualia' => array('HomeSite' => 'EditArticle', 'location' => 1),
//'Treści - NAWA' => array('HomeSite' => 'EditArticle', 'location' => 2)
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
/**
*
*
*/
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,336 @@
<?php
/**
* $Id$
* Słownki
*
*/
class CalcController extends MainController implements ControllerInterface {
const CONTENT_PER_PAGE = 50;
/**
* Domyślna metoda
*
*/
public function IndexAction($param) {
if (isset($param['type'])) {
SessionProxy::SetValue('typeCalc', $param['type']);
} else {
$param['type'] = 1;
}
SessionProxy::SetValue('typeCalc', $param['type']);
$dalData = MfParametersDAL::GetDalDataObj();
$dalData->addCondition('type', $param['type']);
$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('arrayObj', $arrayObjParameters);
$this->smarty->assign('arrayGroupParam', $arrayGroupParam);
}
public function AddAction($param) {
$objParameters = new MfParameters();
$objParameters->setType(SessionProxy::GetValue('typeCalc'));
$this->smarty->assign('obj', $objParameters);
if (Request::GetPost('doCategoryEdit')) {
Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$priceProgres = Request::Get('price_progres');
$priceProgres ? $priceProgres = 1 : $priceProgres = '0';
$objParameters->setPublication($publication);
$objParameters->setPrice($data['price']);
$objParameters->setLinkId($data['link_id']);
$objParameters->setName($data['name']);
$objParameters->setOpis($data['opis']);
$objParameters->setPriceProgres($priceProgres);
$objParameters->setCountProgres($data['count_progres']);
$objParameters->setUnit($data['unit']);
if(empty($out)) {
//Utils::ArrayDisplay($objParameters);
$idParameters = MfParametersDAL::Save($objParameters);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Calc' => 'Index', 'type' => $objParameters->getType())));
} else {
$this->smarty->assign('obj',$objParameters);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function EditAction($param) {
$objParameters = MfParametersDAL::GetById($param['id']);
$this->smarty->assign('obj', $objParameters);
if (Request::GetPost('doCategoryEdit')) {
Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$priceProgres = Request::Get('price_progres');
$priceProgres ? $priceProgres = 1 : $priceProgres = '0';
$objParameters->setPublication($publication);
$objParameters->setPrice($data['price']);
$objParameters->setLinkId($data['link_id']);
$objParameters->setName($data['name']);
$objParameters->setOpis($data['opis']);
$objParameters->setCountProgres($data['count_progres']);
$objParameters->setPriceProgres($priceProgres);
$objParameters->setUnit($data['unit']);
if(empty($out)) {
//Utils::ArrayDisplay($objParameters);
$idParameters = MfParametersDAL::Save($objParameters);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Calc' => 'Index', 'type' => $objParameters->getType())));
} else {
$this->smarty->assign('obj',$objParameters);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function RegEditAction($param) {
$dalData = MfParametersDAL::GetDalDataObj();
//$dalData->addCondition('type', $type);
$dalData->addCondition('publication', 1);
$dalData->setSortBy('sort');
$arrayObjParameters = MfParametersDAL::GetResult($dalData);
$objParticipant = MfParticipantDAL::GetById($param['id']);
$arrayFee = $objParticipant->getFeeFullUnserialize();
//Utils::ArrayDisplay($arrayTextPrice);
$this->smarty->assign('arrayObjParameters', $arrayObjParameters);
$this->smarty->assign('discPrice', $arrayFee['disc']);
$this->smarty->assign('arrayFee', $arrayFee);
$this->smarty->assign('obj', $objParticipant);
$this->smarty->assign('objParticipant', $objParticipant);
if (Request::GetPost('doCategoryEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
//$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$objParticipant->setStatus($data['payment_status']);
if(empty($out)) {
//Utils::ArrayDisplay($objParameters);
$idParameters = MfParticipantDAL::Save($objParticipant);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editReg', array('Calc' => 'Reg')));
} else {
$this->smarty->assign('obj',$objParticipant);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function DeleteAction($param) {
$arrayObjDict = MfDictionaryDAL::GetResult(array('id_mf_dictionary' => $param['id']), array(), 1, 'mf_dictionary.keyword ASC');
if (count($arrayObjDict) > 0) {
MfDictionaryDAL::DeleteByKey($arrayObjDict[0]->GetKeyword());
}
$this->AddRedirect(Router::GenerateUrl('DictLabel', array("Dictionary" => 'Index')), 0);
}
public function RegDeleteAction($param) {
$obj = MfParticipantDAL::GetById($param['id']);
$dalData = MfParticipantDAL::GetDalDataObj();
$dalData->setObj($obj);
MfParticipantDAL::Delete($dalData);
$this->AddRedirectInfo('Usunięto', 'ok', Router::GenerateUrl('editReg', array('Calc' => 'Reg')));
}
public function RegAction($param) {
$dalData = MfParticipantDAL::GetDalDataObj();
//$dalData->setSortBy();
$arrayObjReg = MfParticipantDAL::GetResult($dalData);
//Utils::ArrayDisplay($arrayObjReg);
$dalData = MfParametersDAL::GetDalDataObj();
$dalData->addCondition('publication', 1);
$dalData->setSortBy('sort');
$arrayObjParameters = MfParametersDAL::GetResult($dalData);
$this->smarty->assign('arrayObjParameters', $arrayObjParameters);
$this->smarty->assign('arrayObj', $arrayObjReg);
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Formularz');
$struct = array(
//'User' => array('User' => 'Index'),
'Rejestracja' => array('Calc' => 'Reg'),
// 'Parametry' => array('Calc' => 'Index', 'type' => 1),
//'Parametry mieszkanie' => array('Calc' => 'Index', 'type' => 2),
'Treści' => array('HomeSite' => 'EditArticle')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
/**
*
*
*/
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,440 @@
<?php
/**
* Kontroler konfigurator
*
*/
class ConfigController extends MainController implements ControllerInterface {
const CONTENT_PER_PAGE = 5;
/**
* Strona glowna
*
*/
public function IndexAction($param) {
$dalData = MfStepDAL::GetDalDataObj();
$arrayObjStep = MfStepDAL::GetResult($dalData);
// Utils::ArrayDisplay($arrayObjStep[0]->getStepElement());
$this->smarty->assign('arrayObj', $arrayObjStep);
}
public function AddStructureAction($param) {
}
public function AddAction($param) {
$objStep = MfStepDAL::GetEmptyObj();
if (Request::GetPost('doCategoryAdd')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$objStep->setPublication($publication);
$objStep->setWeight($data['weight']);
$objStep->setLang('pl');
$objStep->setName($data['name']);
$objStep->setDescription($data['description']);
$objStep->setDateAdd(Utils::GetNowDate());
if(empty($out)) {
$idStep = MfStepDAL::Save($objStep);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Config' => 'Index')));
} else {
$this->smarty->assign('obj',$objStep);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
$this->smarty->assign('obj',$objStep);
}
public function EditAction($param) {
$objStep = MfStepDAL::GetById($param['id'], $param['lang']);
$this->smarty->assign('obj', $objStep);
if (Request::GetPost('doCategoryEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$objStep->setPublication($publication);
$objStep->setWeight($data['weight']);
$objStep->setLang('pl');
$objStep->setName($data['name']);
$objStep->setDescription($data['description']);
$objStep->setDateEdit(Utils::GetNowDate());
if(empty($out)) {
//Utils::ArrayDisplay($objStep);
$idStep = MfStepDAL::Save($objStep);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Config' => 'Index')));
} else {
$this->smarty->assign('obj',$objStep);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function DeleteAction($param) {
$dalData = MfStepElementDAL::GetDalDataObj();
$dalData->setCount(true);
$dalData->addCondition('id_mf_step', $param['id']);
$count = MfStepElementDAL::GetResult($dalData);
$delete = true;
$error = '';
if ($count > 0 ) {
$delete = false;
}
if ($delete) {
$objStep = MfStepDAL::GetById($param['id']);
$dalData = MfStepDAL::GetDalDataObj();
$dalData->setObj($objStep);
MfStepDAL::Delete($dalData);
$this->AddRedirectInfo('Element został usunięty', 'ok', Router::GenerateUrl('editCategory', array('Config' => 'Index')));
} else {
if ($count) {
$error .= 'Grupa posiada elementy';
}
// if ($isLang) {
// $error .= $error ? '<br/><br/>' : '';
// $error .= 'Kategoria posiada wersję jezykową';
// }
$this->AddRedirectInfo($error, 'error', Router::GenerateUrl('editCategory', array('Config' => 'Index')));
}
}
public function IndexElementAction($param) {
$dalData = MfStepDAL::GetDalDataObj();
$arrayObjStep = MfStepDAL::GetResult($dalData);
// Utils::ArrayDisplay($arrayObjStep[0]->getStepElement());
$this->smarty->assign('arrayObj', $arrayObjStep);
}
public function AddElementAction($param) {
$idMain = $param['idMain'];
$objStepElement = MfStepElementDAL::GetEmptyObj();
if (Request::GetPost('doCategoryAdd')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$other = Request::Get('other');
$other ? $other = 1 : $other = '0';
$objStepElement->setOther($other);
$objStepElement->setIdMfStep($idMain);
$objStepElement->setPublication($publication);
$objStepElement->setWeight($data['weight']);
$objStepElement->setLang('pl');
$objStepElement->setName($data['name']);
$objStepElement->setDescription($data['description']);
$objStepElement->setDateAdd(Utils::GetNowDate());
if(empty($out)) {
$idStep = MfStepElementDAL::Save($objStepElement);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Config' => 'Edit', 'id' => $idMain)));
} else {
$this->smarty->assign('obj',$objStepElement);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
$this->smarty->assign('obj',$objStepElement);
$this->smarty->assign('idMain',$idMain);
}
public function EditElementAction($param) {
$idMain = $param['idMain'];
$objStepElement = MfStepElementDAL::GetById($param['id'], $param['lang']);
$this->smarty->assign('obj', $objStepElement);
$this->smarty->assign('idMain',$idMain);
if (Request::GetPost('doCategoryEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$other = Request::Get('other');
$other ? $other = 1 : $other = '0';
$objStepElement->setOther($other);
$objStepElement->setIdMfStep($idMain);
$objStepElement->setPublication($publication);
$objStepElement->setWeight($data['weight']);
$objStepElement->setLang('pl');
$objStepElement->setName($data['name']);
$objStepElement->setDescription($data['description']);
$objStepElement->setDateEdit(Utils::GetNowDate());
if(empty($out)) {
//Utils::ArrayDisplay($objStep);
$idStep = MfStepElementDAL::Save($objStepElement);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editConfig', array('Config' => 'Edit', 'id' => $idMain)));
} else {
$this->smarty->assign('obj',$objStep);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function ArchiveAction($param) {
$dalData = MfConfigArchiveDAL::GetDalDataObj();
$page = 1;
if(isset($param['p']) && $param['p'] > 0) {
$page = $param['p'];
}
SessionProxy::SetValue('__news_page_no__', $page);
$offset = ($page - 1) * self::CONTENT_PER_PAGE;
$param['ajax'] = 'GetTableContent($(this).attr(\'href\'), \'#tableContentClient\', $(\'#search\').val(), $(\'#linkedList\').val())';
//$this->smarty->assign('ajax',$param['ajax']);
$dalData->setCount(true);
try {
$limit = Utils::PageConfigure($this->smarty, $param, ceil(MfConfigArchiveDAL::GetResult($dalData)), self::CONTENT_PER_PAGE);
} catch (Exception $e) {
Utils::ArrayDisplay($e);
}
$dalData->setCount(false);
$dalData->setSortBy('date_add DESC');
$dalData->setLimit($limit);
$arrayObj = MfConfigArchiveDAL::GetResult($dalData, false);
$this->smarty->assign('arrayObj', $arrayObj);
}
public function AjaxArchiveAction($param) {
$this->SetAjaxRender();
$dalData = MfConfigArchiveDAL::GetDalDataObj();
$page = 1;
$search= trim(Request::GetPost('search'));
$status = Request::GetPost('linked');
$arraySearch = explode(' ', $search);
if (count($arraySearch) > 0) {
$where = ' ( ';
foreach ($arraySearch as $key => $search) {
$where .= $key == 0 ? '' : ' OR ';
$where .= ' company LIKE "%'.Utils::AddSlashes($search).'%" ';
}
$where .= ' ) ';
$dalData->addCondition(' ', $where, ' ');
}
$dalData->addCondition('status', $status);
if(isset($param['p']) && $param['p'] > 0) {
$page = $param['p'];
}
SessionProxy::SetValue('__news_page_no__', $page);
$offset = ($page - 1) * self::CONTENT_PER_PAGE;
$param['ajax'] = 'GetTableContent($(this).attr(\'href\'), \'#tableContentClient\', $(\'#search\').val(), $(\'#linkedList\').val())';
//$this->smarty->assign('ajax',$param['ajax']);
$dalData->setCount(true);
try {
$limit = Utils::PageConfigure($this->smarty, $param, ceil(MfConfigArchiveDAL::GetResult($dalData)), self::CONTENT_PER_PAGE);
} catch (Exception $e) {
Utils::ArrayDisplay($e);
}
$dalData->setCount(false);
$dalData->setSortBy('date_add DESC');
$dalData->setLimit($limit);
$arrayObj = MfConfigArchiveDAL::GetResult($dalData, false);
$this->smarty->assign('arrayObj', $arrayObj);
}
public function ShowArchiveAction($param) {
$obj = MfConfigArchiveDAL::GetById($param['id']);
$this->smarty->assign('obj', $obj);
}
public function AjaxArchiveStatusAction($param) {
$this->SetNoRender();
$data = Request::GetAllPost();
if (Request::GetPost('id') > 0) {
$obj = MfConfigArchiveDAL::GetById($data['id']);
$obj->setStatus($data['status']);
MfConfigArchiveDAL::Save($obj);
}
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
//$this->RunShared('Admin');
$this->AddScript('structure.js');
$this->Run($param);
//$admin = AuthDAL::GetAdmin();
$this->RunShared('Auth', array());
$this->smarty->assign('titleAdmin', 'CRM');
$struct = array(
//'User' => array('User' => 'Index'),
'Konfigurator' => array('Config' => 'Index'),
'-> Historia konfiguracji' => array('Config' => 'Archive'),
'Demo' => array('Demo' => 'Index'),
'-> Historia pobierania' => array('Demo' => 'File'),
'Pliki' => array('File' => 'Index'),
'Klienci' => array('Client' => 'Index'),
'Strefa Poradnik' => array('Structure' => 'Edit', 'id' => 30),
'Strefa Aktualne promocje' => array('Structure' => 'Edit', 'id' => 31),
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,268 @@
<?php
/**
* Kontroler Demo
*
*/
class DemoController extends MainController implements ControllerInterface {
const CONTENT_PER_PAGE = 30;
/**
* Strona glowna
*
*/
public function IndexAction($param) {
$this->AddScript('structure.js');
$dalData = MfClientDAL::GetDalDataObj();
$page = 1;
$countStart = 0;
if(isset($param['strona']) && $param['strona'] > 0) {
$page = $param['strona'];
$countStart = ($page-1)*self::CONTENT_PER_PAGE;
}
SessionProxy::SetValue('__news_page_no__', $page);
$offset = ($page - 1) * self::CONTENT_PER_PAGE;
$param['ajax'] = 'GetTableContent($(this).attr(\'href\'), \'#tableContentClient\', $(\'#search\').val(), $(\'#linkedList\').val(), $(\'#sortVal\').val())';
//$this->smarty->assign('ajax',$param['ajax']);
$dalData->setCount(true);
$dalData->addCondition('type', 5);
try {
$limit = Utils::PageConfigure($this->smarty, $param, ceil(MfClientDAL::GetResult($dalData)), self::CONTENT_PER_PAGE);
} catch (Exception $e) {
Utils::ArrayDisplay($e);
}
$sortNameASC = '';
$sortNameDESC = '';
$sortIdASC = '';
$sortIdDESC = '';
$sortDateAddDESC = '';
$sortDateAddASC = '';
$sortVal = Request::GetPost('sortVal');
switch (Request::GetPost('sortVal')) {
case 'last_name DESC':
$sortNameDESC = 'Act';
break;
case 'last_name ASC':
$sortNameASC = 'Act';
break;
case 'id_mf_client DESC':
$sortIdDESC = 'Act';
break;
case 'id_mf_client ASC':
$sortIdASC = 'Act';
break;
default:
$sortVal = 'last_name';
$sortNameASC = 'Act';
}
$dalData->setCount(false);
$dalData->setSortBy($sortVal);
$dalData->setLimit($limit);
$dalData->addCondition('type', 5);
$arrayObjClient = MfClientDAL::GetResult($dalData, false);
$this->smarty->assign('arrayObj', $arrayObjClient);
//Utils::ArrayDisplay($arrayObjClient);
$this->smarty->assign('sortVal', 'last_name');
$this->smarty->assign('sortNameASC', $sortNameASC);
$this->smarty->assign('sortNameDESC', $sortNameDESC);
$this->smarty->assign('sortIdASC', $sortIdASC);
$this->smarty->assign('sortIdDESC', $sortIdDESC);
$this->smarty->assign('sortDateAddASC', $sortDateAddASC);
$this->smarty->assign('sortDateAddDESC', $sortDateAddDESC);
$this->smarty->assign('countStart', $countStart);
}
public function AjaxListAction($param) {
$this->AddScript('structure.js');
$this->SetAjaxRender();
$dalData = MfClientDAL::GetDalDataObj();
$page = 1;
$countStart = 0;
if(isset($param['strona']) && $param['strona'] > 0) {
$page = $param['strona'];
$countStart = ($page-1)*self::CONTENT_PER_PAGE;
}
SessionProxy::SetValue('__news_page_no__', $page);
$offset = ($page - 1) * self::CONTENT_PER_PAGE;
$param['ajax'] = 'GetTableContent($(this).attr(\'href\'), \'#tableContentClient\', $(\'#search\').val(), $(\'#linkedList\').val(), $(\'#sortVal\').val())';
$this->smarty->assign('ajax',$param['ajax']);
$dalData->setCount(true);
$dalData->addCondition('type', 5);
try {
$limit = Utils::PageConfigure($this->smarty, $param, ceil(MfClientDAL::GetResult($dalData, false)), self::CONTENT_PER_PAGE);
} catch (Exception $e) {
Utils::ArrayDisplay($e);
}
$sortNameASC = '';
$sortNameDESC = '';
$sortIdASC = '';
$sortIdDESC = '';
$sortDateAddDESC = '';
$sortDateAddASC = '';
$sortVal = Request::GetPost('sortVal');
switch (Request::GetPost('sortVal')) {
case 'last_name DESC':
$sortNameDESC = 'Act';
break;
case 'last_name ASC':
$sortNameASC = 'Act';
break;
case 'id_mf_client DESC':
$sortIdDESC = 'Act';
break;
case 'id_mf_client ASC':
$sortIdASC = 'Act';
break;
case 'date_add ASC':
$sortDateAddASC = 'Act';
break;
case 'date_add DESC':
$sortDateAddDESC = 'Act';
break;
default:
$sortVal = 'last_name';
$sortNameASC = 'Act';
}
$dalData->setCount(false);
$dalData->setSortBy($sortVal);
$dalData->setLimit($limit);
$arrayObjClient = MfClientDAL::GetResult($dalData, false);
$this->smarty->assign('arrayObj', $arrayObjClient);
//Utils::ArrayDisplay($arrayObjClient);
$this->smarty->assign('sortNameASC', $sortNameASC);
$this->smarty->assign('sortNameDESC', $sortNameDESC);
$this->smarty->assign('sortIdASC', $sortIdASC);
$this->smarty->assign('sortIdDESC', $sortIdDESC);
$this->smarty->assign('sortDateAddASC', $sortDateAddASC);
$this->smarty->assign('sortDateAddDESC', $sortDateAddDESC);
$this->smarty->assign('countStart', $countStart);
}
public function ViewAction($param) {
$objClient = MfClientDAL::GetById($param['id']);
$this->smarty->assign('obj', $objClient);
//===FILE=======================================
$dalData = MfFileDemoLogsDAL::GetDalDataObj();
$dalData->addCondition('id_mf_client',$param['id']);
//Utils::ArrayDisplay($_SERVER);
//$dalData->setJoin(array('objFile' => ' LEFT JOIN mf_file ON mf_article.id_mf_article=mf_article_description.id_mf_article'));
$arrayObj = MfFileDemoLogsDAL::GetResult($dalData);
$this->smarty->assign('arrayObjFile', $arrayObj);
//----------------------------------------------
}
public function FileAction($param) {
$dalData = MfFileDemoDAL::GetDalDataObj();
$arrayObj = MfFileDemoDAL::GetResult($dalData);
$dalData = MfFileDemoLogsDAL::GetDalDataObj();
//$dalData->setCount(true);
foreach ($arrayObj as $obj) {
$dalData->addCondition('id_mf_file_demo', $obj->getId());
$arrayByFile[$obj->getId()] = MfFileDemoLogsDAL::GetResult($dalData);
}
//Utils::ArrayDisplay($arrayByFile);
$this->smarty->assign('arrayObj', $arrayObj);
}
public function AddStructureAction($param) {
$this->SetNoRender();
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
//$this->RunShared('Admin');
$this->Run($param);
//$admin = AuthDAL::GetAdmin();
$this->RunShared('Auth', array());
$this->smarty->assign('titleAdmin', 'CRM');
$struct = array(
//'User' => array('User' => 'Index'),
'Konfigurator' => array('Config' => 'Index'),
'-> Historia konfiguracji' => array('Config' => 'Archive'),
'Demo' => array('Demo' => 'Index'),
'-> Historia pobierania' => array('Demo' => 'File'),
'Pliki' => array('File' => 'Index'),
'Klienci' => array('Client' => 'Index'),
'Strefa Poradnik' => array('Structure' => 'Edit', 'id' => 30),
'Strefa Aktualne promocje' => array('Structure' => 'Edit', 'id' => 31),
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,153 @@
<?php
/**
* $Id$
* Słownki
*
*/
class DictionaryController extends MainController implements ControllerInterface {
const CONTENT_PER_PAGE = 50;
/**
* Domyślna metoda
*
*/
public function IndexAction($param) {
//$dalData->setCount(true);
$limit = Utils::PageConfigure($this->smarty, $param, ceil( MfDictionaryDAL::GetResult(array('lang' => "'pl'"), array(), null, null, true)), self::CONTENT_PER_PAGE);
$arrayObjDict = MfDictionaryDAL::GetResult(array('lang' => "'pl'"), array(), $limit, 'mf_dictionary.keyword ASC');
//Utils::ArrayDisplay($arrayObjDict);
$this->smarty->assign('arrayObjDict', $arrayObjDict);
}
public function EditAction($param) {
if (isset($param['id'])) {
$arrayObjDict = MfDictionaryDAL::GetResult(array('id_mf_dictionary' => $param['id']), array(), 1, 'mf_dictionary.keyword ASC');
if (!(count($arrayObjDict) > 0)) {
$this->AddRedirect(Router::GenerateUrl('DictLabel', array("Dictionary" => 'Index')));
}
if (Request::GetPost('doDictEdit')) {
$post = Request::GetAllPost(false);
foreach ($post['replacement'] as $langDict => $replacement) {
$arrayObjDict = MfDictionaryDAL::GetResult(array('keyword' => "'".$post['keyword']."'", 'lang' => "'".$langDict."'"), array(), 1, 'mf_dictionary.keyword ASC');
$objDict = $arrayObjDict[0];
$objDict->SetReplacement($replacement);
MfDictionaryDAL::Save($objDict);
}
$this->AddRedirect(Router::GenerateUrl('DictLabel', array("Dictionary" => 'Index')), 0);
}
$arrayObjDict = MfDictionaryDAL::GetResult(array('id_mf_dictionary' => $param['id']), array(), 1, 'mf_dictionary.keyword ASC');
if (!(count($arrayObjDict) > 0)) {
$this->AddRedirect(Router::GenerateUrl('DictLabel', array("Dictionary" => 'Index')), 0);
}
$this->smarty->assign('objDict', $arrayObjDict[0]);
} else {
$this->AddRedirect(Router::GenerateUrl('DictLabel', array("Dictionary" => 'Index')), 0);
}
}
public function DeleteAction($param) {
$arrayObjDict = MfDictionaryDAL::GetResult(array('id_mf_dictionary' => $param['id']), array(), 1, 'mf_dictionary.keyword ASC');
if (count($arrayObjDict) > 0) {
MfDictionaryDAL::DeleteByKey($arrayObjDict[0]->GetKeyword());
}
$this->AddRedirect(Router::GenerateUrl('DictLabel', array("Dictionary" => 'Index')), 0);
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Administracja');
$struct = array(
//'User' => array('User' => 'Index'),
'Słowniki' => array('Dictionary' => 'Index'),
'Zmienne serwisu' => array('Setup' => 'Index'),
// 'Kategorie produktów' => array('ProductCategory' => 'Index'),
// 'Serie produktów' => array('ProductSeries' => 'Index'),
// 'Materiał produktów' => array('ProductSpec' => 'Index', 'type' => 2),
// 'Kolor produktów' => array('ProductSpec' => 'Index', 'type' => 1),
// 'Żarówki produktów' => array('ProductSpec' => 'Index', 'type' => 3),
//'Paramtery produktów' => array('ProductAttribute' => 'Index')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
/**
*
*
*/
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,489 @@
<?
class FileController extends MainController implements ControllerInterface
{
const AVATAR_DEST_DIR = '/upload/File';
const AVATAR_TEMP_DIR = '/upload/temp';
const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
const PHOTO_WIDTH = 283;
const PHOTO_HEIGHT = 400;
const IMAGE_MINI_WIDTH = 283;
const IMAGE_MINI_HEIGHT = 400;
const IMAGE_NORMAL_WIDTH = 283;
const IMAGE_NORMAL_HEIGHT = 400;
public function IndexAction($param){
$dalData = MfFileDAL::GetDalDataObj();
$dalData->setCondition(array());
$dalData->setLimit(10);
$dalData->setSortBy('weight');
$arrayFile = MfFileDAL::GetResult($dalData);
//Utils::ArrayDisplay($arrayFile);
}
public function IndexStructureAction($param){
$lang = SessionProxy::GetValue('lang');
$dalData = MfFileDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $lang));
$dalData->setSortBy('weight');
$arrayFile = MfFileDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayFile);
//Utils::ArrayDisplay($arrayFile);
}
public function EditStructureAction($param) {
$lang = SessionProxy::GetValue('lang');
$dalData = MfFileDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $lang));
$dalData->setSortBy('weight');
$arrayFile = MfFileDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayFile);
}
/**
* Akcja dodawania
*
* @param <type> $param
*/
public function AddAction($param) {
$lang = SessionProxy::GetValue('lang');
$idStructure = SessionProxy::GetValue('idStructure');
if (!$idStructure) {
$this->AddRedirect(Router::GenerateUrl('IndexStructure', array('Structure' => 'Index')), 0);
}
$this->smarty->assign('idStructure', $idStructure);
//$idCategory = SessionProxy::GetValue('idCategory');
$idCategory = $idStructure;
$arrayFileType = Utils::GetArrayList('mf_file_type', 'id_mf_file_type','name');
$this->smarty->assign('arrayFileType', $arrayFileType);
$objFile = MfFileDAL::GetEmptyObj();
if(Request::IsPost()) {
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('title', 'Pole nazwa musi zostać wypełnione.');
//$validator->IsDate('datepublication', 'Pole data publikacji musi zostać wypełnione.');
//$validator->IsEmpty('description', 'Pole opis musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$data['timepublication'] = $data['timepublication'] ? $data['timepublication'] : '00';
$objFileDescription = $objFile->GetDescriptionObj();
$objFile->SetDate(Utils::GetNowDate());
//$objFile->SetDatePublication($data['datepublication']." ".$data['timepublication'].":00:00");
$objFile->SetDatePublication(Utils::GetNowDate());
$objFile->SetWeight($data['weight']);
$objFile->SetPublication($publication);
$objFile->SetType($data['file_type']);
$objFile->SetIdStructure($idCategory);
$objFile->SetDateUpdate(Utils::GetNowDate());
$objFile->SetAddDate(Utils::GetNowDate());
$objFile->SetEditDate(Utils::GetNowDate());
$objFileDescription->SetLang($lang);
$objFileDescription->SetDescription($data['description']);
$objFileDescription->SetTitle($data['title']);
$objFileDescription->SetPublication($publication);
if(empty($out)) {
if($_FILES['filename']['tmp_name']){
$destName = Utils::TextToUrl($_FILES['filename']['name']);
if(file_exists(PATH_STATIC_CONTENT.'upload/File/'.$destName)) {
$destName = '1_'.$destName;
}
move_uploaded_file($_FILES['filename']['tmp_name'], PATH_STATIC_CONTENT.'upload/File/'.$destName);
umask(0000);
@chmod(PATH_STATIC_CONTENT.'upload/File/'.$destName, 0777);
$objFile->SetName($destName);
}
if($_FILES['photoname']['tmp_name']){
$photoSize = getimagesize($_FILES['photoname']['tmp_name']);
$photoProp = $photoSize[0] / $photoSize[1];
$photoWidth = $photoSize[0];
$photoHeight = $photoSize[1];
if ($photoWidth > self::CROPPER_BIG_PHOTO_MAX_WIDTH) {
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_WIDTH / $photoProp;
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_WIDTH;
}
if ($photoHeight > self::CROPPER_BIG_PHOTO_MAX_HEIGHT) {
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_HEIGHT * $photoProp;
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_HEIGHT;
}
$photoFile = PhotoDAL::SimplePhotoUpload($_FILES['photoname'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
$destName = md5('photo' . microtime());
if(file_exists(PATH_STATIC_CONTENT.'upload/File/'.$destName.'.jpg'))
unlink(PATH_STATIC_CONTENT.'upload/File/'.$destName.'.jpg');
$propW = $photoWidth/self::IMAGE_NORMAL_WIDTH;
$propH = $photoHeight/self::IMAGE_NORMAL_HEIGHT;
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
// maks szerokość
//$photo = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, $photoWidth, $photoHeight, self::IMAGE_NORMAL_WIDTH, $photoWidth/$prop);
// maks wysokość
//$photo = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, $photoWidth, $photoHeight, $photoHeight/$prop, self::IMAGE_NORMAL_HEIGHT);
$photo = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, self::IMAGE_NORMAL_WIDTH*$prop, self::IMAGE_NORMAL_HEIGHT*$prop, self::IMAGE_NORMAL_WIDTH, self::IMAGE_NORMAL_HEIGHT);
// Utils::ArrayDisplay('$prop: '.$prop);
// Utils::ArrayDisplay('$propW: '.$propW);
// Utils::ArrayDisplay('$propH: '.$propH);
// Utils::ArrayDisplay('$photoHeight: '.$photoHeight);
// Utils::ArrayDisplay('$photoWidth: '.$photoWidth);
/// Utils::ArrayDisplay('$photoHeight/$prop: '.$photoWidth/$prop);
// Utils::ArrayDisplay('self::IMAGE_NORMAL_HEIGHT: '.self::IMAGE_NORMAL_HEIGHT);
//Utils::ArrayDisplay('foto: '.$photo);
$objPhoto = new Picture();
$objPhoto->SetLink($photo);
$objPhoto->SetWeight(1);
$objPhoto->SetPublication(1);
$idPhoto = PictureDAL::Insert($objPhoto);
$objFile->SetIdPicture($idPhoto);
$destName = md5('photo' . microtime());
$propW = $photoWidth/self::IMAGE_MINI_WIDTH;
$propH = $photoHeight/self::IMAGE_MINI_HEIGHT;
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
$photoMini = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, self::IMAGE_MINI_WIDTH*$prop, self::IMAGE_MINI_HEIGHT*$prop, self::IMAGE_MINI_WIDTH, self::IMAGE_MINI_HEIGHT);
//Utils::ArrayDisplay('fotoMini: '.$photoMini);
$objPhoto = new Picture();
$objPhoto->SetLink($photoMini);
$objPhoto->SetWeight(1);
$objPhoto->SetPublication(1);
$idPhoto = PictureDAL::Insert($objPhoto);
$objFile->SetIdPictureMini($idPhoto);
}
if (isset($data['deletePhoto'])) {
$objFile->SetIdPictureMini(0);
$objFile->SetIdPicture(0);
}
$iid = MfFileDAL::Save($objFile);
$objFileDescription->SetIdMfFile($iid);
MfFileDescriptionDAL::Save($objFileDescription);
$this->smarty->assign('iid', $iid);
//$this->AddRedirect(Router::GenerateUrl('indexFile', array('File'=> 'Index')), 0);
$this->AddRedirect(Router::GenerateUrl('editStructure', array('id' => $idStructure)), 0);
} else {
//$this->content=$this->FormatAjaxOutput($out, $param);
//Utils::ArrayDisplay($out);
$objFile->SetFileDescriptionObj($objFileDescription);
$this->smarty->assign('objFile',$objFile);
$datePublished = explode(" ",$objFile->GetDatePublication());
$this->smarty->assign("datePublished", $datePublished[0]);
$this->smarty->assign("timePublished", $datePublished[1]);
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
/**
* Akcja dodawania
*
* @param <type> $param
*/
public function EditAction($param) {
//Utils::ArrayDisplay($_POST);
$lang = SessionProxy::GetValue('lang');
$idStructure = SessionProxy::GetValue('idStructure');
$this->smarty->assign('idStructure', $idStructure);
//$idCategory = SessionProxy::GetValue('idCategory');
$idCategory = $idStructure;
//$arrayFileType = Utils::GetArrayList('mf_file_type', 'name', $lang);
//$this->smarty->assign('arrayFileType', $arrayFileType);
//$objFile = MfFileDAL::GetEmptyObj();
$objFile = MfFileDAL::GetById($param['idFile'], $lang);
if(Request::IsPost()) {
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('title', 'Pole nazwa musi zostać wypełnione.');
//$validator->IsDate('datepublication', 'Pole data publikacji musi zostać wypełnione.');
//$validator->IsEmpty('description', 'Pole opis musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$objFileDescription = $objFile->GetDescriptionObj();
$objFile->SetDate(Utils::GetNowDate());
//$objFile->SetDatePublication($data['datepublication']." ".$data['timepublication'].":00:00");
$objFile->SetDatePublication(Utils::GetNowDate());
$objFile->SetWeight($data['weight']);
$objFile->SetPublication($publication);
$objFile->SetIdStructure($idCategory);
$objFile->SetType($data['file_type']);
$objFile->SetDateUpdate(Utils::GetNowDate());
$objFile->SetAddDate(Utils::GetNowDate());
$objFile->SetEditDate(Utils::GetNowDate());
//Utils::ArrayDisplay($objFile);
$objFileDescription->SetLang($lang);
$objFileDescription->SetDescription($data['description']);
$objFileDescription->SetTitle($data['title']);
$objFileDescription->SetPublication($publication);
if(empty($out)) {
if($_FILES['filename']['tmp_name']){
if (file_exists($objFile->GetNamePath())) {
unlink($objFile->GetNamePath());
}
$destName = Utils::TextToUrl($_FILES['filename']['name']);
if(file_exists(PATH_STATIC_CONTENT.'upload/File/'.$destName)) {
$destName = '1_'.$destName;
}
move_uploaded_file($_FILES['filename']['tmp_name'], PATH_STATIC_CONTENT.'upload/File/'.$destName);
umask(0000);
@chmod(PATH_STATIC_CONTENT.'upload/File/'.$destName, 0777);
$objFile->SetName($destName);
}
//=obrazki na listę============================================================================================================================================================
if($_FILES['photoname']['tmp_name']) {
$photoSize = getimagesize($_FILES['photoname']['tmp_name']);
$photoProp = $photoSize[0] / $photoSize[1];
$photoWidth = $photoSize[0];
$photoHeight = $photoSize[1];
if ($photoWidth > self::CROPPER_BIG_PHOTO_MAX_WIDTH) {
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_WIDTH / $photoProp;
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_WIDTH;
}
if ($photoHeight > self::CROPPER_BIG_PHOTO_MAX_HEIGHT) {
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_HEIGHT * $photoProp;
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_HEIGHT;
}
$photoFile = PhotoDAL::SimplePhotoUpload($_FILES['photoname'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
$destName = md5('photo' . microtime());
if(file_exists(PATH_STATIC_CONTENT.'upload/File/'.$destName.'.jpg'))
unlink(PATH_STATIC_CONTENT.'upload/File/'.$destName.'.jpg');
$propW = $photoWidth/self::IMAGE_NORMAL_WIDTH;
$propH = $photoHeight/self::IMAGE_NORMAL_HEIGHT;
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
//$photo = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/Structure', 0, 0, self::IMAGE_NORMAL_WIDTH*$prop, self::IMAGE_NORMAL_HEIGHT*$prop, self::IMAGE_NORMAL_WIDTH, self::IMAGE_NORMAL_HEIGHT);
//maks szerokość
//$photo = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, $photoWidth, $photoHeight, self::IMAGE_NORMAL_WIDTH, $photoWidth/$prop);
// maks wysokość
//$photo = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, $photoWidth, $photoHeight, $photoHeight/$prop, self::IMAGE_NORMAL_HEIGHT);
$photo = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, self::IMAGE_NORMAL_WIDTH*$prop, self::IMAGE_NORMAL_HEIGHT*$prop, self::IMAGE_NORMAL_WIDTH, self::IMAGE_NORMAL_HEIGHT);
$objPhoto = new Picture();
$objPhoto->SetLink($photo);
$objPhoto->SetWeight(1);
$objPhoto->SetPublication(1);
$idPhoto = PictureDAL::Insert($objPhoto);
$objFile->SetIdPicture($idPhoto);
$destName = md5('photo' . microtime());
$propW = $photoWidth/self::IMAGE_MINI_WIDTH;
$propH = $photoHeight/self::IMAGE_MINI_HEIGHT;
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
$photoMini = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/File', 0, 0, self::IMAGE_MINI_WIDTH*$prop, self::IMAGE_MINI_HEIGHT*$prop, self::IMAGE_MINI_WIDTH, self::IMAGE_MINI_HEIGHT);
$objPhoto = new Picture();
$objPhoto->SetLink($photoMini);
$objPhoto->SetWeight(1);
$objPhoto->SetPublication(1);
$idPhoto = PictureDAL::Insert($objPhoto);
$objFile->SetIdPictureMini($idPhoto);
}
if (isset($data['deletePhoto'])) {
$objFile->SetIdPictureMini(0);
$objFile->SetIdPicture(0);
}
//===============================================================================================================================================================
//Utils::ArrayDisplay($objFileDescription);
$iid = MfFileDAL::Save($objFile);
$objFileDescription->SetIdMfFile($iid);
MfFileDescriptionDAL::Save($objFileDescription);
$this->smarty->assign('iid', $iid);
//$this->AddRedirect(Router::GenerateUrl('indexFile', array('File'=> 'Index')), 0);
$this->AddRedirect(Router::GenerateUrl('editStructure', array('id' => $idStructure)), 0);
} else {
//$this->content=$this->FormatAjaxOutput($out, $param);
//Utils::ArrayDisplay($out);
$objFile->SetFileDescriptionObj($objFileDescription);
$this->smarty->assign('objFile',$objFile);
$datePublished = explode(" ",$objFile->GetDatePublication());
$this->smarty->assign("datePublished", $datePublished[0]);
$this->smarty->assign("timePublished", $datePublished[1]);
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
$this->smarty->assign('objFile', $objFile);
}
public function DeleteAction($param) {
$idStructure = SessionProxy::GetValue('idStructure');
$logger = LoggerManager::getLogger(__CLASS__);
$idFile = $param['idFile'];
if ($idFile) {
try {
$objFile = MfFileDAL::GetById($idFile);
if (file_exists($objFile->GetNamePath())) {
unlink($objFile->GetNamePath());
}
MfFileDAL::Delete($objFile);
} catch (Exception $e) {
//Utils::ArrayDisplay($e);
$logger->error('bład usunięcia pliku o id: '.$idFile);
}
}
$this->AddRedirect(Router::GenerateUrl('editStructure', array('id' => $idStructure)), 0);
}
/**
* preDispatch
* @param array $param
* @return null
*/
public function preDispatch($param){
$this->Run($param);
$this->AddScript('dropDown.js');
$this->AddScript('structure.js');
$this->AddScript('Dosia.js');
$this->AddScript('Link.js');
$this->AddScript('drag-drop-folder-tree.js');
// //$this->AddScript('Validator.js');
$this->AddScript('calendar.js');
$this->RunShared('Auth', array());
$this->RunShared('Structure', $param);
$this->smarty->assign('idStucture', SessionProxy::GetValue('idStructure'));
$this->smarty->assign('lang', 'pl');
$this->smarty->assign('titleAdmin', 'Pliki');
$this->smarty->assign('activeTab', 'index');
}
/**
* postDispatch
* @param array $param
* @return null
*/
public function postDispatch($param){
}
}

View File

@@ -0,0 +1,257 @@
<?php
/**
* $Id$
* klient
*
*/
class HomeController extends MainController implements ControllerInterface {
const PATH_BANER = '/upload/Banner';
/**
* Domyslna metoda
*
*/
public function IndexAction($param) {
$lang = SessionProxy::GetValue('lang');
if (!is_dir(PATH_STATIC_CONTENT.self::PATH_BANER)) {
mkdir(PATH_STATIC_CONTENT.self::PATH_BANER, 0777);
}
if (!is_dir(PATH_STATIC_CONTENT.self::PATH_BANER."/".$lang)) {
mkdir(PATH_STATIC_CONTENT.self::PATH_BANER."/".$lang, 0777);
}
//AKCJE DOMYSLNE
$logger = LoggerManager::getLogger(__CLASS__);
if(isset($_POST['saveBanners'])) {
//Utils::ArrayDisplay($_POST);
foreach ($_POST['id'] as $id) {
$name = $_POST['name'][$id];
if (isset($_FILES['baner'.$id]) && $_FILES['baner'.$id]['error'] != 4) {
//echo "sss ".isset($_FILES['photo']['name']);
$fileName = $_FILES['baner'.$id]['name'];
$ext = explode(".",$fileName);
$fileName = Utils::ClearString($fileName);
if (is_file(PATH_STATIC_CONTENT.self::PATH_BANER.$id."/".$_POST['banerSaved'.$id])) {
unlink(PATH_STATIC_CONTENT.self::PATH_BANER.$id."/".$_POST['banerSaved'.$id]);
}
}
else if (isset($_POST['banerSaved'.$id])) {
$fileName = $_POST['banerSaved'.$id];
}
if ($_POST['id']) {
}
//$idCustomer = $_POST['idCustomer'];
$id = HomeDAL::Update($id, $name, $fileName, $lang);
if (!is_dir(PATH_STATIC_CONTENT.self::PATH_BANER."/".$lang."/".$id)) {
mkdir(PATH_STATIC_CONTENT.self::PATH_BANER."/".$lang."/".$id, 0777);
}
CustomerDAL::SaveCustomerFile($_FILES, 'baner'.$id, $fileName, PATH_STATIC_CONTENT.self::PATH_BANER."/".$lang."/".$id);
}
// die(Header('Location: customer'.APPLICATION_FILE_TYPE));
}
$arrayBanner = HomeDAL::GetAll($lang);
$this->smarty->assign('arrayBanner', $arrayBanner);
//Utils::ArrayDisplay($arrayBanner);
$this -> AddScript('AC_RunActiveContent.js');
$this->AddScript('swfobject.js');
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditAction($param) {
$logger = LoggerManager::getLogger(__CLASS__);
//$this->AddScript('CopyFiles.js');
$this->AddScript('prototype.js');
$this->AddScript('validateFormCustomer.js');
$this->AddScript('CheckUnique.js');
if(isset($param['id'])) {
$id=$param['id'];
} else{
$id = null;
}
if(isset($_POST['saveCustomer'])) {
//Utils::ArrayDisplay($_POST);
$id = $_POST['id'];
$name = $_POST['name'];
$url = $_POST['url'];
$sort = $_POST['sort'];
$content = $_POST['content'];
if(!strstr($url, "http://")) {
$url = "http://".$url;
}
if (isset($_FILES['baner']) && $_FILES['baner']['error'] != 4) {
//echo "sss ".isset($_FILES['photo']['name']);
$fileName = $_FILES['baner']['name'];
$ext = explode(".",$fileName);
$fileName = Utils::ClearString($fileName);
if (is_file(PATH_CUSTOMER.$id."/".$_POST['banerSaved'])) {
unlink(PATH_CUSTOMER.$id."/".$_POST['banerSaved']);
}
}
else if (isset($_POST['banerSaved'])) {
$fileName = $_POST['banerSaved'];
}
if ($_POST['id']) {
}
//$idCustomer = $_POST['idCustomer'];
$objCustomer = new Customer($id, $name, $fileName, $content, $url, $sort, $published);
$id = CustomerDAL::Save($objCustomer);
if (!is_dir(PATH_CUSTOMER.$id)) {
mkdir(PATH_CUSTOMER.$id, 0777);
}
CustomerDAL::SaveCustomerFile($_FILES, 'baner', $fileName, PATH_CUSTOMER.$id);
die(Header('Location: customer'.APPLICATION_FILE_TYPE));
}
//AKCJE DOMY<4D>LNE
$objCustomer = CustomerDAL::GetCustomerById($id);
//Utils::ArrayDisplay($objQuery);
$this->smarty->assign('objCustomer', $objCustomer);
$this->smarty->assign('id', $id);
//Utils::ArrayDisplay($objCustomer);
$this->smarty->register_modifier("sslash", "stripslashes");
}
/**
* Sprawdzanie unikalno<6E>ci nazwy klient
*
* @param array $param
*/
public function AjaxCheckUniqueAction($param) {
header('Content-Type: text/html; charset=iso-8859-2');
if ($_POST['value']) {
$value = $_POST['value'];
} else {
$value = "";
}
if ($_POST['column']) {
$column = $_POST['column'];
} else {
$column = "";
}
$unigue = Utils::CheckUnique('customer', $column, $value);
if (!$unigue) {
$this->smarty->assign("uniqueInfo", "1");
}
$this->smarty->assign("column", $column);
$template = 'clean.tpl';
Registry::Remove('smartyTemplate');
Registry::Set('smartyTemplate', $template);
}
/**
* usuwanie banera
*
*/
public function DeleteAction($param) {
$logger = LoggerManager::getLogger(__CLASS__);
$idCustomer = SessionProxy::GetValue(EnumSessionValue::IDCUSTOMER);
if(isset($param['id'])) {
$id=$param['id'];
} else{
$id = null;
}
if($id) {
CustomerDAL::Delete($id);
// $filePath = PATH_BILLBOARD.$idCustomer."/".$id.".swf";
// if (is_file($filePath)) {
// @unlink($filePath);
// }
die(Header('Location: customer'.APPLICATION_FILE_TYPE));
if (Pat) {
}
}
//AKCJE DOMY<4D>LNE
//Utils::ArrayDisplay($objQuery);
}
public function RedirectAction($param) {
if(isset($param) && is_array($param) && !empty($param) && isset($param['id']) && !empty($param['id'])) {
$customer = CustomerDAL::GetCustomerById($param['id']);
Utils::Redirect($customer -> GetRedirectUrl());
}
exit;
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->AddScript("prototype.js");
$this->AddScript("scriptaculous.js");
$this->AddScript("GetContent.js");
$this->AddScript("tree.js");
$this->AddScript('dropDown.js');
$this->AddScript('structure.js');
$this->AddScript('Dosia.js');
$this->AddScript('Link.js');
$this->AddScript('drag-drop-folder-tree.js');
$this->AddScript('Validator.js');
$this->AddScript('calendar.js');
//Utils::ArrayDisplay($param);
$this->Run($param);
$this->RunShared('Structure', $param);
$this->smarty->assign('titleAdmin', 'Struktura strony');
$arrayModuleName = MfModuleDAL::GetArrayModuleName();
$this->smarty->assign( 'arrayModuleName' ,$arrayModuleName);
$this->smarty->assign('showIcon', true);
$this->RunShared('Auth', $param);
//Utils::ArrayDisplay(Utils::ArrayDisplay(SessionProxy::GetValue(EnumSessionValue::USER_OBJECT)));
// if($this->IsUser()==false) {
// $this->AddRedirect(URL_MAIN.'/Login.frmx', 0);
// }
}
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,566 @@
<?php
/**
* $Id$
* klient
*
*/
class HomeSiteController extends MainController implements ControllerInterface {
const PATH_BANER = '/upload/home';
const COUNT_BOX = 6;
const AVATAR_DEST_DIR = '/upload/home';
const LOGO_DEST_DIR = '/upload/logo';
const AVATAR_TEMP_DIR = '/upload/temp';
const MAX_AVATAR_FILE_SIZE = 5; //Rozmiar w mb
const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
const CROPPER_BIG_PHOTO_MAX_WIDTH_BANER = 1000;
const CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER = 1000;
//const PHOTO_WIDTH = 288;
//const PHOTO_HEIGHT = 127;
const IMAGE_MINI_WIDTH = 450;
const IMAGE_MINI_HEIGHT = 200;
const IMAGE_MINI_WIDTH_BANER = 1024;
const IMAGE_MINI_HEIGHT_BANER = 385;
//const IMAGE_NORMAL_WIDTH = 627;
//const IMAGE_NORMAL_HEIGHT = 219;
/**
* 170px × 130px
* Domyslna metoda
*
*/
public function IndexAction($param) {
//$this->SetAjaxRender();
$dalData = StructureDAL::GetDalDataObj();
$dalData->addCondition('publication', 1);
$dalData->setSortBy('name');
$arrayObjElement = StructureDAL::GetResult($dalData);
//Utils::ArrayDisplay($arrayObjElement);
//Utils::ArrayDisplay($param);
$lang = SessionProxy::GetValue('lang');
$countArray = range(0, 3);
//Utils::ArrayDisplay($param);
$dalData = MfHomeSiteDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
$dalData->setCondition(array('lang' =>$lang));
$dalData->setLimit(4);
$arrayObjHome = MfHomeSiteDAL::GetResult($dalData);
//Utils::ArrayDisplay($countArray);
$arrayToEdit = array();
foreach ($countArray as $key => $element) {
if (key_exists($key, $arrayObjHome)) {
$arrayToEdit[] = $arrayObjHome[$key];
} else {
$arrayToEdit[] = MfHomeSiteDAL::GetEmptyObj();
}
}
//Utils::ArrayDisplay($arrayToEdit);
$this->smarty->assign('arrayObjElement', $arrayObjElement);
$this->smarty->assign('arrayToEdit', $arrayToEdit);
$this->smarty->assign('lang', $lang);
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditAction($param) {
$countArray = range(0, 3);
$post = Request::GetAllPost();
foreach ($countArray as $key => $element) {
$objHomeElement = MfHomeSiteDAL::GetById($post['elementId'][$key]);
//$objHomeElement = new MfHomeSite();
$objHomeElement->SetName($post['elementName'][$key]);
$objHomeElement->SetSourceUrl($post['elementUrl'][$key]);
// $objHomeElement->SetDescription($post['elementText'][$key]);
//$objHomeElement->SetIdSource($post['idElement'][$key]);
if ($_FILES['elementImg_' . $key]['tmp_name']) {
// $photoSize = getimagesize($_FILES['elementImg_'.$key]['tmp_name']);
// $photoProp = $photoSize[0] / $photoSize[1];
// $photoWidth = $photoSize[0];
// $photoHeight = $photoSize[1];
// if ($photoWidth > self::CROPPER_BIG_PHOTO_MAX_WIDTH) {
// $photoHeight = self::CROPPER_BIG_PHOTO_MAX_WIDTH / $photoProp;
// $photoWidth = self::CROPPER_BIG_PHOTO_MAX_WIDTH;
// }
// if ($photoHeight > self::CROPPER_BIG_PHOTO_MAX_HEIGHT) {
// $photoWidth = self::CROPPER_BIG_PHOTO_MAX_HEIGHT * $photoProp;
// $photoHeight = self::CROPPER_BIG_PHOTO_MAX_HEIGHT;
// }
// $photoFile = PhotoDAL::SimplePhotoUpload($_FILES['elementImg_'.$key], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
$destName = md5('photo' . microtime());
if (file_exists(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg'))
unlink(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
move_uploaded_file($_FILES['elementImg_' . $key]['tmp_name'], PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
// $propW = $photoWidth/self::IMAGE_MINI_WIDTH;
// $propH = $photoHeight/self::IMAGE_MINI_HEIGHT;
// if ($propW > $propH) {
// $prop = $propH;
// } else {
// $prop = $propW;
// }
// $photoMini = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/home', 0, 0, self::IMAGE_MINI_WIDTH*$prop, self::IMAGE_MINI_HEIGHT*$prop, self::IMAGE_MINI_WIDTH, self::IMAGE_MINI_HEIGHT);
$objHomeElement->SetPhoto($destName . '.jpg');
}
MfHomeSiteDAL::Save($objHomeElement);
//Utils::ArrayDisplay($objHomeElement);
}
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editHomeSite', array('_value' => 'HomeSite')), 0);
//Utils::ArrayDisplay($_POST);
//Utils::ArrayDisplay($_FILES);
}
public function LinksAction($param) {
//Utils::ArrayDisplay($param);
$lang = SessionProxy::GetValue('lang');
$countArray = range(0, 5);
//Utils::ArrayDisplay($param);
$dalData = MfHomeSiteLinkDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
//$dalData->setCondition(array('lang' =>$lang));
$dalData->setLimit(6);
$arrayObjHome = MfHomeSiteLinkDAL::GetResult($dalData);
//Utils::ArrayDisplay($countArray);
$arrayToEdit = array();
foreach ($countArray as $key => $element) {
if (key_exists($key, $arrayObjHome)) {
$arrayToEdit[] = $arrayObjHome[$key];
} else {
$arrayToEdit[] = MfHomeSiteLinkDAL::GetEmptyObj();
}
}
//Utils::ArrayDisplay($arrayToEdit);
$this->smarty->assign('arrayToEdit', $arrayToEdit);
$this->smarty->assign('lang', $lang);
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditLinkAction($param) {
$countArray = range(0, 5);
$post = Request::GetAllPost();
foreach ($countArray as $key => $element) {
$objHomeElement = MfHomeSiteLinkDAL::GetById($post['elementId'][$key]);
//$objHomeElement = new MfHomeSite();
$objHomeElement->SetName($post['elementName'][$key]);
$objHomeElement->SetSourceUrl($post['elementUrl'][$key]);
//$objHomeElement->SetDescription($post['elementText'][$key]);
MfHomeSiteLinkDAL::Save($objHomeElement);
//Utils::ArrayDisplay($objHomeElement);
}
$this->AddRedirect(Router::GenerateUrl('editHomeSite', array('HomeSite' => 'links')), 0);
//Utils::ArrayDisplay($_POST);
//Utils::ArrayDisplay($_FILES);
}
public function BanerAction($param) {
//Utils::ArrayDisplay($param);
$lang = SessionProxy::GetValue('lang');
$countArray = range(0, 9);
//Utils::ArrayDisplay($param);
$dalData = MfHomeSiteBanerDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
$dalData->setCondition(array('lang' =>$lang));
$dalData->setLimit(10);
$dalData->setSortBy('sort');
$arrayObjHome = MfHomeSiteBanerDAL::GetResult($dalData);
//Utils::ArrayDisplay($countArray);
$arrayToEdit = array();
foreach ($countArray as $key => $element) {
if (key_exists($key, $arrayObjHome)) {
$arrayToEdit[] = $arrayObjHome[$key];
} else {
$arrayToEdit[] = MfHomeSiteBanerDAL::GetEmptyObj();
}
}
//Utils::ArrayDisplay($arrayToEdit);
$this->smarty->assign('arrayToEdit', $arrayToEdit);
$this->smarty->assign('lang', $lang);
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditBanerAction($param) {
$countArray = range(0, 9);
$post = Request::GetAllPost();
foreach ($countArray as $key => $element) {
$objHomeElement = MfHomeSiteBanerDAL::GetById($post['elementId'][$key]);
//$objHomeElement = new MfHomeSite();
$objHomeElement->SetName($post['elementName'][$key]);
$objHomeElement->SetSourceUrl($post['elementUrl'][$key]);
$objHomeElement->SetSort($post['elementSort'][$key]);
$objHomeElement->SetDescription($post['elementText'][$key]);
if ($_FILES['elementImg_' . $key]['tmp_name']) {
$photoSize = getimagesize($_FILES['elementImg_' . $key]['tmp_name']);
$photoProp = $photoSize[0] / $photoSize[1];
$photoWidth = $photoSize[0];
$photoHeight = $photoSize[1];
if ($photoWidth > self::CROPPER_BIG_PHOTO_MAX_WIDTH_BANER) {
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_WIDTH_BANER / $photoProp;
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_WIDTH_BANER;
}
if ($photoHeight > self::CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER) {
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER * $photoProp;
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER;
}
//$photoFile = PhotoDAL::SimplePhotoUpload($_FILES['elementImg_'.$key], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
$destName = md5('photo' . microtime());
//Utils::ArrayDisplay($_FILES['elementImg_'.$key]['tmp_name']);
//Utils::ArrayDisplay(PATH_STATIC_CONTENT.'upload/home/'.$destName.'.jpg');
include_once (Config::Get('PATH_CORE') . '/lib/WideImage/WideImage.php');
if (file_exists(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg'))
unlink(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
$img = WideImage::loadFromUpload('elementImg_' . $key);
$img->resizeDown('1920', null)->saveToFile(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg', 90);
//move_uploaded_file($_FILES['elementImg_' . $key]['tmp_name'], PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
$propW = $photoWidth / self::IMAGE_MINI_WIDTH_BANER;
$propH = $photoHeight / self::IMAGE_MINI_HEIGHT_BANER;
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
//$photoMini = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/home', 0, 0, self::IMAGE_MINI_WIDTH_BANER*$prop, self::IMAGE_MINI_HEIGHT_BANER*$prop, self::IMAGE_MINI_WIDTH_BANER, self::IMAGE_MINI_HEIGHT_BANER);
$objHomeElement->SetPhoto($destName . '.jpg');
}
if (isset($post['elementClear'][$key])) {
$objHomeElement->SetName('');
$objHomeElement->SetSourceUrl('');
$objHomeElement->SetPhoto('');
$objHomeElement->SetSort(100);
}
MfHomeSiteBanerDAL::Save($objHomeElement);
//Utils::ArrayDisplay($objHomeElement);
}
$this->AddRedirect(Router::GenerateUrl('editHomeSite', array('HomeSite' => 'Baner')), 0);
//Utils::ArrayDisplay($_POST);
//Utils::ArrayDisplay($_FILES);
}
public function LogoAction($param) {
if (!isset($param['type'])) {
$param['type'] = 1;
}
$this->smarty->assign('type', $param['type']);
$dalData = MfLogaDAL::GetDalDataObj();
$dalData->addCondition('type', $param['type']);
$arrayObj = MfLogaDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayObj);
}
public function AddLogoAction($param) {
if (!isset($param['type'])) {
$param['type'] = 1;
}
$obj = MfLogaDAL::GetEmptyObj();
if (Request::GetPost('doLogoEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
if (!$_FILES['logo']['tmp_name']) {
$validator->AddError('logo', 'Dodaj plik');
}
$out = $validator->GetErrorList();
$active = Request::Get('active');
$active ? $active = 1 : $active = '0';
$obj->setPublication($active);
$obj->setName($data['name']);
$obj->setUrl($data['url']);
$obj->setSort($data['sort']);
$obj->setType($param['type']);
$obj->setDateAdd(Utils::GetNowDate());
//Utils::ArrayDisplay($out);
if (empty($out)) {
$destNameOrg = $_FILES["logo"]["name"];
include(Config::Get('PATH_CORE') . '/lib/WideImage/WideImage.php');
move_uploaded_file($_FILES["logo"]["tmp_name"], PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $destNameOrg);
// $img = WideImage::loadFromUpload('logo');
// $img->saveToFile(PATH_STATIC_CONTENT.self::LOGO_DEST_DIR.'/'.$destNameOrg);
// $img->resizeDown('100%', 75)->saveToFile(PATH_STATIC_CONTENT.self::LOGO_DEST_DIR.'/'.$destNameOrg, 90);
$obj->setPhoto($destNameOrg);
$idLoga = MfLogaDAL::Save($obj);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
} else {
$this->smarty->assign('obj', $obj);
$this->smarty->assign('info', 'Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type', 'error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error', $error);
}
}
$this->smarty->assign('obj', $obj);
$this->smarty->assign('type', $param['type']);
}
public function EditLogoAction($param) {
if (!isset($param['type'])) {
$param['type'] = 1;
}
$dalData = MfLogaDAL::GetDalDataObj();
$obj = MfLogaDAL::GetById($param['id']);
if (Request::GetPost('doLogoEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$active = Request::Get('active');
$active ? $active = 1 : $active = '0';
$obj->setPublication($active);
$obj->setName($data['name']);
$obj->setUrl($data['url']);
$obj->setSort($data['sort']);
$obj->setType($param['type']);
$obj->setDateAdd(Utils::GetNowDate());
//Utils::ArrayDisplay($out);
if (empty($out)) {
if ($_FILES['logo']['tmp_name']) {
$destNameOrg = $_FILES["logo"]["name"];
move_uploaded_file($_FILES["logo"]["tmp_name"], PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $destNameOrg);
// include(Config::Get('PATH_CORE').'/lib/WideImage/WideImage.php');
// $img = WideImage::loadFromUpload('logo');
// $img->resizeDown('100%', 75)->saveToFile(PATH_STATIC_CONTENT.self::LOGO_DEST_DIR.'/'.$destNameOrg, 90);
$obj->setPhoto($destNameOrg);
}
$idLoga = MfLogaDAL::Save($obj);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
} else {
$this->smarty->assign('obj', $obj);
$this->smarty->assign('info', 'Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type', 'error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error', $error);
}
}
$this->smarty->assign('obj', $obj);
}
public function DeleteLogoAction($param) {
$this->SetNoRender();
if (!isset($param['type'])) {
$param['type'] = 1;
}
$dalData = MfLogaDAL::GetDalDataObj();
$obj = MfLogaDAL::GetById($param['id']);
if ($obj->getId() > 0) {
$dalData->setObj($obj);
$param['type'] = $obj->getType();
//Utils::ArrayDisplay(PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $obj->getPhoto());
if (file_exists(PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $obj->getPhoto())) {
unlink(PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $obj->getPhoto());
}
MfLogaDAL::Delete($dalData);
} else {
$this->AddRedirectInfo('Brak elementu', 'error', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
}
$this->AddRedirectInfo('Usunięto', 'ok', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
}
public function BoxAction($param) {
//Utils::ArrayDisplay($param);
//Utils::ArrayDisplay($_FILES);
if (Request::GetPost('doBoxEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
if ($_FILES['box']['tmp_name']) {
move_uploaded_file($_FILES['box']['tmp_name'], PATH_STATIC_CONTENT . "/upload/baner.jpg");
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editBox', array('HomeSite' => 'Box')));
} else {
//Utils::ArrayDisplay('err');
$this->AddRedirectInfo('Dodaj plik', 'info', Router::GenerateUrl('editBox', array('HomeSite' => 'Box')));
}
}
}
public function ArticleBoxAction($param) {
$dalData = MfArticleBoxDAL::GetDalDataObj();
$arrayObj = MfArticleBoxDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayObj);
}
public function EditArticleAction($param) {
$location = 1;
if(isset($param['location'])) {
$location = $param['location'];
}
if ($location == 1) {
$arrayIdLang = array('pl' => 1, 'en' => 2);
} elseif ($location == 2) {
$arrayIdLang = array('pl' => 3, 'en' => 4);
}
$this->smarty->assign('location', $location);
$lang = SessionProxy::GetValue('lang');
if (isset($arrayIdLang[$lang])) {
$id = $arrayIdLang[$lang];
$obj = MfArticleBoxDAL::GetById($id);
//Utils::ArrayDisplay($obj);
if ($obj->getId() != $id) {
$dalData = MfArticleBoxDAL::GetDalDataObj();
$obj->setId($id);
$obj->setLang($lang);
$dalData->setObj($obj);
MfArticleBoxDAL::Insert($dalData);
}
$this->smarty->assign('obj', $obj);
if (Request::IsPost()) {
$data = Request::GetAllPost();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$obj->setDescription($data['description']);
$obj->setShortnote($data['shortnote']);
$obj->setPublication($publication);
$obj->setLang($lang);
//$obj->setDatePublication($data['datePublication']);
$obj->setName($data['name']);
$dalData = MfArticleBoxDAL::GetDalDataObj();
$dalData->setObj($obj);
MfArticleBoxDAL::Save($obj);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('', array('HomeSite'=>'EditArticle', 'location' => $location)));
}
} else {
$obj = MfArticleBoxDAL::GetEmptyObj();
}
$this->smarty->assign('obj', $obj);
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->Run($param);
//$admin = AuthDAL::GetAdmin();
$this->RunShared('Auth', array());
$this->smarty->assign('titleAdmin', 'Formularz');
$struct = array(
//'User' => array('User' => 'Index'),
'Rejestracja - aktualia' => array('Calc' => 'Reg', 'location' => 1),
//'Rejestracja - NAWA' => array('Calc' => 'Reg', 'location' => 2),
// 'Parametry' => array('Calc' => 'Index', 'type' => 1),
//'Parametry mieszkanie' => array('Calc' => 'Index', 'type' => 2),
'Treści - aktualia' => array('HomeSite' => 'EditArticle', 'location' => 1),
//'Treści - NAWA' => array('HomeSite' => 'EditArticle', 'location' => 2)
);
$this->smarty->assign('structure', $this->renderStruct($struct));
}
private function renderStruct($struct) {
$return = '';
foreach ($struct AS $k => $row) {
$return .= '<li><a href="' . Router::GenerateUrl('dictpig', $row) . '">' . $k . '</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,554 @@
<?php
/**
* $Id$
* klient
*
*/
class HomeSiteController extends MainController implements ControllerInterface {
const PATH_BANER = '/upload/home';
const COUNT_BOX = 6;
const AVATAR_DEST_DIR = '/upload/home';
const LOGO_DEST_DIR = '/upload/logo';
const AVATAR_TEMP_DIR = '/upload/temp';
const MAX_AVATAR_FILE_SIZE = 5; //Rozmiar w mb
const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
const CROPPER_BIG_PHOTO_MAX_WIDTH_BANER = 1000;
const CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER = 1000;
//const PHOTO_WIDTH = 288;
//const PHOTO_HEIGHT = 127;
const IMAGE_MINI_WIDTH = 450;
const IMAGE_MINI_HEIGHT = 200;
const IMAGE_MINI_WIDTH_BANER = 1024;
const IMAGE_MINI_HEIGHT_BANER = 385;
//const IMAGE_NORMAL_WIDTH = 627;
//const IMAGE_NORMAL_HEIGHT = 219;
/**
* 170px × 130px
* Domyslna metoda
*
*/
public function IndexAction($param) {
//$this->SetAjaxRender();
$dalData = StructureDAL::GetDalDataObj();
$dalData->addCondition('publication', 1);
$dalData->setSortBy('name');
$arrayObjElement = StructureDAL::GetResult($dalData);
//Utils::ArrayDisplay($arrayObjElement);
//Utils::ArrayDisplay($param);
$lang = SessionProxy::GetValue('lang');
$countArray = range(0, 3);
//Utils::ArrayDisplay($param);
$dalData = MfHomeSiteDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
$dalData->setCondition(array('lang' =>$lang));
$dalData->setLimit(4);
$arrayObjHome = MfHomeSiteDAL::GetResult($dalData);
//Utils::ArrayDisplay($countArray);
$arrayToEdit = array();
foreach ($countArray as $key => $element) {
if (key_exists($key, $arrayObjHome)) {
$arrayToEdit[] = $arrayObjHome[$key];
} else {
$arrayToEdit[] = MfHomeSiteDAL::GetEmptyObj();
}
}
//Utils::ArrayDisplay($arrayToEdit);
$this->smarty->assign('arrayObjElement', $arrayObjElement);
$this->smarty->assign('arrayToEdit', $arrayToEdit);
$this->smarty->assign('lang', $lang);
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditAction($param) {
$countArray = range(0, 3);
$post = Request::GetAllPost();
foreach ($countArray as $key => $element) {
$objHomeElement = MfHomeSiteDAL::GetById($post['elementId'][$key]);
//$objHomeElement = new MfHomeSite();
$objHomeElement->SetName($post['elementName'][$key]);
$objHomeElement->SetSourceUrl($post['elementUrl'][$key]);
// $objHomeElement->SetDescription($post['elementText'][$key]);
//$objHomeElement->SetIdSource($post['idElement'][$key]);
if ($_FILES['elementImg_' . $key]['tmp_name']) {
// $photoSize = getimagesize($_FILES['elementImg_'.$key]['tmp_name']);
// $photoProp = $photoSize[0] / $photoSize[1];
// $photoWidth = $photoSize[0];
// $photoHeight = $photoSize[1];
// if ($photoWidth > self::CROPPER_BIG_PHOTO_MAX_WIDTH) {
// $photoHeight = self::CROPPER_BIG_PHOTO_MAX_WIDTH / $photoProp;
// $photoWidth = self::CROPPER_BIG_PHOTO_MAX_WIDTH;
// }
// if ($photoHeight > self::CROPPER_BIG_PHOTO_MAX_HEIGHT) {
// $photoWidth = self::CROPPER_BIG_PHOTO_MAX_HEIGHT * $photoProp;
// $photoHeight = self::CROPPER_BIG_PHOTO_MAX_HEIGHT;
// }
// $photoFile = PhotoDAL::SimplePhotoUpload($_FILES['elementImg_'.$key], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
$destName = md5('photo' . microtime());
if (file_exists(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg'))
unlink(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
move_uploaded_file($_FILES['elementImg_' . $key]['tmp_name'], PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
// $propW = $photoWidth/self::IMAGE_MINI_WIDTH;
// $propH = $photoHeight/self::IMAGE_MINI_HEIGHT;
// if ($propW > $propH) {
// $prop = $propH;
// } else {
// $prop = $propW;
// }
// $photoMini = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/home', 0, 0, self::IMAGE_MINI_WIDTH*$prop, self::IMAGE_MINI_HEIGHT*$prop, self::IMAGE_MINI_WIDTH, self::IMAGE_MINI_HEIGHT);
$objHomeElement->SetPhoto($destName . '.jpg');
}
MfHomeSiteDAL::Save($objHomeElement);
//Utils::ArrayDisplay($objHomeElement);
}
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editHomeSite', array('_value' => 'HomeSite')), 0);
//Utils::ArrayDisplay($_POST);
//Utils::ArrayDisplay($_FILES);
}
public function LinksAction($param) {
//Utils::ArrayDisplay($param);
$lang = SessionProxy::GetValue('lang');
$countArray = range(0, 5);
//Utils::ArrayDisplay($param);
$dalData = MfHomeSiteLinkDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
//$dalData->setCondition(array('lang' =>$lang));
$dalData->setLimit(6);
$arrayObjHome = MfHomeSiteLinkDAL::GetResult($dalData);
//Utils::ArrayDisplay($countArray);
$arrayToEdit = array();
foreach ($countArray as $key => $element) {
if (key_exists($key, $arrayObjHome)) {
$arrayToEdit[] = $arrayObjHome[$key];
} else {
$arrayToEdit[] = MfHomeSiteLinkDAL::GetEmptyObj();
}
}
//Utils::ArrayDisplay($arrayToEdit);
$this->smarty->assign('arrayToEdit', $arrayToEdit);
$this->smarty->assign('lang', $lang);
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditLinkAction($param) {
$countArray = range(0, 5);
$post = Request::GetAllPost();
foreach ($countArray as $key => $element) {
$objHomeElement = MfHomeSiteLinkDAL::GetById($post['elementId'][$key]);
//$objHomeElement = new MfHomeSite();
$objHomeElement->SetName($post['elementName'][$key]);
$objHomeElement->SetSourceUrl($post['elementUrl'][$key]);
//$objHomeElement->SetDescription($post['elementText'][$key]);
MfHomeSiteLinkDAL::Save($objHomeElement);
//Utils::ArrayDisplay($objHomeElement);
}
$this->AddRedirect(Router::GenerateUrl('editHomeSite', array('HomeSite' => 'links')), 0);
//Utils::ArrayDisplay($_POST);
//Utils::ArrayDisplay($_FILES);
}
public function BanerAction($param) {
//Utils::ArrayDisplay($param);
$lang = SessionProxy::GetValue('lang');
$countArray = range(0, 9);
//Utils::ArrayDisplay($param);
$dalData = MfHomeSiteBanerDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
$dalData->setCondition(array('lang' =>$lang));
$dalData->setLimit(10);
$dalData->setSortBy('sort');
$arrayObjHome = MfHomeSiteBanerDAL::GetResult($dalData);
//Utils::ArrayDisplay($countArray);
$arrayToEdit = array();
foreach ($countArray as $key => $element) {
if (key_exists($key, $arrayObjHome)) {
$arrayToEdit[] = $arrayObjHome[$key];
} else {
$arrayToEdit[] = MfHomeSiteBanerDAL::GetEmptyObj();
}
}
//Utils::ArrayDisplay($arrayToEdit);
$this->smarty->assign('arrayToEdit', $arrayToEdit);
$this->smarty->assign('lang', $lang);
}
/**
* Dodawanie/edycja klient/banera
*
*/
public function EditBanerAction($param) {
$countArray = range(0, 9);
$post = Request::GetAllPost();
foreach ($countArray as $key => $element) {
$objHomeElement = MfHomeSiteBanerDAL::GetById($post['elementId'][$key]);
//$objHomeElement = new MfHomeSite();
$objHomeElement->SetName($post['elementName'][$key]);
$objHomeElement->SetSourceUrl($post['elementUrl'][$key]);
$objHomeElement->SetSort($post['elementSort'][$key]);
$objHomeElement->SetDescription($post['elementText'][$key]);
if ($_FILES['elementImg_' . $key]['tmp_name']) {
$photoSize = getimagesize($_FILES['elementImg_' . $key]['tmp_name']);
$photoProp = $photoSize[0] / $photoSize[1];
$photoWidth = $photoSize[0];
$photoHeight = $photoSize[1];
if ($photoWidth > self::CROPPER_BIG_PHOTO_MAX_WIDTH_BANER) {
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_WIDTH_BANER / $photoProp;
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_WIDTH_BANER;
}
if ($photoHeight > self::CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER) {
$photoWidth = self::CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER * $photoProp;
$photoHeight = self::CROPPER_BIG_PHOTO_MAX_HEIGHT_BANER;
}
//$photoFile = PhotoDAL::SimplePhotoUpload($_FILES['elementImg_'.$key], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
$destName = md5('photo' . microtime());
//Utils::ArrayDisplay($_FILES['elementImg_'.$key]['tmp_name']);
//Utils::ArrayDisplay(PATH_STATIC_CONTENT.'upload/home/'.$destName.'.jpg');
include_once (Config::Get('PATH_CORE') . '/lib/WideImage/WideImage.php');
if (file_exists(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg'))
unlink(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
$img = WideImage::loadFromUpload('elementImg_' . $key);
$img->resizeDown('1920', null)->saveToFile(PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg', 90);
//move_uploaded_file($_FILES['elementImg_' . $key]['tmp_name'], PATH_STATIC_CONTENT . 'upload/home/' . $destName . '.jpg');
$propW = $photoWidth / self::IMAGE_MINI_WIDTH_BANER;
$propH = $photoHeight / self::IMAGE_MINI_HEIGHT_BANER;
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
//$photoMini = PhotoDAL::SaveTempFile($photoFile, $destName, '/upload/home', 0, 0, self::IMAGE_MINI_WIDTH_BANER*$prop, self::IMAGE_MINI_HEIGHT_BANER*$prop, self::IMAGE_MINI_WIDTH_BANER, self::IMAGE_MINI_HEIGHT_BANER);
$objHomeElement->SetPhoto($destName . '.jpg');
}
if (isset($post['elementClear'][$key])) {
$objHomeElement->SetName('');
$objHomeElement->SetSourceUrl('');
$objHomeElement->SetPhoto('');
$objHomeElement->SetSort(100);
}
MfHomeSiteBanerDAL::Save($objHomeElement);
//Utils::ArrayDisplay($objHomeElement);
}
$this->AddRedirect(Router::GenerateUrl('editHomeSite', array('HomeSite' => 'Baner')), 0);
//Utils::ArrayDisplay($_POST);
//Utils::ArrayDisplay($_FILES);
}
public function LogoAction($param) {
if (!isset($param['type'])) {
$param['type'] = 1;
}
$this->smarty->assign('type', $param['type']);
$dalData = MfLogaDAL::GetDalDataObj();
$dalData->addCondition('type', $param['type']);
$arrayObj = MfLogaDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayObj);
}
public function AddLogoAction($param) {
if (!isset($param['type'])) {
$param['type'] = 1;
}
$obj = MfLogaDAL::GetEmptyObj();
if (Request::GetPost('doLogoEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
if (!$_FILES['logo']['tmp_name']) {
$validator->AddError('logo', 'Dodaj plik');
}
$out = $validator->GetErrorList();
$active = Request::Get('active');
$active ? $active = 1 : $active = '0';
$obj->setPublication($active);
$obj->setName($data['name']);
$obj->setUrl($data['url']);
$obj->setSort($data['sort']);
$obj->setType($param['type']);
$obj->setDateAdd(Utils::GetNowDate());
//Utils::ArrayDisplay($out);
if (empty($out)) {
$destNameOrg = $_FILES["logo"]["name"];
include(Config::Get('PATH_CORE') . '/lib/WideImage/WideImage.php');
move_uploaded_file($_FILES["logo"]["tmp_name"], PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $destNameOrg);
// $img = WideImage::loadFromUpload('logo');
// $img->saveToFile(PATH_STATIC_CONTENT.self::LOGO_DEST_DIR.'/'.$destNameOrg);
// $img->resizeDown('100%', 75)->saveToFile(PATH_STATIC_CONTENT.self::LOGO_DEST_DIR.'/'.$destNameOrg, 90);
$obj->setPhoto($destNameOrg);
$idLoga = MfLogaDAL::Save($obj);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
} else {
$this->smarty->assign('obj', $obj);
$this->smarty->assign('info', 'Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type', 'error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error', $error);
}
}
$this->smarty->assign('obj', $obj);
$this->smarty->assign('type', $param['type']);
}
public function EditLogoAction($param) {
if (!isset($param['type'])) {
$param['type'] = 1;
}
$dalData = MfLogaDAL::GetDalDataObj();
$obj = MfLogaDAL::GetById($param['id']);
if (Request::GetPost('doLogoEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$active = Request::Get('active');
$active ? $active = 1 : $active = '0';
$obj->setPublication($active);
$obj->setName($data['name']);
$obj->setUrl($data['url']);
$obj->setSort($data['sort']);
$obj->setType($param['type']);
$obj->setDateAdd(Utils::GetNowDate());
//Utils::ArrayDisplay($out);
if (empty($out)) {
if ($_FILES['logo']['tmp_name']) {
$destNameOrg = $_FILES["logo"]["name"];
move_uploaded_file($_FILES["logo"]["tmp_name"], PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $destNameOrg);
// include(Config::Get('PATH_CORE').'/lib/WideImage/WideImage.php');
// $img = WideImage::loadFromUpload('logo');
// $img->resizeDown('100%', 75)->saveToFile(PATH_STATIC_CONTENT.self::LOGO_DEST_DIR.'/'.$destNameOrg, 90);
$obj->setPhoto($destNameOrg);
}
$idLoga = MfLogaDAL::Save($obj);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
} else {
$this->smarty->assign('obj', $obj);
$this->smarty->assign('info', 'Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type', 'error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error', $error);
}
}
$this->smarty->assign('obj', $obj);
}
public function DeleteLogoAction($param) {
$this->SetNoRender();
if (!isset($param['type'])) {
$param['type'] = 1;
}
$dalData = MfLogaDAL::GetDalDataObj();
$obj = MfLogaDAL::GetById($param['id']);
if ($obj->getId() > 0) {
$dalData->setObj($obj);
$param['type'] = $obj->getType();
//Utils::ArrayDisplay(PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $obj->getPhoto());
if (file_exists(PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $obj->getPhoto())) {
unlink(PATH_STATIC_CONTENT . self::LOGO_DEST_DIR . '/' . $param['type'] . '/' . $obj->getPhoto());
}
MfLogaDAL::Delete($dalData);
} else {
$this->AddRedirectInfo('Brak elementu', 'error', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
}
$this->AddRedirectInfo('Usunięto', 'ok', Router::GenerateUrl('editLoga', array('HomeSite' => 'Logo', 'type' => $param['type'])));
}
public function BoxAction($param) {
//Utils::ArrayDisplay($param);
//Utils::ArrayDisplay($_FILES);
if (Request::GetPost('doBoxEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
if ($_FILES['box']['tmp_name']) {
move_uploaded_file($_FILES['box']['tmp_name'], PATH_STATIC_CONTENT . "/upload/baner.jpg");
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editBox', array('HomeSite' => 'Box')));
} else {
//Utils::ArrayDisplay('err');
$this->AddRedirectInfo('Dodaj plik', 'info', Router::GenerateUrl('editBox', array('HomeSite' => 'Box')));
}
}
}
public function ArticleBoxAction($param) {
$dalData = MfArticleBoxDAL::GetDalDataObj();
$arrayObj = MfArticleBoxDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayObj);
}
public function EditArticleAction($param) {
$arrayIdLang = array('pl' => 1, 'en' => 2);
$lang = SessionProxy::GetValue('lang');
if (isset($arrayIdLang[$lang])) {
$id = $arrayIdLang[$lang];
$obj = MfArticleBoxDAL::GetById($id);
//Utils::ArrayDisplay($obj);
if ($obj->getId() != $id) {
$dalData = MfArticleBoxDAL::GetDalDataObj();
$obj->setId($id);
$obj->setLang($lang);
$dalData->setObj($obj);
MfArticleBoxDAL::Insert($dalData);
}
$this->smarty->assign('obj', $obj);
if (Request::IsPost()) {
$data = Request::GetAllPost();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$obj->setDescription($data['description']);
$obj->setShortnote($data['shortnote']);
$obj->setPublication($publication);
$obj->setLang($lang);
//$obj->setDatePublication($data['datePublication']);
$obj->setName($data['name']);
$dalData = MfArticleBoxDAL::GetDalDataObj();
$dalData->setObj($obj);
MfArticleBoxDAL::Save($obj);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('', array('HomeSite'=>'EditArticle')));
}
} else {
$obj = MfArticleBoxDAL::GetEmptyObj();
}
$this->smarty->assign('obj', $obj);
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->Run($param);
//$admin = AuthDAL::GetAdmin();
$this->RunShared('Auth', array());
$this->smarty->assign('titleAdmin', 'Formularz');
$struct = array(
//'User' => array('User' => 'Index'),
'Rejestracja' => array('Calc' => 'Reg'),
// 'Parametry' => array('Calc' => 'Index', 'type' => 1),
//'Parametry mieszkanie' => array('Calc' => 'Index', 'type' => 2),
'Treści' => array('HomeSite' => 'EditArticle')
);
$this->smarty->assign('structure', $this->renderStruct($struct));
}
private function renderStruct($struct) {
$return = '';
foreach ($struct AS $k => $row) {
$return .= '<li><a href="' . Router::GenerateUrl('dictpig', $row) . '">' . $k . '</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,355 @@
<?
class ImageController extends MainController implements ControllerInterface {
const IMAGE_NORMAL_WIDTH = 1000;
const IMAGE_NORMAL_HEIGHT = 800;
public function IndexAction($param) {
$zip = new ZipArchive();
$archiveName = PATH_STATIC_CONTENT . 'test.zip';
if ($zip->open($archiveName) === true) {
//Utils::ArrayDisplay('ss');
for ($i = 0; $i < $zip->numFiles; $i++) {
$entry = $zip->getNameIndex($i);
//Utils::ArrayDisplay('zip://' . $archiveName . '#' . $entry);
//Utils::ArrayDisplay(PATH_STATIC_CONTENT . 'temp/zip/' . $entry);
copy('zip://' . $archiveName . '#' . $entry, PATH_STATIC_CONTENT . 'temp/zip/' . $entry);
}
$zip->close();
}
}
public function UploadAction($param) {
if (!SessionProxy::IsSetValue('_ARRAY_PHOTO_')) {
SessionProxy::SetValue('_ARRAY_PHOTO_', array());
}
$arrayPhoto = SessionProxy::GetValue('_ARRAY_PHOTO_');
$this->SetAjaxRender();
include(Config::Get('PATH_CORE') . '/lib/WideImage/WideImage.php');
$destDir = 'temp/';
//Utils::ArrayDisplay($_FILES);
if ($_FILES['uploadfile']['name']) {
$ext = Utils::FileExtFromName($_FILES['uploadfile']['name']);
$uploadFileName = Utils::FileNameFromName($_FILES['uploadfile']['name']);
$destNameOrg = 'org_' . $uploadFileName . '_' . md5('photo' . time()) . '.jpg';
$destName = $uploadFileName . '_' . md5('photo' . time()) . '.jpg';
$destNameth = "th_" . $uploadFileName . '_' . md5('photo' . time()) . '.jpg';
if (strtolower($ext) == 'zip') {
//======Muliti=ZIP=File====================================================
move_uploaded_file($_FILES['uploadfile']['tmp_name'], PATH_STATIC_CONTENT . 'temp/zip/' . $_FILES['uploadfile']['name']);
$zip = new ZipArchive();
$archiveName = PATH_STATIC_CONTENT . 'temp/zip/' . $_FILES['uploadfile']['name'];
if ($zip->open($archiveName) === true) {
//Utils::ArrayDisplay('ss');
for ($i = 0; $i < $zip->numFiles; $i++) {
$entry = $zip->getNameIndex($i);
// Kopiowanie do temp/zip;
$uploadFileName = Utils::FileNameFromName($entry);
$destNameOrg = 'org_' . $uploadFileName . '_' . md5('photo' . time()) . '.jpg';
$destName = $uploadFileName . '_' . md5('photo' . time()) . '.jpg';
$destNameth = "th_" . $uploadFileName . '_' . md5('photo' . time()) . '.jpg';
//Utils::ArrayDisplay($entry);
copy('zip://' . $archiveName . '#' . $entry, PATH_STATIC_CONTENT . 'temp/zip/' . $entry);
// wczytywanie do obróbki
$img = WideImage::loadFromFile(PATH_STATIC_CONTENT . 'temp/zip/' . $entry);
$img->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameOrg, 90);
$photoSize = getimagesize(PATH_STATIC_CONTENT . $destDir . $destNameOrg);
if ($photoSize[0] < $photoSize[1]) {
$cropH = true;
} else {
$cropH = false;
}
$img = WideImage::loadFromFile(PATH_STATIC_CONTENT . $destDir . $destNameOrg);
$img->resizeDown('1000', '800')->saveToFile(PATH_STATIC_CONTENT . $destDir . $destName, 90);
//
if ($cropH) {
// zmieniam zmniejszam obrazem do szerokości a potem go obcinam już tylko po wysokości
$img->resizeDown('137', null)->crop('center', 'center', 137, 77)->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameth, 90);
} else {
//Poziom OK!
// zmieniam zmniejszam obrazem do wysokości a potem go obcinam już tylko po szerokości
$img->resizeDown(null, '137')->crop('center', 'center', 137, 77)->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameth, 90);
}
$file = URL_STATIC_CONTENT . $destDir . $destNameth;
$array = array($destName => array('normal' => $destName, 'th' => $destNameth, 'full' => $destNameOrg));
$arrayPhoto = array_merge($arrayPhoto, $array);
SessionProxy::SetValue('_ARRAY_PHOTO_', $arrayPhoto);
$this->smarty->assign('photo', PATH_STATIC_CONTENT . $destDir . $destName);
unlink(PATH_STATIC_CONTENT . 'temp/zip/' . $entry);
}
$zip->close();
}
unlink(PATH_STATIC_CONTENT . 'temp/zip/' . $_FILES['uploadfile']['name']);
} else {
//======Simple=File====================================================
$img = WideImage::loadFromUpload('uploadfile');
$img->resizeDown('1920', null)->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameOrg, 90);
// $img->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameOrg, 90);
$photoSize = getimagesize(PATH_STATIC_CONTENT . $destDir . $destNameOrg);
//Utils::ArrayDisplay($photoSize);
if ($photoSize[0] < $photoSize[1]) {
$cropH = true;
} else {
$cropH = false;
}
$img = WideImage::loadFromFile(PATH_STATIC_CONTENT . $destDir . $destNameOrg);
$img->resizeDown('800', '600')->saveToFile(PATH_STATIC_CONTENT . $destDir . $destName, 90);
//
if ($cropH) {
// zmieniam zmniejszam obrazem do szerokości a potem go obcinam już tylko po wysokości
$img->resizeDown('137', null)->crop('center', 'center', 137, 77)->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameth, 90);
} else {
//Poziom OK!
// zmieniam zmniejszam obrazem do wysokości a potem go obcinam już tylko po szerokości
$img->resizeDown(null, '137')->crop('center', 'center', 137, 77)->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameth, 90);
}
$file = URL_STATIC_CONTENT . $destDir . $destNameth;
$array = array($destName => array('normal' => $destName, 'th' => $destNameth, 'full' => $destNameOrg));
$arrayPhoto = array_merge($arrayPhoto, $array);
SessionProxy::SetValue('_ARRAY_PHOTO_', $arrayPhoto);
$this->smarty->assign('photo', PATH_STATIC_CONTENT . $destDir . $destName);
}
}
$this->smarty->assign('arrayPhoto', $arrayPhoto);
}
public function UploadImageAction($param) {
if (!SessionProxy::IsSetValue('_ARRAY_PHOTO_')) {
SessionProxy::SetValue('_ARRAY_PHOTO_', array());
}
$arrayPhoto = SessionProxy::GetValue('_ARRAY_PHOTO_');
//$this->SetAjaxRender();
// $uploaddir = PATH_STATIC_CONTENT.'/upload/test/';
// $file = $uploaddir . basename($_FILES['uploadfile']['name']);
//Utils::ArrayDisplay($file);
// if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
// echo "success";
// } else {
// echo "error";
// }
//
$destName = md5('photo' . time());
$destName = md5('photo' . time());
$destNameth = "th_" . $destName . ".jpg";
$destName .= ".jpg";
//$destNamea = "test.jpg";
$destDir = 'temp/';
//Utils::ArrayDisplay($_FILES);
if (isset($_FILES['uploadfile']) && $_FILES['uploadfile']['name']) {
//$photoSize = getimagesize(PATH_STATIC_CONTENT.$destDir.$destName);
//Utils::ArrayDisplay(PATH_STATIC_CONTENT);
//Utils::ArrayDisplay(PATH_STATIC_CONTENT);
$photo = PhotoDAL::SimplePhotoUpload($_FILES['uploadfile'], $destDir);
//Utils::ArrayDisplay(PATH_STATIC_CONTENT.$photo);
$img_oryginal = new mImage(PATH_STATIC_CONTENT . $photo);
//$img_oryginal->scaleProp(600, 600, 'ffffff', false, 'c', 0);
$img_oryginal->saveToFile(PATH_STATIC_CONTENT . $destDir . $destName, 'jpg', 90, true);
$normalW = 242;
$normalH = 340;
// $photoSize = getimagesize(PATH_STATIC_CONTENT.$destDir.$destName);
//
// //Utils::ArrayDisplay($photoSize);
//
//// if ($photoSize[0] < $photoSize[1]) {
//// $cropH = true;
//// } else {
//// $cropH = false;
//// }
//
// $propW = $photoSize[0]/$normalW;
// $propH = $photoSize[1]/$normalH;
//
// // Utils::ArrayDisplay($propW.' - '.$propH);
//
// if ($propW > $propH) {
// $prop = $propH;
// } else {
// $prop = $propW;
// }
//
// if ($photoSize[1] < $normalH*$prop) {
// $photoSizeH = $normalH;
// } else {
// $photoSizeH = $photoSize[1];
// }
//
//
// $photoSizeH = $normalW*$prop;
// $photoSizeW =$normalH*$prop;
//
//
//Utils::ArrayDisplay($photoSizeH.'-'.$photoSizeW);
//$img_oryginal->crop1(0, 0, $photoSizeH, $photoSizeW);
//$img_oryginal->scaleProp($normalW, $normalH, 0, 'ffffff', false, 'c', 0);
//$img_oryginal->
//$img_oryginal->saveToFile(PATH_STATIC_CONTENT.$destDir.$destName, 'jpg', 90, true);
//move_uploaded_file($_FILES['uploadfile']['tmp_name'], PATH_STATIC_CONTENT.$destDir.$_FILES['uploadfile']['name']);
$miniW = 242;
$miniH = 340;
//Utils::ArrayDisplay(PATH_STATIC_CONTENT.$photo);
$photoSize = getimagesize(PATH_STATIC_CONTENT . $photo);
//$photoSize = getimagesize(PATH_STATIC_CONTENT.$destDir.$_FILES['uploadfile']['name']);
// if ($photoSize[0] < $photoSize[1]) {
// $cropH = true;
// } else {
// $cropH = false;
// }
$propW = $photoSize[0] / $miniW;
$propH = $photoSize[1] / $miniH;
// Utils::ArrayDisplay($propW.' - '.$propH);
if ($propW > $propH) {
$prop = $propH;
} else {
$prop = $propW;
}
if ($photoSize[1] < $miniH * $prop) {
$photoSizeH = $miniH;
} else {
$photoSizeH = $photoSize[1];
}
$photoSizeH = $miniW * $prop;
$photoSizeW = $miniH * $prop;
$y = ($photoSize[1] - $photoSizeH) / 2;
//Utils::ArrayDisplay($y . '=' .'('.$photoSize[1].' - '.$photoSizeH.') / 2');
if ($y < 0) {
$y = 0;
}
$y = 0;
// Utils::ArrayDisplay($y);
$img_oryginal->crop1(0, $y, $photoSizeH, $photoSizeW);
$img_oryginal->scaleProp(242, 340, 0, 'ffffff', false, 'c', 0);
//$img_oryginal->
$img_oryginal->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameth, 'jpg', 90, true);
//Utils::ArrayDisplay(PATH_STATIC_CONTENT.$destDir.$destNameth);
if (is_file(PATH_STATIC_CONTENT . $photo)) {
unlink(PATH_STATIC_CONTENT . $photo);
}
$file = URL_STATIC_CONTENT . $destDir . $destNameth;
//$fileName = $destName;
$array = array($destName => array('normal' => $destName, 'th' => $destNameth));
$arrayPhoto = array_merge($arrayPhoto, $array);
SessionProxy::SetValue('_ARRAY_PHOTO_', $arrayPhoto);
$this->smarty->assign('photo', PATH_STATIC_CONTENT . $destDir . $destName);
//Utils::ArrayDisplay($arrayPhoto);
$idImageGroup = ImageDAL::SaveImage(111, 'Banner', 5);
if (is_file(PATH_STATIC_CONTENT . "upload/Banner/111/" . $destName)) {
unlink(PATH_STATIC_CONTENT . "upload/Banner/111/" . $destName);
}
SessionProxy::ClearValue('_ARRAY_PHOTO_');
}
$arrayPhoto = ImageDAL::GetResult(array('id_image_group' => 5, 'size' => 1), null, 'position ASC');
//Utils::ArrayDisplay($arrayPhoto);
$this->smarty->assign('arrayPhoto', $arrayPhoto);
}
public function FormAction($param) {
$this->SetAjaxRender();
$this->addScript('jQuery/jquery-1.4.2.js', 'file', 'top', 1);
$this->addScript('imageUpload.js', 'file', 'top', 3);
$this->addScript('ajaxupload.3.5.js', 'file', 'top', 2);
}
public function DeleteImageAction($param) {
$this->SetAjaxRender();
if ($_POST['photo']) {
$obj = ImageDAL::GetResult(array('id_mf_image' => $_POST['photo']));
if (isset($obj[0])) {
ImageDAL::Delete($obj[0]);
}
}
$this->smarty->assign('photo', 'image_' . $_POST['photo']);
}
public function DeleteImageBannerAction($param) {
//$this->SetAjaxRender();
if ($param['photo']) {
$obj = ImageDAL::GetResult(array('id_mf_image' => $param['photo']));
if (isset($obj[0])) {
ImageDAL::Delete($obj[0]);
}
}
$this->AddRedirect(Router::GenerateUrl('ReloadImage', array('Image' => 'UploadImage')), 0);
//$this->smarty->assign('photo', 'image_'.$_POST['photo']);
}
public function SortImageAction($param) {
$this->SetNoRender();
//Utils::ArrayDisplay($_POST);
if ($_POST['sort']) {
$arraySort = $_POST['sort'];
foreach ($arraySort as $id => $sort) {
//$obj = ImageDAL::GetResult(array('id_mf_image' => $id));
ImageDAL::UpdateSort($id, $sort);
}
}
$this->AddRedirect(Router::GenerateUrl('ReloadImage', array('Image' => 'UploadImage')), 0);
}
public static function ImportProductAction() {
}
/**
* preDispatch
* @param array $param
* @return null
*/
public function preDispatch($param) {
//$this->AddScript("jQuery/jquery-1.4.2.js");
//$this->AddScript("ajaxupload.3.5.js");
//$this->AddScript("UploadImage.js");
$this->RunShared('Auth', array());
$this->Run($param);
$this->smarty->assign('titleAdmin', 'Slideshow');
$this->smarty->assign('structure', '');
}
/**
* postDispatch
* @param array $param
* @return null
*/
public function postDispatch($param) {
}
}

View File

@@ -0,0 +1,121 @@
<?php
/**
* $Id: IndexController.php 423 2008-05-30 14:42:41Z dakl $
* Strona glowna
*
*/
class IndexController extends MainController implements ControllerInterface {
/**
* strona glowna
*
*/
public function IndexAction($param) {
$kat = '../temp/compile';
$katalog = opendir($kat);
while ($plik = readdir($katalog)) {
if ($plik != '.' AND $plik != '..') {
unlink($kat . '/' . $plik);
}
}
//$this->AddRedirect(URL_MAIN . '/Structure/', 0);
$this->AddRedirect(URL_MAIN . '/Calc/Reg', 0);
}
public function ParserXmlAction($param) {
//ini_set($varname, $newvalue)
$xml = simplexml_load_file(PATH_STATIC_CONTENT . "/wanda.xml");
//$arrayXml = XML2Array::createArray($xml->channel);
$k = 0;
foreach ($xml->channel->item as $key => $entry) {
//Utils::ArrayDisplay($entry);
$htmlString[$k]['content'] = (string) $entry->children('content', true)->encoded;
$htmlString[$k]['title'] = (string) $entry->title;
$date = $entry->pubDate;
$htmlString[$k]['pubDate'] = (string) $entry->children('wp', true)->post_date;
$htmlString[$k]['autor'] = (string) $entry->children('dc', true)->creator;
$content = (string) $entry->children('content', true)->encoded;
$arrayContent = explode("<!--more-->", $content);
Utils::ArrayDisplay($arrayContent);
$htmlString[$k]['shortnote'] = nl2br($arrayContent[0]);
if (isset($arrayContent[1])) {
$htmlString[$k]['content'] = nl2br($arrayContent[1]);
} else {
$htmlString[$k]['content'] = "";
}
//Utils::ArrayDisplay((string)$entry->children('wp', true)->post_date);
$objArticle = SimpleArticle_MfArticleDAL::GetEmptyObj();
$objArticleDescription = $objArticle->GetDescriptionObj();
$objArticle->SetDate(date('Y-m-d'));
$objArticle->SetDatePublication((string) $entry->children('wp', true)->post_date);
$objArticle->SetDateShown(Utils::GetNowDate());
$objArticle->SetWeight(0);
$objArticle->SetPublication(1);
$objArticle->SetType(2);
$objArticle->SetDateUpdate(Utils::GetNowDate());
$objArticle->SetAddDate(Utils::GetNowDate());
$objArticle->SetEditDate(Utils::GetNowDate());
$objArticle->SetIdStructure(1);
$objArticle->SetIdCategory(0);
$objArticleDescription->SetLang('pl');
$objArticleDescription->SetDescription($htmlString[$k]['content']);
$objArticleDescription->SetShortnote($htmlString[$k]['shortnote']);
$objArticleDescription->SetTitle((string) $entry->title);
$objArticleDescription->SetBrowserTitle((string) $entry->title);
$objArticleDescription->SetPublication(1);
$objArticleDescription->SetAutor($htmlString[$k]['autor']);
// $iid = SimpleArticle_MfArticleDAL::Save($objArticle);
// $objArticleDescription->SetIdMfArticle($iid);
//
//
// $objLink = new MfLink('-1');
// $objLink->SetSourceType('mf_article');
// $objLink->SetIdSource($iid);
// $objLink->SetDestinationType('mf_article_category');
// $objLink->SetIdDestination(2);
// $objLink->SetLinkType(1);
// MfLinkDAL::Save($objLink);
//
// SimpleArticle_MfArticleDescriptionDAL::Save($objArticleDescription);
//
//
//echo $entry;
$k++;
}
Utils::ArrayDisplay($htmlString);
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->smarty->assign('titleAdmin', 'Panel Administracyjny');
// $this->RunShared('Auth');
// $this->RunShared('Auth', array());
// $this->smarty->assign("menuSelected", "");
// $this->smarty->assign('activeTab', 'index');
// $this->AddScript("formAction.js");
// $this->Run($param);
}
/**
*
*
*/
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,66 @@
<?php
/**
* $Id: LoginController.php 969 2008-07-29 13:55:14Z pawy $
* Kontroler autoryzacji
*
*/
class LoginController extends MainController implements ControllerInterface {
/**
* domyslna metoda
*
*/
public function IndexAction($param) {
}
/**
* Autoryzacja
*
*/
public function AuthAction($param) {
if(isset($_REQUEST['eLogin']) && isset($_REQUEST['ePassword'])){
$result = AuthDAL::Login($_REQUEST['eLogin'], $_REQUEST['ePassword']);
//Utils::ArrayDisplay($_REQUEST);
Utils::ArrayDisplay($result);
if($result == true){
//$logger = LoggerManager::getLogger(__CLASS__);
//$logger->info('Zalogowal sie uzytkownik: '.$_REQUEST['eLogin'].', z ip: '.getenv('REMOTE_ADDR').', z domeny: '.getenv('REMOTE_HOST'));
Header("Location: ". Router::GenerateUrl('indexURL', array('Index' => 'Index')) );
} else {
$this->smarty->assign("loginError", "1");
}
}
}
/**
* Wylogowanie
*
*/
public function LogoutAction($param) {
SessionProxy::ClearSession();
AuthDAL::Logout();
die(Header("Location: login".APPLICATION_FILE_TYPE));
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
$this->smarty->assign('projectName', PROJECT_NAME);
//session_start();
$template = 'login.tpl';
Registry::Remove('smartyTemplate');
Registry::Set('smartyTemplate', $template);
$this->smarty->assign("loginError", "");
}
public function postDispatch($param)
{
}
}
?>

View File

@@ -0,0 +1,236 @@
<?php
/**
* $Id$
* przypominarka
*
*/
class MailingController extends ModuleController implements ControllerInterface {
const REDIRECT_URL = "mailing.frmx";
/**
* Domyslna metoda
*
*/
public function IndexAction($param) {
//Utils::ArrayDisplay($param);
//$arrayAddress = MailingDAL::GetMailingAddressList(1);
//PEJDZOWANIE
$countLimit = 10;
if(isset($param['strona']) && $param['strona'] > 0 ){
$offset = ($param['strona']-1) * $countLimit;
$this->smarty->assign('currentPage', ($param['strona']-1)* $countLimit);
}
else{
$offset = 0;
$this->smarty->assign('currentPage', 0);
}
$this->smarty->assign('PageCount', ceil(MailingDAL::GetCountAll()/$countLimit));
$this->RunShared('Pagination', $param);
//AKCJE DOMY<4D>LNE
$arrayObjMailing = MailingDAL::GetAll($offset, $countLimit);
//Utils::ArrayDisplay($_SERVER['DOCUMENT_ROOT']);
$this->smarty->assign('arrayObjMailing', $arrayObjMailing);
}
/**
* Wysy<73>ka metoda
*
*/
public function SendAction($param) {
if (isset($_POST['sendEmail'])) {
//Utils::ArrayDisplay($_POST);
$objMailing = new Mailing('', $_POST['subjet'], $_POST['content'], 0, '', 2, 0);
MailingDAL::Save($objMailing);
$this->smarty->assign('sendInfo', "Email zosta<74> przekazany do wysy<73>i");
Utils::Redirect(URL_MAIN.'/index,'.self::REDIRECT_URL);
}
include("plugins/fckeditor/fckeditor_php5.php");
$oFCKeditor = new FCKeditor('content');
$oFCKeditor->BasePath = 'plugins/fckeditor/';
$oFCKeditor->Value = '';
$oFCKeditor->ToolbarSet = 'Formix';
$oFCKeditor->Height = 400;
$this->smarty->assign('fck', $oFCKeditor);
}
/**
* Podgl<67>d
*
*/
public function ShowAction($param) {
//$arrayAddress = MailingDAL::GetMailingAddressList();
//Utils::ArrayDisplay($arrayAddress);
//Utils::ArrayDisplay($param);
if (isset($param['id'])) {
$objMailing = MailingDAL::GetMailingById($param['id']);
$this->smarty->assign('objMailing', $objMailing);
}
// if (!isset($objMailing)) {
// die(Header('Location: mailing'.APPLICATION_FILE_TYPE));
// }
}
public function GetSendAction() {
$logger = LoggerManager::getLogger(__CLASS__);
$objMailing = MailingDAL::GetMailingToSend();
//while (($objMailing = MailingDAL::GetMailingToSend())) {
// }
if (is_object($objMailing)) {
$logger = LoggerManager::getLogger(__CLASS__);
$limit = $objMailing->GetLastSend() + 50;
$mailList = array();
$logger->info("limit: $limit ".$objMailing->GetLastSend());
$mailList = MailingDAL::GetMailingAddressList(2, $objMailing->GetLastSend(), 50);
MailingDAL::UpdateLastSend($objMailing->GetId(), $limit);
//Utils::ArrayDisplay($mailList);
// pobiera z tabeli user (jezeli taka istnije w tym przypadku nie potrzebna)
// if (!is_array($mailList) || count($mailList) < 50 && $objMailing->GetType() == 1) {
// MailingDAL::UpdateLastSend($objMailing->GetId(), 0);
// MailingDAL::UpdateType($objMailing->GetId());
//
// }
if (!is_array($mailList) || count($mailList) < 50 && $objMailing->GetType() == 2) {
MailingDAL::UpdateLastSend($objMailing->GetId(), 0);
MailingDAL::SetExecuted($objMailing->GetId());
}
//$this->smarty->assign('content', $objMailing->GetText());
//$txtmessage = $this->smarty->fetch('MailTxt.tpl');
//Utils::ArrayDisplay($mailList);
foreach ($mailList as $key => $arrayPackage) {
foreach ($arrayPackage as $keyPackege => $value) {
$subjet = " DB Druk - ".$objMailing->GetTitle();
$mail = new PHPMailer();
$mail -> CharSet = "utf-8";
$mail -> Subject = $subjet;
$mail -> SMTPAuth = true;
$mail -> Mailer = 'smtp';
$mail -> Host = "dbdruk.formix.eu";
$mail -> Port = 25;
$mail -> Priority = 3;
$mail ->IsHTML(true);
//$mail -> ConfirmReadingTo = "wino@wino.formix.eu";
$mail ->From = "smtp@dbdruk.formix.eu";
$mail -> FromName = "DB Druk";
$mail -> Username = "smtp@dbdruk.formix.eu";
$mail -> Password = "smtp1234";
//$mail->AddAddress('maciek@formix.pl', 'Maciej Kloch');
$mail->AddAddress($value['email'], $value['name']);
$mail -> AddBCC("maciek@formix.pl", "Mailing - dbdruk.pl ".$value['email']."- ".$value['name']." ".$key."-".$keyPackege);
$mail -> Body = $objMailing->GetText();
$mail -> Send();
}
//sleep(2);
}
//sleep(25);
}
Utils::Redirect(URL_MAIN.'/index,'.self::REDIRECT_URL);
}
public function ListAction($param) {
//PEJDZOWANIE
$countLimit = 10;
if(isset($param['strona']) && $param['strona'] > 0 ){
$offset = ($param['strona']-1) * $countLimit;
$this->smarty->assign('currentPage', ($param['strona']-1)* $countLimit);
}
else{
$offset = 0;
$this->smarty->assign('currentPage', 0);
}
$this->smarty->assign('PageCount', ceil(MailingDAL::GetCountAllEmail()/$countLimit));
$this->RunShared('Pagination', $param);
//AKCJE DOMY<4D>LNE
$arrayEmail = MailingDAL::GetAllEmail($offset, $countLimit);
//Utils::ArrayDisplay($arrayEmail);
$this->smarty->assign('arrayEmail', $arrayEmail);
}
/**
* usuwanie emial z list mailingowej
*
*/
public function DeleteAction($param) {
$logger = LoggerManager::getLogger(__CLASS__);
//$idCustomer = SessionProxy::GetValue(EnumSessionValue::IDCUSTOMER);
if(isset($param['id'])) {
$id=$param['id'];
} else{
$id = null;
}
if($id) {
MailingDAL::Delete($id);
die(Header('Location: list,mailing'.APPLICATION_FILE_TYPE));
if (Pat) {
}
}
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
//Utils::ArrayDisplay($param);
$this->Run($param);
$this->RunShared('Mailing');
$this->smarty->assign('titleAdmin', 'Mailing');
//$this->smarty->assign('showIcon', false);
if($this->IsUser()==false) {
$this->AddRedirect(URL_MAIN.'/Login.frmx', 0);
}
}
public function postDispatch($param) {
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,540 @@
<?php
/**
* Produkty
*
*
*/
class ProductAttributeController extends MainController implements ControllerInterface {
const AVATAR_DEST_DIR = '/upload/Product';
const AVATAR_TEMP_DIR = '/upload/temp';
const NO_PHOTO_IMG_BIG = "image/Admin/cropperNoPhotoBig.gif";
const NO_PHOTO_IMG_SMALL = "image/Admin/przekatne.gif";
const MAX_AVATAR_FILE_SIZE = 5; //Rozmiar w mb
const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
const PHOTO_WIDTH = 800;
const PHOTO_HEIGHT = 600;
const IMAGE_MINI_WIDTH = 240;
const IMAGE_MINI_HEIGHT = 180;
const IMAGE_NORMAL_WIDTH = 800;
const IMAGE_NORMAL_HEIGHT = 600;
public function IndexAction($param) {
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
$dalData->setCondition(array('lang' => $param['lang']));
$arrayObjProductAttribute = MfProductAttributeDAL::GetResult($dalData);
// $param['runSharedVariable'] = 'linkedAttribute';
// $this->RunModuleController( 'ProductAttributeController', 'LinkedAttribute', $param, true);
//
// $param['runSharedVariable'] = 'unlinkedAttribute';
// $this->RunModuleController( 'ProductAttributeController', 'UnlinkedAttribute', $param, true);
$this->smarty->assign('arrayObjProductAttribute', $arrayObjProductAttribute);
//Utils::ArrayDisplay($arrayObjProductAttribute);
}
// public function UpdateLangAttrAction($param) {
//
// $dalData = MfProductAttributeDAL::GetDalDataObj();
// $dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
// $dalData->setCondition(array('lang' => 'pl'));
// $arrayObjProductAttribute = MfProductAttributeDAL::GetResult($dalData);
//
// //Utils::ArrayDisplay($arrayObjProductAttribute);
//
// foreach ($arrayObjProductAttribute as $objProductAttribute) {
// //Utils::ArrayDisplay($objProductAttribute->GetDescriptionObj());
// $objDesc = $objProductAttribute->GetDescriptionObj();
// foreach (Router::$arrayLang as $lang) {
// if ($lang != 'pl') {
//
// $objDesc->setLang($lang);
// $objDesc->setId('-1');
// Utils::ArrayDisplay($objDesc);
// MfProductAttributeDescriptionDAL::Save($objDesc);
//
// }
// }
// }
//
// }
//
// public function UpdateLangCatAction($param) {
//
// $dalData = MfProductCategoryDAL::GetDalDataObj();
// $dalData->setJoin(array('MfProductCategoryDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
// $dalData->setCondition(array('lang' => 'pl'));
// $arrayObjProductCategory = MfProductCategoryDAL::GetResult($dalData);
//
// //Utils::ArrayDisplay($arrayObjProductAttribute);
//
// foreach ($arrayObjProductCategory as $objProductCategory) {
// //Utils::ArrayDisplay($objProductAttribute->GetDescriptionObj());
// $objDesc = $objProductCategory->GetDescriptionObj();
// foreach (Router::$arrayLang as $lang) {
// if ($lang != 'pl') {
//
// $objDesc->setLang($lang);
// $objDesc->setId('-1');
// Utils::ArrayDisplay($objDesc);
// MfProductCategoryDescriptionDAL::Save($objDesc);
//
// }
// }
// }
//
// }
public function LinkedAttributeAction($param) {
//Utils::ArrayDisplay($param);
if (isset($param['idAttribute'])) {
$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product_attribute', $param['idAttribute'], $param['lang']);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
} else {
$this->smarty->assign('arrayObjAttribute', array());
$this->smarty->assign('clikAttribute', true);
}
}
public function UnlinkedAttributeAction($param) {
//Utils::ArrayDisplay($param);
if (isset($param['idAttribute'])) {
$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product_attribute', $param['idAttribute'], $param['lang']);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
} else {
$this->smarty->assign('arrayObjAttribute', array());
$this->smarty->assign('clikAttribute', true);
}
}
public function IndexStructureAction($param) {
$idAttribute = SessionProxy::GetValue('idAttribute');
$this->smarty->assign('idAttribute', $idAttribute);
$idsProduct = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product',$idAttribute, $param['lang']);
$dalData = MfProductDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductDescription' => ' LEFT JOIN mf_product_description ON mf_product.id_mf_product=mf_product_description.id_mf_product '));
$dalData->setCondition(array('lang' => $param['lang']));
//Utils::ArrayDisplay('ss'.$idsProduct);
$dalData->addCondition(' ', 'mf_product.id_mf_product IN (' .$idsProduct. ') ', ' ');
$arrayObj = MfProductDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayObj);
if (isset($param['methodToRun']) && $param['methodToRun'] == 'Add') {
$this->smarty->assign('add', true);
}
}
public function AddAction($param) {
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttribue);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', array());
$objAttributeProduct = MfProductAttributeDAL::GetEmptyObj();
if (Request::GetPost('doAttributeAdd')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name_pl', 'Pole nazwa musi zostać wypełnione.');
//$validator->IsEmpty('name_en', 'Pole nazwa musi zostać wypełnione.');
//$validator->IsEmpty('name_ru', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$objProduct = new MfProduct();
//$objAttributeProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
$objAttributeProduct->setDate("0000-00-00");
$objAttributeProduct->setPublication($publication);
$objAttributeProductDesc = new MfProductAttributeDescription();
$objAttributeProductDescEn = new MfProductAttributeDescription();
$objAttributeProductDescRu = new MfProductAttributeDescription();
$objAttributeProductDesc->setLang('pl');
$objAttributeProductDesc->setDescription($data['name_pl']);
$objAttributeProductDescEn->setLang('en');
$objAttributeProductDescEn->setDescription($data['name_en']);
$objAttributeProductDescRu->setLang('ru');
$objAttributeProductDescRu->setDescription($data['name_ru']);
//$arrayObjAttributeWithValue = array();
//Utils::ArrayDisplay($arrayObjAttribute);
if(empty($out)) {
//Utils::ArrayDisplay($objAttributeProductDesc);
//Utils::ArrayDisplay($objAttributeProductDescEn);
//Utils::ArrayDisplay($objAttributeProductDescRu);
$idAttributeProduct = MfProductAttributeDAL::Save($objAttributeProduct);
$objAttributeProductDesc->setIdMfProductAttribute($idAttributeProduct);
$objAttributeProductDescEn->setIdMfProductAttribute($idAttributeProduct);
$objAttributeProductDescRu->setIdMfProductAttribute($idAttributeProduct);
MfProductAttributeDescriptionDAL::Save($objAttributeProductDesc);
MfProductAttributeDescriptionDAL::Save($objAttributeProductDescEn);
MfProductAttributeDescriptionDAL::Save($objAttributeProductDescRu);
// foreach ($data['attr'] as $attrKey => $attrId ) {
// $objMfProductLink = new MfProductLink();
// $objMfProductLink->setDestinationType('mf_product_attribute');
// $objMfProductLink->setSourceType('mf_product_attribute');
// $objMfProductLink->setIdDestination($attrId);
// $objMfProductLink->setIdSource($idAttributeProduct);
// $objMfProductLink->setLang($param['lang']);
// $objMfProductLink->setPublication(1);
// MfProductLinkDAL::Save($objMfProductLink);
// }
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'index')));
} else {
// if (isset($data['attr'])) {
// $idAttrLinked = implode(', ',$data['attr']);
// } else {
// $idAttrLinked = '-1';
// }
// $dalData = MfProductAttributeDAL::GetDalDataObj();
// $dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
// $dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//
// //Utils::ArrayDisplay($dalData);
// $arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
// //$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
// //Utils::ArrayDisplay($arrayObjAttributeLinked);
//
// $dalData = MfProductAttributeDAL::GetDalDataObj();
// $dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
// $dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//
// //Utils::ArrayDisplay($dalData);
// $arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
//
// $this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
// $this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
$objAttributeProduct->SetDescriptionObj($objAttributeProductDesc);
$this->smarty->assign('objAttributeProductDesc',$objAttributeProductDesc);
$this->smarty->assign('objAttributeProductDescRu',$objAttributeProductDescRu);
$this->smarty->assign('objAttributeProductDescEn',$objAttributeProductDescEn);
$this->smarty->assign('objAttributeProduct',$objAttributeProduct);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function EditAction($param) {
// $idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_attribute', 'mf_product_attribute', $param['id'], $param['lang']);
// $dalData = MfProductAttributeDAL::GetDalDataObj();
// $dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idsAttribute.') ', ' ');
// $dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//
// //Utils::ArrayDisplay($dalData);
// $arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
//
// $dalData = MfProductAttributeDAL::GetDalDataObj();
// $dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
// $dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//
// //Utils::ArrayDisplay($dalData);
// $arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
// //$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
// //Utils::ArrayDisplay($arrayObjAttribue);
// $this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
// $this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
$objAttributeProduct = MfProductAttributeDAL::GetById($param['id'], 'pl');
$objAttributeProductRu = MfProductAttributeDAL::GetById($param['id'], 'ru');
$objAttributeProductEn = MfProductAttributeDAL::GetById($param['id'], 'en');
//$objAttributeProduct->setLang('pl');
$this->smarty->assign('objAttributeProduct', $objAttributeProduct);
$this->smarty->assign('objAttributeProductDesc',$objAttributeProduct->getDescriptionObj());
//$objAttributeProduct->setLang('en');
$this->smarty->assign('objAttributeProductDescRu',$objAttributeProductRu->getDescriptionObj());
//$objAttributeProduct->setLang('ru');
$this->smarty->assign('objAttributeProductDescEn',$objAttributeProductEn->getDescriptionObj());
if (Request::GetPost('doAttributeEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name_pl', 'Pole nazwa musi zostać wypełnione.');
//$validator->IsEmpty('name_en', 'Pole nazwa musi zostać wypełnione.');
//$validator->IsEmpty('name_ru', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$objProduct = new MfProduct();
//$objAttributeProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
$objAttributeProduct->setDate("0000-00-00");
$objAttributeProduct->setPublication($publication);
$objAttributeProductDesc = $objAttributeProduct->getDescriptionObj();
$objAttributeProductDescEn = $objAttributeProductEn->getDescriptionObj();
$objAttributeProductDescRu = $objAttributeProductRu->getDescriptionObj();
//$objAttributeProductDesc->setDatePublication("0000-00-00 00:00:00");
$objAttributeProductDesc->setLang('pl');
$objAttributeProductDesc->setDescription($data['name_pl']);
$objAttributeProductDescEn->setLang('en');
$objAttributeProductDescEn->setDescription($data['name_en']);
$objAttributeProductDescRu->setLang('ru');
$objAttributeProductDescRu->setDescription($data['name_ru']);
$objAttributeProduct->setLang('pl');
//$arrayObjAttributeWithValue = array();
//Utils::ArrayDisplay($arrayObjAttribute);
if(empty($out)) {
//Utils::ArrayDisplay($objAttributeProductDesc);
//Utils::ArrayDisplay($objAttributeProductDescEn);
//Utils::ArrayDisplay($objAttributeProductDescRu);
$idAttributeProduct = MfProductAttributeDAL::Save($objAttributeProduct);
$objAttributeProductDesc->setIdMfProductAttribute($idAttributeProduct);
$objAttributeProductDescEn->setIdMfProductAttribute($idAttributeProduct);
$objAttributeProductDescRu->setIdMfProductAttribute($idAttributeProduct);
MfProductAttributeDescriptionDAL::Save($objAttributeProductDesc);
MfProductAttributeDescriptionDAL::Save($objAttributeProductDescEn);
MfProductAttributeDescriptionDAL::Save($objAttributeProductDescRu);
// MfProductLinkDAL::DeleteFromLink($idAttributeProduct, 'mf_product_attribute', null, 'mf_product_attribute');
//
// foreach ($data['attr'] as $attrKey => $attrId ) {
// $objMfProductLink = new MfProductLink();
// $objMfProductLink->setDestinationType('mf_product_attribute');
// $objMfProductLink->setSourceType('mf_product_attribute');
// $objMfProductLink->setIdDestination($attrId);
// $objMfProductLink->setIdSource($idAttributeProduct);
// $objMfProductLink->setLang($param['lang']);
// $objMfProductLink->setPublication(1);
// //Utils::ArrayDisplay($objMfProductLink);
// MfProductLinkDAL::Save($objMfProductLink);
// }
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'index')));
} else {
// if (isset($data['attr'])) {
// $idAttrLinked = implode(', ',$data['attr']);
// } else {
// $idAttrLinked = '-1';
// }
// $dalData = MfProductAttributeDAL::GetDalDataObj();
// $dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
// $dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//
// //Utils::ArrayDisplay($dalData);
// $arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
// //$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_attribute', $idAttribute, 'mf_product_attribute');
// //Utils::ArrayDisplay($arrayObjAttributeLinked);
//
// $dalData = MfProductAttributeDAL::GetDalDataObj();
// $dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
// $dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//
// //Utils::ArrayDisplay($dalData);
// $arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
//
// $this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
// $this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
//
$objAttributeProduct->SetDescriptionObj($objAttributeProductDesc);
$this->smarty->assign('objAttributeProduct',$objAttributeProduct);
$this->smarty->assign('objAttributeProductDesc',$objAttributeProductDesc);
$this->smarty->assign('objAttributeProductDescRu',$objAttributeProductDescRu);
$this->smarty->assign('objAttributeProductDescEn',$objAttributeProductDescEn);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function AjaxAddLinkAttrAction($param) {
//$array
}
public function DeleteAction($param) {
$isLinked = MfProductLinkDAL::IsLinked(null, 'mf_product_category', $param['id'], 'mf_product_attribute');
$delete = true;
$error = '';
if ($isLinked > 0 ) {
$delete = false;
}
$arrayLang = (Router::$arrayLang);
unset($arrayLang[$param['lang']]);
$langString = implode(',', $arrayLang);
$isLang = MfProductAttributeDAL::CheakDescLang($param['id'], $param['lang']);
// if ($isLang) {
// $delete = false;
// }
if ($delete) {
foreach (Router::$arrayLang as $lang) {
$objAttribute = MfProductAttributeDAL::GetById($param['id'], $lang);
$objAttributeDesc = $objAttribute->getDescriptionObj();
$dalDataDesc = MfProductAttributeDescriptionDAL::GetDalDataObj();
$dalDataDesc->setObj($objAttributeDesc);
MfProductAttributeDescriptionDAL::Delete($dalDataDesc);
}
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setObj($objAttribute);
MfProductAttributeDAL::Delete($dalData);
$this->AddRedirectInfo('Element został usunięty', 'ok', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'Index')));
} else {
if ($isLinked) {
$error .= 'Parametr jest powiązany z kategorią.';
}
// if ($isLang) {
// $error .= $error ? '<br/><br/>' : '';
// $error .= 'Parametr posiada wersję jezykową';
// }
$this->AddRedirectInfo($error, 'error', Router::GenerateUrl('editAttribute', array('ProductAttribute' => 'Index')));
}
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$this->AddScript('structure.js');
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Administracja');
$struct = array(
//'User' => array('User' => 'Index'),
'Słowniki' => array('Dictionary' => 'Index'),
'Zmienne serwisu' => array('Setup' => 'Index'),
//'Kategorie produktów' => array('ProductCategory' => 'Index'),
'Parametry produktów' => array('ProductAttribute' => 'Index')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function PostDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,572 @@
<?php
/**
* Produkty
*
*
*/
class ProductCategoryController extends MainController implements ControllerInterface {
const AVATAR_DEST_DIR = '/upload/Product';
const AVATAR_TEMP_DIR = '/upload/temp';
const NO_PHOTO_IMG_BIG = "image/Admin/cropperNoPhotoBig.gif";
const NO_PHOTO_IMG_SMALL = "image/Admin/przekatne.gif";
const MAX_AVATAR_FILE_SIZE = 5; //Rozmiar w mb
const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
const PHOTO_WIDTH = 800;
const PHOTO_HEIGHT = 600;
const IMAGE_MINI_WIDTH = 240;
const IMAGE_MINI_HEIGHT = 180;
const IMAGE_NORMAL_WIDTH = 800;
const IMAGE_NORMAL_HEIGHT = 600;
public function IndexAction($param) {
//Utils::ArrayDisplay($param);
$dalData = MfProductCategoryDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductCategoryDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
$dalData->setCondition(array('lang' => $param['lang']));
$arrayObjProductCategory = MfProductCategoryDAL::GetResult($dalData);
$param['runSharedVariable'] = 'linkedAttribute';
$this->RunModuleController( 'ProductCategoryController', 'LinkedAttribute', $param, true);
//
// $param['runSharedVariable'] = 'unlinkedAttribute';
// $this->RunModuleController( 'ProductCategoryController', 'UnlinkedAttribute', $param, true);
foreach ($arrayObjProductCategory as $item) {
$menu[$item->GetId()] = $item;
}
foreach ($menu as $key => $obj) {
if ($obj->GetIdParent() != 0) {
if (key_exists($obj->GetIdParent(), $menu)) {
$menu[$obj->GetIdParent()]->SetHaveChildren(true);
$menu[$obj->GetIdParent()]->AddChildren(array($obj->GetId() => $obj));
} else {
$arrayTree[$key] = $obj;
}
}
if ($obj->GetIdParent() == 0) {
//Utils::ArrayDisplay('ones');
$arrayTree[$key] = $obj;
}
}
foreach ($menu as $key => $obj) {
}
//Utils::ArrayDisplay($arrayTree);
$this->smarty->assign('menuProductCategory', $arrayTree);
$this->smarty->assign('arrayObjProductCategory', $arrayObjProductCategory);
//Utils::ArrayDisplay($arrayObjProductCategory);
}
public function LinkedAttributeAction($param) {
//Utils::ArrayDisplay($param);
if (isset($param['idCategory'])) {
$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_category', 'mf_product_attribute', $param['idCategory'], 'pl');
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
$dalData->setSortBy(' FIELD(mf_product_attribute.id_mf_product_attribute, '.$idsAttribute.')');
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('idCategory', $param['idCategory']);
} else {
$this->smarty->assign('arrayObjAttribute', array());
$this->smarty->assign('clikCategory', true);
}
}
public function SaveSortAction($param) {
$this->SetNoRender();
//Utils::ArrayDisplay($param);
if (Request::GetPost('doSaveSort')) {
$arrayAttrSort = Request::GetPost('attr');
$idCategory = Request::GetPost('idCategory');
//Utils::ArrayDisplay($arrayAttrSort);
//source_type id_source destination_type id_destination
//mf_product_category 2 mf_product_attribute 6 0
foreach ($_POST['attr'] as $idAttr => $sort) {
//Utils::ArrayDisplay($idAttr);
$dalData = MfProductLinkDAL::GetDalDataObj();
$dalData->setCondition(array('source_type' => 'mf_product_category', 'id_source' => $idCategory, 'destination_type'=> 'mf_product_attribute', 'id_destination' => $idAttr, 'lang' => 'pl'));
$arrayAttrLink = MfProductLinkDAL::GetResult($dalData);
//Utils::ArrayDisplay($arrayAttrLink);
foreach ($arrayAttrLink as $link) {
$link->setWeight($sort);
//Utils::ArrayDisplay($link);
MfProductLinkDAL::Save($link);
}
}
// Utils::ArrayDisplay($_POST);
}
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editCategory', array('ProductCategory' => 'index', 'idCategory' => $idCategory)));
}
public function UnlinkedAttributeAction($param) {
//Utils::ArrayDisplay($param);
if (isset($param['idCategory'])) {
$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_category', 'mf_product_attribute', $param['idCategory'], $param['lang']);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => 'pl'));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
} else {
$this->smarty->assign('arrayObjAttribute', array());
$this->smarty->assign('clikCategory', true);
}
}
public function IndexStructureAction($param) {
$idCategory = SessionProxy::GetValue('idCategory');
$this->smarty->assign('idCategory', $idCategory);
$idsProduct = MfProductLinkDAL::GetIdStringDestinaion('mf_product_category', 'mf_product',$idCategory, $param['lang']);
$dalData = MfProductDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductDescription' => ' LEFT JOIN mf_product_description ON mf_product.id_mf_product=mf_product_description.id_mf_product '));
$dalData->setCondition(array('lang' => $param['lang']));
//Utils::ArrayDisplay('ss'.$idsProduct);
$dalData->addCondition(' ', 'mf_product.id_mf_product IN (' .$idsProduct. ') ', ' ');
$arrayObj = MfProductDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayObj);
if (isset($param['methodToRun']) && $param['methodToRun'] == 'Add') {
$this->smarty->assign('add', true);
}
}
public function AddAction($param) {
// Pobiernie rodziców kategorii
$dalData = MfProductCategoryDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductCategoryDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
$dalData->setCondition(array('lang' => $param['lang'], 'mf_product_category.id_parent' => 0));
$arrayObjProductCategory = MfProductCategoryDAL::GetResult($dalData);
//$param['runSharedVariable'] = 'linkedAttribute';
//$this->RunModuleController( 'ProductCategoryController', 'LinkedAttribute', $param, true);
//
// $param['runSharedVariable'] = 'unlinkedAttribute';
// $this->RunModuleController( 'ProductCategoryController', 'UnlinkedAttribute', $param, true);
//Utils::ArrayDisplay($arrayObjProductCategory);
$this->smarty->assign('arrayObjProductCategory', $arrayObjProductCategory);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttribue);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', array());
$objCategoryProduct = MfProductCategoryDAL::GetEmptyObj();
if (Request::GetPost('doCategoryAdd')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$objProduct = new MfProduct();
//$objCategoryProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
$objCategoryProduct->setPublication($publication);
$objCategoryProduct->setIdParent($data['idParent']);
$objCategoryProduct->setWeight($data['weight']);
$objCategoryProductDesc = new MfProductCategoryDescription();
$objCategoryProductDesc->setDatePublication("0000-00-00 00:00:00");
$objCategoryProductDesc->setLang('pl');
$objCategoryProductDesc->setName($data['name']);
$objCategoryProductDesc->setPublication($publication);
//$arrayObjAttributeWithValue = array();
//Utils::ArrayDisplay($arrayObjAttribute);
if(empty($out)) {
$idCategoryProduct = MfProductCategoryDAL::Save($objCategoryProduct);
$objCategoryProductDesc->setIdMfProductCategory($idCategoryProduct);
$objCategoryProductDescEn = $objCategoryProductDesc;
//$objCategoryProductDescEn->setLang('en');
$objCategoryProductDescRu = $objCategoryProductDesc;
//$objCategoryProductDescRu->setLang('ru');
MfProductCategoryDescriptionDAL::Save($objCategoryProductDesc);
///Utils::ArrayDisplay($objCategoryProductDesc);
$objCategoryProductDescEn->setLang('en');
$objCategoryProductDescEn->setId(-1);
MfProductCategoryDescriptionDAL::Save($objCategoryProductDescEn);
//Utils::ArrayDisplay($objCategoryProductDesc);
$objCategoryProductDescRu->setLang('ru');
$objCategoryProductDescRu->setId(-1);
MfProductCategoryDescriptionDAL::Save($objCategoryProductDescRu);
//Utils::ArrayDisplay($objCategoryProductDesc);
if (isset($data['attr'])) {
foreach ($data['attr'] as $attrKey => $attrId ) {
$objMfProductLink = new MfProductLink();
$objMfProductLink->setDestinationType('mf_product_attribute');
$objMfProductLink->setSourceType('mf_product_category');
$objMfProductLink->setIdDestination($attrId);
$objMfProductLink->setIdSource($idCategoryProduct);
$objMfProductLink->setLang('pl');
$objMfProductLink->setPublication(1);
MfProductLinkDAL::Save($objMfProductLink);
}
}
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editCategory', array('ProductCategory' => 'index')));
} else {
if (isset($data['attr'])) {
$idAttrLinked = implode(', ',$data['attr']);
} else {
$idAttrLinked = '-1';
}
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttributeLinked);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
$objCategoryProduct->SetDescriptionObj($objCategoryProductDesc);
$this->smarty->assign('objCategoryProduct',$objCategoryProduct);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function EditAction($param) {
// Pobiernie rodziców kategorii
$dalData = MfProductCategoryDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductCategoryDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
$dalData->setCondition(array('lang' => $param['lang'], 'mf_product_category.id_parent' => 0, ' ' => array('value' => ' mf_product_category.id_mf_product_category NOT IN('.$param['id'].')' ,'condition' => '')));
$arrayObjProductCategory = MfProductCategoryDAL::GetResult($dalData);
//$param['runSharedVariable'] = 'linkedAttribute';
//$this->RunModuleController( 'ProductCategoryController', 'LinkedAttribute', $param, true);
//
// $param['runSharedVariable'] = 'unlinkedAttribute';
// $this->RunModuleController( 'ProductCategoryController', 'UnlinkedAttribute', $param, true);
//Utils::ArrayDisplay($arrayObjProductCategory);
$this->smarty->assign('arrayObjProductCategory', $arrayObjProductCategory);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$idsAttribute = MfProductLinkDAL::GetIdStringDestinaion('mf_product_category', 'mf_product_attribute', $param['id'], 'pl');
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idsAttribute.') ', ' ');
$dalData->setSortBy(' FIELD(mf_product_attribute.id_mf_product_attribute, '.$idsAttribute.')');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
$dalData->setSortBy(' FIELD(mf_product_attribute.id_mf_product_attribute, '.$idsAttribute.')');
//Utils::ArrayDisplay($dalData);
$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttribue);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
$objCategoryProduct = MfProductCategoryDAL::GetById($param['id'], $param['lang']);
$this->smarty->assign('objCategoryProduct', $objCategoryProduct);
if (Request::GetPost('doCategoryEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$objProduct = new MfProduct();
//$objCategoryProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
$objCategoryProduct->setDatePublication("0000-00-00 00:00:00");
$objCategoryProduct->setPublication($publication);
$objCategoryProduct->setIdParent($data['idParent']);
$objCategoryProduct->setWeight($data['weight']);
$objCategoryProductDesc = $objCategoryProduct->getDescriptionObj();
$objCategoryProductDesc->setDatePublication("0000-00-00 00:00:00");
$objCategoryProductDesc->setLang($param['lang']);
$objCategoryProductDesc->setName($data['name']);
$objCategoryProductDesc->setPublication($publication);
//$arrayObjAttributeWithValue = array();
//Utils::ArrayDisplay($arrayObjAttribute);
if(empty($out)) {
//Utils::ArrayDisplay($data);
$idCategoryProduct = MfProductCategoryDAL::Save($objCategoryProduct);
$objCategoryProductDesc->setIdMfProductCategory($idCategoryProduct);
MfProductCategoryDescriptionDAL::Save($objCategoryProductDesc);
MfProductLinkDAL::DeleteFromLink($idCategoryProduct, 'mf_product_category', null, 'mf_product_attribute');
foreach ($data['attr'] as $attrKey => $attrId ) {
$objMfProductLink = new MfProductLink();
$objMfProductLink->setDestinationType('mf_product_attribute');
$objMfProductLink->setSourceType('mf_product_category');
$objMfProductLink->setIdDestination($attrId);
$objMfProductLink->setIdSource($idCategoryProduct);
$objMfProductLink->setLang('pl');
$objMfProductLink->setPublication(1);
$objMfProductLink->setWeight($data['linked_attr_weight'][$attrId]);
//Utils::ArrayDisplay($objMfProductLink);
MfProductLinkDAL::Save($objMfProductLink);
}
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editCategory', array('ProductCategory' => 'index')));
} else {
if (isset($data['attr'])) {
$idAttrLinked = implode(', ',$data['attr']);
} else {
$idAttrLinked = '-1';
}
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttributeLinked);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
$objCategoryProduct->SetDescriptionObj($objCategoryProductDesc);
$this->smarty->assign('objCategoryProduct',$objCategoryProduct);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function AjaxAddLinkAttrAction($param) {
//$array
}
public function DeleteAction($param) {
$isLinked = MfProductLinkDAL::IsLinked($param['id'], 'mf_product_category', null, 'mf_product');
$delete = true;
$error = '';
if ($isLinked > 0 ) {
$delete = false;
}
$arrayLang = (Router::$arrayLang);
unset($arrayLang[$param['lang']]);
$langString = implode(',', $arrayLang);
$isLang = MfProductCategoryDAL::CheakDescLang($param['id'], $param['lang']);
// if ($isLang) {
// $delete = false;
// }
if ($delete) {
foreach (Router::$arrayLang as $lang) {
$objCategory = MfProductCategoryDAL::GetById($param['id'], $lang);
$objCategoryDesc = $objCategory->getDescriptionObj();
$dalDataDesc = MfProductCategoryDescriptionDAL::GetDalDataObj();
$dalDataDesc->setObj($objCategoryDesc);
MfProductCategoryDescriptionDAL::Delete($dalDataDesc);
}
$dalData = MfProductCategoryDAL::GetDalDataObj();
$dalData->setObj($objCategory);
MfProductCategoryDAL::Delete($dalData);
$this->AddRedirectInfo('Element został usunięty', 'ok', Router::GenerateUrl('editCategory', array('ProductCategory' => 'Index')));
} else {
if ($isLinked) {
$error .= 'Kategoria jest powiązana z produktem.';
}
// if ($isLang) {
// $error .= $error ? '<br/><br/>' : '';
// $error .= 'Kategoria posiada wersję jezykową';
// }
$this->AddRedirectInfo($error, 'error', Router::GenerateUrl('editCategory', array('ProductCategory' => 'Index')));
}
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$this->AddScript('structure.js');
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Administracja');
$struct = array(
//'User' => array('User' => 'Index'),
'Słowniki' => array('Dictionary' => 'Index'),
'Zmienne serwisu' => array('Setup' => 'Index'),
'Kategorie produktów' => array('ProductCategory' => 'Index'),
'Serie produktów' => array('ProductSeries' => 'Index'),
'Materiał produktów' => array('ProductSpec' => 'Index', 'type' => 2),
'Kolor produktów' => array('ProductSpec' => 'Index', 'type' => 1),
'Żarówki produktów' => array('ProductSpec' => 'Index', 'type' => 3),
//'Parametry produktów' => array('ProductAttribute' => 'Index')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function PostDispatch($param) {
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,308 @@
<?php
/**
* Produkty serie
*
*
*/
class ProductSeriesController extends MainController implements ControllerInterface {
public function IndexAction($param) {
//Utils::ArrayDisplay($param);
$dalData = ShopSeriesDAL::GetDalDataObj();
//$dalData->setCondition(array('lang' => $param['lang']));
$arryObjSeries = ShopSeriesDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arryObjSeries);
}
public function AddAction($param) {
// Pobiernie rodziców kategorii
$dalData = MfProductCategoryDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductCategoryDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
$dalData->setCondition(array('lang' => $param['lang'], 'mf_product_category.id_parent' => 0));
$arrayObjProductCategory = MfProductCategoryDAL::GetResult($dalData);
//$param['runSharedVariable'] = 'linkedAttribute';
//$this->RunModuleController( 'ProductCategoryController', 'LinkedAttribute', $param, true);
//
// $param['runSharedVariable'] = 'unlinkedAttribute';
// $this->RunModuleController( 'ProductCategoryController', 'UnlinkedAttribute', $param, true);
//Utils::ArrayDisplay($arrayObjProductCategory);
$this->smarty->assign('arrayObjProductCategory', $arrayObjProductCategory);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttribue);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', array());
$objCategoryProduct = MfProductCategoryDAL::GetEmptyObj();
if (Request::GetPost('doCategoryAdd')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$objProduct = new MfProduct();
//$objCategoryProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
$objCategoryProduct->setPublication($publication);
$objCategoryProduct->setIdParent($data['idParent']);
$objCategoryProduct->setWeight($data['weight']);
$objCategoryProductDesc = new MfProductCategoryDescription();
$objCategoryProductDesc->setDatePublication("0000-00-00 00:00:00");
$objCategoryProductDesc->setLang('pl');
$objCategoryProductDesc->setName($data['name']);
$objCategoryProductDesc->setPublication($publication);
//$arrayObjAttributeWithValue = array();
//Utils::ArrayDisplay($arrayObjAttribute);
if(empty($out)) {
$idCategoryProduct = MfProductCategoryDAL::Save($objCategoryProduct);
$objCategoryProductDesc->setIdMfProductCategory($idCategoryProduct);
$objCategoryProductDescEn = $objCategoryProductDesc;
//$objCategoryProductDescEn->setLang('en');
$objCategoryProductDescRu = $objCategoryProductDesc;
//$objCategoryProductDescRu->setLang('ru');
MfProductCategoryDescriptionDAL::Save($objCategoryProductDesc);
///Utils::ArrayDisplay($objCategoryProductDesc);
$objCategoryProductDescEn->setLang('en');
$objCategoryProductDescEn->setId(-1);
MfProductCategoryDescriptionDAL::Save($objCategoryProductDescEn);
//Utils::ArrayDisplay($objCategoryProductDesc);
$objCategoryProductDescRu->setLang('ru');
$objCategoryProductDescRu->setId(-1);
MfProductCategoryDescriptionDAL::Save($objCategoryProductDescRu);
//Utils::ArrayDisplay($objCategoryProductDesc);
if (isset($data['attr'])) {
foreach ($data['attr'] as $attrKey => $attrId ) {
$objMfProductLink = new MfProductLink();
$objMfProductLink->setDestinationType('mf_product_attribute');
$objMfProductLink->setSourceType('mf_product_category');
$objMfProductLink->setIdDestination($attrId);
$objMfProductLink->setIdSource($idCategoryProduct);
$objMfProductLink->setLang('pl');
$objMfProductLink->setPublication(1);
MfProductLinkDAL::Save($objMfProductLink);
}
}
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editCategory', array('ProductCategory' => 'index')));
} else {
if (isset($data['attr'])) {
$idAttrLinked = implode(', ',$data['attr']);
} else {
$idAttrLinked = '-1';
}
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttributeLinked);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
$objCategoryProduct->SetDescriptionObj($objCategoryProductDesc);
$this->smarty->assign('objCategoryProduct',$objCategoryProduct);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function EditAction($param) {
$objSeries = ShopSeriesDAL::GetById($param['id'], $param['lang']);
$this->smarty->assign('obj', $objSeries);
if (Request::GetPost('doSeriesEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
$objSeries->setLang($param['lang']);
$objSeries->setName($data['name']);
$objSeries->setPublication($publication);
if(empty($out)) {
//Utils::ArrayDisplay($data);
$idseries = ShopSeriesDAL::Save($objSeries);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editSeries', array('ProductSeries' => 'index')));
} else {
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function AjaxAddLinkAttrAction($param) {
//$array
}
public function DeleteAction($param) {
$isLinked = MfProductLinkDAL::IsLinked($param['id'], 'mf_product_series', null, 'mf_product');
$delete = true;
$error = '';
if ($isLinked > 0 ) {
$delete = false;
}
if ($delete) {
$objSeries = ShopSeriesDAL::GetById($param['id']);
$dalData = ShopSeriesDAL::GetDalDataObj();
$dalData->setObj($objSeries);
ShopSeriesDAL::Delete($dalData);
$this->AddRedirectInfo('Element został usunięty', 'ok', Router::GenerateUrl('editSeries', array('ProductSeries' => 'Index')));
} else {
if ($isLinked) {
$error .= 'seria jest powiązana z produktem.';
}
$this->AddRedirectInfo($error, 'error', Router::GenerateUrl('editCategory', array('ProductSeries' => 'Index')));
}
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$this->AddScript('structure.js');
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Administracja');
$struct = array(
//'User' => array('User' => 'Index'),
'Słowniki' => array('Dictionary' => 'Index'),
'Zmienne serwisu' => array('Setup' => 'Index'),
'Kategorie produktów' => array('ProductCategory' => 'Index'),
'Serie produktów' => array('ProductSeries' => 'Index'),
'Materiał produktów' => array('ProductSpec' => 'Index', 'type' => 2),
'Kolor produktów' => array('ProductSpec' => 'Index', 'type' => 1),
'Żarówki produktów' => array('ProductSpec' => 'Index', 'type' => 3),
//'Parametry produktów' => array('ProductAttribute' => 'Index')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function PostDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,340 @@
<?php
/**
* Produkty
*
*
*/
class ProductSpecController extends MainController implements ControllerInterface {
const AVATAR_DEST_DIR = '/upload/Product';
const AVATAR_TEMP_DIR = '/upload/temp';
const NO_PHOTO_IMG_BIG = "image/Admin/cropperNoPhotoBig.gif";
const NO_PHOTO_IMG_SMALL = "image/Admin/przekatne.gif";
const MAX_AVATAR_FILE_SIZE = 5; //Rozmiar w mb
const CROPPER_BIG_PHOTO_MAX_WIDTH = 800;
const CROPPER_BIG_PHOTO_MAX_HEIGHT = 800;
const PHOTO_WIDTH = 800;
const PHOTO_HEIGHT = 600;
const IMAGE_MINI_WIDTH = 240;
const IMAGE_MINI_HEIGHT = 180;
const IMAGE_NORMAL_WIDTH = 800;
const IMAGE_NORMAL_HEIGHT = 600;
public function IndexAction($param) {
//Utils::ArrayDisplay($param);
$dalData = MfProductSpecificationDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->setCondition(array('typ' => isset($param['type']) ? $param['type'] : 1));
$arrayObjProductSpec = MfProductSpecificationDAL::GetResult($dalData);
$this->smarty->assign('arrayObj', $arrayObjProductSpec);
//Utils::ArrayDisplay($arrayObjProductSpec);
}
public function AddAction($param) {
// Pobiernie rodziców kategorii
$dalData = MfProductSpecDAL::GetDalDataObj();
$dalData->setJoin(array('MfProductSpecDescription' => ' LEFT JOIN mf_product_category_description ON mf_product_category.id_mf_product_category=mf_product_category_description.id_mf_product_category '));
$dalData->setCondition(array('lang' => $param['lang'], 'mf_product_category.id_parent' => 0));
$arrayObjProductSpec = MfProductSpecDAL::GetResult($dalData);
//$param['runSharedVariable'] = 'linkedAttribute';
//$this->RunModuleController( 'ProductSpecController', 'LinkedAttribute', $param, true);
//
// $param['runSharedVariable'] = 'unlinkedAttribute';
// $this->RunModuleController( 'ProductSpecController', 'UnlinkedAttribute', $param, true);
//Utils::ArrayDisplay($arrayObjProductSpec);
$this->smarty->assign('arrayObjProductSpec', $arrayObjProductSpec);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
// $dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idsAttribute.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttribue);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', array());
$objCategoryProduct = MfProductSpecDAL::GetEmptyObj();
if (Request::GetPost('doCategoryAdd')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$objProduct = new MfProduct();
//$objCategoryProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
$objCategoryProduct->setPublication($publication);
$objCategoryProduct->setIdParent($data['idParent']);
$objCategoryProduct->setWeight($data['weight']);
$objCategoryProductDesc = new MfProductSpecDescription();
$objCategoryProductDesc->setDatePublication("0000-00-00 00:00:00");
$objCategoryProductDesc->setLang('pl');
$objCategoryProductDesc->setName($data['name']);
$objCategoryProductDesc->setPublication($publication);
//$arrayObjAttributeWithValue = array();
//Utils::ArrayDisplay($arrayObjAttribute);
if(empty($out)) {
$idCategoryProduct = MfProductSpecDAL::Save($objCategoryProduct);
$objCategoryProductDesc->setIdMfProductSpec($idCategoryProduct);
$objCategoryProductDescEn = $objCategoryProductDesc;
//$objCategoryProductDescEn->setLang('en');
$objCategoryProductDescRu = $objCategoryProductDesc;
//$objCategoryProductDescRu->setLang('ru');
MfProductSpecDescriptionDAL::Save($objCategoryProductDesc);
///Utils::ArrayDisplay($objCategoryProductDesc);
$objCategoryProductDescEn->setLang('en');
$objCategoryProductDescEn->setId(-1);
MfProductSpecDescriptionDAL::Save($objCategoryProductDescEn);
//Utils::ArrayDisplay($objCategoryProductDesc);
$objCategoryProductDescRu->setLang('ru');
$objCategoryProductDescRu->setId(-1);
MfProductSpecDescriptionDAL::Save($objCategoryProductDescRu);
//Utils::ArrayDisplay($objCategoryProductDesc);
if (isset($data['attr'])) {
foreach ($data['attr'] as $attrKey => $attrId ) {
$objMfProductLink = new MfProductLink();
$objMfProductLink->setDestinationType('mf_product_attribute');
$objMfProductLink->setSourceType('mf_product_category');
$objMfProductLink->setIdDestination($attrId);
$objMfProductLink->setIdSource($idCategoryProduct);
$objMfProductLink->setLang('pl');
$objMfProductLink->setPublication(1);
MfProductLinkDAL::Save($objMfProductLink);
}
}
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editCategory', array('ProductSpec' => 'index')));
} else {
if (isset($data['attr'])) {
$idAttrLinked = implode(', ',$data['attr']);
} else {
$idAttrLinked = '-1';
}
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttributeLinked = MfProductAttributeDAL::GetResult($dalData);
//$objProductAttribute = MfProductAttributeDAL::GetResultByLink('mf_product_category', $idCategory, 'mf_product_attribute');
//Utils::ArrayDisplay($arrayObjAttributeLinked);
$dalData = MfProductAttributeDAL::GetDalDataObj();
$dalData->setCondition(array('lang' => $param['lang']));
$dalData->addCondition(' ', 'mf_product_attribute.id_mf_product_attribute NOT IN ('.$idAttrLinked.') ', ' ');
$dalData->setJoin(array('MfProductAttributeDescription' => ' LEFT JOIN mf_product_attribute_description ON mf_product_attribute.id_mf_product_attribute=mf_product_attribute_description.id_mf_product_attribute '));
//Utils::ArrayDisplay($dalData);
$arrayObjAttribute = MfProductAttributeDAL::GetResult($dalData);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('arrayObjAttributeLinked', $arrayObjAttributeLinked);
$objCategoryProduct->SetDescriptionObj($objCategoryProductDesc);
$this->smarty->assign('objCategoryProduct',$objCategoryProduct);
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function EditAction($param) {
// Pobiernie rodziców kategorii
$dalData = MfProductSpecificationDAL::GetDalDataObj();
$objSpec = MfProductSpecificationDAL::GetById($param['id'], $param['lang']);
$this->smarty->assign('obj', $objSpec);
if (Request::GetPost('doSpecEdit')) {
//Utils::ArrayDisplay(Request::GetAllPost());
$out = array();
$validator = new Validator(Request::GetAllPost());
$data = Request::GetAllPost();
$validator->IsEmpty('name', 'Pole nazwa musi zostać wypełnione.');
$out = $validator->GetErrorList();
$publication = Request::Get('publication');
$publication ? $publication = 1 : $publication = '0';
//$objProduct = new MfProduct();
//$objCategoryProduct->setDate($data['datepublication']." ".$data['timepublication'].":00:00");
$objSpec->setPublication($publication);
//$objSpec->setWeight($data['weight']);
$objSpec->setLang($param['lang']);
$objSpec->setValue($data['name']);
//$arrayObjAttributeWithValue = array();
//Utils::ArrayDisplay($arrayObjAttribute);
if(empty($out)) {
//Utils::ArrayDisplay($data);
$idSpec = MfProductSpecificationDAL::Save($objSpec);
$this->AddRedirectInfo('Zapisano', 'ok', Router::GenerateUrl('editSpec', array('ProductSpec' => 'Index', 'type' => $objSpec->GetTyp())));
} else {
$this->smarty->assign('arrayObjAttribute', $arrayObjAttribute);
$this->smarty->assign('info','Pola obowiązkowe muszą zostać wypełnione.');
$this->smarty->assign('type','error');
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
}
public function AjaxAddLinkAttrAction($param) {
//$array
}
public function DeleteAction($param) {
$isLinked = MfProductLinkDAL::IsLinked($param['id'], 'mf_product_specyfication', null, 'mf_product');
$delete = true;
$error = '';
if ($isLinked > 0 ) {
$delete = false;
}
$objSpec = MfProductSpecificationDAL::GetById($param['id']);
if ($delete) {
$dalData = MfProductSpecificationDAL::GetDalDataObj();
$dalData->setObj($objSpec);
MfProductSpecificationDAL::Delete($dalData);
$this->AddRedirectInfo('Element został usunięty', 'ok', Router::GenerateUrl('editSpec', array('ProductSpec' => 'Index', 'type' => $objSpec->GetTyp())));
} else {
if ($isLinked) {
$error .= 'Parametr jest powiązana z produktem.';
}
$this->AddRedirectInfo($error, 'error', Router::GenerateUrl('editSpec', array('ProductSpec' => 'Index', 'type' => $objSpec->GetTyp())));
}
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$this->AddScript('structure.js');
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Administracja');
$struct = array(
//'User' => array('User' => 'Index'),
'Słowniki' => array('Dictionary' => 'Index'),
'Zmienne serwisu' => array('Setup' => 'Index'),
'Kategorie produktów' => array('ProductCategory' => 'Index'),
'Serie produktów' => array('ProductSeries' => 'Index'),
'Materiał produktów' => array('ProductSpec' => 'Index', 'type' => 2),
'Kolor produktów' => array('ProductSpec' => 'Index', 'type' => 1),
'Żarówki produktów' => array('ProductSpec' => 'Index', 'type' => 3),
//'Parametry produktów' => array('ProductAttribute' => 'Index')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function PostDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,182 @@
<?php
/**
* $Id: SetupController.php 639 2008-06-18 10:51:32Z mija $
* Kontroler Ustawien
*
*/
class SetupController extends MainController implements ControllerInterface {
/**
* Strona glowna
*
*/
public function IndexAction($param) {
if ( isset($_REQUEST["addVariable"]) ) {
//Utils::ArrayDisplay($_REQUEST);
SetupDAL::SaveVariable($_REQUEST["variable"], $_REQUEST["value"], $_REQUEST["description"]);
}
$this->smarty->assign('arrayVariables', SetupDAL::GetAllVariables(false) );
//Utils::ArrayDisplay(SetupDAL::GetAllVariables(false));
}
/**
* Nowy parametr
*
*/
public function NewAction() {
$this->partialTemplate = 'Edit.tpl';
$this->smarty->assign('objVariable', NULL );
}
/**
* Edycja parametru
*
* @param array $param
*/
public function EditAction($param) {
//$this->partialTemplate = 'Edit.tpl';
$objVariable = SetupDAL::GetVariableByName($param["variable"]);
$this->smarty->assign('objVariable', $objVariable );
}
/**
* Czyszczenie cache strony
*
*/
public function ClearCacheAction() {
$directory = PATH_SITE_CACHE;
if( !$dirhandle = @opendir($directory) )
return;
while( false !== ($filename = readdir($dirhandle)) ) {
if( $filename != "." && $filename != ".." ) {
$filename = $directory. "/". $filename;
if(is_file($filename)) {
@unlink($filename);
}
}
}
}
public function ManualPathInstallerAction($param) {
if(Request::IsPost()) {
$post = Request::GetAllPost();
$controller = $post['controller'];
$method = $post['method'];
$matchUri = $post['matchUri'];
$actionSetText = $post['actionSet'];
$paramSet = $post['param'];
$module = $post['module'];
$actionSet = array();
$actionSetText = explode(',', $actionSetText);
foreach($actionSetText as $item) {
$item = explode(':', $item);
if(isset($item[0]) && isset($item[1]) && isset($item[2]))
$actionSet[] = array('module'=>$item[0], 'controller'=>$item[1], 'method'=>$item[2]);
}
$paramText = array();
$paramText = explode(',', $paramSet);
//Utils::ArrayDisplay($paramText);
foreach($paramText as $item) {
$item = explode(':', $item);
if(isset($item[0]) && isset($item[1]))
$paramArray[] = array('var'=>$item[0], 'value'=>$item[1]);
}
$router = new MfRouter();
$router->SetController($controller);
$router->SetMethod($method);
$router->SetUrl($matchUri);
$router->SetParam(serialize($paramArray));
$router->SetConfig(serialize(array('module'=>$module, 'actionSet'=>$actionSet)));
MfRouterDAL::Save($router);
Router::GenerateDbRoutes();
}
}
public function PackageInstallerAction($param) {
$dir = Config::Get('PATH_CORE').'/modules';
$files = scandir($dir);
$modules = array();
foreach($files as $file) {
if(preg_match('((.*)(.zip))', $file)) {
$modules[] = str_replace('.zip', '', $file);
}
}
$this->smarty->assign('modulesList', $modules);
if(isset($param['package'])) {
$installer = new ModuleInstaler($param['package']);
}
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
//$this->RunShared('Admin');
$this->Run($param);
//$admin = AuthDAL::GetAdmin();
$this->RunShared('Auth', array());
$this->smarty->assign('titleAdmin', 'Administracja');
$struct = array(
//'User' => array('User' => 'Index'),
'Słowniki' => array('Dictionary' => 'Index'),
'Zmienne serwisu' => array('Setup' => 'Index'),
// 'Kategorie produktów' => array('ProductCategory' => 'Index'),
// 'Serie produktów' => array('ProductSeries' => 'Index'),
// 'Materiał produktów' => array('ProductSpec' => 'Index', 'type' => 2),
// 'Kolor produktów' => array('ProductSpec' => 'Index', 'type' => 1),
// 'Żarówki produktów' => array('ProductSpec' => 'Index', 'type' => 3),
//'Parametry produktów' => array('ProductAttribute' => 'Index')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,191 @@
<?php
/**
* $Id: SharedController.php 969 2008-07-29 13:55:14Z pawy $
* Kontroller wspolny
*
*/
class SharedController extends MainController implements ControllerInterface {
/**
* domyslna metoda
*
*/
public function IndexAction($param) {
}
public function infoFrame($param) {
$this->smarty->assign('info',$param['info']);
$this->smarty->assign('type',$param['type']);
}
public function Pagination($param) {
if(isset($param['strona']) && $param['strona'] > 0 ){
$page = $param['strona'];
$URLparam = $this->GetUrlParam($param);
}
else{
$page = 1;
$URLtemp = $this->GetUrlParam($param);
if (!isset($URLtemp[1])) {
$URLtemp[1] = '';
}
$URLparam = array($URLtemp[0], $URLtemp[1], 1, 'strona');
$URLparam = array_merge($URLparam, array_slice($URLtemp, 2));
}
$this->smarty->assign('CurrentPage', $page);
$URLParam = array("", "");
$URLParam[0] = $URLparam[3];
$URLParam[1] = $URLparam[1] . ',' . $URLparam[0];
for ( $i = 4, $size = sizeof($URLparam) ; $i < $size ; $i++)
{
$URLParam[0] = $URLparam[$i] . ',' . $URLParam[0];
}
$this->smarty->assign("URLParam", $URLParam);
$this->smarty->assign('pagination', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function Admin($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function DefaultPanel($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function Login($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function Page($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function Mailing($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function News($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function Offer($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function Structure($param) {
$lang = SessionProxy::GetValue('lang');
$location = SessionProxy::GetValue('location');
//Utils::ArrayDisplay($param);
$arrayObjStructureMain = StructureDAL::GetTree(array('lang' => $lang, 'type' => 1, 'location' => $location ),array());
$arrayObjStructureBottom = StructureDAL::GetTree(array('lang' => $lang, 'type' => 2, 'location' => $location),array());
$arrayObjStructureOther = StructureDAL::GetTree(array('lang' => $lang, 'type' => 3, 'location' => $location),array());
//$arrayRouter = RouterParamDAL::GetArrayRouter();
//Utils::ArrayDisplay($arrayObjStructureMain);
if (isset($param['id'])) {
$id = $param['id'];
} elseif (isset($param['idElement'])) {
$id = $param['idElement'];
} else {
$id = '';
}
$this->smarty->assign('idStucture', $id);
$this->smarty->assign( 'arrayObjStructure' ,$arrayObjStructureMain);
$this->smarty->assign( 'arrayObjStructureBottom' ,$arrayObjStructureBottom);
$this->smarty->assign( 'arrayObjStructureOther' ,$arrayObjStructureOther);
//Utils::ArrayDisplay($this->smarty->fetch($this->templatePath.$this->partialTemplate));
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function Preferences($param) {
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function StructureAction($param) {
//$this->SetAjaxRender();
$lang = SessionProxy::GetValue('lang');
//Utils::ArrayDisplay($param);
$arrayObjStructure = StructureDAL::GetTree(array('lang' => $lang),array());
//$arrayRouter = RouterParamDAL::GetArrayRouter();
$this->smarty->assign( 'arrayObjStructure' ,$arrayObjStructure);
$this->smarty->assign('leftBox', $this->smarty->fetch($this->templatePath.$this->partialTemplate));
}
public function CustomerLink($param) {
//$this->SetAjaxRender();
$lang = SessionProxy::GetValue('lang');
//Utils::ArrayDisplay($param);
$type = ( isset($param['tagType']) ? $param['tagType'] : " 2 ");
$arrayCustomer = Utils::GetArrayList('mf_tag', 'id_mf_tag', 'tag', $lang, ' AND type = '.$type, 'tag');
//$arrayRouter = RouterParamDAL::GetArrayRouter();
$this->smarty->assign('arrayCustomer' ,$arrayCustomer);
}
/**
* Startuje sesje, weryfikuje autoryzacje admina
*
*/
/**
* Startuje sesje, weryfikuje autoryzacje admina
*
*/
public function Auth($param) {
$this->SetNoRender();
//session_start();
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
//Utils::ArrayDisplay($this);
$this->smarty->assign('admin', $admin);
Registry::Set('admin', $admin);
if(!is_object($admin)) {
//$this->AddRedirectInfo("NIE ZALOGOWANY", null, Router::GenerateUrl('LOGIN', array("Login" => "Index")));
die(header("Location: ". Router::GenerateUrl('LOGIN', array("Login" => "Index")) ));
//$this->SetActionRedirect('AdminLoginRedirectAction');
}
}
/**
* Metoda wspolna
*
*/
public function preDispatch($param) {
$this->Run($param);
}
/**
*
*
*/
public function postDispatch($param) {
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
<?php
/**
* Struktura menu
*
*
*/
class UploaderController extends MainController implements ControllerInterface {
/**
* strona glowna
*
*/
public function IndexAction($param) {
}
public function UploaderAction($param) {
//Utils::ArrayDisplay($_FILES);
if (isset($_FILES['file'])) {
move_uploaded_file ( $_FILES['file']['tmp_name'], PATH_STATIC_CONTENT.'temp/'.$_FILES['file']['name'] );
}
}
public function preDispatch($param) {
$this->AddScript("prototype.js");
$this->AddScript("GetContent.js");
$this->AddScript('structure.js');
$this->AddScript('Dosia.js');
$this->AddScript('drag-drop-folder-tree.js');
$this->AddScript('calendar.js');
//Utils::ArrayDisplay($param);
//$this->Run($param);
$arrayModuleName = MfModuleDAL::GetArrayModuleName();
$this->smarty->assign( 'arrayModuleName' ,$arrayModuleName);
$this->smarty->assign('showIcon', true);
//Utils::ArrayDisplay(Utils::ArrayDisplay(SessionProxy::GetValue(EnumSessionValue::USER_OBJECT)));
//$this->RunShared('Auth', array());
//$this->smarty->assign("menuSelected", "");
$this->smarty->assign('activeTab', 'index');
$this->AddScript("formAction.js");
$this->Run($param);
$this->RunShared('Structure', $param);
$this->smarty->assign('titleAdmin', 'Struktura strony');
}
/**
*
*
*/
public function postDispatch($param) {
}
}
?>

View File

@@ -0,0 +1,735 @@
<?php
/**
* $Id: UserController.php 969 2008-07-29 13:55:14Z pawy $
* Zarzadzanie uzytkownikami
*
*/
class UserController extends MainController implements ControllerInterface {
// cropper const
const PHOTO_ORG_SMALL_SIZE = 70; // minimalny wymiar oryginalnego obrazka
const MAX_PHOTO_ORG_FILE_SIZE = 5; // maksymalny rozmiar oryginalnego obrazka w mb
const CROPPER_MIN_SIZE = 70; // minimalny wymiar croppera
const CROPPER_MAX_SIZE = 300; // maksymalny wymiar dla croppera
const PHOTO_SESSION_NAME = '__avatar_photo_name__';
const PHOTO_SESSION_ID = '__avatar_photo_id__';
const SIZE_SESSION_NAME = '__avatar_photo_size__';
const AVATAR_DEST_DIR = 'images/upload/Avatar';
const AVATAR_TEMP_DIR = 'images/upload/temp/Avatar';
const GALLERY_DEST_DIR = 'images/upload/Avatar';
const GALLERY_TEMP_DIR = 'images/upload/temp/Avatar';
const NO_PHOTO_IMG_BIG = "image/Admin/cropperNoPhotoBig.gif";
const NO_PHOTO_IMG_SMALL = "image/Admin/cropperNoPhotoSmall.gif";
/**
* Strona glowna
*
*/
public function IndexAction($param) {
if(isset($param['sort']) && isset($param['direction']))
$this->smarty->assign($param['sort'],$param['direction']);
else {
$param['sort'] = "";
$param['direction'] = "";
}
if(isset($param['sort2']) && isset($param['direction2']))
$this->smarty->assign($param['sort2'],$param['direction2']);
else {
$param['sort2'] = "";
$param['direction2'] = "";
}
$this->smarty->assign('userList', AdminDAL::GetResult(array(),array(),null,$param['sort'] . " " . $param['direction']));
$this->smarty->assign('archiveUserList', AdminDAL::GetResult(array('archive' => 1),array(),null,$param['sort2'] . " " . $param['direction2']));
}
public function JoinAction($param)
{
if(isset($param['sort']) && isset($param['direction']))
$this->smarty->assign($param['sort'],$param['direction']);
else
{
$param['sort'] = "";
$param['direction'] = "";
}
$this->smarty->assign('type',$param['type']);
$this->smarty->assign('ids',Request::Get($param['type']));
$this->smarty->assign('UserList', AdminDAL::GetResult(array(),array(),null,$param['sort'] . " " . $param['direction']));
}
public function AjaxJoinAction($param)
{
foreach(Request::Get($param['type']) as $key2 => $value2)
{
MfLinkDAL::DeleteFromLink($value2, $param['type'], null , 'mf_admin');
$i = 0;
foreach(Request::Get('admin') as $key => $value)
{
//przypisujemy łączenia
$mfLinkObj = new MfLink();
$mfLinkObj->SetIdSource($value2);
$mfLinkObj->SetSourceType($param['type']);
$mfLinkObj->SetIdDestination($value);
$mfLinkObj->SetDestinationType('mf_admin');
MfLinkDAL::Insert($mfLinkObj);
$i++;
}
$className = str_replace('mf_','',$param['type']);
$className = ucfirst($className);
$obj = new $className();
$obj->setId($value2);
$obj->setAdminCount($i);
eval($className . 'DAL::Update($obj);');
}
$this->SetAjaxRender();
$param['hide']=false;
$this->content=$this->FormatAjaxOutput(array(),$param);
}
public function AjaxDeleteAction($param)
{
foreach(Request::Get($param['type']) as $key2 => $value2)
{
MfLinkDAL::DeleteFromLink($value2, $param['type'], $param['mf_admin'] , 'mf_admin');
$this->user->SetForumCount($this->user->GetForumCount()-1);
AdminDAL::Update($this->user);
$className = str_replace('mf_','',$param['type']);
$className = ucfirst($className);
$obj = null;
eval('$obj =' .$className . 'DAL::GetById($value2);');
$obj->SetAdminCount($obj->GetAdminCount() - 1);
eval($className . 'DAL::Update($obj);');
}
$this->SetAjaxRender();
$param['hide']=false;
$this->content=$this->FormatAjaxOutput(array(),$param);
}
/**
* Edycja uzytkownika
*
* @param array $param
*/
public function EditAction($param) {
$url = Router::GenerateUrl('UserList',array('User' => 'Index'));
if(Request::IsPost()) {
// [login] =>
// [password] =>
// [passwordconf] =>
// [firstName] =>
// [lastName] =>
// [email] =>
// [description] =>
// [role] => admin
$postData = Request::GetAllPost(false);
//if(Request::GetPost('action') == 'submit' ) {
$validator = new Validator($postData);
$validator->IsEmpty('login','To pole nie może być puste');
$validator->IsEmpty('password','To pole nie może być puste');
$validator->IsEmpty('passwordconf','To pole nie może być puste');
// $validator->IsEmpty('firstName','To pole nie może być puste');
// $validator->IsEmpty('lastName', 'To pole nie może być puste');
//$validator->IsEmpty('email', 'To pole nie może być puste');
//$validator->IsEmpty('role', 'To pole nie może być puste');
if(Request::GetPost('passwordconf') !== Request::GetPost('password')) {
$validator -> AddError('passwordconfDif', 'Hasła są różne');
}
$out = $validator->GetErrorList();
$user = AdminDAL::GetById($postData['id']);
$user->SetLogin(Request::RemoveXss($postData['login']));
$user->SetEmail(Request::RemoveXss($postData['email']));
$user->SetFirstName($postData['firstName']);
$user->SetLastName($postData['lastName']);
$user->SetRole($postData['role']);
$user->SetDescription($postData['description']);
$pass = trim($postData['password']);
$user->SetPassword(md5($pass));
if(empty($out)) {
$postData = Request::GetAllPost(false);
$userId = AdminDAL::Save($user);
$this->AddRedirectInfo('Edycja u<>ytkownika przebieg<65>o pomy<6D>lnie.');
Utils::Redirect($url);
}else {
//Utils::ArrayDisplay($out);
$this->smarty->assign('userData',$user);
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
}
if(isset($param['id']) && is_numeric($param['id']) ) {
$user = AdminDAL::GetById($param['id']);
} else {
$user = new Admin();
}
$this->smarty->assign('userData', $user );
$this->smarty->assign('userRole', AdminDAL::GetArrayObjRoles());
}
public function AjaxEditFormAction($param) {
$this -> SetAjaxRender(true);
if(isset($param['id'])) {
$id = $param['id'];
SessionProxy::SetValue('editedUser', AdminDAL::GetById($id));
} else {
return;
}
$url = Router::GenerateUrl(array('_value' => 'user'));
if(Request::IsPost()) {
if(isset($param['field'])) {
$out = $this->ValidateEdit($param);
$param['msg'] = 'Pole zostało zwalidowane';
$this->content=$this->FormatAjaxOutput($out,$param);
return;
}
if(Request::GetPost('action') == 'submit' ) {
$out = $this -> ValidateEdit($param);
$param['msg'] = 'Twoje zgłoszenie zostało przyjęte';
if(empty($out) && Request::GetPost('action') == 'submit' ) {
$postData = Request::GetAllPost(false);
$mail = Request::RemoveXss($postData['email']);
$editedUser = AdminDAL::GetById($id);
$editedUser->SetEmail(Request::RemoveXss($postData['email']));
$editedUser->SetFirstName($postData['firstName']);
$editedUser->SetLastName($postData['lastName']);
$editedUser->SetRole($postData['role']);
$editedUser->SetDescription($postData['description']);
$photo = SessionProxy::GetValue(self::PHOTO_SESSION_ID);
if($photo) {
$obj->SetPhotoSrc($photo);
SessionProxy::ClearValue(self::PHOTO_SESSION_ID);
}
if(trim(Request::GetPost('password')) != '' && $editedUser->GetPassword() != md5(trim(Request::GetPost('password'))) ) {
$pass = trim($postData['password']);
$editedUser->SetPassword(md5($pass));
}
$userId = AdminDAL::Save($editedUser);
// $mailer = new Mailer();
// $mailer->SendEmail($this->smarty->fetch('partial/Mail/RegisterMail.tpl'), '', 'Rejestracja konta',$postData['email']);
$this->AddRedirectInfo('Dodawanie użytkownika przebiegło pomyślnie.');
$param['redirect'] = $url;
$this->content=$this->FormatAjaxOutput($out,$param);
}else {
$this->content=$this->FormatAjaxOutput($out,$param);
}
}
}
}
private function ValidateEdit($param) {
$validator = new Validator(Request::GetAllPost());
$user = SessionProxy::GetValue('editedUser');
if(isset($param['field']) && !Request::Check(ereg_replace('((\[)(.*)(\]))','',urldecode($param['field'])))) {
$validator -> AddError($param['field'], $this->GetDictionary('validator_field'));
}
//e-mail
if((isset($param['field']) && $param['field'] == 'email') || !isset($param['field']) ) {
if($user->GetEmail() != Request::GetPost('email') )
$validator -> IsNotInDatabase('email', $this->GetDictionary('validator_email_exist'), 'email');
$validator -> IsEmailAddress('email', $this->GetDictionary('validator_email_error'));
$validator -> IsEmpty('email',$this->GetDictionary('validator_email_empty'));
}
if((isset($param['field']) && $param['field'] == 'password') || !isset($param['field']) ) {
if(trim(Request::GetPost('password')) != '' ) {
SessionProxy::SetValue('password',Request::GetPost('password'));
$validator -> IsEmpty('password',$this->GetDictionary('validator_password_empty'));
}
}
//potwierdzenie hasła
if((isset($param['field']) && $param['field'] == 'passwordconf') || !isset($param['field']) ) {
if(trim(Request::GetPost('passwordconf')) != '' ) {
$password = SessionProxy::GetValue('password');
if(!is_null($password) && Request::GetPost('passwordconf') !== $password && strlen(Request::GetPost('passwordconf')) > 0) {
$validator -> AddError('passwordconf',$this->GetDictionary('validator_password_different'));
}
$validator -> IsEmpty('passwordconf',$this->GetDictionary('validator_password_empty'));
}
}
// if((isset($param['field']) && $param['field'] == 'education') || !isset($param['field']) ) {
// $validator -> IsEmpty('education','Nie wybrano wykształcenia','education');
// }
// $param['submitForm'] = 'walidacja';
return $validator->GetErrorList();
}
/**
* Dodawanie uzytkownika
*
* @param array $param
*/
public function AddAction($param) {
$url = Router::GenerateUrl('UserList',array('User' => 'Index'));
//Utils::ArrayDisplay($_POST);
if(Request::IsPost()) {
// [login] =>
// [password] =>
// [passwordconf] =>
// [firstName] =>
// [lastName] =>
// [email] =>
// [description] =>
// [role] => admin
$postData = Request::GetAllPost(false);
//if(Request::GetPost('action') == 'submit' ) {
$validator = new Validator($postData);
$validator->IsEmpty('login','To pole nie może być puste');
$validator->IsEmpty('password','To pole nie może być puste');
$validator->IsEmpty('passwordconf','To pole nie może być puste');
$validator->IsEmpty('firstName','To pole nie może być puste');
$validator->IsEmpty('lastName', 'To pole nie może być puste');
$validator->IsEmpty('email', 'To pole nie może być puste');
$validator->IsEmpty('role', 'To pole nie może być puste');
if(Request::GetPost('passwordconf') !== Request::GetPost('password')) {
$validator -> AddError('passwordconfDif', 'Hasła są róne');
}
$out = $validator->GetErrorList();
if(empty($out)) {
$postData = Request::GetAllPost(false);
$mail = Request::RemoveXss($postData['email']);
$newuser = new Admin();
$newuser->SetId(-1);
$newuser->SetLogin(Request::RemoveXss($postData['login']));
$newuser->SetEmail(Request::RemoveXss($postData['email']));
$newuser->SetFirstName($postData['firstName']);
$newuser->SetLastName($postData['lastName']);
$newuser->SetRole($postData['role']);
$newuser->SetDescription($postData['description']);
$pass = trim($postData['password']);
$newuser->SetPassword(md5($pass));
$userId = AdminDAL::Save($newuser);
$this->AddRedirectInfo('Dodawanie u<>ytkownika przebieg<65>o pomy<6D>lnie.');
Utils::Redirect($url);
}else {
//Utils::ArrayDisplay($out);
$this->smarty->assign('user',$postData);
foreach ($out as $item) {
$error[$item['field']] = $item['msg'];
}
$this->smarty->assign('error',$error);
}
//}
}
$this->smarty->assign('userRole', AdminDAL::GetArrayObjRoles());
}
public function AjaxAddFormAction($param) {
$this -> SetAjaxRender(true);
}
private function ValidateAdd($param) {
$validator = new Validator(Request::GetAllPost());
if(isset($param['field']) && !Request::Check(ereg_replace('((\[)(.*)(\]))','',urldecode($param['field'])))) {
$validator -> AddError($param['field'], $this->GetDictionary('validator_field'));
}
//e-mail
if((isset($param['field']) && $param['field'] == 'email') || !isset($param['field']) ) {
$validator -> IsNotInDatabase('email', $this->GetDictionary('validator_email_exist'), 'email');
$validator -> IsEmailAddress('email', $this->GetDictionary('validator_email_error'));
$validator -> IsEmpty('email',$this->GetDictionary('validator_email_empty'));
}
if((isset($param['field']) && $param['field'] == 'password') || !isset($param['field']) ) {
SessionProxy::SetValue('password',Request::GetPost('password'));
$validator -> IsEmpty('password',$this->GetDictionary('validator_password_empty'));
}
//potwierdzenie hasła
if((isset($param['field']) && $param['field'] == 'passwordconf') || !isset($param['field']) ) {
$password = SessionProxy::GetValue('password');
if(!is_null($password) && Request::GetPost('passwordconf') !== $password && strlen(Request::GetPost('passwordconf')) > 0) {
$validator -> AddError('passwordconf',$this->GetDictionary('validator_password_different'));
}
$validator -> IsEmpty('passwordconf',$this->GetDictionary('validator_password_empty'));
}
// if((isset($param['field']) && $param['field'] == 'education') || !isset($param['field']) ) {
// $validator -> IsEmpty('education','Nie wybrano wykształcenia','education');
// }
// $param['submitForm'] = 'walidacja';
return $validator->GetErrorList();
}
/**
* Usuwanie uzytkownika
*
* @param array $param
*/
public function DeleteAction($param) {
$this->SetAjaxRender(true);
if(isset($param['ok'])) {
$res = null;
if(isset($param['id'])) {
$res = AdminDAL::GetById($param['id']);
} else {
return;
}
if(is_object($res)) {
AdminDAL::Delete($res);
}
$this->AddRedirectInfo('U<>ytkownik zosta<74> usuni<6E>ty');
$this->AddRedirect(Router::GenerateUrl('userIndex', array('User'=>'Index')), 0);
} else {
$buttons = new HtmlButton();
$buttons->AddButton('popoverAbort', 'button anuluj lbAction', 'Anuluj', null, 'deactivate');
$buttons->AddButton('popoverOk', 'button zapisz', 'Ok', 'document.location.href=\''.Router::GenerateUrl(array('User'=>'Delete', 'id'=>$param['id'], 'ok'=>'1')).'\';', null);
$this->content = $this->GeneratePopover('Usuwanie użytkownika', 'usun.gif', 'Czy na pewno chcesz usunąć tego użytkownika?', $buttons->GetElements());
}
}
/**
* Zmiana hasla
*
*/
public function ChangePasswordAction() {
$this->AddScript('prototype.js');
$this->AddScript('scriptaculous.js');
$this->partialTemplate = 'Password.tpl';
$this->smarty->assign('msg', '');
if(isset($_POST['oldPassword']) && isset($_POST['newPassword']) && isset($_POST['confirmPassword'])) {
$admin = AuthDAL::GetAdmin();
if(AdminDAL::CheckPassword($admin->GetId(), $_POST['oldPassword'])) {
AdminDAL::UpdatePassword($admin->GetId(), $_POST['newPassword'], $_POST['oldPassword']);
$this->smarty->assign('msg', 'Hasło zostało zmienione');
} else {
$this->smarty->assign('msg', 'Podano nieprawidłowe hasło. Spróbuj ponownie.');
}
}
}
/**
* Wspolna metoda
*
*/
public function preDispatch($param) {
$this->RunShared('Auth', $param);
$this->Run($param);
$admin = AuthDAL::GetAdmin();
$this->user = $admin;
$this->smarty->assign('titleAdmin', 'Administracja');
$struct = array(
'User' => array('User' => 'Index'),
'Słowniki' => array('Dictionary' => 'Index'),
'Zmienne serwisu' => array('Setup' => 'Index'),
//'Kategorie produktów' => array('ProductCategory' => 'Index')
);
$this->smarty->assign('structure',$this->renderStruct($struct));
}
private function renderStruct($struct){
$return = '';
foreach($struct AS $k => $row){
$return .= '<li><a href="' . Router::GenerateUrl('dictpig',$row).'">'.$k.'</a></li>';
}
$html = '<ul>';
$html .= $return;
$html .= '</ul>';
return $html;
}
public function postDispatch($param) {
}
// cropper
// cropper //
public function AjaxPhotoCropperAction($param) {
$this->SetAjaxRender();
$photoPath = Request::GetPost('photoPath');
$photoHeight = Request::GetPost('photoHeight');
$photoWidth = Request::GetPost('photoWidth');
$this->smarty->assign('photoWidth', $photoWidth);
$this->smarty->assign('photoHeight', $photoHeight);
$this->smarty->assign('minPhotoWidth', self::CROPPER_MIN_SIZE);
$this->smarty->assign('minPhotoHeight', self::CROPPER_MIN_SIZE);
$this->smarty->assign('noPhotoImgBig', URL_STATIC_CONTENT . URL_DELIMITER . self::NO_PHOTO_IMG_BIG);
$this->smarty->assign('noPhotoImgSmall', URL_STATIC_CONTENT . URL_DELIMITER . self::NO_PHOTO_IMG_SMALL);
$this->smarty->assign('photoPath', Request::GetPost('photoPath'));
if (isset($param['id'])) {
$this->smarty->assign('cutUrl', array('user' => 'AjaxPhotoCropped', 'id' => $param['id']));
} else {
$this->smarty->assign('cutUrl', array('user' => 'AjaxPhotoCropped'));
}
$this->smarty->assign('fields',
array(
0 => array('name'=>'colSize', 'type'=>'radio', 'value'=>1, 'label'=>'pół kolumny', 'options'=>'checked="checked"'),
1 => array('name'=>'colSize', 'type'=>'radio', 'value'=>2, 'label'=>'cała kolumna', 'options'=>''),
2 => array('name'=>'colSize', 'type'=>'radio', 'value'=>3, 'label'=>'bez skalowania', 'options'=>''),
)
);
$this->smarty->assign('uploadUrl', array('user' => 'AjaxPhotoUpload'));
}
public function AjaxPhotoCroppedAction($param) {
$upload = true;
$oldPhoto = null;
$redirect = 'self';
$this->SetAjaxRender();
$photoFile = SessionProxy::GetValue(self::PHOTO_SESSION_NAME);
SessionProxy::ClearValue(self::PHOTO_SESSION_NAME);
$tmpPhotoArray = array();
$tmpPhotoArray['name'] = $photoFile . '.' . PhotoDAL::PHOTO_NEW_EXT;
$tmpPhotoArray['tmp_name'] = Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_TEMP_DIR . DIRECTORY_SEPARATOR . $tmpPhotoArray['name'];
$croppSize = SessionProxy::GetValue(self::SIZE_SESSION_NAME);
SessionProxy::ClearValue(self::SIZE_SESSION_NAME);
$orgSize = getimagesize($tmpPhotoArray['tmp_name']);
$sc = 1;
if($upload) {
if($orgSize[0] != $croppSize['w']) {
$sc = $orgSize[0]/$croppSize['w'];
}
} else {
$cs = getimagesize(Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_TEMP_DIR . DIRECTORY_SEPARATOR . $oldPhoto[0]->GetPhoto('temp') . '.' . PhotoDAL::PHOTO_NEW_EXT);
if($orgSize[0] != $cs[0]) {
$sc = $orgSize[0] / $cs[0];
}
}
$croppArray = array(
'x' => Request::Get('x') * $sc,
'y' => Request::Get('y') * $sc,
'w' => Request::Get('w') * $sc,
'h' => Request::Get('h') * $sc
);
$destDir = self::GALLERY_DEST_DIR;
$photo = PhotoDAL::ExtSimplePhotoUpload($tmpPhotoArray, $destDir, 'user', null, null, $croppArray);
$id = null;
// $objPhoto = new Picture();
// $objPhoto->SetLink($photoFile);
// $idPhoto = PictureDAL::Insert($objPhoto);
if (isset($param['id'])) {
$admin = AdminDAL::GetById($param['id']);
$admin->SetPhotoSrc($photoFile);
AdminDAL::Save($admin);
// $articleObj = MfArticleDAL::GetById($param['id']);
// $articleObj->SetIdPicture($idPhoto);
// MfArticleDAL::Save($articleObj);
} else {
SessionProxy::SetValue(self::PHOTO_SESSION_ID, $photoFile);
}
if(isset($param['id'])) {
$redirect = Router::GenerateUrl(array('user'=>'Edit', 'id'=>$param['id']));
} else {
$redirect = Router::GenerateUrl(array('user'=>'Edit'));
}
$this->smarty->assign('photoPath', $photoFile);
$this->smarty->assign('redirect', null);
}
public function AjaxPhotoUploadAction($param) {
$this->SetAjaxRender();
$photoFile = $_FILES['photo']['tmp_name'];
$photoSize = getimagesize($photoFile);
if ($photoSize[0] < self::PHOTO_ORG_SMALL_SIZE) {
$error = "Szerokość zdjęcia jest zbyt mała.";
} else if($photoSize[1] < self::PHOTO_ORG_SMALL_SIZE) {
$error = "Wysokość zdjęcia jest zbyt mała.";
} else if (filesize($photoFile) > (self::MAX_PHOTO_ORG_FILE_SIZE*1048576)) {
$error = "Przekroczony rozmiar zdjęcia(max: " . self::MAX_PHOTO_ORG_FILE_SIZE . "MB).";
}
if (!MimeType::IsImage($_FILES['photo'])) {
$error = "Podany przez ciebie plik ma niepoprawny format.";
}
if (isset($error)) {
$this->smarty->assign('error', $error);
} else {
$photoProp = $photoSize[0] / $photoSize[1];
$photoWidth = $photoSize[0];
$photoHeight = $photoSize[1];
if ($photoWidth > self::CROPPER_MAX_SIZE) {
$photoHeight = self::CROPPER_MAX_SIZE / $photoProp;
$photoWidth = self::CROPPER_MAX_SIZE;
}
if ($photoHeight > self::CROPPER_MAX_SIZE) {
$photoWidth = self::CROPPER_MAX_SIZE * $photoProp;
$photoHeight = self::CROPPER_MAX_SIZE;
}
$newName = md5(time());
SessionProxy::SetValue(self::PHOTO_SESSION_NAME, $newName);
SessionProxy::SetValue(self::SIZE_SESSION_NAME, array('w' => $photoWidth, 'h' => $photoHeight));
$photoFile = PhotoDAL::ExtSimplePhotoUpload($_FILES['photo'], self::GALLERY_TEMP_DIR , 'gallery_cropp_temporary', $newName, 'temp');
$photoFile = self::GALLERY_TEMP_DIR . URL_DELIMITER . $photoFile;
$this->smarty->assign('page2load', Router::GenerateUrl(array('zdjecia' => 'edycja')));
$this->smarty->assign('photoFile', $photoFile);
$this->smarty->assign('photoWidth', (int)$photoWidth);
$this->smarty->assign('photoHeight', (int)$photoHeight);
$this->smarty->assign('onFly', (Request::Check('onFly') ? 'true' : 'false'));
$this->smarty->assign('cropPrefix', Request::GetPost('cropPrefix'));
}
}
}
?>