Source for file DBMS_FIELD_LINK.phpclass

Documentation is available at DBMS_FIELD_LINK.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_LINK.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   string
  8.   *
  9.   * @author     Peter Krebs (pk)<p.krebs@lvus.at>
  10.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   ***/
  14.  
  15. if (empty($GLOBALS['OCSP']['PHPFORMPATH'])) $GLOBALS['OCSP']['PHPFORMPATH']=dirname(__FILE__)."/";
  16.   
  17. if (!class_exists("DBMS_FIELD")) {
  18.     require_once dirname(__FILE__)."/DBMS_FIELD.phpclass";
  19.  
  20. /**
  21.   * Class DBMS_FIELD_LINK
  22.   *
  23.   * @project    Open CSP-Management
  24.   * @package    dbms_field
  25.   * @category   string
  26.   *
  27.   * @author Peter Krebs (pk)<p.krebs@lvus.at>
  28.   * @copyright  (c) 2002-2004 by LVUS <http://opencsp.lvu.at>
  29.   * @copyright  &copy; 2005 by WURM & Partner Unternehmensservice
  30.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  31.   *
  32.   * @version pk-05-12-11
  33.   *
  34.   ***/
  35. class DBMS_FIELD_LINK extends DBMS_FIELD {
  36.     /**
  37.       * @var string $className 
  38.       ***/    
  39.     var $className      = "LinkURL";
  40.     /**
  41.       * @var boolean $checkUrl 
  42.       ***/    
  43.     var $checkUrl       = TRUE;
  44.     /**
  45.       * @var string $linkTxtField 
  46.       ***/    
  47.     var $linkTxtField   = "";
  48.  
  49.     /**
  50.         * source file of the class
  51.         *
  52.         * @var string $classSrcFile 
  53.         * @since pk-05-02-19
  54.         ***/
  55.     var $classSrcFile=__FILE__;
  56.  
  57.     /**
  58.       * @var string $nullReplace 
  59.       * @since pk-05-12-11
  60.       ***/    
  61.     var $nullReplace   = "";
  62.     
  63.     /**
  64.       * @param boolean $showSize 
  65.       * @param boolean $showNull 
  66.       ***/
  67.     function editTblForm($showSize=TRUE,$showNull=TRUE{
  68.         parent::editTblForm($showSize,$showNull);
  69.         ?>
  70.             <tr>
  71.                 <td class="fldName">URL pr�fen:</td>
  72.                 <td class="fldValue">
  73.                      
  74.                 </td>
  75.             </tr>
  76.             <tr>
  77.                 <td class="fldName">Link Text Feld:</td>
  78.                 <td class="fldValue">
  79.                     <input name="linkTxtField" size="30" value="<?php echo $this->linkTxtField?>">
  80.                 </td>
  81.             </tr>            
  82.         <?php
  83.  
  84.         if ($showNull{
  85.             echo "<tr><td class=\"fldName\" title=\"Link der verwendet wird wenn kein Link eingetragen ist.\">Null Link (List/RO)</td>\n";
  86.             echo "<td class=\"fldValue\"><input name=\"nullReplace\" size=\"30\" value=\"".$this->nullReplace."\"><br />\n";
  87.             echo "(Template)</td>";
  88.             echo "</tr>\n";
  89.         }        
  90.     }
  91.     
  92.     /**
  93.       * returns an array of field to bie shown in the edit form
  94.       * by using editTbl_echoForm
  95.       *
  96.       * the array is in the form:
  97.       *
  98.       * <code>
  99.       * [_sectionName_]
  100.       *      [TITLE] -> string
  101.       *      [_rowName_]
  102.       *         [FLDLAB]  (complete html code with <td></td>)
  103.       *         [FLDVAL] (complete html code with <td></td>)
  104.       *         [FLDTIT] (title of the label column)
  105.       * </code>
  106.       *
  107.       * @param boolean $debug 
  108.       *
  109.       * @return array 
  110.       *
  111.       * @since pk-08-01-22
  112.       *
  113.       */
  114.     function editTbl_getFieldEditArr($debug=FALSE
  115.     {    
  116.         $arr_ret=parent::editTbl_getFieldEditArr($debug);
  117.     
  118.         $arr_ret['VALCHECKS']['FLDCHECKURL']=array(
  119.                 'FLDLAB' => "URL pr&uuml;fen",
  120.                 'FLDVAL' => "<input name=\"checkUrl\" type=\"checkbox\"".($this->checkUrl ? " checked" "")." value=\"1\">ja"                
  121.             );
  122.             
  123.         return $arr_ret;
  124.     }
  125.     
  126.     ###############################
  127.  
  128.     /**
  129.       * @returns boolean
  130.       *
  131.       * @version pk-05-12-11
  132.       *
  133.       ***/
  134.     function save({
  135.         $ret parent::save();
  136.         
  137.         $this->checkUrl       = ((isset($_POST['checkUrl']&& intval($_POST['checkUrl'])) TRUE FALSE);
  138.         $this->linkTxtField   = $_POST['linkTxtField'];
  139.         $this->nullReplace    = $_POST['nullReplace'];   
  140.         
  141.         return $ret;
  142.     }    
  143.      
  144.  
  145.     /**
  146.       * @param mixed $aValue 
  147.       * @param string $arrName 
  148.       * @param boolean $debug 
  149.       *
  150.       * @returns string
  151.       *
  152.       * @version pk-05-12-11
  153.       *
  154.       ***/
  155.     function getScreenValue($aValue=NULL,$arrName="DBVAL",$debug=FALSE{
  156.         global ${$arrName};
  157.         $ret="";
  158.         
  159.         if ((empty($aValue)) && (!empty($this->nullReplace))) // <pk-05-12-11>
  160.             require_once $GLOBALS['OCSP']['PHPINCPATH']."common/pcf_templates.phpinc";            
  161.             $aValue=pcf_tmpl_parse($this->nullReplace,${$arrName},$debug);
  162.         }
  163.         if (!empty($aValue)) {
  164.             $ret.= "<a href='$aValuetarget='_blank'>";
  165.             if (!empty(${$arrName}[$this->linkTxtField])) {
  166.                 $ret.= ${$arrName}[$this->linkTxtField];
  167.             else {
  168.                 $ret.= $aValue;
  169.             }
  170.             $ret.="</a>";
  171.         else if (!empty(${$arrName}[$this->linkTxtField])) // <pk-05-12-11>
  172.             $ret.= ${$arrName}[$this->linkTxtField];
  173.         }    
  174.         return $ret;
  175.     }
  176.  
  177.     /**
  178.       * returns the url
  179.       * if $this->checkUrl is true
  180.       * an error is created if the url can not be opende with file command
  181.       *
  182.       * @param  string  $aValue     the value
  183.       * @param  array   $err        error array
  184.       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName}
  185.       * @param  bool    $debug 
  186.       *
  187.       * @return string 
  188.       *
  189.       * @since   pk-03-12-13
  190.       * @version pk-04-07-15
  191.       *
  192.       ***/
  193.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  194.         if ($debugecho "<hr><p><b>DBMS_FIELD_LINK::getValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)." | ".$this->myName.")</p>";
  195.         if (!empty($aValue)) {
  196.             /*
  197.             if (!strstr($aValue,"://")) {
  198.                 $aValue="http://".$aValue;
  199.             }
  200.             */
  201.  
  202.             if ($this->checkUrl{
  203.                 if (!($pageLn=@file($aValue,"r"))) {
  204.                     $err['ERROR']=TRUE;
  205.                     $err[$this->myName]['MSG']   ="URL_NOT_FOUND$aValue";
  206.                     $err[$this->myName]['LABEL'=$this->label;
  207.                 }
  208.             }
  209.         }
  210.  
  211.         /* <pk-04-07-15 />$arrName missing in parent call */
  212.         return parent::getValue($aValue,$err,$arrName,$debug);
  213.     }
  214.  
  215.     /**
  216.       * add slashes to the value from getValue to add it to a sql command
  217.       *
  218.       * @param  string  $aValue     the value
  219.       * @param  array   $err        error array
  220.       * @param  string  $arrName    name of the global array to access field gloabl ${$arrName}
  221.       * @param  bool    $debug 
  222.       *
  223.       * @return string 
  224.       *
  225.       * @version pk-04-07-15
  226.       *
  227.       *
  228.       ***/
  229.     function slashedValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  230.         if ($debugecho "<hr><p><b>DBMS_FIELD_LINK::slashedValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)."/".$this->myName.")</p>";
  231.         /* <pk-04-07-15 /> just call parent which cals $this->getValue() */
  232.         return parent::slashedValue($aValue,$err,$arrName,$debug);
  233.     }
  234.  
  235. }
  236. ?>

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