Changeset 393 for trunk/admin/update.php


Ignore:
Timestamp:
Mar 20, 2004, 1:52:37 AM (20 years ago)
Author:
gweltas
Message:
  • Template migration
  • Admin Control Panel migration
  • Language migration
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/update.php

    r362 r393  
    2626// +-----------------------------------------------------------------------+
    2727
    28 include_once( './admin/include/isadmin.inc.php' );
     28include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
    2929//------------------------------------------------------------------- functions
    3030function insert_local_category( $id_uppercat )
     
    3636
    3737  // 0. retrieving informations on the category to display
    38   $cat_directory = './galleries';
     38  $cat_directory = PHPWG_ROOT_PATH.'galleries';
    3939  if ( is_numeric( $id_uppercat ) )
    4040  {
    41     $query = 'SELECT name,uppercats,dir';
    42     $query.= ' FROM '.PREFIX_TABLE.'categories';
     41    $query = 'SELECT name,uppercats,dir FROM '.CATEGORIES_TABLE;
    4342    $query.= ' WHERE id = '.$id_uppercat;
    4443    $query.= ';';
     
    5352
    5453    $database_dirs = array();
    55     $query = 'SELECT id,dir';
    56     $query.= ' FROM '.PREFIX_TABLE.'categories';
     54    $query = 'SELECT id,dir FROM '.CATEGORIES_TABLE;
    5755    $query.= ' WHERE id IN ('.$uppercats.')';
    5856    $query.= ';';
     
    6967
    7068    // 1. display the category name to update
    71     $src = './template/'.$user['template'].'/admin/images/puce.gif';
    72     $output = '<img src="'.$src.'" alt="&gt;" />';
    73     $output.= '<span style="font-weight:bold;">'.$name.'</span>';
     69    $output = '<ul class="menu">';
     70    $output.= '<li><strong>'.$name.'</strong>';
    7471    $output.= ' [ '.$dir.' ]';
    75     $output.= '<div class="retrait">';
     72    $output.= '</li>';
    7673
    7774    // 2. we search pictures of the category only if the update is for all
     
    8683
    8784  $sub_category_dirs = array();
    88   $query = 'SELECT id,dir';
    89   $query.= ' FROM '.PREFIX_TABLE.'categories';
     85  $query = 'SELECT id,dir FROM '.CATEGORIES_TABLE;
    9086  $query.= ' WHERE site_id = 1';
    9187  if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
     
    135131  if ( count( $inserts ) > 0 )
    136132  {
    137     $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
     133    $query = 'INSERT INTO '.CATEGORIES_TABLE;
    138134    $query.= ' (dir,name,site_id,id_uppercat,uppercats) VALUES ';
    139135    $query.= implode( ',', $inserts );
     
    141137    mysql_query( $query );
    142138    // updating uppercats field
    143     $query = 'UPDATE '.PREFIX_TABLE.'categories';
     139    $query = 'UPDATE '.CATEGORIES_TABLE;
    144140    $query.= ' SET uppercats = ';
    145141    if ( $uppercats != '' ) $query.= "CONCAT('".$uppercats."',',',id)";
     
    154150  // Recursive call on the sub-categories (not virtual ones)
    155151  $query = 'SELECT id';
    156   $query.= ' FROM '.PREFIX_TABLE.'categories';
     152  $query.= ' FROM '.CATEGORIES_TABLE;
    157153  $query.= ' WHERE site_id = 1';
    158154  if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
     
    168164  if ( is_numeric( $id_uppercat ) )
    169165  {
    170     $output.= '</div>';
     166    $output.= '</ul>';
    171167  }
    172168  return $output;
     
    188184  //     - don't have the associated thumbnail available anymore
    189185  $query = 'SELECT id,file,tn_ext';
    190   $query.= ' FROM '.PREFIX_TABLE.'images';
     186  $query.= ' FROM '.IMAGES_TABLE;
    191187  $query.= ' WHERE storage_category_id = '.$category_id;
    192188  $query.= ';';
     
    218214
    219215  $registered_pictures = array();
    220   $query = 'SELECT file';
    221   $query.= ' FROM '.PREFIX_TABLE.'images';
     216  $query = 'SELECT file FROM '.IMAGES_TABLE;
    222217  $query.= ' WHERE storage_category_id = '.$category_id;
    223218  $query.= ';';
     
    234229 
    235230  $query = 'SELECT file,infos,validated';
    236   $query.= ' FROM '.PREFIX_TABLE.'waiting';
     231  $query.= ' FROM '.WAITING_TABLE;
    237232  $query.= ' WHERE storage_category_id = '.$category_id;
    238233  $query.= ';';
     
    294289
    295290          // deleting the waiting element
    296           $query = 'DELETE FROM '.PREFIX_TABLE.'waiting';
     291          $query = 'DELETE FROM '.WAITING_TABLE;
    297292          $query.= " WHERE file = '".$unregistered_picture."'";
    298293          $query.= ' AND storage_category_id = '.$category_id;
     
    337332  {
    338333    // inserts all found pictures
    339     $query = 'INSERT INTO '.PREFIX_TABLE.'images';
     334    $query = 'INSERT INTO '.IMAGES_TABLE;
    340335    $query.= ' (file,storage_category_id,date_available,tn_ext';
    341336    $query.= ',filesize,width,height';
     
    350345
    351346    $query = 'SELECT id';
    352     $query.= ' FROM '.PREFIX_TABLE.'images';
     347    $query.= ' FROM '.IMAGES_TABLE;
    353348    $query.= ' WHERE storage_category_id = '.$category_id;
    354349    $query.= ';';
     
    361356    // recreation of the links between this storage category pictures and
    362357    // its storage category
    363     $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
     358    $query = 'DELETE FROM '.IMAGE_CATEGORY_TABLE;
    364359    $query.= ' WHERE category_id = '.$category_id;
    365360    $query.= ' AND image_id IN ('.implode( ',', $ids ).')';
     
    367362    mysql_query( $query );
    368363
    369     $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
     364    $query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE;
    370365    $query.= '(category_id,image_id) VALUES ';
    371366    foreach ( $ids as $num => $image_id ) {
     
    396391
    397392  // 2. is the site already existing ?
    398   $query = 'SELECT id';
    399   $query.= ' FROM '.PREFIX_TABLE.'sites';
     393  $query = 'SELECT id FROM '.SITES_TABLE;
    400394  $query.= " WHERE galleries_url = '".$url."'";
    401395  $query.= ';';
     
    404398  {
    405399    // we have to register this site in the database
    406     $query = 'INSERT INTO '.PREFIX_TABLE.'sites';
     400    $query = 'INSERT INTO '.SITES_TABLE;
    407401    $query.= " (galleries_url) VALUES ('".$url."')";
    408402    $query.= ';';
     
    438432  {
    439433    $query = 'SELECT name,uppercats,dir';
    440     $query.= ' FROM '.PREFIX_TABLE.'categories';
     434    $query.= ' FROM '.CATEGORIES_TABLE;
    441435    $query.= ' WHERE id = '.$id_uppercat;
    442436    $query.= ';';
     
    468462  // id_uppercat and site_id
    469463  $database_dirs = array();
    470   $query = 'SELECT id,dir';
    471   $query.= ' FROM '.PREFIX_TABLE.'categories';
     464  $query = 'SELECT id,dir FROM '.CATEGORIES_TABLE;
    472465  $query.= ' WHERE site_id = '.$site_id;
    473466  if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
     
    509502  if ( count( $inserts ) > 0 )
    510503  {
    511     $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
     504    $query = 'INSERT INTO '.CATEGORIES_TABLE;
    512505    $query.= ' (dir,name,site_id,id_uppercat,uppercats) VALUES ';
    513506    $query.= implode( ',', $inserts );
     
    515508    mysql_query( $query );
    516509    // updating uppercats field
    517     $query = 'UPDATE '.PREFIX_TABLE.'categories';
     510    $query = 'UPDATE '.CATEGORIES_TABLE;
    518511    $query.= ' SET uppercats = ';
    519512    if ( $uppercats != '' ) $query.= "CONCAT('".$uppercats."',',',id)";
     
    528521  // Recursive call on the sub-categories (not virtual ones)
    529522  $query = 'SELECT id,dir';
    530   $query.= ' FROM '.PREFIX_TABLE.'categories';
     523  $query.= ' FROM '.CATEGORIES_TABLE;
    531524  $query.= ' WHERE site_id = '.$site_id;
    532525  if (!is_numeric($id_uppercat)) $query.= ' AND id_uppercat IS NULL';
     
    568561  // we have to delete all the images from the database that are not in the
    569562  // directory anymore (not in the XML anymore)
    570   $query = 'SELECT id,file';
    571   $query.= ' FROM '.PREFIX_TABLE.'images';
     563  $query = 'SELECT id,file FROM '.IMAGES_TABLE;
    572564  $query.= ' WHERE storage_category_id = '.$category_id;
    573565  $query.= ';';
     
    585577
    586578  $database_pictures = array();
    587   $query = 'SELECT file';
    588   $query.= ' FROM '.PREFIX_TABLE.'images';
     579  $query = 'SELECT file FROM '.IMAGES_TABLE;
    589580  $query.= ' WHERE storage_category_id = '.$category_id;
    590581  $query.= ';';
     
    631622  {
    632623    // inserts all found pictures
    633     $query = 'INSERT INTO '.PREFIX_TABLE.'images';
     624    $query = 'INSERT INTO '.IMAGES_TABLE;
    634625    $query.= ' (file,storage_category_id,date_available,tn_ext';
    635626    $query.= ',filesize,width,height)';
     
    642633    $ids = array();
    643634
    644     $query = 'SELECT id';
    645     $query.= ' FROM '.PREFIX_TABLE.'images';
     635    $query = 'SELECT id FROM '.IMAGES_TABLE;
    646636    $query.= ' WHERE storage_category_id = '.$category_id;
    647637    $query.= ';';
     
    654644    // recreation of the links between this storage category pictures and
    655645    // its storage category
    656     $query = 'DELETE FROM '.PREFIX_TABLE.'image_category';
     646    $query = 'DELETE FROM '.IMAGE_CATEGORY_TABLE;
    657647    $query.= ' WHERE category_id = '.$category_id;
    658648    $query.= ' AND image_id IN ('.implode( ',', $ids ).')';
     
    660650    mysql_query( $query );
    661651
    662     $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
     652    $query = 'INSERT INTO '.IMAGE_CATEGORY_TABLE;
    663653    $query.= '(category_id,image_id) VALUES ';
    664654    foreach ( $ids as $num => $image_id ) {
     
    672662  return $output;
    673663}
     664
    674665//----------------------------------------------------- template initialization
    675 $sub = $vtp->Open( './template/'.$user['template'].'/admin/update.vtp' );
    676 $tpl = array( 'update_default_title', 'update_only_cat', 'update_all',
    677               'update_research_conclusion', 'update_deletion_conclusion',
    678               'remote_site', 'update_part_research' );
    679 templatize_array( $tpl, 'lang', $sub );
    680 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
     666$template->set_filenames( array('update'=>'admin/update.tpl') );
     667
     668$template->assign_vars(array(
     669  'L_UPDATE_TITLE'=>$lang['update_default_title'],
     670  'L_CAT_UPDATE'=>$lang['update_only_cat'],
     671  'L_ALL_UPDATE'=>$lang['update_all'],
     672  'L_RESULT_UPDATE'=>$lang['update_part_research'],
     673  'L_NEW_CATEGORY'=>$lang['update_research_conclusion'],
     674  'L_DEL_CATEGORY'=>$lang['update_deletion_conclusion'],
     675 
     676  'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update=cats' ),
     677  'U_ALL_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update=all' )
     678  ));
     679 
     680$tpl = array('remote_site');
    681681//-------------------------------------------- introduction : choices of update
    682682// Display choice if "update" var is not specified
    683683if (!isset( $_GET['update'] ))
    684684{
    685   $vtp->addSession( $sub, 'introduction' );
    686   // only update the categories, not the pictures.
    687   $url = add_session_id( './admin.php?page=update&amp;update=cats' );
    688   $vtp->setVar( $sub, 'introduction.only_cat:url', $url );
    689   // update the entire tree folder
    690   $url = add_session_id( './admin.php?page=update&amp;update=all' );
    691   $vtp->setVar( $sub, 'introduction.all:url', $url );
    692   $vtp->closeSession( $sub, 'introduction' );
     685 $template->assign_block_vars('introduction',array());
    693686}
    694687//-------------------------------------------------- local update : ./galleries
     
    699692  $count_new = 0;
    700693  $count_deleted = 0;
    701   $vtp->addSession( $sub, 'local_update' );
     694 
    702695  if ( isset( $page['cat'] ) )
    703696  {
     
    709702  }
    710703  $end = get_moment();
    711   echo get_elapsed_time( $start, $end ).' for update <br />';
    712   $vtp->setVar( $sub, 'local_update.categories', $categories );
    713   $vtp->setVar( $sub, 'local_update.count_new', $count_new );
    714   $vtp->setVar( $sub, 'local_update.count_deleted', $count_deleted );
    715   $vtp->closeSession( $sub, 'local_update' );
     704  //echo get_elapsed_time( $start, $end ).' for update <br />';
     705  $template->assign_block_vars('update',array(
     706    'CATEGORIES'=>$categories,
     707        'NEW_CAT'=>$count_new,
     708        'DEL_CAT'=>$count_deleted
     709    ));
    716710}
    717711//------------------------------------------------- remote update : listing.xml
     
    735729if ( isset( $_GET['update'] )
    736730     or isset( $page['cat'] )
    737      or @is_file( './listing.xml' ) )
     731     or @is_file( './listing.xml' ) && DEBUG)
    738732{
    739733  $start = get_moment();
     
    748742}
    749743//----------------------------------------------------------- sending html code
    750 $vtp->Parse( $handle , 'sub', $sub );
     744$template->assign_var_from_handle('ADMIN_CONTENT', 'update');
    751745?>
Note: See TracChangeset for help on using the changeset viewer.