Index: trunk/extensions/Wikidata/OmegaWiki/RecordSet.php |
— | — | @@ -10,6 +10,7 @@ |
11 | 11 | public function getKey(); |
12 | 12 | public function getRecordCount(); |
13 | 13 | public function getRecord($index); |
| 14 | + # public function save(); # <- we first need to implement, then uncomment |
14 | 15 | } |
15 | 16 | |
16 | 17 | class ArrayRecordSet implements RecordSet { |
— | — | @@ -53,8 +54,30 @@ |
54 | 55 | * @return carriage return separated list of values |
55 | 56 | */ |
56 | 57 | public function __tostring() { |
57 | | - return implode("\n",$this->records); |
| 58 | + return $this->tostring_indent(); |
58 | 59 | } |
| 60 | + |
| 61 | + public function tostring_indent($depth=0,$key="") { |
| 62 | + $rv="\n".str_pad("",$depth*8); |
| 63 | + $rv.="$key:ArrayRecordSet {"; |
| 64 | + $rv2=$rv; |
| 65 | + foreach ($this->records as $value) { |
| 66 | + $rv=$rv2; |
| 67 | + $methods=get_class_methods(get_class($value)); |
| 68 | + if (!is_null($methods)) { |
| 69 | + if (in_array("tostring_indent",$methods)) { |
| 70 | + $value=$value->tostring_indent($depth+1); |
| 71 | + } |
| 72 | + } |
| 73 | + $rv.="$value"; |
| 74 | + |
| 75 | + $rv2=$rv; |
| 76 | + $rv2.=", "; |
| 77 | + } |
| 78 | + $rv.="}"; |
| 79 | + |
| 80 | + return $rv; |
| 81 | + } |
59 | 82 | } |
60 | 83 | |
61 | 84 | class ConvertingRecordSet implements RecordSet { |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | require_once('Transaction.php'); |
9 | 9 | require_once('WikiDataTables.php'); |
10 | 10 | require_once('RecordSetQueries.php'); |
| 11 | +require_once('DefinedMeaningModel.php'); |
11 | 12 | |
12 | 13 | function getSynonymSQLForLanguage($languageId, &$definedMeaningIds) { |
13 | 14 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -59,8 +59,33 @@ |
60 | 60 | * @return comma-separated values |
61 | 61 | */ |
62 | 62 | public function __tostring() { |
63 | | - return implode(",",$this->values); |
| 63 | + return $this->tostring_indent(); |
64 | 64 | } |
| 65 | + |
| 66 | + public function tostring_indent($depth=0,$key="") { |
| 67 | + $rv="\n".str_pad("",$depth*8); |
| 68 | + $rv.="$key:Record {"; |
| 69 | + $rv2=$rv; |
| 70 | + foreach ($this->values as $key=>$value) { |
| 71 | + $rv=$rv2; |
| 72 | + $methods=get_class_methods(get_class($value)); |
| 73 | + $repr="$key:$value"; |
| 74 | + if (!is_null($methods)) { |
| 75 | + if (in_array("tostring_indent",$methods)) { |
| 76 | + $repr=$value->tostring_indent($depth+1,$key); |
| 77 | + |
| 78 | + |
| 79 | + } |
| 80 | + } |
| 81 | + $rv.=$repr; |
| 82 | + |
| 83 | + $rv2=$rv; |
| 84 | + $rv2.=", "; |
| 85 | + } |
| 86 | + $rv.="}"; |
| 87 | + return $rv; |
| 88 | + } |
| 89 | + |
65 | 90 | } |
66 | 91 | |
67 | 92 | function project($record, $structure) { |