@@ -123,7 +123,7 @@ public function getVanishedFiles() {
123
123
return $ list ;
124
124
}
125
125
126
- public function export () {
126
+ public function export ($ collapse = false ) {
127
127
if (count ($ this ->collection ) == 0 ) {
128
128
return $ this ->workDom ;
129
129
}
@@ -150,10 +150,13 @@ public function export() {
150
150
}
151
151
152
152
$ this ->collection = array ();
153
+
154
+ if ($ collapse ) {
155
+ $ this ->collapseDirectory ();
156
+ }
153
157
return $ this ->workDom ;
154
158
}
155
159
156
-
157
160
private function importDirNode (fDOMElement $ dir , $ path ) {
158
161
$ path .= $ dir ->getAttribute ('name ' );
159
162
foreach ($ dir ->query ('phpdox:file ' ) as $ file ) {
@@ -173,6 +176,20 @@ private function isChanged($path) {
173
176
return $ org ->getAttribute ('sha1 ' ) != $ new ->getAttribute ('sha1 ' );
174
177
}
175
178
179
+ private function collapseDirectory () {
180
+ $ first = $ this ->workDom ->queryOne ('/phpdox:source/phpdox:dir ' );
181
+ if ($ first ->query ('phpdox:file ' )->length == 0 &&
182
+ $ first ->query ('phpdox:dir ' )->length == 1 ) {
183
+ $ dir = $ first ->queryOne ('phpdox:dir ' );
184
+ foreach ($ dir ->query ('* ' ) as $ child ) {
185
+ $ first ->appendChild ($ child );
186
+ }
187
+ $ first ->setAttribute ('name ' , $ first ->getAttribute ('name ' ) . '/ ' . $ dir ->getAttribute ('name ' ));
188
+ $ first ->removeChild ($ dir );
189
+ $ this ->collapseDirectory ();
190
+ }
191
+ }
192
+
176
193
}
177
194
178
195
0 commit comments