Archived
1
0
Fork 0

AuthLink fix + very small blogpost additions

This commit is contained in:
Fredric N 2010-10-02 00:34:20 +02:00
parent 44d528d0d3
commit ae6bb5be78
3 changed files with 43 additions and 7 deletions

View file

@ -1,6 +1,6 @@
<?php
class BlogPost
class BlogPost extends Fiktiv_Model_Abstract
{
protected $_id;
protected $_title;
@ -9,6 +9,31 @@ class BlogPost
protected $_pubDate;
protected $_isPublished = false;
public function __construct(array $data = array())
{
$this->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()
{

View file

@ -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);
}

View file

@ -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 = '<a href="'.$this->view->url(array('controller' => 'profile'), 'default').'">';
@ -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 .= '</a> | ';
$prefix .= '</a> ';
} else {
$options['action'] = 'login';
$display = 'u:login';
$display = $this->view->translate('u:login');
}
return $prefix
. '<a href="' . $this->view->url($options, 'auth') . '">'
. $this->view->translate($display)
. '</a>';
. $display
. '</a> ';
}
}