Changeset 17864
- Timestamp:
- 10/02/08 14:15:36 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.helper.datamanager2/exec/chooser_handler.php
r17304 r17864 50 50 ); 51 51 $extra_params = unserialize(base64_decode($_REQUEST['extra_params'])); 52 52 53 debug_print_r('extra params', $extra_params); 54 53 55 foreach ($map as $map_key) 54 56 { … … 127 129 // debug_add("Using class: {$class}"); 128 130 129 $_MIDCOM->componentloader->load_graceful($component); 130 131 // Load component if required 132 if (!class_exists($class)) 133 { 134 $_MIDCOM->componentloader->load_graceful($component); 135 } 131 136 // Could not get required class defined, abort 132 137 if (!class_exists($class)) … … 206 211 } 207 212 } 213 208 214 $results = $qb->execute(); 209 215 if ($results === false) … … 288 294 { 289 295 $item_name = $header_item['name']; 290 $value = @$object->$item_name; 291 296 297 if (preg_match('/^metadata\.(.+)$/', $item_name, $regs)) 298 { 299 $metadata_property = $regs[1]; 300 $value = @$object->metadata->$metadata_property; 301 302 switch ($metadata_property) 303 { 304 case 'created': 305 case 'revised': 306 case 'published': 307 case 'schedulestart': 308 case 'scheduleend': 309 case 'imported': 310 case 'exported': 311 case 'approved': 312 if ($value) 313 { 314 $value = strftime('%x %X', $value); 315 } 316 break; 317 318 case 'creator': 319 case 'revisor': 320 case 'approver': 321 case 'locker': 322 if ($value) 323 { 324 $person = new midcom_db_person($value); 325 $value = $person->name; 326 } 327 break; 328 } 329 } 330 else 331 { 332 $value = @$object->$item_name; 333 } 334 292 335 if ( $generate_path_for == $item_name 293 336 || ( $class == 'midcom_db_topic' … … 298 341 $value = resolve_path($object->id, $class, $value); 299 342 } 343 344 $item_name = str_replace('.', '_', $item_name); 300 345 301 346 debug_add("adding header item: name={$item_name} value={$value}"); … … 324 369 $result_components = array(); 325 370 326 if ($class == 'midcom_db_topic') 327 { 328 $id = $object_id; 329 $last_name = ''; 330 while ($id != 0) 331 { 332 $mc = midcom_db_topic::new_collector('id', $id); 333 $mc->add_value_property('extra'); 334 $mc->add_value_property('up'); 335 $mc->add_value_property('name'); 371 switch ($class) 372 { 373 case 'midcom_db_article': 374 case 'midcom_baseclaases_database_article': 375 $result_components[] = $title; 376 377 // Get the owner topic 378 $mc = midcom_db_article::new_collector('id', $object_id); 379 $mc->add_value_property('topic'); 336 380 $mc->execute(); 337 $topics = $mc->list_keys(); 338 339 if (! $topics) 340 { 341 $id = 0; 342 $rc_count = count($result_components); 343 $result_components[$rc_count-1] = $last_name; 344 break; 345 } 346 347 foreach ($topics as $topic_guid => $value) 348 { 349 $id = $mc->get_subkey($topic_guid, 'up'); 350 $last_name = $mc->get_subkey($topic_guid, 'name'); 381 $keys = $mc->list_keys(); 382 383 foreach ($keys as $guid => $array) 384 { 385 $id = $mc->get_subkey($guid, 'topic'); 386 } 387 388 // Fall through 389 390 case 'midcom_db_topic': 391 if (!isset($id)) 392 { 393 $id = $object_id; 394 } 395 396 $last_name = ''; 397 while ($id != 0) 398 { 399 $mc = midcom_db_topic::new_collector('id', $id); 400 $mc->add_value_property('extra'); 401 $mc->add_value_property('up'); 402 $mc->add_value_property('name'); 403 $mc->execute(); 404 $topics = $mc->list_keys(); 405 406 if (! $topics) 407 { 408 $id = 0; 409 $rc_count = count($result_components); 410 $result_components[$rc_count-1] = $last_name; 411 break; 412 } 413 414 foreach ($topics as $topic_guid => $value) 415 { 416 $id = $mc->get_subkey($topic_guid, 'up'); 417 $last_name = $mc->get_subkey($topic_guid, 'name'); 418 419 if ($id == 0) 420 { 421 $result_components[] = $last_name; 422 } 423 else 424 { 425 $result_components[] = $mc->get_subkey($topic_guid, 'extra'); 426 } 427 } 428 } 429 break; 430 431 case 'midcom_db_group': 432 case 'midcom_baseclasses_database_group': 433 $result_components[] = $title; 434 435 $id = $object_id; 436 while ($id != 0) 437 { 438 $mc = midcom_db_group::new_collector('id', $id); 439 $mc->add_value_property('name'); 440 $mc->add_value_property('owner'); 441 $mc->execute(); 442 $groups = $mc->list_keys(); 351 443 352 if ( $id == 0)444 if (! $groups) 353 445 { 354 $result_components[] = $last_name; 446 $id = 0; 447 break; 355 448 } 356 else 449 450 foreach ($groups as $group_guid => $value) 357 451 { 358 $result_components[] = $mc->get_subkey($topic_guid, 'extra'); 452 if ($object_id != $id) 453 { 454 $result_components[] = $mc->get_subkey($group_guid, 'name'); 455 } 456 $id = $mc->get_subkey($group_guid, 'owner'); 359 457 } 360 458 } 361 } 362 } 363 else if ( $class == 'midcom_db_group' 364 || $class == 'midcom_baseclasses_database_group') 365 { 366 $result_components[] = $title; 367 368 $id = $object_id; 369 while ($id != 0) 370 { 371 $mc = midcom_db_group::new_collector('id', $id); 372 $mc->add_value_property('name'); 373 $mc->add_value_property('owner'); 374 $mc->execute(); 375 $groups = $mc->list_keys(); 376 377 if (! $groups) 378 { 379 $id = 0; 380 break; 381 } 382 383 foreach ($groups as $group_guid => $value) 384 { 385 if ($object_id != $id) 386 { 387 $result_components[] = $mc->get_subkey($group_guid, 'name'); 388 } 389 $id = $mc->get_subkey($group_guid, 'owner'); 390 } 391 } 392 } 459 break; 460 } 461 393 462 394 463 if (empty($result_components)) trunk/midcom/midcom.helper.datamanager2/static/chooser/jquery.chooser_widget.js
r16617 r17864 527 527 jQuery.each( options.result_headers, function(i,n) 528 528 { 529 n.name = n.name.replace(/\./, '_'); 530 529 531 var li_elem = jQuery('<li>') 530 532 .addClass('chooser_widget_header_item') trunk/midcom/midcom.helper.datamanager2/widget/chooser.php
r17835 r17864 8 8 */ 9 9 10 $_MIDCOM->load_library('midcom.helper.reflector'); 10 if (! class_exists('midcom_helper_reflector')) 11 { 12 $_MIDCOM->load_library('midcom.helper.reflector'); 13 } 11 14 12 15 /** … … 31 34 * 'type_config' => array 32 35 * ( 33 * 'require_corresponding_option' => false,36 * 'require_corresponding_option' => false, 34 37 * 'allow_multiple' => true, 35 38 * 'multiple_storagemode' => 'array', … … 131 134 * Example: 132 135 * <code> 133 * 'constraints' => array ( 134 * array( 136 * 'constraints' => array 137 * ( 138 * array 139 * ( 135 140 * 'field' => 'username', 136 141 * 'op' => '<>', … … 173 178 * Example: 174 179 * <code> 175 * 'searchfields' => array('firstname', 'lastname', 'email', 'username'), 180 * 'searchfields' => array 181 * ( 182 * 'firstname', 183 * 'lastname', 184 * 'email', 185 * 'username' 186 * ), 176 187 * </code> 177 188 * … … 185 196 * Example: 186 197 * <code> 187 * 'orders' => array(array('lastname' => 'ASC'), array('firstname' => 'ASC')), 198 * 'orders' => array 199 * ( 200 * array 201 * ( 202 * 'lastname' => 'ASC', 203 * ), 204 * array 205 * ( 206 * 'firstname' => 'ASC', 207 * ) 208 * ), 188 209 * </code> 189 210 * … … 384 405 $_MIDCOM->enable_jquery(); 385 406 386 $_MIDCOM->add_link_head( 387 array( 407 $_MIDCOM->add_link_head 408 ( 409 array 410 ( 388 411 'rel' => 'stylesheet', 389 412 'type' => 'text/css', … … 968 991 $this->_js_widget_options['format_items'] = 'null'; 969 992 993 if ($this->generate_path_for) 994 { 995 $this->_js_widget_options['generate_path_for'] = "'{$this->generate_path_for}'"; 996 } 997 970 998 if ($this->sortable) 971 999 { … … 1056 1084 '_renderer_callback_class', '_renderer_callback_args', 1057 1085 'constraints', 'searchfields', 'orders', 1058 'result_headers', 1086 'result_headers', 'generate_path_for', 1059 1087 'auto_wildcards', 1060 1088 'reflector_key' … … 1069 1097 1070 1098 $this->_js_widget_options['extra_params'] = "'" . base64_encode(serialize($params)) . "'"; 1099 } 1100 1101 /** 1102 * Internal helper for parsing the $_REQUEST data for including the elements requested via GET or POST 1103 * 1104 * @access private 1105 * @return Array 1106 */ 1107 function _get_request_elements() 1108 { 1109 $results = array(); 1110 1111 // No results available 1112 if (!isset($_REQUEST["{$this->_element_id}_selections"])) 1113 { 1114 return $results; 1115 } 1116 1117 foreach ($_REQUEST["{$this->_element_id}_selections"] as $guid => $value) 1118 { 1119 if (!$value) 1120 { 1121 continue; 1122 } 1123 1124 $results[$guid] = $value; 1125 } 1126 1127 return $results; 1071 1128 } 1072 1129 … … 1170 1227 $existing_elements = $this->_type->selection; 1171 1228 1229 // Add to existing elements the ones requested (POST/GET) to this page 1230 $new_elements = $this->_get_request_elements(); 1231 1172 1232 //debug_print_r('existing_elements',$existing_elements); 1173 1233 1174 1234 // debug_print_r('static_options',$this->static_options); 1175 1235 1176 $elements = array_merge($this->static_options, $existing_elements );1236 $elements = array_merge($this->static_options, $existing_elements, $new_elements); 1177 1237 // debug_print_r('all elements to be added',$elements); 1178 1238 // debug_pop(); 1179 1239 1180 1240 // $this->_static_items_html = "<noscript>\n"; 1181 $this->_static_items_html .= "<table class=\"widget_chooser_static_items_table\">\n<thead><tr>\n"; 1241 $this->_static_items_html .= "<table class=\"widget_chooser_static_items_table\">\n"; 1242 $this->_static_items_html .= " <thead>\n"; 1243 $this->_static_items_html .= " <tr>\n"; 1182 1244 1183 1245 if ( !empty($this->reflector_key) … … 1185 1247 { 1186 1248 $title = $_MIDCOM->i18n->get_string('Label', 'midcom'); 1187 $this->_static_items_html .= " <th class=\"label\">{$title} </th>\n";1249 $this->_static_items_html .= " <th class=\"label\">{$title} </th>\n"; 1188 1250 } 1189 1251 else … … 1191 1253 foreach ($this->result_headers as $header_item) 1192 1254 { 1193 $this->_static_items_html .= " <th class=\"{$header_item['name']}\">{$header_item['title']} </th>\n";1255 $this->_static_items_html .= " <th class=\"{$header_item['name']}\">{$header_item['title']} </th>\n"; 1194 1256 } 1195 1257 } 1196 1258 1197 1259 $title = $_MIDCOM->i18n->get_string('Selected', 'midcom.helper.datamanager2'); 1198 $this->_static_items_html .= " <th class=\"selected\">{$title} </th>\n"; 1199 1200 $this->_static_items_html .= "</tr></thead>\n<tbody>\n"; 1260 $this->_static_items_html .= " <th class=\"selected\">{$title} </th>\n"; 1261 $this->_static_items_html .= " </tr>\n"; 1262 $this->_static_items_html .= " </thead>\n"; 1263 $this->_static_items_html .= " <tbody>\n"; 1201 1264 1202 1265 $ee_script = ''; … … 1228 1291 { 1229 1292 // debug_add("Got data: {$data}"); 1230 $ee_script .= "\njQuery('#{$this->_element_id}_search_input').midcom_helper_datamanager2_widget_chooser_add_result_item({$data});\n"; 1293 $ee_script .= "\n"; 1294 $ee_script .= "jQuery('#{$this->_element_id}_search_input')\n"; 1295 $ee_script .= ".midcom_helper_datamanager2_widget_chooser_add_result_item(\n"; 1296 $ee_script .= " {$data},\n"; 1297 $ee_script .= " this\n"; 1298 $ee_script .= ");\n"; 1231 1299 1232 1300 $this->_add_existing_item_as_static($key); … … 1237 1305 $this->_jscript .= $ee_script; 1238 1306 $this->_jscript .= '});'; 1307 1308 $this->_jscript .= "\nclose_dialog = function(widget_id){jQuery('#' + widget_id + '_creation_dialog').hide();};"; 1309 $this->_jscript .= "\nadd_item = function(data, widget_id){jQuery('#' + widget_id + '_search_input').midcom_helper_datamanager2_widget_chooser_add_result_item(data);};"; 1310 1239 1311 $this->_jscript .= '</script>'; 1240 1312 1241 $this->_static_items_html .= " </tbody>\n";1313 $this->_static_items_html .= " </tbody>\n"; 1242 1314 $this->_static_items_html .= "</table>\n"; 1243 1315 // $this->_static_items_html .= "</noscript>\n"; … … 1385 1457 $value = rawurlencode(utf8_decode($value)); 1386 1458 // debug_add("adding header item: name={$item_name} value={$value}"); 1387 $jsdata .= "{$item_name}: '{$value}'"; 1459 1460 $tmp = str_replace('.', '_', $item_name); 1461 1462 $jsdata .= "{$tmp}: '{$value}'"; 1388 1463 1389 1464 if ($i < $hi_count)
