瀏覽代碼

merge sandbox with prod

Bachir Soussi Chiadmi 10 年之前
父節點
當前提交
5835745cc2

+ 46 - 42
js/materio_flag.js

@@ -1,5 +1,5 @@
 // @codekit-prepend "gui.js"
 // @codekit-prepend "gui.js"
-// @koala-prepend "gui_ck_fw/gui.js"
+// @koala-prepend "gui.js"
 
 
 
 
 (function($) {
 (function($) {
@@ -87,14 +87,14 @@ MaterioFlag = function(){
           .bind('click', onClickCreatLink)
           .bind('click', onClickCreatLink)
           .addClass('ajax-processed');
           .addClass('ajax-processed');
 
 
-      
+
         // preview block
         // preview block
         $('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
         $('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
           var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
           var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
           $('<i class="icon-remove"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
           $('<i class="icon-remove"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
 
 
           $('a.open-list',  this).bind('click', onClickOpenLink);
           $('a.open-list',  this).bind('click', onClickOpenLink);
-        
+
         }).addClass('ajax-processed');
         }).addClass('ajax-processed');
         break;
         break;
     }
     }
@@ -106,7 +106,7 @@ MaterioFlag = function(){
         type : 'my'+type+'-block-builded',
         type : 'my'+type+'-block-builded',
         block : block,
         block : block,
         name : name
         name : name
-      });  
+      });
     },10);
     },10);
 
 
     // trace('MaterioFlag :: activename', activename);
     // trace('MaterioFlag :: activename', activename);
@@ -115,7 +115,7 @@ MaterioFlag = function(){
 
 
     // trace('MaterioFlag :: activename', activename);
     // trace('MaterioFlag :: activename', activename);
     if(activename)
     if(activename)
-      showPreview(activename, block);    
+      showPreview(activename, block);
   };
   };
 
 
   function refreshBlocks(name){
   function refreshBlocks(name){
@@ -125,17 +125,18 @@ MaterioFlag = function(){
     }else if($('#block-materio-flag-materio-flag-mylists').length){
     }else if($('#block-materio-flag-materio-flag-mylists').length){
       var type = 'lists';
       var type = 'lists';
     }
     }
-    
+
+
     if(type != undefined){
     if(type != undefined){
       var id = '#block-materio-flag-materio-flag-my'+type;
       var id = '#block-materio-flag-materio-flag-my'+type;
       var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
       var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
       $.getJSON(url, function(json){
       $.getJSON(url, function(json){
-        //trace('MaterioFlag :: block refreshed '+type, json);
-        
+        // trace('MaterioFlag :: block refreshed '+type, json);
+
         $(id).replaceWith(json.block);
         $(id).replaceWith(json.block);
         $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
         $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
-        
-        buildBlocks(name);        
+
+        buildBlocks(name);
 
 
         $.event.trigger({
         $.event.trigger({
           type : 'my'+type+'-block-updated',
           type : 'my'+type+'-block-updated',
@@ -150,7 +151,7 @@ MaterioFlag = function(){
     //trace('MaterioFlag :: ajaxifyLinks', container);
     //trace('MaterioFlag :: ajaxifyLinks', container);
 
 
     container = ((container != null) ? container : 'body');
     container = ((container != null) ? container : 'body');
- 
+
     // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
     // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
     if (typeof Drupal.flagLink != 'undefined')
     if (typeof Drupal.flagLink != 'undefined')
       Drupal.flagLink(container);
       Drupal.flagLink(container);
@@ -162,6 +163,7 @@ MaterioFlag = function(){
         .addClass('ajax-processed');
         .addClass('ajax-processed');
     }
     }
 
 
+
     $('a.flag-lists-create:not(.ajax-processed)', container)
     $('a.flag-lists-create:not(.ajax-processed)', container)
       .bind('click', onClickCreatLink)
       .bind('click', onClickCreatLink)
       .addClass('ajax-processed');
       .addClass('ajax-processed');
@@ -189,9 +191,9 @@ MaterioFlag = function(){
     //trace('MaterioFlag :: onClickClosePreview', event);
     //trace('MaterioFlag :: onClickClosePreview', event);
     eraseCookie('materiomyflaglistsopened');
     eraseCookie('materiomyflaglistsopened');
     if($(this).attr('name') == 'bookmarks'){
     if($(this).attr('name') == 'bookmarks'){
-      $(this).parents('.block').find('section.bookmarks').removeClass('active');  
+      $(this).parents('.block').find('section.bookmarks').removeClass('active');
     }else{
     }else{
-      $(this).parents('section.flag-list').removeClass('active');  
+      $(this).parents('section.flag-list').removeClass('active');
     }
     }
 
 
     $.event.trigger('init-layout');
     $.event.trigger('init-layout');
@@ -212,7 +214,7 @@ MaterioFlag = function(){
   function loadList(fid){
   function loadList(fid){
     //trace('MaterioFlag :: loadList | fid', fid);
     //trace('MaterioFlag :: loadList | fid', fid);
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid;
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid;
-    
+
     $.event.trigger('loading-content');
     $.event.trigger('loading-content');
 
 
     $.getJSON(url, {'current_path':document.location.href},function(json){
     $.getJSON(url, {'current_path':document.location.href},function(json){
@@ -229,14 +231,14 @@ MaterioFlag = function(){
     if(json.rendered){
     if(json.rendered){
 
 
       $('.inner-content','#content').html(json.rendered);
       $('.inner-content','#content').html(json.rendered);
-      
+
       $.event.trigger('loaded-content');
       $.event.trigger('loaded-content');
-      
+
       // no need of ajaxifylinks because it's triggered with resultschanged
       // no need of ajaxifylinks because it's triggered with resultschanged
       // ajaxifyLinks('#content');
       // ajaxifyLinks('#content');
 
 
       var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path;
       var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path;
-      
+
       $.event.trigger({
       $.event.trigger({
         type : 'new-history-page',
         type : 'new-history-page',
         path : path,
         path : path,
@@ -244,10 +246,10 @@ MaterioFlag = function(){
         content : json.rendered
         content : json.rendered
       });
       });
 
 
-      // TODO:  change language links for folders  
+      // TODO:  change language links for folders
       // for (language in Drupal.settings.materio_search_api_ajax.languages) {
       // for (language in Drupal.settings.materio_search_api_ajax.languages) {
       //   var l = Drupal.settings.materio_search_api_ajax.languages[language];
       //   var l = Drupal.settings.materio_search_api_ajax.languages[language];
-      //   $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)        
+      //   $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)
       // };
       // };
 
 
       triggerContentChanged();
       triggerContentChanged();
@@ -306,7 +308,7 @@ MaterioFlag = function(){
           case 'cancel':
           case 'cancel':
             //trace('MaterioFlag :: cancel',event);
             //trace('MaterioFlag :: cancel',event);
             $(this).parents('#modal').remove();
             $(this).parents('#modal').remove();
-            
+
             // google analytics
             // google analytics
             $.event.trigger({
             $.event.trigger({
               type:"record-stat",
               type:"record-stat",
@@ -331,11 +333,11 @@ MaterioFlag = function(){
             createList($modal, type, title, $link);
             createList($modal, type, title, $link);
             break;
             break;
         }
         }
-        
+
         return false;
         return false;
       })
       })
       .parents('form').find('input[type="text"]').focus();
       .parents('form').find('input[type="text"]').focus();
-      // TODO:  esc keypressed close the form  
+      // TODO:  esc keypressed close the form
   };
   };
 
 
   function createList($modal, type, title, $link){
   function createList($modal, type, title, $link){
@@ -363,7 +365,7 @@ MaterioFlag = function(){
       }
       }
     });
     });
   };
   };
-  
+
   function flagEntityWithList(name, nid, token){
   function flagEntityWithList(name, nid, token){
     //trace('MaterioFlag :: flagEntityWithList | name', name);
     //trace('MaterioFlag :: flagEntityWithList | name', name);
     // var ret;
     // var ret;
@@ -376,7 +378,7 @@ MaterioFlag = function(){
       success: function (data2) {
       success: function (data2) {
         //trace('MaterioFlag :: node taged with newly created list : data2', data2)
         //trace('MaterioFlag :: node taged with newly created list : data2', data2)
         if (data2.status) {
         if (data2.status) {
-          
+
           // google analytics
           // google analytics
            $.event.trigger({
            $.event.trigger({
               type : "record-stat",
               type : "record-stat",
@@ -408,7 +410,7 @@ MaterioFlag = function(){
           nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
           nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
         });
         });
     // trace('MaterioFlag :: nids', nids);
     // trace('MaterioFlag :: nids', nids);
-    
+
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
     $.getJSON(url, {nids:nids.join(";")}, function(data) {
     $.getJSON(url, {nids:nids.join(";")}, function(data) {
       // trace('MaterioFlag :: data', data);
       // trace('MaterioFlag :: data', data);
@@ -419,14 +421,14 @@ MaterioFlag = function(){
 
 
         // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
         // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
         // if (typeof Drupal.flagLink != 'undefined')
         // if (typeof Drupal.flagLink != 'undefined')
-        //   Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));  
-        
+        //   Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));
+
         // TODO:  sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources
         // TODO:  sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources
         ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links');
         ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links');
 
 
       }
       }
     });
     });
-    
+
     $.event.trigger({
     $.event.trigger({
       type : 'materioflag-nodelinks-updated',
       type : 'materioflag-nodelinks-updated',
       nids : nids
       nids : nids
@@ -438,12 +440,12 @@ MaterioFlag = function(){
   */
   */
   function onCLickEditList(event){
   function onCLickEditList(event){
     //trace('MaterioFlag :: onCLickEditList | event', event);
     //trace('MaterioFlag :: onCLickEditList | event', event);
-    // TODO:  empécher le double formulaire  
+    // TODO:  empécher le double formulaire
     event.preventDefault();
     event.preventDefault();
     var $link = $(event.currentTarget);
     var $link = $(event.currentTarget);
     var lid = $link.attr('href').match(/[^\/]*$/);
     var lid = $link.attr('href').match(/[^\/]*$/);
     var type = 'materiau'; // this is cheap
     var type = 'materiau'; // this is cheap
-    
+
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
 
 
     $.getJSON(url, function(json){
     $.getJSON(url, function(json){
@@ -483,14 +485,14 @@ MaterioFlag = function(){
           case 'cancel':
           case 'cancel':
             //trace('MaterioFlag :: cancel',event);
             //trace('MaterioFlag :: cancel',event);
             $(this).parents('#modal').remove();
             $(this).parents('#modal').remove();
-            
+
             // google analytics
             // google analytics
-            var action = 'cancel edit form';            
+            var action = 'cancel edit form';
 
 
             break;
             break;
           case 'save':
           case 'save':
             //trace('MaterioFlag :: create',event);
             //trace('MaterioFlag :: create',event);
-            
+
             // google analytics
             // google analytics
             var action = "submit edit form";
             var action = "submit edit form";
 
 
@@ -501,14 +503,14 @@ MaterioFlag = function(){
 
 
             if(confirm('Do you realy want to delete your '+title+' folder ?')){
             if(confirm('Do you realy want to delete your '+title+' folder ?')){
               var action = "submit delete form";
               var action = "submit delete form";
-              deleteList($modal, fid);  
+              deleteList($modal, fid);
             }else{
             }else{
               var action = "cancel delete form";
               var action = "cancel delete form";
             }
             }
-            
+
             break;
             break;
         }
         }
-        
+
         // google analytics
         // google analytics
         $.event.trigger({
         $.event.trigger({
           type:"record-stat",
           type:"record-stat",
@@ -519,7 +521,7 @@ MaterioFlag = function(){
         return false;
         return false;
       })
       })
       .parents('form').find('input[type="text"]').focus();
       .parents('form').find('input[type="text"]').focus();
-      // TODO:  esc keypressed close the form  
+      // TODO:  esc keypressed close the form
   };
   };
 
 
   function saveList($modal, fid, name, title){
   function saveList($modal, fid, name, title){
@@ -536,7 +538,7 @@ MaterioFlag = function(){
       }
       }
       else {
       else {
         //trace('MaterioFlag :: saved list : data', data);
         //trace('MaterioFlag :: saved list : data', data);
-        
+
         $.event.trigger({
         $.event.trigger({
           type : 'list-edited',
           type : 'list-edited',
           name : data.listname,
           name : data.listname,
@@ -625,7 +627,7 @@ MaterioFlag = function(){
     var $newcontent = $(json.rendered),
     var $newcontent = $(json.rendered),
         $newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
         $newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
         $newpager = $('ul.pager', $newcontent);
         $newpager = $('ul.pager', $newcontent);
-    
+
     $(container_class, '#content').append($newitems);
     $(container_class, '#content').append($newitems);
     $('ul.pager', '#content').replaceWith($newpager.hide());
     $('ul.pager', '#content').replaceWith($newpager.hide());
 
 
@@ -670,8 +672,8 @@ MaterioFlag = function(){
   };
   };
 
 
 
 
-  /** 
-  * cookies 
+  /**
+  * cookies
   */
   */
   function createCookie(name,value,days) {
   function createCookie(name,value,days) {
     if (days) {
     if (days) {
@@ -700,10 +702,12 @@ MaterioFlag = function(){
 
 
 
 
   init();
   init();
+
+
 };
 };
 
 
 $(document).ready(function() {
 $(document).ready(function() {
   var materioflag = new MaterioFlag();
   var materioflag = new MaterioFlag();
 });
 });
-  
+
 })(jQuery);
 })(jQuery);

+ 49 - 45
js/materio_flag.min.js

@@ -9,8 +9,8 @@
 function trace(s,o){
 function trace(s,o){
   if(window.console && window.console.debug){
   if(window.console && window.console.debug){
     arguments.length === 2 ? window.console.debug(s,o) : window.console.debug(s);
     arguments.length === 2 ? window.console.debug(s,o) : window.console.debug(s);
-  }else if(window.console && window.console.log){
-    arguments.length === 2 ? window.console.log(s,o) : window.console.log(s);
+  }else if(console && console.log){
+    arguments.length === 2 ? console.log(s,o) : console.log(s);
   }
   }
 };
 };
 
 
@@ -30,7 +30,7 @@ function loadjscssfile(filename, filetype){
  }
  }
  if (typeof fileref!="undefined")
  if (typeof fileref!="undefined")
   document.getElementsByTagName("head")[0].appendChild(fileref)
   document.getElementsByTagName("head")[0].appendChild(fileref)
-}
+};
 
 
 // ------ TIMEOUT
 // ------ TIMEOUT
 
 
@@ -369,7 +369,7 @@ function getElementAngle(x1, y1, x2, y2) {
 
 
 
 
 // @codekit-prepend "gui.js"
 // @codekit-prepend "gui.js"
-// @koala-prepend "gui_ck_fw/gui.js"
+// @koala-prepend "gui.js"
 
 
 
 
 (function($) {
 (function($) {
@@ -457,14 +457,14 @@ MaterioFlag = function(){
           .bind('click', onClickCreatLink)
           .bind('click', onClickCreatLink)
           .addClass('ajax-processed');
           .addClass('ajax-processed');
 
 
-      
+
         // preview block
         // preview block
         $('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
         $('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
           var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
           var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
           $('<i class="icon-remove"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
           $('<i class="icon-remove"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
 
 
           $('a.open-list',  this).bind('click', onClickOpenLink);
           $('a.open-list',  this).bind('click', onClickOpenLink);
-        
+
         }).addClass('ajax-processed');
         }).addClass('ajax-processed');
         break;
         break;
     }
     }
@@ -476,7 +476,7 @@ MaterioFlag = function(){
         type : 'my'+type+'-block-builded',
         type : 'my'+type+'-block-builded',
         block : block,
         block : block,
         name : name
         name : name
-      });  
+      });
     },10);
     },10);
 
 
     // trace('MaterioFlag :: activename', activename);
     // trace('MaterioFlag :: activename', activename);
@@ -485,7 +485,7 @@ MaterioFlag = function(){
 
 
     // trace('MaterioFlag :: activename', activename);
     // trace('MaterioFlag :: activename', activename);
     if(activename)
     if(activename)
-      showPreview(activename, block);    
+      showPreview(activename, block);
   };
   };
 
 
   function refreshBlocks(name){
   function refreshBlocks(name){
@@ -495,17 +495,18 @@ MaterioFlag = function(){
     }else if($('#block-materio-flag-materio-flag-mylists').length){
     }else if($('#block-materio-flag-materio-flag-mylists').length){
       var type = 'lists';
       var type = 'lists';
     }
     }
-    
+
+
     if(type != undefined){
     if(type != undefined){
       var id = '#block-materio-flag-materio-flag-my'+type;
       var id = '#block-materio-flag-materio-flag-my'+type;
       var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
       var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
       $.getJSON(url, function(json){
       $.getJSON(url, function(json){
-        //trace('MaterioFlag :: block refreshed '+type, json);
-        
+        // trace('MaterioFlag :: block refreshed '+type, json);
+
         $(id).replaceWith(json.block);
         $(id).replaceWith(json.block);
         $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
         $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
-        
-        buildBlocks(name);        
+
+        buildBlocks(name);
 
 
         $.event.trigger({
         $.event.trigger({
           type : 'my'+type+'-block-updated',
           type : 'my'+type+'-block-updated',
@@ -520,7 +521,7 @@ MaterioFlag = function(){
     //trace('MaterioFlag :: ajaxifyLinks', container);
     //trace('MaterioFlag :: ajaxifyLinks', container);
 
 
     container = ((container != null) ? container : 'body');
     container = ((container != null) ? container : 'body');
- 
+
     // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
     // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
     if (typeof Drupal.flagLink != 'undefined')
     if (typeof Drupal.flagLink != 'undefined')
       Drupal.flagLink(container);
       Drupal.flagLink(container);
@@ -532,6 +533,7 @@ MaterioFlag = function(){
         .addClass('ajax-processed');
         .addClass('ajax-processed');
     }
     }
 
 
+
     $('a.flag-lists-create:not(.ajax-processed)', container)
     $('a.flag-lists-create:not(.ajax-processed)', container)
       .bind('click', onClickCreatLink)
       .bind('click', onClickCreatLink)
       .addClass('ajax-processed');
       .addClass('ajax-processed');
@@ -559,9 +561,9 @@ MaterioFlag = function(){
     //trace('MaterioFlag :: onClickClosePreview', event);
     //trace('MaterioFlag :: onClickClosePreview', event);
     eraseCookie('materiomyflaglistsopened');
     eraseCookie('materiomyflaglistsopened');
     if($(this).attr('name') == 'bookmarks'){
     if($(this).attr('name') == 'bookmarks'){
-      $(this).parents('.block').find('section.bookmarks').removeClass('active');  
+      $(this).parents('.block').find('section.bookmarks').removeClass('active');
     }else{
     }else{
-      $(this).parents('section.flag-list').removeClass('active');  
+      $(this).parents('section.flag-list').removeClass('active');
     }
     }
 
 
     $.event.trigger('init-layout');
     $.event.trigger('init-layout');
@@ -582,7 +584,7 @@ MaterioFlag = function(){
   function loadList(fid){
   function loadList(fid){
     //trace('MaterioFlag :: loadList | fid', fid);
     //trace('MaterioFlag :: loadList | fid', fid);
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid;
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid;
-    
+
     $.event.trigger('loading-content');
     $.event.trigger('loading-content');
 
 
     $.getJSON(url, {'current_path':document.location.href},function(json){
     $.getJSON(url, {'current_path':document.location.href},function(json){
@@ -599,14 +601,14 @@ MaterioFlag = function(){
     if(json.rendered){
     if(json.rendered){
 
 
       $('.inner-content','#content').html(json.rendered);
       $('.inner-content','#content').html(json.rendered);
-      
+
       $.event.trigger('loaded-content');
       $.event.trigger('loaded-content');
-      
+
       // no need of ajaxifylinks because it's triggered with resultschanged
       // no need of ajaxifylinks because it's triggered with resultschanged
       // ajaxifyLinks('#content');
       // ajaxifyLinks('#content');
 
 
       var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path;
       var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path;
-      
+
       $.event.trigger({
       $.event.trigger({
         type : 'new-history-page',
         type : 'new-history-page',
         path : path,
         path : path,
@@ -614,10 +616,10 @@ MaterioFlag = function(){
         content : json.rendered
         content : json.rendered
       });
       });
 
 
-      // TODO:  change language links for folders  
+      // TODO:  change language links for folders
       // for (language in Drupal.settings.materio_search_api_ajax.languages) {
       // for (language in Drupal.settings.materio_search_api_ajax.languages) {
       //   var l = Drupal.settings.materio_search_api_ajax.languages[language];
       //   var l = Drupal.settings.materio_search_api_ajax.languages[language];
-      //   $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)        
+      //   $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)
       // };
       // };
 
 
       triggerContentChanged();
       triggerContentChanged();
@@ -676,7 +678,7 @@ MaterioFlag = function(){
           case 'cancel':
           case 'cancel':
             //trace('MaterioFlag :: cancel',event);
             //trace('MaterioFlag :: cancel',event);
             $(this).parents('#modal').remove();
             $(this).parents('#modal').remove();
-            
+
             // google analytics
             // google analytics
             $.event.trigger({
             $.event.trigger({
               type:"record-stat",
               type:"record-stat",
@@ -701,11 +703,11 @@ MaterioFlag = function(){
             createList($modal, type, title, $link);
             createList($modal, type, title, $link);
             break;
             break;
         }
         }
-        
+
         return false;
         return false;
       })
       })
       .parents('form').find('input[type="text"]').focus();
       .parents('form').find('input[type="text"]').focus();
-      // TODO:  esc keypressed close the form  
+      // TODO:  esc keypressed close the form
   };
   };
 
 
   function createList($modal, type, title, $link){
   function createList($modal, type, title, $link){
@@ -733,7 +735,7 @@ MaterioFlag = function(){
       }
       }
     });
     });
   };
   };
-  
+
   function flagEntityWithList(name, nid, token){
   function flagEntityWithList(name, nid, token){
     //trace('MaterioFlag :: flagEntityWithList | name', name);
     //trace('MaterioFlag :: flagEntityWithList | name', name);
     // var ret;
     // var ret;
@@ -746,7 +748,7 @@ MaterioFlag = function(){
       success: function (data2) {
       success: function (data2) {
         //trace('MaterioFlag :: node taged with newly created list : data2', data2)
         //trace('MaterioFlag :: node taged with newly created list : data2', data2)
         if (data2.status) {
         if (data2.status) {
-          
+
           // google analytics
           // google analytics
            $.event.trigger({
            $.event.trigger({
               type : "record-stat",
               type : "record-stat",
@@ -778,7 +780,7 @@ MaterioFlag = function(){
           nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
           nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
         });
         });
     // trace('MaterioFlag :: nids', nids);
     // trace('MaterioFlag :: nids', nids);
-    
+
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
     $.getJSON(url, {nids:nids.join(";")}, function(data) {
     $.getJSON(url, {nids:nids.join(";")}, function(data) {
       // trace('MaterioFlag :: data', data);
       // trace('MaterioFlag :: data', data);
@@ -789,14 +791,14 @@ MaterioFlag = function(){
 
 
         // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
         // trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
         // if (typeof Drupal.flagLink != 'undefined')
         // if (typeof Drupal.flagLink != 'undefined')
-        //   Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));  
-        
+        //   Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));
+
         // TODO:  sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources
         // TODO:  sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources
         ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links');
         ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links');
 
 
       }
       }
     });
     });
-    
+
     $.event.trigger({
     $.event.trigger({
       type : 'materioflag-nodelinks-updated',
       type : 'materioflag-nodelinks-updated',
       nids : nids
       nids : nids
@@ -808,12 +810,12 @@ MaterioFlag = function(){
   */
   */
   function onCLickEditList(event){
   function onCLickEditList(event){
     //trace('MaterioFlag :: onCLickEditList | event', event);
     //trace('MaterioFlag :: onCLickEditList | event', event);
-    // TODO:  empécher le double formulaire  
+    // TODO:  empécher le double formulaire
     event.preventDefault();
     event.preventDefault();
     var $link = $(event.currentTarget);
     var $link = $(event.currentTarget);
     var lid = $link.attr('href').match(/[^\/]*$/);
     var lid = $link.attr('href').match(/[^\/]*$/);
     var type = 'materiau'; // this is cheap
     var type = 'materiau'; // this is cheap
-    
+
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
     var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
 
 
     $.getJSON(url, function(json){
     $.getJSON(url, function(json){
@@ -853,14 +855,14 @@ MaterioFlag = function(){
           case 'cancel':
           case 'cancel':
             //trace('MaterioFlag :: cancel',event);
             //trace('MaterioFlag :: cancel',event);
             $(this).parents('#modal').remove();
             $(this).parents('#modal').remove();
-            
+
             // google analytics
             // google analytics
-            var action = 'cancel edit form';            
+            var action = 'cancel edit form';
 
 
             break;
             break;
           case 'save':
           case 'save':
             //trace('MaterioFlag :: create',event);
             //trace('MaterioFlag :: create',event);
-            
+
             // google analytics
             // google analytics
             var action = "submit edit form";
             var action = "submit edit form";
 
 
@@ -871,14 +873,14 @@ MaterioFlag = function(){
 
 
             if(confirm('Do you realy want to delete your '+title+' folder ?')){
             if(confirm('Do you realy want to delete your '+title+' folder ?')){
               var action = "submit delete form";
               var action = "submit delete form";
-              deleteList($modal, fid);  
+              deleteList($modal, fid);
             }else{
             }else{
               var action = "cancel delete form";
               var action = "cancel delete form";
             }
             }
-            
+
             break;
             break;
         }
         }
-        
+
         // google analytics
         // google analytics
         $.event.trigger({
         $.event.trigger({
           type:"record-stat",
           type:"record-stat",
@@ -889,7 +891,7 @@ MaterioFlag = function(){
         return false;
         return false;
       })
       })
       .parents('form').find('input[type="text"]').focus();
       .parents('form').find('input[type="text"]').focus();
-      // TODO:  esc keypressed close the form  
+      // TODO:  esc keypressed close the form
   };
   };
 
 
   function saveList($modal, fid, name, title){
   function saveList($modal, fid, name, title){
@@ -906,7 +908,7 @@ MaterioFlag = function(){
       }
       }
       else {
       else {
         //trace('MaterioFlag :: saved list : data', data);
         //trace('MaterioFlag :: saved list : data', data);
-        
+
         $.event.trigger({
         $.event.trigger({
           type : 'list-edited',
           type : 'list-edited',
           name : data.listname,
           name : data.listname,
@@ -995,7 +997,7 @@ MaterioFlag = function(){
     var $newcontent = $(json.rendered),
     var $newcontent = $(json.rendered),
         $newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
         $newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
         $newpager = $('ul.pager', $newcontent);
         $newpager = $('ul.pager', $newcontent);
-    
+
     $(container_class, '#content').append($newitems);
     $(container_class, '#content').append($newitems);
     $('ul.pager', '#content').replaceWith($newpager.hide());
     $('ul.pager', '#content').replaceWith($newpager.hide());
 
 
@@ -1040,8 +1042,8 @@ MaterioFlag = function(){
   };
   };
 
 
 
 
-  /** 
-  * cookies 
+  /**
+  * cookies
   */
   */
   function createCookie(name,value,days) {
   function createCookie(name,value,days) {
     if (days) {
     if (days) {
@@ -1070,10 +1072,12 @@ MaterioFlag = function(){
 
 
 
 
   init();
   init();
+
+
 };
 };
 
 
 $(document).ready(function() {
 $(document).ready(function() {
   var materioflag = new MaterioFlag();
   var materioflag = new MaterioFlag();
 });
 });
-  
+
 })(jQuery);
 })(jQuery);

+ 22 - 8
js/materio_user.js

@@ -4,7 +4,7 @@
 (function($) {
 (function($) {
 
 
 MaterioUser = function(){
 MaterioUser = function(){
-  
+
   var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
   var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
 
 
   function init() {
   function init() {
@@ -17,7 +17,7 @@ MaterioUser = function(){
     // trace('initAdhesion');
     // trace('initAdhesion');
     $('.get-link a').bind('click', function(event) {
     $('.get-link a').bind('click', function(event) {
       // trace('get-link click');
       // trace('get-link click');
-      
+
       // do not show the registration form if already logged-in
       // do not show the registration form if already logged-in
       if($('body').is('.logged-in'))
       if($('body').is('.logged-in'))
         return true;
         return true;
@@ -29,7 +29,7 @@ MaterioUser = function(){
              href = $this.attr("href"),
              href = $this.attr("href"),
              destination = href.match('/\?destination=([^,]+)');
              destination = href.match('/\?destination=([^,]+)');
 
 
-      destination = "/" + destination[1].replace('%23', '#');       
+      destination = "/" + destination[1].replace('%23', '#');
       destination = destination.replace('//', '/');
       destination = destination.replace('//', '/');
       // trace('destination', destination);
       // trace('destination', destination);
 
 
@@ -55,7 +55,7 @@ MaterioUser = function(){
   function formLoaded(json, destination){
   function formLoaded(json, destination){
     //trace('formLoaded | json', json);
     //trace('formLoaded | json', json);
     var $modal = $('<div>').addClass('modal-content').append(json.block);
     var $modal = $('<div>').addClass('modal-content').append(json.block);
-    
+
     var id,label, description;
     var id,label, description;
     $('input.form-text', $modal).each(function(i) {
     $('input.form-text', $modal).each(function(i) {
       id = $(this).attr('id');
       id = $(this).attr('id');
@@ -83,11 +83,16 @@ MaterioUser = function(){
 
 
     $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
     $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
       event.preventDefault();
       event.preventDefault();
+
+      // disable submit button to avoid duplicate user creation
+      // console.log('click', this);
+      $(this).attr('disabled', 'true');
+
       $.ajax({
       $.ajax({
         type: 'POST',
         type: 'POST',
         dataType:'json',
         dataType:'json',
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
-        data: $('#user-register-form', $modal).serialize(), 
+        data: $('#user-register-form', $modal).serialize(),
         success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
         success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
       });
       });
@@ -100,14 +105,14 @@ MaterioUser = function(){
         type: 'POST',
         type: 'POST',
         dataType:'json',
         dataType:'json',
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
-        data: $('#user-login', $modal).serialize(), 
+        data: $('#user-login', $modal).serialize(),
         success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
         success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
       });
       });
       return false;
       return false;
     });
     });
 
 
-    // google analytics 
+    // google analytics
     // $.event.trigger({
     // $.event.trigger({
     //   type : "record-stat",
     //   type : "record-stat",
     //   categorie : 'Search',
     //   categorie : 'Search',
@@ -120,12 +125,21 @@ MaterioUser = function(){
   };
   };
 
 
   function onUserLoginRegisterSubmit($form, data, destination){
   function onUserLoginRegisterSubmit($form, data, destination){
+    // console.log('data', data);
     cleanModalErrors();
     cleanModalErrors();
     if(data.errors != null){
     if(data.errors != null){
       for(field in data.errors){
       for(field in data.errors){
         $('input[name='+field+']', $form).addClass('error');
         $('input[name='+field+']', $form).addClass('error');
         $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
         $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
       }
       }
+
+      (function($form){
+        setTimeout(function(){
+          console.log('enabled');
+          $('input[type=submit]', $form).removeAttr('disabled');
+        }, 0.5*1000);
+      })($form);
+
     }else{
     }else{
       // trace('destination = '+destination);
       // trace('destination = '+destination);
       window.location.pathname = destination;
       window.location.pathname = destination;
@@ -143,5 +157,5 @@ MaterioUser = function(){
 $(document).ready(function() {
 $(document).ready(function() {
   var materiouser = new MaterioUser();
   var materiouser = new MaterioUser();
 });
 });
-  
+
 })(jQuery);
 })(jQuery);

+ 22 - 8
js/materio_user.min.js

@@ -374,7 +374,7 @@ function getElementAngle(x1, y1, x2, y2) {
 (function($) {
 (function($) {
 
 
 MaterioUser = function(){
 MaterioUser = function(){
-  
+
   var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
   var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
 
 
   function init() {
   function init() {
@@ -387,7 +387,7 @@ MaterioUser = function(){
     // trace('initAdhesion');
     // trace('initAdhesion');
     $('.get-link a').bind('click', function(event) {
     $('.get-link a').bind('click', function(event) {
       // trace('get-link click');
       // trace('get-link click');
-      
+
       // do not show the registration form if already logged-in
       // do not show the registration form if already logged-in
       if($('body').is('.logged-in'))
       if($('body').is('.logged-in'))
         return true;
         return true;
@@ -399,7 +399,7 @@ MaterioUser = function(){
              href = $this.attr("href"),
              href = $this.attr("href"),
              destination = href.match('/\?destination=([^,]+)');
              destination = href.match('/\?destination=([^,]+)');
 
 
-      destination = "/" + destination[1].replace('%23', '#');       
+      destination = "/" + destination[1].replace('%23', '#');
       destination = destination.replace('//', '/');
       destination = destination.replace('//', '/');
       // trace('destination', destination);
       // trace('destination', destination);
 
 
@@ -425,7 +425,7 @@ MaterioUser = function(){
   function formLoaded(json, destination){
   function formLoaded(json, destination){
     //trace('formLoaded | json', json);
     //trace('formLoaded | json', json);
     var $modal = $('<div>').addClass('modal-content').append(json.block);
     var $modal = $('<div>').addClass('modal-content').append(json.block);
-    
+
     var id,label, description;
     var id,label, description;
     $('input.form-text', $modal).each(function(i) {
     $('input.form-text', $modal).each(function(i) {
       id = $(this).attr('id');
       id = $(this).attr('id');
@@ -453,11 +453,16 @@ MaterioUser = function(){
 
 
     $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
     $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
       event.preventDefault();
       event.preventDefault();
+
+      // disable submit button to avoid duplicate user creation
+      // console.log('click', this);
+      $(this).attr('disabled', 'true');
+
       $.ajax({
       $.ajax({
         type: 'POST',
         type: 'POST',
         dataType:'json',
         dataType:'json',
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
-        data: $('#user-register-form', $modal).serialize(), 
+        data: $('#user-register-form', $modal).serialize(),
         success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
         success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
       });
       });
@@ -470,14 +475,14 @@ MaterioUser = function(){
         type: 'POST',
         type: 'POST',
         dataType:'json',
         dataType:'json',
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
         url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
-        data: $('#user-login', $modal).serialize(), 
+        data: $('#user-login', $modal).serialize(),
         success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
         success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
         error: function(jqXHR, textStatus, errorThrown) { trace('error : '+textStatus+' | '+errorThrown); }
       });
       });
       return false;
       return false;
     });
     });
 
 
-    // google analytics 
+    // google analytics
     // $.event.trigger({
     // $.event.trigger({
     //   type : "record-stat",
     //   type : "record-stat",
     //   categorie : 'Search',
     //   categorie : 'Search',
@@ -490,12 +495,21 @@ MaterioUser = function(){
   };
   };
 
 
   function onUserLoginRegisterSubmit($form, data, destination){
   function onUserLoginRegisterSubmit($form, data, destination){
+    // console.log('data', data);
     cleanModalErrors();
     cleanModalErrors();
     if(data.errors != null){
     if(data.errors != null){
       for(field in data.errors){
       for(field in data.errors){
         $('input[name='+field+']', $form).addClass('error');
         $('input[name='+field+']', $form).addClass('error');
         $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
         $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
       }
       }
+
+      (function($form){
+        setTimeout(function(){
+          console.log('enabled');
+          $('input[type=submit]', $form).removeAttr('disabled');
+        }, 0.5*1000);
+      })($form);
+
     }else{
     }else{
       // trace('destination = '+destination);
       // trace('destination = '+destination);
       window.location.pathname = destination;
       window.location.pathname = destination;
@@ -513,5 +527,5 @@ MaterioUser = function(){
 $(document).ready(function() {
 $(document).ready(function() {
   var materiouser = new MaterioUser();
   var materiouser = new MaterioUser();
 });
 });
-  
+
 })(jQuery);
 })(jQuery);

+ 177 - 3
materio_admin.module

@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 
 
 
 /**
 /**
@@ -14,9 +14,98 @@ function materio_admin_permission() {
       'title' => t('access default UC roles expiration list'),
       'title' => t('access default UC roles expiration list'),
       'description' => t('access default UC roles expiration list.'),
       'description' => t('access default UC roles expiration list.'),
     ),
     ),
+    'access duplicate mails list' => array(
+      'title' => t('access duplicate mails list'),
+      'description' => t('access duplicate mails list.'),
+    ),
   );
   );
 }
 }
 
 
+/**
+ * Implements hook_menu().
+ */
+function materio_admin_menu() {
+
+  $items['admin/users/duplicatemails'] = array(
+    'title' => "Duplicate mails",
+    'page callback' => 'materio_duplicatemails',
+    'access callback' => 'user_access',
+    'access arguments' => array('access duplicate mails list'),
+    'type' => MENU_LOCAL_TASK
+  );
+
+
+
+  if(module_exists('simplenews')){
+    $cats = simplenews_category_list();
+    // dsm($cats, 'cats');
+    foreach ($cats as $tid => $name) {
+      // $items['node/%node/simplenews'] = array(
+      //   'title' => 'Newsletter',
+      //   'type' => MENU_LOCAL_TASK,
+      //   'access callback' => 'simplenews_node_tab_access',
+      //   'access arguments' => array(1),
+      //   'page callback' => 'simplenews_node_tab_page',
+      //   'page arguments' => array(1),
+      //   'context' => MENU_LOCAL_TASK,
+      //   'file' => 'includes/simplenews.admin.inc',
+      //   'weight' => 2,
+      // );
+      $items['node/add/simplenews/'.$tid] = array(
+        'title' => $name,
+        'title callback' => 'check_plain',
+        'page callback' => 'node_add',
+        'page arguments' => array('simplenews'),
+        'access callback' => 'node_access',
+        'access arguments' => array('create', 'simplenews'),
+        'file path' => drupal_get_path('module', 'node'),
+        'file' => 'node.pages.inc',
+      );
+    }
+  }
+  return $items;
+}
+
+function materio_duplicatemails(){
+  $mails = db_query('SELECT mail FROM {users} GROUP BY mail HAVING count(mail) > 1')->fetchCol();
+
+  // Bail out early if there are no duplicates.
+  if (!$mails) {
+    return t('All accounts have unique email addresses.');
+  }
+
+  // Grab all the user data for accounts with addresses identified as
+  // duplicates. This is a little convoluted, but it lets us grab all the user
+  // data in one shot.
+  $uids = db_select('users', 'u')
+    ->fields('u', array('uid'))
+    ->condition('mail', $mails, 'IN')
+    ->orderBy('access', 'DESC')
+    ->execute()
+    ->fetchCol();
+  $duplicate_users = user_load_multiple($uids);
+  $duplicate_mails = array();
+  foreach ($duplicate_users as $duplicate_user) {
+    $duplicate_mails[$duplicate_user->mail][] = $duplicate_user;
+  }
+
+  // Turn the data we've got into markup.
+  $output = t('Accounts with duplicate email address:') . '<br />';
+  $output = "<ul>";
+  foreach ($duplicate_mails as $mail => $users) {
+    $output .= "<li> <strong>$mail</strong> : <br />";
+    $accounts = array();
+    foreach ($users as $duplicate_user) {
+       $accounts[] =  l($duplicate_user->name, "user/{$duplicate_user->uid}") . ' ('. date('Y-m-d', $duplicate_user->access) .')';
+    }
+    $output .= implode(', ', $accounts);
+
+      $output .= '</li>';
+  }
+  $output .= "</ul>";
+  return $output;
+}
+
 /**
 /**
  * Implements hook_menu_alter().
  * Implements hook_menu_alter().
  */
  */
@@ -27,12 +116,97 @@ function materio_admin_menu_alter(&$items){
     $items['admin/people']['access arguments'] = array('access default users list');
     $items['admin/people']['access arguments'] = array('access default users list');
     // dsm($items['admin/people']);
     // dsm($items['admin/people']);
   }
   }
-    
+
   if(isset($items['admin/people/expiration'])){
   if(isset($items['admin/people/expiration'])){
     $items['admin/people/expiration']['access arguments'] = array('access default UC roles expiration list');
     $items['admin/people/expiration']['access arguments'] = array('access default UC roles expiration list');
     // dsm($items['admin/people/expiration']);
     // dsm($items['admin/people/expiration']);
   }
   }
-    
+
   # deactivate default home page
   # deactivate default home page
   $items['node']['access callback'] = FALSE;
   $items['node']['access callback'] = FALSE;
+
+  // if(isset($items['admin/content/add/simplenews'])){
+    // delete($items['admin/content/add/simplenews']);
+  //   $cats = simplenews_category_list();
+  //   dsm($cats, 'cats');
+  //   foreach ($cats as $tid => $name) {
+  //     $items['admin/content/add/simplenews/'.$tid]
+  //   }
+  // }
 }
 }
+
+/**
+ * Implements hook_menu_local_tasks_alter().
+ */
+function materio_admin_menu_local_tasks_alter(&$data, $router_item, $root_path) {
+
+  if ($root_path == 'admin/people/simplenews') {
+    $item = menu_get_item('admin/content/simplenews');
+    if ($item['access']) {
+      $item['title'] = 'Go to '.$item['title'];
+      $data['actions']['output'][] = array(
+        '#theme' => 'menu_local_task',
+        '#link' => $item,
+      );
+    }
+  }
+
+  if ($root_path == 'admin/content/simplenews') {
+
+    $cats = simplenews_category_list();
+    foreach ($cats as $tid => $name) {
+      $item = menu_get_item('node/add/simplenews/'.$tid);
+      $item['title'] = 'Add new '.$name;
+      if ($item['access']) {
+        $data['actions']['output'][] = array(
+          '#theme' => 'menu_local_task',
+          '#link' => $item,
+        );
+      }
+    }
+
+    $item = menu_get_item('admin/people/simplenews');
+    if ($item['access']) {
+      $item['title'] = 'Go to '.$item['title'];
+      $data['actions']['output'][] = array(
+        '#theme' => 'menu_local_task',
+        '#link' => $item,
+      );
+    }
+  }
+}
+
+/**
+  * Implements hook_form_alter().
+  */
+function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $form_id) {
+  // dsm($form_id, '$form_id');
+  // dsm($form_state, '$form_state');
+  // dsm($form, '$form');
+  // dsm($_GET, 'GET');
+
+  if(!$form['nid']['#value']){
+    $cats = simplenews_category_list();
+    $cats_tids = array_keys($cats);
+    $q = parse_url($_GET['q']);
+    $cat = array_pop(explode('/', $q['path']));
+    // dsm($cat, 'cat');
+    if(in_array($cat, $cats_tids)){
+      // prepopulate type of news
+      $form['field_simplenews_term']['und']['#default_value'] = $cat;
+      $form['field_simplenews_term']['und']['#disabled'] = true;
+
+      // change default template regarding type of news
+      $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($cat);
+    }
+  }else{
+    $form['field_simplenews_term']['und']['#disabled'] = true;
+  }
+
+  $form['body']['und'][0]['#rows'] = 50;
+
+}
+
+function materio_admin_getSimplenewsNodeBodyTemplate($cat){
+  return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$cat.'_node.html');
+}

+ 23 - 0
materio_display.info

@@ -0,0 +1,23 @@
+name = Materio Display
+description = "Materio display module (permissions, ...)"
+
+; Core version (required)
+core = 7.x
+
+; Package name (see http://drupal.org/node/542202 for a list of names)
+package = Materio
+
+; PHP version requirement (optional)
+; php = 5.2
+
+; Loadable code files
+; files[] = materio_ctools_automodal.module
+
+; Module dependencies
+; dependencies[] = user
+
+; Configuration page
+; configure = admin/config/materiobasemod
+
+; For further information about configuration options, see
+; - http://drupal.org/node/542202

+ 58 - 0
materio_display.module

@@ -0,0 +1,58 @@
+<?php
+
+
+/**
+ * Implements hook_init().
+ */
+// function materio_user_init() {
+//   drupal_add_js(drupal_get_path('module', 'materio_user').'/js/materio_user.min.js');
+// }
+
+
+/**
+ * Implements hook_permission().
+ */
+function materio_display_permission() {
+  return array(
+    'view full materiau description' =>  array(
+      'title' => t('view full materiau description'),
+      'description' => t('view full materiau description'),
+    ),
+  );
+}
+
+/**
+ * Implements hook_preprocess().
+ */
+function materio_display_preprocess_field(&$vars, $hook) {
+  // dsm($vars);
+  $element = $vars['element'];
+
+  if($element['#field_name'] == 'field_description'){
+    dsm($vars);
+    if(!user_access('view full materiau description')){
+      $value = $element['#items'][0]['value'];
+
+      switch ($element['#view_mode']) {
+        case 'cardbig':
+        case 'cardfull':
+          $limit = 210;
+          break;
+        default:
+          $limit = 130;
+          break;
+      }
+      $summary = truncate_utf8($value, $limit, TRUE, TRUE);
+
+      $summary .= '<div class="upgrade"><p>'
+        . t("In order to access full description, information about manufacturers and more, you need to upgrade your account.")
+        . l(t("Pricing"), 'node/11187')
+        . '</p></div>';
+
+      // dsm($summary);
+      $vars['items'][0]['#markup'] = $summary;
+
+    }
+  }
+
+}

+ 32 - 32
materio_flag.module

@@ -5,7 +5,7 @@
  * The Flag bookmark module.
  * The Flag bookmark module.
  *
  *
  * This module creates a default Flag when enabled.
  * This module creates a default Flag when enabled.
- * 
+ *
  */
  */
 
 
 /**
 /**
@@ -55,14 +55,14 @@ function materio_flag_menu() {
     'page callback' => 'materio_flag_createlist_form',
     'page callback' => 'materio_flag_createlist_form',
     'page arguments' => array(3),
     'page arguments' => array(3),
   );
   );
-  
+
   $items['materioflag/editlistform/%/%'] = $base+array(
   $items['materioflag/editlistform/%/%'] = $base+array(
     'access arguments' => array('create flag lists'),
     'access arguments' => array('create flag lists'),
     'access callback' => 'user_access',
     'access callback' => 'user_access',
     'page callback' => 'materio_flag_editlist_form',
     'page callback' => 'materio_flag_editlist_form',
     'page arguments' => array(2,3),
     'page arguments' => array(2,3),
   );
   );
-  
+
   $items['materioflag/editlist/%/%'] = $base+array(
   $items['materioflag/editlist/%/%'] = $base+array(
     'access arguments' => array('create flag lists'),
     'access arguments' => array('create flag lists'),
     'access callback' => 'user_access',
     'access callback' => 'user_access',
@@ -83,7 +83,7 @@ function materio_flag_menu() {
     'page callback' => 'materio_flag_nodelinks',
     'page callback' => 'materio_flag_nodelinks',
     // 'page arguments' => array(3),
     // 'page arguments' => array(3),
   );
   );
-  
+
   $items['lists/%'] = $base+array(
   $items['lists/%'] = $base+array(
     'access arguments' => array('view flag lists'),
     'access arguments' => array('view flag lists'),
     'access callback' => 'user_access',
     'access callback' => 'user_access',
@@ -121,7 +121,7 @@ function materio_flag_menu_alter(&$items) {
  * Implements hook_block_info().
  * Implements hook_block_info().
  */
  */
 function materio_flag_block_info() {
 function materio_flag_block_info() {
-  
+
   $blocks['materio_flag_mybookmarks'] = array(
   $blocks['materio_flag_mybookmarks'] = array(
     'info' => t('My bookmarks'),
     'info' => t('My bookmarks'),
     'cache' => DRUPAL_NO_CACHE
     'cache' => DRUPAL_NO_CACHE
@@ -160,7 +160,7 @@ function materio_flag_block_view($delta = '') {
   	      }
   	      }
           // TODO:  put this title generation on a theme function
           // TODO:  put this title generation on a theme function
           $subject = '<span class="listname">'.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).'</span>';
           $subject = '<span class="listname">'.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).'</span>';
-  	      $block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); // 
+  	      $block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); //
   	      $block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark"));
   	      $block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark"));
         }else{
         }else{
         	$block['subject'] = t('My bookmarks');
         	$block['subject'] = t('My bookmarks');
@@ -175,7 +175,7 @@ function materio_flag_block_view($delta = '') {
         // $userflags = flag_get_user_flags('node');
         // $userflags = flag_get_user_flags('node');
         // dsm($userflags, 'userflags');
         // dsm($userflags, 'userflags');
         // dsm($flags, 'flags');
         // dsm($flags, 'flags');
-        
+
         foreach ($flags as $name => $flag) {
         foreach ($flags as $name => $flag) {
           $flag->path = url('lists/'.$flag->fid);
           $flag->path = url('lists/'.$flag->fid);
           $flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid);
           $flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid);
@@ -222,7 +222,7 @@ function materio_flag_block_view($delta = '') {
         // if($flags){
         // if($flags){
           // $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list')));
           // $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list')));
           $block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
           $block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
-        
+
           $block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
           $block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
           // $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
           // $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
         // }
         // }
@@ -255,7 +255,7 @@ function materio_flag_entity_info_alter(&$entity_info) {
 function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
 function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
   if($type == 'node'){
   if($type == 'node'){
     if(user_access('create flag lists') && $view_mode != 'print'){
     if(user_access('create flag lists') && $view_mode != 'print'){
-      
+
       $entity->content['flaglistslinks'] = materio_flag_get_entity_links($entity, $type, $view_mode);
       $entity->content['flaglistslinks'] = materio_flag_get_entity_links($entity, $type, $view_mode);
 
 
       drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css');
       drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css');
@@ -268,12 +268,12 @@ function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
           foreach ($flags as $flag) {
           foreach ($flags as $flag) {
             // dsm($flag, 'flag');
             // dsm($flag, 'flag');
             if ( ($flag->module == 'flag_lists' && _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0)) || $flag->is_flagged($entity->nid) ) {
             if ( ($flag->module == 'flag_lists' && _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0)) || $flag->is_flagged($entity->nid) ) {
-              $entity->flags[] = $flag;      
+              $entity->flags[] = $flag;
             }
             }
           }
           }
         }
         }
       }
       }
-      
+
     }
     }
   }
   }
 }
 }
@@ -290,10 +290,10 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
   $links = array();
   $links = array();
   # if flag name is provided we are on flaglists content list (block mylists)
   # if flag name is provided we are on flaglists content list (block mylists)
   if($view_mode == 'bookmark'){
   if($view_mode == 'bookmark'){
-    // TODO:  define view mode in settings  
+    // TODO:  define view mode in settings
     // if (isset($entity->flag_names) && $flags = flag_lists_get_user_flags($entity->type, $user)) {
     // if (isset($entity->flag_names) && $flags = flag_lists_get_user_flags($entity->type, $user)) {
     //   // dsm($flags, 'flags');
     //   // dsm($flags, 'flags');
-    //   // TODO:  limit flag link by current flag list  
+    //   // TODO:  limit flag link by current flag list
     //   foreach ($flags as $flag) {
     //   foreach ($flags as $flag) {
     //     //dsm($flag->name, 'flag');
     //     //dsm($flag->name, 'flag');
     //     if(in_array($flag->name, $entity->flag_names)){
     //     if(in_array($flag->name, $entity->flag_names)){
@@ -301,7 +301,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
     //         $action = _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0) ? 'unflag' : 'flag';
     //         $action = _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0) ? 'unflag' : 'flag';
     //       } else {
     //       } else {
     //         $action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag';
     //         $action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag';
-    //       }  
+    //       }
     //       $flag->module = 'materio_flag';
     //       $flag->module = 'materio_flag';
     //       $link = $flag->theme($action, $entity->nid);
     //       $link = $flag->theme($action, $entity->nid);
 
 
@@ -349,12 +349,12 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
 
 
       }
       }
     }
     }
-    
+
     // dsm($items, 'items '.$entity->title);
     // dsm($items, 'items '.$entity->title);
 
 
     #create new list
     #create new list
     $link = l(
     $link = l(
-      '<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>', 
+      '<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>',
       'flag-lists/add/' . $entity->type,
       'flag-lists/add/' . $entity->type,
       array(
       array(
         'attributes' => array(
         'attributes' => array(
@@ -366,7 +366,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
         'html' => TRUE,
         'html' => TRUE,
       )
       )
     );
     );
-    
+
     $create = array(
     $create = array(
       'data' => $link,
       'data' => $link,
       'class' => array('flag-lists-create'),
       'class' => array('flag-lists-create'),
@@ -375,15 +375,15 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
 
 
   if(isset($items)){
   if(isset($items)){
     $ops = array(
     $ops = array(
-      '#node' => $entity, 
+      '#node' => $entity,
       '#items' => $items,
       '#items' => $items,
     );
     );
   }
   }
-  
-  if(isset($create)){ 
+
+  if(isset($create)){
     $ops['#create'] = $create;
     $ops['#create'] = $create;
   }
   }
-  
+
   if(isset($ops)){
   if(isset($ops)){
     // dsm($ops, 'ops');
     // dsm($ops, 'ops');
     drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js');
     drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js');
@@ -397,19 +397,19 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
 function _materio_flag_get_listpagetitle($flag){
 function _materio_flag_get_listpagetitle($flag){
   $cont = '<i class="icon-materio-folder"></i>';
   $cont = '<i class="icon-materio-folder"></i>';
   $cont .= '<span class="'.$flag->name.'">'.check_plain($flag->title).'</span>';
   $cont .= '<span class="'.$flag->name.'">'.check_plain($flag->title).'</span>';
-  
+
   if(flag_lists_is_owner('edit', $flag->fid)){
   if(flag_lists_is_owner('edit', $flag->fid)){
-          
-    $cont .= l('<i class="icon-wrench"></i>', 
-                'flags/lists/edit/'.$flag->fid, 
+
+    $cont .= l('<i class="icon-wrench"></i>',
+                'flags/lists/edit/'.$flag->fid,
                 array(
                 array(
                   'html'=>true,
                   'html'=>true,
                   'attributes'=>array('class'=>array('edit-list', $flag->name)),
                   'attributes'=>array('class'=>array('edit-list', $flag->name)),
                 )
                 )
-              ); 
+              );
   }
   }
-        
-  
+
+
   return $cont;
   return $cont;
 }
 }
 
 
@@ -468,11 +468,11 @@ function template_preprocess_materio_flag_mylists_nav_block(&$vars){
 
 
 /**
 /**
  * theme_materio_flag_mylists_entity_links()
  * theme_materio_flag_mylists_entity_links()
- * 
+ *
  * see theme_flag_lists_list()
  * see theme_flag_lists_list()
  */
  */
 function theme_materio_flag_mylists_entity_links($vars){
 function theme_materio_flag_mylists_entity_links($vars){
-  
+
   // $node = $vars['node'];
   // $node = $vars['node'];
   $items = $vars['items'];
   $items = $vars['items'];
 
 
@@ -480,13 +480,13 @@ function theme_materio_flag_mylists_entity_links($vars){
 
 
   if(isset($vars['create']))
   if(isset($vars['create']))
     $items[] = $vars['create'];
     $items[] = $vars['create'];
-  
+
   return theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'flag-lists-entity-links')));
   return theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'flag-lists-entity-links')));
 
 
 }
 }
 
 
 function template_preprocess_materio_flag_mylists_list(&$vars) {
 function template_preprocess_materio_flag_mylists_list(&$vars) {
-  
+
   $vars['list_count'] = format_plural(
   $vars['list_count'] = format_plural(
     $vars['count'],
     $vars['count'],
     '@name @title contains 1 item.', // in @sec seconds
     '@name @title contains 1 item.', // in @sec seconds

+ 44 - 44
materio_flag.pages.inc

@@ -2,10 +2,10 @@
 
 
 /**
 /**
  * materio_flag_refresh_blocks($flag)
  * materio_flag_refresh_blocks($flag)
- * 
+ *
  */
  */
 function materio_flag_refresh_block($flag){
 function materio_flag_refresh_block($flag){
-	
+
 	switch ($flag) {
 	switch ($flag) {
 		case 'bookmarks':
 		case 'bookmarks':
 			$block_name = 'materio_flag_mybookmarks';
 			$block_name = 'materio_flag_mybookmarks';
@@ -18,8 +18,8 @@ function materio_flag_refresh_block($flag){
 
 
 	if(!isset($block_name))
 	if(!isset($block_name))
 		return;
 		return;
-	
-	$rep = array();
+
+	$rep = array("flag"=>$flag);
 
 
 	$block = block_load('materio_flag', $block_name);
 	$block = block_load('materio_flag', $block_name);
 	$block_content = _block_render_blocks(array($block));
 	$block_content = _block_render_blocks(array($block));
@@ -27,20 +27,20 @@ function materio_flag_refresh_block($flag){
 	$block_rendered = drupal_render($build);
 	$block_rendered = drupal_render($build);
   $rep['block'] = $block_rendered;
   $rep['block'] = $block_rendered;
 
 
-  if(isset($block_nav_name))
+  if(isset($block_nav_name)){
     $block = block_load('materio_flag', $block_nav_name);
     $block = block_load('materio_flag', $block_nav_name);
     $block_content = _block_render_blocks(array($block));
     $block_content = _block_render_blocks(array($block));
     $build = _block_get_renderable_array($block_content);
     $build = _block_get_renderable_array($block_content);
     $block_rendered = drupal_render($build);
     $block_rendered = drupal_render($build);
     $rep['block_nav'] = $block_rendered;
     $rep['block_nav'] = $block_rendered;
-
+  }
 
 
  	drupal_json_output($rep);
  	drupal_json_output($rep);
 }
 }
 
 
 /**
 /**
  * materio_flag_createlist($type)
  * materio_flag_createlist($type)
- * 
+ *
  */
  */
 function materio_flag_createlist_form($type){
 function materio_flag_createlist_form($type){
   $debug = false;
   $debug = false;
@@ -55,7 +55,7 @@ function materio_flag_createlist_form($type){
 
 
   // menu_set_active_item($path);
   // menu_set_active_item($path);
   // $return = menu_execute_active_handler($path, FALSE);
   // $return = menu_execute_active_handler($path, FALSE);
-  
+
   // if (is_int($return)) {
   // if (is_int($return)) {
   //   switch ($return) {
   //   switch ($return) {
   //     case MENU_NOT_FOUND :
   //     case MENU_NOT_FOUND :
@@ -69,7 +69,7 @@ function materio_flag_createlist_form($type){
   //       break;
   //       break;
   //   }
   //   }
   // } elseif (isset($return)) {
   // } elseif (isset($return)) {
-  
+
   // $form_state['build_info']['args'] = array(NULL, 'breve');
   // $form_state['build_info']['args'] = array(NULL, 'breve');
   // $f = drupal_get_form('flag_lists_form', $form_state);
   // $f = drupal_get_form('flag_lists_form', $form_state);
   // dsm($f);
   // dsm($f);
@@ -86,11 +86,11 @@ function materio_flag_createlist_form($type){
   );
   );
 
 
   $form['listname'] = array(
   $form['listname'] = array(
-    '#type' => 'textfield', 
+    '#type' => 'textfield',
     '#title' => t('Create new @name', array('@name'=>variable_get('flag_lists_name', 'list'))),
     '#title' => t('Create new @name', array('@name'=>variable_get('flag_lists_name', 'list'))),
-    '#default_value' => '', 
-    // '#size' => 100, 
-    '#maxlength' => 255, 
+    '#default_value' => '',
+    // '#size' => 100,
+    '#maxlength' => 255,
     '#name' => 'flag-lists-name',
     '#name' => 'flag-lists-name',
     '#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'),
     '#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'),
   );
   );
@@ -111,21 +111,21 @@ function materio_flag_createlist_form($type){
     '#value' => t('cancel'),
     '#value' => t('cancel'),
     '#name' => 'cancel',
     '#name' => 'cancel',
   );
   );
-  
+
 
 
   // dsm($form, 'form');
   // dsm($form, 'form');
 
 
-  $return = drupal_render($form); 
+  $return = drupal_render($form);
 
 
   $rep = array(
   $rep = array(
     'rendered_form'=>$return,
     'rendered_form'=>$return,
   );
   );
-  
+
   if ($debug) {
   if ($debug) {
     dsm($rep, 'rep');
     dsm($rep, 'rep');
     return "debug display";
     return "debug display";
   }else{
   }else{
-    drupal_json_output($rep);  
+    drupal_json_output($rep);
   }
   }
 }
 }
 
 
@@ -172,7 +172,7 @@ function materio_flag_editlist_form($type, $fid){
       '#value' => $fid,
       '#value' => $fid,
       '#name' => 'fid',
       '#name' => 'fid',
     );
     );
-    
+
     $form['name'] = array(
     $form['name'] = array(
       '#type' => 'hidden',
       '#type' => 'hidden',
       '#value' => $name,
       '#value' => $name,
@@ -180,11 +180,11 @@ function materio_flag_editlist_form($type, $fid){
     );
     );
 
 
     $form['listtitle'] = array(
     $form['listtitle'] = array(
-      '#type' => 'textfield', 
+      '#type' => 'textfield',
       '#title' => t('Edit this '.variable_get('flag_lists_name', 'list')),
       '#title' => t('Edit this '.variable_get('flag_lists_name', 'list')),
-      '#value' => $flag->title, 
-      // '#size' => 100, 
-      '#maxlength' => 255, 
+      '#value' => $flag->title,
+      // '#size' => 100,
+      '#maxlength' => 255,
       '#name' => 'flag-lists-title',
       '#name' => 'flag-lists-title',
       '#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'),
       '#description' => t('A short, descriptive title for this Folder list. Limit to 255 characters.'),
     );
     );
@@ -211,10 +211,10 @@ function materio_flag_editlist_form($type, $fid){
       '#value' => t('cancel'),
       '#value' => t('cancel'),
       '#name' => 'cancel',
       '#name' => 'cancel',
     );
     );
-    
+
     // dsm($form, 'form');
     // dsm($form, 'form');
 
 
-    $return = drupal_render($form); 
+    $return = drupal_render($form);
 
 
     $rep = array(
     $rep = array(
       'rendered_form'=>$return,
       'rendered_form'=>$return,
@@ -225,12 +225,12 @@ function materio_flag_editlist_form($type, $fid){
       'message' => t('you do not have rights to edit this '.variable_get('flag_lists_name', 'list')),
       'message' => t('you do not have rights to edit this '.variable_get('flag_lists_name', 'list')),
     );
     );
   }
   }
-  
+
   if ($debug) {
   if ($debug) {
     dsm($rep, 'rep');
     dsm($rep, 'rep');
     return "debug display";
     return "debug display";
   }else{
   }else{
-    drupal_json_output($rep);  
+    drupal_json_output($rep);
   }
   }
 }
 }
 
 
@@ -270,7 +270,7 @@ function materio_flag_edit_list($fid, $name, $title){
 
 
   }
   }
 
 
-  drupal_json_output($rep);  
+  drupal_json_output($rep);
 }
 }
 
 
 function materio_flag_delete_list($fid){
 function materio_flag_delete_list($fid){
@@ -299,15 +299,15 @@ function materio_flag_delete_list($fid){
     }
     }
 
 
     $flag = flag_lists_get_flag($name);
     $flag = flag_lists_get_flag($name);
-    
-    flag_lists_fl_delete($flag);  
+
+    flag_lists_fl_delete($flag);
 
 
     $rep = array(
     $rep = array(
       'status' => 'saved',
       'status' => 'saved',
     );
     );
   }
   }
 
 
-  drupal_json_output($rep); 
+  drupal_json_output($rep);
 }
 }
 
 
 function materio_flag_nodelinks(){
 function materio_flag_nodelinks(){
@@ -324,19 +324,19 @@ function materio_flag_nodelinks(){
       "status" => 1,
       "status" => 1,
       "nids" => $nids,
       "nids" => $nids,
       'links' => $links,
       'links' => $links,
-    );  
+    );
   }else{
   }else{
     $rep['status'] = 0;
     $rep['status'] = 0;
   }
   }
 
 
-  drupal_json_output($rep);  
+  drupal_json_output($rep);
 }
 }
 
 
 function materio_flag_user_bookmarks(){
 function materio_flag_user_bookmarks(){
   global $user;
   global $user;
-  
+
   drupal_set_title(t('My bookmarks'), PASS_THROUGH);
   drupal_set_title(t('My bookmarks'), PASS_THROUGH);
-  
+
   $flaged = flag_get_user_flags('node');
   $flaged = flag_get_user_flags('node');
   // dsm($flaged, 'flaged');
   // dsm($flaged, 'flaged');
 
 
@@ -363,7 +363,7 @@ function materio_flag_user_bookmarks(){
       }
       }
     }
     }
   }
   }
-  
+
   $ret['#items'] = $items;
   $ret['#items'] = $items;
   $ret['#theme'] = 'materio_flag_mylists_list';
   $ret['#theme'] = 'materio_flag_mylists_list';
   $ret['#view_mode'] = $viewmode;
   $ret['#view_mode'] = $viewmode;
@@ -397,12 +397,12 @@ function materio_flag_user_lists($fid){
   $count = count($flaged_content);
   $count = count($flaged_content);
   $max = $offset+$limit > $count ? $count : $offset+$limit;
   $max = $offset+$limit > $count ? $count : $offset+$limit;
 
 
-  for ($i=$offset; $i < $max; $i++) { 
+  for ($i=$offset; $i < $max; $i++) {
     if($flaged_content[$i]->entity_type == 'node'){
     if($flaged_content[$i]->entity_type == 'node'){
       $items[] = node_load($flaged_content[$i]->entity_id);
       $items[] = node_load($flaged_content[$i]->entity_id);
     }
     }
-  }  
-  
+  }
+
   $ret['#items'] = $items;
   $ret['#items'] = $items;
   $ret['#theme'] = 'materio_flag_mylists_list';
   $ret['#theme'] = 'materio_flag_mylists_list';
   $ret['#view_mode'] = $viewmode;
   $ret['#view_mode'] = $viewmode;
@@ -425,9 +425,9 @@ function materio_flag_ajax_list($fid, $page = 0){
     $list_path = $path = 'bookmarks';
     $list_path = $path = 'bookmarks';
   }else{
   }else{
     $list_path = 'lists';
     $list_path = 'lists';
-    $path = $list_path.'/'.$fid;  
+    $path = $list_path.'/'.$fid;
   }
   }
-  
+
 
 
   // check if request is ajax, if not rediret to search_api_page page with right keys
   // check if request is ajax, if not rediret to search_api_page page with right keys
   if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
   if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
@@ -462,7 +462,7 @@ function materio_flag_ajax_list($fid, $page = 0){
   $return = menu_execute_active_handler($path, FALSE);
   $return = menu_execute_active_handler($path, FALSE);
 
 
   dsm($return, '$return');
   dsm($return, '$return');
-  
+
   if (is_int($return)) {
   if (is_int($return)) {
     switch ($return) {
     switch ($return) {
       case MENU_NOT_FOUND :
       case MENU_NOT_FOUND :
@@ -480,18 +480,18 @@ function materio_flag_ajax_list($fid, $page = 0){
     if (is_array($return)) {
     if (is_array($return)) {
       $rendered = drupal_render($return);
       $rendered = drupal_render($return);
     }
     }
-      
+
     $rep = array(
     $rep = array(
       'rendered' => $rendered,
       'rendered' => $rendered,
       'path' => $path,
       'path' => $path,
       'title' => drupal_get_title(),
       'title' => drupal_get_title(),
     );
     );
-    
+
     if ($debug) {
     if ($debug) {
       dsm($rep, 'rep');
       dsm($rep, 'rep');
       return "debug display";
       return "debug display";
     }else{
     }else{
-      drupal_json_output($rep);  
+      drupal_json_output($rep);
     }
     }
   }
   }
 }
 }

+ 172 - 76
materio_search_api.module

@@ -99,6 +99,11 @@ function materio_search_api_access_search(){
   return user_access('use materio search api for breves') || user_access('use materio search api');
   return user_access('use materio search api for breves') || user_access('use materio search api');
 }
 }
 
 
+
+/**
+* - - - - - - - - - - - -  SOLR  - - - - - - - - - - - -
+*/
+
 /**
 /**
  * Implements hook_search_api_data_type_info().
  * Implements hook_search_api_data_type_info().
  *
  *
@@ -107,11 +112,18 @@ function materio_search_api_access_search(){
 function materio_search_api_search_api_data_type_info() {
 function materio_search_api_search_api_data_type_info() {
   return array(
   return array(
     'edge_n2_kw_text' => array(
     'edge_n2_kw_text' => array(
-      'name' => t('Fulltext (partial)'),
+      'name' => t('Fulltext (partial matching)'),
       'fallback' => 'text',
       'fallback' => 'text',
+      'prefix' => 'tem',
+      'always multiValued' => TRUE,
+    ),
+    'edge_n2_kw_mapped_text' => array(
+      'name' => t('Fulltext without accents (partial matching)'),
+      'fallback' => 'text',
+      'prefix' => 'temmap',
+      'always multiValued' => TRUE,
     ),
     ),
   );
   );
-  return $types;
 }
 }
 
 
 /**
 /**
@@ -125,20 +137,30 @@ function materio_search_api_search_api_solr_dynamic_field_info() {
       'prefix' => 'tem',
       'prefix' => 'tem',
       'always multiValued' => TRUE,
       'always multiValued' => TRUE,
     ),
     ),
+    'edge_n2_kw_mapped_text' => array(
+      'prefix' => 'temmap',
+      'always multiValued' => TRUE,
+    ),
   );
   );
+
 }
 }
 
 
 
 
 /**
 /**
  * hook_entity_property_info_alter().
  * hook_entity_property_info_alter().
+ *
+ * define own fields
+ * - main taxonomy terms, the purpose is to be able to attribute differente boost on serach api depending on term order
+ * - companies infos (address) : retrieve for materiau content type the companie info from the tode node
+ *
  */
  */
 function materio_search_api_entity_property_info_alter(&$info){
 function materio_search_api_entity_property_info_alter(&$info){
   // dsm($info, 'hook_entity_property_info_alter | info');
   // dsm($info, 'hook_entity_property_info_alter | info');
   // watchdog('materio solr', 'materio_search_api_entity_property_info_alter', array());
   // watchdog('materio solr', 'materio_search_api_entity_property_info_alter', array());
-  $properties = &$info['node']['properties'];
-  
-  for ($i=1; $i <= 5 ; $i++) { 
-    $properties['materio_search_api_onthologie_term_'.$i.'_text'] = array(
+  $node_props = &$info['node']['properties'];
+
+  for ($i=1; $i <= 5 ; $i++) {
+    $node_props['materio_search_api_onthologie_term_'.$i.'_text'] = array(
       'type'=>'text',
       'type'=>'text',
       'label'=> t('Main onthologie term '.$i. ' as text (+ synonyms)'),
       'label'=> t('Main onthologie term '.$i. ' as text (+ synonyms)'),
       // 'query callback'=>'entity_metadata_table_query',
       // 'query callback'=>'entity_metadata_table_query',
@@ -146,28 +168,42 @@ function materio_search_api_entity_property_info_alter(&$info){
     );
     );
   }
   }
 
 
-  $properties['materio_search_api_onthologie_term_others_text'] = array(
+  $node_props['materio_search_api_onthologie_term_others_text'] = array(
     'type'=>'list<text>',
     'type'=>'list<text>',
     'label'=> t('Others onthologie terms as text (+ synonyms)'),
     'label'=> t('Others onthologie terms as text (+ synonyms)'),
     // 'query callback'=>'entity_metadata_table_query',
     // 'query callback'=>'entity_metadata_table_query',
     'getter callback'=>'materio_search_api_get_taxonomy_terms_others_text',
     'getter callback'=>'materio_search_api_get_taxonomy_terms_others_text',
   );
   );
 
 
-  $properties['materio_search_api_taglibres_text'] = array(
+  $node_props['materio_search_api_taglibres_text'] = array(
     'type'=>'list<text>',
     'type'=>'list<text>',
     'label'=> t('Tag libres terms as text (+ synonyms)'),
     'label'=> t('Tag libres terms as text (+ synonyms)'),
     // 'query callback'=>'entity_metadata_table_query',
     // 'query callback'=>'entity_metadata_table_query',
     'getter callback'=>'materio_search_api_get_taglibres_terms_text',
     'getter callback'=>'materio_search_api_get_taglibres_terms_text',
   );
   );
 
 
-  $company_term_props = &$info['taxonomy_term']['bundles']['company']['properties'];
 
 
-  $company_term_props['country'] = array(
-    'label' => t("Country"), 
-    'description' => t("Company's Country get from tode node."), 
-    'type' => 'text', 
-    'getter callback' => 'company_term_property_country_get_props',
+
+  $node_materiau_props = &$info['node']['bundles']['materiau']['properties'];
+
+  $node_materiau_props['materio_search_api_node_propertie_companie'] = array(
+    'type'=>'list<text>',
+    'label'=> t('Manufacturers and distributors companies localised (dont addresse)'),
+    // 'query callback'=>'entity_metadata_table_query',
+    'getter callback'=>'materio_search_api_get_node_propertie_companie',
   );
   );
+
+
+
+  $term_props = &$info['taxonomy_term']['properties'];
+
+  $term_props['materio_search_api_term_property_dup_name'] = array(
+    'label' => t("Term name field dup"),
+    'description' => t("Duplicate the term name field to apply different filter in solr (remove accents for instance)"),
+    'type' => 'text',
+    'getter callback' => 'materio_search_api_term_property_dup_name',
+  );
+
 }
 }
 
 
 function materio_search_api_get_onthologie_term_1_text($item){
 function materio_search_api_get_onthologie_term_1_text($item){
@@ -216,7 +252,7 @@ function materio_search_api_get_taglibres_terms_text($item){
 function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta){
 function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta){
   // dsm($item, 'item');
   // dsm($item, 'item');
   // dsm($delta, 'delta');
   // dsm($delta, 'delta');
-  
+
   if(isset($item->{$field_name}['und'][$delta])){
   if(isset($item->{$field_name}['und'][$delta])){
     // print '** item **'."\n";
     // print '** item **'."\n";
     // print_r($item);
     // print_r($item);
@@ -246,25 +282,40 @@ function materio_search_api_get_taxo_term_field_text($item, $field_name, $delta)
 
 
     return implode(" ", $keywords);
     return implode(" ", $keywords);
   }
   }
-    
+
 
 
   return null;
   return null;
 }
 }
 
 
-
-function company_term_property_country_get_props($term){
-  // dsm($term, 'company_term_property_country_get_props : term');
-  if( $node = company_get_tode_node($term) ){
-    // $field_values = field_get_items('node',$node,'field_public_address');
-    // dsm($field_values, 'field_values');
-    
-    $output = rip_tags(render(field_view_field('node',$node,'field_public_address')));
-    // dsm($output, 'output');
-    
-    return $output;
+function materio_search_api_get_node_propertie_companie($item){
+  // dsm($item, '$item');
+  $lang = "fr";//$item->language;
+
+  $languages = language_list();
+  global $language;
+  $language = $languages[$lang];
+
+  $cies = array();
+  $cie_fields = array("field_company_fab", "field_company_distrib");
+  foreach ($cie_fields as $cie_field_name) {
+    $delta = 0;
+    while( isset($item->{$cie_field_name}['und'][$delta]) ){
+      $tid = $item->{$cie_field_name}['und'][$delta]['tid'];
+      $cie_term =  taxonomy_term_load($tid);
+      if($cie_node = company_get_tode_node($cie_term)){
+        $cie_node->language = $lang;
+        $cie_view = node_view($cie_node, "full", $lang);
+        $cie_rendered = rip_tags(drupal_render($cie_view));
+        // dsm($cie_rendered, 'cie_rendered');
+        $cies[] = $cie_rendered;
+      }
+      $delta++;
+    }
   }
   }
-  return null;
+
+  return $cies;
 }
 }
+
 function company_get_tode_node($term){
 function company_get_tode_node($term){
   if(module_exists('tode'))
   if(module_exists('tode'))
     if( $entitys = tode_get_nids_from_term($term))
     if( $entitys = tode_get_nids_from_term($term))
@@ -274,19 +325,20 @@ function company_get_tode_node($term){
 
 
   return false;
   return false;
 }
 }
-function rip_tags($string) { 
-  // ----- remove HTML TAGs ----- 
-  $string = preg_replace ('/<[^>]*>/', ' ', $string); 
-  
-  // ----- remove control characters ----- 
+
+function rip_tags($string) {
+  // ----- remove HTML TAGs -----
+  $string = preg_replace ('/<[^>]*>/', ' ', $string);
+
+  // ----- remove control characters -----
   $string = str_replace("\r", '', $string);    // --- replace with empty space
   $string = str_replace("\r", '', $string);    // --- replace with empty space
   $string = str_replace("\n", ' ', $string);   // --- replace with space
   $string = str_replace("\n", ' ', $string);   // --- replace with space
   $string = str_replace("\t", ' ', $string);   // --- replace with space
   $string = str_replace("\t", ' ', $string);   // --- replace with space
-  
+
   // $string = str_replace("&nbsp;", ' ', $string);   // --- replace with space
   // $string = str_replace("&nbsp;", ' ', $string);   // --- replace with space
   // $string = str_replace("&#039;", '\'', $string);   // --- replace with space
   // $string = str_replace("&#039;", '\'', $string);   // --- replace with space
 
 
-  // ----- remove multiple spaces ----- 
+  // ----- remove multiple spaces -----
   $string = trim(preg_replace('/ {2,}/', ' ', $string));
   $string = trim(preg_replace('/ {2,}/', ' ', $string));
 
 
   // ----- remove html entities
   // ----- remove html entities
@@ -294,10 +346,24 @@ function rip_tags($string) {
   foreach ($entities[0] as $entity) {
   foreach ($entities[0] as $entity) {
     $string = str_replace($entity, mb_convert_encoding($entity, 'UTF-8', 'HTML-ENTITIES'), $string);
     $string = str_replace($entity, mb_convert_encoding($entity, 'UTF-8', 'HTML-ENTITIES'), $string);
   }
   }
-  
+
   return $string;
   return $string;
 }
 }
 
 
+function materio_search_api_term_property_dup_name($term){
+  $lang = $term->language;
+  return $term->name_field[$lang][0]['value'];
+}
+
+
+
+
+
+/**
+ *  - - -- - - - - - -  blocks - - - - - - - - - - -
+ *
+ */
+
 /**
 /**
  * Implements hook_block_info().
  * Implements hook_block_info().
  */
  */
@@ -312,7 +378,7 @@ function materio_search_api_block_info() {
     'info' => t('Materio search api view mode selection'),
     'info' => t('Materio search api view mode selection'),
     'cache' => DRUPAL_NO_CACHE
     'cache' => DRUPAL_NO_CACHE
   );
   );
-  
+
   // $blocks['materio_search_api_filters'] = array(
   // $blocks['materio_search_api_filters'] = array(
   //   'info' => t('Materio search api filters'),
   //   'info' => t('Materio search api filters'),
   //   'cache' => DRUPAL_NO_CACHE
   //   'cache' => DRUPAL_NO_CACHE
@@ -337,7 +403,16 @@ function materio_search_api_block_view($delta = '') {
       }
       }
       break;
       break;
     case 'materio_search_api_viewmode':
     case 'materio_search_api_viewmode':
-      if (user_access('use materio search api viewmode selection')) {
+      // restrict display on node page for materiau and breve
+      $block_is_visible = true;
+      $q = parse_url($_GET['q']);
+      $parts = explode('/', $q['path']);
+      if($parts[0] == "node"){
+        $node = node_load($parts[1]);
+        $block_is_visible = in_array($node->type, array('materiau','breve')) ? true : false;
+      }
+
+      if (user_access('use materio search api viewmode selection') && $block_is_visible) {
         $block['subject'] = t('View mode');
         $block['subject'] = t('View mode');
         $block['content'] = theme('materio_search_api_select_viewmode_block', array());
         $block['content'] = theme('materio_search_api_select_viewmode_block', array());
       }
       }
@@ -360,12 +435,12 @@ function materio_search_api_entity_info_alter(&$entity_info) {
     'label' => t('Small cards'),
     'label' => t('Small cards'),
     'custom settings' => TRUE,
     'custom settings' => TRUE,
   );
   );
-  
+
   $entity_info['node']['view modes']['cardmedium'] = array(
   $entity_info['node']['view modes']['cardmedium'] = array(
     'label' => t('Medium cards'),
     'label' => t('Medium cards'),
     'custom settings' => TRUE,
     'custom settings' => TRUE,
   );
   );
-  
+
   $entity_info['node']['view modes']['cardbig'] = array(
   $entity_info['node']['view modes']['cardbig'] = array(
     'label' => t('Big cards'),
     'label' => t('Big cards'),
     'custom settings' => TRUE,
     'custom settings' => TRUE,
@@ -389,7 +464,7 @@ function materio_search_api_node_view_alter(&$build) {
     // dsm($viewmode, 'viewmode');
     // dsm($viewmode, 'viewmode');
     $node = $build['#node'];
     $node = $build['#node'];
     if($build['#view_mode'] != $viewmode && $build['#view_mode'] != "bookmark" & in_array($node->type, array('breve', 'materiau'))){
     if($build['#view_mode'] != $viewmode && $build['#view_mode'] != "bookmark" & in_array($node->type, array('breve', 'materiau'))){
-      $build = node_view($node, $viewmode);  
+      $build = node_view($node, $viewmode);
     }
     }
   }
   }
 }
 }
@@ -436,7 +511,7 @@ function materio_search_api_search_form($form, &$form_state){
 
 
   $form['searchfield'] = array(
   $form['searchfield'] = array(
     '#type' => 'textfield',
     '#type' => 'textfield',
-    '#default_value' => $path == 'explore' ? $keys : $default_value, // TODO:  set the search page path global or a variable in settings  
+    '#default_value' => $path == 'explore' ? $keys : $default_value, // TODO:  set the search page path global or a variable in settings
     // '#value' => $keys,
     // '#value' => $keys,
     '#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
     '#autocomplete_path' => 'materiosearchapi/autocomplete/searchapi',
     //'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
     //'#autocomplete_path' => 'materiosearchapi/autocomplete/dbselect',
@@ -446,15 +521,15 @@ function materio_search_api_search_form($form, &$form_state){
   );
   );
 
 
   if(user_access('use materio search api filters')){
   if(user_access('use materio search api filters')){
-    
+
     $index = search_api_index_load(variable_get('mainsearchindex', -1));
     $index = search_api_index_load(variable_get('mainsearchindex', -1));
     $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
     $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
-   
+
     foreach ($indexed_bundles as $bundle) {
     foreach ($indexed_bundles as $bundle) {
       $bundles_options[$bundle] = $bundle;
       $bundles_options[$bundle] = $bundle;
       $default_bundles[] = $bundle;
       $default_bundles[] = $bundle;
     }
     }
-    
+
     $user_bundles_filter = isset($user->data['materiosearchapi_bundlesfilter']) ? $user->data['materiosearchapi_bundlesfilter'] : $default_bundles;
     $user_bundles_filter = isset($user->data['materiosearchapi_bundlesfilter']) ? $user->data['materiosearchapi_bundlesfilter'] : $default_bundles;
 
 
     $form['bundles_filter'] = array(
     $form['bundles_filter'] = array(
@@ -464,7 +539,7 @@ function materio_search_api_search_form($form, &$form_state){
       // '#attributes' => array('class'=>array('btn-group')),
       // '#attributes' => array('class'=>array('btn-group')),
     );
     );
   }
   }
-  
+
   $form['create'] = array(
   $form['create'] = array(
     '#type' => 'image_button',
     '#type' => 'image_button',
     '#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
     '#src' => drupal_get_path('module', 'materio_search_api') . '/images/search.png',
@@ -498,7 +573,7 @@ function materio_search_api_search_form_submit($form, &$form_state){
     # if user have no access to filters
     # if user have no access to filters
     $index = search_api_index_load(variable_get('mainsearchindex', -1));
     $index = search_api_index_load(variable_get('mainsearchindex', -1));
     $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
     $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
-   
+
     foreach ($indexed_bundles as $bundle) {
     foreach ($indexed_bundles as $bundle) {
       $bundles[] = $bundle;
       $bundles[] = $bundle;
     }
     }
@@ -534,7 +609,7 @@ function _materio_search_api_change_viewmode($vm){
 }
 }
 
 
 /**
 /**
-* - - - - - - - - - - - -  THEME  - - - - - - - - - - - - 
+* - - - - - - - - - - - -  THEME  - - - - - - - - - - - -
 */
 */
 
 
 /**
 /**
@@ -558,7 +633,7 @@ function materio_search_api_theme($existing, $type, $theme, $path) {
     //   'path' => drupal_get_path('module', 'materio_search_api').'/templates',
     //   'path' => drupal_get_path('module', 'materio_search_api').'/templates',
     // ),
     // ),
     'materio_search_api_results' => array(
     'materio_search_api_results' => array(
-      'arguments' => array(), 
+      'arguments' => array(),
       'template' => 'materio-search-api-results',
       'template' => 'materio-search-api-results',
       'path' => drupal_get_path('module', 'materio_search_api').'/templates',
       'path' => drupal_get_path('module', 'materio_search_api').'/templates',
       'variables' => array(
       'variables' => array(
@@ -617,7 +692,7 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
 
 
   $entity_infos = entity_get_info();
   $entity_infos = entity_get_info();
   // dsm($entity_infos, 'entity_infos');
   // dsm($entity_infos, 'entity_infos');
-  
+
   $content = '<div class="btn-group btn-group-vertical">';
   $content = '<div class="btn-group btn-group-vertical">';
   foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
   foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
     if(in_array($viewmode, $availableviewmodes)){
     if(in_array($viewmode, $availableviewmodes)){
@@ -654,9 +729,9 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
 //   // $entity_infos = entity_get_info($index->item_type);
 //   // $entity_infos = entity_get_info($index->item_type);
 //   // dsm($entity_infos, 'entity_infos');
 //   // dsm($entity_infos, 'entity_infos');
 //   $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
 //   $indexed_bundles = $index->options['data_alter_callbacks']['search_api_alter_bundle_filter']['settings']['bundles'];
-  
+
 //   dsm($indexed_bundles, 'indexed_bundles');
 //   dsm($indexed_bundles, 'indexed_bundles');
-  
+
 
 
 //   $vars['content'] = drupal_get_form('materio_search_api_filters_form', $indexed_bundles);
 //   $vars['content'] = drupal_get_form('materio_search_api_filters_form', $indexed_bundles);
 // }
 // }
@@ -688,43 +763,64 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
  *
  *
  * @see materio-search-api-results.tpl.php
  * @see materio-search-api-results.tpl.php
  */
  */
-function template_preprocess_materio_search_api_results(array &$variables) {
-  // dsm($variables, '$variables');
-  $results = $variables['results'];
-  $keys = $variables['keys'];
-
-  // $variables['items'] = $variables['index']->loadItems(array_keys($variables['results']['results']));
-  $variables['result_count'] = $results['result count'];
-  $variables['sec'] = round($results['performance']['complete'], 3);
-  
+function template_preprocess_materio_search_api_results(array &$vars) {
+  // dsm($vars, '$vars');
+  $results = $vars['results'];
+  $keys = $vars['keys'];
+
+  // $vars['items'] = $vars['index']->loadItems(array_keys($vars['results']['results']));
+  $vars['result_count'] = $results['result count'];
+  $vars['sec'] = round($results['performance']['complete'], 3);
+
+  $vars['keywords'] = implode(', ', $vars['keys']);
+
   if(isset($results['breves count'])){
   if(isset($results['breves count'])){
-    $variables['search_performance'] = format_plural(
+    $vars['perfascard'] = true;
+    $vars['search_performance'] = format_plural(
       $results['breves count'],
       $results['breves count'],
       'The search found 1 news ',
       'The search found 1 news ',
       'The search found @count news '
       'The search found @count news '
     );
     );
-    $variables['search_performance'] .= format_plural(
-      $variables['result_count'] - $results['breves count'],
+    $vars['search_performance'] .= format_plural(
+      $vars['result_count'] - $results['breves count'],
       'with 1 associated matter.',
       'with 1 associated matter.',
       'with @count associated matters.'
       'with @count associated matters.'
     );
     );
-    $variables['search_performance'] .= format_plural(
+    $vars['search_performance'] .= format_plural(
       $results['could results']['result count'],
       $results['could results']['result count'],
-      ' You could find 1 result with a ',
-      ' You could find <strong>@count results</strong> with a '
+      ' You could have found 1 result with a ',
+      ' You could have found <strong>@count results</strong> with a '
     );
     );
-    $variables['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187');
+    $vars['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187');
+
+    $vars['search_performance'] .= l(t('Pricing'), 'node/11187', array("attributes"=>array("class"=>array('button'))));
 
 
   }else{
   }else{
-    $variables['search_performance'] = format_plural(
-      // $results['result count'],
-      $variables['result_count'],
-      'The search found 1 result.',
-      'The search found @count results.'
+    $vars['perfascard'] = false;
+
+    // $vars['search_performance'] = format_plural(
+    //   // $results['result count'],
+    //   $vars['result_count'],
+    //   'The search found 1 result ',
+    //   'The search found @count results '
+    // )
+
+    $vars['search_performance'] = t('The search found @count result(s) with keywords @keys.', array(
+      "@count"=>$vars['result_count'],
+      "@keys"=>$vars['keywords'])
     );
     );
+
+    // TODO indicate how many materials and how many news
+    // $vars['search_performance'] = t('The search found @count result(s) with keywords @keys. @mat materials and @new news.', array(
+    //   "@count"=>$vars['result_count'],
+    //   "@keys"=>$vars['keywords'],
+    //   "@mat"=>4,
+    //   "@new"=>7)
+    // );
+
   }
   }
 
 
-  //dsm($variables, 'variables');
+  //dsm($vars, '$vars');
 }
 }
 
 
 
 
@@ -736,7 +832,7 @@ function template_preprocess_materio_search_api_actuality(&$vars){
 }
 }
 
 
 /**
 /**
-* - - - - - - - - - - - -  SEARCH API PAGE  - - - - - - - - - - - - 
+* - - - - - - - - - - - -  SEARCH API PAGE  - - - - - - - - - - - -
 */
 */
 
 
 /**
 /**
@@ -747,7 +843,7 @@ function materio_search_api_block_view_alter(&$data, $block) {
   if ($block->module == 'search_api_page') {
   if ($block->module == 'search_api_page') {
     $page = search_api_page_load($block->delta);
     $page = search_api_page_load($block->delta);
     $item = menu_get_item();
     $item = menu_get_item();
-    
+
     if (isset($page->path) && $page->path == $item['path']) {
     if (isset($page->path) && $page->path == $item['path']) {
       $keys = arg(count(arg(NULL, $page->path)));
       $keys = arg(count(arg(NULL, $page->path)));
       if ($keys) {
       if ($keys) {

+ 22 - 22
materio_search_api.pages.inc

@@ -2,22 +2,22 @@
 
 
 /**
 /**
  * materiobase_search_autocomplete_dbselect()
  * materiobase_search_autocomplete_dbselect()
- * 
+ *
  * inspired by taxonomy_autocomplete()
  * inspired by taxonomy_autocomplete()
- * 
+ *
  * OBSOLETE : this fonction use a direct dbselect request to provide results forautocomplete
  * OBSOLETE : this fonction use a direct dbselect request to provide results forautocomplete
- * 
+ *
  */
  */
 function materio_search_api_autocomplete_dbselect($typed = ''){
 function materio_search_api_autocomplete_dbselect($typed = ''){
   // If the request has a '/' in the search text, then the menu system will have
   // If the request has a '/' in the search text, then the menu system will have
   // split it into multiple arguments, recover the intended $tags_typed.
   // split it into multiple arguments, recover the intended $tags_typed.
   $args = func_get_args();
   $args = func_get_args();
   $typed = implode('/', $args);
   $typed = implode('/', $args);
-  
+
   /*
   /*
     TODO riche serach engine + \\ etc gmail like
     TODO riche serach engine + \\ etc gmail like
   */
   */
-  
+
   if ($typed != '') {
   if ($typed != '') {
 
 
     // Part of the criteria for the query come from the field's own settings.
     // Part of the criteria for the query come from the field's own settings.
@@ -56,7 +56,7 @@ function materio_search_api_autocomplete_dbselect($typed = ''){
 
 
 /**
 /**
 * materio_search_api_autocomplete_searchapi($typed = '')
 * materio_search_api_autocomplete_searchapi($typed = '')
-* 
+*
 * GOOD one using searchapi (SOLR)
 * GOOD one using searchapi (SOLR)
 */
 */
 function materio_search_api_autocomplete_searchapi($typed = ''){
 function materio_search_api_autocomplete_searchapi($typed = ''){
@@ -64,7 +64,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
   // split it into multiple arguments, recover the intended $tags_typed.
   // split it into multiple arguments, recover the intended $tags_typed.
   $args = func_get_args();
   $args = func_get_args();
   $typed = implode('/', $args);
   $typed = implode('/', $args);
-  
+
   // dsm($typed, 'typed');
   // dsm($typed, 'typed');
   if ($typed != '') {
   if ($typed != '') {
 
 
@@ -78,7 +78,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
     global $language;
     global $language;
     $index_machine_name = variable_get('autocompletesearchindex_'.$language->language, -1);
     $index_machine_name = variable_get('autocompletesearchindex_'.$language->language, -1);
     $query = search_api_query($index_machine_name);
     $query = search_api_query($index_machine_name);
-    
+
     // $query_filter = $query->createFilter();
     // $query_filter = $query->createFilter();
     // $query_filter->condition('name', $tosearch);
     // $query_filter->condition('name', $tosearch);
     // $query_filter->condition('type', 'article');
     // $query_filter->condition('type', 'article');
@@ -96,14 +96,14 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
         //dsm($item, '$item');
         //dsm($item, '$item');
         //$term_matches[$item->tid] = check_plain($item->name);
         //$term_matches[$item->tid] = check_plain($item->name);
         // $term_matches[check_plain($item->name)] = check_plain($item->name);
         // $term_matches[check_plain($item->name)] = check_plain($item->name);
-        // TODO:  leave tags with nodes  
+        // TODO:  leave tags with nodes
         $term_matches[ trim(implode(' ', $adv_search_q[0]).' '.$last[1].$item->name)] = check_plain($item->name);
         $term_matches[ trim(implode(' ', $adv_search_q[0]).' '.$last[1].$item->name)] = check_plain($item->name);
 
 
         $delta++;
         $delta++;
         if($delta > 15)
         if($delta > 15)
           break;
           break;
-      }  
-      drupal_json_output($term_matches);  
+      }
+      drupal_json_output($term_matches);
     }else{
     }else{
       drupal_json_output(array());
       drupal_json_output(array());
     }
     }
@@ -111,15 +111,15 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
     return;
     return;
   }
   }
 
 
-  
+
   // dsm($term_matches, 'term_matches');
   // dsm($term_matches, 'term_matches');
   // return 'debug mode of materio_search_api_autocomplete_searchapi';
   // return 'debug mode of materio_search_api_autocomplete_searchapi';
 }
 }
 
 
 /**
 /**
 * materio_search_api_results_search()
 * materio_search_api_results_search()
-* 
-* 
+*
+*
 */
 */
 function materio_search_api_results_search(){
 function materio_search_api_results_search(){
   global $user;
   global $user;
@@ -138,11 +138,11 @@ function materio_search_api_results_search(){
   // else{
   // else{
   //   $page = 0;
   //   $page = 0;
   // }
   // }
-  
+
   preg_match_all('/\s?[^\s]+\s?/', $typed, $words);
   preg_match_all('/\s?[^\s]+\s?/', $typed, $words);
   // dsm($words, "words");
   // dsm($words, "words");
 
 
-  
+
   // $match = array('\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '*', '?', ':', '"', ';', ' ');
   // $match = array('\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '*', '?', ':', '"', ';', ' ');
   // $replace = array('\\\\', '\\+', '\\-', '\\&', '\\|', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:', '\\"', '\\;', '\\ ');
   // $replace = array('\\\\', '\\+', '\\-', '\\&', '\\|', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:', '\\"', '\\;', '\\ ');
   foreach ($words[0] as $word) {
   foreach ($words[0] as $word) {
@@ -197,7 +197,7 @@ function materio_search_api_results_search(){
   // dsm($viewmode, 'viewmode');
   // dsm($viewmode, 'viewmode');
 
 
   if ($keys) {
   if ($keys) {
-    // TODO:  cache the results with cache graceful : http://drupal.org/project/cache_graceful  
+    // TODO:  cache the results with cache graceful : http://drupal.org/project/cache_graceful
     try {
     try {
       $limit = variable_get($viewmode.'_limite', '10');
       $limit = variable_get($viewmode.'_limite', '10');
       $offset = pager_find_page() * $limit; //$page*$limit;//
       $offset = pager_find_page() * $limit; //$page*$limit;//
@@ -244,7 +244,7 @@ function materio_search_api_results_search(){
     // $results['results'] = $accessible_results;
     // $results['results'] = $accessible_results;
     // $results['result count'] = count($accessible_results);
     // $results['result count'] = count($accessible_results);
 
 
-    
+
 
 
     if(user_access('use materio search api')){
     if(user_access('use materio search api')){
       $items = $index->loadItems(array_keys($results['results']));
       $items = $index->loadItems(array_keys($results['results']));
@@ -296,7 +296,7 @@ function materio_search_api_results_search(){
 
 
       if (!empty($results['ignored'])) {
       if (!empty($results['ignored'])) {
         drupal_set_message(
         drupal_set_message(
-          t('The following search keys are too short or too common and were therefore ignored: "@list".', 
+          t('The following search keys are too short or too common and were therefore ignored: "@list".',
             array( '@list' => implode(t('", "'), $results['ignored']) ) ),
             array( '@list' => implode(t('", "'), $results['ignored']) ) ),
          'warning'
          'warning'
         );
         );
@@ -320,7 +320,7 @@ function materio_search_api_actuality(){
   global $user;
   global $user;
 
 
   if(isset($user->roles[1])){
   if(isset($user->roles[1])){
-    $date_limit = strtotime('-6 month');  
+    $date_limit = strtotime('-6 month');
     // dsm(date('d m y', $date_limit));
     // dsm(date('d m y', $date_limit));
   }
   }
 
 
@@ -361,7 +361,7 @@ function materio_search_api_actuality(){
   if(isset($result['node'])){
   if(isset($result['node'])){
     foreach ($result['node'] as $nid => $n) {
     foreach ($result['node'] as $nid => $n) {
       $breve = node_load($nid);
       $breve = node_load($nid);
-      
+
       if(!node_access('view', $breve))
       if(!node_access('view', $breve))
         continue;
         continue;
 
 
@@ -377,7 +377,7 @@ function materio_search_api_actuality(){
       }
       }
     }
     }
   }
   }
-  
+
   // drupal_set_title(t('Actualities'));
   // drupal_set_title(t('Actualities'));
   drupal_set_title(t(''));
   drupal_set_title(t(''));
 
 

+ 2 - 2
materio_search_api_ajax.module

@@ -15,7 +15,7 @@ function materio_search_api_ajax_init() {
   if (module_exists('locale')) {
   if (module_exists('locale')) {
     $languages = language_list('enabled');
     $languages = language_list('enabled');
   }
   }
-  
+
   drupal_add_js(array('materio_search_api_ajax' => array(
   drupal_add_js(array('materio_search_api_ajax' => array(
     'module_path' => drupal_get_path('module', 'materio_search_api_ajax'),
     'module_path' => drupal_get_path('module', 'materio_search_api_ajax'),
     // 'strings'=>array(
     // 'strings'=>array(
@@ -51,7 +51,7 @@ function materio_search_api_ajax_menu() {
     'page argument' => array(3),
     'page argument' => array(3),
     'access arguments' => array('use materio search api viewmode selection'),
     'access arguments' => array('use materio search api viewmode selection'),
   );
   );
-  
+
   $items['materio_search_api_ajax/actuality'] = $base+array(
   $items['materio_search_api_ajax/actuality'] = $base+array(
     'page callback' => 'materio_search_api_ajax_actuality',
     'page callback' => 'materio_search_api_ajax_actuality',
     'access callback' => TRUE,
     'access callback' => TRUE,

+ 9 - 3
materio_search_api_ajax.pages.inc

@@ -229,11 +229,17 @@ function materio_search_api_ajax_actuality($page = 0){
 
 
 function materio_search_api_ajax_node($nid){
 function materio_search_api_ajax_node($nid){
   global $user;
   global $user;
-  $viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
+  
+  $viewmode = isset($_GET['viewmode']) ? $_GET['viewmode'] : (isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full'));
+
+  $rep = array(
+    "get" => $_GET,
+    "viewmode" => $viewmode
+  );
 
 
   if($nodeview = node_view(node_load($nid),$viewmode)){
   if($nodeview = node_view(node_load($nid),$viewmode)){
-    $rep = array(
-      'nid'=>$nid,
+    $rep = $rep+array(
+      'nid' => $nid,
       'node' => drupal_render($nodeview),
       'node' => drupal_render($nodeview),
     );
     );
     drupal_json_output($rep);  
     drupal_json_output($rep);  

+ 4 - 0
materio_user.module

@@ -267,6 +267,8 @@ function materio_user_webform_client_11186_validate($form, &$form_state){
         }
         }
       }
       }
     }
     }
+
+
   }
   }
 }
 }
 
 
@@ -495,6 +497,7 @@ function materio_user_help($path, $arg) {
   }
   }
 }
 }
 
 
+
 /**
 /**
  * Implements hook_block_view_alter().
  * Implements hook_block_view_alter().
  */
  */
@@ -506,6 +509,7 @@ function materio_user_block_view_alter(&$data, $block) {
   }
   }
 }
 }
 
 
+
 /**
 /**
  * Define constants
  * Define constants
  */
  */

+ 4 - 4
materio_user.pages.inc

@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 
 function materio_user_registerblock(){
 function materio_user_registerblock(){
   $return = array();
   $return = array();
@@ -28,14 +28,14 @@ function materio_user_register_submit(){
     unset ($_SESSION['messages']['error']);
     unset ($_SESSION['messages']['error']);
   }else{
   }else{
     $messages = drupal_get_messages('status');
     $messages = drupal_get_messages('status');
-    // $return['messages'] = $messages; 
+    // $return['messages'] = $messages;
     drupal_set_message(t("Congratulations, you juste created your free materiO' account, welcome !"), 'status');
     drupal_set_message(t("Congratulations, you juste created your free materiO' account, welcome !"), 'status');
     foreach ($messages['status'] as $msg) {
     foreach ($messages['status'] as $msg) {
       drupal_set_message($msg, 'status');
       drupal_set_message($msg, 'status');
     }
     }
   }
   }
   // after registration user is automaticly logged in, thank's to login tobogan module
   // after registration user is automaticly logged in, thank's to login tobogan module
-  
+
   drupal_json_output($return);
   drupal_json_output($return);
 }
 }
 
 
@@ -45,7 +45,7 @@ function materio_user_login_submit(){
 
 
   $form_state = array("values"=>$_POST);
   $form_state = array("values"=>$_POST);
   drupal_form_submit($_POST['form_id'], $form_state);
   drupal_form_submit($_POST['form_id'], $form_state);
- 
+
   $return['errors'] = form_get_errors();
   $return['errors'] = form_get_errors();
   if($return['errors'])
   if($return['errors'])
     unset ($_SESSION['messages']['error']);
     unset ($_SESSION['messages']['error']);

+ 12 - 2
templates/materio-search-api-results.tpl.php

@@ -38,11 +38,21 @@
 <?php //if (!empty($result_count)) : ?>
 <?php //if (!empty($result_count)) : ?>
   <div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>">
   <div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>">
     <?php if ($result_count) : ?>
     <?php if ($result_count) : ?>
-      <p class="search-performance"><?php print render($search_performance); ?></p>
+      <?php if(!$perfascard): ?>
+        <p class="search-performance"><?php print render($search_performance); ?></P>
+      <?php endif; ?>
       <?php //print render($spellcheck); ?>
       <?php //print render($spellcheck); ?>
       <div class="search-results">
       <div class="search-results">
+        <?php if($perfascard): ?>
+          <article class="search-performance <?php print ' view-mode-' . $variables['view_mode'];?>">
+            <div class="inner">
+
+              <p><?php print render($search_performance); ?></P>
+            </div>
+          </article>
+        <?php endif; ?>
         <?php //dsm($items, '$items'); ?>
         <?php //dsm($items, '$items'); ?>
-        <?php 
+        <?php
         // TODO: use cache system to gain in speed, view http://drupal.org/node/930760
         // TODO: use cache system to gain in speed, view http://drupal.org/node/930760
         ?>
         ?>
         <?php print render(entity_view($index->item_type, $items, $variables['view_mode'])); ?>
         <?php print render(entity_view($index->item_type, $items, $variables['view_mode'])); ?>

+ 1 - 0
templates/simplenews_6274_node.html

@@ -0,0 +1 @@
+<p>TODO</p>

+ 65 - 0
templates/simplenews_6374_node.html

@@ -0,0 +1,65 @@
+<table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
+  <tbody>
+    <tr>
+      <td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding:0 0 5px 0;" align="left">
+        <table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
+          <tbody>
+            <tr>
+              <td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding: 0;" align="left">
+                <img src="/sites/default/files/uploaderuneimage.png" width="600" height="400">
+              </td>
+            </tr>
+          </tbody>
+        </table>
+        <table style="margin: 0 0 0 10px; border-collapse: collapse; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
+          <tbody>
+            <tr>
+              <td style="vertical-align: top; padding: 5px 0;" width="580">
+                <table style="border-collapse: collapse; width: 565px; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;" width="565" cellspacing="0" cellpadding="0">
+                  <tbody>
+                    <tr>
+                      <td style="padding: 5px 0 5px 5px; line-height: normal; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
+                        <p style="color: #444444; text-align: left; ;margin: 0 0 10px; line-height: 1.3em;">
+                          <span style="color: #444444; font-family: arial, helvetica, sans-serif;">
+                            <strong>
+                              ZE DAILY MATERIO'
+                            </strong>
+                          </span>
+                        </p>
+                        <p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
+                          <strong>
+                            le titre en fr
+                          </strong>
+                          <br>
+                          Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur.
+                        </p>
+                        <div>
+                          &nbsp;
+                        </div>
+                        <p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
+                          <span style="color: #696969;">
+                            <em>
+                              <strong>
+                                The english title&nbsp;
+                              </strong>
+                            </em>
+                          </span>
+                          <br>
+                          <span style="color: #808080;">
+                            <em>
+                              A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside.
+                            </em>
+                          </span>
+                        </p>
+                      </td>
+                    </tr>
+                  </tbody>
+                </table>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </td>
+    </tr>
+  </tbody>
+</table>

+ 65 - 0
templates/simplenews_6585_node.html

@@ -0,0 +1,65 @@
+<table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
+  <tbody>
+    <tr>
+      <td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding:0 0 5px 0;" align="left">
+        <table style="margin: 0; border-collapse: collapse;" width="100%" border="0" cellspacing="0" cellpadding="0">
+          <tbody>
+            <tr>
+              <td style="color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff; padding: 0;" align="left">
+                <img src="/sites/default/files/uploaderuneimage.png" width="600" height="400">
+              </td>
+            </tr>
+          </tbody>
+        </table>
+        <table style="margin: 0 0 0 10px; border-collapse: collapse; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
+          <tbody>
+            <tr>
+              <td style="vertical-align: top; padding: 5px 0;" width="580">
+                <table style="border-collapse: collapse; width: 565px; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;" width="565" cellspacing="0" cellpadding="0">
+                  <tbody>
+                    <tr>
+                      <td style="padding: 5px 0 5px 5px; line-height: normal; color: #444444; font-family: arial; font-size: 12px; background-color: #ffffff;">
+                        <p style="color: #444444; text-align: left; ;margin: 0 0 10px; line-height: 1.3em;">
+                          <span style="color: #444444; font-family: arial, helvetica, sans-serif;">
+                            <strong>
+                              ZE DAILY MATERIO'
+                            </strong>
+                          </span>
+                        </p>
+                        <p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
+                          <strong>
+                            le titre en fr
+                          </strong>
+                          <br>
+                          Toute une série de matières recyclées sous vos pieds, car ces tapis sont tissés avec des chambres à air usagées, des papiers de bonbons minutieusement filés, de vieux journaux et magazines tressés ou d'autres matières recyclées surprenantes. Certains tapis de cette gamme peuvent même aller à l'extérieur.
+                        </p>
+                        <div>
+                          &nbsp;
+                        </div>
+                        <p style="color: #444444; ;margin: 0 0 10px; line-height: 1.3em;">
+                          <span style="color: #696969;">
+                            <em>
+                              <strong>
+                                The english title&nbsp;
+                              </strong>
+                            </em>
+                          </span>
+                          <br>
+                          <span style="color: #808080;">
+                            <em>
+                              A wide range of beautiful carpets made out of surprising recycled materials: recycled candy wrappers, recycled tires and bike tubes, different recycled fibers and recycled newspaper! Some of them can even be used outside.
+                            </em>
+                          </span>
+                        </p>
+                      </td>
+                    </tr>
+                  </tbody>
+                </table>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </td>
+    </tr>
+  </tbody>
+</table>