Ticket #6426

xoopstree.php makeMySelBox の機能拡張
Date d'ouverture: 2005-07-28 09:26 Dernière mise à jour: 2005-07-28 09:26

Rapporteur:
Propriétaire:
(Aucun)
État:
Ouvert
Composant:
(Aucun)
Jalon:
(Aucun)
Priorité:
5 - moyen
Sévérité:
5 - moyen
Résolution:
Aucun
Fichier:
Aucun

Détails

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

(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

Modifier

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