/** * Group leaflet markers, layers and vectors by their group. * * @param GetPropertyOptionsEvent $event The GetPropertyOptions Event. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) */ public function getPropertyOptions(GetPropertyOptionsEvent $event) { $model = $event->getModel(); if ($model instanceof Model) { $item = $model->getItem(); $attribute = $item->getAttribute($event->getPropertyName()); if (!$attribute) { return; } $selectTable = $attribute->get('select_table'); $alias = $attribute->get('select_alias'); if ($selectTable == 'tl_leaflet_layer') { $collection = $this->fetchOptionsCollection('Netzmacht\\Contao\\Leaflet\\Model\\LayerModel', $attribute); $options = OptionsBuilder::fromCollection($collection, $alias, array($this, 'parseLayerLabel'))->groupBy('pid', array($this, 'parseLayerGroup'))->getOptions(); $event->setOptions($options); } elseif ($selectTable == 'tl_leaflet_vector' || $selectTable == 'tl_leaflet_marker') { $class = $GLOBALS['TL_MODELS'][$selectTable]; $collection = $this->fetchOptionsCollection($class, $attribute); $options = OptionsBuilder::fromCollection($collection, $alias, $attribute->get('select_column'))->groupBy('pid', array($this, 'parseLayerGroup'))->getOptions(); $event->setOptions($options); } } }
/** * Get all render settings of a metamodel. * * @param \DataContainer $dataContainer The data container driver. * * @return array */ public function getRenderSettings($dataContainer) { $settings = array(); if ($dataContainer->activeRecord) { $layer = LayerModel::findByPk($dataContainer->activeRecord->pid); if (!$layer) { return $settings; } $result = \Database::getInstance()->prepare('SELECT * FROM tl_metamodel_rendersettings WHERE pid=?')->execute($layer->metamodel); return OptionsBuilder::fromResult($result, 'name')->getOptions(); } return $settings; }
/** * Get all layers except of the current layer. * * @param \DataContainer $dataContainer The dataContainer driver. * * @return array */ public function getLayers($dataContainer) { $collection = LayerModel::findBy('id !', $dataContainer->id); return OptionsBuilder::fromCollection($collection, 'id', 'title')->asTree()->getOptions(); }
/** * Get all metamodels. * * @return array */ public function getMetaModels() { $result = \Database::getInstance()->query('SELECT id, name FROM tl_metamodel ORDER BY name'); $options = OptionsBuilder::fromResult($result, 'id', 'name')->getOptions(); return $options; }
/** * Get all popups. * * @return array */ public function getPopups() { $collection = PopupModel::findAll(array('order' => 'title')); $builder = OptionsBuilder::fromCollection($collection, 'title'); return $builder->getOptions(); }
/** * Get all styles. * * @return array */ public function getStyles() { $collection = StyleModel::findAll(array('order' => 'title')); return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); }
/** * Get all leaflet maps. * * @return array */ public function getMaps() { $collection = MapModel::findAll(); return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions(); }
/** * Get the zoom controls for the reference value of the loading control. * * @return array */ public function getZoomControls() { $collection = ControlModel::findBy('type', 'zoom', array('order' => 'title')); return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions(); }
/** * Get all settings. * * @return array */ public function getSettings() { $collection = ValidationModel::findAll(array('order' => 'title')); return OptionsBuilder::fromCollection($collection, 'title')->getOptions(); }
/** * Get notification ids. * * @return array */ public function getNotificationIds() { $collection = Notification::findBy(array('type LIKE ?'), 'workflow_%'); return OptionsBuilder::fromCollection($collection, 'id', 'title')->groupBy('type')->getOptions(); }
/** * Get all metamodels. * * @return array */ public function getMetaModels() { $result = $this->database->query('SELECT id, name FROM tl_metamodel ORDER BY name'); $options = OptionsBuilder::fromResult($result, 'name')->getOptions(); return $options; }