1012 <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?early"></script> |
1012 <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?early"></script> |
1013 JSEOF; |
1013 JSEOF; |
1014 $js_foot = <<<JSEOF |
1014 $js_foot = <<<JSEOF |
1015 <!-- jsres.php is a wrapper script that compresses and caches single JS files to minimize requests --> |
1015 <!-- jsres.php is a wrapper script that compresses and caches single JS files to minimize requests --> |
1016 <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php"></script> |
1016 <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php"></script> |
1017 <script type="text/javascript"> |
1017 <script type="text/javascript">//<![CDATA[ |
1018 // This initializes the Javascript runtime when the DOM is ready - not when the page is |
1018 // This initializes the Javascript runtime when the DOM is ready - not when the page is |
1019 // done loading, because enano-lib-basic still has to load some 15 other script files |
1019 // done loading, because enano-lib-basic still has to load some 15 other script files |
1020 // check for the init function - this is a KHTML fix |
1020 // check for the init function - this is a KHTML fix |
1021 // This doesn't seem to work properly in IE in 1.1.x - there are some problems with |
1021 // This doesn't seem to work properly in IE in 1.1.x - there are some problems with |
1022 // tinyMCE and l10n. |
1022 // tinyMCE and l10n. |
1023 if ( typeof ( enano_init ) == 'function' && !IE ) |
1023 if ( typeof ( enano_init ) == 'function' && !IE ) |
1024 { |
1024 { |
1025 enano_init(); |
1025 enano_init(); |
1026 window.onload = function(e) { }; |
1026 window.onload = function(e) { }; |
1027 } |
1027 } |
1028 </script> |
1028 //]]></script> |
1029 JSEOF; |
1029 JSEOF; |
1030 } |
1030 } |
1031 |
1031 |
1032 $code = $plugins->setHook('compile_template'); |
1032 $code = $plugins->setHook('compile_template'); |
1033 foreach ( $code as $cmd ) |
1033 foreach ( $code as $cmd ) |
1193 'ADMIN_SID_QUES' => $asq, |
1193 'ADMIN_SID_QUES' => $asq, |
1194 'ADMIN_SID_AMP' => $asa, |
1194 'ADMIN_SID_AMP' => $asa, |
1195 'ADMIN_SID_AMP_HTML' => $ash, |
1195 'ADMIN_SID_AMP_HTML' => $ash, |
1196 'ADMIN_SID_AUTO' => $as2, |
1196 'ADMIN_SID_AUTO' => $as2, |
1197 'ADMIN_SID_RAW' => ( is_string($session->sid_super) ? $session->sid_super : '' ), |
1197 'ADMIN_SID_RAW' => ( is_string($session->sid_super) ? $session->sid_super : '' ), |
|
1198 'CSRF_TOKEN' => $session->csrf_token, |
1198 'COPYRIGHT' => RenderMan::parse_internal_links(getConfig('copyright_notice')), |
1199 'COPYRIGHT' => RenderMan::parse_internal_links(getConfig('copyright_notice')), |
1199 'TOOLBAR_EXTRAS' => $this->toolbar_menu, |
1200 'TOOLBAR_EXTRAS' => $this->toolbar_menu, |
1200 'REQUEST_URI' => ( defined('ENANO_CLI') ? '' : $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ), |
1201 'REQUEST_URI' => ( defined('ENANO_CLI') ? '' : $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ), |
1201 'STYLE_LINK' => makeUrlNS('Special', 'CSS'.$p, null, true), //contentPath.$paths->nslist['Special'].'CSS' . $p, |
1202 'STYLE_LINK' => makeUrlNS('Special', 'CSS'.$p, null, true), //contentPath.$paths->nslist['Special'].'CSS' . $p, |
1202 'LOGIN_LINK' => $login_link, |
1203 'LOGIN_LINK' => $login_link, |
1269 function header($simple = false) |
1270 function header($simple = false) |
1270 { |
1271 { |
1271 global $db, $session, $paths, $template, $plugins; // Common objects |
1272 global $db, $session, $paths, $template, $plugins; // Common objects |
1272 global $lang; |
1273 global $lang; |
1273 |
1274 |
1274 ob_start(); |
1275 echo $this->getHeader($simple); |
1275 |
1276 } |
1276 if(!$this->theme_loaded) |
1277 |
|
1278 function footer($simple = false) |
|
1279 { |
|
1280 echo $this->getFooter($simple); |
|
1281 } |
|
1282 |
|
1283 function getHeader($simple = false) |
|
1284 { |
|
1285 global $db, $session, $paths, $template, $plugins; // Common objects |
|
1286 global $lang; |
|
1287 |
|
1288 if ( !$this->theme_loaded ) |
1277 { |
1289 { |
1278 $this->load_theme($session->theme, $session->style); |
1290 $this->load_theme($session->theme, $session->style); |
1279 } |
1291 } |
1280 |
1292 |
1281 // I feel awful doing this. |
1293 // I feel awful doing this. |
1294 $this->process_template('header.tpl'); |
1306 $this->process_template('header.tpl'); |
1295 echo $header; |
1307 echo $header; |
1296 } |
1308 } |
1297 if ( !$simple && $session->user_logged_in && $session->unread_pms > 0 ) |
1309 if ( !$simple && $session->user_logged_in && $session->unread_pms > 0 ) |
1298 { |
1310 { |
1299 echo $this->notify_unread_pms(); |
1311 $header .= $this->notify_unread_pms(); |
1300 } |
1312 } |
1301 if ( !$simple && $session->sw_timed_out ) |
1313 if ( !$simple && $session->sw_timed_out ) |
1302 { |
1314 { |
1303 $login_link = makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $session->user_level, true); |
1315 $login_link = makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $session->user_level, true); |
1304 echo '<div class="usermessage">'; |
1316 $header .= '<div class="usermessage">'; |
1305 echo $lang->get('user_msg_elev_timed_out', array( 'login_link' => $login_link )); |
1317 $header .= $lang->get('user_msg_elev_timed_out', array( 'login_link' => $login_link )); |
1306 echo '</div>'; |
1318 $header .= '</div>'; |
1307 } |
1319 } |
1308 if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) ) |
1320 if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) ) |
1309 { |
1321 { |
1310 $admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true); |
1322 $admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true); |
1311 echo '<div class="usermessage"><b>' . $lang->get('page_sitedisabled_admin_msg_title') . '</b><br /> |
1323 $header .= '<div class="usermessage"><b>' . $lang->get('page_sitedisabled_admin_msg_title') . '</b><br /> |
1312 ' . $lang->get('page_sitedisabled_admin_msg_body', array('admin_link' => $admin_link)) . ' |
1324 ' . $lang->get('page_sitedisabled_admin_msg_body', array('admin_link' => $admin_link)) . ' |
1313 </div>'; |
1325 </div>'; |
1314 } |
1326 } |
1315 } |
|
1316 |
|
1317 function footer($simple = false) |
|
1318 { |
|
1319 echo $this->getFooter($simple); |
|
1320 } |
|
1321 |
|
1322 function getHeader() |
|
1323 { |
|
1324 $headers_sent = true; |
|
1325 if(!defined('ENANO_HEADERS_SENT')) |
|
1326 define('ENANO_HEADERS_SENT', ''); |
|
1327 if(!$this->no_headers) return $this->process_template('header.tpl'); |
|
1328 } |
1327 } |
1329 function getFooter($simple = false) |
1328 function getFooter($simple = false) |
1330 { |
1329 { |
1331 global $db, $session, $paths, $template, $plugins; // Common objects |
1330 global $db, $session, $paths, $template, $plugins; // Common objects |
1332 global $lang; |
1331 global $lang; |
1642 } |
1641 } |
1643 |
1642 |
1644 /** |
1643 /** |
1645 * Post-processor for template code. Basically what this does is it localizes {lang:foo} blocks. |
1644 * Post-processor for template code. Basically what this does is it localizes {lang:foo} blocks. |
1646 * @param string Mostly-processed TPL code |
1645 * @param string Mostly-processed TPL code |
|
1646 * @param bool Post-eval switch. If true, does not escape code. |
1647 * @return string |
1647 * @return string |
1648 */ |
1648 */ |
1649 |
1649 |
1650 function compile_template_text_post($text) |
1650 function compile_template_text_post($text, $post_eval = false) |
1651 { |
1651 { |
|
1652 global $db, $session, $paths, $template, $plugins; // Common objects |
1652 global $lang; |
1653 global $lang; |
|
1654 |
|
1655 // Language strings |
1653 preg_match_all('/\{lang:([a-z0-9]+_[a-z0-9_]+)\}/', $text, $matches); |
1656 preg_match_all('/\{lang:([a-z0-9]+_[a-z0-9_]+)\}/', $text, $matches); |
1654 foreach ( $matches[1] as $i => $string_id ) |
1657 foreach ( $matches[1] as $i => $string_id ) |
1655 { |
1658 { |
1656 $string = $lang->get($string_id); |
1659 $string = $lang->get($string_id); |
1657 $string = str_replace('\\', '\\\\', $string); |
1660 if ( !$post_eval ) |
1658 $string = str_replace('\'', '\\\'', $string); |
1661 { |
|
1662 $string = str_replace('\\', '\\\\', $string); |
|
1663 $string = str_replace('\'', '\\\'', $string); |
|
1664 } |
1659 $text = str_replace_once($matches[0][$i], $string, $text); |
1665 $text = str_replace_once($matches[0][$i], $string, $text); |
1660 } |
1666 } |
1661 preg_match_all('/\{url:([A-z0-9]+):([\w\.\/:;\(\)@\[\]_=-]+)(?::([^\s\}]+))?(?:\|(escape))?\}/', $text, $matches); |
1667 |
|
1668 // URLs |
|
1669 preg_match_all('/\{url:([A-z0-9]+):([^\s\}]+?)(?:;([^\s\}]+?))?(?:\|(escape))?\}/i', $text, $matches); |
1662 foreach ( $matches[1] as $i => $string_id ) |
1670 foreach ( $matches[1] as $i => $string_id ) |
1663 { |
1671 { |
1664 $namespace =& $matches[1][$i]; |
1672 $namespace =& $matches[1][$i]; |
1665 $page_id =& $matches[2][$i]; |
1673 $page_id =& $matches[2][$i]; |
1666 $params =& $matches[3][$i]; |
1674 $params =& $matches[3][$i]; |
1670 $params = false; |
1678 $params = false; |
1671 $escape = !empty($escape); |
1679 $escape = !empty($escape); |
1672 |
1680 |
1673 $result = makeUrlNS($namespace, $page_id, $params, $escape); |
1681 $result = makeUrlNS($namespace, $page_id, $params, $escape); |
1674 |
1682 |
|
1683 if ( !$post_eval ) |
|
1684 { |
|
1685 $result = str_replace('\\', '\\\\', $result); |
|
1686 $result = str_replace('\'', '\\\'', $result); |
|
1687 } |
|
1688 |
1675 $text = str_replace_once($matches[0][$i], $result, $text); |
1689 $text = str_replace_once($matches[0][$i], $result, $text); |
1676 } |
1690 } |
|
1691 |
|
1692 $code = $plugins->setHook('compie_template_text_post'); |
|
1693 foreach ( $code as $cmd ) |
|
1694 { |
|
1695 eval($cmd); |
|
1696 } |
|
1697 |
1677 return $text; |
1698 return $text; |
|
1699 } |
|
1700 |
|
1701 /** |
|
1702 * Returns the output of a theme hook |
|
1703 * @param string Hook name |
|
1704 * @return string |
|
1705 */ |
|
1706 |
|
1707 function get_theme_hook($hook) |
|
1708 { |
|
1709 global $db, $session, $paths, $template, $plugins; // Common objects |
|
1710 global $lang; |
|
1711 |
|
1712 ob_start(); |
|
1713 $code = $plugins->setHook($hook); |
|
1714 foreach ( $code as $cmd ) |
|
1715 { |
|
1716 eval($cmd); |
|
1717 } |
|
1718 $out = ob_get_contents(); |
|
1719 ob_end_clean(); |
|
1720 |
|
1721 return $out; |
1678 } |
1722 } |
1679 |
1723 |
1680 // n00bish comments removed from here. 2008-03-13 @ 12:02AM when I had nothing else to do. |
1724 // n00bish comments removed from here. 2008-03-13 @ 12:02AM when I had nothing else to do. |
1681 |
1725 |
1682 /** |
1726 /** |
2599 // |
2643 // |
2600 |
2644 |
2601 // System messages |
2645 // System messages |
2602 $text = preg_replace('/<!-- SYSMSG ([A-z0-9\._-]+?) -->/is', '\' . $template->tplWikiFormat($paths->sysMsg(\'\\1\')) . \'', $text); |
2646 $text = preg_replace('/<!-- SYSMSG ([A-z0-9\._-]+?) -->/is', '\' . $template->tplWikiFormat($paths->sysMsg(\'\\1\')) . \'', $text); |
2603 |
2647 |
|
2648 // Hooks |
|
2649 $text = preg_replace('/<!-- HOOK ([A-z0-9_]+) -->/', '\' . $this->get_theme_hook(\'\\1\') . \'', $text); |
|
2650 |
2604 // only do this if the plugins API is loaded |
2651 // only do this if the plugins API is loaded |
2605 if ( is_object(@$plugins) ) |
2652 if ( is_object(@$plugins) ) |
2606 { |
2653 { |
2607 $code = $plugins->setHook('template_compile_subst'); |
2654 $code = $plugins->setHook('template_compile_subst'); |
2608 foreach ( $code as $cmd ) |
2655 foreach ( $code as $cmd ) |