Skip to content

Instantly share code, notes, and snippets.

View FMCorz's full-sized avatar

Frédéric Massart FMCorz

  • Branch Up Pty Ltd
  • Perth, Australia
View GitHub Profile
<?php
require('config.php');
require_once($CFG->libdir.'/formslib.php');
class test_form extends moodleform {
function definition() {
$mform =& $this->_form;
// $mform->addElement('static', 'infoeditor', 'Editor limit', 'Max files: Unlimited; Max file size: 1MB; Global limit: 2Mo;');

(Markdown seems to play tricks on my post, it seems more readable here)

Hi Sam,

thanks for your feedback. I have to say that I do not disagree with your approach, I agree with most of it. the only thing that I dislike is the developer that makes assumptions on how things should be displayed.

If you have a renderable that is called dropdown_renderable, then it is awkward for a designer to overwrite that to display it differently as the name does not make sense any more. For instance if I do not want a dropdown, but a horizontal list of links, or tabs, ...

What I am suggesting is that renderables are containers of information that are not tied to their display. If you look at it from a templating point of view, you would say that the renderables contain the variables to pass to the template, ignoring what the final display would be. This is common to a more stricter MVC model, and I guess we could apply it to Moodle.

@FMCorz
FMCorz / style.less
Created July 2, 2015 10:29
Mixin to set navbar height in Bootstrap 3
// For each media query.
.navbar-height-setup(@navbar-height) {
min-height: @navbar-height;
.navbar-brand {
height: @navbar-height;
}
.navbar-nav {
> li {
> a {
line-height: @navbar-height;
@FMCorz
FMCorz / styles.css
Created July 3, 2015 04:10
Styling Moodle's user menu using theme_more
/* Not logged in */
.usermenu .login {
color: red;
}
.usermenu .login a {
color: green;
}
.usermenu .login a:focus,
.usermenu .login a:hover {
color: yellow;
@FMCorz
FMCorz / styles.css
Last active August 29, 2015 14:25
Sticky footer for Moodle with Bootstrap 2
body,
html {
height: 100%;
padding-top: 0; /* Revert default padding for navbar */
}
.wrapper {
min-height: 100%;
margin-bottom: -150px; /* Negative footer minimum height */
}
.wrapper::after {
<?php
/**
* Gets the sort direction for a given field
*
* @param string $field
* @return string ASC or DESC
*/
public function get_field_sort_direction($field) {
$dir = $this->sortdirection || self::DEFAULTSORTDIRECTION;
@FMCorz
FMCorz / mixin.scss
Created September 22, 2015 07:18
Mixin to fix the anchors when a fixed header is causing an offset
.anchor-offset-setup(@offset) {
h2[id]::before,
h3[id]::before,
h4[id]::before,
h5[id]::before,
h6[id]::before {
display: block;
content: "";
padding-top: (@offset + 10);
margin-top: -(@offset + 10);
@FMCorz
FMCorz / iconslist.php
Created November 19, 2012 04:20 — forked from marinaglancy/iconslist.php
Lists all icons in pix/i, pix/t and mod/*/pix
<?php
require_once('config.php');
echo '<table border=1>';
iconslist('/pix/i/');
iconslist('/pix/t/');
$modlist = get_plugin_list('mod');
foreach ($modlist as $modname => $path) {
iconslist('/mod/'.$modname.'/pix/');
<?php
// Preparing the query.
$qb = new mod_glossary_entry_query_builder($glossary);
if (!empty($options['includenotapproved']) && has_capability('mod/glossary:approve', $context)) {
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_ALL);
} else {
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_SELF);
}
@FMCorz
FMCorz / fetch.py
Last active November 18, 2015 07:56
Using MDK as a module to fetch a branch from the tracker
import logging
import mdk
from mdk.tools import parseBranch
from mdk.moodle import Moodle
from mdk.fetch import FetchTracker
logging.basicConfig(format='%(message)s', level=logging.DEBUG)
M = Moodle('/home/fred/www/repositories/sm/moodle', 'sm')
# mdl = parseBranch(M.currentBranch())['issue']