Data models to make database accesses more comfortable.
This file is part of Ratatöskr. Ratatöskr is licensed unter the MIT / X11 License. See “ratatoeskr/licenses/ratatoeskr” for more information.
ratatoeskr/ | Data models to make database accesses more comfortable. |
Variables | |
$imagetype_file_extensions | Array of default file extensions for most IMAGETYPE_* constants |
$ratatoeskr_settings | The global Settings object. |
Constants | |
ARTICLE_STATUS_ | Possible Article::$status values. |
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. |
KVStorage | An abstract class for a KVStorage. |
Silent mode | If the silent mode is enabled, the KVStorage behaves even more like a PHP array, i.e. |
enable_silent_mode | Enable the silent mode. |
disable_silent_mode | Disable the silent mode (default). |
User | Data model for Users |
Variables | |
Public class properties | |
Functions | |
create | Creates a new user. |
by_id | Get a User object by ID |
by_name | Get a User object by username |
all | Returns array of all available users. |
get_id | The user ID. |
save | Saves the object to database |
delete | Deletes the user from the database. |
get_groups | List of all groups where this user is a member (array of Group objects). |
member_of | Checks, if the user is a member of a group. |
Group | Data model for groups |
Variables | |
Public class properties | |
Functions | |
create | Creates a new group. |
by_id | Get a Group object by ID |
by_name | Get a Group object by name |
all | Returns array of all groups |
get_id | The group ID. |
delete | Deletes the group from the database. |
get_members | Get all members of the group. |
exclude_user | Excludes user from group. |
include_user | Includes user to group. |
Translation | A translation. |
Variables | |
Public class variables. | |
Functions | |
__construct | Creates a new Translation object. |
Multilingual | Container for Translation objects. |
Functions | |
get_id | Retuurns the ID of the object. |
create | Creates a new Multilingual object |
by_id | Gets an Multilingual object by ID. |
save | Saves the translations to database. |
delete | Deletes the data from database. |
Settings | A class that holds the Settings of Ratatöskr. |
Functions | |
get_instance | Get an instance of this class. |
PluginKVStorage | A Key-Value-Storage for Plugins Can be accessed like an array. |
Functions | |
__construct | |
Comment | Representing a user comment |
Variables | |
Public class variables. | |
Functions | |
get_id | Gets the comment ID. |
get_article | Gets the article. |
get_language | Gets the language. |
get_timestamp | Gets the timestamp. |
create | Creates a new comment. |
by_id | Gets a Comment by ID. |
all | Get all comments |
htmlize_comment_text | Creates the HTML representation of a comment text. |
create_html | Applys htmlize_comment_text onto this comment’s text. |
save | Save changes to database. |
delete | |
Style | Represents a Style |
Variables | |
Public class variables. | |
Functions | |
test_name | Test, if a name is a valid Style name. |
get_id | |
create | Create a new style. |
by_id | Gets a Style object by ID. |
by_name | Gets a Style object by name. |
all | Get all styles |
save | Save changes to database. |
delete | |
Plugin | The representation of a plugin in the database. |
Variables | |
Public class variables. | |
Functions | |
clean_db | Performs some datadase cleanup jobs on the plugin table. |
get_id | |
create | Creates a new, empty plugin database entry |
fill_from_pluginpackage | Fills plugin data from an PluginPackage object. |
by_id | Gets plugin by ID. |
all | Gets all Plugins |
save | |
delete | |
Section | Representing a section |
Variables | |
Public class variables | |
Functions | |
test_name | Tests, if a name is a valid section name. |
get_id | |
create | Creates a new section. |
by_id | Gets section by ID. |
by_name | Gets section by name. |
all | Gets all sections. |
get_styles | Get all styles associated with this section. |
add_style | Add a style to this section. |
remove_style | Remove a style from this section. |
save | AlreadyExistsError, InvalidDataError |
delete | |
get_articles | Get all articles in this section. |
Tag | Representation of a tag |
Variables | |
Public class variables | |
Functions | |
test_name | Test, if a name is a valid tag name. |
get_id | |
create | Create a new tag. |
by_id | Get tag by ID |
by_name | Get tag by name |
all | Get all tags |
get_articles | Get all articles that are tagged with this tag |
count_articles | The number of articles that are tagged with this tag. |
save | AlreadyExistsError, InvalidDataError |
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. |
Variables | |
Public class variables | |
Functions | |
get_id | Get the ID |
get_filename | Get the filename |
create | Create a new image |
by_id | Get image by ID. |
all | Gets all images. |
exchange_image | Exchanges image file. |
save | |
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. |
Variables | |
Public class variables | |
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 | Create a new repository entry from a base url. |
by_id | Get a repository entry by ID. |
all | Gets all available repositories. |
delete | Delete the repository entry from the database. |
refresh | Refresh the package cache and the name and description. |
get_package_meta | Get metadata of a plugin package from this repository. |
download_package | Download a package from the repository |
Article | Representation of an article |
Variables | |
Public class variables | |
Functions | |
get_id | |
test_urlname | Test, if a urlname is a valid urlname. |
test_status | Test, if a status is valid. |
create | Create a new Article object. |
by_id | Get by ID. |
by_urlname | Get by urlname |
by_multi | Get Articles by multiple criterias |
all | Get all articles |
get_comments | Getting comments for this article. |
get_tags | Get all Tags of this Article. |
set_tags | Set the Tags that should be associated with this Article. |
get_section | Get the section of this article. |
set_section | Set the section of this article. |
get_extradata | Get the extradata for this article and the given plugin. |
save | AlreadyExistsError, InvalidDataError |
delete | |
ArticleExtradata | A Key-Value-Storage assigned to Articles for plugins to store additional data. |
Functions | |
__construct | |
dbversion | Get the version of the database structure currently used. |
clean_database | Clean up the database |
$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. |
Possible Article::$status values.
ARTICLE_STATUS_HIDDEN | Article is hidden (Numeric: 0) |
ARTICLE_STATUS_LIVE | Article is visible / live (Numeric: 1) |
ARTICLE_STATUS_STICKY | Article is sticky (Numeric: 2) |
An abstract class for a KVStorage.
PluginKVStorage, ArticleExtradata
Silent mode | If the silent mode is enabled, the KVStorage behaves even more like a PHP array, i.e. |
enable_silent_mode | Enable the silent mode. |
disable_silent_mode | Disable the silent mode (default). |
Data model for Users
Variables | |
Public class properties | |
Functions | |
create | Creates a new user. |
by_id | Get a User object by ID |
by_name | Get a User object by username |
all | Returns array of all available users. |
get_id | The user ID. |
save | Saves the object to database |
delete | Deletes the user from the database. |
get_groups | List of all groups where this user is a member (array of Group objects). |
member_of | Checks, if the user is a member of a group. |
$username | The username. |
$pwhash | PasswordHash of the password. |
E-Mail-address. | |
$fullname | The full name of the user. |
$language | Users language |
public static function create( $username, $pwhash )
Creates a new user.
$username | The username |
$pwhash | PasswordHash of the password |
An User object
public function get_groups()
List of all groups where this user is a member (array of Group objects).
Data model for groups
Variables | |
Public class properties | |
Functions | |
create | Creates a new group. |
by_id | Get a Group object by ID |
by_name | Get a Group object by name |
all | Returns array of all groups |
get_id | The group ID. |
delete | Deletes the group from the database. |
get_members | Get all members of the group. |
exclude_user | Excludes user from group. |
include_user | Includes user to group. |
A translation. Can only be stored using an Multilingual object.
Variables | |
Public class variables. | |
Functions | |
__construct | Creates a new Translation object. |
Container for Translation objects. Translations can be accessed array-like. So, if you want the german translation: $translation = $my_multilingual[“de”];
<languages.php>
A class that holds the Settings of Ratatöskr. You can access settings like an array.
Functions | |
get_instance | Get an instance of this class. |
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.
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.
Representing a user comment
Variables | |
Public class variables. | |
Functions | |
get_id | Gets the comment ID. |
get_article | Gets the article. |
get_language | Gets the language. |
get_timestamp | Gets the timestamp. |
create | Creates a new comment. |
by_id | Gets a Comment by ID. |
all | Get all comments |
htmlize_comment_text | Creates the HTML representation of a comment text. |
create_html | Applys htmlize_comment_text onto this comment’s text. |
save | Save changes to database. |
delete |
public static function create( $article, $language )
Creates a new comment. Automatically sets the $timestamp and $visible (default from setting “comment_visible_default”).
$article | An Article Object. |
$language | Which language? (see <languages.php>) |
public function create_html()
Applys htmlize_comment_text onto this comment’s text.
The HTML representation.
The representation of a plugin in the database.
Variables | |
Public class variables. | |
Functions | |
clean_db | Performs some datadase cleanup jobs on the plugin table. |
get_id | |
create | Creates a new, empty plugin database entry |
fill_from_pluginpackage | Fills plugin data from an PluginPackage object. |
by_id | Gets plugin by ID. |
all | Gets all Plugins |
save | |
delete |
public function fill_from_pluginpackage( $pkg )
Fills plugin data from an PluginPackage object.
$pkg | The PluginPackage object. |
Representing a section
Variables | |
Public class variables | |
Functions | |
test_name | Tests, if a name is a valid section name. |
get_id | |
create | Creates a new section. |
by_id | Gets section by ID. |
by_name | Gets section by name. |
all | Gets all sections. |
get_styles | Get all styles associated with this section. |
add_style | Add a style to this section. |
remove_style | Remove a style from this section. |
save | AlreadyExistsError, InvalidDataError |
delete | |
get_articles | Get all articles in this section. |
$name | The name of the section. |
$title | The title of the section (a Multilingual object). |
$template | Name of the template. |
public static function by_id( $id )
Gets section by ID.
$id | The ID. |
A Section object.
public static function by_name( $name )
Gets section by name.
$name | The name. |
A Section object.
public function get_styles()
Get all styles associated with this section.
List of Style objects.
public function remove_style( $style )
Remove a style from this section.
$style | A Style object. |
Representation of a tag
Variables | |
Public class variables | |
Functions | |
test_name | Test, if a name is a valid tag name. |
get_id | |
create | Create a new tag. |
by_id | Get tag by ID |
by_name | Get tag by name |
all | Get all tags |
get_articles | Get all articles that are tagged with this tag |
count_articles | The number of articles that are tagged with this tag. |
save | AlreadyExistsError, InvalidDataError |
delete |
$name | The name of the tag |
$title | The title (an Multilingual object) |
public function get_articles()
Get all articles that are tagged with this tag
Array of Article objects
Representation of an image entry.
Variables | |
Public class variables | |
Functions | |
get_id | Get the ID |
get_filename | Get the filename |
create | Create a new image |
by_id | Get image by ID. |
all | Gets all images. |
exchange_image | Exchanges image file. |
save | |
delete |
Representation of an plugin repository.
Variables | |
Public class variables | |
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 | Create a new repository entry from a base url. |
by_id | Get a repository entry by ID. |
all | Gets all available repositories. |
delete | Delete the repository entry from the database. |
refresh | Refresh the package cache and the name and description. |
get_package_meta | Get metadata of a plugin package from this repository. |
download_package | Download a package from the repository |
public static function create( $baseurl )
Create a new repository entry from a base url.
$baseurl | The baseurl of the repository. |
Could throw a RepositoryUnreachableOrInvalid exception. In this case, nothing will be written to the database.
public function get_package_meta( $pkgname )
Get metadata of a plugin package from this repository.
$pkgname | The name of the package. |
A DoesNotExistError Exception, if the package was not found.
A PluginPackageMeta object
public function download_package( $pkgname, $version = "current" )
Download a package from the repository
$pkgname | Name of the package. |
$version | The version to download (defaults to “current”). |
A PluginPackage object.
Representation of an article
Variables | |
Public class variables | |
Functions | |
get_id | |
test_urlname | Test, if a urlname is a valid urlname. |
test_status | Test, if a status is valid. |
create | Create a new Article object. |
by_id | Get by ID. |
by_urlname | Get by urlname |
by_multi | Get Articles by multiple criterias |
all | Get all articles |
get_comments | Getting comments for this article. |
get_tags | Get all Tags of this Article. |
set_tags | Set the Tags that should be associated with this Article. |
get_section | Get the section of this article. |
set_section | Set the section of this article. |
get_extradata | Get the extradata for this article and the given plugin. |
save | AlreadyExistsError, InvalidDataError |
delete |
$urlname | URL name |
$title | Title (an Multilingual object) |
$text | The text (an Multilingual object) |
$excerpt | Excerpt (an Multilingual object) |
$meta | Keywords, comma seperated |
$custom | Custom fields, is an array |
$article_image | The article Image. If none: NULL |
$status | One of the ARTICLE_STATUS_* constants |
$timestamp | Timestamp |
$allow_comments | Are comments allowed? |
public static function by_multi( $criterias, $sortby, $sortdir, $count, $offset, $perpage, $page, & $maxpage )
Get Articles by multiple criterias
$criterias | Array that can have these keys: id (int) , urlname (string), section (Section object), status (int), onlyvisible, langavail(string), tag (Tag object) |
$sortby | Sort by this field (id, urlname, timestamp or title) |
$sortdir | Sorting directory (ASC or DESC) |
$count | How many entries (NULL for unlimited) |
$offset | How many entries should be skipped (NULL for none) |
$perpage | How many entries per page (NULL for no paging) |
$page | Page number (starting at 1, NULL for no paging) |
&$maxpage | Number of pages will be written here, if paging is activated. |
Array of Article objects
public function get_comments( $limit_lang = "", $only_visible = False )
Getting comments for this article.
$limit_lang | Get only comments in a language (empty string for no limitation, this is the default). |
$only_visible | Do you only want the visible comments? (Default: False) |
Array of Comment objects.
public function set_tags( $tags )
Set the Tags that should be associated with this Article.
$tags | Array of Tag objects. |
public function set_section( $section )
Set the section of this article.
$section | A Section object. |
public function get_extradata( $plugin_id )
Get the extradata for this article and the given plugin.
$plugin_id | The ID of the plugin. |
An ArticleExtradata object.
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.
Functions | |
__construct | |
dbversion | Get the version of the database structure currently used. |
clean_database | Clean up the database |
Array of default file extensions for most IMAGETYPE_* constants
$imagetype_file_extensions
The global Settings object.
$ratatoeskr_settings
Creates a new user.
public static function create( $username, $pwhash )
Get a User object by ID
public static function by_id( $id )
Get a User object by username
public static function by_name( $username )
Returns array of all available users.
public static function all()
The user ID.
public function get_id()
Saves the object to database
public function save()
Deletes the user from the database.
public function delete()
List of all groups where this user is a member (array of Group objects).
public function get_groups()
Checks, if the user is a member of a group.
public function member_of( $group )
Creates a new group.
public static function create( $name )
Get a Group object by ID
public static function by_id( $id )
Get a Group object by name
public static function by_name( $name )
Returns array of all groups
public static function all()
The group ID.
public function get_id()
Deletes the group from the database.
public function delete()
Get all members of the group.
public function get_members()
Excludes user from group.
public function exclude_user( $user )
Includes user to group.
public function include_user( $user )
Creates a new Translation object.
public function __construct( $text, $texttype )
Retuurns the ID of the object.
public function get_id()
Creates a new Multilingual object
public static function create()
Gets an Multilingual object by ID.
public static function by_id( $id )
Saves the translations to database.
public function save()
Deletes the data from database.
public function delete()
Get an instance of this class.
public static function get_instance()
public function __construct( $plugin_id )
Creates a new comment.
public static function create( $article, $language )
Gets a Comment by ID.
public static function by_id( $id )
Get all comments
public static function all()
Creates the HTML representation of a comment text.
public static function htmlize_comment_text( $text )
Applys htmlize_comment_text onto this comment’s text.
public function create_html()
Save changes to database.
public function save()
public function delete()
Test, if a name is a valid Style name.
public static function test_name( $name )
public function get_id()
Create a new style.
public static function create( $name )
Gets a Style object by ID.
public static function by_id( $id )
Gets a Style object by name.
public static function by_name( $name )
Get all styles
public static function all()
Save changes to database.
public function save()
public function delete()
Performs some datadase cleanup jobs on the plugin table.
public static function clean_db()
public function get_id()
Creates a new, empty plugin database entry
public static function create()
Fills plugin data from an PluginPackage object.
public function fill_from_pluginpackage( $pkg )
Gets plugin by ID.
public static function by_id( $id )
Gets all Plugins
public static function all()
public function save()
public function delete()
Tests, if a name is a valid section name.
public static function test_name( $name )
public function get_id()
Creates a new section.
public static function create( $name )
Gets section by ID.
public static function by_id( $id )
Gets section by name.
public static function by_name( $name )
Gets all sections.
public static function all()
Get all styles associated with this section.
public function get_styles()
Add a style to this section.
public function add_style( $style )
Remove a style from this section.
public function remove_style( $style )
AlreadyExistsError, InvalidDataError
public function save()
public function delete()
Get all articles in this section.
public function get_articles()
Test, if a name is a valid tag name.
public static function test_name( $name )
public function get_id()
Create a new tag.
public static function create( $name )
Get tag by ID
public static function by_id( $id )
Get tag by name
public static function by_name( $name )
Get all tags
public static function all()
Get all articles that are tagged with this tag
public function get_articles()
The number of articles that are tagged with this tag.
public function count_articles()
AlreadyExistsError, InvalidDataError
public function save()
public function delete()
Create a new image
public static function create( $name, $file )
Get image by ID.
public static function by_id( $id )
Gets all images.
public function all()
Exchanges image file.
public function exchange_image( $file )
public function save()
public function delete()
Create a new repository entry from a base url.
public static function create( $baseurl )
Get a repository entry by ID.
public static function by_id( $id )
Gets all available repositories.
public static function all()
Delete the repository entry from the database.
public function delete()
Refresh the package cache and the name and description.
public function refresh( $force = False )
Get metadata of a plugin package from this repository.
public function get_package_meta( $pkgname )
Download a package from the repository
public function download_package( $pkgname, $version = "current" )
public function get_id()
Test, if a urlname is a valid urlname.
public static function test_urlname( $urlname )
Test, if a status is valid.
public static function test_status( $status )
Create a new Article object.
public static function create( $urlname )
Get by ID.
public static function by_id( $id )
Get by urlname
public static function by_urlname( $urlname )
Get Articles by multiple criterias
public static function by_multi( $criterias, $sortby, $sortdir, $count, $offset, $perpage, $page, & $maxpage )
Get all articles
public static function all()
Getting comments for this article.
public function get_comments( $limit_lang = "", $only_visible = False )
Get all Tags of this Article.
public function get_tags()
Set the Tags that should be associated with this Article.
public function set_tags( $tags )
Get the section of this article.
public function get_section()
Set the section of this article.
public function set_section( $section )
Get the extradata for this article and the given plugin.
public function get_extradata( $plugin_id )
AlreadyExistsError, InvalidDataError
public function save()
public function delete()
public function __construct( $article_id, $plugin_id )
Get the version of the database structure currently used.
function dbversion()
Clean up the database
function clean_database()