X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Futil.php;h=1aa9d2944c9b044da1930fdfb3cb37639bf3cfa2;hb=265d267d8192b5674cf974e0d0429cdf50087cc2;hp=e2c9c67a1ef73f91ae5158c49420d47ad17944a9;hpb=bb3c796c25f989b529af0e985faa857689e0b25f;p=quix0rs-gnu-social.git diff --git a/lib/util.php b/lib/util.php index e2c9c67a1e..1aa9d2944c 100644 --- a/lib/util.php +++ b/lib/util.php @@ -93,14 +93,22 @@ function common_element_start($tag, $attrs=NULL) { } function common_element_end($tag) { + static $empty_tag = array('base', 'meta', 'link', 'hr', + 'br', 'param', 'img', 'area', + 'input', 'col'); global $xw; - $xw->endElement(); + # XXX: check namespace + if (in_array($tag, $empty_tag)) { + $xw->endElement(); + } else { + $xw->fullEndElement(); + } } function common_element($tag, $attrs=NULL, $content=NULL) { - common_element_start($tag, $attrs); + common_element_start($tag, $attrs); + global $xw; if ($content) { - global $xw; $xw->text($content); } common_element_end($tag); @@ -123,7 +131,7 @@ function common_end_xml() { $xw->flush(); } -define('PAGE_TYPE_PREFS', 'application/xhtml+xml,text/html;q=0.7,application/xml;q=0.3,text/xml;q=0.2'); +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; @@ -136,7 +144,7 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall= common_accept_to_prefs(PAGE_TYPE_PREFS)); if (!$type) { - common_client_error(_t('This page is not available in a media type you accept'), 406); + common_user_error(_('This page is not available in a media type you accept'), 406); exit(0); } @@ -163,13 +171,16 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall= if (file_exists(theme_file('ie'.$ver.'.css'))) { # Yes, IE people should be put in jail. $xw->writeComment('[if lte IE '.$ver.']> 'text/javascript', 'src' => common_path('js/jquery.min.js')), ' '); + common_element('script', array('type' => 'text/javascript', + 'src' => common_path('js/util.js')), + ' '); if ($callable) { if ($data) { @@ -217,26 +228,26 @@ function common_show_footer() { common_element_end('div'); # content div common_foot_menu(); common_element_start('div', array('id' => 'footer')); - common_element_start('p', 'laconica'); - common_text(_t('This site is running the ')); - common_element('a', array('class' => 'software', - href => 'http://laconi.ca/'), - 'Laconica'); - common_text(_t('microblogging tool, version ' . LACONICA_VERSION . ', available under the ')); - common_element('a', array(href => 'http://www.fsf.org/licensing/licenses/agpl-3.0.html'), - 'GNU Affero General Public License'); - common_text(_t('.')); - common_element_end('p'); + common_element_start('div', 'laconica'); + if (common_config('site', 'broughtby')) { + $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). '); + } else { + $instr = _('**%%site.name%%** is a microblogging service. '); + } + $instr .= sprintf(_('It runs the [Laconica](http://laconi.ca/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), LACONICA_VERSION); + $output = common_markup_to_html($instr); + common_raw($output); + common_element_end('div'); common_element('img', array('id' => 'cc', 'src' => $config['license']['image'], 'alt' => $config['license']['title'])); common_element_start('p'); - common_text(_t('Unless otherwise specified, contents of this site are copyright by the contributors and available under the ')); + common_text(_('Unless otherwise specified, contents of this site are copyright by the contributors and available under the ')); common_element('a', array('class' => 'license', 'rel' => 'license', href => $config['license']['url']), $config['license']['title']); - common_text(_t('. Contributors should be attributed by full name or nickname.')); + common_text(_('. Contributors should be attributed by full name or nickname.')); common_element_end('p'); common_element_end('div'); common_element_end('div'); @@ -260,20 +271,21 @@ function common_nav_menu() { common_element_start('ul', array('id' => 'nav')); if ($user) { common_menu_item(common_local_url('all', array('nickname' => $user->nickname)), - _t('Home')); + _('Home')); } - common_menu_item(common_local_url('public'), _t('Public')); + common_menu_item(common_local_url('public'), _('Public')); + common_menu_item(common_local_url('peoplesearch'), _('Search')); common_menu_item(common_local_url('doc', array('title' => 'help')), - _t('Help')); + _('Help')); if ($user) { common_menu_item(common_local_url('profilesettings'), - _t('Settings')); + _('Settings')); common_menu_item(common_local_url('logout'), - _t('Logout')); + _('Logout')); } else { - common_menu_item(common_local_url('login'), _t('Login')); - common_menu_item(common_local_url('register'), _t('Register')); - common_menu_item(common_local_url('openidlogin'), _t('OpenID')); + common_menu_item(common_local_url('login'), _('Login')); + common_menu_item(common_local_url('register'), _('Register')); + common_menu_item(common_local_url('openidlogin'), _('OpenID')); } common_element_end('ul'); } @@ -281,11 +293,15 @@ function common_nav_menu() { function common_foot_menu() { common_element_start('ul', array('id' => 'nav_sub')); common_menu_item(common_local_url('doc', array('title' => 'about')), - _t('About')); + _('About')); + common_menu_item(common_local_url('doc', array('title' => 'faq')), + _('FAQ')); common_menu_item(common_local_url('doc', array('title' => 'privacy')), - _t('Privacy')); + _('Privacy')); common_menu_item(common_local_url('doc', array('title' => 'source')), - _t('Source')); + _('Source')); + common_menu_item(common_local_url('doc', array('title' => 'contact')), + _('Contact')); common_element_end('ul'); } @@ -308,6 +324,7 @@ function common_input($id, $label, $value=NULL,$instructions=NULL) { common_element('label', array('for' => $id), $label); $attrs = array('name' => $id, 'type' => 'text', + 'class' => 'input_text', 'id' => $id); if ($value) { $attrs['value'] = htmlspecialchars($value); @@ -319,18 +336,24 @@ function common_input($id, $label, $value=NULL,$instructions=NULL) { common_element_end('p'); } -function common_checkbox($id, $label, $instructions=NULL, $value='true') +function common_checkbox($id, $label, $checked=false, $instructions=NULL, $value='true') { common_element_start('p'); $attrs = array('name' => $id, 'type' => 'checkbox', - 'id' => $id, - 'value' => $value); + 'class' => 'checkbox', + 'id' => $id); if ($value) { $attrs['value'] = htmlspecialchars($value); } + if ($checked) { + $attrs['checked'] = 'checked'; + } common_element('input', $attrs); - common_element('label', array('for' => $id), $label); + # XXX: use a