MetaModels\Attribute\BaseSimple::getFilterOptions PHP Метод

getFilterOptions() публичный Метод

{@inheritDoc}
public getFilterOptions ( $idList, $usedOnly, &$arrCount = null )
    public function getFilterOptions($idList, $usedOnly, &$arrCount = null)
    {
        $strCol = $this->getColName();
        if ($idList) {
            $objRow = $this->getMetaModel()->getServiceContainer()->getDatabase()->prepare('SELECT ' . $strCol . ', COUNT(' . $strCol . ') as mm_count
                    FROM ' . $this->getMetaModel()->getTableName() . ' WHERE id IN (' . $this->parameterMask($idList) . ')
                    GROUP BY ' . $strCol . '
                    ORDER BY FIELD(id,' . $this->parameterMask($idList) . ')')->execute(array_merge($idList, $idList));
        } elseif ($usedOnly) {
            $objRow = $this->getMetaModel()->getServiceContainer()->getDatabase()->execute('SELECT ' . $strCol . ', COUNT(' . $strCol . ') as mm_count
                FROM ' . $this->getMetaModel()->getTableName() . '
                GROUP BY ' . $strCol . '
                ORDER BY ' . $strCol);
        } else {
            // We can not do anything here, must be handled by the derived attribute class.
            return array();
        }
        $arrResult = array();
        while ($objRow->next()) {
            if (is_array($arrCount)) {
                $arrCount[$objRow->{$strCol}] = $objRow->mm_count;
            }
            $arrResult[$objRow->{$strCol}] = $objRow->{$strCol};
        }
        return $arrResult;
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public function getFilterOptions($idList, $usedOnly, &$arrCount = null)
 {
     if (!($idList || $usedOnly)) {
         return array('0' => $GLOBALS['TL_LANG']['MSC']['metamodelattribute_checkbox']['value_0'], '1' => $GLOBALS['TL_LANG']['MSC']['metamodelattribute_checkbox']['value_1']);
     }
     return parent::getFilterOptions($idList, $usedOnly, $arrCount);
 }
All Usage Examples Of MetaModels\Attribute\BaseSimple::getFilterOptions