本文整理汇总了PHP中get_file_url函数的典型用法代码示例。如果您正苦于以下问题:PHP get_file_url函数的具体用法?PHP get_file_url怎么用?PHP get_file_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_file_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: rss_get_url
/**
* This function returns the URL for the RSS XML file.
*
* @param int $contextid the course id
* @param int $userid the current user id
* @param string $componentname the name of the current component. For example "forum"
* @param string $additionalargs For modules, module instance id
* @return string the url of the RSS feed
*/
function rss_get_url($contextid, $userid, $componentname, $additionalargs)
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
$usertoken = rss_get_token($userid);
return get_file_url($contextid . '/' . $usertoken . '/' . $componentname . '/' . $additionalargs . '/rss.xml', null, 'rssfile');
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:16,代码来源:rsslib.php
示例2: picture_header
function picture_header()
{
if (project() && project()->type() == 'picture') {
echo theme()->js(array('src' => get_file_url('ex/plugin/picture/jquery.colorbox-min.js'))), "\n";
echo theme()->css(array('href' => get_file_url('ex/plugin/picture/colorbox.css'))), "\n";
}
}
开发者ID:Wanyor,项目名称:ProjectManager,代码行数:7,代码来源:run.php
示例3: page_edit_header_out
/**
* 增加后台编辑器所需的引用文件
*/
function page_edit_header_out()
{
theme()->header_add(theme()->css(array('href' => get_file_url("ex/kindeditor/themes/default/default.css"))));
theme()->header_add(theme()->js(array('src' => get_file_url("ex/kindeditor/kindeditor-min.js"))));
theme()->header_add(theme()->js(array('src' => get_file_url("ex/kindeditor/lang/zh_CN.js"))));
theme()->header_add(theme()->js(array('src' => get_file_url("js/jquery.form.js"))));
}
开发者ID:Wanyor,项目名称:ProjectManager,代码行数:10,代码来源:admin.php
示例4: blog_rss_print_link
function blog_rss_print_link($filtertype, $filterselect, $tagid = 0, $tooltiptext = '')
{
global $CFG, $USER;
if (empty($USER->id)) {
$userid = 1;
} else {
$userid = $USER->id;
}
switch ($filtertype) {
case 'site':
$path = SITEID . '/' . $userid . '/blog/site/' . SITEID;
break;
case 'course':
$path = $filterselect . '/' . $userid . '/blog/course/' . $filterselect;
break;
case 'group':
$path = SITEID . '/' . $userid . '/blog/group/' . $filterselect;
break;
case 'user':
$path = SITEID . '/' . $userid . '/blog/user/' . $filterselect;
break;
}
if ($tagid) {
$path .= '/' . $tagid;
}
$path .= '/rss.xml';
$rsspix = $CFG->pixpath . '/i/rss.gif';
require_once $CFG->libdir . '/filelib.php';
$path = get_file_url($path, null, 'rssfile');
print '<div class="mdl-right"><a href="' . $path . '"><img src="' . $rsspix . '" title="' . strip_tags($tooltiptext) . '" alt="' . get_string('rss') . '" /></a></div>';
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:31,代码来源:rsslib.php
示例5: sitemap_create
/**
* 生成网站地图信息
*/
function sitemap_create($out_message = false)
{
require_once __DIR__ . "/sitemap.php";
$sitemap = new \Plugin\SiteMap($out_message);
$sitemap->msg("准备生成网站地图,最大10M,最多5000条<br />当前内存消耗:<span class='text-danger'>" . sitemap_size(memory_get_usage()) . "</span>");
$sitemap->create();
$file = _BasePath_ . "/sitemap.xml";
$sitemap->write_file($file);
$sitemap->msg("生成文件大小: <span class='text-danger'>" . sitemap_size(filesize($file))) . "</span>";
$sitemap->msg("生成记录: <span class='text-danger'>" . $sitemap->count() . "</span> 条");
$sitemap->msg("地图地址: <a rel='external' class='text-warning' href='" . get_file_url('sitemap.xml') . "'>" . get_file_url('sitemap.xml') . "</a>");
$sitemap->msg("生成地图成功<br />当前内存消耗:<span class='text-danger'>" . sitemap_size(memory_get_usage()) . "</span>");
}
开发者ID:Wanyor,项目名称:ProjectManager,代码行数:16,代码来源:run.php
示例6: print_student_answer
function print_student_answer($userid, $return = false)
{
global $CFG, $USER;
$filearea = $this->file_area_name($userid);
$output = '';
if ($basedir = $this->file_area($userid)) {
if ($files = get_directory_list($basedir)) {
require_once $CFG->libdir . '/filelib.php';
foreach ($files as $key => $file) {
$icon = mimeinfo('icon', $file);
$ffurl = get_file_url("{$filearea}/{$file}");
//died right here
//require_once($ffurl);
$output = '<img align="middle" src="' . $CFG->pixpath . '/f/' . $icon . '" class="icon" alt="' . $icon . '" />' . '<a href="' . $ffurl . '" >' . $file . '</a><br />';
}
}
}
$output = '<div class="files">' . $output . '</div>';
return $output;
}
开发者ID:veritech,项目名称:pare-project,代码行数:20,代码来源:assignment.class.php
示例7: process_cdata
/**
* Provide NULL and legacy file.php uses decoding
*/
public function process_cdata($cdata)
{
global $CFG;
if ($cdata === '$@NULL@$') {
// Some cases we know we can skip complete processing
return null;
} else {
if ($cdata === '') {
return '';
} else {
if (is_numeric($cdata)) {
return $cdata;
} else {
if (strlen($cdata) < 32) {
// Impossible to have one link in 32cc
return $cdata;
// (http://10.0.0.1/file.php/1/1.jpg, http://10.0.0.1/mod/url/view.php?id=)
} else {
if (strpos($cdata, '$@FILEPHP@$') === false) {
// No $@FILEPHP@$, nothing to convert
return $cdata;
}
}
}
}
}
// Decode file.php calls
$search = array("\$@FILEPHP@\$");
$replace = array(get_file_url($this->courseid));
$result = str_replace($search, $replace, $cdata);
// Now $@SLASH@$ and $@FORCEDOWNLOAD@$ MDL-18799
$search = array('$@SLASH@$', '$@FORCEDOWNLOAD@$');
if ($CFG->slasharguments) {
$replace = array('/', '?forcedownload=1');
} else {
$replace = array('%2F', '&forcedownload=1');
}
return str_replace($search, $replace, $result);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:42,代码来源:restore_structure_parser_processor.class.php
示例8: get_rss_enclosure
function get_rss_enclosure($file_name, $image_type, $cat_id)
{
if (!get_file_path($file_name, $image_type, $cat_id, 0, 0)) {
return array();
}
$file = get_file_path($file_name, $image_type, $cat_id, 0, 1);
$url = get_file_url($file_name, $image_type, $cat_id);
return array('url' => $url, 'length' => @filesize($file), 'type' => get_mime_content_type($file));
}
开发者ID:4images,项目名称:4images,代码行数:9,代码来源:rss.php
示例9: error
<?php
include '../config.php';
//require_login();
/// Remove the following three lines if you want everyone to access it
//require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
if (!($users = get_records("user", "picture", "1", "lastaccess DESC", "id,firstname,lastname"))) {
error("no users!");
}
$title = get_string("users");
print_header($title, $title, build_navigation(array(array('name' => $title, 'link' => null, 'type' => 'misc'))));
foreach ($users as $user) {
$fullname = fullname($user);
echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&course=1\" " . "title=\"{$fullname}\">";
require_once $CFG->libdir . '/filelib.php';
$userpictureurl = get_file_url($user->id . '/f1.jpg', null, 'user');
echo '<img src="' . $userpictureurl . '"' . ' style="border:0px; width:100px; height:100px" alt="' . $fullname . '" />';
echo "</a> \n";
}
print_footer();
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:20,代码来源:faculty.php
示例10: blog_print_attachments
function blog_print_attachments($blogentry, $return = NULL)
{
// if return=html, then return a html string.
// if return=text, then return a text-only string.
// otherwise, print HTML for non-images, and return image HTML
global $CFG;
$filearea = blog_file_area_name($blogentry);
$imagereturn = "";
$output = "";
if ($basedir = blog_file_area($blogentry)) {
if ($files = get_directory_list($basedir)) {
$strattachment = get_string("attachment", "forum");
foreach ($files as $file) {
include_once $CFG->libdir . '/filelib.php';
$icon = mimeinfo("icon", $file);
$type = mimeinfo("type", $file);
$ffurl = get_file_url("{$filearea}/{$file}");
$image = "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"\" />";
if ($return == "html") {
$output .= "<a href=\"{$ffurl}\">{$image}</a> ";
$output .= "<a href=\"{$ffurl}\">{$file}</a><br />";
} else {
if ($return == "text") {
$output .= "{$strattachment} {$file}:\n{$ffurl}\n";
} else {
if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) {
// Image attachments don't get printed as links
$imagereturn .= "<br /><img src=\"{$ffurl}\" alt=\"\" />";
} else {
echo "<a href=\"{$ffurl}\">{$image}</a> ";
echo filter_text("<a href=\"{$ffurl}\">{$file}</a><br />");
}
}
}
}
}
}
if ($return) {
return $output;
}
return $imagereturn;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:42,代码来源:lib.php
示例11: display
//.........这里部分代码省略.........
$querystring = implode('&', $querysbits);
}
}
/// Set up some variables
$inpopup = optional_param('inpopup', 0, PARAM_BOOL);
if (resource_is_url($resource->reference)) {
$fullurl = $resource->reference;
if (!empty($querystring)) {
$urlpieces = parse_url($resource->reference);
if (empty($urlpieces['query']) or $isteamspeak) {
$fullurl .= '?' . $querystring;
} else {
$fullurl .= '&' . $querystring;
}
}
} else {
if ($CFG->resource_allowlocalfiles and strpos($resource->reference, RESOURCE_LOCALPATH) === 0) {
// Localpath
$localpath = get_user_preferences('resource_localpath', 'D:');
$relativeurl = str_replace(RESOURCE_LOCALPATH, $localpath, $resource->reference);
if ($querystring) {
$relativeurl .= '?' . $querystring;
}
$relativeurl = str_replace('\\', '/', $relativeurl);
$relativeurl = str_replace(' ', '%20', $relativeurl);
$fullurl = 'file:///' . htmlentities($relativeurl);
$localpath = true;
} else {
// Normal uploaded file
$forcedownloadsep = '?';
if ($resource->options == 'forcedownload') {
$querys['forcedownload'] = '1';
}
$fullurl = get_file_url($course->id . '/' . $resource->reference, $querys);
}
}
/// Print a notice and redirect if we are trying to access a file on a local file system
/// and the config setting has been disabled
if (!$CFG->resource_allowlocalfiles and strpos($resource->reference, RESOURCE_LOCALPATH) === 0) {
if ($inpopup) {
print_header($pagetitle, $course->fullname);
} else {
$navigation = build_navigation($this->navlinks, $cm);
print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
}
notify(get_string('notallowedlocalfileaccess', 'resource', ''));
if ($inpopup) {
close_window_button();
}
print_footer('none');
die;
}
/// Check whether this is supposed to be a popup, but was called directly
if ($resource->popup and !$inpopup) {
/// Make a page and a pop-up window
$navigation = build_navigation($this->navlinks, $cm);
print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
echo "\n<script type=\"text/javascript\">";
echo "\n<!--\n";
echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
echo "\n-->\n";
echo '</script>';
if (trim(strip_tags($resource->summary))) {
print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
}
$link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&id={$cm->id}\" " . "onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', " . "'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:67,代码来源:resource.class.php
示例12: display
function display()
{
global $CFG;
/// Set up generic stuff first, including checking for access
parent::display();
/// Set up some shorthand variables
$cm = $this->cm;
$course = $this->course;
$resource = $this->resource;
require_once $CFG->libdir . '/filelib.php';
$subdir = optional_param('subdir', '', PARAM_PATH);
$resource->reference = clean_param($resource->reference, PARAM_PATH);
$formatoptions = new object();
$formatoptions->noclean = true;
$formatoptions->para = false;
// MDL-12061, <p> in html editor breaks xhtml strict
add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
if ($resource->reference) {
$relativepath = "{$course->id}/{$resource->reference}";
} else {
$relativepath = "{$course->id}";
}
if ($subdir) {
$relativepath = "{$relativepath}{$subdir}";
if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) {
error("Access not allowed!");
}
$subs = explode('/', $subdir);
array_shift($subs);
$countsubs = count($subs);
$count = 0;
$backsub = '';
foreach ($subs as $sub) {
$count++;
if ($count < $countsubs) {
$backsub .= "/{$sub}";
$this->navlinks[] = array('name' => $sub, 'link' => "view.php?id={$cm->id}", 'type' => 'title');
} else {
$this->navlinks[] = array('name' => $sub, 'link' => '', 'type' => 'title');
}
}
}
$pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
$update = update_module_button($cm->id, $course->id, $this->strresource);
if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id))) {
$options = array('id' => $course->id, 'wdir' => '/' . $resource->reference . $subdir);
$editfiles = print_single_button("{$CFG->wwwroot}/files/index.php", $options, get_string("editfiles"), 'get', '', true);
$update = $editfiles . $update;
}
$navigation = build_navigation($this->navlinks, $cm);
print_header($pagetitle, $course->fullname, $navigation, "", "", true, $update, navmenu($course, $cm));
if (trim(strip_tags($resource->summary))) {
print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
print_spacer(10, 10);
}
$files = get_directory_list("{$CFG->dataroot}/{$relativepath}", array($CFG->moddata, 'backupdata'), false, true, true);
if (!$files) {
print_heading(get_string("nofilesyet"));
print_footer($course);
exit;
}
print_simple_box_start("center", "", "", '0');
$strftime = get_string('strftimedatetime');
$strname = get_string("name");
$strsize = get_string("size");
$strmodified = get_string("modified");
$strfolder = get_string("folder");
$strfile = get_string("file");
echo '<table cellpadding="4" cellspacing="1" class="files" summary="">';
echo "<tr><th class=\"header name\" scope=\"col\">{$strname}</th>" . "<th align=\"right\" colspan=\"2\" class=\"header size\" scope=\"col\">{$strsize}</th>" . "<th align=\"right\" class=\"header date\" scope=\"col\">{$strmodified}</th>" . "</tr>";
foreach ($files as $file) {
if (is_dir("{$CFG->dataroot}/{$relativepath}/{$file}")) {
// Must be a directory
$icon = "folder.gif";
$relativeurl = "/view.php?blah";
$filesize = display_size(get_directory_size("{$CFG->dataroot}/{$relativepath}/{$file}"));
} else {
$icon = mimeinfo("icon", $file);
$relativeurl = get_file_url("{$relativepath}/{$file}");
$filesize = display_size(filesize("{$CFG->dataroot}/{$relativepath}/{$file}"));
}
if ($icon == 'folder.gif') {
echo '<tr class="folder">';
echo '<td class="name">';
echo "<a href=\"view.php?id={$cm->id}&subdir={$subdir}/{$file}\">";
echo "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfolder}\" /> {$file}</a>";
} else {
echo '<tr class="file">';
echo '<td class="name">';
link_to_popup_window($relativeurl, "resourcedirectory{$resource->id}", "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfile}\" /> {$file}", 450, 600, '');
}
echo '</td>';
echo '<td> </td>';
echo '<td align="right" class="size">';
echo $filesize;
echo '</td>';
echo '<td align="right" class="date">';
echo userdate(filemtime("{$CFG->dataroot}/{$relativepath}/{$file}"), $strftime);
echo '</td>';
echo '</tr>';
//.........这里部分代码省略.........
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:101,代码来源:resource.class.php
示例13: get_baseurl
function get_baseurl()
{
// set the url base (first time only)
if (!isset($this->baseurl)) {
global $CFG;
require_once $CFG->libdir . '/filelib.php';
$this->baseurl = get_file_url($this->filedir) . '/';
}
return $this->baseurl;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:10,代码来源:lib.php
示例14: forum_print_attachments
/**
* if return=html, then return a html string.
* if return=text, then return a text-only string.
* otherwise, print HTML for non-images, and return image HTML
*/
function forum_print_attachments($post, $return = NULL)
{
global $CFG;
$filearea = forum_file_area_name($post);
$imagereturn = "";
$output = "";
if ($basedir = forum_file_area($post)) {
if ($files = get_directory_list($basedir)) {
$strattachment = get_string("attachment", "forum");
foreach ($files as $file) {
$icon = mimeinfo("icon", $file);
$type = mimeinfo("type", $file);
$ffurl = get_file_url("{$filearea}/{$file}");
$image = "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"\" />";
if ($return == "html") {
$output .= "<a href=\"{$ffurl}\">{$image}</a> ";
$output .= "<a href=\"{$ffurl}\">{$file}</a><br />";
} else {
if ($return == "text") {
$output .= "{$strattachment} {$file}:\n{$ffurl}\n";
} else {
if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) {
// Image attachments don't get printed as links
$imagereturn .= "<br /><img src=\"{$ffurl}\" alt=\"\" />";
} else {
echo "<a href=\"{$ffurl}\">{$image}</a> ";
echo filter_text("<a href=\"{$ffurl}\">{$file}</a><br />");
}
}
}
}
}
}
if ($return) {
return $output;
}
return $imagereturn;
}
开发者ID:r007,项目名称:PMoodle,代码行数:43,代码来源:lib.php
示例15: rss_get_url
function rss_get_url($courseid, $userid, $modulename, $id)
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
return get_file_url($courseid . '/' . $userid . '/' . $modulename . '/' . $id . '/rss.xml', null, 'rssfile');
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:6,代码来源:rsslib.php
示例16: readquestions
function readquestions($lines)
{
/// Parses an array of lines into an array of questions,
/// where each item is a question object as defined by
/// readquestion().
// set courseid and baseurl
global $CFG, $COURSE, $course;
switch (true) {
case isset($this->course->id):
// import to quiz module
$courseid = $this->course->id;
break;
case isset($course->id):
// import to lesson module
$courseid = $course->id;
break;
case isset($COURSE->id):
// last resort
$courseid = $COURSE->id;
break;
default:
// shouldn't happen !!
$courseid = 0;
}
require_once $CFG->libdir . '/filelib.php';
$baseurl = get_file_url($courseid) . '/';
// get import file name
global $params;
if (!empty($this->realfilename)) {
$filename = $this->realfilename;
} else {
if (isset($params) && !empty($params->choosefile)) {
// course file (Moodle >=1.6+)
$filename = $params->choosefile;
} else {
// uploaded file (all Moodles)
$filename = basename($_FILES['newfile']['tmp_name']);
}
}
// get hotpot file source
$source = implode($lines, " ");
$source = hotpot_convert_relative_urls($source, $baseurl, $filename);
// create xml tree for this hotpot
$xml = new hotpot_xml_tree($source);
// determine the quiz type
$xml->quiztype = '';
$keys = array_keys($xml->xml);
foreach ($keys as $key) {
if (preg_match('/^(hotpot|textoys)-(\\w+)-file$/i', $key, $matches)) {
$xml->quiztype = strtolower($matches[2]);
$xml->xml_root = "['{$key}']['#']";
break;
}
}
// convert xml to questions array
$questions = array();
switch ($xml->quiztype) {
case 'jcloze':
$this->process_jcloze($xml, $questions);
break;
case 'jcross':
$this->process_jcross($xml, $questions);
break;
case 'jmatch':
$this->process_jmatch($xml, $questions);
break;
case 'jmix':
$this->process_jmix($xml, $questions);
break;
case 'jbc':
case 'jquiz':
$this->process_jquiz($xml, $questions);
break;
default:
if (empty($xml->quiztype)) {
notice("Input file not recognized as a Hot Potatoes XML file");
} else {
notice("Unknown quiz type '{$xml->quiztype}'");
}
}
// end switch
if (count($questions)) {
return $questions;
} else {
if (method_exists($this, 'error')) {
// Moodle >= 1.8
$this->error(get_string('giftnovalidquestion', 'quiz'));
}
return false;
}
}
开发者ID:henriquecrang,项目名称:e-UNI,代码行数:91,代码来源:format.php
示例17: get_file_url
<input type="text" class="form-control" name="s[desc]" value="曾记否我们一切安好" id="I_desc">
</div>
<div class="form-group">
<label class="control-label" for="I_url">网站地址</label>
<input type="text" class="form-control" name="s[url]" value="<?php
echo get_file_url();
?>
" id="I_url">
<p class="help-block">注意:如果网站使用PATH_INFO的形式请在结尾处添加<code>index.php/</code>,如若修正指定文件请手动修改。</p>
</div>
<div class="form-group">
<label class="control-label" for="I_static_url">网站静态地址</label>
<input type="text" class="form-control" name="s[static_url]" value="<?php
echo get_file_url();
?>
" id="I_static_url">
</div>
<div class="form-group">
<label class="control-label" for="I_email">管理员邮箱</label>
<input type="text" class="form-control" name="s[email]" placeholder="你必须提交你的管理员邮箱" value="" id="I_email">
</div>
<hr>
<div class="form-group">
<label class="control-label" for="I_user">管理员账户</label>
<input type="text" class="form-control" name="u[name]" placeholder="你的用户名,最低6位" value="" id="I_user">
开发者ID:ttym7993,项目名称:Linger,代码行数:31,代码来源:setup3.php
示例18: extract_data
function extract_data($pages, $courseid, $lessonname, $modname)
{
// this function attempts to extract the content out of the slides
// the slides are ugly broken xml. and the xml is broken... yeah...
global $CFG;
global $matches;
$extratedpages = array();
// directory for images
make_mod_upload_directory($courseid);
// make sure moddata is made
make_upload_directory($courseid . '/moddata/' . $modname, false);
// we store our images in a subfolder in here
$imagedir = $CFG->dataroot . '/' . $courseid . '/moddata/' . $modname;
require_once $CFG->libdir . '/filelib.php';
$imagelink = get_file_url($courseid . '/moddata/' . $modname);
// try to make a unique subfolder to store the images
$lessonname = str_replace(' ', '_', $lessonname);
// get rid of spaces
$i = 0;
while (true) {
if (!file_exists($imagedir . '/' . $lessonname . $i)) {
// ok doesnt exist so make the directory and update our paths
mkdir($imagedir . '/' . $lessonname . $i);
$imagedir = $imagedir . '/' . $lessonname . $i;
$imagelink = $imagelink . '/' . $lessonname . $i;
break;
}
$i++;
}
foreach ($pages as $file => $content) {
// to make life easier on our preg_match_alls, we strip out all tags except
// for div and img (where our content is). We want div because sometimes we
// can identify the content in the div based on the div's class
$tags = '<div><img>';
// should also allow <b><i>
$string = strip_tags($content, $tags);
//echo s($string);
$matches = array();
// this will look for a non nested tag that is closed
// want to allow <b><i>(maybe more) tags but when we do that
// the preg_match messes up.
preg_match_all("/(<([\\w]+)[^>]*>)([^<\\2>]*)(<\\/\\2>)/", $string, $matches);
//(<([\w]+)[^>]*>)([^<\\2>]*)(<\/\\2>) original pattern
//(<(div+)[^>]*>)[^(<div*)](<\/div>) work in progress
$path_parts = pathinfo($file);
$file = substr($path_parts['basename'], 0, strpos($path_parts['basename'], '.'));
// get rid of the extension
$imgs = array();
// this preg matches all images
preg_match_all("/<img[^>]*(src\\=\"(" . $file . "\\_image[^>^\"]*)\"[^>]*)>/i", $string, $imgs);
// start building our page
$page = new stdClass();
$page->title = '';
$page->contents = array();
$page->images = array();
$page->source = $path_parts['basename'];
// need for book only
// this foreach keeps the style intact. Found it doesn't help much. But if you want back uncomment
// this foreach and uncomment the line with the comment imgstyle in it. Also need to comment out
// the $page->images[]... line in the next foreach
/*foreach ($imgs[1] as $img) {
$page->images[] = '<img '.str_replace('src="', "src=\"$imagelink/", $img).' />';
}*/
foreach ($imgs[2] as $img) {
copy($path_parts['dirname'] . '/' . $img, $imagedir . '/' . $img);
$page->images[] = "<img src=\"{$imagelink}/{$img}\" title=\"{$img}\" />";
// comment out this line if you are using the above foreach loop
}
for ($i = 0; $i < count($matches[1]); $i++) {
// go through all of our div matches
$class = isolate_class($matches[1][$i]);
// first step in isolating the class
// check for any static classes
switch ($class) {
case 'T':
// class T is used for Titles
$page->title = $matches[3][$i];
break;
case 'B':
// I would guess that all bullet lists would start with B then go to B1, B2, etc
// I would guess that all bullet lists would start with B then go to B1, B2, etc
case 'B1':
// B1-B4 are just insurance, should just hit B and all be taken care of
// B1-B4 are just insurance, should just hit B and all be taken care of
case 'B2':
case 'B3':
case 'B4':
$page->contents[] = build_list('<ul>', $i, 0);
// this is a recursive function that will grab all the bullets and rebuild the list in html
break;
default:
if ($matches[3][$i] != ' ') {
// odd crap generated... sigh
if (substr($matches[3][$i], 0, 1) == ':') {
// check for leading : ... hate MS ...
$page->contents[] = substr($matches[3][$i], 1);
// get rid of :
} else {
$page->contents[] = $matches[3][$i];
}
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:importppt.php
示例19: question_replace_file_links_in_html
function question_replace_file_links_in_html($html, $fromcourseid, $tocourseid, $url, $destination, &$changed)
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
$tourl = get_file_url("{$tocourseid}/{$destination}");
$fromurl = question_file_links_base_url($fromcourseid) . preg_quote($url, '!');
$searchfor = array('!(<\\s*(a|img)\\s[^>]*(href|src)\\s*=\\s*")' . $fromurl . '(")!i', '!(<\\s*(a|img)\\s[^>]*(href|src)\\s*=\\s*\')' . $fromurl . '(\')!i');
$newhtml = preg_replace($searchfor, '\\1' . $tourl . '\\5', $html);
if ($newhtml != $html) {
$changed = true;
}
return $newhtml;
}
开发者ID:e-rasvet,项目名称:reader,代码行数:13,代码来源:questionlib.php
示例20: qcn_trigger_detail
function qcn_trigger_detail(&$res, $bg_color, $auth, $user, $bDownloadAll)
{
global $unixtimeArchive;
if ($auth || $user->id == $res->hostid) {
$loc_res = 4;
} else {
$loc_res = 2;
}
// CMC took out hostnamebyid below
$sensor_type = $res->sensor_description;
$archpre = $res->is_archive ? "a" : "r";
// prefix to signify if it's an archive record or not
$file_url = get_file_url($res);
if ($auth) {
if ($bDownloadAll) {
echo "<input type=\"hidden\" name=\"cb_" . $archpre . "_dlfile[]\" id=\"cb_" . $archpre . "_dlfile[]\" value=\"{$res->triggerid}\"" . ">\n";
//echo "<tr><td><input type=\"hidden\" name=\"cb_" . $archpre . "_dlfile[]\" id=\"cb_" . $archpre . "_dlfile[]\" value=\"$res->triggerid\"" .
// "></font size></td></tr>\n";
return;
} else {
echo "\n <tr bgcolor=\"" . $bg_color . "\">\n";
echo "\n <td><font size=\"1\"><input type=\"checkbox\" name=\"cb_" . $archpre . "_reqfile[]\" id=\"cb_" . $archpre . "_reqfile[]\" value=\"{$res->triggerid}\"" . ($res->varietyid != 0 || $res->received_file == 100 || $res->trigger_timereq > 0 || $res->trigger_time < $unixtimeArchive ? " disabled " : " ") . "></font size></td>\n <td><font size=\"1\"><input type=\"checkbox\" name=\"cb_" . $archpre . "_dlfile[]\" id=\"cb_" . $archpre . "_dlfile[]\" value=\"{$res->triggerid}\"" . ($res->received_file != 100 || file_url == "N/A" ? " disabled " : ($bDownloadAll ? " checked " : " ")) . "></font size></td>";
}
}
echo "\n <td><font size=\"1\">{$res->triggerid}</font size></td>";
echo "<td><font size=\"1\"><a href=\"show_host_detail.php?hostid={$res->hostid}\">" . $res->hostid . "</a></font size></td>";
if ($auth) {
echo " <td><font size=\"1\">{$res->ipaddr}<br>{$res->hostname}</font size></td>";
}
// echo "<td><font size=\"1\">$res->result_name</font size></td>";
echo "\n <td><font size=\"1\">" . time_str($res->trigger_time) . "</font size></td>\n <td><font size=\"1\">" . round($res->delay_time, 2) . "</font size></td>\n <td><font size=\"1\">" . time_str($res->trigger_sync) . "</font size></td>\n <td><font size=\"1\">" . round($res->sync_offset, 2) . "</font size></td>\n <td><
|
请发表评论