Source for file OCSP_HTMLPAGE.phpclass

Documentation is available at OCSP_HTMLPAGE.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_HTMLPAGE.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    common
  7.   *
  8.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-07-04-16
  12.   * @version $Id: OCSP_HTMLPAGE.phpclass,v 1.27 2008/12/10 15:39:05 peterkrebs Exp $
  13.   *  
  14.   */
  15.  
  16. /**
  17.   * ---------------------------------------------------
  18.   *
  19.   * common settings and requirements
  20.   *
  21.   */
  22.  
  23.     pcf_require_class('OCSP_TRANSLATOR',dirname(__FILE___OCSP_DIRSEP_ "OCSP_TRANSLATOR.phpclass");
  24.     pcf_require_class('OCSP_BROWSER',dirname(__FILE__"/");
  25.     pcf_require_class('OCSP_TEMPLATE',"common/");
  26.     
  27.     require_once dirname(__FILE___OCSP_DIRSEP_ "pcf.phpinc";
  28.     require_once dirname(__FILE___OCSP_DIRSEP_ "pcf_templates.phpinc";
  29.  
  30.     
  31.     
  32. /** ---------------------------------------------------
  33.   * Class OCSP_HTMLPAGE.phpclass
  34.   *
  35.   * @project    Open CSP-Management
  36.   * @package    cms
  37.   *
  38.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  39.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  40.   *
  41.   * @since pk-07-04-16
  42.   *
  43.   * @version $Id: OCSP_HTMLPAGE.phpclass,v 1.27 2008/12/10 15:39:05 peterkrebs Exp $
  44.   * 
  45.   * @desc buffers a html page
  46.   *
  47.   */
  48. class OCSP_HTMLPAGE {
  49.     
  50.     // ---------------------------------------------------------------------------
  51.     // constants
  52.     // ---------------------------------------------------------------------------
  53.     
  54.     /**
  55.      * @constant string CLASS_SRC_FILE
  56.      */
  57.     const CLASS_SRC_FILE = __FILE__;
  58.  
  59.     // ---------------------------------------------------------------------------
  60.     // class (static)
  61.     // ---------------------------------------------------------------------------
  62.     
  63.     /*** class vars ------------------------------------------------------ */
  64.     
  65.     /*** class methods --------------------------------------------------- */
  66.     
  67.     /**
  68.        * if $name is in URIs Query string the value
  69.      * is replaced otherwise $name=$value is appended to the uri
  70.      *
  71.      * @param string $uri 
  72.      * @param string $name 
  73.      * @param string $value 
  74.      * @param boolean $debug 
  75.      *
  76.      * @return string 
  77.      * 
  78.      * @since pk-08-08-12
  79.      */    
  80.     public static function URI_changeGetValue($uri,$name,$value,$debug=False)
  81.     {
  82.         return pcf_HTML_changeURI_GetValue($uri,$name,$value,$debug);
  83.     
  84.     
  85.     // ---------------------------------------------------------------------------
  86.     // object vars
  87.     // ---------------------------------------------------------------------------
  88.     
  89.     /*** compostion --------------------------------------------------- */
  90.     
  91.     /**
  92.       * @var CMS_PROJECT $myProject 
  93.       * @access protected
  94.       */
  95.     protected $myProject = NULL;
  96.  
  97.     /**
  98.       * @var OCSP_AJAX $myAjaxObj 
  99.       * @access protected
  100.       */
  101.     protected $myAjaxObj=NULL;
  102.  
  103.  
  104.     /*** attributes  -------------------------------------------------- */
  105.     
  106.     /**
  107.       * @var string $myDocType 
  108.       * @access protected
  109.       */
  110.     protected $myDocType='<?xml version="1.0" ?>
  111. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  112.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
  113.  
  114.     /**
  115.       * @var string $myHtmlTag &lt;html ...&gt;
  116.       * @access protected
  117.       */
  118.     protected $myHtmlTag="xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de_DE\" lang=\"de_DE\"";
  119.  
  120.     /**
  121.       * http attributes ----------
  122.       */
  123.  
  124.     /**
  125.       * an array of http header fields
  126.       *
  127.       * @var array $myHTTP_headers 
  128.       * @access protected
  129.       * @see http://www.php.net/header
  130.       * @see http://www.faqs.org/rfcs/rfc2616
  131.       */
  132.     protected $myHTTP_headers=array('Content-Type: text/html; charset=utf-8');
  133.  
  134.     /**
  135.       * html header attributes
  136.       */
  137.  
  138.     /**
  139.       * @var string $myTitle 
  140.       * @access protected
  141.       */
  142.     protected $myTitle="";
  143.  
  144.     /**
  145.       * @var array $myMetaTags 
  146.       * @access protected
  147.       */
  148.     protected $myMetaTags=array(
  149.             'Content-Type'          => array('EQUIV'=>"Content-Type",       'CONTENT'=>"text/html;charset=utf-8"),
  150.             'Content-Script-Type'   => array('EQUIV'=>"Content-Script-Type",'CONTENT'=>"text/javascript;charset=utf-8"),
  151.             'Content-Style-Type'    => array('EQUIV'=>"Content-Style-Type"'CONTENT'=>"text/css;charset=utf-8")
  152.         );
  153.  
  154.     /**
  155.       * @var array $myJS_includes 
  156.       * @access protected
  157.       */
  158.     protected $myJS_includes=array('$@SYSTEMURL$javascript/jquery/jquery.js','$@SYSTEMURL$jOCSP/jOCSP.js');
  159.  
  160.     /**
  161.       * @var string $myJS_code 
  162.       * @access protected
  163.       */
  164.     protected $myJS_code="";
  165.  
  166.     /**
  167.       * @var array $myCSS_includes 
  168.       * @access protected
  169.       */
  170.     protected $myCSS_includes=array();
  171.  
  172.     /**
  173.       * @var string $myCSS_code 
  174.       * @access protected
  175.       */
  176.     protected $myCSS_code="";
  177.  
  178.     /**
  179.       * @var string $myHeadContent 
  180.       * @access protected
  181.       */
  182.     protected $myHeadContent="";
  183.  
  184.     /**
  185.       * html body attributes
  186.       */
  187.  
  188.     /**
  189.       * @var string $myBodyTag added to &lt;body .... &gt;
  190.       * @access protected
  191.       */
  192.     protected $myBodyTag="";
  193.  
  194.     /**
  195.       * @var string $myBodyOnload 
  196.       * @access protected
  197.       */
  198.     protected $myBodyOnload="";
  199.  
  200.     /**
  201.       * @var string $myJsOnError 
  202.       * @access protectd
  203.       */
  204.     protected $myJsOnError="";
  205.  
  206.     /**
  207.       * @var array $myBodyBlocks array of block names in the order the have been added
  208.       * @access protected
  209.       */
  210.     protected $myBodyBlocks=array();
  211.  
  212.     /**
  213.       * @var array $myBodyContent 
  214.       * @access protected
  215.       */
  216.     protected $myBodyContent=array();
  217.  
  218.  
  219.     /**
  220.       * @var array $myBodyVars array of template vars to replace
  221.       * @access protected
  222.       */
  223.     protected $myTemplateVars=array();
  224.  
  225.     /**
  226.       *
  227.       * METHODS _____________________________________________
  228.       *
  229.       */
  230.  
  231.  
  232.     /** -----------------------------------------------------
  233.       * Constructors
  234.       *
  235.       * @global $OCSP_OBJ 
  236.       * @global $OCSP_CONF 
  237.       */
  238.     function OCSP_HTMLPAGE()
  239.     {
  240.         global $OCSP_OBJ,$OCSP_CONF;
  241.  
  242.         if (!pcf_is_instance_of($OCSP_OBJ['SESSION'],'OCSP_SESSION'))
  243.         {
  244.             require_once __OCSP_PHPINCPATH__."common/OCSP_SESSION.phpclass";
  245.             $OCSP_OBJ['SESSION']=OCSP_SESSION::getInstance(True);
  246.         }
  247.  
  248.         if (!isset($OCSP_CONF['DEFAULT_WINDOW_WIDTH']|| !intval($OCSP_CONF['DEFAULT_WINDOW_WIDTH']))
  249.         {
  250.             $OCSP_CONF['DEFAULT_WINDOW_WIDTH']=750;
  251.         }
  252.         if (!isset($OCSP_CONF['DEFAULT_WINDOW_HEIGHT']|| !intval($OCSP_CONF['DEFAULT_WINDOW_HEIGHT']))
  253.         {
  254.             $OCSP_CONF['DEFAULT_WINDOW_HEIGHT']=550;
  255.         }
  256.  
  257.  
  258.         $myTemplateVars['ALL']=array();
  259.         $this->myJS_code="
  260.             ocsp_session_name   ='".$OCSP_OBJ['SESSION']->getName()."';
  261.             ocsp_session_id     ='".$OCSP_OBJ['SESSION']->getId()."';
  262.             ocsp_conf_winwidth  ='".$OCSP_CONF['DEFAULT_WINDOW_WIDTH']."';
  263.             ocsp_conf_winheight ='".$OCSP_CONF['DEFAULT_WINDOW_WIDTH']."';
  264.         ";
  265.  
  266.         $this->addJsSrcLink($OCSP_CONF['JAVASCRIPTURL']."window.js");
  267.         $this->addJsSrcLink($OCSP_CONF['JAVASCRIPTURL']."base64.js");
  268.         $this->addJsSrcLink($OCSP_CONF['JAVASCRIPTURL']."forms.js");
  269.         $this->addJsSrcLink($OCSP_CONF['JAVASCRIPTURL']."ajax.js");
  270.     }
  271.  
  272.     /** -----------------------------------------------------
  273.       * getter & setter methods
  274.       */
  275.  
  276.     /**
  277.       * sets the docType
  278.       * @param string $aType HTML Doctype
  279.       */
  280.     function setDocType($aType)
  281.     {
  282.         $this->myDocType=$aType;
  283.     }
  284.  
  285.     /**
  286.       * HTTP-Header
  287.       */
  288.  
  289.     /**
  290.       * appends a HTTP header field
  291.       * @param string $field 
  292.       * @access public
  293.       */
  294.     function appendHTTP_header($field)
  295.     {
  296.         $this->myHTTP_headers[]=$field;
  297.     }
  298.  
  299.     /**
  300.       * clears the HTTP header fields
  301.       * @access public
  302.       */
  303.     function clearHTTP_header()
  304.     {
  305.         $this->myHTTP_headers=array();
  306.     }
  307.  
  308.     /**
  309.       * HTML head ----------------------------------------------------------------------------------
  310.       */
  311.  
  312.     /**
  313.       * sets the title
  314.       * @param string $aTitle 
  315.       * @access public
  316.       */
  317.     function setTitle($aTitle)
  318.     {
  319.         $this->myTitle=$aTitle;
  320.     }
  321.  
  322.     /**
  323.       * sets a meta tag
  324.       *
  325.       * @param string $name 
  326.       * @param string $content 
  327.       * @param boolean $http_equiv; 
  328.       *
  329.       */
  330.     function setMetaData($name,$content,$http_equiv=False)
  331.     {
  332.         $this->myMetaTags[$name]=array('CONTENT'=>$content,'EQUIV'=>$http_equiv);
  333.     }
  334.  
  335.     /**
  336.       * adds a javascript link
  337.       * @param string $src 
  338.       * @access public
  339.       */
  340.     function addJsSrcLink($src)
  341.     {
  342.         if (!in_array($src,$this->myJS_includes))
  343.         {
  344.             $this->myJS_includes[]=$src;
  345.         }
  346.     }
  347.  
  348.     /**
  349.       * adds a javascript code
  350.       * @param string $code 
  351.       * @param boolean $prepend add the code before already added code
  352.       * @param boolean $debug 
  353.       * @access public
  354.       */
  355.     function addJsCode($code,$prepend=False,$debug=False)
  356.     {
  357.         $code=trim($code);
  358.         if (!empty($code))
  359.         {
  360.             if ($prepend)
  361.             {
  362.                 $this->myJS_code=$code."\n".$this->myJS_code;
  363.             else {
  364.                 $this->myJS_code.="\n".$code."\n";
  365.             }
  366.         }
  367.     }
  368.  
  369.     /**
  370.       * includes a javascript code file into the header
  371.       * @param string $file 
  372.       * @param boolean $prepend add the code before already added code
  373.       * @param boolean $debug 
  374.       * @access public
  375.       */
  376.     function addJsFile($file,$prepend=False,$debug=False)
  377.     {
  378.         if (file_exists($file))
  379.         {
  380.             $str_code=file_get_contents($file);
  381.             if ($prepend)
  382.             {
  383.                 $this->myJS_code=$str_code."\n".$this->myJS_code;
  384.             else {
  385.                 $this->myJS_code.="\n".$str_code."\n";
  386.             }
  387.         }
  388.     }
  389.  
  390.     /**
  391.       * @param string $onErrorCode 
  392.       * @access public
  393.       */
  394.     function setJsOnErrorCode($onErrorCode)
  395.     {
  396.         $this->myJsOnError=$onErrorCode;
  397.     }
  398.  
  399.     /**
  400.       * adds a css link
  401.       * @param string $src 
  402.       * @access public
  403.       *
  404.       * @version pk-07-06-08
  405.       */
  406.     function addCssSrcLink($src)
  407.     {
  408.         if (!empty($src)) // <pk-07-06-08>
  409.         {
  410.             if (!in_array($src,$this->myCSS_includes))
  411.             {
  412.                 $this->myCSS_includes[]=$src;
  413.             }
  414.         }
  415.     }
  416.  
  417.     /**
  418.       * adds a css code
  419.       * @param string $code 
  420.       * @param boolean $prepend add the code before already added code
  421.       * @param boolean $debug 
  422.       * @access public
  423.       */
  424.     function addCssCode($code,$prepend=False,$debug=False)
  425.     {
  426.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_HTMLPAGE::addCssCode()");
  427.         $code=trim($code);
  428.         if (!empty($code))
  429.         {
  430.             if ($debugechoDebugLine(__FILE__,__LINE__,"<pre>".htmlspecialchars($code)."</pre>");
  431.             if ($prepend)
  432.             {
  433.                 $this->myCSS_code=$code."\n".$this->myCSS_code;
  434.             else {
  435.                 $this->myCSS_code.="\n".$code;
  436.             }
  437.         }
  438.  
  439.     }
  440.  
  441.     /**
  442.       * adds a string to the &lt;head&gt;
  443.       * @param string $aString 
  444.       * @access public
  445.       */
  446.     function addHeadContent($aString)
  447.     {
  448.         $this->myHeadContent.=$aString."\n";
  449.     }
  450.  
  451.  
  452.     /**
  453.       * adds a file content to the &lt;head&gt;
  454.       * @param string $file 
  455.       * @access public
  456.       */
  457.     function addHeadContentFile($file)
  458.     {
  459.         if (file_exists($file))
  460.         {
  461.             $str_content=file_get_contents($file);
  462.             $this->addHeadContent($str_content);
  463.         else {
  464.             $this->addHeadContent("FILE$file not found",$prepend,$blockName);
  465.         }
  466.     }
  467.  
  468.  
  469.     /**
  470.       * HTML body ----------------------------------------------------------------------------------
  471.       */
  472.  
  473.     /**
  474.       * sets the body tag
  475.       * @param string $tag 
  476.       * @access public
  477.       */
  478.     function setBodyTag($tag)
  479.     {
  480.         $this->myBodyTag=$tag;
  481.     }
  482.  
  483.     /**
  484.       * sets the body onLoad event
  485.       * @param string $jsCmd 
  486.       */
  487.     function setBodyOnload($jsCmd)
  488.     {
  489.         $this->myBodyOnload=$jsCmd;
  490.     }
  491.     
  492.     /**
  493.      * adds a js command to the onLoad of the body
  494.      *
  495.      * @param string $jsCmd 
  496.      * 
  497.      * @since pk-08-04-21
  498.      */
  499.     function addBodyOnload($jsCmd)
  500.     {        
  501.         $this->myBodyOnload .= $jsCmd;
  502.     }
  503.  
  504.     /**
  505.       * @return string 
  506.       */
  507.     function getBodyOnLoad()
  508.     {
  509.         return $this->myBodyOnload;
  510.     }
  511.  
  512.     /**
  513.       * adds a body content (to a block)
  514.       *
  515.       * if the blockname ends with [] the content is treaten as array
  516.       *     in this case prepend is disabled
  517.       *
  518.       * @param string $code 
  519.       * @param boolean $prepend 
  520.       * @param string $blockName 
  521.       * @access public
  522.       *
  523.       * @todo OCSP_HTMLPAGE::prepend in array mode
  524.       *
  525.       */
  526.     function addBodyContent($code,$prepend=False,$blockName='DEFAULT')
  527.     {
  528.         if (!OCSP_OBJ::isMultiByteStr($code))
  529.         {
  530.             $code utf8_encode($code);
  531.         }
  532.         
  533.         $blockName=trim($blockName);
  534.         if (!empty($blockName&& (!empty($code)))
  535.         {
  536.             // check if content block is used as array
  537.             if (substr($blockName,-2== "[]")
  538.             {
  539.                 $b_asArray TRUE;
  540.                 $blockName substr($blockName,0,-2);
  541.             else {
  542.                 $b_asArray False;
  543.             }
  544.  
  545.             if (!in_array($blockName,$this->myBodyBlocks))
  546.             {
  547.                 // add the block to the blocklist
  548.                 $this->myBodyBlocks[]=$blockName;
  549.             }
  550.  
  551.             if (!isset($this->myBodyContent[$blockName]))
  552.             {
  553.                 if ($b_asArray)
  554.                 {
  555.                     $this->myBodyContent[$blockName]=array();
  556.                 else {
  557.                     $this->myBodyContent[$blockName]="<!-- OCSP PAGEBLOCK ".$blockName." -->\n";
  558.                 }
  559.             }
  560.  
  561.             if ($b_asArray{
  562.                 $this->myBodyContent[$blockName][]=$code;
  563.             else {
  564.                 if ($prepend)
  565.                 {
  566.                     $this->myBodyContent[$blockName]=$code."\n".$this->myBodyContent[$blockName]."\n";
  567.                 else {
  568.                     $this->myBodyContent[$blockName].="\n".$code."\n";
  569.                 }
  570.             }
  571.         }
  572.     }
  573.  
  574.     /**
  575.       * loads a html code file and adds it to the body by calling $this->addBodyContent()
  576.       *
  577.       * @param string $file 
  578.       * @param boolean $prepend 
  579.       * @param string $blockName 
  580.       * @access public
  581.       */
  582.     function addBodyContentFile($file,$prepend=False,$blockName='DEFAULT',$debug=False)
  583.     {
  584.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_HTMLPAGE::addBodyContentFile({$file});");
  585.         
  586.         if (file_exists($file))
  587.         {
  588.             $str_content=file_get_contents($file);  
  589.             if ($debugechoDebugLine(__FILE__,__LINE__,htmlspecialchars($str_content));         
  590.             $this->addBodyContent($str_content,$prepend,$blockName);
  591.         else {
  592.             $this->addBodyContent("FILE$file not found",$prepend,$blockName);
  593.         }
  594.     }
  595.  
  596.     /**
  597.       * template vars
  598.       */
  599.  
  600.     /**
  601.       * sets a template var if no block is set it's add to 'ALL' and used in all blocks
  602.       *
  603.       * to add an array set $varName to "" and $varValue to the array
  604.       * 
  605.       * @param string $varName 
  606.       * @param mixed $varValue 
  607.       * @param string $blockName 
  608.       * 
  609.       * @access public
  610.       * 
  611.       * @version pk-08-04-25
  612.       */
  613.     function setTemplateVar($varName,$varValue,$blockName='ALL')
  614.     {
  615.         if (empty($blockName))  $blockName='ALL';
  616.         
  617.         if (empty($varName&& is_array($varValue))
  618.         {
  619.             if (!isset($this->myTemplateVars[$blockName]))
  620.             {
  621.                 $this->myTemplateVars[$blockName$varValue;
  622.             else {
  623.                 $this->myTemplateVars[$blockNamearray_merge($this->myTemplateVars[$blockName],$varValue);
  624.             }
  625.         else {
  626.              $this->myTemplateVars[$blockName][$varName]=$varValue;           
  627.         }
  628.         
  629.     }
  630.  
  631.     /**
  632.      * parses a template var imediatly
  633.      * 
  634.      * @param string $varName 
  635.      * @param string $varValue 
  636.      * @param bolean $debug 
  637.      */
  638.     public function parseTemplateVar($varName,$varValue,$blockName='ALL',$debug=False)
  639.     {
  640.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_HTMLPAGE::parseTemplateVar({$varName});");
  641.         
  642.         $arr_values array($varName => $varValue);
  643.         if ('ALL' == $blockName)
  644.         {
  645.             foreach($this->myBodyContent as $str_key => $str_tmpl)
  646.             {
  647.                 $obj_tmpl new OCSP_TEMPLATE($str_tmpl);                 
  648.                 $this->myBodyContent[$str_key$obj_tmpl->getValueParsedTemplate($arr_values);
  649.             }            
  650.         else {
  651.             $obj_tmpl new OCSP_TEMPLATE($this->myBodyBlocks[$blockName]);                 
  652.             $this->myBodyContent[$blockName$obj_tmpl->getValueParsedTemplate($arr_values);                    
  653.         }
  654.     }
  655.     
  656.     
  657.     /**
  658.      * returns a template var
  659.      * 
  660.      * @param string $varName 
  661.      * @param string $blockName 
  662.      * 
  663.      * @return mixed 
  664.      * 
  665.      * @since pk-08-01-10
  666.      * 
  667.      */
  668.     function getTemplateVar($varName,$blockName='ALL')
  669.     {
  670.         if (empty($blockName))  $blockName='ALL';
  671.         return $this->myTemplateVars[$blockName][$varName];
  672.     }
  673.  
  674.     /**
  675.       * ajax -------------------------------------------------------------------
  676.       */
  677.  
  678.     /**
  679.       * sets the ajax object of the page
  680.       * @param &OCSP_AJAX $ajaxObj 
  681.       */
  682.     function setAjaxObj(&$ajaxObj)
  683.     {
  684.         $this->myAjaxObj=$ajaxObj;
  685.     }
  686.  
  687.     /**
  688.       * returns the ajax object of the page
  689.       * @returns OCSP_AJAX
  690.       */
  691.     function &getAjaxObj()
  692.     {
  693.         return $this->myAjaxObj;
  694.     }
  695.  
  696.     /** -----------------------------------------------------
  697.       * output methods
  698.       */
  699.  
  700.     /**
  701.       * returns the HTML head &lt;head&gt;...&lt;/head&gt;
  702.       *
  703.       * @return string 
  704.       * @access public
  705.       */
  706.     function getHtmlHead()
  707.     {
  708.         $str_ret ="<head>\n";
  709.  
  710.         // title
  711.         if (!empty($this->myTitle))
  712.         {
  713.             $str_ret.="\t<title>".$this->myTitle."</title>\n";
  714.         else if (pcf_is_instance_of($this->myProject,'CMS_PROJECT')) {
  715.             $str_ret.="\t<title>".$this->myProject->getTitle()."</title>\n";
  716.         else if (isset($PROJECT['TITLE']&& (!empty($PROJECT['TITLE']))) {
  717.             $str_ret.="\t<title>".$PROJECT['TITLE']."</title>\n";
  718.         }
  719.  
  720.         // meta
  721.         if (is_array($this->myMetaTags))
  722.         {
  723.             foreach($this->myMetaTags as $str_name => $arr_tag)
  724.             {
  725.                 $str_ret.="\t<meta ";
  726.                 if ($arr_tag['EQUIV']{
  727.                     $str_ret.="http-equiv=\"".$str_name."\" ";
  728.                 else {
  729.                     $str_ret.="name=\"".$str_name."\" ";
  730.                 }
  731.                 $str_ret.="content=\"".$arr_tag['CONTENT']."\"";
  732.                 $str_ret.=" />\n";
  733.             }
  734.         }
  735.  
  736.  
  737.         if (!empty($this->myJsOnError))
  738.         {
  739.             $str_ret.="\n<script type=\"text/javascript\">\n<!--\n";
  740.             $str_ret.=$this->myJsOnError;
  741.             $str_ret.="\n//-->\n</script>\n\n";
  742.         }
  743.  
  744.  
  745.         // js includes
  746.         if (is_array($this->myJS_includes))
  747.         {
  748.             foreach($this->myJS_includes as $str_src)
  749.             {
  750.                 //$str_src=pcf_HTML_changeURI_GetValue($str_src,session_name(),session_id());
  751.                 $str_ret.="\t<script language=\"JavaScript\" src=\"".pcf_HTML_getEncodedURI($str_src)."\" type=\"text/javascript\"></script>\n";
  752.             }
  753.         }
  754.  
  755.         // css includes
  756.         if (is_array($this->myCSS_includes))
  757.         {
  758.             foreach($this->myCSS_includes as $str_src)
  759.             {
  760.                 $str_ret.="\t<link rel=\"stylesheet\" href=\"".$str_src."\" type=\"text/css\" />\n";
  761.             }
  762.         }
  763.  
  764.         if (!empty($this->myCSS_code))
  765.         {
  766.             $str_ret.="\n<style type=\"text/css\">\n<!--\n/*<![CDATA[*/\n";
  767.             $str_ret.=$this->myCSS_code;
  768.             $str_ret.="\n-->\n/*]]*/\n</style>\n\n";
  769.         }
  770.  
  771.         if (!empty($this->myJS_code))
  772.         {
  773.             $str_ret.="\n<script type=\"text/javascript\">\n<!--\n";
  774.             $str_ret.=$this->myJS_code;
  775.             $str_ret.="\n//-->\n</script>\n\n";
  776.         }
  777.  
  778.         if (pcf_is_instance_of($this->myAjaxObj,'OCSP_AJAX')) // the page has an ajax object set
  779.         {                                                     // add the ajax wrappers
  780.             $str_ret.=$this->myAjaxObj->js_getScript();
  781.         }
  782.         
  783.         if ((OCSP_BROWSER::getInstance()->isIE()) && (!OCSP_CONF::getInstance()->getValue('DISABLE_IEPNGFIX')))
  784.         {
  785.             $str_ret.= "
  786.             <!--[if lt IE 7]>
  787.                 <script defer type=\"text/javascript\" src=\"" OCSP_CONF::getInstance()->getValue('SYSTEMURL'"javascript/pngfix.js\"></script>
  788.             <![endif]-->
  789.                 ";            
  790.         }
  791.  
  792.         // other head stuff
  793.         $str_ret.=$this->myHeadContent;
  794.  
  795.         $str_ret.="</head>\n\n";
  796.  
  797.         
  798.         if (isset($this->myTemplateVars['ALL']))
  799.         {
  800.             $str_ret=pcf_tmpl_parse($str_ret,$this->myTemplateVars['ALL']);
  801.         else if (strstr($str_ret,'$')) {
  802.             $str_ret=pcf_tmpl_parse($str_ret,array());
  803.         }
  804.         return $str_ret;
  805.     }
  806.  
  807.     /**
  808.       * returns the page content
  809.       * this methods returns the whole content for each block the blocks are ordered by there first time set
  810.       *
  811.       * @param boolean $debug 
  812.       * 
  813.       * @return string (html)
  814.       * 
  815.       * @access public
  816.       * 
  817.       * @version pk-08-01-10 avoid parsing the template twice to keep inline templates in forms for example
  818.       */
  819.     function getBodyContent($debug=False)
  820.     {
  821.         $str_ret ="";
  822.         if (is_array($this->myBodyBlocks))
  823.         {
  824.             foreach($this->myBodyBlocks as $int_idx => $str_blockName)
  825.             {
  826.                 if (isset($this->myBodyContent[$str_blockName]))
  827.                 {
  828.                     $str_blockContent="<!-- OCSP PAGEBLOCK ".$str_blockName."[] -->\n";
  829.                     
  830.                     if (is_array($this->myBodyContent[$str_blockName]))
  831.                     {
  832.                         foreach($this->myBodyContent[$str_blockNameas $str_content)
  833.                         {                        
  834.                             $str_blockContent.=$str_content."\n";
  835.                         }
  836.                     else {
  837.                         $str_blockContent.=$this->myBodyContent[$str_blockName];
  838.                     }
  839.                     
  840.                     $arr_values=array();
  841.                     if (isset($this->myTemplateVars['ALL']&& is_array($this->myTemplateVars['ALL']))
  842.                     {
  843.                         $arr_values=array_merge($arr_values,$this->myTemplateVars['ALL']);
  844.                     }
  845.                     
  846.                     if (isset($this->myTemplateVars[$str_blockName]&& is_array($this->myTemplateVars[$str_blockName]))
  847.                     {
  848.                         $arr_values=array_merge($arr_values,$this->myTemplateVars[$str_blockName]);
  849.                     }
  850.                                                             
  851.                     $str_ret.=pcf_tmpl_parse($str_blockContent,$arr_values,$debug);
  852.                   
  853.                 }  
  854.             }
  855.         }
  856.         return $str_ret;
  857.     }
  858.  
  859.     /**
  860.       * returns the html code of the page
  861.       *
  862.       * @param boolean $closeBody 
  863.       *
  864.       * @return string 
  865.       * @access public
  866.       *
  867.       * @version pk-07-08-08 ankor ocsp_page_top added
  868.       */
  869.     function toHtml($closeBody=TRUE)
  870.     {
  871.         global $PROJECT;
  872.  
  873.         $str_ret="";
  874.         $str_ret.=$this->myDocType;
  875.         $str_ret.="\n<html ".$this->myHtmlTag.">\n";
  876.  
  877.         $str_ret.=$this->getHtmlHead();
  878.  
  879.         $str_ret.="\n<body id=\"ocspBody\" ".$this->myBodyTag;
  880.         if (!empty($this->myBodyOnload)) $str_ret.=" onLoad=\"".$this->myBodyOnload."\" "// <pk-07-12-19 /> do not escape
  881.         $str_ret.=">\n";
  882.         $str_ret.="<div style=\"display:none\"><a name=\"ocsp_page_top\"></a></div>\n"// <pk-07-08-08 />
  883.         $str_ret.=$this->getBodyContent()."\n";
  884.  
  885.         if ($closeBody)
  886.         {
  887.             $str_ret.="</body>\n";
  888.             $str_ret.="</html>\n";
  889.         }
  890.         return $str_ret;
  891.  
  892.     }
  893.  
  894.     /**
  895.       * outputs the page
  896.       *
  897.       * @param boolean $closeBody 
  898.       * @param string $convertCharSet 
  899.       * 
  900.       * @version pk-07-12-14 gzip return
  901.       */
  902.     function display($closeBody=true,$convertCharSet="UTF-8")
  903.     {
  904.         // check output buffers
  905.         $arr_ob=ob_list_handlers();
  906.         $b_buffer=(sizeof($arr_ob1);
  907.         
  908.         // http header
  909.         if (is_array($this->myHTTP_headers&& sizeof($this->myHTTP_headers))
  910.         {
  911.             foreach($this->myHTTP_headers as $str_header)
  912.             {
  913.                 header($str_header);
  914.             }
  915.         }
  916.        
  917.         if ($b_bufferob_start('ob_gzhandler');
  918.         $str_output=$this->toHtml();
  919.         //if (!empty($convertCharSet))
  920.         //{
  921.         //    echo mb_convert_encoding($str_output, "UTF-8");
  922.         //} else {
  923.         //    echo $str_output;
  924.         //}
  925.         echo $str_output;
  926.         if ($b_bufferob_end_flush();
  927.     }
  928.  
  929. // end class OCSP_HTMLPAGE
  930. ?>

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