Index: trunk/extensions/SemanticInternalObjects/SemanticInternalObjects_body.php |
— | — | @@ -57,19 +57,29 @@ |
58 | 58 | $io_id = $this->makeSMWPageID( $internal_object->getName(), $namespace, '' ); |
59 | 59 | $up_rels2 = array(); |
60 | 60 | $up_atts2 = array(); |
| 61 | + $up_text2 = array(); |
61 | 62 | // set all the properties pointing from this internal object |
62 | 63 | foreach ( $internal_object->property_value_pairs as $property_value_pair ) { |
63 | 64 | list( $property, $value ) = $property_value_pair; |
64 | | - $mode = SMWSQLStore2::getStorageMode( $property->getPropertyTypeID() ); |
65 | | - switch ( $mode ) { |
66 | | - case SMW_SQL2_RELS2: |
| 65 | + // handling changed in SMW 1.5 |
| 66 | + if (method_exists('SMWSQLStore2', 'findPropertyTableID')) { |
| 67 | + $tableid = SMWSQLStore2::findPropertyTableID( $property ); |
| 68 | + $is_relation = ($tableid == 'smw_rels2'); |
| 69 | + $is_attribute = ($tableid == 'smw_atts2'); |
| 70 | + $is_text = ($tableid == 'smw_text2'); |
| 71 | + } else { |
| 72 | + $mode = SMWSQLStore2::getStorageMode( $property->getPropertyTypeID() ); |
| 73 | + $is_relation = ($mode == SMW_SQL2_RELS2); |
| 74 | + $is_attribute = ($mode == SMW_SQL2_ATTS2); |
| 75 | + $is_text = ($mode == SMW_SQL2_TEXT2); |
| 76 | + } |
| 77 | + if ($is_relation) { |
67 | 78 | $up_rels2[] = array( |
68 | 79 | 's_id' => $io_id, |
69 | 80 | 'p_id' => $this->makeSMWPropertyID( $property ), |
70 | 81 | 'o_id' => $this->makeSMWPageID( $value->getDBkey(), $value->getNamespace(), $value->getInterwiki() ) |
71 | 82 | ); |
72 | | - break; |
73 | | - case SMW_SQL2_ATTS2: |
| 83 | + } elseif ($is_attribute) { |
74 | 84 | $keys = $value->getDBkeys(); |
75 | 85 | $up_atts2[] = array( |
76 | 86 | 's_id' => $io_id, |
— | — | @@ -78,10 +88,16 @@ |
79 | 89 | 'value_xsd' => $keys[0], |
80 | 90 | 'value_num' => $value->getNumericValue() |
81 | 91 | ); |
82 | | - break; |
| 92 | + } elseif ($is_text) { |
| 93 | + $keys = $value->getDBkeys(); |
| 94 | + $up_text2[] = array( |
| 95 | + 's_id' => $io_id, |
| 96 | + 'p_id' => $this->makeSMWPropertyID($property), |
| 97 | + 'value_blob' => $keys[0] |
| 98 | + ); |
83 | 99 | } |
84 | 100 | } |
85 | | - return array( $up_rels2, $up_atts2 ); |
| 101 | + return array( $up_rels2, $up_atts2, $up_text2 ); |
86 | 102 | } |
87 | 103 | } |
88 | 104 | |
— | — | @@ -136,10 +152,12 @@ |
137 | 153 | |
138 | 154 | $all_rels2_inserts = array(); |
139 | 155 | $all_atts2_inserts = array(); |
| 156 | + $all_text2_inserts = array(); |
140 | 157 | foreach (self::$internal_objects as $internal_object) { |
141 | | - list($up_rels2, $up_atts2) = $sio_sql_store->getStorageSQL($page_name, $namespace, $internal_object); |
| 158 | + list($up_rels2, $up_atts2, $up_text2) = $sio_sql_store->getStorageSQL($page_name, $namespace, $internal_object); |
142 | 159 | $all_rels2_inserts = array_merge($all_rels2_inserts, $up_rels2); |
143 | 160 | $all_atts2_inserts = array_merge($all_atts2_inserts, $up_atts2); |
| 161 | + $all_text2_inserts = array_merge($all_text2_inserts, $up_text2); |
144 | 162 | } |
145 | 163 | |
146 | 164 | // now save everything to the database |
— | — | @@ -149,6 +167,7 @@ |
150 | 168 | $ids_string = '(' . implode (', ', $ids_for_deletion) . ')'; |
151 | 169 | $db->delete('smw_rels2', array("(s_id IN $ids_string) OR (o_id IN $ids_string)"), 'SIO::deleteRels2Data'); |
152 | 170 | $db->delete('smw_atts2', array("s_id IN $ids_string"), 'SIO::deleteAtts2Data'); |
| 171 | + $db->delete('smw_text2', array("s_id IN $ids_string"), 'SIO::deleteText2Data'); |
153 | 172 | } |
154 | 173 | |
155 | 174 | if (count($all_rels2_inserts) > 0) { |
— | — | @@ -157,6 +176,9 @@ |
158 | 177 | if (count($all_atts2_inserts) > 0) { |
159 | 178 | $db->insert( 'smw_atts2', $all_atts2_inserts, 'SIO::updateAtts2Data'); |
160 | 179 | } |
| 180 | + if (count($all_text2_inserts) > 0) { |
| 181 | + $db->insert( 'smw_text2', $all_text2_inserts, 'SIO::updateText2Data'); |
| 182 | + } |
161 | 183 | $db->commit('SIO::updatePageData'); |
162 | 184 | self::$internal_objects = array(); |
163 | 185 | return true; |