source: trunk/admin/themes/default/template/updates_ext.tpl @ 10538

Last change on this file since 10538 was 10538, checked in by patdenice, 13 years ago

feature:2271
Add pwg.extensions.checkUpdates method to webservices.
Add a warning message on intro page if update is availble for piwigo or extensions.
Add an "Ignore All" button on extensions update page.

File size: 9.6 KB
Line 
1{combine_script id='jquery.ajaxmanager' load='footer' require='jquery' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
2{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'}
3{combine_css path="admin/themes/default/uploadify.jGrowl.css"}
4
5{footer_script require='jquery.effects.blind,jquery.ajaxmanager,jquery.jgrowl'}
6var pwg_token = '{$PWG_TOKEN}';
7var extList = new Array();
8var confirmMsg  = '{'Are you sure?'|@translate|@escape:'javascript'}';
9var errorHead   = '{'ERROR'|@translate|@escape:'javascript'}';
10var successHead = '{'Update Complete'|@translate|@escape:'javascript'}';
11var errorMsg    = '{'an error happened'|@translate|@escape:'javascript'}';
12var restoreMsg  = '{'Reset ignored updates'|@translate|@escape:'javascript'}';
13
14{literal}
15var todo = 0;
16var queuedManager = $.manageAjax.create('queued', {
17        queue: true, 
18        maxRequests: 1,
19  beforeSend: function() { autoupdate_bar_toggle(1); },
20  complete: function() { autoupdate_bar_toggle(-1); }
21});
22
23function updateAll() {
24  if (confirm(confirmMsg)) {
25    jQuery('.updateExtension').each( function() {
26      if (jQuery(this).parents('div').css('display') == 'block')
27        jQuery(this).click();
28    });
29  }
30};
31
32function ignoreAll() {
33  jQuery('.ignoreExtension').each( function() {
34    if (jQuery(this).parents('div').css('display') == 'block')
35      jQuery(this).click();
36  });
37};
38
39function resetIgnored() {
40  jQuery.ajax({
41    type: 'GET',
42    url: 'ws.php',
43    dataType: 'json',
44    data: { method: 'pwg.extensions.ignoreUpdate', reset: true, pwg_token: pwg_token, format: 'json' },
45    success: function(data) {
46      if (data['stat'] == 'ok') {
47        jQuery(".pluginBox, fieldset").show();
48        jQuery("#update_all").show();
49        jQuery("#ignore_all").show();
50        jQuery("#up_to_date").hide();
51        jQuery("#reset_ignore").hide();
52        jQuery("#ignored").hide();
53        checkFieldsets();
54      }
55    }
56  });
57};
58
59function checkFieldsets() {
60  var types = new Array('plugins', 'themes', 'languages');
61  var total = 0;
62  var ignored = 0;
63  for (i=0;i<3;i++) {
64    nbExtensions = 0;
65    jQuery("div[id^='"+types[i]+"_']").each(function(index) {
66      if (jQuery(this).css('display') == 'block')
67        nbExtensions++;
68      else
69        ignored++;
70    });
71    total = total + nbExtensions;
72    if (nbExtensions == 0)
73      jQuery("#"+types[i]).hide();
74  }
75
76  if (total == 0) {
77    jQuery("#update_all").hide();
78    jQuery("#ignore_all").hide();
79    jQuery("#up_to_date").show();
80  }
81  if (ignored > 0) {
82    jQuery("#reset_ignore").val(restoreMsg + ' (' + ignored + ')');
83  }
84};
85
86function updateExtension(type, id, revision) {
87  queuedManager.add({
88    type: 'GET',
89    dataType: 'json',
90    url: 'ws.php',
91    data: { method: 'pwg.extensions.update', type: type, id: id, revision: revision, pwg_token: pwg_token, format: 'json' },
92    success: function(data) {
93      if (data['stat'] == 'ok') {
94        jQuery.jGrowl( data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false });
95        jQuery("#"+type+"_"+id).remove();
96        checkFieldsets();
97      } else {
98        jQuery.jGrowl( data['result'], { theme: 'error', header: errorHead, sticky: true });
99      }
100    },
101    error: function(data) {
102      jQuery.jGrowl( errorMsg, { theme: 'error', header: errorHead, sticky: true });
103    }
104  });
105};
106
107function ignoreExtension(type, id) {
108  queuedManager.add({
109    type: 'GET',
110    url: 'ws.php',
111    dataType: 'json',
112    data: { method: 'pwg.extensions.ignoreUpdate', type: type, id: id, pwg_token: pwg_token, format: 'json' },
113    success: function(data) {
114      if (data['stat'] == 'ok') {
115        jQuery("#"+type+"_"+id).hide();
116        jQuery("#reset_ignore").show();
117        checkFieldsets();
118      }
119    }
120  });
121};
122
123function autoupdate_bar_toggle(i) {
124  todo = todo + i;
125  if ((i == 1 && todo == 1) || (i == -1 && todo == 0))
126    jQuery('.autoupdate_bar').toggle();
127}
128
129jQuery(document).ready(function() {
130        jQuery("td[id^='desc_'], p[id^='revdesc_']").click(function() {
131                id = this.id.split('_');
132                jQuery("#revdesc_"+id[1]).toggle('blind');
133    jQuery(".button_"+id[1]).toggle();
134                return false;
135        });
136});
137
138checkFieldsets();
139{/literal}
140{/footer_script}
141
142<div class="titrePage">
143  <h2>{'Updates'|@translate}</h2>
144</div>
145
146<div class="autoupdate_bar">
147<br>
148<input type="submit" id="update_all" value="{'Update All'|@translate}" onClick="updateAll(); return false;">
149<input type="submit" id="ignore_all" value="{'Ignore All'|@translate}" onClick="ignoreAll(); return false;">
150<input type="submit" id="reset_ignore" value="{'Reset ignored updates'|@translate}" onClick="resetIgnored(); return false;" {if !$SHOW_RESET}style="display:none;"{/if}>
151</div>
152<div class="autoupdate_bar" style="display:none;">
153{'Please wait...'|@translate}<br><img src="admin/themes/default/images/ajax-loader-bar.gif">
154</div>
155
156<p id="up_to_date" style="display:none; text-align:left; margin-left:20px;">{'All extensions are up to date.'|@translate}</p>
157
158{if not empty($update_plugins)}
159<div>
160<fieldset id="plugins">
161<legend>{'Plugins'|@translate}</legend>
162{foreach from=$update_plugins item=plugin name=plugins_loop}
163<div class="pluginBox" id="plugins_{$plugin.EXT_ID}" {if $plugin.IGNORED}style="display:none;"{/if}>
164  <table>
165    <tr>
166      <td class="pluginBoxNameCell">
167        {$plugin.EXT_NAME}
168      </td>
169      <td>
170        <a href="#" onClick="updateExtension('plugins', '{$plugin.EXT_ID}', {$plugin.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
171        | <a href="{$plugin.URL_DOWNLOAD}">{'Download'|@translate}</a>
172        | <a href="#" onClick="ignoreExtension('plugins', '{$plugin.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
173      </td>
174    </tr>
175    <tr>
176      <td>
177        {'Version'|@translate} {$plugin.CURRENT_VERSION}
178      </td>
179      <td class="pluginDesc" id="desc_{$plugin.ID}">
180        <em>{'Downloads'|@translate}: {$plugin.DOWNLOADS}</em>
181        <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/plus.gif" alt="" class="button_{$plugin.ID}">
182        <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/minus.gif" alt="" class="button_{$plugin.ID}" style="display:none;">
183        {'New Version'|@translate} : {$plugin.NEW_VERSION}
184        | {'By %s'|@translate|@sprintf:$plugin.AUTHOR}
185      </td>
186    </tr>
187    <tr>
188      <td></td>
189      <td class="pluginDesc">
190        <p id="revdesc_{$plugin.ID}" style="display:none;">{$plugin.REV_DESC|htmlspecialchars|nl2br}</p>
191      </td>
192    </tr>
193  </table>
194</div>
195{/foreach}
196</fieldset>
197</div>
198{/if}
199
200{if not empty($update_themes)}
201<div>
202<fieldset id="themes">
203<legend>{'Themes'|@translate}</legend>
204{foreach from=$update_themes item=theme name=themes_loop}
205<div class="pluginBox" id="themes_{$theme.EXT_ID}" {if $theme.IGNORED}style="display:none;"{/if}>
206  <table>
207    <tr>
208      <td class="pluginBoxNameCell">
209        {$theme.EXT_NAME}
210      </td>
211      <td>
212        <a href="#" onClick="updateExtension('themes', '{$theme.EXT_ID}', {$theme.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
213        | <a href="{$theme.URL_DOWNLOAD}">{'Download'|@translate}</a>
214        | <a href="#" onClick="ignoreExtension('themes', '{$theme.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
215      </td>
216    </tr>
217    <tr>
218      <td>
219        {'Version'|@translate} {$theme.CURRENT_VERSION}
220      </td>
221      <td class="pluginDesc" id="desc_{$theme.ID}">
222        <em>{'Downloads'|@translate}: {$theme.DOWNLOADS}</em>
223        <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/plus.gif" alt="" class="button_{$theme.ID}">
224        <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/minus.gif" alt="" class="button_{$theme.ID}" style="display:none;">
225        {'New Version'|@translate} : {$theme.NEW_VERSION}
226        | {'By %s'|@translate|@sprintf:$theme.AUTHOR}
227      </td>
228    </tr>
229    <tr>
230      <td></td>
231      <td class="pluginDesc">
232        <p id="revdesc_{$theme.ID}" style="display:none;">{$theme.REV_DESC|htmlspecialchars|nl2br}</p>
233      </td>
234    </tr>
235  </table>
236</div>
237{/foreach}
238</fieldset>
239</div>
240{/if}
241
242{if not empty($update_languages)}
243<div>
244<fieldset id="languages">
245<legend>{'Languages'|@translate}</legend>
246{foreach from=$update_languages item=language name=languages_loop}
247<div class="pluginBox" id="languages_{$language.EXT_ID}" {if $language.IGNORED}style="display:none;"{/if}>
248  <table>
249    <tr>
250      <td class="pluginBoxNameCell">
251        {$language.EXT_NAME}
252      </td>
253      <td>
254        <a href="#" onClick="updateExtension('languages', '{$language.EXT_ID}', {$language.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
255        | <a href="{$language.URL_DOWNLOAD}">{'Download'|@translate}</a>
256        | <a href="#" onClick="ignoreExtension('languages', '{$language.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
257      </td>
258    </tr>
259    <tr>
260      <td>
261        {'Version'|@translate} {$language.CURRENT_VERSION}
262      </td>
263      <td class="pluginDesc" id="desc_{$language.ID}">
264        <em>{'Downloads'|@translate}: {$language.DOWNLOADS}</em>
265        <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/plus.gif" alt="" class="button_{$language.ID}">
266        <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/minus.gif" alt="" class="button_{$language.ID}" style="display:none;">
267        {'New Version'|@translate} : {$language.NEW_VERSION}
268        | {'By %s'|@translate|@sprintf:$language.AUTHOR}
269      </td>
270    </tr>
271    <tr>
272      <td></td>
273      <td class="pluginDesc">
274        <p id="revdesc_{$language.ID}" style="display:none;">{$language.REV_DESC|htmlspecialchars|nl2br}</p>
275      </td>
276    </tr>
277  </table>
278</div>
279{/foreach}
280</fieldset>
281</div>
282{/if}
Note: See TracBrowser for help on using the repository browser.