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; }
public function searchDocumentsByTerm($term, $id, $protocol = '', $filterType = '') { $result = array(); if ($protocol && $protocol != $this->protocol) { return $result; } $application = __ObjectValues::get('org.glizy', 'application'); $entityTypeService = $application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); if ($term) { $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityDocument', 'All'); if ($term != '') { $it->where('title', '%' . $term . '%', 'ILIKE'); } $it->orderBy('title'); foreach ($it as $ar) { $entityTypeId = $entityTypeService->getEntityTypeId($ar->document_type); $result[] = array('id' => $this->protocol . $ar->document_id, 'text' => $ar->title, 'path' => __T('Content') . '/' . $entityTypeService->getEntityTypeName($entityTypeId)); } } elseif ($id) { if (strpos($id, $this->protocol) !== 0) { return $result; } $ar = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.EntityDocument'); $ar->load($this->getIdFromLink($id)); $entityTypeId = $entityTypeService->getEntityTypeId($ar->document_type); $result[] = array('id' => $this->protocol . $ar->document_id, 'text' => $ar->title, 'path' => __T('Content') . '/' . $entityTypeService->getEntityTypeName($entityTypeId)); } return $result; }
public function searchDocumentsByTerm($term, $id, $protocol = '', $filterType = '') { $result = array(); if ($protocol && $protocol != $this->protocol) { return $result; } if ($term) { $it = org_glizy_objectFactory::createModelIterator($this->model)->load('All'); if ($term != '') { $it->where('title', '%' . $term . '%', 'ILIKE'); } $it->orderBy('title'); foreach ($it as $ar) { $result[] = array('id' => $this->protocol . $ar->document_id, 'text' => $ar->title, 'path' => $this->modelName); } } elseif ($id) { if (strpos($id, $this->protocol) !== 0) { return $result; } $ar = org_glizy_objectFactory::createModel($this->model); $ar->load($this->getIdFromLink($id)); $result[] = array('id' => $this->protocol . $ar->document_id, 'text' => $ar->title, 'path' => $this->modelName); } return $result; }
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); }
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; }
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; }
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; }
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; }
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; }
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); }
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(); } } }
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; }
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; } }
function execute() { // TODO controllo dei permessi $it = org_glizy_objectFactory::createModelIterator('movio.modules.codes.models.Model'); $result = array('items' => array()); foreach ($it as $ar) { $id = $ar->getId(); $item = array('id' => $id, 'description' => $ar->custom_code_mapping_description, 'code' => $ar->custom_code_mapping_code, 'resourceLink' => $ar->custom_code_mapping_link); if ($ar->custom_code_mapping_link) { $speakingUrlManager = $this->application->retrieveProxy('org.glizycms.speakingUrl.Manager'); $docs = $speakingUrlManager->searchDocumentsByTerm('', $ar->custom_code_mapping_link); $item['resourceLinkLabel'] = $docs[0]['text']; $item['downloadQrCode'] = __Link::makeUrl('actionsMVC', array('action' => 'makeQRCode', 'id' => $id)); } $result['items'][] = $item; } return $result; }
function execute($term) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $language = $application->getEditingLanguage(); if (is_null($term)) { $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityLabelsDocument'); $it->load('entityLabelsFromLanguage', array('language' => $language)); } else { $params = array('language' => $language, 'term' => $term); $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityLabelsDocument'); $it->load('entityLabelsFromTerm', $params); } $labels = array(); //org_glizy_dataAccessDoctrine_DataAccess::enableLogging(); foreach ($it as $ar) { $labels[] = array('id' => $ar->key, 'text' => $ar->translation[$language]); } //die; return $labels; }
function execute() { $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Languages', 'all'); $translation = array(); foreach ($it as $ar) { $code = $ar->language_code; $word = __Request::get('translation_' . $code); $translation[$code] = $word; if ($word != '') { $key = $word; } } $label = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.EntityLabelsDocument'); $label->key = $key; $label->translation = $translation; $id = $label->save(); $localeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService'); $localeService->invalidate(); return $id; }
function run(&$parent, $params) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $languageId = $application->getLanguageId(); $language = $application->getLanguage(); $it = org_glizy_objectFactory::createModelIterator('movio.search.models.Content'); $it->load('getVisibleEntities', array(':words' => $params, ':language' => $languageId)); foreach ($it as $ar) { //$ar->dump(); $result = $parent->getResultStructure(); $result['title'] = $ar->title; $result['description'] = $ar->description; if ($ar->keyInDataExists('url') && $ar->url) { $url = org_glizy_helpers_Html::renderTag('a', array('href' => $language . '/' . $ar->url), true, $ar->title); } else { $url = __Link::makeLink('link', array('pageId' => $ar->pageId, 'title' => $ar->title)); } $result['__url__'] = $url; $parent->addResult($result); } }
public function execute($id) { // cancella tutti i contenuti collegati al tipo di entità da cancellare $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityDocument'); $it->load('allFromTypeAllStatusAllLanguages', array('entityTypeId' => $id)); foreach ($it as $ar) { $ar->delete(); } // cancella le proprietà collegate all'entità $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityProperties'); $it->load('entityPropertiesFromId', array('entityId' => $id)); foreach ($it as $ar) { $ar->delete(); } // cancella l'entità $entity = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.Entity'); $entity->delete($id); $entityTypeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $entityTypeService->invalidate(); org_glizy_helpers_Navigation::goHere(); }
public function process_ajax() { $a = __Request::get('a'); $b = __Request::get('b'); $it = org_glizy_objectFactory::createModelIterator('org.glizycms.core.models.Content'); $it->where("document_detail_id", $a)->allStatuses(); $ar_a = $it->first(); $it = org_glizy_objectFactory::createModelIterator('org.glizycms.core.models.Content'); $it->where("document_detail_id", $b)->allStatuses(); $ar_b = $it->first(); $a = explode("\n", str_replace("<\\/p>", "<\\/p>\n", json_encode(json_decode($ar_a->document_detail_object), JSON_PRETTY_PRINT))); $b = explode("\n", str_replace("<\\/p>", "<\\/p>\n", json_encode(json_decode($ar_b->document_detail_object), JSON_PRETTY_PRINT))); glz_importLib('Diff/Diff.php'); glz_importLib('Diff/Diff/Renderer/Html/SideBySide.php'); // Options for generating the diff $options = array(); $diff = new Diff($a, $b, $options); $renderer = new Diff_Renderer_Html_SideBySide(); $result = $diff->Render($renderer); return array('html' => $result); }
function execute($text, $key) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $language = $application->getEditingLanguage(); $localeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService'); $keyLanguageCode = $localeService->keyAlreadyExists($lang, $key); if ($keyLanguageCode) { $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityLabelsDocument')->where('translation', $keyLanguageCode . ':' . $key); $entityLabels = $it->first(); $temp = $entityLabels->translation; $temp[$language] = $text; $entityLabels->translation = $temp; $entityLabels->save(); $localeService->invalidate(); } else { $entityLabels = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.EntityLabelsDocument'); $entityLabels->key = $text; $entityLabels->translation = array($language => $text); $entityLabels->save(); } return $entityLabels->key; }
function execute() { $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Languages', 'all'); $translation = array(); foreach ($it as $ar) { $code = $ar->language_code; if (__Request::get('translation_' . $code)) { $translation[$code] = __Request::get('translation_' . $code); if (empty($key)) { $key = $translation[$code]; } } } $relation = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.RelationTypesDocument'); $relation->key = $key; $relation->translation = $translation; $relation->cardinality = __Request::get('cardinality'); $id = $relation->save(); $entityTypeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $entityTypeService->invalidate(); $localeService = $this->application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService'); $localeService->invalidate(); return $id; }
public function rebuildLocale() { $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.RelationTypesDocument'); $languageCodes = $this->getLanguageCodes(); $locale = array(); foreach ($it as $ar) { foreach ($languageCodes as $languageCode) { if (@$ar->translation) { $tr = $ar->translation[$languageCode]; if ($tr) { $locale[$languageCode]['rel:' . $ar->key] = $tr; } } } } $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityLabelsDocument', 'all'); foreach ($it as $ar) { foreach ($languageCodes as $languageCode) { $tr = $ar->translation[$languageCode]; if (@$ar->translation) { if ($tr) { $locale[$languageCode][$ar->key] = $tr; } } } } foreach ($languageCodes as $languageCode) { $out = '<?php' . PHP_EOL; if (!empty($locale[$languageCode])) { $out .= '$strings = ' . var_export($locale[$languageCode], true) . ';' . PHP_EOL; $out .= 'org_glizy_locale_Locale::append($strings);'; } file_put_contents(movio_modules_ontologybuilder_Paths::getLocalePath($languageCode), $out); } $this->locale = $locale; }
function run(&$parent, $params) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $languageId = $application->getLanguageId(); $language = $application->getLanguage(); $it = org_glizy_objectFactory::createModelIterator('movio.search.models.Entity'); $it->load('getVisibleEntities', array(':words' => $params, ':language' => $languageId)); foreach ($it as $ar) { //$ar->dump(); $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $entityTypeService = $application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $descriptionAttribute = $entityTypeService->getDescriptionAttribute($ar->entityTypeId); $result = $parent->getResultStructure(); $result['title'] = $ar->title; $result['description'] = $descriptionAttribute && $ar->keyInDataExists($descriptionAttribute) ? $ar->{$descriptionAttribute} : ''; if ($ar->keyInDataExists('url') && $ar->url) { $url = org_glizy_helpers_Html::renderTag('a', array('href' => $language . '/' . $ar->url), true, $ar->title); } else { $url = __Link::makeLink('showEntityDetail', $ar->getValuesAsArray()); } $result['__url__'] = $url; $parent->addResult($result); } }
function createChildComponents() { $entityTypeId = $this->_content['entityTypeId']; $entityTypeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $skinAttributes = unserialize($entityTypeService->getEntityTypeAttribute($entityTypeId, 'entity_skin_attributes')); if (!$skinAttributes) { return; } $language = $this->_application->getLanguage(); $localeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService'); foreach ($skinAttributes->properties as $i => $property) { $skinAttributes->properties[$i]['label'] = $localeService->getTranslation($language, $property['label']); } foreach ($skinAttributes->body as $i => $body) { $skinAttributes->body[$i]['label'] = $localeService->getTranslation($language, $body['label']); } $groupBoxRel =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Groupbox', $this->_application, $this, 'glz:Groupbox', 'relations'); $this->addChild($groupBoxRel); $skinsName = array('Entity_relationImage.html', 'Entity_relationLink.html', 'Entity_relationImageLink.html'); $groupBox =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Groupbox', $this->_application, $this, 'glz:Groupbox', 'detail'); $groupBox->setAttribute('skin', 'Entity_entry.html'); $this->addChild($groupBox); $this->_content['attributes'] = $skinAttributes; $this->_content['relations'] = new StdClass(); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Hidden', 'attributes', 'attributes'); $groupBox->addChild($c); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Hidden', 'relations', 'relations'); $groupBox->addChild($c); if (isset($this->_content['subtitle']) && $this->_content['subtitle']) { $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.PageTitle', $this->_application, $this, 'glz:Text', 'subtitle', 'subtitle'); $c->setAttributes(array('tag' => 'h2', 'editableRegion' => 'pageTitle', 'value' => $this->_content['subtitle'])); $this->addChild($c); } // TODO usare EntityTypeService per ottenere le proprietà in cache $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityProperties'); $it->load('entityPropertiesFromId', array('entityId' => $entityTypeId)); foreach ($it as $ar) { $attribute = $entityTypeService->getAttributeIdByAr($ar); switch ($ar->entity_properties_type) { case 'attribute.text': case 'attribute.int': case 'attribute.date': case 'attribute.openlist': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', $attribute, $attribute); $groupBox->addChild($c); break; case 'attribute.longtext': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.LongText', $this->_application, $this, 'glz:LongText', $attribute, $attribute); $c->setAttribute('forceP', true); $groupBox->addChild($c); break; case 'attribute.descriptivetext': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.LongText', $this->_application, $this, 'glz:LongText', $attribute, $attribute); $c->setAttribute('adm:htmlEditor', true); $groupBox->addChild($c); break; case 'attribute.externallink': case 'attribute.internallink': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.LinkTo', $this->_application, $this, 'glz:LinkTo', $attribute, $attribute); $groupBox->addChild($c); break; case 'attribute.externalimage': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.ImageExternal', $this->_application, $this, 'glz:ImageExternal', $attribute, $attribute); $groupBox->addChild($c); break; case 'attribute.image': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Image', $this->_application, $this, 'glz:Image', $attribute, $attribute); $c->setAttribute('width', __Config::get('IMG_WIDTH')); $c->setAttribute('height', __Config::get('IMG_HEIGHT')); $c->setAttribute('zoom', true); $c->setAttribute('superZoom', true); $groupBox->addChild($c); break; case 'attribute.media': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Media', $this->_application, $this, 'glz:Media', $attribute, $attribute); $groupBox->addChild($c); break; case 'attribute.imagelist': if ($this->_content[$attribute]) { $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Repeater', $this->_application, $this, 'cmp:Repeater', $attribute, $attribute); $subchild =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Image', $this->_application, $c, 'glz:Image', 'attaches', 'attaches'); $subchild->setAttribute('width', __Config::get('THUMB_WIDTH')); $subchild->setAttribute('height', __Config::get('THUMB_HEIGHT')); $subchild->setAttribute('zoom', true); $c->addChild($subchild); $groupBox->addChild($c); } break; case 'attribute.medialist': if ($this->_content[$attribute]) { $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Repeater', $this->_application, $this, 'cmp:Repeater', $attribute, $attribute); $subchild =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Media', $this->_application, $c, 'glz:Media', 'attaches', 'attaches'); $c->addChild($subchild); $groupBox->addChild($c); } break; case 'attribute.photogallery': $c =& org_glizy_ObjectFactory::createComponent('movio.views.components.PhotogalleryCategory', $this->_application, $this, 'm:PhotogalleryCategory', $attribute, $attribute); $c->setAttribute('label', $localeService->getTranslation($language, $ar->entity_properties_label_key)); $c->setAttribute('editableRegion', 'photogallery'); $groupBoxRel->addChild($c); break; case 'attribute.europeanaRelatedContents': $c =& org_glizy_ObjectFactory::createComponent('movio.modules.europeana.views.components.RelatedContents', $this->_application, $this, 'evc:RelatedContents', $attribute, $attribute); $c->setAttribute('skin', 'EuropeanaRelatedContents.html'); $c->setAttribute('label', $localeService->getTranslation($language, $ar->entity_properties_label_key)); $c->setAttribute('editableRegion', 'europeanaRelatedContents'); $groupBoxRel->addChild($c); break; case 'attribute.thesaurus': $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Thesaurus', $this->_application, $this, 'cmp:Thesaurus', $attribute, $attribute); $groupBox->addChild($c); break; case 'attribute.module': $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.RepeaterForModule', $this->_application, $this, 'cmp:Repeater', $attribute, $attribute); $c->setAttribute('label', $localeService->getTranslation($language, $ar->entity_properties_label_key)); $c->setAttribute('skin', 'Entity_moduleImageLink.html'); $c->setAttribute('editableRegion', 'photogallery'); $module =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Module', $this->_application, $c, 'cmp:Module', 'attaches', 'attaches'); $c->addChild($module); $groupBoxRel->addChild($c); default: // se l'attributo è una relazione if (!is_null($ar->entity_properties_target_FK_entity_id) && $ar->entity_properties_relation_show != 3 && $this->_content[$attribute]['content']) { $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Repeater', $this->_application, $this, 'cmp:Repeater', $attribute, $attribute); $relation =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Relation', $this->_application, $c, 'cmp:Relation', 'attaches', 'attaches'); $c->setAttribute('skin', $skinsName[$ar->entity_properties_relation_show]); $c->setAttribute('editableRegion', 'relations'); $c->addChild($relation); $groupBoxRel->addChild($c); } } } foreach ((array) $this->_content['__reference_relations'] as $entityTypeName => $data) { if ($data['show'] != 3) { $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Repeater', $this->_application, $this, 'cmp:Repeater', $entityTypeName, $entityTypeName); $relation =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.Relation', $this->_application, $c, 'cmp:Relation', 'attaches' . $entityTypeName, 'attaches' . $entityTypeName); $c->setAttribute('skin', $skinsName[$data['show']]); $c->setAttribute('editableRegion', 'referenceRelations'); $c->addChild($relation); $groupBoxRel->addChild($c); } } if ($entityTypeService->getEntityTypeAttribute($entityTypeId, 'entity_show_relations_graph')) { $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.DocumentGraph', $this->_application, $this, 'cmp:DocumentGraph', 'document_graph', 'document_graph'); $c->setAttribute('editableRegion', 'relationsGraph'); $groupBoxRel->addChild($c); } }
public function deleteContent($menuId) { // cancella il contenuto del documento associato $it = org_glizy_objectFactory::createModelIterator('org.glizycms.core.models.Content'); $menuDocument = $it->load('getContentForMenu', array('menuId' => $menuId))->first(); if ($menuDocument) { $menuDocument->delete(); } }
function render_html_onStart() { parent::render_html_onStart(); $folderPath = __Paths::get('CORE') . 'classes/org/glizycms/js/visualsearch/'; $output = <<<EOD <script src="{$folderPath}dependencies.js" type="text/javascript"></script> <script src="{$folderPath}visualsearch.js" type="text/javascript"></script> <!--[if (!IE)|(gte IE 8)]><!--> <link href="{$folderPath}visualsearch-datauri.css" media="screen" rel="stylesheet" type="text/css" /> <!--<![endif]--> <!--[if lte IE 7]><!--> <link href="{$folderPath}visualsearch.css" media="screen" rel="stylesheet" type="text/css" /> <!--<![endif]--> EOD; $this->addOutputCode($output, 'head'); $id = $this->getId(); $query = ''; $callback = array(); $valuesMapping = array(); $valuesMappingRev = array(); $valueMatches = ''; foreach ($this->criteria as $v) { $callback[] = array('label' => $v->label, 'id' => $v->id); if ('facet' == $v->type) { $it = org_glizy_objectFactory::createModelIterator($this->getAttribute('model')); $it->where($v->id, '', '<>')->orderBy($v->id); $foundValues = array(); foreach ($it as $ar) { if (is_array($ar->{$v->id})) { foreach ($ar->{$v->id} as $value) { if (!in_array($value, $foundValues)) { $foundValues[] = $value; } } } else { if (!in_array($ar->{$v->id}, $foundValues)) { $foundValues[] = $ar->{$v->id}; } } } $valueMatches .= 'case "' . $v->label . '":callback(' . json_encode($foundValues) . ');break;'; } else { if ('static' == $v->type) { $foundValues = array(); $valuesMapping[$v->label] = array(); $values = json_decode($v->values); foreach ($values as $kk => $vv) { $label = __T($vv); $foundValues[] = $label; $valuesMapping[$v->label][$label] = $kk; $valuesMappingRev[$v->label][$kk] = $label; } $valueMatches .= 'case "' . $v->label . '":callback(' . json_encode($foundValues) . ');break;'; } else { if ('dictionary' == $v->type) { $dataProvider = $this->getComponentById($v->dataProvider); if (!is_null($dataProvider)) { $foundValues = array(); $valuesMapping[$v->label] = array(); $values = $dataProvider->getItems(); foreach ($values as $vv) { $foundValues[] = $vv['value']; $valuesMapping[$v->label][$vv['value']] = $vv['key']; $valuesMappingRev[$v->label][$vv['key']] = $vv['value']; } $valueMatches .= 'case "' . $v->label . '":callback(' . json_encode($foundValues) . ');break;'; } } } } } foreach ($this->filters as $item) { foreach ($item as $k => $v) { if (isset($valuesMappingRev[$k]) && isset($valuesMappingRev[$k][$v])) { $v = $valuesMappingRev[$k][$v]; } $query .= '"' . $k . '": "' . addslashes($v) . '" '; } } $callback = json_encode($callback); $valuesMapping = json_encode($valuesMapping); $output = <<<EOD <input name="{$id}_filters" id="{$id}_filters" type="hidden" value=""> <div id="{$id}_visualsearch"></div> <script type="text/javascript" charset="utf-8"> \$(document).ready(function() { var valuesMapping = {$valuesMapping}; var visualSearch = VS.init({ container : \$('#{$id}_visualsearch'), query : '{$query}', remainder: '', callbacks : { facetMatches : function(callback) { callback({$callback}) }, valueMatches : function(facet, searchTerm, callback) { switch (facet) { {$valueMatches} } } } }); \$('#{$id}').submit(function(){ var e = jQuery.Event("keydown"); e.which = 13 _.each(visualSearch.searchBox.inputViews, function(inputView, i) { inputView.box.trigger("focus"); inputView.box.trigger(e); }); var values = []; _.each(visualSearch.searchQuery.facets(), function(el, i){ _.each(el, function(el2, i2){ if (valuesMapping[i2]) { var temp = {}; temp[i2] = valuesMapping[i2][el2] values.push(temp); } else { values.push(el); } }); }); \$('#{$id}_filters').val(JSON.stringify(values)); return true; }) }); </script> EOD; $this->addOutputCode($output); }
public function render_html() { $graphCode = ''; $entityTypeId = $this->getAttribute('entityTypeId') ? $this->getAttribute('entityTypeId') : __Request::get('entityTypeId'); if ($entityTypeId) { $visited = array(); $edges = array(); $graphCode = $this->getGraph($entityTypeId, $visited, $edges); } if (!$this->getAttribute('generateLinks')) { $this->language = $this->_application->getEditingLanguage(); $this->localeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.LocaleService'); $html = '<form id="myForm" method="post" class="form-horizontal row-fluid" >'; $html .= '<label for="entityTypeId" class="control-label required">' . __T('Entity') . '</label>'; $html .= '<select id="entityTypeId" name="entityTypeId">'; $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Entity', 'all'); foreach ($it as $ar) { $selected = __Request::get('entityTypeId') == $ar->getId() ? 'selected="selected"' : ''; $html .= '<option value="' . $ar->getId() . '" ' . $selected . '>' . $this->localeService->getTranslation($this->language, $ar->entity_name) . '</option>'; } $html .= '</select>'; $html .= '<input class="submit btn btn-primary" type="submit" value="' . __T('Draw') . '">'; $html .= '</form>'; } $graphCode = <<<EOD digraph "" { {$graphCode} } EOD; $graphCode = str_replace(array("\r", "\n"), '', addslashes($graphCode)); $html .= <<<EOD <div style="text-align: center; position: relative; width: 100%;"> <svg width="800" height="600"> <g transform="translate(20, 20)"/> </svg> </div> <script> function tryDraw() { var result; try { result = graphlibDot.parse('{$graphCode}'); } catch (e) { alert('Errore di caricamento del grafo!'); throw e; } if (result) { var svg = d3.select("svg"); var svgGroup = svg.append('g'); var renderer = new dagreD3.Renderer(); var layout = renderer.run(result, svgGroup); var parentWidth = 800; svg.attr('width', parentWidth); svg.attr('height', layout.graph().height + 250); var xCenterOffset = (svg.attr('width') - layout.graph().width) / 2; svgGroup.attr('transform', 'translate(' + xCenterOffset + ', 100)'); } } function fixBaseTagProblem() { \$('g[class^="edgePaths"]').find('path').each(function() { \$(this).attr('marker-end', 'url(' + window.location + '#arrowhead)'); }); } function selectRootNode() { \$('div[class="main-node"]').parent().parent().parent().parent().children('rect').attr('class', 'main-node'); } \$(window).bind('load', function() { tryDraw(); fixBaseTagProblem(); selectRootNode(); }); </script> EOD; if ($this->getAttribute('addGraphJsLibs.js')) { $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/d3.v3.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/dagre-d3.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/graphlib-dot.min.js')); } $this->addOutputCode($html); }
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(); } } } } } }
public function render_html() { $graphCode = ''; $entityTypeId = $this->getAttribute('entityTypeId') ? $this->getAttribute('entityTypeId') : __Request::get('entityTypeId'); $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.Entity', 'all'); if ($it->count()) { $visited = array(); $edges = array(); foreach ($it as $ar) { if (!in_array($ar->getId(), array_keys($visited))) { $graphCode .= $this->getGraph($ar->getId(), $visited, $edges, true); } } } $graphCode = <<<EOD digraph "" { {$graphCode} } EOD; $graphCode = str_replace(array("\r", "\n"), '', addslashes($graphCode)); $html .= <<<EOD <div style="text-align: center;"> <svg width="800" height="600"> <g transform="translate(20, 20)"/> </svg> </div> <style> svg { overflow: hidden; } /* Stile testo delle entità */ g.nodes tspan { font-family: Helvetica, sans-serif; font-size: 14px; } /* Stile testo delle entità in HTML */ g.nodes div { white-space: nowrap; padding: 4px; font-family: Helvetica, sans-serif; font-size: 13px; } /* Stile testo delle entità principali in HTML */ div.main-node { padding: 2px 7px 2px 7px; font-family: Helvetica, sans-serif; font-size: 14px; } /* Stile testo delle relazioni */ g.edgeLabels tspan { } /* Stile riquadro delle entità */ .node rect { stroke: #cfced3; stroke-width: 2px; fill: none; } /* Stile delle frecce */ .edgePath path { stroke: black; stroke-width: 1.5px; fill: none; } </style> <script> function tryDraw() { var result; try { result = graphlibDot.parse('{$graphCode}'); } catch (e) { alert('Errore di caricamento del grafo!'); throw e; } if (result) { var svg = d3.select("svg"); var svgGroup = svg.append('g'); var renderer = new dagreD3.Renderer(); var layout = renderer.run(result, svgGroup); var parentWidth = parseInt(\$(svg).parent().css('width').replace('px', '')) - 250; svg.attr('width', parentWidth); svg.attr('height', layout.graph().height + 250); var xCenterOffset = (svg.attr('width') - layout.graph().width) / 2; svgGroup.attr('transform', 'translate(' + xCenterOffset + ', 100)'); } } function fixBaseTagProblem() { \$('g[class^="edgePaths"]').find('path').each(function() { \$(this).attr('marker-end', 'url(' + window.location + '#arrowhead)'); }); } function adjustEntityContainers() { \$('foreignObject').each(function() { var width = parseInt(\$(this).attr('width')); \$(this).attr('width', width + 25); }); } \$(window).bind('load', function() { tryDraw(); fixBaseTagProblem(); adjustEntityContainers(); }); </script> EOD; if ($this->getAttribute('addGraphJsLibs.js')) { $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/d3.v3.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/dagre-d3.js')); $this->addOutputCode(org_glizy_helpers_JS::linkJSfile(__Paths::get('STATIC_DIR') . 'dagre-d3/graphlib-dot.min.js')); } $this->addOutputCode($html); }
function createChildComponents() { $entityTypeId = $this->_content['entityTypeId']; $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'title', 'title'); $this->addChild($c); $this->_content['url'] = __Routing::makeUrl('showEntityDetail', array('entityTypeId' => $entityTypeId, 'document_id' => $this->_content['document_id'])); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'url', 'url'); $this->addChild($c); $entityTypeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $it = org_glizy_objectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityProperties'); $it->load('entityPropertiesFromId', array('entityId' => $entityTypeId)); foreach ($it as $ar) { $attribute = $entityTypeService->getAttributeIdByAr($ar); switch ($ar->entity_properties_type) { case 'attribute.image': if (is_null($this->_content['__image']) && $this->_content[$attribute]) { $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Image', $this->_application, $this, 'glz:Image', '__image', '__image'); $c->setAttribute('width', __Config::get('THUMB_WIDTH')); $c->setAttribute('height', __Config::get('THUMB_HEIGHT')); $c->setAttribute('crop', true); $this->addChild($c); $this->_content['__image'] = $this->_content[$attribute]; } break; } if (is_null($this->_content['__description']) && $ar->entity_properties_dublic_core == 'DC.Description' && $this->_content[$attribute]) { $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.LongText', $this->_application, $this, 'glz:LongText', '__description', '__description'); $c->setAttribute('adm:htmlEditor', true); $this->addChild($c); $this->_content['__description'] = glz_strtrim(strip_tags($this->_content[$attribute])); } } // controlla se esiste una lista media/immagini e ne prende la prima if (is_null($this->_content['__image'])) { foreach ($it as $ar) { $attribute = $entityTypeService->getAttributeIdByAr($ar); switch ($ar->entity_properties_type) { case 'attribute.imagelist': if (is_null($this->_content['__image']) && $this->_content[$attribute]) { $objectVars = get_object_vars($this->_content[$attribute]); $content = array_shift($objectVars); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Image', $this->_application, $this, 'glz:Image', '__image', '__image'); $c->setAttribute('width', __Config::get('THUMB_SMALL_WIDTH')); $c->setAttribute('height', __Config::get('THUMB_SMALL_HEIGHT')); $c->setAttribute('crop', true); $this->addChild($c); $this->_content['__image'] = $content[0]; } break; } } } // inserisce un'immagine di default if (is_null($this->_content['__image'])) { $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.NoImage', $this->_application, $this, 'glz:Image', '__image', '__image'); $c->setAttribute('width', __Config::get('THUMB_SMALL_WIDTH')); $c->setAttribute('height', __Config::get('THUMB_SMALL_HEIGHT')); $this->addChild($c); } if (is_null($this->_content['__description'])) { foreach ($it as $ar) { $attribute = $entityTypeService->getAttributeIdByAr($ar); if (is_null($ar->entity_properties_target_FK_entity_id) && preg_match('/text$/', $ar->entity_properties_type) && $this->_content[$attribute]) { $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.LongText', $this->_application, $this, 'glz:LongText', '__description', '__description'); $c->setAttribute('adm:htmlEditor', true); $this->addChild($c); $this->_content['__description'] = glz_strtrim(strip_tags($this->_content[$attribute])); } } } }