当前位置: 首页>>代码示例>>PHP>>正文


PHP array_is_assoc函数代码示例

本文整理汇总了PHP中array_is_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP array_is_assoc函数的具体用法?PHP array_is_assoc怎么用?PHP array_is_assoc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_is_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValidOption

 /**
  * check if options are available and find current value in list
  * if not found: do not set the value, otherwise potential sql injection vulnerability
  * TODO: try to check against options_callbacks as well!!!
  *
  * @param $varValue
  * @param $arrData
  *
  * @return bool
  */
 public static function isValidOption($varValue, &$arrData, $objDc = null)
 {
     $arrOptions = FormHelper::getFieldOptions($arrData, $objDc);
     if (empty($arrOptions)) {
         $arrOptions = array(0, 1);
     }
     $blnIsAssociative = $arrData['eval']['isAssociative'] || array_is_assoc($arrOptions);
     $intFounds = 0;
     foreach ($arrOptions as $k => $v) {
         if (!is_array($v)) {
             $checkValue = $blnIsAssociative ? $k : $v;
             if (is_array($varValue)) {
                 if (in_array(urldecode($checkValue), array_map('urldecode', $varValue))) {
                     $intFounds++;
                 }
             } elseif (urldecode($checkValue) == urldecode($varValue)) {
                 $intFounds++;
                 break;
             }
             continue;
         }
         $blnIsAssoc = array_is_assoc($v);
         foreach ($v as $kk => $vv) {
             $checkValue = $blnIsAssoc ? $kk : $vv;
             if (urldecode($checkValue) == urldecode($varValue)) {
                 $intFounds++;
                 break;
             }
         }
     }
     if (is_array($varValue) && $intFounds < count($varValue) || !is_array($varValue) && $intFounds < 1) {
         return false;
     }
     return true;
 }
开发者ID:heimrichhannot,项目名称:contao-formhybrid,代码行数:45,代码来源:Validator.php

示例2: arrayAssocTest

 /**
  * @test
  */
 public function arrayAssocTest()
 {
     $array = \range(0, 10);
     $true = !\array_is_assoc($array);
     unset($array[3]);
     $true = $true && \array_is_assoc($array);
     $true = $true && \array_is_assoc($GLOBALS);
     $this->assertTrue($true);
 }
开发者ID:rafsalvioni,项目名称:zeus-base,代码行数:12,代码来源:ArrayTest.php

示例3: testArrayIsAssoc

 /**
  * Test if an array is associative
  */
 public function testArrayIsAssoc()
 {
     $array1 = ['foo' => 'bar', 'faa' => 'bor'];
     $array2 = [0 => 'bar', 1 => 'bor'];
     $array3 = ['foo' => 'bar', 999 => 'bor'];
     $this->assertEquals(array_is_assoc($array1), true);
     $this->assertEquals(array_is_assoc($array2), false);
     $this->assertEquals(array_is_assoc($array3), true);
 }
开发者ID:aurelienlhx,项目名称:PhpComponents,代码行数:12,代码来源:ArrayHelpersTest.php

示例4: BenchmarkXarrayAssoc

function BenchmarkXarrayAssoc(Benchmark $b)
{
    $index = makeAssocArray(ARRSIZE);
    $assoc = makeAssocArray(ARRSIZE);
    $mixed = makeMixedArray(HALFSIZE);
    $b->resetTimer();
    for ($i = 0; $i < $b->N(); $i++) {
        array_is_assoc($index);
        array_is_assoc($assoc);
        array_is_assoc($mixed);
    }
}
开发者ID:Ronmi,项目名称:xarray-benchmark,代码行数:12,代码来源:bench.php

示例5: __set

 /**
  * Set an object property
  *
  * @param string $strKey   The property name
  * @param mixed  $varValue The property value
  */
 public function __set($strKey, $varValue)
 {
     switch ($strKey) {
         case 'metaFields':
             if (!array_is_assoc($varValue)) {
                 $varValue = array_combine($varValue, array_fill(0, count($varValue), ''));
             }
             $this->arrConfiguration['metaFields'] = $varValue;
             break;
         default:
             parent::__set($strKey, $varValue);
             break;
     }
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:20,代码来源:MetaWizard.php

示例6: format

 /**
  * {@inheritDoc}
  */
 public function format($value, $fieldName, array $fieldDefinition, $context = null)
 {
     if (!empty($fieldDefinition['eval']['isAssociative']) || !empty($fieldDefinition['options']) && array_is_assoc($fieldDefinition['options'])) {
         if (!empty($fieldDefinition['options'][$value])) {
             $value = $fieldDefinition['options'][$value];
         }
     } elseif (!empty($fieldDefinition['options_callback'])) {
         if ($context instanceof DataContainer) {
             $options = $this->invoker->invoke($fieldDefinition['options_callback'], [$context]);
         } else {
             $options = $this->invoker->invoke($fieldDefinition['options_callback']);
         }
         if (!empty($options[$value])) {
             $value = $options[$value];
         }
     }
     return $value;
 }
开发者ID:netzmacht,项目名称:contao-toolkit,代码行数:21,代码来源:OptionsFormatter.php

示例7: withFilter

 /**
  * Apply row data filters.
  *
  * @param  array $filters
  * @return $this
  */
 public function withFilter($filters)
 {
     if (!count($filters)) {
         return $this;
     }
     if (!array_is_assoc($filters)) {
         throw new \Exception('Invalid $filters structure.');
     }
     foreach ($this->gridQuery->getModelGridQueries() as $mgq) {
         $filterKey = $mgq->whereInFilterKey();
         if (!empty($filters[$filterKey])) {
             $filterValues = is_array($filters[$filterKey]) ? $filters[$filterKey] : [$filters[$filterKey]];
             $mgq->applyWhereInFilter($this->query, $filterValues);
             return $this;
         }
     }
     return $this;
 }
开发者ID:sedp-mis,项目名称:base-report,代码行数:24,代码来源:ReportQueryBuilder.php

示例8: recursiveApplyTransformationToArray

 private function recursiveApplyTransformationToArray(array $input, Transformation $transformation)
 {
     $result = [];
     $attributes = isset($input['@attributes']) ? $input['@attributes'] : [];
     // Strip out the attributes.
     unset($input['@attributes']);
     // Run the input against the transformation test. If it passes, run
     // the actual transformation
     if ($transformation->test($input, $attributes) === true) {
         $input = $transformation->action($input, $attributes);
     }
     // Are we dealing with an associative array, or a sequential indexed array
     $isAssoc = array_is_assoc($input);
     // Iterate over each element in the array and decide if we need to move deeper
     foreach ($input as $key => $value) {
         $next = is_array($value) ? $this->recursiveApplyTransformationToArray($value, $transformation) : $value;
         // Preserve array indexes
         $isAssoc ? $result[$key] = $next : array_push($result, $value);
     }
     return $result;
 }
开发者ID:pointybeard,项目名称:api_framework,代码行数:21,代码来源:Transformer.php

示例9: addFormField

 /**
  * Adds a form field
  *
  * @param string        $strName the form field name
  * @param array         $arrDca The DCA representation of the field
  * @param ArrayPosition $position
  *
  * @return $this
  */
 public function addFormField($strName, array $arrDca, ArrayPosition $position = null)
 {
     $this->checkFormFieldNameIsValid($strName);
     if (null === $position) {
         $position = ArrayPosition::last();
     }
     // Make sure it has a "name" attribute because it is mandatory
     if (!isset($arrDca['name'])) {
         $arrDca['name'] = $strName;
     }
     // Support default values
     if (!$this->isSubmitted()) {
         if (isset($arrDca['default']) && !isset($arrDca['value'])) {
             $arrDca['value'] = $arrDca['default'];
         }
         // Try to load the default value from bound Model
         if (!$arrDca['ignoreModelValue'] && $this->objModel !== null) {
             $arrDca['value'] = $this->objModel->{$strName};
         }
     }
     if (!isset($arrDca['inputType'])) {
         throw new \RuntimeException(sprintf('You did not specify any inputType for the field "%s"!', $strName));
     }
     /** @type \Widget $strClass */
     $strClass = $GLOBALS['TL_FFL'][$arrDca['inputType']];
     if (!class_exists($strClass)) {
         throw new \RuntimeException(sprintf('The class "%s" for type "%s" could not be found.', $strClass, $arrDca['inputType']));
     }
     // Convert date formats into timestamps
     $rgxp = $arrDca['eval']['rgxp'];
     if (in_array($rgxp, array('date', 'time', 'datim'))) {
         $this->addValidator($strName, function ($varValue) use($rgxp) {
             if ($varValue != '') {
                 $key = $rgxp . 'Format';
                 $format = isset($GLOBALS['objPage']) ? $GLOBALS['objPage']->{$key} : $GLOBALS['TL_CONFIG'][$key];
                 $objDate = new \Date($varValue, $format);
                 $varValue = $objDate->tstamp;
             }
             return $varValue;
         });
     }
     if (is_array($arrDca['save_callback'])) {
         $this->addValidator($strName, function ($varValue, \Widget $objWidget, Form $objForm) use($arrDca, $strName) {
             $intId = 0;
             $strTable = '';
             if (($objModel = $objForm->getBoundModel()) !== null) {
                 $intId = $objModel->id;
                 $strTable = $objModel->getTable();
             }
             $dc = (object) array('id' => $intId, 'table' => $strTable, 'value' => $varValue, 'field' => $strName, 'inputName' => $objWidget->name, 'activeRecord' => $objModel);
             foreach ($arrDca['save_callback'] as $callback) {
                 if (is_array($callback)) {
                     $objCallback = \System::importStatic($callback[0]);
                     $varValue = $objCallback->{$callback[1]}($varValue, $dc);
                 } elseif (is_callable($callback)) {
                     $varValue = $callback($varValue, $dc);
                 }
             }
             return $varValue;
         });
     }
     $arrDca = $strClass::getAttributesFromDca($arrDca, $arrDca['name'], $arrDca['value']);
     // Convert optgroups so they work with FormSelectMenu
     if (is_array($arrDca['options']) && array_is_assoc($arrDca['options'])) {
         $arrOptions = $arrDca['options'];
         $arrDca['options'] = array();
         foreach ($arrOptions as $k => $v) {
             if (isset($v['label'])) {
                 $arrDca['options'][] = $v;
             } else {
                 $arrDca['options'][] = array('label' => $k, 'value' => $k, 'group' => '1');
                 foreach ($v as $vv) {
                     $arrDca['options'][] = $vv;
                 }
             }
         }
     }
     $this->arrFormFields = $position->addToArray($this->arrFormFields, array($strName => $arrDca));
     $this->intState = self::STATE_DIRTY;
     return $this;
 }
开发者ID:codefog,项目名称:contao-haste,代码行数:90,代码来源:Form.php

示例10: getListViewLabelArguments

 /**
  * Get arguments for label
  *
  * @param InterfaceGeneralModel $objModelRow
  * @return array
  */
 protected function getListViewLabelArguments($objModelRow)
 {
     if ($this->getDC()->arrDCA['list']['sorting']['mode'] == 6) {
         $this->loadDataContainer($objDC->getParentTable());
         $objTmpDC = new DC_General($objDC->getParentTable());
         $arrCurrentDCA = $objTmpDC->getDCA();
     } else {
         $arrCurrentDCA = $this->getDC()->arrDCA;
     }
     $args = array();
     $showFields = $arrCurrentDCA['list']['label']['fields'];
     // Label
     foreach ($showFields as $k => $v) {
         if (strpos($v, ':') !== false) {
             $args[$k] = $objModelRow->getMeta(DCGE::MODEL_LABEL_ARGS);
         } elseif (in_array($this->getDC()->arrDCA['fields'][$v]['flag'], array(5, 6, 7, 8, 9, 10))) {
             if ($this->getDC()->arrDCA['fields'][$v]['eval']['rgxp'] == 'date') {
                 $args[$k] = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objModelRow->getProperty($v));
             } elseif ($this->getDC()->arrDCA['fields'][$v]['eval']['rgxp'] == 'time') {
                 $args[$k] = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $objModelRow->getProperty($v));
             } else {
                 $args[$k] = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $objModelRow->getProperty($v));
             }
         } elseif ($this->getDC()->arrDCA['fields'][$v]['inputType'] == 'checkbox' && !$this->getDC()->arrDCA['fields'][$v]['eval']['multiple']) {
             $args[$k] = strlen($objModelRow->getProperty($v)) ? $arrCurrentDCA['fields'][$v]['label'][0] : '';
         } else {
             $row = deserialize($objModelRow->getProperty($v));
             if (is_array($row)) {
                 $args_k = array();
                 foreach ($row as $option) {
                     $args_k[] = strlen($arrCurrentDCA['fields'][$v]['reference'][$option]) ? $arrCurrentDCA['fields'][$v]['reference'][$option] : $option;
                 }
                 $args[$k] = implode(', ', $args_k);
             } elseif (isset($arrCurrentDCA['fields'][$v]['reference'][$objModelRow->getProperty($v)])) {
                 $args[$k] = is_array($arrCurrentDCA['fields'][$v]['reference'][$objModelRow->getProperty($v)]) ? $arrCurrentDCA['fields'][$v]['reference'][$objModelRow->getProperty($v)][0] : $arrCurrentDCA['fields'][$v]['reference'][$objModelRow->getProperty($v)];
             } elseif (($arrCurrentDCA['fields'][$v]['eval']['isAssociative'] || array_is_assoc($arrCurrentDCA['fields'][$v]['options'])) && isset($arrCurrentDCA['fields'][$v]['options'][$objModelRow->getProperty($v)])) {
                 $args[$k] = $arrCurrentDCA['fields'][$v]['options'][$objModelRow->getProperty($v)];
             } else {
                 $args[$k] = $objModelRow->getProperty($v);
             }
         }
     }
     return $args;
 }
开发者ID:metamodels,项目名称:dc_general,代码行数:50,代码来源:GeneralViewDefault.php

示例11: addRelationFilters

    /**
     * Add the relation filters
     * @param \DataContainer $dc in BE
     * @return string
     */
    public function addRelationFilters($dc)
    {
        if (empty(static::$arrFilterableFields)) {
            return '';
        }
        $filter = $GLOBALS['TL_DCA'][$dc->table]['list']['sorting']['mode'] == 4 ? $dc->table . '_' . CURRENT_ID : $dc->table;
        $session = \Session::getInstance()->getData();
        // Set filter from user input
        if (\Input::post('FORM_SUBMIT') == 'tl_filters') {
            foreach (array_keys(static::$arrFilterableFields) as $field) {
                if (\Input::post($field, true) != 'tl_' . $field) {
                    $session['filter'][$filter][$field] = \Input::post($field, true);
                } else {
                    unset($session['filter'][$filter][$field]);
                }
            }
            \Session::getInstance()->setData($session);
        }
        $count = 0;
        $return = '<div class="tl_filter tl_subpanel">
<strong>' . $GLOBALS['TL_LANG']['HST']['advanced_filter'] . '</strong> ';
        foreach (static::$arrFilterableFields as $field => $arrRelation) {
            $return .= '<select name="' . $field . '" class="tl_select' . (isset($session['filter'][$filter][$field]) ? ' active' : '') . '">
    <option value="tl_' . $field . '">' . $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['label'][0] . '</option>
    <option value="tl_' . $field . '">---</option>';
            $arrIds = Model::getRelatedValues($arrRelation['reference_table'], $field);
            if (empty($arrIds)) {
                $return .= '</select> ';
                // Add the line-break after 5 elements
                if (++$count % 5 == 0) {
                    $return .= '<br>';
                }
                continue;
            }
            $options = array_unique($arrIds);
            $options_callback = array();
            // Store the field name to be used e.g. in the options_callback
            $this->field = $field;
            // Call the options_callback
            if ((is_array($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options_callback']) || is_callable($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options_callback'])) && !$GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['reference']) {
                if (is_array($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options_callback'])) {
                    $strClass = $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options_callback'][0];
                    $strMethod = $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options_callback'][1];
                    $objClass = \System::importStatic($strClass);
                    $options_callback = $objClass->{$strMethod}($this);
                } elseif (is_callable($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options_callback'])) {
                    $options_callback = $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options_callback']($this);
                }
                // Sort options according to the keys of the callback array
                $options = array_intersect(array_keys($options_callback), $options);
            }
            $options_sorter = array();
            // Options
            foreach ($options as $kk => $vv) {
                $value = $vv;
                // Options callback
                if (!empty($options_callback) && is_array($options_callback)) {
                    $vv = $options_callback[$vv];
                } elseif (isset($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['foreignKey'])) {
                    // Replace the ID with the foreign key
                    $key = explode('.', $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['foreignKey'], 2);
                    $objParent = \Database::getInstance()->prepare("SELECT " . $key[1] . " AS value FROM " . $key[0] . " WHERE id=?")->limit(1)->execute($vv);
                    if ($objParent->numRows) {
                        $vv = $objParent->value;
                    }
                }
                $option_label = '';
                // Use reference array
                if (isset($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['reference'])) {
                    $option_label = is_array($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['reference'][$vv]) ? $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['reference'][$vv][0] : $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['reference'][$vv];
                } elseif ($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options'])) {
                    // Associative array
                    $option_label = $GLOBALS['TL_DCA'][$dc->table]['fields'][$field]['options'][$vv];
                }
                // No empty options allowed
                if (!strlen($option_label)) {
                    $option_label = $vv ?: '-';
                }
                $options_sorter['  <option value="' . specialchars($value) . '"' . (isset($session['filter'][$filter][$field]) && $value == $session['filter'][$filter][$field] ? ' selected="selected"' : '') . '>' . $option_label . '</option>'] = utf8_romanize($option_label);
            }
            $return .= "\n" . implode("\n", array_keys($options_sorter));
            $return .= '</select> ';
            // Add the line-break after 5 elements
            if (++$count % 5 == 0) {
                $return .= '<br>';
            }
        }
        return $return . '</div>';
    }
开发者ID:codefog,项目名称:contao-haste,代码行数:94,代码来源:Relations.php

示例12: generate

 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $varValue = $objProduct->{$this->field_name};
     // Generate a HTML table for associative arrays
     if (is_array($varValue) && !array_is_assoc($varValue) && is_array($varValue[0])) {
         $strBuffer = $this->generateTable($varValue, $objProduct);
     } elseif (is_array($varValue)) {
         $strBuffer = $this->generateList($varValue);
     } else {
         $strBuffer = Format::dcaValue('tl_iso_product', $this->field_name, $varValue);
     }
     return $strBuffer;
 }
开发者ID:Aziz-JH,项目名称:core,代码行数:13,代码来源:Attribute.php

示例13: buildLanguageVariableKeysFrom

 /**
  * Build language variable keys.
  *
  * @param string $translation The translation key.
  * @param string $path        The translation path.
  * @param string $language    The language.
  *
  * @return void
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 protected function buildLanguageVariableKeysFrom($translation, $path, $language)
 {
     if (!isset($GLOBALS['TL_TRANSLATION'][$translation][$path])) {
         if (!is_array($language)) {
             $this->languageVariableKeys[$translation][$path] = array('type' => 'text');
         } elseif (array_is_assoc($language) || count($language) > 2) {
             foreach ($language as $k => $v) {
                 $this->buildLanguageVariableKeysFrom($translation, $path . '|' . $k, $v);
             }
         } else {
             $this->languageVariableKeys[$translation][$path] = array('type' => 'inputField');
         }
     }
 }
开发者ID:netzmacht,项目名称:contao-language-editor,代码行数:24,代码来源:LanguageVariableSearch.php

示例14: renderReadablePropertyValue

 /**
  * Render a property value to readable text.
  *
  * @param RenderReadablePropertyValueEvent $event The event being processed.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public static function renderReadablePropertyValue(RenderReadablePropertyValueEvent $event)
 {
     if ($event->getRendered() !== null) {
         return;
     }
     $dispatcher = $event->getEnvironment()->getEventDispatcher();
     $property = $event->getProperty();
     $value = self::decodeValue($event->getEnvironment(), $event->getModel(), $event->getProperty()->getName(), $event->getValue());
     $extra = $property->getExtra();
     // TODO: refactor - foreign key handling is not yet supported.
     /*
             if (isset($arrFieldConfig['foreignKey']))
             {
        $temp = array();
        $chunks = explode('.', $arrFieldConfig['foreignKey'], 2);
     
     
        foreach ((array) $value as $v)
        {
     //                    $objKey = $this->Database->prepare("SELECT " . $chunks[1] . " AS value FROM " . $chunks[0] . " WHERE id=?")
     //                            ->limit(1)
     //                            ->execute($v);
     //
     //                    if ($objKey->numRows)
     //                    {
     //                        $temp[] = $objKey->value;
     //                    }
        }
     
     //                $row[$i] = implode(', ', $temp);
             }
             // Decode array
             else
     */
     if (is_array($value)) {
         foreach ($value as $kk => $vv) {
             if (is_array($vv)) {
                 $vals = array_values($vv);
                 $value[$kk] = $vals[0] . ' (' . $vals[1] . ')';
             }
         }
         $event->setRendered(implode(', ', $value));
     } elseif (isset($extra['rgxp'])) {
         // Date format.
         if ($extra['rgxp'] == 'date' || $extra['rgxp'] == 'time' || $extra['rgxp'] == 'datim') {
             $event->setRendered(self::parseDateTime($dispatcher, $GLOBALS['TL_CONFIG'][$extra['rgxp'] . 'Format'], $value));
         }
     } elseif ($property->getName() == 'tstamp') {
         // Date and time format.
         $dateEvent = new ParseDateEvent($value, $GLOBALS['TL_CONFIG']['timeFormat']);
         $dispatcher->dispatch(ContaoEvents::DATE_PARSE, $dateEvent);
         $event->setRendered($dateEvent->getResult());
     } elseif ($property->getWidgetType() == 'checkbox' && !$extra['multiple']) {
         $event->setRendered(strlen($value) ? $GLOBALS['TL_LANG']['MSC']['yes'] : $GLOBALS['TL_LANG']['MSC']['no']);
     } elseif ($property->getWidgetType() == 'textarea' && (!empty($extra['allowHtml']) || !empty($extra['preserveTags']))) {
         $event->setRendered(nl2br_html5(specialchars($value)));
     } elseif (isset($extra['reference']) && is_array($extra['reference'])) {
         if (isset($extra['reference'][$value])) {
             $event->setRendered(is_array($extra['reference'][$value]) ? $extra['reference'][$value][0] : $extra['reference'][$value]);
         }
     } elseif ($value instanceof \DateTime) {
         $dateEvent = new ParseDateEvent($value->getTimestamp(), $GLOBALS['TL_CONFIG']['datimFormat']);
         $dispatcher->dispatch(ContaoEvents::DATE_PARSE, $dateEvent);
         $event->setRendered($dateEvent->getResult());
     } else {
         $options = $property->getOptions();
         if (!$options) {
             $options = self::getOptions($event->getEnvironment(), $event->getModel(), $event->getProperty());
             if ($options) {
                 $property->setOptions($options);
             }
         }
         if (array_is_assoc($options)) {
             $event->setRendered($options[$value]);
         }
     }
 }
开发者ID:davidmaack,项目名称:dc-general,代码行数:87,代码来源:Subscriber.php

示例15: formatGroupHeader

 /**
  * Return the formatted group header as string
  *
  * @param string  $field
  * @param mixed   $value
  * @param integer $mode
  * @param array   $row
  *
  * @return string
  */
 protected function formatGroupHeader($field, $value, $mode, $row)
 {
     static $lookup = array();
     if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options'])) {
         $group = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options'][$value];
     } elseif (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'])) {
         if (!isset($lookup[$field])) {
             $strClass = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'][0];
             $strMethod = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['options_callback'][1];
             $this->import($strClass);
             $lookup[$field] = $this->{$strClass}->{$strMethod}($this);
         }
         $group = $lookup[$field][$value];
     } else {
         $group = is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference'][$value]) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference'][$value][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['reference'][$value];
     }
     if (empty($group)) {
         $group = is_array($GLOBALS['TL_LANG'][$this->strTable][$value]) ? $GLOBALS['TL_LANG'][$this->strTable][$value][0] : $GLOBALS['TL_LANG'][$this->strTable][$value];
     }
     if (empty($group)) {
         $group = $value;
         if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['isBoolean'] && $value != '-') {
             $group = is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['label']) ? $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['label'][0] : $GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['label'];
         }
     }
     // Call the group callback ($group, $sortingMode, $firstOrderBy, $row, $this)
     if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['group_callback'])) {
         $strClass = $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['group_callback'][0];
         $strMethod = $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['group_callback'][1];
         $this->import($strClass);
         $group = $this->{$strClass}->{$strMethod}($group, $mode, $field, $row, $this);
     } elseif (is_callable($GLOBALS['TL_DCA'][$this->strTable]['list']['label']['group_callback'])) {
         $group = $GLOBALS['TL_DCA'][$this->strTable]['list']['label']['group_callback']($group, $mode, $field, $row, $this);
     }
     return $group;
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:46,代码来源:DC_Table.php


注:本文中的array_is_assoc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。