private function addDefaultComponents() { $id = '__id'; $c = org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Hidden', $id, $id); $this->addChild($c); $c->init(); }
function createChildComponents() { $entityTypeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $properties = $entityTypeService->getEntityTypeAttributeProperties(__Request::get('entityTypeId'), $this->_parent->getId()); $moduleId = $properties['entity_properties_params']; $this->_content['title'] = $this->data->text; $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'title', 'title'); $this->addChild($c); $this->_content['url'] = __Routing::makeUrl($moduleId, array('document_id' => $this->data->id, 'title' => $this->data->text)); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'url', 'url'); $this->addChild($c); $module = org_glizy_Modules::getModule($moduleId); $ar = org_glizy_ObjectFactory::createModel($module->classPath . '.models.Model'); $ar->load($this->data->id); if ($ar->fieldExists('image')) { $this->_content['__image'] = $ar->image; $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); } else { $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); } }
/** * Process * * @return boolean false if the process is aborted * @access public */ function process() { $tagContent = $this->getText(); if (empty($tagContent)) { // richiede il contenuto al padre $tagContent = $this->_parent->loadContent($this->getId()); $this->setText($tagContent); } if ($this->_parent->_tagname == 'glz:Page') { if (strpos($this->getText(), '.xml') !== false) { // crea i componenti leggendoli dal pageType specificato $fileName = org_glizy_Paths::getRealPath('APPLICATION_PAGE_TYPE', $this->getText()); if (!empty($fileName)) { $originalRootComponent =& $this->_application->getRootComponent(); $this->_pageTypeObj =& org_glizy_ObjectFactory::createPage($this->_application, preg_replace('/.xml$/', '', $this->getText())); $rootComponent =& $this->_application->getRootComponent(); $rootComponent->init(); $this->_application->_rootComponent =& $originalRootComponent; for ($i = 0; $i < count($rootComponent->childComponents); $i++) { $rootComponent->childComponents[$i]->remapAttributes($this->getId() . '-'); $this->addChild($rootComponent->childComponents[$i]); $rootComponent->childComponents[$i]->_parent =& $this; } $this->processChilds(); } } else { $newComponent =& org_glizy_ObjectFactory::createComponent($this->getText(), $this->_application, $this, '', '', ''); $newComponent->init(); $this->addChild($newComponent); $this->processChilds(); } } }
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); } }
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])); } } } }
/** * @param $className */ function createChildsFromModel($className) { // crea i figli /** @var org_glizy_components_Component $newComponent */ $newComponent =& org_glizy_ObjectFactory::createComponent($className, $this->_application, $this, '', $this->getId()); for ($i = 0; $i < count($newComponent->childComponents); $i++) { $newComponent->childComponents[$i]->remapAttributes($this->getId() . '-'); $this->addChild($newComponent->childComponents[$i]); $newComponent->childComponents[$i]->_parent =& $this; } $this->initChilds(); // TODO // problema da risolvere in modo più elengante // quando si crea un componente figlio come in questo caso // l'id del component nella mappa degli ID viene sovrascritto // con il componente nuovo perché al memoneto della creazione gli viene passato lo stesso ID $this->setAttribute('id', $this->getId()); }
function __construct(&$application, &$parent, $tagName = '', $id = '', $originalId = '') { parent::__construct($application, $parent, $tagName, $id, $originalId); if (!__Request::get('entityTypeId')) { return; } $entityTypeId = __Request::get('entityTypeId'); $entityModel = org_glizy_objectFactory::createModel('movio.modules.ontologybuilder.models.Entity'); $entityModel->load($entityTypeId); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', '__type', '__type'); $c->setAttribute('label', 'Tipo'); $c->setAttribute('value', __Tp($entityModel->entity_name)); $c->setAttribute('disabled', true); $this->addChild($c); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Input', $entityTypeId, $entityTypeId); $c->setAttribute('name', 'entityTypeId'); $c->setAttribute('value', $entityTypeId); $this->addChild($c); $entityId = __Request::get('entityId'); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Input', $entityId, $entityId); $c->setAttribute('name', 'entityId'); $c->setAttribute('value', $entityId); $this->addChild($c); $id = '__isVisible'; $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Checkbox', $this->_application, $this, 'glz:Checkbox', $id, $id); $c->setAttribute('label', __Tp('Visible')); $c->setAttribute('data', 'type=checkbox'); $this->addChild($c); $id = 'title'; $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $id, $id); $c->setAttribute('label', __Tp('Title')); $c->setAttribute('required', true); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); $id = 'subtitle'; $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $id, $id); $c->setAttribute('label', __Tp('Subtitle')); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); $id = 'url'; $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $id, $id); $c->setAttribute('label', __Tp('URL')); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); $id = 'profile'; $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $id, $id); $c->setAttribute('label', __Tp('Profile')); $c->setAttribute('data', 'type=selectfrom;multiple=true;model=org.glizycms.groupManager.models.UserGroup;field=usergroup_name'); $c->setAttribute('value', ''); $this->addChild($c); $entityTypeService = $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.text': case 'attribute.externalimage': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('type', 'text'); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.int': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('type', 'number'); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.longtext': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('type', 'multiline'); $c->setAttribute('rows', '10'); $c->setAttribute('cols', '90'); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.descriptivetext': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('type', 'multiline'); $c->setAttribute('rows', '10'); $c->setAttribute('cols', '90'); $c->setAttribute('htmlEditor', true); $c->setAttribute('data', 'type=tinymce'); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.date': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('readOnly', true); $c->setAttribute('type', 'text'); $c->setAttribute('data', 'type=date;date-format=yyyy-mm-dd'); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.externallink': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('type', 'url'); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.internallink': $c =& org_glizy_ObjectFactory::createComponent('org.glizycms.views.components.PagePicker', $this->_application, $this, 'cms:PagePicker', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.openlist': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $proxyParams = json_encode(array('entityTypeId' => $entityTypeId)); $proxyParams = str_replace('"', '##', $proxyParams); $c->setAttribute('data', 'type=selectfrom;multiple=false;add_new_values=true;proxy=movio.modules.ontologybuilder.models.proxy.EntityProxy;proxy_params=' . $proxyParams); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.image': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('data', 'type=mediapicker;mediatype=IMAGE;preview=true'); $c->setAttribute('size', '90'); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.media': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('data', 'type=mediapicker;mediatype=ALL;preview=false'); $c->setAttribute('size', '90'); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.imagelist': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Fieldset', $this->_application, $this, 'glz:Fieldset', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('data', 'type=repeat;repeatMin=0;collapsable=false'); $subchild =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', 'attaches', 'attaches'); $subchild->setAttribute('label', 'Image'); $subchild->setAttribute('size', '90'); $subchild->setAttribute('data', 'type=mediapicker;mediatype=IMAGE;preview=true'); $c->addChild($subchild); $this->addChild($c); break; case 'attribute.medialist': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Fieldset', $this->_application, $this, 'glz:Fieldset', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('data', 'type=repeat;repeatMin=0;collapsable=false'); $subchild =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', 'attaches', 'attaches'); $subchild->setAttribute('label', 'Media'); $subchild->setAttribute('size', '90'); $subchild->setAttribute('data', 'type=mediapicker;mediatype=ALL;preview=false'); $c->addChild($subchild); $this->addChild($c); break; // TODO // TODO case 'attribute.photogallery': $c =& org_glizy_ObjectFactory::createComponent('movio.views.components.PhotogalleryCategory', $this->_application, $this, 'm:PhotogalleryCategory', $attribute, $attribute, true, 'edit'); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $this->addChild($c); break; case 'attribute.europeanaRelatedContents': $searchFields = __Config::get('movio.europeana.searchFields'); $rows = __Config::get('movio.europeana.rows'); $searchFieldsLabels = ''; $keyFieldsLabels = explode(',', __Config::get('movio.europeana.searchFieldsLabels')); $last = count($keyFieldsLabels); $counter = 0; foreach ($keyFieldsLabels as $field) { $counter++; $searchFieldsLabels .= __T($field); if ($counter < $last) { $searchFieldsLabels .= ","; } } $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('data', 'type=europeanaRelatedContents;search_fields=' . $searchFields . ';search_fields_labels=' . $searchFieldsLabels . ';max_result=' . $rows); $c->setAttribute('value', ''); $this->addChild($c); $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.JSscript', $this->_application, $this, 'glz:JSscript', ''); $c->setAttribute('folder', 'movio/modules/europeana/views/js'); $c->setAttribute('editableRegion', 'tail'); $this->addChild($c); break; case 'attribute.thesaurus': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $proxyParams = json_encode(array('dictionaryId' => $ar->entity_properties_params)); $proxyParams = str_replace('"', '##', $proxyParams); $c->setAttribute('data', 'type=selectfrom;multiple=true;add_new_values=false;proxy=movio.modules.thesaurus.models.proxy.ThesaurusProxy;format_selection=formatThesaurusSelection;format_result=formatThesaurusResult;return_object=true;proxy_params=' . $proxyParams); $c->setAttribute('value', ''); $this->addChild($c); break; case 'attribute.module': $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $proxyParams = json_encode(array('moduleId' => $ar->entity_properties_params)); $proxyParams = str_replace('"', '##', $proxyParams); $c->setAttribute('data', 'type=selectfrom;multiple=true;proxy=movio.modules.ontologybuilder.models.proxy.ModelProxy;return_object=true;proxy_params=' . $proxyParams); $c->setAttribute('value', ''); $this->addChild($c); break; default: // se l'attributo è una relazione if (!is_null($ar->entity_properties_target_FK_entity_id)) { $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $attribute, $attribute); $c->setAttribute('label', __Tp($ar->entity_properties_label_key)); $c->setAttribute('required', $ar->entity_properties_required == 1); $relation = $entityTypeService->getRelation($ar->entity_properties_type); $c->setAttribute('data', 'type=entityselect;entity_type_id=' . $ar->entity_properties_target_FK_entity_id . ';cardinality=' . $relation['cardinality']); $c->setAttribute('cssClass', __Config::get('glizy.formElement.admCssClass')); $c->setAttribute('value', ''); $this->addChild($c); break; } } } }
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)); $jsonRelations = array(); 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); $c->setAttribute('parseInternalLinks', false); $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); $c->setAttribute('parseInternalLinks', false); $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': $this->addMedia('images', $this->_content[$attribute]); break; case 'attribute.media': $this->addMedia('medias', $this->_content[$attribute]); break; case 'attribute.imagelist': if ($this->_content[$attribute]) { foreach ($this->_content[$attribute]->attaches as $attach) { $this->addMedia('imageList', $attach); } } break; case 'attribute.medialist': if ($this->_content[$attribute]) { foreach ($this->_content[$attribute]->attaches as $attach) { $this->addMedia('mediaList', $attach); } } break; case 'attribute.photogallery': if ($this->_content[$attribute . '-images']) { foreach ($this->_content[$attribute . '-images'] as $category) { $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.models.Media'); $it->where('media_category', '%' . $category . '%', 'LIKE')->orderBy('media_title'); foreach ($it as $ar) { $media = array('id' => $ar->media_id, 'title' => $ar->media_title, 'fileName' => $ar->media_fileName); $this->addMedia('photogallery', json_encode($media)); } } } break; 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']) { $relations = $this->loadContent($attribute); $entityTypeName = $entityTypeService->getEntityTypeName($ar->entity_properties_target_FK_entity_id); $jsonRelations[$entityTypeName] = array(); foreach ($relations['content'] as $relation) { $jsonRelation = array(); $jsonRelation['title'] = $relation['title']; $image = ''; foreach ($relation as $k => $v) { if (is_string($v) && preg_match('/{"id":\\d+,/', $v, $m)) { $image = $v; break; } } $image = $this->addMedia('', $image); $jsonRelation['image'] = $image; $jsonRelation['entityTypeId'] = $relation['entityTypeId']; $jsonRelation['document_id'] = $relation['document_id']; $jsonRelations[$entityTypeName][] = $jsonRelation; } } } } if ($jsonRelations) { $this->json['relations'][] = $jsonRelations; } $jsonRelations = array(); foreach ((array) $this->_content['__reference_relations'] as $entityTypeName => $data) { if ($data['show'] != 3) { $entityTypeName = $data['relation']; $jsonRelations[$entityTypeName] = array(); foreach ($data['content'] as $relation) { $jsonRelation = array(); $jsonRelation['title'] = $relation['title']; $image = ''; foreach ($relation as $k => $v) { if (is_string($v) && preg_match('/{"id":\\d+,/', $v, $m)) { $image = $v; break; } } $image = $this->addMedia('', $image); $jsonRelation['image'] = $image; $jsonRelation['entityTypeId'] = $relation['entityTypeId']; $jsonRelation['document_id'] = $relation['document_id']; $jsonRelations[$entityTypeName][] = $jsonRelation; } } } if ($jsonRelations) { $this->json['reference_relations'][] = $jsonRelations; } if ($entityTypeService->getEntityTypeAttribute($entityTypeId, 'entity_show_relations_graph')) { $c =& org_glizy_ObjectFactory::createComponent('movio.modules.publishApp.views.components.DocumentGraph', $this->_application, $this, 'cmp:DocumentGraph', 'document_graph', 'document_graph'); $c->setAttribute('entityTypeId', $entityTypeId); $c->setAttribute('documentId', $this->getId()); $c->setAttribute('addGraphJsLibs.js', false); $c->setAttribute('editableRegion', 'graph'); $this->addChild($c); } foreach (array('images', 'imageList', 'medias', 'mediaList', 'photogallery') as $k) { if ($this->json[$k]) { $this->json[$k] = array_values($this->json[$k]); } } $this->addChild($groupBox); }
private function addDefaultComponents($menu) { $id = '__id'; $c = org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Hidden', $id, $id); $this->addChild($c); $c->init(); $id = '__indexFields'; $childs[$id] = org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Hidden', $id, $id); $c =& $childs[$id]; $this->addChild($c); $c->init(); $id = '__title'; $childs[$id] = org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $id, $id); $c =& $childs[$id]; $c->setAttribute('label', __T('Title')); $c->setAttribute('required', true); $c->setAttribute('size', '90'); $c->setAttribute('cssClass', $this->getAttribute('adm:cssClass')); $this->addChild($c); $c->init(); $id = '__url'; if ($this->getAttribute('editUrl')) { $childs[$id] = org_glizy_ObjectFactory::createComponent('org.glizy.components.Input', $this->_application, $this, 'glz:Input', $id, $id); } else { $childs[$id] = org_glizy_ObjectFactory::createComponent('org.glizy.components.Hidden', $this->_application, $this, 'glz:Hidden', $id, $id); } $c =& $childs[$id]; $c->setAttribute('label', __T('URL')); $c->setAttribute('required', false); $c->setAttribute('size', '90'); $c->setAttribute('cssClass', $this->getAttribute('adm:cssClass')); $this->addChild($c); $c->init(); }
/** * Listeners */ public function onProcessStart($evt) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $rootComponent = $application->getRootComponent(); $c = org_glizy_ObjectFactory::createComponent('org.glizy.debug.views.components.DebugBar', $application, $rootComponent, 'debugBar', 'debugBar'); $c->init(); $rootComponent->addChild($c); $this->debugBar['time']->addMeasure('Booting', $this->startTime, microtime(true)); $this->debugBar['time']->startMeasure('application.process', 'Process'); }