本文整理汇总了PHP中wpshop_tools::defineFieldType方法的典型用法代码示例。如果您正苦于以下问题:PHP wpshop_tools::defineFieldType方法的具体用法?PHP wpshop_tools::defineFieldType怎么用?PHP wpshop_tools::defineFieldType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpshop_tools
的用法示例。
在下文中一共展示了wpshop_tools::defineFieldType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_attribute_field_definition
/**
* Build the output for an attribute field
*
* @param object $attribute The complete definition for an attribute
* @param string $attribute_value Optionnal The current value for the attribute
* @param array $specific_argument Optionnal The different parameters used for filter output
* @return array The definition for the field used to display an attribute
*/
public static function get_attribute_field_definition($attribute, $attribute_value = '', $specific_argument = array())
{
global $wpdb;
$wpshop_price_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES);
$wpshop_weight_attributes = unserialize(WPSHOP_ATTRIBUTE_WEIGHT);
$input_def = array();
$input_def['option'] = $input_def['field_container_class'] = '';
$attributeInputDomain = !empty($specific_argument['field_custom_name_prefix']) || !empty($specific_argument['field_custom_name_prefix']) && $specific_argument['field_custom_name_prefix'] == 'empty' ? $specific_argument['field_custom_name_prefix'] : (!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '') . 'attribute[' . $attribute->data_type . ']';
$input_def['input_domain'] = $attributeInputDomain;
$input_def['id'] = (!empty($specific_argument) && !empty($specific_argument['field_id']) ? $specific_argument['field_id'] . '_' : '') . 'attribute_' . $attribute->id;
$input_def['intrinsec'] = $attribute->is_intrinsic;
$input_def['name'] = $attribute->code;
$input_def['type'] = wpshop_tools::defineFieldType($attribute->data_type, $attribute->frontend_input, $attribute->frontend_verification);
$input_def['label'] = $attribute->frontend_label;
$attribute_default_value = stripslashes($attribute->default_value);
$input_def['value'] = $attribute_default_value;
$input_def['default_value'] = $attribute_default_value;
$input_def['is_unique'] = $attribute->is_unique;
$input_def['_need_verification'] = $attribute->_need_verification;
$input_def['required'] = $attribute->is_required;
$input_def['frontend_verification'] = $attribute->frontend_verification;
$input_def['data_type'] = $attribute->data_type;
$input_def['data_type_to_use'] = $attribute->data_type_to_use;
$input_def['backend_type'] = $attribute->backend_input;
$input_def['frontend_type'] = $attribute->frontend_input;
$input_def['is_used_in_quick_add_form'] = $attribute->is_used_in_quick_add_form;
if (!empty($attribute_value) && !is_object($attribute_value)) {
$input_def['value'] = $attribute_value;
} else {
if (!empty($attribute_value->value)) {
$input_def['value'] = stripslashes($attribute_value->value);
} else {
if (!empty($specific_argument['element_identifier']) && empty($attribute_value) && get_post_status($specific_argument['element_identifier']) != 'auto-draft') {
$input_def['value'] = '';
}
}
}
$input_def['options'] = '';
$input_more_class = !empty($specific_argument['input_class']) ? $specific_argument['input_class'] : '';
if ($attribute->data_type == 'datetime') {
$date_config = unserialize($attribute->default_value);
if (($date_config['default_value'] == '' || $date_config['default_value'] == 'date_of_current_day') && $date_config['default_value'] == 'date_of_current_day') {
$input_def['value'] = date('Y-m-d');
} else {
/** Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/ */
$input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace(" 00:00:00", "", $attribute_value->value) : (!empty($attribute_value) && is_string($attribute_value) ? str_replace(" 00:00:00", "", $attribute_value) : '');
}
$input_more_class .= ' wpshop_input_datetime ';
$field_script = '<script type="text/javascript" >
jQuery(document).ready(function(){
wpshop("#' . $input_def['id'] . '").datepicker();
wpshop("#' . $input_def['id'] . '").datepicker("option", "dateFormat", "yy-mm-dd");
wpshop("#' . $input_def['id'] . '").datepicker("option", "changeMonth", true);
wpshop("#' . $input_def['id'] . '").datepicker("option", "changeYear", true);
wpshop("#' . $input_def['id'] . '").datepicker("option", "yearRange", "-90:+10");
wpshop("#' . $input_def['id'] . '").datepicker("option", "navigationAsDateFormat", true);
wpshop("#' . $input_def['id'] . '").val("' . str_replace(" 00:00:00", "", $input_def['value']) . '");';
if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur'])) {
if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0])) {
$field_script .= '
wpshop("#' . $input_def['id'] . '").datepicker("option", "minDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] . '");';
}
if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0])) {
$field_script .= '
wpshop("#' . $input_def['id'] . '").datepicker("option", "maxDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] . '");';
}
}
$script_options = $script_options_params = array();
if (!empty($date_config['field_options']['attribute_type_date_options_day_to_show'])) {
$day_to_show_list = ' ';
foreach ($date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show) {
$day_to_show_list .= '(date.getDay() == ' . $day_to_show . ') || ';
}
$script_options[] = '( ' . substr($day_to_show_list, 0, -4) . ' )';
}
if (!empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0])) {
if (!empty($date_config['field_options']['attribute_type_date_options_available_date'])) {
$available_date = ' ';
foreach ($date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list) {
if (!empty($avalaible_date_list)) {
$available_date .= '"' . $avalaible_date_list . '",';
}
}
$script_options_params[] = 'var dates = [' . substr($available_date, 0, -1) . ']';
$script_options[] = '(jQuery.inArray(dmy, dates) ' . ($date_config['field_options']['attribute_type_date_options_available_date_type'][0] == 'available' ? '!=' : '==') . ' -1)';
}
}
if (!empty($script_options)) {
$field_script .= '
wpshop("#' . $input_def['id'] . '").datepicker("option", "beforeShowDay", function(date){
' . implode(' ', $script_options_params) . ';
var Y = date.getFullYear();
//.........这里部分代码省略.........