From ab5bd8b0db0660ea825a345bc33773532064d55c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Skej=C3=B8?= Date: Sat, 11 Jul 2009 18:45:35 +0200 Subject: [PATCH] News: Changed show()-code. Code was moved from News to NewsView in order to make News more clean. --- modules/News/News.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/News/News.php b/modules/News/News.php index 08909de..fa5e8cc 100644 --- a/modules/News/News.php +++ b/modules/News/News.php @@ -49,21 +49,15 @@ class News extends AOOSModule $this->dataModel()->resetData(); $this->dataModel()->populate(null, array("id", "DESC")); // Get all fields ordered descending by id $p = $this->core()->getModule("Paginator"); - $f = $this->core()->getModule("Form"); switch($p->getOption(0)) { case("add"): return $this->_view->add(); break; case("show"): - $l = $f->getWidget("List"); - $l->setStyle('

#{title}

by #{author} at #{DATE|date}
#{content}
'); - return $l->strRow($this->dataModel()->find(array("id" => $p->getOption(1)))); + return $this->_view->show(); break; default: - $url = $p->currentURL()."/show/"; - $l = $f->getWidget("List"); - $l->setStyle('

#{title}

by #{author}
'); - return $l->str($this->dataModel()); + return $this->_view->noargs(); break; } } @@ -106,6 +100,24 @@ class NewsView extends AOOSModule { $f->setMethod("POST"); return $f->str($this->parent()->dataModel()); } + + public function show() { + $p = $this->core()->getModule("Paginator"); + $f = $this->core()->getModule("Form"); + $l = $f->getWidget("List"); + $modpath = $this->core()->getSetting("module_dir"); + $l->setStyle(file_get_contents($modpath.'News/news_show.tmpl')); + return $l->strRow($this->parent()->dataModel()->find(array("id" => $p->getOption(1)))); + } + + public function noargs() { + $p = $this->core()->getModule("Paginator"); + $f = $this->core()->getModule("Form"); + $l = $f->getWidget("List"); + $modpath = $this->core()->getSetting("module_dir"); + $l->setStyle(file_get_contents($modpath.'News/news_default.tmpl')); + return $l->str($this->parent()->dataModel()); + } } // vim: number ?> -- 2.11.4.GIT