PHP Class Pressbooks\Catalog

Afficher le fichier Open project: pressbooks/pressbooks Class Usage Examples

Méthodes publiques

Свойство Type Description
$currentVersion integer The value for option: pressbooks_catalog_version
$maxTagsGroup integer Maximum number allowed in tags_group column

Protected Properties

Свойство Type Description
$dbColumns array Column structure of catalog_table
$dbLinkTable Catalog tables, set in constructor
$dbTable Catalog tables, set in constructor
$dbTagsTable Catalog tables, set in constructor
$profileMetaKeys array Profile keys, stored in user_meta table
$userId integer User ID to construct this object

Méthodes publiques

Méthode Description
__construct ( integer $user_id )
addMenu ( ) WP Hook, Instantiate UI
delete ( boolean $for_real = false ) : integer | false Delete an entire catalog.
deleteBook ( integer $blog_id, boolean $for_real = false ) : integer | false Delete a book from a user catalog.
deleteCache ( ) Delete the cache(s)
deleteCacheByBookId ( integer $book_id ) Delete the cache(s) by Book ID
deleteLogo ( ) WP_Ajax hook for pb_delete_catalog_logo
deleteTag ( string $tag, integer $blog_id, integer $tag_group, boolean $for_real = false ) : integer | false Delete a tag.
deleteTags ( $blog_id, $tag_group ) : integer | false Delete all tags from a user catalog
formAddByUrl ( ) Add Book by URL
formSubmit ( ) Catch me
get ( ) : array Get an entire catalog.
getAggregate ( ) : array Get all data for an entire catalog, cached
getBook ( integer $blog_id ) : array Get a book from a user catalog.
getBookIds ( ) : array Get only blog IDs.
getByTagId ( integer $tag_group, integer $tag_id ) : array Get catalog by tag id
getProfile ( ) : array Get catalog profile.
getTags ( integer $tag_group, boolean $show_hidden_tags = true ) : array Get tags
getTagsByBook ( integer $blog_id, integer $tag_group ) : array Get all tags for a book
getUserId ( ) : integer Get User ID
isCurrentAction ( $action ) : boolean Two actions are possible in a generic WP_List_Table form. The first takes precedence.
isFormSubmission ( ) : boolean Check if a user submitted something to index.php?page=pb_catalog
loadTemplate ( integer $userId ) Find and load our catalog template.
purgeOrphanTags ( ) Find all IDs in dbTagsTable that have no matching ID in dbLinkTable and delete them.
save ( array $items ) Save an entire catalog.
saveBook ( $blog_id, array $item ) : integer | false Save a book to a user catalog.
saveProfile ( array $item ) Save catalog profile
saveTag ( string $tag, integer $blog_id, integer $tag_group ) : integer | false Save tag
stringToTags ( string $tags ) : array Return an array of tags from a comma delimited string
tagsToString ( array $tags ) : string Return a comma delimited string from an SQL array of tags, in alphabetical order.
thumbnailFromUserId ( integer $user_id, string $size ) : string Catalog image is stored in user's active Media Library.
upgrade ( integer $version ) Upgrade catalog.
uploadLogo ( string $meta_key )

Méthodes protégées

Méthode Description
createOrUpdateTables ( ) DB Delta the initial Catalog tables.
formBulk ( $action ) Save bulk actions
formProfile ( ) Save catalog profile to database
formTags ( ) Save tags to database

Method Details

__construct() public méthode

public __construct ( integer $user_id )
$user_id integer (optional)

addMenu() static public méthode

WP Hook, Instantiate UI
static public addMenu ( )

createOrUpdateTables() protected méthode

If you change this, then don't forget to also change $this->dbColumns
See also: dbColumns
See also: http://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table
protected createOrUpdateTables ( )

delete() public méthode

Delete an entire catalog.
public delete ( boolean $for_real = false ) : integer | false
$for_real boolean (optional)
Résultat integer | false

deleteBook() public méthode

Delete a book from a user catalog.
public deleteBook ( integer $blog_id, boolean $for_real = false ) : integer | false
$blog_id integer
$for_real boolean (optional)
Résultat integer | false

deleteCache() public méthode

Delete the cache(s)
public deleteCache ( )

deleteCacheByBookId() public méthode

Delete the cache(s) by Book ID
public deleteCacheByBookId ( integer $book_id )
$book_id integer

deleteTag() public méthode

IMPORTANT: The 'for_real' option is extremely destructive. Do not use unless you know what you are doing.
public deleteTag ( string $tag, integer $blog_id, integer $tag_group, boolean $for_real = false ) : integer | false
$tag string
$blog_id integer
$tag_group integer
$for_real boolean (optional)
Résultat integer | false

deleteTags() public méthode

Note: Doesn't actually delete a tag, just removes the association in dbLinkTable
public deleteTags ( $blog_id, $tag_group ) : integer | false
$blog_id
$tag_group
Résultat integer | false

formAddByUrl() static public méthode

Add Book by URL
static public formAddByUrl ( )

formBulk() protected static méthode

Save bulk actions
protected static formBulk ( $action )
$action

formProfile() protected static méthode

Save catalog profile to database
protected static formProfile ( )

formSubmit() static public méthode

Catch me
static public formSubmit ( )

formTags() protected static méthode

Save tags to database
protected static formTags ( )

get() public méthode

Get an entire catalog.
public get ( ) : array
Résultat array

getAggregate() public méthode

Get all data for an entire catalog, cached
public getAggregate ( ) : array
Résultat array

getBook() public méthode

Get a book from a user catalog.
public getBook ( integer $blog_id ) : array
$blog_id integer
Résultat array

getBookIds() public méthode

Get only blog IDs.
public getBookIds ( ) : array
Résultat array

getByTagId() public méthode

Get catalog by tag id
public getByTagId ( integer $tag_group, integer $tag_id ) : array
$tag_group integer
$tag_id integer
Résultat array

getProfile() public méthode

Get catalog profile.
public getProfile ( ) : array
Résultat array

getTags() public méthode

Get tags
public getTags ( integer $tag_group, boolean $show_hidden_tags = true ) : array
$tag_group integer
$show_hidden_tags boolean (optional)
Résultat array

getTagsByBook() public méthode

Get all tags for a book
public getTagsByBook ( integer $blog_id, integer $tag_group ) : array
$blog_id integer
$tag_group integer
Résultat array

getUserId() public méthode

Get User ID
public getUserId ( ) : integer
Résultat integer

isCurrentAction() static public méthode

Two actions are possible in a generic WP_List_Table form. The first takes precedence.
See also: WP_List_Table::current_action
static public isCurrentAction ( $action ) : boolean
$action
Résultat boolean

isFormSubmission() static public méthode

Check if a user submitted something to index.php?page=pb_catalog
static public isFormSubmission ( ) : boolean
Résultat boolean

loadTemplate() static public méthode

Find and load our catalog template.
static public loadTemplate ( integer $userId )
$userId integer

purgeOrphanTags() public méthode

Find all IDs in dbTagsTable that have no matching ID in dbLinkTable and delete them.
public purgeOrphanTags ( )

save() public méthode

Save an entire catalog.
public save ( array $items )
$items array

saveBook() public méthode

Save a book to a user catalog.
public saveBook ( $blog_id, array $item ) : integer | false
$blog_id
$item array
Résultat integer | false

saveProfile() public méthode

Save catalog profile
public saveProfile ( array $item )
$item array

saveTag() public méthode

Save tag
public saveTag ( string $tag, integer $blog_id, integer $tag_group ) : integer | false
$tag string
$blog_id integer
$tag_group integer
Résultat integer | false

stringToTags() static public méthode

Return an array of tags from a comma delimited string
static public stringToTags ( string $tags ) : array
$tags string
Résultat array

tagsToString() static public méthode

Return a comma delimited string from an SQL array of tags, in alphabetical order.
static public tagsToString ( array $tags ) : string
$tags array
Résultat string

thumbnailFromUserId() static public méthode

Catalog image is stored in user's active Media Library.
static public thumbnailFromUserId ( integer $user_id, string $size ) : string
$user_id integer
$size string
Résultat string

upgrade() public méthode

Upgrade catalog.
public upgrade ( integer $version )
$version integer

Property Details

$currentVersion static_oe public_oe property

The value for option: pressbooks_catalog_version
See also: install()
static public int $currentVersion
Résultat integer

$dbColumns protected_oe property

Column structure of catalog_table
protected array $dbColumns
Résultat array

$dbLinkTable protected_oe property

Catalog tables, set in constructor
protected $dbLinkTable

$dbTable protected_oe property

Catalog tables, set in constructor
protected $dbTable

$dbTagsTable protected_oe property

Catalog tables, set in constructor
protected $dbTagsTable

$maxTagsGroup static_oe public_oe property

Maximum number allowed in tags_group column
static public int $maxTagsGroup
Résultat integer

$profileMetaKeys protected_oe property

Profile keys, stored in user_meta table
protected array $profileMetaKeys
Résultat array

$userId protected_oe property

User ID to construct this object
protected int $userId
Résultat integer