[3637] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * Plugin Name: CoolIris-Piclens |
---|
[3645] | 4 | * File : piclenswallconfig.php |
---|
| 5 | */ |
---|
[3637] | 6 | |
---|
| 7 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 8 | |
---|
| 9 | global $template, $page; |
---|
| 10 | |
---|
| 11 | $pwgstuff_ok = get_db_plugins('active','PWG_Stuffs'); |
---|
| 12 | $me = get_plugin_data($plugin_id); |
---|
| 13 | |
---|
| 14 | $template->set_filenames( |
---|
[3708] | 15 | array('plugin_admin_content' => PICLENS_ROOT.'/admin/piclenswallconfig.tpl', |
---|
| 16 | 'double_select' => 'double_select.tpl' |
---|
[3637] | 17 | ) ); |
---|
| 18 | |
---|
[3708] | 19 | |
---|
| 20 | |
---|
| 21 | // Switch on right side (=> ) |
---|
[27746] | 22 | if ( isset($_POST['falsify']) |
---|
[3708] | 23 | and isset($_POST['cat_true']) and count($_POST['cat_true']) > 0) |
---|
| 24 | { |
---|
| 25 | foreach ($_POST['cat_true'] as $cat) |
---|
| 26 | unset($me->my_config['piclens_wall_categories'][array_search($cat,$me->my_config['piclens_wall_categories'])]); |
---|
| 27 | |
---|
| 28 | $me->save_config(); |
---|
| 29 | |
---|
| 30 | } |
---|
| 31 | // Switch on left side ( <=) |
---|
[27746] | 32 | if ( isset($_POST['trueify']) |
---|
[3708] | 33 | and isset($_POST['cat_false']) and count($_POST['cat_false']) > 0) |
---|
| 34 | { |
---|
| 35 | |
---|
| 36 | $query = ' |
---|
| 37 | SELECT id, name, uppercats, global_rank |
---|
| 38 | FROM '.CATEGORIES_TABLE. |
---|
| 39 | ' WHERE id IN ("'.implode('","', $_POST['cat_false']).'");'; |
---|
| 40 | |
---|
| 41 | $result = pwg_query($query); |
---|
| 42 | $categories = array(); |
---|
| 43 | if (!empty($result)) |
---|
| 44 | { |
---|
[21238] | 45 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[3708] | 46 | array_push($categories, $row); |
---|
| 47 | } |
---|
| 48 | usort($categories, 'global_rank_compare'); |
---|
| 49 | |
---|
| 50 | if (!empty($result)) |
---|
| 51 | { |
---|
| 52 | foreach ($categories as $cat) |
---|
| 53 | { |
---|
| 54 | array_push($me->my_config['piclens_wall_categories'], $cat['id']); |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | $me->save_config(); |
---|
| 59 | } |
---|
[3637] | 60 | |
---|
| 61 | |
---|
| 62 | if (isset($_POST['submit'])) { |
---|
| 63 | $me->my_config['piclens_wall'] = isset($_POST['piclens_wall']); |
---|
| 64 | $me->my_config['piclens_wall_title'] = $_POST['piclens_wall_title']; |
---|
| 65 | $me->my_config['piclens_wall_height'] = $_POST['piclens_wall_height']; |
---|
| 66 | |
---|
| 67 | $me->my_config['piclens_wall_nav'] = isset($_POST['piclens_wall_nav']); |
---|
| 68 | $me->my_config['piclens_wall_cat_nav_replace'] = isset($_POST['categories_nav']) ? |
---|
[21238] | 69 | array_map("pwg_db_real_escape_string", $_POST['categories_nav']) : |
---|
[3637] | 70 | array(); |
---|
| 71 | $me->my_config['piclens_wall_specif'] = $_POST['piclens_wall_specif']; |
---|
| 72 | $me->my_config['piclens_wall_ontop'] = isset($_POST['piclens_wall_ontop']); |
---|
| 73 | $me->my_config['piclens_wall_oncat'] = isset($_POST['piclens_wall_oncat']); |
---|
| 74 | |
---|
| 75 | $me->my_config['piclens_wall_spec'] = isset($_POST['piclens_wall_spec']); |
---|
| 76 | $me->my_config['piclens_wall_spec_recentpics'] = isset($_POST['piclens_wall_spec_recentpics']); |
---|
| 77 | $me->my_config['piclens_wall_spec_recentcats'] = isset($_POST['piclens_wall_spec_recentcats']); |
---|
| 78 | $me->my_config['piclens_wall_spec_mostvisited'] = isset($_POST['piclens_wall_spec_mostvisited']); |
---|
| 79 | $me->my_config['piclens_wall_spec_bestrated'] = isset($_POST['piclens_wall_spec_bestrated']); |
---|
| 80 | $me->my_config['piclens_wall_spec_favorites'] = isset($_POST['piclens_wall_spec_favorites']); |
---|
| 81 | $me->my_config['piclens_wall_spec_tags'] = isset($_POST['piclens_wall_spec_tags']); |
---|
| 82 | |
---|
| 83 | $me->my_config['piclens_wall_swflocal'] = isset($_POST['piclens_wall_swflocal']); |
---|
| 84 | |
---|
| 85 | if ($pwgstuff_ok && $me->my_config['piclens_wall']) |
---|
| 86 | { |
---|
| 87 | array_push($page['errors'], l10n('piclens_admin_saveERR4')); |
---|
| 88 | $me->my_config['piclens_wall'] = false; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | $me->save_config(); |
---|
| 92 | array_push($page['infos'], l10n('piclens_admin_saveOK')); |
---|
| 93 | |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | // Copie fichier crossdomain a la racine |
---|
| 98 | $filename = $_SERVER['DOCUMENT_ROOT'].'/crossdomain.xml'; |
---|
| 99 | // copie du fichier crossdomain.xml |
---|
| 100 | if (isset($_POST['crossdomain_copy'])) |
---|
| 101 | { |
---|
| 102 | include_once(PICLENS_ADMIN_PATH . '/piclens_copy.php'); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | $query = ' |
---|
| 106 | SELECT id,name,uppercats,global_rank |
---|
| 107 | FROM '.CATEGORIES_TABLE.';'; |
---|
| 108 | |
---|
[3708] | 109 | display_select_cat_wrapper($query, |
---|
[3637] | 110 | $me->my_config['piclens_wall_cat_nav_replace'], |
---|
| 111 | 'categories_nav', |
---|
| 112 | true); |
---|
| 113 | |
---|
[3708] | 114 | |
---|
| 115 | // Test double select wall categories |
---|
| 116 | // Categories non prises en compte |
---|
| 117 | $query = ' |
---|
| 118 | SELECT id, name, uppercats, global_rank |
---|
| 119 | FROM '.CATEGORIES_TABLE. |
---|
| 120 | ' WHERE id not IN ("'.implode('","', $me->my_config['piclens_wall_categories']).'");'; |
---|
[3637] | 121 | |
---|
[3708] | 122 | $result = pwg_query($query); |
---|
| 123 | $categories = array(); |
---|
| 124 | if (!empty($result)) |
---|
| 125 | { |
---|
[21238] | 126 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[3708] | 127 | array_push($categories, $row); |
---|
| 128 | } |
---|
| 129 | usort($categories, 'global_rank_compare'); |
---|
[3637] | 130 | |
---|
[3708] | 131 | $tpl = array(); |
---|
| 132 | if (!empty($result)) |
---|
| 133 | { |
---|
| 134 | foreach ($categories as $cat) |
---|
| 135 | { |
---|
| 136 | $tpl[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], |
---|
| 137 | null, |
---|
| 138 | false); |
---|
| 139 | |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | $template->assign( 'category_option_false', $tpl); |
---|
| 143 | $template->assign( 'category_option_false_selected', array()); |
---|
[3637] | 144 | |
---|
[3708] | 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | // Categories prises en compte |
---|
| 149 | |
---|
| 150 | $query = ' |
---|
| 151 | SELECT id, name, uppercats, global_rank |
---|
| 152 | FROM '.CATEGORIES_TABLE. |
---|
| 153 | ' WHERE id IN ("'.implode('","', $me->my_config['piclens_wall_categories']).'");'; |
---|
| 154 | |
---|
| 155 | $result = pwg_query($query); |
---|
| 156 | $categories = array(); |
---|
| 157 | if (!empty($result)) |
---|
| 158 | { |
---|
[21238] | 159 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[3708] | 160 | array_push($categories, $row); |
---|
| 161 | } |
---|
| 162 | usort($categories, 'global_rank_compare'); |
---|
| 163 | $tpl2 = array(); |
---|
| 164 | if (!empty($result)) |
---|
| 165 | { |
---|
| 166 | foreach ($categories as $cat) |
---|
| 167 | { |
---|
| 168 | $tpl2[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], |
---|
| 169 | null, |
---|
| 170 | false); |
---|
| 171 | |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | $template->assign( 'category_option_true', $tpl2); |
---|
| 175 | $template->assign( 'category_option_true_selected', array()); |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | $template->assign(Array( |
---|
| 179 | 'F_ACTION' => '', |
---|
| 180 | 'L_CAT_OPTIONS_TRUE' => l10n('SelectedCat'), |
---|
| 181 | 'L_CAT_OPTIONS_FALSE' => l10n('NonSelectedCat'), |
---|
| 182 | )); |
---|
| 183 | |
---|
| 184 | |
---|
[3637] | 185 | $template->assign(array( |
---|
| 186 | 'PICLENS_COPY_CROSSDOMAIN' => file_exists($filename), |
---|
| 187 | 'PICLENS_PWGSTUFF' => ($pwgstuff_ok ? 'disabled="disabled"' : ''), |
---|
| 188 | 'PICLENS_PWGSTUFF1' => ($pwgstuff_ok ? l10n('piclens_label_pwgstuff1'): l10n('piclens_label_pwgstuff2')), |
---|
| 189 | 'PICLENS_WALL_ACTIVATED' => ($me->my_config['piclens_wall'] ? 'checked="checked"' : '' ), |
---|
| 190 | $me->my_config['piclens_wall_specif'].'_CHECKED' => 'checked="checked"', |
---|
| 191 | 'PICLENS_WALL_HEIGHT' => $me->my_config['piclens_wall_height'], |
---|
| 192 | 'CROSSDOMAIN_LNK' => PICLENS_PATH.'crossdomain.xml', |
---|
| 193 | 'PICLENS_WALL_ONTOP' => ($me->my_config['piclens_wall_ontop'] ? 'checked="checked"' : '' ), |
---|
| 194 | 'PICLENS_WALL_ONCAT' => ($me->my_config['piclens_wall_oncat'] ? 'checked="checked"' : '' ), |
---|
| 195 | 'PICLENS_WALL_NAV' => ($me->my_config['piclens_wall_nav'] ? 'checked="checked"' : '' ), |
---|
| 196 | 'PICLENS_WALL_TITLE' => $me->my_config['piclens_wall_title'], |
---|
| 197 | 'PICLENS_WALL_SPEC' => ($me->my_config['piclens_wall_spec'] ? 'checked="checked"' : '' ), |
---|
| 198 | 'PICLENS_WALL_SPEC' => ($me->my_config['piclens_wall_spec'] ? 'checked="checked"' : '' ), |
---|
| 199 | 'PICLENS_WALL_SPEC_RECENTPICS' => ($me->my_config['piclens_wall_spec_recentpics'] ? 'checked="checked"' : '' ), |
---|
| 200 | 'PICLENS_WALL_SPEC_RECENTCATS' => ($me->my_config['piclens_wall_spec_recentcats'] ? 'checked="checked"' : '' ), |
---|
| 201 | 'PICLENS_WALL_SPEC_MOSTVISITED' => ($me->my_config['piclens_wall_spec_mostvisited'] ? 'checked="checked"' : '' ), |
---|
| 202 | 'PICLENS_WALL_SPEC_BESTRATED' => ($me->my_config['piclens_wall_spec_bestrated'] ? 'checked="checked"' : '' ), |
---|
| 203 | 'PICLENS_WALL_SPEC_FAVORITES' => ($me->my_config['piclens_wall_spec_favorites'] ? 'checked="checked"' : '' ), |
---|
| 204 | 'PICLENS_WALL_SPEC_TAGS' => ($me->my_config['piclens_wall_spec_tags'] ? 'checked="checked"' : '' ), |
---|
| 205 | 'PICLENS_WALL_SWFLOCAL' => ($me->my_config['piclens_wall_swflocal'] ? 'checked="checked"' : '' ) |
---|
| 206 | )); |
---|
| 207 | |
---|
[3708] | 208 | $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); |
---|
[3637] | 209 | $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 210 | |
---|
[8780] | 211 | ?> |
---|