Changeset 26838


Ignore:
Timestamp:
Jan 17, 2014, 11:20:56 PM (7 years ago)
Author:
rvelices
Message:

merge -r26837 from trunk to branch 2.6
admin rating improvements

  • use web service for deletion
  • use datatables for rating by user
  • use fontello icons
Location:
branches/2.6
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/admin/rating.php

    r26461 r26838  
    213213
    214214  $tpl_image =
    215      array(
    216        'U_THUMB' => $thumbnail_src,
    217        'U_URL' => $image_url,
    218                          'SCORE_RATE' => $image['score'],
     215    array(
     216      'id' => $image['id'],
     217      'U_THUMB' => $thumbnail_src,
     218      'U_URL' => $image_url,
     219      'SCORE_RATE' => $image['score'],
    219220       'AVG_RATE' => $image['avg_rates'],
    220221       'SUM_RATE' => $image['sum_rates'],
     
    227228  while ($row = pwg_db_fetch_assoc($result))
    228229  {
    229 
    230     $url_del = PHPWG_ROOT_PATH.'admin.php'.
    231                 get_query_string_diff(array('del'));
    232 
    233     $del_param = 'e='.$image['id'].
    234                  '&u='.$row['user_id'].
    235                  '&a='.$row['anonymous_id'];
    236 
    237     $url_del .= '&del='.urlencode(urlencode($del_param));
    238 
    239230    if ( isset($users[$row['user_id']]) )
    240231    {
     
    250241    }
    251242
    252     $tpl_image['rates'][] =
    253        array(
    254          'DATE' => /*format_date*/($row['date']),
    255          'RATE' => $row['rate'],
    256          'USER' => $user_rate,
    257          'U_DELETE' => $url_del
    258      );
     243    $row['USER'] = $user_rate;
     244    $tpl_image['rates'][] = $row;
    259245  }
    260246  $template->append( 'images', $tpl_image );
  • branches/2.6/admin/themes/default/template/rating.tpl

    r12528 r26838  
    4141  <td>{'Average rate'|@translate}</td>
    4242  <td>{'Sum of rates'|@translate}</td>
    43   <td>{'Rate'|@translate}</td>
    44   <td>{'Username'|@translate}</td>
    45   <td>{'Rate date'|@translate}</td>
     43  <td>{'Rate'|@translate}/{'Username'|@translate}/{'Rate date'|@translate}</td>
    4644  <td></td>
    4745</tr>
    4846{foreach from=$images item=image name=image}
    4947<tr valign="top" class="{if $smarty.foreach.image.index is odd}row1{else}row2{/if}">
    50         <td rowspan="{$image.NB_RATES_TOTAL+1}"><a href="{$image.U_URL}"><img src="{$image.U_THUMB}" alt="{$image.FILE}" title="{$image.FILE}"></a></td>
    51         <td rowspan="{$image.NB_RATES_TOTAL+1}"><strong>{$image.NB_RATES}/{$image.NB_RATES_TOTAL}</strong></td>
    52         <td rowspan="{$image.NB_RATES_TOTAL+1}"><strong>{$image.SCORE_RATE}</strong></td>
    53         <td rowspan="{$image.NB_RATES_TOTAL+1}"><strong>{$image.AVG_RATE}</strong></td>
    54         <td rowspan="{$image.NB_RATES_TOTAL+1}" style="border-right: 1px solid;" ><strong>{$image.SUM_RATE}</strong></td>
     48        <td><a href="{$image.U_URL}"><img src="{$image.U_THUMB}" alt="{$image.FILE}" title="{$image.FILE}"></a></td>
     49        <td><strong>{$image.NB_RATES}/{$image.NB_RATES_TOTAL}</strong></td>
     50        <td><strong>{$image.SCORE_RATE}</strong></td>
     51        <td><strong>{$image.AVG_RATE}</strong></td>
     52        <td style="border-right:1px solid" ><strong>{$image.SUM_RATE}</strong></td>
     53        <td>
     54                <table style="width:100%">
     55{foreach from=$image.rates item=rate name=rate}
     56<tr>
     57        <td>{$rate.rate}</td>
     58        <td><b>{$rate.USER}</b></td>
     59        <td>{$rate.date}</td>
     60        <td><a onclick="return del(this,{$image.id},{$rate.user_id}{if !empty({$rate.anonymous_id})},'{$rate.anonymous_id}'{/if})" class="icon-trash"> </a></td>
    5561</tr>
    56 {foreach from=$image.rates item=rate name=rate}
    57 <tr class="{if ($smarty.foreach.image.index+$smarty.foreach.rate.index) is odd}row1{else}row2{/if}">
    58         <td>{$rate.RATE}</td>
    59         <td><b>{$rate.USER}</b></td>
    60         <td>{$rate.DATE}</td>
    61         <td><a href="{$rate.U_DELETE}"><img src="{$themeconf.admin_icon_dir}/delete.png" alt="[{'Delete'|@translate}]"></a></td>
     62{/foreach}{*rates*}
     63                </table>
     64        </td>
    6265</tr>
    63 {/foreach} {*rates*}
    64 {/foreach} {*images*}
     66{/foreach}{*images*}
    6567</table>
     68{combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'}
     69{footer_script}
     70function del(node,id,uid,aid){
     71        var tr = jQuery(node).parents("tr").first().fadeTo(1000, 0.4),
     72                data = {
     73                        image_id: id,
     74                        user_id: uid
     75                };
     76        if (aid)
     77                data.anonymous_id = aid;
    6678
    67 {if !empty($navbar) }{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
     79        (new PwgWS('{$ROOT_URL|@escape:javascript}')).callService(
     80                'pwg.rates.delete', data,
     81                {
     82                        method: 'POST',
     83                        onFailure: function(num, text) { tr.stop(); tr.fadeTo(0,1); alert(num + " " + text); },
     84                        onSuccess: function(result){
     85                                if (result)
     86                                        tr.remove();
     87                                else
     88                                        alert(result);
     89                        }
     90                }
     91        );
     92        return false;
     93}
     94{/footer_script}
     95
     96{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
  • branches/2.6/admin/themes/default/template/rating_user.tpl

    r12796 r26838  
     1{combine_script id='jquery.dataTables' load='footer' path='themes/default/js/plugins/jquery.dataTables.js'}
     2{html_style}
     3.sorting { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_both.png) no-repeat center right; cursor:pointer; }
     4.sorting_asc { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_asc.png) no-repeat center right; }
     5.sorting_desc { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_desc.png) no-repeat center right; }
     6
     7.sorting, .sorting_asc, .sorting_desc {
     8        padding: 3px 18px 3px 10px;
     9}
     10.sorting_asc_disabled { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_asc_disabled.png) no-repeat center right; }
     11.sorting_desc_disabled { background: url({$ROOT_URL}themes/default/js/plugins/datatables/images/sort_desc_disabled.png) no-repeat center right; }
     12
     13.dtBar {
     14        text-align:left;
     15        padding-left: 20px;
     16}
     17{/html_style}
     18
    119<h2>{$ratings|@count} {'Users'|@translate}</h2>
    220
    321<form action="{$F_ACTION}" method="GET">
    422<fieldset>
     23<noscript>
    524        <label>{'Sort by'|@translate}
    625                <select name="order_by">
     
    827                </select>
    928        </label>
     29</noscript>
    1030        <label>{'Number of rates'|@translate}&gt;
    1131        <input type="text" size="5" name="f_min_rates" value="{$F_MIN_RATES}">
     
    1838
    1939{combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'}
    20 {footer_script}{literal}
    21 function del(elt,uid,aid)
    22 {
    23         if (!confirm({/literal}'{'Are you sure?'|@translate|@escape:'javascript'}'{literal}))
     40{footer_script}
     41var oTable = jQuery('#rateTable').dataTable({
     42        sDom : '<"dtBar"f>rt',
     43        bPaginate: false,
     44        aaSorting: [[4,'desc']],
     45        aoColumnDefs: [
     46                {
     47                        aTargets: ["dtc_user"],
     48                },
     49                {
     50                        aTargets: ["dtc_stat"],
     51                        asSorting: ["desc","asc"],
     52                        bSearchable: false
     53                },
     54                {
     55                        aTargets: ["dtc_rate"],
     56                        asSorting: ["desc","asc"],
     57                        bSearchable: false
     58                },
     59                {
     60                        aTargets: ["dtc_del"],
     61                        bSortable: false,
     62                        bSearchable: false
     63                }
     64        ]
     65});
     66
     67function del(elt,uid,aid){
     68        if (!confirm('{'Are you sure?'|@translate|@escape:'javascript'}'))
    2469                return false;
    2570        var tr = elt;
    2671        while ( tr.nodeName != "TR") tr = tr.parentNode;
    2772        tr = jQuery(tr).fadeTo(1000, 0.4);
    28         (new PwgWS({/literal}'{$ROOT_URL|@escape:javascript}'{literal})).callService(
    29                 'pwg.rates.delete', {user_id:uid, anonymous_id:aid},
     73
     74        (new PwgWS('{$ROOT_URL|@escape:javascript}')).callService(
     75                'pwg.rates.delete', { user_id:uid, anonymous_id:aid},
    3076                {
    3177                        method: 'POST',
    3278                        onFailure: function(num, text) { tr.stop(); tr.fadeTo(0,1); alert(num + " " + text); },
    33                         onSuccess: function(result) { if (result) {tr.remove();} else alert(result); }
     79                        onSuccess: function(result){
     80                                if (result)
     81                                        oTable.fnDeleteRow(tr[0]);
     82                                else
     83                                        alert(result);
     84                        }
    3485                }
    3586        );
     87       
    3688        return false;
    3789}
    38 {/literal}{/footer_script}
    39 <table>
     90{/footer_script}
     91<table id="rateTable">
     92<thead>
    4093<tr class="throw">
    41         <td>{'Username'|@translate}</td>
    42         <td>{'Number of rates'|@translate}</td>
    43         <td>{'Average rate'|@translate}</td>
    44         <td>{'Variation'|@translate}</td>
    45         <td>{'Consensus deviation'|@translate|@replace:' ':'<br>'}</td>
     94        <td class="dtc_user">{'Username'|@translate}</td>
     95        <td class="dtc_stat">{'Number of rates'|@translate}</td>
     96        <td class="dtc_stat">{'Average rate'|@translate}</td>
     97        <td class="dtc_stat">{'Variation'|@translate}</td>
     98        <td class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'}</td>
    4699{foreach from=$available_rates item=rate}
    47         <td>{$rate}</td>
     100        <td class="dtc_rate">{$rate}</td>
    48101{/foreach}
    49         <td></td>
     102        <td class="dtc_del"></td>
    50103</tr>
     104</thead>
    51105{foreach from=$ratings item=rating key=user}
    52106<tr>
     
    63117                {/if}</td>
    64118        {/foreach}
    65         <td><a onclick="return del(this,{$rating.uid},'{$rating.aid}');"><img src="{$themeconf.admin_icon_dir}/delete.png" alt="[{'Delete'|@translate}]"></a></td>
     119        <td><a onclick="return del(this,{$rating.uid},'{$rating.aid}');" class="icon-trash"></a></td>
    66120</tr>
    67121{/foreach}
  • branches/2.6/include/ws_functions/pwg.php

    r26461 r26838  
    272272    $query .= ' AND anonymous_id=\''.$params['anonymous_id'].'\'';
    273273  }
     274  if (!empty($params['image_id']))
     275  {
     276    $query .= ' AND element_id='.$params['image_id'];
     277  }
    274278
    275279  $changes = pwg_db_changes(pwg_query($query));
  • branches/2.6/ws.php

    r26461 r26838  
    308308        'user_id' =>      array('type'=>WS_TYPE_ID),
    309309        'anonymous_id' => array('default'=>null),
     310        'image_id' =>     array('flags'=>WS_PARAM_OPTIONAL, 'type'=>WS_TYPE_ID),
    310311        ),
    311312      'Deletes all rates for a user.',
Note: See TracChangeset for help on using the changeset viewer.