ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPCSourceCode Class Reference

Class ilPCSourceCode. More...

+ Inheritance diagram for ilPCSourceCode:
+ Collaboration diagram for ilPCSourceCode:

Public Member Functions

 init ()
 Init page content component.
 modifyPageContentPostXsl ($a_output, $outputmode="presentation")
 Modify page content after xsl.
 highlightText ($a_text, $proglang, $autoindent)
 Highligths Text with given ProgLang.
 hasHighlighter ($hfile_ext)
- Public Member Functions inherited from ilPCParagraph
 setNode (&$a_node)
 Set Page Content Node.
 createAtNode (&$node)
 Create new page content (incl.
 createBeforeNode (&$node)
 Create new page content (incl.
 createAfter ($node)
 Create paragraph node (incl.
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 Create paragraph node (incl.
 setText ($a_text, $a_auto_split=false)
 Set (xml) content of text paragraph.
 getText ($a_short_mode=false)
 Get (xml) content of paragraph.
 getParagraphSequenceContent ($a_pg_obj)
 Get paragraph sequenc of current paragraph.
 setCharacteristic ($a_char)
 Set Characteristic of paragraph.
 getCharacteristic ()
 Get characteristic of paragraph.
 setSubCharacteristic ($a_char)
 set attribute subcharacteristic
 getAutoIndent ()
 Get AutoIndent (Code Paragraphs)
 setAutoIndent ($a_char)
 getSubCharacteristic ()
 get attribute subcharacteristic
 setDownloadTitle ($a_char)
 set attribute download title
 getDownloadTitle ()
 get attribute download title
 setShowLineNumbers ($a_char)
 set attribute showlinenumbers
 getShowLineNumbers ()
 get attribute showlinenumbers
 setLanguage ($a_lang)
 set language
 getLanguage ()
 get language
 input2xml ($a_text, $a_wysiwyg=0, $a_handle_lists=true)
 autoSplit ($a_text)
 This function splits a paragraph text that has been already processed with input2xml at each header position =header1=, ==header2== or ===header3=== and returns an array that contains the single chunks.
 handleNextBr ($a_str)
 Remove preceding

 removeTrailingBr ($a_str)
 Remove trailing

 getType ()
 Need to override getType from ilPageContent to distinguish between Pararagraph and Source.
 saveJS ($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at="")
 Save input coming from ajax.
 getLastSavedPCId ($a_pg_obj, $a_as_ajax_str=false)
 Get last inserted pc ids.
 updatePage ($a_page)
 Update page object (it would be better to have this centralized and to change the constructors and pass the page object instead the dom object)
 autoLinkGlossaries ($a_glos)
 Auto link glossaries.
 saveAnchors ($a_page, $a_domdoc)
 Save anchors.
 saveMetaKeywords ($a_page, $a_domdoc)
 save all keywords
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor.
 setPage ($a_val)
 Set page.
 getPage ()
 Get page.
& getNode ()
 Get xml node of page content.
 getJavascriptFiles ()
 Get Javascript files.
 getCssFiles ()
 Get css files.
 getOnloadCode ()
 Get on load code.
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure.
 getHierId ()
 Get hierarchical id.
 lookupHierId ()
 Get hierarchical id from dom.
 readHierId ()
 Read PC Id.
 setPcId ($a_pcid)
 Set PC Id.
 getPCId ()
 Get PC Id.
 readPCId ()
 Read PC Id.
 writePCId ($a_pc_id)
 Write pc id.
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b.
 setEnabled ($value)
 Set Enabled value for page content component.
 enable ()
 Enable page content.
 disable ()
 Disable page content.
 isEnabled ()
 Check whether page content is enabled.
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element)

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing.
- Static Public Member Functions inherited from ilPCParagraph
static _input2xml ($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
 converts user input to xml
static intLinks2xml ($a_text)
 internal links to xml
static input2xmlReplaceLists ($a_text)
 Converts xml from DB to output in edit textarea.
static xml2outputReplaceLists ($a_text)
 Replaces

with *.

static segmentString ($a_haystack, $a_needles)
 Segments a string into an array at each position of a substring.
static xml2output ($a_text, $a_wysiwyg=false, $a_replace_lists=true)
 Converts xml from DB to output in edit textarea.
static handleAjaxContent ($a_content)
 Handle ajax content.
static handleAjaxContentPost ($text)
 Post input2xml handling of ajax content.
static autoLinkGlossariesPage ($a_page, $a_terms)
 Auto link glossary of whole page.
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created)
static beforePageDelete ($a_page)
 Before page is being deleted.
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created.
static _deleteAnchors ($a_parent_type, $a_page_id, $a_page_lang)
 Delete anchors of a page.
static _saveAnchor ($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
 Save an anchor.
static _readAnchors ($a_parent_type, $a_page_id, $a_page_lang="-")
 Read anchors of a page.
- Static Public Member Functions inherited from ilPageContent
static incEdId ($ed_id)
 Increases an hierarchical editing id at lowest level (last number)
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number)
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container.
static sortHierIds ($a_array)
 Sort an array of Hier IDS in ascending order.
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content.

Additional Inherited Members

- Data Fields inherited from ilPCParagraph
 $dom
 $par_node
- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type.
- Static Protected Member Functions inherited from ilPCParagraph
static linkTermsInDom ($a_dom, $a_terms, $a_par_node=null)
 Link terms in a dom page object in bb style.

Detailed Description

Class ilPCSourceCode.

Paragraph of ilPageObject

Author
Roland Küstermann
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 17 of file class.ilPCSourceCode.php.

Member Function Documentation

static ilPCSourceCode::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

Definition at line 31 of file class.ilPCSourceCode.php.

{
return array("ed_insert_code", "pc_code");
}
ilPCSourceCode::hasHighlighter (   $hfile_ext)

Definition at line 174 of file class.ilPCSourceCode.php.

Referenced by highlightText().

{
return file_exists ("Services/COPage/syntax_highlight/php/HFile/HFile_".$hfile_ext.".php");
}

+ Here is the caller graph for this function:

ilPCSourceCode::highlightText (   $a_text,
  $proglang,
  $autoindent 
)

Highligths Text with given ProgLang.

Definition at line 151 of file class.ilPCSourceCode.php.

References hasHighlighter().

Referenced by modifyPageContentPostXsl().

{
if (!$this->hasHighlighter($proglang))
{
$proglang="plain";
}
require_once("./Services/COPage/syntax_highlight/php/HFile/HFile_".$proglang.".php");
$classname = "HFile_$proglang";
$h_instance = new $classname();
if ($autoindent == "n") {
$h_instance ->notrim = 1;
$h_instance ->indent = array ("");
$h_instance ->unindent = array ("");
}
$highlighter = new Core($h_instance, new Output_css());
$a_text = $highlighter->highlight_text(html_entity_decode($a_text));
return $a_text;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCSourceCode::init ( )

Init page content component.

Reimplemented from ilPCParagraph.

Definition at line 22 of file class.ilPCSourceCode.php.

References ilPageContent\setType().

{
$this->setType("src");
}

+ Here is the call graph for this function:

ilPCSourceCode::modifyPageContentPostXsl (   $a_output,
  $outputmode = "presentation" 
)

Modify page content after xsl.

Parameters
string$a_output
Returns
string

Reimplemented from ilPageContent.

Definition at line 42 of file class.ilPCSourceCode.php.

References ilPCParagraph\$dom, $n, $path, $res, ilPageContent\getPage(), highlightText(), xpath_eval(), and xpath_new_context().

{
$dom = $this->getPage()->getDom();
$path = "//Paragraph"; //"[@Characteristic = 'Code']";
$res = & xpath_eval($xpc, $path);
for($i = 0; $i < count($res->nodeset); $i++)
{
$context_node = $res->nodeset[$i];
$char = $context_node->get_attribute('Characteristic');
if ($char != "Code")
continue;
$n = $context_node->parent_node();
$char = $context_node->get_attribute('Characteristic');
$subchar = $context_node->get_attribute('SubCharacteristic');
$showlinenumbers = $context_node->get_attribute('ShowLineNumbers');
$downloadtitle = $context_node->get_attribute('DownloadTitle');
$autoindent = $context_node->get_attribute('AutoIndent');
$content = "";
// get XML Content
$childs = $context_node->child_nodes();
for($j=0; $j<count($childs); $j++)
{
$content .= $dom->dump_node($childs[$j]);
}
while ($context_node->has_child_nodes ())
{
$node_del = $context_node->first_child ();
$context_node->remove_child ($node_del);
}
$content = str_replace("<br />", "<br/>", utf8_decode($content) );
$content = str_replace("<br/>", "\n", $content);
$rownums = count(split ("\n",$content));
$plain_content = html_entity_decode($content);
$plain_content = preg_replace ("/\&#x([1-9a-f]{2});?/ise","chr (base_convert (\\1, 16, 10))",$plain_content);
$plain_content = preg_replace ("/\&#(\d+);?/ise","chr (\\1)",$plain_content);
$content = utf8_encode($this->highlightText($plain_content, $subchar, $autoindent));
$content = str_replace("&amp;lt;", "&lt;", $content);
$content = str_replace("&amp;gt;", "&gt;", $content);
// $content = str_replace("&", "&amp;", $content);
//var_dump($content);
$rows = "<tr valign=\"top\">";
$rownumbers = "";
$linenumbers= "";
//if we have to show line numbers
if (strcmp($showlinenumbers,"y")==0)
{
$linenumbers = "<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
$linenumbers .= "<pre class=\"ilc_Code\">";
for ($j=0; $j < $rownums; $j++)
{
$indentno = strlen($rownums) - strlen($j+1) + 2;
$rownumeration = ($j+1);
$linenumbers .= "<span class=\"ilc_LineNumber\">$rownumeration</span>";
if ($j < $rownums-1)
{
$linenumbers .= "\n";
}
}
$linenumbers .= "</pre>";
$linenumbers .= "</td>";
}
$rows .= $linenumbers."<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code\">".$content."</pre></td>";
$rows .= "</tr>";
// fix for ie explorer which is not able to produce empty line feeds with <br /><br />;
// workaround: add a space after each br.
$newcontent = str_replace("\n", "<br/>",$rows);
// fix for IE
$newcontent = str_replace("<br/><br/>", "<br/> <br/>",$newcontent);
// falls drei hintereinander...
$newcontent = str_replace("<br/><br/>", "<br/> <br/>",$newcontent);
// workaround for preventing template engine
// from hiding paragraph text that is enclosed
// in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
$newcontent = str_replace("{", "&#123;", $newcontent);
$newcontent = str_replace("}", "&#125;", $newcontent);
//echo htmlentities($newcontent);
$a_output = str_replace("[[[[[Code;".($i + 1)."]]]]]", $newcontent, $a_output);
if ($outputmode != "presentation" && is_object($this->getPage()->getOfflineHandler())
&& trim($downloadtitle) != "")
{
// call code handler for offline versions
$this->getPage()->getOfflineHandler()->handleCodeParagraph($this->getPage()->getId(), $i + 1, $downloadtitle, $plain_content);
}
}
return $a_output;
}

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: