Beispiel #1
0
function do_header($title, $id = 'home')
{
    global $current_user, $dblang, $globals, $greetings, $db;
    // escolhe norma
    $stdRow = false;
    // if change by request
    if ($_REQUEST['standard']) {
        $stdRow = $globals['standards'][$_REQUEST['standard']];
        if ($current_user->authenticated) {
            // authenticated users store that in their profile
            $user = new User($current_user->user_id);
            $user->standard = (int) $_REQUEST['standard'];
            $user->store();
        } else {
            // if not authenticated, store on cookie
            setcookie("chuza_current_standard", (int) $_REQUEST['standard'], time() + 3600 * 24 * 365 * 3);
            // 3 anos de cookie
        }
    } elseif ($current_user->authenticated) {
        // user authenticated but NOT request change
        $stdRow = $globals['standards'][(int) $current_user->standard];
    } else {
        // set default standard for non authenticated users
        // search in redis
        $check_ip = $globals['user_ip_int'];
        $redis = new Predis_Client();
        $r = $redis->zrevrangebyscore($globals['enviroment'] . 'ips', $check_ip, '0', 'WITHSCORES', 'LIMIT', '0', '1');
        preg_match('/(^[^-]*)/', $r[0], $matches);
        if (in_array($matches[0], $globals['lusophonia'])) {
            $stdRow = 1;
        } else {
            if (!$_COOKIE['chuza_current_standard']) {
                $_COOKIE['chuza_current_standard'] = 1;
            }
            $stdRow = $globals['standards'][$_COOKIE['chuza_current_standard']];
        }
    }
    if ($stdRow) {
        putenv('LANGUAGE=' . $stdRow['short_name']);
        setlocale(LC_MESSAGES, $stdRow['short_name']);
        $current_user->standard = $stdRow['id'];
    } else {
        // default standard
        putenv('LANGUAGE=gl_ES.utf8');
        setlocale(LC_MESSAGES, 'gl_ES.utf8');
        $current_user->standard = 1;
    }
    bindtextdomain('meneame', mnminclude . '/languages');
    textdomain('meneame');
    // fim de escolher norma
    check_auth_page();
    header('Content-Type: text/html; charset=utf-8');
    http_cache();
    if (!empty($globals['link_id'])) {
        // Pingback autodiscovery
        // http://www.hixie.ch/specs/pingback/pingback
        header('X-Pingback: http://' . get_server_name() . $globals['base_url'] . 'xmlrpc.php');
    }
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
    //echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
    echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $dblang . '" lang="' . $dblang . '">' . "\n";
    echo '<head>' . "\n";
    echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
    echo '<meta name="ROBOTS" content="NOARCHIVE" />' . "\n";
    echo "<title>{$title}</title>\n";
    do_css_includes();
    echo '<meta name="generator" content="meneame" />' . "\n";
    if ($globals['noindex']) {
        echo '<meta name="robots" content="noindex,follow"/>' . "\n";
    }
    if ($globals['tags']) {
        echo '<meta name="keywords" content="' . $globals['tags'] . '" />' . "\n";
    }
    if ($globals['description']) {
        echo '<meta name="description" content="' . $globals['description'] . '" />' . "\n";
    }
    if ($globals['link']) {
        echo '<link rel="pingback" href="http://' . get_server_name() . $globals['base_url'] . 'xmlrpc.php"/>' . "\n";
    }
    echo '<link rel="microsummary" type="application/x.microsummary+xml" href="' . $globals['base_url'] . 'microsummary.xml" />' . "\n";
    echo '<link rel="search" type="application/opensearchdescription+xml" title="' . _("menéame search") . '" href="http://' . get_server_name() . $globals['base_url'] . 'opensearch_plugin.php"/>' . "\n";
    echo '<link rel="alternate" type="application/rss+xml" title="' . _('publicadas') . '" href="http://' . get_server_name() . $globals['base_url'] . 'rss2.php" />' . "\n";
    echo '<link rel="alternate" type="application/rss+xml" title="' . _('pendientes') . '" href="http://' . get_server_name() . $globals['base_url'] . 'rss2.php?status=queued" />' . "\n";
    echo '<link rel="alternate" type="application/rss+xml" title="' . _('comentarios') . '" href="http://' . get_server_name() . $globals['base_url'] . 'comments_rss2.php" />' . "\n";
    if (!$globals['favicon']) {
        $globals['favicon'] = 'favicon.ico';
    }
    echo '<link rel="shortcut icon" href="' . $globals['base_static'] . $globals['favicon'] . '" type="image/x-icon"/>' . "\n";
    do_js_includes();
    if ($globals['thumbnail']) {
        // WARN: It's assumed a thumbanil comes with base_url included
        $thumb = $globals['thumbnail'];
    } else {
        $thumb = 'http://' . get_static_server_name() . $globals['base_url'] . $globals['thumbnail_logo'];
    }
    echo '<meta name="thumbnail_url" content="' . $thumb . "\"/>\n";
    echo '<link rel="image_src" href="' . $thumb . "\"/>\n";
    if ($globals['extra_head']) {
        echo $globals['extra_head'];
    }
    echo '</head>' . "\n";
    echo "<body id=\"{$id}\" " . $globals['body_args'] . ">\n";
    if ($globals["news"]) {
        echo '<div style="background-color:red;padding:8px;font-color:white;font-weigth:bold;" >' . $globals["news"] . '</div>';
    }
    echo '<div id="wrap">' . "\n";
    echo '<div id="header">' . "\n";
    echo '<a href="' . $globals['base_url'] . '" title="' . _('inicio') . '" id="logo">' . _("menéame") . '</a>' . "\n";
    echo '<ul id="headtools">' . "\n";
    // Main search form
    echo '<li class="searchbox">' . "\n";
    echo '<form action="' . $globals['base_url'] . 'search.php" method="get" name="top_search">' . "\n";
    echo '<img src="' . $globals['base_static'] . 'img/common/search-left-04.png" width="6" height="22" alt=""/>';
    if (!empty($_REQUEST['q'])) {
        echo '<input type="text" name="q" value="' . htmlspecialchars($_REQUEST['q']) . '" />';
    } else {
        echo '<input name="q" value="' . _('buscar') . '..." type="text" onblur="if(this.value==\'\') this.value=\'' . _('buscar') . '...\';" onfocus="if(this.value==\'' . _('buscar') . '...\') this.value=\'\';"/>';
    }
    echo '<a href="javascript:document.top_search.submit()"><img class="searchIcon" alt="' . _('buscar') . '" src="' . $globals['base_static'] . 'img/common/search-04.png" id="submit_image" width="28" height="22"/></a>' . "\n";
    if ($globals['search_options']) {
        foreach ($globals['search_options'] as $name => $value) {
            echo '<input type="hidden" name="' . $name . '" value="' . $value . '"/>' . "\n";
        }
    }
    echo '</form>';
    echo '</li>' . "\n";
    // form
    echo '<li><a href="' . $globals["base_url"] . 'equipa/index.php?page=axuda">' . _('ayuda') . ' <img src="' . $globals['base_static'] . 'img/common/help-bt-02.png" alt="help button" title="' . _('ayuda') . '" width="13" height="16" /></a></li>';
    echo '<li><a href="' . $globals["base_url"] . 'equipa/index.php?page=o-novo-chuza">O novo chuza</a></li>';
    if ($globals["show_blog"]) {
        echo '<li><a href="' . $globals["base_url"] . 'blog">blog</a></li>';
    }
    if ($globals["show_wiki"]) {
        echo '<li><a href="' . $globals["base_url"] . 'wiki">wiki</a></li>';
    }
    if ($current_user->admin) {
        echo '<li><a href="' . $globals['base_url'] . 'admin/bans.php">admin <img src="' . $globals['base_static'] . 'img/common/tools-bt-02.png" alt="tools button" title="herramientas" width="16" height="16" /> </a></li>' . "\n";
    }
    // choose standard change link
    $next_standard = $current_user->standard % count($globals['standards']) + 1;
    $this_page = basename($_SERVER['REQUEST_URL']);
    if (strpos($this_page, "?") !== false) {
        $this_page = reset(explode("?", $this_page));
    }
    //echo '<li><a href="'.$this_page.'?standard='.$next_standard.'" >'.$globals['standards'][$current_user->standard]['name'].'</a></li>'."\n";
    echo '<li><a href="' . $this_page . '?standard=' . $next_standard . '" >' . $globals['standards'][$next_standard]['name'] . '</a></li>' . "\n";
    if ($current_user->authenticated) {
        //$randhello = array_rand($greetings, 1); // deprecated in Chuza
        echo '<li><a href="' . get_user_uri($current_user->user_login) . '" title="' . _('Ver perfil de usuario') . '">' . '&nbsp;' . $current_user->user_login . '&nbsp;<img src="' . get_avatar_url($current_user->user_id, $current_user->user_avatar, 20) . '" width="20" height="20" alt="' . $current_user->user_login . '"/></a></li>' . "\n";
        echo '<li><a href="' . $globals['base_url'] . 'login.php?op=logout&amp;return=' . urlencode($_SERVER['REQUEST_URI']) . '">' . _('cerrar sesión') . ' <img src="' . $globals['base_static'] . 'img/common/logout-bt-02.png" alt="" title="logout" width="22" height="16" /></a></li>' . "\n";
    } else {
        echo '<li><a href="' . $globals['base_url'] . 'register.php">' . _('registrarse') . ' <img src="' . $globals['base_static'] . 'img/common/register-bt-02.png" alt="" title="register" width="16" height="18" /></a></li>' . "\n";
        echo '<li><a href="' . $globals['base_url'] . 'login.php?return=' . urlencode($_SERVER['REQUEST_URI']) . '">' . _('login') . ' <img src="' . $globals['base_static'] . 'img/common/login-bt-02.png" alt="" title="login" width="22" height="16" /></a></li>' . "\n";
    }
    //echo '<li><a href="'.$globals['base_url'].'faq-'.$dblang.'.php">' . _('acerca de menéame').'</a></li>' . "\n";
    $s = $_SERVER['SCRIPT_NAME'];
    $matches = array();
    preg_match('/\\/([^\\/]*)$/', $s, $matches);
    switch ($matches[1]) {
        case "topstories.php":
            $classTopstories = "enfatized";
            break;
        case "index.php":
            $classCover = "enfatized";
            break;
        case "shakeit.php":
            $classPendent = "enfatized";
            break;
        case "sneak.php":
            $classSneak = "enfatized";
            break;
    }
    if (strpos($_SERVER['REQUEST_URI'], 'chios') !== FALSE) {
        $classChios = "enfatized";
        $classCover = "";
        // previously assigned wrongly
    }
    echo '</ul>' . "\n";
    echo '</div>' . "\n";
    echo '<div id="newnavbar" >' . "\n";
    echo '<ul class="first">' . "\n";
    //echo '<li style=""><a href="'.$globals['base_url'].'shakeit.php">'._('pendientes').'</a></li>'."\n";
    echo '<li class="' . $classCover . '"><a href="' . $globals['base_url'] . '">' . _('portada') . '</a></li>' . "\n";
    echo '<li class="' . $classPendent . '"><a href="' . $globals['base_url'] . 'shakeit.php">' . _('pendientes') . '</a></li>' . "\n";
    echo '<li class="' . $classTopstories . '"><a href="' . $globals['base_url'] . 'topstories.php">' . _('Populares') . '</a></li>' . "\n";
    //Novas populares
    echo '<li class="' . $classSneak . '"><a href="' . $globals['base_url'] . 'sneak.php">' . _('fisgona') . '</a></li>' . "\n";
    echo '<li class="' . $classChios . '" ><a href="' . $globals['base_url'] . 'chios/">' . _('nótame') . '</a></li>' . "\n";
    echo '<li id="lastlititle" ><a href="' . $globals['base_url'] . 'equipa/?page=calendario">' . _('calendario') . '</a></li>' . "\n";
    echo '</ul>';
    echo '<ul class="last">' . "\n";
    if ($current_user->user_login) {
        $u = get_user_uri($current_user->user_login, 'categories');
        echo '<li><a href="' . $u . '">' . _('personalizar') . '</a></li>' . "\n";
        echo '<li><a href="' . $globals['base_url'] . 'submit.php">' . _('enviar noticia') . '</a></li>' . "\n";
    }
    //echo '<li style=""><a href="'.$globals['base_url'].'shakeit.php">'._('pendientes').'</a></li>'."\n";
    //echo '<li><a href="'.$globals['base_url'].'sneak.php">'._('fisgona').'</a></li>'."\n";
    //echo '<li><a href="'.$globals['base_url'].'chios/">'._('nótame').'</a></li>'."\n";
    echo '</ul>';
    echo '&nbsp;</div>' . "\n";
    //do_banner_top();
    echo '<div id="container">' . "\n";
}