Changeset 33
- Timestamp:
- Jul 23, 2003, 9:49:15 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/infos_images.php
r26 r33 22 22 { 23 23 // date arrives at this format : DD/MM/YYYY 24 // checkdate ( int month, int day, int year) 25 $tab_date = explode( '/', $date ); 26 return checkdate ( $tab_date[1], $tab_date[0], $tab_date[2]); 24 list($day,$month,$year) = explode( '/', $date ); 25 return checkdate ( $month, $day, $year ); 27 26 } 28 27 … … 31 30 // date arrives at this format : DD/MM/YYYY 32 31 // It must be transformed in YYYY-MM-DD 33 $tab_date= explode( '/', $date );34 return $ tab_date[2].'-'.$tab_date[1].'-'.$tab_date[0];32 list($day,$month,$year) = explode( '/', $date ); 33 return $year.'-'.$month.'-'.$day; 35 34 } 36 35 … … 41 40 if ( $date != '' ) 42 41 { 43 $tab_date= explode( '-', $date );44 return $ tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0];42 list($year,$month,$day) = explode( '-', $date ); 43 return $day.'/'.$month.'/'.$year; 45 44 } 46 45 else … … 48 47 return ''; 49 48 } 49 } 50 51 // get_keywords returns an array with relevant keywords found in the string 52 // given in argument. Keywords must be separated by comma in this string. 53 // keywords must : 54 // - be longer or equal to 3 characters 55 // - not contain ', " or blank characters 56 // - unique in the string ("test,test" -> "test") 57 function get_keywords( $keywords_string ) 58 { 59 $keywords = array(); 60 61 $candidates = explode( ',', $keywords_string ); 62 foreach ( $candidates as $candidate ) { 63 if ( strlen($candidate) >= 3 and !preg_match( '/(\'|"|\s)/', $candidate ) ) 64 array_push( $keywords, $candidate ); 65 } 66 67 return array_unique( $keywords ); 50 68 } 51 69 //-------------------------------------------------------------- initialization … … 67 85 $comment = 'comment-'.$row['id']; 68 86 $date_creation = 'date_creation-'.$row['id']; 87 $keywords = 'keywords-'.$row['id']; 69 88 if ( isset( $_POST[$name] ) ) 70 89 { 71 90 $query = 'UPDATE '.PREFIX_TABLE.'images'; 91 92 $query.= ' SET name = '; 72 93 if ( $_POST[$name] == '' ) 94 $query.= 'NULL'; 95 else 96 $query.= "'".htmlentities( $_POST[$name], ENT_QUOTES )."'"; 97 98 $query.= ', author = '; 99 if ( $_POST[$author] == '' ) 100 $query.= 'NULL'; 101 else 102 $query.= "'".htmlentities($_POST[$author],ENT_QUOTES)."'"; 103 104 $query.= ', comment = '; 105 if ( $_POST[$comment] == '' ) 106 $query.= 'NULL'; 107 else 108 $query.= "'".htmlentities($_POST[$comment],ENT_QUOTES)."'"; 109 110 $query.= ', date_creation = '; 111 if ( check_date_format( $_POST[$date_creation] ) ) 112 $query.= "'".date_convert( $_POST[$date_creation] )."'"; 113 else if ( $_POST[$date_creation] == '' ) 114 $query.= 'NULL'; 115 116 $query.= ', keywords = '; 117 $keywords_array = get_keywords( $_POST[$keywords] ); 118 if ( count( $keywords_array ) == 0 ) 119 $query.= 'NULL'; 120 else 73 121 { 74 $query.= ' SET name = NULL'; 75 } 76 else 77 { 78 $query.= " SET name = '".htmlentities( $_POST[$name], ENT_QUOTES )."'"; 79 } 80 if ( $_POST[$author] == '' ) 81 { 82 $query.= ', author = NULL'; 83 } 84 else 85 { 86 $query.= ", author = '".htmlentities($_POST[$author],ENT_QUOTES)."'"; 87 } 88 if ( $_POST[$comment] == '' ) 89 { 90 $query.= ', comment = NULL'; 91 } 92 else 93 { 94 $query.= ", comment = '".htmlentities($_POST[$comment],ENT_QUOTES)."'"; 95 } 96 if ( check_date_format( $_POST[$date_creation] ) ) 97 { 98 $date = date_convert( $_POST[$date_creation] ); 99 $query.= ", date_creation = '".$date."'"; 100 } 101 else if ( $_POST[$date_creation] == '' ) 102 { 103 $query.= ', date_creation = NULL'; 104 } 122 $query.= '"'; 123 foreach ( $keywords_array as $i => $keyword ) { 124 if ( $i > 0 ) $query.= ','; 125 $query.= $keyword; 126 } 127 $query.= '"'; 128 } 129 105 130 $query.= ' WHERE id = '.$row['id']; 106 131 $query.= ';'; … … 147 172 echo $lang['err_date']; 148 173 } 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 } 192 $query.= ' WHERE cat_id = '.$page['cat']; 193 $query.= ';'; 194 mysql_query( $query ); 149 195 } 150 196 //--------------------------------------------------------- form initialization … … 179 225 'infoimage_creation_date','infoimage_detailed','thumbnail', 180 226 'infoimage_title','infoimage_comment', 181 'infoimage_creation_date' );227 'infoimage_creation_date','infoimage_keywords' ); 182 228 templatize_array( $tpl, 'lang', $sub ); 183 229 //------------------------------------------------------------------------ form … … 191 237 $vtp->setVar( $sub, 'cat_name', $cat_name ); 192 238 193 $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation ';239 $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation,keywords'; 194 240 $query.= ' FROM '.PREFIX_TABLE.'images'; 195 241 $query.= ' WHERE cat_id = '.$page['cat']; … … 206 252 $vtp->setVar( $sub, 'picture.author', $row['author'] ); 207 253 $vtp->setVar( $sub, 'picture.comment', $row['comment'] ); 254 $vtp->setVar( $sub, 'picture.keywords', $row['keywords'] ); 208 255 $vtp->setVar( $sub, 'picture.date_creation', 209 256 date_convert_back( $row['date_creation'] ) ); -
trunk/include/functions_category.inc.php
r26 r33 422 422 423 423 $page['where'] = ' WHERE ('; 424 $fields = array( 'file', 'name', 'comment' );424 $fields = array( 'file', 'name', 'comment', 'keywords' ); 425 425 $words = explode( ',', $_GET['search'] ); 426 426 $sql_search = array(); -
trunk/language/francais.php
r26 r33 493 493 // start version 1.3 494 494 // $lang['infoimage_err_date'] = 'date erronée'; 495 $lang['infoimage_keywords'] = 'mots-clefs'; 495 496 // end version 1.3 496 497 $lang['infoimage_general'] = 'Options générale pour la catégorie'; -
trunk/template/default/admin/infos_image.vtp
r25 r33 26 26 </td> 27 27 </tr> 28 <tr> 29 <td> 30 <div style="margin-left:50px;">{#infoimage_keywords}</div> 31 </td> 32 <td style="text-align:center;"> 33 <input type="text" name="keywords_cat" value="" size="12" maxlength="255" /> 34 </td> 35 <td style="text-align:left;"> 36 <input type="checkbox" name="use_common_keywords" value="1" /> 37 {#infoimage_useforall} 38 </td> 39 </tr> 28 40 </table> 29 41 <table width="100%"> 30 42 <tr> 31 <th colspan=" 5">{#infoimage_detailed}</th>43 <th colspan="6">{#infoimage_detailed}</th> 32 44 </tr> 33 45 <tr> 34 <td colspan=" 5" align="center">{#navigation_bar}</td>46 <td colspan="6" align="center">{#navigation_bar}</td> 35 47 </tr> 36 48 <tr> … … 40 52 <td class="row2" style="text-align:center;">{#infoimage_comment}</td> 41 53 <td class="row2" style="text-align:center;">{#infoimage_creation_date}</td> 54 <td class="row2" style="text-align:center;">{#infoimage_keywords}</td> 42 55 </tr> 43 56 <!--VTP_picture--> … … 48 61 <td style="text-align:center;"><textarea name="comment-{#id}" rows="3" cols="40" style="overflow:auto">{#comment}</textarea></td> 49 62 <td style="text-align:center;"><input type="text" name="date_creation-{#id}" value="{#date_creation}" maxlength="10" size="12" /></td> 63 <td style="text-align:center;"><input type="text" name="keywords-{#id}" value="{#keywords}" maxlength="255" /></td> 50 64 </tr> 51 65 <!--/VTP_picture--> 52 66 <tr> 53 <td colspan=" 5" style="text-align:center;">67 <td colspan="6" style="text-align:center;"> 54 68 <input type="submit" value="{#submit}" name="submit" /> 55 69 </td>
Note: See TracChangeset
for help on using the changeset viewer.