Changeset 11900

Show
Ignore:
Timestamp:
08/30/07 18:49:48 (1 year ago)
Author:
bergie
Message:

Minor API cleanup, removing unnecessary comments. refs #102

Files:

Legend:

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

    r11889 r11900  
    767767     * 
    768768     * _process               - CANHANDLE->HANDLE || ATTACHMENT_OUTPUT 
    769      * _checkobject           - CANHANDLE 
     769     * _can_handle           - CANHANDLE 
    770770     * _loadconfig            - CANHANDLE 
    771771     * _handle                - HANDLE 
     
    783783     * Details: The logic will traverse the node tree and for each node it will load 
    784784     * the component that is responsible for it. This component gets the chance to 
    785      * acceppt the request (this is encaspulated in the _checkobject call), which is 
     785     * acceppt the request (this is encaspulated in the _can_handle call), which is 
    786786     * basically a call to can_handle. If the component declares to be able to handle 
    787787     * the call, its handle function is executed. Depending if the handle was successful 
     
    924924            // If so, execute it, if not, continue. 
    925925 
    926             if ($this->_checkobject($object))  
     926            if ($this->_can_handle($object))  
    927927            { 
    928928                $this->_status = MIDCOM_STATUS_HANDLE; 
     
    10021002     * Handle the request. 
    10031003     * 
    1004      * _handle is called after _checkobject determined, that 
     1004     * _handle is called after _can_handle determined, that 
    10051005     * a component can handle a request. The URL of the component that is used 
    10061006     * to handle the request is obtained automatically. The parameter $path is 
     
    10971097     * @access private 
    10981098     */ 
    1099     private function _checkobject($object) 
     1099    private function _can_handle($object) 
    11001100    { 
    11011101        debug_push_class(__CLASS__, __FUNCTION__); 
     
    11031103        $path = $this->get_context_data(MIDCOM_CONTEXT_COMPONENT); 
    11041104 
    1105         $adminmode = false; 
     1105        // Request type safety check 
    11061106        if ($this->_context[$this->_currentcontext][MIDCOM_CONTEXT_REQUESTTYPE] != MIDCOM_REQUEST_CONTENT) 
    11071107        { 
    11081108            debug_add("Unkown Request Type encountered:" . $this->_context[$this->current_context][MIDCOM_CONTEXT_REQUESTTYPE], MIDCOM_LOG_ERROR); 
     1109            debug_pop(); 
    11091110            $this->generate_error(MIDCOM_ERRCRIT, "Unkown Request Type encountered:" . $this->_context[$this->current_context][MIDCOM_CONTEXT_REQUESTTYPE]); 
    11101111        } 
    11111112         
    1112         $concept_component =& $this->componentloader->get_component_class($path); 
    1113         if ($concept_component === null)  
     1113        // Get component interface class 
     1114        $component_interface =& $this->componentloader->get_interface_class($path); 
     1115        if ($component_interface === null)  
    11141116        { 
    11151117            $path = 'midcom.core.nullcomponent'; 
    11161118            $this->_set_context_data($path, MIDCOM_CONTEXT_COMPONENT); 
    1117             $concept_component =& $this->componentloader->get_component_class($path); 
    1118         } 
    1119  
     1119            $component_interface =& $this->componentloader->get_interface_class($path); 
     1120        } 
     1121 
     1122        // Load configuration 
    11201123        $config_obj =& $this->_loadconfig($object); 
    11211124        $config = ($config_obj == false) ? array() : $config_obj->get_all(); 
    1122  
    1123         if (! $concept_component->configure($config, $this->_currentcontext, $adminmode)) 
    1124         { 
    1125             debug_add ("Component Configuration failed: " . $concept_component->errstr($this->_currentcontext), MIDCOM_LOG_ERROR); 
    1126             $this->generate_error(MIDCOM_ERRCRIT, "Component Configuration failed: " . $concept_component->errstr($this->_currentcontext)); 
    1127         } 
    1128  
    1129         if ($concept_component->can_handle($object, $this->_parser->argc, $this->_parser->argv, $this->_currentcontext)) 
    1130         { 
    1131             debug_add("Component $path will handle request.", MIDCOM_LOG_INFO); 
     1125        if (! $component_interface->configure($config, $this->_currentcontext)) 
     1126        { 
     1127            debug_add ("Component Configuration failed: " . $component_interface->errstr($this->_currentcontext), MIDCOM_LOG_ERROR); 
    11321128            debug_pop(); 
    1133             return true; 
    1134         } 
    1135         else 
    1136         { 
    1137             debug_add("Component $path declared unable to handle request.", MIDCOM_LOG_INFO); 
     1129            $this->generate_error(MIDCOM_ERRCRIT, "Component Configuration failed: " . $component_interface->errstr($this->_currentcontext)); 
     1130        } 
     1131 
     1132        // Make can_handle check 
     1133        if (!$component_interface->can_handle($object, $this->_parser->argc, $this->_parser->argv, $this->_currentcontext)) 
     1134        { 
     1135            debug_add("Component {$path} in {$object->name} declared unable to handle request.", MIDCOM_LOG_INFO); 
    11381136            debug_pop(); 
    11391137            return false; 
    11401138        } 
     1139         
     1140        debug_add("Component {$path} in {$object->name} will handle request.", MIDCOM_LOG_INFO); 
     1141        debug_pop(); 
     1142        return true; 
    11411143    } 
    11421144 
     
    11541156    private function & _loadconfig($object)  
    11551157    { 
    1156         debug_push("midcom_application::_loadconfig"); 
    1157  
    11581158        $path = $this->get_context_data(MIDCOM_CONTEXT_COMPONENT); 
    1159         debug_add("Trying to load configuration for $path", MIDCOM_LOG_DEBUG); 
    11601159        $result = new midcom_helper_configuration($object, $path); 
    11611160        return $result; 
     
    11981197        } 
    11991198         
    1200         $component =& $this->componentloader->get_component_class($this->get_context_data(MIDCOM_CONTEXT_COMPONENT)); 
     1199        $component =& $this->componentloader->get_interface_class($this->get_context_data(MIDCOM_CONTEXT_COMPONENT)); 
    12011200        $component->show_content($this->_currentcontext); 
    12021201 
  • trunk/midcom/midcom.core/midcom/baseclasses/components/interface.php

    r11860 r11900  
    539539     * @return bool Indication success. 
    540540     */ 
    541     function configure($configuration, $contextid, $adminmode = false
     541    function configure($configuration, $contextid
    542542    { 
    543543        // Initialize the context data 
     
    565565 
    566566        $data['handler'] = null; 
    567         $data['adminmode'] = $adminmode; 
    568567 
    569568        return true; 
  • trunk/midcom/midcom.core/midcom/helper/_componentloader.php

    r11816 r11900  
    491491 
    492492        return $this->_interface_classes[$path]; 
    493     } 
    494  
    495  
    496     /** 
    497      * Returns a reference to an instance of the specified component's 
    498      * COMPONENT class. The component is given in $path as a MidCOM 
    499      * path. Such an instance will be cached by the framework so that 
    500      * only one instance is always active for each component. Missing 
    501      * components will be dynamically loaded into memory. 
    502      * 
    503      * 
    504      * @param string $path      The component name. 
    505      * @return mixed            A reference to the concept class in question or null if the component is missing. 
    506      * @deprecated This has been deprecated in MidCOM 2.4 in favor of the new component interface classes. 
    507      */ 
    508     function & get_component_class($path) 
    509     { 
    510         debug_push_class(__CLASS__, __FUNCTION__); 
    511         debug_add("Warning, this method is deprecated, you should use the new component interface instead.", 
    512             MIDCOM_LOG_DEBUG); 
    513         debug_pop(); 
    514  
    515         global $midcom; 
    516  
    517         $prefix = $this->path_to_prefix($path); 
    518         // return null if the component is missing. 
    519         if (! $this->is_loaded($path) && ! $this->_load($path)) 
    520         { 
    521             debug_pop( ); 
    522             $ret = null;  
    523             return $ret; 
    524         } 
    525  
    526         if (is_null ($this->_component_classes[$path])) 
    527         { 
    528             debug_push("midcom_helper__componentloader::get_component_class"); 
    529  
    530             if ($this->manifests[$path]->purecode) 
    531             { 
    532                 $GLOBALS['midcom_errstr'] = "Cannot retrieve the COMPONENT concept of the pure code library $path."; 
    533                 debug_add($GLOBALS['midcom_errstr'], MIDCOM_LOG_CRIT); 
    534                 $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    535                 // This will exit. 
    536             } 
    537  
    538             debug_add("Instantinating " . $prefix . "_component.", MIDCOM_LOG_DEBUG); 
    539             eval("\$this->_component_classes[\$path] = new " . $prefix . "_component();"); 
    540  
    541             if ($this->_component_classes[$path] === false) 
    542             { 
    543                 $GLOBALS['midcom_errstr'] = "Could not instantinate " . $prefix . "_component."; 
    544                 debug_add($GLOBALS['midcom_errstr'], MIDCOM_LOG_CRIT); 
    545                 $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    546                 // This will exit. 
    547             } 
    548  
    549             debug_pop(); 
    550         } 
    551  
    552         return $this->_component_classes[$path]; 
    553     } 
    554  
    555     /** 
    556      * Returns a reference to an instance of the specified component's 
    557      * Content Admin COMPONENT class. The component is given in $path 
    558      * as a MidCOM path. Such an instance will be cached by the 
    559      * framework so that only one instance is always active for each 
    560      * component. Missing components will be dynamically loaded into 
    561      * memory. 
    562      * 
    563      * @param string $path      The component name. 
    564      * @return mixed            A reference to the concept class in question. 
    565      * @deprecated This has been deprecated in MidCOM 2.4 in favor of the new component interface classes. 
    566      */ 
    567     function & get_contentadmin_class($path) 
    568     { 
    569         debug_push_class(__CLASS__, __FUNCTION__); 
    570         debug_add("Warning, this method is deprecated, you should use the new component interface instead.", 
    571             MIDCOM_LOG_DEBUG); 
    572         debug_pop(); 
    573  
    574         global $midcom; 
    575         $prefix = $this->path_to_prefix($path); 
    576  
    577         if (! $this->is_loaded($path) && ! $this->_load($path)) 
    578         { 
    579             $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    580             // This will exit. 
    581         } 
    582  
    583         if (is_null ($this->_contentadmin_classes[$path])) 
    584         { 
    585             debug_push("midcom_helper__componentloader::get_contentadmin_class"); 
    586  
    587             if ($this->manifests[$path]->purecode) 
    588             { 
    589                 $GLOBALS['midcom_errstr'] = "Cannot retrieve the Content Admin COMPONENT concept of the pure code library $path."; 
    590                 debug_add($GLOBALS['midcom_errstr'], MIDCOM_LOG_CRIT); 
    591                 $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    592                 // This will exit. 
    593             } 
    594  
    595             if (! class_exists ($prefix . "_contentadmin")) 
    596             { 
    597                 $GLOBALS['midcom_errstr'] = "Class " . $prefix . "_contentadmin does not exist."; 
    598                 debug_add($GLOBALS['midcom_errstr'], MIDCOM_LOG_CRIT); 
    599                 $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    600                 // This will exit. 
    601             } 
    602  
    603             debug_add("Instantinating " . $prefix . "_contentadmin."); 
    604             eval("\$this->_contentadmin_classes[\$path] = new " . $prefix . "_contentadmin();"); 
    605  
    606             if ($this->_contentadmin_classes[$path] === false) 
    607             { 
    608                 $GLOBALS['midcom_errstr'] = "Could not instantinate " . $prefix . "_contentadmin."; 
    609                 debug_add($GLOBALS['midcom_errstr'], MIDCOM_LOG_CRIT); 
    610                 $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    611                 // This will exit. 
    612             } 
    613  
    614             debug_pop(); 
    615         } 
    616  
    617         return $this->_contentadmin_classes[$path]; 
    618     } 
    619  
    620     /** 
    621      * Returns a reference to an instance of the specified component's 
    622      * NAP class. The component is given in $path as a MidCOM 
    623      * path. Such an instance will be cached by the framework so that 
    624      * only one instance is always active for each component. Missing 
    625      * components will be dynamically loaded into memory. 
    626      * 
    627      * @param string $path      The component name. 
    628      * @return mixed            A reference to the concept class in question. 
    629      * @deprecated This has been deprecated in MidCOM 2.4 in favor of the new component interface classes. 
    630      */ 
    631     function & get_nap_class($path) 
    632     { 
    633         debug_push_class(__CLASS__, __FUNCTION__); 
    634         debug_add("Warning, this method is deprecated, you should use the new component ". 
    635                   "interface instead. (hint: get_interface_class()) ", 
    636             MIDCOM_LOG_DEBUG); 
    637         debug_pop(); 
    638  
    639         global $midcom; 
    640  
    641         $prefix = $this->path_to_prefix($path); 
    642  
    643         if (! $this->is_loaded($path) && ! $this->_load($path)) 
    644         { 
    645             $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    646             // This will exit. 
    647         } 
    648  
    649         if (is_null ($this->_nap_classes[$path])) 
    650         { 
    651             debug_push ("midcom_helper__componentloader::get_nap_class"); 
    652  
    653             if ($this->manifests[$path]->purecode) 
    654             { 
    655                 $GLOBALS['midcom_errstr'] = "Cannot retrieve the NAP concept of the pure code library $path."; 
    656                 debug_add($GLOBALS['midcom_errstr'], MIDCOM_LOG_CRIT); 
    657                 $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    658                 // This will exit. 
    659             } 
    660  
    661             debug_add("Instantinating " . $prefix . "_nap.", MIDCOM_LOG_DEBUG); 
    662             eval("\$this->_nap_classes[\$path] = new " . $prefix . "_nap();"); 
    663  
    664             if ($this->_nap_classes[$path] === false) 
    665             { 
    666                 $GLOBALS['midcom_errstr'] = "Could not instantinate " . $prefix . "_nap."; 
    667                 debug_add($GLOBALS['midcom_errstr'], MIDCOM_LOG_CRIT); 
    668                 $midcom->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']); 
    669                 // This will exit. 
    670             } 
    671  
    672             debug_pop(); 
    673         } 
    674  
    675         return $this->_nap_classes[$path]; 
    676493    } 
    677494 
  • trunk/midcom/midcom.core/midcom/helper/_styleloader.php

    r11872 r11900  
    312312        if (!is_dir($path)) 
    313313        { 
     314            debug_push_class(__CLASS__, __FUNCTION__); 
    314315            debug_add("Directory {$path} not found."); 
     316            debug_pop(); 
    315317            return $elements; 
    316318        } 
     
    320322        if (!$directory) 
    321323        { 
     324            debug_push_class(__CLASS__, __FUNCTION__);         
    322325            debug_add("Failed to read directory {$path}"); 
     326            debug_pop(); 
    323327            return $elements; 
    324328        } 
     
    457461        { 
    458462            debug_push_class(__CLASS__, __FUNCTION__); 
    459             debug_add("trying to show '$path' but there is no context set!", MIDCOM_LOG_INFO); 
     463            debug_add("Trying to show '$path' but there is no context set", MIDCOM_LOG_INFO); 
    460464            debug_pop(); 
    461465            return false; 
    462         } 
    463  
    464         if (count($this->_scope) > 0) 
    465         { 
    466             debug_add("style scope is " . $this->_scope[0]); 
    467466        } 
    468467 
     
    566565    function _getComponentStyle($topic) 
    567566    { 
    568         /* this global is set by the urlparser. 
    569          */ 
    570         global $midcom_style_inherited; 
    571         debug_push_class(__CLASS__, __FUNCTION__); 
    572567 
    573568        // get user defined style for component 
    574  
    575569        // style inheritance 
    576570        // should this be cached somehow? 
     
    578572        { 
    579573            $_st = $this->get_style_id_from_path($topic->style); 
    580             debug_add( "topic->style:" . $topic->style . "( $_st )" ); 
    581         } 
    582         else if (   isset($midcom_style_inherited
    583                  && ($midcom_style_inherited)) 
    584         { 
     574        } 
     575        else if (   isset($GLOBALS['midcom_style_inherited']) 
     576                 && ($GLOBALS['midcom_style_inherited'])
     577        { 
     578            // FIXME: This GLOBALS is set by urlparser. Should be removed 
    585579            // get user defined style inherited from topic tree 
    586             $_st = $this->get_style_id_from_path($midcom_style_inherited); 
    587             debug_add( 'Inherited styleid:' . $midcom_style_inherited ); 
     580            $_st = $this->get_style_id_from_path($GLOBALS['midcom_style_inherited']); 
    588581        } 
    589582        else 
     
    594587            { 
    595588                $_st = $this->get_style_id_from_path($GLOBALS['midcom_config']['styleengine_default_styles'][$component]); 
    596                 debug_add( 'Component_default styles: ' . $GLOBALS['midcom_config']['styleengine_default_styles'][$component]); 
    597589            } 
    598590        } 
     
    600592        if (isset($_st)) 
    601593        { 
    602             debug_add("Current component has user defined style: $_st", MIDCOM_LOG_INFO); 
    603594            $substyle = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_SUBSTYLE); 
    604             debug_add( 'Component substyle:' . $substyle ); 
    605595 
    606596            if (isset($substyle))  
     
    614604                    { 
    615605                        $_st = $_subst_id; 
    616                         debug_add("Found substyle '$substyle', overriding component's user defined style.", MIDCOM_LOG_INFO); 
    617                     } 
    618                     else 
    619                     { 
    620                         debug_add("Substyle '$substyle' not found under {$_st}.", MIDCOM_LOG_INFO); 
    621606                    } 
    622607                } 
     
    624609        } 
    625610 
    626         debug_pop(); 
    627         if (isset($_st))
     611        if (isset($_st)) 
     612       
    628613            return $_st; 
    629         } else { 
    630             return false; 
    631         } 
     614        }  
     615         
     616        return false; 
    632617    } 
    633618 
     
    717702    function _merge_styledirs ($component_style) 
    718703    { 
    719         debug_push_class(__CLASS__, __FUNCTION__); 
    720704        /* first the prepend styles */ 
    721705        $this->_styledirs = $this->_styledirs_prepend; 
     
    725709        $this->_styledirs =  array_merge($this->_styledirs, $this->_styledirs_append); 
    726710        $this->_styledirs_count = count($this->_styledirs); 
    727         debug_pop(); 
    728711    } 
    729712 
     
    738721    function enter_context($context) 
    739722    { 
    740         debug_push_class(__CLASS__, __FUNCTION__); 
     723 
    741724 
    742725        // set new context and topic 
    743726        array_unshift($this->_context, $context); // push into context stack 
    744         debug_add("entering context $context", MIDCOM_LOG_DEBUG); 
    745727 
    746728        $this->_topic = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_CONTENTTOPIC); 
     
    754736 
    755737        $this->_merge_styledirs($this->_snippetdir); 
    756  
    757         debug_pop(); 
    758738        return true; 
    759739    } 
     
    768748    function leave_context() 
    769749    { 
    770         debug_push_class(__CLASS__, __FUNCTION__); 
    771  
    772         debug_add("leaving context " . $this->_context[0], MIDCOM_LOG_DEBUG); 
    773750        /* does this cause an extra, not needed call to ->parameter ? */ 
    774751        $_st = $this->_getComponentStyle($this->_topic); 
     
    784761 
    785762        $this->_snippetdir = $this->_getComponentSnippetdir($this->_topic); 
    786  
    787         debug_pop(); 
    788763        return true; 
    789764    } 
  • trunk/midcom/midcom.core/midcom/helper/configuration.php

    r11660 r11900  
    200200                    debug_push_class(__CLASS__, __FUNCTION__); 
    201201                    debug_add("The key {$key} is not present in the global configuration array.", MIDCOM_LOG_INFO); 
    202                     debug_print_r("Current global configuration:", $this->_global); 
    203202                    debug_pop(); 
    204203                } 
  • trunk/midcom/midcom.core/midcom/services/auth.php

    r11856 r11900  
    519519        if (! $credencials) 
    520520        { 
    521             debug_add('No new authentication credencials found.'); 
    522             debug_pop(); 
    523521            return false; 
    524522        } 
     
    11311129 
    11321130        debug_add("Entered SUDO mode for domain {$domain}.", MIDCOM_LOG_INFO); 
    1133         debug_print_function_stack("SUDO mode at depth {$this->_component_sudo} granted for this caller:"); 
    11341131 
    11351132        debug_pop(); 
  • trunk/midcom/midcom.core/midcom/services/cache.php

    r11850 r11900  
    7676    function initialize() 
    7777    { 
    78         debug_push_class(__CLASS__, __FUNCTION__); 
    79  
    8078        foreach ($GLOBALS['midcom_config']['cache_autoload_queue'] as $name) 
    8179        { 
    82             debug_add("Auto-Loading module {$name}", MIDCOM_LOG_DEBUG); 
    8380            $this->load_module($name); 
    8481        } 
    85  
    86         debug_pop(); 
    8782    } 
    8883 
     
    9388    function shutdown() 
    9489    { 
    95         debug_push_class(__CLASS__, __FUNCTION__); 
    96  
    9790        foreach ($this->_unload_queue as $name) 
    9891        { 
    99             debug_add("Stopping module {$name}", MIDCOM_LOG_INFO); 
    10092            $this->_modules[$name]->shutdown(); 
    10193        } 
    102  
    103         debug_pop(); 
    10494    } 
    10595 
  • trunk/midcom/midcom.core/midcom/services/cache/module/content.php

    r11854 r11900  
    372372        if ($this->_uncached) 
    373373        { 
    374             debug_push_class(__CLASS__, __FUNCTION__); 
    375             debug_add('We are in uncached operation, skipping check_hit detection.'); 
    376             debug_pop(); 
    377374            return; 
    378375        }