Source for file DBMS_FIELD_HTMLFCKEDITOR.phpclass

Documentation is available at DBMS_FIELD_HTMLFCKEDITOR.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_HTMLFCKEDITOR.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   text
  8.   *
  9.   * @author     Peter Krebs <p.krebs@lvus.at>
  10.   * @copyright  &copy 2002-2005 by LVUS
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   * @since pk-05-02-20
  14.   *
  15.   ***/
  16.  
  17. if (empty($GLOBALS['OCSP']['DBMSFLD_PATH'])) $GLOBALS['OCSP']['DBMSFLD_PATH']=dirname(__FILE__)."/";
  18.  
  19. if (!class_exists("DBMS_FIELD_HTMLCODE")) {  
  20.     require_once dirname("__FILE__")."/DBMS_FIELD_HTMLCODE.phpclass";
  21. }
  22.  
  23. /**
  24.   * Class DBMS_FIELD_HTMLFCKEDITOR
  25.   *
  26.   * @project    Open CSP-Management
  27.   * @package    dbms_field
  28.   * @category   text
  29.   *
  30.   * @author     Peter Krebs <p.krebs@lvus.at>
  31.   * @copyright  &copy 2002-2005 by LVUS
  32.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  33.   *
  34.   * @since pk-05-02-20
  35.   *  
  36.   ***/
  37.     var $className     = "HTML-FCKeditor";
  38.  
  39.     /**
  40.       * @var string $fixedEditor if (!empty) user can not edit editorUrl
  41.       * @since pk-05-02-20
  42.       ***/
  43.     var $fixedEditor     = TRUE;
  44.  
  45.  
  46.     /**
  47.       * @var int fckHeight inline Editor height
  48.       ***/
  49.     var $fckHeight=200;
  50.  
  51.       
  52.     /**
  53.       * source file of the class
  54.       *
  55.       * @var string $classSrcFile 
  56.       * @since pk-05-02-08
  57.       ***/
  58.     var $classSrcFile=__FILE__;
  59.     
  60.  
  61.     /**
  62.       * echos input form for field definition
  63.       *
  64.       * @param bool $showSize show size and maxlength input
  65.       * @version pk-03-10-10
  66.       ***/
  67.     function editTblForm($showSize=FALSE,$allowHTML=TRUE{
  68.         $this->fixedEditor=TRUE;
  69.         parent::editTblForm($showSize);
  70.     }
  71.  
  72.     /**
  73.       * saves the field definition from $_POST array
  74.       *
  75.       * @returns boolean
  76.       ***/
  77.     function save({
  78.         echo "<p><b>DBMS_FIELD_HTMLFCKEDITOR::save()<b> (".get_class($this)."/".$this->myName.")</p>";
  79.  
  80.         $ret=parent::save();
  81.         $this->editorUrl=$GLOBALS['PROJECT']['SYSTEMURL']."/editors/FCKeditor/";
  82.         return $ret;
  83.     }
  84.  
  85.     /**
  86.       * returns a string with the HTML input-tag for the field
  87.       *
  88.       * @param string $aValue the value to show
  89.       * @param string $arrName name of the form array used in name=
  90.       * @param string $nameAdd add string to the field name
  91.       *
  92.       * @return string 
  93.       *
  94.       * @version pk-03-11-27 layout changed
  95.       * @version pk-05-02-08 $nameAdd added
  96.       ***/
  97.     function getInputTag($aValue,$arrName="DBVAL",$nameAdd="",$debug=FALSE{
  98.         $debug=($debug || $this->fldDebug);
  99.         if ($debugecho "<p><b>DBMS_FIELD_HTMLFCKEDITOR::getInputTag(\$aValue,$arrName,$nameAdd,...)</b> (".get_class($this)."/".$this->myName.")</p>";
  100.  
  101.         $tag.="
  102.             <script type=\"text/javascript\" src=\"".$GLOBALS['PROJECT']['SYSTEMURL']."editors/FCKeditor/fckeditor.js\"></script>
  103.             <script type=\"text/javascript\">
  104.                 /* openCSP overwrite FCKeditor config */
  105.         
  106.                 function FCKeditor_OnComplete( editorInstance )
  107.                 {
  108.                     window.status = editorInstance.Description ;
  109.                 }
  110.         
  111.         
  112.             </script>
  113.         ";
  114.         
  115.         require_once $GLOBALS['OCSP']['PHPINCPATH']."common/pcf.phpinc";
  116.         $tag.="
  117.             <script type=\"text/javascript\">
  118.                 <!--
  119.                 // Automatically calculates the editor base path based on the _samples directory.
  120.                 // This is usefull only for these samples. A real application should use something like this:
  121.                 // oFCKeditor.BasePath = '/fckeditor/' ;    // '/fckeditor/' is the default value.
  122.                 
  123.                 var sBasePath = '".$GLOBALS['PROJECT']['SYSTEMURL']."editors/FCKeditor/';
  124.  
  125.                 var oFCKeditor = new FCKeditor('".$arrName."_".$this->myName."') ;
  126.                 oFCKeditor.BasePath = sBasePath ;
  127.                 oFCKeditor.Value    = '".pcf_makeJS_QuotedString($aValue)."';
  128.                 oFCKeditor.Height   = ".$this->fckHeight.";
  129.                 oFCKeditor.Create() ;
  130.                 //-->
  131.             </script>
  132.         ";       
  133.         return $tag;
  134.  
  135.     }
  136.  
  137.     /**
  138.       * echos the field as html code
  139.       *
  140.       * @param int $mode 
  141.       * @param mixed $aValue 
  142.       * @param string $arrName 
  143.       *
  144.       * @returns boolean true if user input is enabled
  145.       *
  146.       ***/
  147.     function writeField($mode,$aValue="",$arrName="DBVAL"{
  148.         switch($mode{
  149.             case FRM_MODE_READONLY:
  150.                 echo "<pre>".htmlspecialchars($aValue)."</pre>";
  151.                 echo $this->getAddTag($arrName);
  152.                 return FALSE;
  153.             case FRM_MODE_HIDDEN:
  154.                  return parent::writeField($mode,$aValue="",$arrName="DBVAL");
  155.             case FRM_MODE_NEW:
  156.                  if ($this->enableNew{
  157.                     echo $this->getInputTag($aValue,$arrName);
  158.                     echo $this->getAddTag($arrName);
  159.                     return TRUE;
  160.                  }
  161.                  return FALSE;
  162.             case FRM_MODE_COPY:
  163.                  if ($this->enableCopy{
  164.                     echo $this->getInputTag($aValue,$arrName);
  165.                     echo $this->getAddTag($arrName);
  166.                     return TRUE;
  167.                  }
  168.                  return FALSE;
  169.             case FRM_MODE_EDIT:
  170.                  if ($this->enableEdit{
  171.                     echo $this->getInputTag($aValue,$arrName);
  172.                     echo $this->getAddTag($arrName);
  173.                     return TRUE;
  174.                  }
  175.                  return FALSE;
  176.             default:
  177.                  echo $aValue;
  178.                  return FALSE;
  179.         }
  180.     }
  181.  
  182. // end class DBMS_FIELD_HTMLFCKEDITOR
  183. ?>

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