VCL
[ class tree: VCL ] [ index: VCL ] [ all elements ]

Source for file forms.inc.php

Documentation is available at forms.inc.php

  1. <?php
  2. /**
  3. *  This file is part of the VCL for PHP project
  4. *
  5. *  Copyright (c) 2004-2007 qadram software <support@qadram.com>
  6. *
  7. *  Checkout AUTHORS file for more information on the developers
  8. *
  9. *  This library is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU Lesser General Public
  11. *  License as published by the Free Software Foundation; either
  12. *  version 2.1 of the License, or (at your option) any later version.
  13. *
  14. *  This library is distributed in the hope that it will be useful,
  15. *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. *  Lesser General Public License for more details.
  18. *
  19. *  You should have received a copy of the GNU Lesser General Public
  20. *  License along with this library; if not, write to the Free Software
  21. *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  22. *  USA
  23. *
  24. */
  25.  
  26. use_unit("controls.inc.php");
  27. use_unit("stdctrls.inc.php");
  28. use_unit("rtl.inc.php");
  29. use_unit("templateplugins.inc.php");
  30.  
  31. define('dtNone','(none)');
  32. define('dtXHTML_1_0_Strict'     ,'XHTML 1.0 Strict');
  33. define('dtXHTML_1_0_Transitional' ,'XHTML 1.0 Transitional');
  34. define('dtXHTML_1_0_Frameset'     ,'XHTML 1.0 Frameset');
  35. define('dtHTML_4_01_Strict'       ,'HTML 4.01 Strict');
  36. define('dtHTML_4_01_Transitional' ,'HTML 4.01 Transitional');
  37. define('dtHTML_4_01_Frameset'     ,'HTML 4.01 Frameset');
  38. define('dtXHTML_1_1'              ,'XHTML 1.1');
  39.  
  40. /**
  41.  * Shutdown function, the right moment to serialize all components
  42.  *
  43.  */
  44. function VCLShutdown()
  45. {
  46.         global $application;
  47.  
  48.         //This is the moment to store all properties in the session to retrieve them later
  49.         $application->serializeChildren();
  50.  
  51.         //Uncomment this to get what is stored on the session at the last step of your scripts
  52.         /*
  53.         echo "<pre>";
  54.         print_r($_SESSION);
  55.         echo "<pre>";
  56.         */
  57. }
  58.  
  59.  
  60.  
  61. /**
  62.  * Component class
  63.  *
  64.  * Application class
  65.  */
  66. class Application extends Component
  67. {
  68.         protected $_language;
  69.  
  70.         function getLanguage(return $this->_language}
  71.         function setLanguage($value$this->_language=$value}
  72.  
  73.         function __construct($aowner=null)
  74.         {
  75.                 parent::__construct($aowner);
  76.                 session_start();
  77.                 if (isset($_GET['restore_session']))
  78.                 {
  79.                         $_SESSION array();
  80.                         session_destroy();
  81.                 }
  82.  
  83.                 reset($_GET);
  84.                 while (list($k,$v)=each($_GET))
  85.                 {
  86.                         if (strpos($k,'.')===false$_SESSION[$k]=$v;
  87.                 }
  88.         }
  89.  
  90.         /**
  91.         * Autodetects the language for the user browser
  92.         */
  93.         function autoDetectLanguage()
  94.         {
  95.                 use_unit("language/php_language_detection.php");
  96.                 $lang=get_languages('data');
  97.                 reset($lang);
  98.                 while (list($k,$v)=each($lang))
  99.                 {
  100.                         if (array_key_exists(2,$v))
  101.                         {
  102.                                 $this->Language=$v[2];
  103.                                 break;
  104.                         }
  105.                 }
  106.         }
  107.  
  108.  
  109. }
  110.  
  111. global $application;
  112.  
  113. /**
  114.  * Global $application variable
  115.  */
  116. $application=new Application(null);
  117.  
  118.  
  119. /**
  120.  * ScrollingControl class
  121.  *
  122.  * Base class for controls with scrolling area
  123.  */
  124. {
  125. }
  126.  
  127. /**
  128.  * CustomPage class
  129.  *
  130.  * Base class for Page component
  131.  */
  132. class CustomPage extends ScrollingControl
  133. {
  134.         function __construct($aowner=null)
  135.         {
  136.                 //Calls inherited constructor
  137.                 parent::__construct($aowner);
  138.                 $this->ControlStyle="csAcceptsControls=1";
  139.         }
  140. }
  141.  
  142. /**
  143.  * DataModule class, basically a non visible holder for direct Component descendants
  144.  *
  145.  */
  146. class DataModule extends CustomPage
  147. {
  148.  
  149. }
  150.  
  151. /**
  152.  * Function responsible to dispatch ajax requests to the right events
  153.  *
  154.  * @param string $owner 
  155.  * @param string $sender 
  156.  * @param mixed $params 
  157.  * @param string $event 
  158.  * @param array $postvars 
  159.  * @return string 
  160.  */
  161.         function ajaxProcess($owner$sender$params$event$postvars)
  162.         {
  163.                 global $$owner;
  164.  
  165.                 $_POST=$postvars;
  166.  
  167.                 $$owner->loaded();
  168.                 $$owner->loadedChildren();
  169.  
  170.                 $$owner->$event($$owner->$sender$params);
  171.  
  172.                 $objResponse new xajaxResponse();
  173.  
  174.  
  175.                 reset($$owner->controls->items);
  176.  
  177.                 while (list($k,$v)=each($$owner->controls->items))
  178.                 {
  179.                         if ($v->methodExists("dumpForAjax"))
  180.                         {
  181.                             ob_start();
  182.                             $v->dumpForAjax();
  183.                             $ccontents=ob_get_contents();
  184.                             ob_end_clean();
  185.  
  186.                             $ccontents=utf8_encode($ccontents);
  187.                             $objResponse->addScript($ccontents);
  188.                         }
  189.                         else
  190.                         {
  191.                             ob_start();
  192.                             $v->show();
  193.                             $ccontents=ob_get_contents();
  194.                             ob_end_clean();
  195.  
  196.                             $ccontents=utf8_encode($ccontents);
  197.                             $objResponse->addAssign($v->Name."_outer","innerHTML",$ccontents);
  198.                             $js=extractjscript($ccontents);
  199.                             $js[0]=utf8_encode($js[0]);                            
  200.                             $objResponse->addScript($js[0]);
  201.                         }
  202.                 }
  203.  
  204.  
  205.                 $$owner->serialize();
  206.                 $$owner->serializeChildren();
  207.  
  208.                 $response=$objResponse->getXML();
  209.  
  210.                 return $response;
  211.         }
  212.  
  213.  
  214. define('rmFrame','frame');
  215. define('rmOpaque','opaque');
  216. define('rmLazyOpaque','lazyopaque');
  217. define('rmTranslucent','translucent');
  218.  
  219. define('mmFrame','frame');
  220. define('mmOpaque','opaque');
  221. define('mmTranslucent','translucent');
  222.  
  223. /**
  224.  * Window class
  225.  *
  226.  * A class to encapsulate a window living on the browser
  227.  */
  228. class Window extends QWidget
  229. {
  230.         function __construct($aowner=null)
  231.         {
  232.                 //Calls inherited constructor
  233.                 parent::__construct($aowner);
  234.                 $this->ControlStyle="csAcceptsControls=1";
  235.                 $this->ControlStyle="csSlowRedraw=1";                
  236.         }
  237.  
  238.             protected $_modal=0;
  239.  
  240.         /**
  241.         * Specifies if the window is modal or not
  242.         * @return boolean 
  243.         */
  244.             function getModal(return $this->_modal}
  245.             function setModal($value$this->_modal=$value}
  246.             function defaultModal(return 0}
  247.  
  248.             protected $_isvisible=true;
  249.  
  250.         /**
  251.         * Specifies if the window is visible or not
  252.         * @return boolean 
  253.         */
  254.             function getIsVisible(return $this->_isvisible}
  255.             function setIsVisible($value$this->_isvisible=$value}
  256.             function defaultIsVisible(return true}
  257.  
  258.             function getCaption(return $this->readCaption()}
  259.             function setCaption($value$this->writeCaption($value)}
  260.  
  261.             protected $_resizeable=1;
  262.  
  263.         /**
  264.         * Specifies if the window allows to be resized
  265.         * @return boolean 
  266.         */
  267.             function getResizeable(return $this->_resizeable}
  268.             function setResizeable($value$this->_resizeable=$value}
  269.             function defaultResizeable(return 1}
  270.  
  271.             protected $_moveable=1;
  272.  
  273.         /**
  274.         * Specifies if the window is modal allows to be moved
  275.         * @return boolean 
  276.         */
  277.             function getMoveable(return $this->_moveable}
  278.             function setMoveable($value$this->_moveable=$value}
  279.             function defaultMoveable(return 1}
  280.  
  281.             protected $_showminimize=1;
  282.  
  283.         /**
  284.         * Specifies if the window shows the minimize button or not
  285.         * @return boolean 
  286.         */
  287.             function getShowMinimize(return $this->_showminimize}
  288.             function setShowMinimize($value$this->_showminimize=$value}
  289.             function defaultShowMinimize(return 1}
  290.  
  291.             protected $_showmaximize=1;
  292.  
  293.         /**
  294.         * Specifies if the window shows the maximize button or not
  295.         * @return boolean 
  296.         */
  297.             function getShowMaximize(return $this->_showmaximize}
  298.             function setShowMaximize($value$this->_showmaximize=$value}
  299.             function defaultShowMaximize(return 1}
  300.  
  301.             protected $_showclose=1;
  302.  
  303.         /**
  304.         * Specifies if the window shows the close button or not
  305.         * @return boolean 
  306.         */
  307.             function getShowClose(return $this->_showclose}
  308.             function setShowClose($value$this->_showclose=$value}
  309.             function defaultShowClose(return 1}
  310.  
  311.             protected $_showicon=1;
  312.  
  313.         /**
  314.         * Specifies if the window shows the top left icon or not
  315.         * @return boolean 
  316.         */
  317.             function getShowIcon(return $this->_showicon}
  318.             function setShowIcon($value$this->_showicon=$value}
  319.             function defaultShowIcon(return 1}
  320.  
  321.             protected $_showcaption=1;
  322.  
  323.         /**
  324.         * Specifies if the window shows a caption
  325.         * @return boolean 
  326.         */
  327.             function getShowCaption(return $this->_showcaption}
  328.             function setShowCaption($value$this->_showcaption=$value}
  329.             function defaultShowCaption(return 1}
  330.  
  331.             protected $_movemethod="mmOpaque";
  332.  
  333.         /**
  334.         * Specifies the method used to move the window
  335.         * @return enum 
  336.         */
  337.             function getMoveMethod(return $this->_movemethod}
  338.             function setMoveMethod($value$this->_movemethod=$value}
  339.             function defaultMoveMethod(return "mmOpaque"}
  340.  
  341.             protected $_resizemethod="rmFrame";
  342.  
  343.         /**
  344.         * Specifies the method used to resize the window
  345.         * @return enum 
  346.         */
  347.             function getResizeMethod(return $this->_resizemethod}
  348.             function setResizeMethod($value$this->_resizemethod=$value}
  349.             function defaultResizeMethod(return "rmFrame"}
  350.  
  351.             protected $_showstatusbar=0;
  352.  
  353.         /**
  354.         * Specifies if the window shows the status bar or not
  355.         * @return boolean 
  356.         */
  357.             function getShowStatusBar(return $this->_showstatusbar}
  358.             function setShowStatusBar($value$this->_showstatusbar=$value}
  359.             function defaultShowStatusBar(return 0}
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.         function dumpContents()
  367.         {
  368.                 echo "<script type=\"text/javascript\">";
  369.                 echo "var d = qx.ui.core.ClientDocument.getInstance();\n";
  370.  
  371.                 echo "  var $this->Name = new qx.ui.window.Window(\"$this->Caption\", \"icon/16/apps/accessories-disk-usage.png\");\n";
  372.  
  373.                 if (($this->ControlState csDesigning!= csDesigning)
  374.                 {
  375.                         echo " $this->Name.setLocation($this->Left$this->Top);\n";
  376.                         if ($this->Modalecho "  $this->Name.setModal(true);\n";
  377.                         else echo "  $this->Name.setModal(false);\n";
  378.  
  379.                         if ($this->Resizeableecho "  $this->Name.setResizeable(true);\n";
  380.                         else echo "  $this->Name.setResizeable(false);\n";
  381.  
  382.                         if ($this->Moveableecho "  $this->Name.setMoveable(true);\n";
  383.                         else echo "  $this->Name.setMoveable(false);\n";
  384.  
  385.                         echo "  $this->Name.setMoveMethod(\"".constant($this->MoveMethod)."\");\n";
  386.                         echo "  $this->Name.setResizeMethod(\"".constant($this->ResizeMethod)."\");\n";
  387.  
  388.                 }
  389.                 else
  390.                 {
  391.                         echo " $this->Name.setLocation(0,0);\n";
  392.                 }
  393.  
  394.                         if ($this->ShowCloseecho "  $this->Name.setShowClose(true);\n";
  395.                         else echo "  $this->Name.setShowClose(false);\n";
  396.  
  397.                         if ($this->ShowMinimizeecho "  $this->Name.setShowMinimize(true);\n";
  398.                         else echo "  $this->Name.setShowMinimize(false);\n";
  399.  
  400.                         if ($this->ShowMaximizeecho "  $this->Name.setShowMaximize(true);\n";
  401.                         else echo "  $this->Name.setShowMaximize(false);\n";
  402.  
  403.                         if ($this->ShowIconecho "  $this->Name.setShowIcon(true);\n";
  404.                         else echo "  $this->Name.setShowIcon(false);\n";
  405.  
  406.                         if ($this->ShowCaptionecho "  $this->Name.setShowCaption(true);\n";
  407.                         else echo "  $this->Name.setShowCaption(false);\n";
  408.  
  409.                         if ($this->ShowStatusBarecho "  $this->Name.setShowStatusbar(true);\n";
  410.                         else echo "  $this->Name.setShowStatusbar(false);\n";
  411.  
  412.                 echo " $this->Name.setWidth($this->Width);\n";
  413.                 echo " $this->Name.setHeight($this->Height);\n";
  414.                 $js=$this->dumpChildrenControls(-22,-3);
  415.  
  416.                echo " d.add($this->Name)\n";
  417.  
  418.                 if (($this->ControlState csDesigning!= csDesigning)
  419.                 {
  420.                if ($this->IsVisible)
  421.                {
  422.                         if (!$this->Modal)
  423.                         {
  424.                                 echo " $this->Name.open();\n";
  425.                         }
  426.                }
  427.                }
  428.                else
  429.                {
  430.                                 echo " $this->Name.open();\n";
  431.                }
  432.                echo $js;
  433.                 echo "</script>";
  434.         }
  435. }
  436.  
  437. /**
  438.  * Page class
  439.  *
  440.  * A class to encapsulate a web page
  441.  */
  442. class Page extends CustomPage
  443. {
  444.     protected $_showheader=1;
  445.     protected $_showfooter=1;
  446.     protected $_ismaster="0";
  447.     protected $_marginwidth="0";
  448.     protected $_marginheight="0";
  449.     protected $_leftmargin="0";
  450.     protected $_topmargin="0";
  451.     protected $_rightmargin="0";
  452.     protected $_bottommargin="0";
  453.     protected $_useajax=0;
  454.     protected $_dynamic=false;
  455.     protected $_templateengine="";
  456.     protected $_templatefilename="";
  457.  
  458.     protected $_onbeforeshowheader=null;
  459.     protected $_onstartbody=null;
  460.     protected $_onshowheader=null;
  461.     protected $_onaftershowfooter=null;
  462.     protected $_oncreate=null;
  463.  
  464.     protected $_isform=true;
  465.     protected $_action="";
  466.  
  467.     protected $_background="";
  468.     protected $_language="(default)";
  469.  
  470.     protected $_jsonload=null;
  471.     protected $_jsonunload=null;
  472.  
  473.  
  474.         /**
  475.         * The javascript OnLoad event is called after all nested framesets and
  476.         * frames are finished with loading their content.
  477.         * @return mixed 
  478.         */
  479.         function getjsOnLoad(return $this->_jsonload}
  480.         /**
  481.         * The javascript OnLoad event is called after all nested framesets and
  482.         * frames are finished with loading their content.
  483.         * @param mixed $value 
  484.         */
  485.         function setjsOnLoad($value$this->_jsonload=$value}
  486.         function defaultjsOnLoad(return null}
  487.  
  488.         /**
  489.         * The javascript OnUnload event is called after all nested framesets and
  490.         * frames are finished with unloading their content.
  491.         * @return mixed 
  492.         */
  493.         function getjsOnUnload(return $this->_jsonunload}
  494.         /**
  495.         * The javascript OnUnload event is called after all nested framesets and
  496.         * frames are finished with unloading their content.
  497.         * @param mixed $value 
  498.         */
  499.         function setjsOnUnload($value$this->_jsonunload=$value}
  500.         function defaultjsOnUnload(return null}
  501.  
  502.  
  503.         function getLayout(return $this->readLayout()}
  504.         function setLayout($value$this->writeLayout($value)}
  505.  
  506.         protected $_framespacing=0;
  507.         protected $_frameborder=fbNo;
  508.         protected $_borderwidth=0;
  509.         protected $_border="";
  510.  
  511.         /**
  512.         * Sets or retrieves the amount of additional space between the frames.
  513.         * @return integer 
  514.         */
  515.         function getFrameSpacing(return $this->_framespacing;       }
  516.         function setFrameSpacing($value$this->_framespacing=$value}
  517.         function defaultFrameSpacing(return 0}
  518.  
  519.         /**
  520.         * String that specifies or receives one of the following values.
  521.         * fbDefault Inset border is drawn.
  522.         * fbNo       No border is drawn.
  523.         * fbYes     Inset border is drawn.
  524.         * @return enum 
  525.         */
  526.         function getFrameBorder(return $this->_frameborder}
  527.         function setFrameBorder($value$this->_frameborder=$value}
  528.         function defaultFrameBorder(return fbNo}
  529.  
  530.         /**
  531.         * Sets or retrieves the width of the left, right, top, and bottom borders of the object.
  532.         * @return integer 
  533.         */
  534.         function getBorderWidth(return $this->_borderwidth}
  535.         function setBorderWidth($value$this->_borderwidth=$value}
  536.         function defaultBorderWidth(return 0}
  537.  
  538.  
  539.     protected $_encoding='Western European (ISO)     |iso-8859-1';
  540.  
  541.         /**
  542.         * Specifies the encoding to use for the page
  543.         * @return enum 
  544.         */
  545.     function getEncoding(return $this->_encoding}
  546.     function setEncoding($value$this->_encoding=$value}
  547.     function defaultEncoding(return "Western European (ISO)     |iso-8859-1"}
  548.  
  549.     protected $_doctype="dtNone";
  550.  
  551.         /**
  552.         * Specifies the doctype to generate, components are responsible to adapt to this property
  553.         * and generate valid code
  554.         * @return enum 
  555.         */
  556.     function getDocType(return $this->_doctype}
  557.     function setDocType($value$this->_doctype=$value}
  558.     function defaultDocType(return dtNone}
  559.  
  560.  
  561.     protected $_formencoding="";
  562.  
  563.         /**
  564.         * Specifies the encoding to use for forms
  565.         * @return enum 
  566.         */
  567.     function readFormEncoding(return $this->_formencoding}
  568.     function writeFormEncoding($value$this->_formencoding=$value}
  569.     function defaultFormEncoding(return ""}
  570.  
  571.  
  572.  
  573.         function getAlignment(return $this->readAlignment()}
  574.         function setAlignment($value$this->writeAlignment($value)}
  575.  
  576.         function getColor(return $this->readColor()}
  577.         function setColor($value$this->writeColor($value)}
  578.  
  579.         function getShowHint(return $this->readShowHint()}
  580.         function setShowHint($value$this->writeShowHint($value)}
  581.  
  582.         function getVisible(return $this->readVisible()}
  583.         function setVisible($value$this->writeVisible($value)}
  584.  
  585.         function getCaption(return $this->readCaption()}
  586.         function setCaption($value$this->writeCaption($value)}
  587.  
  588.         function getFont(return $this->readFont()}
  589.         function setFont($value$this->writeFont($value)}
  590.  
  591.         /**
  592.         * Specifies the background for the form
  593.         * @return string 
  594.         */
  595.         function getBackground(return $this->_background}
  596.         function setBackground($value$this->_background=$value}
  597.  
  598.         /**
  599.         * Specifies the engine to be used to render this page using templates
  600.         * @return string 
  601.         */
  602.         function getTemplateEngine(return $this->_templateengine}
  603.         function setTemplateEngine($value$this->_templateengine=$value}
  604.         function defaultTemplateEngine(return ""}
  605.  
  606.     //Action property
  607.         
  608.         function getAction(return $this->_action}
  609.         function setAction($value$this->_action=$value}
  610.         function defaultAction(return ""}
  611.  
  612.         /**
  613.         * Specifies the name of the template to be used to render this page
  614.         * @return string 
  615.         */
  616.         function getTemplateFilename(return $this->_templatefilename}
  617.         function setTemplateFilename($value$this->_templatefilename=$value}
  618.         function defaultTemplateFilename(return ""}
  619.  
  620.         /**
  621.         * If true, ajax requests will be processed and handled
  622.         * @return boolean 
  623.         */
  624.         function getUseAjax(return $this->_useajax}
  625.         function setUseAjax($value$this->_useajax=$value}
  626.         function defaultUseAjax(return 0}
  627.  
  628.         /**
  629.         * Specifies the language to be used when rendering this page
  630.         * @return string 
  631.         */
  632.         function getLanguage(return $this->_language}
  633.         function setLanguage($value)
  634.         {
  635.                 if ($value!=$this->_language)
  636.                 {
  637.                         $this->_language=$value;
  638.                         if ((($this->ControlState csDesigning!= csDesigning&& (($this->ControlState csLoading!= csLoading))
  639.                         {
  640.                                 $resourcename=$this->lastresourceread;
  641.                                 if ($value=='(default)'$l="";
  642.                                 else $l=".".$value;
  643.  
  644.                                 $resourcename=str_replace('.php',$l.'.xml.php',$resourcename);
  645.  
  646.                                 //This is to allow gettext usage
  647.                                 if ($value=='(default)'$l='';
  648.                                 else $l=$value;
  649.  
  650.                                 putenv ("LANG=$l");
  651.                                 $domain="messages";
  652.                                 bindtextdomain($domain"./locale");
  653.                                 textdomain($domain);
  654.  
  655.                                 if (file_exists($resourcename))
  656.                                 {
  657.                                         $this->readFromResource($resourcenamefalsefalse);
  658.                                 }
  659.                         }
  660.                 }
  661.         }
  662.         function defaultLanguage(return "(default)"}
  663.  
  664.     //Constructor
  665.     
  666.     function __construct($aowner=null)
  667.     {
  668.                         //Inherited constructor
  669.                         parent::__construct($aowner);
  670.  
  671.     }
  672.  
  673.     function loaded()
  674.     {
  675.         //Once the component has been loaded, calls the oncreate event, if assigned
  676.         $this->callEvent('oncreate',array());
  677.     }
  678.  
  679.     protected $_jsonsubmit=null;
  680.  
  681.         /**
  682.         * Fired when the page is going to be submitted to the form
  683.         */
  684.     function getjsOnSubmit(return $this->_jsonsubmit}
  685.     function setjsOnSubmit($value$this->_jsonsubmit=$value}
  686.     function defaultjsOnSubmit(return null}
  687.  
  688.     protected $_jsonreset=null;
  689.  
  690.         /**
  691.         * Fired when the page is going to be reset
  692.         */
  693.     function getjsOnReset(return $this->_jsonreset}
  694.     function setjsOnReset($value$this->_jsonreset=$value}
  695.     function defaultjsOnReset(return null}
  696.  
  697.         function dumpJsEvents()
  698.         {
  699.                 parent::dumpJsEvents();
  700.  
  701.                 $this->dumpJSEvent($this->_jsonsubmit);
  702.                 $this->dumpJSEvent($this->_jsonreset);
  703.                 $this->dumpJSEvent($this->_jsonload);
  704.                 $this->dumpJSEvent($this->_jsonunload);
  705.         }
  706.  
  707.         /**
  708.         * Dumps the opening form tag
  709.         * @return string 
  710.         */
  711.     function readStartForm()
  712.     {
  713.         $result="";
  714.         if (($this->_isform&& ($this->_showheader))
  715.         {
  716.                 $action="";
  717.                 if (isset($_SERVER['PHP_SELF'])) $action=$_SERVER['PHP_SELF'];
  718.  
  719.                    if ($this->_action!=''$action=$this->_action;
  720.  
  721.                    $formevents='';
  722.  
  723.                    if ($this->_jsonsubmit!="")
  724.                    {
  725.                         $formevents.=" onsubmit=\"return $this->_jsonsubmit();\" ";
  726.                    }
  727.  
  728.                    if ($this->_jsonreset!="")
  729.                    {
  730.                         $formevents.=" onreset=\"return $this->_jsonreset();\" ";
  731.                    }
  732.  
  733.                    $enctype "";
  734.                    if ($this->_formencoding != "")
  735.                    {
  736.                         $enctype " enctype=\"$this->_formencoding\"";
  737.                    }
  738.  
  739.                $result='<form style="margin-bottom: 0" id="'.$this->name.'" name="'.$this->name.'" method="post" '.$formevents.' action="'.$action.'"'.$enctype.'>';
  740.         }
  741.         return($result);
  742.     }
  743.  
  744.         /**
  745.         * Dumps the ending form tag
  746.         * @return string 
  747.         */
  748.     function readEndForm()
  749.     {
  750.         return("</form>");
  751.     }
  752.  
  753. /**
  754.  * Dump the page using a template, it doesn't generate an HTML page, it uses
  755.  * the template and tries to insert components inside it
  756.  *
  757.  */
  758.     function dumpUsingTemplate()
  759.     {
  760.         //Check here for templateengine and templatefilename
  761.         if (($this->ControlState csDesigning!= csDesigning)
  762.         {
  763.                 $tclassname=$this->_templateengine;
  764.  
  765.                 $template=new $tclassname($this);
  766.                 $template->FileName=$this->_templatefilename;
  767.                 $template->initialize();
  768.                 $this->callEvent("ontemplate",array("template"=>$template));
  769.                 $template->assignComponents();
  770.                 $template->dumpTemplate();
  771.         }
  772.     }
  773.  
  774.     protected $_ontemplate=null;
  775.  
  776.         /**
  777.         * Fired when the template is about to be rendered
  778.         */
  779.     function getOnTemplate(return $this->_ontemplate}
  780.     function setOnTemplate($value$this->_ontemplate=$value}
  781.     function defaultOnTemplate(return ""}
  782.  
  783.  
  784.  
  785.     public $hasframes=false;
  786.  
  787.     function dumpHeaderJavascript($return_contents=false)
  788.     {
  789.         global $output_enabled;
  790.  
  791.         if ($output_enabled)
  792.         {
  793.                 ob_start();
  794.                 $this->dumpChildrenJavascript();
  795.                 $js=ob_get_contents();
  796.                 ob_end_clean();
  797.                 $sp='';
  798.                 if (trim($js)!="")
  799.                 {
  800.                         $sp="<script type=\"text/javascript\">\n";
  801.                         $sp.="<!--\n";
  802.                         $sp.=$js;
  803.                         $sp.="-->\n";
  804.                         $sp.="</script>\n";
  805.                 }
  806.  
  807.                 if ($return_contents)
  808.                 {
  809.                     return($sp);
  810.                 }
  811.                 else echo $sp;
  812.         }
  813.     }
  814.  
  815.     function dumpContents()
  816.     {
  817.         //TODO: XHTML support
  818.         //TODO: Isolate all elements of a page into properties
  819.         //Calls beforeshowheader event, if any
  820.         $this->callEvent('onshow',array());
  821.  
  822.         if ($this->_templateengine!="")
  823.         {
  824.                 $this->dumpUsingTemplate();
  825.                 return;
  826.         }
  827.  
  828.         if ($this->_ismasterreturn;
  829.  
  830.  
  831.         if ($this->_useajax)
  832.         {
  833.                 if (($this->ControlState csDesigning!= csDesigning)
  834.                 {
  835.                 use_unit("xajax/xajax.inc.php");
  836.                 //AJAX support
  837.                 global $xajax;
  838.  
  839.                 // Instantiate the xajax object.  No parameters defaults requestURI to this page, method to POST, and debug to off
  840.                 $xajax new xajax();
  841.  
  842.                 // $xajax->debugOn(); // Uncomment this line to turn debugging on
  843.  
  844.                 // Specify the PHP functions to wrap. The JavaScript wrappers will be named xajax_functionname
  845.                 $xajax->registerFunction("ajaxProcess");
  846.  
  847.                 // Process any requests.  Because our requestURI is the same as our html page,
  848.                 // this must be called before any headers or HTML output have been sent
  849.                 $xajax->processRequests();
  850.                 //AJAX support
  851.                 }
  852.         }
  853.  
  854.         $dtd="";
  855.         $extra="";
  856.  
  857.         switch (constant($this->_doctype))
  858.         {
  859.             case dtNone$dtd=""$extra=""break;
  860.  
  861.             case dtXHTML_1_0_Strict$dtd='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'$extra='xmlns="http://www.w3.org/1999/xhtml"'break;
  862.             case dtXHTML_1_0_Transitional$dtd='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'$extra='xmlns="http://www.w3.org/1999/xhtml"'break;
  863.             case dtXHTML_1_0_Frameset$dtd='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'$extra='xmlns="http://www.w3.org/1999/xhtml"'break;
  864.  
  865.             case dtHTML_4_01_Strict$dtd='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'break;
  866.             case dtHTML_4_01_Transitional$dtd='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'break;
  867.             case dtHTML_4_01_Frameset$dtd='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'break;
  868.  
  869.             case dtXHTML_1_1$dtd='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'$extra='xmlns="http://www.w3.org/1999/xhtml"'break;
  870.  
  871.         }
  872.  
  873.  
  874.         $this->hasframes=false;
  875.  
  876.         //Iterates through controls to get the frames
  877.         reset($this->controls->items);
  878.         while (list($k,$v)=each($this->controls->items))
  879.         {
  880.                 if (($v->inheritsFrom('Frame')) || ($v->inheritsFrom('Frameset')))
  881.                 {
  882.                         $this->hasframes=true;
  883.                 }
  884.         }
  885.  
  886.         //Calls beforeshowheader event, if any
  887.         $this->callEvent('onbeforeshowheader',array());
  888.  
  889.         echo "<!-- $this->name begin -->\n";
  890.         //If must dump the header
  891.         if ($this->_showheader)
  892.         {
  893.                 echo "$dtd\n";
  894.                 echo "<html $extra>\n";
  895.                 echo "<head>\n";
  896.  
  897.                 echo "<script type=\"text/javascript\" src=\"".VCL_HTTP_PATH."/js/common.js\"></script>\n";
  898.  
  899.  
  900.                 $this->callEvent('onshowheader',array());
  901.  
  902.                 if ($this->_useajax)
  903.                 {
  904.                 if (($this->ControlState csDesigning!= csDesigning)
  905.                 {
  906.                         global $xajax;
  907.  
  908.                         $xajax->printJavascript("",VCL_HTTP_PATH."/xajax/xajax_js/xajax.js");
  909.                 }
  910.                 }
  911.  
  912.                 $title=$this->Caption;
  913.                 echo "<title>$title</title>\n";
  914.  
  915.                 $cs=explode('|',$this->_encoding);
  916.                 echo "<meta http-equiv=\"Content-Type\" content=\"text/htmlcharset=$cs[1]\" ";
  917.                 if (($this->DocType!='dtHTML_4_01_Strict'&& ($this->DocType!='dtHTML_4_01_Transitional'))
  918.                 {
  919.                     echo "/";
  920.                 }
  921.                 echo ">\n";
  922.  
  923.                 $this->dumpHeaderJavascript();
  924.  
  925.                 $this->dumpChildrenHeaderCode();
  926.  
  927.                 echo "</head>\n";
  928.                 echo "\n";
  929.  
  930.                 $attr="";
  931.  
  932.                 $st="";
  933.  
  934.  
  935.                 if ($this->_leftmargin!=""$st.=" margin-left: ".$this->_leftmargin."px; ";
  936.                 if ($this->_topmargin!=""$st.=" margin-top: ".$this->_topmargin."px; ";
  937.                 if ($this->_rightmargin!=""$st.=" margin-right: ".$this->_rightmargin."px; ";
  938.                 if ($this->_bottommargin!=""$st.=" margin-bottom: ".$this->_bottommargin."px; ";
  939.  
  940.                 if ($st!=""$st=" style=\"$st\" ";
  941.  
  942.                 if ($this->color!=""$attr.=" bgcolor=\"$this->color\" ";
  943.                 if ($this->Background!=""$attr.=" background=\"$this->Background\" ";
  944.  
  945.                 // add the defined JS events to the body
  946.                 if ($this->_jsonload!=null$attr.=" onload=\"return $this->_jsonload(event)\" ";
  947.                 if ($this->_jsonunload!=null$attr.=" onunload=\"return $this->_jsonunload(event)\" ";
  948.  
  949.             if (!$this->hasframes)
  950.             {
  951.                         echo "<body $st $attr>\n";
  952.             }
  953.         }
  954.         else
  955.         {
  956.                 echo "<script type=\"text/JavaScript\">\n";
  957.                 echo "<!--\n";
  958.                 $this->dumpChildrenJavascript();
  959.                 echo "-->\n";
  960.                 echo "</script>\n";
  961.  
  962.                         $this->dumpChildrenHeaderCode();
  963.         }
  964.  
  965.  
  966.         if (!$this->hasframesecho $this->readStartForm();
  967.  
  968.         $this->callEvent('onstartbody',array());
  969.  
  970.  
  971.         //Dump children controls
  972.         if (!$this->hasframes$this->dumpChildren();
  973.         else $this->dumpFrames();
  974.  
  975.         if (($this->_isform&& ($this->_showfooter))
  976.         {
  977.                if (!$this->hasframesecho $this->readEndForm();
  978.         }
  979.  
  980.         $this->callEvent('onaftershowfooter',array());
  981.  
  982.         //If must dump the footer
  983.         if (!$this->hasframes)
  984.         {
  985.                 if ($this->_showfooter)
  986.                 {
  987.                         echo "</body>\n";
  988.                         echo "</html>\n";
  989.                 }
  990.         }
  991.  
  992.         if ($this->hasframes)
  993.         {
  994.                 echo "<noframes><body>\n";
  995.                 echo $this->readStartForm();
  996.                 //Dump children controls
  997.                 $this->dumpChildren();
  998.                 echo $this->readEndForm();
  999.                 echo "</body></noframes>\n";
  1000.         }
  1001.  
  1002.         echo "<!-- $this->name end -->\n";
  1003.  
  1004.     }
  1005.  
  1006.     /**
  1007.      * Dump al children controls
  1008.      *
  1009.      */
  1010.     function dumpChildren()
  1011.     {
  1012.         $width="";
  1013.         $height="";
  1014.         $color="";
  1015.  
  1016.         $alignment="";
  1017.  
  1018.         // fixup to allow initialization of visual stuff in case
  1019.         // if non-visual Q lib classes are used
  1020.  
  1021.         if (defined('QOOXDOO'))
  1022.         {
  1023.                 echo "\n"
  1024.                    . "<script type=\"text/javascript\">\n"
  1025.                    . "    var d = qx.ui.core.ClientDocument.getInstance();\n"
  1026.                    . "    d.setOverflow(\"scrollY\");\n"
  1027.                    . "    d.setBackgroundColor(null);\n"
  1028.                    . "</script>\n";
  1029.         }
  1030.  
  1031.         switch ($this->_alignment)
  1032.         {
  1033.                 case agNone$alignment=""break;
  1034.                 case agLeft$alignment=" align=\"Left\" "break;
  1035.                 case agCenter$alignment=" align=\"Center\" "break;
  1036.                 case agRight$alignment=" align=\"Right\" "break;
  1037.         }
  1038.  
  1039.         if ($this->Color!=""$color=" bgcolor=\"$this->Color\" ";
  1040.         if ($this->Background!=""$background=" background=\"$this->Background\" ";
  1041.         if ($this->Width!=""$width=" width=\"$this->Width\" ";
  1042.         if ($this->Height!=""$height=" style=\"height:".$this->Height."px\" ";
  1043.  
  1044.         if (($this->ControlState csDesigning!= csDesigning)
  1045.         {
  1046.             if (($this->Layout->Type==GRIDBAG_LAYOUT|| ($this->Layout->Type==ROW_LAYOUT|| ($this->Layout->Type==COL_LAYOUT))
  1047.             {
  1048.                 $width=" width=\"100%\" ";
  1049. //                $height="";
  1050.             }
  1051.         }
  1052.  
  1053.         echo "\n<table $width $height border=\"0\" cellpadding=\"0\" cellspacing=\"0\" $color $alignment><tr><td valign=\"top\">\n";
  1054.  
  1055.         if (($this->ControlState csDesigning!= csDesigning)
  1056.         {
  1057.                 $this->Layout->dumpLayoutContents(array('Frame''Frameset'));
  1058.         }
  1059.  
  1060.         echo "</td></tr></table>\n";
  1061.  
  1062.         reset($this->controls->items);
  1063.         while (list($k,$v)=each($this->controls->items))
  1064.         {
  1065.                 if (($v->Visible&& ($v->IsLayer))
  1066.                 {
  1067.                         $v->show();
  1068.                 }
  1069.         }
  1070.  
  1071.     }
  1072.  
  1073.         /**
  1074.         * Dump the page using frames
  1075.         */
  1076.     function dumpFrames()
  1077.     {
  1078.           $frameset=new Frameset(null);
  1079.           $frameset->Align=alClient;
  1080.           $frameset->FrameSpacing=$this->FrameSpacing;
  1081.           $frameset->FrameBorder=$this->FrameBorder;
  1082.           $frameset->BorderWidth=$this->BorderWidth;
  1083.           $frameset->controls=$this->controls;
  1084.           $frameset->show();
  1085.     }
  1086.  
  1087.         /**
  1088.         * Specifies the top margin spacing
  1089.         * @return integer 
  1090.         */
  1091.     function getTopMargin(return $this->_topmargin}
  1092.     function setTopMargin($value$this->_topmargin=$value}
  1093.     function defaultTopMargin(return 0}
  1094.  
  1095.         /**
  1096.         * Specifies the left margin spacing
  1097.         * @return integer 
  1098.         */
  1099.     function getLeftMargin(return $this->_leftmargin}
  1100.     function setLeftMargin($value$this->_leftmargin=$value}
  1101.     function defaultLeftMargin(return 0}
  1102.  
  1103.         /**
  1104.         * Specifies the bottom margin spacing
  1105.         * @return integer 
  1106.         */
  1107.     function getBottomMargin(return $this->_bottommargin}
  1108.     function setBottomMargin($value$this->_bottommargin=$value}
  1109.     function defaultBottomMargin(return 0}
  1110.  
  1111.         /**
  1112.         * Specifies the right margin spacing
  1113.         * @return integer 
  1114.         */
  1115.     function getRightMargin(return $this->_rightmargin}
  1116.     function setRightMargin($value$this->_rightmargin=$value}
  1117.     function defaultRightMargin(return 0}
  1118.  
  1119.         /**
  1120.         * If false, the form doesn't dump any header code
  1121.         * @return boolean 
  1122.         */
  1123.     function getShowHeader(return $this->_showheader}
  1124.     function setShowHeader($value$this->_showheader=$value}
  1125.     function defaultShowHeader(return 1}
  1126.  
  1127.         /**
  1128.         * If false, the form doesn't generate any <form> tag, but events won't be processed
  1129.         * @return boolean 
  1130.         */
  1131.     function getIsForm(return $this->_isform}
  1132.     function setIsForm($value$this->_isform=$value}
  1133.     function defaultIsForm(return 1}
  1134.  
  1135.         /**
  1136.         * If true, this page doesn't render itself, but it's meant to be used as base for another forms
  1137.         * @return boolean 
  1138.         */
  1139.     function getIsMaster(return $this->_ismaster}
  1140.     function setIsMaster($value$this->_ismaster=$value}
  1141.  
  1142.         /**
  1143.         * If false, the form doesn't dump any footer code
  1144.         * @return boolean 
  1145.         */
  1146.     function getShowFooter(return $this->_showfooter}
  1147.     function setShowFooter($value$this->_showfooter=$value}
  1148.     function defaultShowFooter(return 1}
  1149.  
  1150.         /**
  1151.         * Fired before show the header
  1152.         */
  1153.     function getOnBeforeShowHeader(return $this->_onbeforeshowheader}
  1154.     function setOnBeforeShowHeader($value$this->_onbeforeshowheader=$value}
  1155.     function defaultOnBeforeShowHeader(return ""}
  1156.  
  1157.         /**
  1158.         * Fired after show the footer
  1159.         */
  1160.     function getOnAfterShowFooter(return $this->_onaftershowfooter}
  1161.     function setOnAfterShowFooter($value$this->_onaftershowfooter=$value}
  1162.     function defaultOnAfterShowFooter(return ""}
  1163.  
  1164.         /**
  1165.         * Fired when showing the header
  1166.         */
  1167.     function getOnShowHeader(return $this->_onshowheader}
  1168.     function setOnShowHeader($value$this->_onshowheader=$value}
  1169.     function defaultOnShowHeader(return ""}
  1170.  
  1171.         /**
  1172.         * Fired when showing the body
  1173.         */
  1174.     function getOnStartBody(return $this->_onstartbody}
  1175.     function setOnStartBody($value$this->_onstartbody=$value}
  1176.     function defaultOnStartBody(return ""}
  1177.  
  1178.         /**
  1179.         * Fired when the page is created and all components have been loaded
  1180.         */
  1181.     function getOnCreate(return $this->_oncreate}
  1182.     function setOnCreate($value$this->_oncreate=$value}
  1183.     function defaultOnCreate(return ""}
  1184.  
  1185. }
  1186.  
  1187. /**
  1188.  * HiddenField
  1189.  *
  1190.  * A component to generate an html hidden field, useful to send information
  1191.  * to another script, set the value for it on the Value property.
  1192.  * The component is only visible at design time.
  1193.  */
  1194. class HiddenField extends Control
  1195. {
  1196.         protected $_onsubmit = null;
  1197.  
  1198.         protected $_value = "";
  1199.  
  1200.         function __construct($aowner=null)
  1201.         {
  1202.                 //Calls inherited constructor
  1203.                 parent::__construct($aowner);
  1204.  
  1205.                 $this->Width=200;
  1206.                 $this->Height=18;
  1207.         }
  1208.  
  1209.         function preinit()
  1210.         {
  1211.                 parent::preinit();
  1212.                 
  1213.                 //If there is something posted
  1214.                 $submitted $this->input->{$this->Name};
  1215.                 if (is_object($submitted))
  1216.                 {
  1217.                         //Set the value
  1218.                         $this->_value = $submitted->asString();
  1219.                 }
  1220.         }
  1221.  
  1222.         function init()
  1223.         {
  1224.                 parent::init();
  1225.  
  1226.                 $submitted $this->input->{$this->Name};
  1227.  
  1228.                 // Allow the OnSubmit event to be fired because it is not
  1229.                 // a mouse or keyboard event.
  1230.                 if ($this->_onsubmit != null && is_object($submitted))
  1231.                 {
  1232.                         $this->callEvent('onsubmit'array());
  1233.                 }
  1234.         }
  1235.  
  1236.         function dumpContents()
  1237.         {
  1238.                 if (($this->ControlState csDesigning!= csDesigning)
  1239.                 {
  1240.                         if ($this->_onshow != null)
  1241.                         {
  1242.                                 $this->callEvent('onshow'array());
  1243.                         }
  1244.                         else
  1245.                         {
  1246.                                 echo "<input type=\"hidden\" id=\"$this->Name\" name=\"$this->Name\" value=\"$this->Value\" />";
  1247.                         }
  1248.                 }
  1249.                 else
  1250.                 {
  1251.                         echo "<table width=\"$this->width\" cellpadding=\"0\" cellspacing=\"0\" height=\"$this->height\"><tr><td style=\"background-color: #FFFF99border: 1px solid #666666; font-size:10pxfont-family:verdana,tahoma,arial\" align=\"center\">$this->Name=$this->Value</td></tr></table>";
  1252.                 }
  1253.         }
  1254.  
  1255.         /*
  1256.         * Publish the events for the component
  1257.         */
  1258.  
  1259.         /**
  1260.         * Occurs when the form containing the control was submitted.
  1261.         * @return mixed Returns the event handler or null if no handler is set.
  1262.         */
  1263.         function getOnSubmit(return $this->_onsubmit}
  1264.         /**
  1265.         * Occurs when the form containing the control was submitted.
  1266.         * @param mixed Event handler or null if no handler is set.
  1267.         */
  1268.         function setOnSubmit($value$this->_onsubmit=$value}
  1269.         function defaultOnSubmit(return null}
  1270.  
  1271.  
  1272.         /*
  1273.         * Publish the JS events for the component
  1274.         */
  1275.  
  1276.         function getjsOnChange                  (return $this->readjsOnChange()}
  1277.         function setjsOnChange                  ($value$this->writejsOnChange($value)}
  1278.  
  1279.  
  1280.         /*
  1281.         * Publish the properties for the component
  1282.         */
  1283.  
  1284.         /*
  1285.         * Specified the value for the HTML hidden field, and you will be able to
  1286.         * read this value on the script that receives the information.
  1287.         * @return string
  1288.         */
  1289.         function getValue(return $this->_value}
  1290.         /*
  1291.         * Specified the value for the HTML hidden field, and you will be able to
  1292.         * read this value on the script that receives the information.
  1293.         * @param string $value
  1294.         */
  1295.         function setValue($value$this->_value=$value}
  1296.         function defaultValue(return ""}
  1297. }
  1298.  
  1299.  
  1300. define('fbNo','fbNo');
  1301. define('fbYes','fbYes');
  1302. define('fbDefault','fbDefault');
  1303.  
  1304. /**
  1305.  * Frameset class
  1306.  *
  1307.  * A class to encapsulate a frame set and generate frames
  1308.  * This class is also used in the Page component to generate a frameset.
  1309.  *
  1310.  * For further information about HTML framesets and frames please visit following link:
  1311.  * @link http://www.w3.org/TR/html401/present/frames.html
  1312.  */
  1313. class Frameset extends ScrollingControl
  1314. {
  1315.         function __construct($aowner=null)
  1316.         {
  1317.                 //Calls inherited constructor
  1318.                 parent::__construct($aowner);
  1319.                 $this->ControlStyle="csAcceptsControls=1";
  1320.         }
  1321.  
  1322.         protected $_align=alClient;
  1323.         protected $_borderwidth=0;
  1324.         protected $_border="";
  1325.         protected $_framespacing=0;
  1326.         protected $_frameborder=fbNo;
  1327.  
  1328.         protected $_jsonload=null;
  1329.         protected $_jsonunload=null;
  1330.  
  1331.  
  1332.         /**
  1333.         * The javascript OnLoad event is called after all nested framesets and
  1334.         * frames are finished with loading their content.
  1335.         * @return mixed 
  1336.         */
  1337.         function getjsOnLoad(return $this->_jsonload}
  1338.         /**
  1339.         * The javascript OnLoad event is called after all nested framesets and
  1340.         * frames are finished with loading their content.
  1341.         * @param mixed $value 
  1342.         */
  1343.         function setjsOnLoad($value$this->_jsonload=$value}
  1344.         function defaultjsOnLoad(return null}
  1345.  
  1346.         /**
  1347.         * The javascript OnUnload event is called after all nested framesets and
  1348.         * frames are finished with unloading their content.
  1349.         * @return mixed 
  1350.         */
  1351.         function getjsOnUnload(return $this->_jsonunload}
  1352.         /**
  1353.         * The javascript OnUnload event is called after all nested framesets and
  1354.         * frames are finished with unloading their content.
  1355.         * @param mixed $value 
  1356.         */
  1357.         function setjsOnUnload($value$this->_jsonunload=$value}
  1358.         function defaultjsOnUnload(return null}
  1359.  
  1360.  
  1361.         function getAlign(return $this->_align}
  1362.         function setAlign($value$this->_align=$value}
  1363.         function defaultAlign(return alClient}
  1364.  
  1365.         /**
  1366.         * Sets or retrieves the amount of additional space between the frames.
  1367.         * @return integer 
  1368.         */
  1369.         function getFrameSpacing(return $this->_framespacing;       }
  1370.         /**
  1371.         * Sets or retrieves the amount of additional space between the frames.
  1372.         * @param integer $value 
  1373.         */
  1374.         function setFrameSpacing($value$this->_framespacing=$value}
  1375.         function defaultFrameSpacing(return 0}
  1376.  
  1377.         /**
  1378.         * String that specifies or receives one of the following values.
  1379.         * fbDefault Inset border is drawn.
  1380.         * fbNo       No border is drawn.
  1381.         * fbYes     Inset border is drawn.
  1382.         */
  1383.         function getFrameBorder(return $this->_frameborder}
  1384.         /**
  1385.         * String that specifies or receives one of the following values.
  1386.         * fbDefault Inset border is drawn.
  1387.         * fbNo       No border is drawn.
  1388.         * fbYes     Inset border is drawn.
  1389.         */
  1390.         function setFrameBorder($value$this->_frameborder=$value}
  1391.         function defaultFrameBorder(return fbNo}
  1392.  
  1393.         /**
  1394.         * Width of the left, right, top, and bottom borders of the object.
  1395.         * @return integer 
  1396.         */
  1397.         function getBorderWidth(return $this->_borderwidth}
  1398.         /**
  1399.         * Width of the left, right, top, and bottom borders of the object.
  1400.         * @param integer $value 
  1401.         */
  1402.         function setBorderWidth($value$this->_borderwidth=$value}
  1403.         function defaultBorderWidth(return 0}
  1404.  
  1405.  
  1406.     /**
  1407.     * Returns the defined JS events for the frameset.
  1408.     * @return string If empty no JS events are set.
  1409.     */
  1410.     function readFramesetJSEvents()
  1411.     {
  1412.         $result "";
  1413.  
  1414.         if ($this->_jsonload!=null)  $event=$this->_jsonload;  $result.=" onload=\"return $event(event)\" "}
  1415.         if ($this->_jsonunload!=null)  $event=$this->_jsonunload;  $result.=" onunload=\"return $event(event)\" "}
  1416.  
  1417.         return $result;
  1418.     }
  1419.  
  1420.     function dumpJavascript()
  1421.     {
  1422.         parent::dumpJavascript();
  1423.  
  1424.         $this->dumpJSEvent($this->_jsonload);
  1425.         $this->dumpJSEvent($this->_jsonunload);
  1426.     }
  1427.  
  1428.     /**
  1429.     * Dump the frames inside the frameset that are aligned to alClient
  1430.     */
  1431.     function dumpClientFrames()
  1432.     {
  1433.         $fakeframe=true;
  1434.         reset($this->controls->items);
  1435.         while (list($k,$v)=each($this->controls->items))
  1436.         {
  1437.                 if (($v->inheritsFrom('Frame')) || ($v->inheritsFrom('Frameset')))
  1438.                 {
  1439.                         if ($v->Align==alClient)
  1440.                         {
  1441.                                 $v->show();
  1442.                                 $fakeframe=false;
  1443.                         }
  1444.                 }
  1445.         }
  1446.  
  1447.         if ($fakeframe)
  1448.         {
  1449.                 echo "<frame />";
  1450.         }
  1451.     }
  1452.  
  1453.     /**
  1454.     * Dump the frames inside the frameset that are aligned to alLeft or alRight
  1455.     */
  1456.     function dumpHorizontalFrames($hframes$outputevents)
  1457.     {
  1458.                 if (count($hframes)!=0)
  1459.                 {
  1460.                         reset($hframes);
  1461.                         $leftwidths="";
  1462.                         $rightwidths="";
  1463.                         while(list($key$val)=each($hframes))
  1464.                         {
  1465.                           if ($val->Align==alLeft$leftwidths.=$val->Width.",";
  1466.                           if ($val->Align==alRight$rightwidths.=",".$val->Width;
  1467.                         }
  1468.  
  1469.                         // only output events when they have an affect
  1470.                         // (only the most outer frameset will receive the onload event)
  1471.                         $events ($outputevents$this->readFramesetJSEvents("";
  1472.  
  1473.                         $frameborder "";  // fbDefault
  1474.                         switch ($this->FrameBorder)
  1475.                         {
  1476.                                 case fbNo$frameborder "no"break;
  1477.                                 case fbYes$frameborder "yes"break;
  1478.                         }
  1479.  
  1480.                         echo "<frameset cols=\"$leftwidths*$rightwidths\" rows=\"*\" frameborder=\"$frameborder\" border=\"$this->BorderWidth\" framespacing=\"$this->FrameSpacing\" $events>\n";
  1481.                         reset($hframes);
  1482.                         while(list($key$val)=each($hframes))
  1483.                         {
  1484.                           if ($val->Align==alLeft$val->show();
  1485.                         }
  1486.                         //Dump here the alClient frames
  1487.                         $this->dumpClientFrames();
  1488.  
  1489.                         reset($hframes);
  1490.                         while(list($key$val)=each($hframes))
  1491.                         {
  1492.                           if ($val->Align==alRight$val->show();
  1493.                         }
  1494.                         echo "</frameset>\n";
  1495.                 }
  1496.                 else
  1497.                 {
  1498.                         $this->dumpClientFrames();
  1499.                 }
  1500.     }
  1501.  
  1502.     /**
  1503.     * Dump the whole frameset, with the alignment algorithm
  1504.     */
  1505.     function dumpContents()
  1506.     {
  1507.                 if (($this->ControlState csDesigning)==csDesigning)
  1508.                 {
  1509.                         $msg=$this->Name;
  1510.                         $msg="$this->Name<br>place Frames inside this Frameset";
  1511.  
  1512.                         $bstyle=" style=\"border: 1px dotted #000000;font-size:10px; font-family:verdana,tahoma,arial\" ";
  1513.                         echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"$this->width\" height=\"$this->height\"><tr><td $bstyle align=\"center\">$msg</td></tr></table>";
  1514.                 }
  1515.                 else
  1516.                 {
  1517.         reset($this->controls->items);
  1518.         $vframes=array();
  1519.         $hframes=array();
  1520.         while (list($k,$v)=each($this->controls->items))
  1521.         {
  1522.                 if (($v->inheritsFrom('Frame')) || ($v->inheritsFrom('Frameset')))
  1523.                 {
  1524.                         if (($v->Align==alTop|| ($v->Align==alBottom))
  1525.                         {
  1526.                                 $vframes[$v->Top]=$v;
  1527.                         }
  1528.                         if (($v->Align==alLeft|| ($v->Align==alRight))
  1529.                         {
  1530.                                 $hframes[$v->Left]=$v;
  1531.                         }
  1532.                 }
  1533.         }
  1534.  
  1535.         ksort($vframes,SORT_NUMERIC);
  1536.         ksort($hframes,SORT_NUMERIC);
  1537.  
  1538.         //Dump rows
  1539.         if (count($vframes)!=0)
  1540.         {
  1541.                 reset($vframes);
  1542.                 $topheights="";
  1543.                 $bottomheights="";
  1544.                 while(list($key$val)=each($vframes))
  1545.                 {
  1546.                   if ($val->Align==alTop$topheights.=$val->Height.",";
  1547.                   if ($val->Align==alBottom$bottomheights.=",".$val->Height;
  1548.                 }
  1549.  
  1550.                 $events $this->readFramesetJSEvents();
  1551.  
  1552.                 echo "<frameset rows=\"$topheights*$bottomheights\" cols=\"*\" frameborder=\"$this->FrameBorder\" border=\"$this->BorderWidth\" framespacing=\"$this->FrameSpacing\" $events>\n";
  1553.                 reset($vframes);
  1554.                 while(list($key$val)=each($vframes))
  1555.                 {
  1556.                   if ($val->Align==alTop$val->show();
  1557.                 }
  1558.                 //Dump here the horizontal frameset
  1559.                 //**********************************
  1560.                 $this->dumpHorizontalFrames($hframesfalse);
  1561.                 //**********************************
  1562.                 reset($vframes);
  1563.                 while(list($key$val)=each($vframes))
  1564.                 {
  1565.                   if ($val->Align==alBottom$val->show();
  1566.                 }
  1567.                 echo "</frameset>\n";
  1568.         }
  1569.         else
  1570.         {
  1571.                 $this->dumpHorizontalFrames($hframestrue);
  1572.         }
  1573.         }
  1574.  
  1575.     }
  1576.  
  1577. }
  1578.  
  1579. define('fsAuto','fsAuto');
  1580. define('fsYes','fsYes');
  1581. define('fsNo','fsNo');
  1582. /**
  1583.  * Frame control
  1584.  *
  1585.  * A frame is a sub-component of a Frameset. It should only be used within a
  1586.  * Frameset control.
  1587.  * For further information about HTML frames please visit following link:
  1588.  * @link http://www.w3.org/TR/html401/present/frames.html
  1589.  */
  1590. class Frame extends ScrollingControl
  1591. {
  1592.         function __construct($aowner=null)
  1593.         {
  1594.                 //Calls inherited constructor
  1595.                 parent::__construct($aowner);
  1596.                 $this->ControlStyle="csAcceptsControls=1";
  1597.         }
  1598.  
  1599.         protected $_source="";
  1600.  
  1601.         /**
  1602.         * Defines the URL of the file to show in the frame.
  1603.         * @return string 
  1604.         */
  1605.         function getSource(return $this->_source}
  1606.         /**
  1607.         * Defines the URL of the file to show in the frame.
  1608.         * @param string $value 
  1609.         */
  1610.         function setSource($value$this->_source=$value}
  1611.         function defaultSource(return ""}
  1612.  
  1613.         protected $_borders=1;
  1614.  
  1615.         /**
  1616.         * Specifies whether or not to display border around the frame. This
  1617.         * value should be 0 or 1.
  1618.         * @return integer 
  1619.         */
  1620.         function getBorders(return $this->_borders}
  1621.         /**
  1622.         * Specifies whether or not to display border around the frame. This
  1623.         * value should be 0 or 1.
  1624.         * @param integer $value 
  1625.         */
  1626.         function setBorders($value$this->_borders=$value}
  1627.         function defaultBorders(return 1}
  1628.  
  1629.         protected $_align=alLeft;
  1630.  
  1631.         function getAlign(return $this->_align}
  1632.         function setAlign($value$this->_align=$value}
  1633.         function defaultAlign(return alLeft}
  1634.  
  1635.         protected $_marginwidth=0;
  1636.  
  1637.        /**
  1638.        * Defines the left and right margins in the frame.
  1639.        * @return integer 
  1640.        */
  1641.         function getMarginWidth(return $this->_marginwidth}
  1642.         /**
  1643.        * Defines the left and right margins in the frame.
  1644.        * @param integer $value 
  1645.        */
  1646.         function setMarginWidth($value$this->_marginwidth=$value}
  1647.         function defaultMarginWidth(return 0}
  1648.  
  1649.         protected $_marginheight=0;
  1650.  
  1651.         /**
  1652.         * Defines the top and bottom margins in the frame.
  1653.         * @return integer 
  1654.         */
  1655.         function getMarginHeight(return $this->_marginheight}
  1656.         /**
  1657.         * Defines the top and bottom margins in the frame.
  1658.         * @param integer $value 
  1659.         */
  1660.         function setMarginHeight($value$this->_marginheight=$value}
  1661.         function defaultMarginHeight(return 0}
  1662.  
  1663.         protected $_resizeable=1;
  1664.  
  1665.         /**
  1666.         * When set to false the user cannot resize the frame.
  1667.         * @return bool 
  1668.         */
  1669.         function getResizeable(return $this->_resizeable}
  1670.         /**
  1671.         * When set to false the user cannot resize the frame.
  1672.         * @param bool $value 
  1673.         */
  1674.         function setResizeable($value$this->_resizeable=$value}
  1675.         function defaultResizeable(return 1}
  1676.  
  1677.         protected $_scrolling=fsAuto;
  1678.  
  1679.         /**
  1680.         * Determines scrollbar action.
  1681.         * @retun enum (fsAuot, fsYes, fsNo)
  1682.         */
  1683.         function getScrolling(return $this->_scrolling}
  1684.         /**
  1685.         * Determines scrollbar action.
  1686.         * @param enum (fsAuot, fsYes, fsNo)
  1687.         */
  1688.         function setScrolling($value$this->_scrolling=$value}
  1689.         function defaultScrolling(return fsAuto}
  1690.  
  1691.  
  1692.         protected $_jsonload=null;
  1693.  
  1694.         /**
  1695.         * The javascript OnLoad event is called after all nested framesets and
  1696.         * frames are finished with loading their content.
  1697.         * @return mixed 
  1698.         */
  1699.         function getjsOnLoad(return $this->_jsonload}
  1700.         /**
  1701.         * The javascript OnLoad event is called after all nested framesets and
  1702.         * frames are finished with loading their content.
  1703.         * @param mixed $value 
  1704.         */
  1705.         function setjsOnLoad($value$this->_jsonload=$value}
  1706.         function defaultjsOnLoad(return null}
  1707.  
  1708.         /**
  1709.         * Returns the defined JS events for the frame.
  1710.         * @return string If empty no JS events are set.
  1711.         */
  1712.         function readFrameJSEvents()
  1713.         {
  1714.             $result "";
  1715.  
  1716.             if ($this->_jsonload!=null)  $event=$this->_jsonload;  $result.=" onload=\"return $event(event)\" "}
  1717.  
  1718.             return $result;
  1719.         }
  1720.  
  1721.         function dumpJavascript()
  1722.         {
  1723.             parent::dumpJavascript();
  1724.  
  1725.             $this->dumpJSEvent($this->_jsonload);
  1726.         }
  1727.  
  1728.         function dumpContents()
  1729.         {
  1730.                 if (($this->ControlState csDesigning)==csDesigning)
  1731.                 {
  1732.                         $msg=$this->Name;
  1733.                         if (trim($this->Source)=='')
  1734.                         {
  1735.                                 $msg="Fill Source property with the URL you want to show on this Frame";
  1736.                         }
  1737.  
  1738.                         $bstyle=" style=\"border: 1px dotted #000000;font-size:10px; font-family:verdana,tahoma,arial\" ";
  1739.                         echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"$this->width\" height=\"$this->height\"><tr><td $bstyle align=\"center\">$msg</td></tr></table>";
  1740.                 }
  1741.                 else
  1742.                 {
  1743.                         $resizeable="";
  1744.  
  1745.                         if ($this->Resizeable!=1)
  1746.                         {
  1747.                                 $resizeable="noresize";
  1748.                         }
  1749.  
  1750.                         if (($this->ControlState csDesigning)==csDesigning)
  1751.                         {
  1752.                                 echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n";
  1753.                                 echo "<HTML>\n";
  1754.                                 echo "<HEAD>\n";
  1755.                                 echo "</HEAD>\n";
  1756.                                 echo "<FRAMESET cols=\"$this->Width\">\n";
  1757.                         }
  1758.  
  1759.                         $scrolling "auto";    //fsAuto
  1760.                         switch ($this->Scrolling)
  1761.                         {
  1762.                                 case fsYes$scrolling "yes"break;
  1763.                                 case fsNo$scrolling "no"break;
  1764.                         }
  1765.  
  1766.                         $events $this->readFrameJSEvents();
  1767.  
  1768.                         echo "<frame src=\"".$this->Source."\" name=\"".$this->name."\" scrolling=\"$scrolling\" $resizeable marginwidth=\"$this->MarginWidth\" marginheight=\"$this->MarginHeight\" frameborder=\"$this->Borders\" $events>\n";
  1769.  
  1770.                         if (($this->ControlState csDesigning)==csDesigning)
  1771.                         {
  1772.                                 echo "</FRAMESET>\n";
  1773.                                 echo "</HTML>\n";
  1774.                         }
  1775.                 }
  1776.  
  1777.         }
  1778. }
  1779.  
  1780.  
  1781.  
  1782. ?>

Documentation generated on Tue, 27 Mar 2007 13:34:55 +0200 by phpDocumentor 1.3.1