Code Duplication    Length = 46-59 lines in 2 locations

includes/librairies/eav/attributes_set.class.php 1 location

@@ 701-746 (lines=46) @@
698
699
		$attributeSetDetailsManagement = '
700
<div id="managementContainer" >';
701
	if(current_user_can('wpshop_add_attribute_group')){
702
		$dialog_title = __('New attribute set section name', 'wpshop');
703
		$dialog_identifier = 'wpshop_new_set_section_add';
704
		$dialog_input_identifier = 'wpshop_new_attribute_set_section_name';
705
		ob_start();
706
		include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
707
		$attributeSetDetailsManagement .= ob_get_contents();
708
		ob_end_clean();
709
710
		$add_button_text = __('Add a section for this group', 'wpshop');
711
		$add_button_parent_class = 'attribute_set_section_add_new_button';
712
		$add_button_name = 'wpshop_create_new_set_section_top';
713
		ob_start();
714
		include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php');
715
		$add_button = ob_get_contents();
716
		ob_end_clean();
717
718
		$user_more_script .= '
719
			jQuery("#'.$dialog_identifier.'").dialog({
720
				modal: true,
721
				dialogClass: "wpshop_uidialog_box",
722
				autoOpen:false,
723
				show: "blind",
724
				resizable: false,
725
				buttons:{
726
					"'.__('Add', 'wpshop').'": function(){
727
						jQuery("#managementContainer").load(ajaxurl,{
728
							"action": "wps_attribute_set_section_new",
729
							"_wpnonce": "' . wp_create_nonce("saveNewAttributeSetSection") . '",
730
	            "elementIdentifier": "' . $attributeSetId . '",
731
							"attributeSetSectionName": jQuery("#'.$dialog_input_identifier.'").val()
732
						});
733
						jQuery(this).children("img").show();
734
					},
735
					"'.__('Cancel', 'wpshop').'": function(){
736
						jQuery(this).dialog("close");
737
					}
738
				},
739
				close:function(){
740
					jQuery("#'.$dialog_input_identifier.'").val("");
741
				}
742
			});
743
			jQuery(".'.$add_button_parent_class.' input").click(function(){
744
				jQuery("#'.$dialog_identifier.'").dialog("open");
745
			});';
746
	}
747
	$attributeSetDetailsManagement .= '
748
	<input class="newOrder" type="hidden" name="wpshop_attribute_set_section_order" id="wpshop_attribute_set_section_order" value="" />
749
	<ul class="attribute_set_group_details wpshop_cls" >' . $add_button;

includes/librairies/eav/attributes.class.php 1 location

@@ 2835-2893 (lines=59) @@
2832
					}
2833
				}
2834
				$add_button = $add_dialog_box = $user_more_script = '';
2835
				if( current_user_can('wpshop_add_attributes_select_values') ) {
2836
2837
					$dialog_title = __('New value for attribute', 'wpshop');
2838
					$dialog_identifier = 'wpshop_new_attribute_option_value_add';
2839
					$dialog_input_identifier = 'wpshop_new_attribute_option_value';
2840
					ob_start();
2841
					include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
2842
					$add_dialog_box = ob_get_contents();
2843
					ob_end_clean();
2844
2845
					$add_button_text = __('Add a value for this attribute', 'wpshop');
2846
					$add_button_parent_class = 'wpshop_attribute_option_value_add';
2847
					$add_button_name = 'wpshop_add_option_to_select';
2848
					ob_start();
2849
					include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php');
2850
					$add_button = ob_get_contents();
2851
					ob_end_clean();
2852
2853
					$user_more_script = '
2854
			jQuery("#'.$dialog_identifier.'").dialog({
2855
				modal: true,
2856
				dialogClass: "wpshop_uidialog_box",
2857
				autoOpen:false,
2858
				show: "blind",
2859
				resizable: false,
2860
				buttons:{
2861
					"'.__('Add', 'wpshop').'": function(){
2862
						var data = {
2863
							action: "new_option_for_select",
2864
							wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_new_option_for_attribute_creation") . '",
2865
							attribute_new_label: jQuery("#'.$dialog_input_identifier.'").val(),
2866
							attribute_identifier: "' . $attribute_id . '"
2867
						};
2868
						jQuery.post(ajaxurl, data, function(response) {
2869
							if( response[0] ) {
2870
								jQuery("#sortable_attribute li:last-child").before(response[1]);
2871
								jQuery("#wpshop_new_attribute_option_value_add").dialog("close");
2872
							}
2873
							else {
2874
								alert(response[1]);
2875
							}
2876
							jQuery("#wpshop_new_attribute_option_value_add").children("img").hide();
2877
						}, "json");
2878
2879
						jQuery(this).children("img").show();
2880
					},
2881
					"'.__('Cancel', 'wpshop').'": function(){
2882
						jQuery(this).dialog("close");
2883
					}
2884
				},
2885
				close:function(){
2886
					jQuery("#'.$dialog_input_identifier.'").val("");
2887
				}
2888
			});
2889
			jQuery(".'.$add_button_parent_class.' input").click(function(){
2890
				jQuery("#'.$dialog_identifier.'").dialog("open");
2891
			});';
2892
2893
				}
2894
				$output .= $add_dialog_box . '
2895
	<ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options)>5 ? $add_button : '').$sub_output.$add_button.'
2896
	</ul>