public function addAction() { // variables $pageID = $this->_getParam('pageID'); $blockID = $this->_getParam('blockID'); $returnAction = $this->_getParam('return'); $baseDir = $this->view->baseUrl(); if (empty($pageID)) { $categoriesList = 'true'; } else { $categoriesList = 'false'; } if ($returnAction) { $returnUrl = "/events/index/{$returnAction}"; } elseif ($blockID) { $returnUrl = "/events/index/list/blockID/{$blockID}/pageID/{$pageID}"; } else { $returnUrl = "/events/index/list-all/"; } if ($this->view->aclIsAllowed('events', 'edit', true)) { $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($formData['ImageSrc'] != "") { $imageSrc = Zend_Registry::get("www_root") . "/data/images/event/tmp/mcith/mcith_" . $formData['ImageSrc']; } } // generate the form $form = new FormEvents(array('baseDir' => $baseDir, 'imageSrc' => $imageSrc, 'cancelUrl' => "{$baseDir}{$returnUrl}", 'categoriesList' => "{$categoriesList}", 'eventID' => '', 'isNewImage' => true)); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { if (!empty($pageID)) { $blockParameters = Cible_FunctionsBlocks::getBlockParameters($blockID); $formData['CategoryID'] = $blockParameters[0]['P_Value']; } else { $formData['CategoryID'] = $this->_getParam('Param1'); } if ($formData['Status'] == 0) { $formData['Status'] = 2; } $eventsObject = new EventsObject(); $formattedName = Cible_FunctionsGeneral::formatValueForUrl($formData['Title']); $formData['ValUrl'] = $formattedName; $eventID = $eventsObject->insert($formData, Zend_Registry::get("currentEditLanguage")); /*IMAGES*/ mkdir("../../{$this->_config->document_root}/data/images/event/" . $eventID) or die("Could not make event directory"); mkdir("../../{$this->_config->document_root}/data/images/event/" . $eventID . "/tmp") or die("Could not make tmp directory"); if ($form->getValue('ImageSrc') != '') { $config = Zend_Registry::get('config')->toArray(); $srcOriginal = "../../{$this->_config->document_root}/data/images/event/tmp/" . $form->getValue('ImageSrc'); $originalMaxHeight = $config['event']['image']['original']['maxHeight']; $originalMaxWidth = $config['event']['image']['original']['maxWidth']; $originalName = str_replace($form->getValue('ImageSrc'), $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc')); $srcMedium = "../../{$this->_config->document_root}/data/images/event/tmp/medium_{$form->getValue('ImageSrc')}"; $mediumMaxHeight = $config['event']['image']['medium']['maxHeight']; $mediumMaxWidth = $config['event']['image']['medium']['maxWidth']; $mediumName = str_replace($form->getValue('ImageSrc'), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc')); $srcThumb = "../../{$this->_config->document_root}/data/images/event/tmp/thumb_{$form->getValue('ImageSrc')}"; $thumbMaxHeight = $config['event']['image']['thumb']['maxHeight']; $thumbMaxWidth = $config['event']['image']['thumb']['maxWidth']; $thumbName = str_replace($form->getValue('ImageSrc'), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc')); copy($srcOriginal, $srcMedium); copy($srcOriginal, $srcThumb); Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight)); Cible_FunctionsImageResampler::resampled(array('src' => $srcMedium, 'maxWidth' => $mediumMaxWidth, 'maxHeight' => $mediumMaxHeight)); Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight)); rename($srcOriginal, "../../{$this->_config->document_root}/data/images/event/{$eventID}/{$originalName}"); rename($srcMedium, "../../{$this->_config->document_root}/data/images/event/{$eventID}/{$mediumName}"); rename($srcThumb, "../../{$this->_config->document_root}/data/images/event/{$eventID}/{$thumbName}"); } /**********************/ if (!empty($pageID)) { //$blockData = Cible_FunctionsBlocks::getBlockDetails($blockID); //$blockStatus = $blockData['B_Online']; $indexData['pageID'] = $formData['CategoryID']; $indexData['moduleID'] = $this->_moduleID; $indexData['contentID'] = $eventID; $indexData['languageID'] = Zend_Registry::get("currentEditLanguage"); $indexData['title'] = $formData['Title']; $indexData['text'] = ''; $indexData['link'] = ''; $indexData['contents'] = $formData['Title'] . " " . $formData['Brief'] . " " . $formData['Text'] . " " . $formData['ImageAlt']; if ($formData['Status'] == 1) { $indexData['action'] = 'update'; } else { $indexData['action'] = 'delete'; } Cible_FunctionsIndexation::indexation($indexData); } // redirect if (!empty($pageID)) { $this->_redirect("/events/index/list/blockID/{$blockID}/pageID/{$pageID}"); } else { $this->_redirect($returnUrl); } } else { $form->populate($formData); } } } }