1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Memories for Piwigo by TEMMII | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2020-2021 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 | // +-----------------------------------------------------------------------+ |
---|
21 | |
---|
22 | function listyears(){ |
---|
23 | global $conf, $template; |
---|
24 | $confpfoya = safe_unserialize($conf['pfoya']); |
---|
25 | |
---|
26 | for ($i = 1; $i <= $confpfoya['pfoya_datemax']; $i++) { |
---|
27 | $daydate=date("Y-m-d", strtotime('-'.$i.' year')); |
---|
28 | |
---|
29 | $query = ' |
---|
30 | SELECT COUNT(DISTINCT(i.id)) as count |
---|
31 | FROM '.IMAGES_TABLE.' AS i |
---|
32 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id |
---|
33 | INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id |
---|
34 | WHERE ' . |
---|
35 | get_sql_condition_FandF( |
---|
36 | array( |
---|
37 | 'forbidden_categories' => 'category_id', |
---|
38 | 'visible_categories' => 'category_id', |
---|
39 | 'visible_images' => 'image_id', |
---|
40 | ), |
---|
41 | '', true |
---|
42 | ); |
---|
43 | $query .= ' |
---|
44 | and DATE ('.$confpfoya['pfoya_dateb'].') ="'.$daydate.'";'; |
---|
45 | |
---|
46 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
47 | if ($i == 1){ |
---|
48 | $items = array( |
---|
49 | 'NB_IMAGES' => $row['count'], |
---|
50 | 'URL' => make_index_url(array('section' => 'memories-1-year-ago')), |
---|
51 | 'LABEL' => l10n('1 year ago'), |
---|
52 | ); |
---|
53 | $template->append('pfoyas', $items); |
---|
54 | }else{ |
---|
55 | $items = array( |
---|
56 | 'NB_IMAGES' => $row['count'], |
---|
57 | 'URL' => make_index_url(array('section' => 'memories-'.$i.'-years-ago')), |
---|
58 | 'LABEL' => l10n('%d years ago',$i), |
---|
59 | ); |
---|
60 | $template->append('pfoyas', $items); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | function listyearsBlock(){ |
---|
67 | global $conf, $template; |
---|
68 | $confpfoya = safe_unserialize($conf['pfoya']); |
---|
69 | $bnipfoya=0; |
---|
70 | for ($i = 1; $i <= $confpfoya['pfoya_datemax']; $i++) { |
---|
71 | $daydate=date("Y-m-d", strtotime('-'.$i.' year')); |
---|
72 | $query = ' |
---|
73 | SELECT COUNT(DISTINCT(i.id)) as count |
---|
74 | FROM '.IMAGES_TABLE.' AS i |
---|
75 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id |
---|
76 | INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id |
---|
77 | WHERE ' . |
---|
78 | get_sql_condition_FandF( |
---|
79 | array( |
---|
80 | 'forbidden_categories' => 'category_id', |
---|
81 | 'visible_categories' => 'category_id', |
---|
82 | 'visible_images' => 'image_id', |
---|
83 | ), |
---|
84 | '', true |
---|
85 | ); |
---|
86 | $query .= ' |
---|
87 | and DATE ('.$confpfoya['pfoya_dateb'].') ="'.$daydate.'";'; |
---|
88 | |
---|
89 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
90 | $bnipfoya += $row['count']; |
---|
91 | if ($i == 1){ |
---|
92 | $items = array( |
---|
93 | 'NB_IMAGES' => $row['count'], |
---|
94 | 'URL' => make_index_url(array('section' => 'memories-1-year-ago')), |
---|
95 | 'LABEL' => l10n('1 year ago'), |
---|
96 | ); |
---|
97 | }else{ |
---|
98 | $items = array( |
---|
99 | 'NB_IMAGES' => $row['count'], |
---|
100 | 'URL' => make_index_url(array('section' => 'memories-'.$i.'-years-ago')), |
---|
101 | 'LABEL' => l10n('%d years ago',$i), |
---|
102 | ); |
---|
103 | } |
---|
104 | |
---|
105 | $template->append('pfoyasblock', $items); |
---|
106 | } |
---|
107 | $template->assign('BNIPFOYA',$bnipfoya); |
---|
108 | } |
---|
109 | |
---|
110 | function ws_memories_photos_list($params, &$service){ |
---|
111 | $_SESSION['memodate']=$params['memodate']; |
---|
112 | } |
---|
113 | ?> |
---|