Changeset 40


Ignore:
Timestamp:
Jul 26, 2003, 11:28:58 AM (21 years ago)
Author:
z0rglub
Message:

instead of overriding individual keywords,\nyou can add a keyword to all or remove it from all

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/infos_images.php

    r33 r40  
    173173    }
    174174  }
    175   if ( $_POST['use_common_keywords'] == 1 )
    176   {
    177     $keywords = get_keywords( $_POST['keywords_cat'] );
    178     $query = 'UPDATE '.PREFIX_TABLE.'images';
    179     if ( count( $keywords ) == 0 )
    180     {
    181       $query.= ' SET keywords = NULL';
    182     }
    183     else
    184     {
    185       $query.= ' SET keywords = "';
    186       foreach ( $keywords as $i => $keyword ) {
    187         if ( $i > 0 ) $query.= ',';
    188         $query.= $keyword;
    189       }
    190       $query.= '"';
    191     }
     175  if ( isset( $_POST['common_keywords'] ) and $_POST['keywords_cat'] != '' )
     176  {
     177    $query = 'SELECT id,keywords';
     178    $query.= ' FROM '.PREFIX_TABLE.'images';
    192179    $query.= ' WHERE cat_id = '.$page['cat'];
    193180    $query.= ';';
    194     mysql_query( $query );
     181    $result = mysql_query( $query );
     182    while ( $row = mysql_fetch_array( $result ) )
     183    {
     184      $specific_keywords = explode( ',', $row['keywords'] );
     185      $common_keywords   = get_keywords( $_POST['keywords_cat'] );
     186      // first possiblity : adding the given keywords to all the pictures
     187      if ( $_POST['common_keywords'] == 'add' )
     188      {
     189        $keywords = array_merge( $specific_keywords, $common_keywords );
     190        $keywords = array_unique( $keywords );
     191      }
     192      // second possiblity : removing the given keywords from all pictures
     193      // (without deleting the other specific keywords
     194      if ( $_POST['common_keywords'] == 'remove' )
     195      {
     196        $keywords = array_diff( $specific_keywords, $common_keywords );
     197      }
     198      // cleaning the keywords array, sometimes, an empty value still remain
     199      $keywords = array_remove( $keywords, '' );
     200      // updating the picture with new keywords array
     201      $query = 'UPDATE '.PREFIX_TABLE.'images';
     202      $query.= ' SET keywords = ';
     203      if ( count( $keywords ) == 0 )
     204      {
     205        $query.= 'NULL';
     206      }
     207      else
     208      {
     209        $query.= '"';
     210        $i = 0;
     211        foreach ( $keywords as $keyword ) {
     212          if ( $i++ > 0 ) $query.= ',';
     213          $query.= $keyword;
     214        }
     215        $query.= '"';
     216      }
     217      $query.= ' WHERE id = '.$row['id'];
     218      $query.= ';';
     219      mysql_query( $query );
     220    }
    195221  }
    196222//--------------------------------------------------------- form initialization
     
    225251                'infoimage_creation_date','infoimage_detailed','thumbnail',
    226252                'infoimage_title','infoimage_comment',
    227                 'infoimage_creation_date','infoimage_keywords' );
     253                'infoimage_creation_date','infoimage_keywords',
     254                'infoimage_addtoall','infoimage_removefromall',
     255                'infoimage_keyword_separation' );
    228256  templatize_array( $tpl, 'lang', $sub );
    229257//------------------------------------------------------------------------ form
  • trunk/language/francais.php

    r38 r40  
    497497  // $lang['infoimage_err_date'] = 'date erronée';
    498498  $lang['infoimage_keywords'] = 'mots-clefs';
     499  $lang['infoimage_keyword_separation'] = '(séparer avec des ",")';
     500  $lang['infoimage_addtoall'] = 'ajouter à tous';
     501  $lang['infoimage_removefromall'] = 'retirer à tous';
    499502// end version 1.3
    500503  $lang['infoimage_general'] = 'Options générale pour la catégorie';
  • trunk/template/default/admin/infos_image.vtp

    r33 r40  
    2828    <tr>
    2929      <td>
    30         <div style="margin-left:50px;">{#infoimage_keywords}</div>
     30        <div style="margin-left:50px;">{#infoimage_keywords} {#infoimage_keyword_separation}</div>
    3131      </td>
    3232      <td style="text-align:center;">
    33         <input type="text" name="keywords_cat" value="" size="12" maxlength="255" />
     33        <input type="text" name="keywords_cat" value="" maxlength="255" />
    3434      </td>
    3535      <td style="text-align:left;">
    36         <input type="checkbox" name="use_common_keywords" value="1" />
    37         {#infoimage_useforall}
     36        <input type="radio" name="common_keywords" value="add" />
     37        {#infoimage_addtoall}
     38        <input type="radio" name="common_keywords" value="remove" />
     39        {#infoimage_removefromall}
    3840      </td>
    3941    </tr>
Note: See TracChangeset for help on using the changeset viewer.