Changeset 11864

Show
Ignore:
Timestamp:
08/30/07 13:08:43 (1 year ago)
Author:
bergie
Message:

Minor cleanup in preparation for larger refactoring, refs #102

Files:

Legend:

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

    r11858 r11864  
    107107class midcom_application  
    108108{ 
    109  
    110     /** 
    111      * The URL parser. 
    112      * 
    113      * @var midcom_helper_urlparser 
    114      * @access private 
    115      */ 
    116     private $_parser; 
    117  
    118109    /** 
    119110     * Holds the component context information. This is an array of arrays, the outer 
     
    132123     * @access private 
    133124     */ 
    134     private $_currentcontext
     125    private $_currentcontext = null
    135126 
    136127    /** 
     
    140131     * @access private 
    141132     */ 
    142     private $_currentcomponent
     133    private $_currentcomponent = ''
    143134 
    144135    /** 
     
    148139     * @access private 
    149140     */ 
    150     private $_client
     141    private $_client = array()
    151142 
    152143    /** 
     
    158149     * @access private 
    159150     */ 
    160     private $_prefix
     151    private $_prefix = ''
    161152 
    162153    /** 
     
    168159     * @access private 
    169160     */ 
    170     private $_status
     161    private $_status = null
    171162 
    172163    /** 
     
    177168     * @access private 
    178169     */ 
    179     private $_services; 
     170    private $_services = array(); 
     171 
     172    /** 
     173     * The URL parser. 
     174     * 
     175     * @var midcom_helper_urlparser 
     176     * @access private 
     177     */ 
     178    private $_parser = null; 
    180179 
    181180    /** 
     
    272271 
    273272    /** 
    274      * String with all JavaScript declarations for the page's head. 
     273     * Array with all JavaScript declarations for the page's head. 
     274     * 
     275     * @var Array 
     276     * @access private 
     277     */ 
     278    private $_jshead = array(); 
     279 
     280    /** 
     281     * String with all prepend JavaScript declarations for the page's head. 
    275282     * 
    276283     * @var string 
    277284     * @access private 
    278285     */ 
    279     private $_jshead; 
    280  
    281     /** 
    282      * String with all prepend JavaScript declarations for the page's head. 
    283      * 
    284      * @var string 
    285      * @access private 
    286      */ 
    287     private $_prepend_jshead; 
     286    private $_prepend_jshead = ''; 
    288287 
    289288    /** 
     
    304303 
    305304    /** 
    306      * Array with all methods for the BODY's onload event
     305     * Array with all linked URLs for HEAD
    307306     * 
    308307     * @var Array 
    309308     * @access private 
    310309     */ 
    311     private $_jsonload; 
     310    private $_linkhrefs = array(); 
     311 
     312    /** 
     313     * Array with all methods for the BODY's onload event. 
     314     * 
     315     * @var Array 
     316     * @access private 
     317     */ 
     318    private $_jsonload = array(); 
    312319 
    313320    /** 
     
    316323     * @access private 
    317324     */ 
    318     private $_meta_head = ""
     325    private $_meta_head = ''
    319326 
    320327    /** 
     
    323330     * @access private 
    324331     */ 
    325     private $_object_head = ""
     332    private $_object_head = ''
    326333 
    327334    /** 
     
    331338     * @access private 
    332339     */ 
    333     private $_style_head = ""
     340    private $_style_head = ''
    334341 
    335342    /** 
     
    339346     * @access private 
    340347     */ 
    341     private $_link_head = ""
     348    private $_link_head = ''
    342349 
    343350    /** 
     
    348355     * @see midcom_application::get_host_prefix(); 
    349356     */ 
    350     private $_cached_host_prefix
     357    private $_cached_host_prefix = ''
    351358 
    352359    /** 
     
    357364     * @see midcom_application::get_page_prefix(); 
    358365     */ 
    359     private $_cached_page_prefix
     366    private $_cached_page_prefix = ''
    360367 
    361368    /** 
     
    396403    public function initialize() 
    397404    { 
    398         debug_push_class(__CLASS__, __FUNCTION__); 
    399  
    400         // MidCOM System Data 
    401         $this->_parser = false; 
    402         $this->_services = Array(); 
    403         $this->_jsfiles = Array(); 
    404         $this->_jshead = Array(); 
    405         $this->_jsonload = Array(); 
    406         $this->_linkhrefs = Array(); 
    407  
    408405        // set prefix for "new" midgard->self 
    409406        $this->_prefix = $GLOBALS['midcom_config']['midcom_prefix']; 
     
    412409 
    413410        $this->_status = MIDCOM_STATUS_PREPARE; 
    414  
    415         // Service startup 
     411         
     412        // Load the services that are always needed, including the serviceloader 
     413        $this->_load_core_services(); 
     414 
     415        $this->componentloader->load_all_manifests(); 
     416 
     417        $this->_load_core_dba_classes(); 
     418 
     419        // Initialize Root Topic 
     420        $root_topic = new midcom_db_topic($GLOBALS['midcom_config']['midcom_root_topic_guid']); 
     421        if (   ! $root_topic 
     422            || !$root_topic->guid) 
     423        { 
     424            if (mgd_errno() == MGD_ERR_ACCESS_DENIED) 
     425            { 
     426                $this->generate_error(MIDCOM_ERRFORBIDDEN, 
     427                    $this->i18n->get_string('access denied', 'midcom')); 
     428            } 
     429            else 
     430            { 
     431                $this->generate_error(MIDCOM_ERRCRIT, 
     432                    "Unable to load root topic with GUID='{$GLOBALS['midcom_config']['midcom_root_topic_guid']}'.<br />" . 
     433                    "This is fatal, aborting. See the MidCOM log file for details.<br />" . 
     434                    'Last Midgard Error was: ' . mgd_errstr()); 
     435            } 
     436            // This will exit. 
     437        } 
     438 
     439        // Initialize Context Storage 
     440        $this->_context = Array(); 
     441        $this->_create_context(0); 
     442        $this->_currentcontext = 0; 
     443        $this->_context[0][MIDCOM_CONTEXT_ROOTTOPIC] = $root_topic; 
     444 
     445        // Populate browser information 
     446        $this->_populate_client(); 
     447 
     448        // Check the midcom_config site prefix for absolute local urls 
     449        if ($GLOBALS['midcom_config']['midcom_site_url'][0] == '/') 
     450        { 
     451            $GLOBALS['midcom_config']['midcom_site_url'] = 
     452                $this->get_host_prefix() 
     453                . substr($GLOBALS['midcom_config']['midcom_site_url'], 1); 
     454        } 
     455    } 
     456 
     457    /** 
     458     * Load all services MidCOM needs to keep always available 
     459     * 
     460     * @todo: move those that aren't always needed behind serviceloader 
     461     */ 
     462    private function _load_core_services() 
     463    { 
     464        // These are core functionality 
     465        $this->serviceloader = new midcom_helper_serviceloader(); 
    416466        $this->cache =& $GLOBALS['midcom_cache']; 
    417467        $this->i18n = new midcom_services_i18n(); 
     
    419469        $this->dbclassloader = new midcom_services_dbclassloader(); 
    420470        $this->dbclassloader->load_classes('midcom', 'legacy_classes.inc'); 
    421         // 2007-03-27 rambo 
    422471        $this->dbclassloader->load_classes('midcom', 'core_classes.inc'); 
    423472        $this->dbfactory = new midcom_helper__dbfactory(); 
     
    425474        $this->auth = new midcom_services_auth(); 
    426475        $this->auth->initialize(); 
    427         $this->permalinks = new midcom_services_permalinks(); 
    428         $this->serviceloader = new midcom_helper_serviceloader();         
     476         
     477        // These can be refactored behind serviceloader 
     478        $this->permalinks = new midcom_services_permalinks();     
    429479        $this->tmp = new midcom_services_tmp(); 
    430480        $this->toolbars = new midcom_services_toolbars(); 
    431481        $this->uimessages = new midcom_services_uimessages(); 
    432482        $this->metadata = new midcom_services_metadata(); 
    433          
    434483        $this->_services['rcs'] = new midcom_services_rcs($GLOBALS['midcom_config']); 
    435          
    436         $this->componentloader->load_all_manifests(); 
    437  
     484    } 
     485     
     486    /** 
     487     * Load core DBA classes 
     488     * 
     489     * @todo: move behind autoload 
     490     */ 
     491    private function _load_core_dba_classes() 
     492    { 
    438493        // Load DBA legacy classes required for core operation 
    439494        require('db/article.php'); 
     
    462517        require('db/sitegroup.php'); 
    463518         */ 
    464  
    465         // Initialize Root Topic 
    466         $root_topic = new midcom_db_topic($GLOBALS['midcom_config']['midcom_root_topic_guid']); 
    467         if (   ! $root_topic 
    468             || !$root_topic->guid) 
    469         { 
    470             if (mgd_errno() == MGD_ERR_ACCESS_DENIED) 
    471             { 
    472                 $this->generate_error(MIDCOM_ERRFORBIDDEN, 
    473                     $this->i18n->get_string('access denied', 'midcom')); 
    474             } 
    475             else 
    476             { 
    477                 $this->generate_error(MIDCOM_ERRCRIT, 
    478                     "Unable to load root topic with GUID='{$GLOBALS['midcom_config']['midcom_root_topic_guid']}'.<br />" . 
    479                     "This is fatal, aborting. See the MidCOM log file for details.<br />" . 
    480                     'Last Midgard Error was: ' . mgd_errstr()); 
    481             } 
    482             // This will exit. 
    483         } 
    484  
    485         // Initialize Context Storage 
    486         $this->_context = Array(); 
    487         $this->_create_context(0); 
    488         $this->_currentcontext = 0; 
    489         $this->_context[0][MIDCOM_CONTEXT_ROOTTOPIC] = $root_topic; 
    490  
    491         $this->_populate_client(); 
    492  
    493         // Check the midcom_config ais/site prefixes for absolute local urls 
    494         if ($GLOBALS['midcom_config']['midcom_ais_url'][0] == '/') 
    495         { 
    496             $GLOBALS['midcom_config']['midcom_ais_url'] = 
    497                 $this->get_host_prefix() 
    498                 . substr($GLOBALS['midcom_config']['midcom_ais_url'], 1); 
    499         } 
    500         if ($GLOBALS['midcom_config']['midcom_site_url'][0] == '/') 
    501         { 
    502             $GLOBALS['midcom_config']['midcom_site_url'] = 
    503                 $this->get_host_prefix() 
    504                 . substr($GLOBALS['midcom_config']['midcom_site_url'], 1); 
    505         } 
    506  
    507         debug_pop(); 
    508519    } 
    509520 
     
    623634     * $newsticker = '/newsticker/latest/3.html'; 
    624635     * $substyle = 'homepage'; 
    625      * $GLOBALS['midcom']->dynamic_load("/midcom-substyle-{$substyle}/{$newsticker}"); 
     636     * $_MIDCOM->dynamic_load("/midcom-substyle-{$substyle}/{$newsticker}"); 
    626637     * ?> 
    627638     * </code> 
     
    635646     * <?php 
    636647     * global $view; 
    637      * $GLOBALS['midcom']->dynamic_load($view['url1']); 
     648     * $_MIDCOM->dynamic_load($view['url1']); 
    638649     * // You will most probably fail, could even loop infinitly! 
    639      * $GLOBALS['midcom']->dynamic_load($view['url2']); 
     650     * $_MIDCOM->dynamic_load($view['url2']); 
    640651     * ?> 
    641652     * </code> 
     
    652663     * <?php 
    653664     * $view = $GLOBALS['view']; 
    654      * $GLOBALS['midcom']->dynamic_load($view['url1']); 
    655      * $GLOBALS['midcom']->dynamic_load($view['url2']); 
     665     * $_MIDCOM->dynamic_load($view['url1']); 
     666     * $_MIDCOM->dynamic_load($view['url2']); 
    656667     * ?> 
    657668     * </code> 
     
    17781789     * <code> 
    17791790     * <?php 
    1780      * $GLOBALS['midcom']->load_library('midcom.helper.datamanager'); 
     1791     * $_MIDCOM->load_library('midcom.helper.datamanager'); 
    17811792     * ?> 
    17821793     * </code> 
     
    26962707     *     <HEAD> 
    26972708     *         <!-- Further HEAD Tags --> 
    2698      *         <?php echo $GLOBALS['midcom']->print_jscripts(); ?> 
     2709     *         <?php echo $_MIDCOM->print_jscripts(); ?> 
    26992710     *     </HEAD> 
    27002711     * </HTML> 
     
    27382749     * <code> 
    27392750     * <HTML> 
    2740      *     <BODY <?php echo $GLOBALS['midcom']->print_jsonload();?>> 
     2751     *     <BODY <?php echo $_MIDCOM->print_jsonload();?>> 
    27412752     *            <!-- your actual body --> 
    27422753     *     </BODY>