Changeset 11855
- Timestamp:
- 08/30/07 12:10:21 (1 year ago)
- Files:
-
- trunk/midcom/midcom.core/midcom/helper/_basicnav.php (modified) (32 diffs)
- trunk/midcom/midcom.core/midcom/helper/nav.php (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.core/midcom/helper/_basicnav.php
r11359 r11855 56 56 * Basically for each leaf the usual meta information is returned: 57 57 * 58 * - MIDCOM_NAV_URL => URL of the leaf element 59 * - MIDCOM_NAV_NAME => Name of the leaf element 58 60 * - MIDCOM_META_CREATOR => Creator of the element (MidgardPerson) 59 61 * - MIDCOM_META_CREATED => Creation date (UNIX Timestamp) … … 63 65 * - MIDCOM_NAV_TOOLBAR => Toolbar data (see below) 64 66 * 65 * MidCOM NAP has reduced the separation of Admin Mode and Site Mode NAP 66 * Data. Both Site- and Administrative Mode data is now delivered to NAP 67 * (and from there to the NAP user) in a single call. This is done by 68 * creating two sub-arrays retrievable under the keys MIDCOM_NAV_SITE and 69 * MIDCOM_NAV_ADMIN. Both of those arrays contain MIDCOM_NAV_URL and 70 * MIDCOM_NAV_NAME values. For compatibility and ease of use the top-level 71 * entries of MIDCOM_NAV_NAME and MIDCOM_NAV_URL are still existent and 72 * in use. Therefore, three possible constellation exist: 73 * 74 * 1) Both Values present 75 * 67 * Both MIDCOM_NAV_SITE and MIDCOM_NAV_ADMIN are both deprecated. MIDCOM_NAV_ADMIN 68 * for good, but MIDCOM_NAV_SITE will still support backwards compatibility. 69 * 70 * Backwards support for MIDCOM_NAV_SITE is an array that contains both 71 * MIDCOM_NAV_URL and MIDCOM_NAV_NAME 72 * 76 73 * <pre> 77 * MIDCOM_NAV_SITE => Array (MIDCOM_NAV_URL, MIDCOM_NAV_NAME), 78 * MIDCOM_NAV_ADMIN => Array (MIDCOM_NAV_URL, MIDCOM_NAV_NAME), 79 * [... all other tags ...] 74 * MIDCOM_NAV_SITE => array 75 * ( 76 * MIDCOM_NAV_URL => URL of the leaf element 77 * MIDCOM_NAV_NAME => Name of the leaf element 78 * ), 80 79 * </pre> 81 * 82 * The top-level entries MIDCOM_NAV_NAME and _URL will be automatically 83 * popluated according to Admin- or non-Admin mode, so that the displaying 84 * code for all standard-situations won't have to consider this difference. 85 * 86 * 2) One element omitted 87 * 88 * If any Element does have only one of those pairs (like a "Create New 89 * Category"-Link for example), set the unavailable Array Entry to null: 90 * 91 * <pre> 92 * MIDCOM_NAV_SITE => null, 93 * MIDCOM_NAV_ADMIN => Array (MIDCOM_NAV_URL, MIDCOM_NAV_NAME), 94 * [... all other tags ...] 95 * </pre> 96 * 97 * Note, that if one of the elements is missing like outlined above, the 98 * list-methods of NAP will not show them in the corresponding mode. The 99 * element of the above example would only be included in the listings if 100 * the system was running in Admin-Mode. Copying of the primary values will 101 * still happen like in (1). 102 * 103 * 3) Compatibility syntax 104 * 105 * For ease-of-use and for backwards compatibility, you can deliver an old 106 * style data like this: 107 * 108 * <pre> 109 * MIDCOM_NAV_URL => "blah", 110 * MIDCOM_NAV_NAME => "blubb", 111 * [... all other tags ...] 112 * </pre> 113 * 114 * The Datamanger will automatically transform (3) to the syntax described in 80 * 81 * The Datamanager will automatically transform (3) to the syntax described in 115 82 * (1) by copying the values. 116 83 * … … 149 116 * <b>DEPRECATED INFORMATION</b> 150 117 * 151 * The key MIDCOM_NAV_VISIBLE is deprecated from MidCOM 2.4.0 on, visibility is taken into account118 * Key MIDCOM_NAV_VISIBLE is deprecated from MidCOM 2.4.0 on, visibility is taken into account 152 119 * automatically. The key is set to true for all values now for backwards compatibility and will 153 120 * be removed entirely in MidCOM 2.6.0 154 * 155 * @todo Bring the information from http://www.nathan-syntronics.de/midgard/midcom_fs-transition/nap-update.html somehow into this. 121 * 122 * Keys MIDCOM_NAV_ADMIN and MIDCOM_NAV_SITE are both deprecated as of MidCOM 2.8. MIDCOM_NAV_ADMIN 123 * will not work at all and MIDCOM_NAV_SITE will still be supported during the transition phase, but 124 * only if either MIDCOM_NAV_URL or MIDCOM_NAV_NAME are empty. 125 * 156 126 * @package midcom 157 127 */ … … 253 223 254 224 /** 255 * This one is true, if the system is in content administration mode and therefore256 * working with a different topic. See Constructor Documentation for details.257 *258 * @var bool259 */260 var $_adminmode;261 262 /**263 225 * This is a temporary storage where _loadNode can return the last known good 264 226 * node in case the current node not visible. It is evaluated by the … … 301 263 function midcom_helper__basicnav($context = 0) 302 264 { 303 debug_push("_basicnav::constructor");304 305 265 $tmp = $_MIDCOM->get_context_data($context, MIDCOM_CONTEXT_ROOTTOPIC); 306 266 $this->_root = $tmp->id; … … 312 272 $this->_nodes = array(); 313 273 $this->_loader =& $_MIDCOM->get_component_loader(); 314 if ($_MIDCOM->get_context_data($context, MIDCOM_CONTEXT_REQUESTTYPE) == MIDCOM_REQUEST_CONTENTADM)315 {316 $this->_adminmode = true;317 }318 else319 {320 $this->_adminmode = false;321 }322 274 323 275 $current = $_MIDCOM->get_context_data($context, MIDCOM_CONTEXT_CONTENTTOPIC); … … 340 292 341 293 case MIDCOM_ERRFORBIDDEN: 342 debug_add("The current node is hidden behind a undescendable one.", MIDCOM_LOG_INFO); 343 debug_add("Activating last good node ({$this->_lastgoodnode}) as current node"); 294 // Node is hidden behind an undescendable one, activate the last known good node as current 344 295 $this->_current = $this->_lastgoodnode; 345 296 break; 346 297 347 298 default: 299 debug_push("_basicnav::constructor"); 348 300 debug_add("_loadNode failed, see above error for details.", MIDCOM_LOG_ERROR); 349 301 debug_pop(); … … 353 305 // Reset the Root node's URL Parameter to an empty string. 354 306 $this->_nodes[$this->_root][MIDCOM_NAV_URL] = ''; 355 356 debug_pop();357 307 } 358 308 … … 371 321 function _get_node($id) 372 322 { 373 debug_push_class(__CLASS__, __FUNCTION__);374 375 323 /* 376 324 $this->_nap_cache->open(); … … 396 344 if (is_null($nodedata)) 397 345 { 346 debug_push_class(__CLASS__, __FUNCTION__); 398 347 debug_add('We got NULL for this node, so we do not have any NAP information, returning null directly.'); 399 348 debug_pop(); … … 410 359 $nodedata[MIDCOM_NAV_TOOLBAR] = null; 411 360 412 debug_pop();413 361 return $nodedata; 414 362 } … … 426 374 function _get_node_from_database($node) 427 375 { 428 debug_push_class(__CLASS__, __FUNCTION__);429 430 376 if (is_object($node)) 431 377 { … … 436 382 // Load the topic first. 437 383 $topic = new midcom_db_topic($node); 438 if ( ! $topic384 if ( !$topic 439 385 || !$topic->guid) 440 386 { 387 debug_push_class(__CLASS__, __FUNCTION__); 441 388 debug_add("Could not load the topic {$node} through DBA; assuming missing privileges.", MIDCOM_LOG_INFO); 442 389 debug_pop(); … … 445 392 } 446 393 447 debug_add("Trying to load NAP data for topic {$topic->name} (#{$topic->id})");448 449 394 // Retrieve a NAP instance 450 395 // if we are missing the component, use the nullcomponent. 451 396 if (!array_key_exists( $topic->component, $_MIDCOM->componentloader->manifests)) 452 397 { 398 debug_push_class(__CLASS__, __FUNCTION__); 453 399 debug_add("The topic {$topic->id} has no component assigned to it, using nullcomponent.", 454 400 MIDCOM_LOG_ERROR); 401 debug_pop(); 455 402 $topic->component = 'midcom.core.nullcomponent'; 456 403 } 457 404 $path = $topic->component; 405 458 406 /* 459 407 if (!$path) … … 470 418 } 471 419 */ 420 472 421 $interface =& $this->_loader->get_interface_class($path); 473 422 if (!$interface) 474 423 { 424 debug_push_class(__CLASS__, __FUNCTION__); 475 425 debug_add("Could not get interface class of '{$path}' to the topic {$topic->id}, cannot add it to the NAP list.", 476 426 MIDCOM_LOG_ERROR); … … 480 430 if (! $interface->set_object($topic)) 481 431 { 432 debug_push_class(__CLASS__, __FUNCTION__); 482 433 debug_add("Could not set the NAP instance of '{$path}' to the topic {$topic->id}, cannot add it to the NAP list.", 483 434 MIDCOM_LOG_ERROR); 435 debug_pop(); 484 436 return null; 485 437 } … … 491 443 if (is_null($nodedata)) 492 444 { 445 debug_push_class(__CLASS__, __FUNCTION__); 493 446 debug_add("The component '{$path}' did return null for the topic {$topic->id}, indicating no NAP information is available."); 494 447 debug_pop(); … … 549 502 $nodedata[MIDCOM_NAV_VISIBLE] = true; 550 503 551 debug_pop();552 504 return $nodedata; 553 505 } … … 602 554 } 603 555 604 // Post process the leaves for URLs and the like. Don't forget NAV_ADMIN/NAV_SITE556 // Post process the leaves for URLs and the like. 605 557 // Rewrite all host dependant URLs based on the relative URL within our topic tree. 606 558 $this->_update_leaflist_urls($leaves); … … 614 566 /** 615 567 * This helper updates the URLs in the reference-passed leaf list. 616 * FULLURL, ABSOLUTEURL and PERMALINK are built upon RELATIVEURL, 617 * NAV_NAME and NAV_URL are populated based on the administration mode with either 618 * NAV_ADMIN or NAV_SITE values. 568 * FULLURL, ABSOLUTEURL and PERMALINK are built upon RELATIVEURL, NAV_NAME 569 * and NAV_URL are populated based on the administration mode with NAV_SITE values 619 570 * 620 571 * @param Array $leaves A reference to the list of leaves which has to be processed. … … 623 574 function _update_leaflist_urls(&$leaves) 624 575 { 625 debug_push_class(__CLASS__, __FUNCTION__);626 627 576 $fullprefix = "{$GLOBALS['midcom_config']['midcom_site_url']}"; 628 577 $absoluteprefix = substr($GLOBALS['midcom_config']['midcom_site_url'], strlen($GLOBALS['midcom']->get_host_name())); … … 630 579 if (! is_array($leaves)) 631 580 { 632 echo "<pre>"; print_r($leaves); echo "</pre>"; 633 die ("wrong type"); 581 debug_push_class(__CLASS__, __FUNCTION__); 582 debug_print_r("Wrong type", $leaves, MIDCOM_LOG_ERROR); 583 debug_pop(); 584 585 $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Wrong type passed for navigation, see error level log for details'); 586 // This will exit 634 587 } 635 588 … … 646 599 $leaves[$id][MIDCOM_NAV_PERMALINK] = $_MIDCOM->permalinks->create_permalink($leaves[$id][MIDCOM_NAV_GUID]); 647 600 } 648 if ($this->_adminmode) 649 { 650 $leaves[$id][MIDCOM_NAV_URL] = $leaves[$id][MIDCOM_NAV_ADMIN][MIDCOM_NAV_URL]; 651 $leaves[$id][MIDCOM_NAV_NAME] = $leaves[$id][MIDCOM_NAV_ADMIN][MIDCOM_NAV_NAME]; 652 } 653 else 601 602 if (!isset($leaves[$id][MIDCOM_NAV_URL])) 654 603 { 655 604 $leaves[$id][MIDCOM_NAV_URL] = $leaves[$id][MIDCOM_NAV_SITE][MIDCOM_NAV_URL]; 605 } 606 if (!isset($leaves[$id][MIDCOM_NAV_NAME])) 607 { 656 608 $leaves[$id][MIDCOM_NAV_NAME] = $leaves[$id][MIDCOM_NAV_SITE][MIDCOM_NAV_NAME]; 657 609 } 658 610 659 611 // In addition, kill the toolbar as this is cached information and thus not relevant for the current user. 660 612 $leaves[$id][MIDCOM_NAV_TOOLBAR] = null; 661 613 } 662 663 debug_pop();664 614 } 665 615 … … 736 686 debug_add("Could not get interface class of '{$node[MIDCOM_NAV_COMPONENT]}' to the topic {$topic->id}, cannot add it to the NAP list.", 737 687 MIDCOM_LOG_ERROR); 688 debug_pop(); 738 689 return null; 739 690 } … … 741 692 { 742 693 debug_print_r('Topic object dump:', $topic); 694 debug_pop(); 743 695 $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 744 696 "Cannot load NAP information, aborting: Could not set the nap instance of {$node[MIDCOM_NAV_COMPONENT]} to the topic {$topic->id}."); … … 798 750 } 799 751 800 // Complete the NAV_SITE and NAV_ADMIN fields if the old-style 801 // root level URL/NAME parameters are set. This automatically overrides 802 // any NAV_SITE/ADMIN settings. 752 // Complete the NAV_SITE if the old-style root level URL/NAME parameters are set. 753 // This automatically overrides any NAV_SITE/ADMIN settings. 803 754 if ( array_key_exists(MIDCOM_NAV_NAME, $leaf) 804 755 && array_key_exists(MIDCOM_NAV_URL, $leaf)) … … 806 757 $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_URL] = $leaf[MIDCOM_NAV_URL]; 807 758 $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_NAME] = $leaf[MIDCOM_NAV_NAME]; 808 $leaf[MIDCOM_NAV_ADMIN][MIDCOM_NAV_URL] = $leaf[MIDCOM_NAV_URL];809 $leaf[MIDCOM_NAV_ADMIN][MIDCOM_NAV_NAME] = $leaf[MIDCOM_NAV_NAME];810 759 } 811 760 … … 814 763 && trim($leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_NAME]) == '') 815 764 { 816 $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_NAME] = $leaf[MIDCOM_NAV_ADMIN][MIDCOM_NAV_URL]; 817 } 818 if ( ! is_null($leaf[MIDCOM_NAV_ADMIN]) 819 && trim($leaf[MIDCOM_NAV_ADMIN][MIDCOM_NAV_NAME]) == '') 820 { 821 $leaf[MIDCOM_NAV_ADMIN][MIDCOM_NAV_NAME] = $leaf[MIDCOM_NAV_ADMIN][MIDCOM_NAV_URL]; 765 $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_NAME] = $_MIDCOM->i18n->get_string('unknown', 'midcom'); 822 766 } 823 767 … … 875 819 debug_pop(); 876 820 return false; 877 }878 879 // If in admin mode, we are always visible now.880 if ($this->_adminmode)881 {882 return true;883 }884 885 // If this is a leaf, we have to do some additional AIS/Non-AIS visibility checks886 if ($napdata[MIDCOM_NAV_TYPE] == 'leaf')887 {888 // Check wether the leaf may be shown in the current mode889 if ( ( $this->_adminmode && is_null($napdata[MIDCOM_NAV_ADMIN]))890 || (! $this->_adminmode && is_null($napdata[MIDCOM_NAV_SITE])))891 {892 return false;893 }894 821 } 895 822 … … 1187 1114 global $midcom_errstr; 1188 1115 1189 debug_push("_basicnav::list_nodes"); 1116 debug_push(__CLASS__, __FUNCTION__); 1117 1190 1118 if (! is_numeric($parent_node)) 1191 1119 { … … 1206 1134 } 1207 1135 1208 $qb = midcom_db_topic::new_query_builder(); 1209 $qb->add_constraint('up', '=', $parent_node); 1210 $qb->add_constraint('component', '<>', ''); 1211 $qb->add_constraint('name', '<>', ''); 1212 if (!$show_noentry) 1213 { 1214 // Hide "noentry" items 1215 $qb->add_constraint('metadata.navnoentry', '=', 0); 1216 } 1217 $qb->add_order('score'); 1218 $qb->add_order('extra'); 1136 // Use the midgard_collector to get the subnodes 1137 $collector = midcom_db_topic::new_collector('up', $parent_node); 1138 $collector->add_value_property('id'); 1139 $collector->add_constraint('up', '=', $parent_node); 1140 $collector->add_constraint('component', '<>', ''); 1141 $collector->add_constraint('name', '<>', ''); 1219 1142 1220 $topics = $qb->execute(); 1143 $collector->add_order('metadata.score', 'DESC'); 1144 $collector->add_order('metadata.created'); 1145 $collector->execute(); 1221 1146 1222 $result = array(); 1147 // Get the GUIDs of the subnodes 1148 $subnodes = $collector->list_keys(); 1223 1149 1224 if (!$topics) 1225 { 1226 debug_add("Could not list topics under #{$parent_node}: " . mgd_errstr(), MIDCOM_LOG_INFO); 1227 debug_pop(); 1228 return $result; 1150 // No results, return an empty array 1151 if (count($subnodes) === 0) 1152 { 1153 return array(); 1229 1154 } 1230 1155 1231 foreach ($topics as $topic) 1232 { 1233 if ($this->_loadNode($topic->id) != MIDCOM_ERROK) 1234 { 1235 debug_add("Node {$topic->id} could not be loaded, ignoring it", MIDCOM_LOG_INFO); 1156 foreach ($subnodes as $guid => $subnode) 1157 { 1158 $id = $collector->get_subkey($guid, 'id'); 1159 1160 if ($this->_loadNode($id) !== MIDCOM_ERROK) 1161 { 1162 debug_add("Node {$id} could not be loaded, ignoring it", MIDCOM_LOG_INFO); 1236 1163 continue; 1237 1164 } 1238 1165 1239 $result[] = $topic->id; 1240 } 1241 /* 1242 TODO: Revert to collector when the bugs in it are fixed 1243 $mc = midcom_db_topic::new_collector('up', $parent_node); 1244 $mc->add_value_property('id'); 1245 $mc->add_value_property('extra'); 1246 $mc->add_constraint('component', '<>', ''); 1247 $mc->add_constraint('name', '<>', ''); 1166 $result[] = $id; 1167 } 1248 1168 1249 if (!$show_noentry)1250 {1251 // Hide "noentry" items1252 $mc->add_constraint('metadata.navnoentry', '=', 0);1253 }1254 1255 $mc->add_order('score');1256 $mc->add_order('extra');1257 //mgd_debug_start();1258 $mc->execute();1259 //mgd_debug_stop();1260 1261 $topics = $mc->list_keys_unchecked();1262 1263 $result = array();1264 1265 if (!$topics)1266 {1267 debug_add("Could not list topics under #{$parent_node}: " . mgd_errstr(), MIDCOM_LOG_INFO);1268 debug_pop();1269 return $result;1270 }1271 1272 1273 foreach ($topics as $topic_guid => $value)1274 {1275 $topic_id = $mc->get_subkey($topic_guid, 'id');1276 if ($this->_loadNode($topic_id) != MIDCOM_ERROK)1277 {1278 debug_add("Node {$topic_id} could not be loaded, ignoring it", MIDCOM_LOG_INFO);1279 continue;1280 }1281 1282 $result[] = $topic_id;1283 }1284 */1285 1169 debug_pop(); 1286 1170 return $result; … … 1514 1398 } 1515 1399 } 1516 1517 1518 1400 ?> trunk/midcom/midcom.core/midcom/helper/nav.php
r11359 r11855 25 25 * @see midcom_helper__basicnav 26 26 */ 27 class midcom_helper_nav { 27 class midcom_helper_nav 28 { 28 29 29 30 /** … … 70 71 * @see midcom_helper__basicnav::get_current_node() 71 72 */ 72 function get_current_node () { 73 function get_current_node () 74 { 73 75 return $this->_basicnav->get_current_node(); 74 76 } … … 78 80 * displayed by the handling topic. If no leaf is active, this function 79 81 * returns FALSE. (Remeber to make a type sensitve check, e.g. 80 * nav::get_current_leaf() !== false to distinguish "0" and "false".)82 * nav::get_current_leaf() !== false to distinguish '0' and 'false'.) 81 83 * 82 84 * @return int The ID of the leaf in question or false on failure. 83 85 * @see midcom_helper__basicnav::get_current_leaf() 84 86 */ 85 function get_current_leaf () { 87 function get_current_leaf () 88 { 86 89 return $this->_basicnav->get_current_leaf(); 87 90 } … … 96 99 * @see midcom_helper__basicnav::get_root_node() 97 100 */ 98 function get_root_node () { 101 function get_root_node () 102 { 99 103 return $this->_basicnav->get_root_node(); 100 104 } … … 141 145 * @see midcom_helper__basicnav::get_node() 142 146 */ 143 function get_node ($node_id) { 147 function get_node ($node_id) 148 { 144 149 return $this->_basicnav->get_node($node_id); 145 150 } … … 154 159 * @see midcom_helper__basicnav::get_leaf() 155 160 */ 156 function get_leaf ($leaf_id) { 161 function get_leaf ($leaf_id) 162 { 157 163 return $this->_basicnav->get_leaf($leaf_id); 158 164 } … … 166 172 * @see midcom_helper__basicnav::get_leaf_uplink() 167 173 */ 168 function get_leaf_uplink ($leaf_id) { 174 function get_leaf_uplink ($leaf_id) 175 { 169 176 return $this->_basicnav->get_leaf_uplink($leaf_id); 170 177 } … … 178 185 * @see midcom_helper__basicnav::get_node_uplink() 179 186 */ 180 function get_node_uplink ($node_id) { 187 function get_node_uplink ($node_id) 188 { 181 189 return $this->_basicnav->get_node_uplink($node_id); 182 190 } … … 196 204 $qb->add_constraint('id', '=', $node_id); 197 205 $qb->add_constraint('up', 'INTREE', $root_id); 206 198 207 if ($qb->count() > 0) 199 208 { 200 209 return true; 201 210 } 211 202 212 return false; 203 213 } … … 228 238 * 229 239 * - MIDCOM_NAV_ID => 0, 230 * - MIDCOM_NAV_TYPE => "node"240 * - MIDCOM_NAV_TYPE => 'node' 231 241 * 232 242 * If there are no child elements at all the method will return an empty array, … … 239 249 function list_child_elements($parent_node_id) 240 250 { 241 debug_push("nav::list_child_elements");242 243 251 // Fetch nodes and leaves 244 252 if (! is_numeric($parent_node_id)) 245 253 { 254 debug_push_class(__CLASS__, __FUNCTION__); 246 255 debug_add("Parameter passed is no integer: [$parent_node_id]", MIDCOM_LOG_ERROR); 247 256 debug_print_type('Type was:', $parent_node_id); … … 256 265 } 257 266 258 $navorder = $parent_topic->parameter( "midcom.helper.nav", "navorder");267 $navorder = $parent_topic->parameter('midcom.helper.nav', 'navorder'); 259 268 260 269 switch ($navorder) … … 284 293 $result = $nav_object->get_sorted_list(); 285 294 286 debug_pop();287 295 return $result; 288 296 } … … 307 315 function resolve_guid ($guid) 308 316 { 309 debug_push_class(__CLASS__, __FUNCTION__);310 debug_add("Checking GUID {$guid}...");311 312 317 // First, check if the GUID is already known by basicnav: 313 314 318 $cached_result = $this->_basicnav->get_loaded_object_by_guid($guid); 315 319 if (! is_null($cached_result)) 316 320 { 317 debug_add('The GUID was already known by the basicnav instance, returning the cached copy directly.'); 321 debug_push_class(__CLASS__, __FUNCTION__); 322 debug_add('The GUID was already known by the basicnav instance, returning the cached copy directly.', MIDCOM_LOG_INFO); 318 323 debug_pop(); 319 324 return $cached_result; … … 326 331 if (! $object) 327 332 { 328 debug_add("Could not load GUID {$guid}, trying to continue anyway. Last error was: " . mgd_errstr(), MIDCOM_LOG_INFO); 333 debug_push_class(__CLASS__, __FUNCTION__); 334 debug_add("Could not load GUID {$guid}, trying to continue anyway. Last error was: " . mgd_errstr(), MIDCOM_LOG_WARN); 335 debug_pop(); 329 336 } 330 337 … … 332 339 && $object->__table__ == 'topic') 333 340 { 334 debug_add("This is a topic.");335 336 341 // Ok. This topic should be within the content tree, 337 342 // we check this and return the node if everything is ok. 338 343 if (! $this->is_node_in_tree($object->id, $this->get_root_node())) 339 344 { 345 debug_push_class(__CLASS__, __FUNCTION__); 340 346 debug_add("NAP::resolve_guid: The Guid {$guid} leads to an unknown topic not in our tree.", MIDCOM_LOG_WARN); 341 debug_print_r( "Retrieved topic was:", $object);347 debug_print_r('Retrieved topic was:', $object); 342 348 debug_pop(); 343 349 return false; … … 350 356 && $object->__table__ == 'article') 351 357 { 352 debug_add("This is an article."); 353 358 debug_push_class(__CLASS__, __FUNCTION__); 354 359 // Ok, let's try to find the article using the topic in the tree. 355 360 if (! $this->is_node_in_tree($object->topic, $this->get_root_node())) 356 361 { 357 362 debug_add("NAP::resolve_guid: The Guid {$guid} leads to an unknown topic not in our tree.", MIDCOM_LOG_WARN); 358 debug_print_r( "Retrieved article was:", $object);363 debug_print_r('Retrieved article was:', $object); 359 364 debug_pop(); 360 365 return false; … … 364 369 if (! $topic) 365 370 { 366 $_MIDCOM->generate_error( 371 $_MIDCOM->generate_error 372 ( 367 373 MIDCOM_ERRCRIT, 368 374 "Data inconsistency, the topic ID ({$object->topic}) of the article {$object->id} is invalid. " 369 . 'Last error was: ' . mgd_errstr()); 375 . 'Last error was: ' . mgd_errstr() 376 ); 370 377 // This will exit. 371 378 } … … 383 390 384 391 debug_add("The Article GUID {$guid} is somehow hidden from the NAP data in its topic, no results shown.", MIDCOM_LOG_INFO); 385 debug_print_r( "Retrieved article was:", $object);392 debug_print_r('Retrieved article was:', $object); 386 393 debug_pop(); 387 394 return false; … … 391 398 // First, we traverse a list of nodes to be checked on by one, avoiding a recursive 392 399 // function call. 393 394 debug_add("This is something else, we'll do a full scan.");395 400 396 401 $unprocessed_node_ids = Array ($this->get_root_node()); … … 415 420 } 416 421 422 debug_push_class(__CLASS__, __FUNCTION__); 417 423 debug_add("We were unable to find the GUID {$guid} in the MidCOM tree even with a full scan."); 418 424 debug_pop(); … … 424 430 425 431 /** 426 * This function provides an interface to construct links like "View this page".432 * This function provides an interface to construct links like 'View this page'. 427 433 * 428 434 * It takes the currently displayed content … … 437 443 // Go upwards step by step and build together the page view URL 438 444 // up to the root topic. 439 $url = "";445 $url = ''; 440 446 if ($this->get_current_leaf() !== false) 441 447 { 442 448 $leaf = $this->get_leaf($this->get_current_leaf()); 443 if (is_null($leaf[MIDCOM_NAV_SITE])) 449 450 if (isset($leaf[MIDCOM_NAV_URL])) 451 { 452 $url = $leaf[MIDCOM_NAV_URL]; 453 } 454 elseif (isset($leaf[MIDCOM_NAV_SITE]) 455 && !is_null($leaf[MIDCOM_NAV_SITE])) 456 { 457 $url = $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_URL]; 458 } 459 else 444 460 { 445 461 return null; 446 462 } 447 $url = $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_URL]; 448 } 449 $nid = $this->get_current_node(); 463 } 464 $node_id = $this->get_current_node(); 450 465 451 466 do 452 467 { 453 $node = $this->get_node($n id);468 $node = $this->get_node($node_id); 454 469 $url = $node[MIDCOM_NAV_URL] . $url; 455 $n id = $this->get_node_uplink($nid);456 if ($n id === false)457 { 458 debug_add( "get_node_uplink failed; view_this_page_url aborting.");470 $node_id = $this->get_node_uplink($node_id); 471 if ($node_id === false) 472 { 473 debug_add('get_node_uplink failed; view_this_page_url aborting.'); 459 474 return false; 460 475 } 461 476 } 462 while($n id != -1);463 464 if (substr($baseurl, -1) == "/")477 while($node_id != -1); 478 479 if (substr($baseurl, -1) === '/') 465 480 { 466 481 return $baseurl . $url; 467 482 } 468 483 469 return $baseurl . "/" . $url;484 return "{$baseurl}/{$url}"; 470 485 } 471 486 … … 473 488 * Construct a breadcrumb line. 474 489 * 475 * Gives you a line like "Start > Topic1 > Topic2 > Article"using NAP to490 * Gives you a line like 'Start > Topic1 > Topic2 > Article' using NAP to 476 491 * traverse upwards till the root node. $separator is inserted between the 477 492 * pairs, $class, if non-null, will be used as CSS-class for the A-Tags. … … 485 500 * @param string $separator The separator to use between the elements. 486 501 * @param string $class If not-null, it will be assigned to all A tags. 487 * @param int $skip_levels The number of topic levels to skip before starting to work (use this to skip "Home"links etc.).502 * @param int $skip_levels The number of topic levels to skip before starting to work (use this to skip 'Home' links etc.). 488 503 * @param string $current_class The class that should be assigned to the currently active element. 489 504 * @return string The computed breadrumb line. 490 505 */ 491 function get_breadcrumb_line ($separator = " > ", $class = null, $skip_levels = 0, $current_class = null)506 function get_breadcrumb_line ($separator = ' > ', $class = null, $skip_levels = 0, $current_class = null) 492 507 { 493 508 $breadcrumb_data = $this->get_breadcrumb_data(); … … 546 561 * 547 562 * Gives you the data needed to construct a line like 548 * "Start > Topic1 > Topic2 > Article"using NAP to563 * 'Start > Topic1 > Topic2 > Article' using NAP to 549 564 * traverse upwards till the root node. The components custom breadcrumb 550 565 * data is inserted at the end of the computed breadcrumb line after any … … 568 583 * 569 584 * The entry of every level is indexed by its MIDCOM_NAV_ID, where custom keys preserve 570 * their original key (as passed by the component) and prefixing it with "custom-". This585 * their original key (as passed by the component) and prefixing it with 'custom-'. This 571 586 * allows you to easily check if a given node/leave is within the current breadcrumb-line 572 587 * by checking with array_key_exists. (mgd_is_in_topic_tree was originally used for this … … 707 722 return $result; 708 723 } 709 710 724 } 711 712 725 ?>
