source: extensions/PWG_Stuffs/trunk/admin/manage.inc.php @ 28915

Last change on this file since 28915 was 28915, checked in by plg, 10 years ago

compatibility with Piwigo 2.7 (still compatible with Piwigo 2.6, but no more 2.5), change trigger_event into trigger_change

File size: 2.8 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $pwg_loaded_plugins;
6
7// Delete module
8if (isset($_GET['del']))
9{
10  pwg_query('DELETE FROM ' . STUFFS_TABLE . ' WHERE id = ' . $_GET['del'] . ' LIMIT 1;');
11  redirect($my_base_url);
12}
13
14// Save order
15if (isset($_POST['submitOrder']))
16{
17  asort($_POST['position'], SORT_NUMERIC);
18  $pos = 1;
19  foreach($_POST['position'] as $id => $old_pos)
20  {
21    $id_line = !empty($_POST['id_line'][$id]) ? '"'.$_POST['id_line'][$id].'"' : 'NULL';
22    $width = (!empty($_POST['width'][$id]) and is_numeric($_POST['width'][$id])) ? '"'.$_POST['width'][$id].'"' : 'NULL';
23
24    pwg_query('
25UPDATE ' . STUFFS_TABLE . '
26SET pos=' . $pos++ . ' , id_line='.$id_line.', width='.$width.'
27WHERE id=' . $id . ' LIMIT 1');
28  }
29
30    pwg_query('
31UPDATE ' . STUFFS_TABLE . '
32SET datas = "'.addslashes(serialize(!isset($_POST['hidemb']))).'"
33WHERE id=0;');
34
35  array_push($page['infos'], l10n('stuffs_order_saved'));
36}
37
38// Display
39$q = 'SELECT id, name, descr, path, id_line, width, datas
40FROM ' . STUFFS_TABLE . '
41ORDER BY pos ASC;';
42$result = pwg_query($q);
43$num = 0;
44$pos = 1;
45$id_line_options = array(
46    '' => '-',
47    'A' => 'A',
48    'B' => 'B',
49    'C' => 'C',
50    'D' => 'D',
51    'E' => 'E',
52    'F' => 'F',
53    'G' => 'G',
54    'H' => 'H',
55    'I' => 'I',
56    'J' => 'J');
57
58while ($module = pwg_db_fetch_assoc($result))
59{
60  $module['name'] = !empty($module['path']) ? $module['name'] : l10n('stuffs_main_block');
61
62  $missing_message = '';
63  if ($module['path'] == PHPWG_PLUGINS_PATH.'piclens/stuffs_module/' and !file_exists(PICLENS_PATH.'stuffs_module/main.inc.php'))
64  {
65    $missing_message = l10n('stuffs_piclens_need_upgrade');
66  }
67  if (!empty($module['path']))
68  {
69    preg_match('#^'.preg_quote(PHPWG_PLUGINS_PATH).'([^/]*?)/#', $module['path'], $match);
70    if (!isset($pwg_loaded_plugins[$match[1]]))
71    {
72      $missing_message = l10n('stuffs_parent_plugin_is_missing');
73    }
74  }
75
76  $template->append('modules', array(
77    'ID' => $module['id'],
78    'NAME' => trigger_change('render_stuffs_name', $module['name']),
79    'DESC' => $module['descr'],
80    'PATH' => $module['path'],
81    'TYPE_NAME' => (isset($modules[$module['path']]['name']) ? $modules[$module['path']]['name'] : ''),
82    'POS' => 10 * $pos++,
83    'ID_LINE_OPTIONS' => $id_line_options,
84    'ID_LINE_SELECTED' => $module['id_line'],
85    'WIDTH' => $module['width'],
86    'ID' => $module['id'],
87    'U_EDIT' => $my_base_url.'-edit_module&amp;edit='.$module['id'],
88    'U_DELETE' => $my_base_url.'&amp;del=' . $module['id'],
89    'MISSING' => $missing_message,
90    )
91  );
92
93  if (empty($module['path']))
94  {
95    $show = unserialize($module['datas']);
96    $template->assign('HIDEMB', !$show); 
97  }
98}
99
100$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/manage.tpl');
101$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
102
103?>
Note: See TracBrowser for help on using the repository browser.