Changeset 1745
- Timestamp:
- 05/18/08 20:44:40 (8 months ago)
- Location:
- trunk/htdocs/system
- Files:
-
- 1 added
- 6 modified
-
admin/comments.php (modified) (3 diffs)
-
admin/entries.php (modified) (3 diffs)
-
admin/js/admin.js (modified) (5 diffs)
-
admin/timeline_items.php (added)
-
classes/adminhandler.php (modified) (5 diffs)
-
classes/comments.php (modified) (3 diffs)
-
classes/posts.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htdocs/system/admin/comments.php
r1722 r1745 11 11 <div class="years"> 12 12 <div class="months"> 13 <?php foreach($monthcomments as $cdata): ?> 14 <div><span style="width: <?php echo $cdata->ct; ?>px"><?php echo date('M', mktime(0, 0, 0, $cdata->month)) ?></span></div> 15 <?php endforeach; ?> 13 <?php $theme->display( 'timeline_items' )?> 16 14 </div> 17 15 </div> … … 83 81 $.post( 84 82 '<?php echo URL::get('admin_ajax', array('context' => 'comments')) ?>', 85 'do_search=1&search=' + liveSearch.input.val() + 86 <?php 87 $vars= Controller::get_handler_vars(); 88 $out= ''; 89 $keys= array_keys($vars); 90 foreach($keys as $key) { 91 $out .= "&$key=$vars[$key]"; 92 } 93 echo '"' . $out . '"'; 94 ?>, 83 '&search=' + liveSearch.input.val() + '&limit=20', 95 84 function(json) { 96 85 $('#comments').html(json.items); 86 $('.years .months').html(json.timeline); 97 87 spinner.stop(); 98 88 itemManage.initItems(); 89 timeline.reset(); 99 90 $('.modulecore .item:first-child, ul li:first-child').addClass('first-child').show(); 100 91 $('.modulecore .item:last-child, ul li:last-child').addClass('last-child'); … … 107 98 spinner.start(); 108 99 100 var search_args= $('.search input').val(); 101 109 102 $.ajax({ 110 type: "POST",103 type: 'POST', 111 104 url: "<?php echo URL::get('admin_ajax', array('context' => 'comments')); ?>", 112 data: "offset=" + (parseInt(c) - parseInt(b)) + "&limit=" + (1 + parseInt(b) - parseInt(a)) + 113 <?php 114 $vars= Controller::get_handler_vars(); 115 $out= ''; 116 $keys= array_keys($vars); 117 foreach($keys as $key) { 118 $out .= "&$key=$vars[$key]"; 119 } 120 echo '"' . $out . '"'; 121 ?>, 105 data: 'offset=' + (parseInt(c) - parseInt(b)) + '&limit=' + (1 + parseInt(b) - parseInt(a)) + '&search=' + search_args, 122 106 dataType: 'json', 123 107 success: function(json){ -
trunk/htdocs/system/admin/entries.php
r1722 r1745 12 12 <div class="years"> 13 13 <div class="months"> 14 <?php foreach($monthposts as $pdata): ?> 15 <div><span style="width: <?php echo $pdata->ct; ?>px"><?php echo date('M', mktime(0, 0, 0, $pdata->month)) ?></span></div> 16 <?php endforeach; ?> 14 <?php $theme->display( 'timeline_items' )?> 17 15 </div> 18 16 </div> … … 61 59 $.post( 62 60 '<?php echo URL::get('admin_ajax', array('context' => 'entries')) ?>', 63 'do_search=1&search=' + liveSearch.input.val() + 64 <?php 65 $vars= Controller::get_handler_vars(); 66 $out= ''; 67 $keys= array_keys($vars); 68 foreach($keys as $key) { 69 $out .= "&$key=$vars[$key]"; 70 } 71 echo '"' . $out . '"'; 72 ?>, 61 '&search=' + liveSearch.input.val() + '&limit=20', 73 62 function(json) { 74 63 $('.entries').html(json.items); 64 $('.years .months').html(json.timeline); 75 65 spinner.stop(); 76 66 itemManage.initItems(); 67 timeline.reset(); 77 68 $('.modulecore .item:first-child, ul li:first-child').addClass('first-child').show(); 78 69 $('.modulecore .item:last-child, ul li:last-child').addClass('last-child'); … … 84 75 timelineHandle.loupeUpdate = function(a,b,c) { 85 76 spinner.start(); 77 78 var search_args= $('.search input').val(); 86 79 87 80 $.ajax({ 88 type: "POST",81 type: 'POST', 89 82 url: "<?php echo URL::get('admin_ajax', array('context' => 'entries')); ?>", 90 data: "offset=" + (parseInt(c) - parseInt(b)) + "&limit=" + (1 + parseInt(b) - parseInt(a)) + 91 <?php 92 $vars= Controller::get_handler_vars(); 93 $out= ''; 94 $keys= array_keys($vars); 95 foreach($keys as $key) { 96 $out .= "&$key=$vars[$key]"; 97 } 98 echo '"' . $out . '"'; 99 ?>, 83 data: 'offset=' + (parseInt(c) - parseInt(b)) + '&limit=' + (1 + parseInt(b) - parseInt(a)) + '&search=' + search_args, 100 84 dataType: 'json', 101 85 success: function(json){ -
trunk/htdocs/system/admin/js/admin.js
r1722 r1745 191 191 }); 192 192 193 // if there are fewer than 20 things, set the handle width to the timelineWidth 194 var minWidth= ( timelineWidth < 20 ) ? timelineWidth : 20; 193 // find the width which makes the loupe select 20 items 194 var minWidth= timelineWidth - timeline.positionFromIndex( timeline.totalCount - 20 ); 195 196 /* Initialize the timeline handle. We need to do this before we create the slider because 197 * at the end of the slider initializer, it calls slider('moveTo', startValue) which will 198 * trigger the 'stop' event. We also don't need to do a search on initial page load, so 199 * set do_search to false until after slider initialization */ 200 timelineHandle.init( minWidth ); 201 timeline.do_search= false; 195 202 196 203 $('.track') … … 198 205 .slider({ 199 206 handle: '.handle', 200 maxValue: timelineWidth - minWidth,207 maxValue: Math.max( 1, timelineWidth - minWidth ), 201 208 startValue: timelineWidth - minWidth, 202 209 axis: 'horizontal', … … 224 231 else 225 232 timeline.t1 = setTimeout('timeline.skipLoupeRight()', 300); 226 }); 227 228 // update current position text 229 loupeStartPosition = timeline.indexFromPosition( parseInt($('.handle').css('left')) ); 230 $('.currentposition').text( loupeStartPosition +'-'+ timeline.totalCount +' of '+ timeline.totalCount ); 231 232 // Spool the timeline handle 233 timelineHandle.init( ( timelineWidth < 20 ) ? timelineWidth : 20 ); 233 }) 234 .slider( 'moveTo', timelineWidth - minWidth ); // a bug in the jQuery code requires us to explicitly do this in the case that startValue == 0 235 236 // update the do_search state variable 237 timeline.do_search= true; 234 238 }, 235 239 skipLoupeLeft: function(e) { … … 274 278 padding= padding ? padding : 0; 275 279 return monthIndex + Math.min( 276 Math.max( pos - ( monthBoundary + padding ), 0 ), 277 timeline.monthData[month] - 1 ); 280 Math.max( pos - ( monthBoundary + padding ), 0 ), 281 timeline.monthData[month] - 1 ); 282 }, 283 /* the reverse of the above function */ 284 positionFromIndex: function(index) { 285 var month= 0; 286 var position= 0; 287 var positionIndex= 1; 288 289 if ( index < 1 ) return 0; 290 291 for ( i = 0; i < timeline.monthWidths.length && positionIndex + timeline.monthData[i] < index; i++ ) { 292 position+= timeline.monthWidths[i]; 293 positionIndex+= timeline.monthData[i]; 294 month= i + 1; 295 } 296 297 var padding= parseInt( $('.years .months span').css('margin-left') ); 298 padding= padding ? padding : 0; 299 return position + padding + ( index - positionIndex ); 300 }, 301 reset: function () { 302 var timelineWidth = $('.years').width(); 303 304 // update the arrays of posts per month 305 timeline.monthData= [0]; 306 timeline.monthWidths= [0]; 307 timeline.totalCount= 0; 308 $('.years span').each(function(i) { 309 timeline.monthData[i] = $(this).width(); 310 timeline.monthWidths[i] = $(this).parent().width() + 1; // 1px border 311 timeline.totalCount += timeline.monthData[i]; 312 }); 313 314 // find the width which makes the loupe select 20 items 315 var minWidth= timelineWidth - timeline.positionFromIndex( timeline.totalCount - 20 ); 316 317 // reset the widths 318 $('.track').width( $('.years').width() ); 319 $('.handle').width( minWidth + 'px' ); 320 321 // reset the slider maxValue 322 $('.track').data('ui-slider').size= timelineWidth; 323 $('.track').data('ui-slider').options['realMaxValue']= Math.max( 1, timelineWidth - minWidth ); 324 325 // move the handle without triggering a search 326 timeline.do_search= false; 327 $('.track').slider( 'moveTo', timelineWidth - minWidth ); 328 timeline.do_search= true; 278 329 } 279 330 } … … 335 386 336 387 /* AJAX call to fetch needed info goes here. */ 337 if( jQuery.isFunction(this.loupeUpdate)) {388 if( timeline.do_search && jQuery.isFunction(this.loupeUpdate) ) { 338 389 return this.loupeUpdate(loupeStartPosition, loupeEndPosition, timeline.totalCount); 339 390 } -
trunk/htdocs/system/classes/adminhandler.php
r1741 r1745 752 752 753 753 $this->theme->comments= Comments::get( $arguments ); 754 755 $this->theme->monthcomments= DB::get_results( 'SELECT MONTH(date) AS month, YEAR(date) AS year, COUNT(id) AS ct FROM {comments} GROUP BY year, month ORDER BY year, month', array() ); 754 $this->theme->monthcts= Comments::get( array_merge( $arguments, array( 'month_cts' => 1 ) ) ); 756 755 } 757 756 … … 913 912 } 914 913 915 $this->theme->month posts= DB::get_results( 'SELECT MONTH(pubdate) AS month, YEAR(pubdate) AS year, COUNT(id) AS ct FROM {posts} WHERE content_type = ? GROUP BY year, month ORDER BY year, month', array( $type) );914 $this->theme->monthcts= Posts::get( array_merge( $arguments, array( 'month_cts' => 1 ) ) ); 916 915 } 917 916 … … 948 947 $this->fetch_entries( $params ); 949 948 $items= $this->theme->fetch( 'entries_items' ); 949 $timeline= $this->theme->fetch( 'timeline_items' ); 950 950 951 951 $output= array( 952 952 'items' => $items, 953 'timeline' => $timeline, 953 954 ); 954 955 echo json_encode($output); … … 956 957 957 958 /** 958 * Handles ajax requests from the manage commen s page959 * Handles ajax requests from the manage comments page 959 960 */ 960 961 public function ajax_comments() … … 967 968 $this->fetch_comments( $params ); 968 969 $items= $this->theme->fetch( 'comments_items' ); 970 $timeline= $this->theme->fetch( 'timeline_items' ); 969 971 970 972 $output= array( 971 973 'items' => $items, 974 'timeline' => $timeline, 972 975 ); 973 976 echo json_encode($output); -
trunk/htdocs/system/classes/comments.php
r1720 r1745 174 174 $orderby= ''; 175 175 } 176 // is a count of comments by month being requested? 177 $groupby= ''; 178 if ( isset ( $month_cts ) ) { 179 $select= 'MONTH(date) AS month, YEAR(date) AS year, COUNT(id) AS ct'; 180 $groupby= 'year, month'; 181 $orderby= 'year, month'; 182 } 176 183 if ( isset( $limit ) ) { 177 184 $limit= " LIMIT $limit"; … … 180 187 } 181 188 } 182 if ( isset( $nolimit ) ) {189 if ( isset( $nolimit ) || isset( $month_cts )) { 183 190 $limit= ''; 184 191 } … … 192 199 $query.= ' WHERE ' . implode( " \nOR\n ", $wheres ); 193 200 } 201 $query.= ( $groupby == '' ) ? '' : ' GROUP BY ' . $groupby; 194 202 $query.= ( ( $orderby == '' ) ? '' : ' ORDER BY ' . $orderby ) . $limit; 195 203 //Utils::debug( $paramarray, $fetch_fn, $query, $params ); -
trunk/htdocs/system/classes/posts.php
r1720 r1745 374 374 $orderby= ''; 375 375 } 376 377 // If the month counts are requested, replaced the select clause 378 $groupby= ''; 379 if( isset( $paramset['month_cts'] ) ) { 380 $select= 'MONTH(pubdate) AS month, YEAR(pubdate) AS year, COUNT(id) AS ct'; 381 $groupby= 'year, month'; 382 $orderby= 'year, month'; 383 } 384 376 385 377 386 // Define the LIMIT and add the OFFSET if it exists … … 383 392 } 384 393 385 // Remove the LIMIT if 'nolimit' is set386 if ( isset( $nolimit ) ) {394 // Remove the LIMIT if 'nolimit' or 'month_cts' is set 395 if ( isset( $nolimit ) || isset( $paramset['month_cts'] ) ) { 387 396 $limit= ''; 388 397 } … … 400 409 $query.= ' WHERE ' . implode( " \nOR\n ", $wheres ); 401 410 } 411 $query.= ( $groupby == '' ) ? '' : ' GROUP BY ' . $groupby; 402 412 $query.= ( ( $orderby == '' ) ? '' : ' ORDER BY ' . $orderby ) . $limit; 403 413
