Essential Theme and SSL Login

Essential Theme and SSL Login

Bởi Jon Witts -
Số lượng các câu trả lời: 13
Hình của Plugin developers Hình của Testers

Hi there,

I have installed the Essential theme (version 2013120200) on my Moodle server (version 2.6+ (Build: 20131129)) here: http://vle.queenmargarets.com

I have also enabled SSL logins for our site; however when you visit the SSL login page certain icons from the Essential theme are not being displayed. I believe this is because some of the icons are being served over plain http rather than https and the browser is then blocking the content.

You should be able to see what I mean here: https://vle.queenmargarets.com/login/index.php

Thanks,
Jon

Trung bình điểm đánh giá: -
Để phản hồi tới Jon Witts

Re: Essential Theme and SSL Login

Bởi Mary Evans -

Hi,

I think you might need something like this in theme/essential/lib.php where you will find the code which I have highlighted in yellow. You need to add the bit I have highlighted in green...

/**
 * Include the Awesome Font.
 */
function theme_essential_set_fontwww($css) {
    global $CFG, $PAGE;   
    
      $wwwroot = '';
      if (empty($CFG->loginhttps)) {
          $wwwroot = $CFG->wwwroot;
      } else {
          $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);    
    }       
      if(empty($CFG->themewww)) {
        $themewww = $wwwroot . " /theme";
    } else {
        $themewww = $CFG->themewww;
    }
    $tag = 'setting:fontwww';
    
    $theme = theme_config::load('essential');
    if (!empty($theme->settings->bootstrapcdn)) {
        $css = str_replace($tag, '//netdna.bootstrapcdn.com/font-awesome/4.0.0/fonts/', $css);
    } else {
        $css = str_replace($tag, $themewww.'/essential/fonts/', $css);
    }
    return $css;
}

They are fonts and not images, but the problem is the same, they need the https in the font url.

I just hope I am right.

If you try this please make sure you have a copy of the original essential/lib.php

Cheers

Mary

Trung bình điểm đánh giá:Useful (1)
Để phản hồi tới Mary Evans

Re: Essential Theme and SSL Login

Bởi Jon Witts -
Hình của Plugin developers Hình của Testers

Thanks Mary,

I will give it a try tomorrow when I have access to SSH on my server again.

As an aside; is this the best way to report bugs on this theme, or is there a way to report them directly to Julian?

Thanks,
Jon

Để phản hồi tới Mary Evans

Re: Essential Theme and SSL Login

Bởi Jeffery Watkins -

That did not work for me.  I ended up with a blank screen.  I cannot test too much because it is a busy live site.

 

Jeff

Để phản hồi tới Jeffery Watkins

Re: Essential Theme and SSL Login

Bởi Jon Witts -
Hình của Plugin developers Hình của Testers

Just taking a glance at the code I think Mary may have missed of highlighting the last curly brace in green. I have highlighted that in red below. Does this change make it display in your site Jeff?

Jon

/**
* Include the Awesome Font.
*/
function theme_essential_set_fontwww($css) {
global $CFG, $PAGE;

$wwwroot = '';
if (empty($CFG->loginhttps)) {
$wwwroot = $CFG->wwwroot;
} else {
$wwwroot = str_replace("http://", "https://", $CFG->wwwroot);

}
if(empty($CFG->themewww)) {
$themewww = $wwwroot . " /theme";
} else {
$themewww = $CFG->themewww;
}
$tag = 'setting:fontwww';

$theme = theme_config::load('essential');
if (!empty($theme->settings->bootstrapcdn)) {
$css = str_replace($tag, '//netdna.bootstrapcdn.com/font-awesome/4.0.0/fonts/', $css);
} else {
$css = str_replace($tag, $themewww.'/essential/fonts/', $css);
}
return $css;
}

Để phản hồi tới Jon Witts

Re: Essential Theme and SSL Login

Bởi Jeffery Watkins -

Jon,

That fixed the blank screen problem.  However, not only did the icons not show up in https, but all images then disappeared.

 

Jeff

Để phản hồi tới Jeffery Watkins

Re: Essential Theme and SSL Login

Bởi Jon Witts -
Hình của Plugin developers Hình của Testers

Jeff,

I will test tomorrow and see if I can replicate the same thing. It is only a small number of the icons / images which are not showing under the SSL login the majority do; so it may require a little more investigation!

Thanks,
Jon

Để phản hồi tới Jon Witts

Re: Essential Theme and SSL Login

Bởi Mary Evans -

Hi Jon,

This is where I got the code from, it's used in some of my themes, it adds a login section into the header.


    function get_content () {
    global $USER, $CFG, $SESSION, $COURSE;
    $wwwroot = '';
    $signup = '';}

    if (empty($CFG->loginhttps)) {
        $wwwroot = $CFG->wwwroot;
    } else {
        $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
    }

if (!isloggedin() or isguestuser()) {
    echo '<div id="profilelogin">';
    echo '<form id="login" method="post" action="'.$wwwroot.'/login/index.php?authldap_skipntlmsso=1">';
    echo '<ul>';
    echo '<li><input class="loginform" type="text" name="username" id="login_username" value="" placeholder="'.get_string('username').'" /></li>';
    echo '<li><input class="loginform" type="password" name="password" id="login_password" value="" placeholder="'.get_string('password').'" /></li>';
    echo '<li><input type="submit" value="&nbsp;&nbsp;'.get_string('login').'&nbsp;&nbsp;" /></li>';
    echo '</ul>';
    echo '</form>';
    echo '</div>';
} else {
    echo '<div id="profilepic">';
    echo $OUTPUT->user_picture($USER, array('size'=>50));
    echo '</div>';
} ?>

Để phản hồi tới Mary Evans

Re: Essential Theme and SSL Login

Bởi Gareth J Barnard -
Hình của Core developers Hình của Particularly helpful Moodlers Hình của Plugin developers

The relatively new logo serving code uses the method 'setting_file_url' in '/lib/outputlib.php' and that has some https code that could be adapted:

    public function setting_file_url($setting, $filearea) {
        global $CFG;

        if (empty($this->settings->$setting)) {
            return null;
        }

        $component = 'theme_'.$this->name;
        $itemid = theme_get_revision();
        $filepath = $this->settings->$setting;
        $syscontext = context_system::instance();

        $url = moodle_url::make_file_url("$CFG->wwwroot/pluginfile.php", "/$syscontext->id/$component/$filearea/$itemid".$filepath);

        // Now this is tricky because the we can not hardcode http or https here, lets use the relative link.
        // Note: unfortunately moodle_url does not support //urls yet.

        $url = preg_replace('|^https?://|i', '//', $url->out(false));

        return $url;
    } 

 as I do in the Shoelace theme:

function theme_shoelace_set_fontwww($css) {
    global $CFG;
    $tag = 'setting:fontwww';

    $syscontext = context_system::instance();
    $itemid = theme_get_revision();
    $url = moodle_url::make_file_url("$CFG->wwwroot/pluginfile.php", "/$syscontext->id/theme_shoelace/font/$itemid/");
    // Now this is tricky because the we can not hard code http or https here, lets use the relative link.
    // Note: unfortunately moodle_url does not support //urls yet.
    $url = preg_replace('|^https?://|i', '//', $url->out(false));

    $css = str_replace($tag, $url, $css);
    return $css;
}

 and then serve:

function theme_shoelace_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        if ($filearea === 'logo') {
           $theme = theme_config::load('shoelace');
           return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
        } else if ($filearea === 'font') {
            global $CFG;
            if (!empty($CFG->themedir)) {
                $thefontpath = $CFG->themedir . '/shoelace/style/font/';
            } else {
                $thefontpath = $CFG->dirroot . '/theme/shoelace/style/font/';
            }

            // Use log as a way of seeing what is going on.
            //add_to_log(24, 'theme_shoelace', '$thefontpath', $thefontpath);
            //add_to_log(24, 'theme_shoelace', 'args[1]', $args[1]);

            //send_file($thefontpath.$args[1], $args[1]);  // Mime type detection not working?
            // Note: Third parameter is normally 'default' which is the 'lifetime' of the file.  Here set lower for development purposes.
            send_file($thefontpath.$args[1], $args[1], 20 , 0, false, false, 'font/opentype');
        } else {
            send_file_not_found();
        }
    } else {
        send_file_not_found();
    }
} 
Để phản hồi tới Jon Witts

Re: Essential Theme and SSL Login

Bởi Jon Witts -
Hình của Plugin developers Hình của Testers

I just updated my Essential theme to version 2014020300 as I thought that the fix in version 2.6.2 would sort out this issue (FIX: GoogleFonts will now load in HTTPS setups).

However, I am still seeing the fonts in the theme being served out over plain http rather https when visiting a page which uses https (like login/index.php or /user/editadvanced.php) when the site setting "Use HTTPS for logins" is set to Yes.

Firefox is then blocking the content being served over http meaning that on these pages all of the fonts appear broken... See screen shot attached.

Is there any chance this can be fixed Julian?

Thanks,
Jon

File đính kém https-issue-2.jpg
Để phản hồi tới Jon Witts

Re: Essential Theme and SSL Login

Bởi Bulk Edit -

Hello all,

i  found this discussion while i am having the same problem using a theme called 'Klass'.
I added the code from above to the 'lib.php' but it didn't work.

As the discussion is very old, maybe you can give me a little help to get my wenfonts loaded?

Thx
Bulk

Để phản hồi tới Bulk Edit

Re: Essential Theme and SSL Login

Bởi Gareth J Barnard -
Hình của Core developers Hình của Particularly helpful Moodlers Hình của Plugin developers

Have you contacted 'Nephzat Technologies' about the issue?

Để phản hồi tới Gareth J Barnard

Re: Essential Theme and SSL Login

Bởi Bulk Edit -

I tried to contact them about other issues (e.g. Navigation did not work on iOs devices) but they didn't answer at all buồn

Để phản hồi tới Bulk Edit

Re: Essential Theme and SSL Login

Bởi Gareth J Barnard -
Hình của Core developers Hình của Particularly helpful Moodlers Hình của Plugin developers

Hi Bulk,

I'm sorry, but technically they are a competitor to me for my themes etc.  Thus something that would be difficult for me to help and support on.

Kind regards,

Gareth