本文整理汇总了PHP中opToolkit::arrayMapRecursive方法的典型用法代码示例。如果您正苦于以下问题:PHP opToolkit::arrayMapRecursive方法的具体用法?PHP opToolkit::arrayMapRecursive怎么用?PHP opToolkit::arrayMapRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opToolkit
的用法示例。
在下文中一共展示了opToolkit::arrayMapRecursive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateWidget
public static function generateWidget($field, $choices = array())
{
$field = self::arrayKeyCamelize($field);
$params = self::generateWidgetParams($field, $choices);
if (in_array($field['FormType'], self::$choicesType)) {
if ($field['FormType'] === 'select') {
if (!$field['IsRequired']) {
$params['choices'] = array('' => sfContext::getInstance()->getI18N()->__('Please Select')) + $params['choices'];
}
} else {
$params['expanded'] = true;
}
}
switch ($field['FormType']) {
case 'checkbox':
$params['multiple'] = true;
$obj = new sfWidgetFormChoice($params);
break;
case 'select':
$obj = new sfWidgetFormChoice($params);
break;
case 'radio':
$obj = new sfWidgetFormChoice($params);
break;
case 'textarea':
$obj = new sfWidgetFormTextarea($params);
break;
case 'rich_textarea':
$obj = new opWidgetFormRichTextarea($params);
break;
case 'password':
$obj = new sfWidgetFormInputPassword($params);
break;
case 'date':
unset($params['choices']);
$params['culture'] = sfContext::getInstance()->getUser()->getCulture();
$params['month_format'] = 'number';
if (!$field['IsRequired']) {
$params['can_be_empty'] = true;
}
$obj = new opWidgetFormDate($params);
break;
case 'increased_input':
$obj = new opWidgetFormInputIncreased($params);
break;
case 'language_select':
$languages = sfConfig::get('op_supported_languages');
$choices = opToolkit::getCultureChoices($languages);
$obj = new sfWidgetFormChoice(array('choices' => $choices));
break;
case 'country_select':
$info = sfCultureInfo::getInstance(sfContext::getInstance()->getUser()->getCulture());
$obj = new sfWidgetFormChoice(array('choices' => $info->getCountries()));
break;
case 'region_select':
$list = sfYaml::load(sfConfig::get('sf_lib_dir') . '/config/config/regions.yml');
$type = $field['ValueType'];
if ('string' !== $type && isset($list[$type])) {
$list = $list[$type];
$list = array_combine($list, $list);
} else {
foreach ($list as $k => $v) {
if ($v) {
$list[$k] = array_combine($v, $v);
}
}
}
$list = opToolkit::arrayMapRecursive(array(sfContext::getInstance()->getI18N(), '__'), $list);
$obj = new sfWidgetFormChoice(array('choices' => $list));
break;
default:
$obj = new sfWidgetFormInput($params);
}
return $obj;
}
示例2: generateSearchWidget
public static function generateSearchWidget($field, $choices = array())
{
$field = self::arrayKeyCamelize($field);
$params = self::generateWidgetParams($field, $choices);
switch ($field['FormType']) {
// selection
case 'checkbox':
case 'select':
case 'radio':
$obj = new sfWidgetFormChoice($params);
break;
// doesn't allow searching
// doesn't allow searching
case 'increased_input':
case 'language_select':
case 'password':
$obj = null;
break;
// country
// country
case 'country_select':
$info = sfCultureInfo::getInstance(sfContext::getInstance()->getUser()->getCulture());
$params['choices'] = array('' => '') + $info->getCountries();
$obj = new sfWidgetFormChoice($params);
break;
// region
// region
case 'region_select':
$list = (array) (include sfContext::getInstance()->getConfigCache()->checkConfig('config/regions.yml'));
$type = $field['ValueType'];
if ('string' !== $type && isset($list[$type])) {
$list = $list[$type];
$list = array_combine($list, $list);
} else {
foreach ($list as $k => $v) {
if ($v) {
$list[$k] = array_combine($v, $v);
}
}
}
$list = opToolkit::arrayMapRecursive(array(sfContext::getInstance()->getI18N(), '__'), $list);
$params['choices'] = array('' => '') + $list;
$obj = new sfWidgetFormChoice($params);
break;
// date
// date
case 'date':
unset($params['choices']);
$params['culture'] = sfContext::getInstance()->getUser()->getCulture();
$params['month_format'] = 'number';
$params['can_be_empty'] = true;
$obj = new opWidgetFormDate($params);
break;
// text and something else
// text and something else
default:
$obj = new sfWidgetFormInput($params);
}
return $obj;
}