1414 * @return string The first two lowercase letter of the browser language.
1515 */
1616function get_browser_lang () {
17- $ lang = explode (', ' ,@$ _SERVER ['HTTP_ACCEPT_LANGUAGE ' ]);
18- return htmlspecialchars (strtolower (substr (chop ($ lang [0 ]), 0 , 2 )));
17+ $ lang = explode (', ' ,@$ _SERVER ['HTTP_ACCEPT_LANGUAGE ' ]);
18+ return htmlspecialchars (strtolower (substr (chop ($ lang [0 ]), 0 , 2 )));
1919}
2020
2121/**
@@ -41,7 +41,7 @@ function get_page($sPage) {
4141 * @return string The text parsed.
4242 */
4343function parse_var ($ sContent ) {
44- $ sContent = str_replace ('{site_url} ' , ROOT_URL , $ sContent );
44+ $ sContent = str_replace ('{site_url} ' , RELATIVE , $ sContent );
4545 $ sContent = str_replace ('{static_url} ' , STATIC_URL , $ sContent );
4646 $ sContent = str_replace ('{tpl_name} ' , TPL , $ sContent );
4747 $ sContent = str_replace ('{menu_links} ' , get_links_html (), $ sContent );
@@ -90,25 +90,25 @@ function get_current_url() {
9090 * @return string The language available.
9191 */
9292function set_lang () {
93- if (!empty ($ _GET ['l ' ]) && is_file (DATA_PATH . $ _GET ['l ' ] . '/core/welcome.tpl ' ) && is_file (DATA_PATH . $ _GET ['l ' ] . '/core/404-error.tpl ' ))
94- {
95- setcookie ('pH7_doc_lang ' , $ _GET ['l ' ], time ()+60 *60 *24 *365 , null , null , false , true );
96- $ sLang = $ _GET ['l ' ];
97- }
98- elseif (isset ($ _COOKIE ['pH7_doc_lang ' ]) && is_dir (DATA_PATH . $ _COOKIE ['pH7_doc_lang ' ] . '/core/ ' ))
99- {
100- $ sLang = $ _COOKIE ['pH7_doc_lang ' ];
101- }
102- elseif (is_dir (DATA_PATH . get_browser_lang () . '/core/ ' ))
103- {
104- $ sLang = get_browser_lang ();
105- }
106- else
107- {
108- $ sLang = DEF_LANG ;
109- }
93+ if (!empty ($ _GET ['l ' ]) && is_file (DATA_PATH . $ _GET ['l ' ] . '/core/welcome.tpl ' ) && is_file (DATA_PATH . $ _GET ['l ' ] . '/core/404-error.tpl ' ))
94+ {
95+ setcookie ('pH7_doc_lang ' , $ _GET ['l ' ], time ()+60 *60 *24 *365 , null , null , false , true );
96+ $ sLang = $ _GET ['l ' ];
97+ }
98+ elseif (isset ($ _COOKIE ['pH7_doc_lang ' ]) && is_dir (DATA_PATH . $ _COOKIE ['pH7_doc_lang ' ] . '/core/ ' ))
99+ {
100+ $ sLang = $ _COOKIE ['pH7_doc_lang ' ];
101+ }
102+ elseif (is_dir (DATA_PATH . get_browser_lang () . '/core/ ' ))
103+ {
104+ $ sLang = get_browser_lang ();
105+ }
106+ else
107+ {
108+ $ sLang = DEF_LANG ;
109+ }
110110
111- return $ sLang ;
111+ return $ sLang ;
112112}
113113
114114/**
0 commit comments