summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected
diff options
context:
space:
mode:
authorxue <>2005-12-29 11:52:31 +0000
committerxue <>2005-12-29 11:52:31 +0000
commit658a7e1c4cf5a53dcd61ee196658090d00f2d64a (patch)
treec37b767c6e4d70baaf9ff471ce3721c9d8733f72 /demos/quickstart/protected
parentc0006cf0da8c3499060df7378cc376c98cbce7c4 (diff)
Used THighlighter to show code fragments.
Diffstat (limited to 'demos/quickstart/protected')
-rw-r--r--demos/quickstart/protected/controls/TTextHighlighter.php4
-rw-r--r--demos/quickstart/protected/pages/Configurations/AppConfig.page40
-rw-r--r--demos/quickstart/protected/pages/Configurations/PageConfig.page42
-rw-r--r--demos/quickstart/protected/pages/Fundamentals/Applications.page6
-rw-r--r--demos/quickstart/protected/pages/Fundamentals/Components.page65
-rw-r--r--demos/quickstart/protected/pages/Fundamentals/Controls.page16
-rw-r--r--demos/quickstart/protected/pages/Fundamentals/HelloWorld.page8
-rw-r--r--demos/quickstart/protected/pages/Fundamentals/Services.page12
-rw-r--r--demos/quickstart/protected/pages/ViewSource.page2
-rw-r--r--demos/quickstart/protected/pages/ViewSource.php1
10 files changed, 100 insertions, 96 deletions
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
</p>
<p>
Configuration for an application is stored in an XML file named <tt>application.xml</tt>, which should be located under the application base path. Its format is shown in the following,
-<pre class="source">
-&lt;application PropertyName="PropertyValue" ...&gt;
- &lt;paths&gt;
- &lt;alias id="AliasID" path="AliasPath" /&gt;
- &lt;using namespace="Namespace" /&gt;
- &lt;/paths&gt;
- &lt;modules&gt;
- &lt;module id="ModuleID" class="ModuleClass" PropertyName="PropertyValue" ... /&gt;
- &lt;/modules&gt;
- &lt;services&gt;
- &lt;service id="ServiceID" class="ServiceClass" PropertyName="PropertyValue" ... /&gt;
- &lt;/services&gt;
- &lt;parameters&gt;
- &lt;parameter id="ParameterID" class="ParameterClass" PropertyName="PropertyValue" ... /&gt;
- &lt;/parameters&gt;
-&lt;/application&gt;
-</pre>
+<com:TTextHighlighter Language="xml" CssClass="source">
+<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>
+</com:TTextHighlighter>
<ul>
<li>The outermost element <tt>&lt;application&gt;</tt> corresponds to the <tt>TApplication</tt> instance. The <tt>PropertyName="PropertyValue"</tt> pairs specify the initial values for the properties of <tt>TApplication</tt>.</li>
<li>The <tt>&lt;paths&gt;</tt> element contains the definition of path aliases and the PHP inclusion paths for the application. Each path alias is specified via an <tt>&lt;alias&gt;</tt> whose <tt>path</tt> attribute takes an absolute path or a path relative to the directory containing the application configuration file. The <tt>&lt;using&gt;</tt> element specifies a particular path (in terms of namespace) to be appended to the PHP include paths when the application runs. PRADO defines two default aliases: <tt>System</tt> and <tt>Application</tt>. The former refers to the PRADO framework root directory, and the latter refers to the directory containing the application configuration file.</li>
<li>The <tt>&lt;modules&gt;</tt> element contains the configurations for a list of modules. Each module is specified by a <tt>&lt;module&gt;</tt> element. Each module is uniquely identified by the <tt>id</tt> attribute and is of type <tt>class</tt>. The <tt>PropertyName="PropertyValue"</tt> pairs specify the initial values for the properties of the module.</li>
<li>The <tt>&lt;services&gt;</tt> element is similar to the <tt>&lt;modules&gt;</tt> element. It mainly specifies the services provided by the application.</li>
<li>The <tt>&lt;parameters&gt;</tt> element contains a list of application-level parameters that are accessible from anywhere in the application. You may specify component-typed parameters like specifying modules, or you may specify string-typed parameters which take a simpler format as follows,
-<pre class="source">
-&lt;parameter id="ParameterID"&gt;ParameterValue&lt;/parameter&gt;
-</pre>
+<com:TTextHighlighter Language="xml" CssClass="source">
+<parameter id="ParameterID">ParameterValue</parameter>
+</com:TTextHighlighter>
</li>
</ul>
By default without explicit configuration, a PRADO application when running will load a few core modules, such as <tt>THttpRequest</tt>, <tt>THttpResponse</tt>, etc. It will also provide the <tt>TPageService</tt> 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 <tt>&lt;BasePath&gt;/dir1/dir2</tt>, th
</p>
<p>
The format of a page configuration file is as follows,
-<pre class="source">
-&lt;configuration&gt;
- &lt;paths&gt;
- &lt;alias id="AliasID" path="AliasPath" /&gt;
- &lt;using namespace="Namespace" /&gt;
- &lt;/paths&gt;
- &lt;modules&gt;
- &lt;module id="ModuleID" class="ModuleClass" PropertyName="PropertyValue" ... /&gt;
- &lt;/modules&gt;
- &lt;authorization&gt;
- &lt;allow pages="PageID1,PageID2" users="User1,User2" roles="Role1,Role2" verb="get" /&gt;
- &lt;deny pages="PageID1,PageID2" users="User1,User2" roles="Role1,Role2" verb="post" /&gt;
- &lt;/authorization&gt;
- &lt;pages PropertyName="PropertyValue" ...&gt;
- &lt;page id="PageID" PropertyName="PropertyValue" ... /&gt;
- &lt;/pages&gt;
- &lt;parameters&gt;
- &lt;parameter id="ParameterID" class="ParameterClass" PropertyName="PropertyValue" ... /&gt;
- &lt;/parameters&gt;
-&lt;/configuration&gt;
-</pre>
+<com:TTextHighlighter Language="xml" CssClass="source">
+<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>
+</com:TTextHighlighter>
The <tt>&lt;paths&gt;</tt>, <tt>&lt;modules&gt;</tt> and <tt>&lt;parameters&gt;</tt> are similar to those in an application configuration. The <tt>&lt;authorization&gt;</tt> 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 <tt>&lt;pages&gt;</tt> element specifies the initial values for the properties of pages. Each <tt>&lt;page&gt;</tt> element specifies the initial property values for a particular page identified by the <tt>id</code attribute. Initial property values given in the <tt>&lt;pages&gt;</tt> element apply to all pages in the current directory and all its subdirectories.
</p>
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-&gt;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-&gt;ID;
-$component-&gt;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-&gt;getID();
-$component-&gt;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-&gt;getSubProperty('Font.Name');
-$component-&gt;setSubProperty('Font.Name', $name);
-</pre>
+$component->setSubProperty('Font.Name', $name);
+</com:TTextHighlighter>
This is equivalent to the following,
-<pre class="source">
-$name = $component-&gt;getFont()-&gt;getName();
+<com:TTextHighlighter CssClass="source">
+$name = $component->getFont()->getName();
$component-&gt;getFont()-&gt;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-&gt;Click=$callback;
-$button-&gt;Click-&gt;add($callback);
-$button-&gt;Click[]=$callback;
-$button-&gt;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">
&lt;com:TButton Text="Register" /&gt;
-</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-&gt;getViewState('Name',$defaultValue);
-$this-&gt;setViewState('Name',$value,$defaultValue);
-$this-&gt;getControlState('Name',$defaultValue);
-$this-&gt;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-&gt;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>&lt;BasePath&gt;/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>
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 @@
<com:TLiteral ID="SourceList" />
</div>
<div id="sourceView">
+<com:TTextHighlighter Language="prado" CssClass="source">
<com:TLiteral ID="SourceView" />
+</com:TTextHighlighter>
</div>
</body>
</html> \ 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);
}
}