コード例 #1
0
ファイル: attribute.inc.php プロジェクト: pan289091315/Discuz
 }
 //添加或更改屬性的編輯頁面
 shownav('catmanage', 'attribute_' . $_GET['op']);
 showsubmenu('attribute_' . $_GET['op']);
 showtips('attribute_' . $_GET['op'] . '_tips');
 showformheader('attribute&op=' . $_GET['op'] . '&type=' . $type);
 showtableheader('');
 //$attribute['attr_type'] = $attribute ? $attribute['attr_type']: 1;
 if (count($attributes) > 0) {
     echo '<tr><td class="td27" colspan="2">' . lang('select_attribute') . '</td></tr><tr><td class="vtop rowform" id="attributes" colspan="2"><select id="select_attribute" name="select_attribute"><option value="-1">' . lang('shop_region1') . '</option>';
     foreach ($attributes as $k => $v) {
         if ($v['upid'] == 0) {
             echo '<option value="' . $v['attr_id'] . '">' . $v['attr_name'] . '</option>';
         }
     }
     echo '<script>$(function(){var attributes = ' . json_encode_region($attributes) . ';$("#select_attribute").change(function(){var select_attribute = $("#select_attribute").val();for(var i in attributes){if(attributes[i]["attr_id"] == select_attribute){$("#name").val(attributes[i]["attr_name"]);$("#newvalues").val(attributes[i]["attr_values"]);$("input[name=\'attr_type\'][value=\'"+attributes[i]["attr_type"]+"\']").click();return;}}});});</script></td></tr>';
 }
 showsetting('attribute_name', 'name', $attribute['attr_name'], 'text');
 showsetting('attribute_type', array('attr_type', array(array(1, lang('attr_model_input'), array('valuemodel' => 'none', 'newvaluemodel' => 'none')), array(0, lang('attr_model_select'), array('valuemodel' => '', 'newvaluemodel' => ''))), true), $attribute['attr_type'], 'mradio');
 showtagheader('tbody', 'valuemodel', empty($attribute['attr_type']) || $attribute['attr_type'] == 0 ? true : false, 'sub');
 if (!empty($attrvalues)) {
     foreach ($attrvalues as $attrvalue) {
         echo '<tr><td>' . ($_GET['op'] == 'edit' ? '<input style="width:30px;" value="' . $attrvalue['displayorder'] . '" name="display[' . $attrvalue['attr_valueid'] . ']" />&nbsp;&nbsp;' : '') . '<input type="text" name="attr_valueid[' . $attrvalue['attr_valueid'] . ']" value="' . $attrvalue['attr_text'] . '" />&nbsp;<a class="attrvaluedelete" id="valuedelete_' . $attrvalue['attr_valueid'] . '" href="#" onclick="javascript:deletevalue(' . $attrvalue['attr_valueid'] . ',\'' . $attrvalue['attr_text'] . '\');return false;">' . lang('delete') . '</a></td></tr>';
     }
 }
 echo '<tr><td><script>function deletevalue(valueid,valuetext) { if(confirm("' . lang('confirm_delete_attrvalue') . '"+valuetext)){jQuery.post("batch.attribute.php?ajax=1","ajax=1&op=delete&valueid="+valueid,function(data){$("#valuedelete_"+valueid).parent().hide();return false;});}return false; }</script></td></tr>';
 showtagfooter('tbody');
 showtagheader('tbody', 'newvaluemodel', empty($attribute['attr_type']) || $attribute['attr_type'] == 0 ? true : false, 'sub');
 showsetting('attribute_values', 'newvalues', '', 'textarea');
 showtagfooter('tbody');
 showhiddenfields(array('attr_id' => $_GET['attr_id']));
コード例 #2
0
function InteractionCategoryMenu($categorylist, $formname, $value = null, $getattributes = null)
{
    if ($value) {
        $upid = $categorylist[$value]['upid'] ? $categorylist[$value]['upid'] : 0;
        if ($categorylist[$upid]['upid'] != 0) {
            $upupid = $categorylist[$upid]['upid'];
        } else {
            $upupid = 0;
        }
    }
    $html = '';
    $html .= '<span id ="' . $formname . 'div"><select id="' . $formname . '_selector_0" name="' . $formname . '"><option value="-1">' . lang("please_select_" . $formname) . '</option>';
    foreach ($categorylist as $catid => $catinfo) {
        if ($catinfo['upid'] == 0) {
            $html .= '<option value="' . $catid . '"' . ($catid == $upupid || $catid == $upid || $upid == 0 && $value && $catid == $value ? ' selected="selected"' : '') . '>' . $catinfo['name'] . '</option>';
        }
    }
    $html .= '</select></span>';
    $html .= '<span><script>
		$(function(){
			var ' . $formname . 's = ' . json_encode_region($categorylist) . ';
			var selector = 1;
			$("#' . $formname . '_selector_0").bind("change", function(){creat(this.id);});
			function creat(id) {
				var originalrid = $("#"+id+"").val();
				var csid = id.split("_")[2];
				var newregion = "";
				for(var i in ' . $formname . 's) {
					if(' . $formname . 's[i].upid == originalrid) {
						newregion += "<option value=\\""+' . $formname . 's[i].catid+"\\""+((typeof(upid)!="undefined"&&' . $formname . 's[i].catid==upid)||(typeof(value)!="undefined"&&' . $formname . 's[i].catid==value)?" selected=\\"selected\\"":"")+">"+' . $formname . 's[i].name+"</option>";
					}
				}
				var selectlength = $("#' . $formname . 'div select").length;
				if(selectlength > 1) {
					for(var i = selectlength; i > 0; i--) {
						var cid = $("#' . $formname . 'div select:nth-child("+i+")").attr("id");
						if( cid.split("_")[2] > csid) {
							$("#' . $formname . 'div select:nth-child("+i+")").remove();
						}
					}
					selector = $("#' . $formname . 'div select").length;

				}
				if(newregion!="") {
					$("#"+id+"").after("<select><option value=\\"-1\\">' . lang("please_select_" . $formname) . '</option>"+newregion+"</select>");
					$("#"+id+"").removeAttr("name");
					$("#"+id+" + select").attr("name", "' . $formname . '");
					$("#"+id+" + select").attr("id", "' . $formname . '_selector_"+selector);
					$("#"+id+" + select").bind("change", function(){creat(this.id);});
				} else {
					$("#"+id).attr("name","' . $formname . '");
				}

				selector = $("#' . $formname . 'div select").length;
				if(selector == 1) {
					$("#' . $formname . '_selector_0").attr("name","' . $formname . '");
				}
				' . (!empty($getattributes) ? 'getattributes();' : '') . '
			}
		';
    if (!empty($value)) {
        $upids = explode("|", getupid($value, $categorylist));
        $org = 0;
        for ($i = count($upids); $i > 1; $i--) {
            if ($upids[$i - 1] != 0) {
                $html .= '$("#' . $formname . '_selector_' . $org . '").val(' . $upids[$i - 1] . ');$("#' . $formname . '_selector_' . $org . '").change();';
                $org++;
            }
        }
        $html .= '$("#' . $formname . '_selector_' . $org . '").val(' . $value . ');$("#' . $formname . '_selector_' . $org . '").change();';
    }
    $html .= '});</script></span>';
    return $html;
}
コード例 #3
0
ファイル: tpl.func.php プロジェクト: pan289091315/Discuz
function show_shop_changecat()
{
    global $_G, $_SGLOBAL;
    $arr_cat = getmodelcategory('shop');
    echo '
	<div style="width: 700px;" id="catdiv">
		<select id="catid_0" name="catid">
			<option value="-1" selected="selected">' . lang('attend_cats_select') . '</option>';
    foreach ($_G['categorylist'] as $cat) {
        if ($cat['upid'] == 0) {
            echo '<option value="' . $cat['catid'] . '" >' . $cat['pre'] . $cat['name'] . '</option>';
        }
    }
    echo '
		</select>
		<script type="text/javascript" charset="utf-8">
		$(function() {
			var arr_cats = ' . json_encode_region($arr_cat) . ';
			createmultiselect("catid_0", "catid", arr_cats, "catdiv", "' . lang('attend_cats_select') . '");});
		</script>
	</div>';
}