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


PHP SFUtils::labelToValue方法代码示例

本文整理汇总了PHP中SFUtils::labelToValue方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::labelToValue方法的具体用法?PHP SFUtils::labelToValue怎么用?PHP SFUtils::labelToValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SFUtils的用法示例。


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

示例1: formHTML


//.........这里部分代码省略.........
                        $delimiter = ",";
                    }
                    // Get the value from the request, if
                    // it's there, and if it's not an array.
                    $cur_value = null;
                    $escaped_field_name = str_replace("'", "\\'", $field_name);
                    if (isset($template_instance_query_values) && $template_instance_query_values != null && is_array($template_instance_query_values)) {
                        // If the field name contains an
                        // apostrophe, the array sometimes
                        // has the apostrophe escaped, and
                        // sometimes not. For now, just check
                        // for both versions.
                        // @TODO - figure this out.
                        $field_query_val = null;
                        if (array_key_exists($escaped_field_name, $template_instance_query_values)) {
                            $field_query_val = $template_instance_query_values[$escaped_field_name];
                        } elseif (array_key_exists($field_name, $template_instance_query_values)) {
                            $field_query_val = $template_instance_query_values[$field_name];
                        }
                        if ($form_submitted && $field_query_val != '') {
                            $mapping_template = null;
                            if (array_key_exists('mapping_template', $template_instance_query_values) && array_key_exists($field_name, $template_instance_query_values['mapping_template'])) {
                                $mapping_template = $template_instance_query_values['mapping_template'][$field_name];
                            }
                            if (is_array($field_query_val)) {
                                $cur_values = array();
                                foreach ($field_query_val as $key => $value) {
                                    if (!is_null($mapping_template) && !is_null($possible_values)) {
                                        $cur_values = array();
                                        foreach ($field_query_val as $key => $val) {
                                            if ($key === 'is_list') {
                                                $cur_values[$key] = $val;
                                            } else {
                                                $cur_values[] = SFUtils::labelToValue($val, $possible_values, $mapping_template);
                                            }
                                        }
                                    } else {
                                        $cur_values[$key] = $value;
                                    }
                                }
                                $cur_value = $this->getStringFromPassedInArray($cur_values, $delimiter);
                            } else {
                                if (!is_null($mapping_template) && !is_null($possible_values)) {
                                    $cur_value = SFUtils::labelToValue($field_query_val, $possible_values, $mapping_template);
                                } else {
                                    $cur_value = $field_query_val;
                                }
                            }
                        }
                        if (!$form_submitted && $field_query_val != '') {
                            if (is_array($field_query_val)) {
                                $cur_value = $this->getStringFromPassedInArray($field_query_val, $delimiter);
                            } else {
                                $cur_value = $field_query_val;
                            }
                        }
                    }
                    if (empty($cur_value) && !$form_submitted) {
                        if (!is_null($default_value)) {
                            // Set to the default value specified in the form, if it's there.
                            $cur_value = $default_value;
                        } elseif ($preload_page) {
                            $cur_value = SFFormUtils::getPreloadedText($preload_page);
                        }
                    }
                    // If the user is editing a page, and that page contains a call to
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:67,代码来源:SF_FormPrinter.php

示例2: getCurrentValue

 function getCurrentValue($template_instance_query_values, $form_submitted, $source_is_page)
 {
     // Get the value from the request, if
     // it's there, and if it's not an array.
     $cur_value = null;
     $field_name = $this->template_field->getFieldName();
     $delimiter = $this->mFieldArgs['delimiter'];
     $escaped_field_name = str_replace("'", "\\'", $field_name);
     if (isset($template_instance_query_values) && $template_instance_query_values != null && is_array($template_instance_query_values)) {
         // If the field name contains an apostrophe, the array
         // sometimes has the apostrophe escaped, and sometimes
         // not. For now, just check for both versions.
         // @TODO - figure this out.
         $field_query_val = null;
         if (array_key_exists($escaped_field_name, $template_instance_query_values)) {
             $field_query_val = $template_instance_query_values[$escaped_field_name];
         } elseif (array_key_exists($field_name, $template_instance_query_values)) {
             $field_query_val = $template_instance_query_values[$field_name];
         }
         if ($form_submitted && $field_query_val != '') {
             $map_field = false;
             if (array_key_exists('map_field', $template_instance_query_values) && array_key_exists($field_name, $template_instance_query_values['map_field'])) {
                 $map_field = true;
             }
             if (is_array($field_query_val)) {
                 $cur_values = array();
                 if ($map_field && !is_null($this->mPossibleValues)) {
                     $cur_values = array();
                     foreach ($field_query_val as $key => $val) {
                         $val = trim($val);
                         if ($key === 'is_list') {
                             $cur_values[$key] = $val;
                         } else {
                             $cur_values[] = SFUtils::labelToValue($val, $this->mPossibleValues);
                         }
                     }
                 } else {
                     foreach ($field_query_val as $key => $val) {
                         $cur_values[$key] = $val;
                     }
                 }
                 return SFFormPrinter::getStringFromPassedInArray($cur_values, $delimiter);
             } else {
                 $field_query_val = trim($field_query_val);
                 if ($map_field && !is_null($this->mPossibleValues)) {
                     // this should be replaced with an input type neutral way of
                     // figuring out if this scalar input type is a list
                     if ($this->mInputType == "tokens") {
                         $is_list = true;
                     }
                     if ($is_list) {
                         $cur_values = array_map('trim', explode($delimiter, $field_query_val));
                         foreach ($cur_values as $key => $value) {
                             $cur_values[$key] = SFUtils::labelToValue($value, $this->mPossibleValues);
                         }
                         return implode($delimiter, $cur_values);
                     }
                     return SFUtils::labelToValue($field_query_val, $this->mPossibleValues);
                 }
                 return $field_query_val;
             }
         }
         if (!$form_submitted && $field_query_val != '') {
             if (is_array($field_query_val)) {
                 return SFFormPrinter::getStringFromPassedInArray($field_query_val, $delimiter);
             }
             return $field_query_val;
         }
     }
     if (!$source_is_page && empty($cur_value) && !$form_submitted) {
         if (!is_null($this->mDefaultValue)) {
             // Set to the default value specified in the form, if it's there.
             return $this->mDefaultValue;
         } elseif ($this->mPreloadPage) {
             return SFFormUtils::getPreloadedText($this->mPreloadPage);
         }
     }
     return $cur_value;
     // null
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:80,代码来源:SF_FormField.php


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