summaryrefslogtreecommitdiff
path: root/lib/prado/framework/Web/UI/ActiveControls/TActiveMultiView.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-02-24 23:18:07 +0100
committeremkael <emkael@tlen.pl>2016-02-24 23:18:07 +0100
commit6f7fdef0f500cd4bb540affd3bc1482243f337c1 (patch)
tree4853eecd0769a903e6130c1896e1d070848150dd /lib/prado/framework/Web/UI/ActiveControls/TActiveMultiView.php
parent61f2ea48a4e11cb5fb941b3783e19c9e9ef38a45 (diff)
* Prado 3.3.0
Diffstat (limited to 'lib/prado/framework/Web/UI/ActiveControls/TActiveMultiView.php')
-rw-r--r--lib/prado/framework/Web/UI/ActiveControls/TActiveMultiView.php112
1 files changed, 112 insertions, 0 deletions
diff --git a/lib/prado/framework/Web/UI/ActiveControls/TActiveMultiView.php b/lib/prado/framework/Web/UI/ActiveControls/TActiveMultiView.php
new file mode 100644
index 0000000..215706e
--- /dev/null
+++ b/lib/prado/framework/Web/UI/ActiveControls/TActiveMultiView.php
@@ -0,0 +1,112 @@
+<?php
+/**
+ * TActiveMultiView class file
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @link http://www.landwehr-software.de/
+ * @copyright Copyright &copy; 2009 LANDWEHR Computer und Software GmbH
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Includes the following used classes
+ */
+Prado::using('System.Web.UI.WebControls.TMultiView');
+
+/**
+ * TActiveMultiView class.
+ *
+ * TActiveMultiView is the active counterpart to the original {@link TMultiView} control.
+ * It re-renders on Callback when {@link setActiveView ActiveView} or
+ * {@link setActiveViewIndex ActiveViewIndex} is called.
+ *
+ * Please refer to the original documentation of the regular counterpart for usage.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1.6
+ */
+class TActiveMultiView extends TMultiView implements IActiveControl
+{
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveControl standard active control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Returns the id of the surrounding container (span).
+ * @return string container id
+ */
+ protected function getContainerID()
+ {
+ return $this->ClientID.'_Container';
+ }
+
+ /**
+ * Renders the TActiveMultiView.
+ * If the MutliView did not pass the prerender phase yet, it will register itself for rendering later.
+ * Else it will call the {@link renderMultiView()} method which will do the rendering of the MultiView.
+ * @param THtmlWriter writer for the rendering purpose
+ */
+ public function render($writer)
+ {
+ if($this->getHasPreRendered()) {
+ $this->renderMultiView($writer);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer);
+ }
+ else
+ $this->getPage()->getAdapter()->registerControlToRender($this,$writer);
+ }
+
+ /**
+ * Renders the TActiveMultiView by writing a span tag with the container id obtained from {@link getContainerID()}
+ * which will be called by the replacement method of the client script to update it's content.
+ * @param $writer THtmlWriter writer for the rendering purpose
+ */
+ protected function renderMultiView($writer)
+ {
+ $writer->addAttribute('id', $this->getContainerID());
+ $writer->renderBeginTag('span');
+ parent::render($writer);
+ $writer->renderEndTag();
+ }
+
+ /**
+ * @param integer the zero-based index of the current view in the view collection. -1 if no active view.
+ * @throws TInvalidDataValueException if the view index is invalid
+ */
+ public function setActiveViewIndex($value)
+ {
+ $old=parent::getActiveViewIndex();
+ parent::setActiveViewIndex($value);
+ if($this->getActiveControl()->canUpdateClientSide() && $old!=$value)
+ $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());
+ }
+
+ /**
+ * @param TView the view to be activated
+ * @throws TInvalidOperationException if the view is not in the view collection
+ */
+ public function setActiveView($value)
+ {
+ $old=parent::getActiveView();
+ parent::setActiveView($value);
+ if($this->getActiveControl()->canUpdateClientSide() && $old!=$value)
+ $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter());
+ }
+}