Extension talk:Taxonomy
My First Extension
editHello, this is my first attempt to write a mediawiki extension for my first mediawiki site (computational.engineering.or.id). So I released this in beta status. Please help testing and improving it to reach the stable status. Thanks.
Create Database
editHi- can you please give specific instructions for the first step of the installation. I've spoken to my IT consultant and neither of us can figure out how to create the taxonomy table in the database. thanks
Answer: Well, in my case, the mysql database can be accessed by using phpmyadmin. If you have it too, just go to it (e.g to http://localhost/phpmyadmin), then choose the mediawiki databse, and execute the SQL script. Here is the tutorial: http://www.siteground.com/tutorials/phpmyadmin/phpmyadmin_mysql_query.htm If you are not using phpmyadmin, your system administrator should be able to help.
Error
editHi, I can't get this extension to work at all. I've gotten the database in place, have altered the LocalSettings file, however when when the extension is on, I cannot edit any entries in the database. I get a string of error messages on the page when I try to save an edit. Has anyone had this problem before? Can you help fix it if I send the error string?--Lpasquale 15:49, 4 June 2010 (UTC)
Answer: Well, I can't promise I'll have the time. But yes, fell free to send the error message.
Bug fixes
editHi, I was just starting to use this extension and ran into a few bugs with it. I can't see an easy way of getting in contact with the author, so I'm adding the patch to the extension here below, hopefully this will be of use to someone.
The bugfixes are:
- Correct the comment for Indonesian in the i18n file
- Use Database::tableName to add table name prefixes to the "taxonomy" table if necessary
- Correct output of wfTaxonomySaveCompleteHook if the view mode is set to "hide"
- Correct the regex in wfTaxonomySaveCompleteHook to correctly detect the taxonomy-tree element when if there are attributes defined
Code
editTaxonomy.php.diff
editIndex: Taxonomy.php =================================================================== --- Taxonomy.php (revision 956) +++ Taxonomy.php (working copy) @@ -75,15 +75,18 @@ // called whe an article is saved function wfTaxonomySaveCompleteHook(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, $flags) { + + // if not in the TAXONOMY namespace, don't bother $namespace = $article->mTitle->getNamespace(); //debug("SaveCompleteHook " . $article->getTitle() . "(" . $namespace . ")" . NS_TAXONOMY); if (($namespace !== NS_TAXONOMY) && ($namespace !== NS_CATEGORY)) return true; + // search for a <taxonomy-tree> tag // a category article may contain only one taxonomy-tree tag - $pattern = '@<taxonomy-tree>(.*?)</taxonomy-tree>@is'; + $pattern = '@<taxonomy-tree[^>]+>(.*?)</taxonomy-tree>@is'; if (preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE)) { // found one, lets make a taxonomy $text = $matches[1][0]; @@ -107,10 +110,9 @@ $show = 'hide'; switch ($show) { - case 'hide' : break; + case 'hide' : return ""; default: return TaxonomyTreeRenderer::renderDefault($input, $parser); } - return true; } @@ -419,7 +421,7 @@ static function getTaxonomy($dbr, $page_id, $category) { $sql = "SELECT tax_page, tax_category, tax_parent, tax_left, tax_right, cat_title as category " . - "FROM taxonomy INNER JOIN category " . + "FROM " . $dbr->tableName('taxonomy') . " INNER JOIN category " . "ON (tax_category = cat_id) " . "WHERE (cat_title = '$category') AND (tax_page=$page_id) " . "LIMIT 1"; @@ -440,7 +442,8 @@ "FROM page " . "INNER JOIN categorylinks ON page_id = cl_from " . "INNER JOIN category ON cl_to = cat_title " . - "INNER JOIN taxonomy ON cat_id = tax_category " . + "INNER JOIN " . $dbr->tableName('taxonomy') + . " ON cat_id = tax_category " . "WHERE (tax_page=$root_id) AND (tax_left>$tax_left) AND (tax_right<$tax_right) " . "AND (page_namespace=$namespace) AND (page_is_redirect=0) " . "ORDER BY page_touched $sort " . @@ -464,7 +467,8 @@ "FROM page " . "INNER JOIN categorylinks ON page_id = cl_from " . "INNER JOIN category ON cl_to = cat_title " . - "INNER JOIN taxonomy ON cat_id = tax_category " . + "INNER JOIN " . $dbr->tableName('taxonomy') + . " ON cat_id = tax_category " . "WHERE (tax_page=$root_id) AND (tax_left>$tax_left) AND (tax_right<$tax_right) " . "AND (page_namespace=$namespace) AND (page_is_redirect=0) " . "ORDER BY page_counter $sort " .
Taxonomy.i18n.php.diff
editIndex: Taxonomy.i18n.php =================================================================== --- Taxonomy.i18n.php (revision 956) +++ Taxonomy.i18n.php (working copy) @@ -20,7 +20,7 @@ 'taxonomy-no-article' => 'no article in this taxonomy', ); -/** English +/** Indonesian * @author Eko M. Budi */ $messages['id'] = array(