Initial cut at new commenting configuration API

This commit is contained in:
Will Rossiter 2010-11-30 23:06:22 +13:00
parent b9970c1f94
commit 3b5afbce23
2 changed files with 75 additions and 4 deletions

View File

@ -3,14 +3,24 @@
/**
* Comments Default Configuration
*
* To enable comments on your own {@link DataObject}'s then
* add the extension 'CommentsExtension' to your object
* To enable comments on your own {@link DataObject}'s you need to
* call Commenting::add_comments($object_name, $settings);
*
* Where $object_name is the name of the subclass of DataObject you want
* to add the comments to and $settings is a map of configuration options
* and values
*
* Example: mysite/_config.php
*
* <code>
* Object::add_extension('Page', 'CommentsExtension');
* // uses the default values
* Commenting::add('SiteTree');
*
* // set configuration
* Commenting::add('SiteTree', array(
* 'require_login' => true
* ));
* </code>
*/
Object::add_extension('Page', 'CommentsExtension');
Commenting::add('Page');

61
code/Commenting.php Normal file
View File

@ -0,0 +1,61 @@
<?php
/**
* Helper Class for storing the configuration options. Retains the mapping between
* objects which have comments attached and the related configuration options.
*
* Also handles adding the Commenting extension to the {@link DataObject} on behalf
* of the user.
*
* For documentation on how to use this class see docs/en/Configuration.md
*
* @package comments
*/
class Commenting {
/**
* @var array map of enabled {@link DataObject} and related configuration
*/
private static $enabled_classes = array();
/**
* @var array default configuration values
*/
private static $default_configuration = array(
'require_login' => false, // boolean, whether a user needs to login
'required_permission' => '', // required permission to comment (or array of permissions)
'use_ajax_commenting' => true, // use ajax to post comments.
'show_comments_when_disabled' => false, // when comments are disabled should we show older comments (if available)
'order_comments_by' => "\"Created\" DESC"
);
public function add($class, $settings) {
}
public function remove($class) {
}
public function set_config($class, $configuration) {
}
public function set_config_value($class, $key, $value = false) {
}
public function get_config($class) {
}
public function get_config_value($class, $key) {
}
public function config_value_equals($class, $key, $value) {
}
}