Method for update one metadata value added,

method for return one metadata value modified.
This commit is contained in:
tomas 2005-02-07 23:14:51 +00:00
parent 6b77fe7537
commit 7590bbaa49
2 changed files with 58 additions and 12 deletions

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.25 $ Version : $Revision: 1.26 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -52,7 +52,7 @@ require_once "Transport.php";
* Core of LiveSupport file storage module * Core of LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.25 $ * @version $Revision: 1.26 $
* @see Alib * @see Alib
*/ */
class BasicStor extends Alib{ class BasicStor extends Alib{
@ -602,15 +602,36 @@ class BasicStor extends Alib{
* *
* @param id int, virt.file's local id * @param id int, virt.file's local id
* @param category string, metadata element name * @param category string, metadata element name
* @return array of matching records * @param lang string, optional xml:lang value for select language version
* @return array of matching records (as hash {id, value, attrs})
* @see Metadata::getMetadataValue
*/ */
function bsGetMetadataValue($id, $category) function bsGetMetadataValue($id, $category, $lang=NULL)
{ {
require_once "DataEngine.php"; $ac =& StoredFile::recall($this, $id);
$de =& new DataEngine($this); return $ac->md->getMetadataValue($category, $lang);
return $de->getMetadataValue($id, $category);
} }
/**
* Set metadata element value
*
* @param id int, virt.file's local id
* @param category string, metadata element identification (e.g. dc:title)
* @param value string/NULL value to store, if NULL then delete record
* @param lang string, optional xml:lang value for select language version
* @param mid int, metadata record id (OPTIONAL on unique elements)
* @return boolean
*/
function bsSetMetadataValue($id, $category, $value, $lang=NULL, $mid=NULL)
{
$ac =& StoredFile::recall($this, $id);
$res = $ac->md->setMetadataValue($category, $value, $lang, $mid);
if(PEAR::isError($res)) return $res;
$r = $ac->md->regenerateXmlFile();
if(PEAR::isError($r)) return $r;
return $res;
}
/** /**
* Search in local metadata database. * Search in local metadata database.
* *

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.28 $ Version : $Revision: 1.29 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -35,7 +35,7 @@ require_once "BasicStor.php";
* LiveSupport file storage module * LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.28 $ * @version $Revision: 1.29 $
* @see BasicStor * @see BasicStor
*/ */
class GreenBox extends BasicStor{ class GreenBox extends BasicStor{
@ -232,13 +232,38 @@ class GreenBox extends BasicStor{
* @param id int, virt.file's local id * @param id int, virt.file's local id
* @param category string, metadata element name * @param category string, metadata element name
* @param sessid string, session id * @param sessid string, session id
* @return array of matching records * @param lang string, optional xml:lang value for select language version
* @return array of matching records as hash with fields:
* <ul>
* <li>mid int, local metadata record id</li>
* <li>value string, element value</li>
* <li>attrs hasharray of element's attributes indexed by
* qualified name (e.g. xml:lang)</li>
* </ul>
*/ */
function getMdataValue($id, $category, $sessid='') function getMdataValue($id, $category, $sessid='', $lang=NULL)
{ {
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE) if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
return $res; return $res;
return $this->bsGetMetadataValue($id, $category); return $this->bsGetMetadataValue($id, $category, $lang);
}
/**
* Set metadata element value
*
* @param id int, virt.file's local id
* @param category string, metadata element identification (e.g. dc:title)
* @param sessid string, session id
* @param value string/NULL value to store, if NULL then delete record
* @param lang string, optional xml:lang value for select language version
* @param mid int, metadata record id (OPTIONAL on unique elements)
* @return boolean
*/
function setMdataValue($id, $category, $sessid='', $value, $lang=NULL, $mid=NULL)
{
if(($res = $this->_authorize('write', $id, $sessid)) !== TRUE)
return $res;
return $this->bsSetMetadataValue($id, $category, $value, $lang, $mid);
} }
/** /**