Beispiel #1
0
 function execute($id)
 {
     $label = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.EntityLabelsDocument');
     $label->delete($id);
     $localeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService');
     $localeService->invalidate();
 }
Beispiel #2
0
 protected function loadAcl($key)
 {
     // TODO: posstare questa parte di codice in un classe comune
     // e gestire in modo simile quando sono attivi i ruoli e quando no
     $pageId = $this->application->getPageId();
     if (__Config::get('ACL_ROLES')) {
         if (!$this->user->acl($pageId, 'all')) {
             $this->canView = $this->user->acl($pageId, 'visible');
             $this->canEdit = $this->user->acl($pageId, 'edit');
             $this->canDelete = $this->user->acl($pageId, 'delete');
             if ($this->canView) {
                 $ar = org_glizy_objectFactory::createModel('org.glizycms.contents.models.DocumentACL');
                 $ar->load($key);
                 if ($ar->__aclEdit) {
                     $roles = explode(',', $ar->__aclEdit);
                     $this->canEdit = $this->canDelete = $this->user->isInRoles($roles);
                 }
             }
         }
     } else {
         $this->canView = $this->user->acl($pageId, 'visible');
         $this->canEdit = $this->user->acl($pageId, 'edit');
         $this->canDelete = $this->user->acl($pageId, 'delete');
     }
 }
Beispiel #3
0
 function execute($entityId)
 {
     $entityModel = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.Entity');
     $entityModel->load($entityId);
     $language = $this->application->getEditingLanguage();
     $localeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService');
     $entity = array("id" => $entityModel->entity_id, "nameId" => $entityModel->entity_name, "nameText" => $localeService->getTranslation($language, $entityModel->entity_name), "showRelationsGraph" => $entityModel->entity_show_relations_graph);
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Entity');
     $it->load('allButNot', array('entityId' => $entityId));
     $entity["entities"] = array();
     foreach ($it as $ar) {
         $entity["entities"][] = array("id" => $ar->entity_id, "name" => $localeService->getTranslation($language, $ar->entity_name));
     }
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityProperties');
     $it->load('entityPropertiesFromId', array('entityId' => $entityId));
     $entity["properties"] = array();
     foreach ($it as $ar) {
         $entity["properties"][] = array("id" => $ar->entity_properties_id, "type" => $ar->entity_properties_type, "target" => $ar->entity_properties_target_FK_entity_id, "labelId" => $ar->entity_properties_label_key, "labelText" => $localeService->getTranslation($language, $ar->entity_properties_label_key), "required" => $ar->entity_properties_required == 1, "showLabelInFrontend" => $ar->entity_properties_show_label_in_frontend == 1, "relationShow" => $ar->entity_properties_relation_show, "dcField" => $ar->entity_properties_dublic_core, "rowIndex" => $ar->entity_properties_row_index, 'params' => $ar->entity_properties_params);
     }
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityProperties');
     $it->load('entityRelationsFromId', array('entityId' => $entityId));
     $entity["relations"] = array();
     foreach ($it as $ar) {
         $entity["relations"][] = array("id" => $ar->entity_properties_id, "from" => $localeService->getTranslation($language, $ar->entity_name), "to" => $localeService->getTranslation($language, $entity["nameText"]), "show" => $ar->entity_properties_reference_relation_show);
     }
     return $entity;
 }
Beispiel #4
0
    function render()
    {
        $id = $this->getAttribute('id');
        $output = '<div id="' . $id . '_cont" style="display: inline">';
        $output .= '<label for="' . $id . '">' . $this->getAttribute('label') . ' ';
        $output .= '<select id="' . $id . '">';
        $output .= '<option value="">All</option>';
        $it = org_glizy_objectFactory::createModelIterator($this->getAttribute('recordClassName'), 'all');
        foreach ($it as $ar) {
            $output .= '<option value="entity' . $ar->getId() . '">' . $ar->entity_name . '</option>';
        }
        $output .= '</select></label>';
        $output .= '</div>';
        $dataGridId = $this->getAttribute('dataGridAjaxId');
        $fieldNumber = $this->getAttribute('fieldNumber');
        $output .= <<<EOD
<script type="text/javascript">
    jQuery(function(){
        var table = jQuery('#{$dataGridId}').data('dataTable');
        setTimeout(function(){
            jQuery("#{$id}_cont").children().appendTo("#{$dataGridId}_filter");
            var ooSettings = table.fnSettings();
            \$("#{$id}").val(ooSettings.aoPreSearchCols[{$fieldNumber}].sSearch);
        }, 100);

        jQuery('#{$id}').change( function () {
            table.fnFilter( \$(this).val(), {$fieldNumber} );
        });
    });
</script>
EOD;
        $this->addOutputCode($output);
    }
Beispiel #5
0
 function execute($id)
 {
     // TODO verificare permessi
     $ar = org_glizy_objectFactory::createModel('movio.modules.codes.models.Model');
     $ar->delete($id);
     return true;
 }
Beispiel #6
0
 function execute($pk, $name, $value)
 {
     $ar = org_glizy_objectFactory::createModel('movio.modules.codes.models.Model');
     if ($ar->load($pk)) {
         $ar->{$name} = $value;
         $ar->save();
     }
 }
Beispiel #7
0
 public function delete($recordId, $model)
 {
     $ar = org_glizy_objectFactory::createModel($model);
     if (__Config::get('ACL_MODULES')) {
         // permessi editing e visualizzazione record
         $this->addAclRelations($ar);
     }
     $ar->delete($recordId);
 }
Beispiel #8
0
 public function execute($id, $model)
 {
     // TODO controllo ACL
     if ($id) {
         $proxy = org_glizy_objectFactory::createObject('org.glizycms.contents.models.proxy.ActiveRecordProxy');
         $proxy->delete($id, $model);
         org_glizy_helpers_Navigation::goHere();
     }
 }
Beispiel #9
0
 function execute()
 {
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Languages', 'all');
     $languages = array();
     foreach ($it as $ar) {
         $languages[] = array('language_name' => $ar->language_name, 'language_code' => $ar->language_code);
     }
     return $languages;
 }
Beispiel #10
0
 function execute()
 {
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityLabelsDocument', 'all')->groupBy('simple_document_id')->orderBy('translation');
     $result = array("entityLabels" => array());
     foreach ($it as $ar) {
         $result["entityLabels"][] = array('id' => $ar->getId(), 'translation' => $ar->translation);
     }
     return $result;
 }
Beispiel #11
0
 public function execute($id, $model)
 {
     // TODO controllo ACL
     if ($id) {
         $contentproxy = org_glizy_objectFactory::createObject('org.glizycms.contents.models.proxy.ModuleContentProxy');
         $contentproxy->toggleVisibility($id, $model);
         org_glizy_helpers_Navigation::goHere();
     }
 }
Beispiel #12
0
 function execute($custom_code_mapping_description, $custom_code_mapping_code, $custom_code_mapping_link)
 {
     $ar = org_glizy_objectFactory::createModel('movio.modules.codes.models.Model');
     $ar->custom_code_mapping_description = $custom_code_mapping_description;
     $ar->custom_code_mapping_code = $custom_code_mapping_code;
     $ar->custom_code_mapping_link = $custom_code_mapping_link;
     $id = $ar->save();
     return $id;
 }
Beispiel #13
0
 public function execute($entityId)
 {
     // TODO controllo ACL
     if ($entityId) {
         $document = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.EntityDocument');
         $document->delete($entityId);
         org_glizy_helpers_Navigation::goHere();
     }
 }
Beispiel #14
0
 public function executeLater($id)
 {
     // TODO controllo ACL
     if ($id) {
         $proxy = org_glizy_objectFactory::createObject('org.glizycms.languages.models.proxy.LanguagesProxy');
         $proxy->delete($id);
         org_glizy_helpers_Navigation::goHere();
     }
 }
Beispiel #15
0
 function execute($fieldName, $model, $query, $term)
 {
     $it = org_glizy_objectFactory::createModelIterator($model, $query);
     $it->where($fieldName, '%' . $term . '%', 'LIKE');
     $results = array();
     foreach ($it as $ar) {
         $results[] = array('id' => $ar->getId(), 'text' => $ar->{$fieldName});
     }
     return $results;
 }
Beispiel #16
0
 function execute()
 {
     // TODO controllo dei permessi
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.RelationTypesDocument', 'all')->groupBy('simple_document_id')->orderBy('translation');
     $result = array();
     foreach ($it as $ar) {
         $result["relations"][] = array('id' => $ar->getId(), 'translation' => $ar->translation, 'cardinality' => $ar->cardinality);
     }
     return $result;
 }
Beispiel #17
0
 public function execute($id)
 {
     if ($id) {
         $c = $this->view->getComponentById('__model');
         $model = $c->getAttribute('value');
         $proxy = org_glizy_objectFactory::createObject('org.glizycms.contents.models.proxy.ActiveRecordProxy');
         $data = $proxy->load($id, $model);
         $data['__id'] = $id;
         $this->view->setData($data);
     }
 }
Beispiel #18
0
 function execute($entity)
 {
     $resultEntity = array();
     $resultEntity['newProperties'] = array();
     $entityModel = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.Entity');
     $entityModel->load($entity['id']);
     $entityModel->entity_name = $entity['name'];
     $entityModel->entity_show_relations_graph = $entity['showRelationsGraph'] == 'true' ? 1 : 0;
     // se è una nuova entità
     if ($entity['id'] == '') {
         $id = $entityModel->save();
         $resultEntity['id'] = $entity['id'] = $id;
     }
     $entityProperties = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.EntityProperties');
     // elimina dal db le proprietà cancellate dall'utente
     foreach ((array) $entity['deletedRows'] as $id) {
         $entityProperties->delete($id);
     }
     // aggiorna i dati delle proprietà nel db
     for ($i = 0; $i < count($entity['properties']); $i++) {
         $property = $entity['properties'][$i];
         $entityProperties->load($property['id']);
         $entityProperties->entity_properties_FK_entity_id = $entity['id'];
         $entityProperties->entity_properties_type = $property['type'];
         $entityProperties->entity_properties_target_FK_entity_id = $this->checkNull($property['target']);
         $entityProperties->entity_properties_label_key = $property['label'];
         $entityProperties->entity_properties_required = $property['required'] == 'true' ? 1 : 0;
         $entityProperties->entity_properties_show_label_in_frontend = $property['showLabelInFrontend'] == 'true' ? 1 : 0;
         $entityProperties->entity_properties_relation_show = $this->checkNull($property['relationShow']);
         $entityProperties->entity_properties_dublic_core = $this->checkNull($property['dcField']);
         $entityProperties->entity_properties_row_index = $this->checkNull($property['rowIndex']);
         $entityProperties->entity_properties_params = $this->checkNull($property['params']);
         $id = $entityProperties->save();
         // se è una nuova proprietà
         if ($property['id'] == '') {
             $entity['properties'][$i]['id'] = $id;
             $resultEntity['newProperties'][] = $id;
         }
     }
     foreach ((array) $entity['relations'] as $relation) {
         $entityProperties->load($relation['id']);
         $entityProperties->entity_properties_reference_relation_show = $relation['show'];
         $entityProperties->save();
     }
     $this->entityTypeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService');
     $this->entityTypeService->invalidate();
     //
     $skinAttributesVO = org_glizy_objectFactory::createObject('movio.modules.ontologybuilder.models.vo.SkinAttributesVO');
     $this->saveSkin($skinAttributesVO, $entity);
     $this->saveListSkin($skinAttributesVO, $entity);
     $entityModel->entity_skin_attributes = serialize($skinAttributesVO);
     $entityModel->save();
     return $resultEntity;
 }
Beispiel #19
0
 function execute($id)
 {
     // TODO verificare permessi
     $relation = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.RelationTypesDocument');
     $relation->delete($id);
     $entityTypeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService');
     $entityTypeService->invalidate();
     $localeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService');
     $localeService->invalidate();
     return true;
 }
Beispiel #20
0
 public function execute()
 {
     $entityId = __Request::get('entityId');
     // TODO controllare se $entityId == 0
     // se non è 0 e il contenuto non esiste bisogna visualizzare un errore
     $entityProxy = org_glizy_objectFactory::createObject('movio.modules.ontologybuilder.models.proxy.EntityProxy');
     $data = $entityProxy->loadContent($entityId, 'DRAFT');
     if ($data) {
         $data['__id'] = $entityId;
     }
     $this->view->setData($data);
 }
Beispiel #21
0
 function execute($data)
 {
     $entityProxy = org_glizy_objectFactory::createObject('movio.modules.ontologybuilder.models.proxy.EntityProxy');
     $id = $entityProxy->saveContent(json_decode($data));
     $this->directOutput = true;
     // se ci sono stati errori di validazione
     if (is_array($id)) {
         return array('errors' => $id);
     } else {
         return array('set' => array('entityId' => $id));
     }
 }
Beispiel #22
0
 public function execute($id)
 {
     // TODO controllo ACL
     if ($id) {
         // read the module content
         $c = $this->view->getComponentById('__model');
         $contentproxy = org_glizy_objectFactory::createObject('org.glizycms.contents.models.proxy.ModuleContentProxy');
         $data = $contentproxy->loadContent($id, $c->getAttribute('value'), 'DRAFT');
         //  TODO verifica se il record esiste
         $data['__id'] = $id;
         $this->view->setData($data);
     }
 }
Beispiel #23
0
 public function createDbService($dbType)
 {
     if ($dbType == 'mysql') {
         return org_glizy_objectFactory::createObject('movio.modules.modulesBuilder.services.MysqlService', 11);
     } else {
         if ($dbType == 'pgsql') {
             return org_glizy_objectFactory::createObject('movio.modules.modulesBuilder.services.PgsqlService', 12);
         } else {
             $this->logAndMessage('Il dbms selezionato non è supportato', null, true);
             return null;
         }
     }
 }
Beispiel #24
0
 function execute()
 {
     $application = org_glizy_ObjectValues::get('org.glizy', 'application');
     $language = $application->getLanguage();
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.RelationTypesDocument');
     //$it->load('relationTypesFromLanguage', array('language' => $language));
     $it->orderBy('translation');
     $relationTypes = array();
     foreach ($it as $ar) {
         $r = array('id' => $ar->key, 'name' => $ar->translation[$language] ? $ar->translation[$language] : $ar->key);
         $relationTypes[$r['id']] = $r;
     }
     return $relationTypes;
 }
Beispiel #25
0
 public function execute($data)
 {
     // TODO controllo acl
     // TODO per motifi di sicurezza forse è meglio non passare il nome del model nella request
     // ma avere un controller specifico che estende quello base al quale viene passato il nome del model, come succede per Scaffold
     $proxy = org_glizy_objectFactory::createObject('org.glizycms.contents.models.proxy.ActiveRecordProxy');
     $result = $proxy->save(json_decode($data));
     $this->directOutput = true;
     if ($result['__id']) {
         return array('set' => $result);
     } else {
         return array('errors' => $result);
     }
 }
Beispiel #26
0
 function render()
 {
     // $this->addOutputCode( org_glizy_helpers_JS::linkJSfile(__Paths::get('APPLICATION').'templates/js/bootstrap.min.js' ) );
     $output = '<div class="btn-group">' . '<a class="btn dropdown-toggle action-link" data-toggle="dropdown" href="#">' . '<i class="icon-plus"></i> ' . $this->getAttribute('label') . '</a>' . '<ul class="dropdown-menu left forced-left-position">';
     $routeUrl = $this->getAttribute('routeUrl');
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Entity', 'all');
     foreach ($it as $ar) {
         $params = array('entityTypeId' => $ar->getId());
         $url = org_glizy_helpers_Link::makeUrl($routeUrl, $params);
         $output .= '<li><a href="' . $url . '">' . $ar->entity_name . '</a></li>';
     }
     $output .= '</ul>' . '</div>';
     $this->addOutputCode($output);
 }
Beispiel #27
0
 function execute()
 {
     if ($this->user->isLogged()) {
         $it = org_glizy_objectFactory::createModelIterator('movio.modules.codes.models.Model');
         foreach ($it as $ar) {
             if (!$ar->custom_code_mapping_code) {
                 continue;
             }
             $arCode = org_glizy_objectFactory::createModel('movio.modules.publishApp.models.Codes');
             $arCode->mobilecode_code = $ar->custom_code_mapping_code;
             $arCode->mobilecode_link = $ar->custom_code_mapping_link;
             $arCode->save();
         }
     }
 }
Beispiel #28
0
 public function execute($data)
 {
     $this->directOutput = true;
     // TODO: controllo acl
     $contentProxy = org_glizy_objectFactory::createObject('org.glizycms.contents.models.proxy.ContentProxy');
     $contentVO = $contentProxy->getContentVO();
     $contentVO->setFromJson($data);
     $this->menuId = $contentVO->getId();
     $r = $contentProxy->saveContent($contentVO, org_glizy_ObjectValues::get('org.glizy', 'editingLanguageId'), __Config::get('glizycms.content.history'));
     if ($r === true) {
         return true;
     } else {
         return array('errors' => array($r));
     }
 }
Beispiel #29
0
 private function loadData()
 {
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.RelationTypesDocument', 'all');
     $relations = array();
     foreach ($it as $ar) {
         $relations[$ar->key] = array('translation' => $ar->translation, 'cardinality' => $ar->cardinality);
     }
     $this->entityTypes["relations"] = $relations;
     $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Entity', 'allWithProperties');
     $entityTypes = array();
     $descriptionAttributeDc = array();
     foreach ($it as $ar) {
         $entityTypes[$ar->entity_id]['name'] = $ar->entity_name;
         $entityTypes[$ar->entity_id]['entity_show_relations_graph'] = $ar->entity_show_relations_graph;
         $entityTypes[$ar->entity_id]['entity_skin_attributes'] = $ar->entity_skin_attributes;
         if ($ar->entity_properties_id) {
             $attributeId = $this->getAttributeIdById($ar->entity_properties_id);
             $entityTypes[$ar->entity_id]['properties'][$attributeId] = array('entity_properties_id' => $ar->entity_properties_id, 'entity_properties_FK_entity_id' => $ar->entity_properties_FK_entity_id, 'entity_properties_type' => $ar->entity_properties_type, 'entity_properties_target_FK_entity_id' => $ar->entity_properties_target_FK_entity_id, 'entity_properties_label_key' => $ar->entity_properties_label_key, 'entity_properties_required' => $ar->entity_properties_required, 'entity_properties_show_label_in_frontend' => $ar->entity_properties_show_label_in_frontend, 'entity_properties_relation_show' => $ar->entity_properties_relation_show, 'entity_properties_reference_relation_show' => $ar->entity_properties_reference_relation_show, 'entity_properties_dublic_core' => $ar->entity_properties_dublic_core, 'entity_properties_row_index' => $ar->entity_properties_row_index, 'entity_properties_params' => $ar->entity_properties_params);
             $entityTypes[$ar->entity_id]['types'][$ar->entity_properties_type][] = $attributeId;
             // trova l'attributo immagine
             if (!isset($entityTypes[$ar->entity_id]['imageAttribute']) && $ar->entity_properties_type == 'attribute.image' || $ar->entity_properties_type == 'attribute.image') {
                 $entityTypes[$ar->entity_id]['imageAttribute'] = $attributeId;
             }
             // trova l'attributo descrizione
             if (!isset($descriptionAttributeDc[$ar->entity_id])) {
                 // cerca l'attributo con dcField uguale a DC.Description
                 if ($ar->entity_properties_dublic_core == 'DC.Description') {
                     $entityTypes[$ar->entity_id]['descriptionAttribute'] = $attributeId;
                     $descriptionAttributeDc[$ar->entity_id] = true;
                 } else {
                     // verifica che l'attributo non sia una relazione e che sia testuale
                     if (!isset($entityTypes[$ar->entity_id]['descriptionAttribute']) && $ar->entity_properties_dublic_core == '' && preg_match('/text$/', $ar->entity_properties_type)) {
                         $entityTypes[$ar->entity_id]['descriptionAttribute'] = $attributeId;
                     }
                 }
             }
         }
     }
     foreach ($entityTypes as $entityId => $entity) {
         $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityProperties');
         $it->load('entityRelationsFromId', array('entityId' => $entityId));
         foreach ($it as $ar) {
             $entityTypes[$entityId]['reference_relations'][] = array('entity_properties_id' => $ar->entity_properties_id, 'entity_properties_FK_entity_id' => $ar->entity_properties_FK_entity_id, 'entity_properties_type' => $ar->entity_properties_type, 'entity_properties_target_FK_entity_id' => $ar->entity_properties_target_FK_entity_id, 'entity_properties_label_key' => $ar->entity_properties_label_key, 'entity_properties_required' => $ar->entity_properties_required, 'entity_properties_show_label_in_frontend' => $ar->entity_properties_show_label_in_frontend, 'entity_properties_relation_show' => $ar->entity_properties_relation_show, 'entity_properties_reference_relation_show' => $ar->entity_properties_reference_relation_show, 'entity_properties_dublic_core' => $ar->entity_properties_dublic_core, 'entity_properties_row_index' => $ar->entity_properties_row_index, 'entity_properties_params' => $ar->entity_properties_params);
         }
     }
     $this->entityTypes["entityTypes"] = $entityTypes;
 }
Beispiel #30
0
 function execute($fieldName, $model, $query, $term, $proxy, $proxyParams, $getId)
 {
     $fieldName = explode('-', $fieldName);
     $fieldName = array_pop($fieldName);
     if (!$proxy) {
         $it = org_glizy_objectFactory::createModelIterator($model, $query);
         if ($term != '') {
             $it->where($fieldName, '%' . $term . '%', 'LIKE');
         }
         $it->where($fieldName, '', '<>')->orderBy($fieldName);
         $foundValues = array();
         foreach ($it as $ar) {
             if (is_array($ar->{$fieldName})) {
                 foreach ($ar->{$fieldName} as $value) {
                     if ($term == '' || stripos($value, $term) !== false) {
                         if ($getId) {
                             $foundValues[$ar->getId()] = $value;
                         } else {
                             $foundValues[$value] = $value;
                         }
                     }
                 }
             } else {
                 if ($getId) {
                     $foundValues[$ar->getId()] = $ar->{$fieldName};
                 } else {
                     $foundValues[$ar->{$fieldName}] = $ar->{$fieldName};
                 }
             }
         }
         ksort($foundValues);
         $result = array();
         foreach ($foundValues as $k => $v) {
             $result[] = array('id' => $k, 'text' => $v);
         }
         return $result;
     } else {
         $p = $this->application->retrieveProxy($proxy);
         if (!$p) {
             $p = org_glizy_ObjectFactory::createObject($proxy);
         }
         $result = $p->findTerm($fieldName, $model, $query, $term, json_decode($proxyParams));
         return $result;
     }
 }