A minimal CAKEPHP application is provided with the sources (/usr/share/mediatex/useCases/cake.tgz), showing how to use the MEDIATEX system as a storage layer.
Notice: Not tested for a while
There are only 4 interactions from the CAKE’s models and view:
Add a user
function beforeSave() { $cmd = "/var/www/cake/ingest.sh user ". $this->data['User']['username']." ". $this->data['User']['passwd']; system($cmd, $retval); return ($retval == 0); }
Add a directory or a file
function beforeSave() { $father = $this->find('first', array('conditions' => array('Node.id' => $this->data['Node']['node_id']))); switch($this->data['Node']['type']) { case 1: $cmd = "/var/www/cake/ingest.sh dir ". $this->data['Node']['name']." ". $father['Node']['name']; break; case 2: … $cmd = "/var/www/cake/ingest.sh file ". $this->data['Node']['username']." ". $this->data['Node']['name']." ". $father['Node']['name']." ". $path; break; … } system($cmd, $retval); return ($retval == 0); }
CAKE view points on the MEDIATEX URL.
… echo $html->link($fils['name'], 'https://HOSTNAME/~mdtx-cake/cgi/get.cgi'. $fils['url']); …
The cake/ingest.sh manage theses 3 ingestion’s actions
function addUser() { CYPHER=$(printf "$LOGIN:$COLLECTION:$PASSWD" | md5sum | cut -d' ' -f1) LINE="$LOGIN:$COLLECTION:$CYPHER" echo $LINE >> $PWD_FILE sed $GRP_FILE -i -e "s/^\(.*\)$/\1 $LOGIN/" cat >>$CAT_FILE <<EOF Human "$LOGIN" "" EOF } function addDir() { cat >>$CAT_FILE <<EOF top Category "$NAME": "$FATHER" EOF mediatex upgrade coll $COLL } function addFile() { HASH=$(md5sum $TEMP | cut -d' ' -f1) SIZE=$(ls -l $TEMP | awk '{print $5}') mediatex upload $TEMP to coll $COLL cat >>$CAT_FILE <<EOF Document "$NAME": "$FATHER" with "uploader" = "$LOGIN" "" $HASH:$SIZE EOF mediatex upgrade coll $COLL }
To be fully operational, this implementation lakes a process to recover the database from MEDIATEX. This is the purpose of the following section.