当前位置: 首页>>代码示例>>PHP>>正文


PHP moodle_url::make_legacyfile_url方法代码示例

本文整理汇总了PHP中moodle_url::make_legacyfile_url方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url::make_legacyfile_url方法的具体用法?PHP moodle_url::make_legacyfile_url怎么用?PHP moodle_url::make_legacyfile_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moodle_url的用法示例。


在下文中一共展示了moodle_url::make_legacyfile_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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(moodle_url::make_legacyfile_url($this->courseid, null));
     $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', '&amp;forcedownload=1');
     }
     return str_replace($search, $replace, $result);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:42,代码来源:restore_structure_parser_processor.class.php

示例2: line_replace

 function line_replace($line)
 {
     // return line after various formatting replacements
     // have been made - order is vital to stop them interfering with each other
     global $CFG;
     // ---- (at least) means a <hr />
     // MARKDOWN: no change so leave
     // is this a list line (starts with * # ; :)
     if (preg_match("/^([*]+|[#]+|[;]+|[:]+) /i", $line)) {
         $line = $this->do_list($line);
     }
     // typographic conventions
     // MARKDOWN: no equiv. so convert to entity as before
     // $line = str_replace( "--", "&#8212;", $line );
     // $line = str_replace( " - ", " &#8211; ", $line );
     $line = str_replace("...", " &#8230; ", $line);
     $line = str_replace("(R)", "&#174;", $line);
     $line = str_replace("(r)", "&#174;", $line);
     $line = str_replace("(TM)", "&#8482;", $line);
     $line = str_replace("(tm)", "&#8482;", $line);
     $line = str_replace("(C)", "&#169;", $line);
     $line = str_replace("1/4", "&#188;", $line);
     $line = str_replace("1/2", "&#189;", $line);
     $line = str_replace("3/4", "&#190;", $line);
     $line = preg_replace("/([[:digit:]]+[[:space:]]*)x([[:space:]]*[[:digit:]]+)/i", "\\1&#215;\\2", $line);
     // (digits) x (digits) - multiply
     // do formatting tags
     // NOTE: The / replacement  *has* to be first, or it will screw the
     //    HTML tags that are added by the other ones
     // MARKDOWN: only bold and italic change, rest are just HTML
     $line = $this->do_replace_markdown($line, "\\*", "**");
     $line = $this->do_replace_markdown($line, "/", "*");
     $line = $this->do_replace($line, "\\+", "ins");
     // $line = $this->do_replace( $line, "-", "del" );
     $line = $this->do_replace_sub($line, "~", "sub");
     $line = $this->do_replace_sub($line, "\\^", "sup");
     $line = $this->do_replace($line, "%", "code");
     $line = $this->do_replace($line, "@", "cite");
     // convert urls into proper link with optional link text URL(text)
     // MARDOWN: HTML conversion should work fine
     $line = preg_replace("/([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\\(([^)]+)\\)/i", "\\1[\\5](\\2://\\3\\4)", $line);
     $line = preg_replace("/([[:space:]])www\\.([^[:space:]]*)([[:alnum:]#?/&=])\\(([^)]+)\\)/i", "\\1[\\5](http://www.\\2\\3)", $line);
     // make urls (with and without httpd) into proper links
     $line = preg_replace("/([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])/i", "\\1<\\2://\\3\\4>", $line);
     $line = preg_replace("/([[:space:]])www\\.([^[:space:]]*)([[:alnum:]#?/&=])/i", "\\1<http://www.\\2\\3\\>", $line);
     // make email addresses into mailtos....
     // MARKDOWN doesn't quite support this, so do as html
     $line = preg_replace("/([[:space:]]|^)([[:alnum:]._-]+@[[:alnum:]._-]+)\\(([^)]+)\\)/i", "\\1<a href=\"mailto:\\2\">\\3</a>", $line);
     // !# at the beginning of any lines means a heading
     // MARKDOWN: value (1-6) becomes number of hashes
     if (preg_match("/^!([1-6]) (.*)\$/i", $line, $regs)) {
         $depth = substr($line, 1, 1);
         $out = substr('##########', 0, $depth);
         $line = preg_replace("/^!([1-6]) (.*)\$/i", "{$out} \\2", $line);
     }
     // acronym handing, example HTML(Hypertext Markyp Language)
     // MARKDOWN: no equiv. so just leave as HTML
     $line = preg_replace("/([A-Z]+)\\(([^)]+)\\)/", "<acronym title=\"\\2\">\\1</acronym>", $line);
     // Replace resource link >>##(Description Text)
     // MARKDOWN: change to MD web link style
     $line = preg_replace("/ ([a-zA-Z]+):([0-9]+)\\(([^)]+)\\)/i", " [\\3](" . $CFG->wwwroot . "/mod/\\1/view.php?id=\\2) ", $line);
     $coursefileurl = array(moodle_url::make_legacyfile_url($this->courseid, null));
     // Replace picture resource link
     $line = preg_replace("#/([a-zA-Z0-9./_-]+)(png|gif|jpg)\\(([^)]+)\\)#i", "![\\3](" . $coursefileurl . "/\\1\\2)", $line);
     // Replace file resource link
     $line = preg_replace("#file:/([[:alnum:]/._-]+)\\(([^)]+)\\)#i", "[\\2](" . $coursefileurl . "/\\1)", $line);
     return $line;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:68,代码来源:wiki_to_markdown.php


注:本文中的moodle_url::make_legacyfile_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。