Post
The Post model.
See Also
| Post | The Post model. |
| Variables | |
| $url_attrs | The translation array of the post URL setting to regular expressions. Passed through the route_code filter. |
| Functions | |
| __construct | Model::grab |
| find | Model::search |
| add | Adds a post to the database with the passed XML, sanitized URL, and unique URL. The rest is read from $_POST. |
| update | Updates a post with the given XML. The rest is read from $_POST. |
| delete | <Model::destroy> |
| deletable | Checks if the User can delete the post. |
| editable | Checks if the User can edit the post. |
| any_editable | Checks if the Visitor can edit any posts. |
| any_deletable | Checks if the Visitor can delete any posts. |
| exists | Checks if a post exists. |
| check_url | Checks if a given clean URL is already being used as another post’s URL. |
| url | Returns a post’s URL. |
| user | Returns a post’s user. Example: $post->user()->login |
| title_from_excerpt | Generates an acceptable Title from the post’s excerpt. |
| title | Returns the given post’s title, provided by its Feather. |
| excerpt | Returns the given post’s excerpt, provided by its Feather. |
| feed_content | Returns the given post’s Feed content, provided by its Feather. |
| next | The next post (the post made after this one). |
| prev | The next post (the post made after this one). |
| theme_exists | Checks if the current post’s feather theme file exists. |
| parse | Parses the passed XML and loads the tags and values into Post. |
| edit_link | Outputs an edit link for the post, if the <User.can> edit_post. |
| delete_link | Outputs a delete link for the post, if the <User.can> delete_post. |
| trackback_url | Returns the posts trackback URL. |
| arr2xml | Recursively adds an array (or object I guess) to a SimpleXML object. |
| xml2arr | Recursively converts a SimpleXML object (and children) to an array. |
| send_pingbacks | Sends any callbacks in $value. Used by array_walk_recursive in Post.add. |
| from_url | Attempts to grab a post from its clean URL. |
| statuses | Returns a SQL query “chunk” for the “status” column permissions of the current user. |
| enabled_feathers | Returns a SQL query “chunk” for the “feather” column so that it matches enabled feathers. |
add
| static function add( | $values, | |||
| $clean | = | "", | ||
| $url | = | "", | ||
| $feather | = | null, | ||
| $user | = | null, | ||
| $pinned | = | null, | ||
| $status | = | null, | ||
| $created_at | = | null, | ||
| $updated_at | = | null, | ||
| $trackbacks | = | "", | ||
| $pingbacks | = | true, | ||
| $options | = | null | ) |
Adds a post to the database with the passed XML, sanitized URL, and unique URL. The rest is read from $_POST.
Trackbacks are automatically sent based on the contents of $_POST[‘trackbacks’]. Most of the $_POST variables will fall back gracefully if they don’t exist, e.g. if they’re posting from the Bookmarklet.
Calls the add_post trigger with the inserted post and extra options.
Parameters
| $values | The data to insert. |
| $clean | The sanitized URL (or empty to default to “(feather).(new post’s id)”). |
| $url | The unique URL (or empty to default to “(feather).(new post’s id)”). |
| $feather | The feather to post as. |
| $user | User to set as the post’s author. |
| $pinned | Pin the post? |
| $status | Post status |
| $slug | A new URL for the post. |
| $created_at | New created_at timestamp for the post. |
| $updated_at | New updated_at timestamp for the post, or false to not updated it. |
| $trackbacks | URLs separated by “ “ to send trackbacks to. |
| $options | Options for the post. |
Returns
| self | An object containing the new post. |
See Also
update
| public function update( | $values, | |||
| $user | = | null, | ||
| $pinned | = | null, | ||
| $status | = | null, | ||
| $slug | = | null, | ||
| $created_at | = | null, | ||
| $updated_at | = | null, | ||
| $options | = | null | ) |
Updates a post with the given XML. The rest is read from $_POST.
Most of the $_POST variables will fall back gracefully if they don’t exist, e.g. if they’re posting from the Bookmarklet.
Parameters
| $values | An array of data to set for the post. |
| $user | User to set as the post’s author. |
| $pinned | Pin the post? |
| $status | Post status |
| $slug | A new URL for the post. |
| $created_at | New created_at timestamp for the post. |
| $updated_at | New updated_at timestamp for the post, or false to not updated it. |
| $options | Options for the post. |
See Also
deletable
| public function deletable( | $user | = | null | ) |
Checks if the User can delete the post.
editable
| public function editable( | $user | = | null | ) |
Checks if the User can edit the post.
any_editable
static function any_editable()
Checks if the Visitor can edit any posts.
any_deletable
static function any_deletable()
Checks if the Visitor can delete any posts.
parse
private function parse()
Parses the passed XML and loads the tags and values into Post.
edit_link
| public function edit_link( | $text | = | null, | |
| $before | = | null, | ||
| $after | = | null | ) |
Outputs an edit link for the post, if the <User.can> edit_post.
Parameters
| $text | The text to show for the link. |
| $before | If the link can be shown, show this before it. |
| $after | If the link can be shown, show this after it. |
delete_link
| public function delete_link( | $text | = | null, | |
| $before | = | null, | ||
| $after | = | null | ) |
Outputs a delete link for the post, if the <User.can> delete_post.
Parameters
| $text | The text to show for the link. |
| $before | If the link can be shown, show this before it. |
| $after | If the link can be shown, show this after it. |
send_pingbacks
| static function send_pingbacks( | $value, | |
| $key, | ||
| $post | ) |
Sends any callbacks in $value. Used by array_walk_recursive in Post.add.