1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Manage Properties Photos plugin for Piwigo | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2014-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 | // +-----------------------------------------------------------------------+ |
---|
21 | |
---|
22 | //Ajout du prefiltre |
---|
23 | add_event_handler('loc_begin_picture', 'add_info_photo_pre', 05); |
---|
24 | |
---|
25 | function add_info_photo_pre() { |
---|
26 | global $template; |
---|
27 | $template->set_prefilter('picture', 'add_info_photo_preT'); |
---|
28 | } |
---|
29 | |
---|
30 | function add_info_photo_preT($content, &$smarty) { |
---|
31 | |
---|
32 | global $conf; |
---|
33 | |
---|
34 | $search = '/(<dl id="standard" class="imageInfoTable">).*({if isset\(\$metadata\)})/is'; |
---|
35 | |
---|
36 | $repla='<dl id="standard" class="imageInfoTable">{strip} |
---|
37 | {foreach from=$add_info_photos item=addinfophotos} |
---|
38 | {if $addinfophotos.AIPID == 1 and isset($INFO_AUTHOR)} |
---|
39 | <div id="Author" class="imageInfo"> |
---|
40 | <dt>{\'Author\'|@translate}</dt> |
---|
41 | <dd>{$INFO_AUTHOR}</dd> |
---|
42 | </div> |
---|
43 | {else if $addinfophotos.AIPID == 2 and isset($INFO_CREATION_DATE)} |
---|
44 | <div id="datecreate" class="imageInfo"> |
---|
45 | <dt>{\'Created on\'|@translate}</dt> |
---|
46 | <dd>{$INFO_CREATION_DATE}</dd> |
---|
47 | </div> |
---|
48 | {else if $addinfophotos.AIPID == 3 and isset($INFO_POSTED_DATE)} |
---|
49 | <div id="datepost" class="imageInfo"> |
---|
50 | <dt>{\'Posted on\'|@translate}</dt> |
---|
51 | <dd>{$INFO_POSTED_DATE}</dd> |
---|
52 | </div> |
---|
53 | {else if $addinfophotos.AIPID == 4 and isset($INFO_DIMENSIONS)} |
---|
54 | <div id="Dimensions" class="imageInfo"> |
---|
55 | <dt>{\'Dimensions\'|@translate}</dt> |
---|
56 | <dd>{$INFO_DIMENSIONS}</dd> |
---|
57 | </div> |
---|
58 | {else if $addinfophotos.AIPID == 5} |
---|
59 | <div id="File" class="imageInfo"> |
---|
60 | <dt>{\'File\'|@translate}</dt> |
---|
61 | <dd>{$INFO_FILE}</dd> |
---|
62 | </div> |
---|
63 | {else if $addinfophotos.AIPID == 6 and isset($INFO_FILESIZE)} |
---|
64 | <div id="Filesize" class="imageInfo"> |
---|
65 | <dt>{\'Filesize\'|@translate}</dt> |
---|
66 | <dd>{$INFO_FILESIZE}</dd> |
---|
67 | </div> |
---|
68 | {else if $addinfophotos.AIPID == 7 and isset($related_tags)} |
---|
69 | <div id="Tags" class="imageInfo"> |
---|
70 | <dt>{\'Tags\'|@translate}</dt> |
---|
71 | <dd> |
---|
72 | {foreach from=$related_tags item=tag name=tag_loop}{if !$smarty.foreach.tag_loop.first}, {/if}<a href="{$tag.URL}">{$tag.name}</a>{/foreach} |
---|
73 | </dd> |
---|
74 | </div> |
---|
75 | {else if $addinfophotos.AIPID == 8 and isset($related_categories)} |
---|
76 | <div id="Categories" class="imageInfo"> |
---|
77 | <dt>{\'Albums\'|@translate}</dt> |
---|
78 | <dd> |
---|
79 | <ul> |
---|
80 | {foreach from=$related_categories item=cat} |
---|
81 | <li>{$cat}</li> |
---|
82 | {/foreach} |
---|
83 | </ul> |
---|
84 | </dd> |
---|
85 | </div> |
---|
86 | {else if $addinfophotos.AIPID == 9} |
---|
87 | <div id="Visits" class="imageInfo"> |
---|
88 | <dt>{\'Visits\'|@translate}</dt> |
---|
89 | <dd>{$INFO_VISITS}</dd> |
---|
90 | </div> |
---|
91 | {else if $addinfophotos.AIPID == 10 and isset($rate_summary)} |
---|
92 | <div id="Average" class="imageInfo"> |
---|
93 | <dt>{\'Rating score\'|@translate}</dt> |
---|
94 | <dd> |
---|
95 | {if $rate_summary.count} |
---|
96 | <span id="ratingScore">{$rate_summary.score}</span> <span id="ratingCount">({$rate_summary.count|@translate_dec:\'%d rate\':\'%d rates\'})</span> |
---|
97 | {else} |
---|
98 | <span id="ratingScore">{\'no rate\'|@translate}</span> <span id="ratingCount"></span> |
---|
99 | {/if} |
---|
100 | </dd> |
---|
101 | </div> |
---|
102 | {if isset($rating)} |
---|
103 | <div id="rating" class="imageInfo"> |
---|
104 | <dt> |
---|
105 | <span id="updateRate">{if isset($rating.USER_RATE)}{\'Update your rating\'|@translate}{else}{\'Rate this photo\'|@translate}{/if}</span> |
---|
106 | </dt> |
---|
107 | <dd> |
---|
108 | <form action="{$rating.F_ACTION}" method="post" id="rateForm" style="margin:0;"> |
---|
109 | <div> |
---|
110 | {foreach from=$rating.marks item=mark name=rate_loop} |
---|
111 | {if isset($rating.USER_RATE) && $mark==$rating.USER_RATE} |
---|
112 | <input type="button" name="rate" value="{$mark}" class="rateButtonSelected" title="{$mark}"> |
---|
113 | {else} |
---|
114 | <input type="submit" name="rate" value="{$mark}" class="rateButton" title="{$mark}"> |
---|
115 | {/if} |
---|
116 | {/foreach} |
---|
117 | {strip}{combine_script id=\'core.scripts\' load=\'async\' path=\'themes/default/js/scripts.js\'} |
---|
118 | {combine_script id=\'rating\' load=\'async\' require=\'core.scripts\' path=\'themes/default/js/rating.js\'} |
---|
119 | {footer_script} |
---|
120 | var _pwgRatingAutoQueue = _pwgRatingAutoQueue||[]; |
---|
121 | _pwgRatingAutoQueue.push( {ldelim}rootUrl: \'{$ROOT_URL}\', image_id: {$current.id}, |
---|
122 | onSuccess : function(rating) {ldelim} |
---|
123 | var e = document.getElementById("updateRate"); |
---|
124 | if (e) e.innerHTML = "{\'Update your rating\'|@translate|@escape:\'javascript\'}"; |
---|
125 | e = document.getElementById("ratingScore"); |
---|
126 | if (e) e.innerHTML = rating.score; |
---|
127 | e = document.getElementById("ratingCount"); |
---|
128 | if (e) {ldelim} |
---|
129 | if (rating.count == 1) {ldelim} |
---|
130 | e.innerHTML = "({\'%d rate\'|@translate|@escape:\'javascript\'})".replace( "%d", rating.count); |
---|
131 | } else {ldelim} |
---|
132 | e.innerHTML = "({\'%d rates\'|@translate|@escape:\'javascript\'})".replace( "%d", rating.count); |
---|
133 | } |
---|
134 | {rdelim} |
---|
135 | {rdelim}{rdelim} ); |
---|
136 | {/footer_script} |
---|
137 | {/strip} |
---|
138 | </div> |
---|
139 | </form> |
---|
140 | </dd> |
---|
141 | </div> |
---|
142 | {/if} |
---|
143 | {else if $addinfophotos.AIPID == 11 and $display_info.privacy_level and isset($available_permission_levels)} |
---|
144 | <div id="Privacy" class="imageInfo"> |
---|
145 | <dt>{\'Who can see this photo?\'|@translate}</dt> |
---|
146 | <dd> |
---|
147 | <div> |
---|
148 | <a id="privacyLevelLink" href>{$available_permission_levels[$current.level]}</a> |
---|
149 | </div> |
---|
150 | {combine_script id=\'core.scripts\' load=\'async\' path=\'themes/default/js/scripts.js\'} |
---|
151 | {footer_script require=\'jquery\'}{strip} |
---|
152 | function setPrivacyLevel(id, level){ |
---|
153 | (new PwgWS(\'{$ROOT_URL}\')).callService( |
---|
154 | "pwg.images.setPrivacyLevel", { image_id:id, level:level}, |
---|
155 | { |
---|
156 | method: "POST", |
---|
157 | onFailure: function(num, text) { alert(num + " " + text); }, |
---|
158 | onSuccess: function(result) { |
---|
159 | jQuery(\'#privacyLevelBox .switchCheck\').css(\'visibility\',\'hidden\'); |
---|
160 | jQuery(\'#switchLevel\'+level).prev(\'.switchCheck\').css(\'visibility\',\'visible\'); |
---|
161 | jQuery(\'#privacyLevelLink\').text(jQuery(\'#switchLevel\'+level).text()); |
---|
162 | } |
---|
163 | } |
---|
164 | ); |
---|
165 | } |
---|
166 | (SwitchBox=window.SwitchBox||[]).push("#privacyLevelLink", "#privacyLevelBox"); |
---|
167 | {/strip}{/footer_script} |
---|
168 | <div id="privacyLevelBox" class="switchBox" style="display:none"> |
---|
169 | {foreach from=$available_permission_levels item=label key=level} |
---|
170 | <span class="switchCheck"{if $level != $current.level} style="visibility:hidden"{/if}>✔ </span> |
---|
171 | <a id="switchLevel{$level}" href="javascript:setPrivacyLevel({$current.id},{$level})">{$label}</a><br> |
---|
172 | {/foreach} |
---|
173 | </div> |
---|
174 | </dd> |
---|
175 | </div> |
---|
176 | {else if $addinfophotos.AIPWORDING == \'Description\' and isset($COMMENT_IMG)} |
---|
177 | <div id="Description" class="imageInfo"> |
---|
178 | <dt>{\'Description\'|@translate}</dt> |
---|
179 | <dd> |
---|
180 | {$COMMENT_IMG} |
---|
181 | </dd> |
---|
182 | </div> |
---|
183 | {footer_script} |
---|
184 | jQuery(document).ready(function(){ |
---|
185 | jQuery(".imageComment").hide(); |
---|
186 | }); |
---|
187 | {/footer_script} |
---|
188 | {else if $addinfophotos.AIPDATA} |
---|
189 | <div id="add_info" class="imageInfo"> |
---|
190 | <dt class="label">{$addinfophotos.AIPWORDING}</dt> |
---|
191 | <dd class="value">{$addinfophotos.AIPDATA}</dd> |
---|
192 | </div> |
---|
193 | {/if} |
---|
194 | {/foreach} |
---|
195 | {/strip} |
---|
196 | </dl> |
---|
197 | {if isset($metadata)} |
---|
198 | '; |
---|
199 | |
---|
200 | return preg_replace($search, $repla , $content); |
---|
201 | |
---|
202 | } |
---|
203 | |
---|
204 | add_event_handler('loc_begin_picture', 'add_InfoT'); |
---|
205 | |
---|
206 | function add_InfoT() { |
---|
207 | global $conf, $page, $template; |
---|
208 | |
---|
209 | if (!empty($page['image_id'])) { |
---|
210 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
211 | if ($PAED['state'] == 'active') |
---|
212 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
213 | |
---|
214 | $tab_add_info_one_photo = tab_add_info_by_photo_show(); |
---|
215 | |
---|
216 | if (pwg_db_num_rows($tab_add_info_one_photo)) { |
---|
217 | while ($info_photos = pwg_db_fetch_assoc($tab_add_info_one_photo)) { |
---|
218 | |
---|
219 | $d = data_info_photos($page['image_id'], $info_photos['id_prop_pho']); |
---|
220 | $row = pwg_db_fetch_assoc($d); |
---|
221 | |
---|
222 | $items = array( |
---|
223 | 'AIPID' => $info_photos['id_prop_pho'], |
---|
224 | 'AIPORDER' => $info_photos['orderprop'], |
---|
225 | 'AIPWORDING' => trigger_change('AP_render_content', $info_photos['wording']), |
---|
226 | 'AIPDATA' => trigger_change('AP_render_content', $row['data']), |
---|
227 | ); |
---|
228 | |
---|
229 | $template->append('add_info_photos', $items); |
---|
230 | } |
---|
231 | } |
---|
232 | |
---|
233 | $template->assign( |
---|
234 | array( |
---|
235 | 'A' => 'a' |
---|
236 | )); |
---|
237 | } |
---|
238 | } |
---|
239 | |
---|
240 | ?> |
---|