Source for file ResAlt.php

Documentation is available at ResAlt.php

  1. <?PHP
  2. // ----------------------------------------------------------------------------------
  3. // Class: ResAlt
  4. // ----------------------------------------------------------------------------------
  5.  
  6.  
  7.  
  8. /**
  9. * This interface defines methods for accessing RDF Alternative resources.
  10. * These methods operate on the RDF statements contained in a model.
  11. *
  12. * <BR><BR>History:<UL>
  13. * <LI>10-01-2004 : First version of this class.</LI>
  14. *
  15. * @version V0.9.1
  16. * @author Daniel Westphal <mail at d-westphal dot de>
  17. *
  18. * @package resModel
  19. * @access public
  20. ***/
  21. class ResAlt extends ResContainer
  22. {
  23. /**
  24. * Constructor
  25. * You can supply a URI
  26. *
  27. * @param string $uri
  28. * @access public
  29. */
  30. function ResAlt($uri = null)
  31. {
  32. parent::ResContainer($uri);
  33. $this->containerType=new ResResource(RDF_NAMESPACE_URI.RDF_ALT);
  34. }
  35. /**
  36. * Return the default value for this resource
  37. *
  38. * @return object ResResource/ResLiteral
  39. * @access public
  40. */
  41. function getDefault()
  42. {
  43. //get the first memeber
  44. $statements=$this->listProperties($this->_getMembershipPropertyWithIndex(1));
  45. if(isset($statements[0]))
  46. {
  47. //return the value
  48. return $statements[0]->getObject();
  49. } else
  50. {
  51. return null;
  52. }
  53. }
  54. /**
  55. * Set the default value of this container.
  56. *
  57. * @param object ResResource/ResLiteral $object
  58. * @access public
  59. */
  60. function setDefault($object)
  61. {
  62. //remember the old default value
  63. $oldDefaultObject=$this->getDefault();
  64. //if there wasn't a default value before
  65. if($oldDefaultObject === null)
  66. {
  67. //add the new value
  68. $this->addProperty($this->_getMembershipPropertyWithIndex(1),$object);
  69. } else
  70. {
  71. //remove the old value
  72. $this->removeAll($this->_getMembershipPropertyWithIndex(1));
  73. //set the new value
  74. $this->addProperty($this->_getMembershipPropertyWithIndex(1),$object);
  75. //add the old default value at the end
  76. $this->add($oldDefaultObject);
  77. }
  78. }
  79. }
  80. ?>

Documentation generated on Fri, 17 Dec 2004 16:17:45 +0100 by phpDocumentor 1.3.0RC3