Changeset 27164
- Timestamp:
- Feb 4, 2014, 4:13:30 PM (10 years ago)
- Location:
- extensions/physical2virtual
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/physical2virtual/admin.php
r27147 r27164 5 5 global $conf, $template, $page; 6 6 7 if (isset($_POST['submit']) )7 if (isset($_POST['submit']) or isset($_POST['convert'])) 8 8 { 9 9 $conf['physical2virtual'] = array( 10 10 'lock_physical' => isset($_POST['lock_physical']), 11 11 'private_physical' => isset($_POST['private_physical']), 12 'store_structure' => isset($_POST['store_structure']), 12 13 ); 13 14 if (isset($_POST['parent_cat']) and $_POST['parent_cat'] > 0) 14 15 $conf['physical2virtual']['parent_cat'] = $_POST['parent_cat']; 15 16 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 } 28 27 } 29 28 -
extensions/physical2virtual/language/en_UK/plugin.lang.php
r27147 r27164 6 6 $lang['Convert now'] = 'Convert now'; 7 7 $lang['Convertion done'] = 'Convertion done'; 8 $lang['Store folder structure'] = 'Store folder structure'; 8 9 9 10 ?> -
extensions/physical2virtual/language/ru_RU/plugin.lang.php
r27147 r27164 5 5 $lang['Make physical albums private after converting'] = 'Делать физические альбомы приватными после конвертирования'; 6 6 $lang['Convert now'] = 'Конвертировать сейчас'; 7 $lang[' Convertion done'] = 'Конвертирование выполнено';7 $lang['Store folder structure'] = 'Сохранять структуру папок'; 8 8 9 9 ?> -
extensions/physical2virtual/main.inc.php
r27147 r27164 30 30 } 31 31 32 function 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 32 48 function physical2virtual_convert() 33 49 { … … 35 51 36 52 $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 45 54 FROM '.CATEGORIES_TABLE.' 46 55 WHERE dir IS NOT NULL … … 50 59 { 51 60 $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']) 54 65 { 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) 60 72 { 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']; 70 74 } 71 75 } 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']) 73 81 { 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'); 79 91 } 80 92 81 93 $query = ' 82 94 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'].' 84 96 ;'; 85 97 pwg_query($query); 86 98 87 if ( $created)99 if (!(isset($virt_cat['representative_picture_id']) and $virt_cat['representative_picture_id'])) 88 100 { 89 set_random_representant(array($virt_ id));101 set_random_representant(array($virt_cat['id'])); 90 102 } 91 103 } -
extensions/physical2virtual/maintain.inc.php
r27147 r27164 20 20 'update_timeout' => 3, 21 21 'last_update' => 0, 22 'store_structure' => true, 22 23 ); 23 24 -
extensions/physical2virtual/template/admin.tpl
r27147 r27164 29 29 </label> 30 30 </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> 31 37 </ul> 32 38 </fieldset>
Note: See TracChangeset
for help on using the changeset viewer.