Inheritance diagram for wiki:
Public Member Functions | |
wiki (&$con, $prefix) | |
constructs a new instance from a connection object and a prefix | |
getLangs () | |
retrieve all langs available in the wiki | |
getLangById ($id) | |
retrieve a lang by id | |
addUnconfirmedUser ($login, $fname, $lname, $password, $email, $lang_fk, $lang_ui) | |
add a new unconfirmed user | |
confirmUser ($key) | |
confirm a user | |
userExists ($login) | |
does the user exists ? | |
anonymousUser () | |
creates an anonymous user object | |
getUser ($id, $md5password) | |
returns a user from its id and md5 encoded password | |
findUser ($login, $password) | |
find a user by login and plain text password | |
updateUser ($id, $login, $fname, $lname, $password, $email, $lang_fk, $lang_ui) | |
update a user | |
getUsers () | |
get users | |
getAdminEmails () | |
returns emails of admins | |
getGroups () | |
returns all available groups | |
getNodeParents ($related_id, $lang_id) | |
returns an ordered list of parent nodes from a related node and a lang id | |
sortByAlternateTitle ($link1, $link2) | |
getNodeSubLinks ($related_id, $lang_id, $user_id=-1) | |
returns the list of sub nodes from a node | |
getNodesAtUpperLevel ($related_content_id, $lang_id, $level) | |
returns the list of nodes at a level | |
getNodeComments ($node_id) | |
get comments associated to a node | |
getNodeGroups ($node_id) | |
returns list of group having write access to node | |
getNodeLangs ($related_id) | |
return list of lang that translates a given node | |
setRelatedNodeInfo_ ($node) | |
set related info of a node | |
filterNodeResult_ ($result, $lang) | |
private method called from getNodeByIdAndLang or getNodeByTitleAndLang | |
getRootNodeInLang ($lang) | |
retrieve root node in required lang code | |
getNodeByIdAndLang ($node_id, $lang) | |
retrieve a node from its id and its lang code | |
getNodeByTitleAndLang ($title, $lang) | |
retrieve a node from its title and its lang code | |
getSubNodesId_ ($id) | |
returns the list of ALL direct and indirect sub nodes of node | |
contentExists ($title, $lang_id) | |
look if a given node exists | |
contentExistsById ($node_id) | |
look if a given node exists | |
isMasterNode ($node_id) | |
look if a given node exists and if this node is a master node | |
editContent ($node_id, $old_parent_node_id, $parent_node_id, $title, $alternate_title, $content, $commit_msg, $minor_major, $related_content_id, $user, $left, $right) | |
edit an existing content | |
addContent ($parent_node_id, $title, $alternate_title, $content, $commit_msg, $minor_major, $lang_id, $related_content_id, $user) | |
add a new node to the wiki | |
makeNewRootPage ($id) | |
make a new root node out of an existing page | |
deleteContentById ($id) | |
delete a node and all its related nodes (translations) | |
saveHistory ($node) | |
save a new version in history | |
getHistory ($content_id) | |
returns history of a node | |
getHistoryVersion ($history_id) | |
return a particular version of the history from database id | |
getHistoryByDate ($node_id, $timestamp) | |
get nearest history by date strictly below given date | |
getHistoryByTitle ($title, $lang, $offset, $limit, $withAuthor=false, $withContent=false, $withId=false) | |
return a list of version identified by title and lang | |
deleteHistory ($id) | |
delete an entry of history | |
deleteAllHistory ($id) | |
delete all history of a page | |
anonymousComment ($node_id, $author, $email, $title, $comment) | |
add an anonymous comment | |
comment ($node_id, $user, $title, $comment) | |
add a comment from a logged user | |
deleteComment ($id) | |
delete a comment | |
getAllNodesIdByLang ($lang_id) | |
returns list of nodes by lang | |
searchPages ($search, $offset, $limit) | |
search pages by keywords (implicit AND) | |
recentChanges ($offset, $limit, $withAuthor=false, $withContent=false, $withUserForReadAcl=-1) | |
returns the list of recently modified nodes | |
recentComments ($offset, $limit, $withAuthor=false, $withContent=false) | |
returns the list of recent comments | |
recentCommentsByTitle ($title, $lang, $offset, $limit, $withAuthor=false, $withContent=false) | |
returns the list of recent comments from a page | |
whatLinksHere ($title, $offset, $limit) | |
return a list of page that may link to page | |
existAclOnIdAndType ($id, $acl_type) | |
check if an acl exist for a node | |
existAclOnTitleLangAndType ($title, $lang, $acl_type) | |
check if an acl exist for a node | |
addACLOnGroups ($id, $groups, $acl_type, $recApply) | |
add a list of groups having acl_type access to page | |
addACLOnUsers ($id, $users, $acl_type, $recApply) | |
add a list of users having acl_type access to page | |
removeACLOnGroups ($id, $groups, $acl_type, $recApply) | |
remove a list of groups from the groups that have acl_type access to page | |
removeACLOnUsers ($id, $users, $acl_type, $recApply) | |
remove a list of users from the users that have acl_type access to page | |
getEmails ($content_id, $userIdExclusionList=array()) | |
get the list of emails that have subscribed to page | |
getWatches ($user_id) | |
get list of node we have subscribed to | |
addWatch ($node_id, $user_id) | |
subscribe a user to a node | |
removeWatch ($node_id, $user_id) | |
remove a user subscription to a node | |
addWatchRecursively ($node_id, $user_id) | |
subscribe a user to a node and all subnodes | |
removeAllWatch ($user_id) | |
remove all subscription of a user | |
getMetaDatas () | |
get the list of defined metadatas | |
getMetaDataByName ($name) | |
get metadata by name | |
getClosedMetadataValues ($id) | |
get the list of authorized values for a closed metadata | |
addContentMetaDataValue ($node_id, $metadata_id, $value) | |
add an opened metadata value to a node | |
addContentMetadataClosedValue ($node_id, $metadata_id, $metadata_value_id) | |
add a closed metadata value to a node | |
getMetaDataInfoByContentId ($id) | |
returns the list of metadatas attached to a node | |
delContentMetaDataValue ($id) | |
delete a metadata value | |
getClosedMetadataValuesByIds ($closed_metadatas_ids) | |
get the list of closed metadata values | |
addBan ($ip) | |
add a new ip to the list of banned ip | |
getAlreadyBannedIps ($ips) | |
return a list of already banned ips from an array of ip | |
addBans ($ips) | |
ban several ips at once | |
isBanned ($ip) | |
look if ip is banned | |
containsBannedIp ($ips) | |
look if one ip of a list of ip is banned | |
attachFileToPage ($file_name, $node_id, $user_id) | |
add a new attachment to a page | |
deleteAttachments ($file_name, $node_id) | |
delete an attachment | |
getAttachments ($node_id) | |
get all attachments linked to a page | |
Public Attributes | |
$con | |
connection to the database | |
$prefix | |
prefix table to use when building query |
this class act has a controller for all datas stored in the wiki. this class is used from all views and all views must use this class. it contains user handling, data handling (nodes, comments), lang handling, group handling ...
wiki::addACLOnGroups | ( | $ | id, | |
$ | groups, | |||
$ | acl_type, | |||
$ | recApply | |||
) |
add a list of groups having acl_type access to page
id | database id of node we want to write protect | |
groups | array[group_id] | |
acl_type | type of acl to apply | |
recApply | wether to recursively apply acls to sub groups too |
wiki::addACLOnUsers | ( | $ | id, | |
$ | users, | |||
$ | acl_type, | |||
$ | recApply | |||
) |
add a list of users having acl_type access to page
id | database id of node we want to write protect | |
$users | array[user_id] | |
acl_type | type of acl to apply | |
recApply | wether to recursively apply acls to sub groups too |
wiki::addBan | ( | $ | ip | ) |
add a new ip to the list of banned ip
ip | the ip to ban |
wiki::addBans | ( | $ | ips | ) |
ban several ips at once
ips | the ips to ban |
wiki::addContent | ( | $ | parent_node_id, | |
$ | title, | |||
$ | alternate_title, | |||
$ | content, | |||
$ | commit_msg, | |||
$ | minor_major, | |||
$ | lang_id, | |||
$ | related_content_id, | |||
$ | user | |||
) |
add a new node to the wiki
create a new node in the wiki. If this node is a master node (a node in site default lang) then create an entry in table hierarchy and in table content_lang
parent_node_id | database id of parent node | |
title | title of node | |
alternate_title | alternate title of node | |
content | content of node | |
commit_msg | commit message | |
minor_major | is it a major or a minor changement ? | |
lang_id | database id of lang | |
related_content_id | database id of related content (can be zero if this node is a master node) | |
user | user object that is creating this node |
wiki::addContentMetadataClosedValue | ( | $ | node_id, | |
$ | metadata_id, | |||
$ | metadata_value_id | |||
) |
add a closed metadata value to a node
add a metadata to a node with a closed value
node_id | database id of node | |
metadata_id | database id of metadata | |
metadata_value_id | value of closed metadata |
wiki::addContentMetaDataValue | ( | $ | node_id, | |
$ | metadata_id, | |||
$ | value | |||
) |
add an opened metadata value to a node
add a metadata to a node with an open value
node_id | database id of node | |
metadata_id | database id of metadata | |
value | value of open metadata |
wiki::addUnconfirmedUser | ( | $ | login, | |
$ | fname, | |||
$ | lname, | |||
$ | password, | |||
$ | email, | |||
$ | lang_fk, | |||
$ | lang_ui | |||
) |
add a new unconfirmed user
When a user subscribe, as we want to be sure of its email address, we send back to him an email with an hidden link. The user remain 'unconfirmed' while he has not visited the link provided in the email and cannot log in the system.
login | choosen login | |
fname | first name | |
lname | last name | |
password | password | |
lang_fk | choosen lang for content (one available in table lang) | |
lang_ui | choosen lang for ui (one available in i18n/) |
wiki::addWatch | ( | $ | node_id, | |
$ | user_id | |||
) |
subscribe a user to a node
node_id | node to subscribe | |
user_id | user to subscribe |
wiki::addWatchRecursively | ( | $ | node_id, | |
$ | user_id | |||
) |
subscribe a user to a node and all subnodes
node_id | node to subscribe | |
user_id | user to subscribe |
wiki::anonymousComment | ( | $ | node_id, | |
$ | author, | |||
$ | email, | |||
$ | title, | |||
$ | comment | |||
) |
add an anonymous comment
node_id | database if of node to comment | |
author | user given author information | |
user given email | ||
title | title of comment | |
comment |
wiki::anonymousUser | ( | ) |
creates an anonymous user object
wiki::attachFileToPage | ( | $ | file_name, | |
$ | node_id, | |||
$ | user_id | |||
) |
add a new attachment to a page
file_name | file to attach to page | |
node_id | id of page | |
user_id | id of user attaching to page |
wiki::comment | ( | $ | node_id, | |
$ | user, | |||
$ | title, | |||
$ | comment | |||
) |
add a comment from a logged user
node_id | database if of node to comment | |
user | user | |
title | title of comment | |
comment |
wiki::confirmUser | ( | $ | key | ) |
confirm a user
when the user click on the link provided to him in the email that was sent to him when he registered this function is called. The key is a randomly generated key that is passed in the url and must match a value in column temp_key.
key | the temporary key that was assigned to him when he registered |
wiki::containsBannedIp | ( | $ | ips | ) |
look if one ip of a list of ip is banned
ips | the ip to look |
wiki::contentExists | ( | $ | title, | |
$ | lang_id | |||
) |
look if a given node exists
the lookup does not default to site default lang if not found. => the match is exact
title | title of node to look for | |
lang_id | foreign key to table lang |
wiki::contentExistsById | ( | $ | node_id | ) |
look if a given node exists
node_id | id of node to look for |
wiki::delContentMetaDataValue | ( | $ | id | ) |
delete a metadata value
id | database id of metadata value |
wiki::deleteAllHistory | ( | $ | id | ) |
delete all history of a page
id | database id of page's history to delete |
wiki::deleteAttachments | ( | $ | file_name, | |
$ | node_id | |||
) |
delete an attachment
file_name | name of attachment to delete | |
node_id | id of node from which we want to delete the attachement |
wiki::deleteComment | ( | $ | id | ) |
delete a comment
id | database id of comment to delete |
wiki::deleteContentById | ( | $ | id | ) |
delete a node and all its related nodes (translations)
history, comments, acl, notifications associated to the node. If the node is a master node, all translated nodes associated to it will be deleted too.
id | database id of node to delete |
wiki::deleteHistory | ( | $ | id | ) |
delete an entry of history
id | database id of history to delete |
wiki::editContent | ( | $ | node_id, | |
$ | old_parent_node_id, | |||
$ | parent_node_id, | |||
$ | title, | |||
$ | alternate_title, | |||
$ | content, | |||
$ | commit_msg, | |||
$ | minor_major, | |||
$ | related_content_id, | |||
$ | user, | |||
$ | left, | |||
$ | right | |||
) |
edit an existing content
this is the heart of the wiki : it manages content updating AND hierarchy updating by updating the nested set model
node_id | database if of node | |
old_parent_node_id | the old parent id before the content was edited | |
parent_node_id | new parent id (may be equals to old_parent_node_id) | |
title | new title | |
alternate_title | new alternate_title | |
content | new content | |
commit_msg | commit message | |
minor_major | is it a major or a minor changement ? | |
related_content_id | related_content_id !!should not be changed!! | |
user | user object that modified this node | |
left | left value in nested set model !!should not be changed!! | |
right | right value in nested set model !!should not be changed!! |
wiki::existAclOnIdAndType | ( | $ | id, | |
$ | acl_type | |||
) |
check if an acl exist for a node
id | database id of node we want to look at | |
acl_type | type of acl to look for |
wiki::existAclOnTitleLangAndType | ( | $ | title, | |
$ | lang, | |||
$ | acl_type | |||
) |
check if an acl exist for a node
title | title of page to look at | |
lang | lang of page to look at | |
acl_type | type of acl to look for |
wiki::filterNodeResult_ | ( | $ | result, | |
$ | lang | |||
) |
private method called from getNodeByIdAndLang or getNodeByTitleAndLang
composition of result is not documented, look inside caller methods The purpose is to filter out the most relevant node in all nodes contained in $result according to the the desired lang. The fallback is the main lang.
wiki::findUser | ( | $ | login, | |
$ | password | |||
) |
find a user by login and plain text password
When the user register in, login and password are sent as plain text. we then try to find the user in the database and returns it back
login | login of user | |
password | password of user |
wiki::getAdminEmails | ( | ) |
returns emails of admins
wiki::getAllNodesIdByLang | ( | $ | lang_id | ) |
returns list of nodes by lang
the match is exact
lang_id | database id of a lang |
wiki::getAlreadyBannedIps | ( | $ | ips | ) |
return a list of already banned ips from an array of ip
ips | the ips to look for |
wiki::getAttachments | ( | $ | node_id | ) |
get all attachments linked to a page
node_id | id of node from which to get attachments |
wiki::getClosedMetadataValues | ( | $ | id | ) |
get the list of authorized values for a closed metadata
id | database id of metadata |
wiki::getClosedMetadataValuesByIds | ( | $ | closed_metadatas_ids | ) |
get the list of closed metadata values
closed_metadatas_ids | list of closed metadata ids |
wiki::getEmails | ( | $ | content_id, | |
$ | userIdExclusionList = array() | |||
) |
get the list of emails that have subscribed to page
content_id | database id of node | |
userIdExclusionList | list of user to exclude from result |
wiki::getGroups | ( | ) |
returns all available groups
wiki::getHistory | ( | $ | content_id | ) |
returns history of a node
return ordered list of versions of a node
content_id | database id of node to retrieve |
wiki::getHistoryByDate | ( | $ | node_id, | |
$ | timestamp | |||
) |
get nearest history by date strictly below given date
node_id | database id of node | |
timestamp | date to look at |
wiki::getHistoryByTitle | ( | $ | title, | |
$ | lang, | |||
$ | offset, | |||
$ | limit, | |||
$ | withAuthor = false , |
|||
$ | withContent = false , |
|||
$ | withId = false | |||
) |
return a list of version identified by title and lang
the list includes also the current content
title | title of node | |
lang | lang of node | |
offset | what portion of the list to return | |
limit | max number of versions to return | |
withAuthor | add author information in result (firstname, lastname) | |
withContent | add complete content in result | |
withId | add id of history in result |
wiki::getHistoryVersion | ( | $ | history_id | ) |
return a particular version of the history from database id
history_id | database id of version to retrieve |
wiki::getLangById | ( | $ | id | ) |
retrieve a lang by id
id | the database id of the lang |
wiki::getLangs | ( | ) |
retrieve all langs available in the wiki
wiki::getMetaDataByName | ( | $ | name | ) |
get metadata by name
wiki::getMetaDataInfoByContentId | ( | $ | id | ) |
returns the list of metadatas attached to a node
As an optimisation we return open and closed metadata in one request you will have to compare open_value and closed_value_id to see what kind of metadata you're looking at
id | database id of node |
wiki::getMetaDatas | ( | ) |
get the list of defined metadatas
wiki::getNodeByIdAndLang | ( | $ | node_id, | |
$ | lang | |||
) |
retrieve a node from its id and its lang code
if node does not exist in required lang, default to site default lang
node_id | database id of lang | |
lang | lang code |
wiki::getNodeByTitleAndLang | ( | $ | title, | |
$ | lang | |||
) |
retrieve a node from its title and its lang code
if node does not exist in required lang, default to site default lang
title | title of node | |
lang | lang code |
wiki::getNodeComments | ( | $ | node_id | ) |
get comments associated to a node
node_id | database if of node |
wiki::getNodeGroups | ( | $ | node_id | ) |
returns list of group having write access to node
node_id | id of node |
wiki::getNodeLangs | ( | $ | related_id | ) |
return list of lang that translates a given node
related_id | master node |
wiki::getNodeParents | ( | $ | related_id, | |
$ | lang_id | |||
) |
returns an ordered list of parent nodes from a related node and a lang id
Look into hierarchy table for each node that are parent from the nested set model. Once all possible parent nodes have been retrieved, keep only the one that are in the desired lang if it exist, or default to node in site default lang
related_id | master node in site default lang | |
lang_id | the desired lang of parent nodes |
wiki::getNodesAtUpperLevel | ( | $ | related_content_id, | |
$ | lang_id, | |||
$ | level | |||
) |
returns the list of nodes at a level
A little explanation needs to be done here... Let's say you retrieve the parent or the grand parent of the Nth parent of a node and you want to have all other nodes at same N level in the hierarchy. That's exactly what this function is doing. An example :
Level0 | Root | |||||||
Level1 | C1.1 | C1.2 | ||||||
Level2 | GC1.1.1 | GC1.1.2 | GC1.2.1 | GC1.2.2 | GC1.2.3 | |||
Level3 | GGC1.1.2.1 | GGC1.1.2.2 | GGC1.2.3.1 | GGC1.2.3.2 | GC1.2.3.2 |
Now you're displaying node GC1.2.3.2 and you want to display in a tree view for example all nodes at level 2 (GC1.2.1 GC1.2.2 GC1.2.3) Then you call getNodesAtUpperLevel(GC1.2.3.2, lang_id, 2)
related_content_id | master node in site default lang | |
lang_id | the desired lang of parent nodes | |
level | desired level for nodes |
wiki::getNodeSubLinks | ( | $ | related_id, | |
$ | lang_id, | |||
$ | user_id = -1 | |||
) |
returns the list of sub nodes from a node
Look into the hierarchy table for all nodes that have a parent node equals to related_id. Once they have been retrieved, keep only the one in desired lang if they exist, or default to node in site default lang
related_id | master node in site default lang | |
lang_id | the desired lang of parent nodes | |
user_id | filter nodes by returning only nodes that are readable by user identified by user_id |
wiki::getRootNodeInLang | ( | $ | lang | ) |
retrieve root node in required lang code
if node does not exist in required lang, default to site default lang
lang | lang code |
wiki::getSubNodesId_ | ( | $ | id | ) |
returns the list of ALL direct and indirect sub nodes of node
private method used in this class.
id | database id of node |
wiki::getUser | ( | $ | id, | |
$ | md5password | |||
) |
returns a user from its id and md5 encoded password
the cookie sent to the browser contains two fields : id and encoded password this enables to quickly find a user from the cookie
id | database id of user | |
md5password | md5 encoded password |
wiki::getUsers | ( | ) |
get users
get all users (including anonymous)
wiki::getWatches | ( | $ | user_id | ) |
get list of node we have subscribed to
user_id | id of user we're looking |
wiki::isBanned | ( | $ | ip | ) |
look if ip is banned
ip | the ip to look |
wiki::isMasterNode | ( | $ | node_id | ) |
look if a given node exists and if this node is a master node
node_id | id of node to look for |
wiki::makeNewRootPage | ( | $ | id | ) |
make a new root node out of an existing page
id | database id of new root node |
wiki::recentChanges | ( | $ | offset, | |
$ | limit, | |||
$ | withAuthor = false , |
|||
$ | withContent = false , |
|||
$ | withUserForReadAcl = -1 | |||
) |
returns the list of recently modified nodes
offset | what portion of the list to return | |
limit | max number of elements to return | |
withAuthor | includes also in result author information | |
withContent | includes also full content in result | |
withUserForReadAcl | filter nodes by returning only nodes that are readable by user identified by user_id |
wiki::recentComments | ( | $ | offset, | |
$ | limit, | |||
$ | withAuthor = false , |
|||
$ | withContent = false | |||
) |
returns the list of recent comments
offset | what portion of the list to return | |
limit | max number of elements to return | |
withAuthor | includes also in result author information | |
withContent | includes also full content in result |
wiki::recentCommentsByTitle | ( | $ | title, | |
$ | lang, | |||
$ | offset, | |||
$ | limit, | |||
$ | withAuthor = false , |
|||
$ | withContent = false | |||
) |
returns the list of recent comments from a page
title | title of page to look at | |
lang | lang of page to look at | |
offset | what portion of the list to return | |
limit | max number of elements to return | |
withAuthor | includes also in result author information | |
withContent | includes also full content in result |
wiki::removeACLOnGroups | ( | $ | id, | |
$ | groups, | |||
$ | acl_type, | |||
$ | recApply | |||
) |
remove a list of groups from the groups that have acl_type access to page
id | database id of node to protect | |
groups | array[group_id] | |
acl_type | type of acl to apply | |
recApply | wether to recursively apply modification to sub nodes too |
wiki::removeACLOnUsers | ( | $ | id, | |
$ | users, | |||
$ | acl_type, | |||
$ | recApply | |||
) |
remove a list of users from the users that have acl_type access to page
id | database id of node to protect | |
users | array[user_id] | |
acl_type | type of acl to apply | |
recApply | wether to recursively apply modification to sub nodes too |
wiki::removeAllWatch | ( | $ | user_id | ) |
remove all subscription of a user
user_id | database id of user we want to clear subscription |
wiki::removeWatch | ( | $ | node_id, | |
$ | user_id | |||
) |
remove a user subscription to a node
node_id | node to unsubscribe | |
user_id | user to unsubscribe |
wiki::saveHistory | ( | $ | node | ) |
save a new version in history
History are a stripped down version of content : hierarchy, parent relationship, translation relationship, comments, acls, notifications are not saved
node | the node to save |
wiki::searchPages | ( | $ | search, | |
$ | offset, | |||
$ | limit | |||
) |
search pages by keywords (implicit AND)
the pages are searched from content and title
search | space separated list of keywords | |
offset | what portion of the list to return | |
limit | max number of elements to return |
wiki::setRelatedNodeInfo_ | ( | $ | node | ) |
set related info of a node
private method used in this class. it will set fields parents, sublinks, comments, groups, langs
node |
wiki::updateUser | ( | $ | id, | |
$ | login, | |||
$ | fname, | |||
$ | lname, | |||
$ | password, | |||
$ | email, | |||
$ | lang_fk, | |||
$ | lang_ui | |||
) |
update a user
update a user from the user preference dialog
id | database id of user | |
login | login of user | |
fname | first name of user | |
lname | last name of user | |
password | password of user (can be empty if user do not want to update it) | |
email of user | ||
lang_fk | foreign key to lang table (for content) | |
lang_ui | lang code corresponding to an i18n file (for ui) |
wiki::userExists | ( | $ | login | ) |
does the user exists ?
login | the login to check |
wiki::whatLinksHere | ( | $ | title, | |
$ | offset, | |||
$ | limit | |||
) |
return a list of page that may link to page
in fact, the search is naive as we return the list of content that contains title
title | the title to search for | |
offset | what portion of the list to return | |
limit | max number of elements to return |
wiki::wiki | ( | &$ | con, | |
$ | prefix | |||
) |
constructs a new instance from a connection object and a prefix
con | the connection object to a database | |
prefix | prefix used for all tables |
wiki::$con |
connection to the database
wiki::$prefix |
prefix table to use when building query