Changeset 506 for trunk/admin
- Timestamp:
- Aug 29, 2004, 11:22:24 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/infos_images.php
r496 r506 52 52 else 53 53 { 54 $query = 'SELECT id'; 55 $query.= ' FROM '.PREFIX_TABLE.'categories'; 54 $query = 'SELECT id FROM '.CATEGORIES_TABLE; 56 55 $query.= ' WHERE id = '.$_POST['associate']; 57 56 $query.= ';'; … … 63 62 $associate = false; 64 63 65 $query = 'SELECT id,file'; 66 $query.= ' FROM '.PREFIX_TABLE.'images'; 67 $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 64 $query = 'SELECT id,file FROM '.IMAGES_TABLE; 65 $query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; 68 66 $query.= ' WHERE category_id = '.$page['cat']; 69 67 $query.= ';'; … … 78 76 if ( isset( $_POST[$name] ) ) 79 77 { 80 $query = 'UPDATE '.PREFIX_TABLE.'images'; 81 82 $query.= ' SET name = '; 78 $query = 'UPDATE '.IMAGES_TABLE.' SET name = '; 83 79 if ( $_POST[$name] == '' ) 84 80 $query.= 'NULL'; … … 117 113 if ( isset( $_POST['check-'.$row['id']] ) and count( $errors ) == 0 ) 118 114 { 119 $query = 'INSERT INTO '. PREFIX_TABLE.'image_category';115 $query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE; 120 116 $query.= ' (image_id,category_id) VALUES'; 121 117 $query.= ' ('.$row['id'].','.$_POST['associate'].')'; … … 125 121 } 126 122 } 127 update_category( $_POST['associate'] );123 if ( isset( $_POST['associate'] )) update_category( $_POST['associate'] ); 128 124 if ( $associate ) synchronize_all_users(); 129 125 //------------------------------------------------------ update general options 130 126 if ( isset( $_POST['use_common_author'] ) ) 131 127 { 132 $query = 'SELECT image_id'; 133 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 128 $query = 'SELECT image_id FROM '.IMAGE_CATEGORY_TABLE; 134 129 $query.= ' WHERE category_id = '.$page['cat']; 135 130 $result = mysql_query( $query ); 136 131 while ( $row = mysql_fetch_array( $result ) ) 137 132 { 138 $query = 'UPDATE '. PREFIX_TABLE.'images';133 $query = 'UPDATE '.IMAGES_TABLE; 139 134 if ( $_POST['author_cat'] == '' ) 140 135 { … … 156 151 { 157 152 $date = date_convert( $_POST['date_creation_cat'] ); 158 $query = 'SELECT image_id'; 159 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 153 $query = 'SELECT image_id FROM '.IMAGE_CATEGORY_TABLE; 160 154 $query.= ' WHERE category_id = '.$page['cat']; 161 155 $result = mysql_query( $query ); 162 156 while ( $row = mysql_fetch_array( $result ) ) 163 157 { 164 $query = 'UPDATE '. PREFIX_TABLE.'images';158 $query = 'UPDATE '.IMAGES_TABLE; 165 159 if ( $_POST['date_creation_cat'] == '' ) 166 160 { … … 183 177 if ( isset( $_POST['common_keywords'] ) and $_POST['keywords_cat'] != '' ) 184 178 { 185 $query = 'SELECT id,keywords'; 186 $query.= ' FROM '.PREFIX_TABLE.'images'; 187 $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 179 $query = 'SELECT id,keywords FROM '.IMAGES_TABLE; 180 $query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; 188 181 $query.= ' WHERE category_id = '.$page['cat']; 189 182 $query.= ';'; … … 210 203 $keywords = array_remove( $keywords, '' ); 211 204 // updating the picture with new keywords array 212 $query = 'UPDATE '.PREFIX_TABLE.'images'; 213 $query.= ' SET keywords = '; 205 $query = 'UPDATE '.IMAGES_TABLE.' SET keywords = '; 214 206 if ( count( $keywords ) == 0 ) 215 207 { … … 234 226 //--------------------------------------------------------- form initialization 235 227 if( !isset( $_GET['start'] ) 236 or!is_numeric( $_GET['start'] )237 or( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )228 || !is_numeric( $_GET['start'] ) 229 || ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) 238 230 { 239 231 $page['start'] = 0; … … 249 241 floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page']; 250 242 } 251 // retrieving category information 252 $result = get_cat_info( $page['cat'] ); 253 $cat['name'] = $result['name']; 254 $cat['nb_images'] = $result['nb_images']; 243 // Navigation path 244 $current_category = get_cat_info($_GET['cat_id']); 245 $url = PHPWG_ROOT_PATH.'admin.php?page=infos_images&cat_id='; 246 $category_path = get_cat_display_name($current_category['name'], '->', $url); 247 248 $form_action = PHPWG_ROOT_PATH.'admin.php?page=infos_images&cat_id='.$_GET['cat_id']; 249 if( $page['start']) 250 { 251 $form_action.= '&start='.$_GET['start']; 252 } 253 254 $nav_bar = create_navigation_bar( 255 $form_action, $current_category['nb_images'],$page['start'], $page['nb_image_page'], '' ); 256 255 257 //----------------------------------------------------- template initialization 256 $sub = $vtp->Open('./template/'.$user['template'].'/admin/infos_image.vtp'); 257 $tpl = array( 'infoimage_general','author','infoimage_useforall','submit', 258 'infoimage_creation_date','infoimage_detailed','thumbnail', 259 'infoimage_title','infoimage_comment', 260 'infoimage_creation_date','keywords', 261 'infoimage_addtoall','infoimage_removefromall', 262 'infoimage_keyword_separation','infoimage_associate', 263 'errors_title' ); 264 templatize_array( $tpl, 'lang', $sub ); 265 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); 258 $template->set_filenames( array('infos_images'=>'admin/infos_images.tpl') ); 259 $template->assign_vars(array( 260 'CATEGORY'=>$category_path, 261 'NAV_BAR'=>$nav_bar, 262 263 'L_INFOS_TITLE'=>$lang['infoimage_general'], 264 'L_AUTHOR'=>$lang['author'], 265 'L_INFOS_OVERALL_USE'=>$lang['infoimage_useforall'], 266 'L_INFOS_CREATION_DATE'=>$lang['infoimage_creation_date'], 267 'L_KEYWORD'=>$lang['keywords'], 268 'L_KEYWORD_SEPARATION'=>$lang['infoimage_keyword_separation'], 269 'L_INFOS_ADDTOALL'=>$lang['infoimage_addtoall'], 270 'L_INFOS_REMOVEFROMALL'=>$lang['infoimage_removefromall'], 271 'L_INFOS_DETAIL'=>$lang['infoimage_detailed'], 272 'L_THUMBNAIL'=>$lang['thumbnail'], 273 'L_INFOS_IMG'=>$lang['infoimage_title'], 274 'L_INFOS_COMMENT'=>$lang['comment'], 275 'L_INFOS_ASSOCIATE'=>$lang['infoimage_associate'], 276 'L_SUBMIT'=>$lang['submit'], 277 278 'F_ACTION'=>add_session_id($form_action) 279 )); 280 266 281 //-------------------------------------------------------------- errors display 267 if ( count( $errors ) != 0 )282 if ( sizeof( $errors ) != 0 ) 268 283 { 269 $vtp->addSession( $sub, 'errors' ); 270 foreach ( $errors as $error ) { 271 $vtp->addSession( $sub, 'li' ); 272 $vtp->setVar( $sub, 'li.content', $error ); 273 $vtp->closeSession( $sub, 'li' ); 274 } 275 $vtp->closeSession( $sub, 'errors' ); 284 $template->assign_block_vars('errors',array()); 285 for ( $i = 0; $i < sizeof( $errors ); $i++ ) 286 { 287 $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); 288 } 276 289 } 277 290 //------------------------------------------------------------------------ form 278 $url = './admin.php?page=infos_images&cat_id='.$page['cat'];279 $url.= '&start='.$page['start'];280 $vtp->setVar( $sub, 'form_action', add_session_id( $url ) );281 $page['navigation_bar'] = create_navigation_bar(282 $url, $cat['nb_images'],$page['start'], $page['nb_image_page'], '' );283 $vtp->setVar( $sub, 'navigation_bar', $page['navigation_bar'] );284 $cat_name = get_cat_display_name( $cat['name'], ' - ', 'font-style:italic;');285 $vtp->setVar( $sub, 'cat_name', $cat_name );286 291 287 292 $array_cat_directories = array(); … … 291 296 ,'category_id' ); 292 297 293 $query = 'SELECT '.implode( ',', $infos ); 294 $query.= ' FROM '.PREFIX_TABLE.'images'; 295 $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; 298 $query = 'SELECT * FROM '.IMAGES_TABLE; 299 $query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; 296 300 $query.= ' WHERE category_id = '.$page['cat']; 297 301 $query.= $conf['order_by']; … … 302 306 { 303 307 foreach ($infos as $info) { if (!isset($row[$info])) $row[$info] = ''; } 304 305 $vtp->addSession( $sub, 'picture' ); 306 $vtp->setVar( $sub, 'picture.id', $row['id'] ); 307 $vtp->setVar( $sub, 'picture.filename', $row['file'] ); 308 $vtp->setVar( $sub, 'picture.name', $row['name'] ); 309 $vtp->setVar( $sub, 'picture.author', $row['author'] ); 310 $vtp->setVar( $sub, 'picture.comment', $row['comment'] ); 311 $vtp->setVar( $sub, 'picture.keywords', $row['keywords'] ); 312 $vtp->setVar( $sub, 'picture.date_creation', 313 date_convert_back( $row['date_creation'] ) ); 314 $file = get_filename_wo_extension( $row['file'] ); 315 $vtp->setVar( $sub, 'picture.default_name', $file ); 316 // creating url to thumbnail 317 if ( !isset( $array_cat_directories[$row['storage_category_id']] ) ) 308 if ( !isset( $array_cat_directories[$row['storage_category_id']] ) ) 318 309 { 319 310 $array_cat_directories[$row['storage_category_id']] = … … 322 313 $thumbnail_url = $array_cat_directories[$row['storage_category_id']]; 323 314 $thumbnail_url.= 'thumbnail/'; 324 $thumbnail_url.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext']; 325 $vtp->setVar( $sub, 'picture.thumbnail_url', $thumbnail_url ); 326 $url = './admin.php?page=picture_modify&image_id='.$row['id']; 327 $vtp->setVar( $sub, 'picture.url', add_session_id( $url ) ); 328 $vtp->closeSession( $sub, 'picture' ); 329 } 315 $thumbnail_url.= $conf['prefix_thumbnail'].get_filename_wo_extension( $row['file'] ).".".$row['tn_ext']; 316 317 $template->assign_block_vars('picture' ,array( 318 'ID_IMG'=>$row['id'], 319 'URL_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=picture_modify&image_id='.$row['id'] ), 320 'TN_URL_IMG'=>$thumbnail_url, 321 'FILENAME_IMG'=>$row['file'], 322 'DEFAULTNAME_IMG'=>get_filename_wo_extension( $row['file'] ), 323 'NAME_IMG'=>$row['name'], 324 'AUTHOR_IMG'=>$row['author'], 325 'DATE_IMG'=>date_convert_back( $row['date_creation'] ), 326 'KEYWORDS_IMG'=>$row['keywords'], 327 'COMMENT_IMG'=>$row['comment'] 328 )); 329 } 330 330 331 // Virtualy associate a picture to a category 331 332 // … … 333 334 // $conf['max_LOV_categories'] 334 335 $query = 'SELECT COUNT(id) AS nb_total_categories'; 335 $query.= ' FROM '.PREFIX_TABLE.'categories'; 336 $query.= ';'; 336 $query.= ' FROM '.CATEGORIES_TABLE.';'; 337 337 $row = mysql_fetch_array( mysql_query( $query ) ); 338 338 if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] ) 339 339 { 340 $vtp->addSession( $sub, 'associate_LOV' );340 /*$vtp->addSession( $sub, 'associate_LOV' ); 341 341 $page['plain_structure'] = get_plain_structure( true ); 342 342 $structure = create_structure( '', array() ); 343 343 display_categories( $structure, ' ' ); 344 $vtp->closeSession( $sub, 'associate_LOV' ); 344 $vtp->closeSession( $sub, 'associate_LOV' );*/ 345 345 } 346 346 // else, we only display a small text field, we suppose the administrator … … 348 348 else 349 349 { 350 $vtp->addSession( $sub, 'associate_text' );351 $vtp->closeSession( $sub, 'associate_text' );350 //$vtp->addSession( $sub, 'associate_text' ); 351 //$vtp->closeSession( $sub, 'associate_text' ); 352 352 } 353 353 } 354 354 //----------------------------------------------------------- sending html code 355 $ vtp->Parse( $handle , 'sub', $sub);355 $template->assign_var_from_handle('ADMIN_CONTENT', 'infos_images'); 356 356 ?>
Note: See TracChangeset
for help on using the changeset viewer.