Changeset 2824
- Timestamp:
- 01/03/11 14:08:05 (13 years ago)
- Location:
- plugins/myGmaps
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/myGmaps/_admin.php
r2814 r2824 23 23 24 24 $core->addBehavior('adminPostHeaders',array('myGmapsPostBehaviors','postHeaders')); 25 $core->addBehavior('adminPageHeaders',array('myGmapsPostBehaviors','postHeaders')); 25 26 $core->addBehavior('adminPostForm',array('myGmapsPostBehaviors','adminPostForm')); 26 $core->addBehavior('admin AfterPostUpdate',array('myGmapsPostBehaviors','adminAfterPostUpdate'));27 $core->addBehavior('adminPageForm',array('myGmapsPostBehaviors','adminPageForm')); 27 28 28 29 if (isset($_GET['remove']) && $_GET['remove'] == 'map') { … … 32 33 $meta->delPostMeta($post_id,'map'); 33 34 $meta->delPostMeta($post_id,'map_options'); 34 35 http::redirect(DC_ADMIN_URL.'post.php?id='.$post_id); 35 if ($_GET['post_type'] == 'page') { 36 http::redirect('plugin.php?p=pages&act=page&id='.$post_id); 37 } else { 38 http::redirect(DC_ADMIN_URL.'post.php?id='.$post_id); 39 } 36 40 37 41 } catch (Exception $e) { 38 42 $core->error->add($e->getMessage()); 39 43 } 40 } elseif (!empty($_GET['remove']) ) {44 } elseif (!empty($_GET['remove']) && is_numeric($_GET['remove'])) { 41 45 try { 42 46 $post_id = $_GET['id']; … … 44 48 $meta->delPostMeta($post_id,'map',(integer) $_GET['remove']); 45 49 46 http::redirect(DC_ADMIN_URL.'post.php?id='.$post_id); 50 if ($_GET['post_type'] == 'page') { 51 http::redirect('plugin.php?p=pages&act=page&id='.$post_id); 52 } else { 53 http::redirect(DC_ADMIN_URL.'post.php?id='.$post_id); 54 } 47 55 48 56 } catch (Exception $e) { … … 87 95 global $core; 88 96 $id = $post->post_id; 97 $type = $post->post_type; 89 98 $meta =& $GLOBALS['core']->meta; 90 99 $meta_rs = $meta->getMetaStr($post->post_meta,'map'); … … 155 164 } 156 165 } 157 public static function admin AfterPostUpdate()166 public static function adminPageForm($post) 158 167 { 159 if ($_GET['remove'] == 'ok') { 160 echo '<p class="message">'.__('Map has been successfully deleted.').'</p>'; 168 global $core; 169 $id = $post->post_id; 170 $type = $post->post_type; 171 $meta =& $GLOBALS['core']->meta; 172 $meta_rs = $meta->getMetaStr($post->post_meta,'map'); 173 if ($id) { 174 if (!$meta_rs) { 175 echo 176 '<fieldset><legend>'.__('Google Map').'</legend>'. 177 '<p><a href="plugin.php?p=myGmaps&post_type=page&post_id='.$id.'">'.__('Add a map to page').'</a></p>'. 178 '</fieldset>'; 179 } else { 180 181 $meta =& $GLOBALS['core']->meta; 182 $maps_array = explode(",",$meta->getMetaStr($post->post_meta,'map')); 183 $maps_options = explode(",",$meta->getMetaStr($post->post_meta,'map_options')); 184 185 echo '<fieldset><legend>'.__('Google Map').'</legend>'. 186 '<h3>'.__('Map elements').'</h3>'; 187 188 echo 189 '<table class="clear"><tr>'. 190 '<th>'.__('Title').'</th>'. 191 '<th>'.__('Date').'</th>'. 192 '<th>'.__('Category').'</th>'. 193 '<th>'.__('Author').'</th>'. 194 '<th class="nowrap">'.__('Type').'</th>'. 195 '<th> </th>'. 196 '</tr>'; 197 198 $params['post_type'] = 'map'; 199 $params['no_content'] = true; 200 201 $rsp = $core->blog->getPosts($params); 202 while ($rsp->fetch()) { 203 if (in_array($rsp->post_id,$maps_array)) { 204 $meta_rs = $meta->getMetaStr($rsp->post_meta,'map'); 205 if ($core->auth->check('categories',$core->blog->id)) { 206 $cat_link = '<a href="category.php?id=%s">%s</a>'; 207 } else { 208 $cat_link = '%2$s'; 209 } 210 if ($rsp->cat_title) { 211 $cat_title = sprintf($cat_link,$rsp->cat_id, 212 html::escapeHTML($rsp->cat_title)); 213 } else { 214 $cat_title = __('None'); 215 } 216 echo 217 '<tr>'. 218 '<td class="maximal"><a href="plugin.php?p=myGmaps&do=edit&id='.$rsp->post_id.'" title="'.__('Edit map element').' : '.html::escapeHTML($rsp->post_title).'">'.html::escapeHTML($rsp->post_title).'</a></td>'. 219 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rsp->post_dt).'</td>'. 220 '<td class="nowrap">'.$cat_title.'</td>'. 221 '<td class="nowrap">'.$rsp->user_id.'</td>'. 222 '<td class="nowrap">'.__($meta_rs).'</td>'. 223 '<td class="nowrap"><a class="element-remove" href="plugin.php?p=pages&post_type=page&id='.$id.'&remove='.$rsp->post_id.'" title="'.__('Remove map element').' : '.html::escapeHTML($rsp->post_title).'">[x]</a></td>'. 224 '</tr>'; 225 226 } 227 } 228 229 echo '</table>'. 230 '<div class="two-cols">'. 231 '<p class="col"><a href="plugin.php?p=myGmaps&post_type=page&post_id='.$id.'"><strong>'.__('Edit map').'</strong></a></p>'. 232 '<p class="col right"><a class="map-remove" href="plugin.php?p=pages&post_type=page&id='.$id.'&remove=map"><strong>'.__('Remove map').'</strong></a></p>'. 233 '</div>'. 234 '</fieldset>'; 235 236 } 161 237 } 162 238 } -
plugins/myGmaps/_define.php
r2822 r2824 15 15 /* Description*/ "Create Google Maps objects to include in maps associated to your posts", 16 16 /* Author */ "Philippe aka amalgame", 17 /* Version */ '0.6. 6',17 /* Version */ '0.6.7', 18 18 /* Permissions */ 'usage,contentadmin' 19 19 ); -
plugins/myGmaps/_public.php
r2821 r2824 13 13 $core->addBehavior('publicHeadContent',array('myGmapsPublic','publicHeadContent')); 14 14 $core->addBehavior('publicEntryAfterContent',array('myGmapsPublic','publicMapContent')); 15 $core->addBehavior('publicPageAfterContent',array('myGmapsPublic','publicMapContent')); 15 16 16 17 class myGmapsPublic … … 22 23 $my_params['post_id'] = $post_id; 23 24 $my_params['no_content'] = true; 25 $my_params['post_type'] = array('post','page'); 24 26 25 27 $rs = $core->blog->getPosts($my_params); -
plugins/myGmaps/addmap.php
r2817 r2824 133 133 134 134 $post_id = !empty($_GET['post_id']) ? $_GET['post_id'] : ''; 135 $post_type = !empty($_GET['post_type']) ? $_GET['post_type'] : ''; 135 136 $user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : ''; 136 137 $cat_id = !empty($_GET['cat_id']) ? $_GET['cat_id'] : ''; … … 157 158 $my_params['post_id'] = $_GET['post_id']; 158 159 $my_params['no_content'] = true; 160 $my_params['post_type'] = array('post','page'); 159 161 160 162 $rs = $core->blog->getPosts($my_params); 161 163 while ($rs->fetch()) { 162 164 $my_post_maps = $meta->getMetaStr($rs->post_meta,'map'); 165 166 } 167 if ($rs->post_type == 'page') { 168 $page_title = __('Add a map to page'); 163 169 } 164 170 $my_post_maps_options = $meta->getMetaStr($rs->post_meta,'map_options'); … … 258 264 $my_params['post_id'] = $_GET['post_id']; 259 265 $my_params['no_content'] = true; 266 $my_params['post_type'] = array('post','page'); 260 267 261 268 $rs = $core->blog->getPosts($my_params); … … 353 360 $meta->setPostMeta($post_id,'map_options',$map_options); 354 361 355 http::redirect(DC_ADMIN_URL.'post.php?id='.$_POST['post_id']); 362 if ($_POST['post_type'] == 'page') { 363 http::redirect('plugin.php?p=pages&act=page&id='.$post_id); 364 } else { 365 http::redirect(DC_ADMIN_URL.'post.php?id='.$post_id); 366 } 367 356 368 357 369 } catch (Exception $e) { … … 373 385 $meta->setPostMeta($post_id,'map_options',$map_options); 374 386 375 http::redirect(DC_ADMIN_URL.'post.php?id='.$_POST['post_id']); 387 if ($_POST['post_type'] == 'page') { 388 http::redirect('plugin.php?p=pages&act=page&id='.$post_id); 389 } else { 390 http::redirect(DC_ADMIN_URL.'post.php?id='.$post_id); 391 } 376 392 377 393 } catch (Exception $e) { … … 468 484 '<input type="submit" name="addmap" value="'.__('ok').'" /></p>'. 469 485 '<p>'.form::hidden(array('post_id'),$post_id). 486 form::hidden(array('post_type'),$post_type). 470 487 form::hidden(array('user_id'),$user_id). 471 488 form::hidden(array('cat_id'),$cat_id). … … 524 541 525 542 if (isset($has_map) && $has_map == true) { 526 echo '<p>'. ($post_id ? form::hidden('post_id',$post_id) : '').'<input type="submit" value="'.__('Save').'" name="updmap" /></p>';543 echo '<p>'.form::hidden('post_id',$post_id).form::hidden('post_type',$post_type).'<input type="submit" value="'.__('Save').'" name="updmap" /></p>'; 527 544 } 528 545 -
plugins/myGmaps/locales/fr/main.po
r2814 r2824 1 msgid "Sorry, javascript must be activated in your browser to see this map." 2 msgstr "Désolé, javascript doit être activé dans votre navigateur pour voir cette carte." 3 1 4 msgid "Map elements" 2 5 msgstr "Éléments de cartes" … … 116 119 msgstr "Ajouter une carte au billet" 117 120 121 msgid "Add a map to page" 122 msgstr "Ajouter une carte à la page" 123 118 124 msgid "Add elements" 119 125 msgstr "Ajouter des éléments"
Note: See TracChangeset
for help on using the changeset viewer.