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/controls/TTextHighlighter.php | 4 +- .../protected/pages/Configurations/AppConfig.page | 40 ++++++------- .../protected/pages/Configurations/PageConfig.page | 42 +++++++------- .../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 ++-- demos/quickstart/protected/pages/ViewSource.page | 2 + demos/quickstart/protected/pages/ViewSource.php | 1 + 10 files changed, 100 insertions(+), 96 deletions(-) (limited to 'demos/quickstart/protected') diff --git a/demos/quickstart/protected/controls/TTextHighlighter.php b/demos/quickstart/protected/controls/TTextHighlighter.php index d8bb6bba..19b54ad2 100644 --- a/demos/quickstart/protected/controls/TTextHighlighter.php +++ b/demos/quickstart/protected/controls/TTextHighlighter.php @@ -23,12 +23,12 @@ class TTextHighlighter extends TWebControl public function getLanguage() { - return $this->getViewState('Language', ''); + return $this->getViewState('Language', 'php'); } public function setLanguage($value) { - $this->setViewState('Language', $value, ''); + $this->setViewState('Language', $value, 'php'); } public function setEnableLineNumbers($value) diff --git a/demos/quickstart/protected/pages/Configurations/AppConfig.page b/demos/quickstart/protected/pages/Configurations/AppConfig.page index 101e449c..127f74a4 100644 --- a/demos/quickstart/protected/pages/Configurations/AppConfig.page +++ b/demos/quickstart/protected/pages/Configurations/AppConfig.page @@ -6,32 +6,32 @@ Application configurations are used to specify the global behavior of an applica

Configuration for an application is stored in an XML file named application.xml, which should be located under the application base path. Its format is shown in the following, -

-<application PropertyName="PropertyValue" ...>
-  <paths>
-    <alias id="AliasID" path="AliasPath" />
-    <using namespace="Namespace" />
-  </paths>
-  <modules>
-    <module id="ModuleID" class="ModuleClass"  PropertyName="PropertyValue" ... />
-  </modules>
-  <services>
-    <service id="ServiceID" class="ServiceClass" PropertyName="PropertyValue" ... />
-  </services>
-  <parameters>
-    <parameter id="ParameterID" class="ParameterClass" PropertyName="PropertyValue" ... />
-  </parameters>
-</application>
-
+ + + + + + + + + + + + + + + + + By default without explicit configuration, a PRADO application when running will load a few core modules, such as THttpRequest, THttpResponse, etc. It will also provide the TPageService as a default service. Configuration and usage of these modules and services are covered in individual sections of this tutorial. Note, if your application takes default settings for these modules and service, you do not need to provide an application configuration. However, if these modules or services are not sufficient, or you want to change their behavior by configuring their property values, you will need an application configuration. diff --git a/demos/quickstart/protected/pages/Configurations/PageConfig.page b/demos/quickstart/protected/pages/Configurations/PageConfig.page index a7d0ef8e..2aff1fb9 100644 --- a/demos/quickstart/protected/pages/Configurations/PageConfig.page +++ b/demos/quickstart/protected/pages/Configurations/PageConfig.page @@ -9,27 +9,27 @@ When a user requests a page stored under <BasePath>/dir1/dir2, th

The format of a page configuration file is as follows, -

-<configuration>
-  <paths>
-    <alias id="AliasID" path="AliasPath" />
-    <using namespace="Namespace" />
-  </paths>
-  <modules>
-    <module id="ModuleID" class="ModuleClass"  PropertyName="PropertyValue" ... />
-  </modules>
-  <authorization>
-    <allow pages="PageID1,PageID2" users="User1,User2" roles="Role1,Role2" verb="get" />
-    <deny pages="PageID1,PageID2" users="User1,User2" roles="Role1,Role2" verb="post" />
-  </authorization>
-  <pages PropertyName="PropertyValue" ...>
-    <page id="PageID" PropertyName="PropertyValue" ... />
-  </pages>
-  <parameters>
-    <parameter id="ParameterID" class="ParameterClass" PropertyName="PropertyValue" ... />
-  </parameters>
-</configuration>
-
+ + + + + + + + + + + + + + + + + + + + + The <paths>, <modules> and <parameters> are similar to those in an application configuration. The <authorization> specifies the authorization rules that apply to the current page directory and all its subdirectories. It will be explained in more detail in future sections. The <pages> element specifies the initial values for the properties of pages. Each <page> element specifies the initial property values for a particular page identified by the id<pages> element apply to all pages in the current directory and all its subdirectories.

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.

diff --git a/demos/quickstart/protected/pages/ViewSource.page b/demos/quickstart/protected/pages/ViewSource.page index 3732771a..3c175c80 100644 --- a/demos/quickstart/protected/pages/ViewSource.page +++ b/demos/quickstart/protected/pages/ViewSource.page @@ -10,7 +10,9 @@
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ViewSource.php b/demos/quickstart/protected/pages/ViewSource.php index 4ac2c816..65cefa70 100644 --- a/demos/quickstart/protected/pages/ViewSource.php +++ b/demos/quickstart/protected/pages/ViewSource.php @@ -60,6 +60,7 @@ class ViewSource extends TPage } $this->SourceView->Text=highlight_string(file_get_contents($this->_fullPath),true); + //$this->SourceView->Text=file_get_contents($this->_fullPath); } } -- cgit v1.2.3