Beispiel #1
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 #2
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();
                     }
                 }
             }
         }
     }
 }