Пример #1
0
}

var selectedmenu = 'loggedoutmenu';
var adminfiles = null;
addLoadEvent(function () {
    \$('menuselect').value = selectedmenu;
    \$('menuselect').onchange = changemenu;
    changemenu();
});
EOJS;
$menulist = array('loggedinmenu', 'loggedoutmenu');
foreach ($menulist as &$menu) {
    $menu = array('value' => $menu, 'name' => get_string($menu, 'admin'));
}
// Edit form for footer links
$all = footer_menu(true);
$active = get_config('footerlinks');
$active = $active ? unserialize($active) : array_keys($all);
$activeurls = get_config('footercustomlinks');
$activeurls = $activeurls ? unserialize($activeurls) : null;
$footerelements = array();
foreach ($all as $k => $v) {
    $footerelements[$k] = array('type' => 'switchbox', 'class' => 'last pb0', 'title' => $v['title'], 'defaultvalue' => in_array($k, $active), 'onclick' => "getElement('footerlinks_{$k}_link').disabled = !this.checked;");
    $footerelements[$k . '_link'] = array('type' => 'text', 'size' => 60, 'description' => get_string('footercustomlink', 'admin', $v['url']), 'defaultvalue' => isset($activeurls[$k]) ? $activeurls[$k] : '', 'disabled' => !in_array($k, $active));
}
$footerelements['submit'] = array('class' => 'btn-primary', 'type' => 'submit', 'value' => get_string('savechanges', 'admin'));
$footerform = pieform(array('name' => 'footerlinks', 'elements' => $footerelements));
function footerlinks_submit(Pieform $form, $values)
{
    global $active, $activeurls, $all, $SESSION;
    $new = array();
Пример #2
0
/**
 * This function creates a Smarty object and sets it up for use within our
 * podclass app, setting up some variables.
 *
 * The variables that it sets up are:
 *
 * - WWWROOT: The base url for the Mahara system
 * - USER: The user object
 * - JAVASCRIPT: A list of javascript files to include in the header.  This
 *   list is passed into this function (see below).
 * - HEADERS: An array of any further headers to set.  Each header is just
 *   straight HTML (see below).
 * - PUBLIC: Set true if this page is a public page
 * - MAINNAV: Array defining the main navigation
 *
 * @param $javascript A list of javascript includes.  Each include should be just
 *                    the name of a file, and reside in js/{filename}
 * @param $headers    A list of additional headers.  These are to be specified as
 *                    actual HTML.
 * @param $strings    A list of language strings required by the javascript code.
 * @return Smarty
 */
function smarty($javascript = array(), $headers = array(), $pagestrings = array(), $extraconfig = array())
{
    global $USER, $SESSION, $THEME;
    if (!is_array($headers)) {
        $headers = array();
    }
    if (!is_array($pagestrings)) {
        $pagestrings = array();
    }
    if (!is_array($extraconfig)) {
        $extraconfig = array();
    }
    $SIDEBLOCKS = array();
    $smarty = smarty_core();
    $wwwroot = get_config('wwwroot');
    // NOTE: not using jswwwroot - it seems to wreck image paths if you
    // drag them around the wysiwyg editor
    $jswwwroot = json_encode($wwwroot);
    $theme_list = array();
    if (function_exists('pieform_get_headdata')) {
        $headers = array_merge($headers, pieform_get_headdata());
    }
    // Insert the appropriate javascript tags
    $javascript_array = array();
    $jsroot = $wwwroot . 'js/';
    $langdirection = get_string('thisdirection', 'langconfig');
    // TinyMCE must be included first for some reason we're not sure about
    $checkarray = array(&$javascript, &$headers);
    $found_tinymce = false;
    foreach ($checkarray as &$check) {
        if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) {
            if (!$found_tinymce) {
                $found_tinymce = $check[$key];
                $javascript_array[] = $jsroot . 'tinymce/tiny_mce.js';
                $content_css = json_encode($THEME->get_url('style/tinymce.css'));
                $language = substr(current_language(), 0, 2);
                $extrasetup = isset($extraconfig['tinymcesetup']) ? $extraconfig['tinymcesetup'] : '';
                $adv_buttons = array("bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,link,unlink,separator,code,fullscreen", "bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,hr,emotions,image,iespell,cleanup,separator,link,unlink,separator,code", "bullist,numlist,separator,tablecontrols,separator,cut,copy,paste,pasteword", "fontselect,separator,fontsizeselect,separator,formatselect");
                // For right-to-left langs, reverse button order & align controls right.
                $tinymce_langdir = $langdirection == 'rtl' ? 'rtl' : 'ltr';
                $toolbar_align = 'left';
                if ($check[$key] == 'tinymce') {
                    $tinymce_config = <<<EOF
    mode: "none",
    theme: "advanced",
    plugins: "table,emotions,iespell,inlinepopups,paste",
    theme_advanced_buttons1 : "{$adv_buttons[1]}",
    theme_advanced_buttons2 : "{$adv_buttons[2]}",
    theme_advanced_buttons3 : "{$adv_buttons[3]}",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "{$toolbar_align}",
    //width: '512',
EOF;
                } else {
                    $tinymce_config = <<<EOF
    mode: "textareas",
    editor_selector: 'tinywysiwyg',
    theme: "advanced",
    plugins: "fullscreen,inlinepopups",
    theme_advanced_buttons1 : "{$adv_buttons[0]}",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "{$toolbar_align}",
    fullscreen_new_window: true,
    fullscreen_settings: {
        theme: "advanced",
        plugins: "table,emotions,iespell,inlinepopups,paste",
        theme_advanced_buttons1 : "{$adv_buttons[1]}",
        theme_advanced_buttons2 : "{$adv_buttons[2]}",
        theme_advanced_buttons3 : "{$adv_buttons[3]}"
    },
EOF;
                }
                $headers[] = <<<EOF
<script type="text/javascript">
tinyMCE.init({
    button_tile_map: true,
    {$tinymce_config}
    extended_valid_elements : "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],script[src,type,language],+ul[id|type|compact]",
    urlconverter_callback : "custom_urlconvert",
    language: '{$language}',
    directionality: "{$tinymce_langdir}",
    content_css : {$content_css},
    //document_base_url: {$jswwwroot},
    remove_script_host: false,
    relative_urls: false,
    setup: function(ed) {
        ed.onInit.add(function(ed) {
            if (typeof(editor_to_focus) == 'string' && ed.editorId == editor_to_focus) {
                ed.focus();
            }
        });
        {$extrasetup}
    }
});
function custom_urlconvert (u, n, e) {
  // Don't convert the url on the skype status buttons.
  if (u.indexOf('skype:') == 0) {
      return u;
  }
  var t = tinyMCE.activeEditor, s = t.settings;

  // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
  if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
      return u;

  // Convert to relative
  if (s.relative_urls)
      return t.documentBaseURI.toRelative(u);

  // Convert to absolute
  u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);

  return u;
}
</script>

EOF;
                unset($check[$key]);
            } else {
                if ($check[$key] != $found_tinymce) {
                    log_warn('Two differently configured tinyMCE instances have been asked for on this page! This is not possible');
                }
                unset($check[$key]);
            }
        }
    }
    if (get_config('developermode') & DEVMODE_UNPACKEDJS) {
        $javascript_array[] = $jsroot . 'MochiKit/MochiKit.js';
        $javascript_array[] = $jsroot . 'MochiKit/Position.js';
        $javascript_array[] = $jsroot . 'MochiKit/Color.js';
        $javascript_array[] = $jsroot . 'MochiKit/Visual.js';
        $javascript_array[] = $jsroot . 'MochiKit/DragAndDrop.js';
        $javascript_array[] = $jsroot . 'MochiKit/Format.js';
    } else {
        $javascript_array[] = $jsroot . 'MochiKit/Packed.js';
    }
    $javascript_array[] = $jsroot . 'keyboardNavigation.js';
    $strings = array();
    foreach ($pagestrings as $k => $v) {
        if (is_array($v)) {
            foreach ($v as $tag) {
                $strings[$tag] = get_raw_string($tag, $k);
            }
        } else {
            $strings[$k] = get_raw_string($k, $v);
        }
    }
    $jsstrings = jsstrings();
    $themepaths = themepaths();
    foreach ($javascript as $jsfile) {
        // For now, if there's no path in the js file, assume it's in
        // $jsroot and append '.js' to the name.  Later we may want to
        // ensure all smarty() calls include the full path to the js
        // file, with the proper extension.
        if (strpos($jsfile, '/') === false) {
            $javascript_array[] = $jsroot . $jsfile . '.js';
            if (isset($jsstrings[$jsfile])) {
                foreach ($jsstrings[$jsfile] as $section => $tags) {
                    foreach ($tags as $tag) {
                        $strings[$tag] = get_raw_string($tag, $section);
                    }
                }
            }
            if (isset($themepaths[$jsfile])) {
                foreach ($themepaths[$jsfile] as $themepath) {
                    $theme_list[$themepath] = $THEME->get_url($themepath);
                }
            }
        } else {
            // A .js file with a fully specified path
            $javascript_array[] = $wwwroot . $jsfile;
            // If $jsfile is from a plugin (i.e. plugintype/pluginname/js/foo.js)
            // Then get js strings from static function jsstrings in plugintype/pluginname/lib.php
            $bits = explode('/', $jsfile);
            if (count($bits) == 4) {
                safe_require($bits[0], $bits[1]);
                $pluginclass = generate_class_name($bits[0], $bits[1]);
                $name = substr($bits[3], 0, strpos($bits[3], '.js'));
                if (is_callable(array($pluginclass, 'jsstrings'))) {
                    $tempstrings = call_static_method($pluginclass, 'jsstrings', $name);
                    foreach ($tempstrings as $section => $tags) {
                        foreach ($tags as $tag) {
                            $strings[$tag] = get_raw_string($tag, $section);
                        }
                    }
                }
                if (is_callable(array($pluginclass, 'jshelp'))) {
                    $tempstrings = call_static_method($pluginclass, 'jshelp', $name);
                    foreach ($tempstrings as $section => $tags) {
                        foreach ($tags as $tag) {
                            $strings[$tag . '.help'] = get_help_icon($bits[0], $bits[1], null, null, null, $tag);
                        }
                    }
                }
                if (is_callable(array($pluginclass, 'themepaths'))) {
                    $tmpthemepaths = call_static_method($pluginclass, 'themepaths', $name);
                    foreach ($tmpthemepaths as $themepath) {
                        $theme_list[$themepath] = $THEME->get_url($themepath);
                    }
                }
            }
        }
    }
    $javascript_array[] = $jsroot . 'mahara.js';
    if (get_config('developermode') & DEVMODE_DEBUGJS) {
        $javascript_array[] = $jsroot . 'debug.js';
    }
    foreach ($jsstrings['mahara'] as $section => $tags) {
        foreach ($tags as $tag) {
            $strings[$tag] = get_raw_string($tag, $section);
        }
    }
    if (isset($extraconfig['themepaths']) && is_array($extraconfig['themepaths'])) {
        foreach ($extraconfig['themepaths'] as $themepath) {
            $theme_list[$themepath] = $THEME->get_url($themepath);
        }
    }
    $stringjs = '<script type="text/javascript">';
    $stringjs .= 'var strings = ' . json_encode($strings) . ';';
    $stringjs .= '</script>';
    // stylesheet set up - if we're in a plugin also get its stylesheet
    $stylesheets = array_reverse(array_values($THEME->get_url('style/style.css', true)));
    if (defined('SECTION_PLUGINTYPE') && defined('SECTION_PLUGINNAME') && SECTION_PLUGINTYPE != 'core') {
        if ($pluginsheets = $THEME->get_url('style/style.css', true, SECTION_PLUGINTYPE . '/' . SECTION_PLUGINNAME)) {
            $stylesheets = array_merge($stylesheets, array_reverse($pluginsheets));
        }
    }
    if (defined('ADMIN') || defined('INSTITUTIONALADMIN')) {
        if ($adminsheets = $THEME->get_url('style/admin.css', true)) {
            $stylesheets = array_merge($stylesheets, array_reverse($adminsheets));
        }
    }
    if (get_config('developermode') & DEVMODE_DEBUGCSS) {
        $stylesheets[] = get_config('wwwroot') . 'theme/debug.css';
    }
    // look for extra stylesheets
    if (isset($extraconfig['stylesheets']) && is_array($extraconfig['stylesheets'])) {
        foreach ($extraconfig['stylesheets'] as $extrasheet) {
            if ($sheets = $THEME->get_url($extrasheet, true)) {
                $stylesheets = array_merge($stylesheets, array_reverse(array_values($sheets)));
            }
        }
    }
    // Include rtl.css for right-to-left langs
    if ($langdirection == 'rtl') {
        $smarty->assign('LANGDIRECTION', 'rtl');
        if ($rtlsheets = $THEME->get_url('style/rtl.css', true)) {
            $stylesheets = array_merge($stylesheets, array_reverse($rtlsheets));
        }
    }
    $smarty->assign('STRINGJS', $stringjs);
    $smarty->assign('STYLESHEETLIST', $stylesheets);
    if (!empty($theme_list)) {
        // this gets assigned in smarty_core, but do it again here if it's changed locally
        $smarty->assign('THEMELIST', json_encode(array_merge((array) json_decode($smarty->get_template_vars('THEMELIST')), $theme_list)));
    }
    $sitename = get_config('sitename');
    if (!$sitename) {
        $sitename = 'Mahara';
    }
    $smarty->assign('sitename', $sitename);
    if (defined('TITLE')) {
        $smarty->assign('PAGETITLE', TITLE . ' - ' . $sitename);
        $smarty->assign('heading', TITLE);
    } else {
        $smarty->assign('PAGETITLE', $sitename);
    }
    if (defined('PUBLIC')) {
        $smarty->assign('PUBLIC', true);
    }
    if (defined('ADMIN')) {
        $smarty->assign('ADMIN', true);
    }
    if (defined('INSTITUTIONALADMIN')) {
        $smarty->assign('INSTITUTIONALADMIN', true);
    }
    $smarty->assign('LOGGEDIN', $USER->is_logged_in());
    if ($USER->is_logged_in()) {
        global $SELECTEDSUBNAV;
        // It's evil, but rightnav & mainnav stuff are now in different templates.
        $smarty->assign('MAINNAV', main_nav());
        $smarty->assign('RIGHTNAV', right_nav());
        $smarty->assign('SELECTEDSUBNAV', $SELECTEDSUBNAV);
    } else {
        $smarty->assign('sitedefaultlang', get_string('sitedefault', 'admin') . ' (' . get_string_from_language(get_config('lang'), 'thislanguage') . ')');
        $smarty->assign('LANGUAGES', get_languages());
    }
    $smarty->assign('FOOTERMENU', footer_menu());
    $smarty->assign_by_ref('USER', $USER);
    $smarty->assign('SESSKEY', $USER->get('sesskey'));
    $smarty->assign_by_ref('JAVASCRIPT', $javascript_array);
    $smarty->assign_by_ref('HEADERS', $headers);
    $siteclosedforupgrade = get_config('siteclosed');
    if ($siteclosedforupgrade && get_config('disablelogin')) {
        $smarty->assign('SITECLOSED', 'logindisabled');
    } else {
        if ($siteclosedforupgrade || get_config('siteclosedbyadmin')) {
            $smarty->assign('SITECLOSED', 'loginallowed');
        }
    }
    if (!isset($extraconfig['pagehelp']) || $extraconfig['pagehelp'] !== false and $help = has_page_help()) {
        $smarty->assign('PAGEHELPNAME', $help[0]);
        $smarty->assign('PAGEHELPICON', $help[1]);
    }
    if (defined('GROUP')) {
        require_once 'group.php';
        $group = group_current_group();
        $smarty->assign('GROUP', $group);
        $smarty->assign('SUBPAGENAV', group_get_menu_tabs());
        $smarty->assign('PAGEHEADING', $group->name);
    }
    // ---------- sideblock stuff ----------
    $sidebars = !isset($extraconfig['sidebars']) || $extraconfig['sidebars'] !== false;
    if ($sidebars && !defined('INSTALLER') && (!defined('MENUITEM') || substr(MENUITEM, 0, 5) != 'admin')) {
        if (get_config('installed') && !defined('ADMIN') && !defined('INSTITUTIONALADMIN')) {
            $data = site_menu();
            if (!empty($data)) {
                $smarty->assign('SITEMENU', site_menu());
                $SIDEBLOCKS[] = array('name' => 'linksandresources', 'weight' => 10, 'data' => $data);
            }
        }
        if ($USER->is_logged_in() && defined('MENUITEM') && substr(MENUITEM, 0, 11) == 'myportfolio') {
            if (get_config('showselfsearchsideblock')) {
                $SIDEBLOCKS[] = array('name' => 'selfsearch', 'weight' => 0, 'data' => array());
            }
            if (get_config('showtagssideblock')) {
                $SIDEBLOCKS[] = array('name' => 'tags', 'id' => 'sb-tags', 'weight' => 0, 'data' => tags_sideblock());
            }
        }
        if ($USER->is_logged_in() && !defined('ADMIN') && !defined('INSTITUTIONALADMIN')) {
            $SIDEBLOCKS[] = array('name' => 'profile', 'id' => 'sb-profile', 'weight' => -20, 'data' => profile_sideblock());
            if (get_config('showonlineuserssideblock')) {
                $SIDEBLOCKS[] = array('name' => 'onlineusers', 'id' => 'sb-onlineusers', 'weight' => -10, 'data' => onlineusers_sideblock());
            }
        }
        if (defined('GROUP')) {
            $SIDEBLOCKS[] = array('name' => 'group', 'id' => 'sb-groupnav', 'weight' => -10, 'data' => group_sideblock());
        }
        if (!$USER->is_logged_in() && !(get_config('siteclosed') && get_config('disablelogin'))) {
            $SIDEBLOCKS[] = array('name' => 'login', 'weight' => -10, 'id' => 'sb-loginbox', 'data' => array('loginform' => auth_generate_login_form()));
        }
        if (get_config('enablenetworking')) {
            require_once get_config('docroot') . 'api/xmlrpc/lib.php';
            if ($USER->is_logged_in() && ($ssopeers = get_service_providers($USER->authinstance))) {
                $SIDEBLOCKS[] = array('name' => 'ssopeers', 'weight' => 1, 'data' => $ssopeers);
            }
        }
        if (isset($extraconfig['sideblocks']) && is_array($extraconfig['sideblocks'])) {
            foreach ($extraconfig['sideblocks'] as $sideblock) {
                $SIDEBLOCKS[] = $sideblock;
            }
        }
        usort($SIDEBLOCKS, create_function('$a,$b', 'if ($a["weight"] == $b["weight"]) return 0; return ($a["weight"] < $b["weight"]) ? -1 : 1;'));
        // Place all sideblocks on the right. If this structure is munged
        // appropriately, you can put blocks on the left. In future versions of
        // Mahara, we'll make it easy to do this.
        $SIDEBLOCKS = array('left' => array(), 'right' => $SIDEBLOCKS);
        $smarty->assign('userauthinstance', $SESSION->get('authinstance'));
        $smarty->assign('MNETUSER', $SESSION->get('mnetuser'));
        $smarty->assign('SIDEBLOCKS', $SIDEBLOCKS);
        $smarty->assign('SIDEBARS', $sidebars);
    }
    if ($USER->get('parentuser')) {
        $smarty->assign('USERMASQUERADING', true);
        $smarty->assign('masqueradedetails', get_string('youaremasqueradingas', 'mahara', display_name($USER)));
        $smarty->assign('becomeyouagain', ' <a href="' . hsc($wwwroot) . 'admin/users/changeuser.php?restore=1">' . get_string('becomeadminagain', 'admin', hsc($USER->get('parentuser')->name)) . '</a>');
    }
    return $smarty;
}
Пример #3
0
/**
 * This function creates a Smarty object and sets it up for use within our
 * podclass app, setting up some variables.
 *
 * The variables that it sets up are:
 *
 * - WWWROOT: The base url for the Mahara system
 * - USER: The user object
 * - JAVASCRIPT: A list of javascript files to include in the header.  This
 *   list is passed into this function (see below).
 * - HEADERS: An array of any further headers to set.  Each header is just
 *   straight HTML (see below).
 * - PUBLIC: Set true if this page is a public page
 * - MAINNAV: Array defining the main navigation
 *
 * @param $javascript A list of javascript includes.  Each include should be just
 *                    the name of a file, and reside in js/{filename}
 * @param $headers    A list of additional headers.  These are to be specified as
 *                    actual HTML.
 * @param $strings    A list of language strings required by the javascript code.
 * @return Smarty
 */
function smarty($javascript = array(), $headers = array(), $pagestrings = array(), $extraconfig = array())
{
    global $USER, $SESSION, $THEME, $HEADDATA;
    if (!is_array($headers)) {
        $headers = array();
    }
    if (!is_array($pagestrings)) {
        $pagestrings = array();
    }
    if (!is_array($extraconfig)) {
        $extraconfig = array();
    }
    $SIDEBLOCKS = array();
    $langselectform = language_select_form();
    $smarty = smarty_core();
    $wwwroot = get_config('wwwroot');
    // NOTE: not using jswwwroot - it seems to wreck image paths if you
    // drag them around the wysiwyg editor
    $jswwwroot = json_encode($wwwroot);
    // Workaround for $cfg->cleanurlusersubdomains.
    // When cleanurlusersubdomains is on, ajax requests might come from somewhere other than
    // the wwwroot.  To avoid cross-domain requests, set a js variable when this page is on a
    // different subdomain, and let the ajax wrapper function sendjsonrequest rewrite its url
    // if necessary.
    if (get_config('cleanurls') && get_config('cleanurlusersubdomains')) {
        if ($requesthost = get_requested_host_name()) {
            $wwwrootparts = parse_url($wwwroot);
            if ($wwwrootparts['host'] != $requesthost) {
                $fakewwwroot = $wwwrootparts['scheme'] . '://' . $requesthost . '/';
                $headers[] = '<script type="text/javascript">var fakewwwroot = ' . json_encode($fakewwwroot) . ';</script>';
            }
        }
    }
    $theme_list = array();
    if (function_exists('pieform_get_headdata')) {
        $headers = array_merge($headers, pieform_get_headdata());
        if (!defined('PIEFORM_GOT_HEADDATA')) {
            define('PIEFORM_GOT_HEADDATA', 1);
        }
    }
    // Insert the appropriate javascript tags
    $javascript_array = array();
    $jsroot = $wwwroot . 'js/';
    $langdirection = get_string('thisdirection', 'langconfig');
    // TinyMCE must be included first for some reason we're not sure about
    //
    // Note: we do not display tinyMCE for mobile devices
    // as it doesn't work on some of them and can
    // disable the editing of a textarea field
    if ($SESSION->get('handheld_device') == false) {
        $checkarray = array(&$javascript, &$headers);
        $found_tinymce = false;
        foreach ($checkarray as &$check) {
            if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) {
                if (!$found_tinymce) {
                    $found_tinymce = $check[$key];
                    $javascript_array[] = $jsroot . 'tinymce/tiny_mce.js';
                    $content_css = json_encode($THEME->get_url('style/tinymce.css'));
                    $language = substr(current_language(), 0, 2);
                    if ($language != 'en' && !file_exists(get_config('docroot') . 'js/tinymce/langs/' . $language . '.js')) {
                        $language = 'en';
                    }
                    $extrasetup = isset($extraconfig['tinymcesetup']) ? $extraconfig['tinymcesetup'] : '';
                    // OVERWRITE 1: replacement, changed from:
                    // $adv_buttons = array(
                    //    "undo,redo,separator,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,link,unlink,separator,code,fullscreen",
                    //    "bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,hr,emotions,image,spellchecker,cleanup,separator,link,unlink,separator,code,fullscreen",
                    //    "undo,redo,separator,bullist,numlist,separator,tablecontrols,separator,cut,copy,paste,pasteword",
                    //    "fontselect,separator,fontsizeselect,separator,formatselect",
                    //);
                    // to:
                    $adv_buttons = array("undo,redo,separator,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,link,unlink,separator,code,fullscreen", "bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,hr,emotions,image,media,gcrcloudstorage,spellchecker,cleanup,separator,link,unlink,separator,code,fullscreen", "undo,redo,separator,bullist,numlist,separator,tablecontrols,separator,cut,copy,paste,pasteword,tinyautosave", "fontselect,separator,fontsizeselect,separator,formatselect");
                    // END OVERWRITE 1
                    // For right-to-left langs, reverse button order & align controls right.
                    $tinymce_langdir = $langdirection == 'rtl' ? 'rtl' : 'ltr';
                    $toolbar_align = 'left';
                    // OVERWRITE 2: replacement, changed from:
                    /*if ($check[$key] == 'tinymce') {
                                        $spellchecker_rpc = $jsroot.'tinymce/plugins/spellchecker/rpc.php';
                                        $tinymce_config = <<<EOF
                        mode: "none",
                        theme: "advanced",
                        plugins: "table,emotions,spellchecker,inlinepopups,paste,fullscreen",
                        theme_advanced_buttons1 : "{$adv_buttons[1]}",
                        theme_advanced_buttons2 : "{$adv_buttons[2]}",
                        theme_advanced_buttons3 : "{$adv_buttons[3]}",
                        theme_advanced_toolbar_location : "top",
                        theme_advanced_toolbar_align : "{$toolbar_align}",
                        fix_list_elements: true,
                        spellchecker_rpc_url : "{$spellchecker_rpc}",
                        //width: '512',
                    EOF;
                                    }
                                    else {
                                        $tinymce_config = <<<EOF
                        mode: "textareas",
                        editor_selector: 'tinywysiwyg',
                        theme: "advanced",
                        plugins: "fullscreen,inlinepopups,autoresize",
                        theme_advanced_buttons1 : "{$adv_buttons[0]}",
                        theme_advanced_buttons2 : "",
                        theme_advanced_buttons3 : "",
                        theme_advanced_toolbar_location : "top",
                        theme_advanced_toolbar_align : "{$toolbar_align}",
                        fullscreen_new_window: true,
                        fullscreen_settings: {
                            theme: "advanced",
                            plugins: "table,emotions,iespell,inlinepopups,paste,fullscreen",
                            theme_advanced_buttons1 : "{$adv_buttons[1]}",
                            theme_advanced_buttons2 : "{$adv_buttons[2]}",
                            theme_advanced_buttons3 : "{$adv_buttons[3]}"
                        },
                    EOF;
                                    }
                    
                                    $headers[] = <<<EOF
                    <script type="text/javascript">
                    tinyMCE.init({
                        button_tile_map: true,
                        {$tinymce_config}
                        extended_valid_elements : "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],script[src,type,language],+ul[id|type|compact],iframe[src|width|height|align|title|class|type|frameborder|allowfullscreen]",
                        urlconverter_callback : "custom_urlconvert",
                        language: '{$language}',
                        directionality: "{$tinymce_langdir}",
                        content_css : {$content_css},
                        //document_base_url: {$jswwwroot},
                        remove_script_host: false,
                        relative_urls: false,
                        setup: function(ed) {
                            ed.onInit.add(function(ed) {
                                if (typeof(editor_to_focus) == 'string' && ed.editorId == editor_to_focus) {
                                    ed.focus();
                                }
                            });
                            {$extrasetup}
                        }
                    });
                    function custom_urlconvert (u, n, e) {
                      // Don't convert the url on the skype status buttons.
                      if (u.indexOf('skype:') == 0) {
                          return u;
                      }
                      var t = tinyMCE.activeEditor, s = t.settings;
                    
                      // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
                      if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
                          return u;
                    
                      // Convert to relative
                      if (s.relative_urls)
                          return t.documentBaseURI.toRelative(u);
                    
                      // Convert to absolute
                      u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);
                    
                      return u;
                    }
                    </script>
                    
                    EOF;
                                     */
                    //to:
                    if ($check[$key] == 'tinymce') {
                        $tinymce_config = <<<EOF
    mode: "none",
    theme: "advanced",
    plugins: "table,emotions,spellchecker,inlinepopups,paste,gcrcloudstorage,media,tinyautosave",
    theme_advanced_buttons1 : "{$adv_buttons[1]}",
    theme_advanced_buttons2 : "{$adv_buttons[2]}",
    theme_advanced_buttons3 : "{$adv_buttons[3]}",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "{$toolbar_align}",
    //width: '512',
EOF;
                    } else {
                        $tinymce_config = <<<EOF
    mode: "textareas",
    editor_selector: 'tinywysiwyg',
    theme: "advanced",
    plugins: "fullscreen,inlinepopups,autoresize,gcrcloudstorage,media,tinyautosave",
    theme_advanced_buttons1 : "{$adv_buttons[0]}",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "{$toolbar_align}",
    fullscreen_new_window: true,
    fullscreen_settings: {
        theme: "advanced",
        plugins: "table,emotions,iespell,inlinepopups,paste,gcrcloudstorage,fullscreen,tinyautosave",
        theme_advanced_buttons1 : "{$adv_buttons[1]}",
        theme_advanced_buttons2 : "{$adv_buttons[2]}",
        theme_advanced_buttons3 : "{$adv_buttons[3]}"
    },
EOF;
                    }
                    $headers[] = <<<EOF
<script type="text/javascript">
tinyMCE.init({
    button_tile_map: true,
    {$tinymce_config}
    extended_valid_elements : "video[width|height|id|controls|preload],source[src|type],object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],script[src,type,language],+ul[id|type|compact],iframe[src|width|height|align|title|class|type|frameborder|allowfullscreen]",
    urlconverter_callback : "custom_urlconvert",
    language: '{$language}',
    directionality: "{$tinymce_langdir}",
    content_css : {$content_css},
    //document_base_url: {$jswwwroot},
    remove_script_host: false,
    relative_urls: false,
    setup: function(ed) {
        ed.onInit.add(function(ed) {
            if (typeof(editor_to_focus) == 'string' && ed.editorId == editor_to_focus) {
                ed.focus();
            }
        });
        {$extrasetup}
    }
});    
                 
function custom_urlconvert (u, n, e) {
  // Don't convert the url on the skype status buttons.
  if (u.indexOf('skype:') == 0) {
      return u;
  }
  var t = tinyMCE.activeEditor, s = t.settings;

  // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
  if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
      return u;

  // Convert to relative
  if (s.relative_urls)
      return t.documentBaseURI.toRelative(u);

  // Convert to absolute
  u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);

  return u;
}
</script>

EOF;
                    // END OVERWRITE 2
                    unset($check[$key]);
                } else {
                    if ($check[$key] != $found_tinymce) {
                        log_warn('Two differently configured tinyMCE instances have been asked for on this page! This is not possible');
                    }
                    unset($check[$key]);
                }
            }
            // If any page adds jquery explicitly, remove it from the list
            if (($key = array_search('jquery', $check)) !== false) {
                unset($check[$key]);
            }
        }
    } else {
        if (($key = array_search('tinymce', $javascript)) !== false || ($key = array_search('tinytinymce', $javascript)) !== false) {
            unset($javascript[$key]);
        }
        if (($key = array_search('tinymce', $headers)) !== false || ($key = array_search('tinytinymce', $headers)) !== false) {
            unset($headers[$key]);
        }
    }
    // Make jQuery accessible with $j (Mochikit has $)
    $javascript_array[] = $jsroot . 'jquery/jquery.js';
    $headers[] = '<script type="text/javascript">$j=jQuery;</script>';
    if (get_config('developermode') & DEVMODE_UNPACKEDJS) {
        $javascript_array[] = $jsroot . 'MochiKit/MochiKit.js';
        $javascript_array[] = $jsroot . 'MochiKit/Position.js';
        $javascript_array[] = $jsroot . 'MochiKit/Color.js';
        $javascript_array[] = $jsroot . 'MochiKit/Visual.js';
        $javascript_array[] = $jsroot . 'MochiKit/DragAndDrop.js';
        $javascript_array[] = $jsroot . 'MochiKit/Format.js';
    } else {
        $javascript_array[] = $jsroot . 'MochiKit/Packed.js';
    }
    $javascript_array[] = $jsroot . 'keyboardNavigation.js';
    $strings = array();
    foreach ($pagestrings as $k => $v) {
        if (is_array($v)) {
            foreach ($v as $tag) {
                $strings[$tag] = get_raw_string($tag, $k);
            }
        } else {
            $strings[$k] = get_raw_string($k, $v);
        }
    }
    $jsstrings = jsstrings();
    $themepaths = themepaths();
    foreach ($javascript as $jsfile) {
        // For now, if there's no path in the js file, assume it's in
        // $jsroot and append '.js' to the name.  Later we may want to
        // ensure all smarty() calls include the full path to the js
        // file, with the proper extension.
        if (strpos($jsfile, '/') === false) {
            $javascript_array[] = $jsroot . $jsfile . '.js';
            if (isset($jsstrings[$jsfile])) {
                foreach ($jsstrings[$jsfile] as $section => $tags) {
                    foreach ($tags as $tag) {
                        $strings[$tag] = get_raw_string($tag, $section);
                    }
                }
            }
            if (isset($themepaths[$jsfile])) {
                foreach ($themepaths[$jsfile] as $themepath) {
                    $theme_list[$themepath] = $THEME->get_url($themepath);
                }
            }
        } else {
            if (strpos($jsfile, 'http://') === false) {
                // A local .js file with a fully specified path
                $javascript_array[] = $wwwroot . $jsfile;
                // If $jsfile is from a plugin (i.e. plugintype/pluginname/js/foo.js)
                // Then get js strings from static function jsstrings in plugintype/pluginname/lib.php
                $bits = explode('/', $jsfile);
                if (count($bits) == 4) {
                    safe_require($bits[0], $bits[1]);
                    $pluginclass = generate_class_name($bits[0], $bits[1]);
                    $name = substr($bits[3], 0, strpos($bits[3], '.js'));
                    if (is_callable(array($pluginclass, 'jsstrings'))) {
                        $tempstrings = call_static_method($pluginclass, 'jsstrings', $name);
                        foreach ($tempstrings as $section => $tags) {
                            foreach ($tags as $tag) {
                                $strings[$tag] = get_raw_string($tag, $section);
                            }
                        }
                    }
                    if (is_callable(array($pluginclass, 'jshelp'))) {
                        $tempstrings = call_static_method($pluginclass, 'jshelp', $name);
                        foreach ($tempstrings as $section => $tags) {
                            foreach ($tags as $tag) {
                                $strings[$tag . '.help'] = get_help_icon($bits[0], $bits[1], null, null, null, $tag);
                            }
                        }
                    }
                    if (is_callable(array($pluginclass, 'themepaths'))) {
                        $tmpthemepaths = call_static_method($pluginclass, 'themepaths', $name);
                        foreach ($tmpthemepaths as $themepath) {
                            $theme_list[$themepath] = $THEME->get_url($themepath);
                        }
                    }
                }
            } else {
                // A remote .js file
                $javascript_array[] = $jsfile;
            }
        }
    }
    $javascript_array[] = $jsroot . 'mahara.js';
    $javascript_array[] = $jsroot . 'formchangechecker.js';
    if (get_config('developermode') & DEVMODE_DEBUGJS) {
        $javascript_array[] = $jsroot . 'debug.js';
    }
    foreach ($jsstrings['mahara'] as $section => $tags) {
        foreach ($tags as $tag) {
            $strings[$tag] = get_raw_string($tag, $section);
        }
    }
    if (isset($extraconfig['themepaths']) && is_array($extraconfig['themepaths'])) {
        foreach ($extraconfig['themepaths'] as $themepath) {
            $theme_list[$themepath] = $THEME->get_url($themepath);
        }
    }
    $stringjs = '<script type="text/javascript">';
    $stringjs .= 'var strings = ' . json_encode($strings) . ';';
    $stringjs .= "\nfunction plural(n) { return " . get_raw_string('pluralrule', 'langconfig') . "; }\n";
    $stringjs .= '</script>';
    // stylesheet set up - if we're in a plugin also get its stylesheet
    $stylesheets = array_reverse(array_values($THEME->get_url('style/style.css', true)));
    if (defined('SECTION_PLUGINTYPE') && defined('SECTION_PLUGINNAME') && SECTION_PLUGINTYPE != 'core') {
        if ($pluginsheets = $THEME->get_url('style/style.css', true, SECTION_PLUGINTYPE . '/' . SECTION_PLUGINNAME)) {
            $stylesheets = array_merge($stylesheets, array_reverse($pluginsheets));
        }
    }
    if ($adminsection = in_admin_section()) {
        if ($adminsheets = $THEME->get_url('style/admin.css', true)) {
            $stylesheets = array_merge($stylesheets, array_reverse($adminsheets));
        }
    }
    if (get_config('developermode') & DEVMODE_DEBUGCSS) {
        $stylesheets[] = get_config('wwwroot') . 'theme/debug.css';
    }
    // look for extra stylesheets
    if (isset($extraconfig['stylesheets']) && is_array($extraconfig['stylesheets'])) {
        foreach ($extraconfig['stylesheets'] as $extrasheet) {
            if ($sheets = $THEME->get_url($extrasheet, true)) {
                $stylesheets = array_merge($stylesheets, array_reverse(array_values($sheets)));
            }
        }
    }
    if ($sheets = $THEME->additional_stylesheets()) {
        $stylesheets = array_merge($stylesheets, $sheets);
    }
    // Give the skin a chance to affect the page
    if (!empty($extraconfig['skin'])) {
        require_once get_config('docroot') . '/lib/skin.php';
        $skinobj = new Skin($extraconfig['skin']['skinid']);
        $viewid = isset($extraconfig['skin']['viewid']) ? $extraconfig['skin']['viewid'] : null;
        $stylesheets = array_merge($stylesheets, $skinobj->get_stylesheets($viewid));
    }
    // Include rtl.css for right-to-left langs
    if ($langdirection == 'rtl') {
        $smarty->assign('LANGDIRECTION', 'rtl');
        if ($rtlsheets = $THEME->get_url('style/rtl.css', true)) {
            $stylesheets = array_merge($stylesheets, array_reverse($rtlsheets));
        }
    }
    $smarty->assign('STRINGJS', $stringjs);
    $stylesheets = append_version_number($stylesheets);
    $smarty->assign('STYLESHEETLIST', $stylesheets);
    if (!empty($theme_list)) {
        // this gets assigned in smarty_core, but do it again here if it's changed locally
        $smarty->assign('THEMELIST', json_encode(array_merge((array) json_decode($smarty->get_template_vars('THEMELIST')), $theme_list)));
    }
    $dropdownmenu = get_config('dropdownmenu');
    // disable drop-downs if overridden at institution level
    $sitethemeprefs = get_config('sitethemeprefs');
    $institutions = $USER->institutions;
    if (!empty($institutions)) {
        foreach ($institutions as $i) {
            if (!empty($sitethemeprefs)) {
                if (!empty($USER->accountprefs['theme']) && $USER->accountprefs['theme'] == $THEME->basename . '/' . $i->institution) {
                    $dropdownmenu = $i->dropdownmenu;
                }
            } else {
                if (!empty($USER->accountprefs['theme']) && $USER->accountprefs['theme'] == $THEME->basename . '/' . $i->institution || empty($USER->accountprefs) && $i->theme == $THEME->basename && $USER->institutiontheme->institutionname == $i->institution) {
                    $dropdownmenu = $i->dropdownmenu;
                }
            }
        }
    }
    // and/or disable drop-downs if a handheld device detected
    $dropdownmenu = $SESSION->get('handheld_device') ? false : $dropdownmenu;
    if ($dropdownmenu) {
        $smarty->assign('DROPDOWNMENU', $dropdownmenu);
    }
    $smarty->assign('MOBILE', $SESSION->get('mobile'));
    $smarty->assign('HANDHELD_DEVICE', $SESSION->get('handheld_device'));
    $sitename = get_config('sitename');
    if (!$sitename) {
        $sitename = 'Mahara';
    }
    $smarty->assign('sitename', $sitename);
    $smarty->assign('sitelogo', $THEME->header_logo());
    $smarty->assign('sitelogo4facebook', $THEME->facebook_logo());
    $smarty->assign('sitedescription4facebook', get_string('facebookdescription', 'mahara'));
    if (defined('TITLE')) {
        $smarty->assign('PAGETITLE', TITLE . ' - ' . $sitename);
        $smarty->assign('heading', TITLE);
    } else {
        $smarty->assign('PAGETITLE', $sitename);
    }
    $smarty->assign('PRODUCTIONMODE', get_config('productionmode'));
    if (function_exists('local_header_top_content')) {
        $sitetop = (isset($sitetop) ? $sitetop : '') . local_header_top_content();
    }
    if (isset($sitetop)) {
        $smarty->assign('SITETOP', $sitetop);
    }
    if (defined('PUBLIC')) {
        $smarty->assign('PUBLIC', true);
    }
    if (defined('ADMIN')) {
        $smarty->assign('ADMIN', true);
    }
    if (defined('INSTITUTIONALADMIN')) {
        $smarty->assign('INSTITUTIONALADMIN', true);
    }
    if (defined('STAFF')) {
        $smarty->assign('STAFF', true);
    }
    if (defined('INSTITUTIONALSTAFF')) {
        $smarty->assign('INSTITUTIONALSTAFF', true);
    }
    $smarty->assign('LOGGEDIN', $USER->is_logged_in());
    if ($USER->is_logged_in()) {
        global $SELECTEDSUBNAV;
        // It's evil, but rightnav & mainnav stuff are now in different templates.
        $smarty->assign('MAINNAV', main_nav());
        $mainnavsubnav = $SELECTEDSUBNAV;
        $smarty->assign('RIGHTNAV', right_nav());
        if (!$mainnavsubnav && $dropdownmenu) {
            // In drop-down navigation, the submenu is only usable if its parent is one of the top-level menu
            // items.  But if the submenu comes from something in right_nav (settings), it's unreachable.
            // Turning the submenu into SUBPAGENAV group-style tabs makes it usable.
            $smarty->assign('SUBPAGENAV', $SELECTEDSUBNAV);
        } else {
            $smarty->assign('SELECTEDSUBNAV', $SELECTEDSUBNAV);
        }
    } else {
        $smarty->assign('languageform', $langselectform);
    }
    $smarty->assign('FOOTERMENU', footer_menu());
    $smarty->assign_by_ref('USER', $USER);
    $smarty->assign('SESSKEY', $USER->get('sesskey'));
    $javascript_array = append_version_number($javascript_array);
    $smarty->assign_by_ref('JAVASCRIPT', $javascript_array);
    $smarty->assign('RELEASE', get_config('release'));
    $siteclosedforupgrade = get_config('siteclosed');
    if ($siteclosedforupgrade && get_config('disablelogin')) {
        $smarty->assign('SITECLOSED', 'logindisabled');
    } else {
        if ($siteclosedforupgrade || get_config('siteclosedbyadmin')) {
            $smarty->assign('SITECLOSED', 'loginallowed');
        }
    }
    if (!isset($extraconfig['pagehelp']) || $extraconfig['pagehelp'] !== false and $help = has_page_help()) {
        $smarty->assign('PAGEHELPNAME', $help[0]);
        $smarty->assign('PAGEHELPICON', $help[1]);
    }
    if (defined('GROUP')) {
        require_once 'group.php';
        if ($group = group_current_group()) {
            $smarty->assign('GROUP', $group);
            if (!defined('NOGROUPMENU')) {
                $smarty->assign('SUBPAGENAV', group_get_menu_tabs());
                $smarty->assign('PAGEHEADING', $group->name);
            }
        }
    }
    // ---------- sideblock stuff ----------
    $sidebars = !isset($extraconfig['sidebars']) || $extraconfig['sidebars'] !== false;
    if ($sidebars && !defined('INSTALLER') && (!defined('MENUITEM') || substr(MENUITEM, 0, 5) != 'admin')) {
        if (get_config('installed') && !$adminsection) {
            $data = site_menu();
            if (!empty($data)) {
                $smarty->assign('SITEMENU', site_menu());
                $SIDEBLOCKS[] = array('name' => 'linksandresources', 'weight' => 10, 'data' => $data);
            }
        }
        if ($USER->is_logged_in() && defined('MENUITEM') && (substr(MENUITEM, 0, 11) == 'myportfolio' || substr(MENUITEM, 0, 7) == 'content')) {
            if (get_config('showselfsearchsideblock')) {
                $SIDEBLOCKS[] = array('name' => 'selfsearch', 'weight' => 0, 'data' => array());
            }
            if (get_config('showtagssideblock')) {
                $SIDEBLOCKS[] = array('name' => 'tags', 'id' => 'sb-tags', 'weight' => 0, 'data' => tags_sideblock());
            }
        }
        if ($USER->is_logged_in() && !$adminsection) {
            $SIDEBLOCKS[] = array('name' => 'profile', 'id' => 'sb-profile', 'weight' => -20, 'data' => profile_sideblock());
            $showusers = 2;
            $institutions = $USER->institutions;
            if (!empty($institutions)) {
                $showusers = 0;
                foreach ($institutions as $i) {
                    if ($i->showonlineusers == 2) {
                        $showusers = 2;
                        break;
                    }
                    if ($i->showonlineusers == 1) {
                        $showusers = 1;
                    }
                }
            }
            if (get_config('showonlineuserssideblock') && $showusers > 0) {
                $SIDEBLOCKS[] = array('name' => 'onlineusers', 'id' => 'sb-onlineusers', 'weight' => -10, 'data' => onlineusers_sideblock());
            }
        }
        if (defined('GROUP')) {
            $SIDEBLOCKS[] = array('name' => 'group', 'id' => 'sb-groupnav', 'weight' => -10, 'data' => group_sideblock());
        }
        if (!$USER->is_logged_in() && !(get_config('siteclosed') && get_config('disablelogin'))) {
            $SIDEBLOCKS[] = array('name' => 'login', 'weight' => -10, 'id' => 'sb-loginbox', 'data' => array('loginform' => auth_generate_login_form()));
        }
        if (get_config('enablenetworking')) {
            require_once get_config('docroot') . 'api/xmlrpc/lib.php';
            if ($USER->is_logged_in() && ($ssopeers = get_service_providers($USER->authinstance))) {
                $SIDEBLOCKS[] = array('name' => 'ssopeers', 'weight' => 1, 'data' => $ssopeers);
            }
        }
        if (isset($extraconfig['sideblocks']) && is_array($extraconfig['sideblocks'])) {
            foreach ($extraconfig['sideblocks'] as $sideblock) {
                $SIDEBLOCKS[] = $sideblock;
            }
        }
        usort($SIDEBLOCKS, create_function('$a,$b', 'if ($a["weight"] == $b["weight"]) return 0; return ($a["weight"] < $b["weight"]) ? -1 : 1;'));
        // Place all sideblocks on the right. If this structure is munged
        // appropriately, you can put blocks on the left. In future versions of
        // Mahara, we'll make it easy to do this.
        $sidebars = $sidebars && !empty($SIDEBLOCKS);
        $SIDEBLOCKS = array('left' => array(), 'right' => $SIDEBLOCKS);
        $smarty->assign('userauthinstance', $SESSION->get('authinstance'));
        $smarty->assign('MNETUSER', $SESSION->get('mnetuser'));
        $smarty->assign('SIDEBLOCKS', $SIDEBLOCKS);
        $smarty->assign('SIDEBARS', $sidebars);
    }
    if (is_array($HEADDATA) && !empty($HEADDATA)) {
        $headers = array_merge($HEADDATA, $headers);
    }
    $smarty->assign_by_ref('HEADERS', $headers);
    if ($USER->get('parentuser')) {
        $smarty->assign('USERMASQUERADING', true);
        $smarty->assign('masqueradedetails', get_string('youaremasqueradingas', 'mahara', display_name($USER)));
        $smarty->assign('becomeyouagain', ' <a href="' . hsc($wwwroot) . 'admin/users/changeuser.php?restore=1">' . get_string('becomeadminagain', 'admin', hsc($USER->get('parentuser')->name)) . '</a>');
    }
    // Define additional html content
    if (get_config('installed')) {
        $additionalhtmlitems = array('ADDITIONALHTMLHEAD' => get_config('additionalhtmlhead'), 'ADDITIONALHTMLTOPOFBODY' => get_config('additionalhtmltopofbody'), 'ADDITIONALHTMLFOOTER' => get_config('additionalhtmlfooter'));
        if ($additionalhtmlitems) {
            foreach ($additionalhtmlitems as $name => $content) {
                $smarty->assign($name, $content);
            }
        }
    }
    return $smarty;
}
Пример #4
0
/**
 * This function creates a Smarty object and sets it up for use within our
 * podclass app, setting up some variables.
 *
 * WARNING: If you are using pieforms, set them up BEFORE calling this function.
 *
 * The variables that it sets up are:
 *
 * - WWWROOT: The base url for the Mahara system
 * - USER: The user object
 * - JAVASCRIPT: A list of javascript files to include in the header.  This
 *   list is passed into this function (see below).
 * - HEADERS: An array of any further headers to set.  Each header is just
 *   straight HTML (see below).
 * - PUBLIC: Set true if this page is a public page
 * - MAINNAV: Array defining the main navigation
 *
 * @param $javascript A list of javascript includes.  Each include should be just
 *                    the name of a file, and reside in js/{filename}
 * @param $headers    A list of additional headers.  These are to be specified as
 *                    actual HTML.
 * @param $strings    A list of language strings required by the javascript code.
 * @return Smarty
 */
function smarty($javascript = array(), $headers = array(), $pagestrings = array(), $extraconfig = array())
{
    global $USER, $SESSION, $THEME, $HEADDATA, $langselectform;
    if (!is_array($headers)) {
        $headers = array();
    }
    if (!is_array($pagestrings)) {
        $pagestrings = array();
    }
    if (!is_array($extraconfig)) {
        $extraconfig = array();
    }
    $sideblocks = array();
    // Some things like die_info() will try and create a smarty() call when we are already in one, which causes
    // language_select_form() to throw headdata error as it is called twice.
    if (!isset($langselectform)) {
        $langselectform = language_select_form();
    }
    $smarty = smarty_core();
    $wwwroot = get_config('wwwroot');
    // NOTE: not using jswwwroot - it seems to wreck image paths if you
    // drag them around the wysiwyg editor
    $jswwwroot = json_encode($wwwroot);
    // Workaround for $cfg->cleanurlusersubdomains.
    // When cleanurlusersubdomains is on, ajax requests might come from somewhere other than
    // the wwwroot.  To avoid cross-domain requests, set a js variable when this page is on a
    // different subdomain, and let the ajax wrapper function sendjsonrequest rewrite its url
    // if necessary.
    if (get_config('cleanurls') && get_config('cleanurlusersubdomains')) {
        if ($requesthost = get_requested_host_name()) {
            $wwwrootparts = parse_url($wwwroot);
            if ($wwwrootparts['host'] != $requesthost) {
                $fakewwwroot = $wwwrootparts['scheme'] . '://' . $requesthost . '/';
                $headers[] = '<script type="application/javascript">var fakewwwroot = ' . json_encode($fakewwwroot) . ';</script>';
            }
        }
    }
    $theme_list = array();
    $adminsection = in_admin_section();
    if (function_exists('pieform_get_headdata')) {
        $headers = array_merge($headers, pieform_get_headdata());
        if (!defined('PIEFORM_GOT_HEADDATA')) {
            define('PIEFORM_GOT_HEADDATA', 1);
        }
    }
    // Define the stylesheets array early so that javascript modules can add extras
    $stylesheets = array();
    // Insert the appropriate javascript tags
    $javascript_array = array();
    $jsroot = $wwwroot . 'js/';
    $langdirection = get_string('thisdirection', 'langconfig');
    // Make jQuery accessible with $j (Mochikit has $)
    $javascript_array[] = $jsroot . 'jquery/jquery.js';
    $javascript_array[] = $jsroot . 'jquery/deprecated_jquery.js';
    $headers[] = '<script type="application/javascript">$j=jQuery;</script>';
    // If necessary, load MathJax configuration
    if (get_config('mathjax')) {
        $headers[] = '<script type="application/javascript">' . get_config('mathjaxconfig') . '</script>';
    }
    // TinyMCE must be included first for some reason we're not sure about
    //
    // Note: we do not display tinyMCE for mobile devices
    // as it doesn't work on some of them and can
    // disable the editing of a textarea field
    if ($SESSION->get('handheld_device') == false) {
        $checkarray = array(&$javascript, &$headers);
        $found_tinymce = false;
        foreach ($checkarray as &$check) {
            if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) {
                if (!$found_tinymce) {
                    $found_tinymce = $check[$key];
                    $javascript_array[] = $wwwroot . 'artefact/file/js/filebrowser.js';
                    $javascript_array[] = $jsroot . 'tinymce/tinymce.js';
                    $stylesheets = array_merge($stylesheets, array_reverse(array_values($THEME->get_url('style/tinymceskin.css', true))));
                    $content_css = json_encode($THEME->get_url('style/tinymce.css'));
                    $language = current_language();
                    $language = substr($language, 0, substr_count($language, '_') > 0 ? 5 : 2);
                    if ($language != 'en' && !file_exists(get_config('docroot') . 'js/tinymce/langs/' . $language . '.js')) {
                        // In case the language file exists as a string with both lower and upper case, eg fr_FR we test for this
                        $language = substr($language, 0, 2) . '_' . strtoupper(substr($language, 0, 2));
                        if (!file_exists(get_config('docroot') . 'js/tinymce/langs/' . $language . '.js')) {
                            // In case we fail to find a language of 5 chars, eg pt_BR (Portugese, Brazil) we try the 'parent' pt (Portugese)
                            $language = substr($language, 0, 2);
                            if ($language != 'en' && !file_exists(get_config('docroot') . 'js/tinymce/langs/' . $language . '.js')) {
                                $language = 'en';
                            }
                        }
                    }
                    $extrasetup = isset($extraconfig['tinymcesetup']) ? $extraconfig['tinymcesetup'] : '';
                    $extramceconfig = isset($extraconfig['tinymceconfig']) ? $extraconfig['tinymceconfig'] : '';
                    // Check whether to make the spellchecker available
                    if (get_config('tinymcespellcheckerengine')) {
                        $spellchecker = ',spellchecker';
                        $spellchecker_toolbar = '| spellchecker';
                        $spellchecker_config = "gecko_spellcheck : false, spellchecker_rpc_url : \"{$jsroot}tinymce/plugins/spellchecker/spellchecker.php\",";
                    } else {
                        $spellchecker = $spellchecker_toolbar = '';
                        $spellchecker_config = 'gecko_spellcheck : true,';
                    }
                    $mathslate = get_config('mathjax') ? 'mathslate' : '';
                    $mathslateplugin = !empty($mathslate) ? ',' . $mathslate : '';
                    $toolbar = array(null, '"toolbar_toggle | formatselect | bold italic | bullist numlist | link unlink | imagebrowser | undo redo"', '"underline strikethrough subscript superscript | alignleft aligncenter alignright alignjustify | outdent indent | forecolor backcolor | ltr rtl | fullscreen"', '"fontselect | fontsizeselect | emoticons nonbreaking charmap ' . $mathslate . ' ' . $spellchecker_toolbar . ' | table | removeformat pastetext | code"');
                    // For right-to-left langs, reverse button order & align controls right.
                    $tinymce_langdir = $langdirection == 'rtl' ? 'rtl' : 'ltr';
                    $toolbar_align = 'left';
                    // Language strings required for TinyMCE
                    $pagestrings['mahara'] = isset($pagestrings['mahara']) ? $pagestrings['mahara'] : array();
                    $pagestrings['mahara'][] = 'attachedimage';
                    if ($check[$key] == 'tinymce') {
                        $tinymceconfig = <<<EOF
    theme: "modern",
    plugins: "tooltoggle,textcolor,visualblocks,wordcount,link,imagebrowser,table,emoticons{$spellchecker},paste,code,fullscreen,directionality,searchreplace,nonbreaking,charmap{$mathslateplugin}",
    skin: 'light',
    toolbar1: {$toolbar[1]},
    toolbar2: {$toolbar[2]},
    toolbar3: {$toolbar[3]},
    menubar: false,
    fix_list_elements: true,
    image_advtab: true,
    {$spellchecker_config}
EOF;
                    } else {
                        $tinymceconfig = <<<EOF
    selector: "textarea.tinywysiwyg",
    theme: "modern",
    skin: 'light',
    plugins: "fullscreen,autoresize",
    toolbar: {$toolbar[0]},
EOF;
                    }
                    $headers[] = <<<EOF
<script type="application/javascript">
tinyMCE.init({
    {$tinymceconfig}
    schema: 'html4',
    extended_valid_elements : "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],script[src,type,language],+ul[id|type|compact],iframe[src|width|height|align|title|class|type|frameborder|allowfullscreen]",
    urlconverter_callback : "custom_urlconvert",
    language: '{$language}',
    directionality: "{$tinymce_langdir}",
    content_css : {$content_css},
    remove_script_host: false,
    relative_urls: false,
    {$extramceconfig}
    setup: function(ed) {
        ed.on('init', function(ed) {
            if (typeof(editor_to_focus) == 'string' && ed.editorId == editor_to_focus) {
                ed.focus();
            }
        });
        ed.on('LoadContent', function(e) {
            // Hide all the 2nd/3rd row menu buttons
            jQuery('.mce-toolbar.mce-first').siblings().toggleClass('hidden');
            // The tinymce fullscreen mode does not work properly in a transformed container div
            // such as div.vertcentre
            // and IE doesn't like a preset z-index
            // This work-around will remove/add classes: .vertcenter .configure .blockinstane
            // of the configure block div
            // when toggling fullscreen
            jQuery('div[aria-label="Fullscreen"]').on('click', function(e) {
                jQuery('div#configureblock').toggleClass('vertcentre');
                jQuery('div#configureblock').toggleClass('blockinstance');
                jQuery('div#configureblock').toggleClass('configure');
            });
        });
        {$extrasetup}
    }
});

function imageBrowserConfigSuccess(form, data) {
    // handle updates to file browser
    // final form submission handled by tinymce plugin
    if (data.formelementsuccess) {
        eval(data.formelementsuccess + '(form, data)');
        return;
    }
}

function imageBrowserConfigError(form, data) {
    if (data.formelementerror) {
        eval(data.formelementerror + '(form, data)');
        return;
    }
}

function custom_urlconvert (u, n, e) {
    // Don't convert the url on the skype status buttons.
    if (u.indexOf('skype:') == 0) {
      return u;
    }
    var t = tinyMCE.activeEditor, s = t.settings;

    // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
    if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
      return u;

    // Convert to relative
    if (s.relative_urls)
      return t.documentBaseURI.toRelative(u);

    // Convert to absolute
    u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);

    return u;
}
</script>

EOF;
                    unset($check[$key]);
                } else {
                    if ($check[$key] != $found_tinymce) {
                        log_warn('Two differently configured tinyMCE instances have been asked for on this page! This is not possible');
                    }
                    unset($check[$key]);
                }
            }
            // If any page adds jquery explicitly, remove it from the list
            if (($key = array_search('jquery', $check)) !== false) {
                unset($check[$key]);
            }
        }
    } else {
        if (($key = array_search('tinymce', $javascript)) !== false || ($key = array_search('tinytinymce', $javascript)) !== false) {
            unset($javascript[$key]);
        }
        if (($key = array_search('tinymce', $headers)) !== false || ($key = array_search('tinytinymce', $headers)) !== false) {
            unset($headers[$key]);
        }
    }
    if (get_config('developermode') & DEVMODE_UNPACKEDJS) {
        $javascript_array[] = $jsroot . 'MochiKit/MochiKit.js';
        $javascript_array[] = $jsroot . 'MochiKit/Position.js';
        $javascript_array[] = $jsroot . 'MochiKit/Color.js';
        $javascript_array[] = $jsroot . 'MochiKit/Visual.js';
        $javascript_array[] = $jsroot . 'MochiKit/DragAndDrop.js';
        $javascript_array[] = $jsroot . 'MochiKit/Format.js';
    } else {
        $javascript_array[] = $jsroot . 'MochiKit/Packed.js';
    }
    $javascript_array[] = $jsroot . 'keyboardNavigation.js';
    //If necessary, load MathJax path
    if (get_config('mathjax')) {
        $javascript_array[] = get_config('mathjaxpath');
    }
    $strings = array();
    foreach ($pagestrings as $k => $v) {
        if (is_array($v)) {
            foreach ($v as $tag) {
                $strings[$tag] = get_raw_string($tag, $k);
            }
        } else {
            $strings[$k] = get_raw_string($k, $v);
        }
    }
    $jsstrings = jsstrings();
    $themepaths = themepaths();
    foreach ($javascript as $jsfile) {
        // For now, if there's no path in the js file, assume it's in
        // $jsroot and append '.js' to the name.  Later we may want to
        // ensure all smarty() calls include the full path to the js
        // file, with the proper extension.
        if (strpos($jsfile, '/') === false) {
            $javascript_array[] = $jsroot . $jsfile . '.js';
            if (isset($jsstrings[$jsfile])) {
                foreach ($jsstrings[$jsfile] as $section => $tags) {
                    foreach ($tags as $tag) {
                        $strings[$tag] = get_raw_string($tag, $section);
                    }
                }
            }
            if (isset($themepaths[$jsfile])) {
                foreach ($themepaths[$jsfile] as $themepath) {
                    $theme_list[$themepath] = $THEME->get_url($themepath);
                }
            }
        } else {
            if (stripos($jsfile, 'http://') === false && stripos($jsfile, 'https://') === false) {
                // A local .js file with a fully specified path
                $javascript_array[] = $wwwroot . $jsfile;
                // If $jsfile is from a plugin or plugin's block, i.e.:
                // - plugintype/pluginname/js/foo.js
                // - plugintype/pluginname/blocktype/pluginname/js/foo.js
                // Then get js strings from static function jsstrings in:
                // - plugintype/pluginname/lib.php, or
                // - plugintype/pluginname/blocktype/pluginname/lib.php
                $bits = explode('/', $jsfile);
                $pluginname = false;
                $plugintype = false;
                $jsfilename = false;
                if (count($bits) == 4 && $bits[2] == 'js' && in_array($bits[0], plugin_types())) {
                    $plugintype = $bits[0];
                    $pluginname = $bits[1];
                    $jsfilename = $bits[3];
                }
                if (count($bits) == 6 && $bits[0] == 'artefact' && $bits[2] == 'blocktype' && $bits[4] == 'js') {
                    $plugintype = 'blocktype';
                    $pluginname = $bits[3];
                    $jsfilename = $bits[5];
                }
                if ($pluginname) {
                    safe_require($plugintype, $pluginname);
                    $pluginclass = generate_class_name($plugintype, $pluginname);
                    $name = substr($jsfilename, 0, strpos($jsfilename, '.js'));
                    if (is_callable(array($pluginclass, 'jsstrings'))) {
                        $tempstrings = call_static_method($pluginclass, 'jsstrings', $name);
                        foreach ($tempstrings as $section => $tags) {
                            foreach ($tags as $tag) {
                                $strings[$tag] = get_raw_string($tag, $section);
                            }
                        }
                    }
                    if (is_callable(array($pluginclass, 'jshelp'))) {
                        $tempstrings = call_static_method($pluginclass, 'jshelp', $name);
                        foreach ($tempstrings as $section => $tags) {
                            foreach ($tags as $tag) {
                                $strings[$tag . '.help'] = get_help_icon($plugintype, $pluginname, null, null, null, $tag);
                            }
                        }
                    }
                    if (is_callable(array($pluginclass, 'themepaths'))) {
                        $tmpthemepaths = call_static_method($pluginclass, 'themepaths', $name);
                        foreach ($tmpthemepaths as $themepath) {
                            $theme_list[$themepath] = $THEME->get_url($themepath);
                        }
                    }
                }
            } else {
                // A remote .js file
                $javascript_array[] = $jsfile;
            }
        }
    }
    $javascript_array[] = $jsroot . 'mahara.js';
    $javascript_array[] = $jsroot . 'formchangechecker.js';
    if (get_config('developermode') & DEVMODE_DEBUGJS) {
        $javascript_array[] = $jsroot . 'debug.js';
    }
    foreach ($jsstrings['mahara'] as $section => $tags) {
        foreach ($tags as $tag) {
            $strings[$tag] = get_raw_string($tag, $section);
        }
    }
    if (isset($extraconfig['themepaths']) && is_array($extraconfig['themepaths'])) {
        foreach ($extraconfig['themepaths'] as $themepath) {
            $theme_list[$themepath] = $THEME->get_url($themepath);
        }
    }
    $stringjs = '<script type="application/javascript">';
    $stringjs .= 'var strings = ' . json_encode($strings) . ';';
    $stringjs .= "\nfunction plural(n) { return " . get_raw_string('pluralrule', 'langconfig') . "; }\n";
    $stringjs .= '</script>';
    // Allow us to set the HTML lang attribute
    $smarty->assign('LANGUAGE', substr(current_language(), 0, 2));
    $smarty->assign('STRINGJS', $stringjs);
    $stylesheets = get_stylesheets_for_current_page($stylesheets, $extraconfig);
    $smarty->assign('STYLESHEETLIST', $stylesheets);
    if (!empty($theme_list)) {
        // this gets assigned in smarty_core, but do it again here if it's changed locally
        $smarty->assign('THEMELIST', json_encode(array_merge((array) json_decode($smarty->get_template_vars('THEMELIST')), $theme_list)));
    }
    $dropdownmenu = get_config('dropdownmenu');
    // disable drop-downs if overridden at institution level
    $sitethemeprefs = get_config('sitethemeprefs');
    $institutions = $USER->institutions;
    if (!empty($institutions)) {
        foreach ($institutions as $i) {
            if (!empty($sitethemeprefs)) {
                if (!empty($USER->accountprefs['theme']) && $USER->accountprefs['theme'] == $THEME->basename . '/' . $i->institution) {
                    $dropdownmenu = $i->dropdownmenu;
                }
            } else {
                if (!empty($USER->accountprefs['theme']) && $USER->accountprefs['theme'] == $THEME->basename . '/' . $i->institution || empty($USER->accountprefs) && $i->theme == $THEME->basename && $USER->institutiontheme->institutionname == $i->institution) {
                    $dropdownmenu = $i->dropdownmenu;
                }
            }
        }
    }
    // and/or disable drop-downs if a handheld device detected
    $dropdownmenu = $SESSION->get('handheld_device') ? false : $dropdownmenu;
    if ($dropdownmenu) {
        $smarty->assign('DROPDOWNMENU', $dropdownmenu);
        $javascript_array[] = $jsroot . 'dropdown-nav.js';
    }
    $smarty->assign('MOBILE', $SESSION->get('mobile'));
    $smarty->assign('HANDHELD_DEVICE', $SESSION->get('handheld_device'));
    $sitename = get_config('sitename');
    if (!$sitename) {
        $sitename = 'Mahara';
    }
    $smarty->assign('sitename', $sitename);
    $sitelogo = $THEME->header_logo();
    $sitelogo = append_version_number($sitelogo);
    $smarty->assign('sitelogo', $sitelogo);
    $smarty->assign('sitelogo4facebook', $THEME->facebook_logo());
    $smarty->assign('sitedescription4facebook', get_string('facebookdescription', 'mahara'));
    if (defined('TITLE')) {
        $smarty->assign('PAGETITLE', TITLE . ' - ' . $sitename);
        $smarty->assign('heading', TITLE);
    } else {
        $smarty->assign('PAGETITLE', $sitename);
    }
    $smarty->assign('PRODUCTIONMODE', get_config('productionmode'));
    if (function_exists('local_header_top_content')) {
        $sitetop = (isset($sitetop) ? $sitetop : '') . local_header_top_content();
    }
    if (isset($sitetop)) {
        $smarty->assign('SITETOP', $sitetop);
    }
    if (defined('PUBLIC')) {
        $smarty->assign('PUBLIC', true);
    }
    if (defined('ADMIN')) {
        $smarty->assign('ADMIN', true);
    }
    if (defined('INSTITUTIONALADMIN')) {
        $smarty->assign('INSTITUTIONALADMIN', true);
    }
    if (defined('STAFF')) {
        $smarty->assign('STAFF', true);
    }
    if (defined('INSTITUTIONALSTAFF')) {
        $smarty->assign('INSTITUTIONALSTAFF', true);
    }
    $smarty->assign('LOGGEDIN', $USER->is_logged_in());
    $publicsearchallowed = false;
    $searchplugin = get_config('searchplugin');
    if ($searchplugin) {
        safe_require('search', $searchplugin);
        $publicsearchallowed = call_static_method(generate_class_name('search', $searchplugin), 'publicform_allowed') && get_config('publicsearchallowed');
    }
    $smarty->assign('publicsearchallowed', $publicsearchallowed);
    if ($USER->is_logged_in()) {
        global $SELECTEDSUBNAV;
        // It's evil, but rightnav & mainnav stuff are now in different templates.
        $smarty->assign('MAINNAV', main_nav());
        $mainnavsubnav = $SELECTEDSUBNAV;
        $smarty->assign('RIGHTNAV', right_nav());
        if (!$mainnavsubnav && $dropdownmenu) {
            // In drop-down navigation, the submenu is only usable if its parent is one of the top-level menu
            // items.  But if the submenu comes from something in right_nav (settings), it's unreachable.
            // Turning the submenu into SUBPAGENAV group-style tabs makes it usable.
            $smarty->assign('SUBPAGENAV', $SELECTEDSUBNAV);
        } else {
            $smarty->assign('SELECTEDSUBNAV', $SELECTEDSUBNAV);
        }
    } else {
        $smarty->assign('languageform', $langselectform);
    }
    $smarty->assign('FOOTERMENU', footer_menu());
    $smarty->assign_by_ref('USER', $USER);
    $smarty->assign('SESSKEY', $USER->get('sesskey'));
    $smarty->assign('CC_ENABLED', get_config('cookieconsent_enabled'));
    $javascript_array = append_version_number($javascript_array);
    $smarty->assign_by_ref('JAVASCRIPT', $javascript_array);
    $smarty->assign('RELEASE', get_config('release'));
    $smarty->assign('SERIES', get_config('series'));
    $smarty->assign('CACHEVERSION', get_config('cacheversion'));
    $siteclosedforupgrade = get_config('siteclosed');
    if ($siteclosedforupgrade && get_config('disablelogin')) {
        $smarty->assign('SITECLOSED', 'logindisabled');
    } else {
        if ($siteclosedforupgrade || get_config('siteclosedbyadmin')) {
            $smarty->assign('SITECLOSED', 'loginallowed');
        }
    }
    if (!isset($extraconfig['pagehelp']) || $extraconfig['pagehelp'] !== false and $help = has_page_help()) {
        $smarty->assign('PAGEHELPNAME', $help[0]);
        $smarty->assign('PAGEHELPICON', $help[1]);
    }
    if (defined('GROUP')) {
        require_once 'group.php';
        if ($group = group_current_group()) {
            $smarty->assign('GROUP', $group);
            if (!defined('NOGROUPMENU')) {
                $smarty->assign('SUBPAGENAV', group_get_menu_tabs());
                $smarty->assign('PAGEHEADING', $group->name);
            }
        }
    }
    // ---------- sideblock stuff ----------
    $sidebars = !isset($extraconfig['sidebars']) || $extraconfig['sidebars'] !== false;
    if ($sidebars && !defined('INSTALLER') && (!defined('MENUITEM') || substr(MENUITEM, 0, 5) != 'admin')) {
        if (get_config('installed') && !$adminsection) {
            $data = site_menu();
            if (!empty($data)) {
                $smarty->assign('SITEMENU', site_menu());
                $sideblocks[] = array('name' => 'linksandresources', 'weight' => 10, 'data' => $data);
            }
        }
        if ($USER->is_logged_in() && defined('MENUITEM') && (substr(MENUITEM, 0, 11) == 'myportfolio' || substr(MENUITEM, 0, 7) == 'content')) {
            if (get_config('showselfsearchsideblock')) {
                $sideblocks[] = array('name' => 'selfsearch', 'weight' => 0, 'data' => array());
            }
            if (get_config('showtagssideblock')) {
                $sideblocks[] = array('name' => 'tags', 'id' => 'sb-tags', 'weight' => 0, 'data' => tags_sideblock());
            }
        }
        if ($USER->is_logged_in() && !$adminsection) {
            $sideblocks[] = array('name' => 'profile', 'id' => 'sb-profile', 'class' => 'user-panel', 'weight' => -20, 'data' => profile_sideblock());
            $showusers = 2;
            $institutions = $USER->institutions;
            if (!empty($institutions)) {
                $showusers = 0;
                foreach ($institutions as $i) {
                    if ($i->showonlineusers == 2) {
                        $showusers = 2;
                        break;
                    }
                    if ($i->showonlineusers == 1) {
                        $showusers = 1;
                    }
                }
            }
            if (get_config('showonlineuserssideblock') && $showusers > 0) {
                $sideblocks[] = array('name' => 'onlineusers', 'id' => 'sb-onlineusers', 'weight' => -10, 'data' => onlineusers_sideblock());
            }
            if (get_config('showprogressbar') && $USER->get_account_preference('showprogressbar')) {
                $sideblocks[] = array('name' => 'progressbar', 'id' => 'sb-progressbar', 'class' => 'progressbar', 'weight' => -8, 'data' => progressbar_sideblock());
            }
        }
        if ($USER->is_logged_in() && $adminsection && defined('SECTION_PAGE') && SECTION_PAGE == 'progressbar') {
            $sideblocks[] = array('name' => 'progressbar', 'id' => 'sb-progressbar', 'class' => 'progressbar', 'weight' => -8, 'data' => progressbar_sideblock(true));
        }
        $isloginblockvisible = !$USER->is_logged_in() && !(get_config('siteclosed') && get_config('disablelogin')) && get_config('showloginsideblock');
        if ($isloginblockvisible) {
            $sideblocks[] = array('name' => 'login', 'weight' => -10, 'id' => 'sb-loginbox', 'data' => array('loginform' => auth_generate_login_form()));
        }
        if (get_config('enablenetworking')) {
            require_once get_config('docroot') . 'api/xmlrpc/lib.php';
            if ($USER->is_logged_in() && ($ssopeers = get_service_providers($USER->authinstance))) {
                $sideblocks[] = array('name' => 'ssopeers', 'weight' => 1, 'data' => $ssopeers);
            }
        }
        if (isset($extraconfig['sideblocks']) && is_array($extraconfig['sideblocks'])) {
            foreach ($extraconfig['sideblocks'] as $sideblock) {
                $sideblocks[] = $sideblock;
            }
        }
        // local_sideblocks_update allows sites to customise the sideblocks by munging the $sideblocks array.
        if (function_exists('local_sideblocks_update')) {
            local_sideblocks_update($sideblocks);
        }
        usort($sideblocks, create_function('$a,$b', 'if ($a["weight"] == $b["weight"]) return 0; return ($a["weight"] < $b["weight"]) ? -1 : 1;'));
        // Place all sideblocks on the right. If this structure is munged
        // appropriately, you can put blocks on the left. In future versions of
        // Mahara, we'll make it easy to do this.
        $sidebars = $sidebars && !empty($sideblocks);
        $sideblocks = array('left' => array(), 'right' => $sideblocks);
        $smarty->assign('userauthinstance', $SESSION->get('authinstance'));
        $smarty->assign('MNETUSER', $SESSION->get('mnetuser'));
        $smarty->assign('SIDEBLOCKS', $sideblocks);
        $smarty->assign('SIDEBARS', $sidebars);
    }
    if (is_array($HEADDATA) && !empty($HEADDATA)) {
        $headers = array_merge($HEADDATA, $headers);
    }
    $smarty->assign_by_ref('HEADERS', $headers);
    if ($USER->get('parentuser')) {
        $smarty->assign('USERMASQUERADING', true);
        $smarty->assign('masqueradedetails', get_string('youaremasqueradingas', 'mahara', display_name($USER)));
        $smarty->assign('becomeyoulink', hsc($wwwroot) . 'admin/users/changeuser.php?restore=1');
        $smarty->assign('becomeyouagain', get_string('becomeadminagain', 'admin', hsc($USER->get('parentuser')->name)));
    }
    // Define additional html content
    if (get_config('installed')) {
        $additionalhtmlitems = array('ADDITIONALHTMLHEAD' => get_config('additionalhtmlhead'), 'ADDITIONALHTMLTOPOFBODY' => get_config('additionalhtmltopofbody'), 'ADDITIONALHTMLFOOTER' => get_config('additionalhtmlfooter'));
        if ($additionalhtmlitems) {
            foreach ($additionalhtmlitems as $name => $content) {
                $smarty->assign($name, $content);
            }
        }
    }
    // If Cookie Consent is enabled, than define conent
    if (get_config('cookieconsent_enabled')) {
        require_once 'cookieconsent.php';
        $smarty->assign('COOKIECONSENTCODE', get_cookieconsent_code());
    }
    return $smarty;
}
Пример #5
0
			<!-- footer -->
			<footer id="footer" class="footer" role="contentinfo">
				<nav class="nav-footer">
					<div class="container">
						<div class="row">
							<div class="col-md-8">
								<?php 
footer_menu();
?>
							</div>
							<div class="col-md-4 text-right">
							<div class="newsletter">
								<h5>Nhận tin từ <span>SOB.vn</span></h5>
								<input class="form-control" type="text" placeholder="Nhập Email của bạn...">
							</div>
								<div class="like-me">
									<a href="#"><i class="fa fa-facebook-square"></i></a>
									<a href="#"><i class="fa fa-google-plus-square"></i></a>
									<a href="#"><i class="fa fa-youtube-square"></i></a>
									<a href="#"><i class="fa fa-twitter-square"></i></a>
									<a href="#"><i class="fa fa-linkedin-square"></i></a>
									<a href="#"><i class="fa fa-pinterest-square"></i></a>
								</div>
							</div>
						</div>
					</div>
				</nav>
				<!-- /.container -->
				<div class="copyright">
					<div class="container">
						<div class="row text-left">