ratatoeskr/sys/models.php

Data models to make database accesses more comfortable.

License

This file is part of Ratatöskr.  Ratatöskr is licensed unter the MIT / X11 License.  See “ratatoeskr/licenses/ratatoeskr” for more information.

Summary
ratatoeskr/sys/models.phpData models to make database accesses more comfortable.
Variables
$imagetype_file_extensionsArray of default file extensions for most IMAGETYPE_* constants
$ratatoeskr_settingsThe global Settings object.
Constants
ARTICLE_STATUS_Possible Article::$status values.
DoesNotExistErrorThis Exception is thrown by an ::by_*-constructor or any array-like object if the desired object is not present in the database.
AlreadyExistsErrorThis Exception is thrown by an ::create-constructor or a save-method, if the creation/modification of the object would result in duplicates.
NotAllowedError
InvalidDataErrorException that will be thrown, if a object with invalid data (e.g.
KVStorageAn abstract class for a KVStorage.
Silent modeIf the silent mode is enabled, the KVStorage behaves even more like a PHP array, i.e.
enable_silent_modeEnable the silent mode.
disable_silent_modeDisable the silent mode (default).
UserData model for Users
Variables
Public class properties
Functions
createCreates a new user.
by_idGet a User object by ID
by_nameGet a User object by username
allReturns array of all available users.
get_idThe user ID.
saveSaves the object to database
deleteDeletes the user from the database.
get_groupsList of all groups where this user is a member (array of Group objects).
member_ofChecks, if the user is a member of a group.
GroupData model for groups
Variables
Public class properties
Functions
createCreates a new group.
by_idGet a Group object by ID
by_nameGet a Group object by name
allReturns array of all groups
get_idThe group ID.
deleteDeletes the group from the database.
get_membersGet all members of the group.
exclude_userExcludes user from group.
include_userIncludes user to group.
TranslationA translation.
Variables
Public class variables.
Functions
__constructCreates a new Translation object.
MultilingualContainer for Translation objects.
Functions
get_idRetuurns the ID of the object.
createCreates a new Multilingual object
by_idGets an Multilingual object by ID.
saveSaves the translations to database.
deleteDeletes the data from database.
SettingsA class that holds the Settings of Ratatöskr.
Functions
get_instanceGet an instance of this class.
PluginKVStorageA Key-Value-Storage for Plugins Can be accessed like an array.
Functions
__construct
CommentRepresenting a user comment
Variables
Public class variables.
Functions
get_idGets the comment ID.
get_articleGets the article.
get_languageGets the language.
get_timestampGets the timestamp.
createCreates a new comment.
by_idGets a Comment by ID.
allGet all comments
htmlize_comment_textCreates the HTML representation of a comment text.
create_htmlApplys htmlize_comment_text onto this comment’s text.
saveSave changes to database.
delete
StyleRepresents a Style
Variables
Public class variables.
Functions
test_nameTest, if a name is a valid Style name.
get_id
createCreate a new style.
by_idGets a Style object by ID.
by_nameGets a Style object by name.
allGet all styles
saveSave changes to database.
delete
PluginThe representation of a plugin in the database.
Variables
Public class variables.
Functions
clean_dbPerforms some datadase cleanup jobs on the plugin table.
get_id
createCreates a new, empty plugin database entry
fill_from_pluginpackageFills plugin data from an PluginPackage object.
by_idGets plugin by ID.
allGets all Plugins
save
delete
SectionRepresenting a section
Variables
Public class variables
Functions
test_nameTests, if a name is a valid section name.
get_id
createCreates a new section.
by_idGets section by ID.
by_nameGets section by name.
allGets all sections.
get_stylesGet all styles associated with this section.
add_styleAdd a style to this section.
remove_styleRemove a style from this section.
saveAlreadyExistsError, InvalidDataError
delete
get_articlesGet all articles in this section.
TagRepresentation of a tag
Variables
Public class variables
Functions
test_nameTest, if a name is a valid tag name.
get_id
createCreate a new tag.
by_idGet tag by ID
by_nameGet tag by name
allGet all tags
get_articlesGet all articles that are tagged with this tag
count_articlesThe number of articles that are tagged with this tag.
saveAlreadyExistsError, InvalidDataError
delete
UnknownFileFormatException that will be thrown, if a input file has an unsupported file format.
IOErrorThis Exception is thrown, if a IO-Error occurs (file not available, no read/write acccess...)
ImageRepresentation of an image entry.
Variables
Public class variables
Functions
get_idGet the ID
get_filenameGet the filename
createCreate a new image
by_idGet image by ID.
allGets all images.
exchange_imageExchanges image file.
save
delete
RepositoryUnreachableOrInvalidA Exception that will be thrown, if the repository is unreachable or seems to be an invalid repository.
RepositoryRepresentation of an plugin repository.
Variables
Public class variables
Functions
get_idGet internal ID.
get_baseurlGet the baseurl of the repository.
get_nameGet repository name.
get_descriptionGet repository description.
createCreate a new repository entry from a base url.
by_idGet a repository entry by ID.
allGets all available repositories.
deleteDelete the repository entry from the database.
refreshRefresh the package cache and the name and description.
get_package_metaGet metadata of a plugin package from this repository.
download_packageDownload a package from the repository
ArticleRepresentation of an article
Variables
Public class variables
Functions
get_id
test_urlnameTest, if a urlname is a valid urlname.
test_statusTest, if a status is valid.
createCreate a new Article object.
by_idGet by ID.
by_urlnameGet by urlname
by_multiGet Articles by multiple criterias
allGet all articles
get_commentsGetting comments for this article.
get_tagsGet all Tags of this Article.
set_tagsSet the Tags that should be associated with this Article.
get_sectionGet the section of this article.
set_sectionSet the section of this article.
get_extradataGet the extradata for this article and the given plugin.
saveAlreadyExistsError, InvalidDataError
delete
ArticleExtradataA Key-Value-Storage assigned to Articles for plugins to store additional data.
Functions
__construct
dbversionGet the version of the database structure currently used.
clean_databaseClean up the database

Variables

$imagetype_file_extensions

$imagetype_file_extensions

Array of default file extensions for most IMAGETYPE_* constants

$ratatoeskr_settings

$ratatoeskr_settings

The global Settings object.  Can be accessed like an array.  Has these fields:

”default_language”The Language code of the default language.
”comment_visible_default”True, if comments should be visible by default.
”allow_comments_default”True, if comments should be allowed by default.
”default_section”The id of the default Section.
”comment_textprocessor”The textprocessor to be used for comments.
”languages”Array of activated languages.
”last_db_cleanup”Timestamp of the last database cleanup.

Constants

ARTICLE_STATUS_

Possible Article::$status values.

ARTICLE_STATUS_HIDDENArticle is hidden (Numeric: 0)
ARTICLE_STATUS_LIVEArticle is visible / live (Numeric: 1)
ARTICLE_STATUS_STICKYArticle is sticky (Numeric: 2)

DoesNotExistError

This Exception is thrown by an ::by_*-constructor or any array-like object if the desired object is not present in the database.

AlreadyExistsError

This Exception is thrown by an ::create-constructor or a save-method, if the creation/modification of the object would result in duplicates.

NotAllowedError

InvalidDataError

Exception that will be thrown, if a object with invalid data (e.g. urlname in this form not allowed) should have been saved / created.  Unless something else is said at a function, the exception message is a translation key.

KVStorage

An abstract class for a KVStorage.

See also

PluginKVStorage, ArticleExtradata

Summary
Silent modeIf the silent mode is enabled, the KVStorage behaves even more like a PHP array, i.e.
enable_silent_modeEnable the silent mode.
disable_silent_modeDisable the silent mode (default).

Silent mode

If the silent mode is enabled, the KVStorage behaves even more like a PHP array, i.e. it just returns NULL, if a unknown key was requested and does not throw an DoesNotExistError Exception.

enable_silent_mode

Enable the silent mode.

disable_silent_mode

Disable the silent mode (default).

User

Data model for Users

Summary
Variables
Public class properties
Functions
createCreates a new user.
by_idGet a User object by ID
by_nameGet a User object by username
allReturns array of all available users.
get_idThe user ID.
saveSaves the object to database
deleteDeletes the user from the database.
get_groupsList of all groups where this user is a member (array of Group objects).
member_ofChecks, if the user is a member of a group.

Variables

Public class properties

$usernameThe username.
$pwhashPasswordHash of the password.
$mailE-Mail-address.
$fullnameThe full name of the user.
$languageUsers language

Functions

create

public static function create($username,
$pwhash)

Creates a new user.

Parameters

$usernameThe username
$pwhashPasswordHash of the password

Returns

An User object

Throws

AlreadyExistsError

by_id

public static function by_id($id)

Get a User object by ID

Parameters

$idThe ID.

Returns

An User object.

Throws

DoesNotExistError

by_name

public static function by_name($username)

Get a User object by username

Parameters

$usernameThe username.

Returns

An User object.

Throws

DoesNotExistError

all

public static function all()

Returns array of all available users.

get_id

public function get_id()

Returns

The user ID.

save

public function save()

Saves the object to database

Throws

AlreadyExistsError

delete

public function delete()

Deletes the user from the database.  WARNING: Do NOT use this object any longer after you called this function!

get_groups

public function get_groups()

Returns

List of all groups where this user is a member (array of Group objects).

member_of

public function member_of($group)

Checks, if the user is a member of a group.

Parameters

$groupA Group object

Returns

True, if the user is a member of $group.  False, if not.

Group

Data model for groups

Summary
Variables
Public class properties
Functions
createCreates a new group.
by_idGet a Group object by ID
by_nameGet a Group object by name
allReturns array of all groups
get_idThe group ID.
deleteDeletes the group from the database.
get_membersGet all members of the group.
exclude_userExcludes user from group.
include_userIncludes user to group.

Variables

Public class properties

$nameName of the group.

Functions

create

public static function create($name)

Creates a new group.

Parameters

$nameThe name of the group.

Returns

An Group object

Throws

AlreadyExistsError

by_id

public static function by_id($id)

Get a Group object by ID

Parameters

$idThe ID.

Returns

A Group object.

Throws

DoesNotExistError

by_name

public static function by_name($name)

Get a Group object by name

Parameters

$nameThe group name.

Returns

A Group object.

Throws

DoesNotExistError

all

public static function all()

Returns array of all groups

get_id

public function get_id()

Returns

The group ID.

delete

public function delete()

Deletes the group from the database.

get_members

public function get_members()

Get all members of the group.

Returns

Array of User objects.

exclude_user

public function exclude_user($user)

Excludes user from group.

Parameters

$userUser object.

include_user

public function include_user($user)

Includes user to group.

Parameters

$userUser object.

Translation

A translation.  Can only be stored using an Multilingual object.

Summary

Variables

Public class variables.

$textThe translated text.
$texttypeThe type of the text.  Has only a meaning in a context.

Functions

__construct

public function __construct($text,
$texttype)

Creates a new Translation object.  IT WILL NOT BE STORED TO DATABASE!

Parameters

$textThe translated text.
$texttypeThe type of the text.  Has only a meaning in a context.

See also

Multilingual

Multilingual

Container for Translation objects.  Translations can be accessed array-like.  So, if you want the german translation: $translation = $my_multilingual[“de”];

See also

<languages.php>

Summary
Functions
get_idRetuurns the ID of the object.
createCreates a new Multilingual object
by_idGets an Multilingual object by ID.
saveSaves the translations to database.
deleteDeletes the data from database.

Functions

get_id

public function get_id()

Retuurns the ID of the object.

create

public static function create()

Creates a new Multilingual object

Returns

An Multilingual object.

by_id

public static function by_id($id)

Gets an Multilingual object by ID.

Parameters

$idThe ID.

Returns

An Multilingual object.

Throws

DoesNotExistError

save

public function save()

Saves the translations to database.

delete

public function delete()

Deletes the data from database.

Settings

A class that holds the Settings of Ratatöskr.  You can access settings like an array.

Summary
Functions
get_instanceGet an instance of this class.

Functions

get_instance

public static function get_instance()

Get an instance of this class.  All instances are equal (ie. this is a singleton), so you can also use the global $ratatoeskr_settings instance.

PluginKVStorage

A Key-Value-Storage for Plugins Can be accessed like an array.  Keys are strings and Values can be everything serialize() can process.

Extends the abstract KVStorage class.

Functions

__construct

public function __construct($plugin_id)

Parameters

$plugin_idThe ID of the Plugin.

Comment

Representing a user comment

Summary
Variables
Public class variables.
Functions
get_idGets the comment ID.
get_articleGets the article.
get_languageGets the language.
get_timestampGets the timestamp.
createCreates a new comment.
by_idGets a Comment by ID.
allGet all comments
htmlize_comment_textCreates the HTML representation of a comment text.
create_htmlApplys htmlize_comment_text onto this comment’s text.
saveSave changes to database.
delete

Variables

Public class variables.

$author_nameName of comment author.
$author_mailE-Mail of comment author.
$textComment text.
$visibleShould the comment be visible?
$read_by_adminWas the comment read by an admin.

Functions

get_id

Gets the comment ID.

get_article

Gets the article.

get_language

Gets the language.

get_timestamp

Gets the timestamp.

create

public static function create($article,
$language)

Creates a new comment.  Automatically sets the $timestamp and $visible (default from setting “comment_visible_default”).

Parameters

$articleAn Article Object.
$languageWhich language?  (see <languages.php>)

by_id

public static function by_id($id)

Gets a Comment by ID.

Parameters

$idThe comments ID.

Throws

DoesNotExistError

all

public static function all()

Get all comments

Returns

Array of Comment objects

htmlize_comment_text

public static function htmlize_comment_text($text)

Creates the HTML representation of a comment text.  It applys the page’s comment textprocessor on it and filters some potentially harmful tags using kses.

Parameters

$textText to HTMLize.

Returns

HTML code.

create_html

public function create_html()

Applys htmlize_comment_text onto this comment’s text.

Returns

The HTML representation.

save

public function save()

Save changes to database.

delete

public function delete()

Style

Represents a Style

Summary
Variables
Public class variables.
Functions
test_nameTest, if a name is a valid Style name.
get_id
createCreate a new style.
by_idGets a Style object by ID.
by_nameGets a Style object by name.
allGet all styles
saveSave changes to database.
delete

Variables

Public class variables.

$nameThe name of the style.
$codeThe CSS code.

Functions

test_name

public static function test_name($name)

Test, if a name is a valid Style name.

Parameters

$nameThe name to test

Returns

True, if the name is a valid style name, False if not.

get_id

public function get_id()

create

public static function create($name)

Create a new style.

Parameters

$nameA name for the new style.

Throws

AlreadyExistsError

by_id

public static function by_id($id)

Gets a Style object by ID.

Parameters

$idThe ID

Throws

DoesNotExistError

by_name

public static function by_name($name)

Gets a Style object by name.

Parameters

$nameThe name.

Throws

DoesNotExistError

all

public static function all()

Get all styles

Returns

Array of Style objects

save

public function save()

Save changes to database.

Throws

AlreadyExistsError

delete

public function delete()

Plugin

The representation of a plugin in the database.

Summary
Variables
Public class variables.
Functions
clean_dbPerforms some datadase cleanup jobs on the plugin table.
get_id
createCreates a new, empty plugin database entry
fill_from_pluginpackageFills plugin data from an PluginPackage object.
by_idGets plugin by ID.
allGets all Plugins
save
delete

Variables

Public class variables.

$namePlugin name.
$codePlugin code.
$classnameMain class of the plugin.
$activeIs the plugin activated?
$authorAuthor of the plugin.
$versiontextVersion (text)
$versioncountVersion (counter)
$short_descriptionA short description.
$updatepathURL for updates.
$webWebpage of the plugin.
$helpHelp page.
$licenseLicense text.
$installedIs this plugin installed?  Used during the installation process.
$updateShould the plugin be updated at next start?
$apiThe API version this Plugin needs.

Functions

clean_db

public static function clean_db()

Performs some datadase cleanup jobs on the plugin table.

get_id

public function get_id()

create

public static function create()

Creates a new, empty plugin database entry

fill_from_pluginpackage

public function fill_from_pluginpackage($pkg)

Fills plugin data from an PluginPackage object.

Parameters

$pkgThe PluginPackage object.

by_id

public static function by_id($id)

Gets plugin by ID.

Parameters

$idThe ID

Throws

DoesNotExistError

all

public static function all()

Gets all Plugins

Returns

List of Plugin objects.

save

public function save()

delete

public function delete()

Section

Representing a section

Summary
Variables
Public class variables
Functions
test_nameTests, if a name is a valid section name.
get_id
createCreates a new section.
by_idGets section by ID.
by_nameGets section by name.
allGets all sections.
get_stylesGet all styles associated with this section.
add_styleAdd a style to this section.
remove_styleRemove a style from this section.
saveAlreadyExistsError, InvalidDataError
delete
get_articlesGet all articles in this section.

Variables

Public class variables

$nameThe name of the section.
$titleThe title of the section (a Multilingual object).
$templateName of the template.

Functions

test_name

public static function test_name($name)

Tests, if a name is a valid section name.

Parameters

$nameThe name to test.

Returns

True, if the name is a valid section name, False otherwise.

get_id

public function get_id()

create

public static function create($name)

Creates a new section.

Parameters

$nameThe name of the new section.

Throws

AlreadyExistsError, InvalidDataError

by_id

public static function by_id($id)

Gets section by ID.

Parameters

$idThe ID.

Returns

A Section object.

Throws

DoesNotExistError

by_name

public static function by_name($name)

Gets section by name.

Parameters

$nameThe name.

Returns

A Section object.

Throws

DoesNotExistError

all

public static function all()

Gets all sections.

Returns

Array of Section objects.

get_styles

public function get_styles()

Get all styles associated with this section.

Returns

List of Style objects.

add_style

public function add_style($style)

Add a style to this section.

Parameters

$styleA Style object.

remove_style

public function remove_style($style)

Remove a style from this section.

Parameters

$styleA Style object.

save

public function save()

Throws

AlreadyExistsError, InvalidDataError

delete

public function delete()

get_articles

public function get_articles()

Get all articles in this section.

Returns

Array of Article objects

Tag

Representation of a tag

Summary
Variables
Public class variables
Functions
test_nameTest, if a name is a valid tag name.
get_id
createCreate a new tag.
by_idGet tag by ID
by_nameGet tag by name
allGet all tags
get_articlesGet all articles that are tagged with this tag
count_articlesThe number of articles that are tagged with this tag.
saveAlreadyExistsError, InvalidDataError
delete

Variables

Public class variables

$nameThe name of the tag
$titleThe title (an Multilingual object)

Functions

test_name

public static function test_name($name)

Test, if a name is a valid tag name.

Parameters

$nameName to test.

Returns

True, if the name is valid, False otherwise.

get_id

public function get_id()

create

public static function create($name)

Create a new tag.

Parameters

$nameThe name

Throws

AlreadyExistsError, InvalidDataError

by_id

public static function by_id($id)

Get tag by ID

Parameters

$idThe ID

Throws

DoesNotExistError

by_name

public static function by_name($name)

Get tag by name

Parameters

$nameThe name

Throws

DoesNotExistError

all

public static function all()

Get all tags

Returns

Array of Tag objects.

get_articles

public function get_articles()

Get all articles that are tagged with this tag

Returns

Array of Article objects

count_articles

public function count_articles()

Returns

The number of articles that are tagged with this tag.

save

public function save()

Throws

AlreadyExistsError, InvalidDataError

delete

public function delete()

UnknownFileFormat

Exception that will be thrown, if a input file has an unsupported file format.

IOError

This Exception is thrown, if a IO-Error occurs (file not available, no read/write acccess...).

Image

Representation of an image entry.

Summary
Variables
Public class variables
Functions
get_idGet the ID
get_filenameGet the filename
createCreate a new image
by_idGet image by ID.
allGets all images.
exchange_imageExchanges image file.
save
delete

Variables

Public class variables

$nameThe image name

Functions

get_id

Get the ID

get_filename

Get the filename

create

public static function create($name,
$file)

Create a new image

Parameters

$nameThe name for the image
$fileAn uploaded image file (move_uploaded_file must be able to move the file!).

Throws

IOError, UnknownFileFormat

by_id

public static function by_id($id)

Get image by ID.

Parameters

$idThe ID

Throws

DoesNotExistError

all

public function all()

Gets all images.

Returns

Array of Image objects.

exchange_image

public function exchange_image($file)

Exchanges image file.  Also saves object to database.

Parameters

$fileLocation of new image.(move_uploaded_file must be able to move the file!)

Throws

IOError, UnknownFileFormat

save

public function save()

delete

public function delete()

RepositoryUnreachableOrInvalid

A Exception that will be thrown, if the repository is unreachable or seems to be an invalid repository.

Repository

Representation of an plugin repository.

Summary
Variables
Public class variables
Functions
get_idGet internal ID.
get_baseurlGet the baseurl of the repository.
get_nameGet repository name.
get_descriptionGet repository description.
createCreate a new repository entry from a base url.
by_idGet a repository entry by ID.
allGets all available repositories.
deleteDelete the repository entry from the database.
refreshRefresh the package cache and the name and description.
get_package_metaGet metadata of a plugin package from this repository.
download_packageDownload a package from the repository

Variables

Public class variables

$packagesArray with all packages from this repository.  A entry itself is an array: array(name, versioncounter, description)

Functions

get_id

Get internal ID.

get_baseurl

Get the baseurl of the repository.

get_name

Get repository name.

get_description

Get repository description.

create

public static function create($baseurl)

Create a new repository entry from a base url.

Parameters

$baseurlThe baseurl of the repository.

Throws

Could throw a RepositoryUnreachableOrInvalid exception.  In this case, nothing will be written to the database.

by_id

public static function by_id($id)

Get a repository entry by ID.

Parameters

$idID.

Throws

DoesNotExistError

all

public static function all()

Gets all available repositories.

Returns

Array of Repository objects.

delete

public function delete()

Delete the repository entry from the database.

refresh

public function refresh($force =  False)

Refresh the package cache and the name and description.

Parameters

$forceForce a refresh, even if the data was already fetched in the last 6 hours (default: False).

Throws

RepositoryUnreachableOrInvalid

get_package_meta

public function get_package_meta($pkgname)

Get metadata of a plugin package from this repository.

Parameters

$pkgnameThe name of the package.

Throws

A DoesNotExistError Exception, if the package was not found.

Returns

A PluginPackageMeta object

download_package

public function download_package($pkgname,  
$version =  "current")

Download a package from the repository

Parameters

$pkgnameName of the package.
$versionThe version to download (defaults to “current”).

Throws

Returns

A PluginPackage object.

Article

Representation of an article

Summary
Variables
Public class variables
Functions
get_id
test_urlnameTest, if a urlname is a valid urlname.
test_statusTest, if a status is valid.
createCreate a new Article object.
by_idGet by ID.
by_urlnameGet by urlname
by_multiGet Articles by multiple criterias
allGet all articles
get_commentsGetting comments for this article.
get_tagsGet all Tags of this Article.
set_tagsSet the Tags that should be associated with this Article.
get_sectionGet the section of this article.
set_sectionSet the section of this article.
get_extradataGet the extradata for this article and the given plugin.
saveAlreadyExistsError, InvalidDataError
delete

Variables

Public class variables

$urlnameURL name
$titleTitle (an Multilingual object)
$textThe text (an Multilingual object)
$excerptExcerpt (an Multilingual object)
$metaKeywords, comma seperated
$customCustom fields, is an array
$article_imageThe article Image.  If none: NULL
$statusOne of the ARTICLE_STATUS_* constants
$timestampTimestamp
$allow_commentsAre comments allowed?

Functions

get_id

public function get_id()

test_urlname

public static function test_urlname($urlname)

Test, if a urlname is a valid urlname.

Parameters

$urlnameUrlname to test

Returns

True, if the urlname is valid, False otherwise.

test_status

public static function test_status($status)

Test, if a status is valid.

Parameters

$statusStatus value to test.

Returns

True, if the status is a valid status value, False otherwise.

create

public static function create($urlname)

Create a new Article object.

Parameters

urlnameA unique URL name

Throws

AlreadyExistsError, InvalidDataError

by_id

public static function by_id($id)

Get by ID.

Parameters

$idThe ID.

Throws

DoesNotExistError

by_urlname

public static function by_urlname($urlname)

Get by urlname

Parameters

$urlnameThe urlname

Throws

DoesNotExistError

by_multi

public static function by_multi($criterias,
$sortby,
$sortdir,
$count,
$offset,
$perpage,
$page,
&$maxpage)

Get Articles by multiple criterias

Parameters

$criteriasArray that can have these keys: id (int) , urlname (string), section (Section object), status (int), onlyvisible, langavail(string), tag (Tag object)
$sortbySort by this field (id, urlname, timestamp or title)
$sortdirSorting directory (ASC or DESC)
$countHow many entries (NULL for unlimited)
$offsetHow many entries should be skipped (NULL for none)
$perpageHow many entries per page (NULL for no paging)
$pagePage number (starting at 1, NULL for no paging)
&$maxpageNumber of pages will be written here, if paging is activated.

Returns

Array of Article objects

all

public static function all()

Get all articles

Returns

Array of Article objects

get_comments

public function get_comments($limit_lang =  "",
$only_visible =  False)

Getting comments for this article.

Parameters

$limit_langGet only comments in a language (empty string for no limitation, this is the default).
$only_visibleDo you only want the visible comments?  (Default: False)

Returns

Array of Comment objects.

get_tags

public function get_tags()

Get all Tags of this Article.

Returns

Array of Tag objects.

set_tags

public function set_tags($tags)

Set the Tags that should be associated with this Article.

Parameters

$tagsArray of Tag objects.

get_section

public function get_section()

Get the section of this article.

Returns

A Section object.

set_section

public function set_section($section)

Set the section of this article.

Parameters

$sectionA Section object.

get_extradata

public function get_extradata($plugin_id)

Get the extradata for this article and the given plugin.

Parameters

$plugin_idThe ID of the plugin.

Returns

An ArticleExtradata object.

save

public function save()

Throws

AlreadyExistsError, InvalidDataError

delete

public function delete()

ArticleExtradata

A Key-Value-Storage assigned to Articles for plugins to store additional data.  Can be accessed like an array.  Keys are strings and Values can be everything serialize() can process.

Extends the abstract KVStorage class.

Summary
Functions
__construct
dbversionGet the version of the database structure currently used.
clean_databaseClean up the database

Functions

__construct

public function __construct($article_id,
$plugin_id)

Parameters

$article_idThe ID of the Article.
$plugin_idThe ID of the Plugin.

dbversion

function dbversion()

Get the version of the database structure currently used.

Returns

The numerical version of the current database structure.

clean_database

function clean_database()

Clean up the database

$imagetype_file_extensions
Array of default file extensions for most IMAGETYPE_* constants
$ratatoeskr_settings
The global Settings object.
A class that holds the Settings of Ratatöskr.
Representation of an article
public static function create($username,
$pwhash)
Creates a new user.
public static function by_id($id)
Get a User object by ID
public static function by_name($username)
Get a User object by username
public static function all()
Returns array of all available users.
public function get_id()
The user ID.
public function save()
Saves the object to database
public function delete()
Deletes the user from the database.
public function get_groups()
List of all groups where this user is a member (array of Group objects).
Data model for groups
public function member_of($group)
Checks, if the user is a member of a group.
public static function create($name)
Creates a new group.
public static function by_id($id)
Get a Group object by ID
public static function by_name($name)
Get a Group object by name
public static function all()
Returns array of all groups
public function get_id()
The group ID.
public function delete()
Deletes the group from the database.
public function get_members()
Get all members of the group.
public function exclude_user($user)
Excludes user from group.
public function include_user($user)
Includes user to group.
public function __construct($text,
$texttype)
Creates a new Translation object.
A translation.
public function get_id()
Retuurns the ID of the object.
public static function create()
Creates a new Multilingual object
public static function by_id($id)
Gets an Multilingual object by ID.
public function save()
Saves the translations to database.
public function delete()
Deletes the data from database.
public static function get_instance()
Get an instance of this class.
public function __construct($plugin_id)
public static function create($article,
$language)
Creates a new comment.
public static function by_id($id)
Gets a Comment by ID.
public static function all()
Get all comments
public static function htmlize_comment_text($text)
Creates the HTML representation of a comment text.
public function create_html()
Applys htmlize_comment_text onto this comment’s text.
public function save()
Save changes to database.
public function delete()
public static function test_name($name)
Test, if a name is a valid Style name.
public function get_id()
public static function create($name)
Create a new style.
public static function by_id($id)
Gets a Style object by ID.
public static function by_name($name)
Gets a Style object by name.
public static function all()
Get all styles
public function save()
Save changes to database.
public function delete()
public static function clean_db()
Performs some datadase cleanup jobs on the plugin table.
public function get_id()
public static function create()
Creates a new, empty plugin database entry
public function fill_from_pluginpackage($pkg)
Fills plugin data from an PluginPackage object.
A plugin package representation.
public static function by_id($id)
Gets plugin by ID.
public static function all()
Gets all Plugins
public function save()
public function delete()
public static function test_name($name)
Tests, if a name is a valid section name.
public function get_id()
public static function create($name)
Creates a new section.
public static function by_id($id)
Gets section by ID.
public static function by_name($name)
Gets section by name.
public static function all()
Gets all sections.
public function get_styles()
Get all styles associated with this section.
public function add_style($style)
Add a style to this section.
public function remove_style($style)
Remove a style from this section.
public function save()
AlreadyExistsError, InvalidDataError
This Exception is thrown by an ::create-constructor or a save-method, if the creation/modification of the object would result in duplicates.
Exception that will be thrown, if a object with invalid data (e.g.
public function delete()
public function get_articles()
Get all articles in this section.
public static function test_name($name)
Test, if a name is a valid tag name.
public function get_id()
public static function create($name)
Create a new tag.
public static function by_id($id)
Get tag by ID
public static function by_name($name)
Get tag by name
public static function all()
Get all tags
public function get_articles()
Get all articles that are tagged with this tag
public function count_articles()
The number of articles that are tagged with this tag.
public function save()
AlreadyExistsError, InvalidDataError
public function delete()
public static function create($name,
$file)
Create a new image
public static function by_id($id)
Get image by ID.
public function all()
Gets all images.
public function exchange_image($file)
Exchanges image file.
public function save()
public function delete()
public static function create($baseurl)
Create a new repository entry from a base url.
public static function by_id($id)
Get a repository entry by ID.
public static function all()
Gets all available repositories.
public function delete()
Delete the repository entry from the database.
public function refresh($force =  False)
Refresh the package cache and the name and description.
public function get_package_meta($pkgname)
Get metadata of a plugin package from this repository.
public function download_package($pkgname,  
$version =  "current")
Download a package from the repository
public function get_id()
public static function test_urlname($urlname)
Test, if a urlname is a valid urlname.
public static function test_status($status)
Test, if a status is valid.
public static function create($urlname)
Create a new Article object.
public static function by_id($id)
Get by ID.
public static function by_urlname($urlname)
Get by urlname
public static function by_multi($criterias,
$sortby,
$sortdir,
$count,
$offset,
$perpage,
$page,
&$maxpage)
Get Articles by multiple criterias
public static function all()
Get all articles
public function get_comments($limit_lang =  "",
$only_visible =  False)
Getting comments for this article.
public function get_tags()
Get all Tags of this Article.
public function set_tags($tags)
Set the Tags that should be associated with this Article.
public function get_section()
Get the section of this article.
public function set_section($section)
Set the section of this article.
public function get_extradata($plugin_id)
Get the extradata for this article and the given plugin.
public function save()
AlreadyExistsError, InvalidDataError
public function delete()
public function __construct($article_id,
$plugin_id)
function dbversion()
Get the version of the database structure currently used.
function clean_database()
Clean up the database
Representing a section
A Key-Value-Storage for Plugins Can be accessed like an array.
A Key-Value-Storage assigned to Articles for plugins to store additional data.
Contains static functions for password hashes.
This Exception is thrown by an ::by_*-constructor or any array-like object if the desired object is not present in the database.
Data model for Users
Container for Translation objects.
An abstract class for a KVStorage.
The representation of a plugin in the database.
Represents a Style
This Exception is thrown, if a IO-Error occurs (file not available, no read/write acccess...)
Exception that will be thrown, if a input file has an unsupported file format.
Representation of an image entry.
A Exception that will be thrown, if the repository is unreachable or seems to be an invalid repository.
Representation of an plugin repository.
Only the metadata of a PluginPackage.
An Exception that PluginPackage’s function can throw, if the package is invalid.
Representation of a tag
Representing a user comment
Close