Changeset 659


Ignore:
Timestamp:
08/07/2011 02:04:22 AM (10 months ago)
Author:
ofer
Message:

Improve behaviour on 404 pages, don't create links to nowhere and don't do the rel alternate on those pages

Location:
trunk/WordPress/plugin/transposh
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/core/utils.php

    r658 r659  
    5959        //cleanup lang identifier in permalinks 
    6060        //remove the language from the url permalink (if in start of path, and is a defined language) 
    61         $home_path = rtrim(parse_url($home_url, PHP_URL_PATH), "/"); 
     61        $home_path = rtrim(@parse_url($home_url, PHP_URL_PATH), "/"); 
    6262        logger("home: $home_path " . $parsedurl['path'], 5); 
    6363        if ($home_path && strpos($parsedurl['path'], $home_path) === 0) { 
     
    6767        } 
    6868 
    69         if (strlen($parsedurl['path']) > 2) { 
     69        if (@strlen($parsedurl['path']) > 2) { 
    7070            $secondslashpos = strpos($parsedurl['path'], "/", 1); 
    7171            if (!$secondslashpos) $secondslashpos = strlen($parsedurl['path']); 
     
    100100        $newurl = str_replace('&', '&', $url); 
    101101        $newurl = html_entity_decode($newurl, ENT_NOQUOTES); 
    102         $parsedurl = parse_url($newurl); 
     102        $parsedurl = @parse_url($newurl); 
    103103 
    104104        // if we are dealing with some other url, we won't touch it! 
    105         if (isset($parsedurl['host']) && !($parsedurl['host'] == parse_url($home_url, PHP_URL_HOST))) { 
     105        if (isset($parsedurl['host']) && !($parsedurl['host'] == @parse_url($home_url, PHP_URL_HOST))) { 
    106106            return $url; 
    107107        } 
     
    120120        // remove the language from the url permalink (if in start of path, and is a defined language) 
    121121        $gluebackhome = false; 
    122         $home_path = rtrim(parse_url($home_url, PHP_URL_PATH), "/"); 
     122        $home_path = rtrim(@parse_url($home_url, PHP_URL_PATH), "/"); 
    123123        logger("home: $home_path " . $parsedurl['path'], 5); 
    124124        if ($home_path && strpos($parsedurl['path'], $home_path) === 0) { 
     
    191191        // cleanup lang identifier in permalinks 
    192192        // remove the language from the url permalink (if in start of path, and is a defined language) 
    193         $home_path = rtrim(parse_url($home_url, PHP_URL_PATH), "/"); 
     193        $home_path = rtrim(@parse_url($home_url, PHP_URL_PATH), "/"); 
    194194//    logger ("home: $home_path ".$parsedurl['path'],5); 
    195195        if ($home_path && strpos($parsedurl['path'], $home_path) === 0) { 
     
    335335            else $url2 .= '/' . $part; 
    336336        } 
    337         if ($url2 =='') $url2 = '/'; 
     337        if ($url2 == '') $url2 = '/'; 
    338338        // TODO: Consider sanitize_title_with_dashes 
    339339        // TODO : need to handle params.... 
     
    341341        //if (substr($url,strlen($url)-1) == '/') $url2 .= '/'; 
    342342        //$url2 = rtrim($url2,'/'); 
    343         //logger ("$href $url $url2"); 
     343        // logger("h $home_url hr $href ur $url ur2 $url2"); 
    344344        //$href = $this->home_url.$url2; 
    345345        if (substr($href, strlen($href) - 1) == '/') $url2.='/'; 
    346         return $home_url . $url2.$params; 
     346        $url2 = str_replace('//', '/', $url2); 
     347        return $home_url . $url2 . $params; 
    347348    } 
    348349 
  • trunk/WordPress/plugin/transposh/transposh.php

    r639 r659  
    725725     */ 
    726726    function add_rel_alternate() { 
     727        if (is_404()) return; 
    727728        $widget_args = $this->widget->create_widget_args(true, $this->get_clean_url()); 
    728729        logger($widget_args, 4); 
     
    862863    function pre_post_search($query) { 
    863864        logger('pre post', 4); 
    864         logger($query->query_vars); 
     865        logger($query->query_vars, 4); 
    865866        // we hide the search query var from further proccesing, because we do this later 
    866867        if ($query->query_vars['s']) { 
  • trunk/WordPress/plugin/transposh/wp/transposh_widget.php

    r601 r659  
    152152        $widget_args = array(); 
    153153        $page_url = ''; 
     154        if (is_404()) { 
     155            $clean_page_url = transposh_utils::cleanup_url($this->transposh->home_url,$this->transposh->home_url,true); 
     156        } 
    154157        // loop on the languages 
    155158        foreach ($this->transposh->options->get_sorted_langs() as $code => $langrecord) { 
Note: See TracChangeset for help on using the changeset viewer.