summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2005-11-16 13:33:17 +0000
committerxue <>2005-11-16 13:33:17 +0000
commit749dec2fcae7b8cdd86ecc923b1af3abfadbcde2 (patch)
treeb31617a60b7884ce6a7292896c5b7b17cdbf9754
parentf5294995a9324d8e748b2f5520fb43675d1e54fe (diff)
-rw-r--r--.gitattributes15
-rw-r--r--demos/personal/index.php8
-rw-r--r--demos/personal/protected/application.cachebin0 -> 3881 bytes
-rw-r--r--demos/personal/protected/application.xml30
-rw-r--r--demos/personal/protected/data/DataModule.php120
-rw-r--r--demos/personal/protected/data/site.dbbin0 -> 3072 bytes
-rw-r--r--demos/personal/protected/pages/HomePage.php21
-rw-r--r--demos/personal/protected/pages/HomePage.tpl3
-rw-r--r--demos/personal/protected/pages/Layout.php7
-rw-r--r--demos/personal/protected/pages/Layout.tpl27
-rw-r--r--demos/personal/protected/pages/LoginPage.php15
-rw-r--r--demos/personal/protected/pages/LoginPage.tpl7
-rw-r--r--demos/personal/protected/pages/config.xml8
-rw-r--r--demos/personal/themes/BlueTheme/buttons.skin3
-rw-r--r--demos/personal/themes/BlueTheme/icon_profile.gifbin0 -> 771 bytes
-rw-r--r--demos/personal/themes/BlueTheme/labels.skin2
16 files changed, 266 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
index c90c894b..4099a14c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -16,6 +16,21 @@ demos/controls/protected/pages/private/config.xml -text
demos/controls/themes/BlueTheme/buttons.skin -text
demos/controls/themes/BlueTheme/icon_profile.gif -text
demos/controls/themes/BlueTheme/labels.skin -text
+demos/personal/index.php -text
+demos/personal/protected/application.cache -text
+demos/personal/protected/application.xml -text
+demos/personal/protected/data/DataModule.php -text
+demos/personal/protected/data/site.db -text
+demos/personal/protected/pages/HomePage.php -text
+demos/personal/protected/pages/HomePage.tpl -text
+demos/personal/protected/pages/Layout.php -text
+demos/personal/protected/pages/Layout.tpl -text
+demos/personal/protected/pages/LoginPage.php -text
+demos/personal/protected/pages/LoginPage.tpl -text
+demos/personal/protected/pages/config.xml -text
+demos/personal/themes/BlueTheme/buttons.skin -text
+demos/personal/themes/BlueTheme/icon_profile.gif -text
+demos/personal/themes/BlueTheme/labels.skin -text
docs/conceptual-structure.vsd -text
docs/request-sequence.vsd -text
framework/.htaccess -text
diff --git a/demos/personal/index.php b/demos/personal/index.php
new file mode 100644
index 00000000..d5f7caf3
--- /dev/null
+++ b/demos/personal/index.php
@@ -0,0 +1,8 @@
+<?php
+
+require_once(dirname(__FILE__).'/../../framework/prado.php');
+
+$application=new TApplication(dirname(__FILE__).'/protected/application.xml',dirname(__FILE__).'/protected/application.cache');
+$application->run();
+
+?> \ No newline at end of file
diff --git a/demos/personal/protected/application.cache b/demos/personal/protected/application.cache
new file mode 100644
index 00000000..34dbc18b
--- /dev/null
+++ b/demos/personal/protected/application.cache
Binary files differ
diff --git a/demos/personal/protected/application.xml b/demos/personal/protected/application.xml
new file mode 100644
index 00000000..260f26c7
--- /dev/null
+++ b/demos/personal/protected/application.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+ <paths>
+ <alias id="Application" path="." />
+ <alias id="Pages" path="pages" />
+ </paths>
+ <!-- modules configured and loaded for all services -->
+ <modules>
+ <!-- make sure the path "protected" is writable by web server process if you enable this cache
+ <module id="cache" type="System.Data.TSqliteCache" DbFile="Demo.cache"/>
+ -->
+ <module id="session" type="THttpSession" />
+ </modules>
+ <services>
+ <!-- page service, BasePath is required -->
+ <service id="page" BasePath="Pages" DefaultPage="home">
+ <!-- modules configured and loaded when page service is requested -->
+ <modules>
+ <!-- user manager module -->
+ <module id="users" type="System.Security.TUserManager" PasswordMode="Clear">
+ <user name="demo" password="demo" />
+ </module>
+ <!-- auth manager module -->
+ <module id="auth" type="System.Security.TAuthManager" UserManager="users" LoginPage="login" />
+ <module id="data" type="Application.data.DataModule" />
+ </modules>
+ </service>
+ </services>
+</configuration> \ No newline at end of file
diff --git a/demos/personal/protected/data/DataModule.php b/demos/personal/protected/data/DataModule.php
new file mode 100644
index 00000000..03ee3496
--- /dev/null
+++ b/demos/personal/protected/data/DataModule.php
@@ -0,0 +1,120 @@
+<?php
+
+class DataModule extends TComponent implements IModule
+{
+ /**
+ * extension of the db file name
+ */
+ const DB_FILE_EXT='.db';
+ const DB_SCHEMA='
+ CREATE TABLE tblBlogs (id INTEGER PRIMARY KEY, title VARCHAR(256), content TEXT, lastupdate INTEGER, author VARCHAR(64));
+ CREATE TABLE tblComments (id INTEGER PRIMARY KEY, bid INTEGER, content TEXT, lastupdate INTEGER, author VARCHAR(64), email VARCHAR(64), option INTEGER);
+ ';
+ /**
+ * @var string id of this module
+ */
+ private $_id='';
+ private $_file='Application.data.site';
+ /**
+ * @var SQLiteDatabase the sqlite database instance
+ */
+ private $_db=null;
+ private $_initialized=false;
+
+ /**
+ * Destructor.
+ * Disconnect the db connection.
+ */
+ public function __destruct()
+ {
+ $this->_db=null;
+ parent::__destruct();
+ }
+
+ /**
+ * Initializes this module.
+ * This method is required by the IModule interface. It checks if the DbFile
+ * property is set, and creates a SQLiteDatabase instance for it.
+ * If the database or the tables do not exist, they will be created.
+ * @param IApplication Prado application, can be null
+ * @param TXmlElement configuration for this module, can be null
+ * @throws TConfigurationException DbFile is set invalid
+ */
+ public function init($application,$config)
+ {
+ if(!function_exists('sqlite_open'))
+ throw new TConfigurationException('SQLite extension required.');
+ if($this->_file===null)
+ throw new TConfigurationException('SQLite db file required.');
+ if(($fname=Prado::getPathOfNamespace($this->_file,self::DB_FILE_EXT))===null)
+ throw new TConfigurationException('SQLite db file invalid: '.$this->_file);
+ $error='';
+ if(($this->_db=new SQLiteDatabase($fname,0666,$error))===false)
+ throw new TConfigurationException('SQLite db connection failed: ',$error);
+ $res=$this->_db->query('SELECT * FROM sqlite_master WHERE tbl_name=\'tblBlogs\' AND type=\'table\'');
+ if($res===false || $res->numRows()===0 && $this->_db->query(self::DB_SCHEMA)===false)
+ throw new TConfigurationException('SQLite db table creation failed: '.sqlite_error_string(sqlite_last_error()));
+ $this->_initialized=true;
+ }
+
+ /**
+ * @return string id of this module
+ */
+ public function getID()
+ {
+ return $this->_id;
+ }
+
+ /**
+ * @param string id of this module
+ */
+ public function setID($value)
+ {
+ $this->_id=$value;
+ }
+
+ /**
+ * @return string database file path (in namespace form)
+ */
+ public function getDbFile()
+ {
+ return $this->_file;
+ }
+
+ /**
+ * @param string database file path (in namespace form)
+ * @throws TInvalidOperationException if the module is already initialized
+ */
+ public function setDbFile($value)
+ {
+ if($this->_initialized)
+ throw new TInvalidOperationException('DbFile cannot be modified after the module is initialized.');
+ else
+ $this->_file=$value;
+ }
+
+ public function getBlogsByTime($time)
+ {
+ }
+}
+
+class Blog
+{
+ public $id;
+ public $title;
+ public $author;
+ public $content;
+ public $lastupdate;
+ public $comments;
+}
+
+class Comment
+{
+ public $id;
+ public $bid;
+ public $author;
+ public $content;
+ public $lastupdate;
+}
+
+?> \ No newline at end of file
diff --git a/demos/personal/protected/data/site.db b/demos/personal/protected/data/site.db
new file mode 100644
index 00000000..896c452d
--- /dev/null
+++ b/demos/personal/protected/data/site.db
Binary files differ
diff --git a/demos/personal/protected/pages/HomePage.php b/demos/personal/protected/pages/HomePage.php
new file mode 100644
index 00000000..6c69e44b
--- /dev/null
+++ b/demos/personal/protected/pages/HomePage.php
@@ -0,0 +1,21 @@
+<?php
+
+class HomePage extends TPage
+{
+ public function onPreInit($param)
+ {
+ parent::onPreInit($param);
+ if(!$this->getUser()->getIsGuest())
+ $this->setTheme('');
+ }
+
+ public function testClick($sender,$param)
+ {
+ if($sender->BackColor==='')
+ $sender->BackColor='blue';
+ else
+ $sender->BackColor='';
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/personal/protected/pages/HomePage.tpl b/demos/personal/protected/pages/HomePage.tpl
new file mode 100644
index 00000000..9471a9b9
--- /dev/null
+++ b/demos/personal/protected/pages/HomePage.tpl
@@ -0,0 +1,3 @@
+<com:TContent ID="main" >
+main content
+</com:TContent> \ No newline at end of file
diff --git a/demos/personal/protected/pages/Layout.php b/demos/personal/protected/pages/Layout.php
new file mode 100644
index 00000000..ba96038b
--- /dev/null
+++ b/demos/personal/protected/pages/Layout.php
@@ -0,0 +1,7 @@
+<?php
+
+class Layout extends TTemplateControl
+{
+}
+
+?> \ No newline at end of file
diff --git a/demos/personal/protected/pages/Layout.tpl b/demos/personal/protected/pages/Layout.tpl
new file mode 100644
index 00000000..500abf3b
--- /dev/null
+++ b/demos/personal/protected/pages/Layout.tpl
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
+<head>
+<title>My Personal Website</title>
+</head>
+<body>
+<com:TForm>
+<div class="header">
+ <h1>Your Name Here</h1>
+ <h2>My Personal Site</h2>
+ <div class="nav">
+ <a href="?sp=page.home">HOME</a> |
+ <a href="?sp=page.resume">RESUME</a> |
+ <a href="?sp=page.links">LINKS</a> |
+ <a href="?sp=page.albums">ALBUMS</a> |
+ <a href="?sp=page.login">LOGIN</a>
+ </div>
+</div>
+<com:TContentPlaceHolder ID="main" />
+<div class="footer">
+ Copyright &copy; 2005 Your Name here.<br/>
+ Powered by <a href="http://www.pradosoft.com/">PRADO</a>.
+</div>
+</com:TForm>
+</body>
+</html> \ No newline at end of file
diff --git a/demos/personal/protected/pages/LoginPage.php b/demos/personal/protected/pages/LoginPage.php
new file mode 100644
index 00000000..3a3b8432
--- /dev/null
+++ b/demos/personal/protected/pages/LoginPage.php
@@ -0,0 +1,15 @@
+<?php
+
+class LoginPage extends TPage
+{
+ public function login($sender,$param)
+ {
+ $manager=$this->Application->AuthManager;
+ if($manager->login($this->username->Text,$this->password->Text))
+ $this->Application->Response->redirect($this->Application->Request->Items['ReturnUrl']);
+ else
+ $this->error->Text='login failed';
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/personal/protected/pages/LoginPage.tpl b/demos/personal/protected/pages/LoginPage.tpl
new file mode 100644
index 00000000..588b8f6a
--- /dev/null
+++ b/demos/personal/protected/pages/LoginPage.tpl
@@ -0,0 +1,7 @@
+<com:TContent ID="main" >
+Username: <com:TTextBox ID="username" /><br/>
+Password: <com:TTextBox ID="password" TextMode="Password" /><br/>
+<com:TButton Text="Login" Click="login" />
+<com:TLabel ID="error" />
+</com:TContent>
+
diff --git a/demos/personal/protected/pages/config.xml b/demos/personal/protected/pages/config.xml
new file mode 100644
index 00000000..b3d6b036
--- /dev/null
+++ b/demos/personal/protected/pages/config.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+ <pages MasterClass="Pages.Layout">
+ <page id="home" type="HomePage" />
+ <page id="login" type="LoginPage" />
+ </pages>
+</configuration> \ No newline at end of file
diff --git a/demos/personal/themes/BlueTheme/buttons.skin b/demos/personal/themes/BlueTheme/buttons.skin
new file mode 100644
index 00000000..8db810bc
--- /dev/null
+++ b/demos/personal/themes/BlueTheme/buttons.skin
@@ -0,0 +1,3 @@
+<com:TButton BackColor="blue" ForeColor="red" Font.Size="18px" />
+<com:TButton SkinID="abc" BackColor="red" ForeColor="blue" />
+<com:TImageButton ImageUrl=<%~/icon_profile.gif%> /> \ No newline at end of file
diff --git a/demos/personal/themes/BlueTheme/icon_profile.gif b/demos/personal/themes/BlueTheme/icon_profile.gif
new file mode 100644
index 00000000..7ae1cdb8
--- /dev/null
+++ b/demos/personal/themes/BlueTheme/icon_profile.gif
Binary files differ
diff --git a/demos/personal/themes/BlueTheme/labels.skin b/demos/personal/themes/BlueTheme/labels.skin
new file mode 100644
index 00000000..64a8c469
--- /dev/null
+++ b/demos/personal/themes/BlueTheme/labels.skin
@@ -0,0 +1,2 @@
+<com:TLabel BackColor="blue" ForeColor="red" />
+<com:TLabel SkinID="abc" BackColor="red" ForeColor="blue" /> \ No newline at end of file