Beispiel #1
0
 function __construct($data)
 {
     $languageProxy = __ObjectFactory::createObject('org.glizycms.languages.models.proxy.LanguagesProxy');
     $index = null;
     if (is_array($data[self::DOCUMENT_DETAIL_STATUS])) {
         $index = array_search('PUBLISHED', $data[self::DOCUMENT_DETAIL_STATUS]);
         $this->hasPublishedVersion = $index !== FALSE;
         $indexDraft = array_search('DRAFT', $data[self::DOCUMENT_DETAIL_STATUS]);
         $this->hasDraftVersion = $indexDraft !== FALSE;
         if (!$this->hasPublishedVersion) {
             $index = $indexDraft;
         }
     }
     if ($index && $data['document_detail_FK_language_id'][$index] != $languageProxy->getLanguageId()) {
         $data['document_detail_FK_language_id'][$index] = $languageProxy->getLanguageId();
         $data['document_detail_translated'][$index] = 0;
     }
     foreach ($data as $k => $v) {
         if (is_array($v)) {
             $this->data[$k] = $v[$index];
         } else {
             $this->data[$k] = $v;
         }
     }
 }
 protected function initQueryBuilder()
 {
     if ($this->options['type'] == 'PUBLISHED_DRAFT') {
         $options = array('type' => 'PUBLISHED_DRAFT', 'tableAlias' => self::DOCUMENT_TABLE_ALIAS, 'tableDetailPublishedAlias' => self::DOCUMENT_DETAIL_TABLE_PUBLISHED_ALIAS, 'tableDetailDraftAlias' => self::DOCUMENT_DETAIL_TABLE_DRAFT_ALIAS);
         $this->qb = $this->ar->createQueryBuilder($options);
         $languageProxy = __ObjectFactory::createObject('org.glizycms.languages.models.proxy.LanguagesProxy');
         $defaultLanguageId = $languageProxy->getDefaultLanguageId();
         if ($defaultLanguageId != $this->ar->getLanguageId()) {
             $this->qb->select(self::DOCUMENT_TABLE_ALIAS . '.*', self::DOCUMENT_DETAIL_TABLE_PUBLISHED_ALIAS . '.*', self::DOCUMENT_DETAIL_TABLE_DRAFT_ALIAS . '.*', self::DOCUMENT_DETAIL_TABLE_PUBLISHED_ALIAS . '_defaultLanguage.*', self::DOCUMENT_DETAIL_TABLE_DRAFT_ALIAS . '_defaultLanguage.*');
         } else {
             $this->qb->select(self::DOCUMENT_TABLE_ALIAS . '.*', self::DOCUMENT_DETAIL_TABLE_PUBLISHED_ALIAS . '.*', self::DOCUMENT_DETAIL_TABLE_DRAFT_ALIAS . '.*');
         }
         $this->statusSet = true;
         $this->languageSet = true;
     } else {
         $options = array('type' => 'PUBLISHED', 'tableAlias' => self::DOCUMENT_TABLE_ALIAS, 'tableDetailAlias' => self::DOCUMENT_DETAIL_TABLE_ALIAS);
         $this->qb = $this->ar->createQueryBuilder($options);
         $this->qb->select(self::DOCUMENT_TABLE_ALIAS . '.*', self::DOCUMENT_DETAIL_TABLE_ALIAS . '.*');
         $this->statusSet = false;
         $this->languageSet = false;
     }
     $this->hasSelect = true;
     $this->hasLimit = false;
     $this->typeSet = false;
     $this->visibilitySet = false;
     $this->conditionsMap = array();
 }
Beispiel #3
0
 function execute($languages, $menuIdArray, $title, $subtitle, $creditPageId, $isExhibitionActive)
 {
     if ($this->user->isLogged()) {
         $languages = is_array($languages) ? $languages : array($languages);
         $exportPath = __Paths::get('CACHE') . 'export/';
         $mediaPath = $exportPath . 'media/';
         $graphPath = $exportPath . 'graph/';
         $zipFolder = __Paths::get('BASE') . 'export/';
         $zipFile = $zipFolder . 'mobileContents.zip';
         $creditPageId = str_replace('internal:', '', $creditPageId);
         $steps = array();
         $steps[] = array('action' => 'PrepareExport', 'params' => array('exportPath' => $exportPath, 'languages' => $languages, 'mediaPath' => $mediaPath, 'graphPath' => $graphPath, 'zipFolder' => $zipFolder, 'zipFile' => $zipFile));
         $steps[] = array('action' => 'ExportCodes');
         foreach ($languages as $languageId) {
             $ar = __ObjectFactory::createModel('org.glizycms.core.models.Language');
             $ar->load($languageId);
             $sqliteDb = $exportPath . $ar->language_name . '.db';
             $languageCode = $ar->language_code;
             $steps[] = array('action' => 'Export', 'params' => array('mediaPath' => $mediaPath, 'languageId' => $languageId, 'languageCode' => $languageCode, 'menuIdArray' => $menuIdArray, 'title' => $title, 'subtitle' => $subtitle, 'creditPageId' => $creditPageId, 'isExhibitionActive' => $isExhibitionActive));
             $steps[] = array('action' => 'Mysql2Sqlite', 'params' => array('exportPath' => $exportPath, 'sqliteDb' => $sqliteDb));
         }
         $steps[] = array('action' => 'CreateJSON', 'params' => array('exportPath' => $exportPath, 'languages' => $languages));
         $steps[] = array('action' => 'CreateZip', 'params' => array('exportPath' => $exportPath, 'mediaPath' => $mediaPath, 'zipFile' => $zipFile));
         return $steps;
     }
 }
Beispiel #4
0
 /**
  * Read the content for a menu
  *
  * NOTA: per velocizzare non viene controllato se il menù esiste
  * quindi se il menù non esiste oppure se non ci sono contenuti
  * ritorna un oggetto nullo
  *
  * @param  int  $menuId     Menu id
  * @param  int  $languageId Language id
  * @return org_glizycms_contents_models_Content   Content
  */
 public function readRawContentFromMenu($menuId, $languageId)
 {
     $it = org_glizy_objectFactory::createModelIterator('org.glizycms.core.models.Content');
     $it->setOptions(array('type' => 'PUBLISHED_DRAFT'));
     $menuDocument = $it->where('id', $menuId)->first();
     if (!$menuDocument) {
         $languageProxy = __ObjectFactory::createObject('org.glizycms.languages.models.proxy.LanguagesProxy');
         $it = org_glizy_objectFactory::createModelIterator('org.glizycms.core.models.Content')->setOptions(array('type' => 'PUBLISHED_DRAFT'))->whereLanguageIs($languageProxy->getDefaultLanguageId())->where('id', $menuId);
         $menuDocument = $it->first(true);
     }
     return $menuDocument;
 }
Beispiel #5
0
 function execute($exportPath, $languages)
 {
     if ($this->user->isLogged()) {
         $json = array();
         foreach ($languages as $language) {
             $ar = __ObjectFactory::createModel('org.glizycms.core.models.Language');
             $ar->load($language);
             $languageObj = new StdClass();
             $languageObj->code = $ar->language_code;
             $languageObj->label = $ar->language_name;
             $languageObj->file = $ar->language_name . '.db';
             $json[] = $languageObj;
         }
         file_put_contents($exportPath . 'package.json', json_encode($json));
     }
 }
 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);
 }
Beispiel #7
0
 function execute($exportPath, $languages, $mediaPath, $graphPath, $zipFolder, $zipFile)
 {
     if ($this->user->isLogged()) {
         org_glizy_helpers_Files::deleteDirectory($exportPath);
         @unlink($zipFile);
         @mkdir($exportPath);
         @mkdir($mediaPath);
         @mkdir($graphPath);
         @mkdir($graphPath . 'document');
         foreach ($languages as $language) {
             $ar = __ObjectFactory::createModel('org.glizycms.core.models.Language');
             $ar->load($language);
             @mkdir($graphPath . $ar->language_code);
             @mkdir($graphPath . 'document/' . $ar->language_code);
         }
         @mkdir($zipFolder);
         @chmod($zipFolder, 0777);
         $mobileCodesTable = __Config::get('movio.modules.publishApp.mobileCodesTable');
         org_glizy_dataAccessDoctrine_DataAccess::truncateTable($mobileCodesTable);
     }
 }
 public function createQueryBuilder($options)
 {
     $qb = $this->connection->createQueryBuilder();
     if ($options['type'] == 'PUBLISHED') {
         $tableAlias = self::DOCUMENT_TABLE_ALIAS;
         $tableDetailAlias = self::DOCUMENT_DETAIL_TABLE_ALIAS;
         $qb->from($this->getDocumentTableName(), $tableAlias)->join($tableAlias, $this->getDocumentDetailTableName(), $tableDetailAlias, $qb->expr()->eq($tableAlias . '.' . self::DOCUMENT_ID, $tableDetailAlias . '.' . self::DOCUMENT_DETAIL_FK_DOCUMENT));
     } else {
         if ($options['type'] == 'PUBLISHED_DRAFT') {
             $tableAlias = $options['tableAlias'];
             $tableDetailPublishedAlias = $options['tableDetailPublishedAlias'];
             $tableDetailDraftAlias = $options['tableDetailDraftAlias'];
             $this->queryBuilderJoinDetail($qb, $tableAlias, $tableDetailPublishedAlias, self::STATUS_PUBLISHED, ':language');
             $this->queryBuilderJoinDetail($qb, $tableAlias, $tableDetailDraftAlias, self::STATUS_DRAFT, ':language');
             $qb->setParameter(':language', $this->getLanguageId());
             $languageProxy = __ObjectFactory::createObject('org.glizycms.languages.models.proxy.LanguagesProxy');
             $defaultLanguageId = $languageProxy->getDefaultLanguageId();
             if ($defaultLanguageId != $this->getLanguageId()) {
                 $this->queryBuilderJoinDetail($qb, $tableAlias, $tableDetailPublishedAlias . '_defaultLanguage', self::STATUS_PUBLISHED, ':defaultLanguage');
                 $this->queryBuilderJoinDetail($qb, $tableAlias, $tableDetailDraftAlias . '_defaultLanguage', self::STATUS_DRAFT, ':defaultLanguage');
                 $qb->setParameter(':defaultLanguage', $defaultLanguageId);
             }
         }
     }
     return $qb;
 }
Beispiel #9
0
 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();
         }
     }
 }
Beispiel #10
0
 public function export($languageId = 1, $languageCode = null, $menuIdArray = array(), $title = null, $subtitle = null, $creditPageId = null, $isExhibitionActive = null)
 {
     __Paths::set('APPLICATION_TEMPLATE_DEFAULT', __Paths::get('STATIC_DIR') . 'movio/templates/Default/');
     $menuIdArray = array_flip($menuIdArray);
     $menuIdArray = array_fill_keys(array_keys($menuIdArray), 1);
     $this->medias = array();
     $contentProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.ContentProxy');
     // scorre tutti i menù
     $menus = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Menu');
     $menus->load('getAllMenu', array('params' => array('languageId' => $languageId)));
     foreach ($menus as $ar) {
         $menuId = $ar->menu_id;
         // salta tutte le pagine che non sono in menuIdArray
         if (!$menuIdArray[$menuId]) {
             continue;
         }
         $contentVO = $contentProxy->readContentFromMenu($menuId, $languageId);
         $contentJson = array();
         foreach ($contentVO as $k => $v) {
             if ($k == '__title') {
                 $contentJson['title'] = $v;
                 continue;
             }
             if (@strpos($k, '__') === 0) {
                 continue;
             }
             if (is_object($v)) {
                 $contentJson[$k] = $this->convertObjectToArray($v);
             } else {
                 if (@strpos($v, '{"id"') === 0) {
                     $v = $this->addMedia($v);
                 }
                 $contentJson[$k] = $v;
             }
         }
         $arMobile = org_glizy_objectFactory::createModel('movio.models.Mobilecontents');
         // informaizoni da salvare per il menu:
         // menuId, parent, titolo, pageType, type, contenuto
         // salvare solo i menu visibili
         // creare una tabella apposta e salvarci i dati dentro
         //
         if ($ar->menudetail_isVisible) {
             $arMobile->content_menuId = $menuId;
             $arMobile->content_pageType = $ar->menu_pageType;
             $arMobile->content_parent = $ar->menu_parentId;
             $arMobile->content_type = $ar->menu_type;
             $arMobile->content_title = $ar->menudetail_title;
             if ($arMobile->content_pageType == 'Storyteller') {
                 $contentJson = $this->processStoryTeller($contentJson);
             } elseif ($arMobile->content_pageType == 'Photogallery') {
                 $contentJson = $this->processPhotoGallery($contentJson);
             } elseif ($arMobile->content_pageType == 'Photogallery_category') {
                 $arMobile->content_pageType = 'Photogallery';
                 $contentJson = $this->processPhotoGalleryCategory($contentJson);
             } elseif ($arMobile->content_pageType == 'ImageHotspot') {
                 $contentJson = $this->processImageHotspot($contentJson);
             } elseif ($arMobile->content_pageType == 'Timeline') {
                 $contentJson = $this->processTimeline($menuId, $contentJson);
             } elseif ($arMobile->content_pageType == 'Page') {
                 $contentJson = $this->processPage($contentJson);
             } elseif ($arMobile->content_pageType == 'Exhibition') {
                 $contentJson = $this->processExhibition($contentJson);
                 $contentJson['isActive'] = $isExhibitionActive ? 1 : 0;
             } elseif ($arMobile->content_pageType == 'DigitalExhibition') {
                 $contentJson = $this->processDigitalExhibition($contentJson);
             } elseif ($arMobile->content_pageType == 'Home') {
                 $contentJson['title'] = $title;
                 $contentJson['subtitle'] = $subtitle;
             } elseif ($arMobile->content_pageType == 'Video') {
                 $contentJson = $this->processVideo($contentJson);
             } elseif ($arMobile->content_pageType == 'Cover') {
                 $contentJson = $this->processCover($contentJson);
             } elseif ($arMobile->content_pageType == 'GoogleMap') {
                 $contentJson = $this->processGoogleMap($contentJson);
             } elseif ($arMobile->content_pageType == 'Graph') {
                 $contentJson = $this->processGraph($contentJson, $menuId, $languageCode);
             }
             if ($menuId == $creditPageId) {
                 $arMobile->content_pageType = 'Credits';
                 $arMobile->content_parent = 0;
             }
             $arMobile->content_content = json_encode($contentJson);
             $contentId = $arMobile->save();
             $it = org_glizy_objectFactory::createModelIterator('org.glizycms.core.models.Content');
             $fulltextAr = $it->where("id", $menuId)->whereLanguageIs($languageId)->selectIndex('fulltext', 'document_index_fulltext_name', 'document_index_fulltext_value')->first();
             if ($fulltextAr->document_index_fulltext_value) {
                 $ar = org_glizy_objectFactory::createModel('movio.modules.publishApp.models.Mobilefulltext');
                 $ar->mobilefulltext_FK_content_id = $contentId;
                 $ar->mobilefulltext_text = str_replace(' ##', '', $fulltextAr->document_index_fulltext_value);
                 $ar->mobilefulltext_title = $contentJson['title'];
                 $ar->mobilefulltext_subtitle = $contentJson['subtitle'];
                 $ar->save();
             }
             // quando menu_pageType è Entity c'è da scorrere tutti i contenuti dell'entità
             // e caricare i dati
             // salvare
             // documenId, titolo, contenuto
             if ($arMobile->content_pageType == 'Entity') {
                 $parent = $arMobile->content_id;
                 $application = org_glizy_ObjectValues::get('org.glizy', 'application');
                 $it = __ObjectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityDocument');
                 $it->whereTypeIs('entity' . $contentJson['entitySelect']);
                 foreach ($it as $arEntitySelect) {
                     $documentId = $arEntitySelect->document_id;
                     $c = __ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.EntityToJSON', $application, $parent, 'glz:EntityToJSON', $documentId);
                     $c->setAttribute('visible', true);
                     $c->process();
                     $c->render();
                     $medias = $c->getMedias();
                     $this->addMediaArray($medias);
                     $graphCode = $c->getGraph();
                     $this->addGraph($languageCode, $documentId, $graphCode, 'document');
                     $jsonEntity = $c->getJson();
                     $jsonEntity['graph'] = 'graph/document/' . $languageCode . '/' . $documentId . '.svg';
                     $jsonEntity['content'] = $this->processText($jsonEntity['content']);
                     $arContentMobile = org_glizy_objectFactory::createModel('movio.models.Mobilecontents');
                     $arContentMobile->content_documentId = $documentId;
                     $arContentMobile->content_pageType = 'EntityChild';
                     $arContentMobile->content_parent = $parent;
                     $arContentMobile->content_title = $arEntitySelect->title;
                     $arContentMobile->content_content = json_encode($jsonEntity);
                     $contentId = $arContentMobile->save();
                     $fulltextAr = org_glizy_objectFactory::createModel('movio.modules.publishApp.models.DocumentIndexFulltext');
                     $result = $fulltextAr->find(array('document_index_fulltext_FK_document_detail_id' => $arEntitySelect->document_detail_id));
                     if ($result) {
                         $ar = org_glizy_objectFactory::createModel('movio.modules.publishApp.models.Mobilefulltext');
                         $ar->mobilefulltext_FK_content_id = $contentId;
                         $ar->mobilefulltext_text = str_replace(' ##', '', $fulltextAr->document_index_fulltext_value);
                         $ar->mobilefulltext_title = $arEntitySelect->title;
                         $ar->mobilefulltext_subtitle = $arEntitySelect->subtitle;
                         $ar->save();
                     }
                 }
             }
         }
     }
 }
Beispiel #11
0
 /**
  * @return GlizyObject|mixed|null|StdClass
  */
 public function &current()
 {
     if ($this->data == NULL) {
         $this->rewind();
     }
     // se non ci sono record
     if ($this->EOF) {
         return null;
     }
     if (!$this->returnClass) {
         $r = new StdClass();
         foreach ($this->data as $k => $v) {
             $r->{$k} = $v;
         }
     } else {
         $r = __ObjectFactory::createObject($this->returnClass, $this->data);
     }
     return $r;
 }
Beispiel #12
0
 function _render_html()
 {
     if (!empty($this->mediaUrl)) {
         $attributes = $this->_content;
         if (is_string($this->mediaUrl) && (!is_null($this->getAttribute('width')) || !is_null($this->getAttribute('height')))) {
             if (strpos($this->mediaUrl, 'http://') === 0) {
                 $extension = pathinfo(parse_url($this->mediaUrl, PHP_URL_PATH), PATHINFO_EXTENSION);
                 $cacheFileName = 'external_' . md5($this->mediaUrl) . '.' . $extension;
                 $cacheFilePath = __Paths::get('CACHE') . $cacheFileName;
                 // scarica il file e lo mette in cache
                 if (!file_exists($cacheFilePath)) {
                     @file_put_contents($cacheFilePath, @file_get_contents($this->mediaUrl));
                 }
                 $params = array('media_id' => 0, 'media_fileName' => $cacheFilePath);
                 $this->media = __ObjectFactory::createObject('org.glizycms.mediaArchive.media.Image', $params);
             }
             $this->media->allowDownload = true;
             $thumbnail = $this->media->getResizeImage($this->getAttribute('width'), $this->getAttribute('height'), $this->getAttribute('crop'), $this->getAttribute('cropOffset'), false, false);
             $attributes['src'] = $thumbnail['fileName'];
             $attributes['width'] = $thumbnail['width'];
             $attributes['height'] = $thumbnail['height'];
             $this->_content['src'] = $thumbnail['fileName'];
             $this->_content['width'] = $thumbnail['width'];
             $this->_content['height'] = $thumbnail['height'];
         }
         unset($attributes['mediaUrl']);
         unset($attributes['zoom']);
         unset($attributes['size']);
         unset($attributes['mediaType']);
         $this->_content['__html__'] = '<img ' . $this->_renderAttributes($attributes) . '/>';
         if ($this->getAttribute('zoom') || $useZoom) {
             $this->_application->addLightboxJsCode();
             $attributes = array();
             $attributes['title'] = $this->_content['title'];
             $thumbnail = $this->media->getResizeImage(__Config::get('IMG_WIDTH_ZOOM'), __Config::get('IMG_HEIGHT_ZOOM'));
             $attributes['href'] = $thumbnail['fileName'];
             $attributes['rel'] = 'milkbox' . ($this->getAttribute('group') != '' ? '[' . $this->getAttribute('group') . ']' : '');
             $attributes['class'] = $zoomCssClass;
             $this->_content['__html__'] = org_glizy_helpers_Html::renderTag('a', $attributes, true, $this->_content['__html__']);
         }
     } else {
         $this->_content['__html__'] = '';
     }
 }
Beispiel #13
0
 /**
  * @param $className
  *
  * @return GlizyObject|mixed
  */
 function retrieveService($className)
 {
     $classObj = __ObjectFactory::createObject($className, $this);
     return $classObj;
 }
Beispiel #14
0
 public function saveContent($data, $publish = true)
 {
     $entityTypeId = $data->entityTypeId;
     $entityId = $data->entityId;
     $document = org_glizy_objectFactory::createObject('org.glizy.dataAccessDoctrine.ActiveRecordDocument');
     $document->setType('entity' . $entityTypeId);
     $result = $document->load($entityId, 'LAST_MODIFIED');
     if (!$result) {
         $languageProxy = __ObjectFactory::createObject('org.glizycms.languages.models.proxy.LanguagesProxy');
         $defaultLanguageId = $languageProxy->getDefaultLanguageId();
         $document->load($entityId, 'LAST_MODIFIED', $defaultLanguageId);
         $document->setLanguage($languageProxy->getLanguageId());
     }
     $document->setVisible($data->__isVisible);
     $document->addField(new org_glizy_dataAccessDoctrine_DbField('title', Doctrine\DBAL\Types\Type::STRING, 255, false, null, '', false));
     $document->title = $data->title;
     $document->addField(new org_glizy_dataAccessDoctrine_DbField('subtitle', Doctrine\DBAL\Types\Type::STRING, 255, false, null, '', false));
     $document->subtitle = $data->subtitle;
     $document->addField(new org_glizy_dataAccessDoctrine_DbField('url', Doctrine\DBAL\Types\Type::STRING, 255, false, null, '', false, false, '', org_glizy_dataAccessDoctrine_DbField::NOT_INDEXED));
     $originalUrl = $document->url;
     $document->url = $data->url;
     $document->addField(new org_glizy_dataAccessDoctrine_DbField('profile', Doctrine\DBAL\Types\Type::TARRAY, 255, false, null, '', false));
     $document->profile = $data->profile;
     $application = org_glizy_ObjectValues::get('org.glizy', 'application');
     $fieldTypeService = $application->retrieveProxy('movio.modules.ontologybuilder.service.FieldTypeService');
     $entityTypeService = $application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService');
     $entityTypeProperties = $entityTypeService->getEntityTypeProperties($entityTypeId);
     $fulltext = $document->title . org_glizycms_Glizycms::FULLTEXT_DELIMITER;
     if ($document->subtitle) {
         $fulltext .= $document->subtitle . org_glizycms_Glizycms::FULLTEXT_DELIMITER;
     }
     foreach ((array) $entityTypeProperties as $entityTypeProperty) {
         $attribute = $entityTypeService->getAttributeIdByProperties($entityTypeProperty);
         // se l'attributo non è una relazione
         if (is_null($entityTypeProperty['entity_properties_target_FK_entity_id'])) {
             $type = $fieldTypeService->getTypeMapping($entityTypeProperty['entity_properties_type']);
             // TODO permettere di definire in fieldTypes.xml altri validatori per ogni tipo
             if ($entityTypeProperty['entity_properties_required']) {
                 $validator = new org_glizy_validators_NotNull();
             } else {
                 $validator = null;
             }
             if ($fieldTypeService->isTypeIndexed($entityTypeProperty['entity_properties_type']) == true) {
                 $document->addField(new org_glizy_dataAccessDoctrine_DbField($attribute, $type, 255, false, $validator, '', false));
             } else {
                 $document->addField(new org_glizy_dataAccessDoctrine_DbField($attribute, $type, 255, false, $validator, '', false, false, '', org_glizy_dataAccessDoctrine_DbField::NOT_INDEXED));
             }
         } else {
             $document->addField(new org_glizy_dataAccessDoctrine_DbField($attribute, Doctrine\DBAL\Types\Type::TEXT, 1000, false, null, '', false, false, '', org_glizy_dataAccessDoctrine_DbField::INDEXED));
         }
         if (property_exists($data, $attribute)) {
             $value = $data->{$attribute};
             $document->{$attribute} = $value;
         } else {
             // se l'attributo non è nei dati può essere dovuto
             // ad un component custom (es phtogallery) che ha più valori da salvare
             $value = array('__restore' => new StdClass());
             foreach ($data as $k => $v) {
                 if (strpos($k, $attribute) === 0) {
                     $value['__restore']->{$k} = $v;
                 }
             }
             $document->{$attribute} = $value;
         }
         if ($fieldTypeService->isTypeIndexed($entityTypeProperty['entity_properties_type'])) {
             $stripped = trim(strip_tags($value));
             if (!is_numeric($value) && strlen($stripped) > org_glizycms_Glizycms::FULLTEXT_MIN_CHAR) {
                 $fulltext .= $stripped . org_glizycms_Glizycms::FULLTEXT_DELIMITER;
             }
         }
     }
     $document->addField(new org_glizy_dataAccessDoctrine_DbField('fulltext', Doctrine\DBAL\Types\Type::TEXT, 1000, false, null, '', false, false, '', org_glizy_dataAccessDoctrine_DbField::FULLTEXT));
     $document->fulltext = $fulltext;
     try {
         if ($publish) {
             $id = $document->publish();
         } else {
             if (__Config::get('glizycms.content.history')) {
                 $id = $document->saveHistory();
             } else {
                 $id = $document->save();
             }
         }
         $speakingUrlProxy = __Config::get('glizycms.speakingUrl') ? org_glizy_ObjectFactory::createObject('org.glizycms.speakingUrl.models.proxy.SpeakingUrlProxy') : null;
         if ($speakingUrlProxy) {
             $languageId = org_glizy_ObjectValues::get('org.glizy', 'editingLanguageId');
             if ($originalUrl != $document->url) {
                 //valida l'url
                 if (!$speakingUrlProxy->validate($document->url, $languageId, $id, 'movio.modules.ontologybuilder.content')) {
                     throw new org_glizy_validators_ValidationException(array('Url non valido perché già utilizzato'));
                 } else {
                     $options = array('entityTypeId' => $entityTypeId);
                     // aggiorna l'url parlante
                     $speakingUrlProxy->addUrl($document->url, $languageId, $id, 'movio.modules.ontologybuilder.content', $options);
                     org_glizy_cache_CacheFile::cleanPHP('../cache/');
                 }
             }
         }
     } catch (org_glizy_validators_ValidationException $e) {
         return $e->getErrors();
     }
     return $id;
 }