X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=lib%2Futil.php;h=4d670edcc157a059aa84edcc67247e9529b3fde4;hb=17fd7b185054e260f0a9a2cedd264ff3ef43d725;hp=0b71cfe4f596e321e9dceaa2fe524f952ccff320;hpb=b57182a8efd306ea0e8891785412990fbc256c36;p=quix0rs-gnu-social.git diff --git a/lib/util.php b/lib/util.php index 0b71cfe4f5..4d670edcc1 100644 --- a/lib/util.php +++ b/lib/util.php @@ -114,11 +114,11 @@ function common_element($tag, $attrs=NULL, $content=NULL) { common_element_end($tag); } -function common_start_xml($doc=NULL, $public=NULL, $system=NULL) { +function common_start_xml($doc=NULL, $public=NULL, $system=NULL, $indent=true) { global $xw; $xw = new XMLWriter(); $xw->openURI('php://output'); - $xw->setIndent(true); + $xw->setIndent($indent); $xw->startDocument('1.0', 'UTF-8'); if ($doc) { $xw->writeDTD($doc, $public, $system); @@ -131,66 +131,54 @@ function common_end_xml() { $xw->flush(); } +function common_init_locale($language=null) { + if(!$language) { + $language = common_language(); + } + putenv('LANGUAGE='.$language); + putenv('LANG='.$language); + return setlocale(LC_ALL, $language . ".utf8", + $language . ".UTF8", + $language . ".utf-8", + $language . ".UTF-8", + $language); +} + function common_init_language() { mb_internal_encoding('UTF-8'); $language = common_language(); # So we don't have to make people install the gettext locales - putenv('LANGUAGE='.$language); - putenv('LANG='.$language); - $locale_set = setlocale(LC_ALL, $language . ".utf8", - $language . ".UTF8", - $language . ".utf-8", - $language . ".UTF-8", - $language); + $locale_set = common_init_locale($language); bindtextdomain("laconica", common_config('site','locale_path')); bind_textdomain_codeset("laconica", "UTF-8"); textdomain("laconica"); setlocale(LC_CTYPE, 'C'); + if(!$locale_set) { + common_log(LOG_INFO,'Language requested:'.$language.' - locale could not be set:',__FILE__); + } } define('PAGE_TYPE_PREFS', 'text/html,application/xhtml+xml,application/xml;q=0.3,text/xml;q=0.2'); function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall=NULL) { - global $config, $xw; - - $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : NULL; - - # XXX: allow content negotiation for RDF, RSS, or XRDS - - $type = common_negotiate_type(common_accept_to_prefs($httpaccept), - common_accept_to_prefs(PAGE_TYPE_PREFS)); - - if (!$type) { - common_user_error(_('This page is not available in a media type you accept'), 406); - exit(0); - } - - header('Content-Type: '.$type); - - common_start_xml('html', - '-//W3C//DTD XHTML 1.0 Strict//EN', - 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); - - # FIXME: correct language for interface - $language = common_language(); + global $config, $xw; + global $action; /* XXX: kind of cheating here. */ - common_element_start('html', array('xmlns' => 'http://www.w3.org/1999/xhtml', - 'xml:lang' => $language, - 'lang' => $language)); + common_start_html(); common_element_start('head'); common_element('title', NULL, $pagetitle . " - " . $config['site']['name']); common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => theme_path('display.css'), + 'href' => theme_path('display.css') . '?version=' . LACONICA_VERSION, 'media' => 'screen, projection, tv')); foreach (array(6,7) as $ver) { if (file_exists(theme_file('ie'.$ver.'.css'))) { # Yes, IE people should be put in jail. $xw->writeComment('[if lte IE '.$ver.']> common_path('js/jquery.form.js')), ' '); common_element('script', array('type' => 'text/javascript', - 'src' => common_path('js/util.js')), + 'src' => common_path('js/xbImportNode.js')), + ' '); + common_element('script', array('type' => 'text/javascript', + 'src' => common_path('js/util.js?version='.LACONICA_VERSION)), ' '); common_element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml', 'href' => common_local_url('opensearch', array('type' => 'people')), @@ -219,7 +210,7 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall= } } common_element_end('head'); - common_element_start('body'); + common_element_start('body', $action); common_element_start('div', array('id' => 'wrap')); common_element_start('div', array('id' => 'header')); common_nav_menu(); @@ -252,6 +243,37 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall= common_element_start('div', array('id' => 'content')); } +function common_start_html($type=NULL, $indent=true) { + + if (!$type) { + $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : NULL; + + # XXX: allow content negotiation for RDF, RSS, or XRDS + + $type = common_negotiate_type(common_accept_to_prefs($httpaccept), + common_accept_to_prefs(PAGE_TYPE_PREFS)); + + if (!$type) { + common_user_error(_('This page is not available in a media type you accept'), 406); + exit(0); + } + } + + header('Content-Type: '.$type); + + common_start_xml('html', + '-//W3C//DTD XHTML 1.0 Strict//EN', + 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd', $indent); + + # FIXME: correct language for interface + + $language = common_language(); + + common_element_start('html', array('xmlns' => 'http://www.w3.org/1999/xhtml', + 'xml:lang' => $language, + 'lang' => $language)); +} + function common_show_footer() { global $xw, $config; common_element_end('div'); # content div @@ -303,7 +325,6 @@ function common_nav_menu() { _('Home')); } common_menu_item(common_local_url('peoplesearch'), _('Search')); - common_menu_item(common_local_url('tags'), _('Tags')); if ($user) { common_menu_item(common_local_url('profilesettings'), _('Settings')); @@ -318,6 +339,8 @@ function common_nav_menu() { } common_menu_item(common_local_url('openidlogin'), _('OpenID')); } + common_menu_item(common_local_url('doc', array('title' => 'help')), + _('Help')); common_element_end('ul'); } @@ -369,7 +392,7 @@ function common_input($id, $label, $value=NULL,$instructions=NULL) { common_element_end('p'); } -function common_checkbox($id, $label, $checked=false, $instructions=NULL, $value='true') +function common_checkbox($id, $label, $checked=false, $instructions=NULL, $value='true', $disabled=false) { common_element_start('p'); $attrs = array('name' => $id, @@ -382,10 +405,12 @@ function common_checkbox($id, $label, $checked=false, $instructions=NULL, $value if ($checked) { $attrs['checked'] = 'checked'; } + if ($disabled) { + $attrs['disabled'] = 'true'; + } common_element('input', $attrs); - # XXX: use a