Beispiel #1
0
 public function executeSaveNewsI18n()
 {
     try {
         BackendService::objectSave($obj, $parent);
         $end_date = $obj->getEndDate();
         $obj->setEndDate(substr($end_date, 0, 11) . '23:59:59');
         $obj->save(null, $parent, $parameters["attrCulture"]);
         UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error");
     }
     $this->forward(strtolower($this->getRequestParameter('moduleName')), "edit" . $this->getRequestParameter('documentName'));
     exit;
 }
Beispiel #2
0
 public function executeSave()
 {
     try {
         $parameters = $this->getRequest()->getParameterHolder()->getAll();
         $parameters['documentName'] == "Folder" ? $moduleName = "Admin" : ($moduleName = $parameters['moduleName']);
         $documentName = $parameters["documentName"];
         $parent = Document::getDocumentInstance($parameters['parent']);
         if (is_numeric($parameters['id'])) {
             $obj = Document::getDocumentInstance($parameters['id']);
             $parent = Document::getParentOf($parameters['id']);
         } else {
             $obj = new $documentName();
         }
         include_once sfConfig::get('sf_root_dir') . "/config/Schema.class.php";
         $m = "get" . $documentName . "Properties";
         $properties = Schema::$m();
         //exit(var_dump($properties));
         $imageFields = explode(",", $parameters['imageFields']);
         /*foreach ($parameters as $property)
         		{
         			$function = 'set'.$property;
         			$obj->$function();
         		}*/
         foreach ($parameters as $key => $value) {
             if (!(strpos($key, 'attr') === false) && $key != "attrRewriteUrl") {
                 $key = str_replace('attr', '', $key);
                 if ($properties && $key != "Password" && !in_array($key, $properties)) {
                     continue;
                 }
                 if ($key == "Password" && empty($value)) {
                     continue;
                 }
                 $function = 'set' . $key;
                 if (is_array($value)) {
                     $date = $value['year'] . '-' . $value['month'] . '-' . $value['day'];
                     // 2009-02-09 16:10:20
                     if ($value['hour'] && $value['minute']) {
                         $time = $value['hour'] . ':' . $value['minute'];
                         $value = $date . ' ' . $time;
                     } else {
                         $value = $date;
                     }
                 }
                 if (in_array($key, $imageFields)) {
                     $getFunction = 'get' . $key;
                     $imgId = $obj->{$getFunction}();
                     if ($imgId != $value) {
                         $img = Document::getDocumentInstance($imgId);
                         if ($img) {
                             $imgExt = $img->getExtention();
                             @unlink(sfConfig::get('sf_root_dir') . "/www/media/upload/thumbs/" . $parameters["moduleName"] . "/" . $imgId . "-" . $key . "." . $imgExt);
                         }
                     }
                 }
                 if ($key == "Keywords") {
                     if ($value) {
                         $value = str_replace(',', '][', $value);
                         $value = '[' . substr($value, 0, -1);
                     }
                 }
                 $obj->{$function}($value);
             }
             if (in_array($key, $imageFields) && !empty($value)) {
                 $image = Document::getDocumentInstance($value);
                 if ($image) {
                     if (empty($parameters[$key . '_thumbheight'])) {
                         $parameters[$key . '_thumbheight'] = null;
                     }
                     if (empty($parameters[$key . '_thumbwidth'])) {
                         $parameters[$key . '_thumbwidth'] = null;
                     }
                     $image->resizeImage($parameters["moduleName"], $parameters[$key . '_thumbheight'], $parameters[$key . '_thumbwidth'], $key);
                 }
             }
         }
         if (class_exists($documentName . "I18n") && $documentName != "Listitem") {
             if (!($culture = $parameters["attrCulture"])) {
                 $culture = Document::getDocumentByExclusiveTag("default_culture");
                 if ($culture) {
                     $culture = $culture->getValue();
                 } else {
                     throw new Exception("No default culture defined");
                 }
             }
             $obj->save(null, $parent, $culture);
             if (!$parameters["id"]) {
                 if (class_exists($documentName . "I18n")) {
                     BackendService::objectSave($objI8n, $obj, $documentName . "I18n");
                     if ($documentName == "Page") {
                         $objI8n->setRewriteUrl($parameters["attrRewriteUrl"]);
                     }
                     $objI8n->setCulture($culture);
                     $objI8n->save(null, $obj, $culture);
                 }
                 $request = $this->getRequest();
                 $request->setParameter("id", $obj->getId());
             }
         } else {
             $obj->save(null, $parent);
         }
         $tags = Document::getAvailableTagsOf($moduleName, $parameters['documentName']);
         foreach ($tags as $tag) {
             if ($parameters['tag_id_' . $tag->getId()]) {
                 Document::addTag($obj, $tag->getTagId());
             } else {
                 Document::removeTag($obj, $tag->getTagId());
             }
         }
         Tagrelation::updateTagRelationCache();
         UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error");
     }
     $this->forward(strtolower($moduleName), "edit" . $parameters['documentName']);
     exit;
 }
Beispiel #3
0
 public function executeSavePageI18n()
 {
     try {
         $pageType = $this->getRequestParameter("attrPageType");
         if (!$pageType) {
             $request = $this->getRequest();
             $request->setParameter('attrPageType', 'CONTENT');
         }
         BackendService::objectSave($obj, $parent);
         $obj->setRewriteUrl($this->getRequestParameter("attrRewriteUrl"));
         if (!$this->getRequestParameter("attrIsSecure")) {
             $obj->setIsSecure(NULL);
         }
         $obj->save(null, $parent, $this->getRequestParameter("attrCulture"));
         Urlrewrite::updateUrlRelationCache();
         UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error");
     }
     $this->forward(strtolower($this->getRequestParameter('moduleName')), "edit" . $this->getRequestParameter('documentName'));
     exit;
 }