Exemplo n.º 1
0
function trspecial($trname, $varname, $value = '', $type = 'htmltext', $mode = 0, $guide = '', $min = 0, $max = 0, $width = '25%')
{
    global $cms_abs, $ftp_url, $cmsurl, $subject_table;
    $_mc = defined('M_MCENTER') ? 1 : 0;
    $_mc && ($trname = '<b>' . $trname . '</b>');
    $lcls = $_mc ? 'item1' : 'txt txtright fB borderright';
    $rcls = $_mc ? 'item2' : 'txt txtleft';
    $addstr = "<div id=\"alert_{$varname}\" name=\"alert_{$varname}\" class=\"" . ($_mc ? 'red' : 'mistake0') . "\"></div>";
    if ($guide) {
        $addstr .= $_mc ? "<font class=\"gray\">{$guide}</font>" : "<div class=\"tips1\">{$guide}</div>";
    }
    if ($type == 'htmltext') {
        echo !$mode ? "<tr><td colspan=\"2\" class=\"" . ($_mc ? 'item1 item4' : 'txt txtleft fB') . "\">" . $trname . $addstr . "</td></tr><tr><td colspan=\"2\" class=\"{$rcls}\">\n" : "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td><td class=\" class=\"{$rcls}\">\n";
        echo "<textarea cols=\"80\" id=\"{$varname}\" name=\"{$varname}\" rows=\"10\">" . htmlspecialchars(tag2atm($value, 1)) . '</textarea>' . "<script type=\"text/javascript\">CKEDITOR.replace('{$varname}',{" . ($mode ? "toolbar : 'simple'" : 'height : 500') . '});</script>';
        if ($mode) {
            echo $addstr;
        }
        echo "</td></tr>\n";
    } elseif (in_array($type, array('images', 'files', 'medias', 'flashs'))) {
        $type = substr($type, 0, strlen($type) - 1);
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\">\n";
        uploadmodule($varname, $value, $type, $mode, $min, $max);
        echo "{$addstr}</td></tr>\n";
    } elseif ($type == 'image') {
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\">\n";
        singlemodule($varname, $value, 'image');
        echo "{$addstr}</td></tr>\n";
    } elseif (in_array($type, array('file', 'flash', 'media'))) {
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\">\n";
        singlemodule($varname, $value, $type, $mode);
        echo "{$addstr}</td></tr>\n";
    } elseif ($type == 'text') {
        if ($subject_table && ($varname == 'subject' || strpos($varname, '[subject]'))) {
            $addstr = "&nbsp;&nbsp;<input type=\"button\" value=\"" . lang('checksubject') . "\" onclick=\"checksubject(this,'{$subject_table}','{$varname}');\">{$addstr}";
        }
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\"><input type=\"text\" size=\"" . ($mode ? 60 : 20) . "\" id=\"{$varname}\" name=\"{$varname}\" value=\"" . $value . "\">{$addstr}</td></tr>\n";
    } elseif ($type == 'multitext') {
        //
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"txt txtleft\"><textarea rows=\"" . ($mode ? 10 : 4) . "\" id=\"{$varname}\" name=\"{$varname}\" cols=\"" . ($mode ? 90 : 50) . "\">" . $value . "</textarea>{$addstr}</td></tr>\n";
    } elseif ($type == 'select') {
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\">" . ($mode ? $value : "<select name=\"{$varname}\">" . $value . "</select>") . "{$addstr}</td></tr>\n";
    } elseif ($type == 'mselect') {
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"txt txtleft\">" . $value . "{$addstr}</td></tr>\n";
    } elseif ($type == 'date') {
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\"><input type=\"text\" id=\"{$varname}\" size=\"10\" name=\"{$varname}\" value=\"" . $value . "\" onclick=\"ShowCalendar(this.id);\">{$addstr}</td></tr>\n";
    } elseif ($type == 'map') {
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\"><input class=\"imgbtn\" type=\"image\" src=\"{$cms_abs}images/admina/mapmarker.gif\" onmouseover=\"this.onfocus()\" onfocus=\"_08cms.map.setButton(this,'marker','{$varname}','','{$min}','{$mode}');\" align=\"absmiddle\" /><span>{$value}</span><input type=\"hidden\" id=\"{$varname}\" name=\"{$varname}\" value=\"{$value}\">\n";
        echo "{$addstr}</td></tr>\n";
    } elseif ($type == 'vote') {
        //$value是一个序列化之后的字串
        echo "<tr><td width=\"{$width}\" class=\"{$lcls}\">" . $trname . "</td>\n";
        echo "<td class=\"{$rcls}\">";
        $value = $value ? unserialize($value) : array();
        $length = count($value);
        /*
        		echo "<div vote=\"item\" style=\"display:none\"><span vote=\"subject\">{subject}</span>&nbsp;"
        			."[<a href=\"javascript://\" onclick=\"_08cms.vote.editVote(this,'$varname','$min','$mode',{index})\">".lang('edit')."</a>]&nbsp;"
        			."[<a href=\"javascript://\" onclick=\"_08cms.vote.delVote(this,'$varname',{index})\">".lang('delete')."</a>]</div>\n";*/
        foreach ($value as $k => $v) {
            echo "<div id=\"{$varname}[{$k}]\"><span vote=\"subject\">{$v['subject']}</span>&nbsp;" . "[<a href=\"javascript://\" onclick=\"_08cms.vote.editVote(this,'{$varname}','{$min}','{$mode}',{$k})\">" . lang('edit') . "</a>]&nbsp;" . "[<a href=\"javascript://\" onclick=\"_08cms.vote.delVote(this,'{$varname}',{$k})\">" . lang('delete') . "</a>]</div>\n";
            foreach ($v as $x => $z) {
                if (is_array($z)) {
                    foreach ($z as $a => $b) {
                        if (is_array($b)) {
                            foreach ($b as $c => $e) {
                                echo "<input type=\"hidden\" name=\"{$varname}[{$k}][{$x}][{$a}][{$c}]\" value=\"{$e}\">\n";
                            }
                        } else {
                            echo "<input type=\"hidden\" name=\"{$varname}[{$k}][{$x}][{$a}]\" value=\"{$b}\">\n";
                        }
                    }
                } else {
                    echo "<input type=\"hidden\" name=\"{$varname}[{$k}][{$x}]\" value=\"{$z}\">\n";
                }
            }
        }
        echo "<a href=\"javascript://\" onclick=\"_08cms.vote.addVote(this,'{$varname}','{$min}','{$mode}')\">[" . lang('addvote') . "]</a>\n";
        echo "{$addstr}</td></tr>\n";
    }
}
Exemplo n.º 2
0
$url_type = 'repus';
include 'urlsarr.inc.php';
url_nav(lang('repurelate'), $urlsarr, 'grade');
if (!submitcheck('brepugradesedit')) {
    $itemstr = '';
    tabheader(lang('repugradeadmin'), 'repugradesedit', '?entry=repugrades', '7');
    trcategory(array(lang('id'), lang('repugrade') . lang('cname'), lang('rgbase'), lang('available'), lang('ico'), lang('preview')));
    $query = $db->query("SELECT * FROM {$tblprefix}repugrades ORDER BY rgid ASC");
    while ($row = $db->fetch_array($query)) {
        $rgid = $row['rgid'];
        $validstr = empty($invalid) && (!isset($oldvalue) || $row['rgbase'] > $oldvalue) ? 'Y' : '-';
        $oldvalue = $row['rgbase'];
        $invalid = $validstr != '-' ? false : true;
        $thumbstr = $row['thumb'] ? "<img src=\"" . view_atmurl($row['thumb']) . "\" height=\"18\">" : '';
        echo "<tr class=\"txtcenter txt\"><td class=\"txtC\">{$rgid}</td>\n" . "<td class=\"txtC\"><input type=\"text\" size=\"25\" name=\"repugradesnew[{$rgid}][cname]\" value=\"{$row['cname']}\"></td>\n" . "<td class=\"txtC\"><input type=\"text\" size=\"5\" name=\"repugradesnew[{$rgid}][rgbase]\" value=\"{$row['rgbase']}\"></td>\n" . "<td class=\"txtC\">{$validstr}</td>\n" . "<td class=\"txtC\">";
        echo singlemodule("repugradesnew[{$rgid}][thumb]", $row['thumb'], 'image');
        echo "</td>\n" . "<td class=\"txtC\">{$thumbstr}</td>\n" . "</tr>\n";
    }
    tabfooter('brepugradesedit', lang('modify'));
    a_guide('repugradesedit');
} else {
    $c_upload = new cls_upload();
    foreach ($repugradesnew as $rgid => $repugrade) {
        $repugrade['rgbase'] = intval($repugrade['rgbase']);
        $repugrade['cname'] = trim($repugrade['cname']);
        $sqlstr = "rgbase='{$repugrade['rgbase']}'";
        $repugrade['cname'] && ($sqlstr .= ",cname='{$repugrade['cname']}'");
        $repugrade['thumb'] = upload_s($repugrade['thumb'], @$repugrades[$rgid]['thumb'], 'image');
        if ($k = strpos($repugrade['thumb'], '#')) {
            $repugrade['thumb'] = substr($repugrade['thumb'], 0, $k);
        }