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 | |
parent | 87e7366d4d9d3de79772b851f8772a4011d6227d (diff) |
applied further "progressive rendering" patches (#235)
added TFlushOutput component
fixed THtmlarea quickstart demo
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/Javascripts/source/packages.php | 4 | ||||
-rw-r--r-- | framework/Web/THttpResponse.php | 10 | ||||
-rwxr-xr-x | framework/Web/UI/ActiveControls/TActiveDatePicker.php | 8 | ||||
-rwxr-xr-x | framework/Web/UI/ActiveControls/TActiveFileUpload.php | 4 | ||||
-rwxr-xr-x | framework/Web/UI/ActiveControls/TDraggable.php | 2 | ||||
-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 |
9 files changed, 135 insertions, 25 deletions
diff --git a/framework/Web/Javascripts/source/packages.php b/framework/Web/Javascripts/source/packages.php index 5dfbe2c5..a8484820 100644 --- a/framework/Web/Javascripts/source/packages.php +++ b/framework/Web/Javascripts/source/packages.php @@ -94,8 +94,8 @@ $dependencies = array( 'slider' => array('prado', 'slider'),
'keyboard' => array('prado', 'keyboard'),
'tabpanel' => array('prado', 'tabpanel'),
- 'activedatepicker' => array('datepicker', 'ajax', 'activedatepicker'),
- 'activefileupload' => array('prado', 'ajax', 'activefileupload'),
+ 'activedatepicker' => array('prado', 'datepicker', 'ajax', 'activedatepicker'),
+ 'activefileupload' => array('prado', 'effects', 'ajax', 'activefileupload'),
'dragdropextra' => array('prado', 'effects', 'ajax', 'dragdrop','dragdropextra'),
'accordion' => array('prado', 'effects', 'accordion'),
);
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index 07d11a2c..1f314dda 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -482,12 +482,12 @@ class THttpResponse extends TModule implements ITextWriter if (ob_get_length()>0)
{
if (!$continueBuffering)
- {
- $this->_bufferOutput = false;
- ob_end_flush();
- }
+ {
+ $this->_bufferOutput = false;
+ ob_end_flush();
+ }
else
- ob_flush();
+ ob_flush();
flush();
}
}
diff --git a/framework/Web/UI/ActiveControls/TActiveDatePicker.php b/framework/Web/UI/ActiveControls/TActiveDatePicker.php index 3d803664..38796a5e 100755 --- a/framework/Web/UI/ActiveControls/TActiveDatePicker.php +++ b/framework/Web/UI/ActiveControls/TActiveDatePicker.php @@ -107,12 +107,16 @@ class TActiveDatePicker extends TDatePicker implements ICallbackEventHandler, I /** * Registers the javascript code to initialize the date picker. */ - protected function registerCalendarClientScript() + + protected function registerCalendarClientScriptPre() { - $cs = $this->getPage()->getClientScript(); $cs->registerPradoScript("activedatepicker"); + } + protected function registerCalendarClientScriptPost() + { + $cs = $this->getPage()->getClientScript(); if(!$cs->isEndScriptRegistered('TDatePicker.spacer')) { $spacer = $this->getAssetUrl('spacer.gif'); diff --git a/framework/Web/UI/ActiveControls/TActiveFileUpload.php b/framework/Web/UI/ActiveControls/TActiveFileUpload.php index 7820312d..1eaad5d9 100755 --- a/framework/Web/UI/ActiveControls/TActiveFileUpload.php +++ b/framework/Web/UI/ActiveControls/TActiveFileUpload.php @@ -204,9 +204,9 @@ EOS; /** * Publish the javascript */ - public function onPreRender($param){ + public function onPreRender($param) + { parent::onPreRender($param); - $this->getPage()->getClientScript()->registerPradoScript('effects'); $this->getPage()->getClientScript()->registerPradoScript('activefileupload'); if(!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId'] == $this->getClientID()) diff --git a/framework/Web/UI/ActiveControls/TDraggable.php b/framework/Web/UI/ActiveControls/TDraggable.php index 10e78b9b..10ecf5a5 100755 --- a/framework/Web/UI/ActiveControls/TDraggable.php +++ b/framework/Web/UI/ActiveControls/TDraggable.php @@ -145,6 +145,7 @@ class TDraggable extends TPanel public function onPreRender($param) { parent::onPreRender($param); + $cs=$this->getPage()->getClientScript(); if ($this->getGhosting()==TDraggableGhostingOptions::SuperGhosting) $cs->registerPradoScript('dragdropextra'); else @@ -158,6 +159,7 @@ class TDraggable extends TPanel protected function addAttributesToRender($writer) { parent::addAttributesToRender($writer); + $cs=$this->getPage()->getClientScript(); $writer->addAttribute('id',$this->getClientID()); $options=TJavascript::encode($this->getPostBackOptions()); $class=$this->getClientClassName(); 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);
+ }
+ }
}
|