From ae6bb5be788809d4af40304f9331cd5b7c212985 Mon Sep 17 00:00:00 2001 From: Fredric N Date: Sat, 2 Oct 2010 00:34:20 +0200 Subject: [PATCH] AuthLink fix + very small blogpost additions --- application/models/BlogPost.php | 27 ++++++++++++++++++++++++- library/Fiktiv/Model/Abstract.php | 11 ++++++++++ library/Fiktiv/View/Helper/AuthLink.php | 12 +++++------ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/application/models/BlogPost.php b/application/models/BlogPost.php index 7d7d881..45f8ded 100644 --- a/application/models/BlogPost.php +++ b/application/models/BlogPost.php @@ -1,6 +1,6 @@ setAttribs($data); + } + + public function setAttribs(array $data) { + + foreach ($data as $key => $value) { + + switch(strtolower($key)) { + case 'title': + $this->setTitle($value); + break; + case 'content': + $this->setContent($value); + break; + case 'author': + $this->setAuthor($value); + break; + case 'pubdate': + $this->setPubDate(new Zend_Date($value)); + break; + } + } + } public function getId() { diff --git a/library/Fiktiv/Model/Abstract.php b/library/Fiktiv/Model/Abstract.php index 3df45a0..8a98359 100644 --- a/library/Fiktiv/Model/Abstract.php +++ b/library/Fiktiv/Model/Abstract.php @@ -12,4 +12,15 @@ abstract class Fiktiv_Model_Abstract return isset($this->$dataPart) ? $this->$dataPart : false; } } + + public function __get($name) { + + $name = '_'.$name; + if (isset($this->$name)) + return $this->$name; + + } + + abstract public function setAttribs(array $data); + } \ No newline at end of file diff --git a/library/Fiktiv/View/Helper/AuthLink.php b/library/Fiktiv/View/Helper/AuthLink.php index 91b580e..270294b 100644 --- a/library/Fiktiv/View/Helper/AuthLink.php +++ b/library/Fiktiv/View/Helper/AuthLink.php @@ -16,7 +16,7 @@ class Fiktiv_View_Helper_AuthLink extends Zend_View_Helper_Abstract if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); $options['action'] = 'logout'; - $display = 'u:logout'; + $display = ' (' . $this->view->translate('u:logout') . ')'; $prefix = ''; @@ -24,21 +24,21 @@ class Fiktiv_View_Helper_AuthLink extends Zend_View_Helper_Abstract $prefix .= $identity->firstName; if (strlen($identity->lastName)) { - $prefix .= ' ' . $identity->lastName[0]; + $prefix .= ' ' . mb_substr($identity->lastName,0,1); } } else { $prefix .= $this->view->translate('Unknown'); } - $prefix .= ' | '; + $prefix .= ' '; } else { $options['action'] = 'login'; - $display = 'u:login'; + $display = $this->view->translate('u:login'); } return $prefix . '' - . $this->view->translate($display) - . ''; + . $display + . ' '; } }