|
/SW/business/KnowledgeTree:
Installing a New KnowledgeTree instance
If this is a first install on a new server, this guide[1] is a must read. Some of the highlights:
apt-get install apache2 php5 php5-curl php5-mysql mysql-server mysql-client xpdf zip unzip catdoc pstotext
apt-get install python-reportlab python-imaging python-uno antiword sun-java5-jre sun-java5-bin lynx openoffice.org-java
And do not forget to bump memory_limit up to at least 64 in /etc/php5/apache2/php.ini.
Get the latest source tarball from here[2][3].
In your desired web root, make a copy of knowledgetree for this instance, then sim link a simpler name, ie.
tar -xvf ktdms-src-oss-3.5.4a.tgz mv kt-dms-oss/ kt-dms-oss-3.5.4a ln -s kt-dms-oss-3.5.4a/ knowledgetree
Give ownership to the web server process:
chown -R www-data:www-data kt-dms-oss-3.5.4aCreate a new MySQL database for the new instance:
# mysql -u root -p Enter password: mr4gvc7s mysql> create database apps_kt; mysql> grant all on apps_kt.* to 'apps_kt'@'%' identified by 'password'; flush privileges;
Edit config/config.ini to agree:
Now import the database from sql/mysql/install:dbName = apps_kt dbUser = apps_kt dbPass = password dbAdminUser = apps_kt dbAdminPass = password
Separate out the configuration and the data:mysql -u root -p apps_kt < structure.sql mysql -u root -p apps_kt < data.sql
mv knowledgetree/var/ kt-var mv knowledgetree/config/config.ini kt-config.ini cd knowledgetree ln -s ../kt-var/ var cd config/ ln -s ../../kt-config.ini config.ini
Now login to the new KnowledgeTree instance with the default:
user: admin password: admin
and change the admin password.
Anticipated path for upgrading to a new version of Knowledgetree:
[1] http://wiki.knowledgetree.com/Debian_4_Installation_Instructions#Grab_a_few_more_packages
[2] http://www.knowledgetree.com/try-now/knowledgetree_open_source_download
[3] http://www.knowledgetree.com/products/opensource/downloadopensource
posted at: 12:46 | path: /SW/business/KnowledgeTree | permanent link to this entry
/SW/business/KnowledgeTree:
Metadata and the KnowledgeTree REST API
The only way I have personally been able to get this working is by patching KnowledgeTree. The problem is that there is a function get_packed_metadata in ktapi/KTAPIDocument.inc.php that expects to receive metadata in the form of an array. There is no way to pass an array through a URL as a POST parameter using PHP (at least, none that I have yet found....)
What I have found is that the PHP serialize() / unserialize() functions are meant to get this job done: serialize() the array before passing, unserialize() it after passing, and then process the array on the receiving end. So I have added this chunk of code to the top of function get_packed_metadata in ktapi/KTAPIDocument.inc.php:
if (!is_array($metadata)) { $metadata = unserialize($metadata); }
And then if I serialize my metadata array before sending it into the API, everything works. The exact structure of the metadata array was also a bit of a hard-won mystery, so I will reproduce below an actual working metadata update snippet of code:
status_code != 0 ){ echo 'Error - authentication failed: ' . $xml->message; } else { $session_id = $xml->results; echo "Login successful, session ID = " . $session_id; } // *********************************** // Update document metadata // *********************************** $metadata = array( array( "fieldset" => "Tag Cloud", "fields" => array( array( "name" => "Tag", "value" => "Tag name from API call" ) ) ) ); $metadata = serialize($metadata); $postfields = "method=update_document_metadata&session_id=$session_id&document_id=36&metadata=$metadata"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); echo " Update document metadata:
"; if( $xml->status_code != 0 ){ echo 'Error - get_document_metadata failed: ' . $xml->message; } else { echo 'Metadata updated!!'; }
I have posted on this subject to both the KnowledgeTree forum[1] and the issue tracker[2], and received just about zero response.
I have a working example of a file upload followed by an add-document-with-metadata API operation, if anyone is interested in seeing that.
[1] http://forums.knowledgetree.com/viewtopic.php?f=10&t=14291&p=31392#p31392
[2] http://issues.knowledgetree.com/browse/WSA-169
posted at: 04:03 | path: /SW/business/KnowledgeTree | permanent link to this entry
/SW/business/KnowledgeTree:
Accessing the KnowledgeTree API
KnowledgeTree[1] is a very popular server-based Open Source document management system. Something that some users (like me, or rather my clients) need to do is allow certain people to add or manipulate documents in KnowledgeTree without having to have a login ID and knowledge of the KnowledgeTree user interface. Enter the API, and a little custom PHP scripting....
Oddly enough, I found at least three different documents on the wiki[2] that seemed to talk about three different approaches to using the API. Oddly (should I say suspiciously?) because the level of detail was just enough to be interesting, but just short of being useful. Ie. for two of them, I just could not figure it out. I even saw a post on the KnowledgeTree forum asking for more detail / a concrete example (me too! me too!) and the only reply was a curt link to one of the near useless wiki pages that I have already mentioned. And needless to say, my own post was ignored. Whats up? (Some conspiratorial possibilities come to mind....)
The only API approach that I have been able to get working is the "REST web service framework"[3], which, for better or worse, only works as of the currently bleeding edge KnowledgeTree version 3.6.0 (will NOT work with current stable 3.5.4a). [3] is also sorely lacking in detail, but in combination with a little code surfing in
knowledgetree/ktwebservice/webservice.php
I was able to divine what was needed to get it working. Here I will hopefully provide some missing detail for Google to find....
One can of course play with the KnowledgeTree REST web service through a browser, as the means of communication with the server is via POST parameters attached to the server URL. This is also a good way to see the exact format of the XML response the server gives back.
To achieve the same result with PHP one must use libcurl through the PHP curl extension[4]. Since [4] is also a little skimpy on detail, [5] is a very useful supplement. To cut to the chase, I created a function as follows:
$site is the REST URL of the KnowledgeTree server, and $fields are the POST parameters that are to go along with it. This function simply POSTs these parameters to the URL (exactly the same as entering $site?$fields into your web browser).
Here is a concrete and currently working example of how to get the contents of the KnowledgeTree root directory:
status_code != 0 ){ echo 'Error - authentication failed: ' . $xml->message; } else { $session_id = $xml->results; echo "Login successful, session ID = " . $session_id; } // *********************************** // List contents of root folder (id=1) // *********************************** $postfields = "method=get_folder_contents&session_id=$session_id&folder_id=1"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); echo " Get root folder contents:
"; if( $xml->status_code != 0 ){ echo 'Error - get_folder_contents failed: ' . $xml->message; } else { // print_r($xml); // to see data structure echo "folder ID = " . $xml->results->folder_id . "
"; echo "folder name = " . $xml->results->folder_name . "
"; echo "folder path = " . $xml->results->full_path . ""; foreach ($xml->results->items->item as $value) { echo "item type = " . $value->item_type . " "; echo "item ID = " . $value->id . " "; echo "item name = " . $value->filename . "
"; } } // *********************************** // Logout // *********************************** $postfields = "method=logout&session_id=$session_id"; $response = curlPost($url, $postfields); $xml = new SimpleXMLElement($response); echo "Logging out....
"; if( $xml->status_code != 0 ){ echo 'Error - get_folder_contents failed: ' . $xml->message; } else { echo 'successful!'; } ?>
The key point is that there were three operations in the above script, with three corresponding POST strings:
Operation POST string Login login&password=123456&username=admin List Directory get_folder_contents&session_id=$session_id&folder_id=1 Logout method=logout&session_id=$session_id
And something else that is already working -- to add a document to KnowledgeTree, use this POST string:
$document = "bodybg.jpg"; // located in /var/uploads$postfields = "method=add_document&session_id=$session_id&folder_id=1&title=$document&filename=$document&documenttype=Default&tempfilename=/vol/www/vsc/apps/kt-dms-oss-3.6.0/var/uploads/$document";
[1] http://www.knowledgetree.com/
[2] http://wiki.knowledgetree.com/
[3] http://wiki.knowledgetree.com/REST_Web_Service
[4] http://php.net/manual/en/book.curl.php
[5] http://devzone.zend.com/article/1081-Using-cURL-and-libcurl-with-PHP
posted at: 05:08 | path: /SW/business/KnowledgeTree | permanent link to this entry
/SW/business/KnowledgeTree:
Upgrading KnowledgeTree
Per this link http://wiki.knowledgetree.com/Upgrading_KnowledgeTree it is exceedingly simple. Here is the way I do it (unpacking into a new directory each time, not unpacking over top of the old version):
Make sure ownership is correct for the new version:
chown -R www-data:www-data kt-3.6.0/
Then bring up the login dialog, and add "setup/upgrade.php" to the end of the browser URL, for example:
https://apps.vancouversolidcomputing.com/knowledgetree/setup/upgrade.php
Click the "Next" button a hand full of times and it should just work.
posted at: 12:32 | path: /SW/business/KnowledgeTree | permanent link to this entry
/SW/business/KnowledgeTree:
Adding a Chinese Language Pack Plugin to Knowledgetree
This was really quite unnecessarily hard to find. Turns out they are found on the KnowledgeTree Forge[1], and here[2] is the list. There are actually two Simplified Chinese packs, this one[3] seemed more official so that is what I downloaded[4].
Installation is then quite simple. Move the downloaded tarball into knowledgetree/plugins/i18n and then untar it, ie.
tar -xvf SimplifiedChinese.tgz
You should then see a "SimplifiedChinese" sub-directory appear under i18n, and in my experience the plugin should activate automatically, ie. if you now go to the Knowledgetree login dialog "Simplified Chinese" should appear in the language drop-down menu. If it does not, login as a Knowledgetree admin and go to
Administration » Miscellaneous » Plugins
where you might have to hit the "Reread Plugins" button at the bottom, or click on the "Simplified Chinese Translation" check box to activate it.
[1] http://forge.knowledgetree.com/
[2] http://forge.knowledgetree.com/gf/project/?action=ProjectTroveBrowse&_trove_category_id=306
[3] http://forge.knowledgetree.com/gf/project/zhcn/
[4] http://forge.knowledgetree.com/gf/project/zhcn/frs/
posted at: 10:23 | path: /SW/business/KnowledgeTree | permanent link to this entry
/SW/business/KnowledgeTree:
How to Move Knowledgetree
Knowledgetree is Document Management software, so not only does it store things in MySQL, but it also stores a lot in the file system. So one cannot move a KnowledgeTree (KT) instance to a different directory and expect it to just continue working. In fact, it normally does not.
So first step: make a good backup both of the web root directory and the MySQL database.
Then the trick, tipped-off to me courtesy of a forum[1], is to go through the (quite simple) upgrade process by running, for instance
http://ofri.vancouversolidcomputing.com/knowledgetree/setup/upgrade.php
The first prompt is for the admin userid and password of the KT instance (not the MySQL password).
After that, just click through the "Next" button on several screens, and finally you will be presented with a login dialog. All done.
[1] http://forums.knowledgetree.com/viewtopic.php?t=1670
posted at: 05:58 | path: /SW/business/KnowledgeTree | permanent link to this entry