Exemplo n.º 1
0
 /**
  * @param $strProperty
  * @param $value
  * @return string
  */
 public function getPropertyValue($strProperty, $value)
 {
     if (!$this->definition->hasProperty($strProperty)) {
         return '';
     }
     $definition = $this->definition->getProperty($strProperty);
     $value = deserialize($value);
     if (is_array($value)) {
         $value = implode(', ', $value);
     } elseif ($definition->getWidgetType() == 'checkbox' && !$this->definition->get('eval/multiple')) {
         $value = $this->translate('/MSC/' . (strlen($value) ? 'yes' : 'no'));
     } elseif (in_array($this->definition->get('eval/rgxp'), array('date', 'datim', 'time'))) {
         $format = $this->definition->get('eval/rgxp');
         $value = \Date::parse($GLOBALS['TL_CONFIG'][$format], $value);
     } elseif ($this->definition->get(sprintf('reference/%s/0', $value))) {
         $value = $this->definition->get(sprintf('reference/%s/0', $value));
     } elseif ($this->definition->get(sprintf('reference/%s', $value))) {
         $value = $this->definition->get(sprintf('reference/%s', $value));
     } elseif ($this->definition->get('eval/isAssociative') || array_is_assoc($this->definition->get('options'))) {
         $value = $this->definition->get('options/' . $value);
     } elseif ($this->definition->get('eval/foreignKey')) {
         $arrForeignKey = explode('.', $this->definition->get('eval/foreignKey'), 2);
         $objLabel = \Database::getInstance()->prepare("SELECT " . $arrForeignKey[1] . " AS value FROM " . $arrForeignKey[0] . " WHERE id=?")->limit(1)->execute($value);
         if ($objLabel->numRows) {
             $value = $objLabel->value;
         }
     }
     if ($strProperty == 'tstamp') {
         $value = date($GLOBALS['TL_CONFIG']['datimFormat'], $value);
     }
     return $value;
 }
Exemplo n.º 2
0
 /**
  * @param $operation
  */
 public function enableGlobalOperationEvents($operation)
 {
     if (!isset($this->enabledGlobalOperations[$operation])) {
         $config = $this->definition->get('list/global_operations/' . $operation);
         $this->enabledGlobalOperations[$operation] = true;
         if (isset($config['button_callback'])) {
             $this->addGlobalOperationListener($operation, function ($objEvent) use($config) {
                 ContaoListener::generateOperation($objEvent, $config['button_callback']);
             }, static::PRIORITY_LOW);
         }
         $this->definition->set(sprintf('list/global_operations/%s/button_callback', $operation), array('DcaTools\\Bridge', 'globalOperationCallback' . $operation));
     }
 }