Changeset 13595
- Timestamp:
- 11/23/07 11:17:14 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.helper.datamanager2/exec/chooser_handler.php
r13590 r13595 11 11 12 12 debug_push_class('midcom_helper_datamanager2_widget_chooser_handler', 'initialize'); 13 // debug_print_r('_REQUEST', $_REQUEST);13 //debug_print_r('_REQUEST', $_REQUEST); 14 14 15 15 // Common variables … … 45 45 '_renderer_callback_class', '_renderer_callback_args', 46 46 'constraints', 'searchfields', 'orders', 47 'result_headers', 47 'result_headers', 'generate_path_for', 48 48 'auto_wildcards', 49 49 'reflector_key' 50 50 ); 51 51 $extra_params = unserialize(base64_decode($_REQUEST['extra_params'])); 52 debug_print_r('extra params', $extra_params); 52 53 foreach ($map as $map_key) 53 54 { … … 293 294 $value = @$object->$item_name; 294 295 295 if ( $class == 'midcom_db_topic' 296 && $item_name == 'extra' ) 297 { 298 $value = resolve_path_title($object->id, $value); 296 if ( $generate_path_for == $item_name 297 || ( $class == 'midcom_db_topic' 298 && $item_name == 'extra') 299 || ( in_array($class, array('midcom_baseclasses_database_group', 'midcom_db_group')) 300 && $item_name == 'name') ) 301 { 302 $value = resolve_path($object->id, $class, $value); 299 303 } 300 304 … … 315 319 $_MIDCOM->finish(); 316 320 317 function 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 whether 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]} > "; 353 } 354 } 355 356 if (empty($result)) 321 /** 322 * TODO: Reflectorize this 323 */ 324 function resolve_path($object_id, $class, $title) 325 { 326 debug_add("resolve_path for {$object_id}, {$class}, {$title}"); 327 328 $result_components = array(); 329 330 if ($class == 'midcom_db_topic') 331 { 332 $id = $object_id; 333 while ($id != 0) 334 { 335 $mc = midcom_db_topic::new_collector('id', $id); 336 $mc->add_value_property('extra'); 337 $mc->add_value_property('up'); 338 $mc->execute(); 339 $topics = $mc->list_keys(); 340 341 if (! $topics) 342 { 343 $id = 0; 344 break; 345 } 346 347 foreach ($topics as $topic_guid => $value) 348 { 349 $result_components[] = $mc->get_subkey($topic_guid, 'extra'); 350 $id = $mc->get_subkey($topic_guid, 'up'); 351 } 352 } 353 } 354 else if ( $class == 'midcom_db_group' 355 || $class == 'midcom_baseclasses_database_group') 356 { 357 $result_components[] = $title; 358 359 $id = $object_id; 360 while ($id != 0) 361 { 362 $mc = midcom_db_topic::new_collector('id', $id); 363 $mc->add_value_property('name'); 364 $mc->add_value_property('owner'); 365 $mc->execute(); 366 $groups = $mc->list_keys(); 367 368 if (! $groups) 369 { 370 $id = 0; 371 break; 372 } 373 374 foreach ($groups as $group_guid => $value) 375 { 376 $result_components[] = $mc->get_subkey($group_guid, 'name'); 377 $id = $mc->get_subkey($group_guid, 'owner'); 378 } 379 } 380 } 381 382 if (empty($result_components)) 357 383 { 358 384 return $title; 359 385 } 360 386 361 return $result; 387 $result_components = array_reverse($result_components); 388 389 return implode(' > ', $result_components); 362 390 } 363 391 trunk/midcom/midcom.helper.datamanager2/static/chooser/jquery.chooser_widget.js
r13556 r13595 370 370 list_jq_items, 371 371 active = -1, 372 data; 372 data, 373 block_width = 100; 373 374 374 375 list.mouseover( function(event) { … … 404 405 function create_headers() 405 406 { 407 if (options.result_headers.length > 1) 408 { 409 block_width = (100 / options.result_headers.length) - 1; 410 } 411 406 412 jQuery.each( options.result_headers, function(i,n) { 407 413 var li_elem = jQuery("<li>") … … 410 416 margin: 0, 411 417 padding: 0, 412 background: 'none' 418 background: 'none', 419 width: block_width+'%' 413 420 }) 414 421 .attr({ id: 'chooser_widget_header_item_'+n.name }); … … 579 586 else 580 587 { 581 var item_content = midcom_helper_datamanager2_widget_chooser_format_item(data,options )588 var item_content = midcom_helper_datamanager2_widget_chooser_format_item(data,options,block_width) 582 589 .appendTo(li_elem); 583 590 var input_elem = jQuery("<input type=\"hidden\">") … … 798 805 }; 799 806 800 function midcom_helper_datamanager2_widget_chooser_format_item(item, options )807 function midcom_helper_datamanager2_widget_chooser_format_item(item, options, block_width) 801 808 { 802 809 var formatted = ''; … … 828 835 id: 'chooser_widget_item_part_'+n.name, 829 836 title: midcom_helper_datamanager2_widget_chooser_format_value('html2text', value) 837 }) 838 .css({ 839 width: block_width+'%' 830 840 }) 831 841 .html( value ) trunk/midcom/midcom.helper.datamanager2/widget/chooser.php
r13174 r13595 143 143 */ 144 144 var $result_headers = array(); 145 146 /** 147 * In search results replaces given field with full path to the object 148 * 149 * Example: (in topics) 150 * 'generate_path_for' => 'extra', 151 * 152 * @var array 153 */ 154 var $generate_path_for = null; 145 155 146 156 /** … … 619 629 array('metadata.published' => 'ASC'), 620 630 ), 631 'generate_path_for' => 'extra', 621 632 ), 622 633 'group' => array … … 642 653 'id_field' => 'id', 643 654 ), 655 'generate_path_for' => 'name', 644 656 ); 645 657 … … 666 678 $this->result_headers[] = $header; 667 679 } 680 } 681 if ( is_null($this->generate_path_for) 682 && isset($clever_classes[$this->clever_class]['generate_path_for'])) 683 { 684 $this->generate_path_for = $clever_classes[$this->clever_class]['generate_path_for']; 668 685 } 669 686 if (empty($this->constraints))
