smarty->assign('serwis', 1); switch ($param['lang']) { case 'pl': $id = 1000; break; case 'en': $id = 10; break; case 'ru': $id = 11; break; } //$id = 9; $param['runSharedVariable'] = 'editStructure'; $param['homeTemplate'] = 'true'; $param['idArticle'] = $id; //Utils::ArrayDisplay($param); $this->RunModuleController('SimpleArticle_IndexController', 'Edit', $param, true); $struct = array( 'Teksty' => array('Structure' => 'Home'), //'Menu' => array('HomeSite' => 'Links'), 'Baner' => array('HomeSite' => 'Baner'), //'Role' => array('Acl' => 'Index'), //'Uprawnienia' => array('Acl' => 'Rules'), //'Zmienne serwisu' => array('Setup' => 'Index') ); $this->smarty->assign('showIcon', false); $this->smarty->assign('titleAdmin', 'Strona główna'); $this->smarty->assign('structure', $this->renderStruct($struct)); } public function UpdateTreeAction($param) { $this->SetAjaxRender(); $post = Request::GetAllPost(); //Utils::ArrayDisplay($post); if (isset($post['data'])) { $data = $post['data']; $dataArray = explode(',', $data); $previousParent = null; $orderer = array(); foreach ($dataArray as $data) { $data = str_replace('node', '', $data); } //Utils::ArrayDisplay($data); foreach ($dataArray as $dataItem) { $dataItemArray = explode('-', $dataItem); $structureObj = StructureDAL::GetById($dataItemArray[0]); if (isset($orderer[$dataItemArray[1]])) { $orderer[$dataItemArray[1]] = $orderer[$dataItemArray[1]] + 1; } else { $orderer[$dataItemArray[1]] = 0; } $structureObj->SetSort($orderer[$dataItemArray[1]]); $previousParent = $dataItemArray[1]; //echo $orderer[$dataItemArray[1]].":".$previousParent." "; $structureObj->SetIdParent($dataItemArray[1]); if ($dataItemArray[1] != 0) { $structureObjParent = StructureDAL::GetById($dataItemArray[1]); if ($structureObj->GetId() == $structureObjParent->GetIdParent()) { //Utils::ArrayDisplay('tu jestem'); $structureObj->SetIdMain($structureObjParent->GetId()); } else { $structureObj->SetIdMain($structureObjParent->GetIdParent()); } } //Utils::ArrayDisplay($structureObj); //Utils::ArrayDisplay($dataItem); StructureDAL::Save($structureObj); } } } /** * * @param type $param * TODO: Do optymalizacji. */ public function AddAction($param) { $this->AddScript('dropDown.js'); //Utils::ArrayDisplay($param); //Utils::ArrayDisplay($_POST); $post = Request::GetAllPost(); $idParentStructure = 0; //Utils::ArrayDisplay($_POST); if (SessionProxy::GetValue('idParentStructure')) { $idParentStructure = SessionProxy::GetValue('idParentStructure'); } if (isset($post['moduleCategoryId'])) { $idCategory = $post['moduleCategoryId']; } else { $idCategory = 1; } SessionProxy::SetValue('idCategory', $idCategory); $objMetaTag = new MfMetaTag(); $objMetaTag->SetDescriptionObj(MfMetaTagDescriptionDAL::GetEmptyObj()); if (SessionProxy::GetValue('idStructure')) { $idParentStructure = SessionProxy::GetValue('idStructure'); SessionProxy::SetValue('idParentStructure', $idParentStructure); } SessionProxy::ClearValue('idStructure'); SessionProxy::ClearValue('router'); $lang = SessionProxy::GetValue('lang'); $id = -1; $objElement = new Structure($id); $objElement->SetName(Request::GetPost('elementName')); $objElement->SetElementName(Request::GetPost('elementName')); //Utils::ArrayDisplay(SessionProxy::GetValue('idStructure')); if (Request::GetPost('idModule')) { SessionProxy::ClearValue('idContent'); $objModule = MfModuleDAL::GetById($post['idModule']); SessionProxy::SetValue('objModule', $objModule); } else { $objModule = SessionProxy::GetValue('objModule'); } $this->smarty->assign('objModule', $objModule); if (Request::GetPost('moduleCategoryId')) { $idCategory = Request::GetPost('moduleCategoryId'); SessionProxy::SetValue('idCategory', $idCategory); // } elseif (SessionProxy::IsSetValue('idCategory')) { // $idCategory = SessionProxy::GetValue('idCategory'); } else { $idCategory = 1; SessionProxy::SetValue('idCategory', $idCategory); } $idCategory = $idCategory ? $idCategory : 1; $this->smarty->assign('idCategory', $idCategory); //Utils::ArrayDisplay($_POST); //Utils::ArrayDisplay($objModule); //Utils::ArrayDisplay($idCategory); //$class = $objModule->GetClassModuleName(); //$descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); //$catalog = $objModule->GetCatalog(); //$options = unserialize($objModule->GetOptions()); //$defaultUrl = isset($options['defaultUrl']) ? $options['defaultUrl'] : 'artykul'; //Utils::ArrayDisplay($_POST); //Utils::ArrayDisplay($objModule); $methodAdmin = $objModule->GetMethodAdminName(); //== if ($methodAdmin && $methodAdmin != 'null') { $methodAdmin = $methodAdmin == 'Index' ? $methodAdmin : 'Add'; //Utils::ArrayDisplay($methodAdmin); $param['runSharedVariable'] = 'editStructure'; $this->RunModuleController($controller, $methodAdmin . 'Structure', $param, true); } // if ($idCategory == 9 || $idCategory == 8 || $idCategory == 3) { // // $param['runSharedVariable'] = 'editStructureProject'; // $param['text'] = true; // $this->RunModuleController( $controller, 'AddStructure', $param, true); // } //} //Utils::ArrayDisplay($param); // Utils::ArrayDisplay(SessionProxy::GetValue('idCategory'), __LINE__); //Utils::ArrayDisplay($idCategory, __LINE__); if (Request::GetPost('AddStructureForm')) { $out = array(); $validator = new Validator(Request::GetAllPost()); $data = Request::GetAllPost(); $validator->IsEmpty('title', 'To pole nie może być puste'); //$validator -> IsEmpty('datepublication','To pole nie może być puste'); $param['submitForm'] = 'walidacja'; $out = $validator->GetErrorList(); if ($method != 'Index') { } $publication = Request::Get('publication'); $publicationMenu = Request::Get('publication_menu'); $publication ? $publication = 1 : $publication = '0'; $publicationMenu ? $publicationMenu = 1 : $publicationMenu = '0'; //------ //=Making URL'a=============================== //Utils::ArrayDisplay($post); if ($objModule->GetList() == 1) { $arrayModuleOptions = $objModule->GetArrayOptions(); $post['url'] = $arrayModuleOptions['defaultUrl']; } $url = Request::GetPost('url'); $url = Utils::ClearString($url); $url = Utils::cleanUrl($url); $url = substr($url, 0, 30); $id = $post['id']; if ($url) { //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } else { $url = Utils::ClearString($post['title']); $url = Utils::cleanUrl($url); //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } // if ($objModule->GetList() == 1) { // $arrayModuleOptions = $objModule->GetArrayOptions(); // $matchUri = $arrayModuleOptions['defaultUrl']; // $labelUrl = $objModule->GetModuleTitle() . 'Label'; // $url = $arrayModuleOptions['defaultUrl']; // $labelUrlDetail = $objModule->GetModuleTitle() . 'LabelDetail'; // $matchUriList = $arrayModuleOptions['defaultUrl'] . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; // $matchUri = $arrayModuleOptions['defaultUrl'] . STRONA_APPLICATION_FILE_TYPE; // $matchUriPage = $arrayModuleOptions['defaultUrl'] . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; // $labelUrl = $objModule->GetModuleTitle() . 'Label'; // $labelUrlPage = $objModule->GetModuleTitle() . 'LabelPage'; // $labelUrlDetail = $objModule->GetModuleTitle() . 'LabelDetail'; // } // if ($idCategory == 2) { // $arrayModuleOptions = $objModule->GetArrayOptions(); // $matchUri = 'news'; // $labelUrl = 'newsLabel'; // $url = 'news'; // $labelUrlDetail = 'newsLabelDetail'; // $matchUriList = 'news'.STRONA_URL_DELIMITER."id".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.":title"; // $matchUri = 'news'.STRONA_APPLICATION_FILE_TYPE; // $matchUriPage = 'news'.STRONA_URL_DELIMITER.":p".STRONA_APPLICATION_FILE_TYPE; // $labelUrl = 'newsLabel'; // $labelUrlPage = 'newsLabelPage'; // $labelUrlDetail = 'newsLabelDetail'; // } //Utils::ArrayDisplay(SessionProxy::GetValue('idCategory'), __LINE__); //Utils::ArrayDisplay($idCategory, __LINE__); $paramArray = array(); if ($method == 'Index') { //Making ListEleement $idCategory = SessionProxy::GetValue('idCategory'); $idContent = '0'; if (SessionProxy::IsSetValue('idContent')) { $idContent = SessionProxy::GetValue('idContent'); } //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['urlDetail'] = $matchUriList; $paramArray['urlDetailLabel'] = $labelUrlDetail; $paramArray['paged'] = true; //============================== } else { //Making content element $idCategory = SessionProxy::GetValue('idCategory'); $idContent = SessionProxy::GetValue('idContent'); //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; } //TODO: dorobić możliwość definiowana boxów $actionSet = array(); // Utils::ArrayDisplay(SessionProxy::GetValue('idCategory'), __LINE__); //Utils::ArrayDisplay($idCategory, __LINE__); $router = new MfRouter(); $router->SetController($controller); $router->SetMethod($method); $router->SetUrl($matchUri); $router->SetLabelUrl($labelUrl); $router->SetParam(serialize($paramArray)); $router->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $router->SetIdMfModule($objModule->GetId()); $router->SetLang($lang); $router->SetLocation($post['location']); if ($method == 'Index') { $objRouterDetail = new MfRouter(); $objRouterDetail->SetController($controller); $objRouterDetail->SetMethod('View'); $objRouterDetail->SetUrl($matchUriList); $objRouterDetail->SetParam(serialize($paramArray)); $objRouterDetail->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterDetail->SetIdMfModule($objModule->GetId()); $objRouterDetail->SetLabelUrl($labelUrlDetail); $objRouterDetail->SetLang($lang); $objRouterDetail->SetLocation($post['location']); $objRouterPage = new MfRouter(); $objRouterPage->SetController($controller); $objRouterPage->SetMethod($method); $objRouterPage->SetUrl($matchUriPage); $objRouterPage->SetLabelUrl($labelUrlPage); $objRouterPage->SetParam(serialize($paramArray)); $objRouterPage->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterPage->SetIdMfModule($objModule->GetId()); $objRouterPage->SetLang($lang); $objRouterPage->SetLocation($post['location']); } //==zapis struktuy============================================== $objElement = new Structure($id, $idContent, $idParentStructure, $post['idMain'], '', $lang, $post['sort'], $publication, $post['title'], ($post['menuName'] == '' ? $post['title'] : $post['menuName']), $url); $objElement->SetPublicationMenu($publicationMenu); $objElement->SetType($post['type']); $objElement->SetUrlLabel($labelUrl); //$objElement->SetBanner($post['photo']); $objElement->SetBanner(''); $objElement->SetSort(100); $objElement->SetIdParent($idParentStructure); $objElement->SetSubname($post['subname']); $objElement->SetElementName($post['elementName']); $objElement->SetCopy(0); $objElement->SetLocation($post['location']); //==zapis=META TAG========================================= $objMetaTag = new MfMetaTag(); $objMetaTag->SetSourceType('mf_structure'); $objMetaTagDescription = new MfMetaTagDescription(); if (!$post['meta_keywords']) { if (isset($post['description'])) { $metaKeywords = Utils::Truncate(strip_tags($post['description']), 150); $metaKeywords = str_replace(' ', ', ', $metaKeywords); $objMetaTagDescription->SetKeywords($metaKeywords); } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } if (!$post['meta_description']) { if (isset($post['description'])) { $metaDescription = Utils::Truncate(strip_tags($post['description']), 150); $objMetaTagDescription->SetDescription($metaDescription); } else { $objMetaTagDescription->SetDescription($post['meta_description']); } } else { $objMetaTagDescription->SetDescription($post['meta_description']); } $objMetaTagDescription->SetStatistic($post['statistic']); $objMetaTagDescription->SetLang($lang); $objMetaTag->SetDescriptionObj($objMetaTagDescription); //Utils::ArrayDisplay($router, __LINE__); //Utils::ArrayDisplay($out); if (empty($out)) { //TODO: Dorobić dodnie banera bezpośrednio z forma bez Iframe if (isset($_FILES['baner'])) { //--Kopiowanie banerra-------------------------------------------------- if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure)) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure); } //Utils::ArrayDisplay(PATH_STATIC_CONTENT."/temp/".$idStage."/".$Stage->GetPicture()); if (file_exists(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner())) { rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBanner()); rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBannerTh(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBannerTh()); } } //=obrazki na listę============================================================================================================================================================ if (isset($_FILES['filename']) && $_FILES['filename']['tmp_name']) { $photoSize = getimagesize($_FILES['filename']['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['filename'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR, $photoWidth, $photoHeight, 100); $destName = md5('photo' . microtime()); if (file_exists(PATH_STATIC_CONTENT . 'upload/Structure/' . $destName . '.jpg')) unlink(PATH_STATIC_CONTENT . 'upload/Structure/' . $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/Structure', 0, 0, $photoWidth, $photoHeight, self::IMAGE_NORMAL_WIDTH, $photoWidth / $prop); $objPhoto = new Picture(); $objPhoto->SetLink($photo); $objPhoto->SetWeight(1); $objPhoto->SetPublication(1); $idPhoto = PictureDAL::Insert($objPhoto); $objElement->SetIdPicture($idPhoto); } if (isset($_FILES['filename2']) && $_FILES['filename2']['tmp_name']) { $photoSize = getimagesize($_FILES['filename2']['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['filename2'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR, $photoWidth, $photoHeight, 100); $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/Structure', 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); $objElement->SetIdPictureMini($idPhoto); } //=============================================================================================================================================================== $db = Registry::Get('db'); $db->BeginTransaction(); try { //Router if (isset($objRouterDetail)) { $idRouterDetail = MfRouterDAL::Save($objRouterDetail); $idRouterPage = MfRouterDAL::Save($objRouterPage); $objElement->SetIdRouterDetail($idRouterDetail); $objElement->SetIdRouterPage($idRouterPage); } else { $objElement->SetIdRouterDetail(0); $objElement->SetIdRouterPage(0); $idRouterDetail = 0; $idRouterPage = 0; } $idRouter = MfRouterDAL::Save($router); //Utils::ArrayDisplay($objRouterPage, __LINE__); //Structure $objElement->SetIdRouter($idRouter); $idStructure = StructureDAL::Save($objElement); SessionProxy::SetValue('idStructure', $idStructure); //UpdateRouter //$paramSet = "idStructure:".$idStructure; //============================== $paramArray = array(); // $paramText = explode(',', $paramSet); // foreach($paramText as $item) { // $item = explode(':', $item); // if(isset($item[0]) && isset($item[1])) // $paramArray = array($item[0]=>$item[1]); // } $paramArray['idStructure'] = $idStructure; //akktualizcja param MfRouterDAL::UpdateParamPush($idRouter, $paramArray); MfRouterDAL::UpdateParamPush($idRouterDetail, $paramArray); MfRouterDAL::UpdateParamPush($idRouterPage, $paramArray); //MetaTag //Utils::ArrayDisplay($idStructure); $objMetaTag->SetIdSource($idStructure); $idMetaTag = MfMetaTagDAL::Save($objMetaTag); $objMetaTagDescription->SetIdMfMetaTag($idMetaTag); MfMetaTagDescriptionDAL::Save($objMetaTagDescription); //Utils::ArrayDisplay(SessionProxy::GetValue('idContent')); SessionProxy::ClearValue('idCategory'); SessionProxy::ClearValue('idContent'); SessionProxy::ClearValue('objModule'); Router::GenerateDbRoutes(); $db->CommitTransaction(); SessionProxy::ClearValue('idParentStructure'); //$this->AddRedirect(Router::GenerateUrl('editStructure', array('id' => $idStructure)), 0); $this->AddRedirectInfo('Element został zapisany', 'Ok', Router::GenerateUrl('editStructure', array('id' => $idStructure))); } catch (Exception $e) { //Utils::ArrayDisplay($e); $db->Rollback(); } } 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); } } // } $idContent = -1; // $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', $lang, $tableModuleName, $idContent, ' AND id_' . $objModule->GetTableModuleName() . '_category NOT IN (1) '); // $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); // // if ($method == 'Index') { // $this->smarty->assign('arrayObj', $arrayObj); // $this->smarty->assign('idElement', $objElement->GetId()); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureList.tpl'); // } else { // $this->smarty->assign('obj', $obj); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureEdit.tpl'); // } $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('idCategoryChecked', $idCategory); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('method', $method); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('module', $module); $this->smarty->assign('arrayCategory', $arrayCategory); $this->smarty->assign('idContent', $idContent); $this->smarty->assign('idCategory', $idCategory); $this->partialTemplate = 'Add.tpl'; //Utils::ArrayDisplay($idCategory); } /** * * @param type $param * TODO: Do optymalizacji. */ public function ModernAddAction($param) { $this->AddScript('dropDown.js'); //Utils::ArrayDisplay($param); //Utils::ArrayDisplay($_POST); $actionSet = array(); $post = Request::GetAllPost(); $idParentStructure = 0; //Utils::ArrayDisplay($_POST); if (SessionProxy::GetValue('idParentStructure')) { $idParentStructure = SessionProxy::GetValue('idParentStructure'); } if (isset($post['idCategory'])) { $idCategory = $post['idCategory']; } else { $idCategory = 1; } //$idCategoryMode = SessionProxy::GetValue('idCategory'); $objMetaTag = new MfMetaTag(); $objMetaTag->SetDescriptionObj(MfMetaTagDescriptionDAL::GetEmptyObj()); if (SessionProxy::GetValue('idStructure')) { $idParentStructure = SessionProxy::GetValue('idStructure'); SessionProxy::SetValue('idParentStructure', $idParentStructure); } SessionProxy::ClearValue('idStructure'); SessionProxy::ClearValue('router'); $lang = SessionProxy::GetValue('lang'); $id = -1; $objElement = new Structure($id); $objElement->SetName(Request::GetPost('elementName')); $objElement->SetElementName(Request::GetPost('elementName')); //Utils::ArrayDisplay($_SESSION); SessionProxy::ClearValue('idContent'); $objModule = MfModuleDAL::GetById(1); SessionProxy::SetValue('objModule', $objModule); $this->smarty->assign('objModule', $objModule); if (Request::GetPost('idCategory')) { $idCategory = Request::GetPost('idCategory'); SessionProxy::SetValue('idCategory', $idCategory); // } elseif (SessionProxy::IsSetValue('idCategory')) { // $idCategory = SessionProxy::GetValue('idCategory'); } else { $idCategory = 1; SessionProxy::SetValue('idCategory', $idCategory); } //Utils::ArrayDisplay($idCategory); $idCategory = $idCategory ? $idCategory : 1; $this->smarty->assign('idCategory', $idCategory); //Utils::ArrayDisplay($_POST); //Utils::ArrayDisplay($objModule); //Utils::ArrayDisplay($idCategory); //$class = $objModule->GetClassModuleName(); //$descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); //$catalog = $objModule->GetCatalog(); //$options = unserialize($objModule->GetOptions()); //$defaultUrl = isset($options['defaultUrl']) ? $options['defaultUrl'] : 'artykul'; //Utils::ArrayDisplay($_POST); //Utils::ArrayDisplay($objModule); $methodAdmin = $objModule->GetMethodAdminName(); //Utils::ArrayDisplay($objModule); //==Moduł=Podstawowy================================================ if ($methodAdmin && $methodAdmin != 'null') { $methodAdmin = $methodAdmin == 'Index' ? $methodAdmin : 'Add'; //Utils::ArrayDisplay($methodAdmin); $param['runSharedVariable'] = 'editStructure'; $this->RunModuleController($controller, 'AddStructure', $param, true); } //-----Moduł-Podstawowy-KONIEC-------------------------------------------------------------------------------------------- //====Moduły=actionSet================================================================================================== /** * Pobieranie z posta i generowanie okienek modułowych * TODO: Poprawić Kategorie * */ if (isset($post['addModuleController'])) { if (is_array($post['addModuleController'])) { foreach ($post['addModuleController'] as $addModulekey => $addModuleValue) { $objModuleAdd = MfModuleDAL::GetById($post['addModuleId'][$addModulekey]); $arrayModuleCategory = Utils::GetArrayList($objModuleAdd->GetTableModuleName() . '_category_description', 'id_' . $objModuleAdd->GetTableModuleName() . '_category', 'name', $lang, ''); $post['addModuleMetodAdmin'][$addModulekey] = $post['addModuleMetodAdmin'][$addModulekey] == 'Edit' ? 'Add' : $post['addModuleMetod'][$addModulekey]; $param['runSharedVariable'] = 'addModule_'.$addModulekey; $param['moduleName'] = $post['addModuleName'][$addModulekey]; if (isset($arrayModuleCategory[$post['addModuleCategoryId'][$addModulekey]])) { $param['moduleName'] .= " - ".$arrayModuleCategory[$post['addModuleCategoryId'][$addModulekey]]; } $addModuleSharedVariableArray[] = 'addModule_'.$addModulekey; $this->RunModuleController($addModuleValue, $post['addModuleMetodAdmin'][$addModulekey].'Structure', $param, true); $actionSet[] = array( 'moduleId' => $post['addModuleId'][$addModulekey], 'moduleName' => $post['addModuleName'][$addModulekey], 'moduleController' =>$addModuleValue, 'moduleMetod' =>$post['addModuleMetod'][$addModulekey], 'moduleMetodAdmin' => $post['addModuleMetodAdmin'][$addModulekey], 'moduleCategoryId' => $post['addModuleCategoryId'][$addModulekey], 'moduleElementId' => $post['moduleElementId'][$addModulekey], 'modulePublication' => $post['addModulePublication'][$addModulekey], 'runSharedVariable' => $param['runSharedVariable'] ); } $this->smarty->assign('addModuleSharedVariableArray', $addModuleSharedVariableArray); $this->smarty->assign('actionSetModule', $actionSet); //Utils::ArrayDisplay($actionSet); } } //-----Moduły-actionSet-KONIEC-------------------------------------------------------------------------------------------- //Utils::ArrayDisplay($param); if (Request::GetPost('AddStructureForm')) { $validator = new Validator(Request::GetAllPost()); $validator->IsEmpty('title', 'To pole nie może być puste'); //$validator -> IsEmpty('datepublication','To pole nie może być puste'); $param['submitForm'] = 'walidacja'; $out = $validator->GetErrorList(); $publication = Request::Get('publication'); $publicationMenu = Request::Get('publication_menu'); $publication ? $publication = 1 : $publication = '0'; $publicationMenu ? $publicationMenu = 1 : $publicationMenu = '0'; //------ //=Making URL'a=============================== /* * TODO: Przygotować metodę dogeneracji url'ów */ //Utils::ArrayDisplay($post); if ($objModule->GetList() == 1) { $arrayModuleOptions = $objModule->GetArrayOptions(); $post['url'] = $arrayModuleOptions['defaultUrl']; } $url = Request::GetPost('url'); $url = Utils::ClearString($url); $url = Utils::cleanUrl($url); $url = substr($url, 0, 30); $id = $post['id']; if ($url) { //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } else { $url = Utils::ClearString($post['title']); $url = Utils::cleanUrl($url); //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } $paramArray = array(); // if ($method == 'Index') { //Making ListEleement $idCategory = SessionProxy::GetValue('idCategory'); $idContent = '0'; if (SessionProxy::IsSetValue('idContent')) { $idContent = SessionProxy::GetValue('idContent'); } //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['urlDetail'] = $matchUriList; $paramArray['urlDetailLabel'] = $labelUrlDetail; $paramArray['paged'] = true; //============================== // } else { //Making content element // $idCategory = SessionProxy::GetValue('idCategory'); // $idContent = SessionProxy::GetValue('idContent'); // //====== parametry potrzebne do wywołania treści // $paramArray['id'] = $idContent; // $paramArray['idCategory'] = $idCategory; // $paramArray['urlDetail'] = $matchUriList; // $paramArray['urlDetailLabel'] = $labelUrlDetail; // $paramArray['paged'] = true; // } //Utils::ArrayDisplay($paramArray); $router = new MfRouter(); $router->SetController($controller); $router->SetMethod($method); $router->SetUrl($matchUri); $router->SetLabelUrl($labelUrl); $router->SetName('normal'); $router->SetParam(serialize($paramArray)); $router->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $router->SetIdMfModule($objModule->GetId()); $router->SetLang($lang); $router->SetLocation($post['location']); //if ($method == 'Index') { $objRouterDetail = new MfRouter(); $objRouterDetail->SetController($controller); $objRouterDetail->SetMethod('View'); $objRouterDetail->SetUrl($matchUriList); $objRouterDetail->SetParam(serialize($paramArray)); $objRouterDetail->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterDetail->SetIdMfModule($objModule->GetId()); $objRouterDetail->SetLabelUrl($labelUrlDetail); $objRouterDetail->SetName('detail'); $objRouterDetail->SetLang($lang); $objRouterDetail->SetLocation($post['location']); $objRouterPage = new MfRouter(); $objRouterPage->SetController($controller); $objRouterPage->SetMethod($method); $objRouterPage->SetUrl($matchUriPage); $objRouterPage->SetLabelUrl($labelUrlPage); $objRouterPage->SetName('page'); $objRouterPage->SetParam(serialize($paramArray)); $objRouterPage->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterPage->SetIdMfModule($objModule->GetId()); $objRouterPage->SetLang($lang); $objRouterPage->SetLocation($post['location']); //} //==zapis struktuy============================================== $objElement = new Structure($id, $idContent, $idParentStructure, $post['idMain'], '', $lang, $post['sort'], $publication, $post['title'], ($post['menuName'] == '' ? $post['title'] : $post['menuName']), $url); $objElement->SetPublicationMenu($publicationMenu); $objElement->SetType($post['type']); $objElement->SetUrlLabel($labelUrl); //$objElement->SetBanner($post['photo']); $objElement->SetBanner(''); $objElement->SetSort(100); $objElement->SetIdParent($idParentStructure); $objElement->SetSubname($post['subname']); $objElement->SetElementName($post['elementName']); $objElement->SetCopy(0); $objElement->SetLocation($post['location']); //==zapis=META TAG========================================= $objMetaTag = new MfMetaTag(); $objMetaTag->SetSourceType('mf_structure'); $objMetaTagDescription = new MfMetaTagDescription(); if (!$post['meta_keywords']) { if (isset($post['description'])) { $metaKeywords = Utils::Truncate(strip_tags($post['description']), 150); $metaKeywords = str_replace(' ', ', ', $metaKeywords); $objMetaTagDescription->SetKeywords($metaKeywords); } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } if (!$post['meta_description']) { if (isset($post['description'])) { $metaDescription = Utils::Truncate(strip_tags($post['description']), 150); $objMetaTagDescription->SetDescription($metaDescription); } else { $objMetaTagDescription->SetDescription($post['meta_description']); } } else { $objMetaTagDescription->SetDescription($post['meta_description']); } //$objMetaTagDescription->SetStatistic($post['statistic']); $objMetaTagDescription->SetLang($lang); $objMetaTag->SetDescriptionObj($objMetaTagDescription); //Utils::ArrayDisplay($out); if (empty($out)) { $db = Registry::Get('db'); $db->BeginTransaction(); try { //Router if (isset($objRouterDetail)) { $idRouterDetail = MfRouterDAL::Save($objRouterDetail); $idRouterPage = MfRouterDAL::Save($objRouterPage); $objElement->SetIdRouterDetail($idRouterDetail); $objElement->SetIdRouterPage($idRouterPage); } else { $objElement->SetIdRouterDetail(0); $objElement->SetIdRouterPage(0); $idRouterDetail = 0; $idRouterPage = 0; } $idRouter = MfRouterDAL::Save($router); //Structure $objElement->SetIdRouter($idRouter); $idStructure = StructureDAL::Save($objElement); SessionProxy::SetValue('idStructure', $idStructure); //UpdateRouter //$paramSet = "idStructure:".$idStructure; //============================== $paramArray = array(); $paramArray['idStructure'] = $idStructure; //akktualizcja param MfRouterDAL::UpdateParamPush($idRouter, $paramArray); MfRouterDAL::UpdateParamPush($idRouterDetail, $paramArray); MfRouterDAL::UpdateParamPush($idRouterPage, $paramArray); //MetaTag //Utils::ArrayDisplay($idStructure); $objMetaTag->SetIdSource($idStructure); $idMetaTag = MfMetaTagDAL::Save($objMetaTag); $objMetaTagDescription->SetIdMfMetaTag($idMetaTag); MfMetaTagDescriptionDAL::Save($objMetaTagDescription); SessionProxy::ClearValue('idCategory'); SessionProxy::ClearValue('idContent'); SessionProxy::ClearValue('objModule'); Router::GenerateDbRoutes(); $db->CommitTransaction(); SessionProxy::ClearValue('idParentStructure'); //$this->AddRedirect(Router::GenerateUrl('editStructure', array('id' => $idStructure)), 0); $this->AddRedirectInfo('Element został zapisany', 'Ok', Router::GenerateUrl('editStructure', array('id' => $idStructure))); } catch (Exception $e) { //Utils::ArrayDisplay($e); $db->Rollback(); } } 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); } } // } $idContent = -1; // $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', $lang, $tableModuleName, $idContent, ' AND id_' . $objModule->GetTableModuleName() . '_category NOT IN (1) '); // $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('idCategoryChecked', $idCategory); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('method', $method); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('module', $module); $this->smarty->assign('arrayCategory', $arrayCategory); $this->smarty->assign('idContent', $idContent); $this->smarty->assign('idCategory', $idCategory); $this->partialTemplate = 'ModernAdd.tpl'; //Utils::ArrayDisplay($idCategory); } /** * * @param type $param * TODO: WOW 346 lini!!! zoptymalizować. */ public function ModernEditAction($param) { //Utils::ArrayDisplay($param, "param: ".__FILE__.' - '.__LINE__); //Utils::ArrayDisplay($_SESSION, "session: ".__FILE__.' - '.__LINE__); //SessionProxy::ClearSession(); if (Request::GetPost('idCategorySelected')) { SessionProxy::setValue('idCategorySelected', Request::GetPost('idCategorySelected')); } $this->AddScript('dropDown.js'); $lang = SessionProxy::GetValue('lang'); $idCategory = SessionProxy::GetValue('idCategory'); $arrayStructurePl = Utils::GetArrayList('mf_structure', 'id_mf_structure', 'name', 'pl', '', 'name'); //Utils::ArrayDisplay($arrayStructure); $this->smarty->assign('arrayStructurePl', $arrayStructurePl); SessionProxy::ClearValue('objModule'); SessionProxy::ClearValue('idCategory'); $router = new MfRouter; if (isset($param['id']) && is_numeric($param['id'])) { $id = $param['id']; try { $objElement = StructureDAL::GetById($id); if (is_object($objElement)) { //Utils::ArrayDisplay($objElement->GetPicture()); $router = MfRouterDAL::GetById($objElement->GetIdRouter()); $unserializedParam = unserialize($router->GetParam()); } else { Utils::Redirect(Router::GenerateUrl('Index', array())); $this->AddRedirect(Router::GenerateUrl('Index', array()), 0); } } catch (Exception $e) { //Utils::ArrayDisplay($e); Utils::Redirect(Router::GenerateUrl('Index', array())); $this->AddRedirect(Router::GenerateUrl('Index', array()), 0); } ///Utils::ArrayDisplay($ueue); //Utils::ArrayDisplay($router); $this->smarty->assign('idElement', $id); SessionProxy::SetValue('idStructure', $id); SessionProxy::SetValue('idContent', $objElement->GetIdContent()); } else { Utils::Redirect(Router::GenerateUrl('Index', array())); $this->AddRedirect(Router::GenerateUrl('Index', array()), 0); } if ($lang != 'pl') { $slectedLang = LinkLangDAL::GetSelected($id, $lang); $this->smarty->assign('slectedLang', $slectedLang); } else { $this->smarty->assign('slectedLang', 0); } $idContent = SessionProxy::GetValue('idContent'); $objModule = MfModuleDAL::GetById($router->GetIdMfModule()); SessionProxy::SetValue('objModule', $objModule); $this->smarty->assign('objModule', $objModule); $post = Request::GetAllPost(); //Utils::ArrayDisplay($post, __FILE__.' - '.__LINE__); $class = $objModule->GetClassModuleName(); $descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); $catalog = $objModule->GetCatalog(); $options = unserialize($objModule->GetOptions()); if (isset($unserializedParam['idCategory'])) { $idCategory = $unserializedParam['idCategory']; SessionProxy::SetValue('idCategory', $idCategory); } $methodAdmin = $objModule->GetMethodAdminName(); if ($methodAdmin && $methodAdmin != 'null') { $methodAdmin = $methodAdmin == 'Index' ? $methodAdmin : 'Add'; $param['runSharedVariable'] = 'editStructure'; $this->RunModuleController($controller, 'EditStructure', $param, true); } //-----Moduł-Podstawowy-KONIEC-------------------------------------------------------------------------------------------- //====Moduły=actionSet================================================================================================== /** * Pobieranie bazy i generowanie okienek modułowych * TODO: Poprawić Kategorie - edycja kategorii * */ $config = unserialize($router->GetConfig()); //Utils::ArrayDisplay($config['actionSet']); $actionSet = array(); $addModuleSharedVariableArray = array(); if (isset($config['actionSet'])) { if (is_array($config['actionSet'])) { foreach ($config['actionSet'] as $addModulekey => $addModuleValue) { //Utils::ArrayDisplay($addModulekey); $objModuleAdd = MfModuleDAL::GetById($addModuleValue['moduleId']); $arrayModuleCategory = Utils::GetArrayList($objModuleAdd->GetTableModuleName() . '_category_description', 'id_' . $objModuleAdd->GetTableModuleName() . '_category', 'name', $lang, ''); // $addModuleValue['moduleMetodAdmin'] = $addModuleValue['moduleMetodAdmin'] == 'Edit' ? 'Add' : $addModuleValue['moduleMetod']; $param['runSharedVariable'] = 'addedModule_'.$addModulekey; $param['addedModule_'.$addModulekey]['moduleElementId'] = $addModuleValue['moduleElementId']; $param['newModule'] = 0; $param['moduleName'] = $addModuleValue['moduleName']; if (isset($arrayModuleCategory[$addModuleValue['moduleCategoryId']])) { $param['moduleName'] .= " - ".$arrayModuleCategory[$addModuleValue['moduleCategoryId']]; } $param['moduleCategoryIdTmp'] = $addModuleValue['moduleCategoryId']; $param['modulePublication'] = $addModuleValue['modulePublication']; $addModuleSharedVariableArray[] = 'addedModule_'.$addModulekey; $this->RunModuleController($addModuleValue['moduleController'], $addModuleValue['moduleMetodAdmin'].'Structure', $param, true); $actionSet[] = array( 'moduleId' => $addModuleValue['moduleId'], 'moduleName' => $addModuleValue['moduleName'], 'moduleController' =>$addModuleValue['moduleController'], 'moduleMetod' =>$addModuleValue['moduleMetod'], 'moduleMetodAdmin' => $addModuleValue['moduleMetodAdmin'], 'moduleCategoryId' => $addModuleValue['moduleCategoryId'], 'moduleElementId' => $addModuleValue['moduleElementId'], 'modulePublication' => $addModuleValue['modulePublication'], 'runSharedVariable' => $param['runSharedVariable'] ); } $this->smarty->assign('addModuleSharedVariableArray', $addModuleSharedVariableArray); $this->smarty->assign('actionSetModule', $actionSet); //Utils::ArrayDisplay($actionSet); } } /** * Pobieranie z posta i generowanie okienek modułowych * TODO: Poprawić Kategorie - edycja kategorii * */ //Utils::ArrayDisplay($param, "param: ".__FILE__.' - '.__LINE__); //Utils::ArrayDisplay($post, "post: ".__FILE__.' - '.__LINE__); if (isset($post['addModuleController'])) { if (is_array($post['addModuleController'])) { $addModuleSharedVariableArray = array(); $actionSet = array(); //Utils::ArrayDisplay($actionSet, __FILE__.' - '.__LINE__); foreach ($post['addModuleController'] as $addModulekey => $addModuleValue) { $objModuleAdd = MfModuleDAL::GetById($post['addModuleId'][$addModulekey]); $arrayModuleCategory = Utils::GetArrayList($objModuleAdd->GetTableModuleName() . '_category_description', 'id_' . $objModuleAdd->GetTableModuleName() . '_category', 'name', $lang, ''); // $post['addModuleMetodAdmin'][$addModulekey] = $post['addModuleMetodAdmin'][$addModulekey] == 'Edit' ? 'Add' : $post['addModuleMetod'][$addModulekey]; $param['runSharedVariable'] = 'addedModule_'.$addModulekey; $param['newModule'] = $post['addNewModule'][$addModulekey]; //Utils::ArrayDisplay("aaasssa: ".$param['runSharedVariable']); $param['moduleName'] = $post['addModuleName'][$addModulekey]; $param['moduleCategoryIdTmp'] = $post['addModuleCategoryId'][$addModulekey]; if (isset($arrayModuleCategory[$post['addModuleCategoryId'][$addModulekey]])) { $param['moduleName'] .= " - ".$arrayModuleCategory[$post['addModuleCategoryId'][$addModulekey]]; } //Utils::ArrayDisplay($addModulekey, "addModulekey: ".__FILE__.' - '.__LINE__); $addModuleSharedVariableArray[] = 'addModule_'.$addModulekey; $this->RunModuleController($addModuleValue, $post['addModuleMetodAdmin'][$addModulekey].'Structure', $param, true); if ($post['addNewModule'][$addModulekey] == 1) { $moduleElementId = SessionProxy::GetValue('addedModuleElementId'); //Utils::ArrayDisplay($moduleElementId, "nowy moduleElementId: ".__FILE__.' - '.__LINE__); SessionProxy::ClearValue('addedModuleElementId'); } else { $moduleElementId = $post['addModuleElementId'][$addModulekey]; } if (!$post['addModuleDelete'][$addModulekey]) { $actionSet[] = array( 'moduleId' => $post['addModuleId'][$addModulekey], 'moduleName' => $post['addModuleName'][$addModulekey], 'moduleController' =>$addModuleValue, 'moduleMetod' =>$post['addModuleMetod'][$addModulekey], 'moduleMetodAdmin' => $post['addModuleMetodAdmin'][$addModulekey], 'moduleCategoryId' => $post['addModuleCategoryId'][$addModulekey], 'moduleElementId' => $moduleElementId, 'modulePublication' => $post['addModulePublication'][$addModulekey], 'runSharedVariable' => $param['runSharedVariable'] ); } } $this->smarty->assign('addModuleSharedVariableArray', $addModuleSharedVariableArray); $this->smarty->assign('actionSetModule', $actionSet); //Utils::ArrayDisplay($actionSet, 'actionSet: '. __FILE__.' - '.__LINE__); } } //-----Moduły-actionSet-KONIEC-------------------------------------------------------------------------------------------- //--- Dodatkowa treść dla stron z listami - KONIEC------------- $objMetaTag = MfMetaTagDAL::GetByIdSource($id, 'mf_structure', $lang); //Utils::ArrayDisplay($objMetaTag); //Utils::ArrayDisplay($post); if (Request::GetPost('EditStructureForm')) { $validator = new Validator(Request::GetAllPost()); $data = Request::GetAllPost(); $validator->IsEmpty('title', 'To pole nie może być puste'); //$validator -> IsEmpty('datepublication','To pole nie może być puste'); $param['submitForm'] = 'walidacja'; $out = $validator->GetErrorList(); if ($method != 'Index') { } $publication = Request::Get('publication'); $publicationMenu = Request::Get('publication_menu'); $publication ? $publication = 1 : $publication = '0'; $publicationMenu ? $publicationMenu = 1 : $publicationMenu = '0'; //------ //=Making URL'a=============================== $url = Request::GetPost('url'); $url = Utils::ClearString($url); $url = Utils::cleanUrl($url); $url = substr($url, 0, 40); $id = $post['id']; if ($url) { //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.''.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } else { $url = Utils::ClearString($_POST['title']); $url = Utils::cleanUrl($url); //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.''.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } if ($objModule->GetList() == 1) { $arrayModuleOptions = $objModule->GetArrayOptions(); $matchUri = $arrayModuleOptions['defaultUrl']; $url = $arrayModuleOptions['defaultUrl']; $labelUrl = $objModule->GetModuleTitle() . 'Label'; $labelUrlDetail = $objModule->GetModuleTitle() . 'LabelDetail'; $matchUriList = $arrayModuleOptions['defaultUrl'] . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $arrayModuleOptions['defaultUrl'] . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $arrayModuleOptions['defaultUrl'] . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $objModule->GetModuleTitle() . 'Label'; $labelUrlPage = $objModule->GetModuleTitle() . 'LabelPage'; $labelUrlDetail = $objModule->GetModuleTitle() . 'LabelDetail'; } // if ($idCategory == 2) { // $arrayModuleOptions = $objModule->GetArrayOptions(); // $matchUri = 'news'; // $labelUrl = 'newsLabel'; // $url = 'news'; // $labelUrlDetail = 'newsLabelDetail'; // $matchUriList = 'news'.STRONA_URL_DELIMITER."id".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.":title"; // $matchUri = 'news'.STRONA_APPLICATION_FILE_TYPE; // $matchUriPage = 'news'.STRONA_URL_DELIMITER.":p".STRONA_APPLICATION_FILE_TYPE; // $labelUrl = 'newsLabel'; // $labelUrlPage = 'newsLabelPage'; // $labelUrlDetail = 'newsLabelDetail'; // } $paramArray = array(); if ($method == 'Index') { //Making ListEleement $idCategory = SessionProxy::GetValue('idCategory'); $idContent = '0'; if (SessionProxy::IsSetValue('idContent')) { $idContent = SessionProxy::GetValue('idContent'); } //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['urlDetail'] = $matchUriList; $paramArray['urlDetailLabel'] = $labelUrlDetail; $paramArray['idStructure'] = $id; $paramArray['paged'] = true; } else { //Making content element $idCategory = SessionProxy::GetValue('idCategory'); $idContent = SessionProxy::GetValue('idContent'); //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['idStructure'] = $id; } //TODO: dorobić możliwość definiowana boxów //$actionSet = array('FileController,IndexStructure'); //$router = new MfRouter(); $router->SetController($controller); $router->SetMethod($method); $router->SetUrl($matchUri); $router->SetLabelUrl($labelUrl); $router->SetParam(serialize($paramArray)); $router->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $router->SetIdMfModule($objModule->GetId()); $router->SetLabelUrl($labelUrl); $router->SetName('normal'); $router->SetLang($lang); $router->SetLocation($post['location']); $idRouterDetail = $objElement->GetIdRouterDetail(); if ($idRouterDetail == 0) { $objRouterDetail = new MfRouter(); } else { $objRouterDetail = MfRouterDAL::GetById($idRouterDetail); } $objRouterDetail->SetController($controller); $objRouterDetail->SetMethod('View'); $objRouterDetail->SetUrl($matchUriList); $objRouterDetail->SetParam(serialize($paramArray)); $objRouterDetail->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterDetail->SetIdMfModule($objModule->GetId()); $objRouterDetail->SetLabelUrl($labelUrlDetail); $objRouterDetail->SetName('detail'); $objRouterDetail->SetLang($lang); $objRouterDetail->SetLocation($post['location']); $idRouterPage = $objElement->GetIdRouterPage(); if ($idRouterPage == 0) { $objRouterPage = new MfRouter(); } else { $objRouterPage = MfRouterDAL::GetById($idRouterPage); if (!is_object($objRouterPage)) { $objRouterPage = new MfRouter(); } } $objRouterPage->SetController($controller); $objRouterPage->SetMethod($method); $objRouterPage->SetUrl($matchUriPage); $objRouterPage->SetLabelUrl($labelUrlPage); $objRouterPage->SetName('page'); $objRouterPage->SetParam(serialize($paramArray)); $objRouterPage->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterPage->SetIdMfModule($objModule->GetId()); $objRouterPage->SetLang($lang); $objRouterPage->SetLocation($post['location']); //==zapis struktuy============================================== //$objElement = new Structure($id, $idContent, $post['idParent'], $post['idMain'], '', $lang, $post['sort'], $publication, $post['title'], $post['menuName'], $url); $objElement->SetIdContent($idContent); $objElement->SetUrl($url); $objElement->SetMenuName(($post['menuName'] == '' ? $post['title'] : $post['menuName'])); $objElement->SetName($post['title']); $objElement->SetSubname($post['subname']); $objElement->SetElementName($post['elementName']); $objElement->SetPublication($publication); $objElement->SetPublicationMenu($publicationMenu); $objElement->SetType($post['type']); //$objElement->SetBanner($post['photo']); $objElement->SetUrlLabel($labelUrl); $objElement->SetLocation($post['location']); //Utils::ArrayDisplay($post, __FILE__.' - '.__LINE__); //==zapis=META TAG========================================= //$objMetaTag = new MfMetaTag(); $objMetaTag->SetSourceType('mf_structure'); $objMetaTagDescription = $objMetaTag->GetDescriptionObj(); if (!$post['meta_keywords']) { if (isset($post['description'])) { $metaKeywords = Utils::Truncate(strip_tags($post['description']), 150); $metaKeywords = str_replace(' ', ', ', $metaKeywords); $objMetaTagDescription->SetKeywords($metaKeywords); } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } if (!$post['meta_description']) { if (isset($post['description'])) { $metaDescription = Utils::Truncate(strip_tags($post['description']), 150); $objMetaTagDescription->SetDescription($metaDescription); } else { $objMetaTagDescription->SetDescription($post['meta_description']); } } else { $objMetaTagDescription->SetDescription($post['meta_description']); } $objMetaTagDescription->SetStatistic($post['statistic']); $objMetaTagDescription->SetLang($lang); if (empty($out)) { if (isset($_FILES['filename']) && $_FILES['filename']['tmp_name']) { $photoSize = getimagesize($_FILES['filename']['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['filename'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR, $photoWidth, $photoHeight, 100); $destName = md5('photo' . microtime()); if (file_exists(PATH_STATIC_CONTENT . 'upload/Structure/' . $destName . '.jpg')) unlink(PATH_STATIC_CONTENT . 'upload/Structure/' . $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/Structure', 0, 0, $photoWidth, $photoHeight, self::IMAGE_NORMAL_WIDTH, $photoWidth / $prop); // 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('foto: '.$photo); $objPhoto = new Picture(); $objPhoto->SetLink($photo); $objPhoto->SetWeight(1); $objPhoto->SetPublication(1); $idPhoto = PictureDAL::Insert($objPhoto); $objElement->SetIdPicture($idPhoto); } if (isset($_FILES['filename2']) && $_FILES['filename2']['tmp_name']) { $photoSize = getimagesize($_FILES['filename2']['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['filename2'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR, $photoWidth, $photoHeight, 100); $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/Structure', 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); $objElement->SetIdPictureMini($idPhoto); } if (isset($data['deletePhoto'])) { //$objElement->SetIdPictureMini(0); $objElement->SetIdPicture(0); } if (isset($data['deletePhoto2'])) { $objElement->SetIdPictureMini(0); //$objElement->SetIdPicture(0); } $db = Registry::Get('db'); $db->BeginTransaction(); try { //Router if (isset($objRouterDetail)) { $idRouterDetail = MfRouterDAL::Save($objRouterDetail); $idRouterPage = MfRouterDAL::Save($objRouterPage); $objElement->SetIdRouterDetail($idRouterDetail); $objElement->SetIdRouterPage($idRouterPage); } $idRouter = MfRouterDAL::Save($router); if ($objElement->GetCopy() != 0) { Utils::UpdateField('mf_structure', 'url_label', 'copy', $objElement->GetCopy(), $labelUrl); Utils::UpdateField('mf_structure', 'url', 'copy', $objElement->GetCopy(), $matchUri); } $idStructure = StructureDAL::Save($objElement); SessionProxy::SetValue('idStructure', $idStructure); if (isset($post['idStructurePl'])) { LinkLangDAL::Update($post['idStructurePl'], $idStructure, $lang); } //Utils::ArrayDisplay($idStructure); $objMetaTag->SetIdSource($idStructure); $idMetaTag = MfMetaTagDAL::Save($objMetaTag); $objMetaTagDescription->SetIdMfMetaTag($idMetaTag); MfMetaTagDescriptionDAL::Save($objMetaTagDescription); //TODO: Dorobić dodnie banera bezpośrednio z forma bez Iframe if (isset($post['photo']) && $post['photo'] != '') { //--Kopiowanie banerra-------------------------------------------------- if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure)) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure); } //Utils::ArrayDisplay(PATH_STATIC_CONTENT."/temp/".$idStage."/".$Stage->GetPicture()); if (file_exists(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner())) { rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBanner()); rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBannerTh(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBannerTh()); } } SessionProxy::ClearValue('idCategory'); SessionProxy::ClearValue('idContent'); SessionProxy::ClearValue('objModule'); $db->CommitTransaction(); Router::GenerateDbRoutes(); $this->AddRedirectInfo('Element został zapisany', 'Ok', Router::GenerateUrl('editStructure', array('id' => $idStructure))); //Utils::ArrayDisplay("odblogować przekierowanie", __FILE__.' - '.__LINE__); } catch (Exception $e) { Utils::ArrayDisplay($e); $db->Rollback(); } } else { $this->smarty->assign('info', 'Pola obowiązkowe muszą zostać wypełnione.'); $this->smarty->assign('type', 'error'); } } //Utils::ArrayDisplay($objModule); // // //-====wywołanie klasy kontentu======================================== // $className = $class.'DAL'; // $classDAL = new $className(); // $descriptionClassName = $descriptionClass.'DAL'; // if (class_exists($descriptionClassName)) { // $descriptionClassNameDAL = new $descriptionClassName(); // $objDescriptionClass = new $descriptionClass(); // //============================================= // // $data = array('lang' => $lang); // } else { // $data = array(); // } // if ($idCategory) { // $idsContent = MfLinkDAL::GetIdString($tableModuleName, $tableModuleName.'_category', $idCategory); // $categoryData = array($tableModuleName.'.id_'.$tableModuleName => array('condition' => 'IN', 'value' => $idsContent)); // } else { // $idsContent = '()'; // $categoryData = array(); // } // $data = array_merge($data, $categoryData); // // if ($method == 'Index') { // $arrayObj = $classDAL->GetList($data, 20, $tableModuleName.'.id_'.$tableModuleName.' DESC'); // } else { // $obj = $classDAL->GetEmptyObj(); // } // $idContent = -1; $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', $lang, $tableModuleName, $idContent); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); // if ($method == 'Index') { // $this->smarty->assign('arrayObj', $arrayObj); // $this->smarty->assign('idElement', $objElement->GetId()); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureList.tpl'); // } else { // $this->smarty->assign('obj', $obj); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureEdit.tpl'); // } $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('idCategoryChecked', $idCategory); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('method', $method); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('module', $module); $this->smarty->assign('arrayCategory', $arrayCategory); $this->smarty->assign('idContent', $idContent); } /** * * @param type $param * TODO: WOW 346 lini!!! zoptymalizować. */ public function EditAction($param) { //Utils::ArrayDisplay($param); if (Request::GetPost('idCategorySelected')) { SessionProxy::setValue('idCategorySelected', Request::GetPost('idCategorySelected')); } //SessionProxy::ClearValue('idStructure'); //SessionProxy::ClearValue('router'); //SessionProxy::ClearValue('_ARRAY_PHOTO_'); $this->AddScript('dropDown.js'); $lang = SessionProxy::GetValue('lang'); $idCategory = SessionProxy::GetValue('idCategory'); //SessionProxy::ClearValue('objModule'); //SessionProxy::ClearValue('idCategory'); //Utils::ArrayDisplay('structure: '.SessionProxy::GetValue('idContent')); //die(); $arrayStructurePl = Utils::GetArrayList('mf_structure', 'id_mf_structure', 'name', 'pl', '', 'name'); //Utils::ArrayDisplay($arrayStructure); $this->smarty->assign('arrayStructurePl', $arrayStructurePl); SessionProxy::ClearValue('objModule'); SessionProxy::ClearValue('idCategory'); if (isset($param['id']) && is_numeric($param['id'])) { $id = $param['id']; try { $objElement = StructureDAL::GetById($id); if (is_object($objElement)) { //Utils::ArrayDisplay($objElement->GetPicture()); $router = MfRouterDAL::GetById($objElement->GetIdRouter()); $unserializedParam = unserialize($router->GetParam()); } else { Utils::Redirect(Router::GenerateUrl('Index', array())); $this->AddRedirect(Router::GenerateUrl('Index', array()), 0); } } catch (Exception $e) { //Utils::ArrayDisplay($e); Utils::Redirect(Router::GenerateUrl('Index', array())); $this->AddRedirect(Router::GenerateUrl('Index', array()), 0); } ///Utils::ArrayDisplay($ueue); //Utils::ArrayDisplay($router); $this->smarty->assign('idElement', $id); SessionProxy::SetValue('idStructure', $id); SessionProxy::SetValue('idContent', $objElement->GetIdContent()); } else { Utils::Redirect(Router::GenerateUrl('Index', array())); $this->AddRedirect(Router::GenerateUrl('Index', array()), 0); } if ($lang != 'pl') { $slectedLang = LinkLangDAL::GetSelected($id, $lang); $this->smarty->assign('slectedLang', $slectedLang); } else { $this->smarty->assign('slectedLang', 0); } $idContent = SessionProxy::GetValue('idContent'); $objModule = MfModuleDAL::GetById($router->GetIdMfModule()); SessionProxy::SetValue('objModule', $objModule); $this->smarty->assign('objModule', $objModule); $post = Request::GetAllPost(); $class = $objModule->GetClassModuleName(); $descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); $catalog = $objModule->GetCatalog(); $options = unserialize($objModule->GetOptions()); if (isset($unserializedParam['idCategory'])) { $idCategory = $unserializedParam['idCategory']; SessionProxy::SetValue('idCategory', $idCategory); } $methodAdmin = $objModule->GetMethodAdminName(); if ($methodAdmin && $methodAdmin != 'null') { $methodAdmin = $methodAdmin == 'Index' ? $methodAdmin : 'Add'; $param['runSharedVariable'] = 'editStructure'; $this->RunModuleController($controller, $methodAdmin . 'Structure', $param, true); } //Utils::ArrayDisplay($unserializedParam); //Utils::ArrayDisplay($id); // ===== Dodatkowa treść dla stron z listami ================== if ($id == 8) { //Utils::ArrayDisplay($objModule->GetMethodName()); $param['runSharedVariable'] = 'editStructureProject'; $param['text'] = true; $this->RunModuleController('SimpleArticle_IndexController', 'EditStructure', $param, true); } //--- Dodatkowa treść dla stron z listami - KONIEC------------- // ===== Dodatkowa funcja pliki ================== $param['runSharedVariable'] = 'editStructureFile'; $param['text'] = true; $this->RunModuleController('FileController', 'EditStructure', $param, true); //--- Dodatkowa funcja pliki - KONIEC------------- $objMetaTag = MfMetaTagDAL::GetByIdSource($id, 'mf_structure', $lang); //Utils::ArrayDisplay($objMetaTag); //Utils::ArrayDisplay($_POST); if (Request::GetPost('EditStructureForm')) { $out = array(); $validator = new Validator(Request::GetAllPost()); $data = Request::GetAllPost(); $validator->IsEmpty('title', 'To pole nie może być puste'); //$validator -> IsEmpty('datepublication','To pole nie może być puste'); $param['submitForm'] = 'walidacja'; $out = $validator->GetErrorList(); if ($method != 'Index') { } $publication = Request::Get('publication'); $publicationMenu = Request::Get('publication_menu'); $publication ? $publication = 1 : $publication = '0'; $publicationMenu ? $publicationMenu = 1 : $publicationMenu = '0'; //------ //=Making URL'a=============================== $url = Request::GetPost('url'); $url = Utils::ClearString($url); $url = Utils::cleanUrl($url); $url = substr($url, 0, 40); $id = $post['id']; if ($url) { //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.''.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } else { $url = Utils::ClearString($_POST['title']); $url = Utils::cleanUrl($url); //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.''.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $url . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlPage = $url . 'LabelPage'; $labelUrlDetail = $url . 'LabelDetail'; } if ($objModule->GetList() == 1) { $arrayModuleOptions = $objModule->GetArrayOptions(); $matchUri = $arrayModuleOptions['defaultUrl']; $url = $arrayModuleOptions['defaultUrl']; $labelUrl = $objModule->GetModuleTitle() . 'Label'; $labelUrlDetail = $objModule->GetModuleTitle() . 'LabelDetail'; $matchUriList = $arrayModuleOptions['defaultUrl'] . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $arrayModuleOptions['defaultUrl'] . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = $arrayModuleOptions['defaultUrl'] . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $objModule->GetModuleTitle() . 'Label'; $labelUrlPage = $objModule->GetModuleTitle() . 'LabelPage'; $labelUrlDetail = $objModule->GetModuleTitle() . 'LabelDetail'; } // if ($idCategory == 2) { // $arrayModuleOptions = $objModule->GetArrayOptions(); // $matchUri = 'news'; // $labelUrl = 'newsLabel'; // $url = 'news'; // $labelUrlDetail = 'newsLabelDetail'; // $matchUriList = 'news'.STRONA_URL_DELIMITER."id".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.":title"; // $matchUri = 'news'.STRONA_APPLICATION_FILE_TYPE; // $matchUriPage = 'news'.STRONA_URL_DELIMITER.":p".STRONA_APPLICATION_FILE_TYPE; // $labelUrl = 'newsLabel'; // $labelUrlPage = 'newsLabelPage'; // $labelUrlDetail = 'newsLabelDetail'; // } $paramArray = array(); if ($method == 'Index') { //Making ListEleement $idCategory = SessionProxy::GetValue('idCategory'); $idContent = '0'; if (SessionProxy::IsSetValue('idContent')) { $idContent = SessionProxy::GetValue('idContent'); } //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['urlDetail'] = $matchUriList; $paramArray['urlDetailLabel'] = $labelUrlDetail; $paramArray['idStructure'] = $id; $paramArray['paged'] = true; } else { //Making content element $idCategory = SessionProxy::GetValue('idCategory'); $idContent = SessionProxy::GetValue('idContent'); //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['idStructure'] = $id; } //TODO: dorobić możliwość definiowana boxów $actionSet = array('FileController,IndexStructure'); //$router = new MfRouter(); $router->SetController($controller); $router->SetMethod($method); $router->SetUrl($matchUri); $router->SetLabelUrl($labelUrl); $router->SetParam(serialize($paramArray)); $router->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $router->SetIdMfModule($objModule->GetId()); $router->SetLabelUrl($labelUrl); $router->SetLang($lang); $router->SetLocation($post['location']); if ($method == 'Index') { $idRouterDetail = $objElement->GetIdRouterDetail(); if ($idRouterDetail == 0) { $objRouterDetail = new MfRouter(); } else { $objRouterDetail = MfRouterDAL::GetById($idRouterDetail); } $objRouterDetail->SetController($controller); $objRouterDetail->SetMethod('View'); $objRouterDetail->SetUrl($matchUriList); $objRouterDetail->SetParam(serialize($paramArray)); $objRouterDetail->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterDetail->SetIdMfModule($objModule->GetId()); $objRouterDetail->SetLabelUrl($labelUrlDetail); $objRouterDetail->SetLang($lang); $objRouterDetail->SetLocation($post['location']); $idRouterPage = $objElement->GetIdRouterPage(); if ($idRouterPage == 0) { $objRouterPage = new MfRouter(); } else { $objRouterPage = MfRouterDAL::GetById($idRouterPage); if (!is_object($objRouterPage)) { $objRouterPage = new MfRouter(); } } $objRouterPage->SetController($controller); $objRouterPage->SetMethod($method); $objRouterPage->SetUrl($matchUriPage); $objRouterPage->SetLabelUrl($labelUrlPage); $objRouterPage->SetParam(serialize($paramArray)); $objRouterPage->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterPage->SetIdMfModule($objModule->GetId()); $objRouterPage->SetLang($lang); $objRouterPage->SetLocation($post['location']); } //==zapis struktuy============================================== //$objElement = new Structure($id, $idContent, $post['idParent'], $post['idMain'], '', $lang, $post['sort'], $publication, $post['title'], $post['menuName'], $url); $objElement->SetIdContent($idContent); $objElement->SetUrl($url); $objElement->SetMenuName(($post['menuName'] == '' ? $post['title'] : $post['menuName'])); $objElement->SetName($post['title']); $objElement->SetSubname($post['subname']); $objElement->SetElementName($post['elementName']); $objElement->SetPublication($publication); $objElement->SetPublicationMenu($publicationMenu); $objElement->SetType($post['type']); //$objElement->SetBanner($post['photo']); $objElement->SetUrlLabel($labelUrl); $objElement->SetLocation($post['location']); //==zapis=META TAG========================================= //$objMetaTag = new MfMetaTag(); $objMetaTag->SetSourceType('mf_structure'); $objMetaTagDescription = $objMetaTag->GetDescriptionObj(); if (!$post['meta_keywords']) { if (isset($post['description'])) { $metaKeywords = Utils::Truncate(strip_tags($post['description']), 150); $metaKeywords = str_replace(' ', ', ', $metaKeywords); $objMetaTagDescription->SetKeywords($metaKeywords); } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } } else { $objMetaTagDescription->SetKeywords($post['meta_keywords']); } if (!$post['meta_description']) { if (isset($post['description'])) { $metaDescription = Utils::Truncate(strip_tags($post['description']), 150); $objMetaTagDescription->SetDescription($metaDescription); } else { $objMetaTagDescription->SetDescription($post['meta_description']); } } else { $objMetaTagDescription->SetDescription($post['meta_description']); } $objMetaTagDescription->SetStatistic($post['statistic']); $objMetaTagDescription->SetLang($lang); if (empty($out)) { if (isset($_FILES['filename']) && $_FILES['filename']['tmp_name']) { $photoSize = getimagesize($_FILES['filename']['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['filename'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR, $photoWidth, $photoHeight, 100); $destName = md5('photo' . microtime()); if (file_exists(PATH_STATIC_CONTENT . 'upload/Structure/' . $destName . '.jpg')) unlink(PATH_STATIC_CONTENT . 'upload/Structure/' . $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/Structure', 0, 0, $photoWidth, $photoHeight, self::IMAGE_NORMAL_WIDTH, $photoWidth / $prop); // 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('foto: '.$photo); $objPhoto = new Picture(); $objPhoto->SetLink($photo); $objPhoto->SetWeight(1); $objPhoto->SetPublication(1); $idPhoto = PictureDAL::Insert($objPhoto); $objElement->SetIdPicture($idPhoto); } if (isset($_FILES['filename2']) && $_FILES['filename2']['tmp_name']) { $photoSize = getimagesize($_FILES['filename2']['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['filename2'], self::AVATAR_TEMP_DIR . DIRECTORY_SEPARATOR, $photoWidth, $photoHeight, 100); $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/Structure', 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); $objElement->SetIdPictureMini($idPhoto); } if (isset($data['deletePhoto'])) { //$objElement->SetIdPictureMini(0); $objElement->SetIdPicture(0); } if (isset($data['deletePhoto2'])) { $objElement->SetIdPictureMini(0); //$objElement->SetIdPicture(0); } $db = Registry::Get('db'); $db->BeginTransaction(); try { //Router if (isset($objRouterDetail)) { $idRouterDetail = MfRouterDAL::Save($objRouterDetail); $idRouterPage = MfRouterDAL::Save($objRouterPage); $objElement->SetIdRouterDetail($idRouterDetail); $objElement->SetIdRouterPage($idRouterPage); } $idRouter = MfRouterDAL::Save($router); if ($objElement->GetCopy() != 0) { Utils::UpdateField('mf_structure', 'url_label', 'copy', $objElement->GetCopy(), $labelUrl); Utils::UpdateField('mf_structure', 'url', 'copy', $objElement->GetCopy(), $matchUri); } $idStructure = StructureDAL::Save($objElement); SessionProxy::SetValue('idStructure', $idStructure); if (isset($post['idStructurePl'])) { LinkLangDAL::Update($post['idStructurePl'], $idStructure, $lang); } //Utils::ArrayDisplay($idStructure); $objMetaTag->SetIdSource($idStructure); $idMetaTag = MfMetaTagDAL::Save($objMetaTag); $objMetaTagDescription->SetIdMfMetaTag($idMetaTag); MfMetaTagDescriptionDAL::Save($objMetaTagDescription); //TODO: Dorobić dodnie banera bezpośrednio z forma bez Iframe if (isset($post['photo']) && $post['photo'] != '') { //--Kopiowanie banerra-------------------------------------------------- if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure)) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure); } //Utils::ArrayDisplay(PATH_STATIC_CONTENT."/temp/".$idStage."/".$Stage->GetPicture()); if (file_exists(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner())) { rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBanner()); rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBannerTh(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBannerTh()); } } SessionProxy::ClearValue('idCategory'); SessionProxy::ClearValue('idContent'); SessionProxy::ClearValue('objModule'); $db->CommitTransaction(); Router::GenerateDbRoutes(); $this->AddRedirectInfo('Element został zapisany', 'Ok', Router::GenerateUrl('editStructure', array('id' => $idStructure))); } catch (Exception $e) { Utils::ArrayDisplay($e); $db->Rollback(); } } else { $this->smarty->assign('info', 'Pola obowiązkowe muszą zostać wypełnione.'); $this->smarty->assign('type', 'error'); } } //Utils::ArrayDisplay($objModule); // // //-====wywołanie klasy kontentu======================================== // $className = $class.'DAL'; // $classDAL = new $className(); // $descriptionClassName = $descriptionClass.'DAL'; // if (class_exists($descriptionClassName)) { // $descriptionClassNameDAL = new $descriptionClassName(); // $objDescriptionClass = new $descriptionClass(); // //============================================= // // $data = array('lang' => $lang); // } else { // $data = array(); // } // if ($idCategory) { // $idsContent = MfLinkDAL::GetIdString($tableModuleName, $tableModuleName.'_category', $idCategory); // $categoryData = array($tableModuleName.'.id_'.$tableModuleName => array('condition' => 'IN', 'value' => $idsContent)); // } else { // $idsContent = '()'; // $categoryData = array(); // } // $data = array_merge($data, $categoryData); // // if ($method == 'Index') { // $arrayObj = $classDAL->GetList($data, 20, $tableModuleName.'.id_'.$tableModuleName.' DESC'); // } else { // $obj = $classDAL->GetEmptyObj(); // } // $idContent = -1; $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', $lang, $tableModuleName, $idContent); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); // if ($method == 'Index') { // $this->smarty->assign('arrayObj', $arrayObj); // $this->smarty->assign('idElement', $objElement->GetId()); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureList.tpl'); // } else { // $this->smarty->assign('obj', $obj); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureEdit.tpl'); // } $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('idCategoryChecked', $idCategory); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('method', $method); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('module', $module); $this->smarty->assign('arrayCategory', $arrayCategory); $this->smarty->assign('idContent', $idContent); } /** * * @param type $param * TODO: Czy to jest potrzebne? Przetestować i zoptymalizować!! */ public function CopyAction($param) { //$this->partialTemplate = 'Edit.tpl'; $this->AddScript('dropDown.js'); $lang = SessionProxy::GetValue('lang'); $idCategory = SessionProxy::GetValue('idCategory'); SessionProxy::ClearValue('objModule'); SessionProxy::ClearValue('idCategory'); if (isset($param['id']) && $param['id'] > 0) { $id = $param['id']; $objElement = StructureDAL::GetById($id); $router = MfRouterDAL::GetById($objElement->GetIdRouter()); $unserializedParam = unserialize($router->GetParam()); $this->smarty->assign('idElement', $id); SessionProxy::SetValue('idStructure', $id); SessionProxy::SetValue('idContent', $objElement->GetIdContent()); } else { $url = Router::GenerateUrl('IndexStructure', array('Structure' => 'Index')); $this->AddRedirect($url, 0); Utils::Redirect($url); } $idContent = SessionProxy::GetValue('idContent'); $objModule = MfModuleDAL::GetById($router->GetIdMfModule()); SessionProxy::SetValue('objModule', $objModule); $this->smarty->assign('objModule', $objModule); //Utils::ArrayDisplay($objModule); //Utils::ArrayDisplay($objElement); // $aaa = $this->RunModule('SimpleArticle_Index', 'EditStructureAction', $param, true); // // Utils::ArrayDisplay($aaa); $post = Request::GetAllPost(); $class = $objModule->GetClassModuleName(); $descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); $catalog = $objModule->GetCatalog(); $options = unserialize($objModule->GetOptions()); if (isset($unserializedParam['idCategory'])) { $idCategory = $unserializedParam['idCategory']; SessionProxy::SetValue('idCategory', $idCategory); } $methodAdmin = $objModule->GetMethodAdminName(); $methodAdmin = $methodAdmin == 'Index' ? $methodAdmin : 'Edit'; $param['runSharedVariable'] = 'editStructure'; $this->RunModuleController($controller, $methodAdmin . 'Structure', $param, true); $objMetaTag = MfMetaTagDAL::GetByIdSource($id, 'mf_structure', $lang); //Utils::ArrayDisplay($objMetaTag); //Utils::ArrayDisplay($_POST); if (Request::GetPost('EditStructureForm')) { $out = array(); $validator = new Validator(Request::GetAllPost()); $data = Request::GetAllPost(); $validator->IsEmpty('title', 'To pole nie może być puste'); //$validator -> IsEmpty('datepublication','To pole nie może być puste'); $param['submitForm'] = 'walidacja'; $out = $validator->GetErrorList(); if ($method != 'Index') { } $publication = Request::Get('publication'); $publicationMenu = Request::Get('publication_menu'); $publication ? $publication = 1 : $publication = '0'; $publicationMenu ? $publicationMenu = 1 : $publicationMenu = '0'; //------ //=Making URL'a=============================== $url = $post['url']; $url = Utils::ClearString($url); $id = $post['id']; if ($url) { //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.''.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlDetail = $url . 'DetailLabel'; } else { $url = Utils::ClearString($_POST['title']); //$matchUriList = ":title".STRONA_URL_DELIMITER.":id".STRONA_URL_DELIMITER.$url.''.STRONA_APPLICATION_FILE_TYPE; $matchUriList = $url . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; $labelUrl = $url . 'Label'; $labelUrlDetail = $url . 'DetailLabel'; } if ($idCategory == 2) { $arrayModuleOptions = $objModule->GetArrayOptions(); $matchUri = 'news'; $labelUrl = 'newsLabel'; $url = 'news'; $labelUrlDetail = 'newsLabelDetail'; $matchUriList = 'news' . STRONA_URL_DELIMITER . "id" . STRONA_URL_DELIMITER . ":id" . STRONA_URL_DELIMITER . ":title"; $matchUri = 'news' . STRONA_APPLICATION_FILE_TYPE; $matchUriPage = 'news' . STRONA_URL_DELIMITER . ":p" . STRONA_APPLICATION_FILE_TYPE; $labelUrl = 'newsLabel'; $labelUrlPage = 'newsLabelPage'; $labelUrlDetail = 'newsLabelDetail'; } $paramArray = array(); if ($method == 'Index') { //Making ListEleement $idCategory = SessionProxy::GetValue('idCategory'); $idContent = '0'; //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['urlDetail'] = $matchUriList; $paramArray['urlDetailLabel'] = $labelUrlDetail; $paramArray['idStructure'] = $id; } else { //Making content element $idCategory = SessionProxy::GetValue('idCategory'); $idContent = SessionProxy::GetValue('idContent'); //====== parametry potrzebne do wywołania treści $paramArray['id'] = $idContent; $paramArray['idCategory'] = $idCategory; $paramArray['idStructure'] = $id; } //TODO: dorobić możliwość definiowana boxów $actionSet = array(); //$router = new MfRouter(); $router->SetController($controller); $router->SetMethod($method); $router->SetUrl($matchUri); $router->SetLabelUrl($labelUrl); $router->SetParam(serialize($paramArray)); $router->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $router->SetIdMfModule($objModule->GetId()); $router->SetLabelUrl($labelUrl); if ($method == 'Index') { $idRouterDetail = $objElement->GetIdRouterDetail(); if ($idRouterDetail == 0) { $objRouterDetail = new MfRouter(); } else { $objRouterDetail = MfRouterDAL::GetById($idRouterDetail); } $objRouterDetail->SetController($controller); $objRouterDetail->SetMethod('View'); $objRouterDetail->SetUrl($matchUriList); $objRouterDetail->SetParam(serialize($paramArray)); $objRouterDetail->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $objRouterDetail->SetIdMfModule($objModule->GetId()); $objRouterDetail->SetLabelUrl($labelUrlDetail); } //==zapis struktuy============================================== //$objElement = new Structure($id, $idContent, $post['idParent'], $post['idMain'], '', $lang, $post['sort'], $publication, $post['title'], $post['menuName'], $url); $objElement->SetIdContent($idContent); $objElement->SetUrl($url); $objElement->SetMenuName(($post['menuName'] == '' ? $post['title'] : $post['menuName'])); $objElement->SetElementName($post['elementName']); $objElement->SetName($post['title']); $objElement->SetPublication($publication); $objElement->SetPublicationMenu($publicationMenu); $objElement->SetType($post['type']); $objElement->SetBanner($post['photo']); $objElement->SetUrlLabel($labelUrl); //==zapis=META TAG========================================= //$objMetaTag = new MfMetaTag(); $objMetaTag->SetSourceType('mf_structure'); $objMetaTagDescription = $objMetaTag->GetDescriptionObj(); $objMetaTagDescription->SetKeywords($post['meta_keywords']); $objMetaTagDescription->SetDescription($post['meta_description']); $objMetaTagDescription->SetStatistic($post['statistic']); $objMetaTagDescription->SetLang($lang); if (empty($out)) { $db = Registry::Get('db'); $db->BeginTransaction(); try { //Router if (isset($objRouterDetail)) { $idRouterDetail = MfRouterDAL::Save($objRouterDetail); $objElement->SetIdRouterDetail($idRouterDetail); } $idRouter = MfRouterDAL::Save($router); if ($objElement->GetCopy() != 0) { $copyId = $objElement->GetCopy(); } else { $copyId = $objElement->GetId(); } Utils::UpdateField('mf_structure', 'copy', 'id_mf_structure', $objElement->GetId(), $copyId); $objElement->SetId(-1); $idStructure = StructureDAL::Save($objElement); SessionProxy::SetValue('idStructure', $idStructure); Utils::UpdateField('mf_structure', 'copy', 'id_mf_structure', $idStructure, $copyId); $paramArray['idStructure'] = $idStructure; //akktualizcja param // MfRouterDAL::UpdateParamPush($idRouter, $paramArray); // MfRouterDAL::UpdateParamPush($idRouterDetail, $paramArray); //Utils::ArrayDisplay($idStructure); $objMetaTag->SetIdSource($idStructure); $objMetaTag->SetId(-1); $idMetaTag = MfMetaTagDAL::Save($objMetaTag); $objMetaTagDescription->SetId(-1); $objMetaTagDescription->SetIdMfMetaTag($idMetaTag); MfMetaTagDescriptionDAL::Save($objMetaTagDescription); //TODO: Dorobić dodnie banera bezpośrednio z forma bez Iframe if ($post['photo'] != '') { //--Kopiowanie banerra-------------------------------------------------- if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure)) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure); } //Utils::ArrayDisplay(PATH_STATIC_CONTENT."/temp/".$idStage."/".$Stage->GetPicture()); if (file_exists(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner())) { rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBanner()); rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBannerTh(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBannerTh()); } } SessionProxy::ClearValue('idCategory'); SessionProxy::ClearValue('idContent'); SessionProxy::ClearValue('objModule'); $db->CommitTransaction(); Router::GenerateDbRoutes(); $this->AddRedirect(Router::GenerateUrl('editStructure', array('id' => $idStructure)), 0); } catch (Exception $e) { Utils::ArrayDisplay($e); $db->Rollback(); } } else { } } //Utils::ArrayDisplay($objModule); // // //-====wywołanie klasy kontentu======================================== // $className = $class.'DAL'; // $classDAL = new $className(); // $descriptionClassName = $descriptionClass.'DAL'; // if (class_exists($descriptionClassName)) { // $descriptionClassNameDAL = new $descriptionClassName(); // $objDescriptionClass = new $descriptionClass(); // //============================================= // // $data = array('lang' => $lang); // } else { // $data = array(); // } // if ($idCategory) { // $idsContent = MfLinkDAL::GetIdString($tableModuleName, $tableModuleName.'_category', $idCategory); // $categoryData = array($tableModuleName.'.id_'.$tableModuleName => array('condition' => 'IN', 'value' => $idsContent)); // } else { // $idsContent = '()'; // $categoryData = array(); // } // $data = array_merge($data, $categoryData); // // if ($method == 'Index') { // $arrayObj = $classDAL->GetList($data, 20, $tableModuleName.'.id_'.$tableModuleName.' DESC'); // } else { // $obj = $classDAL->GetEmptyObj(); // } // $idContent = -1; $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', $lang, $tableModuleName, $idContent); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); // if ($method == 'Index') { // $this->smarty->assign('arrayObj', $arrayObj); // $this->smarty->assign('idElement', $objElement->GetId()); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureList.tpl'); // } else { // $this->smarty->assign('obj', $obj); // $content = $this->smarty->fetch('partial/'.$catalog.'/StructureEdit.tpl'); // } $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('idCategoryChecked', $idCategory); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('method', $method); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('module', $module); $this->smarty->assign('arrayCategory', $arrayCategory); $this->smarty->assign('idContent', $idContent); } /** * * @param string $param * TODO: posprzątać to!! */ public function SaveAction($param) { //Utils::ArrayDisplay($param); $out = array(); $id = -1; //-ADD--------- if (Request::GetPost('idModule')) { $objModule = MfModuleDAL::GetById(Request::GetPost('idModule')); } else { $objModule = SessionProxy::GetValue('objModule'); } //Utils::ArrayDisplay($objModule); SessionProxy::SetValue('objModule', $objModule); $idCategory = Request::GetPost('idCategory'); SessionProxy::SetValue('idCategory', $idCategory); //-edycja if (isset($param['id'])) { $id = $param['id']; $objElement = StructureDAL::GetById($id); $router = MfRouterDAL::GetById($objElement->GetIdRouter()); $unserializedParam = unserialize($router->GetParam()); SessionProxy::SetValue('idStructure', $id); $objModule = MfModuleDAL::GetById($router->GetIdMfModule()); SessionProxy::SetValue('objModule', $objModule); } $objMetaTag = MfMetaTagDAL::GetResult(array('id_source' => $id), array()); if (isset($objMetaTag[0])) { $objMetaTag = $objMetaTag[0]; //$objMetaTag->SetDescriptionObj($objMetaTag->GetDescriptionObj()); } else { $objMetaTag = new MfMetaTag(); $objMetaTag->SetDescriptionObj(MfMetaTagDescriptionDAL::GetEmptyObj()); } $lang = SessionProxy::GetValue('lang'); $objModule = SessionProxy::GetValue('objModule'); $idContent = SessionProxy::GetValue('idContent'); $idCategory = SessionProxy::GetValue('idCategory'); $class = $objModule->GetClassModuleName(); $descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); $catalog = $objModule->GetCatalog(); $options = unserialize($objModule->GetOptions()); $defaultUrl = isset($options['defaultUrl']) ? $options['defaultUrl'] : 'artykul'; if (isset($param['id']) && $param['id'] > 0) { $objElement = StructureDAL::GetById($param['id']); //Utils::ArrayDisplay($objElement); } else { $objElement = new Structure(-1); $objElement->SetName(Request::GetPost('title')); $objMetaTag = new MfMetaTag(); $objMetaTag->SetDescriptionObj(MfMetaTagDescriptionDAL::GetEmptyObj()); $this->smarty->assign('objMetaTag', $objMetaTag); } //Utils::ArrayDisplay($lang); if (Request::IsPost()) { $validator = new Validator(Request::GetAllPost()); $data = Request::GetAllPost(); $validator->IsEmpty('title', 'To pole nie może być puste'); //$validator -> IsEmpty('datepublication','To pole nie może być puste'); $param['submitForm'] = 'walidacja'; $out = $validator->GetErrorList(); //Utils::ArrayDisplay(SessionProxy::GetValue('ModuleValidator')); if (empty($out) && ($idContent != 0 && $method != 'Index') && SessionProxy::GetValue('ModuleValidator')) { //-====wywołanie klasy kontentu======================================== $className = $class . 'DAL'; $classDAL = new $className(); $descriptionClassName = $descriptionClass . 'DAL'; if (class_exists($descriptionClassName)) { $descriptionClassNameDAL = new $descriptionClassName(); $objDescriptionClass = new $descriptionClass(); $arrayFields = $objDescriptionClass->GetFields(); } $post = $_POST; //$post = Request::GetAllPost(); //Utils::ArrayDisplay($_POST); $publication = Request::Get('publication'); $publicationMenu = Request::Get('publication_menu'); $publication ? $publication = 1 : $publication = '0'; $publicationMenu ? $publicationMenu = 1 : $publicationMenu = '0'; //Utils::ArrayDisplay('=> '.$publication); //================================ $url = $post['url']; $id = $post['id']; if ($url) { $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; } else { if ($method == 'Index') { $matchUri = ":id" . STRONA_URL_DELIMITER . $url . STRONA_APPLICATION_FILE_TYPE; } else { $url = Utils::ClearString($_POST['title']); $matchUri = $url . STRONA_APPLICATION_FILE_TYPE; } } if ($method == 'Index') { $idCategory = SessionProxy::GetValue('idCategory'); $idContent = ''; //====== parametry potrzebne do wywołania treści $paramSet = "idCategory:" . $idCategory; //============================== $paramText = array(); $paramText = explode(',', $paramSet); foreach ($paramText as $item) { $item = explode(':', $item); if (isset($item[0]) && isset($item[1])) $paramArray = array($item[0] => $item[1]); } //--Kopiowanie banerra-------------------------------------------------- if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure)) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure); } //Utils::ArrayDisplay(PATH_STATIC_CONTENT."/temp/".$idStage."/".$Stage->GetPicture()); if (file_exists(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner())) { rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBanner()); rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBannerTh(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBannerTh()); } Router::GenerateDbRoutes(); } else { $idCategory = SessionProxy::GetValue('idCategory'); //sdsdsdsds[asd]as[das][s //====== parametry potrzebne do wywołania treści $paramSet = "id:" . $idContent; //============================== $paramText = array(); $paramText = explode(',', $paramSet); foreach ($paramText as $item) { $item = explode(':', $item); if (isset($item[0]) && isset($item[1])) $paramArray = array($item[0] => $item[1]); } } //Utils::ArrayDisplay('zapis'); //=====TODO: pobieranie zawartości boxów z tabelki z danymi $actionSet = array(); // $actionSetText = $post['actionSet']; // $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]); // } //===zapis=routera==================== $router = new MfRouter($post['idRouter']); $router->SetController($controller); $router->SetMethod($method); $router->SetUrl($matchUri); $router->SetParam(serialize($paramArray)); $router->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $router->SetIdMfModule($objModule->GetId()); $idRouter = MfRouterDAL::Save($router); if (empty($idContent)) { $idContent = 0; } //==zapis struktuy============================================== $objElement = new Structure($id, $idContent, $post['idParent'], $post['idMain'], $idRouter, $lang, $post['sort'], (isset($post['publication']) ? 1 : 0), $post['title'], $post['menuName'], $url); $objElement->SetPublicationMenu($publicationMenu); $objElement->SetType($post['type']); $objElement->SetBanner($post['photo']); $idStructure = StructureDAL::Save($objElement); SessionProxy::SetValue('idStructure', $idStructure); $paramSet = "idStructure:" . $idStructure; //============================== $paramText = array(); $paramText = explode(',', $paramSet); foreach ($paramText as $item) { $item = explode(':', $item); if (isset($item[0]) && isset($item[1])) $paramArray = array($item[0] => $item[1]); } MfRouterDAL::UpdateParamPush($idRouter, $paramArray); //==zapis=META TAG========================================= $objMetaTag = MfMetaTagDAL::GetResult(array('id_source' => $idStructure), array()); //Utils::ArrayDisplay($objMetaTag); if (isset($objMetaTag[0])) { $objMetaTag = $objMetaTag[0]; } else { $objMetaTag = new MfMetaTag(); $objMetaTag->SetIdSource($idStructure); $objMetaTag->SetSourceType($tableModuleName); } $idMetaTag = MfMetaTagDAL::Save($objMetaTag); $objMetaTagDescription = MfMetaTagDescriptionDAL::GetResult(array('id_mf_meta_tag' => $idMetaTag), array()); if (isset($objMetaTagDescription[0])) { $objMetaTagDescription = $objMetaTagDescription[0]; } else { $objMetaTagDescription = new MfMetaTagDescription(); } $objMetaTagDescription->SetIdMfMetaTag($idMetaTag); $objMetaTagDescription->SetKeywords($post['meta_keywords']); $objMetaTagDescription->SetDescription($post['meta_description']); $objMetaTagDescription->SetStatistic($post['statistic']); $objMetaTagDescription->SetLang($lang); MfMetaTagDescriptionDAL::Save($objMetaTagDescription); //--------------------------------------------------------- if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure)) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure); } //Utils::ArrayDisplay(PATH_STATIC_CONTENT."/temp/".$idStage."/".$Stage->GetPicture()); if (file_exists(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner())) { rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBanner()); rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBannerTh(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBannerTh()); } Router::GenerateDbRoutes(); $this->smarty->assign('id', $idStructure); } else { //$this->content=$this->FormatAjaxOutput($out, $param); //Utils::ArrayDisplay($out); } } $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', 'pl', $tableModuleName, $idContent); $this->smarty->assign('out', $out); $this->partialTemplate = 'Edit.tpl'; $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('idContent', $idContent); $this->smarty->assign('idCategoryChecked', $idCategory); $this->smarty->assign('arrayCategory', $arrayCategory); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('method', $method); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('module', $module); } public function PhotoUploadAction($param) { if (!SessionProxy::IsSetValue('_ARRAY_PHOTO_')) { SessionProxy::SetValue('_ARRAY_PHOTO_', array()); } $arrayPhoto = SessionProxy::GetValue('_ARRAY_PHOTO_'); $this->SetAjaxRender(); $ok = ''; //Utils::ArrayDisplay($param); if (isset($_POST['savePhoto'])) { //Utils::ArrayDisplay($arrayPhoto); //$photoFile = Request::Get('file'); $destName = md5('photo' . time()); $destName = md5('photo' . time()); $destNameth = $destName . "_th.jpg"; $destName .= ".jpg"; //$destNamea = "test.jpg"; $destDir = 'temp/'; //Utils::ArrayDisplay($_FILES); if ($_FILES['file']['name']) { $arrayImage = getimagesize($_FILES['file']['tmp_name']); if ($arrayImage[0] != 970 && $arrayImage[1] != 122) { $this->smarty->assign('bannerError', 'Zły rozmiar banera! Prawidłowe wymiary to 970x122px!'); } else { //Utils::ArrayDisplay(PATH_STATIC_CONTENT); //Utils::ArrayDisplay(PATH_STATIC_CONTENT); $photo = PhotoDAL::SimplePhotoUpload($_FILES['file'], $destDir); $img_oryginal = new mImage(PATH_STATIC_CONTENT . $photo); $img_oryginal->scaleProp(970, 970, 'ffffff', false, 'c', 0); $img_oryginal->saveToFile(PATH_STATIC_CONTENT . $destDir . $destName, 'jpg', 90, true); $img_oryginal->scaleProp(false, 60, 'ffffff', false, 'c', 0); $img_oryginal->saveToFile(PATH_STATIC_CONTENT . $destDir . $destNameth, 'jpg', 90, true); //Utils::ArrayDisplay(PATH_STATIC_CONTENT.$photo); if (is_file(PATH_STATIC_CONTENT . $photo)) { unlink(PATH_STATIC_CONTENT . $photo); } $array = array($destName); $arrayPhoto = array_merge($arrayPhoto, $array); SessionProxy::SetValue('_ARRAY_PHOTO_', $arrayPhoto); $this->smarty->assign('photo', PATH_STATIC_CONTENT . $destDir . $destName); $ok = 'ok'; } } else { $ok = ''; } } $this->smarty->assign('arrayPhoto', $arrayPhoto); $display = $this->smarty->fetch('partial/Structure/PhotoDisplay.tpl'); // Utils::ArrayDisplay($arrayPhoto); //Utils::ArrayDisplay($display); $this->smarty->assign('display', $display); $this->smarty->assign('ok', $ok); SessionProxy::ClearValue('_ARRAY_PHOTO_'); } public function AjaxCheckExtAction($param) { $this->SetAjaxRender(); $string = $_POST['file']; $array = explode(".", $string); //$array = array_reverse($array); //Utils::ArrayDisplay($array); $extFile = $array[sizeof($array) - 1]; //Utils::ArrayDisplay($extFile); switch (strtolower($extFile)) { case "jpg": case "jpeg": $ext = "ok"; break; case "png": $ext = "ok"; break; case "gif": $ext = "ok"; break; case "bmp": $ext = "ok"; break; default: $ext = false; } $this->smarty->assign('ext', $ext); //Utils::ArrayDisplay($_SERVER); } /** * Akcja edycji * * @param Array $param * TODO: To jest chyba OUT!! */ public function _EditAction($param) { $this->AddScript('dropDown.js'); //$this->SetAjaxRender(); $lang = SessionProxy::GetValue('lang'); SessionProxy::ClearValue('objModule'); SessionProxy::ClearValue('idCategory'); if (isset($param['id'])) { $id = $param['id']; $objElement = StructureDAL::GetById($id); $router = MfRouterDAL::GetById($objElement->GetIdRouter()); $unserializedParam = unserialize($router->GetParam()); SessionProxy::SetValue('idStructure', $id); } $post = Request::GetAllPost(); $objModule = MfModuleDAL::GetById($router->GetIdMfModule()); SessionProxy::SetValue('objModule', $objModule); //Utils::ArrayDisplay($objModule); //Utils::ArrayDisplay('dfdf'); $class = $objModule->GetClassModuleName(); $descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); $catalog = $objModule->GetCatalog(); $options = unserialize($objModule->GetOptions()); $defaultUrl = isset($options['defaultUrl']) ? $options['defaultUrl'] : 'artykul'; //-====wywołanie klasy kontentu======================================== $className = $class . 'DAL'; $classDAL = new $className(); $descriptionClassName = $descriptionClass . 'DAL'; if (class_exists($descriptionClassName)) { $descriptionClassNameDAL = new $descriptionClassName(); $objDescriptionClass = new $descriptionClass(); } if ($module == 'Stage') { } //============================================= if (isset($unserializedParam['idCategory'])) { $idCategory = $unserializedParam['idCategory']; SessionProxy::SetValue('idCategory', $idCategory); } //Utils::ArrayDisplay($idCategory); if ($method == 'Index') { $idContent = '-1'; if (class_exists($descriptionClassName)) { $data = array('lang' => $lang); } else { $data = array(); } if ($idCategory) { $idsContent = MfLinkDAL::GetIdString($tableModuleName, $tableModuleName . '_category', $idCategory); $categoryData = array($tableModuleName . '.id_' . $tableModuleName => array('condition' => 'IN', 'value' => $idsContent)); } else { $idsContent = '()'; $categoryData = array(); } //Utils::ArrayDisplay($arrayLinkedIdToCategory); $data = array_merge($data, $categoryData); if ($module == 'MainSite') { SessionProxy::SetValue('idCategory', 2); $arrayObj = $classDAL->GetResult(); } else { $arrayObj = $classDAL->GetResult($data, array(), 40, $tableModuleName . '.id_' . $tableModuleName . ' DESC'); } //Utils::ArrayDisplay($arrayObj); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); $this->smarty->assign('arrayObj', $arrayObj); $this->smarty->assign('idElement', $objElement->GetId()); $content = $this->smarty->fetch('partial/' . $catalog . '/StructureList.tpl'); } else { if ($objElement->GetIdContent() > 0) { $obj = $classDAL->GetById($objElement->GetIdContent()); $obj->SetLang($lang); $obj->GetDescriptionObj(); $idContent = $objElement->GetIdContent(); } $this->smarty->assign('obj', $obj); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); //Utils::ArrayDisplay($objElement); $content = $this->smarty->fetch('partial/' . $catalog . '/StructureEdit.tpl'); } if ($module == 'Stage') { $arrayCategory = MfLinkDAL::GetAllList(4, array(), array(), '', 'name'); $obj = SimpleArticle_MfArticleDAL::GetEmptyObj(); $this->smarty->assign('arrayCategory', $arrayCategory); } else { $arraySpectacle = array(); //MfLinkDAL::GetArrayList('ts_spectacle_description', 'title', 'ts_spectacle', $lang, $tableModuleName, $idContent); $arrayPerson = MfLinkDAL::GetArrayList('mf_person_description', 'surname', 'mf_person', $lang, $tableModuleName, $idContent); $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', $lang, $tableModuleName, $idContent); $this->smarty->assign('arrayPerson', $arrayPerson); $this->smarty->assign('arraySpectacle', $arraySpectacle); $this->smarty->assign('arrayCategory', $arrayCategory); } $objMetaTag = MfMetaTagDAL::GetResult(array('id_source' => $id), array()); //Utils::ArrayDisplay($objMetaTag); if (isset($objMetaTag[0])) { $objMetaTag = $objMetaTag[0]; //$objMetaTag->SetDescriptionObj($objMetaTag->GetDescriptionObj()); } else { $objMetaTag = new MfMetaTag(); $objMetaTag->SetDescriptionObj(MfMetaTagDescriptionDAL::GetEmptyObj()); } //Utils::ArrayDisplay($objMetaTag); $this->smarty->assign('module', $module); $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('content', $content); $this->smarty->assign('method', $method); $this->smarty->assign('idCategoryChecked', ''); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('idContent', $idContent); // Utils::ArrayDisplay($tableModuleName); } /** * werja jezykowa dla elementu * * @param Array $param * TODO: czy to jest używane?? */ public function MakeVersionAction($param) { //Utils::ArrayDisplay($param); $this->AddScript('dropDown.js'); $this->SetAjaxRender(); $lang = SessionProxy::GetValue('lang'); SessionProxy::ClearValue('objModule'); SessionProxy::ClearValue('idCategory'); if (isset($param['id'])) { $id = $param['id']; $objElement = StructureDAL::GetById($id); $router = MfRouterDAL::GetById($objElement->GetIdRouter()); $unserializedParam = unserialize($router->GetParam()); //SessionProxy::SetValue('idStructure', $id); } $post = Request::GetAllPost(); $objModule = MfModuleDAL::GetById($router->GetIdMfModule()); SessionProxy::SetValue('objModule', $objModule); //Utils::ArrayDisplay($objModule); $class = $objModule->GetClassModuleName(); $descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $tableModuleNameCategory = $tableModuleName . '_category'; $controller = $objModule->GetController(); $catalog = $objModule->GetCatalog(); $options = unserialize($objModule->GetOptions()); $defaultUrl = isset($options['defaultUrl']) ? $options['defaultUrl'] : 'artykul'; //-====wywołanie klasy kontentu======================================== $className = $class . 'DAL'; $classDAL = new $className(); $descriptionClassName = $descriptionClass . 'DAL'; if (class_exists($descriptionClassName)) { $descriptionClassNameDAL = new $descriptionClassName(); $objDescriptionClass = new $descriptionClass(); //============================================= } if (isset($unserializedParam['idCategory'])) { $idCategory = $unserializedParam['idCategory']; SessionProxy::SetValue('idCategory', $idCategory); } //Utils::ArrayDisplay($idCategory); if ($method == 'Index') { $idContent = '-1'; $data = array('lang' => $lang); if ($idCategory) { $idsContent = MfLinkDAL::GetIdString($tableModuleName, $tableModuleName . '_category', $idCategory); $categoryData = array($tableModuleName . '.id_' . $tableModuleName => array('condition' => 'IN', 'value' => $idsContent)); } else { $idsContent = '()'; $categoryData = array(); } //Utils::ArrayDisplay($arrayLinkedIdToCategory); $data = array_merge($data, $categoryData); $arrayObj = $classDAL->GetResult($data, array()); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); $this->smarty->assign('arrayObj', $arrayObj); $this->smarty->assign('idElement', $objElement->GetId()); $content = $this->smarty->fetch('partial/' . $catalog . '/StructureList.tpl'); } else { if ($objElement->GetIdContent() > 0) { $obj = $classDAL->GetById($objElement->GetIdContent()); ///$obj->SetLang($lang); //$tmpObj = $classDAL->GetEmptyObj(); $obj->SetDescription($descriptionClassNameDAL->GetEmptyObj()); $idContent = $objElement->GetIdContent(); } $this->smarty->assign('obj', $obj); $this->smarty->assign('tableModuleName', $tableModuleName); $this->smarty->assign('lang', $lang); //Utils::ArrayDisplay($objElement); $content = $this->smarty->fetch('partial/' . $catalog . '/StructureEdit.tpl'); } $arraySpectacle = array(); //MfLinkDAL::GetArrayList('ts_spectacle_description', 'title', 'ts_spectacle', $lang, $tableModuleName, $idContent); $arrayPerson = MfLinkDAL::GetArrayList('mf_person_description', 'surname', 'mf_person', 'pl', $tableModuleName, $idContent); $arrayCategory = MfLinkDAL::GetArrayList($tableModuleName . '_category_description', 'name', $tableModuleName . '_category', 'pl', $tableModuleName, $idContent); $objElement = new Structure('-1'); $objMetaTag = new MfMetaTag(); $objMetaTag->SetDescriptionObj(MfMetaTagDescriptionDAL::GetEmptyObj()); $this->smarty->assign('content', $content); $this->smarty->assign('method', $method); $this->smarty->assign('idCategoryChecked', ''); $this->smarty->assign('tableModuleNameCategory', $tableModuleNameCategory); $this->smarty->assign('objElement', $objElement); $this->smarty->assign('objMetaTag', $objMetaTag); $this->smarty->assign('arrayPerson', $arrayPerson); $this->smarty->assign('arraySpectacle', $arraySpectacle); $this->smarty->assign('arrayCategory', $arrayCategory); $this->smarty->assign('idContent', $idContent); $this->smarty->assign('module', $module); $this->partialTemplate = 'Edit.tpl'; // Utils::ArrayDisplay($tableModuleName); } /** * TODO: Do czego to chyba niepotrzebne!!! */ public function AjaxSaveElementAction() { header('Content-Type: text/html; charset=utf-8'); $this->SetAjaxRender(); $lang = SessionProxy::GetValue('lang'); $objModule = SessionProxy::GetValue('objModule'); //Utils::ArrayDisplay($lang); if (Request::IsPost()) { $out = array(); $validator = new Validator(Request::GetAllPost()); $data = Request::GetAllPost(); $validator->IsEmpty('title', 'To pole nie może być puste'); //$validator -> IsEmpty('datepublication','To pole nie może być puste'); $param['submitForm'] = 'walidacja'; $out = $validator->GetErrorList(); //Utils::ArrayDisplay($out); if (empty($out)) { $class = $objModule->GetClassModuleName(); $descriptionClass = $class . 'Description'; $module = $objModule->GetModuleName(); $method = $objModule->GetMethodName(); $tableModuleName = $objModule->GetTableModuleName(); $controller = $objModule->GetController(); $catalog = $objModule->GetCatalog(); $options = unserialize($objModule->GetOptions()); $defaultUrl = isset($options['defaultUrl']) ? $options['defaultUrl'] : 'artykul'; //-====wywołanie klasy kontentu======================================== $className = $class . 'DAL'; $classDAL = new $className(); $descriptionClassName = $descriptionClass . 'DAL'; if (class_exists($descriptionClassName)) { $descriptionClassNameDAL = new $descriptionClassName(); $objDescriptionClass = new $descriptionClass(); $arrayFields = $objDescriptionClass->GetFields(); } $post = $_POST; //$post = Request::GetAllPost(); //Utils::ArrayDisplay($_POST); $publication = Request::Get('publication'); $publicationMenu = Request::Get('publication_menu'); $publication ? $publication = 1 : $publication = '0'; $publicationMenu ? $publicationMenu = 1 : $publicationMenu = '0'; //Utils::ArrayDisplay('=> '.$publication); //================================ $url = $post['url']; $id = $post['id']; if ($url) { $matchUri = "(/$url)"; } else { if ($method == 'Index') { $matchUri = "((/)(..)(/$defaultUrl/id/)(.*))"; } else { $url = Utils::ClearString($_POST['title']); $matchUri = "(/$url)"; } } if ($method == 'Index') { $idCategory = SessionProxy::GetValue('idCategory'); $idContent = ''; //====== parametry potrzebne do wywołania treści $paramSet = "idCategory:" . $idCategory; //============================== $paramText = array(); $paramText = explode(',', $paramSet); foreach ($paramText as $item) { $item = explode(':', $item); if (isset($item[0]) && isset($item[1])) $paramArray = array($item[0] => $item[1]); } } else { $idCategory = SessionProxy::GetValue('idCategory'); if (Request::GetPost('id_' . $tableModuleName) > 0) { $obj = $classDAL->GetById(Request::GetPost('id_' . $tableModuleName)); //Utils::ArrayDisplay($obj); if (class_exists($descriptionClassName)) { $objDescription = $descriptionClassNameDAL->GetResult(array('publication' => 1, 'lang' => $lang, 'id_' . $tableModuleName => $obj->GetId()), array()); if (isset($objDescription[0])) { $objDescription = $objDescription[0]; } else { $objDescription = new $descriptionClass(); } } } else { $obj = new $class(); if (class_exists($descriptionClassName)) { $objDescription = new $descriptionClass(); } } if (class_exists($descriptionClassName)) { $idDescription = $objDescription->GetId(); } $obj->SetDate(date('Y-m-d')); $obj->SetWeight(10); $obj->SetPublication($publication); //dla testów $_REQUEST['descriptionHidden'] = addslashes($_REQUEST['descriptionHidden']); $idContent = $classDAL->Save($obj); if (class_exists($descriptionClassName)) { foreach ($arrayFields as $postname => $name) { $objMethodName = 'Set' . ucfirst($name); $postname = $postname == 'description' ? $postname . 'Hidden' : $postname; $postname = $postname == 'shortnote' ? $postname . 'Hidden' : $postname; $postname = $name == 'description' ? addslashes($postname) : $postname; $objDescription->$objMethodName(Request::Get($postname, false)); //Utils::ArrayDisplay(Request::Get($postname, true)); } // if ($module == "SimpleArticle") { // $objDescription->Set // } //Utils::ArrayDisplay($objDescription); $objMethodName = 'Set' . ucfirst($arrayFields['id_' . $tableModuleName]); $objDescription->$objMethodName($idContent); $objDescription->SetId($idDescription); $objDescription->SetPublication(1); //Utils::ArrayDisplay($objDescription); $descriptionClassNameDAL->Save($objDescription); } $idCategory = SessionProxy::GetValue('idCategory'); if ($idCategory) { $objLink = new MfLink('-1'); $objLink->SetSourceType($tableModuleName); $objLink->SetIdSource($idContent); $objLink->SetDestinationType($tableModuleName . '_category'); $objLink->SetIdDestination($idCategory); $objLink->SetLinkType(1); //Utils::ArrayDisplay($idCategory); MfLinkDAL::Save($objLink); } elseif ($module == 'Stage') { $objLink = new MfLink('-1'); $objLink->SetSourceType($tableModuleName); $objLink->SetIdSource($idContent); $objLink->SetDestinationType('ts_stage'); $objLink->SetIdDestination($post['id_stage']); $objLink->SetLinkType(1); //Utils::ArrayDisplay($idCategory); MfLinkDAL::Save($objLink); } else { $arrayLink = array(); if (isset($_POST[$tableModuleName . '_category_link'])) { $arrayLink = $_POST[$tableModuleName . '_category_link']; //Utils::ArrayDisplay($arrayLink); } foreach ($arrayLink as $idDestination) { $objLink = new MfLink('-1'); $objLink->SetSourceType($tableModuleName); $objLink->SetIdSource($idContent); $objLink->SetDestinationType($tableModuleName . '_category'); $objLink->SetIdDestination($idDestination); $objLink->SetLinkType(1); //Utils::ArrayDisplay($idCategory); MfLinkDAL::Save($objLink); } } //====== parametry potrzebne do wywołania treści $paramSet = "id:" . $idContent; //============================== $paramText = array(); $paramText = explode(',', $paramSet); foreach ($paramText as $item) { $item = explode(':', $item); if (isset($item[0]) && isset($item[1])) $paramArray = array($item[0] => $item[1]); } } //=====TODO: pobieranie zawartości boxów z tabelki z danymi $actionSet = array(); // $actionSetText = $post['actionSet']; // $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]); // } //===zapis=routera==================== $router = new MfRouter($post['idRouter']); $router->SetController($controller); $router->SetMethod($method); $router->SetUrl($matchUri); $router->SetParam(serialize($paramArray)); $router->SetConfig(serialize(array('module' => $module, 'actionSet' => $actionSet))); $router->SetIdMfModule($objModule->GetId()); $idRouter = MfRouterDAL::Save($router); if (empty($idContent)) { $idContent = 0; } //==zapis struktuy============================================== $objElement = new Structure($id, $idContent, $post['idParent'], $post['idMain'], $idRouter, $lang, $post['sort'], (isset($post['publication']) ? 1 : 0), $post['title'], $post['menuName'], $url); $objElement->SetPublicationMenu($publicationMenu); $objElement->SetType($post['type']); $objElement->SetBanner($post['photo']); $idStructure = StructureDAL::Save($objElement); SessionProxy::SetValue('idStructure', $idStructure); $paramSet = "idStructure:" . $idStructure; //============================== $paramText = array(); $paramText = explode(',', $paramSet); foreach ($paramText as $item) { $item = explode(':', $item); if (isset($item[0]) && isset($item[1])) $paramArray = array($item[0] => $item[1]); } MfRouterDAL::UpdateParamPush($idRouter, $paramArray); //==zapis=META TAG========================================= $objMetaTag = MfMetaTagDAL::GetResult(array('id_source' => $idStructure), array()); //Utils::ArrayDisplay($objMetaTag); if (isset($objMetaTag[0])) { $objMetaTag = $objMetaTag[0]; } else { $objMetaTag = new MfMetaTag(); $objMetaTag->SetIdSource($idStructure); $objMetaTag->SetSourceType($tableModuleName); } $idMetaTag = MfMetaTagDAL::Save($objMetaTag); $objMetaTagDescription = MfMetaTagDescriptionDAL::GetResult(array('id_mf_meta_tag' => $idMetaTag), array()); if (isset($objMetaTagDescription[0])) { $objMetaTagDescription = $objMetaTagDescription[0]; } else { $objMetaTagDescription = new MfMetaTagDescription(); } $objMetaTagDescription->SetIdMfMetaTag($idMetaTag); $objMetaTagDescription->SetKeywords($post['meta_keywords']); $objMetaTagDescription->SetDescription($post['meta_description']); $objMetaTagDescription->SetStatistic($post['statistic']); $objMetaTagDescription->SetLang($lang); MfMetaTagDescriptionDAL::Save($objMetaTagDescription); //--------------------------------------------------------- if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/")) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/"); } if (!is_dir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure)) { mkdir(PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure); } //Utils::ArrayDisplay(PATH_STATIC_CONTENT."/temp/".$idStage."/".$Stage->GetPicture()); if (file_exists(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner())) { rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBanner(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBanner()); rename(PATH_STATIC_CONTENT . "/temp/" . $objElement->GetBannerTh(), PATH_STATIC_CONTENT . "/upload/Structure/" . $idStructure . "/" . $objElement->GetBannerTh()); } Router::GenerateDbRoutes(); $this->smarty->assign('id', $idStructure); } else { //$this->content=$this->FormatAjaxOutput($out, $param); //Utils::ArrayDisplay($out); } } $this->smarty->assign('out', $out); } /** * * @param type $param * TODO: Do czego to!!! */ public function MainSiteAction($param) { $this->AddScript('dropDown.js'); $this->SetAjaxRender(); $lang = SessionProxy::GetValue('lang'); 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); } /** * * @param type $param * TODO: zautoamtyzować Id z posta!! */ public function AjaxGetModuleCategoryAction($param) { header('Content-Type: text/html; charset=utf-8'); $this->SetAjaxRender(); $lang = SessionProxy::GetValue('lang'); $arrayModuleCategory = array(); //Utils::ArrayDisplay($_POST); if ($_POST['id'] > 0 && $_POST['id'] != 1 && $_POST['id'] != 4 && $_POST['id'] != 8 && $_POST['id'] != 16 && $_POST['id'] != 14) { //if ($_POST['id'] > 0 && $_POST['id'] != 8) { //Utils::ArrayDisplay($_POST); $objModule = MfModuleDAL::GetById($_POST['id']); //Utils::ArrayDisplay($objModule); // $arrayModuleOptions = $objModule->GetArrayOptions(); // if (key_exists('categoryType', $arrayModuleOptions)) { // $where = " AND type = ".$arrayModuleOptions['categoryType']." "; // } else { // $where = " AND type = 1"; // } $where = " "; if ($objModule->GetModuleName() == 'SimpleArticle') { $arrayModuleCategory = Utils::GetArrayList($objModule->GetTableModuleName() . '_category_description', 'id_' . $objModule->GetTableModuleName() . '_category', 'name', 'pl', ' AND id_' . $objModule->GetTableModuleName() . '_category NOT IN (1) AND publication = 1 '.$where); } else { $arrayModuleCategory = Utils::GetArrayList($objModule->GetTableModuleName() . '_category_description', 'id_' . $objModule->GetTableModuleName() . '_category', 'name', $lang, ' AND publication = 1 '); } //Utils::ArrayDisplay($_POST); // Utils::ArrayDisplay($param); //Utils::ArrayDisplay($arrayModuleCategory); } $this->smarty->assign('arrayModuleCategory', $arrayModuleCategory); //$moduleCategory = $this->smarty->fetch('partial/Structure/ModuleCategory.tpl'); //$this->smarty->assign('moduleCategory', $moduleCategory); } public function LinkAction($param) { $this->SetAjaxRender(); $post = Request::GetAllPost(); if ($post['action'] == 'add') { //Utils::ArrayDisplay($post); $objLink = new MfLink('-1'); $objLink->SetSourceType($post['source']); $objLink->SetIdSource($post['id']); $objLink->SetDestinationType($post['destynation']); $objLink->SetIdDestination($post['idDestynation']); //Utils::ArrayDisplay($objLink); MfLinkDAL::Save($objLink); } else { //Utils::ArrayDisplay('delete'); MfLinkDAL::DeleteFromLink($post['id'], $post['source'], $post['idDestynation'], $post['destynation']); } } public function DeleteAction($param) { //$this->SetAjaxRender(); $post = Request::GetAllPost(); $idStructure = SessionProxy::GetValue('idStructure'); if ($idStructure) { $objElenemt = StructureDAL::GetById($idStructure); $objRouter = MfRouterDAL::GetById($objElenemt->GetIdRouter()); if ($objElenemt->GetIdRouterDetail() && $objElenemt->GetIdRouterDetail() > 0) { $objRouterDetail = MfRouterDAL::GetById($objElenemt->GetIdRouterDetail()); } if ($objElenemt->GetIdRouterPage() && $objElenemt->GetIdRouterPage() > 0) { $objRouterPage = MfRouterDAL::GetById($objElenemt->GetIdRouterPage()); } $objRouter = MfRouterDAL::GetById($objElenemt->GetIdRouter()); $objRouter = MfRouterDAL::GetById($objElenemt->GetIdRouter()); if ($objElenemt->GetCopy() != 0) { $dalData = StructureDAL::GetDalDataObj(); $dalData->setCondition(array('copy' => $objElenemt->GetCopy())); $dalData->setCount(true); $countElement = StructureDAL::GetResult($dalData); } else { $countElement = 1; } if (!StructureDAL::CheckChildren($idStructure)) { StructureDAL::Delete($objElenemt); //Utils::ArrayDisplay($countElement); if ($countElement == 1) { //Utils::ArrayDisplay('usuwa'); MfRouterDAL::Delete($objRouter); if (isset($objRouterPage)) { MfRouterDAL::Delete($objRouterPage); } if (isset($objRouterDetail)) { MfRouterDAL::Delete($objRouterDetail); } } SessionProxy::ClearValue('idStructure'); $this->smarty->assign('deleteAction', false); } else { $this->smarty->assign('deleteAction', true); } } else { $this->smarty->assign('deleteError', true); } $this->AddRedirect(Router::GenerateUrl('structure', array()), 2); } /** * Sprawdzanie unikalno�ci pytania * * @param array $param */ public function AjaxCheckUniqueAction($param) { header('Content-Type: text/html; charset=utf8'); if ($_POST['value']) { $value = $_POST['value']; } else { $value = ""; } if ($_POST['column']) { $column = $_POST['column']; } else { $column = ""; } //Utils::ArrayDisplay($value); $unigue = Utils::CheckUnique('wp_news', $column, $value); if (!$unigue) { $this->smarty->assign("uniqueInfo", "1"); } $this->smarty->assign("column", $column); $template = 'clean.tpl'; Registry::Remove('smartyTemplate'); Registry::Set('smartyTemplate', $template); } 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('SimpleArticle_Index' => 'AjaxPhotoCropped'); if (isset($param['id'])) { $cutUrl['id'] = $param['id']; } $this->smarty->assign('cutUrl', $cutUrl); $this->smarty->assign('uploadUrl', array('SimpleArticle_Index' => 'AjaxPhotoUpload')); } public function AjaxPhotoUploadAction($param) { $this->SetAjaxRender(); $photoFile = $_FILES['photo']['tmp_name']; $photoSize = getimagesize($photoFile); if ($photoSize[0] < 180) { $error = $this->GetDictionary("photo_validator_width"); } else if ($photoSize[1] < 80) { $error = $this->GetDictionary("photo_validator_height"); } else if (filesize($photoFile) > self::MAX_AVATAR_FILE_SIZE * 1048576) { $error = $this->GetDictionary("photo_validator_size", array(self::MAX_AVATAR_FILE_SIZE)); } if (!MimeType::IsImage($_FILES['photo'])) { $error = $this->GetDictionary("photo_validator_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_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('SimpleArticle_Index' => '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, 180, 80); $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 { Request::SetCookie('photoFromUploader', pathinfo($idPhoto, PATHINFO_FILENAME), time() + 3600); } $this->smarty->assign('photoPath', $photo); } public function AjaxChangeLangAction($param) { $this->SetAjaxRender(); //Utils::ArrayDisplay($_POST); if ($_POST['lang']) { SessionProxy::SetValue('lang', $_POST['lang']); } //$this->AddRedirect(URL_MAIN, 0); //Utils::ArrayDisplay($_POST); } public function ChangeLangAction($param) { //$this->SetAjaxRender(); //Utils::ArrayDisplay($_POST); if ($_POST['lang']) { SessionProxy::SetValue('lang', $_POST['lang']); } $this->AddRedirect(Router::GenerateUrl('structureIndex', array('Structure' => 'Index')), 0); } public function AjaxAddModuleAction($param) { $this->SetAjaxRender(); //Utils::ArrayDisplay($param, "param: ".__FILE__.' - '.__LINE__); $lang = SessionProxy::GetValue('lang'); $post = Request::GetAllPost(); $objModule = new MfModule(); $objModule = MfModuleDAL::GetById($post['id']); //Utils::ArrayDisplay($objModule, "objModule: ".__FILE__.' - '.__LINE__); //Utils::ArrayDisplay($objCategory); SessionProxy::SetValue('moduleCategoryId', Request::GetPost('moduleCategoryId')); //Utils::ArrayDisplay(SessionProxy::GetValue('idCategory')); $this->smarty->assign('objModule', $objModule); $methodAdmin = $objModule->GetMethodAdminName(); if ($methodAdmin == 'Edit') { $methodAdmin = 'Add'; } $this->smarty->assign('objModuleAdd', $objModule); $this->smarty->assign('moduleCategoryId', Request::GetPost('moduleCategoryId')); //Utils::ArrayDisplay($methodAdmin); $param['runSharedVariable'] = 'moduleToAdd'; $param['moduleName'] = $objModule->GetModuleTitle(); $param['moduleNameCategory'] = ''; $param['modulePublication'] = 0; //TODO: pobierać pojedynczy obiekt if (Request::GetPost('moduleCategoryId')) { $arrayModuleCategory = Utils::GetArrayList($objModule->GetTableModuleName() . '_category_description', 'id_' . $objModule->GetTableModuleName() . '_category', 'name', $lang, ''); if (Request::GetPost('moduleCategoryId')) { $param['moduleName'] .= " - ".$arrayModuleCategory[Request::GetPost('moduleCategoryId')]; } } $param['newModule'] = 1; $param['text'] = true; $this->RunModuleController($objModule->GetController(), $methodAdmin . 'Structure', $param, true); SessionProxy::ClearValue('moduleCategoryId'); $this->smarty->assign('icon', false); } /** * Metoda wspolna * */ public function preDispatch($param) { $this->AddScript('structure.js'); $this->AddScript('drag-drop-folder-tree.js'); $this->AddScript('calendar.js'); //Utils::ArrayDisplay($param); //$this->Run($param); $this->AddScript('UploadFile.js'); $arrayModuleName = MfModuleDAL::GetArrayModuleName(); $this->smarty->assign('arrayModuleName', $arrayModuleName); $this->smarty->assign('showIcon', true); $this->RunShared('Auth', array()); $this->smarty->assign('activeTab', 'index'); $this->Run($param); $this->RunShared('Structure', $param); $location = SessionProxy::GetValue('location'); $this->smarty->assign('location', $location); switch ($location) { case '1': $this->smarty->assign('titleAdmin', 'Struktura strony'); Router::$typeRouterCache = '1'; Router::$dirRouterCache = '/Strona'; break; // case '2': // $this->smarty->assign('titleAdmin', 'Struktura strony - Play'); // Router::$typeRouterCache = '2'; // Router::$dirRouterCache = '/Play'; // break; } } /** * * */ public function postDispatch($param) { } private function renderStruct($struct) { $return = ''; foreach ($struct AS $k => $row) { $return .= '
  • ' . $k . '
  • '; } $html = ''; return $html; } public function SiteAction($param) { $dalObj = SiteDAL::GetDalDataObj(); $arraySite = SiteDAL::GetResult($dalObj); Utils::ArrayDisplay($arraySite); } } ?>