4 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
33 return array(
"ed_insert_code",
"pc_code");
47 $path =
"//Paragraph";
49 for($i = 0; $i < count(
$res->nodeset); $i++)
51 $context_node =
$res->nodeset[$i];
52 $char = $context_node->get_attribute(
'Characteristic');
57 $n = $context_node->parent_node();
58 $char = $context_node->get_attribute(
'Characteristic');
59 $subchar = $context_node->get_attribute(
'SubCharacteristic');
60 $showlinenumbers = $context_node->get_attribute(
'ShowLineNumbers');
61 $downloadtitle = $context_node->get_attribute(
'DownloadTitle');
62 $autoindent = $context_node->get_attribute(
'AutoIndent');
67 $childs = $context_node->child_nodes();
69 for($j=0; $j<count($childs); $j++)
71 $content .=
$dom->dump_node($childs[$j]);
74 while ($context_node->has_child_nodes ())
76 $node_del = $context_node->first_child ();
77 $context_node->remove_child ($node_del);
80 $content = str_replace(
"<br />",
"<br/>", utf8_decode($content) );
81 $content = str_replace(
"<br/>",
"\n", $content);
82 $rownums = count(split (
"\n",$content));
84 $plain_content = html_entity_decode($content);
85 $plain_content = preg_replace (
"/\&#x([1-9a-f]{2});?/ise",
"chr (base_convert (\\1, 16, 10))",$plain_content);
86 $plain_content = preg_replace (
"/\&#(\d+);?/ise",
"chr (\\1)",$plain_content);
87 $content = utf8_encode($this->
highlightText($plain_content, $subchar, $autoindent));
89 $content = str_replace(
"&lt;",
"<", $content);
90 $content = str_replace(
"&gt;",
">", $content);
93 $rows =
"<tr valign=\"top\">";
98 if (strcmp($showlinenumbers,
"y")==0)
100 $linenumbers =
"<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
101 $linenumbers .=
"<pre class=\"ilc_Code\">";
103 for ($j=0; $j < $rownums; $j++)
105 $indentno = strlen($rownums) - strlen($j+1) + 2;
106 $rownumeration = ($j+1);
107 $linenumbers .=
"<span class=\"ilc_LineNumber\">$rownumeration</span>";
110 $linenumbers .=
"\n";
113 $linenumbers .=
"</pre>";
114 $linenumbers .=
"</td>";
117 $rows .= $linenumbers.
"<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code\">".$content.
"</pre></td>";
122 $newcontent = str_replace(
"\n",
"<br/>",$rows);
124 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>",$newcontent);
126 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>",$newcontent);
131 $newcontent = str_replace(
"{",
"{", $newcontent);
132 $newcontent = str_replace(
"}",
"}", $newcontent);
135 $a_output = str_replace(
"[[[[[Code;".($i + 1).
"]]]]]", $newcontent, $a_output);
137 if ($outputmode !=
"presentation" && is_object($this->
getPage()->getOfflineHandler())
138 && trim($downloadtitle) !=
"")
141 $this->
getPage()->getOfflineHandler()->handleCodeParagraph($this->
getPage()->getId(), $i + 1, $downloadtitle, $plain_content);
159 require_once(
"./Services/COPage/syntax_highlight/php/HFile/HFile_".$proglang.
".php");
160 $classname =
"HFile_$proglang";
161 $h_instance =
new $classname();
162 if ($autoindent ==
"n") {
163 $h_instance ->notrim = 1;
164 $h_instance ->indent = array (
"");
165 $h_instance ->unindent = array (
"");
169 $a_text = $highlighter->highlight_text(html_entity_decode($a_text));
176 return file_exists (
"Services/COPage/syntax_highlight/php/HFile/HFile_".$hfile_ext.
".php");