From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001
From: ctrlaltca <>
Date: Thu, 12 Jul 2012 11:21:01 +0000
Subject: standardize the use of unix eol; use svn properties to enforce native
eol
---
demos/address-book/index.php | 52 +-
.../protected/pages/AddressProvider.php | 96 +-
.../address-book/protected/pages/AddressRecord.php | 68 +-
demos/address-book/protected/pages/FlexApp.php | 226 ++--
.../protected/pages/flex/bin/AC_OETags.js | 538 ++++----
.../protected/pages/flex/bin/history.js | 96 +-
.../pages/flex/html-template/AC_OETags.js | 538 ++++----
.../protected/pages/flex/html-template/history.js | 96 +-
demos/blog-tutorial/index.php | 34 +-
demos/blog-tutorial/protected/common/InfoBox.php | 24 +-
demos/blog-tutorial/protected/common/NoteBox.php | 24 +-
demos/blog-tutorial/protected/common/TipBox.php | 24 +-
demos/blog-tutorial/protected/common/TopicList.php | 14 +-
.../blog-tutorial/protected/layout/MainLayout.php | 12 +-
demos/blog-tutorial/samples/day1/blog/index.php | 42 +-
.../day1/blog/protected/layouts/MainLayout.php | 12 +-
.../samples/day1/blog/protected/pages/Contact.php | 58 +-
demos/blog-tutorial/samples/day2/blog/index.php | 42 +-
.../day2/blog/protected/database/PostRecord.php | 54 +-
.../day2/blog/protected/database/UserRecord.php | 54 +-
.../day2/blog/protected/layouts/MainLayout.php | 12 +-
.../samples/day2/blog/protected/pages/Contact.php | 58 +-
demos/blog-tutorial/samples/day3/blog/index.php | 42 +-
.../samples/day3/blog/protected/BlogUser.php | 116 +-
.../day3/blog/protected/database/PostRecord.php | 54 +-
.../day3/blog/protected/database/UserRecord.php | 54 +-
.../day3/blog/protected/layouts/MainLayout.php | 36 +-
.../samples/day3/blog/protected/pages/Contact.php | 58 +-
.../day3/blog/protected/pages/users/AdminUser.php | 70 +-
.../day3/blog/protected/pages/users/EditUser.php | 164 +--
.../day3/blog/protected/pages/users/LoginUser.php | 72 +-
.../day3/blog/protected/pages/users/NewUser.php | 88 +-
demos/blog-tutorial/samples/day4/blog/index.php | 42 +-
.../samples/day4/blog/protected/BlogUser.php | 116 +-
.../day4/blog/protected/database/PostRecord.php | 54 +-
.../day4/blog/protected/database/UserRecord.php | 54 +-
.../day4/blog/protected/layouts/MainLayout.php | 36 +-
.../samples/day4/blog/protected/pages/Contact.php | 58 +-
.../day4/blog/protected/pages/posts/EditPost.php | 142 +-
.../day4/blog/protected/pages/posts/ListPost.php | 126 +-
.../day4/blog/protected/pages/posts/NewPost.php | 66 +-
.../blog/protected/pages/posts/PostRenderer.php | 12 +-
.../day4/blog/protected/pages/posts/ReadPost.php | 112 +-
.../day4/blog/protected/pages/users/AdminUser.php | 70 +-
.../day4/blog/protected/pages/users/EditUser.php | 164 +--
.../day4/blog/protected/pages/users/LoginUser.php | 72 +-
.../day4/blog/protected/pages/users/NewUser.php | 88 +-
demos/blog-tutorial/samples/day5/blog/index.php | 42 +-
.../day5/blog/protected/BlogErrorHandler.php | 78 +-
.../samples/day5/blog/protected/BlogException.php | 12 +-
.../samples/day5/blog/protected/BlogUser.php | 116 +-
.../day5/blog/protected/database/PostRecord.php | 54 +-
.../day5/blog/protected/database/UserRecord.php | 54 +-
.../day5/blog/protected/layouts/MainLayout.php | 36 +-
.../samples/day5/blog/protected/pages/Contact.php | 58 +-
.../day5/blog/protected/pages/posts/EditPost.php | 142 +-
.../day5/blog/protected/pages/posts/ListPost.php | 126 +-
.../day5/blog/protected/pages/posts/NewPost.php | 66 +-
.../blog/protected/pages/posts/PostRenderer.php | 12 +-
.../day5/blog/protected/pages/posts/ReadPost.php | 116 +-
.../day5/blog/protected/pages/users/AdminUser.php | 70 +-
.../day5/blog/protected/pages/users/EditUser.php | 164 +--
.../day5/blog/protected/pages/users/LoginUser.php | 72 +-
.../day5/blog/protected/pages/users/NewUser.php | 88 +-
demos/blog/index.php | 40 +-
demos/blog/protected/Common/BlogDataModule.php | 1414 ++++++++++----------
demos/blog/protected/Common/BlogErrorHandler.php | 90 +-
demos/blog/protected/Common/BlogException.php | 60 +-
demos/blog/protected/Common/BlogPage.php | 96 +-
demos/blog/protected/Common/BlogUser.php | 118 +-
demos/blog/protected/Common/BlogUserManager.php | 188 +--
demos/blog/protected/Common/XListMenu.php | 252 ++--
demos/blog/protected/Layouts/MainLayout.php | 46 +-
demos/blog/protected/Pages/Admin/AdminMenu.php | 46 +-
demos/blog/protected/Pages/Admin/ConfigMan.php | 152 +--
demos/blog/protected/Pages/Admin/PostMan.php | 144 +-
demos/blog/protected/Pages/Admin/UserMan.php | 148 +-
demos/blog/protected/Pages/ErrorReport.php | 56 +-
demos/blog/protected/Pages/Posts/EditCategory.php | 120 +-
demos/blog/protected/Pages/Posts/EditPost.php | 154 +--
demos/blog/protected/Pages/Posts/ListPost.php | 282 ++--
demos/blog/protected/Pages/Posts/MyPost.php | 100 +-
demos/blog/protected/Pages/Posts/NewCategory.php | 80 +-
demos/blog/protected/Pages/Posts/NewPost.php | 112 +-
demos/blog/protected/Pages/Posts/ViewPost.php | 178 +--
demos/blog/protected/Pages/SearchPost.php | 134 +-
demos/blog/protected/Pages/Users/EditUser.php | 136 +-
demos/blog/protected/Pages/Users/NewUser.php | 114 +-
demos/blog/protected/Pages/Users/ViewUser.php | 82 +-
demos/blog/protected/Portlets/AccountPortlet.php | 60 +-
demos/blog/protected/Portlets/ArchivePortlet.php | 122 +-
demos/blog/protected/Portlets/CategoryPortlet.php | 74 +-
demos/blog/protected/Portlets/CommentPortlet.php | 78 +-
demos/blog/protected/Portlets/LoginPortlet.php | 76 +-
demos/blog/protected/Portlets/Portlet.php | 46 +-
demos/blog/protected/Portlets/SearchPortlet.php | 76 +-
demos/chat/index.php | 56 +-
demos/chat/protected/App_Code/ChatBufferRecord.php | 126 +-
demos/chat/protected/App_Code/ChatUserManager.php | 168 +--
demos/chat/protected/App_Code/ChatUserRecord.php | 80 +-
demos/chat/protected/pages/Home.php | 110 +-
demos/chat/protected/pages/Login.php | 78 +-
demos/composer/index.php | 34 +-
demos/composer/index2.php | 34 +-
demos/composer/protected/pages/ClassDefinition.php | 740 +++++-----
demos/composer/protected/pages/Home.php | 234 ++--
demos/composer/protected/pages/Layout.php | 28 +-
demos/helloworld/index.php | 34 +-
demos/helloworld/protected/pages/Home.php | 20 +-
demos/northwind-db/index.php | 54 +-
demos/northwind-db/protected/database/Category.php | 50 +-
demos/northwind-db/protected/database/Customer.php | 64 +-
demos/northwind-db/protected/database/Employee.php | 94 +-
demos/northwind-db/protected/database/Order.php | 82 +-
.../protected/database/OrderDetail.php | 52 +-
demos/northwind-db/protected/database/Product.php | 70 +-
demos/northwind-db/protected/database/Region.php | 48 +-
demos/northwind-db/protected/database/Shipper.php | 48 +-
demos/northwind-db/protected/database/Supplier.php | 66 +-
.../northwind-db/protected/database/Territory.php | 118 +-
.../northwind-db/protected/pages/NorthwindCrud.php | 54 +-
demos/personal/index.php | 28 +-
demos/personal/protected/Common/LoginPortlet.php | 36 +-
demos/personal/protected/Common/MainMenu.php | 22 +-
demos/personal/protected/Pages/Layout.php | 12 +-
demos/personal/protected/Pages/Register.php | 36 +-
demos/quickstart/index.php | 34 +-
demos/quickstart/index2.php | 34 +-
.../protected/QuickStartGlobalization.php | 60 +-
.../protected/controls/Comments/CommentBlock.php | 212 +--
.../protected/controls/Comments/comments.js | 412 +++---
demos/quickstart/protected/controls/DocLink.php | 60 +-
demos/quickstart/protected/controls/Layout.php | 94 +-
.../protected/controls/RequiresVersion.php | 30 +-
demos/quickstart/protected/controls/RunBar.php | 44 +-
.../quickstart/protected/controls/SampleLayout.php | 24 +-
demos/quickstart/protected/controls/SearchBox.php | 80 +-
.../quickstart/protected/controls/SinceVersion.php | 30 +-
demos/quickstart/protected/controls/TopicList.php | 14 +-
demos/quickstart/protected/index/ZendSearch.php | 108 +-
.../ActiveControls/Samples/TActiveButton/Home.php | 38 +-
.../Samples/TActiveCheckBox/Home.php | 30 +-
.../Samples/TActiveCheckBoxList/Home.php | 50 +-
.../Samples/TActiveCustomValidator/Home.php | 20 +-
.../Samples/TActiveDataGrid/Sample1.php | 72 +-
.../Samples/TActiveDataGrid/Sample2.php | 170 +--
.../Samples/TActiveDataGrid/Sample3.php | 378 +++---
.../Samples/TActiveDataGrid/Sample4.php | 40 +-
.../Samples/TActiveDataGrid/Sample5.php | 156 +--
.../Samples/TActiveDataList/Home.php | 262 ++--
.../Samples/TActiveDropDownList/Home.php | 118 +-
.../Samples/TActiveFileUpload/Home.php | 40 +-
.../Samples/TActiveHyperLink/Home.php | 50 +-
.../ActiveControls/Samples/TActiveImage/Home.php | 32 +-
.../Samples/TActiveImageButton/Home.php | 34 +-
.../Samples/TActiveLinkButton/Home.php | 26 +-
.../ActiveControls/Samples/TActiveListBox/Home.php | 128 +-
.../Samples/TActiveMultiView/Home.php | 28 +-
.../ActiveControls/Samples/TActivePanel/Home.php | 40 +-
.../Samples/TActiveRadioButton/Home.php | 52 +-
.../Samples/TActiveRadioButtonList/Home.php | 50 +-
.../Samples/TActiveRepeater/Home.php | 156 +--
.../Samples/TActiveTableRow/Home.php | 42 +-
.../ActiveControls/Samples/TAutoComplete/Home.php | 68 +-
.../Samples/TCallbackClientScript/Home.php | 56 +-
.../Samples/TCallbackClientSide/Home.php | 22 +-
.../Samples/TCallbackOptions/Home.php | 22 +-
.../protected/pages/Advanced/Samples/I18N/Home.php | 88 +-
.../pages/Advanced/Samples/I18N/LanguageList.php | 36 +-
.../Controls/Samples/LabeledTextBox1/Home.php | 24 +-
.../Samples/LabeledTextBox1/LabeledTextBox.php | 34 +-
.../Controls/Samples/LabeledTextBox2/Home.php | 24 +-
.../Samples/LabeledTextBox2/LabeledTextBox.php | 64 +-
.../Controls/Samples/ResetValidation/Home.php | 14 +-
.../pages/Controls/Samples/TAccordion/Home.php | 32 +-
.../pages/Controls/Samples/TBulletedList/Home.php | 22 +-
.../pages/Controls/Samples/TButton/Home.php | 26 +-
.../pages/Controls/Samples/TCaptcha/Home.php | 52 +-
.../pages/Controls/Samples/TCheckBox/Home.php | 20 +-
.../pages/Controls/Samples/TCheckBoxList/Home.php | 138 +-
.../Controls/Samples/TClientSideValidator/Home.php | 32 +-
.../Controls/Samples/TCompareValidator/Home.php | 14 +-
.../pages/Controls/Samples/TConditional/Home.php | 12 +-
.../Controls/Samples/TCustomValidator/Home.php | 34 +-
.../pages/Controls/Samples/TDataGrid/Sample1.php | 80 +-
.../pages/Controls/Samples/TDataGrid/Sample2.php | 170 +--
.../pages/Controls/Samples/TDataGrid/Sample3.php | 378 +++---
.../pages/Controls/Samples/TDataGrid/Sample4.php | 40 +-
.../pages/Controls/Samples/TDataGrid/Sample5.php | 134 +-
.../pages/Controls/Samples/TDataGrid/Sample6.php | 110 +-
.../pages/Controls/Samples/TDataList/Sample1.php | 80 +-
.../pages/Controls/Samples/TDataList/Sample2.php | 262 ++--
.../Controls/Samples/TDataTypeValidator/Home.php | 14 +-
.../pages/Controls/Samples/TDropDownList/Home.php | 136 +-
.../Samples/TEmailAddressValidator/Home.php | 14 +-
.../pages/Controls/Samples/TFileUpload/Home.php | 40 +-
.../pages/Controls/Samples/THtmlArea/Home.php | 40 +-
.../pages/Controls/Samples/TImageButton/Home.php | 34 +-
.../pages/Controls/Samples/TImageMap/Home.php | 20 +-
.../pages/Controls/Samples/TKeyboard/Home.php | 20 +-
.../pages/Controls/Samples/TLinkButton/Home.php | 26 +-
.../pages/Controls/Samples/TListBox/Home.php | 156 +--
.../pages/Controls/Samples/TMultiView/Home.php | 28 +-
.../pages/Controls/Samples/TPager/Sample1.php | 162 +--
.../pages/Controls/Samples/TPanel/Home.php | 20 +-
.../pages/Controls/Samples/TPlaceHolder/Home.php | 30 +-
.../pages/Controls/Samples/TRadioButton/Home.php | 52 +-
.../Controls/Samples/TRadioButtonList/Home.php | 136 +-
.../Controls/Samples/TRangeValidator/Home.php | 14 +-
.../Samples/TRegularExpressionValidator/Home.php | 14 +-
.../Controls/Samples/TRepeater/RegionDisplay.php | 54 +-
.../pages/Controls/Samples/TRepeater/Sample1.php | 80 +-
.../pages/Controls/Samples/TRepeater/Sample2.php | 156 +--
.../pages/Controls/Samples/TRepeater/Sample3.php | 156 +--
.../pages/Controls/Samples/TRepeater/Sample4.php | 72 +-
.../pages/Controls/Samples/TRepeater/Sample5.php | 102 +-
.../Samples/TRequiredFieldValidator/Home.php | 14 +-
.../pages/Controls/Samples/TSlider/Home.php | 8 +-
.../pages/Controls/Samples/TTabPanel/Home.php | 12 +-
.../pages/Controls/Samples/TTable/Home.php | 64 +-
.../pages/Controls/Samples/TTextBox/Home.php | 42 +-
.../Controls/Samples/TValidationSummary/Home.php | 14 +-
.../pages/Controls/Samples/TWizard/Sample1.php | 20 +-
.../pages/Controls/Samples/TWizard/Sample2.php | 20 +-
.../pages/Controls/Samples/TWizard/Sample3.php | 48 +-
.../pages/Controls/Samples/TWizard/Sample4.php | 20 +-
.../pages/Controls/Samples/TWizard/Sample5.php | 22 +-
.../pages/Database/Samples/Scaffold/Home.php | 64 +-
.../pages/Fundamentals/Samples/Hangman/Home.php | 240 ++--
demos/quickstart/protected/pages/Search.php | 110 +-
demos/quickstart/protected/pages/ViewSource.php | 222 +--
demos/sqlmap/index.php | 38 +-
demos/sqlmap/protected/APP_CODE/Person.php | 50 +-
demos/sqlmap/protected/pages/Manual/Layout.php | 12 +-
demos/sqlmap/protected/pages/Manual/TopicList.php | 14 +-
demos/sqlmap/protected/pages/Sample/crud1.php | 40 +-
demos/sqlmap/protected/pages/Sample/crud2.php | 154 +--
demos/time-tracker/index.php | 68 +-
.../protected/App_Code/Dao/BaseDao.php | 88 +-
.../protected/App_Code/Dao/CategoryDao.php | 104 +-
.../protected/App_Code/Dao/CategoryRecord.php | 24 +-
.../protected/App_Code/Dao/ProjectDao.php | 208 +--
.../protected/App_Code/Dao/ProjectRecord.php | 68 +-
.../protected/App_Code/Dao/ReportsDao.php | 172 +--
.../protected/App_Code/Dao/TimeEntryDao.php | 74 +-
.../protected/App_Code/Dao/TimeEntryRecord.php | 30 +-
.../protected/App_Code/Dao/UserDao.php | 328 ++---
.../time-tracker/protected/App_Code/DaoManager.php | 156 +--
.../protected/App_Code/TimeTrackerException.php | 64 +-
.../protected/App_Code/TimeTrackerUser.php | 94 +-
.../protected/App_Code/TrackerAuthManager.php | 168 +--
.../protected/App_Code/UserManager.php | 178 +--
.../protected/App_Data/DateTimeTypeHandler.php | 68 +-
.../App_Data/TimeTrackerUserTypeHandler.php | 106 +-
.../pages/TimeTracker/CategoryDataList.php | 186 +--
.../protected/pages/TimeTracker/LogTimeEntry.php | 222 +--
.../protected/pages/TimeTracker/Login.php | 108 +-
.../protected/pages/TimeTracker/Logout.php | 66 +-
.../protected/pages/TimeTracker/MainLayout.php | 12 +-
.../protected/pages/TimeTracker/ProjectDetails.php | 380 +++---
.../protected/pages/TimeTracker/ProjectList.php | 66 +-
.../protected/pages/TimeTracker/ReportProject.php | 104 +-
.../protected/pages/TimeTracker/ReportResource.php | 140 +-
.../protected/pages/TimeTracker/SiteMap.php | 112 +-
.../protected/pages/TimeTracker/TimeEntryList.php | 176 +--
.../protected/pages/TimeTracker/UserCreate.php | 222 +--
.../protected/pages/TimeTracker/UserList.php | 66 +-
demos/time-tracker/tests/functional.php | 18 +-
.../tests/functional/HelloPradoTestCase.php | 26 +-
demos/time-tracker/tests/unit.php | 20 +-
demos/time-tracker/tests/unit/BaseTestCase.php | 126 +-
.../tests/unit/CategoryDaoTestCase.php | 400 +++---
.../time-tracker/tests/unit/ProjectDaoTestCase.php | 398 +++---
.../tests/unit/TimeEntryDaoTestCase.php | 426 +++---
demos/time-tracker/tests/unit/UserDaoTestCase.php | 540 ++++----
275 files changed, 13474 insertions(+), 13474 deletions(-)
(limited to 'demos')
diff --git a/demos/address-book/index.php b/demos/address-book/index.php
index 90149c02..65ace715 100644
--- a/demos/address-book/index.php
+++ b/demos/address-book/index.php
@@ -1,27 +1,27 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/address-book/protected/pages/AddressProvider.php b/demos/address-book/protected/pages/AddressProvider.php
index 94b71e11..e903f540 100644
--- a/demos/address-book/protected/pages/AddressProvider.php
+++ b/demos/address-book/protected/pages/AddressProvider.php
@@ -1,50 +1,50 @@
-
- * @version $Id$
- * @since 3.1
- */
-class AddressProvider
-{
- /**
- * @return AddressRecord[]
- * @soapmethod
- */
- public function getAllAddress()
- {
- return AddressRecord::finder()->findAll();
- }
-
- /**
- * Update address if $data->id > 0, otherwise add new address.
- * @param AddressRecord $data
- * @return boolean
- * @soapmethod
- */
- public function saveAddress($data)
- {
- $finder = AddressRecord::finder();
- if($data->id > 0 && $address=$finder->findByPk($data->id))
- {
- return $address->copyFrom($data)->save();
- }
- else
- {
- $data->id = null; //nullify the id
- return $data->save();
- }
- }
-
- /**
- * @param integer $id
- * @return integer number of records deleted
- * @soapmethod
- */
- public function deleteAddress($id)
- {
- return AddressRecord::finder()->deleteByPk($id);
- }
-}
+
+ * @version $Id$
+ * @since 3.1
+ */
+class AddressProvider
+{
+ /**
+ * @return AddressRecord[]
+ * @soapmethod
+ */
+ public function getAllAddress()
+ {
+ return AddressRecord::finder()->findAll();
+ }
+
+ /**
+ * Update address if $data->id > 0, otherwise add new address.
+ * @param AddressRecord $data
+ * @return boolean
+ * @soapmethod
+ */
+ public function saveAddress($data)
+ {
+ $finder = AddressRecord::finder();
+ if($data->id > 0 && $address=$finder->findByPk($data->id))
+ {
+ return $address->copyFrom($data)->save();
+ }
+ else
+ {
+ $data->id = null; //nullify the id
+ return $data->save();
+ }
+ }
+
+ /**
+ * @param integer $id
+ * @return integer number of records deleted
+ * @soapmethod
+ */
+ public function deleteAddress($id)
+ {
+ return AddressRecord::finder()->deleteByPk($id);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/address-book/protected/pages/AddressRecord.php b/demos/address-book/protected/pages/AddressRecord.php
index aaf8db7c..58bb53e6 100644
--- a/demos/address-book/protected/pages/AddressRecord.php
+++ b/demos/address-book/protected/pages/AddressRecord.php
@@ -1,35 +1,35 @@
-
\ No newline at end of file
diff --git a/demos/address-book/protected/pages/FlexApp.php b/demos/address-book/protected/pages/FlexApp.php
index e7a5bf2a..d9b20ab7 100644
--- a/demos/address-book/protected/pages/FlexApp.php
+++ b/demos/address-book/protected/pages/FlexApp.php
@@ -1,114 +1,114 @@
-
- * @version $Id$
- * @since 3.1
- */
-class FlexApp extends TTemplateControl
-{
- private $_parameters;
-
- /**
- * FlashVar parameter name value pairs.
- *
- * NOTE: parameter names must be accessed in lowercase in Flex Applications!
- *
- * @return TAttributeCollection
- */
- public function getParameters()
- {
- if($this->_parameters===null)
- $this->_parameters = new TAttributeCollection();
- return $this->_parameters;
- }
-
- public function getFlashVars()
- {
- $params = array();
- foreach($this->getParameters() as $name=>$value)
- $params[] = $name.'='.$value;
- return implode('&', $params);
- }
-
- public function getWidth()
- {
- return $this->getViewState('Width', '450');
- }
-
- public function setWidth($value)
- {
- $this->setViewState('Width', $value, '450');
- }
-
- public function getHeight()
- {
- return $this->getViewState('Height', '300');
- }
-
- public function setHeight($value)
- {
- $this->setViewState('Height', $value, '300');
- }
-
- public function getBinDirectory()
- {
- return $this->getViewState('Bin');
- }
-
- public function setBinDirectory($value)
- {
- $this->setViewState('Bin', $value);
- }
-
- public function getAppName()
- {
- return $this->getViewState('AppName');
- }
-
- public function setAppName($value)
- {
- $this->setViewState('AppName', $value);
- }
-
- public function getQuality()
- {
- return $this->getViewState('Quality', 'high');
- }
-
- public function setQuality($value)
- {
- $this->setViewState('Quality', $value, 'high');
- }
-
- public function getBgcolor()
- {
- return $this->getViewState('bgcolor', '#ffffff');
- }
-
- public function setBgColor($value)
- {
- $this->setViewState('bgcolor', $value, '#ffffff');
- }
-
- public function getAlign()
- {
- return $this->getViewState('align', 'middle');
- }
-
- public function setAlign($value)
- {
- $this->setViewState('align', $value, 'middle');
- }
-
- public function getAllowScriptAccess()
- {
- return $this->getViewState('allowScriptAccess', 'sameDomain');
- }
-
- public function setAllowScriptAccess($value)
- {
- $this->setViewState('allowScriptAccess', $value, 'sameDomain');
- }
-}
-
+
+ * @version $Id$
+ * @since 3.1
+ */
+class FlexApp extends TTemplateControl
+{
+ private $_parameters;
+
+ /**
+ * FlashVar parameter name value pairs.
+ *
+ * NOTE: parameter names must be accessed in lowercase in Flex Applications!
+ *
+ * @return TAttributeCollection
+ */
+ public function getParameters()
+ {
+ if($this->_parameters===null)
+ $this->_parameters = new TAttributeCollection();
+ return $this->_parameters;
+ }
+
+ public function getFlashVars()
+ {
+ $params = array();
+ foreach($this->getParameters() as $name=>$value)
+ $params[] = $name.'='.$value;
+ return implode('&', $params);
+ }
+
+ public function getWidth()
+ {
+ return $this->getViewState('Width', '450');
+ }
+
+ public function setWidth($value)
+ {
+ $this->setViewState('Width', $value, '450');
+ }
+
+ public function getHeight()
+ {
+ return $this->getViewState('Height', '300');
+ }
+
+ public function setHeight($value)
+ {
+ $this->setViewState('Height', $value, '300');
+ }
+
+ public function getBinDirectory()
+ {
+ return $this->getViewState('Bin');
+ }
+
+ public function setBinDirectory($value)
+ {
+ $this->setViewState('Bin', $value);
+ }
+
+ public function getAppName()
+ {
+ return $this->getViewState('AppName');
+ }
+
+ public function setAppName($value)
+ {
+ $this->setViewState('AppName', $value);
+ }
+
+ public function getQuality()
+ {
+ return $this->getViewState('Quality', 'high');
+ }
+
+ public function setQuality($value)
+ {
+ $this->setViewState('Quality', $value, 'high');
+ }
+
+ public function getBgcolor()
+ {
+ return $this->getViewState('bgcolor', '#ffffff');
+ }
+
+ public function setBgColor($value)
+ {
+ $this->setViewState('bgcolor', $value, '#ffffff');
+ }
+
+ public function getAlign()
+ {
+ return $this->getViewState('align', 'middle');
+ }
+
+ public function setAlign($value)
+ {
+ $this->setViewState('align', $value, 'middle');
+ }
+
+ public function getAllowScriptAccess()
+ {
+ return $this->getViewState('allowScriptAccess', 'sameDomain');
+ }
+
+ public function setAllowScriptAccess($value)
+ {
+ $this->setViewState('allowScriptAccess', $value, 'sameDomain');
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/address-book/protected/pages/flex/bin/AC_OETags.js b/demos/address-book/protected/pages/flex/bin/AC_OETags.js
index 157eb218..f72d7e29 100644
--- a/demos/address-book/protected/pages/flex/bin/AC_OETags.js
+++ b/demos/address-book/protected/pages/flex/bin/AC_OETags.js
@@ -1,269 +1,269 @@
-// Flash Player Version Detection - Rev 1.5
-// Detect Client Browser type
-// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
-var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
-var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
-var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
-
-function ControlVersion()
-{
- var version;
- var axo;
- var e;
-
- // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
-
- try {
- // version will be set for 7.X or greater players
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
- version = axo.GetVariable("$version");
- } catch (e) {
- }
-
- if (!version)
- {
- try {
- // version will be set for 6.X players only
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
-
- // installed player is some revision of 6.0
- // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
- // so we have to be careful.
-
- // default to the first public version
- version = "WIN 6,0,21,0";
-
- // throws if AllowScripAccess does not exist (introduced in 6.0r47)
- axo.AllowScriptAccess = "always";
-
- // safe to call for 6.0r47 or greater
- version = axo.GetVariable("$version");
-
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 4.X or 5.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
- version = axo.GetVariable("$version");
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 3.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
- version = "WIN 3,0,18,0";
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 2.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- version = "WIN 2,0,0,11";
- } catch (e) {
- version = -1;
- }
- }
-
- return version;
-}
-
-// JavaScript helper required to detect Flash Player PlugIn version information
-function GetSwfVer(){
- // NS/Opera version >= 3 check for Flash plugin in plugin array
- var flashVer = -1;
-
- if (navigator.plugins != null && navigator.plugins.length > 0) {
- if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
- var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
- var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
- var descArray = flashDescription.split(" ");
- var tempArrayMajor = descArray[2].split(".");
- var versionMajor = tempArrayMajor[0];
- var versionMinor = tempArrayMajor[1];
- if ( descArray[3] != "" ) {
- tempArrayMinor = descArray[3].split("r");
- } else {
- tempArrayMinor = descArray[4].split("r");
- }
- var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
- var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
- }
- }
- // MSN/WebTV 2.6 supports Flash 4
- else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
- // WebTV 2.5 supports Flash 3
- else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
- // older WebTV supports Flash 2
- else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
- else if ( isIE && isWin && !isOpera ) {
- flashVer = ControlVersion();
- }
- return flashVer;
-}
-
-// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
-function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
-{
- versionStr = GetSwfVer();
- if (versionStr == -1 ) {
- return false;
- } else if (versionStr != 0) {
- if(isIE && isWin && !isOpera) {
- // Given "WIN 2,0,0,11"
- tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
- tempString = tempArray[1]; // "2,0,0,11"
- versionArray = tempString.split(","); // ['2', '0', '0', '11']
- } else {
- versionArray = versionStr.split(".");
- }
- var versionMajor = versionArray[0];
- var versionMinor = versionArray[1];
- var versionRevision = versionArray[2];
-
- // is the major.revision >= requested major.revision AND the minor version >= requested minor
- if (versionMajor > parseFloat(reqMajorVer)) {
- return true;
- } else if (versionMajor == parseFloat(reqMajorVer)) {
- if (versionMinor > parseFloat(reqMinorVer))
- return true;
- else if (versionMinor == parseFloat(reqMinorVer)) {
- if (versionRevision >= parseFloat(reqRevision))
- return true;
- }
- }
- return false;
- }
-}
-
-function AC_AddExtension(src, ext)
-{
- if (src.indexOf('?') != -1)
- return src.replace(/\?/, ext+'?');
- else
- return src + ext;
-}
-
-function AC_Generateobj(objAttrs, params, embedAttrs)
-{
- var str = '';
- if (isIE && isWin && !isOpera)
- {
- str += ' ';
- str += '> ';
- } else {
- str += ' ';
- }
-
- document.write(str);
-}
-
-function AC_FL_RunContent(){
- var ret =
- AC_GetArgs
- ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
- , "application/x-shockwave-flash"
- );
- AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
-}
-
-function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
- var ret = new Object();
- ret.embedAttrs = new Object();
- ret.params = new Object();
- ret.objAttrs = new Object();
- for (var i=0; i < args.length; i=i+2){
- var currArg = args[i].toLowerCase();
-
- switch (currArg){
- case "classid":
- break;
- case "pluginspage":
- ret.embedAttrs[args[i]] = args[i+1];
- break;
- case "src":
- case "movie":
- args[i+1] = AC_AddExtension(args[i+1], ext);
- ret.embedAttrs["src"] = args[i+1];
- ret.params[srcParamName] = args[i+1];
- break;
- case "onafterupdate":
- case "onbeforeupdate":
- case "onblur":
- case "oncellchange":
- case "onclick":
- case "ondblClick":
- case "ondrag":
- case "ondragend":
- case "ondragenter":
- case "ondragleave":
- case "ondragover":
- case "ondrop":
- case "onfinish":
- case "onfocus":
- case "onhelp":
- case "onmousedown":
- case "onmouseup":
- case "onmouseover":
- case "onmousemove":
- case "onmouseout":
- case "onkeypress":
- case "onkeydown":
- case "onkeyup":
- case "onload":
- case "onlosecapture":
- case "onpropertychange":
- case "onreadystatechange":
- case "onrowsdelete":
- case "onrowenter":
- case "onrowexit":
- case "onrowsinserted":
- case "onstart":
- case "onscroll":
- case "onbeforeeditfocus":
- case "onactivate":
- case "onbeforedeactivate":
- case "ondeactivate":
- case "type":
- case "codebase":
- case "id":
- ret.objAttrs[args[i]] = args[i+1];
- break;
- case "width":
- case "height":
- case "align":
- case "vspace":
- case "hspace":
- case "class":
- case "title":
- case "accesskey":
- case "name":
- case "tabindex":
- ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
- break;
- default:
- ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
- }
- }
- ret.objAttrs["classid"] = classid;
- if (mimeType) ret.embedAttrs["type"] = mimeType;
- return ret;
-}
-
-
+// Flash Player Version Detection - Rev 1.5
+// Detect Client Browser type
+// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
+var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
+var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
+var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
+
+function ControlVersion()
+{
+ var version;
+ var axo;
+ var e;
+
+ // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
+
+ try {
+ // version will be set for 7.X or greater players
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 6.X players only
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+
+ // installed player is some revision of 6.0
+ // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
+ // so we have to be careful.
+
+ // default to the first public version
+ version = "WIN 6,0,21,0";
+
+ // throws if AllowScripAccess does not exist (introduced in 6.0r47)
+ axo.AllowScriptAccess = "always";
+
+ // safe to call for 6.0r47 or greater
+ version = axo.GetVariable("$version");
+
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 4.X or 5.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 3.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = "WIN 3,0,18,0";
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 2.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ version = "WIN 2,0,0,11";
+ } catch (e) {
+ version = -1;
+ }
+ }
+
+ return version;
+}
+
+// JavaScript helper required to detect Flash Player PlugIn version information
+function GetSwfVer(){
+ // NS/Opera version >= 3 check for Flash plugin in plugin array
+ var flashVer = -1;
+
+ if (navigator.plugins != null && navigator.plugins.length > 0) {
+ if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ if ( descArray[3] != "" ) {
+ tempArrayMinor = descArray[3].split("r");
+ } else {
+ tempArrayMinor = descArray[4].split("r");
+ }
+ var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
+ var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
+ }
+ }
+ // MSN/WebTV 2.6 supports Flash 4
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
+ // WebTV 2.5 supports Flash 3
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
+ // older WebTV supports Flash 2
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
+ else if ( isIE && isWin && !isOpera ) {
+ flashVer = ControlVersion();
+ }
+ return flashVer;
+}
+
+// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
+function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
+{
+ versionStr = GetSwfVer();
+ if (versionStr == -1 ) {
+ return false;
+ } else if (versionStr != 0) {
+ if(isIE && isWin && !isOpera) {
+ // Given "WIN 2,0,0,11"
+ tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
+ tempString = tempArray[1]; // "2,0,0,11"
+ versionArray = tempString.split(","); // ['2', '0', '0', '11']
+ } else {
+ versionArray = versionStr.split(".");
+ }
+ var versionMajor = versionArray[0];
+ var versionMinor = versionArray[1];
+ var versionRevision = versionArray[2];
+
+ // is the major.revision >= requested major.revision AND the minor version >= requested minor
+ if (versionMajor > parseFloat(reqMajorVer)) {
+ return true;
+ } else if (versionMajor == parseFloat(reqMajorVer)) {
+ if (versionMinor > parseFloat(reqMinorVer))
+ return true;
+ else if (versionMinor == parseFloat(reqMinorVer)) {
+ if (versionRevision >= parseFloat(reqRevision))
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+function AC_AddExtension(src, ext)
+{
+ if (src.indexOf('?') != -1)
+ return src.replace(/\?/, ext+'?');
+ else
+ return src + ext;
+}
+
+function AC_Generateobj(objAttrs, params, embedAttrs)
+{
+ var str = '';
+ if (isIE && isWin && !isOpera)
+ {
+ str += ' ';
+ str += '> ';
+ } else {
+ str += ' ';
+ }
+
+ document.write(str);
+}
+
+function AC_FL_RunContent(){
+ var ret =
+ AC_GetArgs
+ ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
+ , "application/x-shockwave-flash"
+ );
+ AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
+}
+
+function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
+ var ret = new Object();
+ ret.embedAttrs = new Object();
+ ret.params = new Object();
+ ret.objAttrs = new Object();
+ for (var i=0; i < args.length; i=i+2){
+ var currArg = args[i].toLowerCase();
+
+ switch (currArg){
+ case "classid":
+ break;
+ case "pluginspage":
+ ret.embedAttrs[args[i]] = args[i+1];
+ break;
+ case "src":
+ case "movie":
+ args[i+1] = AC_AddExtension(args[i+1], ext);
+ ret.embedAttrs["src"] = args[i+1];
+ ret.params[srcParamName] = args[i+1];
+ break;
+ case "onafterupdate":
+ case "onbeforeupdate":
+ case "onblur":
+ case "oncellchange":
+ case "onclick":
+ case "ondblClick":
+ case "ondrag":
+ case "ondragend":
+ case "ondragenter":
+ case "ondragleave":
+ case "ondragover":
+ case "ondrop":
+ case "onfinish":
+ case "onfocus":
+ case "onhelp":
+ case "onmousedown":
+ case "onmouseup":
+ case "onmouseover":
+ case "onmousemove":
+ case "onmouseout":
+ case "onkeypress":
+ case "onkeydown":
+ case "onkeyup":
+ case "onload":
+ case "onlosecapture":
+ case "onpropertychange":
+ case "onreadystatechange":
+ case "onrowsdelete":
+ case "onrowenter":
+ case "onrowexit":
+ case "onrowsinserted":
+ case "onstart":
+ case "onscroll":
+ case "onbeforeeditfocus":
+ case "onactivate":
+ case "onbeforedeactivate":
+ case "ondeactivate":
+ case "type":
+ case "codebase":
+ case "id":
+ ret.objAttrs[args[i]] = args[i+1];
+ break;
+ case "width":
+ case "height":
+ case "align":
+ case "vspace":
+ case "hspace":
+ case "class":
+ case "title":
+ case "accesskey":
+ case "name":
+ case "tabindex":
+ ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
+ break;
+ default:
+ ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
+ }
+ }
+ ret.objAttrs["classid"] = classid;
+ if (mimeType) ret.embedAttrs["type"] = mimeType;
+ return ret;
+}
+
+
diff --git a/demos/address-book/protected/pages/flex/bin/history.js b/demos/address-book/protected/pages/flex/bin/history.js
index b0537ef1..7d37ea62 100644
--- a/demos/address-book/protected/pages/flex/bin/history.js
+++ b/demos/address-book/protected/pages/flex/bin/history.js
@@ -1,48 +1,48 @@
-// $Revision: 1.49 $
-// Vars
-Vars = function(qStr) {
- this.numVars = 0;
- if(qStr != null) {
- var nameValue, name;
- var pairs = qStr.split('&');
- var pairLen = pairs.length;
- for(var i = 0; i < pairLen; i++) {
- var pair = pairs[i];
- if( (pair.indexOf('=')!= -1) && (pair.length > 3) ) {
- var nameValue = pair.split('=');
- var name = nameValue[0];
- var value = nameValue[1];
- if(this[name] == null && name.length > 0 && value.length > 0) {
- this[name] = value;
- this.numVars++;
- }
- }
- }
- }
-}
-Vars.prototype.toString = function(pre) {
- var result = '';
- if(pre == null) { pre = ''; }
- for(var i in this) {
- if(this[i] != null && typeof(this[i]) != 'object' && typeof(this[i]) != 'function' && i != 'numVars') {
- result += pre + i + '=' + this[i] + '&';
- }
- }
- if(result.length > 0) result = result.substr(0, result.length-1);
- return result;
-}
-function getSearch(wRef) {
- var searchStr = '';
- if(wRef.location.search.length > 1) {
- searchStr = new String(wRef.location.search);
- searchStr = searchStr.substring(1, searchStr.length);
- }
- return searchStr;
-}
-var lc_id = Math.floor(Math.random() * 100000).toString(16);
-if (this != top)
-{
- top.Vars = Vars;
- top.getSearch = getSearch;
- top.lc_id = lc_id;
-}
+// $Revision: 1.49 $
+// Vars
+Vars = function(qStr) {
+ this.numVars = 0;
+ if(qStr != null) {
+ var nameValue, name;
+ var pairs = qStr.split('&');
+ var pairLen = pairs.length;
+ for(var i = 0; i < pairLen; i++) {
+ var pair = pairs[i];
+ if( (pair.indexOf('=')!= -1) && (pair.length > 3) ) {
+ var nameValue = pair.split('=');
+ var name = nameValue[0];
+ var value = nameValue[1];
+ if(this[name] == null && name.length > 0 && value.length > 0) {
+ this[name] = value;
+ this.numVars++;
+ }
+ }
+ }
+ }
+}
+Vars.prototype.toString = function(pre) {
+ var result = '';
+ if(pre == null) { pre = ''; }
+ for(var i in this) {
+ if(this[i] != null && typeof(this[i]) != 'object' && typeof(this[i]) != 'function' && i != 'numVars') {
+ result += pre + i + '=' + this[i] + '&';
+ }
+ }
+ if(result.length > 0) result = result.substr(0, result.length-1);
+ return result;
+}
+function getSearch(wRef) {
+ var searchStr = '';
+ if(wRef.location.search.length > 1) {
+ searchStr = new String(wRef.location.search);
+ searchStr = searchStr.substring(1, searchStr.length);
+ }
+ return searchStr;
+}
+var lc_id = Math.floor(Math.random() * 100000).toString(16);
+if (this != top)
+{
+ top.Vars = Vars;
+ top.getSearch = getSearch;
+ top.lc_id = lc_id;
+}
diff --git a/demos/address-book/protected/pages/flex/html-template/AC_OETags.js b/demos/address-book/protected/pages/flex/html-template/AC_OETags.js
index 157eb218..f72d7e29 100644
--- a/demos/address-book/protected/pages/flex/html-template/AC_OETags.js
+++ b/demos/address-book/protected/pages/flex/html-template/AC_OETags.js
@@ -1,269 +1,269 @@
-// Flash Player Version Detection - Rev 1.5
-// Detect Client Browser type
-// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
-var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
-var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
-var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
-
-function ControlVersion()
-{
- var version;
- var axo;
- var e;
-
- // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
-
- try {
- // version will be set for 7.X or greater players
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
- version = axo.GetVariable("$version");
- } catch (e) {
- }
-
- if (!version)
- {
- try {
- // version will be set for 6.X players only
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
-
- // installed player is some revision of 6.0
- // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
- // so we have to be careful.
-
- // default to the first public version
- version = "WIN 6,0,21,0";
-
- // throws if AllowScripAccess does not exist (introduced in 6.0r47)
- axo.AllowScriptAccess = "always";
-
- // safe to call for 6.0r47 or greater
- version = axo.GetVariable("$version");
-
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 4.X or 5.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
- version = axo.GetVariable("$version");
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 3.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
- version = "WIN 3,0,18,0";
- } catch (e) {
- }
- }
-
- if (!version)
- {
- try {
- // version will be set for 2.X player
- axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- version = "WIN 2,0,0,11";
- } catch (e) {
- version = -1;
- }
- }
-
- return version;
-}
-
-// JavaScript helper required to detect Flash Player PlugIn version information
-function GetSwfVer(){
- // NS/Opera version >= 3 check for Flash plugin in plugin array
- var flashVer = -1;
-
- if (navigator.plugins != null && navigator.plugins.length > 0) {
- if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
- var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
- var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
- var descArray = flashDescription.split(" ");
- var tempArrayMajor = descArray[2].split(".");
- var versionMajor = tempArrayMajor[0];
- var versionMinor = tempArrayMajor[1];
- if ( descArray[3] != "" ) {
- tempArrayMinor = descArray[3].split("r");
- } else {
- tempArrayMinor = descArray[4].split("r");
- }
- var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
- var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
- }
- }
- // MSN/WebTV 2.6 supports Flash 4
- else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
- // WebTV 2.5 supports Flash 3
- else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
- // older WebTV supports Flash 2
- else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
- else if ( isIE && isWin && !isOpera ) {
- flashVer = ControlVersion();
- }
- return flashVer;
-}
-
-// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
-function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
-{
- versionStr = GetSwfVer();
- if (versionStr == -1 ) {
- return false;
- } else if (versionStr != 0) {
- if(isIE && isWin && !isOpera) {
- // Given "WIN 2,0,0,11"
- tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
- tempString = tempArray[1]; // "2,0,0,11"
- versionArray = tempString.split(","); // ['2', '0', '0', '11']
- } else {
- versionArray = versionStr.split(".");
- }
- var versionMajor = versionArray[0];
- var versionMinor = versionArray[1];
- var versionRevision = versionArray[2];
-
- // is the major.revision >= requested major.revision AND the minor version >= requested minor
- if (versionMajor > parseFloat(reqMajorVer)) {
- return true;
- } else if (versionMajor == parseFloat(reqMajorVer)) {
- if (versionMinor > parseFloat(reqMinorVer))
- return true;
- else if (versionMinor == parseFloat(reqMinorVer)) {
- if (versionRevision >= parseFloat(reqRevision))
- return true;
- }
- }
- return false;
- }
-}
-
-function AC_AddExtension(src, ext)
-{
- if (src.indexOf('?') != -1)
- return src.replace(/\?/, ext+'?');
- else
- return src + ext;
-}
-
-function AC_Generateobj(objAttrs, params, embedAttrs)
-{
- var str = '';
- if (isIE && isWin && !isOpera)
- {
- str += ' ';
- str += '> ';
- } else {
- str += ' ';
- }
-
- document.write(str);
-}
-
-function AC_FL_RunContent(){
- var ret =
- AC_GetArgs
- ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
- , "application/x-shockwave-flash"
- );
- AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
-}
-
-function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
- var ret = new Object();
- ret.embedAttrs = new Object();
- ret.params = new Object();
- ret.objAttrs = new Object();
- for (var i=0; i < args.length; i=i+2){
- var currArg = args[i].toLowerCase();
-
- switch (currArg){
- case "classid":
- break;
- case "pluginspage":
- ret.embedAttrs[args[i]] = args[i+1];
- break;
- case "src":
- case "movie":
- args[i+1] = AC_AddExtension(args[i+1], ext);
- ret.embedAttrs["src"] = args[i+1];
- ret.params[srcParamName] = args[i+1];
- break;
- case "onafterupdate":
- case "onbeforeupdate":
- case "onblur":
- case "oncellchange":
- case "onclick":
- case "ondblClick":
- case "ondrag":
- case "ondragend":
- case "ondragenter":
- case "ondragleave":
- case "ondragover":
- case "ondrop":
- case "onfinish":
- case "onfocus":
- case "onhelp":
- case "onmousedown":
- case "onmouseup":
- case "onmouseover":
- case "onmousemove":
- case "onmouseout":
- case "onkeypress":
- case "onkeydown":
- case "onkeyup":
- case "onload":
- case "onlosecapture":
- case "onpropertychange":
- case "onreadystatechange":
- case "onrowsdelete":
- case "onrowenter":
- case "onrowexit":
- case "onrowsinserted":
- case "onstart":
- case "onscroll":
- case "onbeforeeditfocus":
- case "onactivate":
- case "onbeforedeactivate":
- case "ondeactivate":
- case "type":
- case "codebase":
- case "id":
- ret.objAttrs[args[i]] = args[i+1];
- break;
- case "width":
- case "height":
- case "align":
- case "vspace":
- case "hspace":
- case "class":
- case "title":
- case "accesskey":
- case "name":
- case "tabindex":
- ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
- break;
- default:
- ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
- }
- }
- ret.objAttrs["classid"] = classid;
- if (mimeType) ret.embedAttrs["type"] = mimeType;
- return ret;
-}
-
-
+// Flash Player Version Detection - Rev 1.5
+// Detect Client Browser type
+// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
+var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
+var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
+var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
+
+function ControlVersion()
+{
+ var version;
+ var axo;
+ var e;
+
+ // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
+
+ try {
+ // version will be set for 7.X or greater players
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 6.X players only
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+
+ // installed player is some revision of 6.0
+ // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
+ // so we have to be careful.
+
+ // default to the first public version
+ version = "WIN 6,0,21,0";
+
+ // throws if AllowScripAccess does not exist (introduced in 6.0r47)
+ axo.AllowScriptAccess = "always";
+
+ // safe to call for 6.0r47 or greater
+ version = axo.GetVariable("$version");
+
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 4.X or 5.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = axo.GetVariable("$version");
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 3.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
+ version = "WIN 3,0,18,0";
+ } catch (e) {
+ }
+ }
+
+ if (!version)
+ {
+ try {
+ // version will be set for 2.X player
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ version = "WIN 2,0,0,11";
+ } catch (e) {
+ version = -1;
+ }
+ }
+
+ return version;
+}
+
+// JavaScript helper required to detect Flash Player PlugIn version information
+function GetSwfVer(){
+ // NS/Opera version >= 3 check for Flash plugin in plugin array
+ var flashVer = -1;
+
+ if (navigator.plugins != null && navigator.plugins.length > 0) {
+ if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ if ( descArray[3] != "" ) {
+ tempArrayMinor = descArray[3].split("r");
+ } else {
+ tempArrayMinor = descArray[4].split("r");
+ }
+ var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
+ var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
+ }
+ }
+ // MSN/WebTV 2.6 supports Flash 4
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
+ // WebTV 2.5 supports Flash 3
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
+ // older WebTV supports Flash 2
+ else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
+ else if ( isIE && isWin && !isOpera ) {
+ flashVer = ControlVersion();
+ }
+ return flashVer;
+}
+
+// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
+function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
+{
+ versionStr = GetSwfVer();
+ if (versionStr == -1 ) {
+ return false;
+ } else if (versionStr != 0) {
+ if(isIE && isWin && !isOpera) {
+ // Given "WIN 2,0,0,11"
+ tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
+ tempString = tempArray[1]; // "2,0,0,11"
+ versionArray = tempString.split(","); // ['2', '0', '0', '11']
+ } else {
+ versionArray = versionStr.split(".");
+ }
+ var versionMajor = versionArray[0];
+ var versionMinor = versionArray[1];
+ var versionRevision = versionArray[2];
+
+ // is the major.revision >= requested major.revision AND the minor version >= requested minor
+ if (versionMajor > parseFloat(reqMajorVer)) {
+ return true;
+ } else if (versionMajor == parseFloat(reqMajorVer)) {
+ if (versionMinor > parseFloat(reqMinorVer))
+ return true;
+ else if (versionMinor == parseFloat(reqMinorVer)) {
+ if (versionRevision >= parseFloat(reqRevision))
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+function AC_AddExtension(src, ext)
+{
+ if (src.indexOf('?') != -1)
+ return src.replace(/\?/, ext+'?');
+ else
+ return src + ext;
+}
+
+function AC_Generateobj(objAttrs, params, embedAttrs)
+{
+ var str = '';
+ if (isIE && isWin && !isOpera)
+ {
+ str += ' ';
+ str += '> ';
+ } else {
+ str += ' ';
+ }
+
+ document.write(str);
+}
+
+function AC_FL_RunContent(){
+ var ret =
+ AC_GetArgs
+ ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
+ , "application/x-shockwave-flash"
+ );
+ AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
+}
+
+function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
+ var ret = new Object();
+ ret.embedAttrs = new Object();
+ ret.params = new Object();
+ ret.objAttrs = new Object();
+ for (var i=0; i < args.length; i=i+2){
+ var currArg = args[i].toLowerCase();
+
+ switch (currArg){
+ case "classid":
+ break;
+ case "pluginspage":
+ ret.embedAttrs[args[i]] = args[i+1];
+ break;
+ case "src":
+ case "movie":
+ args[i+1] = AC_AddExtension(args[i+1], ext);
+ ret.embedAttrs["src"] = args[i+1];
+ ret.params[srcParamName] = args[i+1];
+ break;
+ case "onafterupdate":
+ case "onbeforeupdate":
+ case "onblur":
+ case "oncellchange":
+ case "onclick":
+ case "ondblClick":
+ case "ondrag":
+ case "ondragend":
+ case "ondragenter":
+ case "ondragleave":
+ case "ondragover":
+ case "ondrop":
+ case "onfinish":
+ case "onfocus":
+ case "onhelp":
+ case "onmousedown":
+ case "onmouseup":
+ case "onmouseover":
+ case "onmousemove":
+ case "onmouseout":
+ case "onkeypress":
+ case "onkeydown":
+ case "onkeyup":
+ case "onload":
+ case "onlosecapture":
+ case "onpropertychange":
+ case "onreadystatechange":
+ case "onrowsdelete":
+ case "onrowenter":
+ case "onrowexit":
+ case "onrowsinserted":
+ case "onstart":
+ case "onscroll":
+ case "onbeforeeditfocus":
+ case "onactivate":
+ case "onbeforedeactivate":
+ case "ondeactivate":
+ case "type":
+ case "codebase":
+ case "id":
+ ret.objAttrs[args[i]] = args[i+1];
+ break;
+ case "width":
+ case "height":
+ case "align":
+ case "vspace":
+ case "hspace":
+ case "class":
+ case "title":
+ case "accesskey":
+ case "name":
+ case "tabindex":
+ ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
+ break;
+ default:
+ ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
+ }
+ }
+ ret.objAttrs["classid"] = classid;
+ if (mimeType) ret.embedAttrs["type"] = mimeType;
+ return ret;
+}
+
+
diff --git a/demos/address-book/protected/pages/flex/html-template/history.js b/demos/address-book/protected/pages/flex/html-template/history.js
index b0537ef1..7d37ea62 100644
--- a/demos/address-book/protected/pages/flex/html-template/history.js
+++ b/demos/address-book/protected/pages/flex/html-template/history.js
@@ -1,48 +1,48 @@
-// $Revision: 1.49 $
-// Vars
-Vars = function(qStr) {
- this.numVars = 0;
- if(qStr != null) {
- var nameValue, name;
- var pairs = qStr.split('&');
- var pairLen = pairs.length;
- for(var i = 0; i < pairLen; i++) {
- var pair = pairs[i];
- if( (pair.indexOf('=')!= -1) && (pair.length > 3) ) {
- var nameValue = pair.split('=');
- var name = nameValue[0];
- var value = nameValue[1];
- if(this[name] == null && name.length > 0 && value.length > 0) {
- this[name] = value;
- this.numVars++;
- }
- }
- }
- }
-}
-Vars.prototype.toString = function(pre) {
- var result = '';
- if(pre == null) { pre = ''; }
- for(var i in this) {
- if(this[i] != null && typeof(this[i]) != 'object' && typeof(this[i]) != 'function' && i != 'numVars') {
- result += pre + i + '=' + this[i] + '&';
- }
- }
- if(result.length > 0) result = result.substr(0, result.length-1);
- return result;
-}
-function getSearch(wRef) {
- var searchStr = '';
- if(wRef.location.search.length > 1) {
- searchStr = new String(wRef.location.search);
- searchStr = searchStr.substring(1, searchStr.length);
- }
- return searchStr;
-}
-var lc_id = Math.floor(Math.random() * 100000).toString(16);
-if (this != top)
-{
- top.Vars = Vars;
- top.getSearch = getSearch;
- top.lc_id = lc_id;
-}
+// $Revision: 1.49 $
+// Vars
+Vars = function(qStr) {
+ this.numVars = 0;
+ if(qStr != null) {
+ var nameValue, name;
+ var pairs = qStr.split('&');
+ var pairLen = pairs.length;
+ for(var i = 0; i < pairLen; i++) {
+ var pair = pairs[i];
+ if( (pair.indexOf('=')!= -1) && (pair.length > 3) ) {
+ var nameValue = pair.split('=');
+ var name = nameValue[0];
+ var value = nameValue[1];
+ if(this[name] == null && name.length > 0 && value.length > 0) {
+ this[name] = value;
+ this.numVars++;
+ }
+ }
+ }
+ }
+}
+Vars.prototype.toString = function(pre) {
+ var result = '';
+ if(pre == null) { pre = ''; }
+ for(var i in this) {
+ if(this[i] != null && typeof(this[i]) != 'object' && typeof(this[i]) != 'function' && i != 'numVars') {
+ result += pre + i + '=' + this[i] + '&';
+ }
+ }
+ if(result.length > 0) result = result.substr(0, result.length-1);
+ return result;
+}
+function getSearch(wRef) {
+ var searchStr = '';
+ if(wRef.location.search.length > 1) {
+ searchStr = new String(wRef.location.search);
+ searchStr = searchStr.substring(1, searchStr.length);
+ }
+ return searchStr;
+}
+var lc_id = Math.floor(Math.random() * 100000).toString(16);
+if (this != top)
+{
+ top.Vars = Vars;
+ top.getSearch = getSearch;
+ top.lc_id = lc_id;
+}
diff --git a/demos/blog-tutorial/index.php b/demos/blog-tutorial/index.php
index 43c0b436..6efff1af 100644
--- a/demos/blog-tutorial/index.php
+++ b/demos/blog-tutorial/index.php
@@ -1,18 +1,18 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/protected/common/InfoBox.php b/demos/blog-tutorial/protected/common/InfoBox.php
index 271ce1e7..97b66067 100644
--- a/demos/blog-tutorial/protected/common/InfoBox.php
+++ b/demos/blog-tutorial/protected/common/InfoBox.php
@@ -1,13 +1,13 @@
-write("
Info: \n");
- $body=$this->renderChildren($writer);
- $writer->write("
");
- }
-}
-
+write("Info: \n");
+ $body=$this->renderChildren($writer);
+ $writer->write("
");
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/protected/common/NoteBox.php b/demos/blog-tutorial/protected/common/NoteBox.php
index f5123380..90d5faab 100644
--- a/demos/blog-tutorial/protected/common/NoteBox.php
+++ b/demos/blog-tutorial/protected/common/NoteBox.php
@@ -1,13 +1,13 @@
-write("Note: \n");
- $body=$this->renderChildren($writer);
- $writer->write("
");
- }
-}
-
+write("Note: \n");
+ $body=$this->renderChildren($writer);
+ $writer->write("
");
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/protected/common/TipBox.php b/demos/blog-tutorial/protected/common/TipBox.php
index 2464a61a..58f79db8 100644
--- a/demos/blog-tutorial/protected/common/TipBox.php
+++ b/demos/blog-tutorial/protected/common/TipBox.php
@@ -1,13 +1,13 @@
-write("Tip: \n");
- $body=$this->renderChildren($writer);
- $writer->write("
");
- }
-}
-
+write("Tip: \n");
+ $body=$this->renderChildren($writer);
+ $writer->write("
");
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/protected/common/TopicList.php b/demos/blog-tutorial/protected/common/TopicList.php
index ce827cc0..eb5976a9 100644
--- a/demos/blog-tutorial/protected/common/TopicList.php
+++ b/demos/blog-tutorial/protected/common/TopicList.php
@@ -1,8 +1,8 @@
-
\ No newline at end of file
diff --git a/demos/blog-tutorial/protected/layout/MainLayout.php b/demos/blog-tutorial/protected/layout/MainLayout.php
index 4b5890de..d6ea146d 100644
--- a/demos/blog-tutorial/protected/layout/MainLayout.php
+++ b/demos/blog-tutorial/protected/layout/MainLayout.php
@@ -1,6 +1,6 @@
-Application->Globalization->Culture == $params['lang'])
$item->link->CssClass="active";
}
- }
-}
-
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day1/blog/index.php b/demos/blog-tutorial/samples/day1/blog/index.php
index 7ccffe49..bffafde2 100644
--- a/demos/blog-tutorial/samples/day1/blog/index.php
+++ b/demos/blog-tutorial/samples/day1/blog/index.php
@@ -1,22 +1,22 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day1/blog/protected/layouts/MainLayout.php b/demos/blog-tutorial/samples/day1/blog/protected/layouts/MainLayout.php
index 253d6c03..c966ba85 100644
--- a/demos/blog-tutorial/samples/day1/blog/protected/layouts/MainLayout.php
+++ b/demos/blog-tutorial/samples/day1/blog/protected/layouts/MainLayout.php
@@ -1,7 +1,7 @@
-
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day1/blog/protected/pages/Contact.php b/demos/blog-tutorial/samples/day1/blog/protected/pages/Contact.php
index b6ce575e..77d7374a 100644
--- a/demos/blog-tutorial/samples/day1/blog/protected/pages/Contact.php
+++ b/demos/blog-tutorial/samples/day1/blog/protected/pages/Contact.php
@@ -1,30 +1,30 @@
-IsValid) // check if input validation is successful
- {
- // obtain the user name, email, feedback from the textboxes
- $name = $this->Name->Text;
- $email = $this->Email->Text;
- $feedback = $this->Feedback->Text;
-
- // send an email to administrator with the above information
- $this->mailFeedback($name, $email, $feedback);
- }
- }
-
- protected function mailFeedback($name, $email, $feedback)
- {
- // implementation of sending the feedback email
- }
-}
-
+IsValid) // check if input validation is successful
+ {
+ // obtain the user name, email, feedback from the textboxes
+ $name = $this->Name->Text;
+ $email = $this->Email->Text;
+ $feedback = $this->Feedback->Text;
+
+ // send an email to administrator with the above information
+ $this->mailFeedback($name, $email, $feedback);
+ }
+ }
+
+ protected function mailFeedback($name, $email, $feedback)
+ {
+ // implementation of sending the feedback email
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day2/blog/index.php b/demos/blog-tutorial/samples/day2/blog/index.php
index 7ccffe49..bffafde2 100644
--- a/demos/blog-tutorial/samples/day2/blog/index.php
+++ b/demos/blog-tutorial/samples/day2/blog/index.php
@@ -1,22 +1,22 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day2/blog/protected/database/PostRecord.php b/demos/blog-tutorial/samples/day2/blog/protected/database/PostRecord.php
index 25702727..3407c09b 100644
--- a/demos/blog-tutorial/samples/day2/blog/protected/database/PostRecord.php
+++ b/demos/blog-tutorial/samples/day2/blog/protected/database/PostRecord.php
@@ -1,28 +1,28 @@
- array(self::BELONGS_TO, 'UserRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::BELONGS_TO, 'UserRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day2/blog/protected/database/UserRecord.php b/demos/blog-tutorial/samples/day2/blog/protected/database/UserRecord.php
index 2051e5de..021f8b09 100644
--- a/demos/blog-tutorial/samples/day2/blog/protected/database/UserRecord.php
+++ b/demos/blog-tutorial/samples/day2/blog/protected/database/UserRecord.php
@@ -1,28 +1,28 @@
- array(self::HAS_MANY, 'PostRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'PostRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day2/blog/protected/layouts/MainLayout.php b/demos/blog-tutorial/samples/day2/blog/protected/layouts/MainLayout.php
index 253d6c03..c966ba85 100644
--- a/demos/blog-tutorial/samples/day2/blog/protected/layouts/MainLayout.php
+++ b/demos/blog-tutorial/samples/day2/blog/protected/layouts/MainLayout.php
@@ -1,7 +1,7 @@
-
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day2/blog/protected/pages/Contact.php b/demos/blog-tutorial/samples/day2/blog/protected/pages/Contact.php
index b6ce575e..77d7374a 100644
--- a/demos/blog-tutorial/samples/day2/blog/protected/pages/Contact.php
+++ b/demos/blog-tutorial/samples/day2/blog/protected/pages/Contact.php
@@ -1,30 +1,30 @@
-IsValid) // check if input validation is successful
- {
- // obtain the user name, email, feedback from the textboxes
- $name = $this->Name->Text;
- $email = $this->Email->Text;
- $feedback = $this->Feedback->Text;
-
- // send an email to administrator with the above information
- $this->mailFeedback($name, $email, $feedback);
- }
- }
-
- protected function mailFeedback($name, $email, $feedback)
- {
- // implementation of sending the feedback email
- }
-}
-
+IsValid) // check if input validation is successful
+ {
+ // obtain the user name, email, feedback from the textboxes
+ $name = $this->Name->Text;
+ $email = $this->Email->Text;
+ $feedback = $this->Feedback->Text;
+
+ // send an email to administrator with the above information
+ $this->mailFeedback($name, $email, $feedback);
+ }
+ }
+
+ protected function mailFeedback($name, $email, $feedback)
+ {
+ // implementation of sending the feedback email
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/index.php b/demos/blog-tutorial/samples/day3/blog/index.php
index 7ccffe49..bffafde2 100644
--- a/demos/blog-tutorial/samples/day3/blog/index.php
+++ b/demos/blog-tutorial/samples/day3/blog/index.php
@@ -1,22 +1,22 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/BlogUser.php b/demos/blog-tutorial/samples/day3/blog/protected/BlogUser.php
index 6b9e0a23..4f094a0c 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/BlogUser.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/BlogUser.php
@@ -1,59 +1,59 @@
-findByPk($username);
- if($userRecord instanceof UserRecord) // if found
- {
- $user=new BlogUser($this->Manager);
- $user->Name=$username; // set username
- $user->Roles=($userRecord->role==1?'admin':'user'); // set role
- $user->IsGuest=false; // the user is not a guest
- return $user;
- }
- else
- return null;
- }
-
- /**
- * Checks if the specified (username, password) is valid.
- * This method is required by TDbUser.
- * @param string username
- * @param string password
- * @return boolean whether the username and password are valid.
- */
- public function validateUser($username,$password)
- {
- // use UserRecord Active Record to look for the (username, password) pair.
- return UserRecord::finder()->findBy_username_AND_password($username,$password)!==null;
- }
-
- /**
- * @return boolean whether this user is an administrator.
- */
- public function getIsAdmin()
- {
- return $this->isInRole('admin');
- }
-}
-
+findByPk($username);
+ if($userRecord instanceof UserRecord) // if found
+ {
+ $user=new BlogUser($this->Manager);
+ $user->Name=$username; // set username
+ $user->Roles=($userRecord->role==1?'admin':'user'); // set role
+ $user->IsGuest=false; // the user is not a guest
+ return $user;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Checks if the specified (username, password) is valid.
+ * This method is required by TDbUser.
+ * @param string username
+ * @param string password
+ * @return boolean whether the username and password are valid.
+ */
+ public function validateUser($username,$password)
+ {
+ // use UserRecord Active Record to look for the (username, password) pair.
+ return UserRecord::finder()->findBy_username_AND_password($username,$password)!==null;
+ }
+
+ /**
+ * @return boolean whether this user is an administrator.
+ */
+ public function getIsAdmin()
+ {
+ return $this->isInRole('admin');
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/database/PostRecord.php b/demos/blog-tutorial/samples/day3/blog/protected/database/PostRecord.php
index 25702727..3407c09b 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/database/PostRecord.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/database/PostRecord.php
@@ -1,28 +1,28 @@
- array(self::BELONGS_TO, 'UserRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::BELONGS_TO, 'UserRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/database/UserRecord.php b/demos/blog-tutorial/samples/day3/blog/protected/database/UserRecord.php
index 2051e5de..021f8b09 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/database/UserRecord.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/database/UserRecord.php
@@ -1,28 +1,28 @@
- array(self::HAS_MANY, 'PostRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'PostRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/layouts/MainLayout.php b/demos/blog-tutorial/samples/day3/blog/protected/layouts/MainLayout.php
index 46c1483d..f605f75c 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/layouts/MainLayout.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/layouts/MainLayout.php
@@ -1,19 +1,19 @@
-Application->getModule('auth')->logout();
- $url=$this->Service->constructUrl($this->Service->DefaultPage);
- $this->Response->redirect($url);
- }
-}
-
+Application->getModule('auth')->logout();
+ $url=$this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($url);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/pages/Contact.php b/demos/blog-tutorial/samples/day3/blog/protected/pages/Contact.php
index b6ce575e..77d7374a 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/pages/Contact.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/pages/Contact.php
@@ -1,30 +1,30 @@
-IsValid) // check if input validation is successful
- {
- // obtain the user name, email, feedback from the textboxes
- $name = $this->Name->Text;
- $email = $this->Email->Text;
- $feedback = $this->Feedback->Text;
-
- // send an email to administrator with the above information
- $this->mailFeedback($name, $email, $feedback);
- }
- }
-
- protected function mailFeedback($name, $email, $feedback)
- {
- // implementation of sending the feedback email
- }
-}
-
+IsValid) // check if input validation is successful
+ {
+ // obtain the user name, email, feedback from the textboxes
+ $name = $this->Name->Text;
+ $email = $this->Email->Text;
+ $feedback = $this->Feedback->Text;
+
+ // send an email to administrator with the above information
+ $this->mailFeedback($name, $email, $feedback);
+ }
+ }
+
+ protected function mailFeedback($name, $email, $feedback)
+ {
+ // implementation of sending the feedback email
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/AdminUser.php b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/AdminUser.php
index ad8f6e3d..ad668e1a 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/AdminUser.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/AdminUser.php
@@ -1,36 +1,36 @@
-UserGrid->DataSource=UserRecord::finder()->findAll();
- // binds the data to interface components
- $this->UserGrid->dataBind();
- }
-
- /**
- * Deletes a specified user record.
- * This method responds to the datagrid's OnDeleteCommand event.
- * @param TDataGrid the event sender
- * @param TDataGridCommandEventParameter the event parameter
- */
- public function deleteButtonClicked($sender,$param)
- {
- // obtains the datagrid item that contains the clicked delete button
- $item=$param->Item;
- // obtains the primary key corresponding to the datagrid item
- $username=$this->UserGrid->DataKeys[$item->ItemIndex];
- // deletes the user record with the specified username primary key
- UserRecord::finder()->deleteByPk($username);
- }
-}
-
+UserGrid->DataSource=UserRecord::finder()->findAll();
+ // binds the data to interface components
+ $this->UserGrid->dataBind();
+ }
+
+ /**
+ * Deletes a specified user record.
+ * This method responds to the datagrid's OnDeleteCommand event.
+ * @param TDataGrid the event sender
+ * @param TDataGridCommandEventParameter the event parameter
+ */
+ public function deleteButtonClicked($sender,$param)
+ {
+ // obtains the datagrid item that contains the clicked delete button
+ $item=$param->Item;
+ // obtains the primary key corresponding to the datagrid item
+ $username=$this->UserGrid->DataKeys[$item->ItemIndex];
+ // deletes the user record with the specified username primary key
+ UserRecord::finder()->deleteByPk($username);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/EditUser.php b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/EditUser.php
index 81538c33..f8c61463 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/EditUser.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/EditUser.php
@@ -1,83 +1,83 @@
-IsPostBack) // if the page is initially requested
- {
- // Retrieves the existing user data. This is equivalent to:
- // $userRecord=$this->getUserRecord();
- $userRecord=$this->UserRecord;
-
- // Populates the input controls with the existing user data
- $this->Username->Text=$userRecord->username;
- $this->Email->Text=$userRecord->email;
- $this->Role->SelectedValue=$userRecord->role;
- $this->FirstName->Text=$userRecord->first_name;
- $this->LastName->Text=$userRecord->last_name;
- }
- }
-
- /**
- * Saves the user account if all inputs are valid.
- * This method responds to the OnClick event of the "save" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // Retrieves the existing user data. This is equivalent to:
- $userRecord=$this->UserRecord;
-
- // Fetches the input data
- $userRecord->username=$this->Username->Text;
- // update password when the input is not empty
- if(!empty($this->Password->Text))
- $userRecord->password=$this->Password->Text;
- $userRecord->email=$this->Email->Text;
- // update the role if the current user is an administrator
- if($this->User->IsAdmin)
- $userRecord->role=(int)$this->Role->SelectedValue;
- $userRecord->first_name=$this->FirstName->Text;
- $userRecord->last_name=$this->LastName->Text;
-
- // saves to the database via Active Record mechanism
- $userRecord->save();
-
- // redirects the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
- }
-
- /**
- * Returns the user data to be editted.
- * @return UserRecord the user data to be editted.
- * @throws THttpException if the user data is not found.
- */
- protected function getUserRecord()
- {
- // the user to be editted is the currently logged-in user
- $username=$this->User->Name;
- // if the 'username' GET var is not empty and the current user
- // is an administrator, we use the GET var value instead.
- if($this->User->IsAdmin && $this->Request['username']!==null)
- $username=$this->Request['username'];
-
- // use Active Record to look for the specified username
- $userRecord=UserRecord::finder()->findByPk($username);
- if(!($userRecord instanceof UserRecord))
- throw new THttpException(500,'Username is invalid.');
- return $userRecord;
- }
-}
-
+IsPostBack) // if the page is initially requested
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ // $userRecord=$this->getUserRecord();
+ $userRecord=$this->UserRecord;
+
+ // Populates the input controls with the existing user data
+ $this->Username->Text=$userRecord->username;
+ $this->Email->Text=$userRecord->email;
+ $this->Role->SelectedValue=$userRecord->role;
+ $this->FirstName->Text=$userRecord->first_name;
+ $this->LastName->Text=$userRecord->last_name;
+ }
+ }
+
+ /**
+ * Saves the user account if all inputs are valid.
+ * This method responds to the OnClick event of the "save" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ $userRecord=$this->UserRecord;
+
+ // Fetches the input data
+ $userRecord->username=$this->Username->Text;
+ // update password when the input is not empty
+ if(!empty($this->Password->Text))
+ $userRecord->password=$this->Password->Text;
+ $userRecord->email=$this->Email->Text;
+ // update the role if the current user is an administrator
+ if($this->User->IsAdmin)
+ $userRecord->role=(int)$this->Role->SelectedValue;
+ $userRecord->first_name=$this->FirstName->Text;
+ $userRecord->last_name=$this->LastName->Text;
+
+ // saves to the database via Active Record mechanism
+ $userRecord->save();
+
+ // redirects the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+ }
+
+ /**
+ * Returns the user data to be editted.
+ * @return UserRecord the user data to be editted.
+ * @throws THttpException if the user data is not found.
+ */
+ protected function getUserRecord()
+ {
+ // the user to be editted is the currently logged-in user
+ $username=$this->User->Name;
+ // if the 'username' GET var is not empty and the current user
+ // is an administrator, we use the GET var value instead.
+ if($this->User->IsAdmin && $this->Request['username']!==null)
+ $username=$this->Request['username'];
+
+ // use Active Record to look for the specified username
+ $userRecord=UserRecord::finder()->findByPk($username);
+ if(!($userRecord instanceof UserRecord))
+ throw new THttpException(500,'Username is invalid.');
+ return $userRecord;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/LoginUser.php b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/LoginUser.php
index a0955490..407906ae 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/LoginUser.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/LoginUser.php
@@ -1,37 +1,37 @@
-Application->getModule('auth');
- if(!$authManager->login($this->Username->Text,$this->Password->Text))
- $param->IsValid=false; // tell the validator that validation fails
- }
-
- /**
- * Redirects the user's browser to appropriate URL if login succeeds.
- * This method responds to the login button's OnClick event.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function loginButtonClicked($sender,$param)
- {
- if($this->Page->IsValid) // all validations succeed
- {
- // obtain the URL of the privileged page that the user wanted to visit originally
- $url=$this->Application->getModule('auth')->ReturnUrl;
- if(empty($url)) // the user accesses the login page directly
- $url=$this->Service->DefaultPageUrl;
- $this->Response->redirect($url);
- }
- }
-}
-
+Application->getModule('auth');
+ if(!$authManager->login($this->Username->Text,$this->Password->Text))
+ $param->IsValid=false; // tell the validator that validation fails
+ }
+
+ /**
+ * Redirects the user's browser to appropriate URL if login succeeds.
+ * This method responds to the login button's OnClick event.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function loginButtonClicked($sender,$param)
+ {
+ if($this->Page->IsValid) // all validations succeed
+ {
+ // obtain the URL of the privileged page that the user wanted to visit originally
+ $url=$this->Application->getModule('auth')->ReturnUrl;
+ if(empty($url)) // the user accesses the login page directly
+ $url=$this->Service->DefaultPageUrl;
+ $this->Response->redirect($url);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/NewUser.php b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/NewUser.php
index 76e8cb88..3bf6768a 100644
--- a/demos/blog-tutorial/samples/day3/blog/protected/pages/users/NewUser.php
+++ b/demos/blog-tutorial/samples/day3/blog/protected/pages/users/NewUser.php
@@ -1,45 +1,45 @@
-IsValid=UserRecord::finder()->findByPk($this->Username->Text)===null;
- }
-
- /**
- * Creates a new user account if all inputs are valid.
- * This method responds to the OnClick event of the "create" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function createButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // populates a UserRecord object with user inputs
- $userRecord=new UserRecord;
- $userRecord->username=$this->Username->Text;
- $userRecord->password=$this->Password->Text;
- $userRecord->email=$this->Email->Text;
- $userRecord->role=(int)$this->Role->SelectedValue;
- $userRecord->first_name=$this->FirstName->Text;
- $userRecord->last_name=$this->LastName->Text;
-
- // saves to the database via Active Record mechanism
- $userRecord->save();
-
- // redirects the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
- }
-}
-
+IsValid=UserRecord::finder()->findByPk($this->Username->Text)===null;
+ }
+
+ /**
+ * Creates a new user account if all inputs are valid.
+ * This method responds to the OnClick event of the "create" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function createButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // populates a UserRecord object with user inputs
+ $userRecord=new UserRecord;
+ $userRecord->username=$this->Username->Text;
+ $userRecord->password=$this->Password->Text;
+ $userRecord->email=$this->Email->Text;
+ $userRecord->role=(int)$this->Role->SelectedValue;
+ $userRecord->first_name=$this->FirstName->Text;
+ $userRecord->last_name=$this->LastName->Text;
+
+ // saves to the database via Active Record mechanism
+ $userRecord->save();
+
+ // redirects the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/index.php b/demos/blog-tutorial/samples/day4/blog/index.php
index 7ccffe49..bffafde2 100644
--- a/demos/blog-tutorial/samples/day4/blog/index.php
+++ b/demos/blog-tutorial/samples/day4/blog/index.php
@@ -1,22 +1,22 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/BlogUser.php b/demos/blog-tutorial/samples/day4/blog/protected/BlogUser.php
index 6b9e0a23..4f094a0c 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/BlogUser.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/BlogUser.php
@@ -1,59 +1,59 @@
-findByPk($username);
- if($userRecord instanceof UserRecord) // if found
- {
- $user=new BlogUser($this->Manager);
- $user->Name=$username; // set username
- $user->Roles=($userRecord->role==1?'admin':'user'); // set role
- $user->IsGuest=false; // the user is not a guest
- return $user;
- }
- else
- return null;
- }
-
- /**
- * Checks if the specified (username, password) is valid.
- * This method is required by TDbUser.
- * @param string username
- * @param string password
- * @return boolean whether the username and password are valid.
- */
- public function validateUser($username,$password)
- {
- // use UserRecord Active Record to look for the (username, password) pair.
- return UserRecord::finder()->findBy_username_AND_password($username,$password)!==null;
- }
-
- /**
- * @return boolean whether this user is an administrator.
- */
- public function getIsAdmin()
- {
- return $this->isInRole('admin');
- }
-}
-
+findByPk($username);
+ if($userRecord instanceof UserRecord) // if found
+ {
+ $user=new BlogUser($this->Manager);
+ $user->Name=$username; // set username
+ $user->Roles=($userRecord->role==1?'admin':'user'); // set role
+ $user->IsGuest=false; // the user is not a guest
+ return $user;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Checks if the specified (username, password) is valid.
+ * This method is required by TDbUser.
+ * @param string username
+ * @param string password
+ * @return boolean whether the username and password are valid.
+ */
+ public function validateUser($username,$password)
+ {
+ // use UserRecord Active Record to look for the (username, password) pair.
+ return UserRecord::finder()->findBy_username_AND_password($username,$password)!==null;
+ }
+
+ /**
+ * @return boolean whether this user is an administrator.
+ */
+ public function getIsAdmin()
+ {
+ return $this->isInRole('admin');
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/database/PostRecord.php b/demos/blog-tutorial/samples/day4/blog/protected/database/PostRecord.php
index 25702727..3407c09b 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/database/PostRecord.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/database/PostRecord.php
@@ -1,28 +1,28 @@
- array(self::BELONGS_TO, 'UserRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::BELONGS_TO, 'UserRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/database/UserRecord.php b/demos/blog-tutorial/samples/day4/blog/protected/database/UserRecord.php
index 2051e5de..021f8b09 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/database/UserRecord.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/database/UserRecord.php
@@ -1,28 +1,28 @@
- array(self::HAS_MANY, 'PostRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'PostRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/layouts/MainLayout.php b/demos/blog-tutorial/samples/day4/blog/protected/layouts/MainLayout.php
index 46c1483d..f605f75c 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/layouts/MainLayout.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/layouts/MainLayout.php
@@ -1,19 +1,19 @@
-Application->getModule('auth')->logout();
- $url=$this->Service->constructUrl($this->Service->DefaultPage);
- $this->Response->redirect($url);
- }
-}
-
+Application->getModule('auth')->logout();
+ $url=$this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($url);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/Contact.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/Contact.php
index b6ce575e..77d7374a 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/Contact.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/Contact.php
@@ -1,30 +1,30 @@
-IsValid) // check if input validation is successful
- {
- // obtain the user name, email, feedback from the textboxes
- $name = $this->Name->Text;
- $email = $this->Email->Text;
- $feedback = $this->Feedback->Text;
-
- // send an email to administrator with the above information
- $this->mailFeedback($name, $email, $feedback);
- }
- }
-
- protected function mailFeedback($name, $email, $feedback)
- {
- // implementation of sending the feedback email
- }
-}
-
+IsValid) // check if input validation is successful
+ {
+ // obtain the user name, email, feedback from the textboxes
+ $name = $this->Name->Text;
+ $email = $this->Email->Text;
+ $feedback = $this->Feedback->Text;
+
+ // send an email to administrator with the above information
+ $this->mailFeedback($name, $email, $feedback);
+ }
+ }
+
+ protected function mailFeedback($name, $email, $feedback)
+ {
+ // implementation of sending the feedback email
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/EditPost.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/EditPost.php
index e137b85e..1b0f82b6 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/EditPost.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/EditPost.php
@@ -1,72 +1,72 @@
-getPost();
- $postRecord=$this->Post;
- // Authorization check: only the author or the administrator can edit the post
- if($postRecord->author_id!==$this->User->Name && !$this->User->IsAdmin)
- throw new THttpException(500,'You are not allowed to edit this post.');
-
- if(!$this->IsPostBack) // if the page is initially requested
- {
- // Populates the input controls with the existing post data
- $this->TitleEdit->Text=$postRecord->title;
- $this->ContentEdit->Text=$postRecord->content;
- }
- }
-
- /**
- * Saves the post if all inputs are valid.
- * This method responds to the OnClick event of the "Save" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // Retrieves the existing user data. This is equivalent to:
- // $postRecord=$this->getPost();
- $postRecord=$this->Post;
-
- // Fetches the input data
- $postRecord->title=$this->TitleEdit->SafeText;
- $postRecord->content=$this->ContentEdit->SafeText;
-
- // saves to the database via Active Record mechanism
- $postRecord->save();
-
- // redirects the browser to the ReadPost page
- $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
- $this->Response->redirect($url);
- }
- }
-
- /**
- * Returns the post data to be editted.
- * @return PostRecord the post data to be editted.
- * @throws THttpException if the post data is not found.
- */
- protected function getPost()
- {
- // the ID of the post to be editted is passed via GET parameter 'id'
- $postID=(int)$this->Request['id'];
- // use Active Record to look for the specified post ID
- $postRecord=PostRecord::finder()->findByPk($postID);
- if($postRecord===null)
- throw new THttpException(500,'Post is not found.');
- return $postRecord;
- }
-}
-
+getPost();
+ $postRecord=$this->Post;
+ // Authorization check: only the author or the administrator can edit the post
+ if($postRecord->author_id!==$this->User->Name && !$this->User->IsAdmin)
+ throw new THttpException(500,'You are not allowed to edit this post.');
+
+ if(!$this->IsPostBack) // if the page is initially requested
+ {
+ // Populates the input controls with the existing post data
+ $this->TitleEdit->Text=$postRecord->title;
+ $this->ContentEdit->Text=$postRecord->content;
+ }
+ }
+
+ /**
+ * Saves the post if all inputs are valid.
+ * This method responds to the OnClick event of the "Save" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ // $postRecord=$this->getPost();
+ $postRecord=$this->Post;
+
+ // Fetches the input data
+ $postRecord->title=$this->TitleEdit->SafeText;
+ $postRecord->content=$this->ContentEdit->SafeText;
+
+ // saves to the database via Active Record mechanism
+ $postRecord->save();
+
+ // redirects the browser to the ReadPost page
+ $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
+ $this->Response->redirect($url);
+ }
+ }
+
+ /**
+ * Returns the post data to be editted.
+ * @return PostRecord the post data to be editted.
+ * @throws THttpException if the post data is not found.
+ */
+ protected function getPost()
+ {
+ // the ID of the post to be editted is passed via GET parameter 'id'
+ $postID=(int)$this->Request['id'];
+ // use Active Record to look for the specified post ID
+ $postRecord=PostRecord::finder()->findByPk($postID);
+ if($postRecord===null)
+ throw new THttpException(500,'Post is not found.');
+ return $postRecord;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ListPost.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ListPost.php
index 7402dace..ae5a7eeb 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ListPost.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ListPost.php
@@ -1,64 +1,64 @@
-IsPostBack) // if the page is requested the first time
- {
- // get the total number of posts available
- $this->Repeater->VirtualItemCount=PostRecord::finder()->count();
- // populates post data into the repeater
- $this->populateData();
- }
- }
-
- /**
- * Event handler to the OnPageIndexChanged event of the pager.
- * This method is invoked when the user clicks on a page button
- * and thus changes the page of posts to display.
- */
- public function pageChanged($sender,$param)
- {
- // change the current page index to the new one
- $this->Repeater->CurrentPageIndex=$param->NewPageIndex;
- // re-populate data into the repeater
- $this->populateData();
- }
-
- /**
- * Determines which page of posts to be displayed and
- * populates the repeater with the fetched data.
- */
- protected function populateData()
- {
- $offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
- $limit=$this->Repeater->PageSize;
- if($offset+$limit>$this->Repeater->VirtualItemCount)
- $limit=$this->Repeater->VirtualItemCount-$offset;
- $this->Repeater->DataSource=$this->getPosts($offset,$limit);
- $this->Repeater->dataBind();
- }
-
- /**
- * Fetches posts from database with offset and limit.
- */
- protected function getPosts($offset, $limit)
- {
- // Construts a query criteria
- $criteria=new TActiveRecordCriteria;
- $criteria->OrdersBy['create_time']='desc';
- $criteria->Limit=$limit;
- $criteria->Offset=$offset;
- // query for the posts with the above criteria and with author information
- return PostRecord::finder()->withAuthor()->findAll($criteria);
- }
-}
-
+IsPostBack) // if the page is requested the first time
+ {
+ // get the total number of posts available
+ $this->Repeater->VirtualItemCount=PostRecord::finder()->count();
+ // populates post data into the repeater
+ $this->populateData();
+ }
+ }
+
+ /**
+ * Event handler to the OnPageIndexChanged event of the pager.
+ * This method is invoked when the user clicks on a page button
+ * and thus changes the page of posts to display.
+ */
+ public function pageChanged($sender,$param)
+ {
+ // change the current page index to the new one
+ $this->Repeater->CurrentPageIndex=$param->NewPageIndex;
+ // re-populate data into the repeater
+ $this->populateData();
+ }
+
+ /**
+ * Determines which page of posts to be displayed and
+ * populates the repeater with the fetched data.
+ */
+ protected function populateData()
+ {
+ $offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
+ $limit=$this->Repeater->PageSize;
+ if($offset+$limit>$this->Repeater->VirtualItemCount)
+ $limit=$this->Repeater->VirtualItemCount-$offset;
+ $this->Repeater->DataSource=$this->getPosts($offset,$limit);
+ $this->Repeater->dataBind();
+ }
+
+ /**
+ * Fetches posts from database with offset and limit.
+ */
+ protected function getPosts($offset, $limit)
+ {
+ // Construts a query criteria
+ $criteria=new TActiveRecordCriteria;
+ $criteria->OrdersBy['create_time']='desc';
+ $criteria->Limit=$limit;
+ $criteria->Offset=$offset;
+ // query for the posts with the above criteria and with author information
+ return PostRecord::finder()->withAuthor()->findAll($criteria);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/NewPost.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/NewPost.php
index a5e3ea4d..d3a36133 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/NewPost.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/NewPost.php
@@ -1,34 +1,34 @@
-IsValid) // when all validations succeed
- {
- // populates a PostRecord object with user inputs
- $postRecord=new PostRecord;
- // using SafeText instead of Text avoids Cross Site Scripting attack
- $postRecord->title=$this->TitleEdit->SafeText;
- $postRecord->content=$this->ContentEdit->SafeText;
- $postRecord->author_id=$this->User->Name;
- $postRecord->create_time=time();
- $postRecord->status=0;
-
- // saves to the database via Active Record mechanism
- $postRecord->save();
-
- // redirects the browser to the newly created post page
- $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
- $this->Response->redirect($url);
- }
- }
-}
-
+IsValid) // when all validations succeed
+ {
+ // populates a PostRecord object with user inputs
+ $postRecord=new PostRecord;
+ // using SafeText instead of Text avoids Cross Site Scripting attack
+ $postRecord->title=$this->TitleEdit->SafeText;
+ $postRecord->content=$this->ContentEdit->SafeText;
+ $postRecord->author_id=$this->User->Name;
+ $postRecord->create_time=time();
+ $postRecord->status=0;
+
+ // saves to the database via Active Record mechanism
+ $postRecord->save();
+
+ // redirects the browser to the newly created post page
+ $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
+ $this->Response->redirect($url);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/PostRenderer.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/PostRenderer.php
index cf0539a1..ed80f10c 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/PostRenderer.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/PostRenderer.php
@@ -1,7 +1,7 @@
-
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php
index 2aeaa4d3..4c2035e6 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php
@@ -1,57 +1,57 @@
-Request['id'];
- // retrieves PostRecord with author information filled in
- $this->_post=PostRecord::finder()->withAuthor()->findByPk($postID);
- if($this->_post===null) // if post id is invalid
- throw new THttpException(500,'Unable to find the specified post.');
- // set the page title as the post title
- $this->Title=$this->_post->title;
- }
-
- /**
- * @return PostRecord the PostRecord currently being viewed
- */
- public function getPost()
- {
- return $this->_post;
- }
-
- /**
- * Deletes the post currently being viewed
- * This method is invoked when the user clicks on the "Delete" button
- */
- public function deletePost($sender,$param)
- {
- // only the author or the administrator can delete a post
- if(!$this->canEdit())
- throw new THttpException('You are not allowed to perform this action.');
- // delete it from DB
- $this->_post->delete();
- // redirect the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
-
- /**
- * @return boolean whether the current user can edit/delete the post being viewed
- */
- public function canEdit()
- {
- // only the author or the administrator can edit/delete a post
- return $this->User->Name===$this->Post->author_id || $this->User->IsAdmin;
- }
-}
-
+Request['id'];
+ // retrieves PostRecord with author information filled in
+ $this->_post=PostRecord::finder()->withAuthor()->findByPk($postID);
+ if($this->_post===null) // if post id is invalid
+ throw new THttpException(500,'Unable to find the specified post.');
+ // set the page title as the post title
+ $this->Title=$this->_post->title;
+ }
+
+ /**
+ * @return PostRecord the PostRecord currently being viewed
+ */
+ public function getPost()
+ {
+ return $this->_post;
+ }
+
+ /**
+ * Deletes the post currently being viewed
+ * This method is invoked when the user clicks on the "Delete" button
+ */
+ public function deletePost($sender,$param)
+ {
+ // only the author or the administrator can delete a post
+ if(!$this->canEdit())
+ throw new THttpException('You are not allowed to perform this action.');
+ // delete it from DB
+ $this->_post->delete();
+ // redirect the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+
+ /**
+ * @return boolean whether the current user can edit/delete the post being viewed
+ */
+ public function canEdit()
+ {
+ // only the author or the administrator can edit/delete a post
+ return $this->User->Name===$this->Post->author_id || $this->User->IsAdmin;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/AdminUser.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/AdminUser.php
index ad8f6e3d..ad668e1a 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/AdminUser.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/AdminUser.php
@@ -1,36 +1,36 @@
-UserGrid->DataSource=UserRecord::finder()->findAll();
- // binds the data to interface components
- $this->UserGrid->dataBind();
- }
-
- /**
- * Deletes a specified user record.
- * This method responds to the datagrid's OnDeleteCommand event.
- * @param TDataGrid the event sender
- * @param TDataGridCommandEventParameter the event parameter
- */
- public function deleteButtonClicked($sender,$param)
- {
- // obtains the datagrid item that contains the clicked delete button
- $item=$param->Item;
- // obtains the primary key corresponding to the datagrid item
- $username=$this->UserGrid->DataKeys[$item->ItemIndex];
- // deletes the user record with the specified username primary key
- UserRecord::finder()->deleteByPk($username);
- }
-}
-
+UserGrid->DataSource=UserRecord::finder()->findAll();
+ // binds the data to interface components
+ $this->UserGrid->dataBind();
+ }
+
+ /**
+ * Deletes a specified user record.
+ * This method responds to the datagrid's OnDeleteCommand event.
+ * @param TDataGrid the event sender
+ * @param TDataGridCommandEventParameter the event parameter
+ */
+ public function deleteButtonClicked($sender,$param)
+ {
+ // obtains the datagrid item that contains the clicked delete button
+ $item=$param->Item;
+ // obtains the primary key corresponding to the datagrid item
+ $username=$this->UserGrid->DataKeys[$item->ItemIndex];
+ // deletes the user record with the specified username primary key
+ UserRecord::finder()->deleteByPk($username);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/EditUser.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/EditUser.php
index 81538c33..f8c61463 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/EditUser.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/EditUser.php
@@ -1,83 +1,83 @@
-IsPostBack) // if the page is initially requested
- {
- // Retrieves the existing user data. This is equivalent to:
- // $userRecord=$this->getUserRecord();
- $userRecord=$this->UserRecord;
-
- // Populates the input controls with the existing user data
- $this->Username->Text=$userRecord->username;
- $this->Email->Text=$userRecord->email;
- $this->Role->SelectedValue=$userRecord->role;
- $this->FirstName->Text=$userRecord->first_name;
- $this->LastName->Text=$userRecord->last_name;
- }
- }
-
- /**
- * Saves the user account if all inputs are valid.
- * This method responds to the OnClick event of the "save" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // Retrieves the existing user data. This is equivalent to:
- $userRecord=$this->UserRecord;
-
- // Fetches the input data
- $userRecord->username=$this->Username->Text;
- // update password when the input is not empty
- if(!empty($this->Password->Text))
- $userRecord->password=$this->Password->Text;
- $userRecord->email=$this->Email->Text;
- // update the role if the current user is an administrator
- if($this->User->IsAdmin)
- $userRecord->role=(int)$this->Role->SelectedValue;
- $userRecord->first_name=$this->FirstName->Text;
- $userRecord->last_name=$this->LastName->Text;
-
- // saves to the database via Active Record mechanism
- $userRecord->save();
-
- // redirects the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
- }
-
- /**
- * Returns the user data to be editted.
- * @return UserRecord the user data to be editted.
- * @throws THttpException if the user data is not found.
- */
- protected function getUserRecord()
- {
- // the user to be editted is the currently logged-in user
- $username=$this->User->Name;
- // if the 'username' GET var is not empty and the current user
- // is an administrator, we use the GET var value instead.
- if($this->User->IsAdmin && $this->Request['username']!==null)
- $username=$this->Request['username'];
-
- // use Active Record to look for the specified username
- $userRecord=UserRecord::finder()->findByPk($username);
- if(!($userRecord instanceof UserRecord))
- throw new THttpException(500,'Username is invalid.');
- return $userRecord;
- }
-}
-
+IsPostBack) // if the page is initially requested
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ // $userRecord=$this->getUserRecord();
+ $userRecord=$this->UserRecord;
+
+ // Populates the input controls with the existing user data
+ $this->Username->Text=$userRecord->username;
+ $this->Email->Text=$userRecord->email;
+ $this->Role->SelectedValue=$userRecord->role;
+ $this->FirstName->Text=$userRecord->first_name;
+ $this->LastName->Text=$userRecord->last_name;
+ }
+ }
+
+ /**
+ * Saves the user account if all inputs are valid.
+ * This method responds to the OnClick event of the "save" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ $userRecord=$this->UserRecord;
+
+ // Fetches the input data
+ $userRecord->username=$this->Username->Text;
+ // update password when the input is not empty
+ if(!empty($this->Password->Text))
+ $userRecord->password=$this->Password->Text;
+ $userRecord->email=$this->Email->Text;
+ // update the role if the current user is an administrator
+ if($this->User->IsAdmin)
+ $userRecord->role=(int)$this->Role->SelectedValue;
+ $userRecord->first_name=$this->FirstName->Text;
+ $userRecord->last_name=$this->LastName->Text;
+
+ // saves to the database via Active Record mechanism
+ $userRecord->save();
+
+ // redirects the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+ }
+
+ /**
+ * Returns the user data to be editted.
+ * @return UserRecord the user data to be editted.
+ * @throws THttpException if the user data is not found.
+ */
+ protected function getUserRecord()
+ {
+ // the user to be editted is the currently logged-in user
+ $username=$this->User->Name;
+ // if the 'username' GET var is not empty and the current user
+ // is an administrator, we use the GET var value instead.
+ if($this->User->IsAdmin && $this->Request['username']!==null)
+ $username=$this->Request['username'];
+
+ // use Active Record to look for the specified username
+ $userRecord=UserRecord::finder()->findByPk($username);
+ if(!($userRecord instanceof UserRecord))
+ throw new THttpException(500,'Username is invalid.');
+ return $userRecord;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/LoginUser.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/LoginUser.php
index a0955490..407906ae 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/LoginUser.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/LoginUser.php
@@ -1,37 +1,37 @@
-Application->getModule('auth');
- if(!$authManager->login($this->Username->Text,$this->Password->Text))
- $param->IsValid=false; // tell the validator that validation fails
- }
-
- /**
- * Redirects the user's browser to appropriate URL if login succeeds.
- * This method responds to the login button's OnClick event.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function loginButtonClicked($sender,$param)
- {
- if($this->Page->IsValid) // all validations succeed
- {
- // obtain the URL of the privileged page that the user wanted to visit originally
- $url=$this->Application->getModule('auth')->ReturnUrl;
- if(empty($url)) // the user accesses the login page directly
- $url=$this->Service->DefaultPageUrl;
- $this->Response->redirect($url);
- }
- }
-}
-
+Application->getModule('auth');
+ if(!$authManager->login($this->Username->Text,$this->Password->Text))
+ $param->IsValid=false; // tell the validator that validation fails
+ }
+
+ /**
+ * Redirects the user's browser to appropriate URL if login succeeds.
+ * This method responds to the login button's OnClick event.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function loginButtonClicked($sender,$param)
+ {
+ if($this->Page->IsValid) // all validations succeed
+ {
+ // obtain the URL of the privileged page that the user wanted to visit originally
+ $url=$this->Application->getModule('auth')->ReturnUrl;
+ if(empty($url)) // the user accesses the login page directly
+ $url=$this->Service->DefaultPageUrl;
+ $this->Response->redirect($url);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/NewUser.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/NewUser.php
index 76e8cb88..3bf6768a 100644
--- a/demos/blog-tutorial/samples/day4/blog/protected/pages/users/NewUser.php
+++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/users/NewUser.php
@@ -1,45 +1,45 @@
-IsValid=UserRecord::finder()->findByPk($this->Username->Text)===null;
- }
-
- /**
- * Creates a new user account if all inputs are valid.
- * This method responds to the OnClick event of the "create" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function createButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // populates a UserRecord object with user inputs
- $userRecord=new UserRecord;
- $userRecord->username=$this->Username->Text;
- $userRecord->password=$this->Password->Text;
- $userRecord->email=$this->Email->Text;
- $userRecord->role=(int)$this->Role->SelectedValue;
- $userRecord->first_name=$this->FirstName->Text;
- $userRecord->last_name=$this->LastName->Text;
-
- // saves to the database via Active Record mechanism
- $userRecord->save();
-
- // redirects the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
- }
-}
-
+IsValid=UserRecord::finder()->findByPk($this->Username->Text)===null;
+ }
+
+ /**
+ * Creates a new user account if all inputs are valid.
+ * This method responds to the OnClick event of the "create" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function createButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // populates a UserRecord object with user inputs
+ $userRecord=new UserRecord;
+ $userRecord->username=$this->Username->Text;
+ $userRecord->password=$this->Password->Text;
+ $userRecord->email=$this->Email->Text;
+ $userRecord->role=(int)$this->Role->SelectedValue;
+ $userRecord->first_name=$this->FirstName->Text;
+ $userRecord->last_name=$this->LastName->Text;
+
+ // saves to the database via Active Record mechanism
+ $userRecord->save();
+
+ // redirects the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/index.php b/demos/blog-tutorial/samples/day5/blog/index.php
index 7ccffe49..bffafde2 100644
--- a/demos/blog-tutorial/samples/day5/blog/index.php
+++ b/demos/blog-tutorial/samples/day5/blog/index.php
@@ -1,22 +1,22 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php b/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php
index 56b71f8a..e8908ba7 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/BlogErrorHandler.php
@@ -1,40 +1,40 @@
-getErrorMessage(),TLogger::ERROR,'BlogApplication');
- // call parent implementation to display the error
- parent::handleExternalError($statusCode,$exception);
- }
-}
-
+getErrorMessage(),TLogger::ERROR,'BlogApplication');
+ // call parent implementation to display the error
+ parent::handleExternalError($statusCode,$exception);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/BlogException.php b/demos/blog-tutorial/samples/day5/blog/protected/BlogException.php
index fd17fc84..946a1bfe 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/BlogException.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/BlogException.php
@@ -1,7 +1,7 @@
-
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/BlogUser.php b/demos/blog-tutorial/samples/day5/blog/protected/BlogUser.php
index 6b9e0a23..4f094a0c 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/BlogUser.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/BlogUser.php
@@ -1,59 +1,59 @@
-findByPk($username);
- if($userRecord instanceof UserRecord) // if found
- {
- $user=new BlogUser($this->Manager);
- $user->Name=$username; // set username
- $user->Roles=($userRecord->role==1?'admin':'user'); // set role
- $user->IsGuest=false; // the user is not a guest
- return $user;
- }
- else
- return null;
- }
-
- /**
- * Checks if the specified (username, password) is valid.
- * This method is required by TDbUser.
- * @param string username
- * @param string password
- * @return boolean whether the username and password are valid.
- */
- public function validateUser($username,$password)
- {
- // use UserRecord Active Record to look for the (username, password) pair.
- return UserRecord::finder()->findBy_username_AND_password($username,$password)!==null;
- }
-
- /**
- * @return boolean whether this user is an administrator.
- */
- public function getIsAdmin()
- {
- return $this->isInRole('admin');
- }
-}
-
+findByPk($username);
+ if($userRecord instanceof UserRecord) // if found
+ {
+ $user=new BlogUser($this->Manager);
+ $user->Name=$username; // set username
+ $user->Roles=($userRecord->role==1?'admin':'user'); // set role
+ $user->IsGuest=false; // the user is not a guest
+ return $user;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Checks if the specified (username, password) is valid.
+ * This method is required by TDbUser.
+ * @param string username
+ * @param string password
+ * @return boolean whether the username and password are valid.
+ */
+ public function validateUser($username,$password)
+ {
+ // use UserRecord Active Record to look for the (username, password) pair.
+ return UserRecord::finder()->findBy_username_AND_password($username,$password)!==null;
+ }
+
+ /**
+ * @return boolean whether this user is an administrator.
+ */
+ public function getIsAdmin()
+ {
+ return $this->isInRole('admin');
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/database/PostRecord.php b/demos/blog-tutorial/samples/day5/blog/protected/database/PostRecord.php
index 25702727..3407c09b 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/database/PostRecord.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/database/PostRecord.php
@@ -1,28 +1,28 @@
- array(self::BELONGS_TO, 'UserRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::BELONGS_TO, 'UserRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/database/UserRecord.php b/demos/blog-tutorial/samples/day5/blog/protected/database/UserRecord.php
index 2051e5de..021f8b09 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/database/UserRecord.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/database/UserRecord.php
@@ -1,28 +1,28 @@
- array(self::HAS_MANY, 'PostRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'PostRecord'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/layouts/MainLayout.php b/demos/blog-tutorial/samples/day5/blog/protected/layouts/MainLayout.php
index 46c1483d..f605f75c 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/layouts/MainLayout.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/layouts/MainLayout.php
@@ -1,19 +1,19 @@
-Application->getModule('auth')->logout();
- $url=$this->Service->constructUrl($this->Service->DefaultPage);
- $this->Response->redirect($url);
- }
-}
-
+Application->getModule('auth')->logout();
+ $url=$this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($url);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/Contact.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/Contact.php
index b6ce575e..77d7374a 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/Contact.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/Contact.php
@@ -1,30 +1,30 @@
-IsValid) // check if input validation is successful
- {
- // obtain the user name, email, feedback from the textboxes
- $name = $this->Name->Text;
- $email = $this->Email->Text;
- $feedback = $this->Feedback->Text;
-
- // send an email to administrator with the above information
- $this->mailFeedback($name, $email, $feedback);
- }
- }
-
- protected function mailFeedback($name, $email, $feedback)
- {
- // implementation of sending the feedback email
- }
-}
-
+IsValid) // check if input validation is successful
+ {
+ // obtain the user name, email, feedback from the textboxes
+ $name = $this->Name->Text;
+ $email = $this->Email->Text;
+ $feedback = $this->Feedback->Text;
+
+ // send an email to administrator with the above information
+ $this->mailFeedback($name, $email, $feedback);
+ }
+ }
+
+ protected function mailFeedback($name, $email, $feedback)
+ {
+ // implementation of sending the feedback email
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/EditPost.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/EditPost.php
index e137b85e..1b0f82b6 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/EditPost.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/EditPost.php
@@ -1,72 +1,72 @@
-getPost();
- $postRecord=$this->Post;
- // Authorization check: only the author or the administrator can edit the post
- if($postRecord->author_id!==$this->User->Name && !$this->User->IsAdmin)
- throw new THttpException(500,'You are not allowed to edit this post.');
-
- if(!$this->IsPostBack) // if the page is initially requested
- {
- // Populates the input controls with the existing post data
- $this->TitleEdit->Text=$postRecord->title;
- $this->ContentEdit->Text=$postRecord->content;
- }
- }
-
- /**
- * Saves the post if all inputs are valid.
- * This method responds to the OnClick event of the "Save" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // Retrieves the existing user data. This is equivalent to:
- // $postRecord=$this->getPost();
- $postRecord=$this->Post;
-
- // Fetches the input data
- $postRecord->title=$this->TitleEdit->SafeText;
- $postRecord->content=$this->ContentEdit->SafeText;
-
- // saves to the database via Active Record mechanism
- $postRecord->save();
-
- // redirects the browser to the ReadPost page
- $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
- $this->Response->redirect($url);
- }
- }
-
- /**
- * Returns the post data to be editted.
- * @return PostRecord the post data to be editted.
- * @throws THttpException if the post data is not found.
- */
- protected function getPost()
- {
- // the ID of the post to be editted is passed via GET parameter 'id'
- $postID=(int)$this->Request['id'];
- // use Active Record to look for the specified post ID
- $postRecord=PostRecord::finder()->findByPk($postID);
- if($postRecord===null)
- throw new THttpException(500,'Post is not found.');
- return $postRecord;
- }
-}
-
+getPost();
+ $postRecord=$this->Post;
+ // Authorization check: only the author or the administrator can edit the post
+ if($postRecord->author_id!==$this->User->Name && !$this->User->IsAdmin)
+ throw new THttpException(500,'You are not allowed to edit this post.');
+
+ if(!$this->IsPostBack) // if the page is initially requested
+ {
+ // Populates the input controls with the existing post data
+ $this->TitleEdit->Text=$postRecord->title;
+ $this->ContentEdit->Text=$postRecord->content;
+ }
+ }
+
+ /**
+ * Saves the post if all inputs are valid.
+ * This method responds to the OnClick event of the "Save" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ // $postRecord=$this->getPost();
+ $postRecord=$this->Post;
+
+ // Fetches the input data
+ $postRecord->title=$this->TitleEdit->SafeText;
+ $postRecord->content=$this->ContentEdit->SafeText;
+
+ // saves to the database via Active Record mechanism
+ $postRecord->save();
+
+ // redirects the browser to the ReadPost page
+ $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
+ $this->Response->redirect($url);
+ }
+ }
+
+ /**
+ * Returns the post data to be editted.
+ * @return PostRecord the post data to be editted.
+ * @throws THttpException if the post data is not found.
+ */
+ protected function getPost()
+ {
+ // the ID of the post to be editted is passed via GET parameter 'id'
+ $postID=(int)$this->Request['id'];
+ // use Active Record to look for the specified post ID
+ $postRecord=PostRecord::finder()->findByPk($postID);
+ if($postRecord===null)
+ throw new THttpException(500,'Post is not found.');
+ return $postRecord;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ListPost.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ListPost.php
index 7402dace..ae5a7eeb 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ListPost.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ListPost.php
@@ -1,64 +1,64 @@
-IsPostBack) // if the page is requested the first time
- {
- // get the total number of posts available
- $this->Repeater->VirtualItemCount=PostRecord::finder()->count();
- // populates post data into the repeater
- $this->populateData();
- }
- }
-
- /**
- * Event handler to the OnPageIndexChanged event of the pager.
- * This method is invoked when the user clicks on a page button
- * and thus changes the page of posts to display.
- */
- public function pageChanged($sender,$param)
- {
- // change the current page index to the new one
- $this->Repeater->CurrentPageIndex=$param->NewPageIndex;
- // re-populate data into the repeater
- $this->populateData();
- }
-
- /**
- * Determines which page of posts to be displayed and
- * populates the repeater with the fetched data.
- */
- protected function populateData()
- {
- $offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
- $limit=$this->Repeater->PageSize;
- if($offset+$limit>$this->Repeater->VirtualItemCount)
- $limit=$this->Repeater->VirtualItemCount-$offset;
- $this->Repeater->DataSource=$this->getPosts($offset,$limit);
- $this->Repeater->dataBind();
- }
-
- /**
- * Fetches posts from database with offset and limit.
- */
- protected function getPosts($offset, $limit)
- {
- // Construts a query criteria
- $criteria=new TActiveRecordCriteria;
- $criteria->OrdersBy['create_time']='desc';
- $criteria->Limit=$limit;
- $criteria->Offset=$offset;
- // query for the posts with the above criteria and with author information
- return PostRecord::finder()->withAuthor()->findAll($criteria);
- }
-}
-
+IsPostBack) // if the page is requested the first time
+ {
+ // get the total number of posts available
+ $this->Repeater->VirtualItemCount=PostRecord::finder()->count();
+ // populates post data into the repeater
+ $this->populateData();
+ }
+ }
+
+ /**
+ * Event handler to the OnPageIndexChanged event of the pager.
+ * This method is invoked when the user clicks on a page button
+ * and thus changes the page of posts to display.
+ */
+ public function pageChanged($sender,$param)
+ {
+ // change the current page index to the new one
+ $this->Repeater->CurrentPageIndex=$param->NewPageIndex;
+ // re-populate data into the repeater
+ $this->populateData();
+ }
+
+ /**
+ * Determines which page of posts to be displayed and
+ * populates the repeater with the fetched data.
+ */
+ protected function populateData()
+ {
+ $offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
+ $limit=$this->Repeater->PageSize;
+ if($offset+$limit>$this->Repeater->VirtualItemCount)
+ $limit=$this->Repeater->VirtualItemCount-$offset;
+ $this->Repeater->DataSource=$this->getPosts($offset,$limit);
+ $this->Repeater->dataBind();
+ }
+
+ /**
+ * Fetches posts from database with offset and limit.
+ */
+ protected function getPosts($offset, $limit)
+ {
+ // Construts a query criteria
+ $criteria=new TActiveRecordCriteria;
+ $criteria->OrdersBy['create_time']='desc';
+ $criteria->Limit=$limit;
+ $criteria->Offset=$offset;
+ // query for the posts with the above criteria and with author information
+ return PostRecord::finder()->withAuthor()->findAll($criteria);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/NewPost.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/NewPost.php
index a5e3ea4d..d3a36133 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/NewPost.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/NewPost.php
@@ -1,34 +1,34 @@
-IsValid) // when all validations succeed
- {
- // populates a PostRecord object with user inputs
- $postRecord=new PostRecord;
- // using SafeText instead of Text avoids Cross Site Scripting attack
- $postRecord->title=$this->TitleEdit->SafeText;
- $postRecord->content=$this->ContentEdit->SafeText;
- $postRecord->author_id=$this->User->Name;
- $postRecord->create_time=time();
- $postRecord->status=0;
-
- // saves to the database via Active Record mechanism
- $postRecord->save();
-
- // redirects the browser to the newly created post page
- $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
- $this->Response->redirect($url);
- }
- }
-}
-
+IsValid) // when all validations succeed
+ {
+ // populates a PostRecord object with user inputs
+ $postRecord=new PostRecord;
+ // using SafeText instead of Text avoids Cross Site Scripting attack
+ $postRecord->title=$this->TitleEdit->SafeText;
+ $postRecord->content=$this->ContentEdit->SafeText;
+ $postRecord->author_id=$this->User->Name;
+ $postRecord->create_time=time();
+ $postRecord->status=0;
+
+ // saves to the database via Active Record mechanism
+ $postRecord->save();
+
+ // redirects the browser to the newly created post page
+ $url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
+ $this->Response->redirect($url);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/PostRenderer.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/PostRenderer.php
index cf0539a1..ed80f10c 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/PostRenderer.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/PostRenderer.php
@@ -1,7 +1,7 @@
-
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ReadPost.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ReadPost.php
index 0c120824..ab7429c3 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ReadPost.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ReadPost.php
@@ -1,59 +1,59 @@
-Request['id'];
- // retrieves PostRecord with author information filled in
- $this->_post=PostRecord::finder()->withAuthor()->findByPk($postID);
- if($this->_post===null) // if post id is invalid
- throw new BlogException(500,'Unable to find the specified post.');
- // set the page title as the post title
- $this->Title=$this->_post->title;
- }
-
- /**
- * @return PostRecord the PostRecord currently being viewed
- */
- public function getPost()
- {
- return $this->_post;
- }
-
- /**
- * Deletes the post currently being viewed
- * This method is invoked when the user clicks on the "Delete" button
- */
- public function deletePost($sender,$param)
- {
- // only the author or the administrator can delete a post
- if(!$this->canEdit())
- throw new THttpException('You are not allowed to perform this action.');
- // delete it from DB
- $this->_post->delete();
- // redirect the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
-
- /**
- * @return boolean whether the current user can edit/delete the post being viewed
- */
- public function canEdit()
- {
- // only the author or the administrator can edit/delete a post
- return $this->User->Name===$this->Post->author_id || $this->User->IsAdmin;
- }
-}
-
+Request['id'];
+ // retrieves PostRecord with author information filled in
+ $this->_post=PostRecord::finder()->withAuthor()->findByPk($postID);
+ if($this->_post===null) // if post id is invalid
+ throw new BlogException(500,'Unable to find the specified post.');
+ // set the page title as the post title
+ $this->Title=$this->_post->title;
+ }
+
+ /**
+ * @return PostRecord the PostRecord currently being viewed
+ */
+ public function getPost()
+ {
+ return $this->_post;
+ }
+
+ /**
+ * Deletes the post currently being viewed
+ * This method is invoked when the user clicks on the "Delete" button
+ */
+ public function deletePost($sender,$param)
+ {
+ // only the author or the administrator can delete a post
+ if(!$this->canEdit())
+ throw new THttpException('You are not allowed to perform this action.');
+ // delete it from DB
+ $this->_post->delete();
+ // redirect the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+
+ /**
+ * @return boolean whether the current user can edit/delete the post being viewed
+ */
+ public function canEdit()
+ {
+ // only the author or the administrator can edit/delete a post
+ return $this->User->Name===$this->Post->author_id || $this->User->IsAdmin;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/AdminUser.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/AdminUser.php
index ad8f6e3d..ad668e1a 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/AdminUser.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/AdminUser.php
@@ -1,36 +1,36 @@
-UserGrid->DataSource=UserRecord::finder()->findAll();
- // binds the data to interface components
- $this->UserGrid->dataBind();
- }
-
- /**
- * Deletes a specified user record.
- * This method responds to the datagrid's OnDeleteCommand event.
- * @param TDataGrid the event sender
- * @param TDataGridCommandEventParameter the event parameter
- */
- public function deleteButtonClicked($sender,$param)
- {
- // obtains the datagrid item that contains the clicked delete button
- $item=$param->Item;
- // obtains the primary key corresponding to the datagrid item
- $username=$this->UserGrid->DataKeys[$item->ItemIndex];
- // deletes the user record with the specified username primary key
- UserRecord::finder()->deleteByPk($username);
- }
-}
-
+UserGrid->DataSource=UserRecord::finder()->findAll();
+ // binds the data to interface components
+ $this->UserGrid->dataBind();
+ }
+
+ /**
+ * Deletes a specified user record.
+ * This method responds to the datagrid's OnDeleteCommand event.
+ * @param TDataGrid the event sender
+ * @param TDataGridCommandEventParameter the event parameter
+ */
+ public function deleteButtonClicked($sender,$param)
+ {
+ // obtains the datagrid item that contains the clicked delete button
+ $item=$param->Item;
+ // obtains the primary key corresponding to the datagrid item
+ $username=$this->UserGrid->DataKeys[$item->ItemIndex];
+ // deletes the user record with the specified username primary key
+ UserRecord::finder()->deleteByPk($username);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/EditUser.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/EditUser.php
index 81538c33..f8c61463 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/EditUser.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/EditUser.php
@@ -1,83 +1,83 @@
-IsPostBack) // if the page is initially requested
- {
- // Retrieves the existing user data. This is equivalent to:
- // $userRecord=$this->getUserRecord();
- $userRecord=$this->UserRecord;
-
- // Populates the input controls with the existing user data
- $this->Username->Text=$userRecord->username;
- $this->Email->Text=$userRecord->email;
- $this->Role->SelectedValue=$userRecord->role;
- $this->FirstName->Text=$userRecord->first_name;
- $this->LastName->Text=$userRecord->last_name;
- }
- }
-
- /**
- * Saves the user account if all inputs are valid.
- * This method responds to the OnClick event of the "save" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // Retrieves the existing user data. This is equivalent to:
- $userRecord=$this->UserRecord;
-
- // Fetches the input data
- $userRecord->username=$this->Username->Text;
- // update password when the input is not empty
- if(!empty($this->Password->Text))
- $userRecord->password=$this->Password->Text;
- $userRecord->email=$this->Email->Text;
- // update the role if the current user is an administrator
- if($this->User->IsAdmin)
- $userRecord->role=(int)$this->Role->SelectedValue;
- $userRecord->first_name=$this->FirstName->Text;
- $userRecord->last_name=$this->LastName->Text;
-
- // saves to the database via Active Record mechanism
- $userRecord->save();
-
- // redirects the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
- }
-
- /**
- * Returns the user data to be editted.
- * @return UserRecord the user data to be editted.
- * @throws THttpException if the user data is not found.
- */
- protected function getUserRecord()
- {
- // the user to be editted is the currently logged-in user
- $username=$this->User->Name;
- // if the 'username' GET var is not empty and the current user
- // is an administrator, we use the GET var value instead.
- if($this->User->IsAdmin && $this->Request['username']!==null)
- $username=$this->Request['username'];
-
- // use Active Record to look for the specified username
- $userRecord=UserRecord::finder()->findByPk($username);
- if(!($userRecord instanceof UserRecord))
- throw new THttpException(500,'Username is invalid.');
- return $userRecord;
- }
-}
-
+IsPostBack) // if the page is initially requested
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ // $userRecord=$this->getUserRecord();
+ $userRecord=$this->UserRecord;
+
+ // Populates the input controls with the existing user data
+ $this->Username->Text=$userRecord->username;
+ $this->Email->Text=$userRecord->email;
+ $this->Role->SelectedValue=$userRecord->role;
+ $this->FirstName->Text=$userRecord->first_name;
+ $this->LastName->Text=$userRecord->last_name;
+ }
+ }
+
+ /**
+ * Saves the user account if all inputs are valid.
+ * This method responds to the OnClick event of the "save" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // Retrieves the existing user data. This is equivalent to:
+ $userRecord=$this->UserRecord;
+
+ // Fetches the input data
+ $userRecord->username=$this->Username->Text;
+ // update password when the input is not empty
+ if(!empty($this->Password->Text))
+ $userRecord->password=$this->Password->Text;
+ $userRecord->email=$this->Email->Text;
+ // update the role if the current user is an administrator
+ if($this->User->IsAdmin)
+ $userRecord->role=(int)$this->Role->SelectedValue;
+ $userRecord->first_name=$this->FirstName->Text;
+ $userRecord->last_name=$this->LastName->Text;
+
+ // saves to the database via Active Record mechanism
+ $userRecord->save();
+
+ // redirects the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+ }
+
+ /**
+ * Returns the user data to be editted.
+ * @return UserRecord the user data to be editted.
+ * @throws THttpException if the user data is not found.
+ */
+ protected function getUserRecord()
+ {
+ // the user to be editted is the currently logged-in user
+ $username=$this->User->Name;
+ // if the 'username' GET var is not empty and the current user
+ // is an administrator, we use the GET var value instead.
+ if($this->User->IsAdmin && $this->Request['username']!==null)
+ $username=$this->Request['username'];
+
+ // use Active Record to look for the specified username
+ $userRecord=UserRecord::finder()->findByPk($username);
+ if(!($userRecord instanceof UserRecord))
+ throw new THttpException(500,'Username is invalid.');
+ return $userRecord;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/LoginUser.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/LoginUser.php
index a0955490..407906ae 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/LoginUser.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/LoginUser.php
@@ -1,37 +1,37 @@
-Application->getModule('auth');
- if(!$authManager->login($this->Username->Text,$this->Password->Text))
- $param->IsValid=false; // tell the validator that validation fails
- }
-
- /**
- * Redirects the user's browser to appropriate URL if login succeeds.
- * This method responds to the login button's OnClick event.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function loginButtonClicked($sender,$param)
- {
- if($this->Page->IsValid) // all validations succeed
- {
- // obtain the URL of the privileged page that the user wanted to visit originally
- $url=$this->Application->getModule('auth')->ReturnUrl;
- if(empty($url)) // the user accesses the login page directly
- $url=$this->Service->DefaultPageUrl;
- $this->Response->redirect($url);
- }
- }
-}
-
+Application->getModule('auth');
+ if(!$authManager->login($this->Username->Text,$this->Password->Text))
+ $param->IsValid=false; // tell the validator that validation fails
+ }
+
+ /**
+ * Redirects the user's browser to appropriate URL if login succeeds.
+ * This method responds to the login button's OnClick event.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function loginButtonClicked($sender,$param)
+ {
+ if($this->Page->IsValid) // all validations succeed
+ {
+ // obtain the URL of the privileged page that the user wanted to visit originally
+ $url=$this->Application->getModule('auth')->ReturnUrl;
+ if(empty($url)) // the user accesses the login page directly
+ $url=$this->Service->DefaultPageUrl;
+ $this->Response->redirect($url);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/NewUser.php b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/NewUser.php
index 76e8cb88..3bf6768a 100644
--- a/demos/blog-tutorial/samples/day5/blog/protected/pages/users/NewUser.php
+++ b/demos/blog-tutorial/samples/day5/blog/protected/pages/users/NewUser.php
@@ -1,45 +1,45 @@
-IsValid=UserRecord::finder()->findByPk($this->Username->Text)===null;
- }
-
- /**
- * Creates a new user account if all inputs are valid.
- * This method responds to the OnClick event of the "create" button.
- * @param mixed event sender
- * @param mixed event parameter
- */
- public function createButtonClicked($sender,$param)
- {
- if($this->IsValid) // when all validations succeed
- {
- // populates a UserRecord object with user inputs
- $userRecord=new UserRecord;
- $userRecord->username=$this->Username->Text;
- $userRecord->password=$this->Password->Text;
- $userRecord->email=$this->Email->Text;
- $userRecord->role=(int)$this->Role->SelectedValue;
- $userRecord->first_name=$this->FirstName->Text;
- $userRecord->last_name=$this->LastName->Text;
-
- // saves to the database via Active Record mechanism
- $userRecord->save();
-
- // redirects the browser to the homepage
- $this->Response->redirect($this->Service->DefaultPageUrl);
- }
- }
-}
-
+IsValid=UserRecord::finder()->findByPk($this->Username->Text)===null;
+ }
+
+ /**
+ * Creates a new user account if all inputs are valid.
+ * This method responds to the OnClick event of the "create" button.
+ * @param mixed event sender
+ * @param mixed event parameter
+ */
+ public function createButtonClicked($sender,$param)
+ {
+ if($this->IsValid) // when all validations succeed
+ {
+ // populates a UserRecord object with user inputs
+ $userRecord=new UserRecord;
+ $userRecord->username=$this->Username->Text;
+ $userRecord->password=$this->Password->Text;
+ $userRecord->email=$this->Email->Text;
+ $userRecord->role=(int)$this->Role->SelectedValue;
+ $userRecord->first_name=$this->FirstName->Text;
+ $userRecord->last_name=$this->LastName->Text;
+
+ // saves to the database via Active Record mechanism
+ $userRecord->save();
+
+ // redirects the browser to the homepage
+ $this->Response->redirect($this->Service->DefaultPageUrl);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/index.php b/demos/blog/index.php
index 6bec1512..269b67ed 100644
--- a/demos/blog/index.php
+++ b/demos/blog/index.php
@@ -1,21 +1,21 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Common/BlogDataModule.php b/demos/blog/protected/Common/BlogDataModule.php
index 26dfc5cf..a071ba9a 100644
--- a/demos/blog/protected/Common/BlogDataModule.php
+++ b/demos/blog/protected/Common/BlogDataModule.php
@@ -1,708 +1,708 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * BlogDataModule class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class BlogDataModule extends TModule
-{
- const DB_FILE_EXT='.db';
- const DEFAULT_DB_FILE='Application.Data.Blog';
- private $_db=null;
- private $_dbFile=null;
-
- public function init($config)
- {
- $this->connectDatabase();
- }
-
- public function getDbFile()
- {
- if($this->_dbFile===null)
- $this->_dbFile=Prado::getPathOfNamespace(self::DEFAULT_DB_FILE,self::DB_FILE_EXT);
- return $this->_dbFile;
- }
-
- public function setDbFile($value)
- {
- if(($this->_dbFile=Prado::getPathOfNamespace($value,self::DB_FILE_EXT))===null)
- throw new BlogException(500,'blogdatamodule_dbfile_invalid',$value);
- }
-
- protected function createDatabase()
- {
- $schemaFile=dirname(__FILE__).'/schema.sql';
- $statements=explode(';',file_get_contents($schemaFile));
- foreach($statements as $statement)
- {
- if(trim($statement)!=='')
- {
- try {
- $command=$this->_db->createCommand($statement);
- $command->execute();
- }
- catch(TDbException $e)
- {
- throw new BlogException(500,'blogdatamodule_createdatabase_failed',$e->getErrorMessage(),$statement);
- }
- }
- }
- }
-
- protected function connectDatabase()
- {
- $dbFile=$this->getDbFile();
- $newDb=!is_file($dbFile);
-
- try {
- $this->_db=new TDbConnection("sqlite:".$dbFile);
- $this->_db->Active=true;
- }
- catch(TDbException $e)
- {
- throw new BlogException(500,'blogdatamodule_dbconnect_failed',$e->getErrorMessage());
- }
-
- if($newDb)
- $this->createDatabase();
- }
-
- protected function generateModifier($filter,$orderBy,$limit)
- {
- $modifier='';
- if($filter!=='')
- $modifier=' WHERE '.$filter;
- if($orderBy!=='')
- $modifier.=' ORDER BY '.$orderBy;
- if($limit!=='')
- $modifier.=' LIMIT '.$limit;
- return $modifier;
- }
-
- public function query($sql)
- {
- try {
- $command=$this->_db->createCommand($sql);
- return $command->query();
- }
- catch(TDbException $e)
- {
- throw new BlogException(500,'blogdatamodule_query_failed',$e->getErrorMessage(),$sql);
- }
- }
-
- protected function populateUserRecord($row)
- {
- $userRecord=new UserRecord;
- $userRecord->ID=(integer)$row['id'];
- $userRecord->Name=$row['name'];
- $userRecord->FullName=$row['full_name'];
- $userRecord->Role=(integer)$row['role'];
- $userRecord->Password=$row['passwd'];
- $userRecord->VerifyCode=$row['vcode'];
- $userRecord->Email=$row['email'];
- $userRecord->CreateTime=(integer)$row['reg_time'];
- $userRecord->Status=(integer)$row['status'];
- $userRecord->Website=$row['website'];
- return $userRecord;
- }
-
- public function queryUsers($filter='',$orderBy='',$limit='')
- {
- if($filter!=='')
- $filter='WHERE '.$filter;
- $sql="SELECT * FROM tblUsers $filter $orderBy $limit";
- $rows=$this->query($sql);
- $users=array();
- foreach($rows as $row)
- $users[]=$this->populateUserRecord($row);
- return $users;
- }
-
- public function queryUserCount($filter)
- {
- if($filter!=='')
- $filter='WHERE '.$filter;
- $sql="SELECT COUNT(id) AS user_count FROM tblUsers $filter";
- $result=$this->query($sql);
- if(($row=$result->read())!==false)
- return $row['user_count'];
- else
- return 0;
- }
-
- public function queryUserByID($id)
- {
- $sql="SELECT * FROM tblUsers WHERE id=$id";
- $result=$this->query($sql);
- if(($row=$result->read())!==false)
- return $this->populateUserRecord($row);
- else
- return null;
- }
-
- public function queryUserByName($name)
- {
- $command=$this->_db->createCommand("SELECT * FROM tblUsers WHERE name=?");
- $command->bindValue(1, $name);
-
- $result=$command->query();
-
- if(($row=$result->read())!==false)
- return $this->populateUserRecord($row);
- else
- return null;
- }
-
- public function insertUser($user)
- {
- $command=$this->_db->createCommand("INSERT INTO tblUsers ".
- "(name,full_name,role,passwd,email,reg_time,status,website) ".
- "VALUES (?,?,?,?,?,?,?,?)");
- $command->bindValue(1, $user->Name);
- $command->bindValue(2, $user->FullName);
- $command->bindValue(3, $user->Role);
- $command->bindValue(4, $user->Password);
- $command->bindValue(5, $user->Email);
- $command->bindValue(6, time());
- $command->bindValue(7, $user->Status);
- $command->bindValue(8, $user->Website);
- $command->execute();
-
- $user->ID=$this->_db->getLastInsertID();
- }
-
- public function updateUser($user)
- {
- $command=$this->_db->createCommand("UPDATE tblUsers SET
- name=?,
- full_name=?,
- role=?,
- passwd=?,
- vcode=?,
- email=?,
- status=?,
- website=?
- WHERE id=?");
- $command->bindValue(1, $user->Name);
- $command->bindValue(2, $user->FullName);
- $command->bindValue(3, $user->Role);
- $command->bindValue(4, $user->Password);
- $command->bindValue(5, $user->VerifyCode);
- $command->bindValue(6, $user->Email);
- $command->bindValue(7, $user->Status);
- $command->bindValue(8, $user->Website);
- $command->bindValue(9, $user->ID);
- $command->execute();
- }
-
- public function deleteUser($id)
- {
- $command=$this->_db->createCommand("DELETE FROM tblUsers WHERE id=?");
- $command->bindValue(1, $id);
- $command->execute();
- }
-
- protected function populatePostRecord($row)
- {
- $postRecord=new PostRecord;
- $postRecord->ID=(integer)$row['id'];
- $postRecord->AuthorID=(integer)$row['author_id'];
- if($row['author_full_name']!=='')
- $postRecord->AuthorName=$row['author_full_name'];
- else
- $postRecord->AuthorName=$row['author_name'];
- $postRecord->CreateTime=(integer)$row['create_time'];
- $postRecord->ModifyTime=(integer)$row['modify_time'];
- $postRecord->Title=$row['title'];
- $postRecord->Content=$row['content'];
- $postRecord->Status=(integer)$row['status'];
- $postRecord->CommentCount=(integer)$row['comment_count'];
- return $postRecord;
- }
-
- public function queryPosts($postFilter,$categoryFilter,$orderBy,$limit)
- {
- //FIXME this is insecure by design since it misses proper escaping
- $filter='';
- if($postFilter!=='')
- $filter.=" AND $postFilter";
- if($categoryFilter!=='')
- $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
- $sql="SELECT a.id AS id,
- a.author_id AS author_id,
- b.name AS author_name,
- b.full_name AS author_full_name,
- a.create_time AS create_time,
- a.modify_time AS modify_time,
- a.title AS title,
- a.content AS content,
- a.status AS status,
- a.comment_count AS comment_count
- FROM tblPosts a, tblUsers b
- WHERE a.author_id=b.id $filter $orderBy $limit";
- $rows=$this->query($sql);
- $posts=array();
- foreach($rows as $row)
- $posts[]=$this->populatePostRecord($row);
- return $posts;
- }
-
- public function queryPostsSearch($keywords,$orderBy,$limit)
- {
- $sql="SELECT a.id AS id,
- a.author_id AS author_id,
- b.name AS author_name,
- b.full_name AS author_full_name,
- a.create_time AS create_time,
- a.modify_time AS modify_time,
- a.title AS title,
- a.content AS content,
- a.status AS status,
- a.comment_count AS comment_count
- FROM tblPosts a, tblUsers b
- WHERE a.author_id=b.id AND a.status=0";
-
- foreach($keywords as $keyword)
- $sql.=" AND (content LIKE ? OR title LIKE ?)";
-
- $sql.=" $orderBy $limit";
-
- $command=$this->_db->createCommand($sql);
-
- $i=1;
- foreach($keywords as $keyword)
- {
- $command->bindValue($i, "%".$keyword."%");
- $i++;
- }
-
- $rows=$command->query();
-
- $posts=array();
- foreach($rows as $row)
- $posts[]=$this->populatePostRecord($row);
- return $posts;
-
- }
-
- public function queryPostCount($postFilter,$categoryFilter)
- {
- //FIXME this is insecure by design since it misses proper escaping
- $filter='';
- if($postFilter!=='')
- $filter.=" AND $postFilter";
- if($categoryFilter!=='')
- $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
- $sql="SELECT COUNT(a.id) AS post_count
- FROM tblPosts a, tblUsers b
- WHERE a.author_id=b.id $filter";
- $result=$this->query($sql);
- if(($row=$result->read())!==false)
- return $row['post_count'];
- else
- return 0;
- }
-
- public function queryPostByID($id)
- {
- $sql="SELECT a.id AS id,
- a.author_id AS author_id,
- b.name AS author_name,
- b.full_name AS author_full_name,
- a.create_time AS create_time,
- a.modify_time AS modify_time,
- a.title AS title,
- a.content AS content,
- a.status AS status,
- a.comment_count AS comment_count
- FROM tblPosts a, tblUsers b
- WHERE a.id=? AND a.author_id=b.id";
-
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $id);
-
- $result=$command->query();
-
- if(($row=$result->read())!==false)
- return $this->populatePostRecord($row);
- else
- return null;
- }
-
- public function insertPost($post,$catIDs)
- {
- $command=$this->_db->createCommand("INSERT INTO tblPosts
- (author_id,create_time,modify_time,title,content,status)
- VALUES (?,?,?,?,?,?)");
- $command->bindValue(1, $post->AuthorID);
- $command->bindValue(2, $post->CreateTime);
- $command->bindValue(3, $post->ModifyTime);
- $command->bindValue(4, $post->Title);
- $command->bindValue(5, $post->Content);
- $command->bindValue(6, $post->Status);
-
- $command->execute();
- $post->ID=$this->_db->getLastInsertID();
- foreach($catIDs as $catID)
- $this->insertPostCategory($post->ID,$catID);
- }
-
- public function updatePost($post,$newCatIDs=null)
- {
- if($newCatIDs!==null)
- {
- $cats=$this->queryCategoriesByPostID($post->ID);
- $catIDs=array();
- foreach($cats as $cat)
- $catIDs[]=$cat->ID;
- $deleteIDs=array_diff($catIDs,$newCatIDs);
- foreach($deleteIDs as $id)
- $this->deletePostCategory($post->ID,$id);
- $insertIDs=array_diff($newCatIDs,$catIDs);
- foreach($insertIDs as $id)
- $this->insertPostCategory($post->ID,$id);
- }
-
- $command=$this->_db->createCommand("UPDATE tblPosts SET
- modify_time=?,
- title=?,
- content=?,
- status=?
- WHERE id=?");
- $command->bindValue(1, $post->ModifyTime);
- $command->bindValue(2, $post->Title);
- $command->bindValue(3, $post->Content);
- $command->bindValue(4, $post->Status);
- $command->bindValue(5, $post->ID);
-
- $command->execute();
- }
-
- public function deletePost($id)
- {
- $cats=$this->queryCategoriesByPostID($id);
- foreach($cats as $cat)
- $this->deletePostCategory($id,$cat->ID);
-
- $command=$this->_db->createCommand("DELETE FROM tblComments WHERE post_id=?");
- $command->bindValue(1, $id);
- $command->execute();
-
- $command=$this->_db->createCommand("DELETE FROM tblPosts WHERE id=?");
- $command->bindValue(1, $id);
- $command->execute();
- }
-
- protected function populateCommentRecord($row)
- {
- $commentRecord=new CommentRecord;
- $commentRecord->ID=(integer)$row['id'];
- $commentRecord->PostID=(integer)$row['post_id'];
- $commentRecord->AuthorName=$row['author_name'];
- $commentRecord->AuthorEmail=$row['author_email'];
- $commentRecord->AuthorWebsite=$row['author_website'];
- $commentRecord->AuthorIP=$row['author_ip'];
- $commentRecord->CreateTime=(integer)$row['create_time'];
- $commentRecord->Content=$row['content'];
- $commentRecord->Status=(integer)$row['status'];
- return $commentRecord;
- }
-
- public function queryComments($filter,$orderBy,$limit)
- {
- //FIXME this is insecure by design since it misses proper escaping
- if($filter!=='')
- $filter='WHERE '.$filter;
- $sql="SELECT * FROM tblComments $filter $orderBy $limit";
- $rows=$this->query($sql);
- $comments=array();
- foreach($rows as $row)
- $comments[]=$this->populateCommentRecord($row);
- return $comments;
- }
-
- public function queryCommentsByPostID($id)
- {
- $sql="SELECT * FROM tblComments WHERE post_id=? ORDER BY create_time DESC";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $id);
-
- $rows=$command->query();
-
- $comments=array();
- foreach($rows as $row)
- $comments[]=$this->populateCommentRecord($row);
- return $comments;
- }
-
- public function insertComment($comment)
- {
- $sql="INSERT INTO tblComments
- (post_id,author_name,author_email,author_website,author_ip,create_time,status,content)
- VALUES (?,?,?,?,?,?,?,?)";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $comment->PostID);
- $command->bindValue(2, $comment->AuthorName);
- $command->bindValue(3, $comment->AuthorEmail);
- $command->bindValue(4, $comment->AuthorWebsite);
- $command->bindValue(5, $comment->AuthorIP);
- $command->bindValue(6, $comment->CreateTime);
- $command->bindValue(7, $comment->Status);
- $command->bindValue(8, $comment->Content);
-
- $command->execute();
- $comment->ID=$this->_db->getLastInsertID();
- $this->query("UPDATE tblPosts SET comment_count=comment_count+1 WHERE id={$comment->PostID}");
- }
-
- public function updateComment($comment)
- {
- $sql="UPDATE tblComments SET status=? WHERE id=?";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $comment->Status);
- $command->bindValue(2, $comment->ID);
-
- $command->execute();
- }
-
- public function deleteComment($id)
- {
- $sql="SELECT post_id FROM tblComments WHERE id=?";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $id);
- $result=$command->query();
-
- if(($row=$result->read())!==false)
- {
- $command=$this->_db->createCommand("DELETE FROM tblComments WHERE id=?");
- $command->bindValue(1, $id);
- $command->execute();
-
- $command=$this->_db->createCommand("UPDATE tblPosts SET comment_count=comment_count-1 WHERE id=?");
- $command->bindValue(1, $row['post_id']);
- $command->execute();
- }
- }
-
- protected function populateCategoryRecord($row)
- {
- $catRecord=new CategoryRecord;
- $catRecord->ID=(integer)$row['id'];
- $catRecord->Name=$row['name'];
- $catRecord->Description=$row['description'];
- $catRecord->PostCount=$row['post_count'];
- return $catRecord;
- }
-
- public function queryCategories()
- {
- $sql="SELECT * FROM tblCategories ORDER BY name ASC";
- $rows=$this->query($sql);
- $cats=array();
- foreach($rows as $row)
- $cats[]=$this->populateCategoryRecord($row);
- return $cats;
- }
-
- public function queryCategoriesByPostID($postID)
- {
- $sql="SELECT a.id AS id,
- a.name AS name,
- a.description AS description,
- a.post_count AS post_count
- FROM tblCategories a, tblPost2Category b
- WHERE a.id=b.category_id AND b.post_id=? ORDER BY a.name";
-
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $postID);
- $rows=$command->query();
-
- $cats=array();
- foreach($rows as $row)
- $cats[]=$this->populateCategoryRecord($row);
- return $cats;
- }
-
- public function queryCategoryByID($id)
- {
- $sql="SELECT * FROM tblCategories WHERE id=?";
-
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $id);
- $result=$command->query();
-
- if(($row=$result->read())!==false)
- return $this->populateCategoryRecord($row);
- else
- return null;
- }
-
- public function queryCategoryByName($name)
- {
- $sql="SELECT * FROM tblCategories WHERE name=?";
-
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $name);
- $result=$command->query();
-
- if(($row=$result->read())!==false)
- return $this->populateCategoryRecord($row);
- else
- return null;
- }
-
- public function insertCategory($category)
- {
- $sql="INSERT INTO tblCategories
- (name,description)
- VALUES (?,?)";
-
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $category->Name);
- $command->bindValue(2, $category->Description);
- $command->execute();
-
- $category->ID=$this->_db->getLastInsertID();
- }
-
- public function updateCategory($category)
- {
- $sql="UPDATE tblCategories SET name=?, description=?, post_count=? WHERE id=?";
-
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $category->Name);
- $command->bindValue(2, $category->Description);
- $command->bindValue(3, $category->PostCount);
- $command->bindValue(4, $category->ID);
-
- $command->execute();
- }
-
- public function deleteCategory($id)
- {
- $sql="DELETE FROM tblPost2Category WHERE category_id=?";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $id);
- $command->execute();
-
- $sql="DELETE FROM tblCategories WHERE id=?";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $id);
- $command->execute();
- }
-
- public function insertPostCategory($postID,$categoryID)
- {
- $sql="INSERT INTO tblPost2Category (post_id, category_id) VALUES (?, ?)";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $postID);
- $command->bindValue(2, $categoryID);
- $command->execute();
-
- $sql="UPDATE tblCategories SET post_count=post_count+1 WHERE id=?";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $categoryID);
- $command->execute();
-
- }
-
- public function deletePostCategory($postID,$categoryID)
- {
- $sql="DELETE FROM tblPost2Category WHERE post_id=? AND category_id=?";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $postID);
- $command->bindValue(2, $categoryID);
- $result=$command->query();
-
- if($result->getRowCount()>0)
- {
- $sql="UPDATE tblCategories SET post_count=post_count-1 WHERE id=?";
- $command=$this->_db->createCommand($sql);
- $command->bindValue(1, $categoryID);
- $command->execute();
- }
- }
-
- public function queryEarliestPostTime()
- {
- $sql="SELECT MIN(create_time) AS create_time FROM tblPosts";
- $result=$this->query($sql);
- if(($row=$result->read())!==false)
- return $row['create_time'];
- else
- return time();
- }
-}
-
-class UserRecord
-{
- const ROLE_USER=0;
- const ROLE_ADMIN=1;
- const STATUS_NORMAL=0;
- const STATUS_DISABLED=1;
- const STATUS_PENDING=2;
- public $ID;
- public $Name;
- public $FullName;
- public $Role;
- public $Password;
- public $VerifyCode;
- public $Email;
- public $CreateTime;
- public $Status;
- public $Website;
-}
-
-class PostRecord
-{
- const STATUS_PUBLISHED=0;
- const STATUS_DRAFT=1;
- const STATUS_PENDING=2;
- const STATUS_STICKY=3;
- public $ID;
- public $AuthorID;
- public $AuthorName;
- public $CreateTime;
- public $ModifyTime;
- public $Title;
- public $Content;
- public $Status;
- public $CommentCount;
-}
-
-class CommentRecord
-{
- public $ID;
- public $PostID;
- public $AuthorName;
- public $AuthorEmail;
- public $AuthorWebsite;
- public $AuthorIP;
- public $CreateTime;
- public $Status;
- public $Content;
-}
-
-class CategoryRecord
-{
- public $ID;
- public $Name;
- public $Description;
- public $PostCount;
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * BlogDataModule class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class BlogDataModule extends TModule
+{
+ const DB_FILE_EXT='.db';
+ const DEFAULT_DB_FILE='Application.Data.Blog';
+ private $_db=null;
+ private $_dbFile=null;
+
+ public function init($config)
+ {
+ $this->connectDatabase();
+ }
+
+ public function getDbFile()
+ {
+ if($this->_dbFile===null)
+ $this->_dbFile=Prado::getPathOfNamespace(self::DEFAULT_DB_FILE,self::DB_FILE_EXT);
+ return $this->_dbFile;
+ }
+
+ public function setDbFile($value)
+ {
+ if(($this->_dbFile=Prado::getPathOfNamespace($value,self::DB_FILE_EXT))===null)
+ throw new BlogException(500,'blogdatamodule_dbfile_invalid',$value);
+ }
+
+ protected function createDatabase()
+ {
+ $schemaFile=dirname(__FILE__).'/schema.sql';
+ $statements=explode(';',file_get_contents($schemaFile));
+ foreach($statements as $statement)
+ {
+ if(trim($statement)!=='')
+ {
+ try {
+ $command=$this->_db->createCommand($statement);
+ $command->execute();
+ }
+ catch(TDbException $e)
+ {
+ throw new BlogException(500,'blogdatamodule_createdatabase_failed',$e->getErrorMessage(),$statement);
+ }
+ }
+ }
+ }
+
+ protected function connectDatabase()
+ {
+ $dbFile=$this->getDbFile();
+ $newDb=!is_file($dbFile);
+
+ try {
+ $this->_db=new TDbConnection("sqlite:".$dbFile);
+ $this->_db->Active=true;
+ }
+ catch(TDbException $e)
+ {
+ throw new BlogException(500,'blogdatamodule_dbconnect_failed',$e->getErrorMessage());
+ }
+
+ if($newDb)
+ $this->createDatabase();
+ }
+
+ protected function generateModifier($filter,$orderBy,$limit)
+ {
+ $modifier='';
+ if($filter!=='')
+ $modifier=' WHERE '.$filter;
+ if($orderBy!=='')
+ $modifier.=' ORDER BY '.$orderBy;
+ if($limit!=='')
+ $modifier.=' LIMIT '.$limit;
+ return $modifier;
+ }
+
+ public function query($sql)
+ {
+ try {
+ $command=$this->_db->createCommand($sql);
+ return $command->query();
+ }
+ catch(TDbException $e)
+ {
+ throw new BlogException(500,'blogdatamodule_query_failed',$e->getErrorMessage(),$sql);
+ }
+ }
+
+ protected function populateUserRecord($row)
+ {
+ $userRecord=new UserRecord;
+ $userRecord->ID=(integer)$row['id'];
+ $userRecord->Name=$row['name'];
+ $userRecord->FullName=$row['full_name'];
+ $userRecord->Role=(integer)$row['role'];
+ $userRecord->Password=$row['passwd'];
+ $userRecord->VerifyCode=$row['vcode'];
+ $userRecord->Email=$row['email'];
+ $userRecord->CreateTime=(integer)$row['reg_time'];
+ $userRecord->Status=(integer)$row['status'];
+ $userRecord->Website=$row['website'];
+ return $userRecord;
+ }
+
+ public function queryUsers($filter='',$orderBy='',$limit='')
+ {
+ if($filter!=='')
+ $filter='WHERE '.$filter;
+ $sql="SELECT * FROM tblUsers $filter $orderBy $limit";
+ $rows=$this->query($sql);
+ $users=array();
+ foreach($rows as $row)
+ $users[]=$this->populateUserRecord($row);
+ return $users;
+ }
+
+ public function queryUserCount($filter)
+ {
+ if($filter!=='')
+ $filter='WHERE '.$filter;
+ $sql="SELECT COUNT(id) AS user_count FROM tblUsers $filter";
+ $result=$this->query($sql);
+ if(($row=$result->read())!==false)
+ return $row['user_count'];
+ else
+ return 0;
+ }
+
+ public function queryUserByID($id)
+ {
+ $sql="SELECT * FROM tblUsers WHERE id=$id";
+ $result=$this->query($sql);
+ if(($row=$result->read())!==false)
+ return $this->populateUserRecord($row);
+ else
+ return null;
+ }
+
+ public function queryUserByName($name)
+ {
+ $command=$this->_db->createCommand("SELECT * FROM tblUsers WHERE name=?");
+ $command->bindValue(1, $name);
+
+ $result=$command->query();
+
+ if(($row=$result->read())!==false)
+ return $this->populateUserRecord($row);
+ else
+ return null;
+ }
+
+ public function insertUser($user)
+ {
+ $command=$this->_db->createCommand("INSERT INTO tblUsers ".
+ "(name,full_name,role,passwd,email,reg_time,status,website) ".
+ "VALUES (?,?,?,?,?,?,?,?)");
+ $command->bindValue(1, $user->Name);
+ $command->bindValue(2, $user->FullName);
+ $command->bindValue(3, $user->Role);
+ $command->bindValue(4, $user->Password);
+ $command->bindValue(5, $user->Email);
+ $command->bindValue(6, time());
+ $command->bindValue(7, $user->Status);
+ $command->bindValue(8, $user->Website);
+ $command->execute();
+
+ $user->ID=$this->_db->getLastInsertID();
+ }
+
+ public function updateUser($user)
+ {
+ $command=$this->_db->createCommand("UPDATE tblUsers SET
+ name=?,
+ full_name=?,
+ role=?,
+ passwd=?,
+ vcode=?,
+ email=?,
+ status=?,
+ website=?
+ WHERE id=?");
+ $command->bindValue(1, $user->Name);
+ $command->bindValue(2, $user->FullName);
+ $command->bindValue(3, $user->Role);
+ $command->bindValue(4, $user->Password);
+ $command->bindValue(5, $user->VerifyCode);
+ $command->bindValue(6, $user->Email);
+ $command->bindValue(7, $user->Status);
+ $command->bindValue(8, $user->Website);
+ $command->bindValue(9, $user->ID);
+ $command->execute();
+ }
+
+ public function deleteUser($id)
+ {
+ $command=$this->_db->createCommand("DELETE FROM tblUsers WHERE id=?");
+ $command->bindValue(1, $id);
+ $command->execute();
+ }
+
+ protected function populatePostRecord($row)
+ {
+ $postRecord=new PostRecord;
+ $postRecord->ID=(integer)$row['id'];
+ $postRecord->AuthorID=(integer)$row['author_id'];
+ if($row['author_full_name']!=='')
+ $postRecord->AuthorName=$row['author_full_name'];
+ else
+ $postRecord->AuthorName=$row['author_name'];
+ $postRecord->CreateTime=(integer)$row['create_time'];
+ $postRecord->ModifyTime=(integer)$row['modify_time'];
+ $postRecord->Title=$row['title'];
+ $postRecord->Content=$row['content'];
+ $postRecord->Status=(integer)$row['status'];
+ $postRecord->CommentCount=(integer)$row['comment_count'];
+ return $postRecord;
+ }
+
+ public function queryPosts($postFilter,$categoryFilter,$orderBy,$limit)
+ {
+ //FIXME this is insecure by design since it misses proper escaping
+ $filter='';
+ if($postFilter!=='')
+ $filter.=" AND $postFilter";
+ if($categoryFilter!=='')
+ $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
+ $sql="SELECT a.id AS id,
+ a.author_id AS author_id,
+ b.name AS author_name,
+ b.full_name AS author_full_name,
+ a.create_time AS create_time,
+ a.modify_time AS modify_time,
+ a.title AS title,
+ a.content AS content,
+ a.status AS status,
+ a.comment_count AS comment_count
+ FROM tblPosts a, tblUsers b
+ WHERE a.author_id=b.id $filter $orderBy $limit";
+ $rows=$this->query($sql);
+ $posts=array();
+ foreach($rows as $row)
+ $posts[]=$this->populatePostRecord($row);
+ return $posts;
+ }
+
+ public function queryPostsSearch($keywords,$orderBy,$limit)
+ {
+ $sql="SELECT a.id AS id,
+ a.author_id AS author_id,
+ b.name AS author_name,
+ b.full_name AS author_full_name,
+ a.create_time AS create_time,
+ a.modify_time AS modify_time,
+ a.title AS title,
+ a.content AS content,
+ a.status AS status,
+ a.comment_count AS comment_count
+ FROM tblPosts a, tblUsers b
+ WHERE a.author_id=b.id AND a.status=0";
+
+ foreach($keywords as $keyword)
+ $sql.=" AND (content LIKE ? OR title LIKE ?)";
+
+ $sql.=" $orderBy $limit";
+
+ $command=$this->_db->createCommand($sql);
+
+ $i=1;
+ foreach($keywords as $keyword)
+ {
+ $command->bindValue($i, "%".$keyword."%");
+ $i++;
+ }
+
+ $rows=$command->query();
+
+ $posts=array();
+ foreach($rows as $row)
+ $posts[]=$this->populatePostRecord($row);
+ return $posts;
+
+ }
+
+ public function queryPostCount($postFilter,$categoryFilter)
+ {
+ //FIXME this is insecure by design since it misses proper escaping
+ $filter='';
+ if($postFilter!=='')
+ $filter.=" AND $postFilter";
+ if($categoryFilter!=='')
+ $filter.=" AND a.id IN (SELECT post_id AS id FROM tblPost2Category WHERE $categoryFilter)";
+ $sql="SELECT COUNT(a.id) AS post_count
+ FROM tblPosts a, tblUsers b
+ WHERE a.author_id=b.id $filter";
+ $result=$this->query($sql);
+ if(($row=$result->read())!==false)
+ return $row['post_count'];
+ else
+ return 0;
+ }
+
+ public function queryPostByID($id)
+ {
+ $sql="SELECT a.id AS id,
+ a.author_id AS author_id,
+ b.name AS author_name,
+ b.full_name AS author_full_name,
+ a.create_time AS create_time,
+ a.modify_time AS modify_time,
+ a.title AS title,
+ a.content AS content,
+ a.status AS status,
+ a.comment_count AS comment_count
+ FROM tblPosts a, tblUsers b
+ WHERE a.id=? AND a.author_id=b.id";
+
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $id);
+
+ $result=$command->query();
+
+ if(($row=$result->read())!==false)
+ return $this->populatePostRecord($row);
+ else
+ return null;
+ }
+
+ public function insertPost($post,$catIDs)
+ {
+ $command=$this->_db->createCommand("INSERT INTO tblPosts
+ (author_id,create_time,modify_time,title,content,status)
+ VALUES (?,?,?,?,?,?)");
+ $command->bindValue(1, $post->AuthorID);
+ $command->bindValue(2, $post->CreateTime);
+ $command->bindValue(3, $post->ModifyTime);
+ $command->bindValue(4, $post->Title);
+ $command->bindValue(5, $post->Content);
+ $command->bindValue(6, $post->Status);
+
+ $command->execute();
+ $post->ID=$this->_db->getLastInsertID();
+ foreach($catIDs as $catID)
+ $this->insertPostCategory($post->ID,$catID);
+ }
+
+ public function updatePost($post,$newCatIDs=null)
+ {
+ if($newCatIDs!==null)
+ {
+ $cats=$this->queryCategoriesByPostID($post->ID);
+ $catIDs=array();
+ foreach($cats as $cat)
+ $catIDs[]=$cat->ID;
+ $deleteIDs=array_diff($catIDs,$newCatIDs);
+ foreach($deleteIDs as $id)
+ $this->deletePostCategory($post->ID,$id);
+ $insertIDs=array_diff($newCatIDs,$catIDs);
+ foreach($insertIDs as $id)
+ $this->insertPostCategory($post->ID,$id);
+ }
+
+ $command=$this->_db->createCommand("UPDATE tblPosts SET
+ modify_time=?,
+ title=?,
+ content=?,
+ status=?
+ WHERE id=?");
+ $command->bindValue(1, $post->ModifyTime);
+ $command->bindValue(2, $post->Title);
+ $command->bindValue(3, $post->Content);
+ $command->bindValue(4, $post->Status);
+ $command->bindValue(5, $post->ID);
+
+ $command->execute();
+ }
+
+ public function deletePost($id)
+ {
+ $cats=$this->queryCategoriesByPostID($id);
+ foreach($cats as $cat)
+ $this->deletePostCategory($id,$cat->ID);
+
+ $command=$this->_db->createCommand("DELETE FROM tblComments WHERE post_id=?");
+ $command->bindValue(1, $id);
+ $command->execute();
+
+ $command=$this->_db->createCommand("DELETE FROM tblPosts WHERE id=?");
+ $command->bindValue(1, $id);
+ $command->execute();
+ }
+
+ protected function populateCommentRecord($row)
+ {
+ $commentRecord=new CommentRecord;
+ $commentRecord->ID=(integer)$row['id'];
+ $commentRecord->PostID=(integer)$row['post_id'];
+ $commentRecord->AuthorName=$row['author_name'];
+ $commentRecord->AuthorEmail=$row['author_email'];
+ $commentRecord->AuthorWebsite=$row['author_website'];
+ $commentRecord->AuthorIP=$row['author_ip'];
+ $commentRecord->CreateTime=(integer)$row['create_time'];
+ $commentRecord->Content=$row['content'];
+ $commentRecord->Status=(integer)$row['status'];
+ return $commentRecord;
+ }
+
+ public function queryComments($filter,$orderBy,$limit)
+ {
+ //FIXME this is insecure by design since it misses proper escaping
+ if($filter!=='')
+ $filter='WHERE '.$filter;
+ $sql="SELECT * FROM tblComments $filter $orderBy $limit";
+ $rows=$this->query($sql);
+ $comments=array();
+ foreach($rows as $row)
+ $comments[]=$this->populateCommentRecord($row);
+ return $comments;
+ }
+
+ public function queryCommentsByPostID($id)
+ {
+ $sql="SELECT * FROM tblComments WHERE post_id=? ORDER BY create_time DESC";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $id);
+
+ $rows=$command->query();
+
+ $comments=array();
+ foreach($rows as $row)
+ $comments[]=$this->populateCommentRecord($row);
+ return $comments;
+ }
+
+ public function insertComment($comment)
+ {
+ $sql="INSERT INTO tblComments
+ (post_id,author_name,author_email,author_website,author_ip,create_time,status,content)
+ VALUES (?,?,?,?,?,?,?,?)";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $comment->PostID);
+ $command->bindValue(2, $comment->AuthorName);
+ $command->bindValue(3, $comment->AuthorEmail);
+ $command->bindValue(4, $comment->AuthorWebsite);
+ $command->bindValue(5, $comment->AuthorIP);
+ $command->bindValue(6, $comment->CreateTime);
+ $command->bindValue(7, $comment->Status);
+ $command->bindValue(8, $comment->Content);
+
+ $command->execute();
+ $comment->ID=$this->_db->getLastInsertID();
+ $this->query("UPDATE tblPosts SET comment_count=comment_count+1 WHERE id={$comment->PostID}");
+ }
+
+ public function updateComment($comment)
+ {
+ $sql="UPDATE tblComments SET status=? WHERE id=?";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $comment->Status);
+ $command->bindValue(2, $comment->ID);
+
+ $command->execute();
+ }
+
+ public function deleteComment($id)
+ {
+ $sql="SELECT post_id FROM tblComments WHERE id=?";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $id);
+ $result=$command->query();
+
+ if(($row=$result->read())!==false)
+ {
+ $command=$this->_db->createCommand("DELETE FROM tblComments WHERE id=?");
+ $command->bindValue(1, $id);
+ $command->execute();
+
+ $command=$this->_db->createCommand("UPDATE tblPosts SET comment_count=comment_count-1 WHERE id=?");
+ $command->bindValue(1, $row['post_id']);
+ $command->execute();
+ }
+ }
+
+ protected function populateCategoryRecord($row)
+ {
+ $catRecord=new CategoryRecord;
+ $catRecord->ID=(integer)$row['id'];
+ $catRecord->Name=$row['name'];
+ $catRecord->Description=$row['description'];
+ $catRecord->PostCount=$row['post_count'];
+ return $catRecord;
+ }
+
+ public function queryCategories()
+ {
+ $sql="SELECT * FROM tblCategories ORDER BY name ASC";
+ $rows=$this->query($sql);
+ $cats=array();
+ foreach($rows as $row)
+ $cats[]=$this->populateCategoryRecord($row);
+ return $cats;
+ }
+
+ public function queryCategoriesByPostID($postID)
+ {
+ $sql="SELECT a.id AS id,
+ a.name AS name,
+ a.description AS description,
+ a.post_count AS post_count
+ FROM tblCategories a, tblPost2Category b
+ WHERE a.id=b.category_id AND b.post_id=? ORDER BY a.name";
+
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $postID);
+ $rows=$command->query();
+
+ $cats=array();
+ foreach($rows as $row)
+ $cats[]=$this->populateCategoryRecord($row);
+ return $cats;
+ }
+
+ public function queryCategoryByID($id)
+ {
+ $sql="SELECT * FROM tblCategories WHERE id=?";
+
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $id);
+ $result=$command->query();
+
+ if(($row=$result->read())!==false)
+ return $this->populateCategoryRecord($row);
+ else
+ return null;
+ }
+
+ public function queryCategoryByName($name)
+ {
+ $sql="SELECT * FROM tblCategories WHERE name=?";
+
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $name);
+ $result=$command->query();
+
+ if(($row=$result->read())!==false)
+ return $this->populateCategoryRecord($row);
+ else
+ return null;
+ }
+
+ public function insertCategory($category)
+ {
+ $sql="INSERT INTO tblCategories
+ (name,description)
+ VALUES (?,?)";
+
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $category->Name);
+ $command->bindValue(2, $category->Description);
+ $command->execute();
+
+ $category->ID=$this->_db->getLastInsertID();
+ }
+
+ public function updateCategory($category)
+ {
+ $sql="UPDATE tblCategories SET name=?, description=?, post_count=? WHERE id=?";
+
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $category->Name);
+ $command->bindValue(2, $category->Description);
+ $command->bindValue(3, $category->PostCount);
+ $command->bindValue(4, $category->ID);
+
+ $command->execute();
+ }
+
+ public function deleteCategory($id)
+ {
+ $sql="DELETE FROM tblPost2Category WHERE category_id=?";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $id);
+ $command->execute();
+
+ $sql="DELETE FROM tblCategories WHERE id=?";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $id);
+ $command->execute();
+ }
+
+ public function insertPostCategory($postID,$categoryID)
+ {
+ $sql="INSERT INTO tblPost2Category (post_id, category_id) VALUES (?, ?)";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $postID);
+ $command->bindValue(2, $categoryID);
+ $command->execute();
+
+ $sql="UPDATE tblCategories SET post_count=post_count+1 WHERE id=?";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $categoryID);
+ $command->execute();
+
+ }
+
+ public function deletePostCategory($postID,$categoryID)
+ {
+ $sql="DELETE FROM tblPost2Category WHERE post_id=? AND category_id=?";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $postID);
+ $command->bindValue(2, $categoryID);
+ $result=$command->query();
+
+ if($result->getRowCount()>0)
+ {
+ $sql="UPDATE tblCategories SET post_count=post_count-1 WHERE id=?";
+ $command=$this->_db->createCommand($sql);
+ $command->bindValue(1, $categoryID);
+ $command->execute();
+ }
+ }
+
+ public function queryEarliestPostTime()
+ {
+ $sql="SELECT MIN(create_time) AS create_time FROM tblPosts";
+ $result=$this->query($sql);
+ if(($row=$result->read())!==false)
+ return $row['create_time'];
+ else
+ return time();
+ }
+}
+
+class UserRecord
+{
+ const ROLE_USER=0;
+ const ROLE_ADMIN=1;
+ const STATUS_NORMAL=0;
+ const STATUS_DISABLED=1;
+ const STATUS_PENDING=2;
+ public $ID;
+ public $Name;
+ public $FullName;
+ public $Role;
+ public $Password;
+ public $VerifyCode;
+ public $Email;
+ public $CreateTime;
+ public $Status;
+ public $Website;
+}
+
+class PostRecord
+{
+ const STATUS_PUBLISHED=0;
+ const STATUS_DRAFT=1;
+ const STATUS_PENDING=2;
+ const STATUS_STICKY=3;
+ public $ID;
+ public $AuthorID;
+ public $AuthorName;
+ public $CreateTime;
+ public $ModifyTime;
+ public $Title;
+ public $Content;
+ public $Status;
+ public $CommentCount;
+}
+
+class CommentRecord
+{
+ public $ID;
+ public $PostID;
+ public $AuthorName;
+ public $AuthorEmail;
+ public $AuthorWebsite;
+ public $AuthorIP;
+ public $CreateTime;
+ public $Status;
+ public $Content;
+}
+
+class CategoryRecord
+{
+ public $ID;
+ public $Name;
+ public $Description;
+ public $PostCount;
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Common/BlogErrorHandler.php b/demos/blog/protected/Common/BlogErrorHandler.php
index 06042be1..f5144fff 100644
--- a/demos/blog/protected/Common/BlogErrorHandler.php
+++ b/demos/blog/protected/Common/BlogErrorHandler.php
@@ -1,46 +1,46 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('System.Exceptions.TErrorHandler');
-Prado::using('Application.Common.BlogException');
-
-/**
- * BlogErrorHandler class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class BlogErrorHandler extends TErrorHandler
-{
- /**
- * Displays error to the client user.
- * THttpException and errors happened when the application is in Debug
- * mode will be displayed to the client user.
- * @param integer response status code
- * @param Exception exception instance
- */
- protected function handleExternalError($statusCode,$exception)
- {
- if($exception instanceof BlogException)
- {
- $message=$exception->getMessage();
- Prado::log($message,TLogger::ERROR,'BlogApplication');
- $message=urldecode($this->getApplication()->getSecurityManager()->hashData($message));
- $this->Response->redirect($this->Service->constructUrl('ErrorReport',array('msg'=>$message),false));
- }
- else
- parent::handleExternalError($statusCode,$exception);
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('System.Exceptions.TErrorHandler');
+Prado::using('Application.Common.BlogException');
+
+/**
+ * BlogErrorHandler class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class BlogErrorHandler extends TErrorHandler
+{
+ /**
+ * Displays error to the client user.
+ * THttpException and errors happened when the application is in Debug
+ * mode will be displayed to the client user.
+ * @param integer response status code
+ * @param Exception exception instance
+ */
+ protected function handleExternalError($statusCode,$exception)
+ {
+ if($exception instanceof BlogException)
+ {
+ $message=$exception->getMessage();
+ Prado::log($message,TLogger::ERROR,'BlogApplication');
+ $message=urldecode($this->getApplication()->getSecurityManager()->hashData($message));
+ $this->Response->redirect($this->Service->constructUrl('ErrorReport',array('msg'=>$message),false));
+ }
+ else
+ parent::handleExternalError($statusCode,$exception);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Common/BlogException.php b/demos/blog/protected/Common/BlogException.php
index 17ae526f..e5ade8a3 100644
--- a/demos/blog/protected/Common/BlogException.php
+++ b/demos/blog/protected/Common/BlogException.php
@@ -1,31 +1,31 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * BlogException class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class BlogException extends THttpException
-{
- /**
- * @return string path to the error message file
- */
- protected function getErrorMessageFile()
- {
- return dirname(__FILE__).'/messages.txt';
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * BlogException class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class BlogException extends THttpException
+{
+ /**
+ * @return string path to the error message file
+ */
+ protected function getErrorMessageFile()
+ {
+ return dirname(__FILE__).'/messages.txt';
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Common/BlogPage.php b/demos/blog/protected/Common/BlogPage.php
index aaf0c7e1..a5ac514e 100644
--- a/demos/blog/protected/Common/BlogPage.php
+++ b/demos/blog/protected/Common/BlogPage.php
@@ -1,49 +1,49 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * BlogPage class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class BlogPage extends TPage
-{
- public function onPreInit($param)
- {
- parent::onPreInit($param);
- $this->Theme=$this->Application->Parameters['ThemeName'];
- }
-
- public function getDataAccess()
- {
- return $this->getApplication()->getModule('data');
- }
-
- public function gotoDefaultPage()
- {
- $this->gotoPage($this->Service->DefaultPage);
- }
-
- public function gotoPage($pagePath,$getParameters=null)
- {
- $this->Response->redirect($this->Service->constructUrl($pagePath,$getParameters,false));
- }
-
- public function reportError($errorCode)
- {
- $this->gotoPage('ErrorReport',array('id'=>$errorCode));
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * BlogPage class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class BlogPage extends TPage
+{
+ public function onPreInit($param)
+ {
+ parent::onPreInit($param);
+ $this->Theme=$this->Application->Parameters['ThemeName'];
+ }
+
+ public function getDataAccess()
+ {
+ return $this->getApplication()->getModule('data');
+ }
+
+ public function gotoDefaultPage()
+ {
+ $this->gotoPage($this->Service->DefaultPage);
+ }
+
+ public function gotoPage($pagePath,$getParameters=null)
+ {
+ $this->Response->redirect($this->Service->constructUrl($pagePath,$getParameters,false));
+ }
+
+ public function reportError($errorCode)
+ {
+ $this->gotoPage('ErrorReport',array('id'=>$errorCode));
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Common/BlogUser.php b/demos/blog/protected/Common/BlogUser.php
index 865d7659..08418965 100644
--- a/demos/blog/protected/Common/BlogUser.php
+++ b/demos/blog/protected/Common/BlogUser.php
@@ -1,60 +1,60 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('System.Security.TUser');
-
-/**
- * BlogUser class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class BlogUser extends TUser
-{
- private $_id;
-
- public function getID()
- {
- return $this->_id;
- }
-
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- public function getIsAdmin()
- {
- return $this->isInRole('admin');
- }
-
- public function saveToString()
- {
- $a=array($this->_id,parent::saveToString());
- return serialize($a);
- }
-
- public function loadFromString($data)
- {
- if(!empty($data))
- {
- list($id,$str)=unserialize($data);
- $this->_id=$id;
- return parent::loadFromString($str);
- }
- else
- return $this;
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('System.Security.TUser');
+
+/**
+ * BlogUser class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class BlogUser extends TUser
+{
+ private $_id;
+
+ public function getID()
+ {
+ return $this->_id;
+ }
+
+ public function setID($value)
+ {
+ $this->_id=$value;
+ }
+
+ public function getIsAdmin()
+ {
+ return $this->isInRole('admin');
+ }
+
+ public function saveToString()
+ {
+ $a=array($this->_id,parent::saveToString());
+ return serialize($a);
+ }
+
+ public function loadFromString($data)
+ {
+ if(!empty($data))
+ {
+ list($id,$str)=unserialize($data);
+ $this->_id=$id;
+ return parent::loadFromString($str);
+ }
+ else
+ return $this;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Common/BlogUserManager.php b/demos/blog/protected/Common/BlogUserManager.php
index efaa7f1f..26a4427a 100644
--- a/demos/blog/protected/Common/BlogUserManager.php
+++ b/demos/blog/protected/Common/BlogUserManager.php
@@ -1,95 +1,95 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('System.Security.IUserManager');
-Prado::using('Application.Common.BlogUser');
-
-/**
- * BlogUserManager class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class BlogUserManager extends TModule implements IUserManager
-{
- public function getGuestName()
- {
- return 'Guest';
- }
-
- /**
- * Returns a user instance given the user name.
- * @param string user name, null if it is a guest.
- * @return TUser the user instance, null if the specified username is not in the user database.
- */
- public function getUser($username=null)
- {
- if($username===null)
- return new BlogUser($this);
- else
- {
- $username=strtolower($username);
- $db=$this->Application->getModule('data');
- if(($userRecord=$db->queryUserByName($username))!==null)
- {
- $user=new BlogUser($this);
- $user->setID($userRecord->ID);
- $user->setName($username);
- $user->setIsGuest(false);
- $user->setRoles($userRecord->Role===UserRecord::ROLE_USER?'user':'admin');
- return $user;
- }
- else
- return null;
- }
- }
-
- /**
- * Validates if the username and password are correct.
- * @param string user name
- * @param string password
- * @return boolean true if validation is successful, false otherwise.
- */
- public function validateUser($username,$password)
- {
- $db=$this->Application->getModule('data');
- if(($userRecord=$db->queryUserByName($username))!==null)
- return $userRecord->Password===md5($password) && $userRecord->Status===UserRecord::STATUS_NORMAL;
- else
- return false;
- }
-
- /**
- * Saves user auth data into a cookie.
- * @param THttpCookie the cookie to receive the user auth data.
- * @since 3.1.1
- */
- public function saveUserToCookie($cookie)
- {
- // do nothing since we don't support cookie-based auth in this example
- }
-
- /**
- * Returns a user instance according to auth data stored in a cookie.
- * @param THttpCookie the cookie storing user authentication information
- * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
- * @since 3.1.1
- */
- public function getUserFromCookie($cookie)
- {
- // do nothing since we don't support cookie-based auth in this example
- return null;
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('System.Security.IUserManager');
+Prado::using('Application.Common.BlogUser');
+
+/**
+ * BlogUserManager class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class BlogUserManager extends TModule implements IUserManager
+{
+ public function getGuestName()
+ {
+ return 'Guest';
+ }
+
+ /**
+ * Returns a user instance given the user name.
+ * @param string user name, null if it is a guest.
+ * @return TUser the user instance, null if the specified username is not in the user database.
+ */
+ public function getUser($username=null)
+ {
+ if($username===null)
+ return new BlogUser($this);
+ else
+ {
+ $username=strtolower($username);
+ $db=$this->Application->getModule('data');
+ if(($userRecord=$db->queryUserByName($username))!==null)
+ {
+ $user=new BlogUser($this);
+ $user->setID($userRecord->ID);
+ $user->setName($username);
+ $user->setIsGuest(false);
+ $user->setRoles($userRecord->Role===UserRecord::ROLE_USER?'user':'admin');
+ return $user;
+ }
+ else
+ return null;
+ }
+ }
+
+ /**
+ * Validates if the username and password are correct.
+ * @param string user name
+ * @param string password
+ * @return boolean true if validation is successful, false otherwise.
+ */
+ public function validateUser($username,$password)
+ {
+ $db=$this->Application->getModule('data');
+ if(($userRecord=$db->queryUserByName($username))!==null)
+ return $userRecord->Password===md5($password) && $userRecord->Status===UserRecord::STATUS_NORMAL;
+ else
+ return false;
+ }
+
+ /**
+ * Saves user auth data into a cookie.
+ * @param THttpCookie the cookie to receive the user auth data.
+ * @since 3.1.1
+ */
+ public function saveUserToCookie($cookie)
+ {
+ // do nothing since we don't support cookie-based auth in this example
+ }
+
+ /**
+ * Returns a user instance according to auth data stored in a cookie.
+ * @param THttpCookie the cookie storing user authentication information
+ * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
+ * @since 3.1.1
+ */
+ public function getUserFromCookie($cookie)
+ {
+ // do nothing since we don't support cookie-based auth in this example
+ return null;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Common/XListMenu.php b/demos/blog/protected/Common/XListMenu.php
index 7dadfbe4..92ab2984 100644
--- a/demos/blog/protected/Common/XListMenu.php
+++ b/demos/blog/protected/Common/XListMenu.php
@@ -1,127 +1,127 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('System.Web.UI.WebControls.TListControl');
-
-/**
- * XListMenu class
- *
- * XListMenu displays a list of hyperlinks that can be used for page menus.
- * Menu items adjust their css class automatically according to the current
- * page displayed. In particular, a menu item is considered as active if
- * the URL it represents is for the page currently displayed.
- *
- * Usage of XListMenu is similar to PRADO list controls. Each list item has
- * two extra properties: {@link XListMenuItem::setPagePath PagePath} and
- * {@link XListMenuItem::setNavigateUrl NavigateUrl}. The former is used to
- * determine if the item is active or not, while the latter specifies the
- * URL for the item. If the latter is not specified, a URL to the page is
- * generated automatically.
- *
- * In template, you may use the following tags to specify a menu:
- *
- *
- *
- *
- *
- *
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class XListMenu extends TListControl
-{
- public function addParsedObject($object)
- {
- if($object instanceof XListMenuItem)
- parent::addParsedObject($object);
- }
-
- public function getActiveCssClass()
- {
- return $this->getViewState('ActiveCssClass','');
- }
-
- public function setActiveCssClass($value)
- {
- $this->setViewState('ActiveCssClass',$value,'');
- }
-
- public function getInactiveCssClass()
- {
- return $this->getViewState('InactiveCssClass','');
- }
-
- public function setInactiveCssClass($value)
- {
- $this->setViewState('InactiveCssClass',$value,'');
- }
-
- public function render($writer)
- {
- if(($activeClass=$this->getActiveCssClass())!=='')
- $activeClass=' class="'.$activeClass.'"';
- if(($inactiveClass=$this->getInactiveCssClass())!=='')
- $inactiveClass=' class="'.$inactiveClass.'"';
- $currentPagePath=$this->getPage()->getPagePath();
- $writer->write("\n");
- foreach($this->getItems() as $item)
- {
- $pagePath=$item->getPagePath();
- //if(strpos($currentPagePath.'.',$pagePath.'.')===0)
- if($pagePath[strlen($pagePath)-1]==='*')
- {
- if(strpos($currentPagePath.'.',rtrim($pagePath,'*'))===0)
- $cssClass=$activeClass;
- else
- $cssClass=$inactiveClass;
- }
- else
- {
- if($pagePath===$currentPagePath)
- $cssClass=$activeClass;
- else
- $cssClass=$inactiveClass;
- }
- if(($url=$item->getNavigateUrl())==='')
- $url=$this->getService()->constructUrl($pagePath);
- $writer->write("".$item->getText()." \n");
- }
- $writer->write(" ");
- }
-}
-
-class XListMenuItem extends TListItem
-{
- public function getPagePath()
- {
- return $this->getValue();
- }
-
- public function setPagePath($value)
- {
- $this->setValue($value);
- }
-
- public function getNavigateUrl()
- {
- return $this->hasAttribute('NavigateUrl')?$this->getAttribute('NavigateUrl'):'';
- }
-
- public function setNavigateUrl($value)
- {
- $this->setAttribute('NavigateUrl',$value);
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('System.Web.UI.WebControls.TListControl');
+
+/**
+ * XListMenu class
+ *
+ * XListMenu displays a list of hyperlinks that can be used for page menus.
+ * Menu items adjust their css class automatically according to the current
+ * page displayed. In particular, a menu item is considered as active if
+ * the URL it represents is for the page currently displayed.
+ *
+ * Usage of XListMenu is similar to PRADO list controls. Each list item has
+ * two extra properties: {@link XListMenuItem::setPagePath PagePath} and
+ * {@link XListMenuItem::setNavigateUrl NavigateUrl}. The former is used to
+ * determine if the item is active or not, while the latter specifies the
+ * URL for the item. If the latter is not specified, a URL to the page is
+ * generated automatically.
+ *
+ * In template, you may use the following tags to specify a menu:
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class XListMenu extends TListControl
+{
+ public function addParsedObject($object)
+ {
+ if($object instanceof XListMenuItem)
+ parent::addParsedObject($object);
+ }
+
+ public function getActiveCssClass()
+ {
+ return $this->getViewState('ActiveCssClass','');
+ }
+
+ public function setActiveCssClass($value)
+ {
+ $this->setViewState('ActiveCssClass',$value,'');
+ }
+
+ public function getInactiveCssClass()
+ {
+ return $this->getViewState('InactiveCssClass','');
+ }
+
+ public function setInactiveCssClass($value)
+ {
+ $this->setViewState('InactiveCssClass',$value,'');
+ }
+
+ public function render($writer)
+ {
+ if(($activeClass=$this->getActiveCssClass())!=='')
+ $activeClass=' class="'.$activeClass.'"';
+ if(($inactiveClass=$this->getInactiveCssClass())!=='')
+ $inactiveClass=' class="'.$inactiveClass.'"';
+ $currentPagePath=$this->getPage()->getPagePath();
+ $writer->write("\n");
+ foreach($this->getItems() as $item)
+ {
+ $pagePath=$item->getPagePath();
+ //if(strpos($currentPagePath.'.',$pagePath.'.')===0)
+ if($pagePath[strlen($pagePath)-1]==='*')
+ {
+ if(strpos($currentPagePath.'.',rtrim($pagePath,'*'))===0)
+ $cssClass=$activeClass;
+ else
+ $cssClass=$inactiveClass;
+ }
+ else
+ {
+ if($pagePath===$currentPagePath)
+ $cssClass=$activeClass;
+ else
+ $cssClass=$inactiveClass;
+ }
+ if(($url=$item->getNavigateUrl())==='')
+ $url=$this->getService()->constructUrl($pagePath);
+ $writer->write("".$item->getText()." \n");
+ }
+ $writer->write(" ");
+ }
+}
+
+class XListMenuItem extends TListItem
+{
+ public function getPagePath()
+ {
+ return $this->getValue();
+ }
+
+ public function setPagePath($value)
+ {
+ $this->setValue($value);
+ }
+
+ public function getNavigateUrl()
+ {
+ return $this->hasAttribute('NavigateUrl')?$this->getAttribute('NavigateUrl'):'';
+ }
+
+ public function setNavigateUrl($value)
+ {
+ $this->setAttribute('NavigateUrl',$value);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Layouts/MainLayout.php b/demos/blog/protected/Layouts/MainLayout.php
index cfc42d50..b7956d75 100644
--- a/demos/blog/protected/Layouts/MainLayout.php
+++ b/demos/blog/protected/Layouts/MainLayout.php
@@ -1,24 +1,24 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * MainLayout class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class MainLayout extends TTemplateControl
-{
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * MainLayout class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class MainLayout extends TTemplateControl
+{
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Admin/AdminMenu.php b/demos/blog/protected/Pages/Admin/AdminMenu.php
index a631d5b5..4687a5ce 100644
--- a/demos/blog/protected/Pages/Admin/AdminMenu.php
+++ b/demos/blog/protected/Pages/Admin/AdminMenu.php
@@ -1,24 +1,24 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * AdminMenu class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class AdminMenu extends TTemplateControl
-{
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * AdminMenu class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class AdminMenu extends TTemplateControl
+{
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Admin/ConfigMan.php b/demos/blog/protected/Pages/Admin/ConfigMan.php
index 61516c27..c60a04e8 100644
--- a/demos/blog/protected/Pages/Admin/ConfigMan.php
+++ b/demos/blog/protected/Pages/Admin/ConfigMan.php
@@ -1,77 +1,77 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * ConfigMan class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class ConfigMan extends BlogPage
-{
- const CONFIG_FILE='Application.Data.Settings';
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $parameters=$this->Application->Parameters;
- $this->SiteTitle->Text=$parameters['SiteTitle'];
- $this->SiteSubtitle->Text=$parameters['SiteSubtitle'];
- $this->SiteOwner->Text=$parameters['SiteOwner'];
- $this->AdminEmail->Text=$parameters['AdminEmail'];
- $this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']);
- $this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']);
- $this->PostPerPage->Text=$parameters['PostPerPage'];
- $this->RecentComments->Text=$parameters['RecentComments'];
- $this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']);
- $themes=$this->Service->ThemeManager->AvailableThemes;
- $this->ThemeName->DataSource=$themes;
- $this->ThemeName->dataBind();
- $this->ThemeName->SelectedValue=array_search($parameters['ThemeName'],$themes);
- }
- }
-
- public function saveButtonClicked($sender,$param)
- {
- $dom=new TXmlDocument;
- $dom->Encoding='utf-8';
- $dom->TagName='parameters';
- $elements=$dom->Elements;
- $elements[]=$this->createParameter('SiteTitle',$this->SiteTitle->Text);
- $elements[]=$this->createParameter('SiteSubtitle',$this->SiteSubtitle->Text);
- $elements[]=$this->createParameter('SiteOwner',$this->SiteOwner->Text);
- $elements[]=$this->createParameter('AdminEmail',$this->AdminEmail->Text);
- $elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked);
- $elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked);
- $elements[]=$this->createParameter('PostPerPage',$this->PostPerPage->Text);
- $elements[]=$this->createParameter('RecentComments',$this->RecentComments->Text);
- $elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked);
- $themeName=$this->ThemeName->SelectedItem->Text;
- $elements[]=$this->createParameter('ThemeName',$themeName);
- $dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml'));
- if($themeName!==$this->Theme->Name)
- $this->Response->reload();
- }
-
- private function createParameter($id,$value)
- {
- $element=new TXmlElement('parameter');
- $element->Attributes['id']=$id;
- $element->Attributes['value']=TPropertyValue::ensureString($value);
- return $element;
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * ConfigMan class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class ConfigMan extends BlogPage
+{
+ const CONFIG_FILE='Application.Data.Settings';
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $parameters=$this->Application->Parameters;
+ $this->SiteTitle->Text=$parameters['SiteTitle'];
+ $this->SiteSubtitle->Text=$parameters['SiteSubtitle'];
+ $this->SiteOwner->Text=$parameters['SiteOwner'];
+ $this->AdminEmail->Text=$parameters['AdminEmail'];
+ $this->MultipleUser->Checked=TPropertyValue::ensureBoolean($parameters['MultipleUser']);
+ $this->AccountApproval->Checked=TPropertyValue::ensureBoolean($parameters['AccountApproval']);
+ $this->PostPerPage->Text=$parameters['PostPerPage'];
+ $this->RecentComments->Text=$parameters['RecentComments'];
+ $this->PostApproval->Checked=TPropertyValue::ensureBoolean($parameters['PostApproval']);
+ $themes=$this->Service->ThemeManager->AvailableThemes;
+ $this->ThemeName->DataSource=$themes;
+ $this->ThemeName->dataBind();
+ $this->ThemeName->SelectedValue=array_search($parameters['ThemeName'],$themes);
+ }
+ }
+
+ public function saveButtonClicked($sender,$param)
+ {
+ $dom=new TXmlDocument;
+ $dom->Encoding='utf-8';
+ $dom->TagName='parameters';
+ $elements=$dom->Elements;
+ $elements[]=$this->createParameter('SiteTitle',$this->SiteTitle->Text);
+ $elements[]=$this->createParameter('SiteSubtitle',$this->SiteSubtitle->Text);
+ $elements[]=$this->createParameter('SiteOwner',$this->SiteOwner->Text);
+ $elements[]=$this->createParameter('AdminEmail',$this->AdminEmail->Text);
+ $elements[]=$this->createParameter('MultipleUser',$this->MultipleUser->Checked);
+ $elements[]=$this->createParameter('AccountApproval',$this->AccountApproval->Checked);
+ $elements[]=$this->createParameter('PostPerPage',$this->PostPerPage->Text);
+ $elements[]=$this->createParameter('RecentComments',$this->RecentComments->Text);
+ $elements[]=$this->createParameter('PostApproval',$this->PostApproval->Checked);
+ $themeName=$this->ThemeName->SelectedItem->Text;
+ $elements[]=$this->createParameter('ThemeName',$themeName);
+ $dom->saveToFile(Prado::getPathOfNamespace(self::CONFIG_FILE,'.xml'));
+ if($themeName!==$this->Theme->Name)
+ $this->Response->reload();
+ }
+
+ private function createParameter($id,$value)
+ {
+ $element=new TXmlElement('parameter');
+ $element->Attributes['id']=$id;
+ $element->Attributes['value']=TPropertyValue::ensureString($value);
+ return $element;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Admin/PostMan.php b/demos/blog/protected/Pages/Admin/PostMan.php
index bf6597b1..c2ceb73f 100644
--- a/demos/blog/protected/Pages/Admin/PostMan.php
+++ b/demos/blog/protected/Pages/Admin/PostMan.php
@@ -1,73 +1,73 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * PostMan class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class PostMan extends BlogPage
-{
- protected function bindData()
- {
- $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize;
- $limit=$this->PostGrid->PageSize;
- $this->PostGrid->DataSource=$this->DataAccess->queryPosts('','','ORDER BY a.status DESC, modify_time DESC',"LIMIT $offset,$limit");
- $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount('','');
- $this->PostGrid->dataBind();
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- $this->bindData();
- }
-
- public function changePage($sender,$param)
- {
- $this->PostGrid->CurrentPageIndex=$param->NewPageIndex;
- $this->bindData();
- }
-
- public function pagerCreated($sender,$param)
- {
- $param->Pager->Controls->insertAt(0,'Page: ');
- }
-
- public function editItem($sender,$param)
- {
- $this->PostGrid->EditItemIndex=$param->Item->ItemIndex;
- $this->bindData();
- }
-
- public function saveItem($sender,$param)
- {
- $item=$param->Item;
- $postID=$this->PostGrid->DataKeys[$item->ItemIndex];
- $postRecord=$this->DataAccess->queryPostByID($postID);
- $postRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->PostStatus->SelectedValue);
- $this->DataAccess->updatePost($postRecord);
- $this->PostGrid->EditItemIndex=-1;
- $this->bindData();
- }
-
- public function cancelItem($sender,$param)
- {
- $this->PostGrid->EditItemIndex=-1;
- $this->bindData();
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * PostMan class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class PostMan extends BlogPage
+{
+ protected function bindData()
+ {
+ $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize;
+ $limit=$this->PostGrid->PageSize;
+ $this->PostGrid->DataSource=$this->DataAccess->queryPosts('','','ORDER BY a.status DESC, modify_time DESC',"LIMIT $offset,$limit");
+ $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount('','');
+ $this->PostGrid->dataBind();
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ $this->bindData();
+ }
+
+ public function changePage($sender,$param)
+ {
+ $this->PostGrid->CurrentPageIndex=$param->NewPageIndex;
+ $this->bindData();
+ }
+
+ public function pagerCreated($sender,$param)
+ {
+ $param->Pager->Controls->insertAt(0,'Page: ');
+ }
+
+ public function editItem($sender,$param)
+ {
+ $this->PostGrid->EditItemIndex=$param->Item->ItemIndex;
+ $this->bindData();
+ }
+
+ public function saveItem($sender,$param)
+ {
+ $item=$param->Item;
+ $postID=$this->PostGrid->DataKeys[$item->ItemIndex];
+ $postRecord=$this->DataAccess->queryPostByID($postID);
+ $postRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->PostStatus->SelectedValue);
+ $this->DataAccess->updatePost($postRecord);
+ $this->PostGrid->EditItemIndex=-1;
+ $this->bindData();
+ }
+
+ public function cancelItem($sender,$param)
+ {
+ $this->PostGrid->EditItemIndex=-1;
+ $this->bindData();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Admin/UserMan.php b/demos/blog/protected/Pages/Admin/UserMan.php
index 5901c334..231f6c84 100644
--- a/demos/blog/protected/Pages/Admin/UserMan.php
+++ b/demos/blog/protected/Pages/Admin/UserMan.php
@@ -1,75 +1,75 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * UserMan class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class UserMan extends BlogPage
-{
- protected function bindData()
- {
- $author=$this->User->ID;
- $offset=$this->UserGrid->CurrentPageIndex*$this->UserGrid->PageSize;
- $limit=$this->UserGrid->PageSize;
- $this->UserGrid->DataSource=$this->DataAccess->queryUsers('','ORDER BY status DESC, name ASC',"LIMIT $offset,$limit");
- $this->UserGrid->VirtualItemCount=$this->DataAccess->queryUserCount('');
- $this->UserGrid->dataBind();
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- $this->bindData();
- }
-
- public function changePage($sender,$param)
- {
- $this->UserGrid->CurrentPageIndex=$param->NewPageIndex;
- $this->bindData();
- }
-
- public function pagerCreated($sender,$param)
- {
- $param->Pager->Controls->insertAt(0,'Page: ');
- }
-
- public function editItem($sender,$param)
- {
- $this->UserGrid->EditItemIndex=$param->Item->ItemIndex;
- $this->bindData();
- }
-
- public function saveItem($sender,$param)
- {
- $item=$param->Item;
- $userID=$this->UserGrid->DataKeys[$item->ItemIndex];
- $userRecord=$this->DataAccess->queryUserByID($userID);
- $userRecord->Role=TPropertyValue::ensureInteger($item->Cells[1]->UserRole->SelectedValue);
- $userRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->UserStatus->SelectedValue);
- $this->DataAccess->updateUser($userRecord);
- $this->UserGrid->EditItemIndex=-1;
- $this->bindData();
- }
-
- public function cancelItem($sender,$param)
- {
- $this->UserGrid->EditItemIndex=-1;
- $this->bindData();
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * UserMan class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class UserMan extends BlogPage
+{
+ protected function bindData()
+ {
+ $author=$this->User->ID;
+ $offset=$this->UserGrid->CurrentPageIndex*$this->UserGrid->PageSize;
+ $limit=$this->UserGrid->PageSize;
+ $this->UserGrid->DataSource=$this->DataAccess->queryUsers('','ORDER BY status DESC, name ASC',"LIMIT $offset,$limit");
+ $this->UserGrid->VirtualItemCount=$this->DataAccess->queryUserCount('');
+ $this->UserGrid->dataBind();
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ $this->bindData();
+ }
+
+ public function changePage($sender,$param)
+ {
+ $this->UserGrid->CurrentPageIndex=$param->NewPageIndex;
+ $this->bindData();
+ }
+
+ public function pagerCreated($sender,$param)
+ {
+ $param->Pager->Controls->insertAt(0,'Page: ');
+ }
+
+ public function editItem($sender,$param)
+ {
+ $this->UserGrid->EditItemIndex=$param->Item->ItemIndex;
+ $this->bindData();
+ }
+
+ public function saveItem($sender,$param)
+ {
+ $item=$param->Item;
+ $userID=$this->UserGrid->DataKeys[$item->ItemIndex];
+ $userRecord=$this->DataAccess->queryUserByID($userID);
+ $userRecord->Role=TPropertyValue::ensureInteger($item->Cells[1]->UserRole->SelectedValue);
+ $userRecord->Status=TPropertyValue::ensureInteger($item->Cells[2]->UserStatus->SelectedValue);
+ $this->DataAccess->updateUser($userRecord);
+ $this->UserGrid->EditItemIndex=-1;
+ $this->bindData();
+ }
+
+ public function cancelItem($sender,$param)
+ {
+ $this->UserGrid->EditItemIndex=-1;
+ $this->bindData();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/ErrorReport.php b/demos/blog/protected/Pages/ErrorReport.php
index 50d4a047..2b086f5f 100644
--- a/demos/blog/protected/Pages/ErrorReport.php
+++ b/demos/blog/protected/Pages/ErrorReport.php
@@ -1,29 +1,29 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * ErrorReport class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class ErrorReport extends BlogPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->ErrorMessage->Text=$this->Application->SecurityManager->validateData(urldecode($this->Request['msg']));
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * ErrorReport class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class ErrorReport extends BlogPage
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $this->ErrorMessage->Text=$this->Application->SecurityManager->validateData(urldecode($this->Request['msg']));
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/EditCategory.php b/demos/blog/protected/Pages/Posts/EditCategory.php
index 76013264..d60418be 100644
--- a/demos/blog/protected/Pages/Posts/EditCategory.php
+++ b/demos/blog/protected/Pages/Posts/EditCategory.php
@@ -1,61 +1,61 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * EditCategory class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class EditCategory extends BlogPage
-{
- private $_category;
-
- public function onInit($param)
- {
- parent::onInit($param);
- $id=TPropertyValue::ensureInteger($this->Request['id']);
- $this->_category=$this->DataAccess->queryCategoryByID($id);
- if($this->_category===null)
- throw new BlogException(500,'category_id_invalid',$id);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->CategoryName->Text=$this->_category->Name;
- $this->CategoryDescription->Text=$this->_category->Description;
- }
- }
-
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid)
- {
- $this->_category->Name=$this->CategoryName->Text;
- $this->_category->Description=$this->CategoryDescription->Text;
- $this->DataAccess->updateCategory($this->_category);
- $this->gotoPage('Posts.ListPost',array('cat'=>$this->_category->ID));
- }
- }
-
- public function checkCategoryName($sender,$param)
- {
- $name=$this->CategoryName->Text;
- $param->IsValid=$this->DataAccess->queryCategoryByName($name)===null;
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * EditCategory class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class EditCategory extends BlogPage
+{
+ private $_category;
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $id=TPropertyValue::ensureInteger($this->Request['id']);
+ $this->_category=$this->DataAccess->queryCategoryByID($id);
+ if($this->_category===null)
+ throw new BlogException(500,'category_id_invalid',$id);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->CategoryName->Text=$this->_category->Name;
+ $this->CategoryDescription->Text=$this->_category->Description;
+ }
+ }
+
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $this->_category->Name=$this->CategoryName->Text;
+ $this->_category->Description=$this->CategoryDescription->Text;
+ $this->DataAccess->updateCategory($this->_category);
+ $this->gotoPage('Posts.ListPost',array('cat'=>$this->_category->ID));
+ }
+ }
+
+ public function checkCategoryName($sender,$param)
+ {
+ $name=$this->CategoryName->Text;
+ $param->IsValid=$this->DataAccess->queryCategoryByName($name)===null;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/EditPost.php b/demos/blog/protected/Pages/Posts/EditPost.php
index 8d754b30..3ba6f069 100644
--- a/demos/blog/protected/Pages/Posts/EditPost.php
+++ b/demos/blog/protected/Pages/Posts/EditPost.php
@@ -1,78 +1,78 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * EditPost class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class EditPost extends BlogPage
-{
- private $_postRecord=null;
-
- public function onInit($param)
- {
- parent::onInit($param);
- $id=TPropertyValue::ensureInteger($this->Request['id']);
- $this->_postRecord=$this->DataAccess->queryPostByID($id);
- if($this->_postRecord===null)
- throw new BlogException(500,'post_id_invalid',$id);
- // only the author and admin can edit the post
- if(!$this->User->IsAdmin && $this->User->ID!==$this->_postRecord->AuthorID)
- throw new BlogException(500,'post_edit_disallowed',$id);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $postRecord=$this->_postRecord;
- $this->Title->Text=$postRecord->Title;
- $this->Content->Text=$postRecord->Content;
- $this->DraftMode->Checked=$postRecord->Status===PostRecord::STATUS_DRAFT;
- $this->Categories->DataSource=$this->DataAccess->queryCategories();
- $this->Categories->dataBind();
- $cats=$this->DataAccess->queryCategoriesByPostID($postRecord->ID);
- $catIDs=array();
- foreach($cats as $cat)
- $catIDs[]=$cat->ID;
- $this->Categories->SelectedValues=$catIDs;
- }
- }
-
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid)
- {
- $postRecord=$this->_postRecord;
- $postRecord->Title=$this->Title->SafeText;
- $postRecord->Content=$this->Content->SafeText;
- if($this->DraftMode->Checked)
- $postRecord->Status=PostRecord::STATUS_DRAFT;
- else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval']))
- $postRecord->Status=PostRecord::STATUS_PENDING;
- else
- $postRecord->Status=PostRecord::STATUS_PUBLISHED;
- $postRecord->ModifyTime=time();
- $cats=array();
- foreach($this->Categories->SelectedValues as $value)
- $cats[]=TPropertyValue::ensureInteger($value);
- $this->DataAccess->updatePost($postRecord,$cats);
- $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID));
- }
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * EditPost class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class EditPost extends BlogPage
+{
+ private $_postRecord=null;
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $id=TPropertyValue::ensureInteger($this->Request['id']);
+ $this->_postRecord=$this->DataAccess->queryPostByID($id);
+ if($this->_postRecord===null)
+ throw new BlogException(500,'post_id_invalid',$id);
+ // only the author and admin can edit the post
+ if(!$this->User->IsAdmin && $this->User->ID!==$this->_postRecord->AuthorID)
+ throw new BlogException(500,'post_edit_disallowed',$id);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $postRecord=$this->_postRecord;
+ $this->Title->Text=$postRecord->Title;
+ $this->Content->Text=$postRecord->Content;
+ $this->DraftMode->Checked=$postRecord->Status===PostRecord::STATUS_DRAFT;
+ $this->Categories->DataSource=$this->DataAccess->queryCategories();
+ $this->Categories->dataBind();
+ $cats=$this->DataAccess->queryCategoriesByPostID($postRecord->ID);
+ $catIDs=array();
+ foreach($cats as $cat)
+ $catIDs[]=$cat->ID;
+ $this->Categories->SelectedValues=$catIDs;
+ }
+ }
+
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $postRecord=$this->_postRecord;
+ $postRecord->Title=$this->Title->SafeText;
+ $postRecord->Content=$this->Content->SafeText;
+ if($this->DraftMode->Checked)
+ $postRecord->Status=PostRecord::STATUS_DRAFT;
+ else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval']))
+ $postRecord->Status=PostRecord::STATUS_PENDING;
+ else
+ $postRecord->Status=PostRecord::STATUS_PUBLISHED;
+ $postRecord->ModifyTime=time();
+ $cats=array();
+ foreach($this->Categories->SelectedValues as $value)
+ $cats[]=TPropertyValue::ensureInteger($value);
+ $this->DataAccess->updatePost($postRecord,$cats);
+ $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID));
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/ListPost.php b/demos/blog/protected/Pages/Posts/ListPost.php
index 0e0a044c..7ff9dac9 100644
--- a/demos/blog/protected/Pages/Posts/ListPost.php
+++ b/demos/blog/protected/Pages/Posts/ListPost.php
@@ -1,142 +1,142 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * ListPost class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class ListPost extends BlogPage
-{
- private $_posts;
- private $_category;
-
- public function onInit($param)
- {
- parent::onInit($param);
- $this->_posts=$this->DataAccess->queryPosts(
- $this->getPostFilter(),
- $this->getCategoryFilter(),
- 'ORDER BY a.status DESC, create_time DESC',
- 'LIMIT '.$this->getPageOffset().','.$this->getPageSize());
- if($this->Request['cat']!==null)
- {
- $catID=TPropertyValue::ensureInteger($this->Request['cat']);
- $this->_category=$this->DataAccess->queryCategoryByID($catID);
- $this->CategoryPanel->Visible=true;
- }
- $this->Title=$this->Application->Parameters['SiteTitle'];
- }
-
- private function getPageOffset()
- {
- if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0)
- $offset=0;
- return $offset;
- }
-
- private function getPageSize()
- {
- if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0)
- $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
- return $limit;
- }
-
- private function getTimeFilter()
- {
- if(($time=TPropertyValue::ensureInteger($this->Request['time']))>0)
- {
- $year=(integer)($time/100);
- $month=$time%100;
- $startTime=mktime(0,0,0,$month,1,$year);
- if(++$month>12)
- {
- $month=1;
- $year++;
- }
- $endTime=mktime(0,0,0,$month,1,$year);
- return "create_time>=$startTime AND create_time<$endTime";
- }
- else
- return '';
- }
-
- private function getPostFilter()
- {
- $filter='(a.status=0 OR a.status=3)';
- if(($timeFilter=$this->getTimeFilter())!=='')
- return "$filter AND $timeFilter";
- else
- return $filter;
- }
-
- private function getCategoryFilter()
- {
- if(($catID=$this->Request['cat'])!==null)
- {
- $catID=TPropertyValue::ensureInteger($catID);
- return "category_id=$catID";
- }
- else
- return '';
- }
-
- private function formUrl($newOffset)
- {
- $gets=array();
- $gets['offset']=$newOffset;
- if($this->Request['limit']!==null)
- $gets['limit']=$this->Request['limit'];
- if($this->Request['time']!==null)
- $gets['time']=$this->Request['time'];
- if($this->Request['cat']!==null)
- $gets['cat']=$this->Request['cat'];
- return $this->Service->constructUrl('Posts.ListPost',$gets);
- }
-
- public function getCategory()
- {
- return $this->_category;
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->PostList->DataSource=$this->_posts;
- $this->PostList->dataBind();
- if($this->getPageOffset()>0)
- {
- if(($offset=$this->getPageOffset()-$this->getPageSize())<0)
- $offset=0;
- $this->PrevPage->NavigateUrl=$this->formUrl($offset);
- $this->PrevPage->Visible=true;
- }
- if(count($this->_posts)===$this->getPageSize())
- {
- $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize());
- $this->NextPage->Visible=true;
- }
- }
-
- public function deleteButtonClicked($sender,$param)
- {
- if($this->User->IsAdmin)
- {
- $this->DataAccess->deleteCategory($this->Category->ID);
- $this->gotoDefaultPage();
- }
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * ListPost class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class ListPost extends BlogPage
+{
+ private $_posts;
+ private $_category;
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $this->_posts=$this->DataAccess->queryPosts(
+ $this->getPostFilter(),
+ $this->getCategoryFilter(),
+ 'ORDER BY a.status DESC, create_time DESC',
+ 'LIMIT '.$this->getPageOffset().','.$this->getPageSize());
+ if($this->Request['cat']!==null)
+ {
+ $catID=TPropertyValue::ensureInteger($this->Request['cat']);
+ $this->_category=$this->DataAccess->queryCategoryByID($catID);
+ $this->CategoryPanel->Visible=true;
+ }
+ $this->Title=$this->Application->Parameters['SiteTitle'];
+ }
+
+ private function getPageOffset()
+ {
+ if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0)
+ $offset=0;
+ return $offset;
+ }
+
+ private function getPageSize()
+ {
+ if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0)
+ $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
+ return $limit;
+ }
+
+ private function getTimeFilter()
+ {
+ if(($time=TPropertyValue::ensureInteger($this->Request['time']))>0)
+ {
+ $year=(integer)($time/100);
+ $month=$time%100;
+ $startTime=mktime(0,0,0,$month,1,$year);
+ if(++$month>12)
+ {
+ $month=1;
+ $year++;
+ }
+ $endTime=mktime(0,0,0,$month,1,$year);
+ return "create_time>=$startTime AND create_time<$endTime";
+ }
+ else
+ return '';
+ }
+
+ private function getPostFilter()
+ {
+ $filter='(a.status=0 OR a.status=3)';
+ if(($timeFilter=$this->getTimeFilter())!=='')
+ return "$filter AND $timeFilter";
+ else
+ return $filter;
+ }
+
+ private function getCategoryFilter()
+ {
+ if(($catID=$this->Request['cat'])!==null)
+ {
+ $catID=TPropertyValue::ensureInteger($catID);
+ return "category_id=$catID";
+ }
+ else
+ return '';
+ }
+
+ private function formUrl($newOffset)
+ {
+ $gets=array();
+ $gets['offset']=$newOffset;
+ if($this->Request['limit']!==null)
+ $gets['limit']=$this->Request['limit'];
+ if($this->Request['time']!==null)
+ $gets['time']=$this->Request['time'];
+ if($this->Request['cat']!==null)
+ $gets['cat']=$this->Request['cat'];
+ return $this->Service->constructUrl('Posts.ListPost',$gets);
+ }
+
+ public function getCategory()
+ {
+ return $this->_category;
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $this->PostList->DataSource=$this->_posts;
+ $this->PostList->dataBind();
+ if($this->getPageOffset()>0)
+ {
+ if(($offset=$this->getPageOffset()-$this->getPageSize())<0)
+ $offset=0;
+ $this->PrevPage->NavigateUrl=$this->formUrl($offset);
+ $this->PrevPage->Visible=true;
+ }
+ if(count($this->_posts)===$this->getPageSize())
+ {
+ $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize());
+ $this->NextPage->Visible=true;
+ }
+ }
+
+ public function deleteButtonClicked($sender,$param)
+ {
+ if($this->User->IsAdmin)
+ {
+ $this->DataAccess->deleteCategory($this->Category->ID);
+ $this->gotoDefaultPage();
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/MyPost.php b/demos/blog/protected/Pages/Posts/MyPost.php
index fd65cc57..7d0be020 100644
--- a/demos/blog/protected/Pages/Posts/MyPost.php
+++ b/demos/blog/protected/Pages/Posts/MyPost.php
@@ -1,51 +1,51 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * MyPost class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class MyPost extends BlogPage
-{
- protected function bindData()
- {
- $author=$this->User->ID;
- $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize;
- $limit=$this->PostGrid->PageSize;
- $this->PostGrid->DataSource=$this->DataAccess->queryPosts("author_id=$author",'','ORDER BY a.status DESC, create_time DESC',"LIMIT $offset,$limit");
- $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount("author_id=$author",'');
- $this->PostGrid->dataBind();
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- $this->bindData();
- }
-
- public function changePage($sender,$param)
- {
- $this->PostGrid->CurrentPageIndex=$param->NewPageIndex;
- $this->bindData();
- }
-
- public function pagerCreated($sender,$param)
- {
- $param->Pager->Controls->insertAt(0,'Page: ');
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * MyPost class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class MyPost extends BlogPage
+{
+ protected function bindData()
+ {
+ $author=$this->User->ID;
+ $offset=$this->PostGrid->CurrentPageIndex*$this->PostGrid->PageSize;
+ $limit=$this->PostGrid->PageSize;
+ $this->PostGrid->DataSource=$this->DataAccess->queryPosts("author_id=$author",'','ORDER BY a.status DESC, create_time DESC',"LIMIT $offset,$limit");
+ $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount("author_id=$author",'');
+ $this->PostGrid->dataBind();
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ $this->bindData();
+ }
+
+ public function changePage($sender,$param)
+ {
+ $this->PostGrid->CurrentPageIndex=$param->NewPageIndex;
+ $this->bindData();
+ }
+
+ public function pagerCreated($sender,$param)
+ {
+ $param->Pager->Controls->insertAt(0,'Page: ');
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/NewCategory.php b/demos/blog/protected/Pages/Posts/NewCategory.php
index 5df0c85b..b5bf26e9 100644
--- a/demos/blog/protected/Pages/Posts/NewCategory.php
+++ b/demos/blog/protected/Pages/Posts/NewCategory.php
@@ -1,41 +1,41 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * NewCategory class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class NewCategory extends BlogPage
-{
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid)
- {
- $categoryRecord=new CategoryRecord;
- $categoryRecord->Name=$this->CategoryName->Text;
- $categoryRecord->Description=$this->CategoryDescription->Text;
- $this->DataAccess->insertCategory($categoryRecord);
- $this->gotoPage('Posts.ListPost',array('cat'=>$categoryRecord->ID));
- }
- }
-
- public function checkCategoryName($sender,$param)
- {
- $name=$this->CategoryName->Text;
- $param->IsValid=$this->DataAccess->queryCategoryByName($name)===null;
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * NewCategory class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class NewCategory extends BlogPage
+{
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $categoryRecord=new CategoryRecord;
+ $categoryRecord->Name=$this->CategoryName->Text;
+ $categoryRecord->Description=$this->CategoryDescription->Text;
+ $this->DataAccess->insertCategory($categoryRecord);
+ $this->gotoPage('Posts.ListPost',array('cat'=>$categoryRecord->ID));
+ }
+ }
+
+ public function checkCategoryName($sender,$param)
+ {
+ $name=$this->CategoryName->Text;
+ $param->IsValid=$this->DataAccess->queryCategoryByName($name)===null;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/NewPost.php b/demos/blog/protected/Pages/Posts/NewPost.php
index 2f894cd5..45b1a794 100644
--- a/demos/blog/protected/Pages/Posts/NewPost.php
+++ b/demos/blog/protected/Pages/Posts/NewPost.php
@@ -1,57 +1,57 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * NewPost class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class NewPost extends BlogPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->Categories->DataSource=$this->DataAccess->queryCategories();
- $this->Categories->dataBind();
- }
- }
-
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid)
- {
- $postRecord=new PostRecord;
- $postRecord->Title=$this->Title->SafeText;
- $postRecord->Content=$this->Content->SafeText;
- if($this->DraftMode->Checked)
- $postRecord->Status=PostRecord::STATUS_DRAFT;
- else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval']))
- $postRecord->Status=PostRecord::STATUS_PENDING;
- else
- $postRecord->Status=PostRecord::STATUS_PUBLISHED;
- $postRecord->CreateTime=time();
- $postRecord->ModifyTime=$postRecord->CreateTime;
- $postRecord->AuthorID=$this->User->ID;
- $cats=array();
- foreach($this->Categories->SelectedValues as $value)
- $cats[]=TPropertyValue::ensureInteger($value);
- $this->DataAccess->insertPost($postRecord,$cats);
- $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID));
- }
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * NewPost class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class NewPost extends BlogPage
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->Categories->DataSource=$this->DataAccess->queryCategories();
+ $this->Categories->dataBind();
+ }
+ }
+
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $postRecord=new PostRecord;
+ $postRecord->Title=$this->Title->SafeText;
+ $postRecord->Content=$this->Content->SafeText;
+ if($this->DraftMode->Checked)
+ $postRecord->Status=PostRecord::STATUS_DRAFT;
+ else if(!$this->User->IsAdmin && TPropertyValue::ensureBoolean($this->Application->Parameters['PostApproval']))
+ $postRecord->Status=PostRecord::STATUS_PENDING;
+ else
+ $postRecord->Status=PostRecord::STATUS_PUBLISHED;
+ $postRecord->CreateTime=time();
+ $postRecord->ModifyTime=$postRecord->CreateTime;
+ $postRecord->AuthorID=$this->User->ID;
+ $cats=array();
+ foreach($this->Categories->SelectedValues as $value)
+ $cats[]=TPropertyValue::ensureInteger($value);
+ $this->DataAccess->insertPost($postRecord,$cats);
+ $this->gotoPage('Posts.ViewPost',array('id'=>$postRecord->ID));
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/ViewPost.php b/demos/blog/protected/Pages/Posts/ViewPost.php
index 662dc659..5831ba93 100644
--- a/demos/blog/protected/Pages/Posts/ViewPost.php
+++ b/demos/blog/protected/Pages/Posts/ViewPost.php
@@ -1,90 +1,90 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * ViewPost class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class ViewPost extends BlogPage
-{
- private $_post=null;
-
- public function onInit($param)
- {
- parent::onInit($param);
- $id=TPropertyValue::ensureInteger($this->Request['id']);
- $this->_post=$this->DataAccess->queryPostByID($id);
- if($this->_post===null)
- throw new BlogException(500,'post_id_invalid',$id);
- // if post is not published, only the author and admin can view it
- if($this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY && !$this->User->IsAdmin && $this->User->ID!==$this->_post->AuthorID)
- throw new BlogException(500,'post_view_disallowed',$id);
- $this->Title=htmlentities($this->_post->Title,ENT_QUOTES,'UTF-8');
- }
-
- public function getCanEditPost()
- {
- $user=$this->getUser();
- return $user->getIsAdmin() || $user->getID()===$this->_post->AuthorID;
- }
-
- public function getCurrentPost()
- {
- return $this->_post;
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->Status->Visible=$this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY;
- $this->CategoryList->DataSource=$this->DataAccess->queryCategoriesByPostID($this->_post->ID);
- $this->CategoryList->dataBind();
- $this->CommentList->DataSource=$this->DataAccess->queryCommentsByPostID($this->_post->ID);
- $this->CommentList->dataBind();
- }
-
- public function submitCommentButtonClicked($sender,$param)
- {
- if($this->IsValid)
- {
- $commentRecord=new CommentRecord;
- $commentRecord->PostID=$this->CurrentPost->ID;
- $commentRecord->AuthorName=$this->CommentAuthor->SafeText;
- $commentRecord->AuthorEmail=$this->CommentEmail->Text;
- $commentRecord->AuthorWebsite=$this->CommentWebsite->SafeText;
- $commentRecord->AuthorIP=$this->Request->UserHostAddress;
- $commentRecord->Content=$this->CommentContent->SafeText;
- $commentRecord->CreateTime=time();
- $commentRecord->Status=0;
- $this->DataAccess->insertComment($commentRecord);
- $this->Response->reload();
- }
- }
-
- public function deleteButtonClicked($sender,$param)
- {
- $this->DataAccess->deletePost($this->CurrentPost->ID);
- $this->gotoDefaultPage();
- }
-
- public function repeaterItemCommand($sender,$param)
- {
- $id=TPropertyValue::ensureInteger($param->CommandParameter);
- $this->DataAccess->deleteComment($id);
- $this->Response->reload();
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * ViewPost class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class ViewPost extends BlogPage
+{
+ private $_post=null;
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $id=TPropertyValue::ensureInteger($this->Request['id']);
+ $this->_post=$this->DataAccess->queryPostByID($id);
+ if($this->_post===null)
+ throw new BlogException(500,'post_id_invalid',$id);
+ // if post is not published, only the author and admin can view it
+ if($this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY && !$this->User->IsAdmin && $this->User->ID!==$this->_post->AuthorID)
+ throw new BlogException(500,'post_view_disallowed',$id);
+ $this->Title=htmlentities($this->_post->Title,ENT_QUOTES,'UTF-8');
+ }
+
+ public function getCanEditPost()
+ {
+ $user=$this->getUser();
+ return $user->getIsAdmin() || $user->getID()===$this->_post->AuthorID;
+ }
+
+ public function getCurrentPost()
+ {
+ return $this->_post;
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $this->Status->Visible=$this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY;
+ $this->CategoryList->DataSource=$this->DataAccess->queryCategoriesByPostID($this->_post->ID);
+ $this->CategoryList->dataBind();
+ $this->CommentList->DataSource=$this->DataAccess->queryCommentsByPostID($this->_post->ID);
+ $this->CommentList->dataBind();
+ }
+
+ public function submitCommentButtonClicked($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $commentRecord=new CommentRecord;
+ $commentRecord->PostID=$this->CurrentPost->ID;
+ $commentRecord->AuthorName=$this->CommentAuthor->SafeText;
+ $commentRecord->AuthorEmail=$this->CommentEmail->Text;
+ $commentRecord->AuthorWebsite=$this->CommentWebsite->SafeText;
+ $commentRecord->AuthorIP=$this->Request->UserHostAddress;
+ $commentRecord->Content=$this->CommentContent->SafeText;
+ $commentRecord->CreateTime=time();
+ $commentRecord->Status=0;
+ $this->DataAccess->insertComment($commentRecord);
+ $this->Response->reload();
+ }
+ }
+
+ public function deleteButtonClicked($sender,$param)
+ {
+ $this->DataAccess->deletePost($this->CurrentPost->ID);
+ $this->gotoDefaultPage();
+ }
+
+ public function repeaterItemCommand($sender,$param)
+ {
+ $id=TPropertyValue::ensureInteger($param->CommandParameter);
+ $this->DataAccess->deleteComment($id);
+ $this->Response->reload();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/SearchPost.php b/demos/blog/protected/Pages/SearchPost.php
index dc483f9a..437435f9 100644
--- a/demos/blog/protected/Pages/SearchPost.php
+++ b/demos/blog/protected/Pages/SearchPost.php
@@ -1,68 +1,68 @@
-_posts=$this->DataAccess->queryPostsSearch(
- $this->getPostKeywords(),
- 'ORDER BY create_time DESC',
- 'LIMIT '.$this->getPageOffset().','.$this->getPageSize());
- }
-
- private function getPostKeywords()
- {
- return explode(' ',$this->Request['keyword']);
- }
-
- private function getPageOffset()
- {
- if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0)
- $offset=0;
- return $offset;
- }
-
- private function getPageSize()
- {
- if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0)
- $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
- return $limit;
- }
-
- private function formUrl($newOffset)
- {
- $gets=array();
- $gets['offset']=$newOffset;
- if($this->Request['limit']!==null)
- $gets['limit']=$this->Request['limit'];
- if($this->Request['time']!==null)
- $gets['time']=$this->Request['time'];
- if($this->Request['cat']!==null)
- $gets['cat']=$this->Request['cat'];
- return $this->Service->constructUrl('Posts.ListPost',$gets);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->PostList->DataSource=$this->_posts;
- $this->PostList->dataBind();
- if($this->getPageOffset()>0)
- {
- if(($offset=$this->getPageOffset()-$this->getPageSize())<0)
- $offset=0;
- $this->PrevPage->NavigateUrl=$this->formUrl($offset);
- $this->PrevPage->Visible=true;
- }
- if(count($this->_posts)===$this->getPageSize())
- {
- $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize());
- $this->NextPage->Visible=true;
- }
- }
-}
-
+_posts=$this->DataAccess->queryPostsSearch(
+ $this->getPostKeywords(),
+ 'ORDER BY create_time DESC',
+ 'LIMIT '.$this->getPageOffset().','.$this->getPageSize());
+ }
+
+ private function getPostKeywords()
+ {
+ return explode(' ',$this->Request['keyword']);
+ }
+
+ private function getPageOffset()
+ {
+ if(($offset=TPropertyValue::ensureInteger($this->Request['offset']))<=0)
+ $offset=0;
+ return $offset;
+ }
+
+ private function getPageSize()
+ {
+ if(($limit=TPropertyValue::ensureInteger($this->Request['limit']))<=0)
+ $limit=TPropertyValue::ensureInteger($this->Application->Parameters['PostPerPage']);
+ return $limit;
+ }
+
+ private function formUrl($newOffset)
+ {
+ $gets=array();
+ $gets['offset']=$newOffset;
+ if($this->Request['limit']!==null)
+ $gets['limit']=$this->Request['limit'];
+ if($this->Request['time']!==null)
+ $gets['time']=$this->Request['time'];
+ if($this->Request['cat']!==null)
+ $gets['cat']=$this->Request['cat'];
+ return $this->Service->constructUrl('Posts.ListPost',$gets);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $this->PostList->DataSource=$this->_posts;
+ $this->PostList->dataBind();
+ if($this->getPageOffset()>0)
+ {
+ if(($offset=$this->getPageOffset()-$this->getPageSize())<0)
+ $offset=0;
+ $this->PrevPage->NavigateUrl=$this->formUrl($offset);
+ $this->PrevPage->Visible=true;
+ }
+ if(count($this->_posts)===$this->getPageSize())
+ {
+ $this->NextPage->NavigateUrl=$this->formUrl($this->getPageOffset()+$this->getPageSize());
+ $this->NextPage->Visible=true;
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Users/EditUser.php b/demos/blog/protected/Pages/Users/EditUser.php
index c574ca6b..8d5cb090 100644
--- a/demos/blog/protected/Pages/Users/EditUser.php
+++ b/demos/blog/protected/Pages/Users/EditUser.php
@@ -1,69 +1,69 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * EditUser class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class EditUser extends BlogPage
-{
- private $_userRecord=null;
-
- public function onInit($param)
- {
- parent::onInit($param);
- if(($id=$this->Request['id'])!==null)
- {
- $id=TPropertyValue::ensureInteger($id);
- if(!$this->User->IsAdmin && $this->User->ID!==$id)
- throw new BlogException(500,'profile_edit_disallowed',$id);
- }
- else
- $id=$this->User->ID;
- if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null)
- throw new BlogException(500,'profile_id_invalid',$id);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $userRecord=$this->_userRecord;
- $this->Username->Text=$userRecord->Name;
- $this->FullName->Text=$userRecord->FullName;
- $this->Email->Text=$userRecord->Email;
- $this->Website->Text=$userRecord->Website;
- }
- }
-
- public function saveButtonClicked($sender,$param)
- {
- if($this->IsValid)
- {
- $userRecord=$this->_userRecord;
- if($this->Password->Text!=='')
- $userRecord->Password=md5($this->Password->Text);
- $userRecord->FullName=$this->FullName->Text;
- $userRecord->Email=$this->Email->Text;
- $userRecord->Website=$this->Website->Text;
- $this->DataAccess->updateUser($userRecord);
- $authManager=$this->Application->getModule('auth');
- $this->gotoPage('Users.ViewUser',array('id'=>$userRecord->ID));
- }
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * EditUser class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class EditUser extends BlogPage
+{
+ private $_userRecord=null;
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ if(($id=$this->Request['id'])!==null)
+ {
+ $id=TPropertyValue::ensureInteger($id);
+ if(!$this->User->IsAdmin && $this->User->ID!==$id)
+ throw new BlogException(500,'profile_edit_disallowed',$id);
+ }
+ else
+ $id=$this->User->ID;
+ if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null)
+ throw new BlogException(500,'profile_id_invalid',$id);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $userRecord=$this->_userRecord;
+ $this->Username->Text=$userRecord->Name;
+ $this->FullName->Text=$userRecord->FullName;
+ $this->Email->Text=$userRecord->Email;
+ $this->Website->Text=$userRecord->Website;
+ }
+ }
+
+ public function saveButtonClicked($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $userRecord=$this->_userRecord;
+ if($this->Password->Text!=='')
+ $userRecord->Password=md5($this->Password->Text);
+ $userRecord->FullName=$this->FullName->Text;
+ $userRecord->Email=$this->Email->Text;
+ $userRecord->Website=$this->Website->Text;
+ $this->DataAccess->updateUser($userRecord);
+ $authManager=$this->Application->getModule('auth');
+ $this->gotoPage('Users.ViewUser',array('id'=>$userRecord->ID));
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Users/NewUser.php b/demos/blog/protected/Pages/Users/NewUser.php
index 40e79910..50f9f123 100644
--- a/demos/blog/protected/Pages/Users/NewUser.php
+++ b/demos/blog/protected/Pages/Users/NewUser.php
@@ -1,58 +1,58 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * NewUser class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class NewUser extends BlogPage
-{
- public function onInit($param)
- {
- if(!$this->User->IsAdmin && !TPropertyValue::ensureBoolean($this->Application->Parameters['MultipleUser']))
- throw new BlogException(500,'newuser_registration_disallowed');
- }
-
- public function checkUsername($sender,$param)
- {
- $username=strtolower($this->Username->Text);
- $param->IsValid=$this->DataAccess->queryUserByName($username)===null;
- }
-
- public function createUser($sender,$param)
- {
- if($this->IsValid)
- {
- $userRecord=new UserRecord;
- $userRecord->Name=strtolower($this->Username->Text);
- $userRecord->FullName=$this->FullName->Text;
- $userRecord->Role=0;
- $userRecord->Password=md5($this->Password->Text);
- $userRecord->Email=$this->Email->Text;
- $userRecord->CreateTime=time();
- $userRecord->Website=$this->Website->Text;
- if(TPropertyValue::ensureBoolean($this->Application->Parameters['AccountApproval']))
- $userRecord->Status=UserRecord::STATUS_PENDING;
- else
- $userRecord->Status=UserRecord::STATUS_NORMAL;
- $this->DataAccess->insertUser($userRecord);
- $authManager=$this->Application->getModule('auth');
- $authManager->login($this->Username->Text,$this->Password->Text);
- $this->gotoDefaultPage();
- }
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * NewUser class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class NewUser extends BlogPage
+{
+ public function onInit($param)
+ {
+ if(!$this->User->IsAdmin && !TPropertyValue::ensureBoolean($this->Application->Parameters['MultipleUser']))
+ throw new BlogException(500,'newuser_registration_disallowed');
+ }
+
+ public function checkUsername($sender,$param)
+ {
+ $username=strtolower($this->Username->Text);
+ $param->IsValid=$this->DataAccess->queryUserByName($username)===null;
+ }
+
+ public function createUser($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $userRecord=new UserRecord;
+ $userRecord->Name=strtolower($this->Username->Text);
+ $userRecord->FullName=$this->FullName->Text;
+ $userRecord->Role=0;
+ $userRecord->Password=md5($this->Password->Text);
+ $userRecord->Email=$this->Email->Text;
+ $userRecord->CreateTime=time();
+ $userRecord->Website=$this->Website->Text;
+ if(TPropertyValue::ensureBoolean($this->Application->Parameters['AccountApproval']))
+ $userRecord->Status=UserRecord::STATUS_PENDING;
+ else
+ $userRecord->Status=UserRecord::STATUS_NORMAL;
+ $this->DataAccess->insertUser($userRecord);
+ $authManager=$this->Application->getModule('auth');
+ $authManager->login($this->Username->Text,$this->Password->Text);
+ $this->gotoDefaultPage();
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Pages/Users/ViewUser.php b/demos/blog/protected/Pages/Users/ViewUser.php
index 75bd711a..86c27592 100644
--- a/demos/blog/protected/Pages/Users/ViewUser.php
+++ b/demos/blog/protected/Pages/Users/ViewUser.php
@@ -1,42 +1,42 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * ViewUser class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class ViewUser extends BlogPage
-{
- private $_userRecord=null;
-
- public function onInit($param)
- {
- parent::onInit($param);
- if(($id=$this->Request['id'])!==null)
- $id=TPropertyValue::ensureInteger($id);
- else
- $id=$this->User->ID;
- if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null)
- throw new BlogException(500,'profile_id_invalid',$id);
- $this->_userRecord->Email=strtr(strtoupper($this->_userRecord->Email),array('@'=>' at ','.'=>' dot '));
- }
-
- public function getProfile()
- {
- return $this->_userRecord;
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * ViewUser class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class ViewUser extends BlogPage
+{
+ private $_userRecord=null;
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ if(($id=$this->Request['id'])!==null)
+ $id=TPropertyValue::ensureInteger($id);
+ else
+ $id=$this->User->ID;
+ if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null)
+ throw new BlogException(500,'profile_id_invalid',$id);
+ $this->_userRecord->Email=strtr(strtoupper($this->_userRecord->Email),array('@'=>' at ','.'=>' dot '));
+ }
+
+ public function getProfile()
+ {
+ return $this->_userRecord;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Portlets/AccountPortlet.php b/demos/blog/protected/Portlets/AccountPortlet.php
index 2bbe55d3..40be36ae 100644
--- a/demos/blog/protected/Portlets/AccountPortlet.php
+++ b/demos/blog/protected/Portlets/AccountPortlet.php
@@ -1,31 +1,31 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('Application.Portlets.Portlet');
-
-/**
- * AccountPortlet class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class AccountPortlet extends Portlet
-{
- public function logout($sender,$param)
- {
- $this->Application->getModule('auth')->logout();
- $this->Response->reload();
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * AccountPortlet class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class AccountPortlet extends Portlet
+{
+ public function logout($sender,$param)
+ {
+ $this->Application->getModule('auth')->logout();
+ $this->Response->reload();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Portlets/ArchivePortlet.php b/demos/blog/protected/Portlets/ArchivePortlet.php
index 003eb0cc..f8bd488e 100644
--- a/demos/blog/protected/Portlets/ArchivePortlet.php
+++ b/demos/blog/protected/Portlets/ArchivePortlet.php
@@ -1,62 +1,62 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('Application.Portlets.Portlet');
-
-/**
- * ArchivePortlet class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class ArchivePortlet extends Portlet
-{
- private function makeMonthTime($timestamp)
- {
- $date=getdate($timestamp);
- return mktime(0,0,0,$date['mon'],1,$date['year']);
- }
-
- public function onLoad($param)
- {
- $currentTime=time();
- $startTime=$this->Application->getModule('data')->queryEarliestPostTime();
- if(empty($startTime)) // if no posts
- $startTime=$currentTime;
-
- // obtain the timestamp for the initial month
- $date=getdate($startTime);
- $startTime=mktime(0,0,0,$date['mon'],1,$date['year']);
-
- $date=getdate($currentTime);
- $month=$date['mon'];
- $year=$date['year'];
-
- $timestamps=array();
- while(true)
- {
- if(($timestamp=mktime(0,0,0,$month,1,$year))<$startTime)
- break;
- $timestamps[]=$timestamp;
- if(--$month===0)
- {
- $month=12;
- $year--;
- }
- }
- $this->MonthList->DataSource=$timestamps;
- $this->MonthList->dataBind();
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * ArchivePortlet class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class ArchivePortlet extends Portlet
+{
+ private function makeMonthTime($timestamp)
+ {
+ $date=getdate($timestamp);
+ return mktime(0,0,0,$date['mon'],1,$date['year']);
+ }
+
+ public function onLoad($param)
+ {
+ $currentTime=time();
+ $startTime=$this->Application->getModule('data')->queryEarliestPostTime();
+ if(empty($startTime)) // if no posts
+ $startTime=$currentTime;
+
+ // obtain the timestamp for the initial month
+ $date=getdate($startTime);
+ $startTime=mktime(0,0,0,$date['mon'],1,$date['year']);
+
+ $date=getdate($currentTime);
+ $month=$date['mon'];
+ $year=$date['year'];
+
+ $timestamps=array();
+ while(true)
+ {
+ if(($timestamp=mktime(0,0,0,$month,1,$year))<$startTime)
+ break;
+ $timestamps[]=$timestamp;
+ if(--$month===0)
+ {
+ $month=12;
+ $year--;
+ }
+ }
+ $this->MonthList->DataSource=$timestamps;
+ $this->MonthList->dataBind();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Portlets/CategoryPortlet.php b/demos/blog/protected/Portlets/CategoryPortlet.php
index d95b0661..0b451db8 100644
--- a/demos/blog/protected/Portlets/CategoryPortlet.php
+++ b/demos/blog/protected/Portlets/CategoryPortlet.php
@@ -1,38 +1,38 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('Application.Portlets.Portlet');
-
-/**
- * CategoryPortlet class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class CategoryPortlet extends Portlet
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $cats=$this->Application->getModule('data')->queryCategories();
- foreach($cats as $cat)
- {
- $cat->ID=$this->Service->constructUrl('Posts.ListPost',array('cat'=>$cat->ID));
- $cat->Name.=' (' . $cat->PostCount .')';
- }
- $this->CategoryList->DataSource=$cats;
- $this->CategoryList->dataBind();
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * CategoryPortlet class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class CategoryPortlet extends Portlet
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $cats=$this->Application->getModule('data')->queryCategories();
+ foreach($cats as $cat)
+ {
+ $cat->ID=$this->Service->constructUrl('Posts.ListPost',array('cat'=>$cat->ID));
+ $cat->Name.=' (' . $cat->PostCount .')';
+ }
+ $this->CategoryList->DataSource=$cats;
+ $this->CategoryList->dataBind();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Portlets/CommentPortlet.php b/demos/blog/protected/Portlets/CommentPortlet.php
index c3549928..ff8d075a 100644
--- a/demos/blog/protected/Portlets/CommentPortlet.php
+++ b/demos/blog/protected/Portlets/CommentPortlet.php
@@ -1,40 +1,40 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('Application.Portlets.Portlet');
-
-/**
- * CommentPortlet class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class CommentPortlet extends Portlet
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $commentLimit=TPropertyValue::ensureInteger($this->Application->Parameters['RecentComments']);
- $comments=$this->Application->getModule('data')->queryComments('','ORDER BY create_time DESC',"LIMIT $commentLimit");
- foreach($comments as $comment)
- {
- $comment->ID=$this->Service->constructUrl('Posts.ViewPost',array('id'=>$comment->PostID)).'#c'.$comment->ID;
- if(strlen($comment->Content)>40)
- $comment->Content=substr($comment->Content,0,40).' ...';
- }
- $this->CommentList->DataSource=$comments;
- $this->CommentList->dataBind();
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * CommentPortlet class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class CommentPortlet extends Portlet
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $commentLimit=TPropertyValue::ensureInteger($this->Application->Parameters['RecentComments']);
+ $comments=$this->Application->getModule('data')->queryComments('','ORDER BY create_time DESC',"LIMIT $commentLimit");
+ foreach($comments as $comment)
+ {
+ $comment->ID=$this->Service->constructUrl('Posts.ViewPost',array('id'=>$comment->PostID)).'#c'.$comment->ID;
+ if(strlen($comment->Content)>40)
+ $comment->Content=substr($comment->Content,0,40).' ...';
+ }
+ $this->CommentList->DataSource=$comments;
+ $this->CommentList->dataBind();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Portlets/LoginPortlet.php b/demos/blog/protected/Portlets/LoginPortlet.php
index 6f400f0a..58c056b3 100644
--- a/demos/blog/protected/Portlets/LoginPortlet.php
+++ b/demos/blog/protected/Portlets/LoginPortlet.php
@@ -1,39 +1,39 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('Application.Portlets.Portlet');
-
-/**
- * LoginPortlet class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class LoginPortlet extends Portlet
-{
- public function validateUser($sender,$param)
- {
- $authManager=$this->Application->getModule('auth');
- if(!$authManager->login(strtolower($this->Username->Text),$this->Password->Text))
- $param->IsValid=false;
- }
-
- public function loginButtonClicked($sender,$param)
- {
- if($this->Page->IsValid)
- $this->Response->reload();
- //$this->Response->redirect($this->Application->getModule('auth')->getReturnUrl());
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * LoginPortlet class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class LoginPortlet extends Portlet
+{
+ public function validateUser($sender,$param)
+ {
+ $authManager=$this->Application->getModule('auth');
+ if(!$authManager->login(strtolower($this->Username->Text),$this->Password->Text))
+ $param->IsValid=false;
+ }
+
+ public function loginButtonClicked($sender,$param)
+ {
+ if($this->Page->IsValid)
+ $this->Response->reload();
+ //$this->Response->redirect($this->Application->getModule('auth')->getReturnUrl());
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Portlets/Portlet.php b/demos/blog/protected/Portlets/Portlet.php
index 50cb634d..6a7cee70 100644
--- a/demos/blog/protected/Portlets/Portlet.php
+++ b/demos/blog/protected/Portlets/Portlet.php
@@ -1,24 +1,24 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-/**
- * Portlet class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class Portlet extends TTemplateControl
-{
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+/**
+ * Portlet class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class Portlet extends TTemplateControl
+{
+}
+
?>
\ No newline at end of file
diff --git a/demos/blog/protected/Portlets/SearchPortlet.php b/demos/blog/protected/Portlets/SearchPortlet.php
index 10ef0499..4f7d6ebf 100644
--- a/demos/blog/protected/Portlets/SearchPortlet.php
+++ b/demos/blog/protected/Portlets/SearchPortlet.php
@@ -1,39 +1,39 @@
-
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- */
-
-Prado::using('Application.Portlets.Portlet');
-
-/**
- * SearchPortlet class
- *
- * @author Qiang Xue
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-class SearchPortlet extends Portlet
-{
- public function onInit($param)
- {
- parent::onInit($param);
- if(!$this->Page->IsPostBack && ($keyword=$this->Request['keyword'])!==null)
- $this->Keyword->Text=$keyword;
- }
-
- public function search($sender,$param)
- {
- $keyword=$this->Keyword->Text;
- $url=$this->Service->constructUrl('SearchPost',array('keyword'=>$keyword),false);
- $this->Response->redirect($url);
- }
-}
-
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * SearchPortlet class
+ *
+ * @author Qiang Xue
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class SearchPortlet extends Portlet
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ if(!$this->Page->IsPostBack && ($keyword=$this->Request['keyword'])!==null)
+ $this->Keyword->Text=$keyword;
+ }
+
+ public function search($sender,$param)
+ {
+ $keyword=$this->Keyword->Text;
+ $url=$this->Service->constructUrl('SearchPost',array('keyword'=>$keyword),false);
+ $this->Response->redirect($url);
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/chat/index.php b/demos/chat/index.php
index 17ed21d0..7a9eaf42 100644
--- a/demos/chat/index.php
+++ b/demos/chat/index.php
@@ -1,29 +1,29 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/chat/protected/App_Code/ChatBufferRecord.php b/demos/chat/protected/App_Code/ChatBufferRecord.php
index f4d53db0..5a714de2 100644
--- a/demos/chat/protected/App_Code/ChatBufferRecord.php
+++ b/demos/chat/protected/App_Code/ChatBufferRecord.php
@@ -1,64 +1,64 @@
-_created_on === null)
- $this->_created_on = time();
- return $this->_created_on;
- }
-
- public function setCreated_On($value)
- {
- $this->_created_on = $value;
- }
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-
- public function saveMessage()
- {
- foreach(ChatUserRecord::finder()->findAll() as $user)
- {
- $message = new self;
- $message->for_user = $user->username;
- $message->from_user = $this->from_user;
- $message->message = $this->message;
- $message->save();
- if($user->username == $this->from_user)
- {
- $user->last_activity = time(); //update the last activity;
- $user->save();
- }
- }
- }
-
- public function getUserMessages($user)
- {
- $content = '';
- foreach($this->findAll('for_user = ?', $user) as $message)
- $content .= $this->formatMessage($message);
- $this->deleteAll('for_user = ? OR created_on < ?', $user, time() - 300); //5 min inactivity
- return $content;
- }
-
- protected function formatMessage($message)
- {
- $user = htmlspecialchars($message->from_user);
- $content = htmlspecialchars($message->message);
- return "{$user}: {$content}
";
- }
-}
-
+_created_on === null)
+ $this->_created_on = time();
+ return $this->_created_on;
+ }
+
+ public function setCreated_On($value)
+ {
+ $this->_created_on = $value;
+ }
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+
+ public function saveMessage()
+ {
+ foreach(ChatUserRecord::finder()->findAll() as $user)
+ {
+ $message = new self;
+ $message->for_user = $user->username;
+ $message->from_user = $this->from_user;
+ $message->message = $this->message;
+ $message->save();
+ if($user->username == $this->from_user)
+ {
+ $user->last_activity = time(); //update the last activity;
+ $user->save();
+ }
+ }
+ }
+
+ public function getUserMessages($user)
+ {
+ $content = '';
+ foreach($this->findAll('for_user = ?', $user) as $message)
+ $content .= $this->formatMessage($message);
+ $this->deleteAll('for_user = ? OR created_on < ?', $user, time() - 300); //5 min inactivity
+ return $content;
+ }
+
+ protected function formatMessage($message)
+ {
+ $user = htmlspecialchars($message->from_user);
+ $content = htmlspecialchars($message->message);
+ return "{$user}: {$content}
";
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/chat/protected/App_Code/ChatUserManager.php b/demos/chat/protected/App_Code/ChatUserManager.php
index f28ee362..d0f242fd 100644
--- a/demos/chat/protected/App_Code/ChatUserManager.php
+++ b/demos/chat/protected/App_Code/ChatUserManager.php
@@ -1,85 +1,85 @@
-setIsGuest(true);
- if($username !== null)
- {
- $user->setIsGuest(false);
- $user->setName($username);
- $user->setRoles(array('normal'));
- }
- return $user;
- }
-
- /**
- * Add a new user to the database.
- * @param string username.
- */
- public function addNewUser($username)
- {
- $user = new ChatUserRecord();
- $user->username = $username;
- $user->save();
- }
-
- /**
- * @return boolean true if username already exists, false otherwise.
- */
- public function usernameExists($username)
- {
- return ChatUserRecord::finder()->findByUsername($username) instanceof ChatUserRecord;
- }
-
- /**
- * Validates if the username exists.
- * @param string user name
- * @param string password
- * @return boolean true if validation is successful, false otherwise.
- */
- public function validateUser($username,$password)
- {
- return $this->usernameExists($username);
- }
-
- /**
- * Saves user auth data into a cookie.
- * @param THttpCookie the cookie to receive the user auth data.
- * @since 3.1.1
- */
- public function saveUserToCookie($cookie)
- {
- // do nothing since we don't support cookie-based auth in this example
- }
-
- /**
- * Returns a user instance according to auth data stored in a cookie.
- * @param THttpCookie the cookie storing user authentication information
- * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
- * @since 3.1.1
- */
- public function getUserFromCookie($cookie)
- {
- // do nothing since we don't support cookie-based auth in this example
- return null;
- }
-}
-
-
+setIsGuest(true);
+ if($username !== null)
+ {
+ $user->setIsGuest(false);
+ $user->setName($username);
+ $user->setRoles(array('normal'));
+ }
+ return $user;
+ }
+
+ /**
+ * Add a new user to the database.
+ * @param string username.
+ */
+ public function addNewUser($username)
+ {
+ $user = new ChatUserRecord();
+ $user->username = $username;
+ $user->save();
+ }
+
+ /**
+ * @return boolean true if username already exists, false otherwise.
+ */
+ public function usernameExists($username)
+ {
+ return ChatUserRecord::finder()->findByUsername($username) instanceof ChatUserRecord;
+ }
+
+ /**
+ * Validates if the username exists.
+ * @param string user name
+ * @param string password
+ * @return boolean true if validation is successful, false otherwise.
+ */
+ public function validateUser($username,$password)
+ {
+ return $this->usernameExists($username);
+ }
+
+ /**
+ * Saves user auth data into a cookie.
+ * @param THttpCookie the cookie to receive the user auth data.
+ * @since 3.1.1
+ */
+ public function saveUserToCookie($cookie)
+ {
+ // do nothing since we don't support cookie-based auth in this example
+ }
+
+ /**
+ * Returns a user instance according to auth data stored in a cookie.
+ * @param THttpCookie the cookie storing user authentication information
+ * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
+ * @since 3.1.1
+ */
+ public function getUserFromCookie($cookie)
+ {
+ // do nothing since we don't support cookie-based auth in this example
+ return null;
+ }
+}
+
+
?>
\ No newline at end of file
diff --git a/demos/chat/protected/App_Code/ChatUserRecord.php b/demos/chat/protected/App_Code/ChatUserRecord.php
index b68fbd4d..ee45cf84 100644
--- a/demos/chat/protected/App_Code/ChatUserRecord.php
+++ b/demos/chat/protected/App_Code/ChatUserRecord.php
@@ -1,41 +1,41 @@
-_last_activity === null)
- $this->_last_activity = time();
- return $this->_last_activity;
- }
-
- public function setLast_Activity($value)
- {
- $this->_last_activity = $value;
- }
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-
- public function getUserList()
- {
- $this->deleteAll('last_activity < ?', time()-300); //5 min inactivity
- $content = '';
- foreach($this->findAll() as $user)
- {
- $content .= ''.htmlspecialchars($user->username).' ';
- }
- $content .= ' ';
-
- return $content;
- }
-}
-
+_last_activity === null)
+ $this->_last_activity = time();
+ return $this->_last_activity;
+ }
+
+ public function setLast_Activity($value)
+ {
+ $this->_last_activity = $value;
+ }
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+
+ public function getUserList()
+ {
+ $this->deleteAll('last_activity < ?', time()-300); //5 min inactivity
+ $content = '';
+ foreach($this->findAll() as $user)
+ {
+ $content .= ''.htmlspecialchars($user->username).' ';
+ }
+ $content .= ' ';
+
+ return $content;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/chat/protected/pages/Home.php b/demos/chat/protected/pages/Home.php
index 65cb22dc..bdcb2d3b 100644
--- a/demos/chat/protected/pages/Home.php
+++ b/demos/chat/protected/pages/Home.php
@@ -1,56 +1,56 @@
-Application->User->Name;
- if(!$this->Application->Modules['users']->usernameExists($username))
- {
- $auth = $this->Application->Modules['auth'];
- $auth->logout();
-
- //redirect to login page.
- $this->Response->Redirect($this->Service->ConstructUrl($auth->LoginPage));
- }
- }
-
- function processMessage($sender, $param)
- {
- if(strlen($this->userinput->Text) > 0)
- {
- $record = new ChatBufferRecord();
- $record->message = $this->userinput->Text;
- $record->from_user = $this->Application->User->Name;
- $record->saveMessage();
- $this->userinput->Text = '';
- $this->refresh($sender, $param);
- $this->CallbackClient->focus($this->userinput);
- }
- }
-
- function refresh($sender, $param)
- {
- //refresh the message list
- $content = ChatBufferRecord::finder()->getUserMessages($this->Application->User->Name);
- if(strlen($content) > 0)
- {
- $client = $this->Page->CallbackClient;
- $anchor = (string)time();
- $content .= " ";
- $client->appendContent("messages", $content);
- $client->focus($anchor);
- }
-
- //refresh the user list
- $lastUpdate = $this->getViewState('userList','');
- $users = ChatUserRecord::finder()->getUserList();
- if($lastUpdate != $users)
- {
- $this->Page->CallbackClient->update('users', $users);
- $this->setViewstate('userList', $users);
- }
- }
-}
-
+Application->User->Name;
+ if(!$this->Application->Modules['users']->usernameExists($username))
+ {
+ $auth = $this->Application->Modules['auth'];
+ $auth->logout();
+
+ //redirect to login page.
+ $this->Response->Redirect($this->Service->ConstructUrl($auth->LoginPage));
+ }
+ }
+
+ function processMessage($sender, $param)
+ {
+ if(strlen($this->userinput->Text) > 0)
+ {
+ $record = new ChatBufferRecord();
+ $record->message = $this->userinput->Text;
+ $record->from_user = $this->Application->User->Name;
+ $record->saveMessage();
+ $this->userinput->Text = '';
+ $this->refresh($sender, $param);
+ $this->CallbackClient->focus($this->userinput);
+ }
+ }
+
+ function refresh($sender, $param)
+ {
+ //refresh the message list
+ $content = ChatBufferRecord::finder()->getUserMessages($this->Application->User->Name);
+ if(strlen($content) > 0)
+ {
+ $client = $this->Page->CallbackClient;
+ $anchor = (string)time();
+ $content .= " ";
+ $client->appendContent("messages", $content);
+ $client->focus($anchor);
+ }
+
+ //refresh the user list
+ $lastUpdate = $this->getViewState('userList','');
+ $users = ChatUserRecord::finder()->getUserList();
+ if($lastUpdate != $users)
+ {
+ $this->Page->CallbackClient->update('users', $users);
+ $this->setViewstate('userList', $users);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/chat/protected/pages/Login.php b/demos/chat/protected/pages/Login.php
index 831ab925..ec39f1f0 100644
--- a/demos/chat/protected/pages/Login.php
+++ b/demos/chat/protected/pages/Login.php
@@ -1,40 +1,40 @@
-Application->Modules['users'];
- if($manager->usernameExists($this->username->Text))
- $param->IsValid = false;
- }
-
- /**
- * Create and login a new user, then redirect to the requested page.
- * @param TControl button control that created the event.
- * @param TEventParameter event parameters.
- */
- function createNewUser($sender, $param)
- {
- if($this->Page->IsValid)
- {
- $manager = $this->Application->Modules['users'];
- $manager->addNewUser($this->username->Text);
-
- //do manual login
- $user = $manager->getUser($this->username->Text);
- $auth = $this->Application->Modules['auth'];
- $auth->updateSessionUser($user);
- $this->Application->User = $user;
-
- $this->Response->redirect($auth->ReturnUrl);
- }
- }
-}
-
+Application->Modules['users'];
+ if($manager->usernameExists($this->username->Text))
+ $param->IsValid = false;
+ }
+
+ /**
+ * Create and login a new user, then redirect to the requested page.
+ * @param TControl button control that created the event.
+ * @param TEventParameter event parameters.
+ */
+ function createNewUser($sender, $param)
+ {
+ if($this->Page->IsValid)
+ {
+ $manager = $this->Application->Modules['users'];
+ $manager->addNewUser($this->username->Text);
+
+ //do manual login
+ $user = $manager->getUser($this->username->Text);
+ $auth = $this->Application->Modules['auth'];
+ $auth->updateSessionUser($user);
+ $this->Application->User = $user;
+
+ $this->Response->redirect($auth->ReturnUrl);
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/composer/index.php b/demos/composer/index.php
index 43c0b436..6efff1af 100644
--- a/demos/composer/index.php
+++ b/demos/composer/index.php
@@ -1,18 +1,18 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/composer/index2.php b/demos/composer/index2.php
index f3d8dd90..30df9480 100644
--- a/demos/composer/index2.php
+++ b/demos/composer/index2.php
@@ -1,18 +1,18 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/composer/protected/pages/ClassDefinition.php b/demos/composer/protected/pages/ClassDefinition.php
index cb657e85..aee5fe6f 100644
--- a/demos/composer/protected/pages/ClassDefinition.php
+++ b/demos/composer/protected/pages/ClassDefinition.php
@@ -1,371 +1,371 @@
-_className='ClassName';
- $this->_parentClass='TWebControl';
- $this->_interfaces='';
- $this->_properties=new TList;
- $this->_events=new TList;
- $this->_email='';
- $this->_author='';
- $this->_comments='';
- }
-
- public function render($writer)
- {
- $this->renderComments($writer);
- $this->renderClass($writer);
- }
-
- protected function renderComments($writer)
- {
- $str ="/**\n";
- $str.=" * Class {$this->ClassName}.\n";
- if($this->Comments!=='')
- {
- $str.=" *\n";
- $str.=" * ".implode("\n * ",explode("\n",wordwrap($this->Comments)));
- $str.="\n *\n";
- }
- if($this->Author!=='')
- {
- $str.=" * @author {$this->Author}";
- if($this->Email!=='')
- $str.=" <{$this->Email}>";
- $str.="\n";
- }
- $str.=" * @version \$Revision: \$ \$Date: \$\n";
- $str.=" */\n";
- $writer->write($str);
- }
-
- protected function renderClass($writer)
- {
- $writer->write("class {$this->ClassName}");
- if($this->ParentClass!=='')
- $writer->write(" extends {$this->ParentClass}");
- if($this->Interfaces!=='')
- $writer->write(" implements {$this->Interfaces}");
- $writer->write("\n{\n");
- $this->renderVariables($writer);
- $this->renderProperties($writer);
- $this->renderEvents($writer);
- $writer->write("}\n");
- }
-
- private function getVariableName($propertyName)
- {
- return '_'.strtolower($propertyName[0]).substr($propertyName,1);
- }
-
- protected function renderVariables($writer)
- {
- foreach($this->Properties as $property)
- {
- if($property->Storage==='Memory')
- {
- $name=$this->getVariableName($property->Name);
- $value=$this->getValueAsString($property->DefaultValue,$property->Type);
- $writer->write("\t/**\n\t * @var {$property->Type} {$property->Comments}\n\t */\n");
- $writer->write("\tprivate \$$name=$value;\n");
- }
- }
- }
-
- private function getValueAsString($value,$type)
- {
- switch($type)
- {
- case 'integer':
- $value=TPropertyValue::ensureInteger($value);
- break;
- case 'float':
- $value=TPropertyValue::ensureFloat($value);
- break;
- case 'boolean':
- if(TPropertyValue::ensureBoolean($value))
- $value='true';
- else
- $value='false';
- break;
- case 'enumerable':
- $value="'$value'";
- break;
- case 'mixed':
- $value='null';
- break;
- case 'string':
- $value="'$value'";
- break;
- }
- return "$value";
- }
-
- private function getValueConversionString($type)
- {
- switch($type)
- {
- case 'integer': return 'TPropertyValue::ensureInteger($value)';
- case 'float': return 'TPropertyValue::ensureFloat($value)';
- case 'boolean': return 'TPropertyValue::ensureBoolean($value)';
- case 'enumerable': return 'TPropertyValue::ensureEnum($value)';
- case 'mixed': return '$value';
- case 'string': return 'TPropertyValue::ensureString($value)';
- }
- }
-
- protected function renderProperties($writer)
- {
- foreach($this->Properties as $property)
- {
- $name=$property->Name;
- if($name==='')
- continue;
- $comments=implode("\n\t * ",explode("\n",wordwrap($property->Comments)));
- $access=$property->IsProtected?'protected':'public';
- $setter='set'.$property->Name.'($value)';
- $getter='get'.$property->Name.'()';
- $value=$this->getValueAsString($property->DefaultValue,$property->Type);
- if($property->Storage==='ViewState')
- {
- $readStatement="return \$this->getViewState('$name',$value);";
- $writeStatement="\$this->setViewState('$name',".$this->getValueConversionString($property->Type).",$value);";
- }
- else if($property->Storage==='ControlState')
- {
- $readStatement="return \$this->getControlState('$name',$value);";
- $writeStatement="\$this->setControlState('$name',".$this->getValueConversionString($property->Type).",$value);";
- }
- else
- {
- $varname=$this->getVariableName($property->Name);
- $readStatement="return \$this->$varname;";
- $writeStatement="\$this->$varname=".$this->getValueConversionString($property->Type).";";
- }
- $writer->write("\n\t/**\n\t * @return {$property->Type} $comments Defaults to $value.\n\t */\n");
- $writer->write("\t$access function $getter\n\t{\n\t\t$readStatement\n\t}\n");
- if(!$property->ReadOnly)
- {
- $writer->write("\n\t/**\n\t * @param {$property->Type} $comments\n\t */\n");
- $writer->write("\t$access function $setter\n\t{\n\t\t$writeStatement\n\t}\n");
- }
- }
- }
-
- protected function renderEvents($writer)
- {
- foreach($this->Events as $event)
- {
- $name=$event->Name;
- if($name==='')
- continue;
- if(strncasecmp($name,'on',2)!==0)
- $name='On'.$name;
- else
- {
- $name[0]='O';
- $name[1]='n';
- }
- $methodName=$name;
- $methodName[0]='o';
- $comments=implode("\n\t * ",explode("\n",wordwrap($event->Comments)));
- $writer->write("\n\t/**\n\t * Raises $name event.\n\t * $comments\n\t * @param TEventParameter event parameter\n\t */\n");
- $writer->write("\tpublic function $methodName(\$param)\n\t{\n\t\t\$this->raiseEvent('$name',\$this,\$param);\n\t}\n");
- }
- }
-
- public function getClassName()
- {
- return $this->_className;
- }
-
- public function setClassName($value)
- {
- $this->_className=trim($value);
- }
-
- public function getParentClass()
- {
- return $this->_parentClass;
- }
-
- public function setParentClass($value)
- {
- $this->_parentClass=trim($value);
- }
-
- public function getInterfaces()
- {
- return $this->_interfaces;
- }
-
- public function setInterfaces($value)
- {
- $this->_interfaces=$value;
- }
-
- public function getProperties()
- {
- if(!$this->_properties)
- $this->_properties=new TList;
- return $this->_properties;
- }
-
- public function getEvents()
- {
- if(!$this->_events)
- $this->_events=new TList;
- return $this->_events;
- }
-
- public function getComments()
- {
- return $this->_comments;
- }
-
- public function setComments($value)
- {
- $this->_comments=$value;
- }
-
- public function getAuthor()
- {
- return $this->_author;
- }
-
- public function setAuthor($value)
- {
- $this->_author=trim($value);
- }
-
- public function getEmail()
- {
- return $this->_email;
- }
-
- public function setEmail($value)
- {
- $this->_email=trim($value);
- }
-}
-
-class EventDefinition extends TComponent
-{
- private $_name='';
- private $_comments='';
-
- public function getName()
- {
- return $this->_name;
- }
-
- public function setName($value)
- {
- $this->_name=ucfirst(trim($value));
- }
-
- public function getComments()
- {
- return $this->_comments;
- }
-
- public function setComments($value)
- {
- $this->_comments=$value;
- }
-}
-
-class PropertyDefinition extends TComponent
-{
- private $_name='';
- private $_type='string';
- private $_default='';
- private $_readOnly=false;
- private $_protected=false;
- private $_storage='ViewState';
- private $_comments='';
-
- public function getName()
- {
- return $this->_name;
- }
-
- public function setName($value)
- {
- $this->_name=ucfirst(trim($value));
- }
-
- public function getType()
- {
- return $this->_type;
- }
-
- public function setType($value)
- {
- $this->_type=trim($value);
- }
-
- public function getDefaultValue()
- {
- return $this->_default;
- }
-
- public function setDefaultValue($value)
- {
- $this->_default=trim($value);
- }
-
- public function getReadOnly()
- {
- return $this->_readOnly;
- }
-
- public function setReadOnly($value)
- {
- $this->_readOnly=TPropertyValue::ensureBoolean($value);
- }
-
- public function getIsProtected()
- {
- return $this->_protected;
- }
-
- public function setIsProtected($value)
- {
- $this->_protected=TPropertyValue::ensureBoolean($value);
- }
-
- public function getStorage()
- {
- return $this->_storage;
- }
-
- public function setStorage($value)
- {
- $this->_storage=trim($value);
- }
-
- public function getComments()
- {
- return $this->_comments;
- }
-
- public function setComments($value)
- {
- $this->_comments=$value;
- }
-}
-
+_className='ClassName';
+ $this->_parentClass='TWebControl';
+ $this->_interfaces='';
+ $this->_properties=new TList;
+ $this->_events=new TList;
+ $this->_email='';
+ $this->_author='';
+ $this->_comments='';
+ }
+
+ public function render($writer)
+ {
+ $this->renderComments($writer);
+ $this->renderClass($writer);
+ }
+
+ protected function renderComments($writer)
+ {
+ $str ="/**\n";
+ $str.=" * Class {$this->ClassName}.\n";
+ if($this->Comments!=='')
+ {
+ $str.=" *\n";
+ $str.=" * ".implode("\n * ",explode("\n",wordwrap($this->Comments)));
+ $str.="\n *\n";
+ }
+ if($this->Author!=='')
+ {
+ $str.=" * @author {$this->Author}";
+ if($this->Email!=='')
+ $str.=" <{$this->Email}>";
+ $str.="\n";
+ }
+ $str.=" * @version \$Revision: \$ \$Date: \$\n";
+ $str.=" */\n";
+ $writer->write($str);
+ }
+
+ protected function renderClass($writer)
+ {
+ $writer->write("class {$this->ClassName}");
+ if($this->ParentClass!=='')
+ $writer->write(" extends {$this->ParentClass}");
+ if($this->Interfaces!=='')
+ $writer->write(" implements {$this->Interfaces}");
+ $writer->write("\n{\n");
+ $this->renderVariables($writer);
+ $this->renderProperties($writer);
+ $this->renderEvents($writer);
+ $writer->write("}\n");
+ }
+
+ private function getVariableName($propertyName)
+ {
+ return '_'.strtolower($propertyName[0]).substr($propertyName,1);
+ }
+
+ protected function renderVariables($writer)
+ {
+ foreach($this->Properties as $property)
+ {
+ if($property->Storage==='Memory')
+ {
+ $name=$this->getVariableName($property->Name);
+ $value=$this->getValueAsString($property->DefaultValue,$property->Type);
+ $writer->write("\t/**\n\t * @var {$property->Type} {$property->Comments}\n\t */\n");
+ $writer->write("\tprivate \$$name=$value;\n");
+ }
+ }
+ }
+
+ private function getValueAsString($value,$type)
+ {
+ switch($type)
+ {
+ case 'integer':
+ $value=TPropertyValue::ensureInteger($value);
+ break;
+ case 'float':
+ $value=TPropertyValue::ensureFloat($value);
+ break;
+ case 'boolean':
+ if(TPropertyValue::ensureBoolean($value))
+ $value='true';
+ else
+ $value='false';
+ break;
+ case 'enumerable':
+ $value="'$value'";
+ break;
+ case 'mixed':
+ $value='null';
+ break;
+ case 'string':
+ $value="'$value'";
+ break;
+ }
+ return "$value";
+ }
+
+ private function getValueConversionString($type)
+ {
+ switch($type)
+ {
+ case 'integer': return 'TPropertyValue::ensureInteger($value)';
+ case 'float': return 'TPropertyValue::ensureFloat($value)';
+ case 'boolean': return 'TPropertyValue::ensureBoolean($value)';
+ case 'enumerable': return 'TPropertyValue::ensureEnum($value)';
+ case 'mixed': return '$value';
+ case 'string': return 'TPropertyValue::ensureString($value)';
+ }
+ }
+
+ protected function renderProperties($writer)
+ {
+ foreach($this->Properties as $property)
+ {
+ $name=$property->Name;
+ if($name==='')
+ continue;
+ $comments=implode("\n\t * ",explode("\n",wordwrap($property->Comments)));
+ $access=$property->IsProtected?'protected':'public';
+ $setter='set'.$property->Name.'($value)';
+ $getter='get'.$property->Name.'()';
+ $value=$this->getValueAsString($property->DefaultValue,$property->Type);
+ if($property->Storage==='ViewState')
+ {
+ $readStatement="return \$this->getViewState('$name',$value);";
+ $writeStatement="\$this->setViewState('$name',".$this->getValueConversionString($property->Type).",$value);";
+ }
+ else if($property->Storage==='ControlState')
+ {
+ $readStatement="return \$this->getControlState('$name',$value);";
+ $writeStatement="\$this->setControlState('$name',".$this->getValueConversionString($property->Type).",$value);";
+ }
+ else
+ {
+ $varname=$this->getVariableName($property->Name);
+ $readStatement="return \$this->$varname;";
+ $writeStatement="\$this->$varname=".$this->getValueConversionString($property->Type).";";
+ }
+ $writer->write("\n\t/**\n\t * @return {$property->Type} $comments Defaults to $value.\n\t */\n");
+ $writer->write("\t$access function $getter\n\t{\n\t\t$readStatement\n\t}\n");
+ if(!$property->ReadOnly)
+ {
+ $writer->write("\n\t/**\n\t * @param {$property->Type} $comments\n\t */\n");
+ $writer->write("\t$access function $setter\n\t{\n\t\t$writeStatement\n\t}\n");
+ }
+ }
+ }
+
+ protected function renderEvents($writer)
+ {
+ foreach($this->Events as $event)
+ {
+ $name=$event->Name;
+ if($name==='')
+ continue;
+ if(strncasecmp($name,'on',2)!==0)
+ $name='On'.$name;
+ else
+ {
+ $name[0]='O';
+ $name[1]='n';
+ }
+ $methodName=$name;
+ $methodName[0]='o';
+ $comments=implode("\n\t * ",explode("\n",wordwrap($event->Comments)));
+ $writer->write("\n\t/**\n\t * Raises $name event.\n\t * $comments\n\t * @param TEventParameter event parameter\n\t */\n");
+ $writer->write("\tpublic function $methodName(\$param)\n\t{\n\t\t\$this->raiseEvent('$name',\$this,\$param);\n\t}\n");
+ }
+ }
+
+ public function getClassName()
+ {
+ return $this->_className;
+ }
+
+ public function setClassName($value)
+ {
+ $this->_className=trim($value);
+ }
+
+ public function getParentClass()
+ {
+ return $this->_parentClass;
+ }
+
+ public function setParentClass($value)
+ {
+ $this->_parentClass=trim($value);
+ }
+
+ public function getInterfaces()
+ {
+ return $this->_interfaces;
+ }
+
+ public function setInterfaces($value)
+ {
+ $this->_interfaces=$value;
+ }
+
+ public function getProperties()
+ {
+ if(!$this->_properties)
+ $this->_properties=new TList;
+ return $this->_properties;
+ }
+
+ public function getEvents()
+ {
+ if(!$this->_events)
+ $this->_events=new TList;
+ return $this->_events;
+ }
+
+ public function getComments()
+ {
+ return $this->_comments;
+ }
+
+ public function setComments($value)
+ {
+ $this->_comments=$value;
+ }
+
+ public function getAuthor()
+ {
+ return $this->_author;
+ }
+
+ public function setAuthor($value)
+ {
+ $this->_author=trim($value);
+ }
+
+ public function getEmail()
+ {
+ return $this->_email;
+ }
+
+ public function setEmail($value)
+ {
+ $this->_email=trim($value);
+ }
+}
+
+class EventDefinition extends TComponent
+{
+ private $_name='';
+ private $_comments='';
+
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ public function setName($value)
+ {
+ $this->_name=ucfirst(trim($value));
+ }
+
+ public function getComments()
+ {
+ return $this->_comments;
+ }
+
+ public function setComments($value)
+ {
+ $this->_comments=$value;
+ }
+}
+
+class PropertyDefinition extends TComponent
+{
+ private $_name='';
+ private $_type='string';
+ private $_default='';
+ private $_readOnly=false;
+ private $_protected=false;
+ private $_storage='ViewState';
+ private $_comments='';
+
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ public function setName($value)
+ {
+ $this->_name=ucfirst(trim($value));
+ }
+
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ public function setType($value)
+ {
+ $this->_type=trim($value);
+ }
+
+ public function getDefaultValue()
+ {
+ return $this->_default;
+ }
+
+ public function setDefaultValue($value)
+ {
+ $this->_default=trim($value);
+ }
+
+ public function getReadOnly()
+ {
+ return $this->_readOnly;
+ }
+
+ public function setReadOnly($value)
+ {
+ $this->_readOnly=TPropertyValue::ensureBoolean($value);
+ }
+
+ public function getIsProtected()
+ {
+ return $this->_protected;
+ }
+
+ public function setIsProtected($value)
+ {
+ $this->_protected=TPropertyValue::ensureBoolean($value);
+ }
+
+ public function getStorage()
+ {
+ return $this->_storage;
+ }
+
+ public function setStorage($value)
+ {
+ $this->_storage=trim($value);
+ }
+
+ public function getComments()
+ {
+ return $this->_comments;
+ }
+
+ public function setComments($value)
+ {
+ $this->_comments=$value;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/composer/protected/pages/Home.php b/demos/composer/protected/pages/Home.php
index d3d02b66..07f02e7e 100644
--- a/demos/composer/protected/pages/Home.php
+++ b/demos/composer/protected/pages/Home.php
@@ -1,118 +1,118 @@
-_classDefinition)
- $this->_classDefinition=new ClassDefinition;
- return $this->_classDefinition;
- }
-
- public function onInit($param)
- {
- parent::onInit($param);
- if(!$this->IsPostBack)
- {
- $properties=$this->ClassDefinition->Properties;
- $properties[]=new PropertyDefinition;
- $properties[]=new PropertyDefinition;
- $properties[]=new PropertyDefinition;
- $this->PropertyList->DataSource=$properties;
- $this->dataBind();
- }
- }
-
- public function propertyAction($sender,$param)
- {
- if($param->CommandName==='add')
- $this->ClassDefinition->Properties->add(new PropertyDefinition);
- if($param->CommandName==='remove')
- $this->ClassDefinition->Properties->removeAt($param->CommandParameter);
- else if($param->CommandName==='up')
- {
- $property=$this->ClassDefinition->Properties->itemAt($param->CommandParameter);
- $this->ClassDefinition->Properties->removeAt($param->CommandParameter);
- $this->ClassDefinition->Properties->insertAt($param->CommandParameter-1,$property);
- }
- else if($param->CommandName==='down')
- {
- $property=$this->ClassDefinition->Properties->itemAt($param->CommandParameter);
- $this->ClassDefinition->Properties->removeAt($param->CommandParameter);
- $this->ClassDefinition->Properties->insertAt($param->CommandParameter+1,$property);
- }
- $this->PropertyList->DataSource=$this->ClassDefinition->Properties;
- $this->PropertyList->dataBind();
- }
-
- public function eventAction($sender,$param)
- {
- if($param->CommandName==='add')
- $this->ClassDefinition->Events->add(new EventDefinition);
- else if($param->CommandName==='remove')
- $this->ClassDefinition->Events->removeAt($param->CommandParameter);
- else if($param->CommandName==='up')
- {
- $property=$this->ClassDefinition->Events->itemAt($param->CommandParameter);
- $this->ClassDefinition->Events->removeAt($param->CommandParameter);
- $this->ClassDefinition->Events->insertAt($param->CommandParameter-1,$property);
- }
- else if($param->CommandName==='down')
- {
- $property=$this->ClassDefinition->Events->itemAt($param->CommandParameter);
- $this->ClassDefinition->Events->removeAt($param->CommandParameter);
- $this->ClassDefinition->Events->insertAt($param->CommandParameter+1,$property);
- }
- $this->EventList->DataSource=$this->ClassDefinition->Events;
- $this->EventList->dataBind();
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- //if($this->IsPostBack && $this->IsValid)
- if($this->IsPostBack)
- {
- $def=$this->ClassDefinition;
- $def->reset();
- $def->ClassName=$this->ClassName->Text;
- $def->ParentClass=$this->ParentClass->Text;
- $def->Interfaces=$this->Interfaces->Text;
- $def->Comments=$this->Comments->Text;
- $def->Author=$this->AuthorName->Text;
- $def->Email=$this->AuthorEmail->Text;
- foreach($this->PropertyList->Items as $item)
- {
- $property=new PropertyDefinition;
- $property->Name=$item->PropertyName->Text;
- $property->Type=$item->PropertyType->Text;
- $property->DefaultValue=$item->DefaultValue->Text;
- $property->ReadOnly=$item->ReadOnly->Checked;
- $property->IsProtected=$item->IsProtected->Checked;
- $property->Comments=$item->Comments->Text;
- $property->Storage=$item->Storage->Text;
- $def->Properties[]=$property;
- }
- foreach($this->EventList->Items as $item)
- {
- $event=new EventDefinition;
- $event->Name=$item->EventName->Text;
- $event->Comments=$item->Comments->Text;
- $def->Events[]=$event;
- }
- }
- }
-
- public function generateCode($sender,$param)
- {
- $writer=Prado::createComponent('TTextWriter');
- $this->ClassDefinition->render($writer);
- $this->SourceCode->Text=$writer->flush();
- }
-}
-
+_classDefinition)
+ $this->_classDefinition=new ClassDefinition;
+ return $this->_classDefinition;
+ }
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ if(!$this->IsPostBack)
+ {
+ $properties=$this->ClassDefinition->Properties;
+ $properties[]=new PropertyDefinition;
+ $properties[]=new PropertyDefinition;
+ $properties[]=new PropertyDefinition;
+ $this->PropertyList->DataSource=$properties;
+ $this->dataBind();
+ }
+ }
+
+ public function propertyAction($sender,$param)
+ {
+ if($param->CommandName==='add')
+ $this->ClassDefinition->Properties->add(new PropertyDefinition);
+ if($param->CommandName==='remove')
+ $this->ClassDefinition->Properties->removeAt($param->CommandParameter);
+ else if($param->CommandName==='up')
+ {
+ $property=$this->ClassDefinition->Properties->itemAt($param->CommandParameter);
+ $this->ClassDefinition->Properties->removeAt($param->CommandParameter);
+ $this->ClassDefinition->Properties->insertAt($param->CommandParameter-1,$property);
+ }
+ else if($param->CommandName==='down')
+ {
+ $property=$this->ClassDefinition->Properties->itemAt($param->CommandParameter);
+ $this->ClassDefinition->Properties->removeAt($param->CommandParameter);
+ $this->ClassDefinition->Properties->insertAt($param->CommandParameter+1,$property);
+ }
+ $this->PropertyList->DataSource=$this->ClassDefinition->Properties;
+ $this->PropertyList->dataBind();
+ }
+
+ public function eventAction($sender,$param)
+ {
+ if($param->CommandName==='add')
+ $this->ClassDefinition->Events->add(new EventDefinition);
+ else if($param->CommandName==='remove')
+ $this->ClassDefinition->Events->removeAt($param->CommandParameter);
+ else if($param->CommandName==='up')
+ {
+ $property=$this->ClassDefinition->Events->itemAt($param->CommandParameter);
+ $this->ClassDefinition->Events->removeAt($param->CommandParameter);
+ $this->ClassDefinition->Events->insertAt($param->CommandParameter-1,$property);
+ }
+ else if($param->CommandName==='down')
+ {
+ $property=$this->ClassDefinition->Events->itemAt($param->CommandParameter);
+ $this->ClassDefinition->Events->removeAt($param->CommandParameter);
+ $this->ClassDefinition->Events->insertAt($param->CommandParameter+1,$property);
+ }
+ $this->EventList->DataSource=$this->ClassDefinition->Events;
+ $this->EventList->dataBind();
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ //if($this->IsPostBack && $this->IsValid)
+ if($this->IsPostBack)
+ {
+ $def=$this->ClassDefinition;
+ $def->reset();
+ $def->ClassName=$this->ClassName->Text;
+ $def->ParentClass=$this->ParentClass->Text;
+ $def->Interfaces=$this->Interfaces->Text;
+ $def->Comments=$this->Comments->Text;
+ $def->Author=$this->AuthorName->Text;
+ $def->Email=$this->AuthorEmail->Text;
+ foreach($this->PropertyList->Items as $item)
+ {
+ $property=new PropertyDefinition;
+ $property->Name=$item->PropertyName->Text;
+ $property->Type=$item->PropertyType->Text;
+ $property->DefaultValue=$item->DefaultValue->Text;
+ $property->ReadOnly=$item->ReadOnly->Checked;
+ $property->IsProtected=$item->IsProtected->Checked;
+ $property->Comments=$item->Comments->Text;
+ $property->Storage=$item->Storage->Text;
+ $def->Properties[]=$property;
+ }
+ foreach($this->EventList->Items as $item)
+ {
+ $event=new EventDefinition;
+ $event->Name=$item->EventName->Text;
+ $event->Comments=$item->Comments->Text;
+ $def->Events[]=$event;
+ }
+ }
+ }
+
+ public function generateCode($sender,$param)
+ {
+ $writer=Prado::createComponent('TTextWriter');
+ $this->ClassDefinition->render($writer);
+ $this->SourceCode->Text=$writer->flush();
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/composer/protected/pages/Layout.php b/demos/composer/protected/pages/Layout.php
index a82d2fff..3d9b5714 100644
--- a/demos/composer/protected/pages/Layout.php
+++ b/demos/composer/protected/pages/Layout.php
@@ -1,15 +1,15 @@
-TopicPanel->Visible=!$this->TopicPanel->Visible;
- if($this->TopicPanel->Visible)
- $sender->Text="Hide TOC";
- else
- $sender->Text="Show TOC";
- }
-}
-
+TopicPanel->Visible=!$this->TopicPanel->Visible;
+ if($this->TopicPanel->Visible)
+ $sender->Text="Hide TOC";
+ else
+ $sender->Text="Show TOC";
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/helloworld/index.php b/demos/helloworld/index.php
index 43c0b436..6efff1af 100644
--- a/demos/helloworld/index.php
+++ b/demos/helloworld/index.php
@@ -1,18 +1,18 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/helloworld/protected/pages/Home.php b/demos/helloworld/protected/pages/Home.php
index 16174b2e..36eb2032 100644
--- a/demos/helloworld/protected/pages/Home.php
+++ b/demos/helloworld/protected/pages/Home.php
@@ -1,11 +1,11 @@
-Text='Hello world!';
- }
-}
-
+Text='Hello world!';
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/northwind-db/index.php b/demos/northwind-db/index.php
index 94e60d49..ef243159 100644
--- a/demos/northwind-db/index.php
+++ b/demos/northwind-db/index.php
@@ -1,28 +1,28 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Category.php b/demos/northwind-db/protected/database/Category.php
index 06fc979f..d708ee96 100644
--- a/demos/northwind-db/protected/database/Category.php
+++ b/demos/northwind-db/protected/database/Category.php
@@ -1,26 +1,26 @@
- array(self::HAS_MANY, 'Product'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'Product'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Customer.php b/demos/northwind-db/protected/database/Customer.php
index 810f2a6a..464b384d 100644
--- a/demos/northwind-db/protected/database/Customer.php
+++ b/demos/northwind-db/protected/database/Customer.php
@@ -1,33 +1,33 @@
- array(self::HAS_MANY, 'Order'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'Order'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Employee.php b/demos/northwind-db/protected/database/Employee.php
index 1e0f090e..573b887d 100644
--- a/demos/northwind-db/protected/database/Employee.php
+++ b/demos/northwind-db/protected/database/Employee.php
@@ -1,48 +1,48 @@
- array(self::MANY_TO_MANY, 'Territory', 'EmployeeTerritories'),
- 'Orders' => array(self::HAS_MANY, 'Order'),
-
- //parent children relationship
- 'Subordinates' => array(self::HAS_MANY, 'Employee'),
- 'Superior' => array(self::BELONGS_TO, 'Employee')
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::MANY_TO_MANY, 'Territory', 'EmployeeTerritories'),
+ 'Orders' => array(self::HAS_MANY, 'Order'),
+
+ //parent children relationship
+ 'Subordinates' => array(self::HAS_MANY, 'Employee'),
+ 'Superior' => array(self::BELONGS_TO, 'Employee')
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Order.php b/demos/northwind-db/protected/database/Order.php
index 228fb2b5..2a425102 100644
--- a/demos/northwind-db/protected/database/Order.php
+++ b/demos/northwind-db/protected/database/Order.php
@@ -1,42 +1,42 @@
- array(self::HAS_MANY, 'OrderDetail'),
- 'Customer' => array(self::BELONGS_TO, 'Customer'),
- 'Shipper' => array(self::BELONGS_TO, 'Shipper'),
- 'Employee' => array(self::BELONGS_TO, 'Employee'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'OrderDetail'),
+ 'Customer' => array(self::BELONGS_TO, 'Customer'),
+ 'Shipper' => array(self::BELONGS_TO, 'Shipper'),
+ 'Employee' => array(self::BELONGS_TO, 'Employee'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/OrderDetail.php b/demos/northwind-db/protected/database/OrderDetail.php
index 1732b0d9..47f77351 100644
--- a/demos/northwind-db/protected/database/OrderDetail.php
+++ b/demos/northwind-db/protected/database/OrderDetail.php
@@ -1,27 +1,27 @@
- array(self::BELONGS_TO, 'Product'),
- 'Order' => array(self::BELONGS_TO, 'Order'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::BELONGS_TO, 'Product'),
+ 'Order' => array(self::BELONGS_TO, 'Order'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Product.php b/demos/northwind-db/protected/database/Product.php
index 93736ab8..088fbbd2 100644
--- a/demos/northwind-db/protected/database/Product.php
+++ b/demos/northwind-db/protected/database/Product.php
@@ -1,36 +1,36 @@
- array(self::BELONGS_TO, 'Supplier'),
- 'Category' => array(self::BELONGS_TO, 'Category'),
- 'OrderDetails' => array(self::HAS_MANY, 'OrderDetail'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::BELONGS_TO, 'Supplier'),
+ 'Category' => array(self::BELONGS_TO, 'Category'),
+ 'OrderDetails' => array(self::HAS_MANY, 'OrderDetail'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Region.php b/demos/northwind-db/protected/database/Region.php
index 3d1c2a84..6473e682 100644
--- a/demos/northwind-db/protected/database/Region.php
+++ b/demos/northwind-db/protected/database/Region.php
@@ -1,25 +1,25 @@
- array(self::HAS_MANY, 'Territory')
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'Territory')
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Shipper.php b/demos/northwind-db/protected/database/Shipper.php
index a3f0aeb3..f90548ea 100644
--- a/demos/northwind-db/protected/database/Shipper.php
+++ b/demos/northwind-db/protected/database/Shipper.php
@@ -1,25 +1,25 @@
- array(self::HAS_MANY, 'Order'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'Order'),
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Supplier.php b/demos/northwind-db/protected/database/Supplier.php
index 7cabdde5..bc3b44e0 100644
--- a/demos/northwind-db/protected/database/Supplier.php
+++ b/demos/northwind-db/protected/database/Supplier.php
@@ -1,34 +1,34 @@
- array(self::HAS_MANY, 'Product')
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::HAS_MANY, 'Product')
+ );
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/database/Territory.php b/demos/northwind-db/protected/database/Territory.php
index 16f33dea..96006bb1 100644
--- a/demos/northwind-db/protected/database/Territory.php
+++ b/demos/northwind-db/protected/database/Territory.php
@@ -1,60 +1,60 @@
- array(self::BELONGS_TO, 'Region'),
- 'Employees' => array(self::HAS_MANY, 'Employee', 'EmployeeTerritories')
- );
-
- /**
- * @return Region
- */
- public function getRegion()
- {
- //lazy load the region
- if($this->_region===null)
- $this->_region = Region::finder()->findByPk($this->RegionID);
- return $this->_region;
- }
-
- public function setRegion($value)
- {
- $this->_region=$value;
- }
-
- /**
- * @return Employee[]
- */
- public function getEmployees()
- {
- //lazy load
- if($this->_employees==null)
- $this->setEmployees($this->withEmployees()->findByPk($this->TerritoryID)->getEmployees());
- return $this->_employees;
- }
-
- public function setEmployees($value)
- {
- //ensure TList
- $this->_employees = $value instanceof TList ? $value : new TList($value);
- }
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+ array(self::BELONGS_TO, 'Region'),
+ 'Employees' => array(self::HAS_MANY, 'Employee', 'EmployeeTerritories')
+ );
+
+ /**
+ * @return Region
+ */
+ public function getRegion()
+ {
+ //lazy load the region
+ if($this->_region===null)
+ $this->_region = Region::finder()->findByPk($this->RegionID);
+ return $this->_region;
+ }
+
+ public function setRegion($value)
+ {
+ $this->_region=$value;
+ }
+
+ /**
+ * @return Employee[]
+ */
+ public function getEmployees()
+ {
+ //lazy load
+ if($this->_employees==null)
+ $this->setEmployees($this->withEmployees()->findByPk($this->TerritoryID)->getEmployees());
+ return $this->_employees;
+ }
+
+ public function setEmployees($value)
+ {
+ //ensure TList
+ $this->_employees = $value instanceof TList ? $value : new TList($value);
+ }
+
+ public static function finder($className=__CLASS__)
+ {
+ return parent::finder($className);
+ }
+}
?>
\ No newline at end of file
diff --git a/demos/northwind-db/protected/pages/NorthwindCrud.php b/demos/northwind-db/protected/pages/NorthwindCrud.php
index 57694caa..72297ac8 100644
--- a/demos/northwind-db/protected/pages/NorthwindCrud.php
+++ b/demos/northwind-db/protected/pages/NorthwindCrud.php
@@ -1,28 +1,28 @@
-getRecordClassList(Prado::getPathOfNamespace('Application.database.*'));
- $this->class_list->dataSource = $classes;
- $this->class_list->dataBind();
- }
-
- protected function getRecordClassList($directory)
- {
- $list=array();
- $folder=@opendir($directory);
- while($entry=@readdir($folder))
- {
- if($entry[0]==='.')
- continue;
- else if(is_file($directory.'/'.$entry) && strpos($entry,'.php'))
- $list[] = str_replace('.php', '', $entry);
- }
- closedir($folder);
- return $list;
- }
-}
-
+getRecordClassList(Prado::getPathOfNamespace('Application.database.*'));
+ $this->class_list->dataSource = $classes;
+ $this->class_list->dataBind();
+ }
+
+ protected function getRecordClassList($directory)
+ {
+ $list=array();
+ $folder=@opendir($directory);
+ while($entry=@readdir($folder))
+ {
+ if($entry[0]==='.')
+ continue;
+ else if(is_file($directory.'/'.$entry) && strpos($entry,'.php'))
+ $list[] = str_replace('.php', '', $entry);
+ }
+ closedir($folder);
+ return $list;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/personal/index.php b/demos/personal/index.php
index 04695b16..1722244d 100644
--- a/demos/personal/index.php
+++ b/demos/personal/index.php
@@ -1,15 +1,15 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/personal/protected/Common/LoginPortlet.php b/demos/personal/protected/Common/LoginPortlet.php
index 1f5cd4f5..1b93912b 100644
--- a/demos/personal/protected/Common/LoginPortlet.php
+++ b/demos/personal/protected/Common/LoginPortlet.php
@@ -1,19 +1,19 @@
-Application->getModule('auth');
- if(!$authManager->login($this->Username->Text,$this->Password->Text))
- $param->IsValid=false;
- }
-
- public function loginButtonClicked($sender,$param)
- {
- if($this->Page->IsValid)
- $this->Response->redirect($this->Application->getModule('auth')->getReturnUrl());
- }
-}
-
+Application->getModule('auth');
+ if(!$authManager->login($this->Username->Text,$this->Password->Text))
+ $param->IsValid=false;
+ }
+
+ public function loginButtonClicked($sender,$param)
+ {
+ if($this->Page->IsValid)
+ $this->Response->redirect($this->Application->getModule('auth')->getReturnUrl());
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/personal/protected/Common/MainMenu.php b/demos/personal/protected/Common/MainMenu.php
index a2334c03..5e1e95c0 100644
--- a/demos/personal/protected/Common/MainMenu.php
+++ b/demos/personal/protected/Common/MainMenu.php
@@ -1,12 +1,12 @@
-Application->getModule('auth')->logout();
- $this->Response->redirect($this->Service->constructUrl('Home'));
- }
-}
-
+Application->getModule('auth')->logout();
+ $this->Response->redirect($this->Service->constructUrl('Home'));
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/personal/protected/Pages/Layout.php b/demos/personal/protected/Pages/Layout.php
index ba96038b..7f5e5802 100644
--- a/demos/personal/protected/Pages/Layout.php
+++ b/demos/personal/protected/Pages/Layout.php
@@ -1,7 +1,7 @@
-
\ No newline at end of file
diff --git a/demos/personal/protected/Pages/Register.php b/demos/personal/protected/Pages/Register.php
index b699d859..26f9aa50 100644
--- a/demos/personal/protected/Pages/Register.php
+++ b/demos/personal/protected/Pages/Register.php
@@ -1,19 +1,19 @@
-IsValid to false if the username is already taken
- }
-
- public function createUser($sender,$param)
- {
- if($this->IsValid)
- {
- // create new user account
- }
- }
-}
-
+IsValid to false if the username is already taken
+ }
+
+ public function createUser($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ // create new user account
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/quickstart/index.php b/demos/quickstart/index.php
index 43c0b436..6efff1af 100644
--- a/demos/quickstart/index.php
+++ b/demos/quickstart/index.php
@@ -1,18 +1,18 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/quickstart/index2.php b/demos/quickstart/index2.php
index f3d8dd90..30df9480 100644
--- a/demos/quickstart/index2.php
+++ b/demos/quickstart/index2.php
@@ -1,18 +1,18 @@
-run();
-
+run();
+
?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/QuickStartGlobalization.php b/demos/quickstart/protected/QuickStartGlobalization.php
index 6a0b0fb2..8fc42e8d 100644
--- a/demos/quickstart/protected/QuickStartGlobalization.php
+++ b/demos/quickstart/protected/QuickStartGlobalization.php
@@ -1,31 +1,31 @@
-Application->OnBeginRequest[] = array($this, 'beginRequest');
- }
-
- public function beginRequest($sender, $param)
- {
- if(null == ($culture=$this->Request['lang']))
- {
- if(null !== ($cookie=$this->Request->Cookies['lang']))
- $culture = $cookie->getValue();
- }
-
- if(is_string($culture))
- {
- $info = new CultureInfo();
- if($info->validCulture($culture))
- {
- $this->setCulture($culture);
- $this->Response->Cookies[] = new THttpCookie('lang',$culture);
- }
- }
- }
-}
-
+Application->OnBeginRequest[] = array($this, 'beginRequest');
+ }
+
+ public function beginRequest($sender, $param)
+ {
+ if(null == ($culture=$this->Request['lang']))
+ {
+ if(null !== ($cookie=$this->Request->Cookies['lang']))
+ $culture = $cookie->getValue();
+ }
+
+ if(is_string($culture))
+ {
+ $info = new CultureInfo();
+ if($info->validCulture($culture))
+ {
+ $this->setCulture($culture);
+ $this->Response->Cookies[] = new THttpCookie('lang',$culture);
+ }
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/controls/Comments/CommentBlock.php b/demos/quickstart/protected/controls/Comments/CommentBlock.php
index 9c008491..ebb82a0f 100644
--- a/demos/quickstart/protected/controls/Comments/CommentBlock.php
+++ b/demos/quickstart/protected/controls/Comments/CommentBlock.php
@@ -1,107 +1,107 @@
-setDbConnection($db);
-
-class CommentRecord extends TActiveRecord
-{
- const TABLE='qs_comments';
-
- public $id;
- public $username;
- public $date_added;
- public $page;
- public $block_id;
- public $content;
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
-
-class CommentBlock extends TTemplateControl
-{
- private $_page;
-
- function onLoad($param)
- {
- if(!$this->Page->IsCallBack)
- {
- $count = array();
- $data = $this->getCommentData();
- foreach($data as $r)
- {
- if(!isset($count[$r->block_id]))
- $count[$r->block_id]=0;
- $count[$r->block_id]++;
- }
- $js = "var comment_count = ".TJavascript::encode($count).";\n";
- $this->Page->ClientScript->registerBeginScript('count',$js);
- $this->comments->dataSource = $data;
- $this->comments->dataBind();
- }
- }
-
- function getCommentData()
- {
- return CommentRecord::finder()->findAllByPage($this->getCurrentPagePath());
- }
-
- function add_comment($sender, $param)
- {
- if(!$this->Page->IsValid)
- return;
- $record = new CommentRecord;
- $record->username = $this->username->Text;
- $record->date_added = date('Y-m-d h:i:s');
- $record->page = $this->getCurrentPagePath();
- $record->block_id = $this->block_id->Value;
- $record->content = $this->content->Text;
- $record->save();
-
- $this->content->Text = '';
- $this->password->Text = '';
- $cc = $this->Page->CallbackClient;
- $cc->appendContent('comment-list', $this->format_message($record));
- $cc->callClientFunction('hide_add_comment');
- $cc->callClientFunction('increment_count_tag', $record->block_id);
- if(!$this->Page->IsCallBack)
- {
- $this->comments->dataSource = $this->getCommentData();
- $this->comments->dataBind();
- }
- }
-
- protected function getCurrentPagePath()
- {
- if(is_null($this->_page))
- {
- $page = str_replace($this->Service->BasePath, '', $this->Page->Template->TemplateFile);
- $this->_page = str_replace('\\', '/', $page);
- }
- return $this->_page;
- }
-
- function validate_credential($sender, $param)
- {
- $param->IsValid = $this->password->Text == 'Prado';
- }
-
- protected function format_message($record)
- {
- $username=htmlspecialchars($record->username);
- $content=nl2br(htmlspecialchars($record->content));
- return <<