待辦事項 #6426

xoopstree.php makeMySelBox の機能拡張
啟用日期: 2005-07-28 09:26 最後更新: 2005-07-28 09:26

回報者:
負責人:
(無)
類型:
狀態:
開啟
元件:
(無)
里程碑:
(無)
優先權:
5 - 中
嚴重程度:
5 - 中
處理結果:
檔案:

細節

ちょっと使いにくいところがあるので、下記のように機能拡
張する

(1) echo を $text に変更。
(2) none のときの選択肢を "---" から任意にする

PHPコード
-----
function makeMySelBox($title,$order="",$preset_id=0,
$none=0, $sel_name="", $onchange="")
{
echo $this->makeMySelBox2($title, $order, $preset_id,
$none, $sel_name, $onchange, "---");
}

function makeMySelBox2($title, $order="", $preset_id=0,
$none=0, $sel_name="", $onchange="", $none_name="---")
{
if ( $sel_name == "" ) {
$sel_name = $this->id;
}
$myts =& MyTextSanitizer::getInstance();
$text = "<select name='".$sel_name."'";
if ( $onchange != "" ) {
$text .= " onchange='".$onchange."'";
}
$text .= ">\n";
$sql = "SELECT ".$this->id.", ".$title." FROM
".$this->table." WHERE ".$this->pid."=0";
if ( $order != "" ) {
$sql .= " ORDER BY $order";
}
$result = $this->db->query($sql);
if ( $none ) {
$text .= "<option value='0'>".$none_name."</option>\n";
}
while ( list($catid, $name) =
$this->db->fetchRow($result) ) {
$sel = "";
if ( $catid == $preset_id ) {
$sel = " selected='selected'";
}
$text .= "<option value='$catid'$sel>$name</option>\n";
$sel = "";
$arr = $this->getChildTreeArray($catid, $order);
foreach ( $arr as $option ) {
$option['prefix'] =
str_replace(".","--",$option['prefix']);
$catpath =
$option['prefix']."&nbsp;".$myts->makeTboxData4Show($option[$title]);
if ( $option[$this->id] == $preset_id ) {
$sel = " selected='selected'";
}
$text .= "<option
value='".$option[$this->id]."'$sel>$catpath</option>\n";
$sel = "";
}
}
$text .= "</select>\n";
return $text;
}
-----

Ticket History (0/0 Histories)

Attachment File List

No attachments

編輯

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » 登入