From 658a7e1c4cf5a53dcd61ee196658090d00f2d64a Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 29 Dec 2005 11:52:31 +0000 Subject: Used THighlighter to show code fragments. --- .../protected/pages/Fundamentals/Applications.page | 6 +- .../protected/pages/Fundamentals/Components.page | 65 +++++++++++----------- .../protected/pages/Fundamentals/Controls.page | 16 +++--- .../protected/pages/Fundamentals/HelloWorld.page | 8 +-- .../protected/pages/Fundamentals/Services.page | 12 ++-- 5 files changed, 54 insertions(+), 53 deletions(-) (limited to 'demos/quickstart/protected/pages/Fundamentals') 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 TApplication or its derived class. It

Applications are configured via application configurations. They are usually created in entry scripts like the following, -

+
 require_once('/path/to/prado.php');
 $application = new TApplication;
-$application->run();
-
+$application->run(); + where the method run() starts the application to handle user requests.

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 TComponent or its child class. The base c

Component Properties

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 TControl, we define its ID property using the following getter and setter methods, - + class TControl extends TComponent { public function getID() { ... @@ -20,15 +20,15 @@ class TControl extends TComponent {

To get or set the ID property, do as follows, just like working with a variable, -

-$id = $component->ID;
-$component->ID = $id;
-
+ +$id = $component->ID; +$component->ID = $id; + This is equivalent to the following, -
-$id = $component->getID();
-$component->setID( $id );
-
+ +$id = $component->getID(); +$component->setID( $id ); +

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, TWeb

To get or set the Name subproperty, use the following method, -

+
 $name = $component->getSubProperty('Font.Name');
-$component->setSubProperty('Font.Name', $name);
-
+$component->setSubProperty('Font.Name', $name); + This is equivalent to the following, -
-$name = $component->getFont()->getName();
+
+$name = $component->getFont()->getName();
 $component->getFont()->setName( $name );
-
+ +

@@ -58,19 +59,19 @@ Component events are special properties that take method names as their values.

A component event is defined by the existence of an on-method. For example, in TButton, we have - + class TButton extends TWebControl { - public function onClick($param) { + public function onClick( $param ) { ... } } This defines an event named Click, and a handler can be attached to the event using one of the following ways, - -$button->Click=$callback; -$button->Click->add($callback); -$button->Click[]=$callback; -$button->attachEventHandler('Click',$callback); + +$button->Click = $callback; +$button->Click->add( $callback ); +$button->Click[] = $callback; +$button->attachEventHandler( 'Click' , $callback ); where $callback refers to a valid PHP callback (e.g. a function name, a class method array($object,'method'), etc.)

@@ -81,20 +82,20 @@ A namespace refers to a logical grouping of some class names so that they can be

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, -

+
PathAlias.Dir1.Dir2 -
+ where PathAlias is an alias of some directory, while Dir1 and Dir2 are subdirectories under that directory. A class named MyClass defined under Dir2 may now be fully qualified as PathAlias.Dir1.Dir2.MyClass.

To use a namespace in code, do as follows, -

+
 Prado::using('PathAlias.Dir1.Dir2.*');
-
+ which appends the directory referred to by PathAlias.Dir1.Dir2 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 -
+
 Prado::using('PathAlias.Dir1.Dir2.MyClass');
-
+ which will include the class file if MyClass is not defined.

@@ -109,19 +110,19 @@ Component instantiation means creating instances of component classes. There are

Dynamic Component Instantiation

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, -

+
 $component = new ComponentClassName;
 $component = Prado::createComponent('ComponentType');
-
+ where ComponentType refers to a class name or a type name in namespace format (e.g. System.Web.UI.TControl). The second approach is introduced to compensate for the lack of namespace support in PHP.

Static Component Instantiation

Static component instantiation is about creating components via configurations. The actual creation work is done by the PRADO framework. For example, in an application configuration, 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 templates. 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 TButton component on the page, -

+
 <com:TButton Text="Register" />
-
+

\ 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

The parent-child relationship is usually established by the framework via templates. In code, you may explicitly specify a control as a child of another using one of the following methods, -

+
 $parent->Controls->add($child);
 $parent->Controls[]=$child;
-
+ where the property Controls refers to the child control collection of the parent.

@@ -39,12 +39,12 @@ PRADO borrows the viewstate and controlstate concept from Microsoft ASP.NET to p

Viewstate and controlstate are implemented in TControl. They are commonly used to define various properties of controls. To save and retrieve values from viewstate or controlstate, use following methods, -

-$this->getViewState('Name',$defaultValue);
-$this->setViewState('Name',$value,$defaultValue);
-$this->getControlState('Name',$defaultValue);
-$this->setControlState('Name',$value,$defaultValue);
-
+ +$this->getViewState('Name',$defaultValue); +$this->setViewState('Name',$value,$defaultValue); +$this->getControlState('Name',$defaultValue); +$this->setControlState('Name',$value,$defaultValue); + where $this refers to the control instance, Name refers to a key identifying the persistent value, $defaultValue is optional. When retrieving values from viewstate or controlstate, if the corresponding key does not exist, the default value will be returned.

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

The code that a developer needs to write is merely the following event handler function, where $sender refers to the button object. -

-
+
 public function buttonClicked($sender,$param)
 {
-	$sender->Text="Hello World";
+	$sender->Text = "Hello World";
 }
-
+ +

\ 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 IService interface

A service is uniquely identified by its ID property. By default when THttpRequest is used as the request module, GET variable names are used to identify which service a user is requesting. If a GET variable name is equal to some service ID, 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 page. For example, the following URL requests for the Fundamentals.Services page, -

+
http://hostname/index.php?page=Fundamentals.Services -
+

Developers may implement additional services for their applications. To make a service available, configure it in application configurations. @@ -23,11 +23,11 @@ Pages may be organized into subdirectories under the BasePath. In each

Service parameter for the page service refers to the page being requested. A parameter like Fundamentals.Services refers to the Services page under the <BasePath>/Fundamentals directory. If such a parameter is absent in a request, a default page named Home is assumed. Using THttpRequest as the request module (default), the following URLs will request for Home, About and Register pages, respectively, -

-http://hostname/index.php
-http://hostname/index.php?page=About
+
+http://hostname/index.php
+http://hostname/index.php?page=About
http://hostname/index.php?page=Users.Register -
+ where the first example takes advantage of the fact that the page service is the default service and Home is the default page.

-- cgit v1.2.3