#4569 - Script to transition IOTDs to galleries
| Identifier | #4569 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Script to transition IOTDs to galleries |
| Status | Open |
| Handling member | Deleted |
| Addon | General / Uncategorised |
| Description | In v11 the iotds addon will be no longer available, at least officially. It's recommended people move to galleries and just randomise a gallery image.
Create some migration script. Below is one I wrote for a client people could repurpose. It makes assumptions, esp that content translation is disabled. |
| Steps to reproduce | |
| Additional information | require_code('galleries2');
$test = $GLOBALS['SITE_DB']->query_select_value_if_there('galleries', 'name', array('name' => 'iotds')); if ($test === null) { add_gallery('iotds', 'Images of the day', 'Images of the day (prior to ' . date('Y/m/d') . ' upgrade).', '', 'root'); } $forum = get_option('comments_forum_name'); $max = 10; $start = 0; do { $iotds = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array(), 'ORDER BY id', $max, $start); foreach ($iotds as $iotd) { $url = $iotd['url']; $thumb_url = $iotd['thumb_url']; foreach (array(&$url, &$thumb_url) as &$_url) { if (preg_match('#^uploads/iotds(_addon)?/#', $_url) != 0) { $old_path = get_custom_file_base() . '/' . urldecode($_url); $i = 0; do { $_url = preg_replace('#[\d_]*(\.\w+)$#', (($i == 0) ? '' : ('_' . strval($i))) . '$1', $_url); $new_path = get_custom_file_base() . '/' . urldecode(preg_replace('#^uploads/iotds(_addon)?/#', 'uploads/galleries/', $_url)); $i++; } while (file_exists($new_path)); rename($old_path, $new_path); } } $insert_map = array( 'cat' => 'iotds', 'url' => $url, 'thumb_url' => $thumb_url, 'allow_rating' => $iotd['allow_rating'], 'allow_comments' => $iotd['allow_comments'], 'allow_trackbacks' => $iotd['allow_trackbacks'], 'notes' => $iotd['notes'], 'submitter' => $iotd['submitter'], 'validated' => 1, 'add_date' => $iotd['add_date'], 'edit_date' => $iotd['edit_date'], 'image_views' => $iotd['iotd_views'], 'description' => $iotd['caption'], 'title' => $iotd['i_title'], ); if (!multi_lang_content()) { $insert_map += array( 'description__text_parsed' => $iotd['caption__text_parsed'], 'description__source_user' => $iotd['caption__source_user'], ); } $id = $GLOBALS['SITE_DB']->query_insert('images', $insert_map, true); if (get_forum_type() == 'cns') { $topic_id = $GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, 'iotds_' . strval($iotd['id']), do_lang('COMMENT')); if ($topic_id !== null) { $new_description = do_lang('COMMENT') . ': #iotds_' . strval($iotd['id']); $GLOBALS['FORUM_DB']->query_update('f_topics', array('t_description' => $new_description), array('id' => $topic_id), '', 1); } } } $start += $max; } while (!empty($iotds)); $GLOBALS['SITE_DB']->query_delete('iotd'); |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".
Comments
There have been no comments yet