Ignore:
Timestamp:
Mar 13, 2016, 7:00:55 AM (8 years ago)
Author:
ddtddt
Message:

[extensions] - delete_hit_rate - update design

Location:
extensions/delete_hit_rate
Files:
2 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/delete_hit_rate/initadmin.php

    r21160 r31436  
    11<?php
     2
     3// +-----------------------------------------------------------------------+
     4// | Delete Hit/Rate plugin for piwigo                                     |
     5// +-----------------------------------------------------------------------+
     6// | Copyright(C) 2011-2016 ddtddt               http://temmii.com/piwigo/ |
     7// +-----------------------------------------------------------------------+
     8// | This program is free software; you can redistribute it and/or modify  |
     9// | it under the terms of the GNU General Public License as published by  |
     10// | the Free Software Foundation                                          |
     11// |                                                                       |
     12// | This program is distributed in the hope that it will be useful, but   |
     13// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     14// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     15// | General Public License for more details.                              |
     16// |                                                                       |
     17// | You should have received a copy of the GNU General Public License     |
     18// | along with this program; if not, write to the Free Software           |
     19// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     20// | USA.                                                                  |
     21// +-----------------------------------------------------------------------+
     22
    223if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    324
     
    526define('PDHR_PATH' , PHPWG_PLUGINS_PATH . PDHR_DIR . '/');
    627load_language('plugin.lang', PDHR_PATH);
     28define('PDHR_ADMIN',get_root_url().'admin.php?page=plugin-'.PDHR_DIR);
    729
    830add_event_handler('get_admin_plugin_menu_links', 'dphr_admin_menu');
    9 function dphr_admin_menu($menu)
    10 {
    11   array_push($menu, array(
    12         'NAME' => 'Delete Hit Rate',
    13     'URL' => get_admin_plugin_menu_link(PDHR_PATH . 'admin/admin.php')));
     31function dphr_admin_menu($menu){
     32  load_language('plugin.lang', PDHR_PATH);
     33  $menu[] = array(
     34    'NAME' => l10n('Delete Hit Rate'),
     35    'URL' => PDHR_ADMIN,
     36  );
    1437  return $menu;
    1538}
    16 
    1739
    1840//add prefiltre photo
     
    2143
    2244function plugdphrPf()
    23         {
    24         global $template;
    25         $template->set_prefilter('picture_modify', 'plugdphrPT');
    26         }
     45  {
     46  global $template;
     47  $admin_base_url = $_SERVER['REQUEST_URI'];
     48  $template->set_prefilter('picture_modify', 'plugdphrPT');
     49 $template->assign(
     50    array(
     51                'U_DELETEPHIT' => $admin_base_url . '&amp;deletephit',
     52                'U_DELETEPRATE' => $admin_base_url . '&amp;deleteprate',
     53  ));
     54  }
    2755
    2856function plugdphrPT($content, &$smarty)
    2957        {
    3058load_language('plugin.lang', PDHR_PATH);
    31   $search = '#</form>#';
     59  $search = '#          </ul>
     60        </td>
     61      </tr>
     62    </table>#';
    3263 
    3364  $replacement = '
    34         <div>
    35                 <form method="post" >
    36                         <fieldset>
    37                                 <legend>{\'Purge - Plugin Delete Hit/Rate\'|@translate}</legend>
    38                                         <div style="text-align:center;">
    39                                         <input class="submit" name="plugdphphoto" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge hit of the photo\'|@translate}" {$TAG_INPUT_ENABLED} />
    40                                         <input class="submit" name="plugdprphoto" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge rate of the photo\'|@translate}" {$TAG_INPUT_ENABLED} />
    41                                         </div>
    42                         </fieldset>
    43                 </form>
    44         </div>
    45   </form>';
     65        <li><a href="{$U_DELETEPHIT}" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:javascript}\');"><span class="icon-trash mouse"></span>{\'Purge hit of the photo\'|@translate}</a></li>
     66        <li><a href="{$U_DELETEPRATE}" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:javascript}\');"><span class="icon-trash mouse"></span>{\'Purge rate of the photo\'|@translate}</a></li>
     67
     68          </ul>
     69        </td>
     70      </tr>
     71    </table>';
    4672
    4773  return preg_replace($search, $replacement, $content);
     
    5076function plugdphrPf2()
    5177        {
    52 if (isset($_POST['plugdphphoto']))
    53  {
    54         $query = '
    55 UPDATE ' . IMAGES_TABLE . '
    56   SET hit= \'0\'
    57   WHERE id = '.$_GET['image_id'].'
    58     ;';
    59 $result = pwg_query($query);
    60   }
    61 
    62 if (isset($_POST['plugdprphoto']))
    63  {
    64         $query = '
    65 UPDATE ' . IMAGES_TABLE . '
    66   SET rating_score = \'NULL\'
    67   WHERE id = '.$_GET['image_id'].'
    68     ;';
    69 $result = pwg_query($query);
    70 
    71         $query = '
    72   DELETE FROM ' . RATE_TABLE . '
    73   WHERE element_id = '.$_GET['image_id'].'
    74     ;';
    75 $result = pwg_query($query);
    76   }
     78if (isset($_GET['deletephit'])) {
     79  $admin_base_url=explode('&deletephit', $_SERVER['REQUEST_URI']);
     80  $photoid = explode('photo-', $_SERVER['REQUEST_URI']);
     81  if(strstr($photoid[1], '-properties')){$photoid = explode('-properties', $photoid[1]);}
     82  else if(strstr($photoid[1], '&cat')){$photoid = explode('&cat', $photoid[1]);}
     83  else{
     84  $_SESSION['page_infos'] = array('error');
     85  redirect($_SERVER['REQUEST_URI']);
     86  }
     87  $query = 'UPDATE ' . IMAGES_TABLE . ' SET hit= \'0\' WHERE id = '.$photoid[0].';';
     88  $result = pwg_query($query);
     89  redirect($admin_base_url[0]);
     90}
     91
     92if (isset($_GET['deleteprate'])) {
     93  $admin_base_url=explode('&deleteprate', $_SERVER['REQUEST_URI']);
     94  $photoid = explode('photo-', $_SERVER['REQUEST_URI']);
     95  if(strstr($photoid[1], '-properties')){$photoid = explode('-properties', $photoid[1]);}
     96  else if(strstr($photoid[1], '&cat')){$photoid = explode('&cat', $photoid[1]);}
     97  else{
     98  $_SESSION['page_infos'] = array('error');
     99  redirect($_SERVER['REQUEST_URI']);
     100  }
     101  $query = 'UPDATE ' . IMAGES_TABLE . ' SET rating_score = \'NULL\' WHERE id = '.$photoid[0].';';
     102  $result = pwg_query($query);
     103  $query = 'DELETE FROM ' . RATE_TABLE . ' WHERE element_id = '.$photoid[0].';';
     104  $result = pwg_query($query);
     105  redirect($admin_base_url[0]);
     106}
     107
    77108  }
    78109 
     
    84115 {
    85116        global $template;
     117        $admin_base_url = $_SERVER['REQUEST_URI'];
    86118        $template->set_prefilter('album_properties', 'plugdphrAT');
     119        $template->assign(
     120    array(
     121                'U_DELETEAHIT' => $admin_base_url . '&amp;deleteahit',
     122                'U_DELETEARATE' => $admin_base_url . '&amp;deletearate',
     123  ));
    87124 }
    88125
     
    90127 {
    91128load_language('plugin.lang', PDHR_PATH);
    92   $search = '#</form>#';
     129  $search = '#</ul>
     130      </td>
     131    </tr>
     132  </table>#';
    93133 
    94134  $replacement = '
    95         <div>
    96                
    97                         <fieldset>
    98                                 <legend>{\'Purge - Plugin Delete Hit/Rate\'|@translate}</legend>
    99                                         <div style="text-align:center;">
    100                                         <input class="submit" name="plugdphA" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge hits on all pictures album\'|@translate}" {$TAG_INPUT_ENABLED} />
    101                                         <input class="submit" name="plugdprA" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge rates on all pictures album\'|@translate}" {$TAG_INPUT_ENABLED} />
    102                                         </div>
    103                         </fieldset>
    104                
    105         </div>
    106 </form>
     135                        <li><a href="{$U_DELETEAHIT}" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:javascript}\');"><span class="icon-trash mouse"></span>{\'Purge hits on all pictures album\'|@translate}</a></li>
     136                        <li><a href="{$U_DELETEARATE}" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:javascript}\');"><span class="icon-trash mouse"></span>{\'Purge rates on all pictures album\'|@translate}</a></li>
     137                   </ul>
     138      </td>
     139    </tr>
     140  </table>
    107141  ';
    108142
     
    112146 function plugdphrAf2()
    113147 {
    114 if (isset($_POST['plugdphA']))
    115  {
    116         $query = '
    117 select image_id
    118   FROM ' . IMAGE_CATEGORY_TABLE . '
    119   WHERE category_id = '.$_GET['cat_id'].'
    120   ;';
    121 $result = pwg_query($query);
    122 
    123 $delval = array();
    124 while($row = pwg_db_fetch_assoc($result))
     148 
     149if (isset($_GET['deleteahit'])) {
     150  $admin_base_url=explode('&deleteahit', $_SERVER['REQUEST_URI']);
     151  $albumid = explode('album-', $_SERVER['REQUEST_URI']);
     152  if(strstr($albumid[1], '-properties')){
     153    $albumid = explode('-properties', $albumid[1]);
     154        $albumid = $albumid[0];
     155  }  else if(strstr($albumid[1], '&deleteahit')){
     156    $albumid = explode('&deleteahit', $albumid[1]);
     157        $albumid = $albumid[0];
     158        }
     159  else{
     160  $_SESSION['page_infos'] = array('error');
     161  redirect($_SERVER['REQUEST_URI']);
     162  }
     163  $query = 'select image_id FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE category_id = '.$albumid.';';
     164  $result = pwg_query($query);
     165  $delval = array();
     166  while($row = pwg_db_fetch_assoc($result))
    125167        {
    126168    array_push($delval, $row['image_id']);
    127169        }
     170  foreach ($delval as $delrate)
     171        {
     172        $query = 'UPDATE ' . IMAGES_TABLE . ' SET hit= \'0\' WHERE id = \''.$delrate.'\';';
     173        $result = pwg_query($query);
     174        }
     175  redirect($admin_base_url[0]);
     176}
    128177 
    129  foreach ($delval as $delrate)
    130         {
    131         $query = '
    132 UPDATE ' . IMAGES_TABLE . '
    133   SET hit= \'0\'
    134   WHERE id = \''.$delrate.'\'
    135     ;';
    136 $result = pwg_query($query);
    137         }
    138  }
    139 
    140 if (isset($_POST['plugdprA']))
    141  {
    142         $query = '
    143 select image_id
    144   FROM ' . IMAGE_CATEGORY_TABLE . '
    145   WHERE category_id = '.$_GET['cat_id'].'
    146   ;';
    147 $result = pwg_query($query);
    148 
    149 $delval = array();
    150 while($row = pwg_db_fetch_assoc($result))
     178if (isset($_GET['deletearate'])) {
     179  $admin_base_url=explode('&deletearate', $_SERVER['REQUEST_URI']);
     180  $albumid = explode('album-', $_SERVER['REQUEST_URI']);
     181  if(strstr($albumid[1], '-properties')){
     182    $albumid = explode('-properties', $albumid[1]);
     183        $albumid = $albumid[0];
     184  }  else if(strstr($albumid[1], '&deletearate')){
     185    $albumid = explode('&deletearate', $albumid[1]);
     186        $albumid = $albumid[0];
     187        }
     188  else{
     189  $_SESSION['page_infos'] = array('error');
     190  redirect($_SERVER['REQUEST_URI']);
     191  }
     192  $query = 'select image_id FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE category_id = '.$albumid.';';
     193  $result = pwg_query($query);
     194  $delval = array();
     195  while($row = pwg_db_fetch_assoc($result))
    151196        {
    152197    array_push($delval, $row['image_id']);
    153198        }
    154 
    155 foreach ($delval as $delrate)
    156         {
    157                 $query = '
    158                 UPDATE ' . IMAGES_TABLE . '
    159                 SET rating_score = \'NULL\'
    160                 WHERE id = \''.$delrate.'\'
    161     ;';
    162 $result = pwg_query($query);
     199  foreach ($delval as $delrate)
     200        {
     201        $query = 'UPDATE ' . IMAGES_TABLE . ' SET rating_score = \'NULL\' WHERE id = \''.$delrate.'\';';
     202        $result = pwg_query($query);
    163203       
    164                 $query = '
    165                 DELETE FROM ' . RATE_TABLE . '
    166                 WHERE element_id = \''.$delrate.'\'
    167                 ;';
    168                 $result = pwg_query($query);
    169         }
    170  }
     204        $query = 'DELETE FROM ' . RATE_TABLE . ' WHERE element_id = \''.$delrate.'\';';
     205        $result = pwg_query($query);
     206        }
     207  redirect($admin_base_url[0]);
     208}
     209
    171210}
    172211?>
  • extensions/delete_hit_rate/language/en_UK/plugin.lang.php

    r12999 r31436  
    11<?php
     2// +-----------------------------------------------------------------------+
     3// | Delete Hit/Rate plugin for piwigo                                     |
     4// +-----------------------------------------------------------------------+
     5// | Copyright(C) 2011-2016 ddtddt               http://temmii.com/piwigo/ |
     6// +-----------------------------------------------------------------------+
     7// | This program is free software; you can redistribute it and/or modify  |
     8// | it under the terms of the GNU General Public License as published by  |
     9// | the Free Software Foundation                                          |
     10// |                                                                       |
     11// | This program is distributed in the hope that it will be useful, but   |
     12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     14// | General Public License for more details.                              |
     15// |                                                                       |
     16// | You should have received a copy of the GNU General Public License     |
     17// | along with this program; if not, write to the Free Software           |
     18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     19// | USA.                                                                  |
     20// +-----------------------------------------------------------------------+
    221
     22$lang['Delete Hit Rate'] = 'Delete Hit Rate';
    323$lang['Purge All'] = 'Purge All';
    4 $lang['Purge all hits on all pictures gallery'] = 'Purge all hits on all pictures gallery';
    524$lang['Hit purge completed successfully'] = 'Hit purge completed successfully';
    625$lang['Purge all rate on all pictures gallery'] = 'Purge all rate on all pictures gallery';
  • extensions/delete_hit_rate/language/es_ES/plugin.lang.php

    r13276 r31436  
    2222// +-----------------------------------------------------------------------+
    2323$lang['Hit purge completed successfully'] = 'Borrado satisfactorio de contadores de visitas';
    24 $lang['Purge - Plugin Delete Hit/Rate'] = 'Plugin de borrado de puntuaciones/contadores de visitas';
    2524$lang['Purge All'] = 'Borrar todos';
    2625$lang['Purge all hits on all pictures gallery'] = 'Borrar todos los contadores de visitas en todas las galerías';
  • extensions/delete_hit_rate/language/fr_FR/plugin.lang.php

    r12999 r31436  
    11<?php
     2// +-----------------------------------------------------------------------+
     3// | Delete Hit/Rate plugin for piwigo                                     |
     4// +-----------------------------------------------------------------------+
     5// | Copyright(C) 2011-2016 ddtddt               http://temmii.com/piwigo/ |
     6// +-----------------------------------------------------------------------+
     7// | This program is free software; you can redistribute it and/or modify  |
     8// | it under the terms of the GNU General Public License as published by  |
     9// | the Free Software Foundation                                          |
     10// |                                                                       |
     11// | This program is distributed in the hope that it will be useful, but   |
     12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     14// | General Public License for more details.                              |
     15// |                                                                       |
     16// | You should have received a copy of the GNU General Public License     |
     17// | along with this program; if not, write to the Free Software           |
     18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     19// | USA.                                                                  |
     20// +-----------------------------------------------------------------------+
    221
     22$lang['Delete Hit Rate'] = 'Supprimer Scores / notes';
    323$lang['Purge All'] = 'Purge Total';
    424$lang['Purge all hits on all pictures gallery'] = 'Purger tous les hits de la galerie';
     
    626$lang['Purge all rate on all pictures gallery'] = 'Purger toutes les notes de la galerie';
    727$lang['Rate purge completed successfully'] = 'Purge total des notes effectuée avec succès';
    8 $lang['Purge - Plugin Delete Hit/Rate'] = 'Purger - Plugin Delete Hit/Rate';
    928$lang['Purge hit of the photo'] = 'Purger le hit de la photo';
    1029$lang['Purge rate of the photo'] = 'Purger la note de la photo';
  • extensions/delete_hit_rate/main.inc.php

    r9796 r31436  
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=520
    77Author: ddtddt
    8 Author URI: http://piwigo.org/
     8Author URI: http://temmii.com/piwigo/
    99*/
     10// +-----------------------------------------------------------------------+
     11// | Delete Hit/Rate plugin for piwigo                                     |
     12// +-----------------------------------------------------------------------+
     13// | Copyright(C) 2011-2016 ddtddt               http://temmii.com/piwigo/ |
     14// +-----------------------------------------------------------------------+
     15// | This program is free software; you can redistribute it and/or modify  |
     16// | it under the terms of the GNU General Public License as published by  |
     17// | the Free Software Foundation                                          |
     18// |                                                                       |
     19// | This program is distributed in the hope that it will be useful, but   |
     20// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     21// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     22// | General Public License for more details.                              |
     23// |                                                                       |
     24// | You should have received a copy of the GNU General Public License     |
     25// | along with this program; if not, write to the Free Software           |
     26// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     27// | USA.                                                                  |
     28// +-----------------------------------------------------------------------+
    1029
    1130if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
Note: See TracChangeset for help on using the changeset viewer.