public static function advanced_settings_field($input) { /* WPSHOP_DEBUG_MODE_ALLOWED_IP WPSHOP_DEBUG_MODE WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION WPSHOP_DISPLAY_TOOLS_MENU WPSHOP_INTERNAL_TYPES_TO_EXCLUDE WPSHOP_ATTRIBUTE_VALUE_PER_USER WPSHOP_PAYMENT_METHOD_CIC */ $advanced_settings_output = ' <!-- DEFINE EXTRA PARAMS WPSHOP_DEBUG_MODE_ALLOWED_IP WPSHOP_DEBUG_MODE WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION WPSHOP_DISPLAY_TOOLS_MENU WPSHOP_ATTRIBUTE_VALUE_PER_USER WPSHOP_INTERNAL_TYPES_TO_EXCLUDE --> <ul>'; $wpshop_advanced_settings = get_option('wpshop_extra_options', array()); if (!empty($wpshop_advanced_settings)) { $i = 0; foreach ($wpshop_advanced_settings as $setting_name => $setting_value) { $advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>' . __('Extra parameter key', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[existing][' . $i . '][key]', 'wpshop_extra_options_new_key', $setting_name, 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>' . __('Extra parameter value', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[existing][' . $i . '][value]', 'wpshop_extra_options_new_value', $setting_value, 'text') . '</div><div class="wpshop_cls" ></div></li>'; $i++; } } $advanced_settings_output .= '<li><div class="alignleft wpshop_advanced_options_container" ><p>' . __('New extra parameter key', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[new][key]', 'wpshop_extra_options_new_key', '', 'text') . '</div><div class="alignleft wpshop_advanced_options_container" ><p>' . __('New extra parameter value', 'wpshop') . '</p>' . wpshop_form::form_input('wpshop_extra_options[new][value]', 'wpshop_extra_options_new_value', '', 'text') . '</div><div class="wpshop_cls" ></div></li> </ul>'; echo $advanced_settings_output; }
/** * Return the page content to add a new item * * @return string The html code that output the interface for adding a nem item */ function elementEdition($itemToEdit = '') { global $attribute_displayed_field, $attribute_options_group; $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); $editedItem = ''; if ($itemToEdit != '') { $editedItem = self::getElement($itemToEdit); } $the_form_content_hidden = $the_form_general_content = ''; $the_form_option_content_list = array(); foreach ($dbFieldList as $input_key => $input_def) { if (!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)) { $input_def['label'] = $input_def['name']; $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_def['label']; $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable() . '_action']) : ''; $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? wpshop_tools::varSanitizer($_REQUEST[self::currentPageCode][$input_def['label']]) : ''; $currentFieldValue = $input_def['value']; if (is_object($editedItem)) { $currentFieldValue = $editedItem->{$input_def}['label']; } elseif ($pageAction != '' && $requestFormValue != '') { $currentFieldValue = $requestFormValue; } if ($input_def['label'] == 'status') { if (in_array('notused', $input_def['possible_value'])) { $key = array_keys($input_def['possible_value'], 'notused'); unset($input_def['possible_value'][$key[0]]); } if (in_array('dbl', $input_def['possible_value'])) { $key = array_keys($input_def['possible_value'], 'dbl'); unset($input_def['possible_value'][$key[0]]); } $input_def['type'] = 'checkbox'; $input_def['label'] = __('Use this attribute', 'wpshop'); $input_def['possible_value'] = array('valid'); $input_def_id .= '_valid'; $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; } if (substr($input_def['label'], 0, 3) == 'is_' || $input_def['label'] == '_display_informations_about_value') { $input_def['type'] = 'checkbox'; $input_def['possible_value'] = 'yes'; } switch ($input_def['label']) { case 'is_requiring_unit': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using unit with this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_visible_in_front': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_visible_in_front_listing': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in product listing in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_used_for_sort_by': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute into sortbar', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_searchable': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for including values of this attribute as search parameter', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_visible_in_advanced_search': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using in advanced search form', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'frontend_css_class': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'backend_css_class': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_historisable': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_filterable': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute in the filter search', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_intrinsic': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is intrinsic for a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_used_for_variation': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'is_used_in_variation': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute for variation definition', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; if (!empty($editedItem) && $editedItem->is_used_for_variation == 'yes') { $input_def['option'] = 'disabled="disabled"'; } break; case 'is_user_defined': $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; } $input_def['value'] = $currentFieldValue; if ($input_def['label'] == 'code') { $input_def['type'] = 'hidden'; } elseif ($input_def['label'] == 'entity_id') { $input_def['possible_value'] = wpshop_entities::get_entities_list(); $input_def['valueToPut'] = 'index'; $input_def['type'] = 'select'; $i = 0; foreach ($input_def['possible_value'] as $entity_id => $entity_name) { if ($i <= 0) { $current_entity_id = $entity_id; } $i++; } } elseif ($input_def['label'] == '_unit_group_id') { $input_def['possible_value'] = wpshop_attributes_unit::get_unit_group(); $input_def['type'] = 'select'; } elseif ($input_def['label'] == '_default_unit') { $unit_group_list = wpshop_attributes_unit::get_unit_group(); $input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id) ? $editedItem->_unit_group_id : (!empty($unit_group_list) ? $unit_group_list[0]->id : '')); $input_def['type'] = 'select'; } elseif ($input_def['label'] == 'backend_input') { if (!is_object($editedItem)) { $input_def['type'] = 'hidden'; } else { $new_possible_value = array(); switch ($editedItem->data_type) { case 'integer': $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; $new_possible_value[__('select', 'wpshop')] = 'select'; $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; break; case 'varchar': switch ($input_def['value']) { case 'hidden': $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; break; case 'password': $new_possible_value[__('Password field', 'wpshop')] = 'pass_field'; break; default: $new_possible_value[__('Text field', 'wpshop')] = 'short_text'; break; } break; case 'text': $new_possible_value[__('Textarea field', 'wpshop')] = 'textarea'; break; case 'decimal': $new_possible_value[__('Number field', 'wpshop')] = 'float_field'; break; case 'datetime': $new_possible_value[__('Date field', 'wpshop')] = 'date_field'; break; } $input_def['possible_value'] = $new_possible_value; } } elseif ($input_def['label'] == 'frontend_input') { $new_possible_value = array(); if (is_object($editedItem)) { switch ($editedItem->data_type) { case 'integer': $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; $new_possible_value[__('select', 'wpshop')] = 'select'; $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; break; case 'varchar': switch ($input_def['value']) { case 'hidden': $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; break; case 'password': $new_possible_value[__('Password field', 'wpshop')] = 'pass_field'; break; default: $new_possible_value[__('Text field', 'wpshop')] = 'short_text'; break; } break; case 'text': $new_possible_value[__('Textarea field', 'wpshop')] = 'textarea'; break; case 'decimal': $new_possible_value[__('Number field', 'wpshop')] = 'float_field'; break; case 'datetime': $new_possible_value[__('Date field', 'wpshop')] = 'date_field'; break; } } else { $new_possible_value[__('Text field', 'wpshop')] = 'short_text'; $new_possible_value[__('Number field', 'wpshop')] = 'float_field'; $new_possible_value[__('Date field', 'wpshop')] = 'date_field'; $new_possible_value[__('Textarea field', 'wpshop')] = 'textarea'; $new_possible_value[__('Password field', 'wpshop')] = 'pass_field'; $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; $new_possible_value[__('select', 'wpshop')] = 'select'; $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; } $input_def['possible_value'] = $new_possible_value; if (!empty($editedItem->frontend_input)) { switch ($editedItem->frontend_input) { case 'text': switch ($editedItem->data_type) { case 'varchar': $input_def['value'] = 'short_text'; break; case 'decimal': $input_def['value'] = 'float_field'; break; case 'datetime': $input_def['value'] = 'date_field'; break; case 'hidden': $input_def['value'] = 'hidden_field'; break; case 'password': $input_def['value'] = 'pass_field'; break; } break; default: $input_def['value'] = $editedItem->frontend_input; break; } } } if (is_object($editedItem) && ($input_def['label'] == 'code' || $input_def['label'] == 'data_type' || $input_def['label'] == 'entity_id')) { // $input_def['type'] = 'hidden'; $input_def['option'] = ' disabled="disabled" '; $the_form_content_hidden .= '<input type="hidden" name="' . self::getDbTable() . '[' . $input_def['name'] . ']" value="' . $input_def['value'] . '" />'; $input_def['label'] = $input_def['name']; $input_def['name'] = $input_def['name'] . '_already_defined'; } $input_def['value'] = str_replace("\\", "", $input_def['value']); $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); if ($input_def['label'] == 'default_value') { if (!empty($editedItem->frontend_input)) { switch ($editedItem->frontend_input) { case 'text': $input_def['type'] = 'text'; switch ($editedItem->data_type) { case 'datetime': $the_input = wpshop_attributes::attribute_type_date_config(unserialize($input_def['value'])); $input_def['label'] = __('Date field configuration', 'wpshop'); break; default: $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); break; } break; case 'hidden': $the_input = ''; break; case 'password': $the_input = ''; break; case 'select': case 'multiple-select': case 'radio': case 'checkbox': $input_def['label'] = __('Options list for attribute', 'wpshop') . ' <div class="alignright wpshop_change_select_data_type" > +' . __('Change data type for this attribute', 'wpshop') . ' </div>'; $the_input = wpshop_attributes::get_select_options_list($itemToEdit, $editedItem->data_type_to_use); break; case 'textarea': $input_def['type'] = 'textarea'; $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); break; } } else { $input_def['type'] = 'text'; $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); } } if ($input_def['label'] == '_unit_group_id') { $the_input .= '<div id="wpshop_loader_input_group_unit"></div>'; $the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener">' . __('Manage group unit', 'wpshop') . '</a>'; } if ($input_def['label'] == '_default_unit') { $the_input .= '<div id="wpshop_loader_input_unit"></div>'; $the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener">' . __('Manage units', 'wpshop') . '</a>'; $the_input .= '<input type="hidden" name="input_wpshop_load_attribute_unit_list" id="input_wpshop_load_attribute_unit_list" value="' . wp_create_nonce("wpshop_load_attribute_unit_list") . '" />'; $the_input .= '<div id="wpshop_attribute_unit_manager" title="' . __('Unit management', 'wpshop') . '" class="wpshopHide" ><div class="loading_picture_container" id="product_chooser_picture" ><img src="' . WPSHOP_LOADING_ICON . '" alt="loading..." /></div></div>'; } if ($input_def['type'] != 'hidden') { if ($input_def['label'] == 'entity_id' && is_object($editedItem)) { $the_input .= '<br/><span class="wpshop_duplicate_attribute" >' . __('Duplicate this attribute to another entity', 'wpshop') . '</span>'; } $input = ' <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_def['name'] . '" > <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_def['name'] . '" ><label for="' . $input_def_id . '" >' . __($input_def['label'], 'wpshop') . '</label></td> <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_def['name'] . '" >' . $the_input . '</td> </tr>'; if (substr($input_def['label'], 0, 3) == 'is_' || substr($input_def['label'], 0, 1) == '_' || in_array($input_def['label'], unserialize(WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS))) { $the_form_option_content_list[$input_def['label']] = $input; } else { $the_form_general_content .= $input; if ($input_def['label'] == 'frontend_input' && !is_object($editedItem)) { $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); $input = ' <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_set_section" > <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="' . self::currentPageCode . '_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td> <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_set_section" >' . $the_input . '</td> </tr>'; $the_form_general_content .= $input; } } } else { $the_form_content_hidden .= ' ' . $the_input; } } } $section_legend = ''; $section_page_code = self::currentPageCode; $section_content = $the_form_general_content; ob_start(); include WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'; $the_form_general_content = ob_get_contents(); ob_end_clean(); /** It is attribute TVA, add a button to calcilate price in mass **/ if (!empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva') { $the_form_general_content .= '<input type="button" id="wps_update_price_infos" value="' . __('Update all products price', 'wpshop') . '" /> <img src="' . WPSHOP_LOADING_ICON . '" alt="" id="update_products_loader" /> <br/>'; $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop'); } if (!empty($the_form_option_content_list)) { $the_form_option_content_section = ''; foreach ($attribute_options_group as $group_name => $group_content) { $section_content = ''; foreach ($group_content as $group_code) { if (array_key_exists($group_code, $the_form_option_content_list)) { $section_content .= $the_form_option_content_list[$group_code]; unset($the_form_option_content_list[$group_code]); } } $section_legend = __($group_name, 'wpshop'); $section_page_code = self::currentPageCode; ob_start(); include WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'; $the_form_option_content_section .= ob_get_contents(); ob_end_clean(); } /* Check there are other attributes to display not in defined group */ if (!empty($the_form_option_content_list)) { $section_legend = __('General options', 'wpshop'); $section_content = implode('', $the_form_option_content_list); $section_page_code = self::currentPageCode; ob_start(); include WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'; $the_form_option_content = ob_get_contents(); ob_end_clean(); $the_form_option_content .= $the_form_option_content_section; } } /* Default content for the current page */ $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; $bloc_list[self::currentPageCode]['options']['title'] = __('Options', 'wpshop'); $bloc_list[self::currentPageCode]['options']['content'] = $the_form_option_content; $the_form = ' <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', isset($_REQUEST['action']) && $_REQUEST['action'] != '' ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'save', 'hidden') . ' ' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . ' </form> <div title="' . __('Change data type for selected attribute', 'wpshop') . '" id="wpshop_dialog_change_select_data_type" ><div id="wpshop_dialog_change_select_data_type_container" ></div></div>'; $input_def['possible_value'] = wpshop_entities::get_entities_list(); unset($input_def['possible_value'][$current_entity_id]); $input_def['valueToPut'] = 'index'; $input_def['type'] = 'select'; $input_def['name'] = 'wpshop_entity_to_duplicate_to'; $input_def['id'] = 'wpshop_entity_to_duplicate_to'; $the_form .= ' <div title="' . __('Duplicate attribute to another entity', 'wpshop') . '" id="wpshop_dialog_duplicate_attribute" > ' . __('Choose an entity to copy the selected attribute to', 'wpshop') . ' ' . wpshop_form::check_input_type($input_def) . ' </div>'; $the_form .= ' <script type="text/javascript" > wpshop(document).ready(function(){ wpshopMainInterface("' . self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); jQuery("#wpshop_dialog_duplicate_attribute").dialog({ autoOpen: false, width: 500, height: 100, modal: true, dialogClass: "wpshop_uidialog_box", resizable: false, buttons:{ "' . __('Duplicate', 'wpshop') . '": function(){ var data = { action: "wpshop_duplicate_attribute", wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_duplicate_attribute") . '", attribute_id: jQuery("#wpshop_attributes_edition_table_field_id_id").val(), entity: jQuery("#wpshop_entity_to_duplicate_to").val() }; jQuery.post(ajaxurl, data, function(response) { if (response[0]) { jQuery("#wpshop_dialog_duplicate_attribute").append(response[1]); } else { alert(response[1]); } }, "json"); }, "' . __('Cancel', 'wpshop') . '": function(){ jQuery(this).dialog("close"); jQuery(".wpshop_duplicate_attribute_result").remove(); } } }); jQuery(".wpshop_duplicate_attribute").live("click", function(){ jQuery("#wpshop_dialog_duplicate_attribute").dialog("open"); }); jQuery("#wpshop_dialog_change_select_data_type").dialog({ autoOpen: false, width: 800, height: 200, modal: true, dialogClass: "wpshop_uidialog_box", resizable: false, buttons:{ "' . __('Change type', 'wpshop') . '": function(){ var delete_entity = false; if(jQuery("#delete_entity").is(":checked")){ var delete_entity = true; } var delete_items_of_entity = false; if(jQuery("#delete_items_of_entity").is(":checked")){ var delete_items_of_entity = true; } var data = { action: "attribute_select_data_type_change", wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_change_select_data_type_change") . '", attribute_id: jQuery("#wpshop_attributes_edition_table_field_id_id").val(), internal_data: jQuery("#internal_data").val(), data_type: jQuery("#wpshop_attribute_change_data_type_new_type").val(), delete_entity: delete_entity, delete_items_of_entity: delete_items_of_entity }; jQuery.post(ajaxurl, data, function(response) { jQuery(".wpshop_attributes_edition_table_field_input_default_value").html( response ); jQuery("#wpshop_dialog_change_select_data_type").dialog("close"); }, "json"); }, "' . __('Cancel', 'wpshop') . '": function(){ jQuery(this).dialog("close"); } } }); jQuery(".wpshop_attribute_change_select_data_type_deletion_input").live("click",function() { var display = false; if (jQuery(".wpshop_attribute_change_select_data_type_deletion_input_item").is(":checked") ) { display = true; } if (jQuery(".wpshop_attribute_change_select_data_type_deletion_input_entity").is(":checked") ) { display = true; } if (display) { jQuery(".wpshop_attribute_change_data_type_alert").show(); } else { jQuery(".wpshop_attribute_change_data_type_alert").hide(); } }); jQuery(".wpshop_change_select_data_type").live("click",function(){ jQuery("#wpshop_dialog_change_select_data_type_container").html(jQuery("#wpshopLoadingPicture").html()); jQuery("#wpshop_dialog_change_select_data_type").dialog("open"); var data = { action: "attribute_select_data_type", current_attribute: jQuery("#wpshop_attributes_edition_table_field_id_id").val(), wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_change_select_data_type") . '" }; jQuery.post(ajaxurl, data, function(response) { jQuery("#wpshop_dialog_change_select_data_type_container").html( response ); }, "json"); }); jQuery("#wpshop_attributes_edition_table_field_id__unit_group_id").change(function(){ change_unit_list(); });'; if (!is_object($editedItem)) { $the_form .= ' jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").change(function(){ jQuery(".wpshop_attributes_edition_table_field_input_default_value").html(jQuery("#wpshopLoadingPicture").html()); var data = { action: "attribute_output_type", current_type: jQuery(this).val(), wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_output_type_selection") . '" }; jQuery.post(ajaxurl, data, function(response) { jQuery(".wpshop_attributes_edition_table_field_input_default_value").html((response[0])); jQuery(".wpshop_attributes_edition_table_field_label_default_value label").html((response[1])); }, "json"); // var data = { // action: "attribute_frontend_input_type", // current_type: jQuery(this).val(), // wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_frontend_input_type") . '" // }; // jQuery.getJSON(ajaxurl, data, function(response) { // jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").html(response); // }); });'; } $the_form .= ' jQuery("#wpshop_attributes_edition_table_field_id_entity_id").change(function(){ jQuery(".wpshop_attributes_edition_table_field_input_set_section").html(jQuery("#wpshopLoadingPicture").html()); var data = { action: "attribute_entity_set_selection", current_entity_id: jQuery(this).val(), wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_entity_set_selection") . '" }; jQuery.post(ajaxurl, data, function(response) { jQuery(".wpshop_attributes_edition_table_field_input_set_section").html( response ); }, "json"); }); jQuery("#wpshop_attributes_edition_table_field_id_is_used_for_variation").click(function(){ if ( jQuery(this).is(":checked") ) { jQuery("#wpshop_attributes_edition_table_field_id_is_used_in_variation").prop("checked", false); jQuery("#wpshop_attributes_edition_table_field_id_is_used_in_variation").prop("disabled", true); } else { jQuery("#wpshop_attributes_edition_table_field_id_is_used_in_variation").prop("disabled", false); } }); }); function change_unit_list(){ var data = { action: "load_attribute_unit_list", wpshop_ajax_nonce: jQuery("#input_wpshop_load_attribute_unit_list").val(), current_group: jQuery("#wpshop_attributes_edition_table_field_id__unit_group_id").val(), selected_list:"unit" }; //Response, update the combo box jQuery.post(ajaxurl, data, function(response) { if ( response[0] ) { jQuery("#wpshop_attributes_edition_table_field_id__default_unit").html(response[1]); } else { alert( response[1] ); } }, "json"); } </script>'; return $the_form; }
public static function list_table_filters() { if (isset($_GET['post_type'])) { $post_type = $_GET['post_type']; if (post_type_exists($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { $filter_possibilities = array(); $filter_possibilities['all'] = __('-- Select Filter --', 'wpshop'); $filter_possibilities['only_orders'] = __('List orders only', 'wpshop'); $filter_possibilities['quotations'] = __('List quotations only', 'wpshop'); $filter_possibilities['free_orders'] = __('List orders free', 'wpshop'); echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, !empty($_GET['entity_filter']) ? $_GET['entity_filter'] : '', '', 'index'); $min = !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ? $_GET['entity_filter_btpf'] : ''; $max = !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ? $_GET['entity_filter_btps'] : ''; echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> '; echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null); echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null); } } }
<?php if (current_user_can('wpshop_edit_options')) { ?> <?php $value = $wpshop_display_option[$field_identifier] <= 0 ? WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE : $wpshop_display_option[$field_identifier]; ?> <div id="<?php echo $field_identifier; ?> slider" class="slider_variable wpshop_options_slider wpshop_options_slider_display wpshop_options_slider_display_grid_element_number"></div> <?php echo wpshop_form::form_input('wpshop_display_option[' . $field_identifier . ']', $field_identifier, $wpshop_display_option[$field_identifier], 'text', ' readonly class="sliderValue" '); ?> <script type="text/javascript" > wpshop(document).ready(function(){ jQuery('#<?php echo $field_identifier; ?> slider').slider({ value : <?php echo $value; ?> , min: <?php echo WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE; ?> , max: <?php
/** * FIELDS - Display elements per page option */ function wpshop_display_element_per_page() { $wpshop_display_option = get_option('wpshop_display_option'); $field_identifier = 'wpshop_display_element_per_page'; if (current_user_can('wpshop_edit_options')) { $option_field_output = wpshop_form::form_input('wpshop_display_option[' . $field_identifier . ']', $field_identifier, !empty($wpshop_display_option[$field_identifier]) ? $wpshop_display_option[$field_identifier] : 20, 'text'); } else { $option_field_output = $wpshop_display_option[$field_identifier]; } echo $option_field_output . ' <a href="#" title="' . __('Number of elements per page', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; }
/** * Return the page content to add a new item * * @return string The html code that output the interface for adding a nem item */ function unit_group_edition($itemToEdit = '') { global $attribute_displayed_field; $dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); $editedItem = ''; $_REQUEST['action'] = 'save_new_attribute_unit_group'; if ($itemToEdit != '') { $editedItem = self::get_unit_group($itemToEdit); $_REQUEST['action'] = 'update_attribute_unit_group'; } $the_form_content_hidden = $the_form_general_content = $the_form_option_content = ''; foreach ($dbFieldList as $input_key => $input_def) { $pageAction = isset($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) : ''; $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? wpshop_tools::varSanitizer($_REQUEST[self::currentPageCode][$input_def['name']]) : ''; $currentFieldValue = $input_def['value']; if (is_object($editedItem)) { $currentFieldValue = $editedItem->{$input_def}['name']; } elseif ($pageAction != '' && $requestFormValue != '') { $currentFieldValue = $requestFormValue; } $input_def['value'] = $currentFieldValue; $input_def['value'] = __(str_replace("\\", "", $input_def['value']), 'wpshop'); $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); if ($input_def['type'] != 'hidden') { $label = 'for="' . $input_def['name'] . '"'; if ($input_def['type'] == 'radio' || $input_def['type'] == 'checkbox') { $label = ''; } $input = ' <div class="wpshop_cls" > <div class="wpshop_form_label wpshop_' . self::currentPageCode . '_' . $input_def['name'] . '_label alignleft" > <label ' . $label . ' >' . __($input_def['name'], 'wpshop') . '</label> </div> <div class="wpshop_form_input wpshop_' . self::currentPageCode . '_' . $input_def['name'] . '_input alignleft" > ' . $the_input . ' </div> </div>'; if (substr($input_def['name'], 0, 3) == 'is_') { $the_form_option_content .= $input; } else { $the_form_general_content .= $input; } } else { $the_form_content_hidden .= ' ' . $the_input; } } $the_form = ' <form name="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" id="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" method="post" action="' . WPSHOP_AJAX_FILE_URL . '" > ' . wpshop_form::form_input('action', 'action', $_REQUEST['action'], 'hidden') . ' ' . wpshop_form::form_input('post', 'post', 'true', 'hidden') . ' ' . wpshop_form::form_input('elementCode', 'elementCode', 'attribute_unit_management', 'hidden') . ' ' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . ' ' . $the_form_content_hidden . '' . $the_form_general_content . ' <input type="button" value="' . __('Retour', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_group_edition" id="cancel_unit_group_edition" /> <input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit_group" id="save_new_unit_group" /> </form> <script type="text/javascript" > wpshop(document).ready(function(){ wpshopMainInterface("' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this unit group?', 'wpshop') . '"); jQuery("#wpshop_unit_list_tab").hide(); jQuery("#cancel_unit_group_edition").click(function(){ jQuery("#wpshop_unit_group_list").load(WPSHOP_AJAX_FILE_URL, { "post": "true", "elementCode": "attribute_unit_management", "action": "load_attribute_unit_groups" }); }); jQuery("#' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form").ajaxForm({ target: "#wpshop_unit_group_list" }); }); </script>'; return $the_form; }
/** * Return the page content to add a new item * * @return string The html code that output the interface for adding a nem item */ function elementEdition($itemToEdit = '') { global $attribute_hidden_field; $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); $form_more_content = $the_form_content_hidden = $the_form_general_content = ''; $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; $bloc_list = array(); $editedItem = ''; if ($itemToEdit != '') { $editedItem = self::getElement($itemToEdit); } foreach ($dbFieldList as $input_key => $input_def) { $input_name = $input_def['name']; $input_value = $input_def['value']; $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_name; $attributeAction = isset($_REQUEST[self::getDbTable() . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable() . '_action']) : ''; $attributeFormValue = isset($_REQUEST[self::getDbTable()][$input_name]) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable()][$input_name]) : ''; /* Get value by checking current object type */ $currentFieldValue = $input_value; if (is_object($editedItem)) { $currentFieldValue = $editedItem->{$input_name}; } elseif ($attributeAction != '' && $attributeFormValue != '') { $currentFieldValue = $attributeFormValue; } /* Check if the field must be hidden */ if (in_array($input_name, $attribute_hidden_field)) { $input_def['type'] = 'hidden'; } if ($input_name == 'entity_id') { $input_def['type'] = 'select'; $input_def['possible_value'] = wpshop_entities::get_entities_list(); $input_def['valueToPut'] = 'index'; if (is_object($editedItem) || count($input_def['possible_value']) == 1) { $input_def['type'] = 'hidden'; $currentFieldValue = count($input_def['possible_value']) == 1 ? $input_def['possible_value'][0]->id : $currentFieldValue; } $input_def['name'] = $input_name; $input_def['value'] = $currentFieldValue; $i = 0; foreach ($input_def['possible_value'] as $entity_id => $entity_name) { if ($i <= 0) { $current_entity_id = $entity_id; } $i++; } $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); } else { if (in_array($input_name, array('status', 'default_set'))) { $input_def['type'] = 'checkbox'; switch ($input_name) { case 'status': $input_name = __('Use this attribute group', 'wpshop'); $input_def['possible_value'] = array('valid'); $input_def_id .= '_valid'; $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; break; case 'default_set': $input_def['possible_value'] = array('yes'); $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group as default group in selected element', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; $input_def_id .= '_yes'; break; } } $input_def['value'] = $currentFieldValue; $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); } if ($input_def['type'] != 'hidden') { $the_form_general_content .= ' <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_name . '" > <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_name . '" ><label for="' . $input_def_id . '" >' . __($input_name, 'wpshop') . '</label></td> <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_name . '" >' . $the_input . '</td> </tr>'; } else { $the_form_content_hidden .= ' ' . $the_input; } } if (empty($itemToEdit)) { $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode, false); $the_form_general_content .= ' <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_existing_attribute_set_copy_from" > <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="' . $input_def_id . '" >' . __('Create the new group from an existing', 'wpshop') . '</label></td> <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_existing_attribute_set_copy_from" >' . $the_input . '</td> </tr>'; } $the_form_general_content = ' <table class="wpshop_' . self::currentPageCode . '_edition_table wpshop_' . self::currentPageCode . '_edition_table_main_info" > ' . $the_form_general_content . ' </table>'; /* Default content for the current page */ $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; if (is_object($editedItem)) { $bloc_list[self::currentPageCode]['detail']['title'] = __('Attribute group section details', 'wpshop'); $bloc_list[self::currentPageCode]['detail']['content'] = self::attributeSetDetailsManagement($itemToEdit); } $the_form = ' <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', !empty($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'save', 'hidden') . ' ' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . ' <div class="wpshop_edition_button wpshop_edition_button_' . self::currentPageCode . '" >'; if ($action == 'add' && current_user_can('wpshop_add_attribute_set')) { $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; } elseif (current_user_can('wpshop_edit_attribute_set')) { $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; } if (current_user_can('wpshop_delete_attribute_set') && $action != 'add') { $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; } $the_form .= ' </div> </form> <script type="text/javascript" > wpshop(document).ready(function(){ wpshopMainInterface("' . self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); jQuery("#wpshop_attribute_set_edition_table_field_id_entity_id").change(function(){ jQuery(".wpshop_attribute_set_edition_table_field_input_existing_attribute_set_copy_from").html(jQuery("#wpshopLoadingPicture").html()); var data = { action: "attribute_set_entity_selection", current_entity_id: jQuery(this).val(), wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_set_entity_selection") . '" }; jQuery.post(ajaxurl, data, function(response) { jQuery(".wpshop_attribute_set_edition_table_field_input_existing_attribute_set_copy_from").html( response ); }, "json"); }); }); </script>'; return $the_form; }