/** * Certain symbols need preprocessing, before the output stream is made. * * @param array Symbol details * @param array Where we store children stuff */ function handle_symbol_preprocessing($bit, &$children) { switch ($bit[2]) { case 'PAGE_LINK': if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; if (array_key_exists(0, $param)) { if (is_object($param[0])) { $param[0] = $param[0]->evaluate(); } list(, $url_parts, ) = page_link_decode(str_replace(chr(10), '', $param[0])); if (!array_key_exists('id', $url_parts)) { return; } if (!array_key_exists('type', $url_parts)) { $url_parts['type'] = 'misc'; } if (is_null($url_parts['type'])) { $url_parts['type'] = 'misc'; } // NULL means "do not take from environment"; so we default it to 'misc' (even though it might actually be left out when SEO URLs are off, we know it cannot be for SEO URLs) if (!array_key_exists('page', $url_parts)) { return; } if (!is_string($url_parts['id'])) { if (is_null($url_parts['id'])) { $url_parts['id'] = strval(db_get_first_id()); } } // Does this URL arrangement support monikers? global $CONTENT_OBS, $LOADED_MONIKERS; load_moniker_hooks(); $found = false; $looking_for = '_SEARCH:' . $url_parts['page'] . ':' . $url_parts['type'] . ':_WILD'; $ob_info = isset($CONTENT_OBS[$looking_for]) ? $CONTENT_OBS[$looking_for] : NULL; if (!is_null($ob_info)) { if (!isset($LOADED_MONIKERS[$url_parts['page']][$url_parts['type']][$url_parts['id']])) { $LOADED_MONIKERS[$url_parts['page']][$url_parts['type']][$url_parts['id']] = true; } // Indicator to preload this } } return; case 'SET': if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; if (array_key_exists(1, $param)) { global $TEMPCODE_SETGET; $param_copy = array(); foreach ($param as $i => $x) { if ($i != 0) { $param_copy[] = is_object($x) ? $x->evaluate() : $x; } } $TEMPCODE_SETGET[is_object($param[0]) ? $param[0]->evaluate() : $param[0]] = implode(',', $param_copy); } return; case 'BLOCK': if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } if (count($param) == 1 && strpos($param[0], ',') !== false) { $param = preg_split('#((?<![^\\\\])|(?<!\\\\\\\\)|(?<!^)),#', $param[0]); } //if (strpos(serialize($param),'side_stored_menu')!==false) { @debug_print_backtrace();exit(); } // Useful for debugging global $REQUEST_BLOCK_NEST_LEVEL; global $LOADED_BLOCKS; if (array_key_exists(serialize($param), $LOADED_BLOCKS)) { $REQUEST_BLOCK_NEST_LEVEL--; return; } $REQUEST_BLOCK_NEST_LEVEL++; if ($REQUEST_BLOCK_NEST_LEVEL > 20) { $REQUEST_BLOCK_NEST_LEVEL = 0; $LOADED_BLOCKS[serialize($param)] = do_lang_tempcode('INTERNAL_ERROR'); attach_message(do_lang_tempcode('STOPPED_RECURSIVE_RESOURCE_INCLUDE', is_string($param[0]) ? $param[0] : 'block'), 'warn'); return; } $block_parms = array(); foreach ($param as $_param) { $block_parts = explode('=', $_param, 2); if (count($block_parts) != 2) { $LOADED_BLOCKS[serialize($param)] = new ocp_tempcode(); continue 2; } list($key, $val) = $block_parts; $block_parms[$key] = $val; } $b_value = do_block($block_parms['block'], $block_parms); if ($GLOBALS['RECORD_TEMPLATES_TREE']) { $children[] = array(':block: ' . $block_parms['block'], array(array($b_value->codename, $b_value->children, $b_value->fresh)), true); } $b_value->handle_symbol_preprocessing(); $LOADED_BLOCKS[serialize($param)] = $b_value; $REQUEST_BLOCK_NEST_LEVEL--; return; case 'JAVASCRIPT_INCLUDE': if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } require_javascript($param[0]); return; case 'FACILITATE_AJAX_BLOCK_CALL': require_javascript('javascript_ajax'); return; case 'CSS_INCLUDE': if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } require_css($param[0]); return; case 'LOAD_PANEL': if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } global $LOADED_PANELS; if (array_key_exists(serialize($param), $LOADED_PANELS)) { return; } if (array_key_exists(0, $param)) { if (substr(get_page_name(), 0, 6) != 'panel_') { if (strpos($param[0], ':') !== false) { $param = array_reverse(explode(':', $param[0], 2)); } if (substr($param[0], 0, 6) == 'panel_') { $param[0] = substr($param[0], 6); } global $ZONE; $wide_high = is_wide_high(); $wide = is_wide(); if (($wide == 0 || $wide_high == 0 && ($param[0] == 'bottom' || $param[0] == 'top')) && (get_option('site_closed') == '0' || $GLOBALS['IS_ACTUALLY_ADMIN'] || has_specific_permission(get_member(), 'access_closed_site'))) { $tp_value = request_page('panel_' . $param[0], false, array_key_exists(1, $param) ? $param[1] : NULL, NULL); $sub_children = array(); $tp_value->handle_symbol_preprocessing(); if ($GLOBALS['RECORD_TEMPLATES_TREE']) { $children[] = array(':panel: ' . $param[0], $sub_children, isset($tp_value->fresh) ? $tp_value->fresh : false); } $value = $tp_value->evaluate(); } else { $value = ''; } } else { $value = ''; } } else { $value = ''; } $LOADED_PANELS[serialize($param)] = $value; return; case 'JS_TEMPCODE': if ($GLOBALS['RECORD_TEMPLATES_TREE']) { if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } $temp = javascript_tempcode(array_key_exists(0, $param) ? $param[0] : NULL); $children[] = array(':container', $temp->children, $temp->fresh); } return; case 'CSS_TEMPCODE': if ($GLOBALS['RECORD_TEMPLATES_TREE']) { if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $temp = css_tempcode(); $children[] = array(':container', $temp->children, $temp->fresh); } return; case 'LOAD_PAGE': if (!array_key_exists(3, $bit) || is_null($bit[3])) { return; } $param = $bit[3]; foreach ($param as $i => $p) { if (is_object($p)) { $param[$i] = $p->evaluate(); } } global $LOADED_PAGES; if (array_key_exists(serialize($param), $LOADED_PAGES)) { return; } if (array_key_exists(0, $param)) { if (strpos($param[0], ':') !== false) { $param = array_reverse(explode(':', $param[0], 2)); } $being_included = !array_key_exists(2, $param) || $param[2] == '1'; $tp_value = request_page($param[0], false, array_key_exists(1, $param) ? $param[1] : NULL, NULL, $being_included); if ($GLOBALS['RECORD_TEMPLATES_TREE']) { $children[] = array(':page: ' . $param[0], $tp_value->children, $tp_value->fresh); } } else { $tp_value = new ocp_tempcode(); } $LOADED_PAGES[serialize($param)] = $tp_value; return; case 'FRACTIONAL_EDITABLE': require_javascript('javascript_fractional_edit'); return; } }
/** * Find whether panels will be shown. * * @return BINARY Result. */ function is_wide() { global $IS_WIDE; if ($IS_WIDE !== NULL) { return $IS_WIDE; } global $ZONE; $IS_WIDE = get_param_integer('wide', get_param_integer('keep_wide', is_wide_high() == 1 ? 1 : $ZONE['zone_wide'])); if ($IS_WIDE == 0) { return 0; } // Need to check it is allowed $theme = $GLOBALS['FORUM_DRIVER']->get_theme(); $ini_path = ($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . $theme . '/theme.ini'; if (is_file($ini_path)) { require_code('files'); $details = better_parse_ini_file($ini_path); if (isset($details['supports_wide']) && $details['supports_wide'] == '0') { $IS_WIDE = 0; return $IS_WIDE; } } return $IS_WIDE; }