/**
  * Retrieve the options for the attributes.
  *
  * @param GetOptionsEvent $event The event.
  *
  * @return void
  */
 public function getOptions(GetOptionsEvent $event)
 {
     if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute' || $event->getPropertyName() !== 'combinedvalues_fields' || $event->getSubPropertyName() !== 'field_attribute') {
         return;
     }
     $model = $event->getModel();
     $metaModel = $this->getMetaModelById($model->getProperty('pid'));
     if (!$metaModel) {
         return;
     }
     $result = array();
     // Add meta fields.
     $result['meta'] = self::getMetaModelsSystemColumns();
     // Fetch all attributes except for the current attribute.
     foreach ($metaModel->getAttributes() as $attribute) {
         if ($attribute->get('id') === $model->getId()) {
             continue;
         }
         $type = $event->getEnvironment()->getTranslator()->translate('typeOptions.' . $attribute->get('type'), 'tl_metamodel_attribute');
         if ($type == 'typeOptions.' . $attribute->get('type')) {
             $type = $attribute->get('type');
         }
         $result['attributes'][$attribute->getColName()] = sprintf('%s [%s]', $attribute->getName(), $type);
     }
     $event->setOptions($result);
 }
 /**
  * Check if the event is intended for us.
  *
  * @param GetOptionsEvent $event The event to test.
  *
  * @return bool
  */
 private function isEventForMe(GetOptionsEvent $event)
 {
     $input = $event->getEnvironment()->getInputProvider();
     if ($input->hasValue('type')) {
         $type = $input->getValue('type');
     }
     if (empty($type)) {
         $type = $event->getModel()->getProperty('type');
     }
     return $event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute' || $type !== 'translatedalias' || $event->getPropertyName() !== 'talias_fields' || $event->getSubPropertyName() !== 'field_attribute';
 }
 /**
  * Check if the event is intended for us.
  *
  * @param GetOptionsEvent $event The event to test.
  *
  * @return bool
  */
 private function isEventForMe(GetOptionsEvent $event)
 {
     $input = $event->getEnvironment()->getInputProvider();
     $type = $event->getModel()->getProperty('type');
     if ($input->hasValue('type')) {
         $type = $input->getValue('type');
     }
     if (empty($type)) {
         $type = $event->getModel()->getProperty('type');
     }
     return $event->getEnvironment()->getDataDefinition()->getName() === 'tl_metamodel_attribute' && $type === 'combinedvalues' && $event->getPropertyName() === 'combinedvalues_fields' && $event->getSubPropertyName() === 'field_attribute';
 }
 /**
  * @param GetOptionsEvent $event
  */
 public function bypassCreateRecipientPropertiesOptions(GetOptionsEvent $event)
 {
     if ($event->getModel()->getProviderName() === 'orm_avisota_recipient_source' && $event->getPropertyName() != 'membersPropertyFilter' || $event->getSubPropertyName() != 'membersPropertyFilter_property') {
         return;
     }
     $options = $event->getOptions();
     $options = $this->getRecipientPropertiesOptions($event->getEnvironment(), $options);
     $event->setOptions($options);
 }
 /**
  * Check if the current context is valid.
  *
  * @param GetPropertyOptionsEvent|GetOptionsEvent $event              The event.
  *
  * @param string                                  $dataDefinitionName The allowed name of the data definition.
  *
  * @param array                                   $properties         A list of allowed properties.
  *
  * @return bool
  */
 protected function isAllowedProperty($event, $dataDefinitionName, $properties)
 {
     if ($event->getEnvironment()->getDataDefinition()->getName() !== $dataDefinitionName) {
         return false;
     }
     if (!in_array($event->getPropertyName(), $properties)) {
         return false;
     }
     return true;
 }
예제 #6
0
파일: Subscriber.php 프로젝트: zonky2/core
 /**
  * Get all options for the render settings.
  *
  * @param GetOptionsEvent $event The event.
  *
  * @return void
  */
 public function getRenderSettingsOptions(GetOptionsEvent $event)
 {
     if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_dca_combine' || $event->getPropertyName() !== 'rows' || $event->getSubPropertyName() !== 'view_id') {
         return;
     }
     $inputScreens = $this->getDatabase()->prepare('SELECT id,name FROM tl_metamodel_rendersettings WHERE pid=?')->execute($event->getModel()->getProperty('id'));
     $result = array();
     while ($inputScreens->next()) {
         $result[$inputScreens->id] = $inputScreens->name;
     }
     $event->setOptions($result);
 }
예제 #7
0
 /**
  * Provide options for additional javascript files.
  *
  * @param GetOptionsEvent $event The event.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public static function getJsFilesOptions(GetOptionsEvent $event)
 {
     if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_rendersettings' || $event->getPropertyName() !== 'additionalJs' || $event->getSubPropertyName() !== 'file') {
         return;
     }
     $options = Helper::searchFiles($GLOBALS['TL_CONFIG']['uploadPath'], '.js');
     $event->setOptions($options);
 }