コード例 #1
0
function organizer_make_infobox($params, $organizer, $context, &$popups)
{
    global $PAGE;
    user_preference_allow_ajax_update('mod_organizer_showpasttimeslots', PARAM_BOOL);
    user_preference_allow_ajax_update('mod_organizer_showmyslotsonly', PARAM_BOOL);
    user_preference_allow_ajax_update('mod_organizer_showfreeslotsonly', PARAM_BOOL);
    $PAGE->requires->js_init_call('M.mod_organizer.init_infobox');
    $output = '';
    if ($organizer->alwaysshowdescription || time() > $organizer->allowregistrationsfromdate) {
        $output = organizer_make_description_section($organizer);
    }
    switch ($params['mode']) {
        case ORGANIZER_TAB_APPOINTMENTS_VIEW:
            break;
        case ORGANIZER_TAB_STUDENT_VIEW:
            $output .= organizer_make_myapp_section($params, $organizer, organizer_get_last_user_appointment($organizer), $popups);
            break;
        case ORGANIZER_TAB_REGISTRATION_STATUS_VIEW:
            $output .= organizer_make_reminder_section($params, $context);
            break;
        default:
            print_error("Wrong view mode: {$params['mode']}");
    }
    $output .= organizer_make_slotoptions_section($params);
    $output .= organizer_make_messages_section($params);
    return $output;
}
コード例 #2
0
 /**
  * Gets Javascript that may be required for navigation
  */
 function load_all_js($expandable)
 {
     global $CFG;
     user_preference_allow_ajax_update('docked_block_instance_' . $this->instance->id, PARAM_INT);
     $this->page->requires->js_module('core_dock');
     $limit = 20;
     if (!empty($CFG->navcourselimit)) {
         $limit = $CFG->navcourselimit;
     }
     $expansionlimit = 0;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
     }
     if (!empty($CFG->block_course_menu_docked_background)) {
         $bg_color = $CFG->block_course_menu_docked_background;
     } else {
         $bg_color = self::DEFAULT_DOCKED_BG;
     }
     $arguments = array('id' => $this->instance->id, 'instance' => $this->instance->id, 'candock' => $this->instance_can_be_docked(), 'courselimit' => $limit, 'expansionlimit' => $expansionlimit, 'bg_color' => $bg_color, 'expansions' => $expandable);
     $this->page->requires->string_for_js('viewallcourses', 'moodle');
     $this->page->requires->yui_module(array('core_dock', 'moodle-block_course_menu-navigation'), 'M.block_course_menu.init_add_tree', array($arguments));
 }
コード例 #3
0
ファイル: weblib.php プロジェクト: hatone/moodle
/**
 * Print (or return) the start of a collapsible region, that has a caption that can
 * be clicked to expand or collapse the region. If JavaScript is off, then the region
 * will always be expanded.
 *
 * @param string $classes class names added to the div that is output.
 * @param string $id id added to the div that is output. Must not be blank.
 * @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
 * @param string $userpref the name of the user preference that stores the user's preferred default state.
 *      (May be blank if you do not wish the state to be persisted.
 * @param boolean $default Initial collapsed state to use if the user_preference it not set.
 * @param boolean $return if true, return the HTML as a string, rather than printing it.
 * @return string|void if $return is false, returns nothing, otherwise returns a string of HTML.
 */
function print_collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false, $return = false)
{
    global $CFG, $PAGE, $OUTPUT;
    // Work out the initial state.
    if (!empty($userpref) and is_string($userpref)) {
        user_preference_allow_ajax_update($userpref, PARAM_BOOL);
        $collapsed = get_user_preferences($userpref, $default);
    } else {
        $collapsed = $default;
        $userpref = false;
    }
    if ($collapsed) {
        $classes .= ' collapsed';
    }
    $output = '';
    $output .= '<div id="' . $id . '" class="collapsibleregion ' . $classes . '">';
    $output .= '<div id="' . $id . '_sizer">';
    $output .= '<div id="' . $id . '_caption" class="collapsibleregioncaption">';
    $output .= $caption . ' ';
    $output .= '</div><div id="' . $id . '_inner" class="collapsibleregioninner">';
    $PAGE->requires->js_init_call('M.util.init_collapsible_region', array($id, $userpref, get_string('clicktohideshow')));
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #4
0
ファイル: lib.php プロジェクト: isuruAb/moodle
/**
 * Generate all options needed by filepicker
 *
 * @param array $args including following keys
 *          context
 *          accepted_types
 *          return_types
 *
 * @return array the list of repository instances, including meta infomation, containing the following keys
 *          externallink
 *          repositories
 *          accepted_types
 */
function initialise_filepicker($args)
{
    global $CFG, $USER, $PAGE, $OUTPUT;
    static $templatesinitialized = array();
    require_once $CFG->libdir . '/licenselib.php';
    $return = new stdClass();
    $licenses = array();
    if (!empty($CFG->licenses)) {
        $array = explode(',', $CFG->licenses);
        foreach ($array as $license) {
            $l = new stdClass();
            $l->shortname = $license;
            $l->fullname = get_string($license, 'license');
            $licenses[] = $l;
        }
    }
    if (!empty($CFG->sitedefaultlicense)) {
        $return->defaultlicense = $CFG->sitedefaultlicense;
    }
    $return->licenses = $licenses;
    $return->author = fullname($USER);
    if (empty($args->context)) {
        $context = $PAGE->context;
    } else {
        $context = $args->context;
    }
    $disable_types = array();
    if (!empty($args->disable_types)) {
        $disable_types = $args->disable_types;
    }
    $user_context = context_user::instance($USER->id);
    list($context, $course, $cm) = get_context_info_array($context->id);
    $contexts = array($user_context, context_system::instance());
    if (!empty($course)) {
        // adding course context
        $contexts[] = context_course::instance($course->id);
    }
    $externallink = (int) get_config(null, 'repositoryallowexternallinks');
    $repositories = repository::get_instances(array('context' => $contexts, 'currentcontext' => $context, 'accepted_types' => $args->accepted_types, 'return_types' => $args->return_types, 'disable_types' => $disable_types));
    $return->repositories = array();
    if (empty($externallink)) {
        $return->externallink = false;
    } else {
        $return->externallink = true;
    }
    $return->userprefs = array();
    $return->userprefs['recentrepository'] = get_user_preferences('filepicker_recentrepository', '');
    $return->userprefs['recentlicense'] = get_user_preferences('filepicker_recentlicense', '');
    $return->userprefs['recentviewmode'] = get_user_preferences('filepicker_recentviewmode', '');
    user_preference_allow_ajax_update('filepicker_recentrepository', PARAM_INT);
    user_preference_allow_ajax_update('filepicker_recentlicense', PARAM_SAFEDIR);
    user_preference_allow_ajax_update('filepicker_recentviewmode', PARAM_INT);
    // provided by form element
    $return->accepted_types = file_get_typegroup('extension', $args->accepted_types);
    $return->return_types = $args->return_types;
    $templates = array();
    foreach ($repositories as $repository) {
        $meta = $repository->get_meta();
        // Please note that the array keys for repositories are used within
        // JavaScript a lot, the key NEEDS to be the repository id.
        $return->repositories[$repository->id] = $meta;
        // Register custom repository template if it has one
        if (method_exists($repository, 'get_upload_template') && !array_key_exists('uploadform_' . $meta->type, $templatesinitialized)) {
            $templates['uploadform_' . $meta->type] = $repository->get_upload_template();
            $templatesinitialized['uploadform_' . $meta->type] = true;
        }
    }
    if (!array_key_exists('core', $templatesinitialized)) {
        // we need to send each filepicker template to the browser just once
        $fprenderer = $PAGE->get_renderer('core', 'files');
        $templates = array_merge($templates, $fprenderer->filepicker_js_templates());
        $templatesinitialized['core'] = true;
    }
    if (sizeof($templates)) {
        $PAGE->requires->js_init_call('M.core_filepicker.set_templates', array($templates), true);
    }
    return $return;
}
コード例 #5
0
 /**
  * Allows the block to load any JS it requires into the page.
  *
  * By default this function simply permits the user to dock the block if it is dockable.
  */
 function get_required_javascript()
 {
     if ($this->instance_can_be_docked() && !$this->hide_header()) {
         user_preference_allow_ajax_update('docked_block_instance_' . $this->instance->id, PARAM_INT);
     }
 }
コード例 #6
0
 function get_required_javascript()
 {
     if ($this->instance_can_be_docked() && !$this->hide_header()) {
         $this->page->requires->js_init_call('M.core_dock.init_genericblock', array($this->instance->id));
         user_preference_allow_ajax_update('docked_block_instance_' . $this->instance->id, PARAM_INT);
     }
 }
コード例 #7
0
ファイル: lib.php プロジェクト: JOANMM/bcu
function theme_bcu_initialise_full(moodle_page $page)
{
    user_preference_allow_ajax_update('theme_bcu_full', PARAM_TEXT);
    $page->requires->yui_module('moodle-theme_bcu-full', 'M.theme_bcu.full.init', array());
}
コード例 #8
0
ファイル: lib.php プロジェクト: vuchannguyen/web
/**
 * Adds the JavaScript for the colour switcher to the page.
 *
 * The colour switcher is a YUI moodle module that is located in
 *     theme/splash/yui/splash/splash.js
 *
 * @param moodle_page $page 
 */
function splash_initialise_colourswitcher(moodle_page $page)
{
    user_preference_allow_ajax_update('theme_splash_chosen_colour', PARAM_ALPHA);
    $page->requires->yui_module('moodle-theme_splash-colourswitcher', 'M.theme_splash.initColourSwitcher', array(array('div' => '#colourswitcher')));
}
コード例 #9
0
 /**
  * Calls the JS require function to hide a block.
  * @param block_contents $bc A block_contents object
  * @return void
  */
 protected function init_block_hider_js($bc)
 {
     if ($bc->collapsible != block_contents::NOT_HIDEABLE) {
         $userpref = 'block' . $bc->blockinstanceid . 'hidden';
         user_preference_allow_ajax_update($userpref, PARAM_BOOL);
         $this->page->requires->yui_lib('dom');
         $this->page->requires->yui_lib('event');
         $plaintitle = strip_tags($bc->title);
         $this->page->requires->js_function_call('new block_hider', array($bc->id, $userpref, get_string('hideblocka', 'access', $plaintitle), get_string('showblocka', 'access', $plaintitle), $this->old_icon_url('t/switch_minus'), $this->old_icon_url('t/switch_plus')));
     }
 }
コード例 #10
0
ファイル: lib.php プロジェクト: adonm/learning
/**
 * Loads the JavaScript for the zoom function.
 *
 * @param moodle_page $page Pass in $PAGE.
 */
function theme_bootstrap_initialise_zoom(moodle_page $page)
{
    user_preference_allow_ajax_update('theme_bootstrap_zoom', PARAM_TEXT);
    $page->requires->yui_module('moodle-theme_bootstrap-zoom', 'M.theme_bootstrap.zoom.init', array());
}
コード例 #11
0
ファイル: lib.php プロジェクト: number33/moodle
/**
 * Allow AJAX updating of the user defined columns for tablets or not
 *
 * @param moodle_page $page
 */
function mymobile_initialise_colpos(moodle_page $page) {
    user_preference_allow_ajax_update('theme_mymobile_chosen_colpos', PARAM_ALPHA);
}
コード例 #12
0
ファイル: columns2.php プロジェクト: rezaies/moodle
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * A two column layout for the boost theme.
 *
 * @package   theme_boost
 * @copyright 2016 Damyon Wiese
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

defined('MOODLE_INTERNAL') || die();

user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php');

if (isloggedin()) {
    $navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
} else {
    $navdraweropen = false;
}
$extraclasses = [];
if ($navdraweropen) {
    $extraclasses[] = 'drawer-open-left';
}
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
$blockshtml = $OUTPUT->blocks('side-pre');
$hasblocks = strpos($blockshtml, 'data-block=') !== false;
$regionmainsettingsmenu = $OUTPUT->region_main_settings_menu();
コード例 #13
0
 public function render_stats_view($name, $maintitle, $content, $subtitle = '', $info = '', $form = null, $ajax = false)
 {
     global $PAGE, $OUTPUT;
     if ($ajax) {
         // Don't render - return the data.
         $out = new stdClass();
         $out->name = $name;
         $out->maintitle = $maintitle;
         $out->maintitleclass = 'oublog_statsview_title';
         $out->subtitle = $subtitle;
         $out->subtitleclass = 'oublog_statsview_subtitle';
         $out->content = $content;
         $out->info = $info;
         $out->infoclass = "oublog_{$name}_info";
         $out->containerclass = "oublog_statsview_content_{$name}";
         $out->contentclass = "oublog_statsview_innercontent_{$name}";
         return $out;
     }
     $out = '';
     if (!empty($subtitle)) {
         $out .= $OUTPUT->heading($subtitle, 3, 'oublog_statsview_subtitle');
     }
     if (!empty($info)) {
         $out .= html_writer::start_tag('a', array('class' => 'block_action_oublog', 'tabindex' => 0, 'href' => '#'));
         $minushide = '';
         $plushide = ' oublog_displaynone';
         if ($userpref = get_user_preferences("mod_oublog_hidestatsform_{$name}", false)) {
             $minushide = ' oublog_displaynone';
             $plushide = '';
         }
         // Setup Javascript for stats view.
         user_preference_allow_ajax_update("mod_oublog_hidestatsform_{$name}", PARAM_BOOL);
         $PAGE->requires->js('/mod/oublog/module.js');
         $module = array('name' => 'mod_oublog');
         $module['fullpath'] = '/mod/oublog/module.js';
         $module['requires'] = array('node', 'node-event-delegate');
         $module['strings'] = array();
         $PAGE->requires->js_init_call('M.mod_oublog.init_showhide', array($name, $userpref), false, $module);
         $out .= $this->output->pix_icon('t/switch_minus', get_string('timefilter_close', 'oublog'), 'moodle', array('class' => 'oublog_stats_minus' . $minushide));
         $out .= $this->output->pix_icon('t/switch_plus', get_string('timefilter_open', 'oublog'), 'moodle', array('class' => 'oublog_stats_plus' . $plushide));
         $out .= html_writer::end_tag('a');
         // Stats bar - call once per 'view'.
         $PAGE->requires->yui_module('moodle-mod_oublog-statsbar', 'M.mod_oublog.statsbar.init', array("oublog_statsview_content_{$name}"));
         $out .= html_writer::tag('p', $info, array('class' => "oublog_{$name}_info"));
     }
     if (!empty($form)) {
         $out .= $form->render();
     }
     $out .= html_writer::div($content, "oublog_statsview_innercontent oublog_statsview_innercontent_{$name}");
     return html_writer::div($this->output->heading($maintitle, 2), 'oublog_statsview_title') . $this->output->container($out, "oublog_statsview_content oublog_statsview_content_{$name}");
 }
コード例 #14
0
ファイル: weblib.php プロジェクト: ajv/Offline-Caching
/**
 * Print (or return) the start of a collapisble region, that has a caption that can
 * be clicked to expand or collapse the region. If JavaScript is off, then the region
 * will always be exanded.
 *
 * @global object
 * @param string $classes class names added to the div that is output.
 * @param string $id id added to the div that is output. Must not be blank.
 * @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
 * @param boolean $userpref the name of the user preference that stores the user's preferred deafault state.
 *      (May be blank if you do not wish the state to be persisted.
 * @param boolean $default Inital collapsed state to use if the user_preference it not set.
 * @param boolean $return if true, return the HTML as a string, rather than printing it.
 * @return string|void if $return is false, returns nothing, otherwise returns a string of HTML.
 */
function print_collapsible_region_start($classes, $id, $caption, $userpref = false, $default = false, $return = false)
{
    global $CFG, $PAGE, $OUTPUT;
    // Include required JavaScript libraries.
    $PAGE->requires->yui_lib('animation');
    // Work out the initial state.
    if (is_string($userpref)) {
        user_preference_allow_ajax_update($userpref, PARAM_BOOL);
        $collapsed = get_user_preferences($userpref, $default);
    } else {
        $collapsed = $default;
        $userpref = false;
    }
    if ($collapsed) {
        $classes .= ' collapsed';
    }
    $output = '';
    $output .= '<div id="' . $id . '" class="collapsibleregion ' . $classes . '">';
    $output .= '<div id="' . $id . '_sizer">';
    $output .= '<div id="' . $id . '_caption" class="collapsibleregioncaption">';
    $output .= $caption . ' ';
    $output .= '</div><div id="' . $id . '_inner" class="collapsibleregioninner">';
    $PAGE->requires->js_function_call('new collapsible_region', array($id, $userpref, get_string('clicktohideshow'), $OUTPUT->old_icon_url('t/collapsed'), $OUTPUT->old_icon_url('t/expanded')));
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #15
0
ファイル: weblib.php プロジェクト: nicolasconnault/moodle2.0
/**
 * Print (or return) the start of a collapisble region, that has a caption that can
 * be clicked to expand or collapse the region. If JavaScript is off, then the region
 * will always be exanded.
 *
 * @param string $classes class names added to the div that is output.
 * @param string $id id added to the div that is output. Must not be blank.
 * @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
 * @param string $userpref the name of the user preference that stores the user's preferred deafault state.
 *      (May be blank if you do not wish the state to be persisted.
 * @param boolean $default Inital collapsed state to use if the user_preference it not set.
 * @param boolean $return if true, return the HTML as a string, rather than printing it.
 * @return mixed if $return is false, returns nothing, otherwise returns a string of HTML.
 */
function print_collapsible_region_start($classes, $id, $caption, $userpref = false, $default = false, $return = false)
{
    global $CFG;
    // Include required JavaScript libraries.
    require_js(array('yui_yahoo', 'yui_dom-event', 'yui_event', 'yui_animation'));
    // Work out the initial state.
    if (is_string($userpref)) {
        user_preference_allow_ajax_update($userpref, PARAM_BOOL);
        $collapsed = get_user_preferences($userpref, $default);
    } else {
        $collapsed = $default;
        $userpref = false;
    }
    if ($collapsed) {
        $classes .= ' collapsed';
    }
    $output = '';
    $output .= '<div id="' . $id . '" class="collapsibleregion ' . $classes . '">';
    $output .= '<div id="' . $id . '_sizer">';
    $output .= '<div id="' . $id . '_caption" class="collapsibleregioncaption">';
    $output .= $caption . ' ';
    $output .= '</div><div id="' . $id . '_inner" class="collapsibleregioninner">';
    $output .= print_js_call('new collapsible_region', array($id, $userpref, get_string('clicktohideshow')), true);
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #16
0
ファイル: block_settings.php プロジェクト: vuchannguyen/web
 /**
  * Gets the content for this block by grabbing it from $this->page
  */
 function get_content()
 {
     global $CFG, $OUTPUT;
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return true;
     }
     $this->page->requires->yui2_lib('dom');
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     block_settings::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_settingsnav' . block_settings::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_settingsnav' . block_settings::$navcount, 0);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_settingsnav' . block_settings::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $renderer = $this->page->get_renderer('block_settings');
     $this->content->text = $renderer->settings_tree($this->page->settingsnav);
     // only do search if you have moodle/site:config
     if (!empty($this->content->text)) {
         if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
             $this->content->footer = $renderer->search_form(new moodle_url("{$CFG->wwwroot}/{$CFG->admin}/search.php"), optional_param('query', '', PARAM_RAW));
         } else {
             $this->content->footer = '';
         }
         if (!empty($this->config->enabledock) && $this->config->enabledock == 'yes') {
             user_preference_allow_ajax_update('nav_in_tab_panel_settingsnav' . block_settings::$navcount, PARAM_INT);
         }
     }
     $this->contentgenerated = true;
     return true;
 }
コード例 #17
0
 /**
  * Print (or return) the start of a collapsible region, that has a caption that can
  * be clicked to expand or collapse the region. If JavaScript is off, then the region
  * will always be expanded.
  *
  * @param string $classes class names added to the div that is output.
  * @param string $id id added to the div that is output. Must not be blank.
  * @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
  * @param string $userpref the name of the user preference that stores the user's preferred default state.
  *      (May be blank if you do not wish the state to be persisted.
  * @param bool $default Initial collapsed state to use if the user_preference it not set.
  * @return bool if true, return the HTML as a string, rather than printing it.
  */
 protected function collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false)
 {
     // Work out the initial state.
     if (!empty($userpref) and is_string($userpref)) {
         user_preference_allow_ajax_update($userpref, PARAM_BOOL);
         $collapsed = get_user_preferences($userpref, $default);
     } else {
         $collapsed = $default;
         $userpref = false;
     }
     if ($collapsed) {
         $classes .= ' collapsed';
     }
     $output = '';
     $output .= '<div id="' . $id . '" class="collapsibleregion ' . $classes . '">';
     $output .= '<div id="' . $id . '_sizer">';
     $output .= '<div id="' . $id . '_caption" class="collapsibleregioncaption">';
     $output .= $caption . ' ';
     $output .= '</div><div id="' . $id . '_inner" class="collapsibleregioninner">';
     $this->page->requires->js_init_call('M.block_course_overview.collapsible', array($id, $userpref, get_string('clicktohideshow')));
     return $output;
 }
コード例 #18
0
 /**
  * Adds the JavaScript for the colour switcher to the page.
  *
  * The colour switcher is a YUI moodle module that is located in
  *     theme/udemspl/yui/udemspl/udemspl.js
  *
  * @param moodle_page $page
  */
 public static function initialise_colourswitcher(\moodle_page $page)
 {
     self::check_colours_switch();
     \user_preference_allow_ajax_update('theme_essential_colours', PARAM_ALPHANUM);
     $page->requires->js_call_amd('theme_essential/coloursswitcher', 'init', array(array('div' => '#custom_menu_themecolours .dropdown-menu')));
 }
コード例 #19
0
ファイル: lib.php プロジェクト: Burick/moodle
 private function option_checkbox($name, $on, $label) {
     if ($on) {
         $checked = ' checked="checked"';
     } else {
         $checked = '';
     }
     $name = 'userselector_' . $name;
     $output = '<p><input type="hidden" name="' . $name . '" value="0" />' .
             // For the benefit of brain-dead IE, the id must be different from the name of the hidden form field above.
             // It seems that document.getElementById('frog') in IE will return and element with name="frog".
             '<input type="checkbox" id="' . $name . 'id" name="' . $name . '" value="1"' . $checked . ' /> ' .
             '<label for="' . $name . 'id">' . $label . "</label></p>\n";
     user_preference_allow_ajax_update($name, PARAM_BOOL);
     return $output;
 }
コード例 #20
0
 /**
  * Return the notices.
  *
  * @param block_xp_manager $manager The manager.
  * @return string The notices.
  */
 public function notices($manager)
 {
     global $CFG;
     $o = '';
     if (!$manager->can_manage()) {
         return $o;
     }
     if (!get_user_preferences(block_xp_manager::USERPREF_NOTICES, false)) {
         require_once $CFG->libdir . '/ajax/ajaxlib.php';
         user_preference_allow_ajax_update(block_xp_manager::USERPREF_NOTICES, PARAM_BOOL);
         $moodleorgurl = new moodle_url('https://moodle.org/plugins/view.php?plugin=block_xp');
         $githuburl = new moodle_url('https://github.com/FMCorz/moodle-block_xp');
         $text = get_string('likenotice', 'block_xp', (object) array('moodleorg' => $moodleorgurl->out(), 'github' => $githuburl->out()));
         $id = html_writer::random_id();
         $this->page->requires->js_init_call("Y.one('.block-xp-rocks').on('click', function(e) {\n                e.preventDefault();\n                M.util.set_user_preference('" . block_xp_manager::USERPREF_NOTICES . "', 1);\n                Y.one('.block-xp-notices').hide();\n            });");
         $icon = new pix_icon('t/delete', get_string('dismissnotice', 'block_xp'));
         $actionicon = $this->action_icon(new moodle_url($this->page->url), $icon, null, array('class' => 'block-xp-rocks'));
         $text .= html_writer::div($actionicon, 'dismiss-action');
         $o .= html_writer::div($this->notification($text, 'notifysuccess'), 'block-xp-notices');
     }
     return $o;
 }
コード例 #21
0
ファイル: outputrenderers.php プロジェクト: afgal/moodle-1
    /**
     * Calls the JS require function to hide a block.
     *
     * @param block_contents $bc A block_contents object
     */
    protected function init_block_hider_js(block_contents $bc) {
        if (!empty($bc->attributes['id']) and $bc->collapsible != block_contents::NOT_HIDEABLE) {
            $config = new stdClass;
            $config->id = $bc->attributes['id'];
            $config->title = strip_tags($bc->title);
            $config->preference = 'block' . $bc->blockinstanceid . 'hidden';
            $config->tooltipVisible = get_string('hideblocka', 'access', $config->title);
            $config->tooltipHidden = get_string('showblocka', 'access', $config->title);

            $this->page->requires->js_init_call('M.util.init_block_hider', array($config));
            user_preference_allow_ajax_update($config->preference, PARAM_BOOL);
        }
    }
コード例 #22
0
if ($devicetype == "mobile") {
    $portable = 1;
} else {
    if ($devicetype == "tablet") {
        $portable = 2;
    } else {
        $portable = 0;
    }
}
$renderer->set_portable($portable);
if (!empty($displaysection) && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
    $renderer->print_single_section_page($course, null, null, null, null, $displaysection);
} else {
    $defaulttogglepersistence = clean_param(get_config('format_topcoll', 'defaulttogglepersistence'), PARAM_INT);
    if ($defaulttogglepersistence == 1) {
        user_preference_allow_ajax_update('topcoll_toggle_' . $course->id, PARAM_RAW);
        $userpreference = get_user_preferences('topcoll_toggle_' . $course->id);
    } else {
        $userpreference = null;
    }
    $renderer->set_user_preference($userpreference);
    $defaultuserpreference = clean_param(get_config('format_topcoll', 'defaultuserpreference'), PARAM_INT);
    $renderer->set_default_user_preference($defaultuserpreference);
    $PAGE->requires->js_init_call('M.format_topcoll.init', array($course->id, $userpreference, $course->numsections, $defaulttogglepersistence, $defaultuserpreference));
    $tcsettings = $courseformat->get_settings();
    ?>
    <style type="text/css" media="screen">
    /* <![CDATA[ */

    /* -- Toggle -- */
    .course-content ul.ctopics li.section .content .toggle, .course-content ul.ctopics li.section .content.sectionhidden {
コード例 #23
0
ファイル: block_navigation.php プロジェクト: JP-Git/moodle
 /**
  * Gets Javascript that may be required for navigation
  */
 function get_required_javascript()
 {
     global $CFG;
     user_preference_allow_ajax_update('docked_block_instance_' . $this->instance->id, PARAM_INT);
     $this->page->requires->js_module('core_dock');
     $limit = 20;
     if (!empty($CFG->navcourselimit)) {
         $limit = $CFG->navcourselimit;
     }
     $expansionlimit = 0;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
     }
     $arguments = array('id' => $this->instance->id, 'instance' => $this->instance->id, 'candock' => $this->instance_can_be_docked(), 'courselimit' => $limit, 'expansionlimit' => $expansionlimit);
     $this->page->requires->string_for_js('viewallcourses', 'moodle');
     $this->page->requires->yui_module(array('core_dock', 'moodle-block_navigation-navigation'), 'M.block_navigation.init_add_tree', array($arguments));
 }
コード例 #24
0
ファイル: renderer.php プロジェクト: Jtgadbois/Pedadida
 /**
  * Adds the item in course settings navigation to toggle modchooser
  *
  * Theme can overwrite as an empty function to exclude it (for example if theme does not
  * use modchooser at all)
  */
 protected function add_modchoosertoggle()
 {
     global $CFG;
     static $modchoosertoggleadded = false;
     // Add the module chooser toggle to the course page
     if ($modchoosertoggleadded || $this->page->state > moodle_page::STATE_PRINTING_HEADER || $this->page->course->id == SITEID || !$this->page->user_is_editing() || !($context = context_course::instance($this->page->course->id)) || !has_capability('moodle/course:update', $context) || !course_ajax_enabled($this->page->course) || !($coursenode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) || !$coursenode->get('editsettings')) {
         // too late or we are on site page or we could not find the course settings node
         // or we are not allowed to edit
         return;
     }
     $modchoosertoggleadded = true;
     if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         // We are on the course page, retain the current page params e.g. section.
         $modchoosertoggleurl = clone $this->page->url;
     } else {
         // Edit on the main course page.
         $modchoosertoggleurl = new moodle_url('/course/view.php', array('id' => $this->page->course->id, 'return' => $this->page->url->out_as_local_url(false)));
     }
     $modchoosertoggleurl->param('sesskey', sesskey());
     if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
         $modchoosertogglestring = get_string('modchooserdisable', 'moodle');
         $modchoosertoggleurl->param('modchooser', 'off');
     } else {
         $modchoosertogglestring = get_string('modchooserenable', 'moodle');
         $modchoosertoggleurl->param('modchooser', 'on');
     }
     $modchoosertoggle = navigation_node::create($modchoosertogglestring, $modchoosertoggleurl, navigation_node::TYPE_SETTING);
     $coursenode->add_node($modchoosertoggle, 'editsettings');
     $modchoosertoggle->add_class('modchoosertoggle');
     $modchoosertoggle->add_class('visibleifjs');
     user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
 }
コード例 #25
0
 * @package    course/format
 * @subpackage collblct
 * @version    See the value of '$plugin->version' in below.
 * @copyright  &copy; 2014-onwards G J Barnard in respect to modifications of standard topics format.
 * @author     G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
 * @link       http://docs.moodle.org/en/Collapsed_Topics_course_format
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 *
 */
defined('MOODLE_INTERNAL') || die;
require_once $CFG->dirroot . '/course/format/collblct/togglelib.php';
$run = false;
if ($run) {
    // TEST CODE.
    for ($i = 0; $i < 64; $i++) {
        user_preference_allow_ajax_update('collblct_toggle_a' . $i . '_' . $course->id, PARAM_collblct);
        user_preference_allow_ajax_update('collblct_toggle_b' . $i . '_' . $course->id, PARAM_collblct);
        user_preference_allow_ajax_update('collblct_toggle_c' . $i . '_' . $course->id, PARAM_collblct);
    }
    user_preference_allow_ajax_update('collblct_toggle_bf_' . $course->id, PARAM_collblct);
    user_preference_allow_ajax_update('collblct_toggle_bf2_' . $course->id, PARAM_collblct);
    user_preference_allow_ajax_update('collblct_toggle_bf3_' . $course->id, PARAM_collblct);
    user_preference_allow_ajax_update('collblct_toggle_af_' . $course->id, PARAM_collblct);
    user_preference_allow_ajax_update('collblct_toggle_af2_' . $course->id, PARAM_collblct);
    user_preference_allow_ajax_update('collblct_toggle_af3_' . $course->id, PARAM_collblct);
    // Test clean_param to see if it accepts '<' and '>' for PARAM_TEXT as stated in moodlelib.php.
    echo '<h3>PARAM_TEXT < : ' . clean_param('<', PARAM_TEXT) . '</h3>';
    echo '<h3>PARAM_TEXT > : ' . clean_param('>', PARAM_TEXT) . '</h3>';
    echo '<h3>PARAM_RAW  < : ' . clean_param('<', PARAM_RAW) . '</h3>';
    echo '<h3>PARAM_RAW  > : ' . clean_param('>', PARAM_RAW) . '</h3>';
}
コード例 #26
0
ファイル: toolbox.php プロジェクト: syedhameed/sc
 /**
  * Adds the JavaScript for the colour switcher to the page.
  *
  * The colour switcher is a YUI moodle module that is located in
  *     theme/udemspl/yui/udemspl/udemspl.js
  *
  * @param moodle_page $page
  */
 static public function initialise_colourswitcher(\moodle_page $page) {
     self::check_colours_switch();
     \user_preference_allow_ajax_update('theme_essential_colours', PARAM_ALPHANUM);
     $page->requires->yui_module(
             'moodle-theme_essential-coloursswitcher', 'M.theme_essential.initColoursSwitcher',
             array(array('div' => '.dropdown-menu'))
     );
 }
コード例 #27
0
ファイル: lib.php プロジェクト: nmicha/moodle
 private function option_checkbox($name, $on, $label)
 {
     if ($on) {
         $checked = ' checked="checked"';
     } else {
         $checked = '';
     }
     $name = 'userselector_' . $name;
     $output = '<p><input type="hidden" name="' . $name . '" value="0" />' . '<input type="checkbox" id="' . $name . 'id" name="' . $name . '" value="1"' . $checked . ' /> ' . '<label for="' . $name . 'id">' . $label . "</label></p>\n";
     user_preference_allow_ajax_update($name, PARAM_BOOL);
     return $output;
 }
コード例 #28
0
ファイル: renderer.php プロジェクト: rushi963/moodle
 /**
  * Adds the item in course settings navigation to toggle modchooser
  *
  * Theme can overwrite as an empty function to exclude it (for example if theme does not
  * use modchooser at all)
  */
 protected function add_modchoosertoggle()
 {
     global $CFG;
     // Only needs to be done once per page.
     if (!$this->page->requires->should_create_one_time_item_now('core_course_modchoosertoggle')) {
         return;
     }
     if ($this->page->state > moodle_page::STATE_PRINTING_HEADER || $this->page->course->id == SITEID || !$this->page->user_is_editing() || !($context = context_course::instance($this->page->course->id)) || !has_capability('moodle/course:manageactivities', $context) || !course_ajax_enabled($this->page->course) || !($coursenode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) || !($turneditingnode = $coursenode->get('turneditingonoff'))) {
         // Too late, or we are on site page, or we could not find the
         // adjacent nodes in course settings menu, or we are not allowed to edit.
         return;
     }
     if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         // We are on the course page, retain the current page params e.g. section.
         $modchoosertoggleurl = clone $this->page->url;
     } else {
         // Edit on the main course page.
         $modchoosertoggleurl = new moodle_url('/course/view.php', array('id' => $this->page->course->id, 'return' => $this->page->url->out_as_local_url(false)));
     }
     $modchoosertoggleurl->param('sesskey', sesskey());
     if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
         $modchoosertogglestring = get_string('modchooserdisable', 'moodle');
         $modchoosertoggleurl->param('modchooser', 'off');
     } else {
         $modchoosertogglestring = get_string('modchooserenable', 'moodle');
         $modchoosertoggleurl->param('modchooser', 'on');
     }
     $modchoosertoggle = navigation_node::create($modchoosertogglestring, $modchoosertoggleurl, navigation_node::TYPE_SETTING, null, 'modchoosertoggle');
     // Insert the modchoosertoggle after the settings node 'turneditingonoff' (navigation_node only has function to insert before, so we insert before and then swap).
     $coursenode->add_node($modchoosertoggle, 'turneditingonoff');
     $turneditingnode->remove();
     $coursenode->add_node($turneditingnode, 'modchoosertoggle');
     $modchoosertoggle->add_class('modchoosertoggle');
     $modchoosertoggle->add_class('visibleifjs');
     user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
 }
コード例 #29
0
 /**
  * This function loads the course settings that are available for the user
  *
  * @param bool $forceopen If set to true the course node will be forced open
  * @return navigation_node|false
  */
 protected function load_course_settings($forceopen = false)
 {
     global $CFG;
     $course = $this->page->course;
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
     // note: do not test if enrolled or viewing here because we need the enrol link in Course administration section
     $coursenode = $this->add(get_string('courseadministration'), null, self::TYPE_COURSE, null, 'courseadmin');
     if ($forceopen) {
         $coursenode->force_open();
     }
     if (has_capability('moodle/course:update', $coursecontext)) {
         // Add the turn on/off settings
         if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
             // We are on the course page, retain the current page params e.g. section.
             $baseurl = clone $this->page->url;
             $baseurl->param('sesskey', sesskey());
         } else {
             // Edit on the main course page.
             $baseurl = new moodle_url('/course/view.php', array('id' => $course->id, 'return' => $this->page->url->out_as_local_url(false), 'sesskey' => sesskey()));
         }
         $editurl = clone $baseurl;
         if ($this->page->user_is_editing()) {
             $editurl->param('edit', 'off');
             $editstring = get_string('turneditingoff');
         } else {
             $editurl->param('edit', 'on');
             $editstring = get_string('turneditingon');
         }
         $coursenode->add($editstring, $editurl, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
         // Add the module chooser toggle
         $modchoosertoggleurl = clone $baseurl;
         if ($this->page->user_is_editing() && course_ajax_enabled($course)) {
             if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
                 $modchoosertogglestring = get_string('modchooserdisable', 'moodle');
                 $modchoosertoggleurl->param('modchooser', 'off');
             } else {
                 $modchoosertogglestring = get_string('modchooserenable', 'moodle');
                 $modchoosertoggleurl->param('modchooser', 'on');
             }
             $modchoosertoggle = $coursenode->add($modchoosertogglestring, $modchoosertoggleurl, self::TYPE_SETTING);
             $modchoosertoggle->add_class('modchoosertoggle');
             $modchoosertoggle->add_class('visibleifjs');
             user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
         }
         if ($this->page->user_is_editing()) {
             // Removed as per MDL-22732
             // $this->add_course_editing_links($course);
         }
         // Add the course settings link
         $url = new moodle_url('/course/edit.php', array('id' => $course->id));
         $coursenode->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
         // Add the course completion settings link
         if ($CFG->enablecompletion && $course->enablecompletion) {
             $url = new moodle_url('/course/completion.php', array('id' => $course->id));
             $coursenode->add(get_string('completion', 'completion'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
         }
     }
     // add enrol nodes
     enrol_add_course_navigation($coursenode, $course);
     // Manage filters
     if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
         $url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
     }
     // Add view grade report is permitted
     $reportavailable = false;
     if (has_capability('moodle/grade:viewall', $coursecontext)) {
         $reportavailable = true;
     } else {
         if (!empty($course->showgrades)) {
             $reports = get_plugin_list('gradereport');
             if (is_array($reports) && count($reports) > 0) {
                 // Get all installed reports
                 arsort($reports);
                 // user is last, we want to test it first
                 foreach ($reports as $plugin => $plugindir) {
                     if (has_capability('gradereport/' . $plugin . ':view', $coursecontext)) {
                         //stop when the first visible plugin is found
                         $reportavailable = true;
                         break;
                     }
                 }
             }
         }
     }
     if ($reportavailable) {
         $url = new moodle_url('/grade/report/index.php', array('id' => $course->id));
         $gradenode = $coursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, 'grades', new pix_icon('i/grades', ''));
     }
     //  Add outcome if permitted
     if (!empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $coursecontext)) {
         $url = new moodle_url('/grade/edit/outcome/course.php', array('id' => $course->id));
         $coursenode->add(get_string('outcomes', 'grades'), $url, self::TYPE_SETTING, null, 'outcomes', new pix_icon('i/outcomes', ''));
     }
     // Backup this course
     if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
         $url = new moodle_url('/backup/backup.php', array('id' => $course->id));
         $coursenode->add(get_string('backup'), $url, self::TYPE_SETTING, null, 'backup', new pix_icon('i/backup', ''));
     }
     // Restore to this course
     if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
         $url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('restore'), $url, self::TYPE_SETTING, null, 'restore', new pix_icon('i/restore', ''));
     }
     // Import data from other courses
     if (has_capability('moodle/restore:restoretargetimport', $coursecontext)) {
         $url = new moodle_url('/backup/import.php', array('id' => $course->id));
         $coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, 'import', new pix_icon('i/restore', ''));
     }
     // Publish course on a hub
     if (has_capability('moodle/course:publish', $coursecontext)) {
         $url = new moodle_url('/course/publish/index.php', array('id' => $course->id));
         $coursenode->add(get_string('publish'), $url, self::TYPE_SETTING, null, 'publish', new pix_icon('i/publish', ''));
     }
     // Reset this course
     if (has_capability('moodle/course:reset', $coursecontext)) {
         $url = new moodle_url('/course/reset.php', array('id' => $course->id));
         $coursenode->add(get_string('reset'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/return', ''));
     }
     // Questions
     require_once $CFG->libdir . '/questionlib.php';
     question_extend_settings_navigation($coursenode, $coursecontext)->trim_if_empty();
     if (has_capability('moodle/course:update', $coursecontext)) {
         // Repository Instances
         if (!$this->cache->cached('contexthasrepos' . $coursecontext->id)) {
             require_once $CFG->dirroot . '/repository/lib.php';
             $editabletypes = repository::get_editable_types($coursecontext);
             $haseditabletypes = !empty($editabletypes);
             unset($editabletypes);
             $this->cache->set('contexthasrepos' . $coursecontext->id, $haseditabletypes);
         } else {
             $haseditabletypes = $this->cache->{'contexthasrepos' . $coursecontext->id};
         }
         if ($haseditabletypes) {
             $url = new moodle_url('/repository/manage_instances.php', array('contextid' => $coursecontext->id));
             $coursenode->add(get_string('repositories'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/repository', ''));
         }
     }
     // Manage files
     if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $coursecontext)) {
         // hidden in new courses and courses where legacy files were turned off
         $url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('courselegacyfiles'), $url, self::TYPE_SETTING, null, 'coursefiles', new pix_icon('i/files', ''));
     }
     // Switch roles
     $roles = array();
     $assumedrole = $this->in_alternative_role();
     if ($assumedrole !== false) {
         $roles[0] = get_string('switchrolereturn');
     }
     if (has_capability('moodle/role:switchroles', $coursecontext)) {
         $availableroles = get_switchable_roles($coursecontext);
         if (is_array($availableroles)) {
             foreach ($availableroles as $key => $role) {
                 if ($assumedrole == (int) $key) {
                     continue;
                 }
                 $roles[$key] = $role;
             }
         }
     }
     if (is_array($roles) && count($roles) > 0) {
         $switchroles = $this->add(get_string('switchroleto'));
         if (count($roles) == 1 && array_key_exists(0, $roles) || $assumedrole !== false) {
             $switchroles->force_open();
         }
         $returnurl = $this->page->url;
         $returnurl->param('sesskey', sesskey());
         foreach ($roles as $key => $name) {
             $url = new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => $key, 'returnurl' => $returnurl->out(false)));
             $switchroles->add($name, $url, self::TYPE_SETTING, null, $key, new pix_icon('i/roles', ''));
         }
     }
     // Return we are done
     return $coursenode;
 }
コード例 #30
0
ファイル: block_navigation.php プロジェクト: vuchannguyen/web
 function get_required_javascript()
 {
     global $CFG;
     user_preference_allow_ajax_update('docked_block_instance_' . $this->instance->id, PARAM_INT);
 }