X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Futil.php;h=1a0dd07d2628552ab6c2551f33ce95dac3c5342a;hb=3f1f1427d9d65215af7546de2ad5c16120f44857;hp=def3a57506f9037c4d85fea46bd23ae15cb6f2ab;hpb=9f39fd31afe198fc78c669088710af64a9976c3d;p=quix0rs-gnu-social.git
diff --git a/lib/util.php b/lib/util.php
index def3a57506..1a0dd07d26 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -94,16 +94,15 @@ function common_element_start($tag, $attrs=NULL) {
function common_element_end($tag) {
global $xw;
- $xw->endElement();
+ # TODO: switch based on $tag
+ $xw->fullEndElement();
}
function common_element($tag, $attrs=NULL, $content=NULL) {
common_element_start($tag, $attrs);
- if ($content) {
- global $xw;
- $xw->text($content);
- }
- common_element_end($tag);
+ global $xw;
+ $xw->text($content);
+ common_element_end($tag);
}
function common_start_xml($doc=NULL, $public=NULL, $system=NULL) {
@@ -123,10 +122,24 @@ function common_end_xml() {
$xw->flush();
}
-function common_show_header($pagetitle, $callable=NULL, $data=NULL, $notice=NULL) {
+define('PAGE_TYPE_PREFS', 'application/xhtml+xml,text/html;q=0.7,application/xml;q=0.3,text/xml;q=0.2');
+
+function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall=NULL) {
global $config, $xw;
- header('Content-Type: application/xhtml+xml');
+ $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(_t('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',
@@ -149,9 +162,17 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $notice=NULL
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) {
call_user_func($callable, $data);
@@ -164,14 +185,30 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $notice=NULL
common_element_start('div', array('id' => 'wrap'));
common_element_start('div', array('id' => 'header'));
common_nav_menu();
- common_element_start('a', array('href' => common_local_url('public')));
- common_element('img', array('src' => ($config['site']['logo']) ?
- ($config['site']['logo']) : theme_path('logo.png'),
- 'alt' => $config['site']['name'],
- 'id' => 'logo'));
- common_element_end('a');
- if (common_logged_in()) {
- common_notice_form();
+ if ((is_string($config['site']['logo']) && (strlen($config['site']['logo']) > 0))
+ || file_exists(theme_file('logo.png')))
+ {
+ common_element_start('a', array('href' => common_local_url('public')));
+ common_element('img', array('src' => ($config['site']['logo']) ?
+ ($config['site']['logo']) : theme_path('logo.png'),
+ 'alt' => $config['site']['name'],
+ 'id' => 'logo'));
+ common_element_end('a');
+ } else {
+ common_element_start('p', array('id' => 'branding'));
+ common_element('a', array('href' => common_local_url('public')),
+ $config['site']['name']);
+ common_element_end('p');
+ }
+
+ common_element('h1', 'pagetitle', $pagetitle);
+
+ if ($headercall) {
+ if ($data) {
+ call_user_func($headercall, $data);
+ } else {
+ call_user_func($headercall);
+ }
}
common_element_end('div');
common_element_start('div', array('id' => 'content'));
@@ -182,6 +219,20 @@ function common_show_footer() {
common_element_end('div'); # content div
common_foot_menu();
common_element_start('div', array('id' => 'footer'));
+ common_element_start('div', 'laconica');
+ if (common_config('site', 'broughtby')) {
+ $instr = _t('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
+ } else {
+ $instr = _t('**%%site.name%%** is a microblogging service. ');
+ }
+ $instr .= _t('It runs the [Laconica](http://laconi.ca/) ' .
+ 'microblogging software, version ' . LACONICA_VERSION . ', ' .
+ 'available under the ' .
+ '[GNU Affero General Public License]' .
+ '(http://www.fsf.org/licensing/licenses/agpl-3.0.html).');
+ $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']));
@@ -228,6 +279,7 @@ function common_nav_menu() {
} 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_element_end('ul');
}
@@ -236,14 +288,18 @@ function common_foot_menu() {
common_element_start('ul', array('id' => 'nav_sub'));
common_menu_item(common_local_url('doc', array('title' => 'about')),
_t('About'));
+ common_menu_item(common_local_url('doc', array('title' => 'faq')),
+ _t('FAQ'));
common_menu_item(common_local_url('doc', array('title' => 'privacy')),
_t('Privacy'));
common_menu_item(common_local_url('doc', array('title' => 'source')),
_t('Source'));
+ common_menu_item(common_local_url('doc', array('title' => 'contact')),
+ _t('Contact'));
common_element_end('ul');
}
-function common_menu_item($url, $text, $title=NULL, $is_selected) {
+function common_menu_item($url, $text, $title=NULL, $is_selected=false) {
$lattrs = array();
if ($is_selected) {
$lattrs['class'] = 'current';
@@ -257,16 +313,44 @@ function common_menu_item($url, $text, $title=NULL, $is_selected) {
common_element_end('li');
}
-function common_input($id, $label, $value=NULL) {
+function common_input($id, $label, $value=NULL,$instructions=NULL) {
common_element_start('p');
common_element('label', array('for' => $id), $label);
$attrs = array('name' => $id,
'type' => 'text',
+ 'class' => 'input_text',
'id' => $id);
if ($value) {
$attrs['value'] = htmlspecialchars($value);
}
common_element('input', $attrs);
+ if ($instructions) {
+ common_element('span', 'input_instructions', $instructions);
+ }
+ common_element_end('p');
+}
+
+function common_checkbox($id, $label, $checked=false, $instructions=NULL, $value='true')
+{
+ common_element_start('p');
+ $attrs = array('name' => $id,
+ 'type' => 'checkbox',
+ 'class' => 'checkbox',
+ 'id' => $id);
+ if ($value) {
+ $attrs['value'] = htmlspecialchars($value);
+ }
+ if ($checked) {
+ $attrs['checked'] = 'checked';
+ }
+ common_element('input', $attrs);
+ # XXX: use a