Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fiktivkod/application/models/BlogPost.php
2010-09-11 20:10:43 +02:00

86 lines
No EOL
1.6 KiB
PHP

<?php
class BlogPost
{
protected $_title;
protected $_content;
protected $_author;
protected $_pubDate;
protected $_isPublished = false;
public function setTitle($title)
{
if (is_string($title) && null == $title[30]) {
$this->_title = $title;
return true;
}
return false;
}
public function setContent($content)
{
if (is_string($content)) {
$this->_content = $content;
return true;
}
return false;
}
public function setAuthor($author)
{
if ($author instanceof User) {
$this->_author = $author;
return true;
}
return false;
}
public function setPubDate($date)
{
if (is_string($date) && preg_match('/^(?:(?:19[0-9]{2})|(?:20[0-9]{2}))\-' .
'(?:(?:0[1-9])|(?:1[012]))\-(?:(?:0[1-9])|(?:[12][0-9])|(?:3[01]))$/', $date)) {
$this->_pubDate = $date;
} else if ($date instanceof Zend_Date) {
$this->_pubDate = $date->toString('yyyy-MM-dd');
} else {
return false;
}
return true;
}
public function isPublished($flag = null)
{
if (null === $flag) {
return $this->_isPublished;
}
$this->_isPublished = (boolean)$flag;
}
public function __call($name,$args) {
// getX methods
if ('get' == substr($name,0,3)) {
$dataPart = '_'.lcfirst(substr($name,3));
if (isset($this->$dataPart))
return $this->$dataPart;
}
}
}