[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/adodb_lite/generic_modules/ -> menu_module.inc (source)

   1  <?php
   2  // Generic Menu Module

   3  
   4  eval('class menu_EXTENDER extends ' . $last_module . '_ADOConnection { }');
   5  
   6  class menu_ADOConnection extends menu_EXTENDER
   7  {
   8  }
   9  
  10  eval('class menu_resultset_EXTENDER extends ' . $last_module . '_ResultSet { }');
  11  
  12  class menu_ResultSet extends menu_resultset_EXTENDER
  13  {
  14      // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM

  15  	function GetMenu($name, $defstr='', $blank1stItem=true, $multiple=false, $size=0, $selectAttr='', $compareFields0=true)
  16      {
  17          $hasvalue = false;
  18  
  19          if($multiple or is_array($defstr))
  20          {
  21              if($size==0)
  22                  $size=5;
  23              $attr = ' multiple size="'.$size.'"';
  24              if(!strpos($name,'[]'))
  25                  $name .= '[]';
  26          }
  27          else if($size)
  28              $attr = ' size="'.$size.'"';
  29          else $attr ='';
  30  
  31          $s = '<select name="'.$name.'"'.$attr.' '.$selectAttr.'>';
  32          if($blank1stItem) 
  33              if(is_string($blank1stItem))
  34              {
  35                  $barr = explode(':',$blank1stItem);
  36                  if(sizeof($barr) == 1)
  37                      $barr[] = '';
  38                  $s .= "\n<option value=\"".$barr[0]."\">".$barr[1]."</option>";
  39              } else $s .= "\n<option></option>";
  40  
  41          if($this->FieldCount() > 1)
  42              $hasvalue=true;
  43          else $compareFields0 = true;
  44  
  45          $value = '';
  46          $optgroup = null;
  47          $firstgroup = true;
  48          $fieldsize = $this->FieldCount();
  49          while(!$this->EOF)
  50          {
  51              $zval = rtrim(reset($this->fields));
  52  
  53              if($blank1stItem && $zval=="")
  54              {
  55                  $this->MoveNext();
  56                  continue;
  57              }
  58  
  59              if($fieldsize > 1)
  60              {
  61                  if(isset($this->fields[1]))
  62                      $zval2 = rtrim($this->fields[1]);
  63                  else
  64                      $zval2 = rtrim(next($this->fields));
  65              }
  66              $selected = ($compareFields0) ? $zval : $zval2;
  67  
  68              $group = '';
  69              if($fieldsize > 2)
  70              {
  71                  $group = rtrim($this->fields[2]);
  72              }
  73  
  74              if($optgroup != $group)
  75              {
  76                  $optgroup = $group;
  77                  if($firstgroup)
  78                  {
  79                      $firstgroup = false;
  80                      $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
  81                  }
  82                  else
  83                  {
  84                      $s .="\n</optgroup>";
  85                      $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
  86                  }
  87              }
  88  
  89              if($hasvalue) 
  90                  $value = " value='".htmlspecialchars($zval2)."'";
  91  
  92              if(is_array($defstr))
  93              {
  94                  if(in_array($selected,$defstr))
  95                      $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
  96                  else 
  97                      $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
  98              }
  99              else
 100              {
 101                  if(strcasecmp($selected,$defstr)==0) 
 102                      $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
 103                  else
 104                      $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
 105              }
 106              $this->MoveNext();
 107          } // while

 108  
 109          // closing last optgroup

 110          if($optgroup != null)
 111          {
 112              $s .= "\n</optgroup>";
 113          }
 114          return $s ."\n</select>\n";
 115      }
 116  
 117  	function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='')    
 118      {
 119          return $this->GetMenu($name, $defstr, $blank1stItem, $multiple, $size, $selectAttr, false);
 120      }
 121  
 122  	function GetMenu3($name, $defstr='', $blank1stItem=true, $multiple=false, $size=0, $selectAttr='')
 123      {
 124          $hasvalue = false;
 125  
 126          if($multiple or is_array($defstr))
 127          {
 128              if($size==0)
 129                  $size=5;
 130              $attr = ' multiple size="'.$size.'"';
 131              if(!strpos($name,'[]'))
 132                  $name .= '[]';
 133          }
 134          else if($size)
 135              $attr = ' size="'.$size.'"';
 136          else $attr ='';
 137  
 138          $s = '<select name="'.$name.'"'.$attr.' '.$selectAttr.'>';
 139          if($blank1stItem) 
 140              if(is_string($blank1stItem))
 141              {
 142                  $barr = explode(':',$blank1stItem);
 143                  if(sizeof($barr) == 1)
 144                      $barr[] = '';
 145                  $s .= "\n<option value=\"".$barr[0]."\">".$barr[1]."</option>";
 146              } else $s .= "\n<option></option>";
 147  
 148          if($this->FieldCount() > 1)
 149              $hasvalue=true;
 150          else $compareFields0 = true;
 151  
 152          $value = '';
 153          $optgroup = null;
 154          $firstgroup = true;
 155          $fieldsize = sizeof($this->fields);
 156          while(!$this->EOF)
 157          {
 158              $zval = rtrim(reset($this->fields));
 159  
 160              if($blank1stItem && $zval=="")
 161              {
 162                  $this->MoveNext();
 163                  continue;
 164              }
 165  
 166              if($fieldsize > 1)
 167              {
 168                  if(isset($this->fields[1]))
 169                      $zval2 = rtrim($this->fields[1]);
 170                  else
 171                      $zval2 = rtrim(next($this->fields));
 172              }
 173              $selected = ($compareFields0) ? $zval : $zval2;
 174  
 175              $group = '';
 176              if(isset($this->fields[2]))
 177              {
 178                  $group = rtrim($this->fields[2]);
 179              }
 180  
 181              if($optgroup != $group)
 182              {
 183                  $optgroup = $group;
 184                  if($firstgroup)
 185                  {
 186                      $firstgroup = false;
 187                      $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
 188                  }
 189                  else
 190                  {
 191                      $s .="\n</optgroup>";
 192                      $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
 193                  }
 194              }
 195  
 196              if($hasvalue) 
 197                  $value = " value='".htmlspecialchars($zval2)."'";
 198  
 199              if(is_array($defstr))
 200              {
 201                  if(in_array($selected,$defstr))
 202                      $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
 203                  else 
 204                      $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
 205              }
 206              else
 207              {
 208                  if(strcasecmp($selected,$defstr)==0) 
 209                      $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
 210                  else
 211                      $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
 212              }
 213              $this->MoveNext();
 214          } // while

 215  
 216          // closing last optgroup

 217          if($optgroup != null)
 218          {
 219              $s .= "\n</optgroup>";
 220          }
 221          return $s ."\n</select>\n";
 222      }
 223  
 224  }
 225  
 226  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7