Location: PHPKode > projects > MyDB > mydatalib/execregistry.inc.php3
<?
/*************************************************************
 * The MyDB librairy and applications are product of SQLFusion
 * It may be used and/or distributed under the terms of the Q Public
 * License (QPL) version 1.0, enclosed in the file licence.txt.
 ****************************************************************/
/** MyDataLib Version 0.7    **/ 


   /*
    *  Class execregistry
    *  Its used by mydataform to translate db arrays
    *  into their actual form, including registry
    *  informations and current status, such as currency
    *  or language used by the web browser
    *   Authors : Philippe et David pour SQLFusion
    *   Version : 1.1.009 du 2000.03.30, 21:50
    *
   */

$language="fr";
$currency="frf";

Class ExecRegistry
{
 var $tbl_registry = "registry" ;        /* Name of the registry Table */
 var $db_registry ;        /* Name of the registry Table */
 var $table ;
 var $caracteristic;
 var $field ;
 var $optiontype ;
 var $list;
 var $language ;
 var $currency ;
 var $required ;
 var $default ;
 var $email ;
 var $hidden;
 var $readonly ;
 var $label ;
 var $picture ;
 var $showpicture ;
 var $categorie ;
 var $hidetable;
 var $datef ;
 var $access ;

 function getreg($dbc)
 {

   /* Getting information from the registry for all the types */
   $rregistry = mysql_db_query($dbc->db, "select rfield, rdata, rtype from $this->tbl_registry where rtable='$this->table' ", $dbc->id) ;
        if ($rregistry >0) {
              while (list($rfield, $rdata, $rtype) = mysql_fetch_row($rregistry)) {
                                 if ($this->{$rtype}[$rfield] == "") {
             $this->{$rtype}[$rfield]=$rdata ;
            }
           }
   }
 }

 function applyregistry($tname, $fname, $ftype, $fval, $dbc)
 {
  global $language,$currency;

    if(($this->language[$fname]) && ($this->language[$fname]<>$language))
     {
   $fval = "";
     } elseif ($this->caracteristic[$fname])
     {
         //   echo "unecaractéristique une !!!" ;
         $car = new Caract ;
         $fval = $car->getcaract($fval, $dbc) ;
      }
        elseif ($this->list[$fname])
    {
       list($tablename, $fielduniqid, $fielddisplay, $defaultvalue) = explode (":", $this->list[$fname]) ;
       $conl=new mydataconnect;
       $conl->id = $dbc->id ;
	   $conl->sql_order = "";
	   $conl->sql_pos = "" ;
	   $conl->db = $dbc->db ;
       $conl->sql_query="select $fielddisplay, $fielduniqid from $tablename where $fielduniqid='".$fval."'";
       $rlist = $conl->query() ;
       list($vfielddisplay, $vfielduniqid) = $conl->fetcharray($rlist) ;
       $fval=$vfielddisplay;
		
    } elseif (strlen($this->date[$fname])>0) {
   $fval = date($this->date[$fname], $fval);
      }
       elseif($this->currency[$fname])  /* Getting information from the registry for the field's currency */
       {
         $cf = new currency;
         $cf->name = $this->currency[$fname];
         $cf->getcurrency($dbc) ;
         $ct = new currency;
         $ct->name = $currency;
         $ct->getcurrency($dbc) ;
         $fval = $ct->printcurrency($dbc,(($cf->coef!=0)?($fval/$cf->coef):(0)));
        } elseif($this->picture[$fname]!="" && $fval!="")   /* Getting information from the registry for the pictures fields */
          {
            $fval="/$fval"; /** temporaire juste utilise pour fila ***/

            if ($this->showpicture[$fname]=="1" && $fval!="")   /* Getting information from the registry for the showpicture flag */
             {
     $width = ( ($tname=="category" && $fname=="simage" && $dbc->db=="podofrance") ? (" width='150'") : ("") );
        $fval="<img border='0' $width src='".trim($this->picture[$fname])."$fval'>";
   } else {
    $fval=trim($this->picture[$fname])."$fval";
   }
           }
  return $fval;
 }

 function fetch($result, $dbc)
 {
    $this->table = mysql_field_table($result,0);
    $this->db_registry = $dbc->db;
    $this->getreg($dbc) ;

  if($row = mysql_fetch_row($result))
  {
   for($i=0;$i<count($row);$i++)
   {
    $tname=mysql_field_table($result,$i);
    $fname=mysql_field_name($result,$i);
    $ftype=mysql_field_type($result,$i);
    if($fval=$this->applyregistry($tname, $fname, $ftype, $row[$i], $dbc))
      $rowOk[$fname]=$fval;
   }
   if(isset($rowOk)) return $rowOk;
  }
  return false;
 }

 function fetch_all($result, $dbc)
 {
  while($row=$this->fetch($result, $dbc)) $rows[]=$row;
  if($rows.count()>0) return $rows;
  else return false;
 }

}
?>
Return current item: MyDB