diff options
Diffstat (limited to 'demos/quickstart/protected/pages')
53 files changed, 1395 insertions, 691 deletions
diff --git a/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page b/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page index d4167f6e..6385b658 100755 --- a/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page +++ b/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page @@ -24,70 +24,4 @@ events of an <tt>TActiveButton</tt>.</p> <com:RunBar PagePath="ActiveControls.Samples.TActiveButton.Home" />
-<h2 id="122027">TActiveButton Class Diagram</h2>
-<p id="610414" class="block-content">The class diagram for <tt>TActiveButton</tt> is illustrated in the figure below.
-Most active control that can perform callback request have a similar structure.
-</p>
-
-<img src=<%~ TActiveButtonClass.png %> class="figure"
- alt="TActiveButton class diagram" title="TActiveButton class diagram" />
-
-<p id="610415" class="block-content"><tt>TActiveButton</tt> is an extension of <a href="?page=Controls.Button">TButton</a>
-and implements two additional interfaces <tt>ICallbackEventHandler</tt> and
-<tt>IActiveControl</tt>. The <tt>TActiveButton</tt> contains an instance of
-<a href="?page=ActiveControls.BaseActiveControl">TBaseActiveCallbackControl</a>
-available through the <tt>ActiveControl</tt> property of <tt>TActiveButton</tt>.
-The following example set the callback parameter of the <tt>TActiveButton</tt> when
-a callback request is dispatched.
-</p>
-<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code1">
-<com:TActiveButton
- Text="Click Me"
- OnCallback="button_callback"
- ActiveControl.CallbackParameter="value" />
-</com:TTextHighlighter>
-<p id="610416" class="block-content">In the <tt>OnCallback</tt> event handler method, the <tt>CallbackParameter</tt>
-is available in the <tt>$param</tt> object.</p>
-<com:TTextHighlighter Language="php" CssClass="source block-content" id="code2">
-public function button_callback($sender, $param)
-{
- echo $param->CallbackParameter; //outputs "value"
-}
-</com:TTextHighlighter>
-
-<h2 id="122028">Adding Client Side Behaviour</h2>
-
-<p id="610417" class="block-content">With in the <tt>ActiveControl</tt> property is an instance of
-<a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a> available
-as a property <tt>ClientSide</tt> of <tt>TActiveButton</tt>.
-The <tt>ClientSide</tt> property contains sub-properties, such as <tt>RequestTimeOut</tt>,
-and client-side javascript event handler, such as <tt>OnLoading</tt>,
-that are used by the client-side when making a callback request.
-The following example demonstrates the toggling of a "loading" indicator
-when the client-side is making a callback request.
-</p>
-
-<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code3">
-<com:TClientScript PradoScripts="effects" />
-<span id="callback_status">Loading...</span>
-
-<com:TActiveButton
- Text="Click Me"
- OnCallback="button_callback"
- ActiveControl.CallbackParameter="value" >
- <prop:ClientSide
- OnLoading="Element.show('callback_status')"
- OnComplete="Element.hide('callback_status')" />
-</com:TActiveButton>
-</com:TTextHighlighter>
-
-<p id="610418" class="block-content">The example loads the "effects" javascript library using the
-<a href="?page=Controls.ClientScript">TClientScript</a> component.
-The <tt>ClientSide.OnLoading</tt> property value contains
-javascript statement that uses the "effects" library to show the "Loading..."
-span tag. Similarly, <tt>ClientSide.OnComplete</tt> property
-value contains the javascript statement that hides the "Loading..." span tag.
-See <a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a> for
-further details on client-side property details.
-</p>
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/ActiveRatingList.page b/demos/quickstart/protected/pages/ActiveControls/ActiveRatingList.page new file mode 100644 index 00000000..7b6fb83d --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/ActiveRatingList.page @@ -0,0 +1,32 @@ +<com:TContent ID="body" > + +<h1>TActiveRatingList</h1> +<com:DocLink ClassPath="System.Web.UI.ActiveControls.TActiveRatingList" /> + +<p class="block-content"> +<tt>TActiveRatingList</tt> is the active counterpart to the original <tt>TRatingList</tt> control. +</p> + +<p class="block-content"> +The <tt>AutoPostBack</tt> property is set to true by default. +Thus, when a radio button is clicked a <tt>OnCallback</tt> event is +raised after <tt>OnSelectedIndexChanged</tt> event. +</p> + +<p class="block-content"> +With <tt>ActiveControl.EnableUpdate</tt> +set to true (default is true), changes to the selection will be updated +on the client side. +</p> + +<p class="block-content"> +List items can <b>not</b> be changed dynamically during a callback request. +</p> + +<p class="block-content"> +Please refer to the original documentation of <a href="?page=Controls.List">TRatingList</a> for usage. +</p> + +<com:RunBar PagePath="ActiveControls.Samples.TActiveRatingList.Home" /> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page index 9586f421..25590089 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Home.page @@ -1,15 +1,8 @@ <com:TContent ID="body" >
<h1 id="128031">Active Controls (AJAX enabled Controls)</h1>
-<p id="640423" class="block-content">See the <a href="?page=ActiveControls.Introduction">Introduction</a>
+<p id="640423" class="block-content">
+Active controls extends standard PRADO controls adding the ability to automatically update themselves on callbacks without the need of ad-hoc javascript calls. See the <a href="?page=ActiveControls.Introduction">Introduction</a>
for a quick overview of the concept behind active controls (AJAX enabled controls).
-Most active controls have a property of
-<a href="?page=ActiveControls.BaseActiveControl">ActiveControl</a> and
-a sub-property <a href="?page=ActiveControls.CallbackClientSide">ClientSide</a>
-that provides many properties to customize the controls. The
-<a href="?page=TCallbackClientScript">CallbackClient</a> property of the
-<tt>TPage</tt> class provides many methods to update and alter the client-side content
-during a callback request. Active controls is reliant on a collection
-of <a href="?page=ActiveControl.ClientSideJavascript">javascript classes</a>.
</p>
<p id="640424" class="block-content">For a quick demo of active controls, try the <a href="?page=ActiveControls.ActiveButton">
@@ -104,11 +97,6 @@ TActiveButton</a> control. See also the later part of the <a href="?page=Tutoria </li>
<li>
- <a href="">TActiveRatingList</a>
- is an EXPERIMENTAL class that displays clickable images that represent a TRadioButtonList.
- </li>
-
- <li>
<a href="?page=ActiveControls.ActiveTextBox">TActiveTextBox</a>
represents a text input field on a Web page.
It can collect single-line, multi-line or password text input from users.
@@ -144,6 +132,11 @@ TActiveButton</a> control. See also the later part of the <a href="?page=Tutoria TActiveRadioButtonList displays a group of radiobuttons. Each radio button
can perform a callback request.
</li>
+
+ <li>
+ <a href="?page=ActiveControls.ActiveRatingList">TActiveRatingList</a>
+ is an EXPERIMENTAL class that displays clickable images that represent a TRadioButtonList.
+ </li>
</ul>
<h2 id="134001">Active Data Controls</h2>
@@ -201,9 +194,9 @@ TActiveButton</a> control. See also the later part of the <a href="?page=Tutoria monitors (using a timer) an attribute of an HTML element and triggers a callback request
when the attribute value changes.
</li>
-
+
<li>
- <a href="?page=ActiveControls.DragDrop">TDropContainer & TDraggable</a> represents drag and drop containers.
+ <a href="?page=ActiveControls.DragDrop">TDropContainer & TDraggable</a> represents drag and drop containers.
The former will make its child controls "draggable" while the latter will raise a callback when a draggable
control is dropped on it.
</li>
@@ -357,7 +350,7 @@ if Javascript was disabled on the client's browser.</p> </td>
<td>Yes</td><td>No</td>
</tr>
-
+
<tr><td>
<a href="?page=ActiveControls.DragDrop">TDropContainer</a>
</td>
@@ -370,95 +363,7 @@ if Javascript was disabled on the client's browser.</p> <td>No</td><td>No</td>
</tr>
-
-</table>
-
-<h2 id="128036">Active Control Basic Infrastructure Classes</h2>
-<p id="640427" class="block-content">The following classes provide the basic infrastructure classes required to
-realize the active controls. They can be useful to develop new active controls, but Prado users tipically don't need
-to use them.</p>
-<ul id="u4" class="block-content">
- <li>
- <h3 id="190038">TActiveControlAdapter</h3>
- <com:DocLink ClassPath="System.Web.UI.ActiveControls.TActiveControlAdapter" />
- <p class="block-content">
- <tt>TActiveControlAdapter</tt> customizes the parent TControl class for active control classes.
- It tracks changes in the viewstate values of the control and update
- differences of the client-side HTML element attributes.
- </p>
- </li>
-
- <li>
- <h3 id="190039">TActiveListControlAdapter</h3>
- <com:DocLink ClassPath="System.Web.UI.ActiveControls.TActiveListControlAdapter" />
- <p class="block-content">
- <tt>TActiveListControlAdapter</tt> allows the adapted list controls to change the selections
- on the client-side during a callback request.
- </p>
- </li>
-
- <li>
- <h3 id="190040">TActivePageAdapter</h3>
- <com:DocLink ClassPath="System.Web.UI.ActiveControls.TActivePageAdapter" />
- <p class="block-content">
- <tt>TActivePageAdapter</tt> process the page life-cycle for callback requests.
- </p>
- </li>
-
- <li>
- <h3 id="190041">TBaseActiveControl</h3>
- <com:DocLink ClassPath="System.Web.UI.ActiveControls.TBaseActiveControl" />
- <p class="block-content">
- <tt>TBaseActiveControl</tt> class provided additional basic properties common for every
- active control. An instance of <tt>TBaseActiveControl</tt> or its decendent
- <tt>TBaseActiveCallbackControl</tt> is created by <tt>TActiveControlAdapter::getBaseActiveControl()</tt>
- method.
- The <tt>EnableUpdate</tt> property determines wether the active
- control is allowed to update the contents of the client-side when the callback
- response returns.
- </p>
- </li>
-
- <li>
- <h3 id="190042">TCallbackResponseAdapter</h3>
- <com:DocLink ClassPath="System.Web.UI.ActiveControls.TCallbackResponseAdapter" />
- <p class="block-content">
- <tt>TCallbackResponseAdapter</tt> alters the <tt>THttpResponse</tt>'s outputs.
- A <tt>TCallbackResponseWriter</tt> is used instead of the <tt>TTextWrite</tt> when
- <tt>createHtmlWriter</tt> is called. Each call to createHtmlWriter will create
- a new <tt>TCallbackResponseWriter</tt>. When <tt>flushContent()</tt> is called each
- instance of <tt>TCallbackResponseWriter</tt>'s content is flushed.
- The callback response data can be set using the <tt>ResponseData</tt> property.
- </p>
- </li>
-
-</ul>
-
-<h2 id="190037">Active Control Infrastructure Advanced Classes</h2>
-<p class="block-content">The following classes provide advanced properties and events needed to realize the active controls.
-A Prado user can use them to customize active controls behaviour and interact directly with the client side during a callback.
-</p>
-<ul class="block-content">
- <li>
- <a href="?page=ActiveControls.CallbackClientScript">TCallbackClientScript</a>
- methods to manipulate the client-side HTML elements, also includes methods
- to invoke javascript Effects on HTML elements.
- </li>
- <li>
- <a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a>
- is used to specify client-side callback request options and client-side event handlers.
- </li>
-
- <li>
- <a href="?page=ActiveControls.CallbackEventParameter">TCallbackEventParameter</a>
- provides the parameter passed during the callback request.
- </li>
-
- <li>
- <a href="?page=ActiveControls.CallbackOptions">TCallbackOptions</a>
- allows a common set of callback client-side options to be attached to one or more active controls.
- </li>
-</ul>
+</table>
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Introduction.page b/demos/quickstart/protected/pages/ActiveControls/Introduction.page index 70cb9cbf..edc0b5bc 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Introduction.page +++ b/demos/quickstart/protected/pages/ActiveControls/Introduction.page @@ -1,7 +1,204 @@ <com:TContent ID="body">
-<h1 id="130037">Overview of Active Controls</h1>
-
-TODO:
+<h1 id="130037">AJAX: Introduction</h1>
+<p class="block-content">
+A classic webpage can only transfer data back to the server using an http postback request that requires a full page reload. This is a problem for web applications, since a synchronous page reload breaks the user interaction: the user must wait for the response to arrive and the page will lose its current status (the scrolling position, the currently focused control, etc..).
+</p>
<img src=<%~ postback-callback.png %> class="figure" />
+<p class="block-content">
+A common solution to this problem is the use of AJAX (Asynchronous JavaScript and XML) callbacks. After the first full page load, the web application can make subsequents requests using javascript. The callback requests are asynchronous, so the user can continue to interact with the page while the response is loading. The response contains a list of changes that will be applied to the page "on the fly", like replacing existing elements with new content or add some css style to an existing element.
+</p>
+
+<h2>Interacting with a page on callback</h2>
+
+<p class="block-content">
+PRADO has builtin support for AJAX callbacks in the form of <i>Active Controls</i>. These controls can trigger a callback request and have their properties (value, css style, attributes, ..) updated during a callback.
+Before digging inside the list of Active Controls, it's good to have a look to how a page can be aware if the current request is a callback and how to interact with the page rendered on the client browser.
+<br/>
+The <tt>IsCallBack</tt> property of the <tt>TPage</tt> class exposes whether the current request being handled is the consequence of a callback, and the <a href="?page=ActiveControls.CallbackClientScript">CallbackClient</a> property provides many methods to update and alter the client-side content during a callback request.
+</p>
+
+<com:TTextHighlighter CssClass="source block-content">
+public function onClick($sender, $param)
+{
+ if($this->IsCallback)
+ {
+ $this->getCallbackClient()->hide($this->TextBox1);
+ }
+}
+</com:TTextHighlighter>
+
+<h1>Active Controls (AJAX enabled Controls)</h1>
+<p class="block-content">
+Active controls extends standard PRADO controls adding the ability to automatically update themselves on callbacks without the need of ad-hoc javascript calls. Active controls are reliant on a collection of javascript classes that gets added to the page automatically when needed.
+</p>
+
+<p class="block-content">
+Most active controls have a <tt>ActiveControl.EnableUpdate</tt> property that determines whether the active control is allowed to update the contents of the client-side when the callback response returns. Depending on the control different properties can be updated.
+</p>
+
+<p class="block-content">
+Some active controls can trigger a callback as a consequence of a clientside event (a button click, a checkbox being checked, a DOM event). The callback will first raise the normal serverside event associated to the control (eg: OnClick for a <tt>TButton</tt> or OnSelectedIndexChanged for a <tt>TRadioButtonList</tt>) and then the <tt>OnCallBack</tt> event.
+The <tt>AutoPostBack</tt> property typically defaults to true for these controls.
+</p>
+</p>
+
+<p class="block-content">
+Active controls have a <a href="?page=ActiveControls.CallbackClientSide">ClientSide</a> property that provides many subproperties to customize the controls and to hook some javascript code to the callback lifecycle, like showing a "Loading" logo at the start of a callback and hide it at the end.
+</p>
+
+<h2 id="122027">TActiveButton Class Diagram</h2>
+<p id="610414" class="block-content">The class diagram for <tt>TActiveButton</tt> is illustrated in the figure below.
+Most active control that can perform callback request have a similar structure.
+</p>
+
+<img src=<%~ TActiveButtonClass.png %> class="figure"
+ alt="TActiveButton class diagram" title="TActiveButton class diagram" />
+
+<p id="610415" class="block-content"><tt>TActiveButton</tt> is an extension of <a href="?page=Controls.Button">TButton</a>
+and implements two additional interfaces <tt>ICallbackEventHandler</tt> and
+<tt>IActiveControl</tt>. The <tt>TActiveButton</tt> contains an instance of
+<a href="?page=ActiveControls.BaseActiveControl">TBaseActiveCallbackControl</a>
+available through the <tt>ActiveControl</tt> property of <tt>TActiveButton</tt>.
+The following example set the callback parameter of the <tt>TActiveButton</tt> when
+a callback request is dispatched.
+</p>
+<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code1">
+<com:TActiveButton
+ Text="Click Me"
+ OnCallback="button_callback"
+ ActiveControl.CallbackParameter="value" />
+</com:TTextHighlighter>
+<p id="610416" class="block-content">In the <tt>OnCallback</tt> event handler method, the <tt>CallbackParameter</tt>
+is available in the <tt>$param</tt> object.</p>
+<com:TTextHighlighter Language="php" CssClass="source block-content" id="code2">
+public function button_callback($sender, $param)
+{
+ echo $param->CallbackParameter; //outputs "value"
+}
+</com:TTextHighlighter>
+
+<h2 id="122028">Adding Client Side Behaviour</h2>
+
+<p id="610417" class="block-content">With in the <tt>ActiveControl</tt> property is an instance of
+<a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a> available
+as a property <tt>ClientSide</tt> of <tt>TActiveButton</tt>.
+The <tt>ClientSide</tt> property contains sub-properties, such as <tt>RequestTimeOut</tt>,
+and client-side javascript event handler, such as <tt>OnLoading</tt>,
+that are used by the client-side when making a callback request.
+The following example demonstrates the toggling of a "loading" indicator
+when the client-side is making a callback request.
+</p>
+
+<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code3">
+<com:TClientScript PradoScripts="effects" />
+<span id="callback_status">Loading...</span>
+
+<com:TActiveButton
+ Text="Click Me"
+ OnCallback="button_callback"
+ ActiveControl.CallbackParameter="value" >
+ <prop:ClientSide
+ OnLoading="Element.show('callback_status')"
+ OnComplete="Element.hide('callback_status')" />
+</com:TActiveButton>
+</com:TTextHighlighter>
+
+<p id="610418" class="block-content">The example loads the "effects" javascript library using the
+<a href="?page=Controls.ClientScript">TClientScript</a> component.
+The <tt>ClientSide.OnLoading</tt> property value contains
+javascript statement that uses the "effects" library to show the "Loading..."
+span tag. Similarly, <tt>ClientSide.OnComplete</tt> property
+value contains the javascript statement that hides the "Loading..." span tag.
+See <a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a> for
+further details on client-side property details.
+</p>
+
+<h2 id="128036">Active Control Basic Infrastructure Classes</h2>
+<p id="640427" class="block-content">The following classes provide the basic infrastructure classes required to
+realize the active controls. They can be useful to develop new active controls, but Prado users tipically don't need
+to use them.</p>
+<ul id="u4" class="block-content">
+ <li>
+ <h3 id="190038">TActiveControlAdapter</h3>
+ <com:DocLink ClassPath="System.Web.UI.ActiveControls.TActiveControlAdapter" />
+ <p class="block-content">
+ <tt>TActiveControlAdapter</tt> customizes the parent TControl class for active control classes.
+ It tracks changes in the viewstate values of the control and update
+ differences of the client-side HTML element attributes.
+ </p>
+ </li>
+
+ <li>
+ <h3 id="190039">TActiveListControlAdapter</h3>
+ <com:DocLink ClassPath="System.Web.UI.ActiveControls.TActiveListControlAdapter" />
+ <p class="block-content">
+ <tt>TActiveListControlAdapter</tt> allows the adapted list controls to change the selections
+ on the client-side during a callback request.
+ </p>
+ </li>
+
+ <li>
+ <h3 id="190040">TActivePageAdapter</h3>
+ <com:DocLink ClassPath="System.Web.UI.ActiveControls.TActivePageAdapter" />
+ <p class="block-content">
+ <tt>TActivePageAdapter</tt> process the page life-cycle for callback requests.
+ </p>
+ </li>
+
+ <li>
+ <h3 id="190041">TBaseActiveControl</h3>
+ <com:DocLink ClassPath="System.Web.UI.ActiveControls.TBaseActiveControl" />
+ <p class="block-content">
+ <tt>TBaseActiveControl</tt> class provided additional basic properties common for every
+ active control. An instance of <tt>TBaseActiveControl</tt> or its decendent
+ <tt>TBaseActiveCallbackControl</tt> is created by <tt>TActiveControlAdapter::getBaseActiveControl()</tt>
+ method.
+ The <tt>EnableUpdate</tt> property determines wether the active
+ control is allowed to update the contents of the client-side when the callback
+ response returns.
+ </p>
+ </li>
+
+ <li>
+ <h3 id="190042">TCallbackResponseAdapter</h3>
+ <com:DocLink ClassPath="System.Web.UI.ActiveControls.TCallbackResponseAdapter" />
+ <p class="block-content">
+ <tt>TCallbackResponseAdapter</tt> alters the <tt>THttpResponse</tt>'s outputs.
+ A <tt>TCallbackResponseWriter</tt> is used instead of the <tt>TTextWrite</tt> when
+ <tt>createHtmlWriter</tt> is called. Each call to createHtmlWriter will create
+ a new <tt>TCallbackResponseWriter</tt>. When <tt>flushContent()</tt> is called each
+ instance of <tt>TCallbackResponseWriter</tt>'s content is flushed.
+ The callback response data can be set using the <tt>ResponseData</tt> property.
+ </p>
+ </li>
+
+</ul>
+
+<h2 id="190037">Active Control Infrastructure Advanced Classes</h2>
+<p class="block-content">The following classes provide advanced properties and events needed to realize the active controls.
+A Prado user can use them to customize active controls behaviour and interact directly with the client side during a callback.
+</p>
+<ul class="block-content">
+ <li>
+ <a href="?page=ActiveControls.CallbackClientScript">TCallbackClientScript</a>
+ methods to manipulate the client-side HTML elements, also includes methods
+ to invoke javascript Effects on HTML elements.
+ </li>
+
+ <li>
+ <a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a>
+ is used to specify client-side callback request options and client-side event handlers.
+ </li>
+
+ <li>
+ <a href="?page=ActiveControls.CallbackEventParameter">TCallbackEventParameter</a>
+ provides the parameter passed during the callback request.
+ </li>
+
+ <li>
+ <a href="?page=ActiveControls.CallbackOptions">TCallbackOptions</a>
+ allows a common set of callback client-side options to be attached to one or more active controls.
+ </li>
+</ul>
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page index 1e030102..8482ae14 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page @@ -43,5 +43,4 @@ A button causing validation with <tt>OnCallback</tt>: </table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.page index 139306f6..89543ef0 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.page @@ -71,6 +71,5 @@ A checkbox validated by a required field validator: </table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page index 8ef69a9a..1d16235e 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page @@ -16,6 +16,5 @@ Custom validator using callbacks: </td></tr>
</table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page index a3f10613..a7767e2d 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page @@ -66,5 +66,4 @@ Body contents </tr>
</table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page index 79a4f540..57e08e1c 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page @@ -99,5 +99,4 @@ Choose page: jQuery('#wait').hide() </prop:ClientSide.OnComplete> </com:TActivePager> -<com:TJavascriptLogger/> </com:TContent> diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.page index 360b6b0f..f3bfe843 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePanel/Home.page @@ -20,5 +20,4 @@ anyway since they are placed inside the active panel. </com:TActivePanel>
</td></tr>
</table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRatingList/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRatingList/Home.page new file mode 100644 index 00000000..332ccb63 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRatingList/Home.page @@ -0,0 +1,71 @@ +<com:TContent ID="body"> +<h1>TActiveRatingList Samples</h1> + +<table class="sampletable"> + +<tr><td class="samplenote"> +A simple TActiveRatingList and its caption: +</td><td class="sampleaction"> + +<com:TLabel ID="label1" Text="Rate it:" /> +<com:TActiveRatingList CaptionID="label1"> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> +</com:TActiveRatingList> + +</td></tr> + +<tr><td class="samplenote"> +TActiveRatingList in vertical mode, SelectedIndex=2 +</td><td class="sampleaction"> + +<com:TLabel ID="label2" Text="Rate it:" /> +<com:TActiveRatingList CaptionID="label2" SelectedIndex="2" RepeatDirection="Vertical" Style="caption-side: right;"> + <com:TListItem Text="Poor" /> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> + <com:TListItem Text="Super" /> +</com:TActiveRatingList> + +</td></tr> + +<tr><td class="samplenote"> +TActiveRatingList with RatingStyle=blocks, AutoPostback=true, SelectedValue=Good +</td><td class="sampleaction"> + +<com:TLabel ID="label3" Text="Rate it:" /> +<com:TActiveRatingList ID="Rating3" CaptionID="label3" RatingStyle="blocks" SelectedValue="Good" AutoPostBack="true" OnSelectedIndexChanged="rating3_selectionChanged"> + <com:TListItem Text="Poor" /> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> + <com:TListItem Text="Super" /> +</com:TActiveRatingList> +<br/> +A label to check callback results: <com:TActiveLabel ID="labelResult3" /> + +</td></tr> + +<tr><td class="samplenote"> +TActiveRatingList with AllowInput=false, Rating=4.6 +</td><td class="sampleaction"> + +<com:TLabel ID="label4" Text="Rate it:" /> +<com:TActiveRatingList CaptionID="label4" AllowInput="false" Rating="4.6"> + <com:TListItem Text="Poor" /> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> + <com:TListItem Text="Super" /> +</com:TActiveRatingList> + +</td></tr> + +</table> +</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRatingList/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRatingList/Home.php new file mode 100644 index 00000000..5e8ed1bd --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRatingList/Home.php @@ -0,0 +1,9 @@ +<?php + +class Home extends TPage +{ + protected function rating3_selectionChanged($sender, $param) + { + $this->labelResult3->Text=$this->Rating3->SelectedValue; + } +}
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.page index 0b3f84fb..49b5bcb6 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveTableRow/Home.page @@ -14,6 +14,5 @@ </com:TTable>
<com:TActiveLabel id="lblResult"/>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.page index 539909a9..84521acb 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.page @@ -7,12 +7,37 @@ </p>
<h2>Actions</h2>
-<com:TRadioButtonList ID="radio1">
+<com:TClientScript PradoScripts="jqueryui" />
+<com:TStyleSheet>
+ .red_background {
+ background-color: red;
+ }
+</com:TStyleSheet>
+
+<com:TRadioButtonList ID="radio1" RepeatColumns="2">
<com:TListItem Value="1" Text="alert() me of something" />
<com:TListItem Value="2" Text="toggle Checkbox 1" />
<com:TListItem Value="3" Text="hide Label 1" />
<com:TListItem Value="4" Text="show Label 1" />
- <com:TListItem Value="5" Text="focus TextBox 1" />
+ <com:TListItem Value="5" Text="toggle Label 1 visibility" />
+ <com:TListItem Value="6" Text="toggle Label 1 (fade)" />
+ <com:TListItem Value="7" Text="toggle Label 1 (slide)" />
+ <com:TListItem Value="8" Text="highlight Label 1 (requires jQuery UI)" />
+ <com:TListItem Value="9" Text="focus TextBox 1" />
+ <com:TListItem Value="10" Text="scroll to CheckBox 1" />
+ <com:TListItem Value="11" Text="add red_background class to TextBox 1" />
+ <com:TListItem Value="12" Text="remove red_background class from TextBox 1" />
+ <com:TListItem Value="13" Text="animated resize TextBox 1" />
+ <com:TListItem Value="14" Text="set the 'disable' attribute on TextBox 1" />
+ <com:TListItem Value="15" Text="change the background color of Panel 1" />
+ <com:TListItem Value="16" Text="prepend and append some content inside Panel 1" />
+ <com:TListItem Value="17" Text="prepend and append some content outside Panel 1" />
+ <com:TListItem Value="18" Text="replace Panel 1 with some plain text" />
+ <com:TListItem Value="19" Text="remove TextBox 1" />
+ <com:TListItem Value="20" Text="fade out TextBox 1" />
+ <com:TListItem Value="21" Text="fade in TextBox 1" />
+ <com:TListItem Value="22" Text="trigger a click event on Panel 1" />
+ <com:TListItem Value="23" Text="call a specific effect on TextBox 1 (toggle)" />
</com:TRadioButtonList>
<br/><com:TActiveButton ID="button1" OnCallback="buttonCallback" Text="callback!" />
@@ -32,8 +57,17 @@ <td>TextBox 1:</td>
<td><com:TTextBox ID="txt1" Text="Sample text" /></td>
</tr>
+ <tr>
+ <td>Panel 1:</td>
+ <td>
+ <com:TPanel ID="pan1" Style="width:100px;height:100px;background:green" Attributes.OnClick="alert('clicked on Panel1')" >
+ Panel contents
+ </com:TPanel>
+ </td>
+ </tr>
</table>
-<com:TJavascriptLogger />
-
+<div style="height:900px">
+Thw following space is intentionally left blank for the scrolling test
+</div>
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php index eeacb660..50a69911 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientScript/Home.php @@ -8,7 +8,7 @@ class Home extends TPage switch($this->radio1->SelectedValue) { case 1: - $this->getCallbackClient()->evaluateScript("<script> alert('something'); </script>"); + $this->getCallbackClient()->evaluateScript("alert('something');"); break; case 2: $this->getCallbackClient()->check($this->check1, !$this->check1->Checked); @@ -20,8 +20,74 @@ class Home extends TPage $this->getCallbackClient()->show($this->label1); break; case 5: + $this->getCallbackClient()->toggle($this->label1); + break; + case 6: + $this->getCallbackClient()->toggle($this->label1, 'fade'); + break; + case 7: + $this->getCallbackClient()->toggle($this->label1, 'slide'); + break; + case 8: + $this->getCallbackClient()->highlight($this->label1); + break; + case 9: $this->getCallbackClient()->focus($this->txt1); break; + case 10: + $this->getCallbackClient()->scrollTo($this->check1, array('duration' => 1000, 'offset' => 10)); + break; + case 11: + $this->getCallbackClient()->addCssClass($this->txt1, 'red_background'); + break; + case 12: + $this->getCallbackClient()->removeCssClass($this->txt1, 'red_background'); + break; + case 13: + $this->getCallbackClient()->jQuery($this->txt1, 'animate', array( + array( 'width' => '+=100', + 'height' => '+=50' + ), + array( + 'duration' => 1000, + ) + )); + break; + case 14: + $this->getCallbackClient()->setAttribute($this->txt1, 'disabled', true); + break; + case 15: + $this->getCallbackClient()->setStyle($this->pan1, array('background-color' => 'blue')); + break; + case 16: + $this->getCallbackClient()->prependContent($this->pan1, 'prepend<br/>'); + $this->getCallbackClient()->appendContent($this->pan1, '<br/>append'); + break; + case 17: + $this->getCallbackClient()->insertContentBefore($this->pan1, 'before'); + $this->getCallbackClient()->insertContentAfter($this->pan1, 'after'); + break; + case 18: + $this->getCallbackClient()->replaceContent($this->pan1, 'No more Panel 1'); + break; + case 19: + $this->getCallbackClient()->remove($this->txt1); + break; + case 20: + $this->getCallbackClient()->fadeOut($this->txt1); + break; + case 21: + $this->getCallbackClient()->fadeIn($this->txt1); + break; + case 22: + $this->getCallbackClient()->click($this->pan1); + // alternative + // $this->getCallbackClient()->raiseClientEvent($this->pan1, 'click'); + break; + case 23: + $this->getCallbackClient()->jQuery($this->txt1, 'toggle'); + break; + } } } diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.page index 0d13bb90..0f94fd79 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackClientSide/Home.page @@ -68,6 +68,5 @@ connection error has occured. </table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.page index cfb041ea..8c6ccd02 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TCallbackOptions/Home.page @@ -72,6 +72,5 @@ The same TCallbackOptions can be shared among different controls, even of differ </td></tr>
</table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/Advanced/Error.page b/demos/quickstart/protected/pages/Advanced/Error.page index 24c7ead0..391997fb 100755 --- a/demos/quickstart/protected/pages/Advanced/Error.page +++ b/demos/quickstart/protected/pages/Advanced/Error.page @@ -71,7 +71,7 @@ The naming convention for the template files used for all other exceptions is as Again, if the preferred language is not found, PRADO will try to use <tt>exception.html</tt>, instead.
</p>
<div class="note">
-<b class="tip">CAUTION:</b> When saving a template file, please make sure the file is saved using UTF-8 encoding. On Windows, you may use <tt>Notepad.exe</tt> to accomplish such saving.
+<b class="tip">CAUTION:</b> When saving a template file, please make sure the file is saved using UTF-8 encoding. On Windows, you may use <tt>Notepad++</tt> to accomplish such saving.
</div>
</com:TContent>
diff --git a/demos/quickstart/protected/pages/Configurations/Templates1.page b/demos/quickstart/protected/pages/Configurations/Templates1.page index 22b693a6..6c2870f2 100755 --- a/demos/quickstart/protected/pages/Configurations/Templates1.page +++ b/demos/quickstart/protected/pages/Configurations/Templates1.page @@ -3,7 +3,7 @@ <p id="180166" class="block-content">
Templates are used to specify the presentational layout of controls. A template can contain static text, components, or controls that contribute to the ultimate presentation of the associated control. By default, an instance of <tt>TTemplateControl</tt> or its subclass may automatically load and instantiate a template from a file whose name is the same as the control class name. For page templates, the file name suffix must be <tt>.page</tt>; for other regular template controls, the suffix is <tt>.tpl</tt>.
</p>
-<p id="180167" class="block-content">The template format is like HTML, with a few PRADO-specifc tags, including <a href="#ct">component tags</a>, <a href="#tct">template control tags</a>, <a href="#cot">comment tags</a>, <a href="?page=Configurations.Templates2#dct">dynamic content tags</a>, and <a href="?page=Configurations.Templates3#dpt">dynamic property tags</a>. .
+<p id="180167" class="block-content">The template format is like HTML, with a few PRADO-specifc tags, including <a href="#ct">component tags</a>, <a href="#tct">template control tags</a>, <a href="#cot">comment tags</a>, <a href="?page=Configurations.Templates2#dct">dynamic content tags</a>, and <a href="?page=Configurations.Templates3#dpt">dynamic property tags</a>.
</p>
<a name="ct"></a>
diff --git a/demos/quickstart/protected/pages/Controls/Data.page b/demos/quickstart/protected/pages/Controls/Data.page index 3843b332..829a4ef5 100755 --- a/demos/quickstart/protected/pages/Controls/Data.page +++ b/demos/quickstart/protected/pages/Controls/Data.page @@ -2,6 +2,12 @@ <h1 id="5001">Data Controls</h1>
+<p class="block-content">
+Data controls are used to display a repeated content like a list or a table. The content is generated from a collection of items containing the data, called the <tt>DataSource</tt>, and a template describing the appearance, called <tt>Renderer</tt>.
+<br/>
+The process of assigning a DataSource to a Data control and render the template for each item is called <tt>data binding</tt>.
+</p>
+
<ul id="u1" class="block-content">
<li>
<a href="?page=Controls.DataList">TDataList</a> is used to display or modify a list of data items.
diff --git a/demos/quickstart/protected/pages/Controls/List.page b/demos/quickstart/protected/pages/Controls/List.page index ae8d86bf..5e78bb13 100755 --- a/demos/quickstart/protected/pages/Controls/List.page +++ b/demos/quickstart/protected/pages/Controls/List.page @@ -108,4 +108,6 @@ Since v3.1.1, <tt>TDropDownList</tt> starts to support prompt text (something li This is an EXPERIMENTAL class that displays clickable images that represent a TRadioButtonList.
</p>
+<com:RunBar PagePath="Controls.Samples.TRatingList.Home" />
+
</com:TContent>
diff --git a/demos/quickstart/protected/pages/Controls/NewControl.page b/demos/quickstart/protected/pages/Controls/NewControl.page index 10c789db..9a680f43 100755 --- a/demos/quickstart/protected/pages/Controls/NewControl.page +++ b/demos/quickstart/protected/pages/Controls/NewControl.page @@ -10,7 +10,7 @@ In general, there are two ways of writing new controls: composition of existing <h2 id="5402">Composition of Existing Controls</h2>
<p id="660430" class="block-content">
-Composition is the easiest way of creating new controls. It mainly involves instantiating existing controls, configuring them and making them the constituent components. The properties of the constituent components are exposed through <a href="?page=Fundamentals.Components">subproperties</a>.
+Composition is the easiest way of creating new controls. It mainly involves instantiating existing controls, configuring them and making them the constituent components. The properties of the constituent components are exposed through <a href="?page=Fundamentals.Components1">subproperties</a>.
</p>
<p id="660431" class="block-content">
One can compose a new control in two ways. One is to extend <tt>TCompositeControl</tt> and override the <tt>TControl::createChildControls()</tt> method. The other is to extend <tt>TTemplateControl</tt> (or its child classes) and write a control template. The latter is easier to use and can organize the layout constituent components more intuitively, while the former is more efficient because it does not require parsing of the template.
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.page index de419172..6e6cb54d 100755 --- a/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.page @@ -67,6 +67,5 @@ will be clicked because it is set as the default button of the panel. </com:TPanel>
</td></tr>
</table>
-<com:TJavascriptLogger />
</com:TContent>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRatingList/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TRatingList/Home.page new file mode 100644 index 00000000..5790f840 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRatingList/Home.page @@ -0,0 +1,71 @@ +<com:TContent ID="body"> +<h1>TRatingList Samples</h1> + +<table class="sampletable"> + +<tr><td class="samplenote"> +A simple TRatingList and its caption: +</td><td class="sampleaction"> + +<com:TLabel ID="label1" Text="Rate it:" /> +<com:TRatingList CaptionID="label1"> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> +</com:TRatingList> + +</td></tr> + +<tr><td class="samplenote"> +TRatingList in vertical mode, SelectedIndex=2 +</td><td class="sampleaction"> + +<com:TLabel ID="label2" Text="Rate it:" /> +<com:TRatingList CaptionID="label2" SelectedIndex="2" RepeatDirection="Vertical" Style="caption-side: right;"> + <com:TListItem Text="Poor" /> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> + <com:TListItem Text="Super" /> +</com:TRatingList> + +</td></tr> + +<tr><td class="samplenote"> +TRatingList with RatingStyle=blocks, AutoPostback=true, SelectedValue=Good +</td><td class="sampleaction"> + +<com:TLabel ID="label3" Text="Rate it:" /> +<com:TRatingList ID="Rating3" CaptionID="label3" RatingStyle="blocks" SelectedValue="Good" AutoPostBack="true" OnSelectedIndexChanged="rating3_selectionChanged"> + <com:TListItem Text="Poor" /> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> + <com:TListItem Text="Super" /> +</com:TRatingList> +<br/> +A label to check postback results: <com:TLabel ID="labelResult3" /> + +</td></tr> + +<tr><td class="samplenote"> +TRatingList with AllowInput=false, Rating=4.6 +</td><td class="sampleaction"> + +<com:TLabel ID="label4" Text="Rate it:" /> +<com:TRatingList CaptionID="label4" AllowInput="false" Rating="4.6"> + <com:TListItem Text="Poor" /> + <com:TListItem Text="Fair" /> + <com:TListItem Text="Average" /> + <com:TListItem Text="Good" /> + <com:TListItem Text="Excellent" /> + <com:TListItem Text="Super" /> +</com:TRatingList> + +</td></tr> + +</table> +</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRatingList/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRatingList/Home.php new file mode 100644 index 00000000..5e8ed1bd --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRatingList/Home.php @@ -0,0 +1,9 @@ +<?php + +class Home extends TPage +{ + protected function rating3_selectionChanged($sender, $param) + { + $this->labelResult3->Text=$this->Rating3->SelectedValue; + } +}
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Standard.page b/demos/quickstart/protected/pages/Controls/Standard.page index 463f90a5..bac51351 100755 --- a/demos/quickstart/protected/pages/Controls/Standard.page +++ b/demos/quickstart/protected/pages/Controls/Standard.page @@ -1,7 +1,9 @@ <com:TContent ID="body" >
<h1 id="52001">Standard Controls</h1>
-<p id="260001" class="block-content">* the tutorial for this control is not completed yet.</p>
+<p class="block-content">
+ Standard controls are the most basic controls in PRADO. They can represent a simple html tag like an <input> or even more comple controls like a date picker or a WYSIWYG text area. Standard controls are in the <tt>System.Web.UI.WebControls</tt> namespace.
+</p>
<ul id="u1" class="block-content">
<li>
<a href="?page=Controls.Accordion">TAccordion</a> displays an accordion consisting of multiple views. At any time, only one view is visible.
diff --git a/demos/quickstart/protected/pages/Controls/id/NewControl.page b/demos/quickstart/protected/pages/Controls/id/NewControl.page index ea083f6c..85c6eff0 100755 --- a/demos/quickstart/protected/pages/Controls/id/NewControl.page +++ b/demos/quickstart/protected/pages/Controls/id/NewControl.page @@ -10,7 +10,7 @@ Secara umum, ada dua cara penulisan kontrol baru: komposisi kontrol yang sudah a <h2 id="5402">Komposisi Kontrol yang Sudah Ada</h2>
<p id="660430" class="block-content">
-Komposisi adalah cara termudah membuat kontrol baru. Ia melibatkan terutama penurunan kontrol yang sudah ada, mengkonfigurasinya dan menjadikannya unsur komponen. Properti dari unsur komponen diperlihatkan melalui <a href="?page=Fundamentals.Components">subproperti</a>.
+Komposisi adalah cara termudah membuat kontrol baru. Ia melibatkan terutama penurunan kontrol yang sudah ada, mengkonfigurasinya dan menjadikannya unsur komponen. Properti dari unsur komponen diperlihatkan melalui <a href="?page=Fundamentals.Components1">subproperti</a>.
</p>
<p id="660431" class="block-content">
Seseorang dapat menciptakan sebuah kontrol baru dalam dua cara. Pertama adalah memperluas <tt>TCompositeControl</tt> dan mengganti metode <tt>TControl::createChildControls()</tt>. Kedua adalah memperluas <tt>TTemplateControl</tt> (atau kelas anaknya) dan menulis template kontrol. Yang terakhir lebih mudah digunakan dan bisa mengatur tata letak unsur komponen lebih intuitif, sementara pembentuk lebih efisien karena ia tidak perlu menguraikan template.
diff --git a/demos/quickstart/protected/pages/Database/ActiveRecord.page b/demos/quickstart/protected/pages/Database/ActiveRecord.page index 537c65e0..cf1485bd 100755 --- a/demos/quickstart/protected/pages/Database/ActiveRecord.page +++ b/demos/quickstart/protected/pages/Database/ActiveRecord.page @@ -129,7 +129,7 @@ You may specify qualified table names. E.g. for MySQL, <tt>TABLE = "`database1`. </div> <div class="note"><b class="note">Note:</b> -Since version <b>3.1.3</b> you can also use a method <tt>table()</tt> to define the table name. +Since version <b>3.1.3</b> you can also use a method <tt>table()</tt> to define the table name. This allows you to dynamically specify which table should be used by the ActiveRecord. <com:TTextHighlighter Language="php" CssClass="source block-content"> class TeamRecord extends TActiveRecord @@ -159,7 +159,7 @@ class UserRecord extends TActiveRecord { } } </com:TTextHighlighter> -<p id="710010" class="block-content">More details regarding TComponent can be found in the <a href="?page=Fundamentals.Components">Components documentation</a>. +<p id="710010" class="block-content">More details regarding TComponent can be found in the <a href="?page=Fundamentals.Components1">Components documentation</a>. Later we shall use the getter/setters to allow for lazy loading of relationship objects. </p> @@ -1128,7 +1128,7 @@ class PlayerRecord extends BaseFkRecord <p id="710046" class="block-content">We first need to change the <tt>$skills=array()</tt> declaration to a private property <tt>$_skills</tt> (notice the underscore) and set it to null instead. This allows us to define the <tt>skills</tt> property using getter/setter methods -(see <a href="?page=Fundamentals.Components">Components</a> for details). The <tt>getSkills()</tt> +(see <a href="?page=Fundamentals.Components1">Components</a> for details). The <tt>getSkills()</tt> getter method for the <tt>skills</tt> property will lazy load the corresponding skills foreign record when it is used as follows. Notice that we only do a lazy load when its <tt>$player_id</tt> is not null (that is, when the record is already fetched from the database or player id was already set). diff --git a/demos/quickstart/protected/pages/Database/id/ActiveRecord.page b/demos/quickstart/protected/pages/Database/id/ActiveRecord.page index 454aa3f9..8e81678e 100755 --- a/demos/quickstart/protected/pages/Database/id/ActiveRecord.page +++ b/demos/quickstart/protected/pages/Database/id/ActiveRecord.page @@ -3,7 +3,7 @@ <com:SinceVersion Version="3.1a" /> <p id="690478" class="block-content">Rekaman Aktif adalah obyek yang melapisi baris dalam tabel atau view database, melindungi akses database dan menambahkan logika domain pada data tersebut. - Dasar dari Rekaman Aktif adalah kelas bisnis, sebagai contoh, kelas + Dasar dari Rekaman Aktif adalah kelas bisnis, sebagai contoh, kelas <tt>Products</tt>, yang hampir menyamai struktur rekaman dari tabel database dibawahnya. Setiap Rekaman Aktif akan bertanggung jawab atas penyimpanan dan pengambilan data ke dan dari database. </p> @@ -14,22 +14,22 @@ </div> <h2 id="138047">Kapan Menggunakannya</h2> -<p id="690479" class="block-content">Rekaman Aktif adalah pilihan yang baik untuk logika domain yang tidak terlalu rumit, +<p id="690479" class="block-content">Rekaman Aktif adalah pilihan yang baik untuk logika domain yang tidak terlalu rumit, seperti membuat, membaca, memutakhirkan, dan menghapus. Derivasi dan validasi didasarkan pada satu rekaman yang bekerja denga baik dalam struktur ini. Rekaman Aktif mempunyai kuntungan utama dalam hal kesederhanaan. Mudah untuk membangun Rekaman Aktif, dan mudah untuk dimengerti.</p> <p id="690480" class="block-content">Akan tetapi, seiring dengan perkembangan logika bisnis Anda dalm hal kompleksitas, Anda akan segera ingin menggunakan hubungan langsung obyek Anda, koleksi, turunan, dan seterusnya. Ini tidak mudah diterapkan ke dalam Rekaman Aktif, dan menambahkannya sedikit demi sedikit menjadi sangat kacau. Argumen lain terhadap Rekaman Aktif adalah kenyataan bahwa ia menyandingkan desin obyek ke desain database. Ini menjadikannya lebih sulit untuk merefraktorisasi karena proyek terus berjalan.</p> - - <p id="690481" class="block-content">Alternatifnya adalah menggunakan Pemeta Data yang yang memisahkan aturan dari obyek bisnis dan bagaimana obyek ini disimpan. + + <p id="690481" class="block-content">Alternatifnya adalah menggunakan Pemeta Data yang yang memisahkan aturan dari obyek bisnis dan bagaimana obyek ini disimpan. Prado menyediakan pilihan tambahan antara Rekaman Aktif dan - <a href="?page=Database.SqlMap">Pemeta Data SqlMap</a>. - Pemeta Data SqlMap bisa dipakai untuk mengambil obyek Rekaman Aktif, hasilnya; obyek Rekaman Aktif ini bisa dipakai untuk memutakhirkan database. + <a href="?page=Database.SqlMap">Pemeta Data SqlMap</a>. + Pemeta Data SqlMap bisa dipakai untuk mengambil obyek Rekaman Aktif, hasilnya; obyek Rekaman Aktif ini bisa dipakai untuk memutakhirkan database. "Hubungan" antara Rekaman Aktif dan <a href="?page=Database.SqlMap">SqlMap</a> digambarkan dalam diagram berikut. Lebih rinci mengenai Pemeta Data SqlMap dapat ditemukan dalam <a href="http://www.pradosoft.com/demos/sqlmap/">Manual SqlMap</a>. <img src=<%~ sqlmap_active_record.png %> alt="Rekaman Aktif dan SqlMap DataMapper" id="fig:diagram.png" class="figure"/> </p> - + <p id="690482" class="block-content"> Kelas Rekaman Aktif berfungsi untuk melakukan tugas-tugas berikut. </p> @@ -41,22 +41,22 @@ </ul> <h2>Implikasi Desain</h2> <p> -Implementasi Prado terhadap Rekaman Aktif tidak memelihara identitas referensial. Setiap obyek diperoleh menggunakan Rekaman Aktif pada data dalam database. Sebagai contoh, jika Anda meminta kustomer tertentu dan mendapatkan kembali obyek <tt>Customer</tt>, kali berikutnya Anda meminta kustomer itu, Anda akan kembali mendapatkan turunan lain dari obyek <tt>Customer</tt>. Ini berarti bahwa perbandingan tepat (misalnya menggunakan <tt>===</tt>) akan mengembalikan false, sementara perbandingan bebas (misalnya menggunakan <tt>==</tt>) akan mengembalikan true jika nilai obyek sama menurut perbandingan bebas. +Implementasi Prado terhadap Rekaman Aktif tidak memelihara identitas referensial. Setiap obyek diperoleh menggunakan Rekaman Aktif pada data dalam database. Sebagai contoh, jika Anda meminta kustomer tertentu dan mendapatkan kembali obyek <tt>Customer</tt>, kali berikutnya Anda meminta kustomer itu, Anda akan kembali mendapatkan turunan lain dari obyek <tt>Customer</tt>. Ini berarti bahwa perbandingan tepat (misalnya menggunakan <tt>===</tt>) akan mengembalikan false, sementara perbandingan bebas (misalnya menggunakan <tt>==</tt>) akan mengembalikan true jika nilai obyek sama menurut perbandingan bebas. <p> <p> Implikasi desain ini terkait dengan pertanyaan berikut. -<i>"Anda pikir kustomer sebagai obyek, di mana hanya satu, +<i>"Anda pikir kustomer sebagai obyek, di mana hanya satu, atau Anda pikir obyek yang Anda operasikan sebagai <b>duplikat</b> dari database?"</i> -Pemetaan O/R lain akan mengartikan bahwa hanya ada satu obyek Kustomer dengan custID 100, dan secara literal ia adalah kustomer. -Jika Anda mendapatkan kustomer dan mengubah field-nya, maka Anda sekarang telah mengubah kustomer itu. -<i>"Itu berbatasan dengan: Anda telah mengubah duplikat kustomer ini, tapi bukan pada duplikat itu. +Pemetaan O/R lain akan mengartikan bahwa hanya ada satu obyek Kustomer dengan custID 100, dan secara literal ia adalah kustomer. +Jika Anda mendapatkan kustomer dan mengubah field-nya, maka Anda sekarang telah mengubah kustomer itu. +<i>"Itu berbatasan dengan: Anda telah mengubah duplikat kustomer ini, tapi bukan pada duplikat itu. Dan jika dua orang memutakhirkan kustomer pada dua duplikat obyek, siapapun yang memutakhirkan pertama kali, atau mungkin yang terakhir yang menang."</i> [A. Hejlsberg 2003] </p> <h2 id="142010">Database yang Didukung</h2> <p id="p1" class="block-content"> -Implementasi Rekaman Aktif memanfaatkan kelas <a href="?page=Database.DAO">Prado DAO</a> untuk akses data. -Implementasi Rekaman Aktif saat ini mendukung database sebagai berikut. +Implementasi Rekaman Aktif memanfaatkan kelas <a href="?page=Database.DAO">Prado DAO</a> untuk akses data. +Implementasi Rekaman Aktif saat ini mendukung database sebagai berikut. </p> <ul> <li><a href="http://www.mysql.com">MySQL 4.1 atau lebih tinggi</a></li> @@ -69,8 +69,8 @@ Implementasi Rekaman Aktif saat ini mendukung database sebagai berikut. <h1 id="138048">Mendefinisikan Rekaman Aktif</h1> <p id="690483" class="block-content">Mari kita anggap tabel - "<tt>users</tt>" berikut yang berisi dua kolom bernama "<tt>username</tt>" dan "<tt>email</tt>", - di mana "<tt>username</tt>" juga merupakan kunci primer. + "<tt>users</tt>" berikut yang berisi dua kolom bernama "<tt>username</tt>" dan "<tt>email</tt>", + di mana "<tt>username</tt>" juga merupakan kunci primer. <com:TTextHighlighter Language="sql" CssClass="source block-content" id="code_690147"> CREATE TABLE users ( @@ -88,7 +88,7 @@ class UserRecord extends TActiveRecord public $username; //kolom bernama "username" dalam tabel "users" public $email; - + /** * @return TActiveRecord active record finder instance */ @@ -116,7 +116,7 @@ Anda dapat menetapkan nama-nama tabel yang memenuhi syarat. Contohnya untuk MySQ <com:TTextHighlighter Language="php" CssClass="source block-content" id="code_690149"> class UserRecord extends TActiveRecord { ... //definisi yang sudah ada seprti di atas - + private $_level; public function setLevel($value) { $this->_level=TPropertyValue::ensureInteger($value,0); @@ -126,18 +126,18 @@ class UserRecord extends TActiveRecord { } } </com:TTextHighlighter> -<p id="710010" class="block-content">Lebih jelas mengenai TComponent dapat ditemukan dalam <a href="?page=Fundamentals.Components">Dokumentasi komponen</a>. +<p id="710010" class="block-content">Lebih jelas mengenai TComponent dapat ditemukan dalam <a href="?page=Fundamentals.Components1">Dokumentasi komponen</a>. Nantinya kita harus dapat menggunakan pengambil/penyetel guna membolehkan pengambilan malas atas obyek yang berhubungan. </p> <div class="info"><b class="note">Info:</b> <tt>TActiveRecord</tt> juga dapat bekerja dengan view database dengan menetapkan konstan <tt>TABLE</tt> terkait ke nama view. Akan tetapi, obyek yang dikembalikan dari view hanya-baca, memanggil metode -<tt>save()</tt> atau <tt>delete()</tt> akan memunculkan eksepsi. +<tt>save()</tt> atau <tt>delete()</tt> akan memunculkan eksepsi. </div> <p id="690486" class="block-content"> - Metode statis <tt>finder()</tt> mengembalilkan turunan <tt>UserRecord</tt> + Metode statis <tt>finder()</tt> mengembalilkan turunan <tt>UserRecord</tt> yang dapat dipakai untuk mengambil rekaman dari database. Pengambilan rekaman menggunakan metode finder akan didiskusikan nanti. Metode statis <tt>TActiveRecord::finder()</tt> mengambil nama kelas Rekaman Aktif sebagai parameter. </p> @@ -152,7 +152,7 @@ obyek yang dikembalikan dari view hanya-baca, memanggil metode $dsn = 'pgsql:host=localhost;dbname=test'; //Postgres SQL $conn = new TDbConnection($dsn, 'dbuser','dbpass'); TActiveRecordManager::getInstance()->setDbConnection($conn); -</com:TTextHighlighter> +</com:TTextHighlighter> <p id="710011" class="block-content">Alternatifnya, Anda dapat membuat basis kelas dan mengganti metode <tt>getDbConnection()</tt> untuk mengembalikan koneksi database. Ini adalah cara sederhana untuk mengijinkan koneksi database multipel. Kode berikut mendemonstrasikan penetapan koneksi database dalam sebuah basis kelas (tidak perlu menyetel koneksi DB di manapun juga). @@ -178,13 +178,13 @@ class MyDb2Record extends TActiveRecord return $conn; } } -</com:TTextHighlighter> +</com:TTextHighlighter> <h3 class="prado-specific">Menggunakan <tt>application.xml</tt> di dalam Kerangka Kerja Prado</h3> <div class="prado-specific"> <p id="690488" class="block-content"> - Koneksi database standar dapat juga dikonfigurasi menggunakan tag <tt><module></tt> dalam <a href="?page=Configurations.AppConfig">application.xml</a> + Koneksi database standar dapat juga dikonfigurasi menggunakan tag <tt><module></tt> dalam <a href="?page=Configurations.AppConfig">application.xml</a> atau <a href="?page=Configurations.PageConfig">config.xml</a> seperti berikut. <com:TTextHighlighter Language="xml" CssClass="source block-content" id="code_690151"> <modules> @@ -192,8 +192,8 @@ class MyDb2Record extends TActiveRecord <database ConnectionString="pgsql:host=localhost;dbname=test" Username="dbuser" Password="dbpass" /> </module> -</modules> -</com:TTextHighlighter> +</modules> +</com:TTextHighlighter> <div class="tip"><b class="note">Tip:</b> Atribut <tt>EnableCache</tt> ketika disetel ke "true" akan melakukan cache meta data tabel, yakni nama kolom tabel, indeks dan batasan yang disimpan dalam cache dan dipakai ulang. Anda harus membersihkan atau mematikan cache jika Anda ingin melihat perubahan terhadap definisi tabel Anda. <a href="?page=Advanced.Performance#6402">Modul cache</a> juga harus didefinisikan agar cache berfungsi. </div> @@ -207,13 +207,13 @@ class MyDb2Record extends TActiveRecord Username="dbuser" Password="dbpass" /> </module> - <module class="System.Data.ActiveRecord.TActiveRecordConfig" + <module class="System.Data.ActiveRecord.TActiveRecordConfig" ConnectionID="db1" EnableCache="true" /> <module class="System.Data.SqlMap.TSqlMapConfig" ConnectionID="db1" ... /> -</modules> -</com:TTextHighlighter> +</modules> +</com:TTextHighlighter> </p> </div> @@ -299,10 +299,10 @@ $criteria->Offset = 20; <div class="note"><b class="note">Catatan:</b> Untuk MSSQL dan saat <tt>Limit</tt> serta <tt>Offset</tt> berisi nilai integer positif. Query aktual yang dijalankan diubah oleh kelas -<com:DocLink ClassPath="System.Data.ActiveRecord.Common.Mssql.TMssqlCommandBuilder" +<com:DocLink ClassPath="System.Data.ActiveRecord.Common.Mssql.TMssqlCommandBuilder" Text="TMssqlCommandBuilder" /> -berdasarkan pada +berdasarkan pada <a href="http://troels.arvin.dk/db/rdbms/#select-limit-offset">http://troels.arvin.dk/db/rdbms/</a> untuk mengemulasikan kondisi <tt>Limit</tt> dan <tt>Offset</tt>. </div> @@ -332,11 +332,11 @@ $finder->find('Username = ? AND Password = ?', $name, $pass); $finder->findAllByAge($age); $finder->findAll('Age = ?', $age); </com:TTextHighlighter> - + <div class="tip"><b class="note">Tip:</b> Anda juga dapat menggunakan kombinasi <tt>AND</tt> dan <tt>OR</tt> sebagai kondisi dalam metode dinamis. </div> - + <h3 id="138060"><tt>findBySql()</tt> dan <tt>findAllBySql()</tt></h3> <p id="690497" class="block-content">Mencari rekaman menggunakan SQL penuh di mana <tt>findBySql()</tt> mengembalikan Rekaman Aktif dan <tt>findAllBySql()</tt>mengembalikan array obyek rekaman. Untuk setiap kolom yang dikembalikan, kelas Rekaman Aktif terkait harus mendefinisikan variabel atau properti untuk setiap nama kolom terkait. @@ -371,7 +371,7 @@ Obyek dimutakhirkan dengan kunci primer dari tabel itu yang berisi definisi yang Sebagai contoh, jika Anda menyisipkan sebuah rekaman baru ke dalam tabel MySQL yang kolomnya didefinisikan dengan "autoincrement", obyek Rekaman Aktif akan dimutakhirkan dengan nilai yang ditambahkan.</div> <p id="690500" class="block-content"> -Untuk memutakhirkan rekaman dalam database, cukup ubah satu atau lebih properti obyek Rekaman Aktif yang sudah diambil dari database dan kemudian panggil metode <tt>save()</tt>. +Untuk memutakhirkan rekaman dalam database, cukup ubah satu atau lebih properti obyek Rekaman Aktif yang sudah diambil dari database dan kemudian panggil metode <tt>save()</tt>. <com:TTextHighlighter Language="php" CssClass="source block-content" id="code_690162"> $user = UserRecord::finder()->findByName('admin'); @@ -392,7 +392,7 @@ Kapan saja Anda memanggil metode <tt>save()</tt> pada obyek TActiveRecord, obyek <h2 id="138052">Menghapus rekaman yang sudah ada</h2> <p id="690502" class="block-content"> Untuk menghapus rekaman yang sudah ada dan diambil, cukup panggil metode <tt>delete()</tt>. - Anda juga dapat menghapus rekaman dalam database dengan kunci primer tanpa mengambil rekaman apapun menggunakan metode <tt>deleteByPk()</tt> (dan metode yang sama <tt>deleteAllByPks()</tt>). + Anda juga dapat menghapus rekaman dalam database dengan kunci primer tanpa mengambil rekaman apapun menggunakan metode <tt>deleteByPk()</tt> (dan metode yang sama <tt>deleteAllByPks()</tt>). Sebagai contoh, untuk menghapus satu atau beberapa rekaman dengan menggunakan satu atau lebih kunci primer. </p> <com:TTextHighlighter Language="php" CssClass="source block-content" id="code_690163"> @@ -457,8 +457,8 @@ TActiveRecord menawarkan dua event, <tt>OnCreateCommand</tt> dan <tt>OnExecuteCo </p> <p id="710015" class="block-content"> -Event <tt>OnExecuteCommand</tt> dimunculkan ketika perintah dijalankan dan hasil dari database dikembalikan. Obyek parameter <tt>TDataGatewayResultEventParameter</tt> -dari properti <tt>Result</tt> berisi data yang dikembalikan dari database. +Event <tt>OnExecuteCommand</tt> dimunculkan ketika perintah dijalankan dan hasil dari database dikembalikan. Obyek parameter <tt>TDataGatewayResultEventParameter</tt> +dari properti <tt>Result</tt> berisi data yang dikembalikan dari database. Data yang dikembalikan dapat diubah dengan setelan properti <tt>Result</tt>. </p> @@ -491,7 +491,7 @@ function logger($sender,$param) } TActiveRecord::finder('MyRecord')->OnExecuteCommand[] = 'logger'; $obj->OnExecuteCommand[] = array($logger, 'log'); //setiap PHP callback yg benar. -</com:TTextHighlighter> +</com:TTextHighlighter> <h1 id="ar_relations">Hubungan Rekaman Aktif</h1> <com:SinceVersion Version="3.1rc1" /> @@ -507,7 +507,7 @@ Dalam bagian berikut kita akan menganggap hubungan tabel antara <img src=<%~ ar_relations.png %> class="figure" /> -<p id="710018" class="block-content">Tujuannya adalah untuk mendapatkan model obyek yang mewakili ke beberapa derajat hubungan entitas dalam gambar di atas. +<p id="710018" class="block-content">Tujuannya adalah untuk mendapatkan model obyek yang mewakili ke beberapa derajat hubungan entitas dalam gambar di atas. </p> <img src=<%~ ar_objects.png %> class="figure" /> @@ -534,7 +534,7 @@ CREATE TABLE bar </div> <h2 id="142012">Pemetaan Kunci Asing</h2> -<p class="block-content">Hubungan entitas antara tabel <tt>Teams</tt> dan <tt>Players</tt> adalah apa yang dikenal sebagai hubungan 1-M. Yaitu, satu Tim dapat berisi 0 atau lebih Pemain. Dalam batasan hubungan obyek, kita katakan bahwa obyek <tt>TeamRecord</tt> <b>memiliki banyak</b> obyek <tt>PlayerRecord</tt>. +<p class="block-content">Hubungan entitas antara tabel <tt>Teams</tt> dan <tt>Players</tt> adalah apa yang dikenal sebagai hubungan 1-M. Yaitu, satu Tim dapat berisi 0 atau lebih Pemain. Dalam batasan hubungan obyek, kita katakan bahwa obyek <tt>TeamRecord</tt> <b>memiliki banyak</b> obyek <tt>PlayerRecord</tt>. (Perhatikan kebalikan dari arah hubungan antara tabel dan obyek.) <p id="710019" class="block-content"> @@ -548,7 +548,7 @@ class TeamRecord extends TActiveRecord const TABLE='Teams'; public $name; public $location; - + public $players=array(); // deklarasi ini tidak diperlukan lagi sejak v3.1.2 //mendefinisikan anggota $player yang memiliki hubungan banyak dengan PlayerRecord @@ -616,7 +616,7 @@ Metode <tt>with_xxx()</tt> (di mana <tt>xxx</tt> adalah nama properti hubungan, <div class="note"><b class="note">Catatan:</b> Penting untuk dimengerti bahwa obyek terkait diambil menggunakan query tambahan. Query pertama mengambil obyek sumber, misalnya <tt>TeamRecord</tt> dalam contoh kode di atas. -Query kedua dipakai untuk mengambil obyek <tt>PlayerRecord</tt> terkait. +Query kedua dipakai untuk mengambil obyek <tt>PlayerRecord</tt> terkait. Penggunaan dua query mirip dengan query tunggal menggunakan Left-Outer join dengan eksepsi bahwa hasil null pada tabel kanan tidak dikembalikan. Konsekuensi pemakaian dua tau lebih query adalah kondisi agregat dan join tidak layak menggunakan Rekaman Aktif. Untuk query di luar lingkup Rekaman Aktif, <a href="?page=Database.SqlMap">Pemeta Data SqlMap</a> diapat dupertimbangkan. </div> @@ -634,9 +634,9 @@ Kode berikut mendefinisikan kelas <tt>PlayerRecord</tt> lengkap dengan 3 hubunga class PlayerRecord extends TActiveRecord { const TABLE='Players'; - public $player_id; - public $age; - public $team_name; + public $player_id; + public $age; + public $team_name; public $team; // deklarasi ini tidak diperlukan lagi sejak v3.1.2 public $skills=array(); // deklarasi ini tidak diperlukan lagi sejak v3.1.2 @@ -656,9 +656,9 @@ class PlayerRecord extends TActiveRecord } </com:TTextHighlighter> <p id="710026" class="block-content"> -Properti <tt>$RELATIONS</tt> dari <tt>PlayerRecord</tt> mendefinisikan properti <tt>$team</tt> <b>milik</b> <tt>TeamRecord</tt>. -Array <tt>$RELATIONS</tt> juga mendefinisikan dua hubungan lainnya yang nanti akan kita uji dalam seksi di bawah ini. -Dalam <tt>array(self::BELONGS_TO, 'TeamRecord')</tt>, elemen pertama mendefinisikan tipe hubungan, dalam hal ini <strong><tt>self::BELONGS_TO</tt></strong> dan +Properti <tt>$RELATIONS</tt> dari <tt>PlayerRecord</tt> mendefinisikan properti <tt>$team</tt> <b>milik</b> <tt>TeamRecord</tt>. +Array <tt>$RELATIONS</tt> juga mendefinisikan dua hubungan lainnya yang nanti akan kita uji dalam seksi di bawah ini. +Dalam <tt>array(self::BELONGS_TO, 'TeamRecord')</tt>, elemen pertama mendefinisikan tipe hubungan, dalam hal ini <strong><tt>self::BELONGS_TO</tt></strong> dan elemen kedua adalah string <tt>'TeamRecord'</tt> yang terkait ke nama kelas dari kelas <tt>TeamRecord</tt>. Obyek pemain dengan obyek tim terkait dapat diambil serperti berikut. </p> @@ -703,7 +703,7 @@ class ProfileRecord extends TActiveRecord <p id="710029" class="block-content">Intinya, ada hubungan "<b>belongs to</b>" untuk obyek yang mengaitkan entitas yang memmpunyai kolom yakni kunci asing. Dalam keadaan tertentu, kita melihat bahwa tabel <tt>Profiles</tt> mempunyai batasan kunci asing pada kolom <tt>player_id</tt> yang terkait ke tabel <tt>Players</tt> kolom <tt>player_id</tt>. Selanjutnya, obyek <tt>ProfileRecord</tt> memiliki properti (<tt>$player</tt>) yang adalah <b>milik</b> obyek <tt>PlayerRecord</tt>. -Demikian juga, tabel <tt>Players</tt> mempunyai batasan kunci asing pada kolom <tt>team_name</tt> yang terkait ke tabel <tt>Teams</tt> kolom <tt>name</tt>. +Demikian juga, tabel <tt>Players</tt> mempunyai batasan kunci asing pada kolom <tt>team_name</tt> yang terkait ke tabel <tt>Teams</tt> kolom <tt>name</tt>. Kemudian, obyek <tt>PlayerRecord</tt> mempunyai properti (<tt>$team</tt>) yang adalah <b>milik</b> obyek <tt>TeamRecord</tt>. </p> @@ -756,13 +756,13 @@ dua elemen tambahan ini mirip seperti parameter yang dikirimkan ke metode <tt>fi Obyek dapat dengan mudah menangani field multi nilai dengan menggunakan koleksi sebagai nilai field. Database relasional tidak memiliki fitur ini dan dibatasi hanya ke field nilai-tunggal. Ketika Anda memetakan asosiasi satu-ke-banyak, Anda bisa menangani ini menggunakan hubungan <b>has many</b>, intinya menggunakan kunci asing untuk nilai-tunggal akhir dari asosiasi. Tapi asosiasi banyak-ke-banyak tidak bisa melakukan ini karena tidak ada nilai-tunggal akhir ke kunci asing yang dipegangnya. </p> <p id="710033" class="block-content"> -Jawabannya adalah resolusi klasik yang telah dipakai oleh orang selama dekade ini yakni: buat tabel ekstra (tabel asosiasi) untuk merekam asosiasi. +Jawabannya adalah resolusi klasik yang telah dipakai oleh orang selama dekade ini yakni: buat tabel ekstra (tabel asosiasi) untuk merekam asosiasi. Ide dasarnya adalah menggunakan tabel asosiasi untuk menyimpan asosiasi. Tabel ini memiliki ID kunci asing untuk dua tabel yang dikaitkan bersama, masing-masing memiliki pasangan dari obyek yang diasosiasikan. </p> <p id="710034" class="block-content"> Tabel asosiasi tidak mempunyai kaitan obyek dalam-memori dan kunci primernya adalah gabungan dari dua kunci primer dari tabel yang diasosiasikan. -Dalam batasan yang sederhana, tuntuk mengambil data dari tabel asosiasi, Anda melakukan dua query (secara umum, ini juga bisa dicapai menggunakan satu query yang terdiri dari join). -Anggap pengambilan koleksi <tt>SkillRecord</tt> untuk daftar obyek <tt>PlayerRecord</tt>. +Dalam batasan yang sederhana, tuntuk mengambil data dari tabel asosiasi, Anda melakukan dua query (secara umum, ini juga bisa dicapai menggunakan satu query yang terdiri dari join). +Anggap pengambilan koleksi <tt>SkillRecord</tt> untuk daftar obyek <tt>PlayerRecord</tt>. Dalam hal ini, Anda melakukan query dalam dua tahap. Tahap pertama meng-query tabel <tt>Players</tt> untuk mencari seluruh baris dari pemain yang Anda inginkan. Tahap kedua mencari obyek <tt>SkillRecord</tt> ID pemain terkait untuk setiap barisnya dalam tabel asosiasi <tt>Player_Skills</tt> menggunakan sebuah inner join. </p> @@ -794,7 +794,7 @@ class SkillRecord extends TActiveRecord <p id="710036" class="block-content"> Properti statis <tt>$RELATIONS</tt> dari SkillRecord mendefinisikan bahwa properti <tt>$players</tt> memiliki banyak <tt>PlayerRecord</tt>s melalui tabel asosiasi '<tt>Player_Skills</tt>'. Dalam <tt>array(self::MANY_TO_MANY, 'PlayerRecord', 'Player_Skills')</tt>, elemen pertama mendefinisikan tipe hubungan, dalam hal ini <strong><tt>self::HAS_MANY</tt></strong>, -elemen kedua adalah string <tt>'PlayerRecord'</tt> yang terkait ke nama kelas dari kelas <tt>PlayerRecord</tt>, dan elemen ketiga adalah nama dari nama tabel asosiasi. +elemen kedua adalah string <tt>'PlayerRecord'</tt> yang terkait ke nama kelas dari kelas <tt>PlayerRecord</tt>, dan elemen ketiga adalah nama dari nama tabel asosiasi. </p> <div class="note"><b class="note">Catatan:</b> @@ -815,22 +815,22 @@ Metode <tt>with_xxx()</tt> (di mana <tt>xxx</tt> adalah nama properti hubungan, <p id="710039" class="block-content"> Untuk tabel asosiasi yang mererefensi dirinya sendiri, yaitu titik asosiasi ke tabel yang sama. Sebagai contoh, anggap tabel <tt>items</tt> dengan item terkait M-N melalui tabel asosiasi <tt>related_items</tt>. Sintaks dalam contoh berikut adalah benar untuk database PostgreSQL. Untuk database lain, lihat dokumentasinya masing-masing untuk mendefinisikan batasan kunci asing. <com:TTextHighlighter Language="sql" CssClass="source block-content"> -CREATE TABLE items +CREATE TABLE items ( - "item_id" SERIAL, + "item_id" SERIAL, "name" VARCHAR(128) NOT NULL, PRIMARY KEY("item_id") ); -CREATE TABLE "related_items" +CREATE TABLE "related_items" ( - "item_id" INTEGER NOT NULL, - "related_item_id" INTEGER NOT NULL, - CONSTRAINT "related_items_pkey" PRIMARY KEY("item_id", "related_item_id"), + "item_id" INTEGER NOT NULL, + "related_item_id" INTEGER NOT NULL, + CONSTRAINT "related_items_pkey" PRIMARY KEY("item_id", "related_item_id"), CONSTRAINT "related_items_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "items"("item_id") ON DELETE CASCADE ON UPDATE NO ACTION - NOT DEFERRABLE, + NOT DEFERRABLE, CONSTRAINT "related_items_related_item_id_fkey" FOREIGN KEY ("related_item_id") REFERENCES "items"("item_id") ON DELETE CASCADE @@ -839,7 +839,7 @@ CREATE TABLE "related_items" ); </com:TTextHighlighter> -<p id="710040" class="block-content">Nama tabel asosiasi dalam elemen ketiga dari array hubungan dapat berisi nama kolom tabel asing. Kolom yang didefinisikan dalam tabel asosiasi harus juga didefinisikan dalam kelas rekaman (contohnya properti <tt>$related_item_id</tt> terkait ke kolom <tt>related_item_id</tt> dalam tabel <tt>related_items</tt>). +<p id="710040" class="block-content">Nama tabel asosiasi dalam elemen ketiga dari array hubungan dapat berisi nama kolom tabel asing. Kolom yang didefinisikan dalam tabel asosiasi harus juga didefinisikan dalam kelas rekaman (contohnya properti <tt>$related_item_id</tt> terkait ke kolom <tt>related_item_id</tt> dalam tabel <tt>related_items</tt>). </p> <com:TTextHighlighter Language="php" CssClass="source block-content"> class Item extends TActiveRecord @@ -849,18 +849,18 @@ class Item extends TActiveRecord public $details; //id item asing tambahan didefinisikan dalam tabel asosiasi - public $related_item_id; + public $related_item_id; public $related_items=array(); // deklarasi ini tidak diperlukan lagi sejak v3.1.2 public static $RELATIONS=array ( - 'related_items' => array(self::MANY_TO_MANY, + 'related_items' => array(self::MANY_TO_MANY, 'Item', 'related_items.related_item_id'), ); } </com:TTextHighlighter> <div class="tip"><b class="note">Tip:</b> -Kunci gabungan dalam tabel asing dapat ditetapkan sebagai nilai dipisahkan koma diantara kurung buka/tutup. Contohnya <tt>'related_items.(id1,id2)'</tt>. +Kunci gabungan dalam tabel asing dapat ditetapkan sebagai nilai dipisahkan koma diantara kurung buka/tutup. Contohnya <tt>'related_items.(id1,id2)'</tt>. </div> <!--- @@ -882,7 +882,7 @@ Karena kelas <tt>TeamRecord</tt> berisi hubungan <b>has many</b> dengan <tt>Play </p> <p id="710043" class="block-content">Untuk menghapus obyek asing tertentu (atau setiap obyek Rekaman Aktif), cukup panggil metode obyek <tt>delete()</tt>. Anda dapat menyiapkan batas kunci asing tabel database seperti saat menghapus data tertentu dalam database ia akan menghapus data yang direferensi juga (ia juga dapat dicapai dengan menggunakan pemicu database). Contohnya seperti mempunyai batasan "<tt>ON DELETE CASCADE</tt>". -Menghapus kunci obyek asing dengan menyetel nilai properti ke null atau menghapus obyek dari array <b>TIDAK</b> akan menghapus data terkait dalam database. +Menghapus kunci obyek asing dengan menyetel nilai properti ke null atau menghapus obyek dari array <b>TIDAK</b> akan menghapus data terkait dalam database. </p> <p id="710044" class="block-content">Untuk menghapus asosiasi hubungan banyak-ke-banyak melalui tabel asosiasi, Rekaman Aktif yang terkait tabel asosiasi yang bisas dipakai. Kemudian asosiasi dapat dihapus dengan memanggil metode <tt>deleteByPk()</tt>, sebagai contoh: @@ -908,7 +908,7 @@ class PlayerRecord extends BaseFkRecord //... properti dan metode lainnya seperti sebelumnya private $_skills; //ubah ke private dan standar sebagai null - + public function getSkills() { if($this->_skills===null && $this->player_id !==null) @@ -932,7 +932,7 @@ class PlayerRecord extends BaseFkRecord } </com:TTextHighlighter> <p id="710046" class="block-content">Pertama kita perlu mengubah deklarasi <tt>$skills=array()</tt> ke properti private <tt>$_skills</tt> (perhatikan garis bawah) dan sebaliknya setel ke null. Ini membolehkan kita untuk mendefinisikan properti <tt>skills</tt> menggunakan metode pengambil/penyetel -(lihat <a href="?page=Fundamentals.Components">Komponen</a> untuk lebih jelasnya). Metode pengambil <tt>getSkills()</tt> untuk properti <tt>skills</tt> akan mengambil malas rekaman skill terkait saat ia dipakai sebagai berikut. Catatan bahwa kita hanya melakukan pengambilan malas ketika <tt>$player_id</tt> tidak null (yakni, ketika rekaman sudah diambil dari database ataau id player sudah disetel). +(lihat <a href="?page=Fundamentals.Components1">Komponen</a> untuk lebih jelasnya). Metode pengambil <tt>getSkills()</tt> untuk properti <tt>skills</tt> akan mengambil malas rekaman skill terkait saat ia dipakai sebagai berikut. Catatan bahwa kita hanya melakukan pengambilan malas ketika <tt>$player_id</tt> tidak null (yakni, ketika rekaman sudah diambil dari database ataau id player sudah disetel). </p> <com:TTextHighlighter Language="php" CssClass="source block-content"> $player = PlayerRecord::finder()->findByPk(1); @@ -943,13 +943,13 @@ $player->skills[] = new SkillRecord(); //menambah skill <p id="710047" class="block-content">The <tt>setSkills()</tt> memastikan bahwa properti <tt>skills</tt> akan selalu berupa TList. Menggunakan TList yang membolehkan kita untuk menyetel elemen properti <tt>skills</tt> seolah-olah mereka -sebuah array. Contohnya <tt>$player->skills[] = new SkillRecord()</tt>. Jika <tt>array</tt> dipakai, kesalahan PHP -akan dikeluarkan. +sebuah array. Contohnya <tt>$player->skills[] = new SkillRecord()</tt>. Jika <tt>array</tt> dipakai, kesalahan PHP +akan dikeluarkan. </p> <h2>Pemetaan Kolom</h2> <p> -Sejak v3.1.1, Rekaman Aktif mulai mendukung pemetaan kolom. Pemetaan kolom membolehkan para +Sejak v3.1.1, Rekaman Aktif mulai mendukung pemetaan kolom. Pemetaan kolom membolehkan para pengembang untuk mengalamatkan kolom dalam Rekaman Aktif menggunakan konvensi penamaan lebih konsisten. Dalam keadaan tertentu, menggunakan pemetaan kolom, seseorang dapat mengakses kolom menggunakan apapun namanya yang disukainya, daripada nama terbatas yang didefinisikan dalam diff --git a/demos/quickstart/protected/pages/Database/pl/ActiveRecord.page b/demos/quickstart/protected/pages/Database/pl/ActiveRecord.page index 97a054fe..3a073e57 100755 --- a/demos/quickstart/protected/pages/Database/pl/ActiveRecord.page +++ b/demos/quickstart/protected/pages/Database/pl/ActiveRecord.page @@ -2,7 +2,7 @@ <h1 id="138046">Rekord Aktywny (ang. Active Record)</h1> <com:SinceVersion Version="3.1a" /> <p id="690478" class="block-content">Rekordy Aktywne są obiektami, które opakowują wiersz w bazie danych lub widoku, - obudowują (ang. encapsulate) dostęp do bazy danych oraz dziedziny logiki dla tych danych. + obudowują (ang. encapsulate) dostęp do bazy danych oraz dziedziny logiki dla tych danych. Podstawą Rekordu Aktywnego są klasy biznesowe np. klasa <tt>Produkty</tt>, które są bardzo podobne do struktury rekordu należącego do bazy danych. Każdy Rekord Aktywny jest odpowiedzialny za zapisywanie i łądowanie danych do i z bazy danych.</p> @@ -13,18 +13,18 @@ <h2 id="138047">Kiedy używać?</h2> <p id="690479" class="block-content">Rekord Aktywne jest dobrym wyborem dla dziedziny logiki, która nie jest zbyt złożona, tak jak tworzenie, odczyty, aktualizacje oraz usuwanie. - Pochocne (ang. derivations) oraz sprawdzenia bazujące na pojedyńczym rekordzie sprawdzają się dobrze w tej konstrukcji. + Pochocne (ang. derivations) oraz sprawdzenia bazujące na pojedyńczym rekordzie sprawdzają się dobrze w tej konstrukcji. Rekord Aktywne ma podstawową zaletę, którą jest prostota. Łatwo jest stworzyć Rekord Aktywny, łatwo go również zrozuieć. </p> - <p id="690480" class="block-content">Jednakże, jeśli twoja logika biznesowa staje się coraz bardziej złożona, wkrótce będziesz chciał + <p id="690480" class="block-content">Jednakże, jeśli twoja logika biznesowa staje się coraz bardziej złożona, wkrótce będziesz chciał używać bezpośrednich relacji, zbiorów, dziedziczenia twojego obiektu i tak dalej. Nie da się tego łatwo odwzorować za pomocą Rekordu Aktywnego, a dodawanie ich po kawałku staje się bardzo kłopotliwe. Innym argumentem przeciw Rekordowi Aktywnemu jest fakt, że łączy model obiektowy z modelem baz danych. To czyni trudniejszym refaktoring, gdy projekt idzie naprzód. </p> <p id="690481" class="block-content">Alternatywą jest używanie wzorca Data Mapper (mapa danych), który odseparowuje role obiektu biznesowego od tego jak te obiekty są przechowywane. - Prado dostarcza + Prado dostarcza Prado provides a darmowy wybór pomiędzy rekordem aktywnym a <a href="?page=Database.SqlMap">SqlMap Data Mapper</a>. SqlMap Data Mapper może być uzywany do wczytania obiektów Rekordu Aktywnego, i na odwrót, te Rekordy Aktywne mogą zostać użyte do aktualizacji bazy danych. Związek pomiędzy Rekordem Aktywnym a <a href="?page=Database.SqlMap">SqlMap</a> przedstawiony jest na kolejnym diagramie. Więcej informacji związanych z SqlMap Data Mapper można znaleźć w @@ -33,7 +33,7 @@ </p> <p id="690482" class="block-content"> - Klasa Rekordu aktywnego posiada funkcjonalność do przeprowadzenia następujących zadań: + Klasa Rekordu aktywnego posiada funkcjonalność do przeprowadzenia następujących zadań: </p> <ul id="u1" class="block-content"> <li>Tworzenie, zwracanie, aktualizowani i usuwanie recordów (CRUD)</li> @@ -51,16 +51,16 @@ zwróci fałsz, natomiast luźne porównianie (np. używając <tt>==</tt>) zwró <p> Jest to implikacja modelu wynikająca z następującego pytania: <i>"Czy myślisz o kliencie jako o obiekcie, którego któy jest tylko jeden, czy też myślisz o obiekcie na którym działasz jako o <b>kopii</b> bazy danych.</i> -Inne mapowania O/R implikują, że istnieje tylko jeden obiekt Klienta z KlientID 100 +Inne mapowania O/R implikują, że istnieje tylko jeden obiekt Klienta z KlientID 100 Other O/R mappings will imply that there is only one Customer object with custID 100 i to dosłownie jest ten klient. -Jeśli pobierzesz klienta i zmienisz pole w nim, wtedy masz zmienionego tego klienta. +Jeśli pobierzesz klienta i zmienisz pole w nim, wtedy masz zmienionego tego klienta. <i>"To kontroastuje z: zmieniłeś tą kopię klienta ale nie tamtą kopię. Jeśli dwóch ludzi zaktualizuje kleinta z dwóch kopii obiektu, kto zaktualizuje pierwszy lub być może ostanie wygrywa."</i> [A. Hejlsberg 2003] </p> <h2 id="142010">Wspierane bazy danych</h2> <p id="p1" class="block-content"> -Implementacja Aktywnego Rekordu wykorzystuje kalsy <a href="?page=Database.DAO">Prado DAO</a> by uzyskać dostęp do danych. Aktualna implementacja Aktywnego Rekordu wspiera następujace bazy danych +Implementacja Aktywnego Rekordu wykorzystuje kalsy <a href="?page=Database.DAO">Prado DAO</a> by uzyskać dostęp do danych. Aktualna implementacja Aktywnego Rekordu wspiera następujace bazy danych </p> <ul> <li><a href="http://www.mysql.com">MySQL 4.1 i wyższe</a></li> @@ -104,7 +104,7 @@ class UserRecord extends TActiveRecord </p> <p id="690485" class="block-content">Każda kolumna tablicy "<tt>users</tt>" musi posiadać odpowiadającą jej właściwość o tej samej nazwie co kolumna w tablicy w klasie <tt>UserRecord</tt>. Oczywiście, możesz zdefiniować dodatkowe zmienne lub właściwości, które nie istnieją w strukturze tablicy. - Stała <tt>TABLE</tt> jest opcjonalna w klasie , kiedy nazwa klasy jest taka sama jak nazwa tablicy w bazie danych, w przeciwnym przypadku <tt>TABLE</tt> + Stała <tt>TABLE</tt> jest opcjonalna w klasie , kiedy nazwa klasy jest taka sama jak nazwa tablicy w bazie danych, w przeciwnym przypadku <tt>TABLE</tt> musi określać nazwę tablicy, która odpowiada klasie Rekordu Aktywnego. </p> @@ -114,7 +114,7 @@ Możesz określić kwalifikowane (ang. qualified) nazwy tablic np dla MySQL, <tt <p class="block-content" id="ar_as_component"> Odkąd <tt>TActiveRecord</tt> rozszerza <tt>TComponent</tt>, metody setter i getter mogą zostać zdefiniowane - by umożliwić kontrolę nad tym jak zmienne są ustawiane i zwracane. Na przykłąd dodanie właściwości <tt>$level</tt> + by umożliwić kontrolę nad tym jak zmienne są ustawiane i zwracane. Na przykłąd dodanie właściwości <tt>$level</tt> do klasy UserRecord: </p> <com:TTextHighlighter Language="php" CssClass="source block-content" id="code_690149"> @@ -130,13 +130,13 @@ class UserRecord extends TActiveRecord { } } </com:TTextHighlighter> -<p id="710010" class="block-content">Więcej szczegółów dotyczących TComponent można znaleźć <a href="?page=Fundamentals.Components">dokumentacji komponentów</a>. +<p id="710010" class="block-content">Więcej szczegółów dotyczących TComponent można znaleźć <a href="?page=Fundamentals.Components1">dokumentacji komponentów</a>. Później użyjemy metod getter/setters by umożliwić opóźnione ładowanie (ang. lazy loading) obiektów relacji. </p> <div class="info"><b class="note">Info:</b> <tt>TActiveRecord</tt> może również działać z widokami poprzez przypisanie do stałej <tt>TABLE</tt> - odpowiedniej nazwy widoku. Jednakże obiektu zwracane przez widoki są tylko do odczytu, wywołanie metod <tt>save()</tt> lub <tt>delete()</tt> + odpowiedniej nazwy widoku. Jednakże obiektu zwracane przez widoki są tylko do odczytu, wywołanie metod <tt>save()</tt> lub <tt>delete()</tt> spowoduje wywołanie wyjątku. </div> @@ -149,7 +149,7 @@ spowoduje wywołanie wyjątku. <h2 id="138049">Ustanawianie połączenia z bazą danych</h2> <p id="690487" class="block-content"> Domyślne połączenie z bazą dla Rekordu Aktywnego może zostać ustawione następujaco. - Zobacz <a href="?page=Database.DAO">Ustanawianie połączenia z bazą</a> + Zobacz <a href="?page=Database.DAO">Ustanawianie połączenia z bazą</a> by uzyskać ogólnie dalsze szczegóły odnośnie tworzenia połączenia z bazą danych. </p> <com:TTextHighlighter Language="php" CssClass="source block-content" id="code_690150"> @@ -160,7 +160,7 @@ TActiveRecordManager::getInstance()->setDbConnection($conn); </com:TTextHighlighter> <p id="710011" class="block-content">Alternatywnie, możesz stworzyć klasę bazową i nadpisać metodę <tt>getDbConnection()</tt> -do zwracania połączenia z bazą. To jest prosty spodób, by umożliwić wielkokrotne połączenia do wielu baz danych. +do zwracania połączenia z bazą. To jest prosty spodób, by umożliwić wielkokrotne połączenia do wielu baz danych. Następujący kod demonstruje definiowanie połączenia z bazą danych w klasie bazowej (nie ma potrzeby by ustawiać połączenie DB gdziekolwiek indziej). </p> <com:TTextHighlighter Language="php" CssClass="source block-content"> @@ -203,7 +203,7 @@ class MyDb2Record extends TActiveRecord </com:TTextHighlighter> <div class="tip"><b class="note">Wskazówka:</b> Atrybut <tt>EnableCache</tt> gdy ustawiony na "true" będzie keszował metadane tablicy, to oznacza, że nazwy kolumn, indeksy i ograniczenia (ang. constraints) - są zapisywane w keszu i używane ponownie. Musisz wyczyścić lub wyłączyć kesz jeśli chcesz zobaczyć wprowadzone zmiany do definicji twoich tablic. + są zapisywane w keszu i używane ponownie. Musisz wyczyścić lub wyłączyć kesz jeśli chcesz zobaczyć wprowadzone zmiany do definicji twoich tablic. <a href="?page=Advanced.Performance#6402">Moduł keszowania</a> musi być również zdefiniowany dla keszu by zadziałał. </div> </p> @@ -229,14 +229,14 @@ class MyDb2Record extends TActiveRecord <h2 id="138050">Ładowanie danych z tablicy</h2> <p id="690490" class="block-content"> - Klasa <tt>TActiveRecord</tt> dostarcza wielu wygodnych metod do wyszukiwania rekordów z bazy danych. + Klasa <tt>TActiveRecord</tt> dostarcza wielu wygodnych metod do wyszukiwania rekordów z bazy danych. Najprostszym jest znajdowanie jednego rekordu poprzez dopasowanie klucza głównego lub klucza złożonego (ang. composite key) (klucz główny skłądający się z wielu kolumn). Zobacz <com:DocLink ClassPath="System.Data.ActiveRecord.TActiveRecord" /> by dowiedzieć się więcej. </p> <div class="info"><b class="note">Info:</b> -Wszystkie metody wyszukujące, które mogą zwrócić tylko 1 rekord zwrócą <tt>null</tt> jeśli nie znajdą pasujących danych. +Wszystkie metody wyszukujące, które mogą zwrócić tylko 1 rekord zwrócą <tt>null</tt> jeśli nie znajdą pasujących danych. Wszystkie metody wyszukujące, które zwracają tablicę rekordów zwrócą pustą tablicęm jeśli nie znajdą pasujących danych. </div> @@ -352,8 +352,8 @@ Możesz również użyć połączenia <tt>AND</tt> oraz <tt>OR</tt> jako warunek </div> <h3 id="138060"><tt>findBySql()</tt> oraz <tt>findAllBySql()</tt></h3> -<p id="690497" class="block-content">Znajdują rekordy używając pełnego zapytania SQL z tym, że <tt>findBySql()</tt> -zwraca Rekord Aktywny a <tt>findAllBySql()</tt>zwraca tablicę obiektów rekordów. +<p id="690497" class="block-content">Znajdują rekordy używając pełnego zapytania SQL z tym, że <tt>findBySql()</tt> +zwraca Rekord Aktywny a <tt>findAllBySql()</tt>zwraca tablicę obiektów rekordów. Dla każdej zwróconej kolumny, odpowiadająca klasa Rekordu Aktywnego musi posiadać zdefiniowaną zmienną lub właściwość odpowiadającą nazwie kolumny. <com:TTextHighlighter Language="php" CssClass="source block-content"> class UserRecord2 extends UserRecord @@ -382,7 +382,7 @@ $user2 = new UserRecord($data); //stwórz przekazując istniejące dane $user2->save(); //wstaw nowy rekord </com:TTextHighlighter> <div class="tip"><b class="note">Wskazówka:</b> -Obiekty są aktualizowe automatycznie o wartość klucza głównego dla tych tablic, które zawierają definicję +Obiekty są aktualizowe automatycznie o wartość klucza głównego dla tych tablic, które zawierają definicję określającą automatyczne tworzenie klucza głównego dla nowo tworzonych rekordów (przyp. tłum. autoincrement). Na przykład jeśli wstawiasz nowy rekord do tablicy MySQL która posiada kolumnę zdefiniowaną jako to obiekt Rekordu Aktywnego zostanie zaktualizowant o nową zwiększoną wartość.</div> @@ -403,10 +403,10 @@ Obiekt Rekordu Aktywnego posiada prosty cykl życia zilustrowany następujący d <img src=<%~ object_states.png %> alt="Active Records Life Cycle" id="fig:cycle.png" class="figure"/> <p id="690501" class="block-content"> Widzimy, że nowe obiekty Rekordu Aktywnego są tworzone zarówno przez jedną z metod <tt>find*()</tt> -lub poprzez stworzenie nowej instancji poprzez użycie polecenia PHP <tt>new</tt>. Obiekty stworzone przez metodę <tt>find*()</tt> +lub poprzez stworzenie nowej instancji poprzez użycie polecenia PHP <tt>new</tt>. Obiekty stworzone przez metodę <tt>find*()</tt> zaczynają ze stanem <tt>czysty (ang. clean)</tt>. Nowa instancja TActiveRecord stworzona inaczej niż za pomocą metod <tt>find*()</tt> zaczyna ze stanem <tt>nowy (ang. new)</tt>. -Kiedykolwiek wywołasz metodę <tt>save()</tt> na obiekcie TActiveRecord, obiekt przyjmuje stan <tt>czysty</tt>. -Obiekty będące <tt>czystymi</tt> stają się <tt>brudne (ang. dirty)</tt> kiedy jeden lub więcej ze stwoich wewnętrznych stanów ulegnie zmianie. +Kiedykolwiek wywołasz metodę <tt>save()</tt> na obiekcie TActiveRecord, obiekt przyjmuje stan <tt>czysty</tt>. +Obiekty będące <tt>czystymi</tt> stają się <tt>brudne (ang. dirty)</tt> kiedy jeden lub więcej ze stwoich wewnętrznych stanów ulegnie zmianie. Wywoałanie metody <tt>delete()</tt> obiektu kończy cykl życia, żadne inne akcje nie mogą być wywołane na obiekcie. </p> @@ -451,7 +451,7 @@ $finder->deleteBy_Username_And_Password($name,$pass); </com:TTextHighlighter> <h2 id="138053">Tranzakcje</h2> -<p id="690504" class="block-content">Wszystkie obiekkty Rekordu Aktywnego zawierają właściwość <tt>DbConnection</tt>, +<p id="690504" class="block-content">Wszystkie obiekkty Rekordu Aktywnego zawierają właściwość <tt>DbConnection</tt>, która może być używana by uzyskać obiekt tranzakcyjny. <com:TTextHighlighter Language="php" CssClass="source block-content" id="code_690165"> $finder = UserRecord::finder(); @@ -486,8 +486,8 @@ Zdarzenie <tt>OnExecuteCommand</tt> jest wywoływane kiedy polecenie jest wykona </p> <h3 id="142016">Przykład z logowaniem</h3> -<p id="710016" class="block-content">Używając <tt>OnExecuteCommand</tt> możemy przypiąć uchwyt zdarzenia by logować całe -zapytanie SQL wwywoływane dla danej instancji lub klasy TActiveRecord. Na przykład definiujemy klasę bazową i nadpisujemy +<p id="710016" class="block-content">Używając <tt>OnExecuteCommand</tt> możemy przypiąć uchwyt zdarzenia by logować całe +zapytanie SQL wwywoływane dla danej instancji lub klasy TActiveRecord. Na przykład definiujemy klasę bazową i nadpisujemy metodę <tt>getDbConnection()</tt> lub konstruktor. </p> @@ -537,12 +537,12 @@ W następnych sekcjach będziemy rozważać nastepujące relacje pomiędzy tabel <img src=<%~ ar_objects.png %> class="figure" /> <p class="block-content"> -Istnieje rozbieżność pomiędzy relacjami w obiektach i relacjami w tablicach. +Istnieje rozbieżność pomiędzy relacjami w obiektach i relacjami w tablicach. Po pierwsze jest różnica w reprezentacji. Obiekty trzymają powiązanie poprzez przechowywanie referencji, które są trzymane poprzez zarządzające pamięcią środowiko uruchomieniowe. Bazy relacyjne trzymają powiązanie poprzez utworzenie klucza do innej tablicy. - Po drugie, obiekty mogą łatwo uzywać kolekcji by trzymać wielokrotnie referencje z jednego pola, -to handle multiple references from a single field, gdyż normalizacja zmusza wszystkie powiązania relacji encji by były pojedyńczymi wartościami. -To prowadzi do odwrócenia struktury danych pomiędzy obiektami i tablicami. + Po drugie, obiekty mogą łatwo uzywać kolekcji by trzymać wielokrotnie referencje z jednego pola, +to handle multiple references from a single field, gdyż normalizacja zmusza wszystkie powiązania relacji encji by były pojedyńczymi wartościami. +To prowadzi do odwrócenia struktury danych pomiędzy obiektami i tablicami. Podejście zastosowane w modelu Rekordu Aktywnego Prado uzywa ograniczeń kluczów obcych tablicy do wyprowadzenia relacji obiektów. To implikuje fakt wspierania ograniczeń kluczów obcych dla bazy danych. </p> @@ -564,8 +564,8 @@ CREATE TABLE bar </com:TTextHighlighter> </div> -<h2 id="142012">Mapowanie kluczów obcych</h2> -<p class="block-content">Relacja pól pomiędzy tablicami <tt>Teams</tt> and <tt>Players</tt> jest znana jako relacja jeden-do-wielu (ang. 1-M). Oznacza to, że jeden Team moze zawierać zero lub więcej Players. Z punktu widzenia relacji obiektów +<h2 id="142012">Mapowanie kluczów obcych</h2> +<p class="block-content">Relacja pól pomiędzy tablicami <tt>Teams</tt> and <tt>Players</tt> jest znana jako relacja jeden-do-wielu (ang. 1-M). Oznacza to, że jeden Team moze zawierać zero lub więcej Players. Z punktu widzenia relacji obiektów powiemy, że obiekt <tt>TeamRecord</tt> <b>posiada wiele</b> (ang. has many) obiektów <tt>PlayerRecord</tt>. (Zauważ odwrócenie kierunku relacji pomiędzy tablicami a obiektami) </p> @@ -1074,7 +1074,7 @@ class PlayerRecord extends BaseFkRecord <p id="710046" class="block-content">We first need to change the <tt>$skills=array()</tt> declaration to a private property <tt>$_skills</tt> (notice the underscore) and set it to null instead. This allows us to define the <tt>skills</tt> property using getter/setter methods -(see <a href="?page=Fundamentals.Components">Components</a> for details). The <tt>getSkills()</tt> +(see <a href="?page=Fundamentals.Components1">Components</a> for details). The <tt>getSkills()</tt> getter method for the <tt>skills</tt> property will lazy load the corresponding skills foreign record when it is used as follows. Notice that we only do a lazy load when its <tt>$player_id</tt> is not null (that is, when the record is already fetched from the database or player id was already set). diff --git a/demos/quickstart/protected/pages/Fundamentals/Applications.page b/demos/quickstart/protected/pages/Fundamentals/Applications.page index 8e0b9e9a..71901170 100755 --- a/demos/quickstart/protected/pages/Fundamentals/Applications.page +++ b/demos/quickstart/protected/pages/Fundamentals/Applications.page @@ -7,7 +7,11 @@ An application is an instance of <tt>TApplication</tt> or its derived class. It <p id="160158" class="block-content">
Applications are configured via <a href="?page=Configurations.AppConfig">application configurations</a>. They are usually created in entry scripts like the following,
<com:TTextHighlighter CssClass="source block-content" id="code_160071">
+// load the prado entry script
require_once('/path/to/prado.php');
+// or, if using composer:
+require_once('vendor/autoload.php');
+
$application = new TApplication;
$application->run();
</com:TTextHighlighter>
diff --git a/demos/quickstart/protected/pages/Fundamentals/Architecture.page b/demos/quickstart/protected/pages/Fundamentals/Architecture.page index 10f16c3f..c6bee7de 100755 --- a/demos/quickstart/protected/pages/Fundamentals/Architecture.page +++ b/demos/quickstart/protected/pages/Fundamentals/Architecture.page @@ -2,12 +2,31 @@ <h1 id="601">Architecture</h1>
<p id="100111" class="block-content">
-PRADO is primarily a presentational framework, although it is not limited to be so. The framework focuses on making Web programming, which deals most of the time with user interactions, to be component-based and event-driven so that developers can be more productive. The following class tree depicts some of the major classes provided by PRADO,
+PRADO is primarily a presentational framework, although it is not limited to be so. The framework focuses on making Web programming, which deals most of the time with user interactions, to be component-based and event-driven so that developers can be more productive. The following class tree depicts some of the major classes provided by PRADO:
</p>
<img src="<%~classtree.gif%>" />
<p id="100112" class="block-content">
-When a PRADO application is processing a page request, its static object diagram can be shown as follows,
+When a PRADO application is processing a page request, its static object diagram can be shown as follows:
</p>
<img src="<%~objectdiagram.gif%>" />
-</com:TContent>
+
+<p class="block-content">
+Once the main <tt>Application</tt> object gets created, it load the <a href="?page=Configurations.AppConfig">application configuration</a>.
+The minimal configuration defines a set of basic <a href="?page=Fundamentals.Modules">modules</a> to parse the <tt>Request</tt>, create a proper <tt>Response</tt>, mantain the user <tt>Session</tt>, handle any <tt>Error</tt> and publish the needed <tt>Assets</tt> (images, css, javascript, etc). These helpers module will be available from anywhere inside the application code.
+<br/>
+Additionally, any 3rd-party or <tt>custom module</tt> can be loaded, and external <tt>Parameters</tt> can be loaded from external configurations.
+</p>
+
+<p class="block-content">
+Once the basic infrastructure has been set up, the <tt>Request</tt> module parses the request trying to identify the requested route. Different routes can be handled by different services, but the default route for http requests is the <tt>Page Service</tt>.
+<br/>
+The <a href="?page=Configurations.AppConfig">Page Service</a>'s role is to instanciate the requested <tt>Page</tt>, run it, apply any defined <tt>Theme</tt> and grab the result in order to build the <tt>Response</tt>.
+</p>
+
+<p class="block-content">
+A <a href="?page=Fundamentals.Pages">Page</a> can be a simple script (.php), a <tt>Template</tt> (.page), or both. PRADO uses a very powerful <a href="?page=Configurations.Templates1">template engine</a> where <tt>Controls</tt> can be instanciated directly.
+<br/>
+A <a href="?page=Fundamentals.Controls">Control</a> is an self-contained widget that fullfills a specific task; they can be a simple script (.php), a <tt>Template</tt> (.page), or both.
+</p>
+</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Fundamentals/Components.page b/demos/quickstart/protected/pages/Fundamentals/Components.page deleted file mode 100755 index 11235b56..00000000 --- a/demos/quickstart/protected/pages/Fundamentals/Components.page +++ /dev/null @@ -1,360 +0,0 @@ -<com:TContent ID="body" >
-<h1 id="701">Components</h1>
-<p id="110113" class="block-content">
-A component is an instance of <tt>TComponent</tt> or its child class. The base class <tt>TComponent</tt> implements the mechanism of component properties and events.
-</p>
-
-<h2 id="702">Component Properties</h2>
-<p id="110114" class="block-content">
-A component property can be viewed as a public variable describing a specific aspect of the component, such as the background color, the font size, etc. A property is defined by the existence of a getter and/or a setter method in the component class. For example, in <tt>TControl</tt>, we define its <tt>ID</tt> property using the following getter and setter methods,
-<com:TTextHighlighter CssClass="source block-content" id="code_110056">
-class TControl extends TComponent {
- public function getID() {
- ...
- }
- public function setID($value) {
- ...
- }
-}
-</com:TTextHighlighter>
-</p>
-<p id="110115" class="block-content">
-To get or set the <tt>ID</tt> property, do as follows, just like working with a variable,
-<com:TTextHighlighter CssClass="source block-content" id="code_110057">
-$id = $component->ID;
-$component->ID = $id;
-</com:TTextHighlighter>
-This is equivalent to the following,
-<com:TTextHighlighter CssClass="source block-content" id="code_110058">
-$id = $component->getID();
-$component->setID( $id );
-</com:TTextHighlighter>
-</p>
-<p id="110116" class="block-content">
-A property is read-only if it has a getter method but no setter method. Since PHP method names are case-insensitive, property names are also case-insensitive. A component class inherits all its ancestor classes' properties.
-</p>
-
-<h3 id="706">Subproperties</h3>
-<p id="110117" class="block-content">
-A subproperty is a property of some object-typed property. For example, <tt>TWebControl</tt> has a <tt>Font</tt> property which is of <tt>TFont</tt> type. Then the <tt>Name</tt> property of <tt>Font</tt> is referred to as a subproperty (with respect to <tt>TWebControl</tt>).
-</p>
-<p id="110118" class="block-content">
-To get or set the <tt>Name</tt> subproperty, use the following method,
-<com:TTextHighlighter CssClass="source block-content" id="code_110059">
-$name = $component->getSubProperty('Font.Name');
-$component->setSubProperty('Font.Name', $name);
-</com:TTextHighlighter>
-This is equivalent to the following,
-<com:TTextHighlighter CssClass="source block-content" id="code_110060">
-$name = $component->getFont()->getName();
-$component->getFont()->setName( $name );
-</com:TTextHighlighter>
-</p>
-
-<h3 id="26001">Js-friendly properties</h3>
-<p class="block-content">
-A JavaScript-friendly property is a property that can accept both simple strings and raw javascript.
-Prado automatically encodes all properties sent clientside inside javascript blocks to avoid security problems (like injections or cross site scripting).
-If a property is known to always contain only safe javascript code and its value needs to bypass this encoding, that property can be defined in a special way that will make Prado mark its value as "safe".
-Js-friendly properties are identified by their name starting with 'js' (case insensitive):
-<com:TTextHighlighter CssClass="source block-content">
-// getter, defines a readable property 'Text'
-function getJsText() { … }
-// setter, defines a writable property 'Text', with $value being the value to be set to the property
-function setJsText(TJavaScriptLiteral $value) { … }
-</com:TTextHighlighter>
-Js-friendly properties can be accessed using both their Js-less name and their Js-enabled name:
-<com:TTextHighlighter CssClass="source block-content">
-// set some simple text as property value
-$component->Text = 'text';
-// set some javascript code as property value
-$component->JsText = 'raw javascript';
-</com:TTextHighlighter>
-In the first case, the property value will automatically gets encoded when sent clientside inside a javascript block.
-In the second case, the property will be 'marked' as being a safe javascript statement and will not be encoded when rendered inside a javascript block.
-This special handling makes use of the <tt>TJavaScriptLiteral</tt> class.
-</p>
-
-
-<h2 id="703">Component Events</h2>
-<p id="110119" class="block-content">
-Component events are special properties that take method names as their values. Attaching (setting) a method to an event will hook up the method to the places at which the event is raised. Therefore, the behavior of a component can be modified in a way that may not be foreseen during the development of the component.
-</p>
-<p id="110120" class="block-content">
-A component event is defined by the existence of a method whose name starts with the word <tt>on</tt>. The event name is the method name and is thus case-insensitve. For example, in <tt>TButton</tt>, we have
-<com:TTextHighlighter CssClass="source block-content" id="code_110061">
-class TButton extends TWebControl {
- public function onClick( $param ) {
- ...
- }
-}
-</com:TTextHighlighter>
-This defines an event named <tt>OnClick</tt>, and a handler can be attached to the event using one of the following ways,
-<com:TTextHighlighter CssClass="source block-content" id="code_110062">
-$button->OnClick = $callback;
-$button->OnClick->add( $callback );
-$button->OnClick[] = $callback;
-$button->attachEventHandler( 'OnClick' , $callback );
-</com:TTextHighlighter>
-</p>
- The variable <tt>$callback</tt> contains the definition of the event handler that can be either a string referring to a global function name, or an array whose first element refers to an object and second element a method name/path that is reachable by the object, e.g.
- </p>
-<ul>
-<li>'buttonClicked' : buttonClicked($sender,$param);</li>
-<li>array($object,'buttonClicked') : $object->buttonClicked($sender,$param);</li>
-<li>array($object,'MainContent.SubmitButton.buttonClicked') : $object->MainContent->SubmitButton->buttonClicked($sender,$param);</li>
-</ul>
-<com:SinceVersion Version="3.2.3" />
-<h2 id="26001">Global events</h2>
-<p id="130001" class="block-content">
-With the addition of behaviors, a more expansive event model is needed. There
-are two new event types (global and dynamic events) as well as a more comprehensive
-behavior model that includes class wide behaviors.
-</p>
-<p id="130002" class="block-content">
-A global event is defined by all events whose name starts with 'fx'.
-The event name is potentially a method name and is thus case-insensitive. All 'fx' events
-are valid as the whole 'fx' event/method space is global in nature. Any object may patch into
-any global event by defining that event as a method. Global events have priorities
-just like 'on' events; so as to be able to order the event execution. Due to the
-nature of all events which start with 'fx' being valid, in effect, every object
-has every 'fx' global event. It is simply an issue of tapping into the desired
-global event.
-</p>
-<p id="130003" class="block-content">
-A global event that starts with 'fx' can be called even if the object does not
-implement the method of the global event. A call to a non-existing 'fx' method
-will, at minimal, function and return null. If a method argument list has a first
-parameter, it will be returned instead of null. This allows filtering and chaining.
-'fx' methods do not automatically install and uninstall. To install and uninstall an
-object's global event listeners, call the object's <tt>listen</tt> and
-<tt>unlisten</tt> methods, respectively. An object may auto-install its global event
-during <tt>__construct</tt> by overriding <tt>getAutoGlobalListen</tt> and returning true.
-</p>
-<p id="130004" class="block-content">
-As of PHP version 5.3, nulled objects without code references will still continue to persist
-in the global event queue because <tt>__destruct</tt> is not automatically called. In the common
-__destruct method, if an object is listening to global events, then <tt>unlisten</tt> is called.
-<tt>unlisten</tt> is required to be manually called before an object is
-left without references if it is currently listening to any global events. This includes
-class wide behaviors.
-</p>
-<p id="130005" class="block-content">
-An object that contains a method that starts with 'fx' will have those functions
-automatically receive those events of the same name after <tt>listen</tt> is called on the object.
-</p>
-<p id="130006" class="block-content">
-An object may listen to a global event without defining an 'fx' method of the same name by
-adding an object method to the global event list. For example
-</p>
-<com:TTextHighlighter CssClass="source block-content">
-$component->fxGlobalCheck=$callback; // or $component->OnClick->add($callback);
-$component->attachEventHandler('fxGlobalCheck',array($object, 'someMethod'));
-</com:TTextHighlighter>
-<h2 id="26002">Events between Objects and their behaviors, Dynamic Events</h2>
-<p id="130007" class="block-content">
-An intra-object/behavior event is defined by methods that start with 'dy'. Just as with
-'fx' global events, every object has every dynamic event. Any call to a method that
-starts with 'dy' will be handled, regardless of whether it is implemented. These
-events are for communicating with attached behaviors.
-</p>
-<p id="130008" class="block-content">
-Dynamic events can be used in a variety of ways. They can be used to tell behaviors
-when a non-behavior method is called. Dynamic events could be used as data filters.
-They could also be used to specify when a piece of code is to be run, eg. should the
-loop process be performed on a particular piece of data. In this way, some control
-is handed to the behaviors over the process and/or data.
-</p>
-<p id="130009" class="block-content">
-If there are no handlers for an 'fx' or 'dy' event, it will return the first
-parameter of the argument list. If there are no arguments, these events
-will return null. If there are handlers an 'fx' method will be called directly
-within the object. Global 'fx' events are triggered by calling <tt>raiseEvent</tt>.
-For dynamic events where there are behaviors that respond to the dynamic events, a
-<tt>TCallChain</tt> is developed. A call chain allows the behavior dynamic event
-implementations to call further implementing behaviors within a chain.
-</p>
-<p id="130010" class="block-content">
-If an object implements <tt>IDynamicMethods</tt>, all global and object dynamic
-events will be sent to <tt>__dycall</tt>. In the case of global events, all
-global events will trigger this method. In the case of behaviors, all undefined
-dynamic events which are called will be passed through to this method.
-</p>
-<p id="130011" class="block-content">
-<h2 id="26003">Behaviors</h2>
-<p id="130012" class="block-content">
-There are two types of behaviors. There are individual object behaviors and
-there are class wide behaviors. Class behaviors depend upon object behaviors.
-</p>
-<p id="130013" class="block-content">
-When a new class implements <tt>IBehavior</tt> or <tt>IClassBehavior</tt> or
-extends <tt>TBehavior</tt> or <tt>TClassBehavior</tt>, it may be added to an
-object by calling the object's <tt>attachBehavior</tt>. The behaviors associated
-name can then be used to <tt>enableBehavior</tt> or <tt>disableBehavior</tt>
-the specific behavior.
-</p>
-<p id="130014" class="block-content">
-All behaviors may be turned on and off via <tt>enableBehaviors</tt> and
-<tt>disableBehaviors</tt>, respectively. To check if behaviors are on or off
-a call to <tt>getBehaviorsEnabled</tt> will provide the variable.
-</p>
-<p id="130015" class="block-content">
-Attaching and detaching whole sets of behaviors is done using
-<tt>attachBehaviors</tt> and <tt>detachBehaviors</tt>. <tt>clearBehaviors</tt>
-removes all of an object's behaviors.
-</p>
-<p id="130016" class="block-content">
-<tt>asa</tt> returns a behavior of a specific name. <tt>isa</tt> is the
-behavior inclusive function that acts as the PHP operator <tt>instanceof</tt>.
-A behavior could provide the functionality of a specific class thus causing
-the host object to act similarly to a completely different class. A behavior
-would then implement <tt>IInstanceCheck</tt> to provide the identity of the
-different class.
-</p>
-<p id="130017" class="block-content">
-Class behaviors are similar to object behaviors except that the class behavior
-is the implementation for all instances of the class. A class behavior
-will have the object upon which is being called be prepended to the parameter
-list. This way the object is known across the class behavior implementation.
-</p>
-<p id="130018" class="block-content">
-Class behaviors are attached using <tt>attachClassBehavior</tt> and detached
-using <tt>detachClassBehavior</tt>. Class behaviors are important in that
-they will be applied to all new instances of a particular class. In this way
-class behaviors become default behaviors to a new instances of a class in
-<tt>__construct</tt>. Detaching a class behavior will remove the behavior
-from the default set of behaviors created for an object when the object
-is instanced.
-</p>
-<p id="130019" class="block-content">
-Class behaviors are also added to all existing instances via the global 'fx'
-event mechanism. When a new class behavior is added, the event
-<tt>fxAttachClassBehavior</tt> is raised and all existing instances that are
-listening to this global event (primarily after <tt>listen</tt> is called)
-will have this new behavior attached. A similar process is used when
-detaching class behaviors. Any objects listening to the global 'fx' event
-<tt>fxDetachClassBehavior</tt> will have a class behavior removed.
-</p>
-<h2 id="26004">Dynamic Intra-Object Events</h2>
-<p id="130020" class="block-content">
-Dynamic events start with 'dy'. This mechanism is used to allow objects
-to communicate with their behaviors directly. The entire 'dy' event space
-is valid. All attached, enabled behaviors that implement a dynamic event
-are called when the host object calls the dynamic event. If there is no
-implementation or behaviors, this returns null when no parameters are
-supplied and will return the first parameter when there is at least one
-parameter in the dynamic event.
-</p>
-<com:TTextHighlighter CssClass="source block-content">
- null == $this->dyBehaviorEvent();
- 5 == $this->dyBehaviorEvent(5); //when no behaviors implement this dynamic event
-</com:TTextHighlighter>
-<p id="130021" class="block-content">
-Dynamic events can be chained together within behaviors to allow for data
-filtering. Dynamic events are implemented within behaviors by defining the
-event as a method.
-</p>
-<com:TTextHighlighter CssClass="source block-content">
-class TObjectBehavior extends TBehavior {
- public function dyBehaviorEvent($param1, $callchain) {
- //Do something, eg: $param1 += 13;
- return $callchain->dyBehaviorEvent($param1);
- }
-}
-</com:TTextHighlighter>
-<p id="130022" class="block-content">
-This implementation of a behavior and dynamic event will flow through to the
-next behavior implementing the dynamic event. The first parameter is always
-return when it is supplied. Otherwise a dynamic event returns null.
-</p>
-<p id="130023" class="block-content">
-In the case of a class behavior, the object is also prepended to the dynamic
-event.
-</p>
-<com:TTextHighlighter CssClass="source block-content">
-class TObjectClassBehavior extends TClassBehavior {
- public function dyBehaviorEvent($hostobject, $param1, $callchain) {
- //Do something, eg: $param1 += $hostobject->getNumber();
- return $callchain->dyBehaviorEvent($param1);
- }
-}
-</com:TTextHighlighter>
-</p>
-<p id="130024" class="block-content">
-When calling a dynamic event, only the parameters are passed. The host object
-and the call chain are built into the framework.
-</p>
-
-<h2 id="26005">Global Event and Dynamic event catching</h2>
-
-<p id="130025" class="block-content">
-Given that all global 'fx' events and dynamic 'dy' events are valid and
-operational, there is a mechanism for catching events called that are not
-implemented (similar to the built-in PHP method <tt>__call</tt>). When
-a dynamic or global event is called but a behavior does not implement it,
-yet desires to know when an undefined dynamic event is run, the behavior
-implements the interface <tt>IDynamicMethods</tt> and method <tt>__dycall</tt>.
-</p>
-<p id="130026" class="block-content">
-In the case of dynamic events, <tt>__dycall</tt> is supplied with the method
-name and its parameters. When a global event is raised, via <tt>raiseEvent</tt>,
-the method is the event name and the parameters are supplied.
-</p>
-<p id="130027" class="block-content">
-When implemented, this catch-all mechanism is called for event global event event
-when implemented outside of a behavior. Within a behavior, it will also be called
-when the object to which the behavior is attached calls any unimplemented dynamic
-event. This is the fall-back mechanism for informing a class and/or behavior
-of when an global and/or undefined dynamic event is executed.
-</p>
-
-<h2 id="704">Namespaces</h2>
-<p id="110121" class="block-content">
-A namespace refers to a logical grouping of some class names so that they can be differentiated from other class names even if their names are the same. Since PHP does not support namespace intrinsically, you cannot create instances of two classes who have the same name but with different definitions. To differentiate from user defined classes, all PRADO classes are prefixed with a letter 'T' (meaning 'Type'). Users are advised not to name their classes like this. Instead, they may prefix their class names with any other letter(s).
-</p>
-<p id="110122" class="block-content">
-A namespace in PRADO is considered as a directory containing one or several class files. A class may be specified without ambiguity using such a namespace followed by the class name. Each namespace in PRADO is specified in the following format,
-<div class="source">
-PathAlias.Dir1.Dir2
-</div>
-where <tt>PathAlias</tt> is an alias of some directory, while <tt>Dir1</tt> and <tt>Dir2</tt> are subdirectories under that directory. A class named <tt>MyClass</tt> defined under <tt>Dir2</tt> may now be fully qualified as <tt>PathAlias.Dir1.Dir2.MyClass</tt>.
-</p>
-<p id="110123" class="block-content">
-To use a namespace in code, do as follows,
-<com:TTextHighlighter CssClass="source block-content" id="code_110063">
-Prado::using('PathAlias.Dir1.Dir2.*');
-</com:TTextHighlighter>
-which appends the directory referred to by <tt>PathAlias.Dir1.Dir2</tt> into PHP include path so that classes defined under that directory may be instantiated without the namespace prefix. You may also include an individual class definition by
-<com:TTextHighlighter CssClass="source block-content" id="code_110064">
-Prado::using('PathAlias.Dir1.Dir2.MyClass');
-</com:TTextHighlighter>
-which will include the class file if <tt>MyClass</tt> is not defined.
-</p>
-<p id="110124" class="block-content">
-For more details about defining path aliases, see <a href="?page=Configurations.AppConfig">application configuration</a> section.
-</p>
-
-<h2 id="705">Component Instantiation</h2>
-<p id="110125" class="block-content">
-Component instantiation means creating instances of component classes. There are two types of component instantation: static instantiation and dynamic instantiation. The created components are called static components and dynamic components, respectively.
-</p>
-
-<h3 id="707">Dynamic Component Instantiation</h3>
-<p id="110126" class="block-content">
-Dynamic component instantiation means creating component instances in PHP code. It is the same as the commonly referred object creation in PHP. A component can be dynamically created using one of the following two methods in PHP,
-<com:TTextHighlighter CssClass="source block-content" id="code_110065">
-$component = new ComponentClassName;
-$component = Prado::createComponent('ComponentType');
-</com:TTextHighlighter>
-where <tt>ComponentType</tt> refers to a class name or a type name in namespace format (e.g. <tt>System.Web.UI.TControl</tt>). The second approach is introduced to compensate for the lack of namespace support in PHP.
-</p>
-
-<h3 id="708">Static Component Instantiation</h3>
-<p id="110127" class="block-content">
-Static component instantiation is about creating components via <a href="?page=Configurations.Overview">configurations</a>. The actual creation work is done by the PRADO framework. For example, in an <a href="?page=Configurations.AppConfig">application configuration</a>, one can configure a module to be loaded when the application runs. The module is thus a static component created by the framework. Static component instantiation is more commonly used in <a href="?page=Configurations.Templates1">templates</a>. Every component tag in a template specifies a component that will be automatically created by the framework when the template is loaded. For example, in a page template, the following tag will lead to the creation of a <tt>TButton</tt> component on the page,
-<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code_110066">
-<com:TButton Text="Register" />
-</com:TTextHighlighter>
-</p>
-
-</com:TContent>
diff --git a/demos/quickstart/protected/pages/Fundamentals/Components1.page b/demos/quickstart/protected/pages/Fundamentals/Components1.page new file mode 100755 index 00000000..a610045d --- /dev/null +++ b/demos/quickstart/protected/pages/Fundamentals/Components1.page @@ -0,0 +1,157 @@ +<com:TContent ID="body" > +<h1 id="701">Components: Part I</h1> +<p id="110113" class="block-content"> +A component is an instance of <tt>TComponent</tt> or its child class. The base class <tt>TComponent</tt> implements the mechanism of component properties and events. +</p> + +<h2 id="702">Component Properties</h2> +<p id="110114" class="block-content"> +A component property can be viewed as a public variable describing a specific aspect of the component, such as the background color, the font size, etc. A property is defined by the existence of a getter and/or a setter method in the component class. For example, in <tt>TControl</tt>, we define its <tt>ID</tt> property using the following getter and setter methods, +<com:TTextHighlighter CssClass="source block-content" id="code_110056"> +class TControl extends TComponent { + public function getID() { + ... + } + public function setID($value) { + ... + } +} +</com:TTextHighlighter> +</p> +<p id="110115" class="block-content"> +To get or set the <tt>ID</tt> property, do as follows, just like working with a variable, +<com:TTextHighlighter CssClass="source block-content" id="code_110057"> +$id = $component->ID; +$component->ID = $id; +</com:TTextHighlighter> +This is equivalent to the following, +<com:TTextHighlighter CssClass="source block-content" id="code_110058"> +$id = $component->getID(); +$component->setID( $id ); +</com:TTextHighlighter> +</p> +<p id="110116" class="block-content"> +A property is read-only if it has a getter method but no setter method. Since PHP method names are case-insensitive, property names are also case-insensitive. A component class inherits all its ancestor classes' properties. +</p> + +<h3 id="706">Subproperties</h3> +<p id="110117" class="block-content"> +A subproperty is a property of some object-typed property. For example, <tt>TWebControl</tt> has a <tt>Font</tt> property which is of <tt>TFont</tt> type. Then the <tt>Name</tt> property of <tt>Font</tt> is referred to as a subproperty (with respect to <tt>TWebControl</tt>). +</p> +<p id="110118" class="block-content"> +To get or set the <tt>Name</tt> subproperty, use the following method, +<com:TTextHighlighter CssClass="source block-content" id="code_110059"> +$name = $component->getSubProperty('Font.Name'); +$component->setSubProperty('Font.Name', $name); +</com:TTextHighlighter> +This is equivalent to the following, +<com:TTextHighlighter CssClass="source block-content" id="code_110060"> +$name = $component->getFont()->getName(); +$component->getFont()->setName( $name ); +</com:TTextHighlighter> +</p> + +<h3 id="26001">Js-friendly properties</h3> +<p class="block-content"> +A JavaScript-friendly property is a property that can accept both simple strings and raw javascript. +Prado automatically encodes all properties sent clientside inside javascript blocks to avoid security problems (like injections or cross site scripting). +If a property is known to always contain only safe javascript code and its value needs to bypass this encoding, that property can be defined in a special way that will make Prado mark its value as "safe". +Js-friendly properties are identified by their name starting with 'js' (case insensitive): +<com:TTextHighlighter CssClass="source block-content"> +// getter, defines a readable property 'Text' +function getJsText() { … } +// setter, defines a writable property 'Text', with $value being the value to be set to the property +function setJsText(TJavaScriptLiteral $value) { … } +</com:TTextHighlighter> +Js-friendly properties can be accessed using both their Js-less name and their Js-enabled name: +<com:TTextHighlighter CssClass="source block-content"> +// set some simple text as property value +$component->Text = 'text'; +// set some javascript code as property value +$component->JsText = 'raw javascript'; +</com:TTextHighlighter> +In the first case, the property value will automatically gets encoded when sent clientside inside a javascript block. +In the second case, the property will be 'marked' as being a safe javascript statement and will not be encoded when rendered inside a javascript block. +This special handling makes use of the <tt>TJavaScriptLiteral</tt> class. +</p> + + +<h2 id="703">Component Events</h2> +<p id="110119" class="block-content"> +Component events are special properties that take method names as their values. Attaching (setting) a method to an event will hook up the method to the places at which the event is raised. Therefore, the behavior of a component can be modified in a way that may not be foreseen during the development of the component. +</p> +<p id="110120" class="block-content"> +A component event is defined by the existence of a method whose name starts with the word <tt>on</tt>. The event name is the method name and is thus case-insensitve. For example, in <tt>TButton</tt>, we have +<com:TTextHighlighter CssClass="source block-content" id="code_110061"> +class TButton extends TWebControl { + public function onClick( $param ) { + ... + } +} +</com:TTextHighlighter> +This defines an event named <tt>OnClick</tt>, and a handler can be attached to the event using one of the following ways, +<com:TTextHighlighter CssClass="source block-content" id="code_110062"> +$button->OnClick = $callback; +$button->OnClick->add( $callback ); +$button->OnClick[] = $callback; +$button->attachEventHandler( 'OnClick' , $callback ); +</com:TTextHighlighter> +</p> + The variable <tt>$callback</tt> contains the definition of the event handler that can be either a string referring to a global function name, or an array whose first element refers to an object and second element a method name/path that is reachable by the object, e.g. + </p> +<ul> +<li>'buttonClicked' : buttonClicked($sender,$param);</li> +<li>array($object,'buttonClicked') : $object->buttonClicked($sender,$param);</li> +<li>array($object,'MainContent.SubmitButton.buttonClicked') : $object->MainContent->SubmitButton->buttonClicked($sender,$param);</li> +</ul> + +<h2 id="704">Namespaces</h2> +<p id="110121" class="block-content"> +A namespace refers to a logical grouping of some class names so that they can be differentiated from other class names even if their names are the same. Since PHP does not support namespace intrinsically, you cannot create instances of two classes who have the same name but with different definitions. To differentiate from user defined classes, all PRADO classes are prefixed with a letter 'T' (meaning 'Type'). Users are advised not to name their classes like this. Instead, they may prefix their class names with any other letter(s). +</p> +<p id="110122" class="block-content"> +A namespace in PRADO is considered as a directory containing one or several class files. A class may be specified without ambiguity using such a namespace followed by the class name. Each namespace in PRADO is specified in the following format, +<div class="source"> +PathAlias.Dir1.Dir2 +</div> +where <tt>PathAlias</tt> is an alias of some directory, while <tt>Dir1</tt> and <tt>Dir2</tt> are subdirectories under that directory. A class named <tt>MyClass</tt> defined under <tt>Dir2</tt> may now be fully qualified as <tt>PathAlias.Dir1.Dir2.MyClass</tt>. +</p> +<p id="110123" class="block-content"> +To use a namespace in code, do as follows, +<com:TTextHighlighter CssClass="source block-content" id="code_110063"> +Prado::using('PathAlias.Dir1.Dir2.*'); +</com:TTextHighlighter> +which appends the directory referred to by <tt>PathAlias.Dir1.Dir2</tt> into PHP include path so that classes defined under that directory may be instantiated without the namespace prefix. You may also include an individual class definition by +<com:TTextHighlighter CssClass="source block-content" id="code_110064"> +Prado::using('PathAlias.Dir1.Dir2.MyClass'); +</com:TTextHighlighter> +which will include the class file if <tt>MyClass</tt> is not defined. +</p> +<p id="110124" class="block-content"> +For more details about defining path aliases, see <a href="?page=Configurations.AppConfig">application configuration</a> section. +</p> + +<h2 id="705">Component Instantiation</h2> +<p id="110125" class="block-content"> +Component instantiation means creating instances of component classes. There are two types of component instantation: static instantiation and dynamic instantiation. The created components are called static components and dynamic components, respectively. +</p> + +<h3 id="707">Dynamic Component Instantiation</h3> +<p id="110126" class="block-content"> +Dynamic component instantiation means creating component instances in PHP code. It is the same as the commonly referred object creation in PHP. A component can be dynamically created using one of the following two methods in PHP, +<com:TTextHighlighter CssClass="source block-content" id="code_110065"> +$component = new ComponentClassName; +$component = Prado::createComponent('ComponentType'); +</com:TTextHighlighter> +where <tt>ComponentType</tt> refers to a class name or a type name in namespace format (e.g. <tt>System.Web.UI.TControl</tt>). The second approach is introduced to compensate for the lack of namespace support in PHP. +</p> + +<h3 id="708">Static Component Instantiation</h3> +<p id="110127" class="block-content"> +Static component instantiation is about creating components via <a href="?page=Configurations.Overview">configurations</a>. The actual creation work is done by the PRADO framework. For example, in an <a href="?page=Configurations.AppConfig">application configuration</a>, one can configure a module to be loaded when the application runs. The module is thus a static component created by the framework. Static component instantiation is more commonly used in <a href="?page=Configurations.Templates1">templates</a>. Every component tag in a template specifies a component that will be automatically created by the framework when the template is loaded. For example, in a page template, the following tag will lead to the creation of a <tt>TButton</tt> component on the page, +<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code_110066"> +<com:TButton Text="Register" /> +</com:TTextHighlighter> +</p> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/Fundamentals/Components2.page b/demos/quickstart/protected/pages/Fundamentals/Components2.page new file mode 100644 index 00000000..7fc3e010 --- /dev/null +++ b/demos/quickstart/protected/pages/Fundamentals/Components2.page @@ -0,0 +1,207 @@ +<com:TContent ID="body" > +<h1 id="701">Components: Part II</h1> +<com:SinceVersion Version="3.2.3" /> +<h2 id="26001">Global events</h2> +<p id="130001" class="block-content"> +With the addition of behaviors, a more expansive event model is needed. There +are two new event types (global and dynamic events) as well as a more comprehensive +behavior model that includes class wide behaviors. +</p> +<p id="130002" class="block-content"> +A global event is defined by all events whose name starts with 'fx'. +The event name is potentially a method name and is thus case-insensitive. All 'fx' events +are valid as the whole 'fx' event/method space is global in nature. Any object may patch into +any global event by defining that event as a method. Global events have priorities +just like 'on' events; so as to be able to order the event execution. Due to the +nature of all events which start with 'fx' being valid, in effect, every object +has every 'fx' global event. It is simply an issue of tapping into the desired +global event. +</p> +<p id="130003" class="block-content"> +A global event that starts with 'fx' can be called even if the object does not +implement the method of the global event. A call to a non-existing 'fx' method +will, at minimal, function and return null. If a method argument list has a first +parameter, it will be returned instead of null. This allows filtering and chaining. +'fx' methods do not automatically install and uninstall. To install and uninstall an +object's global event listeners, call the object's <tt>listen</tt> and +<tt>unlisten</tt> methods, respectively. An object may auto-install its global event +during <tt>__construct</tt> by overriding <tt>getAutoGlobalListen</tt> and returning true. +</p> +<p id="130004" class="block-content"> +As of PHP version 5.3, nulled objects without code references will still continue to persist +in the global event queue because <tt>__destruct</tt> is not automatically called. In the common +__destruct method, if an object is listening to global events, then <tt>unlisten</tt> is called. +<tt>unlisten</tt> is required to be manually called before an object is +left without references if it is currently listening to any global events. This includes +class wide behaviors. +</p> +<p id="130005" class="block-content"> +An object that contains a method that starts with 'fx' will have those functions +automatically receive those events of the same name after <tt>listen</tt> is called on the object. +</p> +<p id="130006" class="block-content"> +An object may listen to a global event without defining an 'fx' method of the same name by +adding an object method to the global event list. For example +</p> +<com:TTextHighlighter CssClass="source block-content"> +$component->fxGlobalCheck=$callback; // or $component->OnClick->add($callback); +$component->attachEventHandler('fxGlobalCheck',array($object, 'someMethod')); +</com:TTextHighlighter> +<h2 id="26002">Events between Objects and their behaviors, Dynamic Events</h2> +<p id="130007" class="block-content"> +An intra-object/behavior event is defined by methods that start with 'dy'. Just as with +'fx' global events, every object has every dynamic event. Any call to a method that +starts with 'dy' will be handled, regardless of whether it is implemented. These +events are for communicating with attached behaviors. +</p> +<p id="130008" class="block-content"> +Dynamic events can be used in a variety of ways. They can be used to tell behaviors +when a non-behavior method is called. Dynamic events could be used as data filters. +They could also be used to specify when a piece of code is to be run, eg. should the +loop process be performed on a particular piece of data. In this way, some control +is handed to the behaviors over the process and/or data. +</p> +<p id="130009" class="block-content"> +If there are no handlers for an 'fx' or 'dy' event, it will return the first +parameter of the argument list. If there are no arguments, these events +will return null. If there are handlers an 'fx' method will be called directly +within the object. Global 'fx' events are triggered by calling <tt>raiseEvent</tt>. +For dynamic events where there are behaviors that respond to the dynamic events, a +<tt>TCallChain</tt> is developed. A call chain allows the behavior dynamic event +implementations to call further implementing behaviors within a chain. +</p> +<p id="130010" class="block-content"> +If an object implements <tt>IDynamicMethods</tt>, all global and object dynamic +events will be sent to <tt>__dycall</tt>. In the case of global events, all +global events will trigger this method. In the case of behaviors, all undefined +dynamic events which are called will be passed through to this method. +</p> +<p id="130011" class="block-content"> +<h2 id="26003">Behaviors</h2> +<p id="130012" class="block-content"> +There are two types of behaviors. There are individual object behaviors and +there are class wide behaviors. Class behaviors depend upon object behaviors. +</p> +<p id="130013" class="block-content"> +When a new class implements <tt>IBehavior</tt> or <tt>IClassBehavior</tt> or +extends <tt>TBehavior</tt> or <tt>TClassBehavior</tt>, it may be added to an +object by calling the object's <tt>attachBehavior</tt>. The behaviors associated +name can then be used to <tt>enableBehavior</tt> or <tt>disableBehavior</tt> +the specific behavior. +</p> +<p id="130014" class="block-content"> +All behaviors may be turned on and off via <tt>enableBehaviors</tt> and +<tt>disableBehaviors</tt>, respectively. To check if behaviors are on or off +a call to <tt>getBehaviorsEnabled</tt> will provide the variable. +</p> +<p id="130015" class="block-content"> +Attaching and detaching whole sets of behaviors is done using +<tt>attachBehaviors</tt> and <tt>detachBehaviors</tt>. <tt>clearBehaviors</tt> +removes all of an object's behaviors. +</p> +<p id="130016" class="block-content"> +<tt>asa</tt> returns a behavior of a specific name. <tt>isa</tt> is the +behavior inclusive function that acts as the PHP operator <tt>instanceof</tt>. +A behavior could provide the functionality of a specific class thus causing +the host object to act similarly to a completely different class. A behavior +would then implement <tt>IInstanceCheck</tt> to provide the identity of the +different class. +</p> +<p id="130017" class="block-content"> +Class behaviors are similar to object behaviors except that the class behavior +is the implementation for all instances of the class. A class behavior +will have the object upon which is being called be prepended to the parameter +list. This way the object is known across the class behavior implementation. +</p> +<p id="130018" class="block-content"> +Class behaviors are attached using <tt>attachClassBehavior</tt> and detached +using <tt>detachClassBehavior</tt>. Class behaviors are important in that +they will be applied to all new instances of a particular class. In this way +class behaviors become default behaviors to a new instances of a class in +<tt>__construct</tt>. Detaching a class behavior will remove the behavior +from the default set of behaviors created for an object when the object +is instanced. +</p> +<p id="130019" class="block-content"> +Class behaviors are also added to all existing instances via the global 'fx' +event mechanism. When a new class behavior is added, the event +<tt>fxAttachClassBehavior</tt> is raised and all existing instances that are +listening to this global event (primarily after <tt>listen</tt> is called) +will have this new behavior attached. A similar process is used when +detaching class behaviors. Any objects listening to the global 'fx' event +<tt>fxDetachClassBehavior</tt> will have a class behavior removed. +</p> +<h2 id="26004">Dynamic Intra-Object Events</h2> +<p id="130020" class="block-content"> +Dynamic events start with 'dy'. This mechanism is used to allow objects +to communicate with their behaviors directly. The entire 'dy' event space +is valid. All attached, enabled behaviors that implement a dynamic event +are called when the host object calls the dynamic event. If there is no +implementation or behaviors, this returns null when no parameters are +supplied and will return the first parameter when there is at least one +parameter in the dynamic event. +</p> +<com:TTextHighlighter CssClass="source block-content"> + null == $this->dyBehaviorEvent(); + 5 == $this->dyBehaviorEvent(5); //when no behaviors implement this dynamic event +</com:TTextHighlighter> +<p id="130021" class="block-content"> +Dynamic events can be chained together within behaviors to allow for data +filtering. Dynamic events are implemented within behaviors by defining the +event as a method. +</p> +<com:TTextHighlighter CssClass="source block-content"> +class TObjectBehavior extends TBehavior { + public function dyBehaviorEvent($param1, $callchain) { + //Do something, eg: $param1 += 13; + return $callchain->dyBehaviorEvent($param1); + } +} +</com:TTextHighlighter> +<p id="130022" class="block-content"> +This implementation of a behavior and dynamic event will flow through to the +next behavior implementing the dynamic event. The first parameter is always +return when it is supplied. Otherwise a dynamic event returns null. +</p> +<p id="130023" class="block-content"> +In the case of a class behavior, the object is also prepended to the dynamic +event. +</p> +<com:TTextHighlighter CssClass="source block-content"> +class TObjectClassBehavior extends TClassBehavior { + public function dyBehaviorEvent($hostobject, $param1, $callchain) { + //Do something, eg: $param1 += $hostobject->getNumber(); + return $callchain->dyBehaviorEvent($param1); + } +} +</com:TTextHighlighter> +</p> +<p id="130024" class="block-content"> +When calling a dynamic event, only the parameters are passed. The host object +and the call chain are built into the framework. +</p> + +<h2 id="26005">Global Event and Dynamic event catching</h2> + +<p id="130025" class="block-content"> +Given that all global 'fx' events and dynamic 'dy' events are valid and +operational, there is a mechanism for catching events called that are not +implemented (similar to the built-in PHP method <tt>__call</tt>). When +a dynamic or global event is called but a behavior does not implement it, +yet desires to know when an undefined dynamic event is run, the behavior +implements the interface <tt>IDynamicMethods</tt> and method <tt>__dycall</tt>. +</p> +<p id="130026" class="block-content"> +In the case of dynamic events, <tt>__dycall</tt> is supplied with the method +name and its parameters. When a global event is raised, via <tt>raiseEvent</tt>, +the method is the event name and the parameters are supplied. +</p> +<p id="130027" class="block-content"> +When implemented, this catch-all mechanism is called for event global event event +when implemented outside of a behavior. Within a behavior, it will also be called +when the object to which the behavior is attached calls any unimplemented dynamic +event. This is the fall-back mechanism for informing a class and/or behavior +of when an global and/or undefined dynamic event is executed. +</p> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/Fundamentals/Pages.page b/demos/quickstart/protected/pages/Fundamentals/Pages.page index 19900937..58f4f06d 100755 --- a/demos/quickstart/protected/pages/Fundamentals/Pages.page +++ b/demos/quickstart/protected/pages/Fundamentals/Pages.page @@ -5,13 +5,27 @@ Pages are top-most controls that have no parent. The presentation of pages are directly displayed to end-users. Users access pages by sending page service requests.
</p>
<p id="130138" class="block-content">
-Each page must have a <a href="?page=Configurations.Templates1">template</a> file. The file name suffix must be <tt>.page</tt>. The file name (without suffix) is the page name. PRADO will try to locate a page class file under the directory containing the page template file. Such a page class file must have the same file name (suffixed with <tt>.php</tt>) as the template file. If the class file is not found, the page will take class <tt>TPage</tt>.
+Each page can have a <a href="?page=Configurations.Templates1">template</a> file. The file name suffix must be <tt>.page</tt>. The file name (without suffix) is the page name. PRADO will try to locate a page class file under the directory containing the page template file. Such a page class file must have the same file name (suffixed with <tt>.php</tt>) as the template file. If the class file is not found, the page will take class <tt>TPage</tt>.
</p>
<h2 id="902">PostBack</h2>
<p id="130139" class="block-content">
A form submission is called <i>postback</i> if the submission is made to the page containing the form. Postback can be considered an event happened on the client side, raised by the user. PRADO will try to identify which control on the server side is responsible for a postback event. If one is determined, for example, a <tt>TButton</tt>, we call it the postback event sender which will translate the postback event into some specific server-side event (e.g. <tt>OnClick</tt> and <tt>OnCommand</tt> events for <tt>TButton</tt>).
+<br/>
+<tt>TPage</tt> has a <tt>IsPostBack</tt> property exposing whether the current request being handled is the first request for this page or the consequence of a postback.
+</p>
+<h2>CallBack</h2>
+<p class="block-content">
+A <i>callback</i> is a special form submission that, instead of requiring a full page reload on the browser, gets executed in the background through an ajax call. So, a callback is considered a postback too, but not vice versa.
+<br/>
+A callback is handled as a normal postback but, instead of re-rendering the entire page, only the specific changes occured on the page gets sent back to the client and merged with the current browser page. A typical callback response consists of:
+<ol>
+ <li>one or more pieces of html code that will replace existing content on the page;</li>
+ <li>the javascript instructions needed to update the page;</li>
+ <li>some specific fields used by prado to mantain the pagestate and add the needed external resources (stylesheets, javascript files, etc..).</li>
+</ol>
+<tt>TPage</tt> has a <tt>IsCallBack</tt> property exposing whether the current request being handled is the consequence of a callback. Since a callback is also a postback, both <tt>IsPostBack</tt> and <tt>IsCallBack</tt> are true during callback requests.
</p>
<h2 id="903">Page Lifecycles</h2>
diff --git a/demos/quickstart/protected/pages/Fundamentals/Services.page b/demos/quickstart/protected/pages/Fundamentals/Services.page index 5e5889df..ee19a159 100755 --- a/demos/quickstart/protected/pages/Fundamentals/Services.page +++ b/demos/quickstart/protected/pages/Fundamentals/Services.page @@ -16,7 +16,7 @@ Developers may implement additional services for their applications. To make a s <h2 id="1102">Page Service</h2>
<p id="150154" class="block-content">
-PRADO implements <tt>TPageService</tt> to process users' page requests. Pages are stored under a directory specified by the <tt>BasePath</tt> property of the page service. The property defaults to <tt>pages</tt> directory under the application base path. You may change this default by configuring the service in the application configuration.
+PRADO implements <tt>TPageService</tt> to process users' page requests. Pages are stored under a directory specified by the <tt>BasePath</tt> property of the page service. The property defaults to <tt>Pages</tt> directory under the application base path. You may change this default by configuring the service in the application configuration.
</p>
<p id="150155" class="block-content">
Pages may be organized into subdirectories under the <tt>BasePath</tt>. In each directory, there may be a page configuration file named <tt>config.xml</tt>, which contains configurations effective only when a page under that directory or a sub-directory is requested. For more details, see the <a href="?page=Configurations.PageConfig">page configuration</a> section.
@@ -30,5 +30,8 @@ http://hostname/index.php?page=Users.Register </com:TTextHighlighter>
where the first example takes advantage of the fact that the page service is the default service and <tt>Home</tt> is the default page.
</p>
+<p class="block-content">
+More advanced url routes, like masking real page names and permitting the use of dynamic parameters can be created using the <a href="?page=Configurations.UrlMapping">Url mapping</a> module.
+</p>
</com:TContent>
diff --git a/demos/quickstart/protected/pages/GettingStarted/AboutPrado.page b/demos/quickstart/protected/pages/GettingStarted/AboutPrado.page index 22437158..1a416a32 100755 --- a/demos/quickstart/protected/pages/GettingStarted/AboutPrado.page +++ b/demos/quickstart/protected/pages/GettingStarted/AboutPrado.page @@ -51,12 +51,12 @@ Most PHP frameworks mainly focuses on separating presentation and logic and prom <h2 id="4004">Is PRADO Stable Enough?</h2>
<p id="20004" class="block-content">
-Yes. PRADO was initially released in August 2004. Many test suites have been written and conducted frequently to ensure its quality. It has been used by thousands of developers and many Web applications have been developed based on it. Bugs and feature requests are managed through TRAC system and we have a great user community and development team to ensure all questions are answered in a timely fashion.
+Yes. PRADO was initially released in August 2004. Many test suites have been written and conducted frequently to ensure its quality. It has been used by thousands of developers and many Web applications have been developed based on it. Bugs and feature requests are managed through GitHub and we have a great user community and development team to ensure all questions are answered in a timely fashion.
</p>
<h2 id="205">History of PRADO</h2>
<p id="20014" class="block-content">
-The very original inspiration of PRADO came from Apache Tapestry. During the design and implementation, I borrowed many ideas from Borland Delphi and Microsoft ASP.NET. The first version of PRADO came out in June 2004 and was written in PHP 4. Driven by the Zend PHP 5 coding contest, I rewrote PRADO in PHP 5, which proved to be a wise move, thanks to the new object model provided by PHP 5. PRADO won the grand prize in the Zend contest, earning the highest votes from both the public and the judges' panel.
+The very original inspiration of PRADO came from Apache Tapestry. During the design and implementation, Qiang Xue borrowed many ideas from Borland Delphi and Microsoft ASP.NET. The first version of PRADO came out in June 2004 and was written in PHP 4. Driven by the Zend PHP 5 coding contest, Qiang rewrote PRADO in PHP 5, which proved to be a wise move, thanks to the new object model provided by PHP 5. PRADO won the grand prize in the Zend contest, earning the highest votes from both the public and the judges' panel.
</p>
<p id="20015" class="block-content">
In August 2004, PRADO started to be hosted on SourceForge as an open source project. Soon after, the project site <a href="http://www.xisc.com/">xisc.com</a> was announced to public. With the fantastic support of PRADO developer team and PRADO users, PRADO evolved to version 2.0 in mid 2005. In this version, Wei Zhuo contributed to PRADO with the excellent I18N and L10N support.
@@ -64,6 +64,12 @@ In August 2004, PRADO started to be hosted on SourceForge as an open source proj <p id="20016" class="block-content">
In May 2005, we decided to completely rewrite the PRADO framework to resolve a few fundamental issues found in version 2.0 and to catch up with some cool features available in Microsoft ASP.NET 2.0. After nearly a year's hard work with over 50,000 lines of new code, version 3.0 was finally made available in April 2006.
</p>
+<p class="block-content">
+In October 2008, the original development team released a new framework called <a href="http://www.yiiframework.com/">Yii</a>. Inheriting most of the PRADO code, Yii left the pages/events concept, focusing on a pure MVC design pattern. Since 2009 a lot of people contributed to PRADO fixing issues, developing new features or backporting them from Yii.
+</p>
+<p class="block-content">
+To promote a model of community-driven development, the project repositories were moved first on <a href="http://code.google.com/p/prado3/">Google Code</a> and then, in September 2013, on <a href="http://github.com/pradosoft/prado">GitHub</a>.
+</p>
<p id="20017" class="block-content">
Starting from version 3.0, significant efforts are allocated to ensure the quality and stability of PRADO. If we say PRADO v2.x and v1.x are proof-of-concept work, we can say PRADO 3.x has grown up to a project that is suitable for serious business application development.
</p>
diff --git a/demos/quickstart/protected/pages/GettingStarted/CommandLine.page b/demos/quickstart/protected/pages/GettingStarted/CommandLine.page index bc8f2f55..07609da5 100644 --- a/demos/quickstart/protected/pages/GettingStarted/CommandLine.page +++ b/demos/quickstart/protected/pages/GettingStarted/CommandLine.page @@ -15,7 +15,7 @@ the command line. <h2 id="503">Usage</h2>
<p id="70048" class="block-content">
If you type <tt>php path/to/framework/prado-cli.php</tt>, you should see
-the following information. Alternatively, if you are not on Windows,
+the following information. Alternatively, if you are not on Windows,
you may try to change the <tt>prado-cli.php</tt> into an executable
and execute it as a script</p>
<com:TTextHighlighter Language="cli" CssClass="source block-content cli" id="code_70006">
@@ -85,7 +85,7 @@ we <b>leave out the semicolon</b> to show the results. <com:TTextHighlighter Language="cli" CssClass="source block-content cli" id="code_70010">
>> $db->queryPostByID(1)
</com:TTextHighlighter>
-There should not be any errors and you should see the following.
+There should not be any errors and you should see the following.
<com:TTextHighlighter Language="cli" CssClass="source block-content cli" id="code_70011">
PostRecord#1
(
@@ -130,7 +130,7 @@ At the prompt, enter the following two commands to create <tt>UserRecord</tt> an </com:TTextHighlighter>
<p>
-Here we used the <a href="?page=Fundamentals.Components">namespace format</a> again to specify the classes to be created. The path <tt>Application.database.UserRecord</tt> indicates that we want the <tt>UserRecord</tt> class file to be <tt>protected/database/UserRecord.php</tt>.
+Here we used the <a href="?page=Fundamentals.Components1">namespace format</a> again to specify the classes to be created. The path <tt>Application.database.UserRecord</tt> indicates that we want the <tt>UserRecord</tt> class file to be <tt>protected/database/UserRecord.php</tt>.
</p>
</com:TContent>
diff --git a/demos/quickstart/protected/pages/GettingStarted/Installation.page b/demos/quickstart/protected/pages/GettingStarted/Installation.page index 7919e733..956f53c2 100755 --- a/demos/quickstart/protected/pages/GettingStarted/Installation.page +++ b/demos/quickstart/protected/pages/GettingStarted/Installation.page @@ -5,16 +5,17 @@ If you are viewing this page from your own Web server, you are already done with the installation.
</p>
<p id="30019">
-The minimum requirement by PRADO is that the Web server support PHP 5.2. PRADO has been tested with Apache Web server on Windows and Linux. Highly possibly it may also run on other platforms with other Web servers, as long as PHP 5.2 is supported.
+The minimum requirement by PRADO is that the Web server support PHP 5.3.3. PRADO has been tested with Apache Web server on Windows, MacOSX and various Linux distro. Highly possibly it may also run on other platforms with other Web servers, as long as PHP 5.3.3 is supported.
</p>
</div>
-<div id="install-steps" class="block-content">
<p id="30020">
-Installation of PRADO mainly involves downloading and unpacking.
+PRADO can be installed as a standalone package or using <a href="http://getcomposer.org/">composer</a>
</p>
+<div id="install-steps" class="block-content">
+<h3>Standalone package</h3>
<ol>
-<li>Go to <a href="http://www.pradosoft.com/">pradosoft.com</a> to grab the latest version of PRADO.</li>
+<li>Go to <a href="http://www.pradosoft.com/download/">pradosoft.com</a> to grab the latest version of PRADO.</li>
<li>Unpack the PRADO release file to a Web-accessible directory.
</ol>
</div>
@@ -25,5 +26,37 @@ Your installation of PRADO is done and you can start to play with the demo appli <p id="30022">
If you encounter any problems with the demo applications, please use the PRADO requirement checker script, accessible via <tt>http://web-server-address/prado/requirements/index.php</tt>, to check first if your server configuration fulfills the conditions required by PRADO.
</p>
+
+<div id="install-steps" class="block-content">
+<h3>Composer install</h3>
+<ol>
+<li>If you don't have installed composer already, install it globally:
+<com:TTextHighlighter CssClass="source block-content">
+$ curl -s http://getcomposer.org/installer | php
+$ php composer.phar install
+</com:TTextHighlighter>
+</li>
+<li>Create a composer.json file for your project:
+<com:TTextHighlighter CssClass="source block-content">
+{
+ "require": {
+ "pradosoft/prado": "~3.2"
+ }
+}
+</com:TTextHighlighter>
+</li>
+<li>Now run the actual installation:
+<com:TTextHighlighter CssClass="source block-content">
+$ composer install
+</com:TTextHighlighter>
+</li>
+<li>In your project include the autoloader, and you will have access to the library classes:
+<com:TTextHighlighter CssClass="source block-content">
+<?php
+require_once('vendor/autoload.php');
+</com:TTextHighlighter>
+</li>
+</ol>
</div>
+
</com:TContent>
diff --git a/demos/quickstart/protected/pages/JuiControls/Home.page b/demos/quickstart/protected/pages/JuiControls/Home.page new file mode 100644 index 00000000..dee08dfe --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Home.page @@ -0,0 +1,49 @@ +<com:TContent ID="body" > +<h1>Jui Controls (jQuery UI)</h1> +<p class="block-content"> +Jui controls are the PRADO port of the standard <a href="http://jqueryui.com/">jQuery UI</a> widgets. They can be used as standard <a href="?page=ActiveControls.Introduction">Active Controls</a>, but will automatically load the needed jQuery UI javascript libraries. Jui controls have a <tt>Options</tt> property used to pass options to the underlying javascript object. For informations of the specific options of each widget, follow the <a href="http://api.jqueryui.com/category/widgets/">API Documentation</a> for the specific widget. +</p> + +<h2>PRADO Jui interactions controls</h2> +<ul id="u1" class="block-content"> + <li> + <a href="?page=JuiControls.TJuiDraggable">TJuiDraggable</a> + is an element that can be moved using the mouse. + <com:RunBar PagePath="JuiControls.Samples.TJuiDraggable.Home" /> + </li> + + <li> + <a href="?page=JuiControls.TJuiDroppable">TJuiDroppable</a> + is an area where TJuiDraggable elements can be released. + <com:RunBar PagePath="JuiControls.Samples.TJuiDroppable.Home" /> + </li> + + <li> + <a href="?page=JuiControls.TJuiResizable">TJuiResizable</a> + is an element that cna be resized using the mouse. + <com:RunBar PagePath="JuiControls.Samples.TJuiResizable.Home" /> + </li> + + <li> + <a href="?page=JuiControls.TJuiSelectable">TJuiSelectable</a> + displays a list of elements that can be selected individually. + <com:RunBar PagePath="JuiControls.Samples.TJuiSelectable.Home" /> + </li> + + <li> + <a href="?page=JuiControls.TJuiSortable">TJuiSortable</a> + displays a list of elements that can be selected individually. + <com:RunBar PagePath="JuiControls.Samples.TJuiSortable.Home" /> + </li> +</ul> + +<h2>PRADO Jui controls</h2> +<ul id="u2" class="block-content"> + <li> + <a href="?page=JuiControls.TJuiAutocomplete">TJuiAutocomplete</a> + displays a textbox where the user can choose from a list of suggestions. + <com:RunBar PagePath="JuiControls.Samples.TJuiAutocomplete.Home" /> + </li> +</ul> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDraggable/Home.page b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDraggable/Home.page new file mode 100644 index 00000000..6912389d --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDraggable/Home.page @@ -0,0 +1,25 @@ +<com:TContent ID="body"> +<h1>TJuiDraggable Samples</h1> + +<com:TStyleSheet> + .ui-draggable { + width: 100px; + height:100px; + background-color: lime; + border: 1px solid black; + padding: 1em; + } +</com:TStyleSheet> +<table class="sampletable"> + +<tr><td class="samplenote"> +Default options with a little css applied: +</td><td class="sampleaction" style="height:600px"> + <com:TJuiDraggable> + Drag me around + </com:TJuiDraggable> +</td></tr> + +</table> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDroppable/Home.page b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDroppable/Home.page new file mode 100644 index 00000000..59cd3838 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDroppable/Home.page @@ -0,0 +1,48 @@ +<com:TContent ID="body"> +<h1>TJuiDraggable Samples</h1> + +<com:TStyleSheet> + .ui-draggable { + width: 100px; + height:100px; + background-color: lime; + border: 1px solid black; + padding: 1em; + } + .ui-droppable { + width: 150px; + height:150px; + border: 1px solid black; + padding: 1em; + margin: 1em; + } + .drop-yellow { + background-color: yellow; + } + .drop-red { + background-color: red; + } +</com:TStyleSheet> +<table class="sampletable"> + +<tr><td class="samplenote"> +Default options with a little css applied: +</td><td class="sampleaction" style="height:600px"> + <com:TJuiDraggable> + Drag me around + </com:TJuiDraggable> + + <com:TJuiDroppable OnDrop="drop1_ondrop" CssClass="drop-yellow"> + Drop it here! + <br/><com:TActiveLabel ID="label1" /> + </com:TJuiDroppable ID="drop1"> + + <com:TJuiDroppable OnDrop="drop2_ondrop" CssClass="drop-red"> + Drop it here! + <br/><com:TActiveLabel ID="label2" /> + </com:TJuiDroppable ID="drop1"> +</td></tr> + +</table> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDroppable/Home.php b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDroppable/Home.php new file mode 100644 index 00000000..cdbe85ba --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiDroppable/Home.php @@ -0,0 +1,16 @@ +<?php + +class Home extends TPage +{ + public function drop1_ondrop($sender, $param) + { + $draggable=$param->getDroppedControl()->ID; + $this->label1->Text="Dropped ".$draggable." at: <br/>Top=".$param->getOffsetTop()." Left=".$param->getOffsetLeft(); + } + + public function drop2_ondrop($sender, $param) + { + $draggable=$param->getDroppedControl()->ID; + $this->label2->Text="Dropped ".$draggable." at: <br/>Top=".$param->getOffsetTop()." Left=".$param->getOffsetLeft(); + } +} diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiResizable/Home.page b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiResizable/Home.page new file mode 100644 index 00000000..b5a207c0 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiResizable/Home.page @@ -0,0 +1,25 @@ +<com:TContent ID="body"> +<h1>TJuiResizable Samples</h1> + +<com:TStyleSheet> + .resizable { + width: 150px; + height: 150px; + padding: 0.5em; + background: #fff; + border: 1px solid #000; + } + </com:TStyleSheet> +<table class="sampletable"> + +<tr><td class="samplenote"> +Default options with a little css applied: +</td><td class="sampleaction"> + <com:TJuiResizable CssClass="resizable"> + Resize me! + </com:TJuiResizable> +</td></tr> + +</table> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.page b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.page new file mode 100644 index 00000000..4af5d637 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.page @@ -0,0 +1,38 @@ +<com:TContent ID="body"> +<h1>TJuiSelectable Samples</h1> + +<com:TStyleSheet> + .ui-selectable { + list-style: none; + cursor: pointer; + } + .ui-selectable li { + border: 1px solid transparent; + padding: 3px; + border-radius:3px; + } + + .ui-selectable li:hover { + background: #FECA40; + border: 1px solid black; + } + + .ui-selecting { + background: #FECA40; + } + .ui-selected { + background: #F39814; color: white; + } +</com:TStyleSheet> +<table class="sampletable"> + +<tr><td class="samplenote"> +Default options with a little css applied: +</td><td class="sampleaction"> + <com:TJuiSelectable ID="repeater1" onSelectedIndexChanged="repeater1_onSelectedIndexChanged"/> + <com:TActiveLabel ID="label1" /> +</td></tr> + +</table> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.php b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.php new file mode 100644 index 00000000..cf8d40f1 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.php @@ -0,0 +1,32 @@ +<?php + +class Home extends TPage +{ + protected $data = array( + 'PRADO', + 'quickstart', + 'tutorial', + 'sample', + 'for the', + 'TJuiSortable', + 'control', + ); + + public function onLoad($param) + { + if(!$this->IsPostback) + { + $this->repeater1->DataSource=$this->data; + $this->repeater1->dataBind(); + } + } + + public function repeater1_onSelectedIndexChanged($sender, $param) + { + $this->label1->Text="Selected items:"; + $items = $param->getSelectedIndexes(); + + foreach($items as $index) + $this->label1->Text.=' '.$this->data[$index]; + } +} diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSortable/Home.page b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSortable/Home.page new file mode 100644 index 00000000..2e1d2f55 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSortable/Home.page @@ -0,0 +1,32 @@ +<com:TContent ID="body"> +<h1>TJuiSortable Samples</h1> + +<com:TStyleSheet> + .ui-sortable { + list-style: none; + cursor: pointer; + } + + .ui-sortable li { + border: 1px solid transparent; + padding: 3px; + border-radius:3px; + } + + .ui-sortable li:hover { + background: lime; + border: 1px solid black; + } +</com:TStyleSheet> +<table class="sampletable"> + +<tr><td class="samplenote"> +Default options with a little css applied: +</td><td class="sampleaction"> + <com:TJuiSortable ID="repeater1" onSort="repeater1_onSort"/> + <com:TActiveLabel ID="label1" /> +</td></tr> + +</table> + +</com:TContent> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSortable/Home.php b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSortable/Home.php new file mode 100644 index 00000000..4b3a0ff4 --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSortable/Home.php @@ -0,0 +1,31 @@ +<?php + +class Home extends TPage +{ + protected $data = array( + 'PRADO', + 'quickstart', + 'tutorial', + 'sample', + 'for the', + 'TJuiSortable', + 'control', + ); + + public function onLoad($param) + { + if(!$this->IsPostback) + { + $this->repeater1->DataSource=$this->data; + $this->repeater1->dataBind(); + } + } + + public function repeater1_onSort($sender, $param) + { + $this->label1->Text="Items order:"; + $order = $param->getOrder(); + foreach($order as $index) + $this->label1->Text.=' '.$this->data[$index]; + } +} diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/config.xml b/demos/quickstart/protected/pages/JuiControls/Samples/config.xml new file mode 100644 index 00000000..315e42af --- /dev/null +++ b/demos/quickstart/protected/pages/JuiControls/Samples/config.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Id: config.xml 1405 2006-09-10 01:03:56Z wei $ --> +<configuration> + <paths> + <using namespace="System.Web.UI.JuiControls.*" /> + </paths> + <pages MasterClass="SampleLayout" /> +</configuration>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Tutorial/AddressBook.page b/demos/quickstart/protected/pages/Tutorial/AddressBook.page deleted file mode 100755 index f028a636..00000000 --- a/demos/quickstart/protected/pages/Tutorial/AddressBook.page +++ /dev/null @@ -1,9 +0,0 @@ -<com:TContent ID="body">
- <h1 id="22007">A Simple Address Book</h1>
- <p id="110006" class="block-content">This tutorial introduces the basics of connecting to a database
- using <a href="?page=Database.ActiveRecord">ActiveRecord</a>
- and using <a href="?page=Database.Scaffold">Active Record scaffolds </a>to quickly
- build a simple address book.
- </p>
-
-</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page index d94dfa89..4a8f23ab 100755 --- a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page +++ b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page @@ -170,7 +170,7 @@ as <tt>App_Code/chat.db</tt>. class ChatUserRecord extends TActiveRecord { const TABLE='chat_users'; - + public $username; public $last_activity; @@ -431,7 +431,6 @@ and a button to send the message. Text="Send" /> </div> </com:TForm> -<com:TJavascriptLogger /> </body> </html> </com:TTextHighlighter> @@ -572,7 +571,7 @@ public function getUserMessages($user) $content = ''; foreach($this->findAll('for_user = ?', $user) as $message) $content .= $this->formatMessage($message); - $this->deleteAll('for_user = ? OR created_on < ?',
+ $this->deleteAll('for_user = ? OR created_on < ?', $user, time() - 300); //5 min inactivity return $content; } @@ -581,7 +580,7 @@ protected function formatMessage($message) { $user = htmlspecialchars($message->from_user); $content = htmlspecialchars($message->message); - return "<div class=\"message\"><strong>{$user}:</strong>"
+ return "<div class=\"message\"><strong>{$user}:</strong>" ." <span>{$content}</span></div>"; } </com:TTextHighlighter> diff --git a/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page b/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page index 66bb0e43..39d7f9e5 100755 --- a/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page +++ b/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page @@ -430,7 +430,6 @@ and a button to send the message. Text="Send" /> </div> </com:TForm> -<com:TJavascriptLogger /> </body> </html> </com:TTextHighlighter> @@ -571,7 +570,7 @@ public function getUserMessages($user) $content = ''; foreach($this->findAll('for_user = ?', $user) as $message) $content .= $this->formatMessage($message); - $this->deleteAll('for_user = ? OR created_on < ?',
+ $this->deleteAll('for_user = ? OR created_on < ?', $user, time() - 300); //5 min inactivity return $content; } @@ -580,7 +579,7 @@ protected function formatMessage($message) { $user = htmlspecialchars($message->from_user); $content = htmlspecialchars($message->message); - return "<div class=\"message\"><strong>{$user}:</strong>"
+ return "<div class=\"message\"><strong>{$user}:</strong>" ." <span>{$content}</span></div>"; } </com:TTextHighlighter> |