\ADcomments
Universal additional comments class which allows attach comments for any items on some scope
Synopsis
class ADcomments
{
- // constants
- const TABLE_COMMENTS = 'adcomments';
- const PROUTE_NEW_TEXT = 'newadcommentstext';
- const PROUTE_EDIT_FORM = 'adcommentseditid';
- const PROUTE_EDIT_ID = 'adcommentsmodifyid';
- const PROUTE_EDIT_TEXT = 'adcommentsmodifytext';
- const PROUTE_DELETE = 'adcommentsdeleteid';
- const CACHE_KEY = 'ADCOMMENTS_';
- const EX_EMPTY_SCOPE = 'EMPTY_SCOPE_RECEIVED';
- const EX_EMPTY_ITEM = 'EMPTY_ITEMID_RECEIVED';
- const EX_EMPTY_QUERY_STRING = 'EMPTY_SERVER_QUERY_STRING_RECEIVED';
- // members
- protected array $allCommentsData = ;
- protected string $scope = '';
- protected $cache = '';
- protected integer $cacheTime = 2592000;
- protected string $item = '';
- protected string $myLogin = '';
- protected array $scopeItems = ;
- protected $commentsDb = '';
- protected bool $scopeItemsLoaded = false;
- protected string $textAreaSize = '60x10';
- // methods
- public void __construct()
- protected void setScope()
- protected void setMyLogin()
- protected void initCache()
- protected void initDb()
- protected void clearScopeCache()
- protected void setItem()
- protected void loadComments()
- protected string commentAddForm()
- protected void createComment()
- protected void deleteComment()
- protected void modifyComment()
- protected void commentSaver()
- protected string jsAlert()
- protected string commentControls()
- protected string commentEditForm()
- public string renderComments()
- protected array getScopeItemsCached()
- protected void loadScopeItems()
- public bool haveComments()
- public int getCommentsCount()
- public string getCommentsIndicator()
- public array getScopeItemsCommentsAll()
Constants
Name | Value |
---|---|
TABLE_COMMENTS | 'adcomments' |
PROUTE_NEW_TEXT | 'newadcommentstext' |
PROUTE_EDIT_FORM | 'adcommentseditid' |
PROUTE_EDIT_ID | 'adcommentsmodifyid' |
PROUTE_EDIT_TEXT | 'adcommentsmodifytext' |
PROUTE_DELETE | 'adcommentsdeleteid' |
CACHE_KEY | 'ADCOMMENTS_' |
EX_EMPTY_SCOPE | 'EMPTY_SCOPE_RECEIVED' |
EX_EMPTY_ITEM | 'EMPTY_ITEMID_RECEIVED' |
EX_EMPTY_QUERY_STRING | 'EMPTY_SERVER_QUERY_STRING_RECEIVED' |
Members
protected
- $allCommentsData
—
array
Current scope and item comments data as id=>commentData - $cache
—
UbillingCache object placeholder - $cacheTime
—
int
Comments caching time - $commentsDb
—
Comments data database abstraction layer - $item
—
string
Current instance item id - $myLogin
—
string
Current instance administrator login - $scope
—
string
Current instance scope - $scopeItems
—
array
Current scope items counters as item=>commentsCount - $scopeItemsLoaded
—
bool
Scope items loaded flag - $textAreaSize
—
string
Default editing area size
Methods
protected
- clearScopeCache() — Clear scope cache object
- commentAddForm() — Returns new comment creation form
- commentControls() — Returns coment controls for own comments or for the user with root rights
- commentEditForm() — Returns comment editing form
- commentSaver() — Controls post environment and do something object actions when its required
- createComment() — Creates some new comment in database
- deleteComment() — Deletes comment from database
- getScopeItemsCached() — Loads current scope items from database or cache
- initCache() — Initalizes system cache object for further usage
- initDb() — Inits database abstraction layer
- jsAlert() — Returns JavaScript comfirmation box for deleting/editing inputs
- loadComments() — Loads selected scope and item comments into private data property
- loadScopeItems() — Loads scope items list with counters if its really required
- modifyComment() — Edits some comment text in database
- setItem() — Sets current scope item commenting ID
- setMyLogin() — Sets current administrator login into private prop
- setScope() — Current instance comments scope
public
- __construct() — ADcomments class constructor
- getCommentsCount() — Checks have item some additional comments and return native indicator
- getCommentsIndicator() — Checks have item some additional comments and return native indicator
- getScopeItemsCommentsAll() — Returns all items comments data for a given scope, like: $item => array( [0] => array($comment1), [1] => array($comment2), .......................
- haveComments() — Checks have item some comments or not?
- renderComments() — Returns list of available comments for some item