Dotclear 2.24
Loading...
Searching...
No Matches
dcBlog Class Reference

Public Member Functions

 __construct ($id)
 
Common public methods
 getQmarkURL ()
 
 getJsJQuery ()
 
 getPF (string $pf, bool $strip_host=true)
 
 getVF (string $vf, bool $strip_host=true)
 
 getPostStatus (int $status)
 
 getAllPostStatus ()
 
 getAllCommentStatus ()
 
 withoutPassword (bool $value)
 
Triggers methods
 triggerBlog ()
 
 triggerComment (int $id, bool $del=false)
 
 triggerComments ($ids, bool $del=false, $affected_posts=null)
 

Data Fields

const BLOG_TABLE_NAME = 'blog'
 
const POST_TABLE_NAME = 'post'
 
const COMMENT_TABLE_NAME = 'comment'
 
const BLOG_ONLINE = 1
 
const BLOG_OFFLINE = 0
 
const BLOG_REMOVED = -1
 
const POST_PENDING = -2
 
const POST_SCHEDULED = -1
 
const POST_UNPUBLISHED = 0
 
const POST_PUBLISHED = 1
 
const COMMENT_JUNK = -2
 
const COMMENT_PENDING = -1
 
const COMMENT_UNPUBLISHED = 0
 
const COMMENT_PUBLISHED = 1
 
 $con
 
 $prefix
 
 $id
 
 $uid
 
 $name
 
 $desc
 
 $url
 
 $host
 
 $creadt
 
 $upddt
 
 $status
 
 $settings
 
 $themes_path
 
 $public_path
 
 $without_password = true
 

Categories management methods

 categories ()
 
 getCategories ($params=[])
 
 getCategory (?int $id)
 
 getCategoryParents (int $id)
 
 getCategoryParent (int $id)
 
 getCategoryFirstChildren (int $id)
 
 IsInCatSubtree (string $cat_url, string $start_url)
 
 addCategory (cursor $cur, int $parent=0)
 
 updCategory (int $id, cursor $cur)
 
 updCategoryPosition (int $id, int $left, int $right)
 
 setCategoryParent (int $id, int $parent)
 
 setCategoryPosition (int $id, int $sibling, string $move)
 
 delCategory (int $id)
 
 resetCategoriesOrder ()
 

Entries management methods

 getPosts ($params=[], bool $count_only=false, ?dcSelectStatement $ext_sql=null)
 
 getNextPost (dcRecord $post, int $dir, bool $restrict_to_category=false, bool $restrict_to_lang=false)
 
 getLangs ($params=[])
 
 getDates ($params=[])
 
 addPost (cursor $cur)
 
 updPost ($id, cursor $cur)
 
 updPostStatus ($id, $status)
 
 updPostsStatus ($ids, $status)
 
 updPostSelected ($id, $selected)
 
 updPostsSelected ($ids, $selected)
 
 updPostCategory ($id, $cat_id)
 
 updPostsCategory ($ids, $cat_id)
 
 changePostsCategory ($old_cat_id, $new_cat_id)
 
 delPost ($id)
 
 delPosts ($ids)
 
 publishScheduledEntries ()
 
 firstPublicationEntries ($ids)
 
 getPostsUsers (string $post_type='post')
 
 setPostContent ($post_id, $format, $lang, &$excerpt, &$excerpt_xhtml, &$content, &$content_xhtml)
 
 getPostURL ($url, $post_dt, $post_title, $post_id)
 

Comments management methods

 getComments ($params=[], bool $count_only=false, ?dcSelectStatement $ext_sql=null)
 
 addComment (cursor $cur)
 
 updComment ($id, cursor $cur)
 
 updCommentStatus ($id, $status)
 
 updCommentsStatus ($ids, $status)
 
 delComment ($id)
 
 delComments ($ids)
 
 delJunkComments ()
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $id)

Constructs a new instance.

Parameters
string$idThe blog identifier

References $id, dcCore\app(), DC_ROOT, path\fullFromRoot(), and http\getHostFromURL().

Member Function Documentation

◆ getQmarkURL()

getQmarkURL ( )

Returns blog URL ending with a question mark.

Returns
string The qmark url.

References $url.

Referenced by getPF(), and getVF().

◆ getJsJQuery()

getJsJQuery ( )

Gets the jQuery version.

Returns
string

References $version, and DC_DEFAULT_JQUERY.

◆ getPF()

getPF ( string  $pf,
bool  $strip_host = true 
)

Returns public URL of specified plugin file.

Parameters
string$pfplugin file
bool$strip_hostStrip host in URL
Returns
string

References $ret, getQmarkURL(), and html\stripHostURL().

◆ getVF()

getVF ( string  $vf,
bool  $strip_host = true 
)

Returns public URL of specified var file.

Parameters
string$vfvar file
bool$strip_hostStrip host in URL
Returns
string

References $ret, getQmarkURL(), and html\stripHostURL().

◆ getPostStatus()

getPostStatus ( int  $status)

Returns an entry status name given to a code. Status are translated, never use it for tests. If status code does not exist, returns unpublished.

Parameters
int$statusThe status code
Returns
string The post status.

References $status.

◆ getAllPostStatus()

getAllPostStatus ( )

Returns an array of available entry status codes and names.

Returns
array Simple array with codes in keys and names in value.

◆ getAllCommentStatus()

getAllCommentStatus ( )

Returns an array of available comment status codes and names.

Returns
array Simple array with codes in keys and names in value

◆ withoutPassword()

withoutPassword ( bool  $value)

Disallows entries password protection. You need to set it to false while serving a public blog.

Parameters
bool$value

◆ triggerBlog()

◆ triggerComment()

triggerComment ( int  $id,
bool  $del = false 
)

Updates comment and trackback counters in post table. Should be called every time a comment or trackback is added, removed or changed its status.

Parameters
int$idThe comment identifier
bool$delIf comment is deleted, set this to true

References triggerComments().

Referenced by addComment(), and updComment().

◆ triggerComments()

triggerComments (   $ids,
bool  $del = false,
  $affected_posts = null 
)

Updates comments and trackbacks counters in post table. Should be called every time comments or trackbacks are added, removed or changed their status.

Parameters
mixed$idsThe identifiers
bool$delIf comment is delete, set this to true
mixed$affected_postsThe affected posts IDs

References dcUtils\cleanIds().

Referenced by delComments(), triggerComment(), and updCommentsStatus().

◆ categories()

◆ getCategories()

getCategories (   $params = [])

Retrieves categories. $params is an associative array which can take the following parameters:

  • post_type: Get only entries with given type (default "post")
  • cat_url: filter on cat_url field
  • cat_id: filter on cat_id field
  • start: start with a given category
  • level: categories level to retrieve
Parameters
array | ArrayObject$paramsThe parameters
Returns
dcRecord The categories.

References dcCore\app(), categories(), if, and dcRecord\newFromArray().

Referenced by getCategory(), getCategoryFirstChildren(), and IsInCatSubtree().

◆ getCategory()

getCategory ( ?int  $id)

Gets the category by its ID.

Parameters
int$idThe category identifier
Returns
dcRecord The category.

References getCategories().

Referenced by addCategory().

◆ getCategoryParents()

getCategoryParents ( int  $id)

Gets the category parents.

Parameters
int$idThe category identifier
Returns
dcRecord The category parents.

References categories().

◆ getCategoryParent()

getCategoryParent ( int  $id)

Gets the category first parent.

Parameters
int$idThe category identifier
Returns
dcRecord The category parent.

References categories().

◆ getCategoryFirstChildren()

getCategoryFirstChildren ( int  $id)

Gets all category's first children.

Parameters
int$idThe category identifier
Returns
dcRecord The category first children.

References $id, and getCategories().

◆ IsInCatSubtree()

IsInCatSubtree ( string  $cat_url,
string  $start_url 
)

Returns true if a given category if in a given category's subtree

Parameters
string$cat_urlThe cat url
string$start_urlThe top cat url
Returns
bool true if cat_url is in given start_url cat subtree

References getCategories().

◆ addCategory()

addCategory ( cursor  $cur,
int  $parent = 0 
)

Adds a new category. Takes a cursor as input and returns the new category ID.

Parameters
cursor$curThe category cursor
int$parentThe parent category ID
Exceptions
Exception
Returns
int New category ID

References $id, $url, dcCore\app(), categories(), getCategory(), dcAuth\PERMISSION_CATEGORIES, text\tidyURL(), and triggerBlog().

◆ updCategory()

updCategory ( int  $id,
cursor  $cur 
)

Updates an existing category.

Parameters
int$idThe category ID
cursor$curThe category cursor
Exceptions
Exception

References $id, $url, dcCore\app(), categories(), dcAuth\PERMISSION_CATEGORIES, text\tidyURL(), and triggerBlog().

◆ updCategoryPosition()

updCategoryPosition ( int  $id,
int  $left,
int  $right 
)

Set category position.

Parameters
int$idThe category ID
int$leftThe category ID before
int$rightThe category ID after

References categories(), and triggerBlog().

◆ setCategoryParent()

setCategoryParent ( int  $id,
int  $parent 
)

Sets the category parent.

Parameters
int$idThe category ID
int$parentThe parent category ID

References categories(), and triggerBlog().

◆ setCategoryPosition()

setCategoryPosition ( int  $id,
int  $sibling,
string  $move 
)

Sets the category position.

Parameters
int$idThe category ID
int$siblingThe sibling category ID
string$moveThe move (before|after)

References categories(), and triggerBlog().

◆ delCategory()

delCategory ( int  $id)

Delete a category.

Parameters
int$idThe category ID
Exceptions
Exception

References $id, dcCore\app(), categories(), dcAuth\PERMISSION_CATEGORIES, and triggerBlog().

◆ resetCategoriesOrder()

resetCategoriesOrder ( )

Reset categories order and relocate them to first level

References dcCore\app(), categories(), dcAuth\PERMISSION_CATEGORIES, and triggerBlog().

◆ getPosts()

getPosts (   $params = [],
bool  $count_only = false,
?dcSelectStatement  $ext_sql = null 
)

Retrieves entries. $params is an array taking the following optionnal parameters:

  • no_content: Don't retrieve entry content (excerpt and content)
  • post_type: Get only entries with given type (default "post", array for many types and '' for no type)
  • post_id: (integer or array) Get entry with given post_id
  • post_url: Get entry with given post_url field
  • user_id: (integer) Get entries belonging to given user ID
  • cat_id: (string or array) Get entries belonging to given category ID
  • cat_id_not: deprecated (use cat_id with "id ?not" instead)
  • cat_url: (string or array) Get entries belonging to given category URL
  • cat_url_not: deprecated (use cat_url with "url ?not" instead)
  • post_status: (integer) Get entries with given post_status
  • post_selected: (boolean) Get select flaged entries
  • post_year: (integer) Get entries with given year
  • post_month: (integer) Get entries with given month
  • post_day: (integer) Get entries with given day
  • post_lang: Get entries with given language code
  • search: Get entries corresponding of the following search string
  • columns: (array) More columns to retrieve
  • join: Append a JOIN clause for the FROM statement in query
  • sql: Append SQL string at the end of the query
  • from: Append another FROM source in query
  • order: Order of results (default "ORDER BY post_dt DES")
  • limit: Limit parameter
  • exclude_post_id : (integer or array) Exclude entries with given post_id

Please note that on every cat_id or cat_url, you can add ?not to exclude the category and ?sub to get subcategories.

Parameters
array | ArrayObject$paramsParameters
bool$count_onlyOnly counts results
dcSelectStatement$ext_sqlOptional dcSelectStatement instance
Returns
dcRecord A record with some more capabilities

References dcCore\app(), dcCategories\CATEGORY_TABLE_NAME, dcAuth\PERMISSION_CONTENT_ADMIN, dcPostMedia\POST_MEDIA_TABLE_NAME, text\splitWords(), and dcAuth\USER_TABLE_NAME.

Referenced by firstPublicationEntries().

◆ getNextPost()

getNextPost ( dcRecord  $post,
int  $dir,
bool  $restrict_to_category = false,
bool  $restrict_to_lang = false 
)

Returns a dcRecord with post id, title and date for next or previous post according to the post ID. $dir could be 1 (next post) or -1 (previous post).

Parameters
dcRecord$postThe post ID
int$dirThe search direction
bool$restrict_to_categoryRestrict to same category
bool$restrict_to_langRestrict to same language
Returns
dcRecord|null The next post.

References if.

◆ getLangs()

getLangs (   $params = [])

Retrieves different languages and post count on blog, based on post_lang field. $params is an array taking the following optionnal parameters:

  • post_type: Get only entries with given type (default "post", '' for no type)
  • lang: retrieve post count for selected lang
  • order: order statement (default post_lang DESC)
Parameters
array | ArrayObject$paramsThe parameters
Returns
dcRecord The langs.

◆ getDates()

getDates (   $params = [])

Returns a dcRecord with all distinct blog dates and post count. $params is an array taking the following optionnal parameters:

  • type: (day|month|year) Get days, months or years
  • year: (integer) Get dates for given year
  • month: (integer) Get dates for given month
  • day: (integer) Get dates for given day
  • cat_id: (integer) Category ID filter
  • cat_url: Category URL filter
  • post_lang: lang of the posts
  • next: Get date following match
  • previous: Get date before match
  • order: Sort by date "ASC" or "DESC"
Parameters
array | ArrayObject$paramsThe parameters
Returns
dcRecord The dates.

◆ addPost()

addPost ( cursor  $cur)

Creates a new entry. Takes a cursor as input and returns the new entry ID.

Parameters
cursor$curThe post cursor
Exceptions
Exception
Returns
int

◆ updPost()

updPost (   $id,
cursor  $cur 
)

Updates an existing post.

Parameters
int$idThe post identifier
cursor$curThe post cursor
Exceptions
Exception

References $id, and dcCore\app().

◆ updPostStatus()

updPostStatus (   $id,
  $status 
)

Update post status.

Parameters
int$idThe identifier
int$statusThe status

References $id, $status, and updPostsStatus().

◆ updPostsStatus()

updPostsStatus (   $ids,
  $status 
)

Updates posts status.

Parameters
mixed$idsThe identifiers
int$statusThe status
Exceptions
Exception

References $status, dcCore\app(), dcUtils\cleanIds(), firstPublicationEntries(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_PUBLISH, and triggerBlog().

Referenced by updPostStatus().

◆ updPostSelected()

updPostSelected (   $id,
  $selected 
)

Updates post selection.

Parameters
int$idThe identifier
mixed$selectedThe selected flag

References $id, and updPostsSelected().

◆ updPostsSelected()

updPostsSelected (   $ids,
  $selected 
)

Updates posts selection.

Parameters
mixed$idsThe identifiers
mixed$selectedThe selected flag
Exceptions
Exception

References dcCore\app(), dcUtils\cleanIds(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_USAGE, and triggerBlog().

Referenced by updPostSelected().

◆ updPostCategory()

updPostCategory (   $id,
  $cat_id 
)

Updates post category. $cat_id can be null.

Parameters
int$idThe identifier
mixed$cat_idThe cat identifier

References $id, and updPostsCategory().

◆ updPostsCategory()

updPostsCategory (   $ids,
  $cat_id 
)

Updates posts category. $cat_id can be null.

Parameters
mixed$idsThe identifiers
mixed$cat_idThe cat identifier
Exceptions
Exception

References dcCore\app(), dcUtils\cleanIds(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_USAGE, and triggerBlog().

Referenced by updPostCategory().

◆ changePostsCategory()

changePostsCategory (   $old_cat_id,
  $new_cat_id 
)

Updates posts category. $new_cat_id can be null.

Parameters
mixed$old_cat_idThe old cat identifier
mixed$new_cat_idThe new cat identifier
Exceptions
Exception

References dcCore\app(), dcAuth\PERMISSION_CATEGORIES, dcAuth\PERMISSION_CONTENT_ADMIN, and triggerBlog().

◆ delPost()

delPost (   $id)

Deletes a post.

Parameters
int$idThe post identifier

References $id, and delPosts().

◆ delPosts()

delPosts (   $ids)

Deletes multiple posts.

Parameters
mixed$idsThe posts identifiers
Exceptions
Exception

References dcCore\app(), dcUtils\cleanIds(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_DELETE, and triggerBlog().

Referenced by delPost().

◆ publishScheduledEntries()

publishScheduledEntries ( )

Publishes all entries flaged as "scheduled".

References dcCore\app(), firstPublicationEntries(), dt\getTimeOffset(), dt\toUTC(), and triggerBlog().

◆ firstPublicationEntries()

firstPublicationEntries (   $ids)

First publication mecanism (on post create, update, publish, status)

Parameters
mixed$idsThe posts identifiers

References dcCore\app(), dcUtils\cleanIds(), and getPosts().

Referenced by publishScheduledEntries(), and updPostsStatus().

◆ getPostsUsers()

getPostsUsers ( string  $post_type = 'post')

Retrieves all users having posts on current blog.

Parameters
string$post_typepost_type filter (post)
Returns
dcRecord

References dcAuth\USER_TABLE_NAME.

◆ setPostContent()

setPostContent (   $post_id,
  $format,
  $lang,
$excerpt,
$excerpt_xhtml,
$content,
$content_xhtml 
)

Creates post HTML content, taking format and lang into account.

Parameters
int$post_idThe post identifier
string$formatThe format
string$langThe language
string$excerptThe excerpt
string$excerpt_xhtmlThe excerpt HTML
string$contentThe content
string$content_xhtmlThe content HTML

References dcCore\app().

◆ getPostURL()

getPostURL (   $url,
  $post_dt,
  $post_title,
  $post_id 
)

Returns URL for a post according to blog setting post_url_format. It will try to guess URL and append some figures if needed.

Parameters
string$urlThe url
string$post_dtThe post dt
string$post_titleThe post title
int$post_idThe post identifier
Returns
string The post url.

References $url, and text\tidyURL().

◆ getComments()

getComments (   $params = [],
bool  $count_only = false,
?dcSelectStatement  $ext_sql = null 
)

Retrieves comments. $params is an array taking the following optionnal parameters:

  • no_content: Don't retrieve comment content
  • post_type: Get only entries with given type (default no type, array for many types)
  • post_id: (integer) Get comments belonging to given post_id
  • cat_id: (integer or array) Get comments belonging to entries of given category ID
  • comment_id: (integer or array) Get comment with given ID (or IDs)
  • comment_site: (string) Get comments with given comment_site
  • comment_status: (integer) Get comments with given comment_status
  • comment_trackback: (integer) Get only comments (0) or trackbacks (1)
  • comment_ip: (string) Get comments with given IP address
  • post_url: Get entry with given post_url field
  • user_id: (integer) Get entries belonging to given user ID
  • q_author: Search comments by author
  • sql: Append SQL string at the end of the query
  • from: Append SQL string after "FROM" statement in query
  • order: Order of results (default "ORDER BY comment_dt DES")
  • limit: Limit parameter
Parameters
array | ArrayObject$paramsParameters
bool$count_onlyOnly counts results
dcSelectStatement$ext_sqlOptional dcSelectStatement instance
Returns
dcRecord A record with some more capabilities

References dcCore\app(), dcAuth\PERMISSION_CONTENT_ADMIN, POST_PUBLISHED, text\splitWords(), and dcAuth\USER_TABLE_NAME.

Referenced by updComment().

◆ addComment()

addComment ( cursor  $cur)

Creates a new comment. Takes a cursor as input and returns the new comment ID.

Parameters
cursor$curThe comment cursor
Returns
int

References dcCore\app(), dt\getTimeOffset(), cursor\insert(), http\realIP(), triggerBlog(), and triggerComment().

◆ updComment()

updComment (   $id,
cursor  $cur 
)

Updates an existing comment.

Parameters
int$idThe comment identifier
cursor$curThe comment cursor
Exceptions
Exception

References $id, dcCore\app(), getComments(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_PUBLISH, dcAuth\PERMISSION_USAGE, triggerBlog(), triggerComment(), and cursor\unsetField().

◆ updCommentStatus()

updCommentStatus (   $id,
  $status 
)

Updates comment status.

Parameters
int$idThe comment identifier
mixed$statusThe comment status

References $id, $status, and updCommentsStatus().

◆ updCommentsStatus()

updCommentsStatus (   $ids,
  $status 
)

Updates comments status.

Parameters
mixed$idsThe identifiers
mixed$statusThe status
Exceptions
Exception

References $status, dcCore\app(), dcUtils\cleanIds(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_PUBLISH, triggerBlog(), and triggerComments().

Referenced by updCommentStatus().

◆ delComment()

delComment (   $id)

Delete a comment.

Parameters
int$idThe comment identifier

References $id, and delComments().

◆ delComments()

delComments (   $ids)

Delete comments.

Parameters
mixed$idsThe comments identifiers
Exceptions
Exception

References dcCore\app(), dcUtils\cleanIds(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_DELETE, triggerBlog(), and triggerComments().

Referenced by delComment().

◆ delJunkComments()

delJunkComments ( )

Delete Junk comments

Exceptions
Exception(description)

References dcCore\app(), dcAuth\PERMISSION_CONTENT_ADMIN, dcAuth\PERMISSION_DELETE, and triggerBlog().

Field Documentation

◆ BLOG_TABLE_NAME

◆ POST_TABLE_NAME

◆ COMMENT_TABLE_NAME

◆ BLOG_ONLINE

const BLOG_ONLINE = 1

◆ BLOG_OFFLINE

◆ BLOG_REMOVED

const BLOG_REMOVED = -1

◆ POST_PENDING

◆ POST_SCHEDULED

◆ POST_UNPUBLISHED

◆ POST_PUBLISHED

◆ COMMENT_JUNK

◆ COMMENT_PENDING

◆ COMMENT_UNPUBLISHED

◆ COMMENT_PUBLISHED

◆ $con

$con

◆ $prefix

$prefix

◆ $id

◆ $uid

$uid

◆ $name

$name

◆ $desc

$desc

◆ $url

◆ $host

$host

◆ $creadt

$creadt

◆ $upddt

$upddt

◆ $status

◆ $settings

$settings

◆ $themes_path

$themes_path

◆ $public_path

$public_path

◆ $without_password

$without_password = true

The documentation for this class was generated from the following file: