diff options
author | xue <> | 2005-12-29 11:52:31 +0000 |
---|---|---|
committer | xue <> | 2005-12-29 11:52:31 +0000 |
commit | 658a7e1c4cf5a53dcd61ee196658090d00f2d64a (patch) | |
tree | c37b767c6e4d70baaf9ff471ce3721c9d8733f72 /demos/quickstart/protected/pages/Fundamentals | |
parent | c0006cf0da8c3499060df7378cc376c98cbce7c4 (diff) |
Used THighlighter to show code fragments.
Diffstat (limited to 'demos/quickstart/protected/pages/Fundamentals')
5 files changed, 54 insertions, 53 deletions
diff --git a/demos/quickstart/protected/pages/Fundamentals/Applications.page b/demos/quickstart/protected/pages/Fundamentals/Applications.page index f438e3d4..b67debaa 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Applications.page +++ b/demos/quickstart/protected/pages/Fundamentals/Applications.page @@ -6,11 +6,11 @@ An application is an instance of <tt>TApplication</tt> or its derived class. It </p>
<p>
Applications are configured via <a href="?page=Configurations.AppConfig">application configurations</a>. They are usually created in entry scripts like the following,
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
require_once('/path/to/prado.php');
$application = new TApplication;
-$application->run();
-</pre>
+$application->run();
+</com:TTextHighlighter>
where the method <tt>run()</tt> starts the application to handle user requests.
</p>
diff --git a/demos/quickstart/protected/pages/Fundamentals/Components.page b/demos/quickstart/protected/pages/Fundamentals/Components.page index be71b18b..56cf1671 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Components.page +++ b/demos/quickstart/protected/pages/Fundamentals/Components.page @@ -7,7 +7,7 @@ A component is an instance of <tt>TComponent</tt> or its child class. The base c <h2>Component Properties</h2>
<p>
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 Language="php" CssClass="source">
+<com:TTextHighlighter CssClass="source">
class TControl extends TComponent {
public function getID() {
...
@@ -20,15 +20,15 @@ class TControl extends TComponent { </p>
<p>
To get or set the <tt>ID</tt> property, do as follows, just like working with a variable,
-<pre class="source">
-$id = $component->ID;
-$component->ID = $id;
-</pre>
+<com:TTextHighlighter CssClass="source">
+$id = $component->ID;
+$component->ID = $id;
+</com:TTextHighlighter>
This is equivalent to the following,
-<pre class="source">
-$id = $component->getID();
-$component->setID( $id );
-</pre>
+<com:TTextHighlighter CssClass="source">
+$id = $component->getID();
+$component->setID( $id );
+</com:TTextHighlighter>
</p>
<p>
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.
@@ -40,15 +40,16 @@ A subproperty is a property of some object-typed property. For example, <tt>TWeb </p>
<p>
To get or set the <tt>Name</tt> subproperty, use the following method,
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
$name = $component->getSubProperty('Font.Name');
-$component->setSubProperty('Font.Name', $name);
-</pre>
+$component->setSubProperty('Font.Name', $name);
+</com:TTextHighlighter>
This is equivalent to the following,
-<pre class="source">
-$name = $component->getFont()->getName();
+<com:TTextHighlighter CssClass="source">
+$name = $component->getFont()->getName();
$component->getFont()->setName( $name );
-</pre>
+</com:TTextHighlighter>
+
</p>
@@ -58,19 +59,19 @@ Component events are special properties that take method names as their values. </p>
<p>
A component event is defined by the existence of an <tt>on</tt>-method. For example, in <tt>TButton</tt>, we have
-<com:TTextHighlighter Language="php" CssClass="source">
+<com:TTextHighlighter CssClass="source">
class TButton extends TWebControl {
- public function onClick($param) {
+ public function onClick( $param ) {
...
}
}
</com:TTextHighlighter>
This defines an event named <tt>Click</tt>, and a handler can be attached to the event using one of the following ways,
-<com:TTextHighlighter Language="php" CssClass="source">
-$button->Click=$callback;
-$button->Click->add($callback);
-$button->Click[]=$callback;
-$button->attachEventHandler('Click',$callback);
+<com:TTextHighlighter CssClass="source">
+$button->Click = $callback;
+$button->Click->add( $callback );
+$button->Click[] = $callback;
+$button->attachEventHandler( 'Click' , $callback );
</com:TTextHighlighter>
where <tt>$callback</tt> refers to a valid PHP callback (e.g. a function name, a class method <tt>array($object,'method')</tt>, etc.)
</p>
@@ -81,20 +82,20 @@ A namespace refers to a logical grouping of some class names so that they can be </p>
<p>
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,
-<pre class="source">
+<div class="source">
PathAlias.Dir1.Dir2
-</pre>
+</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>
To use a namespace in code, do as follows,
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
Prado::using('PathAlias.Dir1.Dir2.*');
-</pre>
+</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
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
Prado::using('PathAlias.Dir1.Dir2.MyClass');
-</pre>
+</com:TTextHighlighter>
which will include the class file if <tt>MyClass</tt> is not defined.
</p>
<p>
@@ -109,19 +110,19 @@ Component instantiation means creating instances of component classes. There are <h3>Dynamic Component Instantiation</h3>
<p>
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,
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
$component = new ComponentClassName;
$component = Prado::createComponent('ComponentType');
-</pre>
+</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>Static Component Instantiation</h3>
<p>
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,
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
<com:TButton Text="Register" />
-</pre>
+</com:TTextHighlighter>
</p>
</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Fundamentals/Controls.page b/demos/quickstart/protected/pages/Fundamentals/Controls.page index cc0b3eda..a90dd604 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Controls.page +++ b/demos/quickstart/protected/pages/Fundamentals/Controls.page @@ -10,10 +10,10 @@ Controls are related to each other via parent-child relationship. Each parent co </p>
<p>
The parent-child relationship is usually established by the framework via <a href="?page=Configurations.Templates1">templates</a>. In code, you may explicitly specify a control as a child of another using one of the following methods,
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
$parent->Controls->add($child);
$parent->Controls[]=$child;
-</pre>
+</com:TTextHighlighter>
where the property <tt>Controls</tt> refers to the child control collection of the parent.
</p>
@@ -39,12 +39,12 @@ PRADO borrows the viewstate and controlstate concept from Microsoft ASP.NET to p </p>
<p>
Viewstate and controlstate are implemented in <tt>TControl</tt>. They are commonly used to define various properties of controls. To save and retrieve values from viewstate or controlstate, use following methods,
-<pre class="source">
-$this->getViewState('Name',$defaultValue);
-$this->setViewState('Name',$value,$defaultValue);
-$this->getControlState('Name',$defaultValue);
-$this->setControlState('Name',$value,$defaultValue);
-</pre>
+<com:TTextHighlighter CssClass="source">
+$this->getViewState('Name',$defaultValue);
+$this->setViewState('Name',$value,$defaultValue);
+$this->getControlState('Name',$defaultValue);
+$this->setControlState('Name',$value,$defaultValue);
+</com:TTextHighlighter>
where <tt>$this</tt> refers to the control instance, <tt>Name</tt> refers to a key identifying the persistent value, <tt>$defaultValue</tt> is optional. When retrieving values from viewstate or controlstate, if the corresponding key does not exist, the default value will be returned.
</p>
diff --git a/demos/quickstart/protected/pages/Fundamentals/HelloWorld.page b/demos/quickstart/protected/pages/Fundamentals/HelloWorld.page index b543afb7..d6d497c1 100644 --- a/demos/quickstart/protected/pages/Fundamentals/HelloWorld.page +++ b/demos/quickstart/protected/pages/Fundamentals/HelloWorld.page @@ -12,14 +12,14 @@ PRADO promotes component-based and event-driven Web programming. The button is r <img src="<%~Samples/HelloWorld/sequence.gif%>" />
<p>
The code that a developer needs to write is merely the following event handler function, where <tt>$sender</tt> refers to the button object.
-</p>
-<pre class="source">
+<com:TTextHighlighter CssClass="source">
public function buttonClicked($sender,$param)
{
- $sender->Text="Hello World";
+ $sender->Text = "Hello World";
}
-</pre>
+</com:TTextHighlighter>
<com:RunBar PagePath="Fundamentals.Samples.HelloWorld.Home" />
+</p>
</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Fundamentals/Services.page b/demos/quickstart/protected/pages/Fundamentals/Services.page index 49b8041b..61bd440b 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Services.page +++ b/demos/quickstart/protected/pages/Fundamentals/Services.page @@ -6,9 +6,9 @@ A service is an instance of a class implementing the <tt>IService</tt> interface </p>
<p>
A service is uniquely identified by its <tt>ID</tt> property. By default when <tt>THttpRequest</tt> is used as the <a href="?page=Fundamentals.Modules#request">request module</a>, GET variable names are used to identify which service a user is requesting. If a GET variable name is equal to some service <tt>ID</tt>, the request is considered for that service, and the value of the GET variable is passed as the service parameter. For page service, the name of the GET variable must be <tt>page</tt>. For example, the following URL requests for the <tt>Fundamentals.Services</tt> page,
-<pre class="source">
+<div class="source">
http://hostname/index.php?page=Fundamentals.Services
-</pre>
+</div>
</p>
<p>
Developers may implement additional services for their applications. To make a service available, configure it in <a href="?page=Configurations.AppConfig">application configurations</a>.
@@ -23,11 +23,11 @@ Pages may be organized into subdirectories under the <tt>BasePath</tt>. In each </p>
<p>
Service parameter for the page service refers to the page being requested. A parameter like <tt>Fundamentals.Services</tt> refers to the <tt>Services</tt> page under the <tt><BasePath>/Fundamentals</tt> directory. If such a parameter is absent in a request, a default page named <tt>Home</tt> is assumed. Using <tt>THttpRequest</tt> as the request module (default), the following URLs will request for <tt>Home</tt>, <tt>About</tt> and <tt>Register</tt> pages, respectively,
-<pre class="source">
-http://hostname/index.php
-http://hostname/index.php?page=About
+<div class="source">
+http://hostname/index.php<br/>
+http://hostname/index.php?page=About<br/>
http://hostname/index.php?page=Users.Register
-</pre>
+</div>
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>
|