Index: /trunk/admin/infos_images.php
===================================================================
--- /trunk/admin/infos_images.php	(revision 32)
+++ /trunk/admin/infos_images.php	(revision 33)
@@ -22,7 +22,6 @@
 {
   // date arrives at this format : DD/MM/YYYY
-  // checkdate ( int month, int day, int year)
-  $tab_date = explode( '/', $date );
-  return checkdate ( $tab_date[1], $tab_date[0], $tab_date[2]);
+  list($day,$month,$year) = explode( '/', $date );
+  return checkdate ( $month, $day, $year );
 }
 
@@ -31,6 +30,6 @@
   // date arrives at this format : DD/MM/YYYY
   // It must be transformed in YYYY-MM-DD
-  $tab_date = explode( '/', $date );
-  return $tab_date[2].'-'.$tab_date[1].'-'.$tab_date[0];
+  list($day,$month,$year) = explode( '/', $date );
+  return $year.'-'.$month.'-'.$day;
 }
 
@@ -41,6 +40,6 @@
   if ( $date != '' )
   {
-    $tab_date = explode( '-', $date );
-    return $tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0];
+    list($year,$month,$day) = explode( '-', $date );
+    return $day.'/'.$month.'/'.$year;
   }
   else
@@ -48,4 +47,23 @@
     return '';
   }
+}
+
+// get_keywords returns an array with relevant keywords found in the string
+// given in argument. Keywords must be separated by comma in this string.
+// keywords must :
+//   - be longer or equal to 3 characters
+//   - not contain ', " or blank characters
+//   - unique in the string ("test,test" -> "test")
+function get_keywords( $keywords_string )
+{
+  $keywords = array();
+
+  $candidates = explode( ',', $keywords_string );
+  foreach ( $candidates as $candidate ) {
+    if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) )
+      array_push( $keywords, $candidate );
+  }
+
+  return array_unique( $keywords );
 }
 //-------------------------------------------------------------- initialization
@@ -67,40 +85,47 @@
     $comment       = 'comment-'.$row['id'];
     $date_creation = 'date_creation-'.$row['id'];
+    $keywords      = 'keywords-'.$row['id'];
     if ( isset( $_POST[$name] ) )
     {
       $query = 'UPDATE '.PREFIX_TABLE.'images';
+
+      $query.= ' SET name = ';
       if ( $_POST[$name] == '' )
+        $query.= 'NULL';
+      else
+        $query.= "'".htmlentities( $_POST[$name], ENT_QUOTES )."'";
+
+      $query.= ', author = ';
+      if ( $_POST[$author] == '' )
+        $query.= 'NULL';
+      else
+        $query.= "'".htmlentities($_POST[$author],ENT_QUOTES)."'";
+
+      $query.= ', comment = ';
+      if ( $_POST[$comment] == '' )
+        $query.= 'NULL';
+      else
+        $query.= "'".htmlentities($_POST[$comment],ENT_QUOTES)."'";
+
+      $query.= ', date_creation = ';
+      if ( check_date_format( $_POST[$date_creation] ) )
+        $query.= "'".date_convert( $_POST[$date_creation] )."'";
+      else if ( $_POST[$date_creation] == '' )
+        $query.= 'NULL';
+
+      $query.= ', keywords = ';
+      $keywords_array = get_keywords( $_POST[$keywords] );
+      if ( count( $keywords_array ) == 0 )
+        $query.= 'NULL';
+      else
       {
-        $query.= ' SET name = NULL';
-      }
-      else
-      {
-        $query.= " SET name = '".htmlentities( $_POST[$name], ENT_QUOTES )."'";
-      }
-      if ( $_POST[$author] == '' )
-      {
-        $query.= ', author = NULL';
-      }
-      else
-      {
-        $query.= ", author = '".htmlentities($_POST[$author],ENT_QUOTES)."'";
-      }
-      if ( $_POST[$comment] == '' )
-      {
-        $query.= ', comment = NULL';
-      }
-      else
-      {
-        $query.= ", comment = '".htmlentities($_POST[$comment],ENT_QUOTES)."'";
-      }
-      if ( check_date_format( $_POST[$date_creation] ) )
-      {
-        $date = date_convert( $_POST[$date_creation] );
-        $query.= ", date_creation = '".$date."'";
-      }
-      else if ( $_POST[$date_creation] == '' )
-      {
-        $query.= ', date_creation = NULL';
-      }
+        $query.= '"';
+        foreach ( $keywords_array as $i => $keyword ) {
+          if ( $i > 0 ) $query.= ',';
+          $query.= $keyword;
+        }
+        $query.= '"';
+      }
+
       $query.= ' WHERE id = '.$row['id'];
       $query.= ';';
@@ -147,4 +172,25 @@
       echo $lang['err_date'];
     }
+  }
+  if ( $_POST['use_common_keywords'] == 1 )
+  {
+    $keywords = get_keywords( $_POST['keywords_cat'] );
+    $query = 'UPDATE '.PREFIX_TABLE.'images';
+    if ( count( $keywords ) == 0 )
+    {
+      $query.= ' SET keywords = NULL';
+    }
+    else
+    {
+      $query.= ' SET keywords = "';
+      foreach ( $keywords as $i => $keyword ) {
+        if ( $i > 0 ) $query.= ',';
+        $query.= $keyword;
+      }
+      $query.= '"';
+    }
+    $query.= ' WHERE cat_id = '.$page['cat'];
+    $query.= ';';
+    mysql_query( $query );
   }
 //--------------------------------------------------------- form initialization
@@ -179,5 +225,5 @@
                 'infoimage_creation_date','infoimage_detailed','thumbnail',
                 'infoimage_title','infoimage_comment',
-                'infoimage_creation_date' );
+                'infoimage_creation_date','infoimage_keywords' );
   templatize_array( $tpl, 'lang', $sub );
 //------------------------------------------------------------------------ form
@@ -191,5 +237,5 @@
   $vtp->setVar( $sub, 'cat_name', $cat_name );
 
-  $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation';
+  $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation,keywords';
   $query.= ' FROM '.PREFIX_TABLE.'images';
   $query.= ' WHERE cat_id = '.$page['cat'];
@@ -206,4 +252,5 @@
     $vtp->setVar( $sub, 'picture.author', $row['author'] );
     $vtp->setVar( $sub, 'picture.comment', $row['comment'] );
+    $vtp->setVar( $sub, 'picture.keywords', $row['keywords'] );
     $vtp->setVar( $sub, 'picture.date_creation',
                   date_convert_back( $row['date_creation'] ) );
Index: /trunk/include/functions_category.inc.php
===================================================================
--- /trunk/include/functions_category.inc.php	(revision 32)
+++ /trunk/include/functions_category.inc.php	(revision 33)
@@ -422,5 +422,5 @@
 
         $page['where'] = ' WHERE (';
-        $fields = array( 'file', 'name', 'comment' );
+        $fields = array( 'file', 'name', 'comment', 'keywords' );
         $words = explode( ',', $_GET['search'] );
         $sql_search = array();
Index: /trunk/language/francais.php
===================================================================
--- /trunk/language/francais.php	(revision 32)
+++ /trunk/language/francais.php	(revision 33)
@@ -493,4 +493,5 @@
 // start version 1.3
   // $lang['infoimage_err_date'] = 'date erronée';
+  $lang['infoimage_keywords'] = 'mots-clefs';
 // end version 1.3
   $lang['infoimage_general'] = 'Options générale pour la catégorie';
Index: /trunk/template/default/admin/infos_image.vtp
===================================================================
--- /trunk/template/default/admin/infos_image.vtp	(revision 32)
+++ /trunk/template/default/admin/infos_image.vtp	(revision 33)
@@ -26,11 +26,23 @@
       </td>
     </tr>
+    <tr>
+      <td>
+        <div style="margin-left:50px;">{#infoimage_keywords}</div>
+      </td>
+      <td style="text-align:center;">
+        <input type="text" name="keywords_cat" value="" size="12" maxlength="255" />
+      </td>
+      <td style="text-align:left;">
+        <input type="checkbox" name="use_common_keywords" value="1" />
+        {#infoimage_useforall}
+      </td>
+    </tr>
   </table>
   <table width="100%">
     <tr>
-      <th colspan="5">{#infoimage_detailed}</th>
+      <th colspan="6">{#infoimage_detailed}</th>
     </tr>
     <tr>
-      <td colspan="5" align="center">{#navigation_bar}</td>
+      <td colspan="6" align="center">{#navigation_bar}</td>
     </tr>
     <tr>
@@ -40,4 +52,5 @@
       <td class="row2" style="text-align:center;">{#infoimage_comment}</td>
       <td class="row2" style="text-align:center;">{#infoimage_creation_date}</td>
+      <td class="row2" style="text-align:center;">{#infoimage_keywords}</td>
     </tr>
     <!--VTP_picture-->
@@ -48,8 +61,9 @@
       <td style="text-align:center;"><textarea name="comment-{#id}" rows="3" cols="40" style="overflow:auto">{#comment}</textarea></td>
       <td style="text-align:center;"><input type="text" name="date_creation-{#id}" value="{#date_creation}" maxlength="10" size="12" /></td>
+      <td style="text-align:center;"><input type="text" name="keywords-{#id}" value="{#keywords}" maxlength="255" /></td>
     </tr>
     <!--/VTP_picture-->
     <tr>
-      <td colspan="5" style="text-align:center;">
+      <td colspan="6" style="text-align:center;">
         <input type="submit" value="{#submit}" name="submit" />
       </td>
