4 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
33 return array(
"ed_insert_code",
"pc_code");
44 $path =
"//Paragraph";
46 for (
$i = 0;
$i < count(
$res->nodeset);
$i++) {
47 $context_node =
$res->nodeset[
$i];
48 $char = $context_node->get_attribute(
'Characteristic');
50 if ($char !=
"Code") {
54 $n = $context_node->parent_node();
55 $char = $context_node->get_attribute(
'Characteristic');
56 $subchar = $context_node->get_attribute(
'SubCharacteristic');
57 $showlinenumbers = $context_node->get_attribute(
'ShowLineNumbers');
58 $downloadtitle = $context_node->get_attribute(
'DownloadTitle');
59 $autoindent = $context_node->get_attribute(
'AutoIndent');
64 $childs = $context_node->child_nodes();
66 for ($j = 0; $j < count($childs); $j++) {
67 $content .=
$dom->dump_node($childs[$j]);
70 while ($context_node->has_child_nodes()) {
71 $node_del = $context_node->first_child();
72 $context_node->remove_child($node_del);
75 $content = str_replace(
"<br />",
"<br/>", utf8_decode($content));
76 $content = str_replace(
"<br/>",
"\n", $content);
77 $rownums = count(explode(
"\n", $content));
81 $plain_content = $content;
83 $plain_content = preg_replace_callback(
84 "/\&#x([1-9a-f]{2});?/is",
86 return chr(base_convert($hit[1], 16, 10));
90 $plain_content = preg_replace_callback(
97 $content = utf8_encode($this->
highlightText($plain_content, $subchar, $autoindent));
99 $content = str_replace(
"&lt;",
"<", $content);
100 $content = str_replace(
"&gt;",
">", $content);
103 $rows =
"<tr valign=\"top\">";
108 if (strcmp($showlinenumbers,
"y") == 0) {
109 $linenumbers =
"<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
110 $linenumbers .=
"<pre class=\"ilc_Code ilc_code_block_Code\">";
112 for ($j = 0; $j < $rownums; $j++) {
113 $indentno = strlen($rownums) - strlen($j + 1) + 2;
114 $rownumeration = ($j + 1);
115 $linenumbers .=
"<span class=\"ilc_LineNumber\">$rownumeration</span>";
116 if ($j < $rownums - 1) {
117 $linenumbers .=
"\n";
120 $linenumbers .=
"</pre>";
121 $linenumbers .=
"</td>";
124 $rows .= $linenumbers .
"<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code ilc_code_block_Code\">" . $content .
"</pre></td>";
129 $newcontent = str_replace(
"\n",
"<br/>",
$rows);
131 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>", $newcontent);
133 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>", $newcontent);
138 $newcontent = str_replace(
"{",
"{", $newcontent);
139 $newcontent = str_replace(
"}",
"}", $newcontent);
142 $a_output = str_replace(
"[[[[[Code;" . (
$i + 1) .
"]]]]]", $newcontent, $a_output);
144 if ($outputmode !=
"presentation" && is_object($this->
getPage()->getOfflineHandler())
145 && trim($downloadtitle) !=
"") {
147 $this->
getPage()->getOfflineHandler()->handleCodeParagraph($this->
getPage()->getId(),
$i + 1, $downloadtitle, $plain_content);
159 include_once(
"./Services/UIComponent/SyntaxHighlighter/classes/class.ilSyntaxHighlighter.php");
163 $a_text = $highl->highlight($a_text);
static getNewLanguageId($a_old_lang_id)
Get new language id (for an old one)
xpath_new_context($dom_document)
static getLangVars()
Get lang vars needed for editing.
xpath_eval($xpath_context, $eval_str, $contextnode=null)
setType($a_type)
Set Type.
foreach($_POST as $key=> $value) $res
modifyPageContentPostXsl($a_output, $outputmode="presentation", $a_abstract_only=false)
static isSupported($a_lang)
Is language supported?
static getInstance($a_lang)
Get instance.
init()
Init page content component.
highlightText($a_text, $proglang, $autoindent="")
Highligths Text with given ProgLang.