Exemplo n.º 1
0
 public function execute($data)
 {
     // TODO: controllo acl
     $data = json_decode($data);
     if ($data && property_exists($data, 'template')) {
         $templateProxy = org_glizy_ObjectFactory::createObject('org.glizycms.template.models.proxy.TemplateProxy');
         $templateProxy->setSelectedTemplate($data->template);
         org_glizy_cache_CacheFile::cleanPHP(__Paths::get('APPLICATION_TO_ADMIN_CACHE'));
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 function execute()
 {
     org_glizy_Modules::deleteCache();
     org_glizy_cache_CacheFile::cleanPHP(__Paths::get('APPLICATION_TO_ADMIN_CACHE'));
     return true;
 }
Exemplo n.º 3
0
 function deleteCache()
 {
     org_glizy_cache_CacheFile::cleanPHP();
 }
Exemplo n.º 4
0
 public function invalidate()
 {
     org_glizy_cache_CacheFile::cleanPHP();
     org_glizy_cache_CacheFile::cleanPHP(__Paths::get('BASE') . 'cache/');
     $this->init();
 }
Exemplo n.º 5
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;
 }