1258 lines
43 KiB
PHP
1258 lines
43 KiB
PHP
<?php
|
|
/*
|
|
* Zarządzanie Stroną głowną
|
|
*
|
|
*/
|
|
class MainSiteController extends MainController implements ControllerInterface {
|
|
|
|
|
|
|
|
const AVATAR_DEST_DIR = '/upload/Article';
|
|
const AVATAR_TEMP_DIR = '/upload/temp';
|
|
const NO_PHOTO_IMG_BIG = "image/Admin/cropperNoPhotoBig.gif";
|
|
const NO_PHOTO_IMG_SMALL = "image/Admin/cropperNoPhotoSmall.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 = 298;
|
|
const PHOTO_HEIGHT = 598;
|
|
const PHOTO_SESSION_ID = '__article_photo_id__';
|
|
|
|
const CONTENT_PER_PAGE = 10;
|
|
const ACTUAL_SEASON = 177;
|
|
|
|
|
|
|
|
/**
|
|
* metoda glowna
|
|
*
|
|
*/
|
|
public function IndexAction($param) {
|
|
|
|
|
|
|
|
SessionProxy::ClearValue('radioChecked');
|
|
|
|
if(isset($param['blockade'])) {
|
|
$place = ($param['place']>0?$param['place']:null);
|
|
$id = $param['id'];
|
|
|
|
$obj = MfMainSiteDAL::GetById($id);
|
|
|
|
$obj -> SetBlockade($place);
|
|
MfMainSiteDAL::Update($obj,true);
|
|
$this->AddRedirect(Router::GenerateUrl(array('_value' => 'mainSite')),0);
|
|
// var_dump($obj);
|
|
}
|
|
|
|
$subPromoCount = SetupDAL::GetVariableByName(MfMainSite::SUB_PROMO_COUNT);
|
|
$arraySubPromoWeight = range(0, $subPromoCount['value']);
|
|
//
|
|
$newsCount = SetupDAL::GetVariableByName(MfMainSite::NEWS_COUNT);
|
|
$arrayNewsWeight = range(0, $newsCount['value']);
|
|
//Utils::ArrayDisplay($newsCount);
|
|
$arrayObjMainNewsTop = MfMainSiteDAL::GetList(MfMainSite::MAIN_PROMO,SetupDAL::GetVariableByName(MfMainSite::MAIN_PROMO_COUNT));
|
|
$arrayObjMainRecommend = MfMainSiteDAL::GetList(MfMainSite::SUB_PROMO,$subPromoCount);
|
|
$arrayObjMainNews = MfMainSiteDAL::GetList(MfMainSite::NEWS, $newsCount);
|
|
|
|
$arrayObjMainNewsTopWaiting = MfMainSiteDAL::GetList(MfMainSite::MAIN_PROMO, SetupDAL::GetVariableByName(MfMainSite::MAIN_PROMO_COUNT), true);
|
|
$arrayObjMainRecommendWaiting = MfMainSiteDAL::GetList(MfMainSite::SUB_PROMO, $subPromoCount, true);
|
|
$arrayObjMainNewsWaiting = MfMainSiteDAL::GetList(MfMainSite::NEWS, $newsCount, true);
|
|
|
|
//Utils::ArrayDisplay($arrayObjMainRecommend);
|
|
//Utils::ArrayDisplay($arrayObjMainRecommendWaiting);
|
|
|
|
$this->smarty->assign('arrayObjMainNewsTop', $arrayObjMainNewsTop);
|
|
$this->smarty->assign('arrayObjMainRecommend', $arrayObjMainRecommend);
|
|
$this->smarty->assign('arrayObjMainNews', $arrayObjMainNews);
|
|
|
|
$this->smarty->assign('arrayObjMainNewsTopWaiting', $arrayObjMainNewsTopWaiting);
|
|
$this->smarty->assign('arrayObjMainRecommendWaiting', $arrayObjMainRecommendWaiting);
|
|
$this->smarty->assign('arrayObjMainNewsWaiting', $arrayObjMainNewsWaiting);
|
|
|
|
$this->smarty->assign('subPromoCount', $subPromoCount['value']);
|
|
$this->smarty->assign('arraySubPromoWeight', $arraySubPromoWeight);
|
|
|
|
$this->smarty->assign('newsCount', $newsCount['value']);
|
|
$this->smarty->assign('arrayNewsWeight', $arrayNewsWeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Dodawanie/Edycja artykułu formularz
|
|
*
|
|
* @param Array $param
|
|
*/
|
|
public function AddAction($param) {
|
|
$this->AddScript('Dosia.js');
|
|
$this->AddScript('lightbox.js');
|
|
$this->AddScript('cropper.js');
|
|
$this->AddScript('uploader.js');
|
|
$this->AddScript("urlStatic = '" . URL_STATIC_CONTENT . URL_DELIMITER . "';", 'code');
|
|
|
|
$lang = 'pl';
|
|
if (isset($param['mainType'])) {
|
|
$mainType = $param['mainType'];
|
|
SessionProxy::SetValue('mainType', $mainType);
|
|
|
|
if (isset($param['type'])) {
|
|
SessionProxy::SetValue('AtricleType', $param['type']);
|
|
$atricleType = SessionProxy::GetValue('AtricleType');
|
|
} else {
|
|
if (SessionProxy::IsSetValue('AtricleType')) {
|
|
$atricleType = SessionProxy::GetValue('AtricleType');
|
|
} else {
|
|
$atricleType = 5;
|
|
}
|
|
}
|
|
|
|
$idSource = null;
|
|
if (isset($param['id']) && $param['id'] != '' && $param['id'] != '-1') {
|
|
$id = $param['id'];
|
|
$objMainSite = MfMainSiteDAL::GetById($id);
|
|
$idSource = $objMainSite->GetIdSource();
|
|
//Utils::arrayDisplay($objMainSite);
|
|
$objArticle = $objMainSite->GetMainArticleObj();
|
|
} else {
|
|
$id = -1;
|
|
$objMainSite = new MfMainSite($id);
|
|
$objArticle = null;
|
|
}
|
|
$this->smarty->assign('objArticle', $objArticle);
|
|
SessionProxy::SetValue('idArticle', $id);
|
|
$this->smarty->assign('idArticle', $id);
|
|
$this->smarty->assign('idSource', $idSource);
|
|
$this->smarty->assign('id', $id);
|
|
$lang = 'pl'; // GetArrayList($table, $column, $destination, $lang = null, $source, $idSource, $where = '') {
|
|
$arrayCategory = MfLinkDAL::GetArrayList('mf_article_category_description', 'name', 'mf_article_category', $lang, 'mf_article', $id);
|
|
|
|
|
|
$arrayArticle = array();
|
|
$arrayNews = array();
|
|
$arrayGallery = array();
|
|
|
|
$menuSelected = 'addMainSite';
|
|
if ($mainType == 3) {
|
|
$type = 2;
|
|
} else {
|
|
$type = null;
|
|
}
|
|
|
|
$types = array(1,2,3,4);
|
|
|
|
//zawezanie
|
|
SessionProxy::ClearValue('ms_id');
|
|
SessionProxy::ClearValue('ms_name');
|
|
$conditionArray = array();
|
|
$conditionArray['season'] = self::ACTUAL_SEASON;;
|
|
$data = Request::GetAllPost(false);
|
|
$this->smarty->assign('ms_id', '');
|
|
$this->smarty->assign('ms_name', '');
|
|
//koniec
|
|
|
|
//sortowanie
|
|
$fields = array(
|
|
'kolejnosc' => 'mf_article.id_mf_article',
|
|
'tytul' => 'mf_article_description.title',
|
|
'typ' => 'mf_article.type',
|
|
'stan' => 'mf_article.publication'
|
|
);
|
|
$sortBy = Utils::SortList($param, $fields, 'mainsite_article');
|
|
//koniec sortowania
|
|
|
|
//paginacja
|
|
$count = MfLinkDAL::GetAllList($mainType, $conditionArray, array(), null, '', true);
|
|
$perpage = self::CONTENT_PER_PAGE;
|
|
$pageCount = ceil($count/$perpage);
|
|
if(isset($param['strona']) && $param['strona']!=1) {
|
|
$currPage = ($param['strona']-1)*$perpage;
|
|
if($currPage <= 0) $currPage = 0;
|
|
if($currPage > $pageCount) $currPage = $pageCount;
|
|
$this->smarty->assign("currPage",$param['strona']);
|
|
}
|
|
else {
|
|
$currPage = 0;
|
|
$this->smarty->assign("currPage",1);
|
|
}
|
|
SessionProxy::SetValue('c_currPage', $currPage);
|
|
$this->smarty->assign('pageCount', $pageCount);
|
|
//koniec paginacji
|
|
|
|
//STARE !!!! $arrayArticle = MfLinkDAL::GetArrayArticleList($type,$id, $lang, '6');
|
|
|
|
|
|
|
|
$arrayArticle = MfLinkDAL::GetAllList($mainType, $conditionArray, array(), "$currPage,$perpage", '', null, $types);
|
|
|
|
//$arrayArticle = MfLinkDAL::GetAllList($mainType, $conditionArray, array(), "$currPage,$perpage", '', null, $types);
|
|
//Utils::ArrayDisplay($arrayArticle);
|
|
//$arrayArticle = MfLinkDAL::GetAllArticles($conditionArray, "$currPage,$perpage", $sortBy, null, $types);
|
|
|
|
|
|
//Utils::ArrayDisplay($arrayArticle);
|
|
$this->smarty->assign('arrayArticle', $arrayArticle);
|
|
|
|
|
|
if (SessionProxy::IsSetValue('arrayIdArticleLink')) {
|
|
SessionProxy::ClearValue('arrayIdArticleLink');
|
|
}
|
|
|
|
if ($mainType == 3) {
|
|
$newsCount = SetupDAL::GetVariableByName(MfMainSite::NEWS_COUNT);
|
|
$arrayNewsWeight = range(0, $newsCount['value']);
|
|
$this->smarty->assign('newsCount', $newsCount['value']);
|
|
$this->smarty->assign('arrayWeight', $arrayNewsWeight);
|
|
} elseif ($mainType == 2) {
|
|
$recommendCount = SetupDAL::GetVariableByName(MfMainSite::SUB_PROMO_COUNT);
|
|
|
|
$arrayRecommendWeight = range(0, $recommendCount['value']);
|
|
$this->smarty->assign('newsCount', $recommendCount['value']);
|
|
$this->smarty->assign('arrayWeight', $arrayRecommendWeight);
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->partialTemplate = 'Edit.tpl';
|
|
$this->smarty->assign("objMainSite", $objMainSite);
|
|
$this->smarty->assign("mainType", $mainType);
|
|
$this->smarty->assign("menuSelected", $menuSelected);
|
|
$this->smarty->assign("atricleType", $atricleType);
|
|
$this->smarty->assign('tableModuleNameCategory', 'mf_article');
|
|
$this->smarty->assign('arrayCategory', $arrayCategory);
|
|
//Utils::ArrayDisplay($arrayCategory);
|
|
$this->smarty->assign('arrayArticle', $arrayArticle);
|
|
$this->smarty->assign('arrayNews', $arrayNews);
|
|
$this->smarty->assign('arrayGallery', $arrayGallery);
|
|
$this->AddScript('calendar.js');
|
|
$this->AddScript('autocompleter.js');
|
|
$this->smarty->assign('articleListToLink', $this->smarty->fetch($this->templatePath."ArticleListToLink.tpl"));
|
|
//$this->smarty->assign('tableContentCategory', $this->smarty->fetch($this->templatePath."TableContentCategory.tpl"));
|
|
}
|
|
}
|
|
|
|
public function AjaxListAction($param) {
|
|
$this->SetAjaxRender();
|
|
$types = array(1,2,3,4);
|
|
|
|
if(isset($param['id']) && $param['id'] != '-1' && $param['id'] != '') {
|
|
$objMainSite = MfMainSiteDAL::GetById($param['id']);
|
|
$idSource = $objMainSite->GetIdSource();
|
|
|
|
|
|
$this->smarty->assign('id', $objMainSite->GetId());
|
|
} else {
|
|
$idSource = -1;
|
|
$this->smarty->assign('id', '-1');
|
|
}
|
|
|
|
if(SessionProxy::IsSetValue('radioChecked')) {
|
|
$idSource = SessionProxy::GetValue('radioChecked');
|
|
}
|
|
|
|
$this->smarty->assign('idSource', $idSource);
|
|
|
|
$mainType = SessionProxy::GetValue('mainType');
|
|
$this->smarty->assign('mainType', $mainType);
|
|
//zawezanie
|
|
$linkedConditions = array();
|
|
$id = '';
|
|
$search = '';
|
|
$data = Request::GetAllPost(false);
|
|
|
|
|
|
$arrayTableType = MfLink::GetArrayTableType();
|
|
if(isset($data['ms_id']) && $data['ms_id'] != '') {
|
|
SessionProxy::SetValue('ms_id', $data['ms_id']);
|
|
$linkedConditions[$arrayTableType[$mainType].'.id_'.$arrayTableType[$mainType]] = array('value' => '"%'.addslashes($data['ms_id']).'%"', 'condition' => 'LIKE');
|
|
}
|
|
if(isset($data['ms_name']) && $data['ms_name'] != '') {
|
|
SessionProxy::SetValue('ms_name', $data['ms_name']);
|
|
$linkedConditions[$arrayTableType[$mainType].'_description.title'] = array('value' => '"%'.addslashes($data['ms_name']).'%"', 'condition' => 'LIKE');
|
|
}
|
|
|
|
if(SessionProxy::IsSetValue('ms_id') && !isset($data['ms_id'])) {
|
|
$sId = SessionProxy::GetValue('ms_id');
|
|
if(trim($sId) != '') {
|
|
$linkedConditions[$arrayTableType[$mainType].'.id_'.$arrayTableType[$mainType]] = array('value' => '"%'.addslashes($sId).'%"', 'condition' => 'LIKE');
|
|
}
|
|
}
|
|
if(SessionProxy::IsSetValue('ms_name') && !isset($data['ms_name'])) {
|
|
//Utils::ArrayDisplay($data);
|
|
$sName = SessionProxy::GetValue('ms_name');
|
|
if(trim($sName) != '') {
|
|
$linkedConditions[$arrayTableType[$mainType].'_description.title'] = array('value' => '"%'.addslashes($sName).'%"', 'condition' => 'LIKE');
|
|
}
|
|
}
|
|
//koniec
|
|
// $sName = $data['ms_name'];
|
|
// $sId = $data['ms_id'];
|
|
//
|
|
//
|
|
//
|
|
// //Utils::ArrayDisplay($arrayTableType[$mainType]);
|
|
//
|
|
// $linkedConditions[$arrayTableType[$mainType].'.id_'.$arrayTableType[$mainType]] = array('value' => '"%'.addslashes($sId).'%"', 'condition' => 'LIKE');
|
|
|
|
$conditionArray['season'] = self::ACTUAL_SEASON;
|
|
$linkedConditions = array_merge_recursive($linkedConditions, $conditionArray);
|
|
//paginacja
|
|
$count = MfLinkDAL::GetAllList($mainType, $linkedConditions, array(), null, '', true);
|
|
//$count = MfLinkDAL::GetAllArticles($conditionArray, null, null, true, $types);
|
|
$perpage = self::CONTENT_PER_PAGE;
|
|
$pageCount = ceil($count/$perpage);
|
|
if(isset($param['strona']) && $param['strona']!=1) {
|
|
$currPage = ($param['strona']-1)*$perpage;
|
|
//if($currPage <= 0) $currPage = 0;
|
|
//if($currPage > $pageCount) $currPage = $pageCount;
|
|
$this->smarty->assign("currPage",$param['strona']);
|
|
}
|
|
else {
|
|
$currPage = 0;
|
|
$this->smarty->assign("currPage",1);
|
|
}
|
|
SessionProxy::SetValue('c_currPage', $currPage);
|
|
$this->smarty->assign('pageCount', $pageCount);
|
|
//koniec paginacji
|
|
|
|
//sortowanie
|
|
$fields = array(
|
|
'kolejnosc' => 'mf_article.id_mf_article',
|
|
'tytul' => 'mf_article_description.title',
|
|
'typ' => 'mf_article.type',
|
|
'stan' => 'mf_article.publication'
|
|
);
|
|
$sortBy = Utils::SortList($param, $fields, 'mainsite_article');
|
|
//koniec sortowania
|
|
|
|
//Utils::ArrayDisplay($conditionArray);
|
|
//$arrayArticle = MfLinkDAL::GetAllArticles($conditionArray, "$currPage,$perpage", $sortBy, null, $types);
|
|
$arrayArticle = MfLinkDAL::GetAllList($mainType, $linkedConditions, array(), "$currPage,$perpage", '');
|
|
|
|
$this->smarty->assign('arrayArticle', $arrayArticle);
|
|
$this->smarty->assign('articleListToLink', $this->smarty->fetch($this->templatePath."ArticleListToLink.tpl"));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Edycja artykułu
|
|
*
|
|
* @param Array $param
|
|
*/
|
|
public function EditAction($param) {
|
|
|
|
//zawezanie
|
|
SessionProxy::ClearValue('ms_id');
|
|
SessionProxy::ClearValue('ms_name');
|
|
$conditionArray = array();
|
|
$conditionArray['season'] = self::ACTUAL_SEASON;;
|
|
$data = Request::GetAllPost(false);
|
|
$this->smarty->assign('ms_id', '');
|
|
$this->smarty->assign('ms_name', '');
|
|
//koniec
|
|
|
|
|
|
|
|
|
|
//$mainType = SessionProxy::GetValue('mainType');
|
|
|
|
if(isset($param['id'])) {
|
|
$objMainSite = MfMainSiteDAL::GetById($param['id']);
|
|
$mainType = $objMainSite->GetMainType();
|
|
SessionProxy::SetValue('mainType', $mainType);
|
|
$objArticle = SimpleArticle_MfArticleDAL::GetById($objMainSite->GetIdMainArticle());
|
|
|
|
//$objTags = TableToTagDAL::GetTagsString($objArticle);
|
|
|
|
//sortowanie
|
|
$fields = array(
|
|
'kolejnosc' => 'mf_article.id_mf_article',
|
|
'tytul' => 'mf_article_description.title',
|
|
'typ' => 'mf_article.type',
|
|
'stan' => 'mf_article.publication'
|
|
);
|
|
$sortBy = Utils::SortList($param, $fields, 'mainsite_article');
|
|
//koniec sortowania
|
|
$types = array(1,2,3,4);
|
|
//paginacja
|
|
$count = MfLinkDAL::GetAllList($mainType, $conditionArray, array(), null, '', true);
|
|
$perpage = self::CONTENT_PER_PAGE;
|
|
|
|
// Utils::ArrayDisplay(array($count, $perpage));
|
|
|
|
$pageCount = ceil($count/$perpage);
|
|
if(isset($param['strona']) && $param['strona']!=1) {
|
|
$currPage = ($param['strona']-1)*$perpage;
|
|
if($currPage <= 0) $currPage = 0;
|
|
if($currPage > $pageCount) $currPage = $pageCount;
|
|
$this->smarty->assign("currPage",$param['strona']);
|
|
}
|
|
else {
|
|
$currPage = 0;
|
|
$this->smarty->assign("currPage",1);
|
|
}
|
|
SessionProxy::SetValue('c_currPage', $currPage);
|
|
$this->smarty->assign('pageCount', $pageCount);
|
|
//koniec paginacji
|
|
|
|
|
|
|
|
$this->AddScript('Dosia.js');
|
|
// $this->AddScript('lightbox.js');
|
|
$this->AddScript('cropper.js');
|
|
// $this->AddScript('uploaderArticle.js');
|
|
$this->AddScript("urlStatic = '" . URL_STATIC_CONTENT . URL_DELIMITER . "';", 'code');
|
|
|
|
|
|
//$this->smarty->assign('tags', $objTags);
|
|
if (is_object($objArticle)) {
|
|
$this->smarty->assign('objArticle', $objArticle);
|
|
}
|
|
|
|
if (isset($param['idElement'])) {
|
|
$this->smarty->assign('idElement', $param['idElement']);
|
|
}
|
|
|
|
$idSource = $objMainSite->GetIdSource();
|
|
//Utils::ArrayDisplay($objMainSite);
|
|
$this->smarty->assign('mainType', $mainType);
|
|
$this->smarty->assign('idSource', $idSource);
|
|
$this->smarty->assign('id', $objMainSite->GetId());
|
|
$this->smarty->assign('objMainSite', $objMainSite);
|
|
$this->AddAction($param);
|
|
$this->AddScript('calendar.js');
|
|
|
|
if ($mainType == 3) {
|
|
$type = 2;
|
|
} else {
|
|
$type = null;
|
|
}
|
|
|
|
if ($mainType == 3) {
|
|
$newsCount = SetupDAL::GetVariableByName(MfMainSite::NEWS_COUNT);
|
|
$arrayNewsWeight = range(0, $newsCount['value']);
|
|
$this->smarty->assign('newsCount', $newsCount['value']);
|
|
$this->smarty->assign('arrayWeight', $arrayNewsWeight);
|
|
} elseif ($mainType == 2) {
|
|
$recommendCount = SetupDAL::GetVariableByName(MfMainSite::SUB_PROMO_COUNT);
|
|
//Utils::ArrayDisplay($recommendCount);
|
|
$arrayRecommendWeight = range(0, $recommendCount['value']);
|
|
$this->smarty->assign('newsCount', $recommendCount['value']);
|
|
$this->smarty->assign('arrayWeight', $arrayRecommendWeight);
|
|
}
|
|
|
|
//STARE !!!! $arrayArticle = MfLinkDAL::GetArrayArticleList($type,$id, $lang, '6');
|
|
$conditions = array();
|
|
$types = array(1,2,3,4);
|
|
//$arrayArticle = MfLinkDAL::GetAllArticles($conditionArray, "$currPage,$perpage", $sortBy, null, $types);
|
|
$arrayArticle = MfLinkDAL::GetAllList($mainType, $conditionArray, array(), "$currPage,$perpage", '', null, $types);
|
|
//KONIEC NOWEGO
|
|
//Utils::ArrayDisplay($objMainSite);
|
|
$this->smarty->assign('arrayArticle', $arrayArticle);
|
|
$this->smarty->assign('articleListToLink', $this->smarty->fetch($this->templatePath."ArticleListToLink.tpl"));
|
|
//$this->smarty->assign('TableEditCategories', $this->smarty->fetch($this->templatePath."TableEditCategories.tpl"));
|
|
} else {
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function ValidateFormAction($param) {
|
|
|
|
$this->SetAjaxRender();
|
|
if(Request::IsPost()) {
|
|
$data = Request::GetAllPost(false);
|
|
|
|
if(isset($data['zajawkafck'])) $data['zajawkafck'] = trim(substr($data['zajawkafck'],0,-6));
|
|
else $data['zajawkafck'] = '';
|
|
|
|
if(isset($data['photoadded'])) {
|
|
$photo = explode('.', $data['photoadded']);
|
|
if(isset($photo[1])) $data['photoadded'] = 'jpg';
|
|
else $data['photoadded'] = '';
|
|
} else $data['photoadded'] = '';
|
|
|
|
$validator = new Validator($data);
|
|
|
|
$validator->IsEmpty('tytul', 'Pole tytuł musi zostać wypełnione.');
|
|
//$validator->IsDate('datepublication', 'Pole data publikacji musi zostać wypełnione.');
|
|
//$validator->IsDate('date_stop_publication', 'Pole data publikacji musi zostać wypełnione.');
|
|
|
|
|
|
if(isset($data['mainType']) && $data['mainType'] != 3) {
|
|
$validator->IsEmpty('zajawkafck', 'Artykuł musi mieć zajawkę.', 'zajawkafck2');
|
|
//$validator->IsEmpty('photoadded', 'Zdjęcie musi być dodane', 'zdjecie2');
|
|
}
|
|
$param['submitForm'] = 'walidacja';
|
|
$out = $validator->GetErrorList();
|
|
$param['redirect'] = Router::GenerateUrl(array('_value'=>'mainSite,articlesave'));
|
|
$this->content=$this->FormatAjaxOutput($out, $param);
|
|
if(empty($out) && Request::GetPost('action') == 'submit')SessionProxy::SetValue('postData',Request::GetAllPost(false));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Akcja zapisu danych
|
|
*
|
|
* @param <type> $param
|
|
*/
|
|
public function ArticleSaveAction($param) {
|
|
//SessionProxy::SetValue('AtricleType', 5);
|
|
$atricleType = SessionProxy::GetValue('AtricleType');
|
|
|
|
$data['tresc'] = 'MainSite';
|
|
|
|
$data = SessionProxy::GetValue('postData');
|
|
if (sizeof($data)) {
|
|
|
|
if(!isset($data['allowrating'])) $data['allowrating'] = 0;
|
|
else $data['allowrating'] = 1;
|
|
if(!isset($data['allowcomment'])) $data['allowcomment'] = 0;
|
|
else $data['allowcomment'] = 1;
|
|
|
|
$publication = Request::Get('publication');
|
|
$publication ? $publication = 1 : $publication = '0';
|
|
|
|
if (isset($data['idArticle']) && $data['idArticle'] != -1) {
|
|
$objArticle = SimpleArticle_MfArticleDAL::GetById($data['idArticle']);
|
|
//$objArticle->SetEditUser($this->user->GetPrimaryMail());
|
|
$objArticle->SetEditDate(date("Y-m-d H:i:s"));
|
|
$objArticleDescription = SimpleArticle_MfArticleDescriptionDAL::GetResult(array('lang' => $objArticle->GetLang(), 'id_mf_article' => $objArticle->GetId()), array('id_mf_article_description', 'title', 'description', 'shortnote'));
|
|
$objArticleDescription = $objArticleDescription[0];
|
|
$objArticleDescription->SetShortnote(Utils::TrimString($data['zajawkafck'], "<br />"));
|
|
$objArticle->SetDatePublication($data['datepublication']." ".$data['timepublication'].":00:00");
|
|
} else {
|
|
$objArticle = new SimpleArticle_MfArticle();
|
|
//$objArticle->SetIdPhysician($this->user->GetId());
|
|
//$objArticle->SetPhysicianLogin($this->user->GetPrimaryMail());
|
|
$objArticle->SetDatePublication($data['datepublication']." ".$data['timepublication'].":00:00");
|
|
|
|
//$objArticle->SetAddUser($this->user->GetPrimaryMail());
|
|
$objArticle->SetAddDate(date("Y-m-d H:i:s"));
|
|
|
|
|
|
$objArticleDescription = new SimpleArticle_MfArticleDescription();
|
|
$objArticleDescription->SetShortnote(Utils::TrimString($data['zajawkafck'], "<br />"));
|
|
$objArticle->SetType($atricleType);
|
|
$objArticle->SetArticleDescriptionObj($objArticleDescription);
|
|
|
|
if (isset($data['saveAndPublish']) && $data['saveAndPublish']) {
|
|
$objArticleDescription->SetPublication(1);
|
|
}
|
|
}
|
|
|
|
if(SessionProxy::IsSetValue(self::PHOTO_SESSION_ID)) {
|
|
$photoId = SessionProxy::GetValue(self::PHOTO_SESSION_ID);
|
|
|
|
if ($photoId) {
|
|
$objArticle->SetIdPicture($photoId);
|
|
SessionProxy::ClearValue(self::PHOTO_SESSION_ID);
|
|
}
|
|
}
|
|
|
|
if(isset($data['deleteOldPhoto']) && $data['deleteOldPhoto'] == 1) $objArticle->SetIdPicture(0);
|
|
|
|
//$objArticle->SetTag($_POST['tags']);
|
|
//TableToTagDAL::SaveTagsFromString($_POST['tags'], $objArticle);
|
|
// var_dump($objArticleDescription->GetId());
|
|
|
|
$objArticle->SetDate(date('Y-m-d'));
|
|
$objArticle->SetWeight(10);
|
|
$objArticle->SetPublication(1);
|
|
|
|
//Utils::ArrayDisplay($objArticle);
|
|
$iid = SimpleArticle_MfArticleDAL::Save($objArticle);
|
|
|
|
//Utils::ArrayDisplay(" id ".$iid);
|
|
|
|
$objArticleDescription->SetLang('pl');
|
|
$objArticleDescription->SetDescription('SG');
|
|
if (SessionProxy::GetValue('mainType') == 3) {
|
|
$objArticleDescription->SetShortnote('SG-NEWS');
|
|
} else {
|
|
$objArticleDescription->SetShortnote(Utils::TrimString($data['zajawkafck'], "<br />"));
|
|
}
|
|
$objArticleDescription->SetTitle($data['tytul']);
|
|
$objArticleDescription->SetBrowserTitle($data['tytul']);
|
|
$objArticleDescription->SetIdMfArticle($iid);
|
|
//$objArticleDescription->SetPublication($publication);
|
|
|
|
//==Linkowanie materiału ===================================================
|
|
//$arrayLinkCategory = array();
|
|
if (isset($data['mf_article_link'])) {
|
|
$linkConntent = $data['mf_article_link'];
|
|
// Utils::ArrayDisplay($arrayLink);
|
|
}
|
|
if (SessionProxy::IsSetValue('radioChecked')) {
|
|
$linkConntent = SessionProxy::GetValue('radioChecked');
|
|
}
|
|
SessionProxy::ClearValue('radioChecked');
|
|
|
|
//Utils::ArrayDisplay($data);
|
|
if (isset($data['idMainSite'])) {
|
|
$idMainSite = $data['idMainSite'];
|
|
} else {
|
|
$idMainSite = -1;
|
|
}
|
|
$objMainSite = new MfMainSite($idMainSite) ;
|
|
|
|
//$objMainSite->SetSourceType('mf_article');
|
|
if (isset($data['mf_article_link'])) $objMainSite->SetIdSource($linkConntent);
|
|
|
|
$objMainSite->SetIdMainArticle($iid);
|
|
|
|
$objMainSite->SetMainType(SessionProxy::GetValue('mainType'));
|
|
if(isset($data['weight']))$objMainSite->SetWeight($data['weight']);
|
|
else $objMainSite->SetWeight(1);
|
|
if(!isset($data['time_stop_publication'])) $data['time_stop_publication'] = '00';
|
|
if(!isset($data['timepublication'])) $data['timepublication'] = '00';
|
|
if(isset($data['date_stop_publication']) && $data['date_stop_publication'] && $data['time_stop_publication']) {
|
|
$objMainSite->SetDateStopPublication($data['date_stop_publication']." ".$data['time_stop_publication'].":00");
|
|
} else {
|
|
$objMainSite->SetDateStopPublication("0000-00-00 00:00:00");
|
|
}
|
|
if(isset($data['datepublication'])) $objMainSite->SetDatePublication($data['datepublication']." ".$data['timepublication'].":00:00");
|
|
|
|
|
|
//Utils::ArrayDisplay($objMainSite);
|
|
|
|
MfMainSiteDAL::Save($objMainSite);
|
|
|
|
|
|
//====kopiowanie=zdjecia=======================================================
|
|
if (SessionProxy::GetValue('mainType') == 3) {
|
|
//Utils::ArrayDisplay(' test '. SessionProxy::GetValue('mainType'). $linkConntent);
|
|
$objArticleSource = SimpleArticle_MfArticleDAL::GetById($linkConntent);
|
|
if ($objArticleSource->GetIdPicture()) {
|
|
$objPicture = PictureDAL::GetById($objArticleSource->GetIdPicture());
|
|
//Utils::ArrayDisplay($objArticle->GetIdPicture());
|
|
if ($objArticle->GetIdPicture()) {
|
|
$objPhoto = PictureDAL::GetById($objArticle->GetIdPicture());
|
|
$photoFile = $objPhoto->GetLink();
|
|
//Utils::ArrayDisplay('podmianka');
|
|
} else {
|
|
//Utils::ArrayDisplay('tu');
|
|
//Utils::ArrayDisplay($objArticle->GetIdPicture());
|
|
//$objPhoto = PictureDAL::GetById($objArticle->GetIdPicture());
|
|
|
|
//$objPicture->GetLink() . '.' . PhotoDAL::PHOTO_NEW_EXT;
|
|
|
|
$photoFile = md5(date("Y-m-d H:i:s"));
|
|
//Utils::ArrayDisplay('nowe');
|
|
}
|
|
//Utils::ArrayDisplay($objPicture);
|
|
|
|
// if (is_file(Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_DEST_DIR . URL_DELIMITER . $objPicture->GetLink() . '_50.' . PhotoDAL::PHOTO_NEW_EXT)) {
|
|
// copy(Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_DEST_DIR . URL_DELIMITER . $objPicture->GetLink() . '_50.' . PhotoDAL::PHOTO_NEW_EXT, PATH_STATIC_CONTENT . self::GALLERY_DEST_DIR . URL_DELIMITER .$photoFile . '.' . PhotoDAL::PHOTO_NEW_EXT);
|
|
// }
|
|
|
|
|
|
//PhotoDAL::ExtSimplePhotoUpload($tmpPhotoArray, $destDir);
|
|
$objPhoto = new Picture();
|
|
if ($objArticle->GetIdPicture()) {
|
|
$objPhoto->SetId($objArticle->GetIdPicture());
|
|
} else {
|
|
$objPhoto->SetId(-1);
|
|
}
|
|
|
|
$objPhoto->SetLink($photoFile);
|
|
$idPhoto = PictureDAL::Save($objPhoto);
|
|
//Utils::ArrayDisplay('id '.$idPhoto);
|
|
$objArticle = SimpleArticle_MfArticleDAL::GetById($iid);
|
|
$objArticle->SetIdPicture($idPhoto);
|
|
SimpleArticle_MfArticleDAL::Update($objArticle);
|
|
//$objArticle = MfArticleDAL::GetById($iid);
|
|
//Utils::ArrayDisplay($objArticle);
|
|
$objPicture = PictureDAL::GetById($idPhoto);
|
|
} else {
|
|
//Utils::ArrayDisplay('brak zdjecia');
|
|
$objArticle = SimpleArticle_MfArticleDAL::GetById($iid);
|
|
if ($objArticle->GetIdPicture()) {
|
|
|
|
$objPhoto = PictureDAL::GetById($objArticle->GetIdPicture());
|
|
|
|
if (is_file(Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_DEST_DIR . URL_DELIMITER . $objPhoto->GetLink() . '.' . PhotoDAL::PHOTO_NEW_EXT)) {
|
|
unlink(Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_DEST_DIR . URL_DELIMITER . $objPhoto->GetLink() . '.' . PhotoDAL::PHOTO_NEW_EXT);
|
|
}
|
|
//Utils::ArrayDisplay($objPhoto);
|
|
PictureDAL::Delete($objPhoto);
|
|
|
|
$objArticle->SetIdPicture(0);
|
|
SimpleArticle_MfArticleDAL::Update($objArticle);
|
|
}
|
|
|
|
}
|
|
//Utils::ArrayDisplay($objPicture);
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SimpleArticle_MfArticleDescriptionDAL::Save($objArticleDescription);
|
|
|
|
$this->smarty->assign('iid', $iid);
|
|
$this->smarty->assign('atricleType', $atricleType);
|
|
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')), 0);
|
|
|
|
|
|
} else {
|
|
$this->smarty->assgin('errorList', array('Formularz nie został wysłany.'));
|
|
}
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')));
|
|
}
|
|
|
|
public function DeleteAction($param) {
|
|
$obj = MfMainSiteDAL::GetById($param['id']);
|
|
$dataStop = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m") , date("d")-1, date("Y")));
|
|
$obj->SetDateStopPublication($dataStop);
|
|
MfMainSiteDAL::Update($obj);
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')));
|
|
}
|
|
|
|
public function SortAction($param) {
|
|
|
|
$arrayList = MfMainSiteDAL::GetList($param['mainType'],SetupDAL::GetVariableByName(MfMainSite::GetTypSetupByType($param['mainType'])));
|
|
|
|
$i = 1;
|
|
foreach($arrayList AS $key => $item){
|
|
if(is_numeric($item->GetBlockade()))$blocked[$item->GetBlockade()] = $item;
|
|
else $rest[$i++] = $item;
|
|
}
|
|
|
|
$index = 1;
|
|
$count = count($rest);
|
|
|
|
foreach($rest AS $k => $item ) {
|
|
if($item->GetId() == $param['id'])$index = $k;
|
|
}
|
|
|
|
switch($param['direct']){
|
|
case 'down':
|
|
$direction = 1;
|
|
break;
|
|
case 'up':
|
|
$direction = -1;
|
|
}
|
|
|
|
if(($index == $count && $direction == 1) || (($index == 1 && $direction == -1))) {
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')));
|
|
} else {
|
|
|
|
$orgElement = $rest[$index];
|
|
$subElement = $rest[$index + $direction];
|
|
|
|
$rest[$index + $direction] = $orgElement;
|
|
$rest[$index] = $subElement;
|
|
|
|
$count = count($arrayList);
|
|
$return = array();
|
|
for($i = 1; $i <= $count; $i++){
|
|
if(isset($blocked[$i]))$return[$i] = $blocked[$i];
|
|
else $return[$i] = array_shift($rest);
|
|
}
|
|
|
|
foreach ($return as $key => $item) {
|
|
$item->SetWeight($key);
|
|
MfMainSiteDAL::Update($item);
|
|
}
|
|
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')),0);
|
|
}
|
|
}
|
|
|
|
public function SetPublicationAction($param) {
|
|
if (isset($param['id'])) {
|
|
MfMainSiteDAL::UpdateSetPublication($param['id']);
|
|
}
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')), 0);
|
|
}
|
|
|
|
public function SetWeightAction($param) {
|
|
//Utils::ArrayDisplay($_POST);
|
|
if (isset($param['id'])) {
|
|
if (!$_POST['weight_'.$param['id']]) {
|
|
MfMainSiteDAL::UpdateWeight($param['id'], '0');
|
|
} else {
|
|
MfMainSiteDAL::UpdateWeight($param['id'], $_POST['weight_'.$param['id']]);
|
|
}
|
|
}
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')),0);
|
|
}
|
|
|
|
public function SetCountRecommendAction() {
|
|
|
|
SetupDAL::SaveVariable('info_main_site_count', $_POST['count'], 'ilość wiadomości na pierwszej stronie informacji');
|
|
$this -> AddRedirect(Router::GenerateURL(array('mainSite')),0);
|
|
}
|
|
|
|
|
|
|
|
public function PhotoAction($param) {
|
|
|
|
$this->AddScript('gallery.js');
|
|
$this->AddScript('cropper.js');
|
|
$this->AddScript('uploader.js');
|
|
$this->AddScript("urlStatic = '" . URL_STATIC_CONTENT . URL_DELIMITER . "';", 'code');
|
|
$this->AddHeader('link',array('rel'=>'stylesheet','type'=>'text/css','href'=>URL_STATIC_CONTENT.'/css/styleGallery.css'));
|
|
|
|
|
|
$galleryObj = null;
|
|
if(isset($param['gid'])) {
|
|
$galleryObj = SimpleArticle_MfArticleDAL::GetById($param['gid']);
|
|
}
|
|
if(empty($galleryObj)) {
|
|
$this->AddRedirect(Router::GenerateUrl(array('mainSite'=>'Gallery')), 0);
|
|
return;
|
|
}
|
|
$this->smarty->assign('galleryObj', $galleryObj);
|
|
|
|
$photoObjList = ProfileGalleryDAL::GetResult(array('id_mf_article'=>$param['gid']));
|
|
$this->smarty->assign('photoObjList', $photoObjList);
|
|
}
|
|
|
|
public function PhotoEditAction($param) {
|
|
|
|
if(!isset($param['id'])) {
|
|
$this->AddRedirectInfo('Zdjęcie nie istnieje lub nie masz do niego dostępu', 'error');
|
|
$this->AddRedirect(Router::GenerateUrl(array('zdjecia'=>'moje')), 0);
|
|
return;
|
|
}
|
|
|
|
$photo = ProfileGalleryDAL::GetResult(array('id_nm_profile_gallery' => $param['id']), array());
|
|
|
|
if(empty($photo)) {
|
|
$this->AddRedirectInfo($this->GetDictionary("gallery_notify_error"), 'error');
|
|
$this->AddRedirect(Router::GenerateUrl(array('zdjecia'=>'moje')), 0);
|
|
return;
|
|
}else{
|
|
|
|
}
|
|
|
|
$resize = Request::Get('resize');
|
|
if(Request::IsPost() && $resize == '1')
|
|
{ // edycja miniatury
|
|
$tmpPhotoArray = array();
|
|
$tmpPhotoArray['name'] = $photo[0]->GetPhoto() . '.' . PhotoDAL::PHOTO_NEW_EXT;
|
|
$tmpPhotoArray['org_name'] = $photo[0]->GetPhoto() . '_750.' . PhotoDAL::PHOTO_NEW_EXT;
|
|
$tmpPhotoArray['tmp_name'] = Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_DEST_DIR . URL_DELIMITER . $this->user->GetId() . URL_DELIMITER . $tmpPhotoArray['name'];
|
|
$tmpPhotoArray['resize'] = true;
|
|
$orgSize = getimagesize(Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_DEST_DIR . URL_DELIMITER . $this->user->GetId() . URL_DELIMITER . $tmpPhotoArray['name']);
|
|
|
|
$tmpFile = $photo[0]->GetPhoto() . '_temp.' . PhotoDAL::PHOTO_NEW_EXT;
|
|
$tmpFileName = $photo[0]->GetPhoto() . '_temp.' . PhotoDAL::PHOTO_NEW_EXT;
|
|
$tmpFile = Config::Get('PATH_STATIC_CONTENT') . self::GALLERY_DEST_DIR . URL_DELIMITER . $this->user->GetId() . URL_DELIMITER . $tmpFileName;
|
|
$croppSize = getimagesize($tmpFile);
|
|
|
|
$sx = 1;
|
|
if($orgSize[0] != $croppSize[0]) {
|
|
$sx = $orgSize[0]/$croppSize[0];
|
|
}
|
|
|
|
|
|
$croppArray = array(
|
|
'x' => Request::Get('photoCropperImageCropX1') * $sx,
|
|
'y' => Request::Get('photoCropperImageCropY1') * $sx,
|
|
'w' => (Request::Get('photoCropperImageCropX2') - Request::Get('photoCropperImageCropX1')) * $sx,
|
|
'h' => (Request::Get('photoCropperImageCropY2') - Request::Get('photoCropperImageCropY1')) * $sx
|
|
);
|
|
|
|
$destDir = self::GALLERY_DEST_DIR . URL_DELIMITER . $this->user->GetId();
|
|
|
|
PhotoDAL::ExtSimplePhotoUpload($tmpPhotoArray, $destDir, 'gallery_crop', null, null, $croppArray);
|
|
|
|
$photo[0]->SetDescription(Request::Get('photoCropperDescription'));
|
|
ProfileGalleryDAL::Save($photo[0]);
|
|
|
|
}
|
|
|
|
$this->AddScript('carousel.js');
|
|
//$this->AddScript('Validator.js');
|
|
|
|
$photoList = ProfileGalleryDAL::GetResult(array('id_nm_physician' => $this->user->getId()), array());
|
|
$countPhotoList = count($photoList);
|
|
|
|
$act = 0;
|
|
for($act = 0; $act < $countPhotoList; $act++) {
|
|
if($photoList[$act]->GetId() == $photo[0]->GetId()) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
$prevId = -1;
|
|
if($act > 0) {
|
|
$prevId = $photoList[$act-1]->GetId();
|
|
}
|
|
|
|
$nextId = -1;
|
|
if(isset($photoList[$act+1])) {
|
|
$nextId = $photoList[$act+1]->GetId();
|
|
}
|
|
|
|
$act += 1;
|
|
|
|
|
|
|
|
$this->smarty->assign('photoObj', $photo[0]);
|
|
$this->smarty->assign('photoList', $photoList);
|
|
|
|
$this->smarty->assign('actPhoto', $act);
|
|
$this->smarty->assign('photoCount', $countPhotoList);
|
|
|
|
$showForm = false;
|
|
|
|
|
|
$this->smarty->assign('showAddForm', $showForm);
|
|
$this->smarty->assign('showForm', false);
|
|
$this->AddScript('gallery.js');
|
|
|
|
|
|
$this->smarty->assign('nextId', $nextId);
|
|
$this->smarty->assign('prevId', $prevId);
|
|
|
|
}
|
|
|
|
public function AjaxDeletePhotoAction($param) {
|
|
if(!isset($param['id'])) {
|
|
$this->AddRedirectInfo('Zdjęcie nie istnieje lub nie masz do niego dostępu.', 'error');
|
|
$this->AddRedirect(Router::GenerateUrl(array()), 0);
|
|
return;
|
|
}
|
|
|
|
$photo = ProfileGalleryDAL::GetResult(array('id_nm_profile_gallery' => $param['id']), array());
|
|
|
|
if(empty($photo)) {
|
|
$this->AddRedirectInfo($this->GetDictionary("gallery_notify_error"), 'error');
|
|
$this->AddRedirect(Router::GenerateUrl(array('zdjecia'=>'moje')), 0);
|
|
return;
|
|
}
|
|
|
|
if(isset($param['ok']) && $param['ok'] == 1) {
|
|
ProfileGalleryDAL::Delete($photo[0]->GetId());
|
|
$this->AddRedirectInfo($this->GetDictionary('gallery_notify_delete'));
|
|
$this->AddRedirect(Router::GenerateUrl(array('mainSite'=>'Photo', 'gid'=>$photo[0]->GetIdMfArticle())), 0);
|
|
return;
|
|
}
|
|
|
|
$this->SetAjaxRender();
|
|
$buttons = new HtmlButton();
|
|
$buttons->AddButton('popoverAbort', 'button buttonAnuluj lbAction', '', null, 'deactivate');
|
|
$title = 'Usuń zdjęcie';
|
|
$message = 'Czy na pewno chcesz usunąć zdjęcie?';
|
|
$buttons->AddButton('popoverOk', 'button buttonUsun popoverOk', '', 'document.location.href=\''.Router::GenerateUrl(array('mainSite'=>'AjaxDeletePhoto', 'id'=>$photo[0]->GetId(), 'ok'=>1)).'\';', null);
|
|
$this->content = $this->GeneratePopover($title, 'usun-wiadomosc_03.gif', $message, $buttons->GetElements(), null);
|
|
}
|
|
|
|
// -- cropper
|
|
|
|
public function AjaxGalleryCropperAction($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('mainSite' => 'AjaxGalleryCropped', 'gid' => $param['gid'], 'id' => $param['id']));
|
|
} else {
|
|
$this->smarty->assign('cutUrl', array('mainSite' => 'AjaxGalleryCropped', 'gid' => $param['gid']));
|
|
}
|
|
|
|
$this->smarty->assign('uploadUrl', array('mainSite' => 'AjaxGalleryUpload'));
|
|
|
|
}
|
|
|
|
public function AjaxGalleryCroppedAction($param) {
|
|
|
|
$upload = true;
|
|
$oldPhoto = null;
|
|
if(isset($param['id']) && $param['id'] > 0) {
|
|
$upload = false;
|
|
}
|
|
|
|
|
|
$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::PUB_GALLERY_TEMP_DIR . URL_DELIMITER . $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::PUB_GALLERY_TEMP_DIR . URL_DELIMITER . $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::PUB_GALLERY_DIR;
|
|
|
|
$photo = PhotoDAL::ExtSimplePhotoUpload($tmpPhotoArray, $destDir, 'gallery_crop', null, null, $croppArray);
|
|
|
|
$id = null;
|
|
|
|
if($upload) {
|
|
$newPhoto = new ProfileGallery();
|
|
$newPhoto -> SetPhoto($photoFile);
|
|
// $newPhoto -> SetIdNmPhysician($this->user->GetId());
|
|
$newPhoto -> SetDescription(Request::Get('description'));
|
|
$newPhoto -> SetIdMfArticle($param['gid']);
|
|
$newPhoto -> SetExt(PhotoDAL::PHOTO_NEW_EXT);
|
|
$id = ProfileGalleryDAL::Insert($newPhoto);
|
|
} else {
|
|
$oldPhoto[0]->SetPhoto($photoFile);
|
|
$oldPhoto[0]->SetDescription(Request::Get('description'));
|
|
ProfileGalleryDAL::Update($oldPhoto[0]);
|
|
$id = $oldPhoto[0]->GetId();
|
|
}
|
|
|
|
$this->AddRedirectInfo($this->GetDictionary("gallery_notify_add"));
|
|
$redirect = Router::GenerateUrl(array('mainSite'=>'edycja', 'id'=>$id));
|
|
|
|
$this->smarty->assign('photoPath', $photo);
|
|
$this->smarty->assign('redirect', $redirect);
|
|
}
|
|
|
|
public function AjaxGalleryUploadAction($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::PUB_GALLERY_TEMP_DIR , 'gallery_cropp_temporary', $newName, 'temp');
|
|
$photoFile = self::PUB_GALLERY_TEMP_DIR . URL_DELIMITER . $photoFile;
|
|
|
|
$this->smarty->assign('page2load', null);
|
|
$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'));
|
|
}
|
|
}
|
|
|
|
// 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::PHOTO_WIDTH);
|
|
$this->smarty->assign('minPhotoHeight', self::PHOTO_HEIGHT);
|
|
|
|
$this->smarty->assign('noPhotoImgBig', URL_STATIC_CONTENT . '/' . self::NO_PHOTO_IMG_BIG);
|
|
$this->smarty->assign('noPhotoImgSmall', URL_STATIC_CONTENT . '/' . self::NO_PHOTO_IMG_SMALL);
|
|
|
|
$this->smarty->assign('photoPath', Request::GetPost('photoPath'));
|
|
$cutUrl = array('MainSite' => 'AjaxPhotoCropped');
|
|
if (isset($param['id'])) {
|
|
$cutUrl['id'] = $param['id'];
|
|
}
|
|
$this->smarty->assign('cutUrl', $cutUrl);
|
|
$this->smarty->assign('uploadUrl', array('MainSite' => 'AjaxPhotoUpload'));
|
|
}
|
|
|
|
public function AjaxPhotoUploadAction($param) {
|
|
$this->SetAjaxRender();
|
|
|
|
$photoFile = $_FILES['photo']['tmp_name'];
|
|
|
|
$photoSize = getimagesize($photoFile);
|
|
|
|
if ($photoSize[0] < self::PHOTO_WIDTH ) {
|
|
$error = 'raz';
|
|
} else if($photoSize[1] < self::PHOTO_HEIGHT ) {
|
|
$error = 'dwa';
|
|
} else if (filesize($photoFile) > self::MAX_AVATAR_FILE_SIZE*1048576) {
|
|
$error = 'trzy';
|
|
}
|
|
|
|
if (!MimeType::IsImage($_FILES['photo'])) {
|
|
$error = 'cztery';
|
|
}
|
|
|
|
if (isset($error)) {
|
|
$this->smarty->assign('error', $error);
|
|
} else {
|
|
|
|
$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['photo'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR , $photoWidth, $photoHeight, 100);
|
|
|
|
$this->smarty->assign('page2load', Router::GenerateUrl(array('MainSite' => 'AjaxPhotoCropper')));
|
|
$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'));
|
|
}
|
|
}
|
|
|
|
public function AjaxPhotoCroppedAction($param) {
|
|
$this->SetAjaxRender();
|
|
|
|
$x = Request::Get('x');
|
|
$y = Request::Get('y');
|
|
$w = Request::Get('w');
|
|
$h = Request::Get('h');
|
|
|
|
$photoFile = Request::Get('photoFileName');
|
|
$destName = md5('photo' . time());
|
|
|
|
$destDir = self::AVATAR_DEST_DIR;
|
|
|
|
$photo = PhotoDAL::SaveTempFile($photoFile, $destName, $destDir, $x, $y, $w, $h, self::PHOTO_WIDTH , self::PHOTO_HEIGHT);
|
|
|
|
$objPhoto = new Picture();
|
|
$objPhoto->SetLink($photo);
|
|
|
|
$idPhoto = PictureDAL::Insert($objPhoto);
|
|
|
|
if (isset($param['id'])) {
|
|
$articleObj = SimpleArticle_MfArticleDAL::GetById($param['id']);
|
|
|
|
$articleObj->SetIdPicture($idPhoto);
|
|
|
|
SimpleArticle_MfArticleDAL::Save($articleObj);
|
|
} else {
|
|
SessionProxy::SetValue(self::PHOTO_SESSION_ID, $idPhoto);
|
|
}
|
|
|
|
$this->smarty->assign('photoPath', 'Article/' . $photo);
|
|
}
|
|
|
|
public function SaveInSessionAction($param) {
|
|
$this->SetAjaxRender();
|
|
SessionProxy::SetValue('radioChecked', $param['id']);
|
|
}
|
|
|
|
/**
|
|
* metoda wywolywana przed metoda
|
|
*
|
|
*/
|
|
public function PreDispatch($param) {
|
|
|
|
$this->smarty->assign("search", null);
|
|
$this->smarty->assign("pageCount",0);
|
|
$this->smarty->assign("currPage",1);
|
|
|
|
$this->smarty->assign("menuSelected", "");
|
|
$this->Run($param);
|
|
SessionProxy::SetValue('AtricleType', 5);
|
|
if($this->IsUser()==false) {
|
|
$this->AddRedirect(URL_MAIN.'/Login.frmx', 0);
|
|
}
|
|
$this->RunShared('Structure');
|
|
$this->AddScript("prototype.js");
|
|
$this->AddScript('Dosia.js');
|
|
$this->AddScript('lightbox.js');
|
|
$this->AddScript('dropDown.js');
|
|
$this->AddScript('drag-drop-folder-tree.js');
|
|
$this->AddScript('calendar.js');
|
|
|
|
$this->AddScript('scriptaculous.js');
|
|
$this->AddScript('structure.js');
|
|
$this->AddScript('Link.js');
|
|
$arrayModuleName = MfModuleDAL::GetArrayModuleName();
|
|
$this->smarty->assign( 'arrayModuleName' ,$arrayModuleName);
|
|
$this->smarty->assign('showIcon', true);
|
|
|
|
}
|
|
|
|
/**
|
|
* metoda wywolywana po metodzie
|
|
*
|
|
*/
|
|
public function PostDispatch($param) {
|
|
|
|
}
|
|
}
|
|
?>
|