source: extensions/DownloadSinceThumbnail/main.inc.php @ 31376

Last change on this file since 31376 was 31376, checked in by ddtddt, 5 years ago

[extensions] - DownloadSinceThumbnail - first commit

File size: 2.2 KB
Line 
1<?php
2/*
3Plugin Name: Download Since Thumbnail
4Version: 2.7.0
5Description:
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
7Author: TEMMII
8Author URI: http://temmii.com/
9*/
10
11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
12
13global $conf, $prefixeTable;
14
15define('DST_ID',          basename(dirname(__FILE__)));
16define('DST_PATH',        PHPWG_PLUGINS_PATH . DST_ID . '/');
17
18add_event_handler('init', 'DST_init');
19add_event_handler('loc_end_index_thumbnails', 'DST_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
20
21
22function DST_init()
23{
24  if (mobile_theme())
25  {
26    return;
27  }
28  load_language('plugin.lang', DST_PATH);
29   
30}
31
32function DST_thumbnails_list($tpl_thumbnails_var, $pictures)
33{
34  if (is_a_guest()) return $tpl_thumbnails_var;
35
36  global $page, $template,$conf, $user;
37
38  $template->set_prefilter('index_thumbnails', 'DST_prefilter_thumbnails');
39  $template->set_filename('DST', realpath(DST_PATH.'dst.tpl'));
40  $template->append('head_elements',$template->parse('DST',true));
41
42 
43  // the content is different on collection edition page and no button on batch downloader set edition page
44  if (empty($pictures))
45  {
46    return $tpl_thumbnails_var;
47  }
48
49 // $image_ids = array_map(create_function('$i', 'return $i["id"];'), $pictures);
50
51  $query = '
52  SELECT enabled_high
53  FROM '.USER_INFOS_TABLE.'
54  WHERE user_id = \''.$user['id'].'\'
55  ;';
56  $result = pwg_query($query);
57  $row = pwg_db_fetch_assoc($result);
58  if($row['enabled_high']=='true'){
59        $template->assign('PLUG_DST', 'ok');
60  }
61  foreach ($tpl_thumbnails_var as &$thumbnail)
62  {
63    $thumbnail['dowpic']=DST_PATH.'save.png';
64  }
65 
66  $template->func_combine_css(array('id'=>'dst','path'=>DST_PATH.'dst.css'));
67 
68  return $tpl_thumbnails_var;
69}
70
71function DST_prefilter_thumbnails($content, &$smarty) {
72        global $template;
73
74       
75 $search = '#(<span class="wrap2">)#';
76 $replace = '$1
77  {strip}{if isset($PLUG_DST)}
78  <form method="post" >
79  <a href="{$thumbnail.path}" class="dowpica" data-id="{$thumbnail.id}" download="{$thumbnail.name}" title="{\'Download this file\'|@translate}" rel="nofollow">
80  <img class="dowpic" src="{$thumbnail.dowpic}" /></a>
81  </form>
82  {/if}{/strip}
83';
84
85  return preg_replace($search, $replace, $content);
86       
87}
88
Note: See TracBrowser for help on using the repository browser.