summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages
diff options
context:
space:
mode:
authorwei <>2007-01-30 11:36:13 +0000
committerwei <>2007-01-30 11:36:13 +0000
commit7fa1200b5e589a47884aa4d62630ce9099fccee1 (patch)
tree739e307440b4fccf3125ab11719dc09fccefed41 /demos/quickstart/protected/pages
parentfcb45e6479d4c13084c8033e543e0c1fdeead8e5 (diff)
Add basic Scaffold view for Active Record
Diffstat (limited to 'demos/quickstart/protected/pages')
-rw-r--r--demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page7
-rw-r--r--demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php33
-rw-r--r--demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.dbbin0 -> 4096 bytes
-rw-r--r--demos/quickstart/protected/pages/Database/Samples/config.xml5
-rw-r--r--demos/quickstart/protected/pages/Database/Scaffold.page99
5 files changed, 144 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page
new file mode 100644
index 00000000..21f508f7
--- /dev/null
+++ b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page
@@ -0,0 +1,7 @@
+<com:TContent ID="body" >
+
+<h1>Active Record Scaffold Example</h1>
+
+<com:TScaffoldView RecordClass="AddressRecord" />
+
+</com:TContent>
diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php
new file mode 100644
index 00000000..9bfe3f6d
--- /dev/null
+++ b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php
@@ -0,0 +1,33 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+Prado::using('System.Data.ActiveRecord.Scaffold.TScaffoldView');
+
+class AddressRecord extends TActiveRecord
+{
+ public $id;
+ public $username;
+ public $phone;
+
+ public static $_tablename='addresses';
+
+ //for demo, we use static db here
+ //otherwise we should use TActiveRecordConfig in application.xml
+ private static $_db;
+ public function getDbConnection()
+ {
+ if(self::$_db===null)
+ {
+ $file = dirname(__FILE__).'/sqlite.db';
+ self::$_db = new TDbConnection("sqlite:{$file}");
+ }
+ return self::$_db;
+ }
+}
+
+class Home extends TPage
+{
+
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db b/demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db
new file mode 100644
index 00000000..65d77a66
--- /dev/null
+++ b/demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db
Binary files differ
diff --git a/demos/quickstart/protected/pages/Database/Samples/config.xml b/demos/quickstart/protected/pages/Database/Samples/config.xml
new file mode 100644
index 00000000..51da9ed0
--- /dev/null
+++ b/demos/quickstart/protected/pages/Database/Samples/config.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+ <pages MasterClass="SampleLayout" />
+</configuration> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Database/Scaffold.page b/demos/quickstart/protected/pages/Database/Scaffold.page
new file mode 100644
index 00000000..36a0ec21
--- /dev/null
+++ b/demos/quickstart/protected/pages/Database/Scaffold.page
@@ -0,0 +1,99 @@
+<com:TContent ID="body" >
+<!-- $Id$ -->
+<h1>Active Record Scaffold Views</h1>
+<p><a href="?page=Database.ActiveRecord">Active Record</a> classes can be used together with
+<com:DocLink ClassPath="System.Data.ActiveRecord.Scaffold.TScaffoldListView" Text="TScaffoldListView"/>
+and
+<com:DocLink ClassPath="System.Data.ActiveRecord.Scaffold.TScaffoldEditView" Text="TScaffoldEditView"/>
+( <com:DocLink ClassPath="System.Data.ActiveRecord.Scaffold.TScaffoldView" Text="TScaffoldView"/>
+links both <tt>TScaffoldListView</tt> and <tt>TScaffoldEditView</tt>) to create
+<i>simple</i> Create/Read/Update/Delete (CRUD) web applications.</p>
+
+<p>The scaffold views are intended to assist in prototyping web application,
+they are not designed to be as customiziable as more complex components such as
+<a href="?page=Controls.DataGrid">TDataGrid</a>. The scaffold views provide
+the following builtin functionality:
+</p>
+
+<ul>
+ <li>Listing of all active record items.</li>
+ <li>Paging and sorting.</li>
+ <li>Deleting an item.</li>
+ <li>Inserting a new item.</li>
+ <li>Updating an existing item.</li>
+ <li>Validates required fields and basic data types.</li>
+ <li>Presents specialized controls such as date pickers.</li>
+</ul>
+
+<p>Scaffold views are dependent on Active Records and currently supports
+the following databases: Mysql, Sqlite and Postgres SQL. Support for other databases
+can be considered when there are sufficient demand.</p>
+
+<h2>Setting up a Scaffold View</h2>
+<p>To use the scaffold view, we first define an <a href="?page=Database.ActiveRecord">Active Record</a>
+class that represents a table or view in the database. Consider the following
+Active Record class that corresponds to the <tt>users</tt>
+table as defined in the <a href="?page=Database.ActiveRecord">Active Record</a> quickstart page.
+</p>
+
+<com:TTextHighlighter Language="php" CssClass="source">
+class UserRecord extends TActiveRecord
+{
+ public $username;
+ public $email;
+
+ public static $_tablename='users';
+}
+</com:TTextHighlighter>
+
+<p>The scaffold view classes are in the <tt>System.Data.ActiveRecord.Scaffold.*</tt>
+<a href="?page=Fundamentals.Components#704">namespace</a>.
+This <a href="?page=Fundamentals.Components#704">namespace</a> can be "imported" in the
+<a href="?page=Configurations.AppConfig">Application Configuration</a>
+using the <tt>application.xml</tt> file or through the php code using the <tt>Prado::using()</tt>
+method. The simplest way to provide CRUD functional is to use the
+<com:DocLink ClassPath="System.Data.ActiveRecord.Scaffold.TScaffoldView" Text="TScaffoldView"/>
+where the <tt>RecordClass</tt> property value equals to an Active Record
+class name.
+</p>
+
+<com:TTextHighlighter Language="prado" CssClass="source">
+&lt;com:TScaffoldView RecordClass="UserRecord" /&gt;
+</com:TTextHighlighter>
+
+<h2>Todo...</h2>
+
+<p>Other views... list view</p>
+
+<com:TTextHighlighter Language="prado" CssClass="source">
+&lt;com:TScaffoldListView RecordClass="UserRecord" /&gt;
+</com:TTextHighlighter>
+
+<p>edit view...</p>
+<com:TTextHighlighter Language="prado" CssClass="source">
+&lt;com:TScaffoldEditView RecordPk="user1" RecordClass="UserRecord" /&gt;
+</com:TTextHighlighter>
+
+<p>Combining list + edit views</p>
+
+<com:TTextHighlighter Language="prado" CssClass="source">
+&lt;com:TScaffoldEditView ID="edit_view" RecordClass="UserRecord" /&gt;
+&lt;com:TScaffoldListView EditViewID="edit_view" RecordClass="UserRecord" /&gt;
+</com:TTextHighlighter>
+
+<p>custom list view...</p>
+<com:TTextHighlighter Language="prado" CssClass="source">
+&lt;com:TScaffoldView RecordClass="UserRecord" &gt;
+ &lt;prop:ListView.List.ItemTemplate&gt;
+ &lt;%# $this->DataItem->username %&gt;
+ &lt;com:TLinkButton Text="Edit" CommandName="edit" /&gt;
+ &lt;/prop:ListView.List.ItemTemplate&gt;
+&lt;/com:TScaffoldView/&gt;
+</com:TTextHighlighter>
+<p>To be completed...</p>
+
+<p>Address book example...</p>
+
+<com:RunBar PagePath="Database.Samples.Scaffold.Home" />
+
+<div class="last-modified">$Id$</div></com:TContent> \ No newline at end of file