Changeset 27164


Ignore:
Timestamp:
02/04/14 16:13:30 (5 years ago)
Author:
JanisV
Message:

Set thumbnails for new virtual albums
Make physical albums private
Processing folder structure

Location:
extensions/physical2virtual
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/physical2virtual/admin.php

    r27147 r27164  
    55global $conf, $template, $page; 
    66 
    7 if (isset($_POST['submit'])) 
     7if (isset($_POST['submit']) or isset($_POST['convert'])) 
    88{ 
    99  $conf['physical2virtual'] = array( 
    1010    'lock_physical' => isset($_POST['lock_physical']),  
    1111    'private_physical' => isset($_POST['private_physical']),  
     12    'store_structure' => isset($_POST['store_structure']),  
    1213    ); 
    1314  if (isset($_POST['parent_cat']) and $_POST['parent_cat'] > 0) 
    1415    $conf['physical2virtual']['parent_cat'] = $_POST['parent_cat']; 
    1516 
    16   conf_update_param('physical2virtual', serialize($conf['physical2virtual'])); 
    17   $page['infos'][] = l10n('Information data registered in database'); 
    18 } 
    19 if (isset($_POST['convert'])) 
    20 { 
    21   $conf['physical2virtual']['lock_physical'] = isset($_POST['lock_physical']); 
    22   $conf['physical2virtual']['private_physical'] = isset($_POST['private_physical']); 
    23   if (isset($_POST['parent_cat']) and $_POST['parent_cat'] > 0) 
    24     $conf['physical2virtual']['parent_cat'] = $_POST['parent_cat']; 
    25  
    26   physical2virtual_convert(); 
    27   $page['infos'][] = l10n('Convertion done'); 
     17  if (isset($_POST['submit'])) 
     18  { 
     19    conf_update_param('physical2virtual', serialize($conf['physical2virtual'])); 
     20    $page['infos'][] = l10n('Information data registered in database'); 
     21  } 
     22  if (isset($_POST['convert'])) 
     23  { 
     24    physical2virtual_convert(); 
     25    $page['infos'][] = l10n('Convertion done'); 
     26  } 
    2827} 
    2928 
  • extensions/physical2virtual/language/en_UK/plugin.lang.php

    r27147 r27164  
    66$lang['Convert now'] = 'Convert now'; 
    77$lang['Convertion done'] = 'Convertion done'; 
     8$lang['Store folder structure'] = 'Store folder structure'; 
    89 
    910?> 
  • extensions/physical2virtual/language/ru_RU/plugin.lang.php

    r27147 r27164  
    55$lang['Make physical albums private after converting'] = 'Делать физические альбомы приватными после конвертирования'; 
    66$lang['Convert now'] = 'Конвертировать сейчас'; 
    7 $lang['Convertion done'] = 'Конвертирование выполнено'; 
     7$lang['Store folder structure'] = 'Сохранять структуру папок'; 
    88 
    99?> 
  • extensions/physical2virtual/main.inc.php

    r27147 r27164  
    3030} 
    3131 
     32function find_or_create_virtual_category($category_name, $parent_id=null, $options=array()) 
     33{ 
     34  if (!is_null($parent_id)) 
     35  { 
     36    $sub_ids = get_subcat_ids(array($parent_id)); 
     37    foreach ($sub_ids as $id) 
     38    { 
     39      $cat_info = get_cat_info($id); 
     40      if ($cat_info['name'] == $category_name and !$cat_info['dir']) 
     41        return $cat_info; 
     42    } 
     43  } 
     44 
     45  return create_virtual_category($category_name, $parent_id, $options); 
     46} 
     47 
    3248function physical2virtual_convert() 
    3349{ 
     
    3551 
    3652  $query = ' 
    37     SELECT name 
    38     FROM '.CATEGORIES_TABLE.' 
    39     WHERE dir IS NULL 
    40   ;';  // get virtual 
    41   $virt_cats = array_from_query($query, 'name');  
    42    
    43   $query = ' 
    44     SELECT id, name 
     53    SELECT id, name, id_uppercat 
    4554    FROM '.CATEGORIES_TABLE.' 
    4655    WHERE dir IS NOT NULL 
     
    5059  { 
    5160    $virt_name = $row['name']; 
    52     $created = false; 
    53     if (!in_array($virt_name, $virt_cats)) 
     61 
     62    $parent = isset($conf['physical2virtual']['parent_cat']) ? $conf['physical2virtual']['parent_cat'] : null; 
     63         
     64    if ($conf['physical2virtual']['store_structure']) 
    5465    { 
    55       $parent = isset($conf['physical2virtual']['parent_cat']) ? $conf['physical2virtual']['parent_cat'] : null; 
    56       $virt_id = create_virtual_category($virt_name, $parent)['id']; 
    57       $created = true; 
    58  
    59       if (isset($conf['physical2virtual']['lock_physical']) and $conf['physical2virtual']['lock_physical']) 
     66      // get array of physical parents 
     67      $cat_info = get_cat_info($row['id']); 
     68      $uppers = $cat_info['upper_names']; 
     69      array_pop($uppers); // remove themself 
     70       
     71      foreach ($uppers as $upper) 
    6072      { 
    61         $cat_info = get_cat_info($row['id']); 
    62         if ($cat_info['visible'] == true) 
    63         { 
    64           set_cat_visible(array($row['id']), false); 
    65         } 
    66       } 
    67       if (isset($conf['physical2virtual']['private_physical']) and $conf['physical2virtual']['private_physical']) 
    68       { 
    69         set_cat_status(array($row['id']), 'private');  
     73        $parent = find_or_create_virtual_category($upper['name'], $parent)['id']; 
    7074      } 
    7175    } 
    72     else 
     76 
     77    $virt_cat = find_or_create_virtual_category($virt_name, $parent); 
     78//    $virt_cat = create_virtual_category($virt_name, $parent)['id']; // use this for duplicate folders name 
     79 
     80    if (isset($conf['physical2virtual']['lock_physical']) and $conf['physical2virtual']['lock_physical']) 
    7381    { 
    74       // Get existen virt category ID 
    75       $query = ' 
    76         SELECT id FROM '.CATEGORIES_TABLE.' WHERE dir IS NULL AND name = \''.pwg_db_real_escape_string($virt_name).'\' 
    77       ;'; 
    78       list($virt_id) = pwg_db_fetch_row(pwg_query($query)); 
     82      $cat_info = get_cat_info($row['id']); 
     83      if ($cat_info['visible'] == true) 
     84      { 
     85        set_cat_visible(array($row['id']), false); 
     86      } 
     87    } 
     88    if (isset($conf['physical2virtual']['private_physical']) and $conf['physical2virtual']['private_physical']) 
     89    { 
     90      set_cat_status(array($row['id']), 'private');  
    7991    } 
    8092 
    8193    $query = ' 
    8294      INSERT IGNORE INTO '.IMAGE_CATEGORY_TABLE.' (category_id, image_id) 
    83         SELECT '.$virt_id.', image_id FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$row['id'].' 
     95        SELECT '.$virt_cat['id'].', image_id FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$row['id'].' 
    8496    ;'; 
    8597    pwg_query($query); 
    8698 
    87     if ($created) 
     99    if (!(isset($virt_cat['representative_picture_id']) and $virt_cat['representative_picture_id'])) 
    88100    { 
    89       set_random_representant(array($virt_id)); 
     101      set_random_representant(array($virt_cat['id'])); 
    90102    } 
    91103  } 
  • extensions/physical2virtual/maintain.inc.php

    r27147 r27164  
    2020    'update_timeout' => 3, 
    2121    'last_update' => 0, 
     22    'store_structure' => true, 
    2223  ); 
    2324 
  • extensions/physical2virtual/template/admin.tpl

    r27147 r27164  
    2929    </label> 
    3030  </li> 
     31  <li> 
     32    <input type="checkbox" id="store_structure" name="store_structure"{if $physical2virtual.store_structure} checked="checked"{/if}> 
     33    <label for="store_structure"> 
     34      <b>{'Store folder structure'|@translate}</b> 
     35    </label> 
     36  </li> 
    3137</ul> 
    3238</fieldset> 
Note: See TracChangeset for help on using the changeset viewer.