diff options
author | gweltas <gweltas@piwigo.org> | 2004-08-29 21:22:24 +0000 |
---|---|---|
committer | gweltas <gweltas@piwigo.org> | 2004-08-29 21:22:24 +0000 |
commit | 0c482df04e1631e12db1fe99e904d6111b17adf1 (patch) | |
tree | ec090ccba9111e24f72a9a2e9f8bbb3981366400 /admin | |
parent | c714a9dbaf16a92822769ba88b2d6ee721ee5660 (diff) |
Migration of the template of images_infos.php
git-svn-id: http://piwigo.org/svn/trunk@506 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r-- | admin/infos_images.php | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/admin/infos_images.php b/admin/infos_images.php index 0cbfb54eb..ad620286f 100644 --- a/admin/infos_images.php +++ b/admin/infos_images.php @@ -51,8 +51,7 @@ if ( isset( $page['cat'] ) ) } else { - $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query = 'SELECT id FROM '.CATEGORIES_TABLE; $query.= ' WHERE id = '.$_POST['associate']; $query.= ';'; if ( mysql_num_rows( mysql_query( $query ) ) == 0 ) @@ -62,9 +61,8 @@ if ( isset( $page['cat'] ) ) $associate = false; - $query = 'SELECT id,file'; - $query.= ' FROM '.PREFIX_TABLE.'images'; - $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; + $query = 'SELECT id,file FROM '.IMAGES_TABLE; + $query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; $query.= ' WHERE category_id = '.$page['cat']; $query.= ';'; $result = mysql_query( $query ); @@ -77,9 +75,7 @@ if ( isset( $page['cat'] ) ) $keywords = 'keywords-'.$row['id']; if ( isset( $_POST[$name] ) ) { - $query = 'UPDATE '.PREFIX_TABLE.'images'; - - $query.= ' SET name = '; + $query = 'UPDATE '.IMAGES_TABLE.' SET name = '; if ( $_POST[$name] == '' ) $query.= 'NULL'; else @@ -116,7 +112,7 @@ if ( isset( $page['cat'] ) ) // add link to another category if ( isset( $_POST['check-'.$row['id']] ) and count( $errors ) == 0 ) { - $query = 'INSERT INTO '.PREFIX_TABLE.'image_category'; + $query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE; $query.= ' (image_id,category_id) VALUES'; $query.= ' ('.$row['id'].','.$_POST['associate'].')'; $query.= ';'; @@ -124,18 +120,17 @@ if ( isset( $page['cat'] ) ) $associate = true; } } - update_category( $_POST['associate'] ); + if ( isset( $_POST['associate'] )) update_category( $_POST['associate'] ); if ( $associate ) synchronize_all_users(); //------------------------------------------------------ update general options if ( isset( $_POST['use_common_author'] ) ) { - $query = 'SELECT image_id'; - $query.= ' FROM '.PREFIX_TABLE.'image_category'; + $query = 'SELECT image_id FROM '.IMAGE_CATEGORY_TABLE; $query.= ' WHERE category_id = '.$page['cat']; $result = mysql_query( $query ); while ( $row = mysql_fetch_array( $result ) ) { - $query = 'UPDATE '.PREFIX_TABLE.'images'; + $query = 'UPDATE '.IMAGES_TABLE; if ( $_POST['author_cat'] == '' ) { $query.= ' SET author = NULL'; @@ -155,13 +150,12 @@ if ( isset( $page['cat'] ) ) if ( check_date_format( $_POST['date_creation_cat'] ) ) { $date = date_convert( $_POST['date_creation_cat'] ); - $query = 'SELECT image_id'; - $query.= ' FROM '.PREFIX_TABLE.'image_category'; + $query = 'SELECT image_id FROM '.IMAGE_CATEGORY_TABLE; $query.= ' WHERE category_id = '.$page['cat']; $result = mysql_query( $query ); while ( $row = mysql_fetch_array( $result ) ) { - $query = 'UPDATE '.PREFIX_TABLE.'images'; + $query = 'UPDATE '.IMAGES_TABLE; if ( $_POST['date_creation_cat'] == '' ) { $query.= ' SET date_creation = NULL'; @@ -182,9 +176,8 @@ if ( isset( $page['cat'] ) ) } if ( isset( $_POST['common_keywords'] ) and $_POST['keywords_cat'] != '' ) { - $query = 'SELECT id,keywords'; - $query.= ' FROM '.PREFIX_TABLE.'images'; - $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; + $query = 'SELECT id,keywords FROM '.IMAGES_TABLE; + $query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; $query.= ' WHERE category_id = '.$page['cat']; $query.= ';'; $result = mysql_query( $query ); @@ -209,8 +202,7 @@ if ( isset( $page['cat'] ) ) // cleaning the keywords array, sometimes, an empty value still remain $keywords = array_remove( $keywords, '' ); // updating the picture with new keywords array - $query = 'UPDATE '.PREFIX_TABLE.'images'; - $query.= ' SET keywords = '; + $query = 'UPDATE '.IMAGES_TABLE.' SET keywords = '; if ( count( $keywords ) == 0 ) { $query.= 'NULL'; @@ -233,8 +225,8 @@ if ( isset( $page['cat'] ) ) } //--------------------------------------------------------- form initialization if( !isset( $_GET['start'] ) - or !is_numeric( $_GET['start'] ) - or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) + || !is_numeric( $_GET['start'] ) + || ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) { $page['start'] = 0; } @@ -248,41 +240,54 @@ if ( isset( $page['cat'] ) ) $page['start'] = floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page']; } - // retrieving category information - $result = get_cat_info( $page['cat'] ); - $cat['name'] = $result['name']; - $cat['nb_images'] = $result['nb_images']; + // Navigation path + $current_category = get_cat_info($_GET['cat_id']); + $url = PHPWG_ROOT_PATH.'admin.php?page=infos_images&cat_id='; + $category_path = get_cat_display_name($current_category['name'], '->', $url); + + $form_action = PHPWG_ROOT_PATH.'admin.php?page=infos_images&cat_id='.$_GET['cat_id']; + if( $page['start']) + { + $form_action.= '&start='.$_GET['start']; + } + + $nav_bar = create_navigation_bar( + $form_action, $current_category['nb_images'],$page['start'], $page['nb_image_page'], '' ); + //----------------------------------------------------- template initialization - $sub = $vtp->Open('./template/'.$user['template'].'/admin/infos_image.vtp'); - $tpl = array( 'infoimage_general','author','infoimage_useforall','submit', - 'infoimage_creation_date','infoimage_detailed','thumbnail', - 'infoimage_title','infoimage_comment', - 'infoimage_creation_date','keywords', - 'infoimage_addtoall','infoimage_removefromall', - 'infoimage_keyword_separation','infoimage_associate', - 'errors_title' ); - templatize_array( $tpl, 'lang', $sub ); - $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); +$template->set_filenames( array('infos_images'=>'admin/infos_images.tpl') ); +$template->assign_vars(array( + 'CATEGORY'=>$category_path, + 'NAV_BAR'=>$nav_bar, + + 'L_INFOS_TITLE'=>$lang['infoimage_general'], + 'L_AUTHOR'=>$lang['author'], + 'L_INFOS_OVERALL_USE'=>$lang['infoimage_useforall'], + 'L_INFOS_CREATION_DATE'=>$lang['infoimage_creation_date'], + 'L_KEYWORD'=>$lang['keywords'], + 'L_KEYWORD_SEPARATION'=>$lang['infoimage_keyword_separation'], + 'L_INFOS_ADDTOALL'=>$lang['infoimage_addtoall'], + 'L_INFOS_REMOVEFROMALL'=>$lang['infoimage_removefromall'], + 'L_INFOS_DETAIL'=>$lang['infoimage_detailed'], + 'L_THUMBNAIL'=>$lang['thumbnail'], + 'L_INFOS_IMG'=>$lang['infoimage_title'], + 'L_INFOS_COMMENT'=>$lang['comment'], + 'L_INFOS_ASSOCIATE'=>$lang['infoimage_associate'], + 'L_SUBMIT'=>$lang['submit'], + + 'F_ACTION'=>add_session_id($form_action) + )); + //-------------------------------------------------------------- errors display -if ( count( $errors ) != 0 ) +if ( sizeof( $errors ) != 0 ) { - $vtp->addSession( $sub, 'errors' ); - foreach ( $errors as $error ) { - $vtp->addSession( $sub, 'li' ); - $vtp->setVar( $sub, 'li.content', $error ); - $vtp->closeSession( $sub, 'li' ); + $template->assign_block_vars('errors',array()); + for ( $i = 0; $i < sizeof( $errors ); $i++ ) + { + $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); } - $vtp->closeSession( $sub, 'errors' ); } //------------------------------------------------------------------------ form - $url = './admin.php?page=infos_images&cat_id='.$page['cat']; - $url.= '&start='.$page['start']; - $vtp->setVar( $sub, 'form_action', add_session_id( $url ) ); - $page['navigation_bar'] = create_navigation_bar( - $url, $cat['nb_images'],$page['start'], $page['nb_image_page'], '' ); - $vtp->setVar( $sub, 'navigation_bar', $page['navigation_bar'] ); - $cat_name = get_cat_display_name( $cat['name'], ' - ', 'font-style:italic;'); - $vtp->setVar( $sub, 'cat_name', $cat_name ); $array_cat_directories = array(); @@ -290,9 +295,8 @@ if ( count( $errors ) != 0 ) ,'date_creation','keywords','storage_category_id' ,'category_id' ); - $query = 'SELECT '.implode( ',', $infos ); - $query.= ' FROM '.PREFIX_TABLE.'images'; - $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id'; + $query = 'SELECT * FROM '.IMAGES_TABLE; + $query.= ' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; $query.= ' WHERE category_id = '.$page['cat']; $query.= $conf['order_by']; $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page']; @@ -301,56 +305,52 @@ if ( count( $errors ) != 0 ) while ( $row = mysql_fetch_array( $result ) ) { foreach ($infos as $info) { if (!isset($row[$info])) $row[$info] = ''; } - - $vtp->addSession( $sub, 'picture' ); - $vtp->setVar( $sub, 'picture.id', $row['id'] ); - $vtp->setVar( $sub, 'picture.filename', $row['file'] ); - $vtp->setVar( $sub, 'picture.name', $row['name'] ); - $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'] ) ); - $file = get_filename_wo_extension( $row['file'] ); - $vtp->setVar( $sub, 'picture.default_name', $file ); - // creating url to thumbnail - if ( !isset( $array_cat_directories[$row['storage_category_id']] ) ) + if ( !isset( $array_cat_directories[$row['storage_category_id']] ) ) { $array_cat_directories[$row['storage_category_id']] = get_complete_dir( $row['storage_category_id'] ); } $thumbnail_url = $array_cat_directories[$row['storage_category_id']]; $thumbnail_url.= 'thumbnail/'; - $thumbnail_url.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext']; - $vtp->setVar( $sub, 'picture.thumbnail_url', $thumbnail_url ); - $url = './admin.php?page=picture_modify&image_id='.$row['id']; - $vtp->setVar( $sub, 'picture.url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'picture' ); + $thumbnail_url.= $conf['prefix_thumbnail'].get_filename_wo_extension( $row['file'] ).".".$row['tn_ext']; + + $template->assign_block_vars('picture' ,array( + 'ID_IMG'=>$row['id'], + 'URL_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=picture_modify&image_id='.$row['id'] ), + 'TN_URL_IMG'=>$thumbnail_url, + 'FILENAME_IMG'=>$row['file'], + 'DEFAULTNAME_IMG'=>get_filename_wo_extension( $row['file'] ), + 'NAME_IMG'=>$row['name'], + 'AUTHOR_IMG'=>$row['author'], + 'DATE_IMG'=>date_convert_back( $row['date_creation'] ), + 'KEYWORDS_IMG'=>$row['keywords'], + 'COMMENT_IMG'=>$row['comment'] + )); } + // Virtualy associate a picture to a category // // We only show a List Of Values if the number of categories is less than // $conf['max_LOV_categories'] $query = 'SELECT COUNT(id) AS nb_total_categories'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ';'; + $query.= ' FROM '.CATEGORIES_TABLE.';'; $row = mysql_fetch_array( mysql_query( $query ) ); if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] ) { - $vtp->addSession( $sub, 'associate_LOV' ); + /*$vtp->addSession( $sub, 'associate_LOV' ); $page['plain_structure'] = get_plain_structure( true ); $structure = create_structure( '', array() ); display_categories( $structure, ' ' ); - $vtp->closeSession( $sub, 'associate_LOV' ); + $vtp->closeSession( $sub, 'associate_LOV' );*/ } // else, we only display a small text field, we suppose the administrator // knows the id of its category else { - $vtp->addSession( $sub, 'associate_text' ); - $vtp->closeSession( $sub, 'associate_text' ); + //$vtp->addSession( $sub, 'associate_text' ); + //$vtp->closeSession( $sub, 'associate_text' ); } } //----------------------------------------------------------- sending html code -$vtp->Parse( $handle , 'sub', $sub ); +$template->assign_var_from_handle('ADMIN_CONTENT', 'infos_images'); ?> |