Changeset 170

Show
Ignore:
Timestamp:
01/11/08 21:08:19 (5 years ago)
Author:
d0nut
Message:

appending to .htaccess works!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • taggingreloaded/optionals/de.easy-coding.wcf.taggingreloaded.seo/files/lib/system/event/listener/TaggingReloadedSEOOptionFormListener.class.php

    r169 r170  
    2121                 
    2222                        if ($options['SEO_ENABLE']) { 
    23                         return; //TODO 
    24                                 require_once(WCF_DIR.'lib/data/page/seo/RewriteRulesFile.class.php'); 
    25                                 $file = new RewriteRulesFile(WBB_DIR.'.htaccess'); 
     23                                require_once(WCF_DIR.'lib/system/io/File.class.php'); 
     24                                 
     25                                $filename = WBB_DIR.'.htaccess'; 
     26                                $file = new File($filename); 
     27 
     28                                if (file_exists($filename)) { 
     29                                        $existingContent = StringUtil::unifyNewlines(file_get_contents($filename)); 
    2630                         
    27                                 if ($options['SEO_REWRITE_TAGGING']) { 
    28                                         $file->addRewriteRule($options['SEO_REWRITE_TAGGING_FORMAT'], 'index.php?page=Tagging&tag={1}', array('TAG' => '.+')); 
     31                                        // filter wcf seo rules 
     32                                        $existingContent = preg_replace("~\n?# WCF-SEO-TAGGING-START.*# WCF-SEO-TAGGING-END~s", '', $existingContent); 
    2933                                } 
    30                          
    31                                 $file->close(); 
     34                                 
     35                                // reinsert existing content 
     36                                if (!empty($existingContent)) { 
     37                                        $this->write($existingContent); 
     38                                }                                
     39                                 
     40                                $file->write("\n# WCF-SEO-TAGGING-START\n"); 
     41                                $file->write("RewriteRule ^tags/(.+)$ index.php?page=Tagging&tag=$1 [L,QSA]"); 
     42                                $file->write("\n# WCF-SEO-TAGGING-END\n"); 
     43                                $file->close();                  
    3244                        } 
    3345                }