Ejemplo n.º 1
0
 /**
  * Collect the attribute settings for the given render setting.
  *
  * @param IMetaModel  $metaModel     The MetaModel instance to retrieve the settings for.
  *
  * @param ICollection $renderSetting The render setting.
  *
  * @return void
  */
 public function collectAttributeSettings(IMetaModel $metaModel, $renderSetting)
 {
     $attributeRow = $this->serviceContainer->getDatabase()->prepare('SELECT * FROM tl_metamodel_rendersetting WHERE pid=? AND enabled=1 ORDER BY sorting')->execute($renderSetting->get('id'));
     while ($attributeRow->next()) {
         $attribute = $metaModel->getAttributeById($attributeRow->attr_id);
         if (!$attribute) {
             continue;
         }
         // TODO: we should provide attribute type based render setting elements in version 2.X.
         $attributeSetting = $renderSetting->getSetting($attribute->getColName());
         if (!$attributeSetting) {
             $attributeSetting = $attribute->getDefaultRenderSettings();
         }
         foreach ($attributeRow->row() as $strKey => $varValue) {
             if ($varValue) {
                 $attributeSetting->set($strKey, deserialize($varValue));
             }
         }
         $renderSetting->setSetting($attribute->getColName(), $attributeSetting);
     }
 }
Ejemplo n.º 2
0
Archivo: Item.php Proyecto: zonky2/core
 /**
  * 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;
 }