Esempio n. 1
0
/**
 * Generate layout color form.
 *
 * @author Laurent Declercq <*****@*****.**>
 * @param $tpl iMSCP_pTemplate Template engine instance
 * @return void
 */
function client_generateLayoutColorForm($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $colors = layout_getAvailableColorSet();
    if (!empty($POST) && isset($_POST['layoutColor']) && in_array($_POST['layoutColor'], $colors)) {
        $selectedColor = $_POST['layoutColor'];
    } else {
        $selectedColor = layout_getUserLayoutColor($_SESSION['user_id']);
    }
    if (!empty($colors)) {
        foreach ($colors as $color) {
            $tpl->assign(array('COLOR' => $color, 'SELECTED_COLOR' => $color == $selectedColor ? $cfg->HTML_SELECTED : ''));
            $tpl->parse('LAYOUT_COLOR_BLOCK', '.layout_color_block');
        }
    } else {
        $tpl->assign('LAYOUT_COLORS_BLOCK', '');
    }
}
Esempio n. 2
0
    /**
     * Returns xhtml header for the Debug Bar
     *
     * @return string
     */
    protected function buildHeader()
    {
        $collapsed = isset($_COOKIE['iMSCPdebugCollapsed']) ? $_COOKIE['iMSCPdebugCollapsed'] : 0;
        $backgroundColor = array('black' => '#000000', 'red' => '#5a0505', 'blue' => '#151e72', 'green' => '#055a0d', 'yellow' => '#85742f');
        $color = isset($_SESSION['user_id']) ? $backgroundColor[layout_getUserLayoutColor($_SESSION['user_id'])] : '#000000';
        return '
            <style type="text/css" media="screen">
                #iMSCPdebug_debug h4 {margin:0.5em;font-weight:bold;}
                #iMSCPdebug_debug strong {font-weight:bold;}
                #iMSCPdebug_debug { font: 1em Geneva, Arial, Helvetica, sans-serif; position:fixed; bottom:5px; left:0; color:#fff; z-index: 255;}
                #iMSCPdebug_debug a {color:red;}
                #iMSCPdebug_debug span {color:#fff;}
                #iMSCPdebug_debug p {margin:0;}
                #iMSCPdebug_debug ol {margin:10px 0; padding:0 25px}
                #iMSCPdebug_debug li {margin:0 0 10px 0;}
                #iMSCPdebug_debug .clickable { cursor:pointer }
                #iMSCPdebug_toggler { font-weight:bold; background:' . $color . '; }
                .iMSCPdebug_span { border: 1px solid #ccc; border-right:0; background:' . $color . '; padding: 6px 5px; }
                .iMSCPdebug_last { border: 1px solid #ccc; }
                .iMSCPdebug_panel { text-align:left; position:absolute;bottom:21px;width:600px; max-height:400px; overflow:auto; display:none; background:' . $color . '; padding:0.5em; border: 1px solid #ccc; }
                .iMSCPdebug_panel .pre {font: 1em Geneva, Arial, Helvetica, sans-serif; margin:0 0 0 22px}
                #iMSCPdebug_exception { border:1px solid #000;display: block; }
            </style>
            <script type="text/javascript">
                if (typeof jQuery == "undefined") {
                    var scriptObj = document.createElement("script");
                    scriptObj.src = "/themes/default/js/jquery.js";
                    scriptObj.type = "text/javascript";
                    var head=document.getElementsByTagName("head")[0];
                    head.insertBefore(scriptObj,head.firstChild);
                }
                var iMSCPdebugLoad = window.onload;
                window.onload = function(){
                    if (iMSCPdebugLoad) {
                        iMSCPdebugLoad();
                    }
                    //jQuery.noConflict();
                    iMSCPdebugCollapsed();
                };

                function iMSCPdebugCollapsed() {
                    if (' . $collapsed . ' == 1) {
                        iMSCPdebugPanel();
                        jQuery("#iMSCPdebug_toggler").html("&#187;");
                        return jQuery("#iMSCPdebug_debug").css("left", "-"+parseInt(jQuery("#iMSCPdebug_debug").outerWidth()-jQuery("#iMSCPdebug_toggler").outerWidth()+1)+"px");
                    }
                }

                function iMSCPdebugPanel(name) {
                    jQuery(".iMSCPdebug_panel").each(function(i) {
                        if(jQuery(this).css("display") == "block") {
                            jQuery(this).slideUp();
                        } else {
                            if (jQuery(this).attr("id") == name)
                                jQuery(this).slideDown();
                            else
                                jQuery(this).slideUp();
                        }
                    });
                }

                function iMSCPdebugSlideBar() {
                    if (jQuery("#iMSCPdebug_debug").position().left >= 0) {
                        document.cookie = "iMSCPdebugCollapsed=1;expires=;path=/";
                        iMSCPdebugPanel();
                        jQuery("#iMSCPdebug_toggler").html("&#187;");
                        return jQuery("#iMSCPdebug_debug").animate({left:"-"+parseInt(jQuery("#iMSCPdebug_debug").outerWidth()-jQuery("#iMSCPdebug_toggler").outerWidth()+1)+"px"}, "normal", "swing");
                    } else {
                        document.cookie = "iMSCPdebugCollapsed=0;expires=;path=/";
                        jQuery("#iMSCPdebug_toggler").html("&#171;");
                        return jQuery("#iMSCPdebug_debug").animate({left:"0px"}, "normal", "swing");
                    }
                }

                function iMSCPdebugToggleElement(name, whenHidden, whenVisible){
                    if(jQuery(name).css("display")=="none"){
                        jQuery(whenVisible).show();
                        jQuery(whenHidden).hide();
                    } else {
                        jQuery(whenVisible).hide();
                        jQuery(whenHidden).show();
                    }
                    jQuery(name).slideToggle();
                }
            </script>';
    }
Esempio n. 3
0
/**
 * Init layout
 *
 * @author Laurent Declercq <*****@*****.**>
 * @param iMSCP_Events_Event $event
 * @return void
 * @todo Use cookies to store user UI properties (Remember me implementation?)
 */
function layout_init($event)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    if ($cfg->DEBUG) {
        $themesAssetsVersion = time();
    } else {
        $themesAssetsVersion = $cfg->THEME_ASSETS_VERSION;
    }
    ini_set('default_charset', 'UTF-8');
    if (isset($_SESSION['user_theme_color'])) {
        $color = $_SESSION['user_theme_color'];
    } elseif (isset($_SESSION['user_id'])) {
        $userId = isset($_SESSION['logged_from_id']) ? $_SESSION['logged_from_id'] : $_SESSION['user_id'];
        $color = layout_getUserLayoutColor($userId);
        $_SESSION['user_theme_color'] = $color;
    } else {
        $colors = layout_getAvailableColorSet();
        $color = array_shift($colors);
    }
    /** @var $tpl iMSCP_pTemplate */
    $tpl = $event->getParam('templateEngine');
    $tpl->assign(array('THEME_CHARSET' => 'UTF-8', 'THEME_ASSETS_PATH' => '/themes/' . $cfg->USER_INITIAL_THEME . '/assets', 'THEME_ASSETS_VERSION' => $themesAssetsVersion, 'THEME_COLOR' => $color, 'ISP_LOGO' => isset($_SESSION['user_id']) ? layout_getUserLogo() : '', 'JS_TRANSLATIONS' => i18n_getJsTranslations()));
    $tpl->parse('LAYOUT', 'layout');
}