Dotclear

Changeset 3048


Ignore:
Timestamp:
05/30/11 07:29:18 (12 years ago)
Author:
dolmen
Message:

Use new options to help custom migrations for people who want to keep
DC1 and DC2 side-by site until the migration is finished: it's better
if you can build your .htaccess while keeping the the old DC1 blog.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/dc1redirect/index.php

    r3017 r3048  
    119119 
    120120$url = $core->blog->url; 
    121 preg_match('|^([a-z]{3,}://).*?(/.*)$|',$url,$matches); 
     121preg_match('|^([a-z]{3,}://)[^/]*(.*?)/?$|',$url,$matches); 
    122122$proto = $matches[1]; 
    123 $path = $matches[2]; 
     123$path_dc1 = $path_dc2 = $matches[2]; 
     124if ($core->blog->settings->dc1redirect->dc1_old_url) { 
     125    $path_dc1 = $core->blog->settings->dc1redirect->dc1_old_url; 
     126} 
     127 
     128# The old DotClear directory where rss.php/atom.php and images were located 
     129$path_dc1_dc = $core->blog->settings->dc1redirect->dc1_old_dc_url; 
     130if (empty($path_dc1_dc)) { 
     131    $path_dc1_dc = dirname($core->blog->settings->system->public_url); 
     132} 
     133 
    124134 
    125135# Template for DC1 feeds PHP script replacement 
     
    130140// Created manually following plugin 'dc1redirect' instructions 
    131141 
    132 \$url = '$proto'.\$_SERVER['HTTP_HOST'].'${path}feed'; 
     142\$url = '$proto'.\$_SERVER['HTTP_HOST'].'${path_dc2}/feed'; 
    133143 
    134144if (!empty(\$_GET['lang'])) { 
     
    172182     $t_dc1 = 'tag/'.str2url($t); 
    173183 
    174      if ($t_dc2 != $t_dc1) { 
    175           $tags_htaccess[] = "RedirectPermanent $path$t_dc1 $url$t_dc2"; 
     184     if ("$path_dc2/$t_dc2" != "$path_dc1/$t_dc1") { 
     185          $tags_htaccess[] = "RedirectPermanent $path_dc1/$t_dc1 $url$t_dc2"; 
    176186     } else { 
    177187          $tags_htaccess[] = "# $t => $t_dc2"; 
     
    181191$tags_htaccess = implode("\n", $tags_htaccess); 
    182192 
     193# Prepare categories redirections 
     194$categories = $core->blog->getCategories(array('post_type' => 'post'))->rows(); 
     195 
     196$categories = array_unique( 
     197          array_map( 
     198               create_function('$c', "return \$c['cat_url'];"), 
     199               $categories), 
     200          SORT_STRING); 
     201natcasesort($categories); 
     202 
     203$categories_url_base = $core->url->getBase('category').'/'; 
     204 
     205foreach ($categories as $c) { 
     206     # URL path for DC2 (from the TagURL function in plugins/tags/_public.php) 
     207     $c_dc2 = $categories_url_base.$c; 
     208     $c_dc1 = $c; 
     209 
     210     if ("$path_dc2/$c_dc2" != "$path_dc1/$c_dc1") { 
     211          $categories_htaccess[] = "RedirectPermanent $path_dc1/$c_dc1 $url$c_dc2"; 
     212     } else { 
     213          $categories_htaccess[] = "# $c => $c_dc2"; 
     214     } 
     215} 
     216 
     217$categories_htaccess = implode("\n", $categories_htaccess); 
    183218 
    184219?> 
     
    199234 
    200235echo 
    201 '<p>'.__('In order to avoid broken feeds, you should replace your old '. 
     236'<p>'.sprintf(__('In order to avoid broken feeds, you should replace your old '. 
    202237'Atom and RSS feeds by redirections to new ones. The following files replace '. 
    203 'your Dotclear 1 atom.php and rss.php files.').'</p>'; 
     238'your Dotclear 1 %s/atom.php and %s/rss.php files.'), $path_dc1_dc, $path_dc1_dc).'</p>'; 
    204239echo 
    205240'<p>'.__('Note: The script content has been updated after dc1redirect-1.0.1 '. 
     
    222257 
    223258echo 
    224 '<h4>.htaccess</h4>'. 
    225 '<p>'.form::textarea('tags',60,50,html::escapeHTML($tags_htaccess),'maximal').'</p>'; 
     259'<p><label class="classic">.htaccess:</label><br/>'. 
     260form::textarea('tags_htaccess',60,50,html::escapeHTML($tags_htaccess),'maximal').'</p>'; 
     261 
     262/* 
     263# Categories are already handled by _public.php 
     264 
     265echo '<h3>'.__('Categories').'</h3>'. 
     266'<p>'.__('Add those lines to .htaccess to redirect category URLs:').'</p>'. 
     267'<p><label class="classic">.htaccess:</label><br/>'. 
     268form::textarea('categories_htaccess',60,10,html::escapeHTML($categories_htaccess),'maximal').'</p>'; 
     269*/ 
     270 
     271# Nothing to do for languages: URLs are the same in DC2 as in DC1 
     272 
     273# TODO images 
    226274 
    227275?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map