Index: /extensions/Piwecard/admin/admin_management.php
===================================================================
--- /extensions/Piwecard/admin/admin_management.php	(revision 27593)
+++ /extensions/Piwecard/admin/admin_management.php	(revision 27594)
@@ -121,5 +121,5 @@
 	$valid = $piwecard->is_valid($file['ecard_id']);
 
-	$template->append('ecard_file',array(
+	$template->append('ecard_files',array(
 									'id'				=> $file['ecard_id'],
 									'title'				=> $file['title'],
Index: /extensions/Piwecard/admin/template/admin_configuration.tpl
===================================================================
--- /extensions/Piwecard/admin/template/admin_configuration.tpl	(revision 27593)
+++ /extensions/Piwecard/admin/template/admin_configuration.tpl	(revision 27594)
@@ -6,4 +6,5 @@
 {combine_script id='colorpicker' load="footer" path='plugins/Piwecard/js/colorpicker/js/colorpicker.js'}
 {combine_css path="plugins/Piwecard/js/colorpicker/css/colorpicker.css"}
+{combine_css path='themes/default/js/plugins/jquery.tokeninput.css'}
 
 {footer_script require="piwecard"}
@@ -136,5 +137,5 @@
 jQuery(document).ready(function() {ldelim}
 	jQuery('select[name="ecard_validity_list"]').tokenInput(
-		[{foreach from=$validity item=validity name=validity}{ldelim}"{$validity|@escape:'javascript'}"{rdelim}{if !$smarty.foreach.validity.last},{/if}{/foreach}],
+		[{foreach from=$validity item=validity_item name=validity}{ldelim}"{$validity_item|@escape:'javascript'}"{rdelim}{if !$smarty.foreach.validity.last},{/if}{/foreach}],
     {ldelim}
 		searchDelay: 0,
@@ -146,5 +147,5 @@
 		animateDropdown: false,
 		preventDuplicates: true,
-		allowCreation: true,
+		allowFreeTagging: true,
 		onAdd:function(item){ldelim}$("<option value=\""+item.name+"\">"+((item.name == '0') ? "{'piwecard_nolimit'|@translate}" : item.name+" {'piwecard_days'|@translate}")+"</option>").appendTo("#ecard_validity_default");{rdelim},
 		onDelete:function(item){ldelim}$("#ecard_validity_default option[value="+item.name+"]").remove();{rdelim},
@@ -170,6 +171,6 @@
 				<span class="ecard_error" id="ecard_validity_list_error" style="{$ecard_errors.validity.style_error_text}">{'piwecard_error'|@translate} {'piwecard_error_validity_list'|@translate}</span>
 				<select id="ecard_validity_list" name="ecard_validity_list">
-					{foreach from=$ecard_validity_list item=ecard_validity_list}
-						<option value="{$ecard_validity_list}">{$ecard_validity_list}</option>
+					{foreach from=$ecard_validity_list item=ecard_validity_item}
+						<option value="{$ecard_validity_item}">{$ecard_validity_item}</option>
 					{/foreach}
 				</select>
@@ -178,6 +179,6 @@
 				{'piwecard_validity_default'|@translate}
 				<select id="ecard_validity_default" name="ecard_validity_default">
-					{foreach from=$ecard_validity item=ecard_validity}
-						<option value="{$ecard_validity.id}" {$ecard_validity.selected}>{$ecard_validity.name}</option>
+					{foreach from=$ecard_validity item=ecard_validity_item}
+						<option value="{$ecard_validity_item.id}" {$ecard_validity_item.selected}>{$ecard_validity_item.name}</option>
 					{/foreach}
 				</select>
@@ -239,6 +240,6 @@
 				</div>
 				<div>
-					{foreach from=$ecard_email_format item=ecard_email_format}
-						<span><input type="checkbox" name="ecard_email_format[{$ecard_email_format.id}]" id="ecard_email_format_{$ecard_email_format.id}" value="{$ecard_email_format.id}" {$ecard_email_format.selected}/><label for="ecard_email_format_{$ecard_email_format.id}"> {$ecard_email_format.language_string|@translate}</label></span>
+					{foreach from=$ecard_email_format item=ecard_email_format_item}
+						<span><input type="checkbox" name="ecard_email_format[{$ecard_email_format_item.id}]" id="ecard_email_format_{$ecard_email_format_item.id}" value="{$ecard_email_format_item.id}" {$ecard_email_format_item.selected}/><label for="ecard_email_format_{$ecard_email_format_item.id}"> {$ecard_email_format_item.language_string|@translate}</label></span>
 					{/foreach}
 				</div>
@@ -247,6 +248,6 @@
 				</div>
 				<div>
-					{foreach from=$ecard_email_format_default item=ecard_email_format_default}
-						<span id="ecard_form_line_default_{$ecard_email_format_default.id}"><input type="radio" name="ecard_email_format_default" id="ecard_email_format_default_{$ecard_email_format_default.id}" value="{$ecard_email_format_default.id}" {$ecard_email_format_default.selected_default}/><label for="ecard_email_format_default_{$ecard_email_format_default.id}"> {$ecard_email_format_default.language_string|@translate}</label></span>
+					{foreach from=$ecard_email_format_default item=ecard_email_format_default_item}
+						<span id="ecard_form_line_default_{$ecard_email_format_default_item.id}"><input type="radio" name="ecard_email_format_default" id="ecard_email_format_default_{$ecard_email_format_default_item.id}" value="{$ecard_email_format_default_item.id}" {$ecard_email_format_default_item.selected_default}/><label for="ecard_email_format_default_{$ecard_email_format_default_item.id}"> {$ecard_email_format_default_item.language_string|@translate}</label></span>
 					{/foreach}
 					<span class="ecard_error" id="ecard_email_format_default_error" style="{$piwecard_errors.email_format_default.style_error_text}">{'piwecard_error'|@translate} {'piwecard_email_format_default_error'|@translate}</span>
Index: /extensions/Piwecard/admin/template/admin_management.tpl
===================================================================
--- /extensions/Piwecard/admin/template/admin_management.tpl	(revision 27593)
+++ /extensions/Piwecard/admin/template/admin_management.tpl	(revision 27594)
@@ -76,5 +76,5 @@
 		</form>
 	</fieldset>
-	{if count($ecard_file)}
+	{if count($ecard_files)}
 		<form method="post" id="ecard_form_delete">
 			<table class="table2" width="97%">
@@ -90,5 +90,5 @@
 				</thead>
 				<tbody>
-					{foreach from=$ecard_file item=ecard_file name=foreach_ecard_file}
+					{foreach from=$ecard_files item=ecard_file name=foreach_ecard_file}
 						{if $smarty.foreach.foreach_ecard_file.iteration is even}
 							<tr class="row1">
Index: /extensions/Piwecard/include/piwecard.class.php
===================================================================
--- /extensions/Piwecard/include/piwecard.class.php	(revision 27593)
+++ /extensions/Piwecard/include/piwecard.class.php	(revision 27594)
@@ -467,4 +467,29 @@
 		}
 	}
+
+  /**
+   * Encodes a string using Q form if required (RFC2045)
+   * mail headers MUST contain only US-ASCII characters
+   *
+   * This function was in Piwigo core include/functions_mail.inc.php, but
+   * was removed from version 2.6.
+   */
+  function encode_mime_header($str)
+  {
+    $x = preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+    if ($x==0)
+    {
+      return $str;
+    }
+    // Replace every high ascii, control =, ? and _ characters
+    $str = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
+                        "'='.sprintf('%02X', ord('\\1'))", $str);
+    
+    // Replace every spaces to _ (more readable than =20)
+    $str = str_replace(" ", "_", $str);
+    
+    global $lang_info;
+    return '=?'.get_pwg_charset().'?Q?'.$str.'?=';
+  }
 	
 	/**
@@ -478,5 +503,5 @@
 		
 		$from = '"'.$email_infos['from_name'].'" <'.$email_infos['from_email'].'>';
-		$subject = encode_mime_header(trim(preg_replace('#[\n\r]+#s', '', $email_infos['subject'])));
+		$subject = $this->encode_mime_header(trim(preg_replace('#[\n\r]+#s', '', $email_infos['subject'])));
 		$boundary = '_----------='.md5(uniqid(mt_rand()));
 
Index: /extensions/Piwecard/template/ecard.tpl
===================================================================
--- /extensions/Piwecard/template/ecard.tpl	(revision 27593)
+++ /extensions/Piwecard/template/ecard.tpl	(revision 27594)
@@ -164,6 +164,6 @@
 					<span class="ecard_label">{'piwecard_email_format'|@translate} : </span>
 						<span>
-						{foreach from=$ecard_email_format item=ecard_email_format}
-							<input type="radio" name="ecard_email_format" id="ecard_email_format_{$ecard_email_format.id}" value="{$ecard_email_format.id}" {$ecard_email_format.selected}><label for="ecard_email_format_{$ecard_email_format.id}"> {$ecard_email_format.name} </label>
+						{foreach from=$ecard_email_format item=ecard_email_format_item}
+							<input type="radio" name="ecard_email_format" id="ecard_email_format_{$ecard_email_format_item.id}" value="{$ecard_email_format_item.id}" {$ecard_email_format_item.selected}><label for="ecard_email_format_{$ecard_email_format_item.id}"> {$ecard_email_format_item.name} </label>
 						{/foreach}
 					</span>
@@ -173,6 +173,6 @@
 							<span class="ecard_label">{'piwecard_validity_label'|@translate} :</span>
 							<span>
-								{foreach from=$ecard_validity item=ecard_validity}
-									<input type="radio" name="ecard_validity" id="ecard_validity_{$ecard_validity.id}" value="{$ecard_validity.id}" {$ecard_validity.selected}><label for="ecard_validity_{$ecard_validity.id}"> {$ecard_validity.name} </label>
+								{foreach from=$ecard_validity item=ecard_validity_item}
+									<input type="radio" name="ecard_validity" id="ecard_validity_{$ecard_validity_item.id}" value="{$ecard_validity_item.id}" {$ecard_validity_item.selected}><label for="ecard_validity_{$ecard_validity_item.id}"> {$ecard_validity_item.name} </label>
 								{/foreach}
 							</span>
