PHP Class Habari\Post

$this->info= new PostInfo( 1 ); // Info records of post with id = 1 $this->info->option1= "blah"; // set info record with name "option1" to value "blah" $info_value= $this->info->option1; // get value of info record with name "option1" into variable $info_value if ( isset ( $this->info->option1 ) ) // test for existence of "option1" unset ( $this->info->option1 ); // delete "option1" info record
Inheritance: extends QueryRecord, implements IsContent, implements habari\FormStorage
Exibir arquivo Open project: habari/system Class Usage Examples

Public Properties

Property Type Description
$post_status_list static variables to hold post status and post type values
$post_type_list_active
$post_type_list_all
$schema

Protected Properties

Property Type Description
$url_args

Public Methods

Method Description
__call ( string $name, array $args ) : mixed Handle calls to this Post object that are implemented by plugins
__construct ( array $paramarray = [] ) Constructor for the Post class.
__get ( string $name ) : mixed Overrides QueryRecord __get to implement custom object properties
__isset ( string $name ) : boolean Overrides QueryRecord __isset to implement custom object properties
__set ( string $name, mixed $value ) : mixed Overrides QueryRecord __set to implement custom object properties
__static ( ) Register plugin hooks
activate_post_type ( string $type ) : boolean Activate an existing post type
add_new_status ( string $status, boolean $internal = false ) inserts a new post status into the database, if it doesn't exist
add_new_type ( string $type, boolean $active = true ) inserts a new post type into the database, if it doesn't exist
add_tokens ( array | string $tokens ) Add a token to a post
ascend ( null $params = null ) : Post Returns the ascending post, relative to this post, according to params
comment_form ( string $context = 'public' ) : FormUI Manage this post's comment form
content_type ( ) : array Return the content type of this object
create ( array $paramarray ) : Post Create a post and save it.
create_default_tokens ( ) Adds the default tokens to this post when it's saved
css_class ( string | array $append = [] ) : string Returns a list of CSS classes for the post
deactivate_post_type ( string $type ) : boolean Deactivate a post type
default_fields ( ) : array Return the defined database columns for a Post.
delete ( ) : boolean Deletes this post instance
delete_post_status ( string $status ) Delete a post status
delete_post_type ( string $type ) : boolean removes a post type from the database, if it exists and there are no posts of the type
delete_tokens ( ) Deletes all tokens from a post
descend ( $params = null ) : Post Returns the descending post, relative to this post, according to params
field_load ( string $key ) : mixed Loads form values from this post
field_save ( string $key, mixed $value ) Stores a form value into this post's info records
filter_post_get_7 ( string $content, string $field, Post $post ) : string Filter post content and titles for shortcodes
filter_post_status_display_4 ( string $status ) : string How to display the built-in post statuses.
filter_post_type_display_4 ( string $type, string $foruse ) : string How to display the built-in post types.
form_publish_delete ( FormUI $form ) The on_success handler for the delete button on the post editing form
form_publish_success ( FormUI $form ) Called when the publish form is successfully submitted
get ( array $paramarray = [] ) : Post Return a single requested post.
get_access ( User $user = null ) : Bitmask Returns an access Bitmask for the given user on this post
get_form ( string $context ) : FormUI Returns a form for editing this post
get_revision_data ( DateTime | string | integer $date ) : array Get the fields of the post that differ from what is stored by date
get_schema_map ( ) : array Get the schema data for this post
get_tokens ( ) : array Returns an array of token ids that are associated with this post Also initializes the internal token array for use by other token operations
get_url_args ( ) : array Returns a set of properties used by URL::get to create URLs
has_tokens ( mixed $tokens ) : mixed Checks if this post has one or more tokens
insert ( ) : integer | null Saves a new post to the posts table
list_active_post_types ( boolean $refresh = false ) : array returns an associative array of active post types
list_all_post_types ( boolean $refresh = false ) : array returns an associative array of all post types
list_post_statuses ( mixed $all = true, boolean $refresh = false ) : array returns an associative array of post statuses
list_revisions ( ) : array List the stored revisions of this post by date and user id
publish ( ) : boolean Updates an existing post to published status
remove_tokens ( array | string $tokens ) Deletes tokens from a post
set_revision ( DateTime | string | integer $date ) Set this post to have the same data as the post on the specified date
set_tokens ( mixed $tokens ) Applies a new set of specific tokens to a post
status ( string | integer $name ) : integer | boolean returns the integer value of the specified post status, or false
status_name ( string | integer $status ) : string | null returns the friendly name of a post status, or null
type ( string | integer $name ) : boolean | integer returns the integer value of the specified post type, or false
type_name ( string | integer $type ) : string returns the friendly name of a post type, or null
update ( boolean $minor = true ) : boolean Updates an existing post in the posts table

Private Methods

Method Description
get_author ( ) : User private function get_author() returns a User object for the author of this post
get_comment_feed_link ( ) : string private function get_comment_feed_link Returns the permalink for this post's comments Atom feed
get_comments ( ) : Comments Gets the comments for the post
get_editlink ( ) : string Returns a URL for the ->editlink property of this class.
get_info ( ) : PostInfo function get_info Gets the info object for this post, which contains data from the postinfo table related to this post.
get_permalink ( ) : string Returns a URL for the ->permalink property of this class.
get_tags ( ) : Terms function get_tags Gets the tags for the post
save_tags ( ) : boolean Save the tags associated to this post into the terms and object_terms tables
setguid ( ) Generate the GUID for the new post.
setslug ( ) : string Generate a new slug for the post.
setstatus ( string | integer $value ) : integer | boolean Sets the status for a post, given a string or integer.

Method Details

__call() public method

Handle calls to this Post object that are implemented by plugins
public __call ( string $name, array $args ) : mixed
$name string The name of the function called
$args array Arguments passed to the function call
return mixed The value returned from any plugin filters, null if no value is returned

__construct() public method

Constructor for the Post class.
public __construct ( array $paramarray = [] )
$paramarray array an associative array of initial Post field values.

__get() public method

Overrides QueryRecord __get to implement custom object properties
public __get ( string $name ) : mixed
$name string Name of property to return
return mixed The requested field value

__isset() public method

Overrides QueryRecord __isset to implement custom object properties
public __isset ( string $name ) : boolean
$name string Name of property to return
return boolean true if var is set and not NULL, false otherwise

__set() public method

Overrides QueryRecord __set to implement custom object properties
public __set ( string $name, mixed $value ) : mixed
$name string Name of property to return
$value mixed Value to set
return mixed The requested field value

__static() public static method

Register plugin hooks
public static __static ( )

activate_post_type() public static method

Activate an existing post type
public static activate_post_type ( string $type ) : boolean
$type string The post type to activate
return boolean True on success

add_new_status() public static method

inserts a new post status into the database, if it doesn't exist
public static add_new_status ( string $status, boolean $internal = false )
$status string The name of the new post status
$internal boolean Whether this status is for internal use only. If true, this status will NOT be presented to the user

add_new_type() public static method

inserts a new post type into the database, if it doesn't exist
public static add_new_type ( string $type, boolean $active = true )
$type string The name of the new post type
$active boolean Whether the new post type is active or not

add_tokens() public method

Add a token to a post
public add_tokens ( array | string $tokens )
$tokens array | string The name of the permission to add, or an array of permissions to add

ascend() public method

Returns the ascending post, relative to this post, according to params
public ascend ( null $params = null ) : Post
$params null The params by which to work out what is the ascending post
return Post The ascending post

comment_form() public method

Manage this post's comment form
public comment_form ( string $context = 'public' ) : FormUI
$context string The context in which the form is used, used to facilitate plugin alteration of the comment form in different circumstances
return FormUI The comment form for this post

content_type() public method

Return the content type of this object
See also: IsContent
public content_type ( ) : array
return array An array of content types that this object represents, starting with the most specific

create() static public method

Create a post and save it.
static public create ( array $paramarray ) : Post
$paramarray array An associative array of post fields
return Post The new Post object

create_default_tokens() public method

Adds the default tokens to this post when it's saved

css_class() public method

Returns a list of CSS classes for the post
public css_class ( string | array $append = [] ) : string
$append string | array Additional classes that should be added to the ones generated
return string The resultant classes

deactivate_post_type() public static method

Deactivate a post type
public static deactivate_post_type ( string $type ) : boolean
$type string The post type to deactivate
return boolean True on success

default_fields() public static method

Return the defined database columns for a Post.
public static default_fields ( ) : array
return array Array of columns in the Post table

delete() public method

Deletes this post instance
public delete ( ) : boolean
return boolean True on success

delete_post_status() public static method

Delete a post status
public static delete_post_status ( string $status )
$status string The name of the status to delete

delete_post_type() public static method

removes a post type from the database, if it exists and there are no posts of the type
public static delete_post_type ( string $type ) : boolean
$type string The post type name
return boolean true if post type has been deleted false if it has not been deleted (does not exist or there are posts using this content type)

delete_tokens() public method

Deletes all tokens from a post
public delete_tokens ( )

descend() public method

Returns the descending post, relative to this post, according to params
public descend ( $params = null ) : Post
$params The params by which to work out what is the descending post
return Post The descending post

field_load() public method

Loads form values from this post
public field_load ( string $key ) : mixed
$key string The name of a form component that will be loaded
return mixed The stored value returned

field_save() public method

Stores a form value into this post's info records
public field_save ( string $key, mixed $value )
$key string The name of a form component that will be stored
$value mixed The value of the form component to store

filter_post_get_7() public static method

Filter post content and titles for shortcodes
public static filter_post_get_7 ( string $content, string $field, Post $post ) : string
$content string The field value to filter
$field string The name of the field to filter
$post Post The post that is being filtered
return string The fitlered field value

filter_post_status_display_4() public static method

How to display the built-in post statuses.
public static filter_post_status_display_4 ( string $status ) : string
$status string The built-in status name
return string The translated status name, or the built-in name if there is no translation

filter_post_type_display_4() public static method

How to display the built-in post types.
public static filter_post_type_display_4 ( string $type, string $foruse ) : string
$type string The type of Post
$foruse string Either 'singular' or 'plural'
return string The translated type name, or the built-in name if there is no translation

form_publish_delete() public method

The on_success handler for the delete button on the post editing form
public form_publish_delete ( FormUI $form )
$form FormUI The submitted post editing form

form_publish_success() public method

Called when the publish form is successfully submitted
public form_publish_success ( FormUI $form )
$form FormUI

get() static public method

$post= Post::get( array( 'slug' => 'wooga' ) );
static public get ( array $paramarray = [] ) : Post
$paramarray array An associative array of parameters, or a querystring
return Post The first post that matched the given criteria

get_access() public method

Returns an access Bitmask for the given user on this post
public get_access ( User $user = null ) : Bitmask
$user User The user mask to fetch
return Bitmask

get_form() public method

Returns a form for editing this post
public get_form ( string $context ) : FormUI
$context string The context the form is being created in, most often 'admin'
return FormUI A form appropriate for creating and updating this post.

get_revision_data() public method

Get the fields of the post that differ from what is stored by date
public get_revision_data ( DateTime | string | integer $date ) : array
$date DateTime | string | integer The date to fetch the revision of
return array An array of field data for the post with the values of those fields at the specified date

get_schema_map() public method

Get the schema data for this post
public get_schema_map ( ) : array
return array An array of schema data for this post

get_tokens() public method

Returns an array of token ids that are associated with this post Also initializes the internal token array for use by other token operations
public get_tokens ( ) : array
return array An array of token ids

get_url_args() public method

Returns a set of properties used by URL::get to create URLs
public get_url_args ( ) : array
return array Properties of this post used to build a URL

has_tokens() public method

Checks if this post has one or more tokens
public has_tokens ( mixed $tokens ) : mixed
$tokens mixed A single token string or an array of tokens
return mixed false if no tokens match, an array of matching token ids if any match

insert() public method

Saves a new post to the posts table
public insert ( ) : integer | null
return integer | null The new post id on success, or false on failure

list_active_post_types() public static method

returns an associative array of active post types
public static list_active_post_types ( boolean $refresh = false ) : array
$refresh boolean whether to force a refresh of the cached values
return array An array of post type names => integer values

list_all_post_types() public static method

returns an associative array of all post types
public static list_all_post_types ( boolean $refresh = false ) : array
$refresh boolean whether to force a refresh of the cached values
return array An array of post type names => (integer values, active values)

list_post_statuses() public static method

returns an associative array of post statuses
public static list_post_statuses ( mixed $all = true, boolean $refresh = false ) : array
$all mixed true to list all statuses, not just external ones, Post to list external and any that match the Post status
$refresh boolean true to force a refresh of the cached values
return array An array of post statuses names => integer values

list_revisions() public method

List the stored revisions of this post by date and user id
public list_revisions ( ) : array
return array

publish() public method

Updates an existing post to published status
public publish ( ) : boolean
return boolean True on success, false if not

remove_tokens() public method

Deletes tokens from a post
public remove_tokens ( array | string $tokens )
$tokens array | string The name of the permission to remove, or an array of permissions to remove

set_revision() public method

Set this post to have the same data as the post on the specified date
public set_revision ( DateTime | string | integer $date )
$date DateTime | string | integer The date to fetch the revision of

set_tokens() public method

Applies a new set of specific tokens to a post
public set_tokens ( mixed $tokens )
$tokens mixed A string token, or an array of tokens to apply to this post

status() public static method

returns the integer value of the specified post status, or false
public static status ( string | integer $name ) : integer | boolean
$name string | integer a post status name or value
return integer | boolean an integer or boolean false

status_name() public static method

returns the friendly name of a post status, or null
public static status_name ( string | integer $status ) : string | null
$status string | integer a post status value, or name
return string | null a string of the status name, or null

type() public static method

returns the integer value of the specified post type, or false
public static type ( string | integer $name ) : boolean | integer
$name string | integer a post type name or id
return boolean | integer the id of the type or false if not found

type_name() public static method

returns the friendly name of a post type, or null
public static type_name ( string | integer $type ) : string
$type string | integer a post type name or id
return string the string of the type or emptystring if not found

update() public method

Updates an existing post in the posts table
public update ( boolean $minor = true ) : boolean
$minor boolean Indicates if this is a major or minor update
return boolean True on success

Property Details

$post_status_list static_oe public_oe property

static variables to hold post status and post type values
static public $post_status_list

$post_type_list_active static_oe public_oe property

static public $post_type_list_active

$post_type_list_all static_oe public_oe property

static public $post_type_list_all

$schema public_oe property

public $schema

$url_args protected_oe property

protected $url_args