Dotclear

Changeset 2546:e9b5815be220


Ignore:
Timestamp:
11/14/13 14:05:49 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Message:

meta-editor.js may now be instancied more than once, Fixes #1866

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • admin/js/meta-editor.js

    r2545 r2546  
    11//~ metaEditor & metaEditor.prototype should go to the core. 
    2 function metaEditor(target,meta_field,meta_type) { 
     2function metaEditor(target,meta_field,meta_type,meta_options) { 
    33     this.target = target; 
     4 
    45     this.meta_field = meta_field; 
    56     this.meta_type = meta_type; 
     7     this.meta_url = meta_options.meta_url || this.meta_url; 
     8     this.list_type = meta_options.list_type || this.list_type; 
     9     this.text_confirm_remove = meta_options.text_confirm_remove || this.text_confirm_remove; 
     10     this.text_add_meta = meta_options.text_add_meta || this.text_add_meta; 
     11     this.text_choose = meta_options.text_choose || this.text_choose; 
     12     this.text_all = meta_options.text_all || this.text_all; 
     13     this.text_separation = meta_options.text_separation || this.text_separation; 
    614}; 
    715 
     
    1321     text_all: 'all', 
    1422     text_separation: 'Separate each %s by comas', 
     23     list_type: 'more', 
    1524 
    1625     target: null, 
     
    124133          } 
    125134 
    126           this.showMetaList(metaEditor.prototype.meta_type,this.target); 
    127  
    128      }, 
    129  
    130      showMetaList: function(type,target) { 
     135          this.showMetaList(this.list_type,this.target); 
     136 
     137     }, 
     138 
     139     showMetaList: function(list_type,target) { 
    131140 
    132141          var params = { 
     
    136145          }; 
    137146 
    138           if (type == 'more') { 
     147          if (list_type == 'more') { 
    139148               params.limit = '30'; 
    140149          } 
     
    167176                    }); 
    168177 
    169                     if (type == 'more') { 
     178                    if (list_type == 'more') { 
    170179                         var a_more = $('<a href="#" class="metaGetMore"></a>'); 
    171180                         a_more.append(This.text_all + String.fromCharCode(160)+String.fromCharCode(187)); 
     
    177186                    } 
    178187 
    179                     if (type != 'more-all') { 
     188                    if (list_type != 'more-all') { 
    180189                         pl.addClass('hide'); 
    181190 
  • locales/fr/plugins.po

    r2509 r2546  
    16391639 
    16401640#, php-format 
    1641 msgid "Are you sure you want to remove this %s?" 
    1642 msgstr "Êtes-vous sûr de vouloir supprimer ce %s ?" 
    1643  
    1644 #, php-format 
    1645 msgid "Add a %s to this entry" 
    1646 msgstr "Ajouter %s à ce billet" 
     1641msgid "Are you sure you want to remove this tag?" 
     1642msgstr "Êtes-vous sûr de vouloir supprimer ce mot-clé ?" 
     1643 
     1644#, php-format 
     1645msgid "Add a tag to this entry" 
     1646msgstr "Ajouter un mot-clé à ce billet" 
    16471647 
    16481648msgid "Choose from list" 
     
    16531653 
    16541654msgid "Enter tags separated by coma" 
    1655 msgstr "Entrez les mots-clés séparés par des virgules" 
     1655msgstr "Séparez les mot-clés par des virgules" 
    16561656 
    16571657msgid "used in %e - frequency %p%" 
  • plugins/tags/_admin.php

    r2322 r2546  
    7373          $wiki2xhtml->registerFunction('url:tag',array('tagsBehaviors','wiki2xhtmlTag')); 
    7474     } 
    75       
     75 
    7676     public static function wiki2xhtmlTag($url,$content) 
    7777     { 
     
    8080               $content = substr($content,4); 
    8181          } 
    82            
    83            
     82 
     83 
    8484          $tag_url = html::stripHostURL($GLOBALS['core']->blog->url.$GLOBALS['core']->url->getURLFor('tag')); 
    8585          $res['url'] = $tag_url.'/'.rawurlencode(dcMeta::sanitizeMetaID($url)); 
    8686          $res['content'] = $content; 
    87            
     87 
    8888          return $res; 
    8989     } 
    90       
     90 
    9191     public static function tagsField($main,$sidebar,$post) 
    9292     { 
    9393          $meta =& $GLOBALS['core']->meta; 
    94            
     94 
    9595          if (!empty($_POST['post_tags'])) { 
    9696               $value = $_POST['post_tags']; 
     
    102102          '<div class="p s-tags" id="tags-edit">'.form::textarea('post_tags',20,3,$value,'maximal').'</div>'; 
    103103     } 
    104       
     104 
    105105     public static function setTags($cur,$post_id) 
    106106     { 
    107107          $post_id = (integer) $post_id; 
    108            
     108 
    109109          if (isset($_POST['post_tags'])) { 
    110110               $tags = $_POST['post_tags']; 
    111111               $meta =& $GLOBALS['core']->meta; 
    112112               $meta->delPostMeta($post_id,'tag'); 
    113                 
     113 
    114114               foreach ($meta->splitMetaValues($tags) as $tag) { 
    115115                    $meta->setPostMeta($post_id,'tag',$tag); 
     
    117117          } 
    118118     } 
    119       
    120       
     119 
     120 
    121121     public static function adminPostsActionsPage($core,$ap) 
    122122     { 
     
    125125               array('tagsBehaviors','adminAddTags') 
    126126          ); 
    127            
     127 
    128128          if ($core->auth->check('delete,contentadmin',$core->blog->id)) { 
    129129               $ap->addAction( 
     
    133133          } 
    134134     } 
    135       
     135 
    136136     public static function adminAddTags($core, dcPostsActionsPage $ap, $post) 
    137137     { 
     
    165165               ); 
    166166               $ap->redirect(true); 
    167           }  
    168           else  
     167          } 
     168          else 
    169169          { 
    170170               $tag_url = $core->blog->url.$core->url->getURLFor('tag'); 
     
    173173               $type = isset($opts['tag_list_format']) ? $opts['tag_list_format'] : 'more'; 
    174174 
    175                 
     175 
    176176               $ap->beginPage( 
    177177                    dcPage::breadcrumb( 
     
    183183                    dcPage::jsLoad('js/jquery/jquery.autocomplete.js'). 
    184184                    dcPage::jsMetaEditor(). 
     185                    '<script type="text/javascript">'."\n". 
     186                    "//<![CDATA[\n". 
     187                    "var editor_tags_options = {\n". 
     188                         "meta_url : 'plugin.php?p=tags&m=tag_posts&amp;tag=',\n". 
     189                         "list_type : '".html::escapeJS($type)."',\n". 
     190                         "text_confirm_remove : '".html::escapeJS(__('Are you sure you want to remove this tag?'))."',\n". 
     191                         "text_add_meta : '".html::escapeJS(__('Add a tag to this entry'))."',\n". 
     192                         "text_choose : '".html::escapeJS(__('Choose from list'))."',\n". 
     193                         "text_all : '".html::escapeJS(__('all'))."',\n". 
     194                         "text_separation : '".html::escapeJS(__('Enter tags separated by coma'))."',\n". 
     195                    "};\n". 
     196                    "\n//]]>\n". 
     197                    "</script>\n". 
    185198                    '<script type="text/javascript" src="index.php?pf=tags/js/jquery.autocomplete.js"></script>'. 
    186199                    '<script type="text/javascript" src="index.php?pf=tags/js/posts_actions.js"></script>'. 
    187200                    '<script type="text/javascript">'."\n". 
    188201                    "//<![CDATA[\n". 
    189                     "metaEditor.prototype.meta_url = 'plugin.php?p=tags&m=tag_posts&amp;tag=';\n". 
    190                     "metaEditor.prototype.meta_type = '".html::escapeJS($type)."';\n". 
    191                     "metaEditor.prototype.text_confirm_remove = '".html::escapeJS(__('Are you sure you want to remove this %s?'))."';\n". 
    192                     "metaEditor.prototype.text_add_meta = '".html::escapeJS(__('Add a %s to this entry'))."';\n". 
    193                     "metaEditor.prototype.text_choose = '".html::escapeJS(__('Choose from list'))."';\n". 
    194                     "metaEditor.prototype.text_all = '".html::escapeJS(__('all'))."';\n". 
    195                     "metaEditor.prototype.text_separation = '".html::escapeJS(__('Enter tags separated by coma'))."';\n". 
    196202                    "dotclear.msg.tags_autocomplete = '".html::escapeJS(__('used in %e - frequency %p%'))."';\n". 
    197203                    "dotclear.msg.entry = '".html::escapeJS(__('entry'))."';\n". 
     
    217223     public static function adminRemoveTags($core, dcPostsActionsPage $ap, $post) 
    218224     { 
    219           if (!empty($post['meta_id']) &&  
     225          if (!empty($post['meta_id']) && 
    220226               $core->auth->check('delete,contentadmin',$core->blog->id)) 
    221227          { 
     
    242248               $meta =& $core->meta; 
    243249               $tags = array(); 
    244                 
     250 
    245251               foreach ($ap->getIDS() as $id) { 
    246252                    $post_tags = $meta->getMetadata(array( 
     
    257263               if (empty($tags)) { 
    258264                    throw new Exception(__('No tags for selected entries')); 
    259                }               
     265               } 
    260266               $ap->beginPage( 
    261267                    dcPage::breadcrumb( 
     
    266272               ))); 
    267273               $posts_count = count($_POST['entries']); 
    268                 
     274 
    269275               echo 
    270276               '<form action="'.$ap->getURI().'" method="post">'. 
    271277               $ap->getCheckboxes(). 
    272278               '<div><p>'.__('Following tags have been found in selected entries:').'</p>'; 
    273                 
     279 
    274280               foreach ($tags as $k => $n) { 
    275281                    $label = '<label class="classic">%s %s</label>'; 
     
    282288                         '</p>'; 
    283289               } 
    284                 
     290 
    285291               echo 
    286292               '<p><input type="submit" value="'.__('ok').'" />'. 
    287                 
     293 
    288294               $core->formNonce().$ap->getHiddenFields(). 
    289295               form::hidden(array('action'),'tags_remove'). 
     
    291297               $ap->endPage(); 
    292298          } 
    293            
    294      } 
    295       
     299 
     300     } 
     301 
    296302     public static function postHeaders() 
    297303     { 
    298304          $tag_url = $GLOBALS['core']->blog->url.$GLOBALS['core']->url->getURLFor('tag'); 
    299            
     305 
    300306          $opts = $GLOBALS['core']->auth->getOptions(); 
    301307          $type = isset($opts['tag_list_format']) ? $opts['tag_list_format'] : 'more'; 
    302            
    303           return  
     308 
     309          return 
     310          '<script type="text/javascript">'."\n". 
     311          "//<![CDATA[\n". 
     312          "var editor_tags_options = {\n". 
     313               "meta_url : 'plugin.php?p=tags&m=tag_posts&amp;tag=',\n". 
     314               "list_type : '".html::escapeJS($type)."',\n". 
     315               "text_confirm_remove : '".html::escapeJS(__('Are you sure you want to remove this tag?'))."',\n". 
     316               "text_add_meta : '".html::escapeJS(__('Add a tag to this entry'))."',\n". 
     317               "text_choose : '".html::escapeJS(__('Choose from list'))."',\n". 
     318               "text_all : '".html::escapeJS(__('all'))."',\n". 
     319               "text_separation : '".html::escapeJS(__('Enter tags separated by coma'))."',\n". 
     320          "};\n". 
     321          "\n//]]>\n". 
     322          "</script>\n". 
    304323          '<script type="text/javascript" src="index.php?pf=tags/js/jquery.autocomplete.js"></script>'. 
    305324          '<script type="text/javascript" src="index.php?pf=tags/js/post.js"></script>'. 
    306325          '<script type="text/javascript">'."\n". 
    307326          "//<![CDATA[\n". 
    308           "metaEditor.prototype.meta_url = 'plugin.php?p=tags&m=tag_posts&amp;tag=';\n". 
    309           "metaEditor.prototype.meta_type = '".html::escapeJS($type)."';\n". 
    310           "metaEditor.prototype.text_confirm_remove = '".html::escapeJS(__('Are you sure you want to remove this %s?'))."';\n". 
    311           "metaEditor.prototype.text_add_meta = '".html::escapeJS(__('Add a %s to this entry'))."';\n". 
    312           "metaEditor.prototype.text_choose = '".html::escapeJS(__('Choose from list'))."';\n". 
    313           "metaEditor.prototype.text_all = '".html::escapeJS(__('all'))."';\n". 
    314           "metaEditor.prototype.text_separation = '';\n". 
    315327          "jsToolBar.prototype.elements.tag.title = '".html::escapeJS(__('Tag'))."';\n". 
    316328          "jsToolBar.prototype.elements.tag.url = '".html::escapeJS($tag_url)."';\n". 
     
    322334          '<link rel="stylesheet" type="text/css" href="index.php?pf=tags/style.css" />'; 
    323335     } 
    324       
     336 
    325337     public static function adminUserForm($args) 
    326338     { 
     
    334346               $opts = array(); 
    335347          } 
    336            
     348 
    337349          $combo = array(); 
    338350          $combo[__('Short')] = 'more'; 
    339351          $combo[__('Extended')] = 'all'; 
    340            
     352 
    341353          $value = array_key_exists('tag_list_format',$opts) ? $opts['tag_list_format'] : 'more'; 
    342            
     354 
    343355          echo 
    344356          '<p><label for="user_tag_list_format" class="classic">'.__('Tags list format:').'</label> '. 
     
    346358          '</p>'; 
    347359     } 
    348       
     360 
    349361     public static function setTagListFormat($cur,$user_id = null) 
    350362     { 
  • plugins/tags/_define.php

    r2257 r2546  
    1616     /* Description*/         "Tags for posts", 
    1717     /* Author */             "Olivier Meunier", 
    18      /* Version */            '1.2', 
     18     /* Version */            '1.2.1', 
    1919     array( 
    2020          'permissions' =>    'usage,contentadmin', 
  • plugins/tags/js/post.js

    r2180 r2546  
    44          var post_id = $('#id'); 
    55          var meta_field = null; 
    6            
     6 
    77          if (tags_edit.length > 0) { 
    88               post_id = (post_id.length > 0) ? post_id.get(0).value : false; 
     
    1111                    meta_field.val($('#post_tags').val()); 
    1212               } 
    13                var mEdit = new metaEditor(tags_edit,meta_field,'tag'); 
     13               var mEdit = new metaEditor(tags_edit,meta_field,'tag',editor_tags_options); 
    1414               mEdit.meta_url = 'plugin.php?p=tags&m=tag_posts&amp;tag='; 
    1515               mEdit.displayMeta('tag',post_id); 
    16                 
     16 
    1717               // mEdit object reference for toolBar 
    1818               window.dc_tag_editor = mEdit; 
    1919          } 
    20            
     20 
    2121          $('#post_meta_input').autocomplete(mEdit.service_uri, { 
    2222               extraParams: { 
     
    2929               matchSubset: false, 
    3030               matchContains: true, 
    31                parse: function(xml) {  
     31               parse: function(xml) { 
    3232                    var results = []; 
    3333                    $(xml).find('meta').each(function(){ 
     
    3939                              }, 
    4040                              result: $(this).text() 
    41                          };  
     41                         }; 
    4242                    }); 
    4343                    return results; 
     
    6969// Toolbar button for tags 
    7070jsToolBar.prototype.elements.tagSpace = { 
    71      type: 'space',  
     71     type: 'space', 
    7272     format:{ 
    7373          wysiwyg:true, 
     
    105105jsToolBar.prototype.elements.tag.fn.wysiwyg = function() { 
    106106     var t = this.getSelectedText(); 
    107       
     107 
    108108     if (t == '') { window.alert(dotclear.msg.no_selection); return; } 
    109109     if (t.indexOf(',') != -1) { return; } 
    110       
     110 
    111111     var n = this.getSelectedNode(); 
    112112     var a = document.createElement('a'); 
  • plugins/tags/js/posts_actions.js

    r1112 r2546  
    11$(function() { 
    22     var tag_field = $('#new_tags'); 
    3       
     3 
    44     tag_field.after('<div id="tags_list"></div>'); 
    55     tag_field.hide(); 
    6       
    7      var target = $('#tags_list');  
    8      var mEdit = new metaEditor(target,tag_field,'tag'); 
     6 
     7     var target = $('#tags_list'); 
     8     var mEdit = new metaEditor(target,tag_field,'tag',editor_tags_options); 
    99     mEdit.meta_url = 'plugin.php?p=tags&m=tag_posts&amp;tag='; 
    10       
     10 
    1111     mEdit.meta_dialog = $('<input type="text" />'); 
    1212     mEdit.meta_dialog.attr('title',mEdit.text_add_meta.replace(/%s/,mEdit.meta_type)); 
    1313     mEdit.meta_dialog.attr('id','post_meta_input'); 
    1414     mEdit.meta_dialog.css('width','90%'); 
    15       
     15 
    1616     mEdit.addMetaDialog(); 
    17       
     17 
    1818     $('input[name="save_tags"]').click(function() { 
    1919          tag_field.val($('#post_meta_input').val()); 
    2020     }); 
    21       
     21 
    2222     $('#post_meta_input').autocomplete(mEdit.service_uri, { 
    2323          extraParams: { 
     
    2929          matchSubset: false, 
    3030          matchContains: true, 
    31           parse: function(xml) {  
     31          parse: function(xml) { 
    3232               var results = []; 
    3333               $(xml).find('meta').each(function(){ 
     
    3939                         }, 
    4040                         result: $(this).text() 
    41                     };  
     41                    }; 
    4242               }); 
    4343               return results; 
     
    5454               ')</em>'; 
    5555          }, 
    56           formatResult: function(tag) {  
    57                return tag.result;  
     56          formatResult: function(tag) { 
     57               return tag.result; 
    5858          } 
    5959     }); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map