public function saveContent($data, $publish = true) { $recordId = $data->__id; $model = $data->__model; $document = org_glizy_objectFactory::createModel($model); $result = $document->load($recordId, 'LAST_MODIFIED'); if (!$result) { $languageProxy = __ObjectFactory::createObject('org.glizycms.languages.models.proxy.LanguagesProxy'); $defaultLanguageId = $languageProxy->getDefaultLanguageId(); $document->load($recordId, 'LAST_MODIFIED', $defaultLanguageId); $document->setLanguage($languageProxy->getLanguageId()); } if (property_exists($data, 'title')) { $document->title = $data->title; } if (property_exists($data, 'url')) { $document->url = $data->url; } $document->fulltext = org_glizycms_core_helpers_Fulltext::make($data, $document, true); try { if ($publish) { $id = $document->publish(); } else { if (__Config::get('glizycms.content.history')) { $id = $document->saveHistory(); } else { $id = $document->save(); } } if (__Config::get('ACL_MODULES')) { // gestione acl record $ar = org_glizy_objectFactory::createModel('org.glizycms.contents.models.DocumentACL'); $ar->load($id); $ar->__aclEdit = $data->__aclEdit; $ar->__aclView = $data->__aclView; $ar->save(); } } catch (org_glizy_validators_ValidationException $e) { return $e->getErrors(); } return array('__id' => $id); }
function execute_step4($oldState) { $model = __Request::get('mbTable') . '.models.Model'; $ar = __ObjectFactory::createModel($model); // reindicizza se necessario if (method_exists($ar, 'reIndex')) { $it = __ObjectFactory::createModelIterator($model); foreach ($it as $ar) { $ar->reIndex(); $data = $ar->getValuesAsArray(); $ar->fulltext = org_glizycms_core_helpers_Fulltext::make($data, $ar); $ar->forceModified('fulltext'); $ar->save(); } } }