- Timestamp:
- Jul 17, 2014, 9:06:05 PM (10 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/rating_user.php
r26900 r29053 94 94 $rating['uid'] = (int)$row['user_id']; 95 95 $rating['aid'] = $usr['anon'] ? $row['anonymous_id'] : ''; 96 $rating['last_date'] = $row['date']; 97 } 96 $rating['last_date'] = $rating['first_date'] = $row['date']; 97 } 98 else 99 $rating['first_date'] = $row['date']; 100 98 101 $rating['rates'][$row['rate']][] = array( 99 102 'id' => $row['element_id'], … … 108 111 if (count($image_ids) > 0 ) 109 112 { 110 $query = 'SELECT id, name, file, path, representative_ext 113 $query = 'SELECT id, name, file, path, representative_ext, level 111 114 FROM '.IMAGES_TABLE.' 112 115 WHERE id IN ('.implode(',', array_keys($image_ids)).')'; 113 116 $result = pwg_query($query); 117 $params = ImageStdParams::get_by_type(IMG_SQUARE); 114 118 while ($row = pwg_db_fetch_assoc($result)) 115 119 { 116 120 $image_urls[ $row['id'] ] = array( 117 'tn' => DerivativeImage:: thumb_url($row),121 'tn' => DerivativeImage::url($params, $row), 118 122 'page' => make_picture_url( array('image_id'=>$row['id'], 'image_file'=>$row['file']) ), 119 123 ); … … 172 176 'cv' => $s==0 ? -1 : sqrt($var)/($s/$c), // http://en.wikipedia.org/wiki/Coefficient_of_variation 173 177 'cd' => $consensus_dev, 174 'cdtop' => $consensus_dev_top_count ? $consensus_dev_top : '' 178 'cdtop' => $consensus_dev_top_count ? $consensus_dev_top : '', 175 179 ); 176 180 } … … 211 215 } 212 216 213 $order_by_index=3; 217 function last_rate_compare($a, $b) 218 { 219 return -strcmp( $a['last_date'], $b['last_date']); 220 } 221 222 $order_by_index=4; 214 223 if (isset($_GET['order_by']) and is_numeric($_GET['order_by'])) 215 224 { … … 222 231 array(l10n('Variation'), 'cv_compare'), 223 232 array(l10n('Consensus deviation'), 'consensus_dev_compare'), 233 array(l10n('Last'), 'last_rate_compare'), 224 234 ); 225 235 … … 242 252 'ratings' => $by_user_ratings, 243 253 'image_urls' => $image_urls, 244 'TN_WIDTH' => 28+2*ImageStdParams::get_by_type(IMG_THUMB)->sizing->ideal_size[0],254 'TN_WIDTH' => ImageStdParams::get_by_type(IMG_SQUARE)->sizing->ideal_size[0], 245 255 ) ); 246 256 $template->set_filename('rating', 'rating_user.tpl'); -
trunk/admin/themes/default/template/rating_user.tpl
r26941 r29053 13 13 .dtBar { 14 14 text-align:left; 15 padding-left: 20px; 16 } 15 padding: 10px 0 10px 20px 16 } 17 .dtBar DIV{ 18 display:inline; 19 padding-right: 5px; 20 } 21 22 .dataTables_paginate A { 23 padding-left: 3px; 24 } 25 26 .ui-tooltip { 27 padding: 8px; 28 position: absolute; 29 z-index: 9999; 30 max-width: {3*$TN_WIDTH}px; 31 -webkit-box-shadow: 0 0 5px #aaa; 32 box-shadow: 0 0 5px #aaa; 33 } 34 body .ui-tooltip { 35 border-width: 2px; 36 } 37 17 38 {/html_style} 18 39 … … 43 64 44 65 {combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'} 66 {combine_script id='jquery.geoip' load='async' path='admin/themes/default/js/jquery.geoip.js'} 45 67 {footer_script} 46 68 var oTable = jQuery('#rateTable').dataTable({ 47 sDom : '<"dtBar"f>rt', 48 bPaginate: false, 49 aaSorting: [[5,'desc']], 69 sDom : '<"dtBar"filp>rt<"dtBar"ilp>', 70 iDisplayLength: 100, 71 aLengthMenu: [ [25, 50, 100, 500, -1], [25, 50, 100, 500, "All"]], 72 aaSorting: [], //[[1,'desc']], 73 bAutoWidth: false, 74 bSortClasses: false, 50 75 aoColumnDefs: [ 51 /*{ 52 aTargets: ["dtc_user"] 53 },*/ 76 { 77 aTargets: ["dtc_user"], 78 sType: "string", 79 sClass: null 80 }, 54 81 { 55 82 aTargets: ["dtc_date"], 56 asSorting: ["desc","asc"] 83 asSorting: ["desc","asc"], 84 sType: "string", 85 sClass: null 57 86 }, 58 87 { 59 88 aTargets: ["dtc_stat"], 60 89 asSorting: ["desc","asc"], 61 bSearchable: false 90 bSearchable: false, 91 sType: "numeric", 92 sClass: null 62 93 }, 63 94 { 64 95 aTargets: ["dtc_rate"], 65 96 asSorting: ["desc","asc"], 66 bSearchable: false 97 bSearchable: false, 98 sType: "html", 99 sClass: null 67 100 }, 68 101 { 69 102 aTargets: ["dtc_del"], 70 103 bSortable: false, 71 bSearchable: false 104 bSearchable: false, 105 sType: "string", 106 sClass: null 72 107 } 73 108 ] 74 109 }); 75 110 76 function del(elt,uid,aid){ 77 if (!confirm('{'Are you sure?'|@translate|@escape:'javascript'}')) 78 return false; 79 var tr = elt; 111 112 function uidFromCell(cell){ 113 var tr = cell; 80 114 while ( tr.nodeName != "TR") tr = tr.parentNode; 81 tr = jQuery(tr).fadeTo(1000, 0.4); 82 83 (new PwgWS('{$ROOT_URL|@escape:javascript}')).callService( 84 'pwg.rates.delete', { user_id:uid, anonymous_id:aid}, 85 { 86 method: 'POST', 87 onFailure: function(num, text) { tr.stop(); tr.fadeTo(0,1); alert(num + " " + text); }, 88 onSuccess: function(result){ 89 if (result) 90 oTable.fnDeleteRow(tr[0]); 91 else 92 alert(result); 115 return $(tr).data("usr"); 116 } 117 118 {* -----DELETE----- *} 119 $(document).ready( function(){ 120 $("#rateTable").on( "click", ".del", function(e) { 121 e.preventDefault(); 122 if (!confirm('{'Are you sure?'|@translate|@escape:'javascript'}')) 123 return; 124 var cell = e.target.parentNode, 125 tr = cell; 126 while ( tr.nodeName != "TR") tr = tr.parentNode; 127 tr = jQuery(tr).fadeTo(1000, 0.4); 128 129 var data=uidFromCell(cell); 130 131 (new PwgWS('{$ROOT_URL|@escape:javascript}')).callService( 132 'pwg.rates.delete', { user_id:data.uid, anonymous_id:data.aid}, 133 { 134 method: 'POST', 135 onFailure: function(num, text) { tr.stop(); tr.fadeTo(0,1); alert(num + " " + text); }, 136 onSuccess: function(result){ 137 if (result) 138 oTable.fnDeleteRow(tr[0]); 139 else 140 alert(result); 141 } 93 142 } 94 }95 ); 96 97 return false;98 } 143 ); 144 145 }); 146 }); 147 99 148 {/footer_script} 100 149 <table id="rateTable"> 101 150 <thead> 102 151 <tr class="throw"> 103 <t d class="dtc_user">{'Username'|@translate}</td>104 <t d class="dtc_date">{'Last'|@translate}</td>105 <t d class="dtc_stat">{'Number of rates'|@translate}</td>106 <t d class="dtc_stat">{'Average rate'|@translate}</td>107 <t d class="dtc_stat">{'Variation'|@translate}</td>108 <t d class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'}</td>109 <t d class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'} {$CONSENSUS_TOP_NUMBER}</td>152 <th class="dtc_user">{'Username'|@translate}</th> 153 <th class="dtc_date">{'Last'|@translate}</th> 154 <th class="dtc_stat">{'Number of rates'|@translate}</th> 155 <th class="dtc_stat">{'Average rate'|@translate}</th> 156 <th class="dtc_stat">{'Variation'|@translate}</th> 157 <th class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'}</th> 158 <th class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'} {$CONSENSUS_TOP_NUMBER}</th> 110 159 {foreach from=$available_rates item=rate} 111 <t d class="dtc_rate">{$rate}</td>160 <th class="dtc_rate">{$rate}</th> 112 161 {/foreach} 113 <t d class="dtc_del"></td>162 <th class="dtc_del"></th> 114 163 </tr> 115 164 </thead> 116 165 {foreach from=$ratings item=rating key=user} 117 <tr> 118 <td>{$user}</td> 119 <td>{$rating.last_date}</td> 120 <td>{$rating.count}</td> 121 <td>{$rating.avg|@number_format:2}</td> 122 <td>{$rating.cv|@number_format:3}</td> 123 <td>{$rating.cd|@number_format:3}</td> 124 <td>{if !empty($rating.cdtop)}{$rating.cdtop|@number_format:3}{/if}</td> 125 {foreach from=$rating.rates item=rates key=rate} 126 <td>{if !empty($rates)} 127 {capture assign=rate_over}{foreach from=$rates item=rate_arr}<img src="{$image_urls[$rate_arr.id].tn}" alt="thumb-{$rate_arr.id}" title="{$rate_arr.date}"></img> 128 {/foreach}{/capture} 129 <a class="cluetip" title="|{$rate_over|@htmlspecialchars}">{$rates|@count}</a> 130 {/if}</td> 131 {/foreach} 132 <td><a onclick="return del(this,{$rating.uid},'{$rating.aid}');" class="icon-trash"></a></td> 166 <tr data-usr='{ldelim}"uid":{$rating.uid},"aid":"{$rating.aid}"}'> 167 {strip} 168 <td class=usr>{$user}</td><td title="First: {$rating.first_date}">{$rating.last_date}</td> 169 <td>{$rating.count}</td><td>{$rating.avg|@number_format:2}</td> 170 <td>{$rating.cv|@number_format:3}</td><td>{$rating.cd|@number_format:3}</td><td>{if !empty($rating.cdtop)}{$rating.cdtop|@number_format:3}{/if}</td> 171 {foreach from=$rating.rates item=rates key=rate} 172 <td>{if !empty($rates)} 173 {capture assign=rate_over}{foreach $rates as $rate_arr}{if $rate_arr@index>29}{break}{/if}<img src="{$image_urls[$rate_arr.id].tn}" alt="thumb-{$rate_arr.id}" width="{$TN_WIDTH}" height="{$TN_WIDTH}">{/foreach}{/capture} 174 <a title="{$rate_over|@htmlspecialchars}">{$rates|@count}</a> 175 {/if}</td> 176 {/foreach} 177 <td><a class="del icon-trash"></a></td> 133 178 </tr> 179 {/strip} 134 180 {/foreach} 135 181 </table> 136 182 137 {combine_script id='jquery.cluetip' load='footer' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'} 138 {footer_script require='jquery.cluetip'} 139 jQuery(document).ready(function(){ldelim} 140 jQuery('.cluetip').cluetip({ldelim} 141 width: {$TN_WIDTH}, showTitle:false, splitTitle: '|' 183 {combine_script id='jquery.ui.tooltip' load='footer'} 184 {footer_script require='jquery.ui.tooltip'} 185 jQuery(document).ready(function(){ 186 jQuery("#rateTable").tooltip({ 187 items: ".usr,[title]", 188 content: function(callback) { 189 var t = $(this).attr("title"); 190 if (t) 191 return t; 192 var that = $(this), 193 udata = uidFromCell(this); 194 if (!udata.aid) 195 return; 196 that 197 .data("isOver", true) 198 .one("mouseleave", function() { 199 that.removeData("isOver"); 200 }); 201 202 GeoIp.get( udata.aid + ".1", function(data) { 203 if (!data.fullName) return; 204 var content = data.fullName; 205 if (data.latitude && data.region_name) { 206 content += "<br><img width=300 height=220 src=\"http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=300x220&zoom=6" 207 + "&markers=size:tiny%7C" + data.latitude + "," + data.longitude 208 + "\">"; 209 } 210 if (that.data("isOver")) 211 callback(content); 212 }); 213 } 142 214 }); 143 215 })
Note: See TracChangeset
for help on using the changeset viewer.