@@ -149,11 +149,15 @@ public function _render($tpl = '')
149
149
}
150
150
151
151
if (isset ($ item [$ date ])) {
152
+ if (!$ item [$ date ] && $ date == 'pub_date ' && isset ($ item ['createdon ' ])) {
153
+ $ date = 'createdon ' ;
154
+ }
152
155
$ _date = is_numeric ($ item [$ date ]) && $ item [$ date ] == (int )$ item [$ date ] ? $ item [$ date ] : strtotime ($ item [$ date ]);
153
156
if ($ _date !== false ) {
154
157
$ _date = $ _date + $ this ->modx ->config ['server_offset_time ' ];
155
- if ($ this ->getCFGDef ('dateFormat ' , '%d.%b.%y %H:%M ' ) != '' ) {
156
- $ item ['date ' ] = strftime ($ this ->getCFGDef ('dateFormat ' , '%d.%b.%y %H:%M ' ), $ _date );
158
+ $ dateFormat = $ this ->getCFGDef ('dateFormat ' , '%d.%b.%y %H:%M ' );
159
+ if ($ dateFormat ) {
160
+ $ item ['date ' ] = strftime ($ dateFormat , $ _date );
157
161
}
158
162
}
159
163
}
@@ -205,7 +209,6 @@ public function getJSON($data, $fields, $array = array())
205
209
$ out = array ();
206
210
$ fields = is_array ($ fields ) ? $ fields : explode (", " , $ fields );
207
211
$ date = $ this ->getCFGDef ('dateSource ' , 'pub_date ' );
208
-
209
212
/**
210
213
* @var $extSummary summary_DL_Extender
211
214
*/
@@ -221,22 +224,27 @@ public function getJSON($data, $fields, $array = array())
221
224
*/
222
225
$ extE = $ this ->getExtender ('e ' , true , true );
223
226
224
- foreach ($ data as $ num => $ item ) {
225
- $ row = $ item ;
227
+ foreach ($ data as $ num => $ row ) {
226
228
if ((array ('1 ' ) == $ fields || in_array ('summary ' , $ fields )) && $ extSummary ) {
227
- $ row ['summary ' ] = $ this ->getSummary ($ this -> _docs [ $ num ] , $ extSummary , 'introtext ' , 'content ' );
229
+ $ row ['summary ' ] = $ this ->getSummary ($ row , $ extSummary , 'introtext ' , 'content ' );
228
230
}
231
+
229
232
if (array ('1 ' ) == $ fields || in_array ('date ' , $ fields )) {
230
- if (isset ($ this ->_docs [$ num ][$ date ])) {
231
- $ _date = is_numeric ($ this ->_docs [$ num ][$ date ]) && $ this ->_docs [$ num ][$ date ] == (int )$ this ->_docs [$ num ][$ date ] ? $ this ->_docs [$ num ][$ date ] : strtotime ($ this ->_docs [$ num ][$ date ]);
233
+ if (isset ($ row [$ date ])) {
234
+ if (!$ row [$ date ] && $ date == 'pub_date ' && isset ($ row ['createdon ' ])) {
235
+ $ date = 'createdon ' ;
236
+ }
237
+ $ _date = is_numeric ($ row [$ date ]) && $ row [$ date ] == (int )$ row [$ date ] ? $ row [$ date ] : strtotime ($ row [$ date ]);
232
238
if ($ _date !== false ) {
233
239
$ _date = $ _date + $ this ->modx ->config ['server_offset_time ' ];
234
- if ($ this ->getCFGDef ('dateFormat ' , '%d.%b.%y %H:%M ' ) != '' ) {
235
- $ row ['date ' ] = strftime ($ this ->getCFGDef ('dateFormat ' , '%d.%b.%y %H:%M ' ), $ _date );
240
+ $ dateFormat = $ this ->getCFGDef ('dateFormat ' , '%d.%b.%y %H:%M ' );
241
+ if ($ dateFormat ) {
242
+ $ row ['date ' ] = strftime ($ dateFormat , $ _date );
236
243
}
237
244
}
238
245
}
239
246
}
247
+
240
248
if (array ('1 ' ) == $ fields || in_array (array ('menutitle ' , 'pagetitle ' ), $ fields )) {
241
249
$ row ['title ' ] = ($ row ['menutitle ' ] == '' ? $ row ['pagetitle ' ] : $ row ['menutitle ' ]);
242
250
}
@@ -340,11 +348,11 @@ public function getChildrenCount()
340
348
if (trim ($ where ) == 'WHERE ' ) {
341
349
$ where = '' ;
342
350
}
343
- $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , 'c.id ' ));
351
+ $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
344
352
$ sort = $ this ->SortOrderSQL ("if(c.pub_date=0,c.createdon,c.pub_date) " );
345
353
list ($ from ) = $ this ->injectSortByTV ($ from , $ sort );
346
354
347
- $ q_true = $ q_true ? $ q_true : $ group != 'GROUP BY c.id ' ;
355
+ $ q_true = $ q_true ? $ q_true : $ group != '' ;
348
356
349
357
if ( $ q_true ){
350
358
$ rs = $ this ->dbQuery ("SELECT count(*) FROM (SELECT count(*) FROM {$ from } {$ where } {$ group }) as `tmp` " );
@@ -395,7 +403,7 @@ protected function getDocList()
395
403
396
404
397
405
$ fields = $ this ->getCFGDef ('selectFields ' , 'c.* ' );
398
- $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , 'c.id ' ));
406
+ $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
399
407
$ sort = $ this ->SortOrderSQL ("if(c.pub_date=0,c.createdon,c.pub_date) " );
400
408
list ($ tbl_site_content , $ sort ) = $ this ->injectSortByTV ($ tbl_site_content . ' ' . $ this ->_filters ['join ' ],
401
409
$ sort );
@@ -520,7 +528,7 @@ protected function getChildrenList()
520
528
$ where = '' ;
521
529
}
522
530
$ fields = $ this ->getCFGDef ('selectFields ' , 'c.* ' );
523
- $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , 'c.id ' ));
531
+ $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
524
532
525
533
if ($ sanitarInIDs != "'' " || $ this ->getCFGDef ('ignoreEmpty ' , '0 ' )) {
526
534
$ sql = $ this ->dbQuery ("SELECT {$ fields } FROM " . $ from . " " . $ where . " " .
0 commit comments