Changeset 40 for trunk/admin
- Timestamp:
- Jul 26, 2003, 11:28:58 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/infos_images.php
r33 r40 173 173 } 174 174 } 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'; 192 179 $query.= ' WHERE cat_id = '.$page['cat']; 193 180 $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 } 195 221 } 196 222 //--------------------------------------------------------- form initialization … … 225 251 'infoimage_creation_date','infoimage_detailed','thumbnail', 226 252 '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' ); 228 256 templatize_array( $tpl, 'lang', $sub ); 229 257 //------------------------------------------------------------------------ form
Note: See TracChangeset
for help on using the changeset viewer.