예제 #1
0
/**
 * Returns general link or file embedding html.
 * @param string $fullurl
 * @param string $title
 * @param string $clicktoopen
 * @return string html
 */
function tab_embed_general($fullurl, $title, $clicktoopen, $mimetype)
{
    global $CFG, $PAGE;
    $iframe = false;
    $forcelink = false;
    // IE can not embed stuff properly if stored on different server.
    // That is why we use iframe instead, unfortunately this tag does not validate.
    // In xhtml strict mode.
    if ($mimetype === 'text/html' and core_useragent::check_browser_version('MSIE', 5)) {
        debugging("Detected IE", DEBUG_DEVELOPER);
        if (preg_match('(^https?://[^/]*)', $fullurl, $matches)) {
            debugging("Detected IE w/ http://", DEBUG_DEVELOPER);
            // Make sure we aren't redirecting to a moodle page.
            if (strpos($CFG->wwwroot, $matches[0]) !== 0) {
                $forcelink = true;
            } else {
                // If it is a moodle then embed as iframe.
                $iframe = true;
            }
        }
    }
    $idsuffix = md5($fullurl);
    // We force the link because IE doesn't support embedding web pages.
    if ($forcelink) {
        $clicktoopen = get_string('embed_fail_msg_ie', 'tab') . "<a href='{$fullurl}' target='_blank'>" . get_string('embed_fail_link_text', 'tab') . '</a>';
        $code = <<<EOT
<div class="resourcecontent resourcegeneral">
        {$clicktoopen}
</div>
EOT;
    } else {
        if ($iframe) {
            $code = <<<EOT
<div class="resourcecontent resourcegeneral">
  <iframe id="resourceobject_{$idsuffix}" src="{$fullurl}">
    {$clicktoopen}
  </iframe>
</div>
EOT;
        } else {
            $code = <<<EOT
<div class="resourcecontent resourcegeneral">
  <object id="resourceobject_{$idsuffix}" data="{$fullurl}" type="{$mimetype}">
    <param name="src" value="{$fullurl}" />
    {$clicktoopen}
  </object>
</div>
EOT;
        }
    }
    $PAGE->requires->js_init_call('M.mod_tab.init_maximised_embed', array("resourceobject_{$idsuffix}"), true);
    return $code;
}
예제 #2
0
 protected function can_use_drag_and_drop()
 {
     global $USER;
     $ie = core_useragent::check_browser_version('MSIE', 6.0);
     $ff = core_useragent::check_browser_version('Gecko', 20051106);
     $op = core_useragent::check_browser_version('Opera', 9.0);
     $sa = core_useragent::check_browser_version('Safari', 412);
     $ch = core_useragent::check_browser_version('Chrome', 6);
     if (!$ie && !$ff && !$op && !$sa && !$ch or !empty($USER->screenreader)) {
         return false;
     }
     return true;
 }
예제 #3
0
/**
 * Returns whether ajax is enabled/allowed or not.
 * @param array $browsers optional list of alowed browsers, empty means use default list
 * @return bool
 */
function ajaxenabled(array $browsers = null)
{
    global $CFG;
    if (!empty($browsers)) {
        $valid = false;
        foreach ($browsers as $brand => $version) {
            if (core_useragent::check_browser_version($brand, $version)) {
                $valid = true;
            }
        }
        if (!$valid) {
            return false;
        }
    }
    if (!empty($CFG->enableajax)) {
        return true;
    } else {
        return false;
    }
}
예제 #4
0
    }
}
echo '</select> <input type="submit" value="' . get_string('showsession', 'realtimequiz') . '" /></form></center>';
if ($CFG->version < 2013111800) {
    $tickimg = '<img src="' . $OUTPUT->pix_url('i/tick_green_big') . '" alt="' . get_string('tick', 'realtimequiz') . '" />';
    $crossimg = '<img src="' . $OUTPUT->pix_url('i/cross_red_big') . '" alt="' . get_string('cross', 'realtimequiz') . '" />';
} else {
    $tickimg = '<img src="' . $OUTPUT->pix_url('i/grade_correct') . '" alt="' . get_string('tick', 'realtimequiz') . '" />';
    $crossimg = '<img src="' . $OUTPUT->pix_url('i/grade_incorrect') . '" alt="' . get_string('cross', 'realtimequiz') . '" />';
}
if ($questionid == 0) {
    // Show all of the questions
    if ($CFG->version < 2013111800) {
        $isff = check_browser_version('Gecko');
    } else {
        $isff = core_useragent::check_browser_version('Gecko');
    }
    if ($isff) {
        $blankcolspan = 'colspan="999" ';
    } else {
        $blankcolspan = '';
    }
    $questions = $DB->get_records('realtimequiz_question', array('quizid' => $realtimequiz->id), 'questionnum');
    $linkurl = new moodle_url('/mod/realtimequiz/responses.php', array('id' => $cm->id, 'showsession' => $showsession));
    if ($showusers) {
        $linkurl->param('showusers', 1);
        if ($CFG->version < 2013111800) {
            $usernames = 'u.firstname, u.lastname';
        } else {
            $usernames = get_all_user_name_fields(true, 'u');
        }
예제 #5
0
/**
 * Checks to see if is a browser matches the specified
 * brand and is equal or better version.
 *
 * @deprecated since 2.6
 * @param string $brand The browser identifier being tested
 * @param int $version The version of the browser, if not specified any version (except 5.5 for IE for BC reasons)
 * @return bool true if the given version is below that of the detected browser
 */
function check_browser_version($brand, $version = null)
{
    debugging('check_browser_version has been deprecated, please update your code to use core_useragent instead.', DEBUG_DEVELOPER);
    return core_useragent::check_browser_version($brand, $version);
}
예제 #6
0
/**
 * Returns general link or file embedding html.
 *
 * @param string $fullurl
 * @param string $clicktoopen
 * @param string $mimetype
 * @return string html
 */
function equella_embed_general($equella)
{
    global $CFG, $PAGE;
    if ($CFG->equella_enable_lti) {
        $launchurl = new moodle_url('/mod/equella/ltilaunch.php', array('cmid' => $equella->cmid, 'action' => 'view'));
        $url = $launchurl->out();
    } else {
        $url = equella_appendtoken($equella->url);
    }
    $link = html_writer::tag('a', $equella->name, array('href' => str_replace('&amp;', '&', $url)));
    $clicktoopen = get_string('clicktoopen', 'equella', $link);
    $iframe = false;
    // IE can not embed stuff properly, that is why we use iframe instead.
    // Unfortunately this tag does not validate in xhtml strict mode,
    // but in any case it is undeprecated in HTML 5 - we will use it everywhere soon!
    $ie5 = false;
    $vendor = 'MSIE';
    $version = 5;
    if (method_exists('core_useragent', 'check_browser_version')) {
        $ie5 = core_useragent::check_browser_version($vendor, $version);
    } else {
        $ie5 = check_browser_version($vendor, $version);
    }
    if ($ie5 || $CFG->equella_enable_lti) {
        $iframe = true;
    }
    if ($iframe) {
        $code = <<<EOT
<div class="resourcecontent resourcegeneral">
  <iframe id="resourceobject" src="{$url}">
    {$clicktoopen}
  </iframe>
</div>
EOT;
    } else {
        $param = '<param name="src" value="' . $url . '" />';
        $code = <<<EOT
<div class="resourcecontent resourcegeneral">
  <object id="resourceobject" data="{$url}" width="800" height="600">
    {$param}
    {$clicktoopen}
  </object>
</div>
EOT;
    }
    // the size is hardcoded in the object above intentionally because it is adjusted by the following function on-the-fly
    $PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);
    return $code;
}
예제 #7
0
 /**
  * Get the user dashboard report view.
  *
  * @uses $CFG
  * @uses $OUTPUT
  * @param none
  * @return string The HTML for the dashboard report.
  * @todo move out of this class
  */
 function get_dashboard()
 {
     global $CFG, $OUTPUT, $DB, $PAGE;
     require_once elispm::lib('data/curriculumstudent.class.php');
     $content = '';
     $archive_var = '_elis_program_archive';
     if (optional_param('tab', '', PARAM_CLEAN) == 'archivedlp') {
         $tab = 'archivedlp';
         $show_archived = 1;
     } else {
         $tab = 'currentlp';
         $show_archived = 0;
     }
     //obtain all of our core program-specific data
     list($usercurs, $curriculas, $classids, $totalcurricula, $completecoursesmap, $totalcoursesmap) = $this->get_dashboard_program_data(true, $show_archived);
     // Show different css for IE below version 8
     if (core_useragent::check_browser_version('MSIE', 7.0) && !core_useragent::check_browser_version('MSIE', 8.0)) {
         // IEs that are lower than version 8 do not get the float because it messes up the tabs at the top of the page for some reason
         $float_style = 'text-align:right;';
     } else {
         // Sane browsers get the float tag
         $float_style = 'text-align:right; float:right;';
     }
     // Tab header
     $field_exists = field::get_for_context_level_with_name('curriculum', $archive_var);
     if (!empty($field_exists)) {
         $tabrow = array();
         $tabrow[] = new tabobject('currentlp', $CFG->wwwroot . '/local/elisprogram/index.php?tab=currentlp', get_string('tab_current_learning_plans', 'local_elisprogram'));
         $tabrow[] = new tabobject('archivedlp', $CFG->wwwroot . '/local/elisprogram/index.php?tab=archivedlp', get_string('tab_archived_learning_plans', 'local_elisprogram'));
         $tabrows = array($tabrow);
         print_tabs($tabrows, $tab);
     }
     $content .= $OUTPUT->heading(get_string('learningplanwelcome', 'local_elisprogram', $this->moodle_fullname()));
     if ($totalcurricula === 0) {
         // ELIS-3615 was: if ($totalcourses === 0)
         $blank_lang = $tab == 'archivedlp' ? 'noarchivedplan' : 'nolearningplan';
         $content .= '<br /><center>' . get_string($blank_lang, 'local_elisprogram') . '</center>';
     }
     // Load the user preferences for hide/show button states
     if ($collapsed = get_user_preferences('crlm_learningplan_collapsed_curricula')) {
         $collapsed_array = explode(',', $collapsed);
     } else {
         $collapsed = '';
         $collapsed_array = array();
     }
     //use a div to track which programs have completed elements displayed
     $content .= '<input type="hidden" name="displayedcompleted" id="displayedcompleted" value="">';
     $content .= '<input type="hidden" name="collapsed" id="collapsed" value="' . $collapsed . '">';
     //determine whether we are allow students to view completed courses
     //(value default to enabled)
     $allow_show_completed = !isset(elis::$config->local_elisprogram->display_completed_courses) || !empty(elis::$config->local_elisprogram->display_completed_courses);
     if (!empty($usercurs)) {
         foreach ($usercurs as $usercur) {
             if (!isset($curriculas[$usercur->curid])) {
                 continue;
             }
             $curricula = $curriculas[$usercur->curid];
             //convert our data to an output table
             $table = $this->get_dashboard_program_table($curricula);
             $curricula_name = empty(elis::$config->local_elisprogram->disablecoursecatalog) ? '<a href="index.php?s=crscat&section=curr&showcurid=' . $curricula['id'] . '">' . $curricula['name'] . '</a>' : $curricula['name'];
             $header_curr_name = get_string('learningplanname', 'local_elisprogram', $curricula_name);
             //only show toggle if enabled via PM config
             if ($allow_show_completed) {
                 //do not display toggle button if program is hidden
                 $displayed = in_array($curricula['id'], $collapsed_array) ? 'false' : 'true';
                 //grey out toggle button if there are not hidden courses
                 $enabled = $completecoursesmap[$curricula['id']] > 0 ? 'true' : 'false';
                 // Javascript code for toggling display of completed courses
                 $PAGE->requires->yui_module('moodle-local_elisprogram-dashboard', 'M.local_elisprogram.init_togglecomplete', array(array('addbefore' => 'curriculum' . $curricula['id'] . 'script', 'nameattr' => 'curriculum-' . $curricula['id'] . 'completedbutton', 'buttonlabel' => get_string('showcompletedcourses', 'local_elisprogram'), 'hidetext' => get_string('hidecompletedcourses', 'local_elisprogram'), 'showtext' => get_string('showcompletedcourses', 'local_elisprogram'), 'element' => 'curriculum-' . $curricula['id'], 'displayed' => $displayed, 'enabled' => $enabled, 'wwwroot' => $CFG->wwwroot, 'currid' => $curricula['id'])));
             }
             if (in_array($curricula['id'], $collapsed_array)) {
                 $button_label = get_string('showcourses', 'local_elisprogram');
                 $extra_class = ' hide';
             } else {
                 $button_label = get_string('hidecourses', 'local_elisprogram');
                 $extra_class = '';
             }
             $PAGE->requires->yui_module('moodle-local_elisprogram-dashboard', 'M.local_elisprogram.init_togglevisibleinitstate', array(array('addbefore' => 'curriculum' . $curricula['id'] . 'script', 'nameattr' => 'curriculum' . $curricula['id'] . 'button', 'buttonlabel' => $button_label, 'hidetext' => get_string('hidecourses', 'local_elisprogram'), 'showtext' => get_string('showcourses', 'local_elisprogram'), 'element' => 'curriculum-' . $curricula['id'], 'wwwroot' => $CFG->wwwroot)));
             $heading = '<div class="clearfix"></div>' . '<div style="' . $float_style . '"><div id="curriculum' . $curricula['id'] . 'script"></div></div>' . $header_curr_name;
             $content .= '<div class="dashboard_curricula_block">';
             $content .= $OUTPUT->heading($heading);
             $content .= '<div id="curriculum-' . $curricula['id'] . '" class="yui-skin-sam ' . $extra_class . '">';
             if (empty($curricula['data']) && $totalcoursesmap[$usercur->curid] == 0) {
                 //nothing in the table, and no completed courses are being hidden
                 $content .= $OUTPUT->box(get_string('nocoursedescassoc', 'local_elisprogram'));
             } else {
                 if (!empty($table->data)) {
                     //we are showing some data
                     $content .= html_writer::table($table);
                 }
                 //display the summary text
                 $completecourses = $completecoursesmap[$usercur->curid];
                 $totalcourses = $totalcoursesmap[$usercur->curid];
                 $content .= $this->get_dashboard_program_summary($completecourses, $totalcourses, $usercur->curid);
             }
             $content .= '</div>';
             $content .= '</div>';
         }
     }
     /// Completed non-curricula course data
     if ($tab != 'archivedlp') {
         //obtain all of our core non-program course data
         list($classes, $completecourses, $totalcourses) = $this->get_dashboard_nonprogram_data($classids);
         //if ($classes != false) {
         if ($totalcourses > 0) {
             //convert this data to a display table
             $table = $this->get_dashboard_nonprogram_table($classes);
             $header_curr_name = get_string('noncurriculacourses', 'local_elisprogram');
             //only show toggle if enabled via PM config
             if ($allow_show_completed) {
                 //do not display toggle button if non-program courses are hidden
                 $displayed = in_array('na', $collapsed_array) ? 'false' : 'true';
                 //grey out toggle button if no non-program courses are hidden
                 $enabled = $completecourses > 0 ? 'true' : 'false';
                 // Javascript code for toggling display of completed courses
                 $PAGE->requires->yui_module('moodle-local_elisprogram-dashboard', 'M.local_elisprogram.init_togglecomplete', array(array('addbefore' => 'noncurriculascript', 'nameattr' => 'noncurriculacompletedbutton', 'buttonlabel' => get_string('showcompletedcourses', 'local_elisprogram'), 'hidetext' => get_string('hidecompletedcourses', 'local_elisprogram'), 'showtext' => get_string('showcompletedcourses', 'local_elisprogram'), 'element' => 'curriculum-na', 'displayed' => $displayed, 'enabled' => $enabled, 'wwwroot' => $CFG->wwwroot, 'currid' => 'na')));
             }
             if (in_array('na', $collapsed_array)) {
                 $button_label = get_string('showcourses', 'local_elisprogram');
                 $extra_class = ' hide';
             } else {
                 $button_label = get_string('hidecourses', 'local_elisprogram');
                 $extra_class = '';
             }
             // Javascript code for toggling display of completed courses
             $PAGE->requires->yui_module('moodle-local_elisprogram-dashboard', 'M.local_elisprogram.init_togglevisibleinitstate', array(array('addbefore' => 'noncurriculascript', 'nameattr' => 'noncurriculabutton', 'buttonlabel' => $button_label, 'hidetext' => get_string('hidecourses', 'local_elisprogram'), 'showtext' => get_string('showcourses', 'local_elisprogram'), 'element' => 'curriculum-na', 'wwwroot' => $CFG->wwwroot)));
             $heading = '<div class="clearfix"></div>' . '<div style="' . $float_style . '"><div id="noncurriculascript"></div></div>' . $header_curr_name;
             $content .= '<div class="dashboard_curricula_block">';
             $content .= $OUTPUT->heading($heading);
             $content .= '<div id="curriculum-na" class="yui-skin-sam ' . $extra_class . '">';
             if (count($table->data) > 0) {
                 //we are showing some data
                 $content .= html_writer::table($table);
             }
             $content .= $this->get_dashboard_program_summary($completecourses, $totalcourses, false);
             $content .= '</div>';
             $content .= '</div>';
         }
     }
     return $content;
 }
예제 #8
0
/**
 * Sets up the editing lock
 *
 * @param object $lock
 * @param string $ouwiki
 */
function ouwiki_print_editlock($lock, $ouwiki)
{
    global $DB, $PAGE;
    // Prepare the warning about lock without JS...
    $a = new StdClass();
    $a->now = userdate(time(), get_string('strftimetime'));
    $a->minutes = (int) (OUWIKI_LOCK_NOJS / 60);
    $a->deadline = userdate(time() + $a->minutes * 60, get_string('strftimetime'));
    $nojswarning = get_string('nojswarning', 'ouwiki', $a);
    $nojsstart = '<p class="ouw_nojswarning">';
    // Put in the AJAX for keeping the lock, if on a supported browser
    $ie = core_useragent::check_browser_version('MSIE', 6.0);
    $ff = core_useragent::check_browser_version('Gecko', 20051106);
    $op = core_useragent::check_browser_version('Opera', 9.0);
    $sa = core_useragent::check_browser_version('Safari', 412);
    $ch = core_useragent::check_browser_version('Chrome', 14);
    $js = $ie || $ff || $op || $sa || $ch;
    if ($js) {
        $nojsdisabled = get_string('nojsdisabled', 'ouwiki');
        $nojs = $nojsstart . $nojsdisabled . ' ' . $nojswarning . '<img src="nojslock.php?lockid=' . $lock->id . '" alt=""/></p>';
        $strlockcancelled = ouwiki_javascript_escape(get_string('lockcancelled', 'ouwiki'));
        $intervalms = OUWIKI_LOCK_RECONFIRM * 1000;
        $timeoutscript = '';
        if ($ouwiki->timeout) {
            $countdownurgent = ouwiki_javascript_escape(get_string('countdownurgent', 'ouwiki'));
            $timeoutscript = "var ouw_countdownto = (new Date()).getTime()+1000*{$ouwiki->timeout};\n                    var ouw_countdowninterval=setInterval(function() {\n                    var countdown=document.getElementById('ouw_countdown');\n                    var timeleft=ouw_countdownto-(new Date().getTime());\n                    if (timeleft < 0) {\n                        clearInterval(ouw_countdowninterval);\n                        document.forms['mform1'].elements['save'].click();\n                        return;\n                    }\n                    if(timeleft<2*60*1000) {\n                        var urgent=document.getElementById('ouw_countdownurgent');\n                        if(!urgent.firstChild) {\n                            urgent.appendChild(document.createTextNode(\"" . $countdownurgent . "\"));\n                            countdown.style.fontWeight='bold';\n                            countdown.style.color='red';\n                        }\n                    }\n                    var minutes=Math.floor(timeleft/(60*1000));\n                    var seconds=Math.floor(timeleft/1000) - minutes*60;\n                    var text=minutes+':';\n                    if(seconds<10) text+='0';\n                    text+=seconds;\n                    while(countdown.firstChild) {\n                        countdown.removeChild(countdown.firstChild);\n                    }\n                    countdown.appendChild(document.createTextNode(text));\n                },500);\n            ";
        }
        print "<script type='text/javascript'>\n            var intervalID;\n            function handleResponse(id, o) {\n                if (o.responseText=='cancel') {\n                    document.forms['mform1'].elements['preview'].disabled=true;\n                    document.forms['mform1'].elements['save'].disabled=true;\n                    clearInterval(intervalID);\n                    alert(\"{$strlockcancelled}\");\n                }\n            }\n            function handleFailure(o) {\n                // Ignore for now\n            }\n            intervalID=setInterval(function() {\n                var cfg = {\n                    method: 'POST',\n                    data: 'lockid={$lock->id}',\n                    on: {\n                        success: handleResponse,\n                        failure: handleFailure\n                    }\n                };\n                Y.io('confirmlock.php', cfg);\n            }, {$intervalms});\n            {$timeoutscript}\n            </script>\n            <noscript>\n            {$nojs}\n            </noscript>\n        ";
    } else {
        // If they have a non-supported browser, update the lock time right now without
        // going through the dodgy image method, to reserve their 15-minute slot.
        // (This means it will work for Lynx, for instance.)
        print $nojsstart . get_string('nojsbrowser', 'ouwiki') . ' ' . $nojswarning . '.</p>';
        $lock->seenat = time() + OUWIKI_LOCK_NOJS;
        $DB->update_record('ouwiki_locks', $lock);
    }
}