Esempio n. 1
0
/**
 * Preparse a string to handle element inclusion and variable
 *
 * @see mgd_preparse
 */
function mgd_preparse($code)
{
    return midcom_helper_misc::preparse($code);
}
Esempio n. 2
0
 /**
  * This is a bit of a hack to allow &(); tags
  */
 private function _parse_element($_style, $path)
 {
     $data =& midcom_core_context::get()->get_custom_key('request_data');
     $instance_id = false;
     if (in_array('style', $GLOBALS['midcom_config']['cache_module_memcache_data_groups'])) {
         // Cache style elements
         $instance_id = $path;
         if (midcom::get('cache')->memcache->exists('style', $instance_id)) {
             eval('?>' . midcom::get('cache')->memcache->get('style', $instance_id));
             return;
         }
     }
     if ($GLOBALS['midcom_config']['wrap_style_show_with_name']) {
         $_style = "\n<!-- Start of style '{$path}' -->\n" . $_style;
         $_style .= "\n<!-- End of style '{$path}' -->\n";
     }
     $preparsed = midcom_helper_misc::preparse($_style);
     $result = eval('?>' . $preparsed);
     if ($result === false) {
         // Note that src detection will be semi-reliable, as it depends on all errors being
         // found before caching kicks in.
         throw new midcom_error("Failed to parse style element '{$path}', content was loaded from '{$src}', see above for PHP errors.");
     }
     if ($instance_id) {
         // This element will be cached after display (if no errors occured)
         midcom::get('cache')->memcache->put('style', $instance_id, $preparsed);
     }
 }
Esempio n. 3
0
 /**
  * Display the output of the component
  *
  * This function must be called in the content area of the
  * Style template, usually <(content)>.
  */
 public function content()
 {
     // Enter Context
     $oldcontext = midcom_core_context::get();
     if ($oldcontext->id != 0) {
         debug_add("Entering Context 0 (old Context: {$oldcontext->id})");
     }
     $this->_currentcontext = 0;
     midcom::get('style')->enter_context(0);
     $template = midcom_helper_misc::preparse('<(ROOT)>');
     $template_parts = explode('<(content)>', $template);
     eval('?>' . $template_parts[0]);
     $this->_output();
     if (isset($template_parts[1])) {
         eval('?>' . $template_parts[1]);
     }
     // Leave Context
     if ($oldcontext->id != 0) {
         debug_add("Leaving Context 0 (new Context: {$oldcontext->id})");
     }
     midcom::get('style')->leave_context();
     $oldcontext->set_current();
 }