Details
Description
It would be really, really nice to have a require_css function that works a bit like require_js. It would make it much easier for plugins and patches that need to get stylesheet links into the header, but which don't make the print_header call directly. See http://cvs.moodle.org/contrib/plugins/admin/report/userroles/index.php?revision=1.2&view=markup for an implementation. You aslo need to change the $meta .= "\n".require_js(); line in print_header.
As we are approaching AJAXy times, I think it would help if this function had a parameter to make it load the requested css via javascript. Currently I am using this for hiding an element (repaginating form) before the page gets loaded if the user has javascript - if they don't, that element displays as an alternative for the ajax form.
In moodle quiz UI redesign, I currently have this hack in weblib.php print_header(), and I am not sure, this should probably be done via YUI as the newer versions provide the facilities for dynamically loading things, and they are probably more reliable than some piece of code I cut-and-pasted from http://some.randomurldotcom.
$meta .= <<<EOF
<script>
var headID = document.getElementsByTagName("head")[0];
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = 'edit-js.css';
cssNode.media = 'screen';
headID.appendChild(cssNode);
</script>
EOF;