Dotclear

Changeset 2824


Ignore:
Timestamp:
01/03/11 14:08:05 (13 years ago)
Author:
philippe
Message:

myGmaps : now works with pages

Location:
plugins/myGmaps
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/myGmaps/_admin.php

    r2814 r2824  
    2323      
    2424$core->addBehavior('adminPostHeaders',array('myGmapsPostBehaviors','postHeaders')); 
     25$core->addBehavior('adminPageHeaders',array('myGmapsPostBehaviors','postHeaders')); 
    2526$core->addBehavior('adminPostForm',array('myGmapsPostBehaviors','adminPostForm')); 
    26 $core->addBehavior('adminAfterPostUpdate',array('myGmapsPostBehaviors','adminAfterPostUpdate')); 
     27$core->addBehavior('adminPageForm',array('myGmapsPostBehaviors','adminPageForm')); 
    2728 
    2829if (isset($_GET['remove']) && $_GET['remove'] == 'map') { 
     
    3233     $meta->delPostMeta($post_id,'map'); 
    3334     $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     } 
    3640      
    3741  } catch (Exception $e) { 
    3842    $core->error->add($e->getMessage()); 
    3943  } 
    40 } elseif (!empty($_GET['remove'])) { 
     44} elseif (!empty($_GET['remove']) && is_numeric($_GET['remove'])) { 
    4145     try { 
    4246     $post_id = $_GET['id']; 
     
    4448     $meta->delPostMeta($post_id,'map',(integer) $_GET['remove']); 
    4549      
    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     } 
    4755      
    4856  } catch (Exception $e) { 
     
    8795          global $core; 
    8896          $id = $post->post_id; 
     97          $type = $post->post_type; 
    8998          $meta =& $GLOBALS['core']->meta; 
    9099          $meta_rs = $meta->getMetaStr($post->post_meta,'map'); 
     
    155164          } 
    156165     } 
    157      public static function adminAfterPostUpdate() 
     166     public static function adminPageForm($post) 
    158167     { 
    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&amp;post_type=page&amp;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>&nbsp;</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&amp;do=edit&amp;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&amp;post_type=page&amp;id='.$id.'&amp;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&amp;post_type=page&amp;post_id='.$id.'"><strong>'.__('Edit map').'</strong></a></p>'. 
     232                    '<p class="col right"><a class="map-remove" href="plugin.php?p=pages&amp;post_type=page&amp;id='.$id.'&amp;remove=map"><strong>'.__('Remove map').'</strong></a></p>'. 
     233                    '</div>'. 
     234                    '</fieldset>'; 
     235                     
     236               } 
    161237          } 
    162238     } 
  • plugins/myGmaps/_define.php

    r2822 r2824  
    1515     /* Description*/         "Create Google Maps objects to include in maps associated to your posts", 
    1616     /* Author */             "Philippe aka amalgame", 
    17      /* Version */            '0.6.6', 
     17     /* Version */            '0.6.7', 
    1818     /* Permissions */        'usage,contentadmin' 
    1919); 
  • plugins/myGmaps/_public.php

    r2821 r2824  
    1313$core->addBehavior('publicHeadContent',array('myGmapsPublic','publicHeadContent')); 
    1414$core->addBehavior('publicEntryAfterContent',array('myGmapsPublic','publicMapContent')); 
     15$core->addBehavior('publicPageAfterContent',array('myGmapsPublic','publicMapContent')); 
    1516 
    1617class myGmapsPublic 
     
    2223          $my_params['post_id'] = $post_id; 
    2324          $my_params['no_content'] = true; 
     25          $my_params['post_type'] = array('post','page'); 
    2426                          
    2527          $rs = $core->blog->getPosts($my_params); 
  • plugins/myGmaps/addmap.php

    r2817 r2824  
    133133 
    134134$post_id = !empty($_GET['post_id']) ?   $_GET['post_id'] : ''; 
     135$post_type = !empty($_GET['post_type']) ?    $_GET['post_type'] : ''; 
    135136$user_id = !empty($_GET['user_id']) ?   $_GET['user_id'] : ''; 
    136137$cat_id = !empty($_GET['cat_id']) ?     $_GET['cat_id'] : ''; 
     
    157158     $my_params['post_id'] = $_GET['post_id']; 
    158159     $my_params['no_content'] = true; 
     160     $my_params['post_type'] = array('post','page'); 
    159161                     
    160162     $rs = $core->blog->getPosts($my_params); 
    161163     while ($rs->fetch()) { 
    162164          $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'); 
    163169     } 
    164170     $my_post_maps_options = $meta->getMetaStr($rs->post_meta,'map_options'); 
     
    258264               $my_params['post_id'] = $_GET['post_id']; 
    259265               $my_params['no_content'] = true; 
     266               $my_params['post_type'] = array('post','page'); 
    260267                               
    261268               $rs = $core->blog->getPosts($my_params); 
     
    353360     $meta->setPostMeta($post_id,'map_options',$map_options); 
    354361      
    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      
    356368      
    357369  } catch (Exception $e) { 
     
    373385     $meta->setPostMeta($post_id,'map_options',$map_options); 
    374386      
    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     } 
    376392      
    377393  } catch (Exception $e) { 
     
    468484     '<input type="submit" name="addmap" value="'.__('ok').'" /></p>'. 
    469485     '<p>'.form::hidden(array('post_id'),$post_id). 
     486     form::hidden(array('post_type'),$post_type). 
    470487     form::hidden(array('user_id'),$user_id). 
    471488     form::hidden(array('cat_id'),$cat_id). 
     
    524541      
    525542     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>'; 
    527544     } 
    528545      
  • plugins/myGmaps/locales/fr/main.po

    r2814 r2824  
     1msgid "Sorry, javascript must be activated in your browser to see this map." 
     2msgstr "Désolé, javascript doit être activé dans votre navigateur pour voir cette carte." 
     3 
    14msgid "Map elements" 
    25msgstr "Éléments de cartes" 
     
    116119msgstr "Ajouter une carte au billet" 
    117120 
     121msgid "Add a map to page" 
     122msgstr "Ajouter une carte à la page" 
     123 
    118124msgid "Add elements" 
    119125msgstr "Ajouter des éléments" 
Note: See TracChangeset for help on using the changeset viewer.

Sites map