Changeset 27330
- Timestamp:
- Feb 11, 2014, 1:25:40 PM (10 years ago)
- Location:
- extensions/physical2virtual
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/physical2virtual/language/ru_RU/plugin.lang.php
r27229 r27330 5 5 $lang['Make physical albums private after converting'] = 'Делать физические альбомы приватными после конвертирования'; 6 6 $lang['Convert now'] = 'Конвертировать сейчас'; 7 $lang['Convertion done'] = 'Конвертирование выполнено'; 7 8 $lang['Store folder structure'] = 'Сохранять структуру папок'; 8 9 $lang['Unlock new virtual albums when possible'] = 'Разблокировать новые виртуальные альбомы когда возможно'; -
extensions/physical2virtual/main.inc.php
r27229 r27330 2 2 /* 3 3 Plugin Name: physical2virtual 4 Version: 2.6. d4 Version: 2.6.e 5 5 Description: Autoconvert physical albums to virtual 6 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=730 … … 10 10 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 11 11 12 global $prefixeTable; 13 12 14 define('PHYSICAL2VIRTUAL_ID', basename(dirname(__FILE__))); 13 15 define('PHYSICAL2VIRTUAL_PATH' , PHPWG_PLUGINS_PATH . PHYSICAL2VIRTUAL_ID . '/'); 14 16 define('PHYSICAL2VIRTUAL_ADMIN', get_root_url() . 'admin.php?page=plugin-' . PHYSICAL2VIRTUAL_ID); 17 define('PHY2VIRT_CATEGORIES_TABLE', $prefixeTable . 'phy2virt_categories'); 15 18 16 19 add_event_handler('init', 'physical2virtual_init'); … … 31 34 } 32 35 33 function find_or_create_virtual_category($ category_name, $parent_id=null, $options=array())36 function find_or_create_virtual_category($phy_category, $parent_id=null, $options=array()) 34 37 { 38 $query = ' 39 SELECT DISTINCT virt_category_id AS id 40 FROM '.PHY2VIRT_CATEGORIES_TABLE.' 41 WHERE phy_category_id = '.$phy_category['id'].' 42 ;'; 43 $virt_category = pwg_db_fetch_assoc(pwg_query($query)); 44 if (!empty($virt_category)) 45 { 46 return $virt_category; /// add $virt_cat['representative_picture_id'] 47 } 48 49 $category_name = $phy_category['name']; 35 50 // process empty album name 36 51 if (preg_match('/^\s*$/', $category_name)) … … 50 65 } 51 66 52 return create_virtual_category($category_name, $parent_id, $options); 67 $cat = create_virtual_category($category_name, $parent_id, $options); 68 $insert = array( 69 'phy_category_id' => $phy_category['id'], 70 'virt_category_id' => $cat['id'], 71 // 'updated' => date('Y-m-d H:i:s'), 72 ); 73 single_insert(PHY2VIRT_CATEGORIES_TABLE, $insert); 74 75 return $cat; 53 76 } 54 77 … … 62 85 $options['inherit'] = $conf['physical2virtual']['inherit']; 63 86 87 // Remove virtual without physical 88 $query = ' 89 SELECT virt_category_id 90 FROM '.PHY2VIRT_CATEGORIES_TABLE.' 91 WHERE phy_category_id NOT IN ( 92 SELECT cat.id 93 FROM '.CATEGORIES_TABLE.' cat 94 WHERE cat.dir IS NOT NULL 95 ) 96 ;'; 97 $category_ids = array_from_query($query, 'virt_category_id'); 98 delete_categories($category_ids); 99 100 $query = ' 101 DELETE FROM '.PHY2VIRT_CATEGORIES_TABLE.' 102 WHERE phy_category_id NOT IN ( 103 SELECT cat.id 104 FROM '.CATEGORIES_TABLE.' cat 105 WHERE cat.dir IS NOT NULL 106 ) 107 ;'; 108 pwg_query($query); 109 64 110 $query = ' 65 111 SELECT id, name, id_uppercat … … 70 116 while ($row = pwg_db_fetch_assoc($result)) 71 117 { 72 $virt_name = $row['name'];73 74 118 $parent = isset($conf['physical2virtual']['parent_cat']) ? $conf['physical2virtual']['parent_cat'] : null; 75 119 … … 83 127 foreach ($uppers as $upper) 84 128 { 85 $parent = find_or_create_virtual_category($upper ['name'], $parent, $options)['id'];129 $parent = find_or_create_virtual_category($upper, $parent, $options)['id']; 86 130 } 87 131 } 88 132 89 $virt_cat = find_or_create_virtual_category($virt_name, $parent, $options); 90 // $virt_cat = create_virtual_category($virt_name, $parent, $options); // use this for duplicate folders name 133 $virt_cat = find_or_create_virtual_category($row, $parent, $options); 91 134 92 135 if (isset($conf['physical2virtual']['lock_physical']) and $conf['physical2virtual']['lock_physical']) … … 106 149 INSERT IGNORE INTO '.IMAGE_CATEGORY_TABLE.' (category_id, image_id) 107 150 SELECT '.$virt_cat['id'].', image_id FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$row['id'].' 151 ;'; 152 pwg_query($query); 153 154 $query = ' 155 UPDATE '.PHY2VIRT_CATEGORIES_TABLE.' 156 SET updated = NOW() 157 WHERE virt_category_id = '.$virt_cat['id'].' 108 158 ;'; 109 159 pwg_query($query); -
extensions/physical2virtual/maintain.inc.php
r27229 r27330 27 27 function __construct($plugin_id) 28 28 { 29 global $prefixeTable; 30 29 31 parent::__construct($plugin_id); 32 33 $this->table = $prefixeTable . 'phy2virt_categories'; 30 34 } 31 35 32 36 function install($plugin_version, &$errors=array()) 33 37 { 34 global $conf ;38 global $conf, $prefixeTable; 35 39 36 40 if (empty($conf['physical2virtual'])) … … 47 51 } 48 52 53 // new table 54 pwg_query( 55 'CREATE TABLE IF NOT EXISTS `' . $this->table . '` ( 56 `phy_category_id` smallint(5) unsigned NOT NULL, 57 `virt_category_id` smallint(5) unsigned NOT NULL, 58 `updated` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00", 59 KEY `phy_category_id` (`phy_category_id`) 60 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 61 ;'); 62 49 63 $this->installed = true; 50 64 } … … 65 79 { 66 80 conf_delete_param('physical2virtual'); 81 82 pwg_query('DROP TABLE `' . $this->table . '`;'); 67 83 } 68 84 }
Note: See TracChangeset
for help on using the changeset viewer.