Source for file post.class.php
Documentation is available at post.class.php
* Contains definition of Post, subclass of DataContainer. Post is a container of DataItems but has some extended functionality such as outputting to various sources and in different formats, and adding customized items such as time, ID, title etc.
* @todo Add functions to simplyfy post creation, such as AddTitle, AddContent etc.
* @author Daniel Nordstrom <dnordstrom@mankindorganization.com>
* @link www.mrnordstrom.com
* Contains a post, composed of several data fields/items. Has extended functionality specific to it's purpose as a container of not just data, but data composing a blogpost.
* Constructor, calls constructor of parent DataContainer.
* Sets an author of the post. If no author field yet exists, it creates one.
if(!(parent::EditItem("AUTHOR", $value))) // If we can't edit it, it doesn't exist, so we...
parent::AddItem("AUTHOR", $value); // ...add it as a new item.
* Sets the timestamp of the post. If no timestamp field yet exists, it creates one.
if(!(parent::EditItem("DATE", date("d/m/y g:i A")))) // If we can't edit it, it doesn't exist, so we...
parent::AddItem("DATE", date("d/m/y g:i A")); // ...add it as a new item.
* Sets content of the post. If no content field yet exists, it creates one.
if(!(parent::EditItem("CONTENT", $value))) // If we can't edit it, it doesn't exist, so we...
parent::AddItem("CONTENT", $value); // ...add it as a new item.
* Sets tags of the post. If no tag field yet exists, it creates one.
if(!(parent::EditItem("TAGS", $value))) // If we can't edit it, it doesn't exist, so we...
parent::AddItem("TAGS", $value); // ...add it as a new item.
* Sets title of the post. If no title field yet exists, it creates one.
if(!(parent::EditItem("TITLE", $value))) // If we can't edit it, it doesn't exist, so we...
parent::AddItem("TITLE", $value); // ...add it as a new item.
* @return string $author Author of post.
return parent::GetValue("AUTHOR"); // Return post author.
* @return string $title Title of post.
return parent::GetValue("TITLE"); // Return post title.
* @return string $content Content of post.
return parent::GetValue("CONTENT"); // Return post content.
* @return string $tags Tags of post.
return parent::GetValue("TAGS"); // Return post tags.
* @return string $date Date of post.
return parent::GetValue("DATE"); // Return post author.
* @return integer $id ID of post.
return parent::GetValue("ID"); // Return post author.
* Prints out post data text in our own format.
* @param handle $handle File handle to use for writing.
$string = "STARTPOST" . PHP_EOL;
foreach ( $this->items as $item )
$string .= $item->GetKey() . PHP_EOL . $item->GetValue() . PHP_EOL;
$string .= "ENDPOST" . PHP_EOL;
* Prints out post data as XML.
$string = "<POST>" . PHP_EOL;
foreach ( $this->items as $item ) // Append all items to XML string
$string .= "<" . $item->GetKey() . ">" . htmlentities($item->GetValue()) . "</" . $item->GetKey() . ">" . PHP_EOL;
$string .= '</POST>' . PHP_EOL;
* Prints out all items in container.
foreach ( $this->items as $item )
print '[' . $item->GetKey () . '] => "' . $item->GetValue () . '";' . PHP_EOL;
|