📄 threadtypes.inc.php
字号:
}
}
updatecache('threadtypes');
cpmsg('threadtype_infotypes_succeed', 'admincp.php?action=threadtypes&operation=typeoption&classid='.$classid, 'succeed');
}
} elseif($operation == 'optiondetail') {
$option = $db->fetch_first("SELECT * FROM {$tablepre}typeoptions WHERE optionid='$optionid'");
if(!$option) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
shownav('forum', 'threadtype_infotypes_option');
showsubmenu('threadtype_infotypes_option');
$typeselect = '<select name="typenew" onchange="var styles, key;styles=new Array(\'number\',\'text\',\'radio\', \'checkbox\', \'textarea\', \'select\', \'image\'); for(key in styles) {var obj=$(\'style_\'+styles[key]); obj.style.display=styles[key]==this.options[this.selectedIndex].value?\'\':\'none\';}">';
foreach(array('number', 'text', 'radio', 'checkbox', 'textarea', 'select', 'calendar', 'email', 'url', 'image') as $type) {
$typeselect .= '<option value="'.$type.'" '.($option['type'] == $type ? 'selected' : '').'>'.$lang['threadtype_edit_vars_type_'.$type].'</option>';
}
$typeselect .= '</select>';
$option['rules'] = unserialize($option['rules']);
showformheader("threadtypes&operation=optiondetail&optionid=$optionid");
showtableheader();
showtitle('threadtype_infotypes_option_config');
showsetting($lang['name'], 'titlenew', $option['title'], 'text');
showsetting($lang['threadtype_variable'], 'identifiernew', $option['identifier'], 'text');
showsetting($lang['type'], '', '', $typeselect);
showsetting('fields_edit_desc', 'descriptionnew', $option['description'], 'textarea');
showtagheader('tbody', "style_number", $option['type'] == 'number');
showtitle('threadtype_edit_vars_type_number');
showsetting('fields_edit_maxnum', 'rules[number][maxnum]', $option['rules']['maxnum'], 'text');
showsetting('fields_edit_minnum', 'rules[number][minnum]', $option['rules']['minnum'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_text", $option['type'] == 'text');
showtitle('threadtype_edit_vars_type_text');
showsetting('fields_edit_textmax', 'rules[text][maxlength]', $option['rules']['maxlength'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_textarea", $option['type'] == 'textarea');
showtitle('threadtype_edit_vars_type_textarea');
showsetting('fields_edit_textmax', 'rules[textarea][maxlength]', $option['rules']['maxlength'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_select", $option['type'] == 'select');
showtitle('threadtype_edit_vars_type_select');
showsetting('fields_edit_choices', 'rules[select][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_radio", $option['type'] == 'radio');
showtitle('threadtype_edit_vars_type_radio');
showsetting('fields_edit_choices', 'rules[radio][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_checkbox", $option['type'] == 'checkbox');
showtitle('threadtype_edit_vars_type_checkbox');
showsetting('fields_edit_choices', 'rules[checkbox][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_image", $option['type'] == 'image');
showtitle('threadtype_edit_vars_type_image');
showsetting('fields_edit_images_weight', 'rules[image][maxwidth]', $option['rules']['maxwidth'], 'text');
showsetting('fields_edit_images_height', 'rules[image][maxheight]', $option['rules']['maxheight'], 'text');
showtagfooter('tbody');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$titlenew = trim($titlenew);
if(!$titlenew || !$identifiernew) {
cpmsg('threadtype_infotypes_option_invalid', '', 'error');
}
$query = $db->query("SELECT optionid FROM {$tablepre}typeoptions WHERE identifier='$identifiernew' AND optionid!='$optionid' LIMIT 1");
if($db->num_rows($query) || strlen($identifiernew) > 40 || !ispluginkey($identifiernew)) {
cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}typeoptions SET title='$titlenew', description='$descriptionnew', identifier='$identifiernew', type='$typenew', rules='".addslashes(serialize($rules[$typenew]))."' WHERE optionid='$optionid'");
updatecache('threadtypes');
cpmsg('threadtype_infotypes_option_succeed', 'admincp.php?action=threadtypes&operation=optiondetail&optionid='.$optionid, 'succeed');
}
} elseif($operation == 'typedetail') {
if(!submitcheck('typedetailsubmit') && !submitcheck('typepreviewsubmit')) {
$threadtype = $db->fetch_first("SELECT name, template, modelid, expiration FROM {$tablepre}threadtypes WHERE typeid='$typeid'");
$threadtype['modelid'] = isset($modelid) ? intval($modelid) : $threadtype['modelid'];
$typemodelopt = '';
$existoption = $showoption = array();
$query = $db->query("SELECT id, name, options, customoptions FROM {$tablepre}typemodels ORDER BY displayorder");
while($typemodel = $db->fetch_array($query)) {
if($typemodel['id'] == $threadtype['modelid']) {
foreach(explode("\t", $typemodel['customoptions']) as $id) {
$existoption[$id] = 0;
}
foreach(explode("\t", $typemodel['options']) as $id) {
$existoption[$id] = 1;
}
}
$typemodelopt .= "<option value=\"$typemodel[id]\" ".($typemodel['id'] == $threadtype['modelid'] ? 'selected="selected"' : '').">$typemodel[name]</option>";
}
$typeoptions = $jsoptionids = '';
$query = $db->query("SELECT t.optionid, t.displayorder, t.available, t.required, t.unchangeable, t.search, tt.title, tt.type, tt.identifier
FROM {$tablepre}typevars t, {$tablepre}typeoptions tt
WHERE t.typeid='$typeid' AND t.optionid=tt.optionid ORDER BY t.displayorder");
while($option = $db->fetch_array($query)) {
$jsoptionids .= "optionids.push($option[optionid]);\r\n";
$optiontitle[$option['identifier']] = $option['title'];
$showoption[$option['optionid']]['optionid'] = $option['optionid'];
$showoption[$option['optionid']]['title'] = $option['title'];
$showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$showoption[$option['optionid']]['identifier'] = $option['identifier'];
$showoption[$option['optionid']]['displayorder'] = $option['displayorder'];
$showoption[$option['optionid']]['available'] = $option['available'];
$showoption[$option['optionid']]['required'] = $option['required'];
$showoption[$option['optionid']]['unchangeable'] = $option['unchangeable'];
$showoption[$option['optionid']]['search'] = $option['search'];
}
if($existoption && is_array($existoption)) {
$optionids = $comma = '';
foreach($existoption as $optionid => $val) {
$optionids .= $comma.$optionid;
$comma = '\',\'';
}
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN ('$optionids')");
while($option = $db->fetch_array($query)) {
$showoption[$option['optionid']]['optionid'] = $option['optionid'];
$showoption[$option['optionid']]['title'] = $option['title'];
$showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$showoption[$option['optionid']]['identifier'] = $option['identifier'];
$showoption[$option['optionid']]['required'] = $existoption[$option['optionid']];
$showoption[$option['optionid']]['available'] = 1;
$showoption[$option['optionid']]['unchangeable'] = 0;
$showoption[$option['optionid']]['model'] = 1;
}
}
foreach($showoption as $optionid => $option) {
$typeoptions .= showtablerow('id="optionid'.$optionid.'"', array('class="td25"', 'class="td28 td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\" ".($option['model'] ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$option[optionid]]\" value=\"1\" ".($option['available'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
dhtmlspecialchars($option['title']),
$option[type],
"<input class=\"checkbox\" type=\"checkbox\" name=\"required[$option[optionid]]\" value=\"1\" ".($option['required'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"unchangeable[$option[optionid]]\" value=\"1\" ".($option['unchangeable'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"search[$option[optionid]]\" value=\"1\" ".($option['search'] ? 'checked' : '').">",
"<a href=\"###\" onclick=\"insertvar('$option[identifier]');doane(event);return false;\" class=\"act\">".$lang['threadtype_infotypes_add_template']."</a>",
"<a href=\"admincp.php?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">".$lang['edit']."</a>"
), TRUE);
}
if($threadtype['template']) {
$previewtemplate = preg_replace("/{(.+?)}/ies", "showoption('\\1', 'title')", $threadtype['template']);
$previewtemplate = preg_replace("/\[(.+?)value\]/ies", "showoption('\\1', 'value')", $previewtemplate);
}
shownav('forum', 'forums_threadtypes');
showsubmenu('forums_threadtypes');
showformheader("threadtypes&operation=typedetail&typeid=$typeid");
showtableheader('threadtype_models', 'nobottom');
showsetting('threadtype_models_select', '', '', '<select name="modelid" onchange="window.location=(\'admincp.php?action=threadtypes&operation=typedetail&typeid='.$typeid.'&modelid=\'+this.options[this.selectedIndex].value)"><option value="0">'.$lang['none'].'</option>'.$typemodelopt.'</select>');
showsetting('threadtype_infotypes_validity', 'typeexpiration', $threadtype['expiration'], 'radio');
showtablefooter();
showtableheader("$threadtype[name] - $lang[threadtype_infotypes_add_option]", 'noborder fixpadding');
showtablerow('', 'id="classlist"', '');
showtablerow('', 'id="optionlist"', '');
showtablefooter();
showtableheader("$threadtype[name] - $lang[threadtype_infotypes_exist_option]", 'noborder fixpadding', 'id="typelist"');
showsubtitle(array('<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form,\'delete\')" /><label for="chkall">'.lang('del').'</label>', 'display_order', 'available', 'name', 'type', 'required', 'unchangeable', 'threadtype_infotypes_search', '', ''));
echo $typeoptions;
showtablefooter();
?>
<a name="template"></a>
<div class="colorbox">
<h4 style="margin-bottom:15px;"><?=$threadtype['name']?> - <?=$lang['threadtype_infotypes_template']?></h4>
<textarea cols="100" rows="5" id="typetemplate" name="typetemplate" style="width: 95%;" onkeyup="textareasize(this)"><?=$threadtype['template']?></textarea>
<br /><br />
<b><?=$lang['threadtype_infotypes_template']?>:</b>
<ul class="tpllist"><?=$lang['threadtype_infotypes_template_tips']?></ul>
<?php
if($previewtemplate) {
echo '<fieldset style="margin:1em 0; padding:1em 1.5em;"><legend><b>'.$lang['threadtype_infotypes_template_preview'].':</b></legend>';
echo $previewtemplate;
echo '</fieldset>';
}
?>
<input type="submit" class="btn" name="typedetailsubmit" value="<?=$lang['submit']?>"> <input type="submit" class="btn" name="typepreviewsubmit" value="<?=$lang['threadtype_infotypes_template_preview']?>">
</div>
</form>
<script type="text/JavaScript">
var optionids = new Array();
<?=$jsoptionids?>
function insertvar(text) {
$('typetemplate').focus();
selection = document.selection;
if(selection && selection.createRange) {
var sel = selection.createRange();
sel.text = '<li><b>{' + text + '}</b>: [' + text + "value]</li>\r\n";
sel.moveStart('character', -strlen(text));
} else {
$('typetemplate').value += '<li><b>{' + text + '}<b>: [' + text + "value]</li>\r\n";
}
}
function checkedbox() {
var tags = $('optionlist').getElementsByTagName('input');
for(var i=0; i<tags.length; i++) {
if(in_array(tags[i].value, optionids)) {
tags[i].checked = true;
}
}
}
function insertoption(optionid) {
var x = new Ajax();
x.optionid = optionid;
x.get('admincp.php?action=threadtypes&operation=typelist&inajax=1&optionid=' + optionid, function(s, x) {
if(!in_array(x.optionid, optionids)) {
var div = document.createElement('div');
div.style.display = 'none';
$('append_parent').appendChild(div);
div.innerHTML = '<table>' + s + '</table>';
var tr = div.getElementsByTagName('tr');
var trs = $('typelist').getElementsByTagName('tr');
tr[0].id = 'optionid' + optionid;
trs[trs.length - 1].parentNode.appendChild(tr[0]);
$('append_parent').removeChild(div);
optionids.push(x.optionid);
} else {
$('optionid' + x.optionid).parentNode.removeChild($('optionid' + x.optionid));
for(var i=0; i<optionids.length; i++) {
if(optionids[i] == x.optionid) {
optionids[i] = 0;
}
}
}
});
}
</script>
<script type="text/JavaScript">ajaxget('admincp.php?action=threadtypes&operation=classlist', 'classlist');</script>
<script type="text/JavaScript">ajaxget('admincp.php?action=threadtypes&operation=optionlist&typeid=<?=$typeid?>', 'optionlist', '', '', '', checkedbox);</script>
<?
} else {
$db->query("UPDATE {$tablepre}threadtypes SET special='1', modelid='".intval($modelid)."', template='$typetemplate', expiration='$typeexpiration' WHERE typeid='$typeid'");
if(submitcheck('typedetailsubmit')) {
$orgoption = $orgoptions = $addoption = array();
$query = $db->query("SELECT optionid FROM {$tablepre}typevars WHERE typeid='$typeid'");
while($orgoption = $db->fetch_array($query)) {
$orgoptions[] = $orgoption['optionid'];
}
if(intval($modelid)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -