@@ -149,11 +149,15 @@ public function _render($tpl = '')
149149 }
150150
151151 if (isset ($ item [$ date ])) {
152+ if (!$ item [$ date ] && $ date == 'pub_date ' && isset ($ item ['createdon ' ])) {
153+ $ date = 'createdon ' ;
154+ }
152155 $ _date = is_numeric ($ item [$ date ]) && $ item [$ date ] == (int )$ item [$ date ] ? $ item [$ date ] : strtotime ($ item [$ date ]);
153156 if ($ _date !== false ) {
154157 $ _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 );
157161 }
158162 }
159163 }
@@ -205,7 +209,6 @@ public function getJSON($data, $fields, $array = array())
205209 $ out = array ();
206210 $ fields = is_array ($ fields ) ? $ fields : explode (", " , $ fields );
207211 $ date = $ this ->getCFGDef ('dateSource ' , 'pub_date ' );
208-
209212 /**
210213 * @var $extSummary summary_DL_Extender
211214 */
@@ -221,22 +224,27 @@ public function getJSON($data, $fields, $array = array())
221224 */
222225 $ extE = $ this ->getExtender ('e ' , true , true );
223226
224- foreach ($ data as $ num => $ item ) {
225- $ row = $ item ;
227+ foreach ($ data as $ num => $ row ) {
226228 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 ' );
228230 }
231+
229232 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 ]);
232238 if ($ _date !== false ) {
233239 $ _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 );
236243 }
237244 }
238245 }
239246 }
247+
240248 if (array ('1 ' ) == $ fields || in_array (array ('menutitle ' , 'pagetitle ' ), $ fields )) {
241249 $ row ['title ' ] = ($ row ['menutitle ' ] == '' ? $ row ['pagetitle ' ] : $ row ['menutitle ' ]);
242250 }
@@ -340,11 +348,11 @@ public function getChildrenCount()
340348 if (trim ($ where ) == 'WHERE ' ) {
341349 $ where = '' ;
342350 }
343- $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , 'c.id ' ));
351+ $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
344352 $ sort = $ this ->SortOrderSQL ("if(c.pub_date=0,c.createdon,c.pub_date) " );
345353 list ($ from ) = $ this ->injectSortByTV ($ from , $ sort );
346354
347- $ q_true = $ q_true ? $ q_true : $ group != 'GROUP BY c.id ' ;
355+ $ q_true = $ q_true ? $ q_true : $ group != '' ;
348356
349357 if ( $ q_true ){
350358 $ rs = $ this ->dbQuery ("SELECT count(*) FROM (SELECT count(*) FROM {$ from } {$ where } {$ group }) as `tmp` " );
@@ -395,7 +403,7 @@ protected function getDocList()
395403
396404
397405 $ fields = $ this ->getCFGDef ('selectFields ' , 'c.* ' );
398- $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , 'c.id ' ));
406+ $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
399407 $ sort = $ this ->SortOrderSQL ("if(c.pub_date=0,c.createdon,c.pub_date) " );
400408 list ($ tbl_site_content , $ sort ) = $ this ->injectSortByTV ($ tbl_site_content . ' ' . $ this ->_filters ['join ' ],
401409 $ sort );
@@ -520,7 +528,7 @@ protected function getChildrenList()
520528 $ where = '' ;
521529 }
522530 $ fields = $ this ->getCFGDef ('selectFields ' , 'c.* ' );
523- $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , 'c.id ' ));
531+ $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
524532
525533 if ($ sanitarInIDs != "'' " || $ this ->getCFGDef ('ignoreEmpty ' , '0 ' )) {
526534 $ sql = $ this ->dbQuery ("SELECT {$ fields } FROM " . $ from . " " . $ where . " " .
0 commit comments