Changeset 35
- Timestamp:
- Jul 15, 2011, 2:51:52 PM (14 years ago)
- Location:
- php/trunk/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
php/trunk/classes/rdfa_Data.php
r30 r35 794 794 * Sets a property value for a subject. 795 795 * 796 * \param subject Subject to get the property set 797 * \param property Property to be added 798 * \param value Value to be set for the property 796 * \param subject Subject to get the property set as URI or CURIE 797 * \param property Property to be added as URI or CURIE 798 * \param value Value to be set for the property as URI, CURIE or literal value 799 799 * \param type The type of the value, either 'uri', 'literal' or 'bnode' 800 800 * (case-insensitive). Specifying the first character is sufficient. 801 801 * If not specified, strings starting with 'http://' are taken as a URI, 802 * otherwise as a literal802 * strings starting with '_:' as a blank node, otherwise as a literal 803 803 * \retval boolean true: property value set \n 804 804 * false: subject not found or invalid value type specified … … 813 813 $predicate = $property; 814 814 $object = $value; 815 816 // insert code here817 815 818 return $result; 816 // resolve namespace prefixes 817 $uriSubject = $this->_resolve( $subject); 818 $uriPredicate = $this->_resolve( $predicate); 819 $uriObject = $this->_resolve( $object); 820 821 // resolve method may return NULL, then use original value 822 $uriSubject = ($uriSubject === NULL) ? $subject : $uriSubject; 823 $uriPredicate = ($uriPredicate === NULL) ? $predicate : $uriPredicate; 824 $uriObject = ($uriObject === NULL) ? $object : $uriObject; 825 826 // check what type we have 827 // This is not clear in the API. It could be interpreted that the only acceptable value is a literal 828 // We have to check what the intention is and adjust it accordingly or enhance the specs 829 if ($type == null) { 830 if (preg_match('#^http://.?#', $value)) 831 $type = 'uri'; 832 elseif (preg_match('#/^_:.?/#', $value)) 833 $type = 'bnode'; 834 else 835 $type = 'literal'; 836 } 837 838 if (!preg_match('#^(uri|bnode|literal)$#', strtolower($type))) 839 return false; 840 841 // construct the aTriple array 842 $aTriple = array(); 843 $aTriple['type'] = 'triple'; 844 $aTriple['s'] = $uriSubject; 845 $aTriple['p'] = $uriPredicate; 846 $aTriple['o'] = $uriObject; 847 $aTriple['s_type'] = 'uri'; 848 $aTriple['p_type'] = 'uri'; 849 $aTriple['o_type'] = strtolower($type); 850 851 $aTriple['o_datatype'] = ''; // data types, currently not supported by the API 852 $aTriple['o_lang'] = ''; // language, same same 853 854 855 $this->_addTriple( $aTriple); 856 857 return true; 819 858 820 859 } // public function _setValue … … 1089 1128 1090 1129 } // public function _serialize 1130 1091 1131 1092 1132 } // class Data -
php/trunk/classes/rdfa_Projection.php
r30 r35 177 177 * \retval boolean false: invalid value type specified 178 178 * 179 * \see rdfa::Data:: setValue179 * \see rdfa::Data::_setValue 180 180 * 181 181 * \note … … 185 185 186 186 public function set( $property, $value, $type = NULL) { 187 188 // insert code here 187 188 $ret = $this->rdfaData->_setValue($this->subject, $property, $value, $type ); 189 190 if($ret) 191 return $this; 192 else 193 return false; 189 194 } 190 195
Note:
See TracChangeset
for help on using the changeset viewer.