Changeset 11855

Show
Ignore:
Timestamp:
08/30/07 12:10:21 (1 year ago)
Author:
adrenalin
Message:

Dropping out excessive debug logs and using midgard_collector instead
of midgard_query_builder

refs #102

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/helper/_basicnav.php

    r11359 r11855  
    5656 * Basically for each leaf the usual meta information is returned: 
    5757 * 
     58 * - MIDCOM_NAV_URL      => URL of the leaf element 
     59 * - MIDCOM_NAV_NAME     => Name of the leaf element 
    5860 * - MIDCOM_META_CREATOR => Creator of the element (MidgardPerson) 
    5961 * - MIDCOM_META_CREATED => Creation date (UNIX Timestamp) 
     
    6365 * - MIDCOM_NAV_TOOLBAR  => Toolbar data (see below) 
    6466 * 
    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 *  
    7673 * <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 * ), 
    8079 * </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 
    11582 * (1) by copying the values. 
    11683 * 
     
    149116 * <b>DEPRECATED INFORMATION</b> 
    150117 * 
    151  * The key MIDCOM_NAV_VISIBLE is deprecated from MidCOM 2.4.0 on, visibility is taken into account 
     118 * Key MIDCOM_NAV_VISIBLE is deprecated from MidCOM 2.4.0 on, visibility is taken into account 
    152119 * automatically. The key is set to true for all values now for backwards compatibility and will 
    153120 * 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 *  
    156126 * @package midcom 
    157127 */ 
     
    253223 
    254224    /** 
    255      * This one is true, if the system is in content administration mode and therefore 
    256      * working with a different topic. See Constructor Documentation for details. 
    257      * 
    258      * @var bool 
    259      */ 
    260     var $_adminmode; 
    261  
    262     /** 
    263225     * This is a temporary storage where _loadNode can return the last known good 
    264226     * node in case the current node not visible. It is evaluated by the 
     
    301263    function midcom_helper__basicnav($context = 0) 
    302264    { 
    303         debug_push("_basicnav::constructor"); 
    304  
    305265        $tmp = $_MIDCOM->get_context_data($context, MIDCOM_CONTEXT_ROOTTOPIC); 
    306266        $this->_root = $tmp->id; 
     
    312272        $this->_nodes = array(); 
    313273        $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         else 
    319         { 
    320             $this->_adminmode = false; 
    321         } 
    322274 
    323275        $current = $_MIDCOM->get_context_data($context, MIDCOM_CONTEXT_CONTENTTOPIC); 
     
    340292 
    341293            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 
    344295                $this->_current = $this->_lastgoodnode; 
    345296                break; 
    346297 
    347298            default: 
     299                debug_push("_basicnav::constructor"); 
    348300                debug_add("_loadNode failed, see above error for details.", MIDCOM_LOG_ERROR); 
    349301                debug_pop(); 
     
    353305        // Reset the Root node's URL Parameter to an empty string. 
    354306        $this->_nodes[$this->_root][MIDCOM_NAV_URL] = ''; 
    355  
    356         debug_pop(); 
    357307    } 
    358308 
     
    371321    function _get_node($id) 
    372322    { 
    373         debug_push_class(__CLASS__, __FUNCTION__); 
    374  
    375323        /* 
    376324        $this->_nap_cache->open(); 
     
    396344        if (is_null($nodedata)) 
    397345        { 
     346            debug_push_class(__CLASS__, __FUNCTION__); 
    398347            debug_add('We got NULL for this node, so we do not have any NAP information, returning null directly.'); 
    399348            debug_pop(); 
     
    410359        $nodedata[MIDCOM_NAV_TOOLBAR] = null; 
    411360 
    412         debug_pop(); 
    413361        return $nodedata; 
    414362    } 
     
    426374    function _get_node_from_database($node) 
    427375    { 
    428         debug_push_class(__CLASS__, __FUNCTION__); 
    429  
    430376        if (is_object($node)) 
    431377        { 
     
    436382            // Load the topic first. 
    437383            $topic = new midcom_db_topic($node); 
    438             if (   ! $topic 
     384            if (   !$topic 
    439385                || !$topic->guid) 
    440386            { 
     387                debug_push_class(__CLASS__, __FUNCTION__); 
    441388                debug_add("Could not load the topic {$node} through DBA; assuming missing privileges.", MIDCOM_LOG_INFO); 
    442389                debug_pop(); 
     
    445392        } 
    446393 
    447         debug_add("Trying to load NAP data for topic {$topic->name} (#{$topic->id})"); 
    448  
    449394        // Retrieve a NAP instance 
    450395        // if we are missing the component, use the nullcomponent. 
    451396        if (!array_key_exists( $topic->component, $_MIDCOM->componentloader->manifests))  
    452397        { 
     398            debug_push_class(__CLASS__, __FUNCTION__); 
    453399            debug_add("The topic {$topic->id} has no component assigned to it, using nullcomponent.", 
    454400                MIDCOM_LOG_ERROR); 
     401            debug_pop(); 
    455402            $topic->component = 'midcom.core.nullcomponent'; 
    456403        } 
    457404        $path = $topic->component; 
     405         
    458406        /* 
    459407        if (!$path) 
     
    470418        } 
    471419        */ 
     420         
    472421        $interface =& $this->_loader->get_interface_class($path); 
    473422        if (!$interface) 
    474423        { 
     424            debug_push_class(__CLASS__, __FUNCTION__); 
    475425            debug_add("Could not get interface class of '{$path}' to the topic {$topic->id}, cannot add it to the NAP list.", 
    476426                MIDCOM_LOG_ERROR); 
     
    480430        if (! $interface->set_object($topic)) 
    481431        { 
     432            debug_push_class(__CLASS__, __FUNCTION__); 
    482433            debug_add("Could not set the NAP instance of '{$path}' to the topic {$topic->id}, cannot add it to the NAP list.", 
    483434                MIDCOM_LOG_ERROR); 
     435            debug_pop(); 
    484436            return null; 
    485437        } 
     
    491443        if (is_null($nodedata)) 
    492444        { 
     445            debug_push_class(__CLASS__, __FUNCTION__); 
    493446            debug_add("The component '{$path}' did return null for the topic {$topic->id}, indicating no NAP information is available."); 
    494447            debug_pop(); 
     
    549502        $nodedata[MIDCOM_NAV_VISIBLE] = true; 
    550503 
    551         debug_pop(); 
    552504        return $nodedata; 
    553505    } 
     
    602554        } 
    603555 
    604         // Post process the leaves for URLs and the like. Don't forget NAV_ADMIN/NAV_SITE 
     556        // Post process the leaves for URLs and the like. 
    605557        // Rewrite all host dependant URLs based on the relative URL within our topic tree. 
    606558        $this->_update_leaflist_urls($leaves); 
     
    614566    /** 
    615567     * 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 
    619570     * 
    620571     * @param Array $leaves A reference to the list of leaves which has to be processed. 
     
    623574    function _update_leaflist_urls(&$leaves) 
    624575    { 
    625         debug_push_class(__CLASS__, __FUNCTION__); 
    626  
    627576        $fullprefix = "{$GLOBALS['midcom_config']['midcom_site_url']}"; 
    628577        $absoluteprefix = substr($GLOBALS['midcom_config']['midcom_site_url'], strlen($GLOBALS['midcom']->get_host_name())); 
     
    630579        if (! is_array($leaves)) 
    631580        { 
    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 
    634587        } 
    635588 
     
    646599                $leaves[$id][MIDCOM_NAV_PERMALINK] = $_MIDCOM->permalinks->create_permalink($leaves[$id][MIDCOM_NAV_GUID]); 
    647600            } 
    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])) 
    654603            { 
    655604                $leaves[$id][MIDCOM_NAV_URL] = $leaves[$id][MIDCOM_NAV_SITE][MIDCOM_NAV_URL]; 
     605            } 
     606            if (!isset($leaves[$id][MIDCOM_NAV_NAME])) 
     607            { 
    656608                $leaves[$id][MIDCOM_NAV_NAME] = $leaves[$id][MIDCOM_NAV_SITE][MIDCOM_NAV_NAME]; 
    657609            } 
    658  
     610             
    659611            // In addition, kill the toolbar as this is cached information and thus not relevant for the current user. 
    660612            $leaves[$id][MIDCOM_NAV_TOOLBAR] = null; 
    661613        } 
    662  
    663         debug_pop(); 
    664614    } 
    665615 
     
    736686            debug_add("Could not get interface class of '{$node[MIDCOM_NAV_COMPONENT]}' to the topic {$topic->id}, cannot add it to the NAP list.", 
    737687                MIDCOM_LOG_ERROR); 
     688            debug_pop(); 
    738689            return null; 
    739690        } 
     
    741692        { 
    742693            debug_print_r('Topic object dump:', $topic); 
     694            debug_pop(); 
    743695            $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 
    744696                "Cannot load NAP information, aborting: Could not set the nap instance of {$node[MIDCOM_NAV_COMPONENT]} to the topic {$topic->id}."); 
     
    798750            } 
    799751 
    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. 
    803754            if (   array_key_exists(MIDCOM_NAV_NAME, $leaf) 
    804755                && array_key_exists(MIDCOM_NAV_URL, $leaf)) 
     
    806757                $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_URL] = $leaf[MIDCOM_NAV_URL]; 
    807758                $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]; 
    810759            } 
    811760 
     
    814763                && trim($leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_NAME]) == '') 
    815764            { 
    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'); 
    822766            } 
    823767 
     
    875819            debug_pop(); 
    876820            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 checks 
    886         if ($napdata[MIDCOM_NAV_TYPE] == 'leaf') 
    887         { 
    888             // Check wether the leaf may be shown in the current mode 
    889             if (   (  $this->_adminmode && is_null($napdata[MIDCOM_NAV_ADMIN])) 
    890                 || (! $this->_adminmode && is_null($napdata[MIDCOM_NAV_SITE]))) 
    891             { 
    892                 return false; 
    893             } 
    894821        } 
    895822 
     
    11871114        global $midcom_errstr; 
    11881115 
    1189         debug_push("_basicnav::list_nodes"); 
     1116        debug_push(__CLASS__, __FUNCTION__); 
     1117         
    11901118        if (! is_numeric($parent_node)) 
    11911119        { 
     
    12061134        } 
    12071135         
    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', '<>', ''); 
    12191142         
    1220         $topics = $qb->execute(); 
     1143        $collector->add_order('metadata.score', 'DESC'); 
     1144        $collector->add_order('metadata.created'); 
     1145        $collector->execute(); 
    12211146         
    1222         $result = array(); 
     1147        // Get the GUIDs of the subnodes 
     1148        $subnodes = $collector->list_keys(); 
    12231149         
    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(); 
    12291154        } 
    12301155         
    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); 
    12361163                continue; 
    12371164            } 
    12381165 
    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        } 
    12481168         
    1249         if (!$show_noentry) 
    1250         { 
    1251             // Hide "noentry" items 
    1252             $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         */ 
    12851169        debug_pop(); 
    12861170        return $result; 
     
    15141398    } 
    15151399} 
    1516  
    1517  
    15181400?> 
  • trunk/midcom/midcom.core/midcom/helper/nav.php

    r11359 r11855  
    2525 * @see midcom_helper__basicnav 
    2626 */ 
    27 class midcom_helper_nav { 
     27class midcom_helper_nav 
     28
    2829 
    2930    /** 
     
    7071     * @see midcom_helper__basicnav::get_current_node() 
    7172     */ 
    72     function get_current_node () { 
     73    function get_current_node () 
     74    { 
    7375        return $this->_basicnav->get_current_node(); 
    7476    } 
     
    7880     * displayed by the handling topic. If no leaf is active, this function 
    7981     * 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'.) 
    8183     * 
    8284     * @return int      The ID of the leaf in question or false on failure. 
    8385     * @see midcom_helper__basicnav::get_current_leaf() 
    8486     */ 
    85     function get_current_leaf () { 
     87    function get_current_leaf () 
     88    { 
    8689        return $this->_basicnav->get_current_leaf(); 
    8790    } 
     
    9699     * @see midcom_helper__basicnav::get_root_node() 
    97100     */ 
    98     function get_root_node () { 
     101    function get_root_node () 
     102    { 
    99103        return $this->_basicnav->get_root_node(); 
    100104    } 
     
    141145     * @see midcom_helper__basicnav::get_node() 
    142146     */ 
    143     function get_node ($node_id) { 
     147    function get_node ($node_id) 
     148    { 
    144149        return $this->_basicnav->get_node($node_id); 
    145150    } 
     
    154159     * @see midcom_helper__basicnav::get_leaf() 
    155160     */ 
    156     function get_leaf ($leaf_id) { 
     161    function get_leaf ($leaf_id) 
     162    { 
    157163        return $this->_basicnav->get_leaf($leaf_id); 
    158164    } 
     
    166172     * @see midcom_helper__basicnav::get_leaf_uplink() 
    167173     */ 
    168     function get_leaf_uplink ($leaf_id) { 
     174    function get_leaf_uplink ($leaf_id) 
     175    { 
    169176        return $this->_basicnav->get_leaf_uplink($leaf_id); 
    170177    } 
     
    178185     * @see midcom_helper__basicnav::get_node_uplink() 
    179186     */ 
    180     function get_node_uplink ($node_id) { 
     187    function get_node_uplink ($node_id) 
     188    { 
    181189        return $this->_basicnav->get_node_uplink($node_id); 
    182190    } 
     
    196204        $qb->add_constraint('id', '=', $node_id); 
    197205        $qb->add_constraint('up', 'INTREE', $root_id); 
     206         
    198207        if ($qb->count() > 0) 
    199208        { 
    200209            return true; 
    201210        } 
     211         
    202212        return false; 
    203213    } 
     
    228238     * 
    229239     * - MIDCOM_NAV_ID => 0, 
    230      * - MIDCOM_NAV_TYPE => "node" 
     240     * - MIDCOM_NAV_TYPE => 'node' 
    231241     * 
    232242     * If there are no child elements at all the method will return an empty array, 
     
    239249    function list_child_elements($parent_node_id) 
    240250    { 
    241         debug_push("nav::list_child_elements"); 
    242  
    243251        // Fetch nodes and leaves 
    244252        if (! is_numeric($parent_node_id)) 
    245253        { 
     254            debug_push_class(__CLASS__, __FUNCTION__); 
    246255            debug_add("Parameter passed is no integer: [$parent_node_id]", MIDCOM_LOG_ERROR); 
    247256            debug_print_type('Type was:', $parent_node_id); 
     
    256265        } 
    257266 
    258         $navorder = $parent_topic->parameter("midcom.helper.nav", "navorder"); 
     267        $navorder = $parent_topic->parameter('midcom.helper.nav', 'navorder'); 
    259268 
    260269        switch ($navorder) 
     
    284293        $result = $nav_object->get_sorted_list(); 
    285294 
    286         debug_pop(); 
    287295        return $result; 
    288296    } 
     
    307315    function resolve_guid ($guid) 
    308316    { 
    309         debug_push_class(__CLASS__, __FUNCTION__); 
    310         debug_add("Checking GUID {$guid}..."); 
    311  
    312317        // First, check if the GUID is already known by basicnav: 
    313  
    314318        $cached_result = $this->_basicnav->get_loaded_object_by_guid($guid); 
    315319        if (! is_null($cached_result)) 
    316320        { 
    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); 
    318323            debug_pop(); 
    319324            return $cached_result; 
     
    326331        if (! $object) 
    327332        { 
    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(); 
    329336        } 
    330337 
     
    332339            && $object->__table__ == 'topic') 
    333340        { 
    334             debug_add("This is a topic."); 
    335  
    336341            // Ok. This topic should be within the content tree, 
    337342            // we check this and return the node if everything is ok. 
    338343            if (! $this->is_node_in_tree($object->id, $this->get_root_node())) 
    339344            { 
     345                debug_push_class(__CLASS__, __FUNCTION__); 
    340346                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); 
    342348                debug_pop(); 
    343349                return false; 
     
    350356            && $object->__table__ == 'article') 
    351357        { 
    352             debug_add("This is an article."); 
    353  
     358            debug_push_class(__CLASS__, __FUNCTION__); 
    354359            // Ok, let's try to find the article using the topic in the tree. 
    355360            if (! $this->is_node_in_tree($object->topic, $this->get_root_node())) 
    356361            { 
    357362                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); 
    359364                debug_pop(); 
    360365                return false; 
     
    364369            if (! $topic) 
    365370            { 
    366                 $_MIDCOM->generate_error( 
     371                $_MIDCOM->generate_error 
     372                ( 
    367373                    MIDCOM_ERRCRIT, 
    368374                    "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                ); 
    370377                // This will exit. 
    371378            } 
     
    383390 
    384391            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); 
    386393            debug_pop(); 
    387394            return false; 
     
    391398        // First, we traverse a list of nodes to be checked on by one, avoiding a recursive 
    392399        // function call. 
    393  
    394         debug_add("This is something else, we'll do a full scan."); 
    395400 
    396401        $unprocessed_node_ids = Array ($this->get_root_node()); 
     
    415420        } 
    416421 
     422        debug_push_class(__CLASS__, __FUNCTION__); 
    417423        debug_add("We were unable to find the GUID {$guid} in the MidCOM tree even with a full scan."); 
    418424        debug_pop(); 
     
    424430 
    425431    /** 
    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'
    427433     * 
    428434     * It takes the currently displayed content 
     
    437443        // Go upwards step by step and build together the page view URL 
    438444        // up to the root topic. 
    439         $url = ""
     445        $url = ''
    440446        if ($this->get_current_leaf() !== false) 
    441447        { 
    442448            $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 
    444460            { 
    445461                return null; 
    446462            } 
    447             $url = $leaf[MIDCOM_NAV_SITE][MIDCOM_NAV_URL]; 
    448         } 
    449         $nid = $this->get_current_node(); 
     463        } 
     464        $node_id = $this->get_current_node(); 
    450465 
    451466        do 
    452467        { 
    453             $node = $this->get_node($nid); 
     468            $node = $this->get_node($node_id); 
    454469            $url = $node[MIDCOM_NAV_URL] . $url; 
    455             $nid = $this->get_node_uplink($nid); 
    456             if ($nid === 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.'); 
    459474                return false; 
    460475            } 
    461476        } 
    462         while($nid != -1); 
    463  
    464         if (substr($baseurl, -1) == "/"
     477        while($node_id != -1); 
     478 
     479        if (substr($baseurl, -1) === '/'
    465480        { 
    466481            return $baseurl . $url; 
    467482        } 
    468483 
    469         return $baseurl . "/" . $url
     484        return "{$baseurl}/{$url}"
    470485    } 
    471486 
     
    473488     * Construct a breadcrumb line. 
    474489     * 
    475      * Gives you a line like "Start > Topic1 > Topic2 > Article" using NAP to 
     490     * Gives you a line like 'Start > Topic1 > Topic2 > Article' using NAP to 
    476491     * traverse upwards till the root node. $separator is inserted between the 
    477492     * pairs, $class, if non-null, will be used as CSS-class for the A-Tags. 
     
    485500     * @param string    $separator              The separator to use between the elements. 
    486501     * @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.). 
    488503     * @param string    $current_class  The class that should be assigned to the currently active element. 
    489504     * @return string   The computed breadrumb line. 
    490505     */ 
    491     function get_breadcrumb_line ($separator = " &gt; ", $class = null, $skip_levels = 0, $current_class = null) 
     506    function get_breadcrumb_line ($separator = ' &gt; ', $class = null, $skip_levels = 0, $current_class = null) 
    492507    { 
    493508        $breadcrumb_data = $this->get_breadcrumb_data(); 
     
    546561     * 
    547562     * Gives you the data needed to construct a line like 
    548      * "Start > Topic1 > Topic2 > Article" using NAP to 
     563     * 'Start > Topic1 > Topic2 > Article' using NAP to 
    549564     * traverse upwards till the root node. The components custom breadcrumb 
    550565     * data is inserted at the end of the computed breadcrumb line after any 
     
    568583     * 
    569584     * 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-". This 
     585     * their original key (as passed by the component) and prefixing it with 'custom-'. This 
    571586     * allows you to easily check if a given node/leave is within the current breadcrumb-line 
    572587     * by checking with array_key_exists. (mgd_is_in_topic_tree was originally used for this 
     
    707722        return $result; 
    708723    } 
    709  
    710724} 
    711  
    712725?>