Dotclear


Ignore:
Timestamp:
09/24/13 14:03:31 (12 years ago)
Author:
Dsls
Branch:
default
Message:

Made favorite link recognition a bit more intelligent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/prepend.php

    r1949 r2062  
    3535} 
    3636 
    37 function dc_prepare_url($url) { 
    38  
    39      $u = str_replace(array('?','&','/'),array('\?','&','\\/'),$url); 
    40      return (!strpos($u,'\?') ?  
    41           '/'.$u.'$/' : 
    42           (!strpos($u,'&') ?  
    43           '/'.$u.'(\?.*)?$/' : 
    44           '/'.$u.'(&.*)?$/')); 
    45 } 
     37function dc_check_active($url) { 
     38     $u = explode('?',$url,2); 
     39     if (!preg_match('/'.preg_quote($u[0],"/").'/',$_SERVER['REQUEST_URI'])) { 
     40          return false; 
     41     } 
     42     if (count($u) == 2) { 
     43          parse_str($u[1],$p); 
     44          foreach ($p as $k => $v) { 
     45               if (!isset($_REQUEST[$k]) || $_REQUEST[$k] !== $v) { 
     46                    return false; 
     47               } 
     48          } 
     49     } 
     50     return true; 
     51} 
     52 
    4653 
    4754function dc_load_locales() { 
     
    357364                         $count++; 
    358365                         $_menu['Favorites']->addItem(__($fav['title']),$fav['url'],$fav['small-icon'], 
    359                               preg_match(dc_prepare_url($fav['url']),$_SERVER['REQUEST_URI']), 
     366                              dc_check_active($fav['url']), 
    360367                              (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)),$fav['id'],$fav['class']); 
    361368                    } 
     
    369376                         $count++; 
    370377                         $_menu['Favorites']->addItem(__($fav['title']),$fav['url'],$fav['small-icon'], 
    371                               preg_match(dc_prepare_url($fav['url']),$_SERVER['REQUEST_URI']), 
     378                              dc_check_active($fav['url']), 
    372379                              (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)),$fav['id'],$fav['class']); 
    373380                    } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map