style.php

来自「八星瓢虫留言本特点:采用PHP+Access数据库实现」· PHP 代码 · 共 1,049 行 · 第 1/4 页

PHP
1,049
字号
function Up() {
    var sel=document.myform.d_b2;
    var nIndex = sel.selectedIndex;
    var nLen = sel.length;
    if ((nLen<1)||(nIndex==0)) return;
    if (nIndex<0) {
        alert("请选择一个要移动的已选按钮!");
        return;
    }
    var sValue=sel.options[nIndex].value;
    var sHTML=sel.options[nIndex].innerHTML;
    sel.options[nIndex].value=sel.options[nIndex-1].value;
    sel.options[nIndex].innerHTML=sel.options[nIndex-1].innerHTML;
    sel.options[nIndex-1].value=sValue;
    sel.options[nIndex-1].innerHTML=sHTML;
    sel.selectedIndex=nIndex-1;
}

function Down() {
    var sel=document.myform.d_b2;
    var nIndex = sel.selectedIndex;
    var nLen = sel.length;
    if ((nLen<1)||(nIndex==nLen-1)) return;
    if (nIndex<0) {
        alert("请选择一个要移动的已选按钮!");
        return;
    }
    var sValue=sel.options[nIndex].value;
    var sHTML=sel.options[nIndex].innerHTML;
    sel.options[nIndex].value=sel.options[nIndex+1].value;
    sel.options[nIndex].innerHTML=sel.options[nIndex+1].innerHTML;
    sel.options[nIndex+1].value=sValue;
    sel.options[nIndex+1].innerHTML=sHTML;
    sel.selectedIndex=nIndex+1;
}

function checkform() {
    var sel=document.myform.d_b2;
    var nLen = sel.length;
    var str="";
    for (var i=0;i<nLen;i++) {
        if (i>0) str+="|";
        str+=sel.options[i].value;
    }
    document.myform.d_button.value=str;
    return true;
}

</script>

<?php


    $s_SubmitButton = "<input type=submit name=b value=' 保存设置 '>";

    echo "<table border=0 cellpadding=5 cellspacing=0 align=center>".
        "<form action='?action=buttonsave&id=".$GLOBALS["sStyleID"]."&toolbarid=".$GLOBALS["sToolBarID"]."' method=post name=myform onsubmit='return checkform()'>".
        "<tr align=center><td>可选按钮</td><td></td><td>已选按钮</td><td></td></tr>".
        "<tr align=center>".
            "<td><select name='d_b1' size=20 style='width:250px' ondblclick='Add()'>".$s_Option1."</select></td>".
            "<td><input type=button name=b1 value=' → ' onclick='Add()'><br><br><input type=button name=b1 value=' ← ' onclick='Del()'></td>".
            "<td><select name='d_b2' size=20 style='width:250px' ondblclick='Del()'>".$s_Option2."</select></td>".
            "<td><input type=button name=b3 value='↑' onclick='Up()'><br><br><br><input type=button name=b4 value='↓' onclick='Down()'></td>".
        "</tr>".
        "<input type=hidden name='d_button' value=''>".
        "<tr><td colspan=4 align=right>".$s_SubmitButton."</td></tr>".
        "</form></table>";


    echo "<table border=0 cellspacing=1 align=center class=list>".
        "<tr><th colspan=4>以下是按钮图片对照表(部分下拉框或特殊按钮可能没图):</th></tr>";
    $n = 0;
    $m = 0;
    for ($i=1;$i<=count($GLOBALS["aButton"]);$i++){
        if ($GLOBALS["aButton"][$i][8] == 1){
            $m = $m + 1;
            $n = $m % 4;
            if ($n == 1) {
                echo "<tr>";
            }
            echo "<td>";
            if ($GLOBALS["aButton"][$i][3] != "") {
                echo "<img border=0 align=absmiddle src='../buttonimage/".$GLOBALS["sStyleDir"]."/".$GLOBALS["aButton"][$i][3]."'>";
            }
            echo $GLOBALS["aButton"][$i][2];
            echo "</td>";
            if ($n == 0) {
                echo "</tr>";
            }
        }
    }
    if ($n > 0) {
        for ($i=1;$i<=4-$n;$i++){
            echo "<td>&nbsp;</td>";
        }
        echo "</tr>";
    }
    echo "</table>";
}

function Code2Title($s_Code){
    for ($i=1;$i<=count($GLOBALS["aButton"]);$i++){
        if (strtoupper($GLOBALS["aButton"][$i][1]) == strtoupper($s_Code)) {
            return $GLOBALS["aButton"][$i][2];
        }
    }
    return "";
}

function DoButtonSave(){
    $s_Button = toTrim("d_button");

    $nToolBarID = (int)($GLOBALS["sToolBarID"]);
    $aCurrToolbar = explode("|||", $GLOBALS["aToolbar"][$nToolBarID]);
    $GLOBALS["aToolbar"][$nToolBarID] = $aCurrToolbar[0]."|||".$s_Button."|||".$aCurrToolbar[2]."|||".$aCurrToolbar[3];

    WriteConfig();
    WriteStyle($GLOBALS["sStyleID"]);

    ShowMessage("<b><span class=red>工具栏按钮设置保存成功!</span></b><li><a href='?action=stylepreview&id=".$GLOBALS["sStyleID"]."' target='_blank'>预览此样式</a><li><a href='?action=toolbar&id=".$GLOBALS["sStyleID"]."'>返回工具栏管理</a><li><a href='?action=buttonset&id=".$GLOBALS["sStyleID"]."&toolbarid=".$GLOBALS["sToolBarID"]."'>重新设置此工具栏下的按钮</a>");

}

function InitSelect($s_FieldName, $a_Name, $a_Value, $v_InitValue, $s_Sql, $s_AllName){
    $s_Result = "<select name='".$s_FieldName."' size=1>";
    if ($s_AllName != "") {
        $s_Result = $s_Result."<option value=''>".$s_AllName."</option>";
    }
    if ($s_Sql == "") {
        for ($i=0;$i<count($a_Name);$i++){
            $s_Result = $s_Result."<option value=\"".htmlspecialchars($a_Value[$i])."\"";
            if ($a_Value[$i] == $v_InitValue) {
                $s_Result = $s_Result." selected";
            }
            $s_Result = $s_Result.">".htmlspecialchars($a_Name[$i])."</option>";
        }
    }
    $s_Result = $s_Result."</select>";
    return $s_Result;
}

function WriteStyle($n_StyleID){

    $sConfig = "";
    $aTmpStyle = explode("|||", $GLOBALS["aStyle"][$n_StyleID]);
    $sConfig = $sConfig."config.ButtonDir = \"".$aTmpStyle[1]."\";\n";
    $sConfig = $sConfig."config.StyleUploadDir = \"".$aTmpStyle[3]."\";\n";
    $sConfig = $sConfig."config.InitMode = \"".$aTmpStyle[18]."\";\n";
    $sConfig = $sConfig."config.AutoDetectPasteFromWord = \"".$aTmpStyle[17]."\";\n";
    $sConfig = $sConfig."config.BaseUrl = \"".$aTmpStyle[19]."\";\n";
    $sConfig = $sConfig."config.BaseHref = \"".$aTmpStyle[22]."\";\n";
    $sConfig = $sConfig."config.AutoRemote = \"".$aTmpStyle[24]."\";\n";
    $sConfig = $sConfig."config.ShowBorder = \"".$aTmpStyle[25]."\";\n";
    $sConfig = $sConfig."config.StateFlag = \"".$aTmpStyle[16]."\";\n";
    $sConfig = $sConfig."config.CssDir = \"".$aTmpStyle[2]."\";\n";
    $sConfig = $sConfig."config.AutoDetectLanguage = \"".$aTmpStyle[27]."\";\n";
    $sConfig = $sConfig."config.DefaultLanguage = \"".$aTmpStyle[28]."\";\n";
    $sConfig = $sConfig."config.AllowBrowse = \"".$aTmpStyle[43]."\";\n";
    $sConfig = $sConfig."\n";
    $sConfig = $sConfig."function showToolbar(){\n";
    $sConfig = $sConfig."\n";

    $sConfig = $sConfig."\tdocument.write (\"";
    $sConfig = $sConfig."<table border=0 cellpadding=0 cellspacing=0 width='100%' class='Toolbar' id='eWebEditor_Toolbar'>";

    $s_Order = "";
    $s_ID = "";
    for ($n=1;$n<=count($GLOBALS["aToolbar"]);$n++){
        if ($GLOBALS["aToolbar"][$n] != "") {
            $aTmpToolbar = explode("|||", $GLOBALS["aToolbar"][$n]);
            if ((int)$aTmpToolbar[0] == $n_StyleID) {
                if ($s_ID != "") {
                    $s_ID = $s_ID."|";
                    $s_Order = $s_Order."|";
                }
                $s_ID = $s_ID.$n;
                $s_Order = $s_Order.$aTmpToolbar[3];
            }
        }
    }

    if ($s_ID != "") {
        $a_ID = explode("|", $s_ID);
        $a_Order = explode("|", $s_Order);
        for ($n=0;$n<count($a_Order);$n++){
            $a_Order[$n] = (int)($a_Order[$n]);
            $a_ID[$n] = (int)($a_ID[$n]);
        }
        $a_ID = doSort($a_ID, $a_Order);
        for ($n=0;$n<count($a_ID);$n++){
            $aTmpToolbar = explode("|||", $GLOBALS["aToolbar"][$a_ID[$n]]);
            $aTmpButton = explode("|", $aTmpToolbar[1]);

            $sConfig = $sConfig."<tr><td><div class=yToolbar>";
            for ($i=0;$i<count($aTmpButton);$i++){
                if (strtoupper($aTmpButton[$i]) == "MAXIMIZE") {
                    $sConfig = $sConfig."\");\n";
                    $sConfig = $sConfig."\n";

                    $sConfig = $sConfig."\tif (sFullScreen==\"1\"){\n";
                    $sConfig = $sConfig."\t\tdocument.write (\"".Code2HTML("Minimize", $aTmpStyle[1])."\");\n";
                    $sConfig = $sConfig."\t}else{\n";
                    $sConfig = $sConfig."\t\tdocument.write (\"".Code2HTML($aTmpButton[$i], $aTmpStyle[1])."\");\n";
                    $sConfig = $sConfig."\t}\n";
                    $sConfig = $sConfig."\n";

                    $sConfig = $sConfig."\tdocument.write (\"";
                }else{
                    $sConfig = $sConfig.Code2HTML($aTmpButton[$i], $aTmpStyle[1]);
                }
            }
            $sConfig = $sConfig."</div></td></tr>";
        }
    }else{
        $sConfig = $sConfig."<tr><td></td></tr>";
    }

    $sConfig = $sConfig."</table>\");\n";
    $sConfig = $sConfig."\n";
    $sConfig = $sConfig."}\n";

    WriteFile("../style/".strtolower($aTmpStyle[0]).".js", $sConfig);

}

function Code2HTML($s_Code, $s_ButtonDir){
    $s_Result = "";
    for ($i=1;$i<=count($GLOBALS["aButton"]);$i++){
        if (strtoupper($GLOBALS["aButton"][$i][1]) == strtoupper($s_Code)) {
            switch ($GLOBALS["aButton"][$i][5]) {
            case 0:
                $s_Result = "<DIV CLASS=".$GLOBALS["aButton"][$i][7]." TITLE='\"+lang[\"".$GLOBALS["aButton"][$i][1]."\"]+\"' onclick=\\\"".$GLOBALS["aButton"][$i][6]."\\\"><IMG CLASS=Ico SRC='buttonimage/".$s_ButtonDir."/".$GLOBALS["aButton"][$i][3]."'></DIV>";
                break;
            case 1:
                if ($GLOBALS["aButton"][$i][4] != "") {
                    $s_Result = "<SELECT CLASS=".$GLOBALS["aButton"][$i][7]." onchange=\\\"".$GLOBALS["aButton"][$i][6]."\\\">".$GLOBALS["aButton"][$i][4]."</SELECT>";
                }else{
                    $s_Result = "<SELECT CLASS=".$GLOBALS["aButton"][$i][7]." onchange=\\\"".$GLOBALS["aButton"][$i][6]."\\\">\"+lang[\"".$GLOBALS["aButton"][$i][1]."\"]+\"</SELECT>";
                }
                break;
            case 2:
                $s_Result = "<DIV CLASS=".$GLOBALS["aButton"][$i][7].">".$GLOBALS["aButton"][$i][4]."</DIV>";
                break;
            }
            return $s_Result;
        }
    }
    return $s_Result;
}

function DeleteFile($s_StyleName){
    @unlink("../style/".strtolower($s_StyleName).".js");
}

function isValidColor($str){
    $s_Match = "/[A-Fa-f0-9]{6}/i";
    return preg_match($s_Match, $str);
}

?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?