Changeset 22740

Show
Ignore:
Timestamp:
06/30/09 14:54:44 (1 year ago)
Author:
bergie
Message:

Sensible fallback for missing ROOT element

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ragnaroek/midcom/midcom.core/support/midgard-root-ragnaland.php

    r22690 r22740  
    1212 
    1313define('MIDCOM_ROOT', dirname(dirname(__FILE__)) . '/Midcom/ragnaroek'); 
     14 
     15// Ragnaroek uses more memory in some operations than standard settings allow 
     16// FIXME: Set sensible but big values instead of removing limits completely 
     17@ini_set('memory_limit', -1); 
     18@ini_set('max_execution_time', 0); 
    1419 
    1520// Figure out a root topic 
     
    4146// Prepare $_MIDGARD superglobal to be Ragnaroek-compatible 
    4247$_MIDGARD['user'] = 0; 
     48$_MIDGARD['admin'] = false; 
    4349$request_config = $_MIDGARD_CONNECTION->get_request_config(); 
    4450if (!$request_config) 
     
    124130    $element = $name[1]; 
    125131    $request_config = $_MIDGARD_CONNECTION->get_request_config(); 
     132 
     133    // Sensible fallback if we don't have a style or ROOT element 
     134    $root_fallback = '<html><head><?php $_MIDCOM->print_head_elements(); ?></head><body><?php $_MIDCOM->content(); $_MIDCOM->uimessages->show(); $_MIDCOM->toolbars->show(); ?></body></html>'; 
     135 
    126136    switch ($element) 
    127137    { 
     
    135145            if (!$style) 
    136146            { 
     147                if ($element == 'ROOT') 
     148                { 
     149                    return $root_fallback; 
     150                } 
    137151                return ''; 
    138152            } 
     
    143157            if (count($elements) == 0) 
    144158            { 
     159                if ($element == 'ROOT') 
     160                { 
     161                    return $root_fallback; 
     162                } 
    145163                return ''; 
    146164            } 
    147             return preg_replace_callback("/<\\(([a-zA-Z0-9 _-]+)\\)>/", 'mgd_element', $elements[0]->value); 
     165            else 
     166            { 
     167                $value = $elements[0]->value; 
     168            } 
     169            return preg_replace_callback("/<\\(([a-zA-Z0-9 _-]+)\\)>/", 'mgd_element', $value); 
    148170    } 
    149171} 
     
    183205// Display the template 
    184206eval('?>' . mgd_preparse_compat('<(ROOT)>')); 
    185 /** 
    186  * <html> 
    187  *     <head> 
    188  *         <?php 
    189  *         $_MIDCOM->print_head_elements(); 
    190  *         ?> 
    191  *     </head> 
    192  *     <body> 
    193  *         <?php 
    194  *         $_MIDCOM->content(); 
    195  *         ?> 
    196  *     </body> 
    197  * </html> 
    198  */ 
    199207?>