Beispiel #1
0
 /**
  * @param FieldType $fieldType
  * @return array
  */
 protected static function getFieldOptions(FieldType $fieldType)
 {
     $optionsValue = $fieldType->getOptions();
     $fields = self::getDocumentSelectFields($fieldType);
     $options = array();
     if (isset($fields[$optionsValue]['Options'])) {
         $options = $fields[$optionsValue]['Options'];
     }
     return static::normalizeOptions($options);
 }
 /**
  * @param FieldType $fieldType
  * @param string $callbackFunctionName
  * @param mixed $value
  * @return string
  */
 public static function renderControlOptions(FieldType $fieldType, $callbackFunctionName, $value)
 {
     if (is_array($value)) {
         reset($value);
         $valueTmp = (int) current($value);
     } else {
         $valueTmp = (int) $value;
     }
     $iblockId = 0;
     if ($valueTmp > 0) {
         $elementIterator = \CIBlockElement::getList(array(), array('ID' => $valueTmp), false, false, array('ID', 'IBLOCK_ID'));
         if ($element = $elementIterator->fetch()) {
             $iblockId = $element['IBLOCK_ID'];
         }
     }
     if ($iblockId <= 0 && (int) $fieldType->getOptions() > 0) {
         $iblockId = (int) $fieldType->getOptions();
     }
     $defaultIBlockId = 0;
     $result = '<select id="WFSFormOptionsX" onchange="' . htmlspecialcharsbx($callbackFunctionName) . '(this.options[this.selectedIndex].value)">';
     $iblockTypeIterator = \CIBlockParameters::getIBlockTypes();
     foreach ($iblockTypeIterator as $iblockTypeId => $iblockTypeName) {
         $result .= '<optgroup label="' . htmlspecialcharsbx($iblockTypeName) . '">';
         $iblockIterator = \CIBlock::getList(array('SORT' => 'ASC'), array('TYPE' => $iblockTypeId, 'ACTIVE' => 'Y'));
         while ($iblock = $iblockIterator->fetch()) {
             $result .= '<option value="' . $iblock['ID'] . '"' . ($iblock['ID'] == $iblockId ? ' selected' : '') . '>' . htmlspecialcharsbx($iblock['NAME']) . '</option>';
             if ($defaultIBlockId <= 0 || $iblock['ID'] == $iblockId) {
                 $defaultIBlockId = $iblock['ID'];
             }
         }
         $result .= '</optgroup>';
     }
     $result .= '</select><!--__defaultOptionsValue:' . $defaultIBlockId . '--><!--__modifyOptionsPromt:' . Loc::getMessage('UTP_ELIST_DOCUMENT_MOPROMT') . '-->';
     $fieldType->setOptions($defaultIBlockId);
     return $result;
 }
Beispiel #3
0
 /**
  * @param FieldType $fieldType
  * @return array
  */
 protected static function getFieldOptions(FieldType $fieldType)
 {
     $options = $fieldType->getOptions();
     return self::normalizeOptions($options);
 }