Changeset 3048
- Timestamp:
- 05/30/11 07:29:18 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dc1redirect/index.php
r3017 r3048 119 119 120 120 $url = $core->blog->url; 121 preg_match('|^([a-z]{3,}://) .*?(/.*)$|',$url,$matches);121 preg_match('|^([a-z]{3,}://)[^/]*(.*?)/?$|',$url,$matches); 122 122 $proto = $matches[1]; 123 $path = $matches[2]; 123 $path_dc1 = $path_dc2 = $matches[2]; 124 if ($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; 130 if (empty($path_dc1_dc)) { 131 $path_dc1_dc = dirname($core->blog->settings->system->public_url); 132 } 133 124 134 125 135 # Template for DC1 feeds PHP script replacement … … 130 140 // Created manually following plugin 'dc1redirect' instructions 131 141 132 \$url = '$proto'.\$_SERVER['HTTP_HOST'].'${path }feed';142 \$url = '$proto'.\$_SERVER['HTTP_HOST'].'${path_dc2}/feed'; 133 143 134 144 if (!empty(\$_GET['lang'])) { … … 172 182 $t_dc1 = 'tag/'.str2url($t); 173 183 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"; 176 186 } else { 177 187 $tags_htaccess[] = "# $t => $t_dc2"; … … 181 191 $tags_htaccess = implode("\n", $tags_htaccess); 182 192 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); 201 natcasesort($categories); 202 203 $categories_url_base = $core->url->getBase('category').'/'; 204 205 foreach ($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); 183 218 184 219 ?> … … 199 234 200 235 echo 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 '. 202 237 '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>'; 204 239 echo 205 240 '<p>'.__('Note: The script content has been updated after dc1redirect-1.0.1 '. … … 222 257 223 258 echo 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/>'. 260 form::textarea('tags_htaccess',60,50,html::escapeHTML($tags_htaccess),'maximal').'</p>'; 261 262 /* 263 # Categories are already handled by _public.php 264 265 echo '<h3>'.__('Categories').'</h3>'. 266 '<p>'.__('Add those lines to .htaccess to redirect category URLs:').'</p>'. 267 '<p><label class="classic">.htaccess:</label><br/>'. 268 form::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 226 274 227 275 ?>
Note: See TracChangeset
for help on using the changeset viewer.