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

Public Member Functions

 __construct ()
 
 splitMetaValues (string $str)
 
 getMetaArray (?string $str)
 
 getMetaStr (?string $str, string $type)
 
 getMetaRecordset (?string $str, string $type)
 
 getPostsByMeta (array $params=[], bool $count_only=false, ?dcSelectStatement $ext_sql=null)
 
 getCommentsByMeta (array $params=[], bool $count_only=false, ?dcSelectStatement $ext_sql=null)
 
 getMetadata (array $params=[], bool $count_only=false, ?dcSelectStatement $ext_sql=null)
 
 computeMetaStats (dcRecord $rs)
 
 setPostMeta ($post_id, ?string $type, ?string $value)
 
 delPostMeta ($post_id, ?string $type=null, ?string $meta_id=null)
 
 updateMeta (string $meta_id, string $new_meta_id, ?string $type=null, ?string $post_type=null)
 
 delMeta (string $meta_id, ?string $type=null, ?string $post_type=null)
 

Static Public Member Functions

static sanitizeMetaID (string $str)
 

Data Fields

const META_TABLE_NAME = 'meta'
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Constructs a new instance.

References dcCore\app(), and META_TABLE_NAME.

Member Function Documentation

◆ splitMetaValues()

splitMetaValues ( string  $str)

Splits up comma-separated values into an array of unique, URL-proof metadata values.

Parameters
string$strComma-separated metadata
Returns
array The array of sanitized metadata

References sanitizeMetaID().

◆ sanitizeMetaID()

static sanitizeMetaID ( string  $str)
static

Make a metadata ID URL-proof.

Parameters
string$strThe metadata ID
Returns
string

References text\tidyURL().

Referenced by adminTag\process(), dcImportFeed\process(), splitMetaValues(), updateMeta(), and tagsBehaviors\wiki2xhtmlTag().

◆ getMetaArray()

getMetaArray ( ?string  $str)

Converts serialized metadata (for instance in dc_post post_meta) into a meta array.

Parameters
string$strThe serialized metadata
Returns
array The meta array.

Referenced by getMetaRecordset(), and getMetaStr().

◆ getMetaStr()

getMetaStr ( ?string  $str,
string  $type 
)

Converts serialized metadata (for instance in dc_post post_meta) into a comma-separated meta list for a given type.

Parameters
string$strThe serialized metadata
string$typeThe meta type to retrieve metaIDs from
Returns
string The comma-separated list of meta.

References getMetaArray().

◆ getMetaRecordset()

getMetaRecordset ( ?string  $str,
string  $type 
)

Converts serialized metadata (for instance in dc_post post_meta) into a "fetchable" metadata dcRecord.

Parameters
string$strThe serialized metadata
string$typeThe meta type to retrieve metaIDs from
Returns
dcRecord The meta recordset.

References getMetaArray(), and dcRecord\newFromArray().

◆ getPostsByMeta()

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

Retrieves posts corresponding to given meta criteria. $params is an array taking the following optional parameters:

  • meta_id : get posts having meta id
  • meta_type : get posts having meta type
Parameters
array$paramsThe parameters
bool$count_onlyOnly count results
dcSelectStatement | null$ext_sqlOptional dcSqlStatement instance
Returns
dcRecord The resulting posts record.

References dcCore\app().

◆ getCommentsByMeta()

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

Retrieves comments corresponding to given meta criteria. $params is an array taking the following optional parameters:

  • meta_id : get posts having meta id
  • meta_type : get posts having meta type
Parameters
array$paramsThe parameters
bool$count_onlyOnly count results
dcSelectStatement | null$ext_sqlOptional dcSqlStatement instance
Returns
dcRecord The resulting comments record.

References dcCore\app().

◆ getMetadata()

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

Generic-purpose metadata retrieval : gets metadatas according to given criteria. $params is an array taking the following optionnal parameters:

  • type: get metas having the given type
  • meta_id: if not null, get metas having the given id
  • post_id: get metas for the given post id
  • limit: number of max fetched metas
  • order: results order (default : posts count DESC)
Parameters
array$paramsThe parameters
bool$count_onlyOnly counts results
dcSelectStatement | null$ext_sqlOptional dcSqlStatement instance
Returns
dcRecord The metadata.

References dcCore\app(), dcAuth\PERMISSION_CONTENT_ADMIN, dcBlog\POST_PUBLISHED, and dcBlog\POST_TABLE_NAME.

◆ computeMetaStats()

computeMetaStats ( dcRecord  $rs)

Computes statistics from a metadata recordset. Each record gets enriched with lowercase name, percent and roundpercent columns

Parameters
dcRecord$rsThe metadata recordset
Returns
dcRecord The meta statistics.

References dcUtils\removeDiacritics(), and dcRecord\toStatic().

◆ setPostMeta()

setPostMeta (   $post_id,
?string  $type,
?string  $value 
)

Adds a metadata to a post.

Parameters
mixed$post_idThe post identifier
string$typeThe type
string$valueThe value

◆ delPostMeta()

delPostMeta (   $post_id,
?string  $type = null,
?string  $meta_id = null 
)

Removes metadata from a post.

Parameters
mixed$post_idThe post identifier
string$typeThe meta type (if null, delete all types)
string$meta_idThe meta identifier (if null, delete all values)

◆ updateMeta()

updateMeta ( string  $meta_id,
string  $new_meta_id,
?string  $type = null,
?string  $post_type = null 
)

Mass updates metadata for a given post_type.

Parameters
string$meta_idThe old meta value
string$new_meta_idThe new meta value
string$typeThe type (if null, select all types)
string$post_typeThe post type (if null, select all types)
Returns
bool true if at least 1 post has been impacted

References dcCore\app(), dcAuth\PERMISSION_CONTENT_ADMIN, dcBlog\POST_TABLE_NAME, and sanitizeMetaID().

◆ delMeta()

delMeta ( string  $meta_id,
?string  $type = null,
?string  $post_type = null 
)

Mass delete metadata for a given post_type.

Parameters
string$meta_idThe meta identifier
string$typeThe meta type (if null, select all types)
string$post_typeThe post type (if null, select all types)
Returns
array The list of impacted post_ids

References dcCore\app(), and dcBlog\POST_TABLE_NAME.

Field Documentation

◆ META_TABLE_NAME

const META_TABLE_NAME = 'meta'

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