From 05869f23f798c9393e2bc6d310d56a97a11d1acd Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 29 May 2006 02:05:19 +0000 Subject: Added blog demo (not done yet) --- demos/blog/protected/Portlets/AccountPortlet.php | 14 +++++++ demos/blog/protected/Portlets/AccountPortlet.tpl | 20 ++++++++++ demos/blog/protected/Portlets/ArchivePortlet.php | 45 +++++++++++++++++++++++ demos/blog/protected/Portlets/ArchivePortlet.tpl | 15 ++++++++ demos/blog/protected/Portlets/CategoryPortlet.php | 15 ++++++++ demos/blog/protected/Portlets/CategoryPortlet.tpl | 24 ++++++++++++ demos/blog/protected/Portlets/LoginPortlet.php | 22 +++++++++++ demos/blog/protected/Portlets/LoginPortlet.tpl | 36 ++++++++++++++++++ demos/blog/protected/Portlets/Portlet.php | 7 ++++ demos/blog/protected/Portlets/SearchPortlet.php | 22 +++++++++++ demos/blog/protected/Portlets/SearchPortlet.tpl | 21 +++++++++++ 11 files changed, 241 insertions(+) create mode 100644 demos/blog/protected/Portlets/AccountPortlet.php create mode 100644 demos/blog/protected/Portlets/AccountPortlet.tpl create mode 100644 demos/blog/protected/Portlets/ArchivePortlet.php create mode 100644 demos/blog/protected/Portlets/ArchivePortlet.tpl create mode 100644 demos/blog/protected/Portlets/CategoryPortlet.php create mode 100644 demos/blog/protected/Portlets/CategoryPortlet.tpl create mode 100644 demos/blog/protected/Portlets/LoginPortlet.php create mode 100644 demos/blog/protected/Portlets/LoginPortlet.tpl create mode 100644 demos/blog/protected/Portlets/Portlet.php create mode 100644 demos/blog/protected/Portlets/SearchPortlet.php create mode 100644 demos/blog/protected/Portlets/SearchPortlet.tpl (limited to 'demos/blog/protected/Portlets') diff --git a/demos/blog/protected/Portlets/AccountPortlet.php b/demos/blog/protected/Portlets/AccountPortlet.php new file mode 100644 index 00000000..0f0e60c6 --- /dev/null +++ b/demos/blog/protected/Portlets/AccountPortlet.php @@ -0,0 +1,14 @@ +Application->getModule('auth')->logout(); + $this->Response->reload(); + } +} + +?> \ No newline at end of file diff --git a/demos/blog/protected/Portlets/AccountPortlet.tpl b/demos/blog/protected/Portlets/AccountPortlet.tpl new file mode 100644 index 00000000..2a401f41 --- /dev/null +++ b/demos/blog/protected/Portlets/AccountPortlet.tpl @@ -0,0 +1,20 @@ +
+ +

Account

+ +
+Welcome, <%= $this->User->Name %>! + + +
+ +
diff --git a/demos/blog/protected/Portlets/ArchivePortlet.php b/demos/blog/protected/Portlets/ArchivePortlet.php new file mode 100644 index 00000000..a004c7a9 --- /dev/null +++ b/demos/blog/protected/Portlets/ArchivePortlet.php @@ -0,0 +1,45 @@ +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/ArchivePortlet.tpl b/demos/blog/protected/Portlets/ArchivePortlet.tpl new file mode 100644 index 00000000..c576e9f5 --- /dev/null +++ b/demos/blog/protected/Portlets/ArchivePortlet.tpl @@ -0,0 +1,15 @@ +
+ +

Archives

+ +
+ +
+ +
diff --git a/demos/blog/protected/Portlets/CategoryPortlet.php b/demos/blog/protected/Portlets/CategoryPortlet.php new file mode 100644 index 00000000..9c2033aa --- /dev/null +++ b/demos/blog/protected/Portlets/CategoryPortlet.php @@ -0,0 +1,15 @@ +CategoryList->DataSource=$this->Application->getModule('data')->queryCategories(); + $this->CategoryList->dataBind(); + } +} + +?> \ No newline at end of file diff --git a/demos/blog/protected/Portlets/CategoryPortlet.tpl b/demos/blog/protected/Portlets/CategoryPortlet.tpl new file mode 100644 index 00000000..acbd3bec --- /dev/null +++ b/demos/blog/protected/Portlets/CategoryPortlet.tpl @@ -0,0 +1,24 @@ +
+ +

+Categories +Service->constructUrl('Posts.NewCategory') %> + Visible=<%= $this->User->isInRole('admin') %> /> +

+ +
+ +
+ +
diff --git a/demos/blog/protected/Portlets/LoginPortlet.php b/demos/blog/protected/Portlets/LoginPortlet.php new file mode 100644 index 00000000..0085c17f --- /dev/null +++ b/demos/blog/protected/Portlets/LoginPortlet.php @@ -0,0 +1,22 @@ +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->reload(); + //$this->Response->redirect($this->Application->getModule('auth')->getReturnUrl()); + } +} + +?> \ No newline at end of file diff --git a/demos/blog/protected/Portlets/LoginPortlet.tpl b/demos/blog/protected/Portlets/LoginPortlet.tpl new file mode 100644 index 00000000..6f8c5d4a --- /dev/null +++ b/demos/blog/protected/Portlets/LoginPortlet.tpl @@ -0,0 +1,36 @@ +
+ +

Login

+ + +Username + +
+ +
+ +Password + +
+ + +
+ +| Register + +
+ +
diff --git a/demos/blog/protected/Portlets/Portlet.php b/demos/blog/protected/Portlets/Portlet.php new file mode 100644 index 00000000..4b1c80e9 --- /dev/null +++ b/demos/blog/protected/Portlets/Portlet.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/demos/blog/protected/Portlets/SearchPortlet.php b/demos/blog/protected/Portlets/SearchPortlet.php new file mode 100644 index 00000000..1bad7f1c --- /dev/null +++ b/demos/blog/protected/Portlets/SearchPortlet.php @@ -0,0 +1,22 @@ +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)); + $this->Response->redirect($url); + } +} + +?> \ No newline at end of file diff --git a/demos/blog/protected/Portlets/SearchPortlet.tpl b/demos/blog/protected/Portlets/SearchPortlet.tpl new file mode 100644 index 00000000..f88fca7e --- /dev/null +++ b/demos/blog/protected/Portlets/SearchPortlet.tpl @@ -0,0 +1,21 @@ +
+ +

Search

+ + +Keyword + +
+ + +
+ +
-- cgit v1.2.3