Esempio n. 1
0
function elggadmin_pagesetup()
{
    // first login?
    global $CFG;
    if (user_flag_get('admin', $_SESSION['userid']) && !isset($CFG->elggadmin_installed)) {
        $CFG->elggadmin_installed = true;
        set_config('elggadmin_installed', true);
        header_redirect(get_url(null, 'elggadmin::config'), __gettext('Welcome to the Elgg configuration manager!'));
    }
    if (context() == 'admin') {
        if (!plugin_is_loaded('pages')) {
            elgg_messages_add(__gettext('Error: <code>elggadmin</code> plugin needs <code>pages</code> plugin to run'));
        } else {
            pages_submenu_add('elggadmin', __gettext('Site administration'), get_url(null, 'elggadmin::'), 10);
        }
    } elseif (context() == 'elggadmin') {
        if (!plugin_is_loaded('pages')) {
            elgg_messages_add(__gettext('Error: <code>elggadmin</code> plugin needs <code>pages</code> plugin to run'));
            header_redirect(get_url(null, 'admin::'));
        }
        // submenu options
        pages_submenu_add('elggadmin', __gettext('Configuration manager'), get_url(null, 'elggadmin::'));
        pages_submenu_add('elggadmin:theme', __gettext('Default theme editor'), get_url(null, 'elggadmin::theme'));
        pages_submenu_add('elggadmin:frontpage', __gettext('Frontpage template editor'), get_url(null, 'elggadmin::frontpage'));
        pages_submenu_add('elggadmin:logs', __gettext('Error log'), get_url(null, 'elggadmin::logs'));
        sidebar_add(50, 'sidebar-' . elggadmin_currentpage(), elggadmin_sidebar());
        // clear sidebar
        $clear_sidebar[] = 'sidebar-profile';
        $clear_sidebar[] = 'sidebar-' . elggadmin_currentpage();
        sidebar_remove($clear_sidebar, true);
        if (elggadmin_is_404()) {
            header('HTTP/1.0 404 Not Found');
        }
    }
}
function elggadmin_sidebar()
{
    $output = '';
    if (elggadmin_currentpage() == 'frontpage' || elggadmin_currentpage() == 'theme') {
        $output .= "<h2>" . __gettext("Special keywords") . "</h2>";
        $output .= "<p>" . __gettext("You can insert these into your pageshell for special functionality:") . "</p>";
        $output .= "<p><b>{{url}}</b> " . __gettext("The address of your site.") . "</p>";
        $output .= "<p><b>{{sitename}}</b> " . __gettext("The name of your site.") . "</p>";
        $output .= "<p><b>{{tagline}}</b> " . __gettext("Your site's tagline.") . "</p>";
        $output .= "<p><b>{{username}}</b> " . __gettext("The current user's username.") . "</p>";
        $output .= "<p><b>{{userfullname}}</b> " . __gettext("The current user's full name.") . "</p>";
        $output .= "<p><b>{{populartags}}</b> " . __gettext("A list of the most popular tags.") . "</p>";
        $output .= "<p><b>{{randomusers}}</b> " . __gettext("A list of random users who have filled in their profiles, if some exist.") . "</p>";
        $output .= "<p><b>{{people:interests:foo:5}}</b> " . __gettext("Lists five people interested in 'foo' in a horizontal table.") . "</p>";
        $output .= "<p><b>{{toptags:town}}</b> " . __gettext("Lists the top tags of type 'town' (or select weblog, file or the profile field of your choice).") . "</p>";
    }
    return $output;
}