bludit/kernel/post.class.php

115 lines
1.9 KiB
PHP
Raw Normal View History

2015-05-05 03:00:01 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2015-03-08 18:02:59 +01:00
2015-05-05 03:00:01 +02:00
class Post extends fileContent
2015-03-08 18:02:59 +01:00
{
function __construct($slug)
{
$this->path = PATH_POSTS;
parent::__construct($slug);
}
2015-05-05 03:00:01 +02:00
// Returns the post title.
public function title()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return $this->getField('title');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
// Returns the post content.
public function content()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return $this->getField('content');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
public function contentRaw()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return $this->getField('contentRaw');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
public function key()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return $this->getField('key');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
public function username()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return $this->getField('username');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
// Returns TRUE if the post is published, FALSE otherwise.
public function published()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return ($this->getField('status')==='published');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
public function author()
{
return $this->getField('author');
}
public function description()
{
return $this->getField('description');
}
public function unixTimeCreated()
{
return $this->getField('unixTimeCreated');
}
public function unixTimeModified()
{
return $this->getField('unixTimeModified');
}
2015-05-19 01:22:05 +02:00
public function dateCreated($format=false)
2015-03-08 18:02:59 +01:00
{
2015-05-19 01:22:05 +02:00
if($format===false) {
return $this->getField('date');
2015-03-08 18:02:59 +01:00
}
2015-05-19 01:22:05 +02:00
$unixTimeCreated = $this->unixTimeCreated();
return Date::format($unixTimeCreated, $format);
}
public function dateModified($format=false)
{
if($format===false) {
return $this->getField('date');
}
$unixTimeModified = $this->unixTimeModified();
return Date::format($unixTimeModified, $format);
2015-05-05 03:00:01 +02:00
}
public function timeago()
{
return $this->getField('timeago');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
public function tags()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return $this->getField('tags');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
public function slug()
2015-03-08 18:02:59 +01:00
{
2015-05-05 03:00:01 +02:00
return $this->getField('key');
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
public function permalink()
2015-03-08 18:02:59 +01:00
{
global $Url;
2015-05-05 03:00:01 +02:00
2015-03-08 18:02:59 +01:00
$filter = ltrim($Url->filters('post'), '/');
if($Url->filters('post')==HTML_PATH_ROOT)
return HTML_PATH_ROOT.$this->slug();
return HTML_PATH_ROOT.$filter.$this->slug();
}
}