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