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

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