Midgard Multiple Languages and Page Owner patches
(not on a production system, in any case)
Download + unpack the source archive, compile and install. If you want to skip compiling, try the i386 .debs created on woody. You need the source archive anyway, as it contains needed stuff that is not in the .debs.
The patch relies on a slightly different database layout. See data/README in the source archive on how to convert your databases.
If you use replication, convert all the databases you replicate to and replace your repligard_withsg.xml config file (probably in /usr/local/share/midgard or /etc/repligard) with lib/repligard/repligard_withsg.xml from the source archive.
Tests are in php4/test in the source archive. See the php4/test/README for instructions.
Feedback and bug reports are very welcome.
The tables page, pageelement, element, snippet and article have been split up. Metadata or "structure" fields like name, id, etc. stay where they are. "Content" fields like content, title go to the new tables page_i, pageelement_i, element_i, snippet_i and article_i. A record in a "structure" table can be linked to multiple content records. Content records all have a lang field that specifies their language.
The table page has got a new owner field which points to a group that is the owner of the page. It overrides the host owner and is inherited down the tree.
The table host has got a new lang field.
The table language has been added to have ISO-codes handy. Midgard itself does nothing with them, but they can be used in applications where a mapping from ISO-codes to language ids is needed, i.e. in multilingual content creation applications and language selection snippets.
id The id of the article record.
up Points to the id of the article this record is a reply/followup to.
topic Points to the topic-id of the topic this record is under.
author Points to the person-id of the author of the article.
created Date and time the article was created.
calstart Date indicating a calendar start.
caldays An integer representing the number of calendar days.
icon An integer pointing to a possible icon for this article.
view An integer pointing to a possible view for this article.
print An integer pointing to a possible printable version of this article.
extra1 A freeform information field.
extra2 A freeform information field.
extra3 A freeform information field.
name The name of the article.
creator Points to the person-id of the creator of the article.
revisor Points to the person-id of the last revisor of the article.
revision An integer representing the number of times the article has been revised.
approver Points to the person-id of the approver of the article.
revised Date and time of the last revision of the article.
approved Date and time the article has been approved.
score An integer value that can be used to sort articles.
type an integer value that can be used to filter articles.
locked Data and time the article has been locked.
locker Points to the person-id of the locker of the article.
sitegroup Points to the sitegroup-id of the sitegroup to which the article belongs.
id The id of the article content record.
sid The id of the article the content record belongs to.
title The title of the article.
abstract An abstract of the article.
content The content of the article.
author Points to the person-id of the author of the article content. Can be 0 for backwards compatibility.
created Date and time the article content was created.
url Pointer to a url containing extra information.
lang the id of the language the content belongs to
id The id of the element record.
style Points to the style-id the element belongs to.
name The name of the style element.
value The contents of the style element.
sitegroup Points to the sitegroup-id of the sitegroup the record belongs to.
id The id of the element content record.
sid The id of the element the content record belongs to.
value The contents of the style element.
lang the id of the language the content belongs to
id The id of the language record.
code ISO639 two-letter language code
name English name of the language
id The id of the page record.
up The id of the parent page.
style The id of the style of the page.
name The name of the page. Will be part of the URL.
author The id of the person that is the author of the page.
owner The id of the group that is the owner of the page.
info Contains bits for "auth" and "virtual path". Authentication can be required or inherited. A page is either "virtual path enabled" or not.
changed The date and time the page record was last changed.
sitegroup The id of the sitegroup the page record belongs to.
id The id of the page content record.
sid The id of the page the content record belongs to.
title The title of the page.
content The content of the page.
author The id of the person that is the author of the page content. Can be 0 for backwards compatibility.
owner The id of the group that is the owner of the page content. Can be 0 (inherited). Is first inherited from the parent page contents, then from the parent pages and in the end, from the current host.
lang the id of the language the content belongs to
id The id of the page element.
page The id of the page record the page element belongs to.
name The name of the page element
info Contains set('inherit'). If inherit is set, the page element will also be valid for subpages of the page record with id page.
sitegroup The id of the sitegroup the page element belongs to.
id The id of the page element content record.
sid The id of the page element the content record belongs to.
value The content of the page element.
lang The id of the language the content belongs to
id The id of the snippet record.
up The id of the snippetdir the snippet is in.
name The name of the snippet record.
creator The person id of the creator of the snippet.
created Date and time the Snippet was created.
revisor The person id of the last revisor of the snippet.
revised Date and time the Snippet was last revised.
revision An integer representing the number of times the snippet has been revised.
sitegroup The id of the sitegroup the snippet belongs to.
New snippet_i record definition
id The id of the snippet content record.
sid The id of the snippet the content record belongs to.
code The code of the snippet. The content of this field is the actual code that gets executed.
doc Documentation about the snippet.
author The person id of the author of the snippet.
lang The id of the language the content belongs to
The API changes are 100% backwards compatible. All objects keep their fields, and all functions can be called with the same number of parameters as before. The fields of the objects are split up into the "structure" (ex. page) and "content" (ex. page_i) tables. The content fields correspond with the content record in the global language that is currently set.
The global language can be read by mgd_get_lang(). It is an id of a record in the language table.
It can be set in different ways:
mod_midgard sees if there is a cookie named "MidgardLang". It sets the language to the value of this cookie.
mod_midgard sets the language according to the lang field of the current host. This setting is taken into account only if the MidgardLang cookie is not set or set to "0".
mgd_set_midgard($lang) sets the language. It can be called any number of times during processing of a request. You can not reset the language of the current page or any preparsed page- and style-elements, however. They are preparsed by mod_midgard, before mgd_set_lang can be called.
If you ignore the multilanguage features and never set the language, it will always be set to 0 (meaning no language). Consequently, the content always gets inserted in records with lang=0 and every structure record will relate 1-1 to a content record. The objects will be stored differently, but apart from that, they will behave the same as before.
If you use the multilanguage features, objects can get created in different languages, and their content records will have lang values different from 0. Functions are always constrained to objects of one language, except mgd_get_object_by_guid_all_langs(). Since an object always consists of a structure record and a content record, you can't mgd_get or do anything else with an object if it has no content record in your current language. To facilitate showing objects in different languages at once, every object gets a default content record, lang=0. If you want to have access to objects in all languages, set language to 0. You could then call mgd_get_object_by_guid_all_langs to get the different language variants of an object.
creates language with two-letter code and the english name / description. Only sitegroup admin can do this.
gets the language object with the two-letter code specified.
returns all languages defined in the sitegroup, traversable by fetch()
updates language with two-letter code and the english name / description. Only sitegroup admin can do this.
Deletes the language. Only sitegroup admin can do this.
Returns id of the current language.
Sets id of the current language.
returns all language variants of the object pointed to by guid.
Create a new content record using the values in $obj and the current language. Fails if there is already a content record for this language or if the structure record does not exist.
Applies to: article, element, page, pageelement, snippet.
Update the content record using the values in $obj and the value in $obj->lang (not the glboal current language). Fails if there is no structure record or no content record for this language.
Applies to: article, element, page, pageelement, snippet.
Deletes $obj, including content in ALL languages. You must be owner of all content records (can be inherited) for this to succeed.
Applies to: article, element, page, pageelement, snippet.
Deletes $obj's content for language $obj->lang.
Applies to: article, element, page, pageelement, snippet.
The id of the person that is the author of the $obj content.
The id of the group that is the owner of the $obj content.
creates page, content fields (see record definition) in current language.
mgd_create_page(int up, string name, int style, string title, string content, int author, int auth, int active);
mgd_create_page(int up, string name, int style, string title, string content, int author, int owner, int auth, int active);
mgd_create_page(int up, string name, int style, string title, string content, int author, int owner, int auth, int active, int contentauthor, int contentowner);
creates page content in current language.
mgd_create_page_content(int id, string title, string content)
mgd_create_page_content(int id, string title, string content, int contentauthor, int contentowner)
updates page, content fields (see record definition) in current language.
mgd_update_page(int id,int up, string name, int style, string title, string content, int author, int auth, int active);
mgd_update_page(int id,int up, string name, int style, string title, string content, int author, int owner, int auth, int active);
mgd_update_page(int id,int up, string name, int style, string title, string content, int author,int auth, int active, int contentauthor, int contentowner);
updates page content in current language.
mgd_update_page_content(int id, string title, string content)
mgd_update_page_content(int id, string title, string content, int contentauthor, int contentowner)
Deletes page, including content in ALL languages. You must be owner of all content records (can be inherited) for this to succeed.
Deletes page content in the current language.
creates article, content fields (see record definition) in current language.
int mgd_create_article(int up, int topic, string name, string title, string abstract, string content, int author, string url, string calstart, int caldays, int icon, int view, int print, string extra1, string extra2, string extra3, int type);
int mgd_create_article(int up, int topic, string name, string title, string abstract, string content, int author, string url, string calstart, int caldays, int icon, int view, int print, string extra1, string extra2, string extra3, int type, int contentauthor);
creates article content in current language.
int mgd_create_article_content(int id, string title, string abstract, string content, string url);
int mgd_create_article_content(int id, string title, string abstract, string content, string url, int contentauthor);
updates article, content fields (see record definition) in current language.
int mgd_update_article(int id, int up, int topic, string name, string title, string abstract, string content, int author, string url, string calstart, int caldays, int icon, int view, int print, string extra1, string extra2, string extra3, int type);
int mgd_update_article(int id, int up, int topic, string name, string title, string abstract, string content, int author, string url, string calstart, int caldays, int icon, int view, int print, string extra1, string extra2, string extra3, int type, int contentauthor);
updates article content in current language.
int mgd_update_article_content(int id, string title, string abstract, string content, string url);
int mgd_update_article_content(int id, string title, string abstract, string content, string url, int contentauthor);
Deletes article, including content in ALL languages. You must be owner of all content records (can be inherited) for this to succeed.
Deletes article content in the current language.
Creates element, content fields (see record definition) in current language.
Creates element content in current language.
Updates element, content fields (see record definition) in current language.
Updates element content in current language.
Deletes element, including content in ALL languages. You must be owner of all content records (can be inherited) for this to succeed.
Deletes element content in the current language.
Creates page element, content fields (see record definition) in current language.
Creates page element content in current language.
Updates page element, content fields (see record definition) in current language.
Updates page element content in current language.
Deletes page element, including content in ALL languages. You must be owner of all content records (can be inherited) for this to succeed.
Deletes page element content in the current language.
Creates snippet, content fields (see record definition) in current language.
Creates snippet content in current language.
Updates snippet, content fields (see record definition) in current language.
Updates snippet content in current language.
Deletes snippet, including content in ALL languages. You must be owner of all content records (can be inherited) for this to succeed.
Deletes snippet content in the current language.