Changeset 13557

Show
Ignore:
Timestamp:
11/22/07 14:44:10 (1 year ago)
Author:
w_i
Message:

Resolve topics full path to replace title

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.datamanager2/exec/chooser_handler.php

    r12726 r13557  
    3737$query = $_REQUEST["query"]; 
    3838$query = str_replace("*","%", $query); 
     39$query = preg_replace('/%+/', '%', $query); 
    3940 
    4041$map = array 
     
    217218        exit(); 
    218219    } 
     220} 
     221 
     222if (count($results) <= 0) 
     223{ 
     224    echo "    <status>2</status>\n"; 
     225    echo "    <errstr>No results found</errstr>\n"; 
     226    echo "</response>\n"; 
     227    $_MIDCOM->finish(); 
     228    exit(); 
    219229} 
    220230 
     
    283293            $value = @$object->$item_name; 
    284294 
     295            if (   $class == 'midcom_db_topic' 
     296                && $item_name == 'extra' ) 
     297            { 
     298                $value = resolve_path_title($object->id, $value); 
     299            } 
     300 
    285301            debug_add("adding header item: name={$item_name} value={$value}"); 
    286302            echo "          <{$item_name}><![CDATA[{$value}]]></{$item_name}>\n"; 
     
    299315$_MIDCOM->finish(); 
    300316 
     317function resolve_path_title($object_id, $title) 
     318{    
     319    $result = '';     
     320    $nav = new midcom_helper_nav(); 
     321     
     322    $bc_data = $nav->get_breadcrumb_data($object_id);     
     323    reset($bc_data); 
     324     
     325    // Detect real starting Node 
     326    if ($skip_levels > 0) 
     327    { 
     328        if ($skip_levels >= count($bc_data)) 
     329        { 
     330            debug_add('We were asked to skip all (or even more) breadcrumb elements then there were present. Returning an empty breadcrumb line therefore.', MIDCOM_LOG_INFO); 
     331            debug_pop(); 
     332            return $title; 
     333        } 
     334        for ($i = 0; $i < $skip_levels; $i++) 
     335        { 
     336            next($bc_data); 
     337        } 
     338    } 
     339     
     340    while(current($bc_data) !== false) 
     341    { 
     342        $data = current($bc_data); 
     343        $data[MIDCOM_NAV_NAME] = htmlspecialchars($data[MIDCOM_NAV_NAME]); 
     344 
     345        // Add the next element sensitive to the fact wether we are at the end or not. 
     346        if (next($bc_data) === false) 
     347        { 
     348            $result .= $data[MIDCOM_NAV_NAME]; 
     349        } 
     350        else 
     351        { 
     352            $result .= "{$data[MIDCOM_NAV_NAME]}  &gt; "; 
     353        } 
     354    } 
     355     
     356    if (empty($result)) 
     357    { 
     358        return $title; 
     359    } 
     360     
     361    return $result; 
     362} 
     363 
    301364?>