本文整理汇总了PHP中url_get_final_display_type函数的典型用法代码示例。如果您正苦于以下问题:PHP url_get_final_display_type函数的具体用法?PHP url_get_final_display_type怎么用?PHP url_get_final_display_type使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_get_final_display_type函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: url_print_workaround
/**
* Print url info and link.
* @param object $url
* @param object $cm
* @param object $course
* @return does not return
*/
function url_print_workaround($url, $cm, $course)
{
global $OUTPUT;
url_print_header($url, $cm, $course);
url_print_heading($url, $cm, $course, true);
url_print_intro($url, $cm, $course, true);
$fullurl = url_get_full_url($url, $cm, $course);
$display = url_get_final_display_type($url);
if ($display == RESOURCELIB_DISPLAY_POPUP) {
$jsfullurl = addslashes_js($fullurl);
$options = empty($url->displayoptions) ? array() : unserialize($url->displayoptions);
$width = empty($options['popupwidth']) ? 620 : $options['popupwidth'];
$height = empty($options['popupheight']) ? 450 : $options['popupheight'];
$wh = "width={$width},height={$height},toolbar=no,location=no,menubar=no,copyhistory=no,status=no,directories=no,scrollbars=yes,resizable=yes";
$extra = "onclick=\"window.open('{$jsfullurl}', '', '{$wh}'); return false;\"";
} else {
if ($display == RESOURCELIB_DISPLAY_NEW) {
$extra = "onclick=\"this.target='_blank';\"";
} else {
$extra = '';
}
}
echo '<div class="urlworkaround">';
print_string('clicktoopen', 'url', "<a href=\"{$fullurl}\" {$extra}>{$fullurl}</a>");
echo '</div>';
echo $OUTPUT->footer();
die;
}
示例2: url_get_coursemodule_info
/**
* Given a course_module object, this function returns any
* "extra" information that may be needed when printing
* this activity in a course listing.
*
* See {@link get_array_of_activities()} in course/lib.php
*
* @param object $coursemodule
* @return object info
*/
function url_get_coursemodule_info($coursemodule)
{
global $CFG, $DB;
require_once "{$CFG->dirroot}/mod/url/locallib.php";
if (!($url = $DB->get_record('url', array('id' => $coursemodule->instance), 'id, name, display, displayoptions, externalurl, parameters, intro, introformat'))) {
return NULL;
}
$info = new cached_cm_info();
$info->name = $url->name;
//note: there should be a way to differentiate links from normal resources
$info->icon = url_guess_icon($url->externalurl);
$display = url_get_final_display_type($url);
if ($display == RESOURCELIB_DISPLAY_POPUP) {
$fullurl = "{$CFG->wwwroot}/mod/url/view.php?id={$coursemodule->id}&redirect=1";
$options = empty($url->displayoptions) ? array() : unserialize($url->displayoptions);
$width = empty($options['popupwidth']) ? 620 : $options['popupwidth'];
$height = empty($options['popupheight']) ? 450 : $options['popupheight'];
$wh = "width={$width},height={$height},toolbar=no,location=no,menubar=no,copyhistory=no,status=no,directories=no,scrollbars=yes,resizable=yes";
$info->onclick = "window.open('{$fullurl}', '', '{$wh}'); return false;";
} else {
if ($display == RESOURCELIB_DISPLAY_NEW) {
$fullurl = "{$CFG->wwwroot}/mod/url/view.php?id={$coursemodule->id}&redirect=1";
$info->onclick = "window.open('{$fullurl}'); return false;";
}
}
if ($coursemodule->showdescription) {
// Convert intro to html. Do not filter cached version, filters run at display time.
$info->content = format_module_intro('url', $url, $coursemodule->id, false);
}
return $info;
}
示例3: get_coursemodule_from_instance
$cm = get_coursemodule_from_instance('url', $url->id, $url->course, false, MUST_EXIST);
} else {
$cm = get_coursemodule_from_id('url', $id, 0, false, MUST_EXIST);
$url = $DB->get_record('url', array('id' => $cm->instance), '*', MUST_EXIST);
}
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/url:view', $context);
add_to_log($course->id, 'url', 'view', 'view.php?id=' . $cm->id, $url->id, $cm->id);
// Update 'viewed' state if required by completion system
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/url/view.php', array('id' => $cm->id));
if ($redirect) {
// coming from course page or url index page,
// the redirection is needed for completion tracking and logging
$fullurl = url_get_full_url($url, $cm, $course);
redirect(str_replace('&', '&', $fullurl));
}
switch (url_get_final_display_type($url)) {
case RESOURCELIB_DISPLAY_EMBED:
url_display_embed($url, $cm, $course);
break;
case RESOURCELIB_DISPLAY_FRAME:
url_display_frame($url, $cm, $course);
break;
default:
url_print_workaround($url, $cm, $course);
break;
}
示例4: url_get_coursemodule_info
/**
* Given a course_module object, this function returns any
* "extra" information that may be needed when printing
* this activity in a course listing.
*
* See {@link get_array_of_activities()} in course/lib.php
*
* @param object $coursemodule
* @return object info
*/
function url_get_coursemodule_info($coursemodule)
{
global $CFG, $DB;
require_once "{$CFG->dirroot}/mod/url/locallib.php";
if (!($url = $DB->get_record('url', array('id' => $coursemodule->instance), 'id, name, display, displayoptions, externalurl, parameters'))) {
return NULL;
}
$info = new object();
$info->name = $url->name;
//note: there should be a way to differentiate links from normal resources
$info->icon = url_guess_icon($url->externalurl);
$display = url_get_final_display_type($url);
if ($display == RESOURCELIB_DISPLAY_POPUP) {
$fullurl = "{$CFG->wwwroot}/mod/url/view.php?id={$coursemodule->id}&redirect=1";
$options = empty($url->displayoptions) ? array() : unserialize($url->displayoptions);
$width = empty($options['popupwidth']) ? 620 : $options['popupwidth'];
$height = empty($options['popupheight']) ? 450 : $options['popupheight'];
$wh = "width={$width},height={$height},toolbar=no,location=no,menubar=no,copyhistory=no,status=no,directories=no,scrollbars=yes,resizable=yes";
$info->extra = urlencode("onclick=\"window.open('{$fullurl}', '', '{$wh}'); return false;\"");
} else {
if ($display == RESOURCELIB_DISPLAY_NEW) {
$fullurl = "{$CFG->wwwroot}/mod/url/view.php?id={$coursemodule->id}&redirect=1";
$info->extra = urlencode("onclick=\"window.open('{$fullurl}'); return false;\"");
} else {
if ($display == RESOURCELIB_DISPLAY_OPEN) {
$fullurl = "{$CFG->wwwroot}/mod/url/view.php?id={$coursemodule->id}&redirect=1";
$info->extra = urlencode("onclick=\"window.location.href ='{$fullurl}';return false;\"");
}
}
}
return $info;
}
示例5: array
$PAGE->set_url('/mod/url/view.php', array('id' => $cm->id));
// Make sure URL exists before generating output - some older sites may contain empty urls
// Do not use PARAM_URL here, it is too strict and does not support general URIs!
$exturl = trim($url->externalurl);
if (empty($exturl) or $exturl === 'http://') {
url_print_header($url, $cm, $course);
url_print_heading($url, $cm, $course);
url_print_intro($url, $cm, $course);
notice(get_string('invalidstoredurl', 'url'), new moodle_url('/course/view.php', array('id'=>$cm->course)));
die;
}
unset($exturl);
$displaytype = url_get_final_display_type($url);
if ($displaytype == RESOURCELIB_DISPLAY_OPEN) {
// For 'open' links, we always redirect to the content - except if the user
// just chose 'save and display' from the form then that would be confusing
if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], 'modedit.php') === false) {
$redirect = true;
}
}
if ($redirect) {
// coming from course page or url index page,
// the redirection is needed for completion tracking and logging
$fullurl = str_replace('&', '&', url_get_full_url($url, $cm, $course));
if (!course_get_format($course)->has_view_page()) {
// If course format does not have a view page, add redirection delay with a link to the edit page.