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(explode(
"\n",$content));
86 $plain_content = $content;
88 $plain_content = preg_replace_callback(
89 "/\&#x([1-9a-f]{2});?/is",
91 return chr(base_convert($hit[1], 16, 10));
95 $plain_content = preg_replace_callback(
102 $content = utf8_encode($this->
highlightText($plain_content, $subchar, $autoindent));
104 $content = str_replace(
"&lt;",
"<", $content);
105 $content = str_replace(
"&gt;",
">", $content);
108 $rows =
"<tr valign=\"top\">";
113 if (strcmp($showlinenumbers,
"y")==0)
115 $linenumbers =
"<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
116 $linenumbers .=
"<pre class=\"ilc_Code\">";
118 for ($j=0; $j < $rownums; $j++)
120 $indentno = strlen($rownums) - strlen($j+1) + 2;
121 $rownumeration = ($j+1);
122 $linenumbers .=
"<span class=\"ilc_LineNumber\">$rownumeration</span>";
125 $linenumbers .=
"\n";
128 $linenumbers .=
"</pre>";
129 $linenumbers .=
"</td>";
132 $rows .= $linenumbers.
"<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code\">".$content.
"</pre></td>";
137 $newcontent = str_replace(
"\n",
"<br/>",$rows);
139 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>",$newcontent);
141 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>",$newcontent);
146 $newcontent = str_replace(
"{",
"{", $newcontent);
147 $newcontent = str_replace(
"}",
"}", $newcontent);
150 $a_output = str_replace(
"[[[[[Code;".($i + 1).
"]]]]]", $newcontent, $a_output);
152 if ($outputmode !=
"presentation" && is_object($this->
getPage()->getOfflineHandler())
153 && trim($downloadtitle) !=
"")
156 $this->
getPage()->getOfflineHandler()->handleCodeParagraph($this->
getPage()->getId(), $i + 1, $downloadtitle, $plain_content);
169 include_once(
"./Services/UIComponent/SyntaxHighlighter/classes/class.ilSyntaxHighlighter.php");
174 $a_text = $highl->highlight($a_text);
181 return file_exists (
"Services/COPage/syntax_highlight/php/HFile/HFile_".$hfile_ext.
".php");
modifyPageContentPostXsl($a_output, $outputmode="presentation")
Modify page content after xsl.
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.
hasHighlighter($hfile_ext)
Create styles array
The data for the language used.
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.