From 5ead9b9257cbd3acd21ebd4626de3d213f73464f Mon Sep 17 00:00:00 2001 From: habarnam Date: Fri, 2 May 2008 18:21:49 +0300 Subject: [PATCH] * refactored display to index and moved the sidebar in a separate template --- _pages/display/display.tpl | 1 - _pages/{display => index}/code.php | 62 ++++++++++++++++++++++---------- _pages/index/index.tpl | 2 +- _pages/{display => index}/pages/main.tpl | 24 ++----------- _pages/{display => index}/pages/post.tpl | 0 _pages/index/pages/sidebar.tpl | 23 ++++++++++++ 6 files changed, 69 insertions(+), 43 deletions(-) delete mode 100644 _pages/display/display.tpl rename _pages/{display => index}/code.php (78%) rename _pages/{display => index}/pages/main.tpl (68%) rename _pages/{display => index}/pages/post.tpl (100%) create mode 100644 _pages/index/pages/sidebar.tpl diff --git a/_pages/display/display.tpl b/_pages/display/display.tpl deleted file mode 100644 index 082a5fd..0000000 --- a/_pages/display/display.tpl +++ /dev/null @@ -1 +0,0 @@ -{if $mainFile neq ''}{include file=$mainFile}{/if} \ No newline at end of file diff --git a/_pages/display/code.php b/_pages/index/code.php similarity index 78% rename from _pages/display/code.php rename to _pages/index/code.php index 2716213..e3aac67 100644 --- a/_pages/display/code.php +++ b/_pages/index/code.php @@ -1,5 +1,5 @@ db); - $o->option_name = 'title'; - $o->findFirst(); - $p = new tdoPosts ($this->db); if ( !empty($search) ) { @@ -38,7 +34,45 @@ class display extends tsPage{ $posts[0]['post_body'] = 'There are no posts currently'; } - + +// unset ($p); + $this->display($posts); + } + + private function buildSidebar ($posts) { + $actions = array (); + if ($this->user->isLogged () ) { + $action['url'] = str_replace (URL, URL.'/adm/', tsPage::setRequest()); + $action['label'] = 'Admin'; + $actions[] = $action; + + $action['url'] = str_replace (URL, URL.'/adm/', tsPage::setRequest('login', array('do'=>'logout'))); + $action['label'] = 'Logout'; + $actions[] = $action; + } + $user['actions'] = $actions; + + $this->varArray['sidebar'] = dirname(__FILE__).'/pages/sidebar.tpl'; + $this->varArray['user'] = $user; + } + + private function getAll ($start, $end) { + + } + + private function getOne () { + + } + + private function getSearch () { + + } + + private function display ($posts) { + $o = new tdoOptions($this->db); + $o->option_name = 'title'; + $o->findFirst(); + // admin edit and stuff foreach ($posts as $key => $post) { if ($this->user->isLogged ()) { @@ -60,22 +94,12 @@ class display extends tsPage{ $this->varArray['mainFile'] = dirname(__FILE__).'/pages/post.tpl'; } + $this->buildSidebar($posts); + $this->varArray['title'] = $o->option_value; $this->varArray['main'] = tsPage::setRequest (get_class($this)); $this->varArray['contact'] = tsPage::setRequest ('contact'); - $this->varArray['search'] = tsPage::setRequest (get_class($this)); - } - - private function displayAll () { - - } - - private function displayOne () { - - } - - private function displaySearch () { - + $this->varArray['search'] = tsPage::setRequest (get_class($this)); } private function postComment () { diff --git a/_pages/index/index.tpl b/_pages/index/index.tpl index 6cf59b9..082a5fd 100644 --- a/_pages/index/index.tpl +++ b/_pages/index/index.tpl @@ -1 +1 @@ -

empty page

\ No newline at end of file +{if $mainFile neq ''}{include file=$mainFile}{/if} \ No newline at end of file diff --git a/_pages/display/pages/main.tpl b/_pages/index/pages/main.tpl similarity index 68% rename from _pages/display/pages/main.tpl rename to _pages/index/pages/main.tpl index aaef36a..4092c79 100644 --- a/_pages/display/pages/main.tpl +++ b/_pages/index/pages/main.tpl @@ -1,25 +1,5 @@

{$title|ucwords|spacify}

-
-
-
- - -
-
-{if $posts neq ''} - Contents: -
    -{foreach from=$posts item=post} -
  1. {$post.post_title|ucfirst}
  2. -{/foreach} -{if $user neq ''} -{foreach from=$user.actions item=action} -
  3. $action.label
  4. -{/foreach} -{/if} -
-{/if} -
+{include file=$sidebar} {if $posts neq ''}