diff options
author | ctrlaltca@gmail.com <> | 2011-06-25 09:08:40 +0000 |
---|---|---|
committer | ctrlaltca@gmail.com <> | 2011-06-25 09:08:40 +0000 |
commit | cda44920115f2aadd7c3fbe2df13cb48a2cbc0c5 (patch) | |
tree | b367d872dcf3cec40497f4d6755ce7bb47312058 /framework/Web/UI/WebControls | |
parent | 87e7366d4d9d3de79772b851f8772a4011d6227d (diff) |
applied further "progressive rendering" patches (#235)
added TFlushOutput component
fixed THtmlarea quickstart demo
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 14 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TFlushOutput.php | 86 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/THtmlArea.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TPanel.php | 30 |
4 files changed, 118 insertions, 14 deletions
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 2f9758d1..1dabb7ce 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -407,6 +407,7 @@ class TDatePicker extends TTextBox $page->registerPostDataLoader($uniqueID.TControl::ID_SEPARATOR.'year');
}
$this->publishCalendarStyle();
+ $this->registerCalendarClientScriptPre();
}
/**
@@ -427,7 +428,7 @@ class TDatePicker extends TTextBox $this->renderDropDownListCalendar($writer);
if($this->hasDayPattern())
{
- $this->registerCalendarClientScript();
+ $this->registerCalendarClientScriptPost();
$this->renderDatePickerButtons($writer);
}
}
@@ -840,20 +841,27 @@ class TDatePicker extends TTextBox {
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
- $this->registerCalendarClientScript();
+ $this->registerCalendarClientScriptPost();
}
/**
* Registers the javascript code to initialize the date picker.
*/
- protected function registerCalendarClientScript()
+ protected function registerCalendarClientScriptPre()
{
if($this->getShowCalendar())
{
$cs = $this->getPage()->getClientScript();
$cs->registerPradoScript("datepicker");
+ }
+ }
+ protected function registerCalendarClientScriptPost()
+ {
+ if($this->getShowCalendar())
+ {
+ $cs = $this->getPage()->getClientScript();
if(!$cs->isEndScriptRegistered('TDatePicker.spacer'))
{
$spacer = $this->getAssetUrl('spacer.gif');
diff --git a/framework/Web/UI/WebControls/TFlushOutput.php b/framework/Web/UI/WebControls/TFlushOutput.php new file mode 100644 index 00000000..ab79fe0b --- /dev/null +++ b/framework/Web/UI/WebControls/TFlushOutput.php @@ -0,0 +1,86 @@ +<?php
+/**
+ * TFlushOutput class file
+ *
+ * @author Berczi Gabor <gabor.berczi@devworx.hu>
+ * @link http://www.pradosoft.com/
+ * @license http://www.pradosoft.com/license/
+ * @version $Id: TFlushOutput.php $
+ * @package System.Web.UI.WebControls
+ */
+
+/**
+ * TFlushOutput class.
+ *
+ * TFlushOutput enables forced flushing of the current output buffer
+ * at (a) certain point(s) in the page, after rendering of all previous
+ * controls has been completed.
+ *
+ * To use TFlushOutput, simply place it in a template where you want
+ * the have the output buffered between the start of the page or the
+ * last TFlushOutput to be sent to the client immediately
+ * <code>
+ * <com:TFlushOutput />
+ * </code>
+ *
+ * You can specify whether you want to keep buffering of the output
+ * (if it was enabled) till the next occourence of a <com: TFlushOutput />
+ * or the end of the page rendering, or stop buffering, by using the
+ * {@link setContinueBuffering ContinueBuffering}.
+ *
+ * @author Berczi Gabor <gabor.berczi@devworx.hu>
+ * @version $Id: TFlushOutput.php $
+ * @package System.Web.UI.WebControls
+ * @since 3.1
+ */
+class TFlushOutput extends TControl
+{
+ /**
+ * @var boolean whether to continue buffering of output
+ */
+ private $_continueBuffering=true;
+
+
+ /**
+ * Constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->EnableViewState = false;
+ }
+
+ /**
+ * @return Tells whether buffering of output can continue after this point
+ */
+ public function getContinueBuffering()
+ {
+ return $this->_continueBuffering;
+ }
+
+ /**
+ * @param boolean sets whether buffering of output can continue after this point
+ */
+ public function setContinueBuffering($value)
+ {
+ $this->_continueBuffering = TPropertyValue::ensureBoolean($value);
+ }
+
+ /**
+ * Flushes the output of all completely rendered controls to the client.
+ * @param THtmlWriter writer for the rendering purpose
+ */
+ public function render($writer)
+ {
+$writer->write('<!-- flush -->');
+ // ajax responses can't be parsed by the client side before loaded and returned completely,
+ // so don't bother with flushing output somewhere mid-page if refreshing in a callback
+ if (!$this->Page->IsCallback)
+ {
+ $this->Page->flushWriter();
+// $this->Application->flushOutput($this->ContinueBuffering);
+ }
+ }
+}
+
+?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php index b11778bd..2411f8f3 100644 --- a/framework/Web/UI/WebControls/THtmlArea.php +++ b/framework/Web/UI/WebControls/THtmlArea.php @@ -402,7 +402,7 @@ class THtmlArea extends TTextBox $options['debug'] = false;
$js = TJavaScript::encode($options,true,true);
$script = "if(typeof(tinyMCE_GZ)!='undefined'){ tinyMCE_GZ.init({$js}); }";
- $scripts->registerBeginScript($key, $script);
+ $scripts->registerEndScript($key, $script);
}
}
diff --git a/framework/Web/UI/WebControls/TPanel.php b/framework/Web/UI/WebControls/TPanel.php index cf21eeef..227a9a3e 100644 --- a/framework/Web/UI/WebControls/TPanel.php +++ b/framework/Web/UI/WebControls/TPanel.php @@ -4,7 +4,7 @@ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2011 PradoSoft + * @copyright Copyright © 2005-2011 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -73,15 +73,7 @@ class TPanel extends TWebControl {
parent::addAttributesToRender($writer);
if(($butt=$this->getDefaultButton())!=='')
- {
- if(($button=$this->findControl($butt))===null)
- throw new TInvalidDataValueException('panel_defaultbutton_invalid',$butt);
- else
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerDefaultButton($this, $button);
- }
- }
+ $writer->addAttribute('id',$this->getClientID());
}
/**
@@ -232,5 +224,23 @@ class TPanel extends TWebControl $writer->renderEndTag();
parent::renderEndTag($writer);
}
+
+ public function render($writer)
+ {
+ parent::render($writer);
+
+ if(($butt=$this->getDefaultButton())!=='')
+ {
+ $buttons = $this->findControlsByID($butt);
+ if (count($buttons)>0)
+ $button = reset($buttons);
+ else
+ $buttons = null;
+ if($button===null)
+ throw new TInvalidDataValueException('panel_defaultbutton_invalid',$butt);
+ else
+ $this->getPage()->getClientScript()->registerDefaultButton($this, $button);
+ }
+ }
}
|