getColName() public method

Queries the attribute for it's column name within it's MetaModel.
public getColName ( ) : string
return string the attributes column name.
 /**
  * {@inheritDoc}
  */
 public function getMatchingIds()
 {
     if ($this->mode == self::MODE_SINGLE) {
         return $this->runSimpleQuery('item_id', 'tl_metamodel_geolocation', 'latitude', 'longitude', array('att_id=?' => $this->singleAttribute->get('id')));
     } else {
         return $this->runSimpleQuery('id', $this->getMetaModelTableName(), $this->latitudeAttribute->getColName(), $this->longitudeAttribute->getColName(), null);
     }
 }
 /**
  * Generate the toggle command information.
  *
  * @param CommandCollectionInterface $commands    The already existing commands.
  *
  * @param IAttribute                 $attribute   The attribute.
  *
  * @param string                     $commandName The name of the new command.
  *
  * @param string                     $class       The name of the CSS class for the command.
  *
  * @param string                     $language    The language name.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function generateToggleCommand($commands, $attribute, $commandName, $class, $language)
 {
     if (!$commands->hasCommandNamed($commandName)) {
         $toggle = new TranslatedToggleCommand();
         $toggle->setLanguage($language)->setToggleProperty($attribute->getColName())->setName($commandName)->setLabel($GLOBALS['TL_LANG']['MSC']['metamodelattribute_translatedcheckbox']['toggle'][0])->setDescription(sprintf($GLOBALS['TL_LANG']['MSC']['metamodelattribute_translatedcheckbox']['toggle'][1], $attribute->getName(), $language));
         $extra = $toggle->getExtra();
         $extra['icon'] = 'visible.gif';
         $extra['class'] = $class;
         if ($commands->hasCommandNamed('show')) {
             $info = $commands->getCommandNamed('show');
         } else {
             $info = null;
         }
         $commands->addCommand($toggle, $info);
     }
 }
Beispiel #3
0
 /**
  * Helper function for {@see MetaModelItem::parseValue()} and {@see MetaModelItem::parseAttribute()}.
  *
  * @param IAttribute       $objAttribute    The attribute to parse.
  *
  * @param string           $strOutputFormat The desired output format.
  *
  * @param ICollection|null $objSettings     The settings object to be applied.
  *
  * @return array The parsed information for the given attribute.
  */
 public function internalParseAttribute($objAttribute, $strOutputFormat, $objSettings)
 {
     $arrResult = array();
     if ($objAttribute) {
         // Extract view settings for this attribute.
         if ($objSettings) {
             $objAttributeSettings = $objSettings->getSetting($objAttribute->getColName());
         } else {
             $objAttributeSettings = null;
         }
         foreach ($objAttribute->parseValue($this->arrData, $strOutputFormat, $objAttributeSettings) as $strKey => $varValue) {
             $arrResult[$strKey] = $varValue;
         }
     }
     // If "hideEmptyValues" is true and the raw is empty remove text and output format.
     if ($objSettings instanceof ICollection && $objSettings->get('hideEmptyValues') && $this->isEmptyValue($arrResult['raw'])) {
         unset($arrResult[$strOutputFormat]);
         unset($arrResult['text']);
     }
     return $arrResult;
 }
 /**
  * Run the search for the complex attribute geolocation.
  *
  * @param Container  $container     The container with all information.
  *
  * @param array      $idList        The list with the current ID's.
  *
  * @param IAttribute $latAttribute  The attribute to filter on.
  *
  * @param IAttribute $longAttribute The attribute to filter on.
  *
  * @return array A list with all sorted id's.
  */
 protected function doSearchForTwoSimpleAtt($container, $idList, $latAttribute, $longAttribute)
 {
     // Get location.
     $lat = $container->getLatitude();
     $lng = $container->getLongitude();
     $intDist = $container->getDistance();
     $subSQL = sprintf('SELECT
             id,
             round
             (
               sqrt
               (
                 power
                 (
                   2 * pi() / 360 * (%1$s -  CAST(%3$s AS DECIMAL(10,6))   ) * 6371,2) 
                   + power(2 * pi() / 360 * (%2$s - CAST(%4$s AS DECIMAL(10,6))) 
                   * 6371 * COS(2 * pi() / 360 * (%1$s + CAST(%3$s AS DECIMAL(10,6))) * 0.5),2
                 )
               )
             ) 
             AS item_dist
         FROM
             %6$s
         WHERE
             id IN(%5$s)
         ORDER BY item_dist', $lat, $lng, $latAttribute->getColName(), $longAttribute->getColName(), implode(', ', $idList), $this->getMetaModel()->getTableName());
     $objResult = \Database::getInstance()->prepare($subSQL)->execute($intDist);
     $newIdList = array();
     foreach ($objResult->fetchAllAssoc() as $item) {
         $id = $item['id'];
         $distance = $item['item_dist'];
         $newIdList[] = $id;
         self::$data[$id] = $distance;
     }
     $diff = array_diff($idList, $newIdList);
     return array_merge($newIdList, $diff);
 }
 /**
  * Prepare used values.
  *
  * @param MetaModel $metaModel The meta model.
  * @param Items     $items     The meta model items list.
  * @param Attribute $reference The reference attribute.
  * @param array     $values    The reference values.
  * @param array     $icons     The used icons.
  * @param array     $styles    The used styles.
  *
  * @return void
  */
 protected function prepareValues(MetaModel $metaModel, Items $items, Attribute $reference, &$values, &$icons, &$styles)
 {
     $icon = $metaModel->getAttributeById($this->model->iconAttribute);
     $style = $metaModel->getAttributeById($this->model->styleAttribute);
     foreach ($items as $item) {
         $value = $item->get($reference->getColName());
         $itemId = $item->get('id');
         if ($value) {
             $values[$itemId] = $this->getAttributeValue($value);
         }
         if ($icon) {
             $value = $item->get($icon->getColName());
             if ($value) {
                 $icons[$itemId] = $this->getAttributeValue($value);
             }
         }
         if ($style) {
             $value = $item->get($style->getColName());
             if ($value) {
                 $styles[$itemId] = $this->getAttributeValue($value);
             }
         }
     }
 }
Beispiel #6
0
 /**
  * {@inheritdoc}
  */
 public function addAttribute(IAttribute $objAttribute)
 {
     if (!$this->hasAttribute($objAttribute->getColName())) {
         $this->arrAttributes[$objAttribute->getColName()] = $objAttribute;
     }
     return $this;
 }
Beispiel #7
0
 /**
  * Obtain the values of a property within a dc-general instance.
  *
  * @param IMetaModel           $metaModel   The metamodel instance to obtain the values from.
  *
  * @param EnvironmentInterface $environment The environment used in the input screen table dc-general.
  *
  * @param IAttribute           $attribute   The attribute to obtain the values for.
  *
  * @return array
  */
 private function getOptionsViaDcGeneral($metaModel, $environment, $attribute)
 {
     $factory = new DcGeneralFactory();
     $dcGeneral = $factory->setContainerName($metaModel->getTableName())->setEventDispatcher($environment->getEventDispatcher())->setTranslator($environment->getTranslator())->createDcGeneral();
     $subEnv = $dcGeneral->getEnvironment();
     $optEv = new GetPropertyOptionsEvent($subEnv, $subEnv->getDataProvider()->getEmptyModel());
     $optEv->setPropertyName($attribute->getColName());
     $subEnv->getEventDispatcher()->dispatch(GetPropertyOptionsEvent::NAME, $optEv);
     $options = $optEv->getOptions();
     return $options;
 }
 /**
  * Run the search for the complex attribute geolocation.
  *
  * @param Container  $container     The container with all information.
  *
  * @param IFilter    $filter        The filter container.
  *
  * @param IAttribute $latAttribute  The attribute to filter on.
  *
  * @param IAttribute $longAttribute The attribute to filter on.
  *
  * @return void
  */
 protected function doSearchForTwoSimpleAtt($container, $filter, $latAttribute, $longAttribute)
 {
     // Get location.
     $lat = $container->getLatitude();
     $lng = $container->getLongitude();
     $intDist = $container->getDistance();
     $distance = sprintf('round(sqrt(' . 'power(2 * pi() / 360 * (%1$s - %3$s) * 6371,2)' . '+ power(2 * pi() / 360 * (%2$s - %4$s) * 6371 * COS( 2 * pi() / 360 * (%1$s + %3$s) * 0.5), 2)' . '))', $lat, $lng, $latAttribute->getColName(), $longAttribute->getColName());
     $objResult = \Database::getInstance()->prepare(sprintf('SELECT id FROM %1$s WHERE %2$s<=? ORDER BY %2$s', $this->getMetaModel()->getTableName(), $distance))->execute($intDist);
     if ($objResult->numRows == 0) {
         $filter->addFilterRule(new StaticIdList(array()));
     } else {
         $filter->addFilterRule(new StaticIdList($objResult->fetchEach('id')));
     }
 }