Source for file DBMS_FIELD_MEDIA.phpclass

Documentation is available at DBMS_FIELD_MEDIA.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_MEDIA.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   int
  8.   *
  9.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @version $Id: DBMS_FIELD_MEDIA.phpclass,v 1.3 2008/11/19 15:00:37 peterkrebs Exp $
  13.   */
  14.  
  15. pcf_require_class('DBMS_FIELD_FOREIGNKEY',dirname(__FILE__)."/");  
  16. require_once __OCSP_DEFAULTCONFPATH__."media.conf.phpinc";
  17.  
  18.  
  19. /**
  20.   * handles foreign keys to media files
  21.   *
  22.   * @project    Open CSP-Management
  23.   * @package    dbms_field
  24.   * @category   int
  25.   *
  26.   * @author     Peter Krebs (pk) <p.krebs@lvus.at>
  27.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  28.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  29.   *
  30.   ***/
  31.     var $className          = "MEDIAFILE";
  32.     var $foreignTbl         = "T_MED_FILES";
  33.     var $showField          = "CONCAT(MEF_NAME,' (',MEC_ID,'/',MEF_ID,')')";
  34.     var $keyField           = "MEF_ID";
  35.     var $sortField          = "MEF_NAME";
  36.     var $allowNullSelect    = False;
  37.  
  38.     var $rootMEC_ID         =0;
  39.     var $defaultMEC_ID      =0;
  40.  
  41.     /**
  42.         * source file of the class
  43.         *
  44.         * @var string $classSrcFile 
  45.         * @since pk-05-02-19
  46.         ***/
  47.     var $classSrcFile=__FILE__;    
  48.  
  49.     /**
  50.       * show the filed definition form
  51.       *
  52.       * @param bool $showSize       show size input
  53.       * @param bool $showSortFld    show Select-List sortfield input
  54.       * @param bool $showDBFld      show Table Selector for Foreign TABL and KEY,VALUE input fields
  55.       *
  56.       * @version pk-03-10-17
  57.       ***/
  58.     function editTblForm($showSize=False,$showSortFld=False,$showDBFld=False,$showNewEdit=False{
  59.         global $USRDB;
  60.  
  61.         parent::editTblForm($showSize,$showSortFld,$showDBFld,$showNewEdit);
  62.  
  63.         require_once $GLOBALS['MED']['PHPINCPATH']."MED_CATEGORY.phpclass";
  64.  
  65.         $mecTree=new MED_CATEGORY();
  66.         $mecTree->populateTree(True,$debug);
  67.         ?>
  68.             <tr>
  69.                 <td class="fldName">
  70.                     Wurzelkategorie
  71.                 </td>
  72.                 <td>
  73.                     <select name="rootMEC_ID" size="1">
  74.                         <option value="0">Wurzel</option>
  75.                         <?php echo $mecTree->getHTMLSelectOptionList(NULL,$this->rootMEC_ID,$debug)?>
  76.                     </select>
  77.                 </td>
  78.             </tr>
  79.             <tr>
  80.                 <td class="fldName">
  81.                     Default Kategorie
  82.                 </td>
  83.                 <td>
  84.                     <select name="defaultMEC_ID" size="1">
  85.                         <option value="0">Wurzel</option>
  86.                         <?php echo $mecTree->getHTMLSelectOptionList(NULL,$this->defaultMEC_ID,$debug)?>
  87.                     </select>
  88.                 </td>
  89.             </tr>
  90.         <?php
  91.  
  92.     }
  93.  
  94.     function DBcheckEditInput($str{
  95.         $ret="";
  96.         if (!empty($str)) {
  97.             if ($arr=explode(';',$str)) {
  98.                 $ret=$arr[0];
  99.             }
  100.         }   
  101.         return $ret;
  102.     }
  103.  
  104.     /**
  105.       * save the filed definition form
  106.       *
  107.       * @return bool <code>parent::save()</code>
  108.       * @version pk-03-10-17
  109.       *
  110.       ***/
  111.     function save($debug=False{
  112.         $ret=parent::save($debug);
  113.  
  114.         /* done in parent
  115.         $this->reloadFormOnChange   =False;
  116.         $this->allowNullSelect      =(intval($_POST['allowNullSelect']) ? True : False );
  117.         $this->nullLabel            =$_POST['NULLLABEL'];
  118.         */
  119.  
  120.         $this->foreignTbl           = "MEDIAFILE";
  121.         $this->showField            = "T_MED_FILES";
  122.         $this->keyField             = "CONCAT(MEF_NAME,' (',MEC_ID,'/',MEF_ID,')')";
  123.         $this->whereAnd             "MEF_ID";
  124.         $this->sortField            = "MEF_NAME";
  125.  
  126.         $this->newUrl               = "";
  127.         $this->newWndWidth          0;
  128.         $this->newWndHeight         0;
  129.  
  130.         $this->editUrl              = "";
  131.         $this->editWndWidth         0;
  132.         $this->editWndHeight        0;
  133.         $this->editEnableInList     = False;
  134.  
  135.         $this->myURIQueryArrgs      ="";
  136.  
  137.         $this->rootMEC_ID           = intval($_POST['rootMEC_ID']);
  138.         $this->defaultMEC_ID        = intval($_POST['defaultMEC_ID']);
  139.  
  140.         return $ret;
  141.     }
  142.  
  143.     // ###########################################
  144.  
  145.     function getSelectStmt($debug=False{
  146.         $ret "SELECT ".$this->showField." AS SHOWFIELD";
  147.         $ret.= ",".$this->keyField." AS KEYFIELD";
  148.         $ret.= " FROM ".$this->foreignTbl;
  149.         if ($debugecho "<pre>$ret</pre>";
  150.         return $ret;
  151.     }
  152.  
  153.     function getWhereStmt($arrName="DBVAL",$append="",$debug=False{
  154.         global ${$arrName};
  155.         if ($debugecho "<hr /><p><b>DBMS_FIELD_MEDIA::getWhereStmt($arrName,$append,$debug)</b></p><blockquote>";
  156.         if ($debugecho "<pre>$arrName:\n";print_r(${$arrName});echo "</pre>";}
  157.         require_once $GLOBALS['PROJECT']['PHPINCPATH']."common/pcf_templates.phpinc";
  158.         $wKey=pcf_tmpl_parse(trim($this->whereAnd),${$arrName},$debug);
  159.         if ($debugecho "<pre>2:\n$wKey</pre>";
  160.         $where=" WHERE ";
  161.         $ret="";
  162.         if (!empty($wKey)) {
  163.              $ret $where.$wKey;
  164.              $where=" AND ";
  165.         }
  166.         if (!empty($append)) {
  167.             $ret .= $where.$append;
  168.         }
  169.         if ($debugecho "<pre>3:\n$ret</pre>";
  170.         if ($debugecho "</blockquote>";
  171.         return $ret;
  172.     }        
  173.  
  174.     // ###########################################
  175.  
  176.     /**
  177.       * echos a link to open a new window
  178.       *
  179.       * as we don't know the keys of the row
  180.       * we add each integer value of the ${$arrName}
  181.       * as get param to the link url
  182.       *
  183.       * @param string $arrName  name of the GLOBAL array holding the row values
  184.       *
  185.       ***/
  186.     function echoAddButton($arrName="DBVAL"{
  187.         global ${$arrName},$frmReloadURL;
  188.         if (empty($frmReloadURL)) {
  189.             $frmReloadURL=$_SERVER['REQUEST_URI'];
  190.         }
  191.         if (!empty($this->newUrl)) {
  192.             $url=$this->newUrl . (strstr($this->newUrl,"?""&" "?""OPENERURL=".base64_encode($frmReloadURL);
  193.             $url.="&FIELD=".$arrName."[".$this->myName."]";
  194.             reset(${$arrName});
  195.  
  196.             if (!empty($this->myURIQueryArrgs)) {
  197.                 $qaLst=explode(";",$this->myURIQueryArrgs);
  198.                 foreach($qaLst as $key{
  199.                     $url.="&$key=".${$arrName}[$key];
  200.                 }
  201.             else {
  202.                 while(list($key,$val)=each(${$arrName})) {
  203.                     if (($key != $this->myName&& (intval($val)) && (!is_array($val))) $url.="&$key=$val";
  204.                 }
  205.             }
  206.  
  207.             ?>
  208.                 <a href="javascript:{
  209.                         var opt_<?php echo $this->myName?>='width=<?php echo $this->newWndWidth?>,height=<?php echo $this->newWndHeight?>,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';
  210.                         var url_<?php echo $this->myName?>='<?php echo $url."&".$this->myName?>='+getSelectedOptionByName(document.forms[0],'<?php echo $arrName."[".$this->myName."]"?>');
  211.                         hWnd_<?php echo $this->myName?>=window.open(url_<?php echo $this->myName?>,'<?php echo $this->myName?>', opt_<?php echo $this->myName?>);
  212.                         hWnd_<?php echo $this->myName?>.focus();
  213.                     }"><img src="<?php echo $GLOBALS['PROJECT']['SYSIMGURL']?>icons-22x22/edit_add.png" border="0" alt="hinzuf�gen" width="18" height="18"></a>
  214.             <?php
  215.         }
  216.     }
  217.  
  218.     function echoZoomButton($arrName="DBVAL"{
  219.         global ${$arrName},$frmReloadURL;
  220.         if (empty($frmReloadURL)) {
  221.             $frmReloadURL=$_SERVER['REQUEST_URI'];
  222.         }
  223.         if (!empty($this->editUrl)) {
  224.             $url=$this->editUrl . (strstr($this->editUrl,"?""&" "?""OPENERURL=".base64_encode($frmReloadURL);
  225.             $url.="&FIELD=".$arrName."[".$this->myName."]";
  226.             reset(${$arrName});
  227.             if (!empty($this->myURIQueryArrgs)) {
  228.                 $qaLst=explode(";",$this->myURIQueryArrgs);
  229.                 foreach($qaLst as $key{
  230.                     $url.="&$key=".${$arrName}[$key];
  231.                 }
  232.             else {
  233.                 while(list($key,$val)=each(${$arrName})) {
  234.                     if (($key != $this->myName&& (intval($val)) && (!is_array($val))) $url.="&$key=$val";
  235.                 }
  236.             }
  237.             ?>
  238.                 <a href="javascript:{
  239.                         var e_opt_<?php echo $this->myName?>='width=<?php echo $this->editWndWidth?>,height=<?php echo $this->editWndHeight?>,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';
  240.                         var e_url_<?php echo $this->myName?>='<?php echo $url."&".$this->myName?>='+getSelectedOptionByName(document.forms[0],'<?php echo $arrName."[".$this->myName."]"?>');
  241.                         hWnd_<?php echo $this->myName?>=window.open(e_url_<?php echo $this->myName?>,'<?php echo $this->myName?>', e_opt_<?php echo $this->myName?>);
  242.                         hWnd_<?php echo $this->myName?>.focus();
  243.                     }"><img src="<?php echo $GLOBALS['PROJECT']['SYSIMGURL']?>icons-22x22/viewmag.png" border="0" alt="bearbeiten" width="18" height="18"></a>
  244.             <?php
  245.         }
  246.     }
  247.  
  248.     function echoReloadButton($arrName="DBVAL"{
  249.         global $frmReloadURL;
  250.         if (empty($frmReloadURL)) {
  251.             $frmReloadURL=$_SERVER['REQUEST_URI'];
  252.         }
  253.         if ($this->reloadFormOnChange{
  254.             echo "<span class=\"button\"><a href=\"javascript:{document.forms[0].action='".$frmReloadURL."';document.forms[0].submit();}\">";
  255.             echo "<img src=\"".$GLOBALS['PROJECT']['SYSIMGURL']."icons-22x22/reload.png\" border=\"0\" alt=\"refresh form\"  width=\"18\" height=\"18\">";
  256.             echo "</a></span>";
  257.         }
  258.     }
  259.  
  260.     function echoSelectStart($arrName{
  261.         global $frmReloadURL;
  262.         if (empty($frmReloadURL)) {
  263.             $frmReloadURL=$_SERVER['REQUEST_URI'];
  264.         }
  265.         echo "\n\n<select name=\"".$arrName."[".$this->myName."]\"";
  266.         if ($this->reloadFormOnChange{
  267.             echo " onChange=\"document.forms[0].action='".$frmReloadURL."#".$this->myName."';document.forms[0].submit();\"";
  268.         }
  269.         echo ">\n";
  270.     }
  271.  
  272.     /**
  273.       * echos the select option list
  274.       *
  275.       * the query is created by:
  276.       * <code>
  277.       * $query=$this->getSelectStmt().$this->getWhereStmt();
  278.       * if ($this->sortField) $query.= " ORDER BY ".$this->sortField;
  279.       * else $query .=" ORDER BY SHOWFIELD";
  280.       * </code>
  281.       * if the query does not return a row the select statement
  282.       * is echoed as html comment (<!-- $query -->)
  283.       *
  284.       * @param mixed $aValue current value to set as selected
  285.       * @param bool  $debug  show debug info
  286.       *
  287.       ***/
  288.     function echoSelectOptionLst($aValue="",$debug=False{
  289.         $query=$this->getSelectStmt().$this->getWhereStmt();
  290.         if ($this->sortField$query.= " ORDER BY ".$this->sortField;
  291.         else $query .=" ORDER BY SHOWFIELD";
  292.  
  293.         if ($debugecho "<pre>$query</pre>";
  294.         $count=0;
  295.         if ($cursor=$GLOBALS['USRDB']->query($query)) {
  296.             while($row=$cursor->fetchArray()) {
  297.                 echo "\t<option value=\"".$row['KEYFIELD']."\"";
  298.                 if ($aValue==$row['KEYFIELD']echo " selected";
  299.                 echo ">".$row['SHOWFIELD']."</option>\n";
  300.                 $count++;
  301.             }
  302.             $cursor->free();
  303.         }
  304.         if (!$count{
  305.             echo "\n<!-- $query -->\n";
  306.         }
  307.  
  308.     }
  309.  
  310.     /**
  311.       * echos a select box
  312.       *
  313.       * is overritten here because echoSelectOptionLst requires
  314.       * an aditional parameter
  315.       *
  316.       * for $arrName see {@link DBMS_FIELD::writeField()}
  317.       *
  318.       * calls the following functions:
  319.       *
  320.       * - calls $this->echoSelectStart()
  321.       * - echos NULL option with html code
  322.       * - calls $this->SelectOptionLst()
  323.       * - echos </select>
  324.       * - calls $this->echoAddButton()
  325.       * - calls $this->echoReloadButton()
  326.       *
  327.       * @param mixed    $aValue    selected value
  328.       * @param string   $arrName   array in Name of the html input form <input name=ARRNAME[FIELDNAME]>
  329.       * @param bool     $debug     show debug info
  330.       *
  331.       * @return bool    always True
  332.       *
  333.       * @version        pk-03-10-19
  334.       *
  335.       ***/      
  336.     function echoSelect($aValue="",$arrName="DBVAL",$debug=False{
  337.         /* <pk-03-10-19> */
  338.         if ($debugecho "<hr /><p><b>DBMS_FIELD_MEDIA::echoSelect($aValue,$arrName,$debug)</b></p><blockquote>";
  339.  
  340.         if (empty($arrName)) $arrName=$this->myTableAlias;
  341.         $this->myDataArrName = $arrName;
  342.         /* </pk-03-10-19> */
  343.                 
  344.         $this->echoSelectStart($arrName);
  345.         if ($this->allowNullSelect {
  346.             echo "<option value=\"".$this->defaultValue."\">".$this->nullLabel."</option>\n";
  347.         }        
  348.         $this->echoSelectOptionLst($aValue,$debug);
  349.         echo "</select>\n\n";
  350.  
  351.         $this->echoAddButton($arrName);
  352.         $this->echoZoomButton($arrName);
  353.         $this->echoReloadButton($arrName="DBVAL");
  354.  
  355.         echo $this->getAddTag($arrName);
  356.  
  357.         if ($debugecho "</blockquote><hr />";
  358.         return True;
  359.     }
  360.  
  361.  
  362.     // ###########################################
  363.  
  364.     /**
  365.       * html output of the field
  366.       *
  367.       * echos the field due to $mode
  368.       * - FRM_MODE_READONLY echos
  369.       *     $this->getScreenValue()
  370.       *     $this->getAddTag()
  371.       *
  372.       * - FRM_MODE_LIST echos
  373.       *     $this->getScreenValue()
  374.       *
  375.       * - FRM_MODE_EDIT calls
  376.       *     $this->echoSelect()
  377.       *
  378.       * - FRM_MODE_NEW calls
  379.       *     $this->echoSelect()
  380.       *
  381.       * - FRM_MODE SEARCH outputs
  382.       *     <code>
  383.       *         $this->echoSelectStart($arrName."[VALUE]");
  384.       *         echo "<option value=\"\">---???---</option>\n";
  385.       *         if (!$this->allowNullSelect) {
  386.       *             echo "<option value=\"".$this->treeROOTKey."\">".$this->nullLabel."</option>\n";
  387.       *         }
  388.       *         $this->echoSelectOptionLst(NULL,$debug);
  389.       *         echo "</select>\n\n";
  390.       *     </code>
  391.       *
  392.       *
  393.       * @param int      $mode       show mode of the field
  394.       * @param mixed    $aValue     value of the field
  395.       * @param string   $arrName    array in Name of the html input form <input name=ARRNAME[FIELDNAME]>
  396.       *                              it also needs to be a global array global ${$arrName}
  397.       * @param boolean  $debug      show debug info
  398.       *
  399.       * @return True if an input field is written
  400.       *
  401.       * @version pk-03-10-19
  402.       * @version pk-05-09-05
  403.       *
  404.       ***/
  405.     function writeField($mode,$aValue="",$arrName="DBVAL",$debug=False{
  406.         /* <pk-03-10-19> */
  407.         if ($debugecho "<hr /><p><b>DBMS_FIELD_MEDIA::writeField($mode,$aValue,$arrName,$debug)</b></p>";
  408.  
  409.         if (empty($arrName)) $arrName=$this->myTableAlias;
  410.  
  411.         if ($arrName != $this->myDataArrName)
  412.             $this->myDataArrName = $arrName;
  413.         /* </pk-03-10-19> */
  414.  
  415.         global ${$arrName};
  416.  
  417.  
  418.         switch($mode{
  419.             case FRM_MODE_READONLY:
  420.                 echo $this->getScreenValue($aValue,$arrName,$debug);
  421.                 echo $this->getAddTag($arrName);
  422.                 return False;
  423.             case FRM_MODE_LIST:
  424.                 echo $this->getScreenValue($aValue,$arrName,$debug);
  425.                 return False;
  426.             case FRM_MODE_HIDDEN:
  427.                 return parent::writeField(FRM_MODE_HIDDEN,$aValue,$arrName,$debug);
  428.             case FRM_MODE_NEW:
  429.                 if ($this->enableNew{
  430.                     return $this->echoSelect($aValue,$arrName,$debug);
  431.                 }
  432.                 $this->writeField(FRM_MODE_READONLY,$aValue,$arrName,$debug);
  433.                 return parent::writeField(FRM_MODE_HIDDEN,$aValue,$arrName,$debug);
  434.             case FRM_MODE_COPY// <pk-05-09-05>
  435.                 if ($this->enableCopy{
  436.                     return $this->echoSelect($aValue,$arrName,$debug);
  437.                 }
  438.                 $this->writeField(FRM_MODE_READONLY,$aValue,$arrName,$debug);
  439.                 return parent::writeField(FRM_MODE_HIDDEN,$aValue,$arrName,$debug);
  440.             case FRM_MODE_EDIT:
  441.                 if ($this->enableEdit{
  442.                     return $this->echoSelect($aValue,$arrName,$debug);
  443.                 }
  444.                 $this->writeField(FRM_MODE_READONLY,$aValue,$arrName,$debug);
  445.                 return parent::writeField(FRM_MODE_HIDDEN,$aValue,$arrName,$debug);
  446.             case FRM_MODE_SEARCH:
  447.                 /* <pk-04-02-25 /> */
  448.                 ?>
  449.                     <select name="<?php echo $arrName."[".$this->myName."]"?>[ANDOR]">
  450.                         <option value="">---</option>
  451.                         <option value="AND">UND</option>
  452.                         <option value="OR">ODER</option>
  453.                     </select>
  454.                     <input name="<?php echo $arrName."[".$this->myName."]"?>[COMPTYPE]" value="=" type="hidden"> =
  455.                     <select name="<?php echo $arrName."[".$this->myName."]"?>[VALUE]" size="1">
  456.                         <option value="">---???---</option>
  457.                 <?php
  458.                 $this->echoSelectOptionLst(NULL,$debug);
  459.                 echo "</select>\n\n";
  460.                 return True;
  461.             default:
  462.                 return parent::writeField($mode,$aValue,$arrName);
  463.         }
  464.     }
  465.  
  466.     // ################################################
  467.     // SEARCH FORM METHODS
  468.     // ################################################
  469.  
  470.  
  471.     function writeSearchCompTypes($arrName{
  472.         echo "<select name=\"".$arrName."[".$this->myName."][COMPTYPE]\">";
  473.         echo "  <option value=\"=\">=</option>";
  474.         echo "  <option value=\"<>\">&lt;&gt;</option>";
  475.         echo "</select>";
  476.     }
  477.  
  478.     /**
  479.       * returns the where statement part for the field
  480.       *
  481.       * @param array $aArr  form input array
  482.       * @param bool $debug 
  483.       *
  484.       * @return string 
  485.       *
  486.       ***/
  487.     function searchWhere($aArr,$debug=False{
  488.         if ($debug{
  489.             echo "<p><b>DBMS_FIELD_MEDIA::searchWhere($aArr,$debug)</b> (".get_class($this).")</p>";
  490.             echo "<blockquote><pre>";print_r($aArr);echo "</pre></blockquote>";
  491.         }
  492.         if (!is_array($aArr)) return "";
  493.         if (empty($aArr['ANDOR'])) return "";
  494.         $ret=($aArr['ANDOR'== "OR" " OR " " AND ");
  495.         $ret.=$this->myTable.".".$this->myName/* <pk-04-02-25 /> */
  496.         if ((is_array($aArr['VALUE'])) && (sizeof($aArr['VALUE']))) {
  497.             switch($aArr['COMPTYPE']// check input
  498.                 case "<>":
  499.                     $ret.=" NOT IN( ";
  500.                     break;
  501.                 default:
  502.                     $ret.=" IN( ";
  503.             }
  504.             $sep="";
  505.             foreach($aArr['VALUE'as $val{
  506.                 if (empty($val)) return "";
  507.                 $ret.= $sep.$val;
  508.                 $sep=",";
  509.             }
  510.             $ret.=")";
  511.             return $ret;
  512.         else {
  513.             if (intval($aArr['VALUE'])) {
  514.                 switch($aArr['COMPTYPE']// check input
  515.                     case "<>":
  516.                         $ret.=" <> ";
  517.                         break;
  518.                     default:
  519.                         $ret.=" = ";
  520.                 }
  521.                 return $ret.intval($aArr['VALUE']);
  522.             else {
  523.                 return "";
  524.             }
  525.         }
  526.     }
  527.  
  528.  
  529.     // ###########################################################
  530.     // OBJECT VALUE CHECK/RETURN METHODS
  531.     // ###########################################################
  532.  
  533.     /**
  534.       * get the link url for a list entry
  535.       *
  536.       * as we don't know the keys of the row
  537.       * we add each integer value of the ${$arrName}
  538.       * as get param to the link url
  539.       *
  540.       * @param mixed $aValue value of the db field
  541.       * @param string $arrName  name of the GLOBAL array holding the row values
  542.       *
  543.       * @return string empty if no link is to show a <a href=...url..> if the field is linked
  544.       *
  545.       * @version pk-03-10-17
  546.       *
  547.       ***/
  548.     function getListLink($aValue,$arrName="DBVAL"{
  549.         global ${$arrName};
  550.         if ((!empty($aValue)) && (!empty($this->editUrl)) && ($this->editEnableInList)) {
  551.             $url=$this->editUrl . (strstr($url,"?""&" "?""OPENERURL=".base64_encode($_SERVER['REQUEST_URI']);
  552.             $url.="&FIELD=".$arrName."[".$this->myName."]";
  553.             reset(${$arrName});
  554.             while(list($key,$val)=each(${$arrName})) {
  555.                 if (($key != $this->myName&& (intval($val))) $url.="&$key=".intval($val);
  556.             }
  557.             $ret="<a href=\"javascript:{
  558.                         var opt_".$this->myName."='width=".$this->editWndWidth.",height=".$this->editWndHeight.",toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';
  559.                         var url_".$this->myName."='".$url."&".$this->myName."=".pcf_makeJS_QuotedString($aValue,"'")."';
  560.                         hWnd_".$this->myName."=window.open(url_".$this->myName.",'".$this->myName."', opt_".$this->myName.");
  561.                         hWnd_".$this->myName.".focus();
  562.                     }\">";
  563.             return $ret;
  564.         else {
  565.             return "";
  566.         }
  567.  
  568.     }
  569.  
  570.  
  571.     function getScreenValue($aValue,$arrName="DBVAL",$debug=False{
  572.         global ${$arrName};
  573.  
  574.         $query=$this->getSelectStmt().$this->getWhereStmt($arrName,$this->keyField."=".intval($aValue),$debug);
  575.         if ($debugecho "<pre>$query</pre>";
  576.         if ($row=$GLOBALS['USRDB']->quickQuery($query)) {
  577.             if ($debug{echo "<pre>";print_r($row);echo "</pre>";}
  578.             return $row['SHOWFIELD'];
  579.         }
  580.         else if (!empty($aValue)) return $aValue."<!--\n\t$query \n-->";
  581.         return $this->nullLabel;
  582.     }
  583.  
  584.  
  585.     /**
  586.       * returns the field value if the referenzed row exists
  587.       *
  588.       * @param  string  $aValue     the value
  589.       * @param  array   $err        error array
  590.       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName}
  591.       * @param  bool    $debug 
  592.       *
  593.       * @return string 
  594.       *
  595.       * @since   pk-03-12-13
  596.       * @version pk-03-12-13
  597.       *
  598.       ***/
  599.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=False{
  600.         if ($debugecho "<hr><p><b>DBMS_FIELD_MEDIA::getValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)." | ".$this->myName.")</p>";
  601.         if (empty($aValue)) {
  602.             // if ($aValue == "0") {
  603.             if ($this->allowNullSelectreturn "0";
  604.             if ($this->allowNull()) {
  605.                 return NULL;
  606.             else {
  607.                 $err['ERROR']=True;
  608.                 $err[$this->myName]['MSG']=(empty($this->nullErrMsg"NULL_NOT_ALLOWED" $this->nullErrMsg);
  609.                 $err[$this->myName]['LABEL']=$this->label;
  610.                 if ($debug{echo "<pre style=\"font-color:red;font-weight:bolder\">";print_r($err);echo "</pre>";}
  611.                 return False;
  612.             }
  613.         }
  614.  
  615.         if ((!empty($aValue)) && ($aValue == $this->getDefaultValue($debug))) {
  616.             // no need to check
  617.             return $aValue;
  618.         }
  619.  
  620.         $query =$this->getSelectStmt();
  621.         $query.=$this->getWhereStmt($arrName,$this->keyField."=".intval($aValue),$debug);
  622.         if ($GLOBALS[$this->getGlobalDBObjIdx()]->quickQuery($query)) {
  623.             return $aValue;
  624.         }
  625.         $err['ERROR']=TRUE;
  626.         $err[$this->myName]['MSG']="ROW_NOT_FOUND FOR ".$this->myName." QUERY$query";
  627.         $err[$this->myName]['LABEL']=$this->label;
  628.         if ($debug{echo "<pre style=\"font-color:red;font-weight:bolder\">$query\n";print_r($err);echo "</pre>";}
  629.         return False;
  630.     }
  631.  
  632.     /**
  633.       * add slashes to the value from getValue to add it to a sql command
  634.       *
  635.       * @param  string  $aValue     the value
  636.       * @param  array   $err        error array
  637.       * @param  string  $arrName    name of the global array to access field gloabl ${$arrName}
  638.       * @param  bool    $debug 
  639.       *
  640.       * @return string 
  641.       *
  642.       * @version pk-03-12-13
  643.       *
  644.       ***/
  645.     function slashedValue($aValue,&$err,$arrName="DBVAL",$debug=False{
  646.         if ($debugecho "<hr><p><b>DBMS_FIELD_MEDIA::slashedValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)."/".$this->myName.")</p>";
  647.         return $this->getValue($aValue,$err,$arrName,$debug);
  648.     }
  649. }
  650. ?>

Documentation generated on Thu, 08 Jan 2009 17:42:21 +0100 by phpDocumentor 1.4.0a2