精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● PHP>>荷音 PHP 库>>HEYIN PHP扩展库 (2)

主题:HEYIN PHP扩展库 (2)
发信人: bb_rain()
整理人: tang(2001-01-31 09:00:37), 站内信件
<?

/*********************************************************************
*********

Html Module for PHP3 & PHP4 ( friend, v 1.00 )

Copyright (C) 2000 heyin.com, All Rights Reserved.
http://www.heyin.com
Rain ( Email: [email protected] Oicq: 1235686 )

cl_html.php, 2000/8/26

**********************************************************************
*********/


// Group Class

class Group {
var $Value;
var $Text;
var $IN;
var $RetVar;

function Group($GroupArray,$In="",$RetVar="") {
$count=sizeof($GroupArray);
for ($i=0;$i<$count;$i++) {
list($key,$val) = each($GroupArray);
$this->Value[$i] = $key;
      $this->Text[$i] = $val;
    }
    $this->RetVar = $RetVar;
    $this->IN = $In;
  }

  function Set($varname,$value) {
    $this->$varname=$value;
  }
}


// Text Group Class

class GroupText extends Group {
  var $Out;

  function OutText() {
    $count=sizeof($this->IN);
    $S = "\n ";
    for ($i=0;$i<$count;$i++) {
$this->Out[$i] = $this->Text[$this->IN[$i]];
    }
    $S.= implode(',', $this->Out);
    $S.= "\n";
    return $S;
  }
}


// Check Group Class

class GroupCheck extends Group {
  function OutText() {
    $count=sizeof($this->Text);
    $S = "\n";
    for ($i=0;$i<$count;$i++) {
$S .= " <INPUT NAME=\"".$this->RetVar."[]\" TYPE=\"checkbox\" VA
LUE=\"".$this->Value[$i]."\"";
      $S .= eregi($i,$this->IN) ? " checked" : "";
      $S .= ">".$this->Text[$i];
      $S .= "\n";
    }
    return $S;
  }
}


// Radio Group Class

class GroupRadio extends Group {
  function OutText() {
    $count=sizeof($this->Text);
    $S = "\n";
    for ($i=0;$i<$count;$i++) {
$S .= " <INPUT NAME=\"".$this->RetVar."\" TYPE=\"radio\" VALUE=\
"".$this->Value[$i]."\"";
      $S .= ($i==$this->IN) ? " checked" : "";
      $S .= ">".$this->Text[$i];
      $S .= "\n";
    }
    return $S;
  }
}


// Select Text Class

class SelectText extends Group {
  var $STYLE;

  function OutText() {
    $S .= "\n <SELECT NAME=\"".$this->RetVar."\"";
    $S .= ($this->STYLE) ? " STYLE=\"".$this->STYLE."\"" : "";
    $S .= ">\n";
    $count=sizeof($this->Text);
    for ($i=0;$i<$count;$i++) {
$S .= " <OPTION VALUE=\"".$this->Value[$i]."\"";
      $S .= ($i==$this->IN)  ? " selected" : "";
      $S .= ">".$this->Text[$i]."</OPTION>\n";
    }
    $S .= " </SELECT>\n";
    return $S;
  }
}


// Select Num Class

class SelectNum extends Group {
  var $STYLE;

  function OutText() {
    $S .= "\n <SELECT NAME=\"".$this->RetVar."\"";
    $S .= ($this->STYLE) ? " STYLE=\"".$this->STYLE."\"" : "";
    $S .= ">\n";
    $S .= ($this->Text[0]==0) ? "  <OPTION VALUE=\"0\"></OPTION>\n" : 
"";
    for ($i=$this->Text[1];$i<=$this->Text[2];$i++) {
      $S .= "  <OPTION VALUE=\"$i\"";
$S .= ($i==$this->IN)  ? " selected" : "";
      $S .= ">$i</OPTION>\n";
    }
    $S .= " </SELECT>\n";
    return $S;
  }
}


// Page Class

class Page {
  var $Total;
  var $Show;

  var $PAGE_MAX;

  function Page() {
    global $show,$TOTAL,$PAGE_MAX;

    $this->Total = $TOTAL;
    $this->Show = ($Show>0) ? $Show : 1;
    $this->PAGE_MAX = $PAGE_MAX;
  }

  function OutText() {
    global $PHP_SELF;

    $page= ($this->Total>$this->PAGE_MAX) ? ceil($this->Total/$this->P
AGE_MAX) : 1;

    $prev= $this->Show - 1;
    $next= $this->Show + 1;

    $S = ($prev>0) ? "<A href=\"$PHP_SELF?show=$prev\">上一页 -" :
 "";
    $S.= " [ 第 ";
    for ($i=1;$i<=$page;$i++) {
$S.= ($i==$this->Show) ? "<FONT COLOR=\"red\">$i" : "<A h
ref=\"$PHP_SELF?show=$i\">$i";
      $S.= " \n";
    }
    $S.= " 页 ] ";
    $S.= ($next<$page) ? "- <A href=\"$PHP_SELF?show=$next\">下一页>" : "";
    return $S;
  }
}

?>

--
HEYIN 软件 http://www.heyin.com  
虚拟社区,聊天室,交友程序,网上超市,电子商务 ...

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 61.133.178.72]

[关闭][返回]