protected function escape($s, $trim = false) { $s = htmlentities($s, null, "UTF-8"); // si taglia la stringa dopo i 60 caratteri $s = glz_strtrim($s, 60); return $s; }
public function execute($id) { $this->directOutput = true; $output = array(); $languageId = org_glizy_ObjectValues::get('org.glizy', 'editingLanguageId'); $menuProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.MenuProxy'); $contentProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.ContentProxy'); $itMenus = $menuProxy->getChildMenusFromId($id, $languageId, false); foreach ($itMenus as $subMenu) { $content = $contentProxy->readRawContentFromMenu($subMenu->menu_id, $languageId); $description = ''; if ($content) { $description = property_exists($content->content, 'text') ? $content->content->text : (property_exists($content->content, 'description') ? $content->content->description : ''); } $output[] = array('id' => $subMenu->menu_id, 'title' => $subMenu->menudetail_title, 'description' => glz_strtrim($description) . ' (' . $subMenu->menu_pageType . ')'); } return $output; }
public function getDocumentsWithTerm($termId) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $entityTypeService = $application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $entityResolver = org_glizy_objectFactory::createObject('movio.modules.ontologybuilder.EntityResolver'); $menuMap = array(); // TODO: non va bene l'implementazione perché scorre tutti i documenti // eseguire un filtro sui documenti del tipo di entità che ha una campo di tipo dizionario $it = org_glizy_ObjectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityDocument')->load('All'); $result = array(); foreach ($it as $ar) { $entityTypeId = $entityTypeService->getEntityTypeId($ar->getType()); if (!isset($menuMap[$entityTypeId])) { $arMenu = $entityResolver->getMenuVisibleEntity($entityTypeId); $menuMap[$entityTypeId] = $arMenu; } else { $arMenu = $menuMap[$entityTypeId]; } $thesaurusAttribute = $entityTypeService->getAttributeByType($entityTypeId, 'attribute.thesaurus'); $descriptionAttribute = $entityTypeService->getDescriptionAttribute($entityTypeId); // se l'entità di questo documento ha un campo di tipo thesaurus if ($arMenu && $thesaurusAttribute) { $thesaurusAttribute = $this->prepareThesaurusAttribute($thesaurusAttribute); foreach ($thesaurusAttribute as $attribute) { if ($ar->keyInDataExists($attribute)) { if (!is_array($ar->{$attribute})) { continue; } // si cerca nei tag il termine con id uguale a termId foreach ($ar->{$attribute} as $term) { if ($term->id == $termId) { $document_id = $ar->getId(); $result[] = array('id' => $document_id, 'title' => $ar->title, 'description' => glz_strtrim($descriptionAttribute && $ar->keyInDataExists($descriptionAttribute) ? $ar->{$descriptionAttribute} : '', 300), 'url' => __Routing::makeUrl('showEntityDetail', array('pageId' => $arMenu->id, 'entityTypeId' => $entityTypeId, 'document_id' => $document_id))); break; } } } } } } return $result; }
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])); } } } }