[3609] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 4 | |
---|
[9369] | 5 | global $pwg_loaded_plugins; |
---|
| 6 | |
---|
| 7 | // Delete module |
---|
[9737] | 8 | if (isset($_GET['del'])) |
---|
[9369] | 9 | { |
---|
| 10 | pwg_query('DELETE FROM ' . STUFFS_TABLE . ' WHERE id = ' . $_GET['del'] . ' LIMIT 1;'); |
---|
[9738] | 11 | redirect($my_base_url); |
---|
[9369] | 12 | } |
---|
| 13 | |
---|
| 14 | // Save order |
---|
[9737] | 15 | if (isset($_POST['submitOrder'])) |
---|
[3609] | 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(' |
---|
| 25 | UPDATE ' . STUFFS_TABLE . ' |
---|
| 26 | SET pos=' . $pos++ . ' , id_line='.$id_line.', width='.$width.' |
---|
| 27 | WHERE id=' . $id . ' LIMIT 1'); |
---|
| 28 | } |
---|
[7340] | 29 | |
---|
[7855] | 30 | pwg_query(' |
---|
| 31 | UPDATE ' . STUFFS_TABLE . ' |
---|
[9449] | 32 | SET datas = "'.addslashes(serialize(!isset($_POST['hidemb']))).'" |
---|
[7855] | 33 | WHERE id=0;'); |
---|
| 34 | |
---|
[3609] | 35 | array_push($page['infos'], l10n('stuffs_order_saved')); |
---|
| 36 | } |
---|
| 37 | |
---|
[9369] | 38 | // Display |
---|
[9410] | 39 | $q = 'SELECT id, name, descr, path, id_line, width, datas |
---|
[3609] | 40 | FROM ' . STUFFS_TABLE . ' |
---|
| 41 | ORDER 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 | |
---|
[19921] | 58 | while ($module = pwg_db_fetch_assoc($result)) |
---|
[3609] | 59 | { |
---|
[9369] | 60 | $module['name'] = !empty($module['path']) ? $module['name'] : l10n('stuffs_main_block'); |
---|
[3609] | 61 | |
---|
[9449] | 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 | } |
---|
[9410] | 67 | if (!empty($module['path'])) |
---|
| 68 | { |
---|
| 69 | preg_match('#^'.preg_quote(PHPWG_PLUGINS_PATH).'([^/]*?)/#', $module['path'], $match); |
---|
[9449] | 70 | if (!isset($pwg_loaded_plugins[$match[1]])) |
---|
| 71 | { |
---|
| 72 | $missing_message = l10n('stuffs_parent_plugin_is_missing'); |
---|
| 73 | } |
---|
[9410] | 74 | } |
---|
| 75 | |
---|
[3609] | 76 | $template->append('modules', array( |
---|
| 77 | 'ID' => $module['id'], |
---|
[28915] | 78 | 'NAME' => trigger_change('render_stuffs_name', $module['name']), |
---|
[3609] | 79 | 'DESC' => $module['descr'], |
---|
[9369] | 80 | 'PATH' => $module['path'], |
---|
| 81 | 'TYPE_NAME' => (isset($modules[$module['path']]['name']) ? $modules[$module['path']]['name'] : ''), |
---|
[3609] | 82 | 'POS' => 10 * $pos++, |
---|
| 83 | 'ID_LINE_OPTIONS' => $id_line_options, |
---|
| 84 | 'ID_LINE_SELECTED' => $module['id_line'], |
---|
[9369] | 85 | 'WIDTH' => $module['width'], |
---|
| 86 | 'ID' => $module['id'], |
---|
[9738] | 87 | 'U_EDIT' => $my_base_url.'-edit_module&edit='.$module['id'], |
---|
| 88 | 'U_DELETE' => $my_base_url.'&del=' . $module['id'], |
---|
[9449] | 89 | 'MISSING' => $missing_message, |
---|
[9369] | 90 | ) |
---|
| 91 | ); |
---|
[7855] | 92 | |
---|
[9449] | 93 | if (empty($module['path'])) |
---|
[7855] | 94 | { |
---|
[9449] | 95 | $show = unserialize($module['datas']); |
---|
| 96 | $template->assign('HIDEMB', !$show); |
---|
[7855] | 97 | } |
---|
[3609] | 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 | |
---|
[3300] | 103 | ?> |
---|