ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPCParagraph Class Reference

Class ilPCParagraph. More...

+ Inheritance diagram for ilPCParagraph:
+ Collaboration diagram for ilPCParagraph:

Public Member Functions

 init ()
 Init page content component.
 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.
- Public Member Functions inherited from ilPageContent
 __construct ($a_dom)
 Constructor.
getNode ()
 Get xml node of page content.
 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 _input2xml ($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
 converts user input 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 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.

Data Fields

 $dom
 $par_node
- Data Fields inherited from ilPageContent
 $hier_id
 $node
 $dom

Additional Inherited Members

- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type.

Detailed Description

Class ilPCParagraph.

Paragraph of ilPageObject

Author
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.ilPCParagraph.php.

Member Function Documentation

static ilPCParagraph::_input2xml (   $a_text,
  $a_lang,
  $a_wysiwyg = 0,
  $a_handle_lists = true 
)
static

converts user input to xml

Definition at line 495 of file class.ilPCParagraph.php.

References ilUtil\attribsToArray(), input2xmlReplaceLists(), and ilUtil\stripSlashes().

Referenced by input2xml(), ilPCDataTableGUI\update(), and ilPCDataTableGUI\updateJS().

{
if (!$a_wysiwyg)
{
$a_text = ilUtil::stripSlashes($a_text, false);
}
if ($a_wysiwyg)
{
$a_text = str_replace("<br />", chr(10), $a_text);
}
// note: the order of the processing steps is crucial
// and should be the same as in xml2output() in REVERSE order!
$a_text = trim($a_text);
//echo "<br>between:".htmlentities($a_text);
// mask html
if (!$a_wysiwyg)
{
$a_text = str_replace("&","&amp;",$a_text);
}
$a_text = str_replace("<","&lt;",$a_text);
$a_text = str_replace(">","&gt;",$a_text);
// Reconvert PageTurn and BibItemIdentifier
$a_text = preg_replace('/&lt;([\s\/]*?PageTurn.*?)&gt;/i',"<$1>",$a_text);
$a_text = preg_replace('/&lt;([\s\/]*?BibItemIdentifier.*?)&gt;/i',"<$1>",$a_text);
//echo "<br>second:".htmlentities($a_text);
// mask curly brackets
/*
echo htmlentities($a_text);
$a_text = str_replace("{", "&#123;", $a_text);
$a_text = str_replace("}", "&#125;", $a_text);
echo htmlentities($a_text);*/
// linefeed to br
$a_text = str_replace(chr(13).chr(10),"<br />",$a_text);
$a_text = str_replace(chr(13),"<br />", $a_text);
$a_text = str_replace(chr(10),"<br />", $a_text);
if ($a_handle_lists)
{
}
// remove empty tags
$atags = array("com", "emp", "str", "fn", "quot", "code", "acc", "imp", "kw");
foreach ($atags as $at)
{
$a_text = str_replace("[".$at."][/".$at."]", "", $a_text);
}
// bb code to xml
$a_text = eregi_replace("\[com\]","<Comment Language=\"".$a_lang."\">",$a_text);
$a_text = eregi_replace("\[\/com\]","</Comment>",$a_text);
$a_text = eregi_replace("\[emp\]","<Emph>",$a_text);
$a_text = eregi_replace("\[\/emp\]","</Emph>",$a_text);
$a_text = eregi_replace("\[str\]","<Strong>",$a_text);
$a_text = eregi_replace("\[\/str\]","</Strong>",$a_text);
$a_text = eregi_replace("\[fn\]","<Footnote>",$a_text);
$a_text = eregi_replace("\[\/fn\]","</Footnote>",$a_text);
$a_text = eregi_replace("\[quot\]","<Quotation Language=\"".$a_lang."\">",$a_text);
$a_text = eregi_replace("\[\/quot\]","</Quotation>",$a_text);
$a_text = eregi_replace("\[code\]","<Code>",$a_text);
$a_text = eregi_replace("\[\/code\]","</Code>",$a_text);
$a_text = eregi_replace("\[acc\]","<Accent>",$a_text);
$a_text = eregi_replace("\[\/acc\]","</Accent>",$a_text);
$a_text = eregi_replace("\[imp\]","<Important>",$a_text);
$a_text = eregi_replace("\[\/imp\]","</Important>",$a_text);
$a_text = eregi_replace("\[kw\]","<Keyw>",$a_text);
$a_text = eregi_replace("\[\/kw\]","</Keyw>",$a_text);
// internal links
//$any = "[^\]]*"; // this doesn't work :-(
$ws= "[ \t\r\f\v\n]*";
$ltypes = "page|chap|term|media|htlm|lm|dbk|glo|frm|exc|tst|svy|webr|chat|cat|crs|grp|file|fold|mep|wiki|sahs|mcst|obj|dfile";
// empty internal links
while (eregi("\[(iln$ws((inst$ws=$ws([\"0-9])*)?$ws".
"((".$ltypes.")$ws=$ws([\"0-9])*)$ws".
"(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]", $a_text, $found))
{
$a_text = str_replace($found[0], "",$a_text);
}
while (eregi("\[(iln$ws((inst$ws=$ws([\"0-9])*)?$ws".
"((".$ltypes.")$ws=$ws([\"0-9])*)$ws".
"(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]", $a_text, $found))
{
$attribs = ilUtil::attribsToArray($found[2]);
$inst_str = $attribs["inst"];
// pages
if (isset($attribs["page"]))
{
$tframestr = "";
if (!empty($found[10]))
{
$tframestr = " TargetFrame=\"".$found[10]."\" ";
}
$ancstr = "";
if ($attribs["anchor"] != "")
{
$ancstr = ' Anchor="'.$attribs["anchor"].'" ';
}
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_pg_".$attribs[page]."\" Type=\"PageObject\"".$tframestr.$ancstr.">", $a_text);
}
// chapters
else if (isset($attribs["chap"]))
{
if (!empty($found[10]))
{
$tframestr = " TargetFrame=\"".$found[10]."\" ";
}
else
{
$tframestr = "";
}
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_st_".$attribs[chap]."\" Type=\"StructureObject\"".$tframestr.">", $a_text);
}
// glossary terms
else if (isset($attribs["term"]))
{
switch ($found[10])
{
case "New":
$tframestr = " TargetFrame=\"New\" ";
break;
default:
$tframestr = " TargetFrame=\"Glossary\" ";
break;
}
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_git_".$attribs[term]."\" Type=\"GlossaryItem\" $tframestr>", $a_text);
}
// media object
else if (isset($attribs["media"]))
{
if (!empty($found[10]))
{
$tframestr = " TargetFrame=\"".$found[10]."\" ";
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"".$tframestr.">", $a_text);
}
else
{
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"/>", $a_text);
}
}
// direct download file (no repository object)
else if (isset($attribs["dfile"]))
{
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_dfile_".$attribs[dfile]."\" Type=\"File\">", $a_text);
}
// repository items (id is ref_id (will be used internally but will
// be replaced by object id for export purposes)
else if (isset($attribs["lm"]) || isset($attribs["dbk"]) || isset($attribs["glo"])
|| isset($attribs["frm"]) || isset($attribs["exc"]) || isset($attribs["tst"])
|| isset($attribs["svy"]) || isset($attribs["obj"]) || isset($attribs['webr'])
|| isset($attribs["htlm"]) || isset($attribs["chat"]) || isset($attribs["grp"])
|| isset($attribs["fold"]) || isset($attribs["sahs"]) || isset($attribs["mcst"])
|| isset($attribs["mep"]) || isset($attribs["wiki"])
|| isset($attribs["cat"]) || isset($attribs["crs"]) || isset($attribs["file"]))
{
$obj_id = (isset($attribs["lm"])) ? $attribs["lm"] : $obj_id;
$obj_id = (isset($attribs["dbk"])) ? $attribs["dbk"] : $obj_id;
$obj_id = (isset($attribs["chat"])) ? $attribs["chat"] : $obj_id;
$obj_id = (isset($attribs["glo"])) ? $attribs["glo"] : $obj_id;
$obj_id = (isset($attribs["frm"])) ? $attribs["frm"] : $obj_id;
$obj_id = (isset($attribs["exc"])) ? $attribs["exc"] : $obj_id;
$obj_id = (isset($attribs["htlm"])) ? $attribs["htlm"] : $obj_id;
$obj_id = (isset($attribs["tst"])) ? $attribs["tst"] : $obj_id;
$obj_id = (isset($attribs["svy"])) ? $attribs["svy"] : $obj_id;
$obj_id = (isset($attribs["obj"])) ? $attribs["obj"] : $obj_id;
$obj_id = (isset($attribs["webr"])) ? $attribs["webr"] : $obj_id;
$obj_id = (isset($attribs["fold"])) ? $attribs["fold"] : $obj_id;
$obj_id = (isset($attribs["cat"])) ? $attribs["cat"] : $obj_id;
$obj_id = (isset($attribs["crs"])) ? $attribs["crs"] : $obj_id;
$obj_id = (isset($attribs["grp"])) ? $attribs["grp"] : $obj_id;
$obj_id = (isset($attribs["file"])) ? $attribs["file"] : $obj_id;
$obj_id = (isset($attribs["sahs"])) ? $attribs["sahs"] : $obj_id;
$obj_id = (isset($attribs["mcst"])) ? $attribs["mcst"] : $obj_id;
$obj_id = (isset($attribs["mep"])) ? $attribs["mep"] : $obj_id;
$obj_id = (isset($attribs["wiki"])) ? $attribs["wiki"] : $obj_id;
//$obj_id = (isset($attribs["obj"])) ? $attribs["obj"] : $obj_id;
if ($inst_str == "")
{
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_obj_".$obj_id."\" Type=\"RepositoryItem\">", $a_text);
}
else
{
$a_text = eregi_replace("\[".$found[1]."\]",
"<IntLink Target=\"il_".$inst_str."_".$found[6]."_".$obj_id."\" Type=\"RepositoryItem\">", $a_text);
}
}
else
{
$a_text = eregi_replace("\[".$found[1]."\]", "[error: iln".$found[1]."]",$a_text);
}
}
while (eregi("\[(iln$ws((inst$ws=$ws([\"0-9])*)?".$ws."media$ws=$ws([\"0-9])*)$ws)/\]", $a_text, $found))
{
$attribs = ilUtil::attribsToArray($found[2]);
$inst_str = $attribs["inst"];
$a_text = eregi_replace("\[".$found[1]."/\]",
"<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"/>", $a_text);
}
$a_text = eregi_replace("\[\/iln\]","</IntLink>",$a_text);
// external link
$ws= "[ \t\r\f\v\n]*";
// remove empty external links
while (eregi("\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]", $a_text, $found))
{
$a_text = str_replace($found[0], "",$a_text);
}
while (eregi("\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]", $a_text, $found))
{
$a_text = str_replace($found[0], "",$a_text);
}
// external links
while (eregi("\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]", $a_text, $found))
{
$attribs = ilUtil::attribsToArray($found[2]);
if (isset($attribs["url"]))
{
$a2 = ilUtil::attribsToArray($found[4]);
$tstr = "";
if (in_array($a2["target"], array("FAQ", "Glossary", "Media")))
{
$tstr = ' TargetFrame="'.$a2["target"].'"';
}
$a_text = str_replace("[".$found[1]."]", "<ExtLink Href=\"".$attribs["url"]."\"$tstr>", $a_text);
}
else
{
$a_text = str_replace("[".$found[1]."]", "[error: xln".$found[1]."]",$a_text);
}
}
// ie/tinymce fix for links without "", see bug #8391
while (eregi("\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]", $a_text, $found))
{
if ($found[3] != "")
{
$a_text = str_replace("[".$found[1]."]", "<ExtLink Href=\"".$found[3]."\">", $a_text);
}
else
{
$a_text = str_replace("[".$found[1]."]", "[error: xln".$found[1]."]",$a_text);
}
}
$a_text = eregi_replace("\[\/xln\]","</ExtLink>",$a_text);
// anchor
$ws= "[ \t\r\f\v\n]*";
while (eregi("\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]", $a_text, $found))
{
$attribs = ilUtil::attribsToArray($found[2]);
$a_text = str_replace("[".$found[1]."]", "<Anchor Name=\"".$attribs["name"]."\">", $a_text);
}
$a_text = eregi_replace("\[\/anc\]","</Anchor>",$a_text);
//echo htmlentities($a_text); exit;
return $a_text;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCParagraph::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.

Definition at line 1181 of file class.ilPCParagraph.php.

References $n, handleNextBr(), and removeTrailingBr().

Referenced by setText().

{
$a_text = str_replace ("=<SimpleBulletList>", "=<br /><SimpleBulletList>", $a_text);
$a_text = str_replace ("=<SimpleNumberedList>", "=<br /><SimpleNumberedList>", $a_text);
$a_text = str_replace ("</SimpleBulletList>=", "</SimpleBulletList><br />=", $a_text);
$a_text = str_replace ("</SimpleNumberedList>=", "</SimpleNumberedList><br />=", $a_text);
$a_text = "<br />".$a_text."<br />"; // add preceding and trailing br
$chunks = array();
$c_text = $a_text;
//echo "0";
while ($c_text != "")
{
//var_dump($c_text); flush();
//echo "1";
$s1 = strpos($c_text, "<br />=");
if (is_int($s1))
{
//echo "2";
$s2 = strpos($c_text, "<br />==");
if (is_int($s2) && $s2 <= $s1)
{
//echo "3";
$s3 = strpos($c_text, "<br />===");
if (is_int($s3) && $s3 <= $s2) // possible level three header
{
//echo "4";
$n = strpos($c_text, "<br />", $s3 + 1);
if ($n > ($s3+9) && substr($c_text, $n-3, 9) == "===<br />")
{
//echo "5";
// found level three header
if ($s3 > 0 || $head != "")
{
//echo "6";
$chunks[] = array("level" => 0,
"text" => $this->removeTrailingBr($head.substr($c_text, 0, $s3)));
$head = "";
}
$chunks[] = array("level" => 3,
"text" => trim(substr($c_text, $s3+9, $n-$s3-12)));
$c_text = $this->handleNextBr(substr($c_text, $n+6));
}
else
{
//echo "7";
$head.= substr($c_text, 0, $n);
$c_text = substr($c_text, $n);
}
}
else // possible level two header
{
//echo "8";
$n = strpos($c_text, "<br />", $s2 + 1);
if ($n > ($s2+8) && substr($c_text, $n-2, 8) == "==<br />")
{
//echo "9";
// found level two header
if ($s2 > 0 || $head != "")
{
//echo "A";
$chunks[] = array("level" => 0,
"text" => $this->removeTrailingBr($head.substr($c_text, 0, $s2)));
$head = "";
}
$chunks[] = array("level" => 2, "text" => trim(substr($c_text, $s2+8, $n-$s2-10)));
$c_text = $this->handleNextBr(substr($c_text, $n+6));
}
else
{
//echo "B";
$head.= substr($c_text, 0, $n);
$c_text = substr($c_text, $n);
}
}
}
else // possible level one header
{
//echo "C";
$n = strpos($c_text, "<br />", $s1 + 1);
if ($n > ($s1+7) && substr($c_text, $n-1, 7) == "=<br />")
{
//echo "D";
// found level one header
if ($s1 > 0 || $head != "")
{
//echo "E";
$chunks[] = array("level" => 0,
"text" => $this->removeTrailingBr($head.substr($c_text, 0, $s1)));
$head = "";
}
$chunks[] = array("level" => 1, "text" => trim(substr($c_text, $s1+7, $n-$s1-8)));
$c_text = $this->handleNextBr(substr($c_text, $n+6));
//echo "<br>ctext:".htmlentities($c_text)."<br>";
}
else
{
$head.= substr($c_text, 0, $n);
$c_text = substr($c_text, $n);
//echo "<br>head:".$head."c_text:".$c_text."<br>";
}
}
}
else
{
//echo "G";
$chunks[] = array("level" => 0, "text" => $head.$c_text);
$head = "";
$c_text = "";
}
}
if (count($chunks) == 0)
{
$chunks[] = array("level" => 0, "text" => "");
}
// remove preceding br
if (substr($chunks[0]["text"], 0, 6) == "<br />")
{
$chunks[0]["text"] = substr($chunks[0]["text"], 6);
}
// remove trailing br
if (substr($chunks[count($chunks) - 1]["text"],
strlen($chunks[count($chunks) - 1]["text"]) - 6, 6) == "<br />")
{
$chunks[count($chunks) - 1]["text"] =
substr($chunks[count($chunks) - 1]["text"], 0, strlen($chunks[count($chunks) - 1]["text"]) - 6);
if ($chunks[count($chunks) - 1]["text"] == "")
{
unset($chunks[count($chunks) - 1]);
}
}
return $chunks;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCParagraph::create ( $a_pg_obj,
  $a_hier_id,
  $a_pc_id = "" 
)

Create paragraph node (incl.

page content node) at given hierarchical ID.

Parameters
object$a_pg_objPage Object
string$a_hier_idHierarchical ID

Definition at line 108 of file class.ilPCParagraph.php.

References IL_INSERT_AFTER.

{
//echo "-$a_pc_id-";
//echo "<br>-".htmlentities($a_pg_obj->getXMLFromDom())."-<br><br>"; mk();
$this->node =& $this->dom->create_element("PageContent");
// this next line kicks out placeholders, if something is inserted
$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
$this->par_node =& $this->dom->create_element("Paragraph");
$this->par_node =& $this->node->append_child($this->par_node);
$this->par_node->set_attribute("Language", "");
}
ilPCParagraph::createAfter (   $node)

Create paragraph node (incl.

page content node) after given node.

Parameters
object$nodePredecessing node

Definition at line 84 of file class.ilPCParagraph.php.

References ilPageContent\$node, and ilPageContent\createPageContentNode().

{
$this->node = $this->createPageContentNode(false);
if($succ_node = $node->next_sibling())
{
$this->node = $succ_node->insert_before($this->node, $succ_node);
}
else
{
$parent_node = $node->parent_node();
$this->node = $parent_node->append_child($this->node);
}
$this->par_node = $this->dom->create_element("Paragraph");
$this->par_node = $this->node->append_child($this->par_node);
$this->par_node->set_attribute("Language", "");
}

+ Here is the call graph for this function:

ilPCParagraph::createAtNode ( $node)

Create new page content (incl.

paragraph) node at node

Parameters
object$nodeParent Node for Page Content

Definition at line 55 of file class.ilPCParagraph.php.

References ilPageContent\$node, and ilPageContent\createPageContentNode().

{
$this->node = $this->createPageContentNode();
$this->par_node =& $this->dom->create_element("Paragraph");
$this->par_node =& $this->node->append_child($this->par_node);
$this->par_node->set_attribute("Language", "");
$node->append_child ($this->node);
}

+ Here is the call graph for this function:

ilPCParagraph::createBeforeNode ( $node)

Create new page content (incl.

paragraph) node at node

Parameters
object$nodeParent Node for Page Content

Definition at line 69 of file class.ilPCParagraph.php.

References ilPageContent\$node, and ilPageContent\createPageContentNode().

{
$this->node = $this->createPageContentNode();
$this->par_node =& $this->dom->create_element("Paragraph");
$this->par_node =& $this->node->append_child($this->par_node);
$this->par_node->set_attribute("Language", "");
$node->insert_before($this->node, $node);
}

+ Here is the call graph for this function:

ilPCParagraph::getAutoIndent ( )

Get AutoIndent (Code Paragraphs)

Parameters
stringAuto Indent attribute

Definition at line 396 of file class.ilPCParagraph.php.

{
return $this->par_node->get_attribute("AutoIndent");
}
ilPCParagraph::getCharacteristic ( )

Get characteristic of paragraph.

Returns
string characteristic

Definition at line 364 of file class.ilPCParagraph.php.

Referenced by getType(), and setText().

{
if (is_object($this->par_node))
{
return $this->par_node->get_attribute("Characteristic");
}
}

+ Here is the caller graph for this function:

ilPCParagraph::getDownloadTitle ( )

get attribute download title

Definition at line 446 of file class.ilPCParagraph.php.

{
return $this->par_node->get_attribute("DownloadTitle");
}
ilPCParagraph::getLanguage ( )

get language

Definition at line 482 of file class.ilPCParagraph.php.

Referenced by input2xml(), and setText().

{
return $this->par_node->get_attribute("Language");
}

+ Here is the caller graph for this function:

ilPCParagraph::getLastSavedPCId (   $a_pg_obj,
  $a_as_ajax_str = false 
)

Get last inserted pc ids.

Parameters
@return

Definition at line 1429 of file class.ilPCParagraph.php.

References ilPageContent\$hier_id.

{
if ($a_as_ajax_str)
{
$a_pg_obj->stripHierIDs();
$a_pg_obj->addHierIds();
$ids = "###";
//var_dump($this->inserted_pc_ids);
$combined = $a_pg_obj->getHierIdsForPCIds(
array($this->inserted_pc_id));
foreach ($combined as $pc_id => $hier_id)
{
//echo "1";
$ids.= $sep.$hier_id.":".$pc_id;
$sep = ";";
}
$ids.= "###";
return $ids;
}
return $this->inserted_pc_id;
}
ilPCParagraph::getParagraphSequenceContent (   $a_pg_obj)

Get paragraph sequenc of current paragraph.

Definition at line 278 of file class.ilPCParagraph.php.

References ilPageContent\$hier_id, ilPageContent\readHierId(), ilPageContent\readPCId(), and ilPCParagraphGUI\xml2outputJS().

{
$childs = $this->par_node->parent_node()->parent_node()->child_nodes();
$seq = array();
$cur_seq = array();
$found = false;
$pc_id = $this->readPCId();
$hier_id = $this->readHierId();
for($i=0; $i<count($childs); $i++)
{
$pchilds = $childs[$i]->child_nodes();
if ($pchilds[0]->node_name() == "Paragraph" &&
$pchilds[0]->get_attribute("Characteristic") != "Code")
{
$cur_seq[] = $childs[$i];
// check whether this is the sequence of the current paragraph
if ($childs[$i]->get_attribute("PCID") == $pc_id &&
$childs[$i]->get_attribute("HierId") == $hier_id)
{
$found = true;
}
// if this is the current sequenc, get it
if ($found)
{
$seq = $cur_seq;
}
}
else
{
// non-paragraph element found -> init the current sequence
$cur_seq = array();
$found = false;
}
}
$content = "";
$ids = "###";
$id_sep = "";
foreach ($seq as $p_node)
{
$ids.= $id_sep.$p_node->get_attribute("HierId").":".$p_node->get_attribute("PCID");
$po = $a_pg_obj->getContentObject($p_node->get_attribute("HierId"),
$p_node->get_attribute("PCID"));
$s_text = $po->getText();
$s_text = $po->xml2output($s_text, true, false);
$char = $po->getCharacteristic();
if ($char == "")
{
$char = "Standard";
}
$s_text = ilPCParagraphGUI::xml2outputJS($s_text, $char, $po->readPCId());
$content.= $s_text;
$id_sep = ";";
}
$ids.= "###";
return $ids.$content;
}

+ Here is the call graph for this function:

ilPCParagraph::getShowLineNumbers ( )

get attribute showlinenumbers

Definition at line 466 of file class.ilPCParagraph.php.

{
return $this->par_node->get_attribute("ShowLineNumbers");
}
ilPCParagraph::getSubCharacteristic ( )

get attribute subcharacteristic

Definition at line 419 of file class.ilPCParagraph.php.

{
return $this->par_node->get_attribute("SubCharacteristic");
}
ilPCParagraph::getText (   $a_short_mode = false)

Get (xml) content of paragraph.

Returns
string Paragraph Content.

Definition at line 257 of file class.ilPCParagraph.php.

{
if (is_object($this->par_node))
{
$content = "";
$childs = $this->par_node->child_nodes();
for($i=0; $i<count($childs); $i++)
{
$content .= $this->dom->dump_node($childs[$i]);
}
return $content;
}
else
{
return "";
}
}
ilPCParagraph::getType ( )

Need to override getType from ilPageContent to distinguish between Pararagraph and Source.

Reimplemented from ilPageContent.

Definition at line 1356 of file class.ilPCParagraph.php.

References getCharacteristic().

{
return ($this->getCharacteristic() == "Code")?"src":parent::getType();
}

+ Here is the call graph for this function:

static ilPCParagraph::handleAjaxContent (   $a_content)
static

Handle ajax content.

Definition at line 1456 of file class.ilPCParagraph.php.

References $res, $ret, ilPageContentGUI\_getCommonBBButtons(), ilDOM2Util\addParent(), ilDOM2Util\changeName(), ilDOM2Util\replaceByChilds(), and ilUtil\stripSlashes().

Referenced by saveJS(), and ilPCDataTableGUI\updateJS().

{
$a_content = "<dummy>".$a_content."</dummy>";
$doc = new DOMDocument();
$content = ilUtil::stripSlashes($a_content, false);
// $content = str_replace("&lt;", "<", $content);
// $content = str_replace("&gt;", ">", $content);
//echo "<br><br>".htmlentities($content); mk();
$res = $doc->loadXML($content);
if (!$res)
{
return false;
}
// convert tags
$xpath = new DOMXpath($doc);
$elements = $xpath->query("//span");
include_once("./Services/Utilities/classes/class.ilDOM2Util.php");
while (!is_null($elements) && !is_null($element = $elements->item(0)))
{
//$element = $elements->item(0);
$class = $element->getAttribute("class");
if (substr($class, 0, 16) == "ilc_text_inline_")
{
$class_arr = explode(" ", $class);
$cnode = ilDOM2Util::changeName($element, "il".substr($class_arr[0], 16), false);
for ($i = 1; $i < count($class_arr); $i++)
{
$cnode = ilDOM2Util::addParent($cnode, "il".substr($class_arr[$i], 16));
}
}
else
{
}
$elements = $xpath->query("//span");
}
// convert tags
$xpath = new DOMXpath($doc);
$elements = $xpath->query("/dummy/div");
$ret = array();
if (!is_null($elements))
{
foreach ($elements as $element)
{
$id = $element->getAttribute("id");
$class = $element->getAttribute("class");
$class = substr($class, 15);
if (trim($class) == "")
{
$class = "Standard";
}
$text = $doc->saveXML($element);
$text = str_replace("<br/>", "\n", $text);
// remove wrapping div
$pos = strpos($text, ">");
$text = substr($text, $pos + 1);
$pos = strrpos($text, "<");
$text = substr($text, 0, $pos);
// todo: remove empty spans <span ...> </span>
// replace tags by bbcode
foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl)
{
if (!in_array($bb, array("code", "tex", "fn", "xln")))
{
$text = str_replace("<il".$cl.">",
"[".$bb."]", $text);
$text = str_replace("</il".$cl.">",
"[/".$bb."]", $text);
$text = str_replace("<il".$cl."/>", "", $text);
}
}
$text = str_replace(array("<code>", "</code>"),
array("[code]", "[/code]"), $text);
$text = str_replace("<code/>", "", $text);
$text = str_replace('<ul class="ilc_list_u_BulletedList"/>', "", $text);
$text = str_replace('<ul class="ilc_list_o_NumberedList"/>', "", $text);
$ret[] = array("text" => $text, "id" => $id, "class" => $class);
}
}
// we should only have one here!
return $ret[0];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPCParagraph::handleAjaxContentPost (   $text)
static

Post input2xml handling of ajax content.

Definition at line 1558 of file class.ilPCParagraph.php.

Referenced by saveJS(), and ilPCDataTableGUI\updateJS().

{
$text = str_replace(array("&lt;ul&gt;", "&lt;/ul&gt;"),
array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
$text = str_replace(array("&lt;ul class='ilc_list_u_BulletedList'&gt;", "&lt;/ul&gt;"),
array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
$text = str_replace(array("&lt;ul class=\"ilc_list_u_BulletedList\"&gt;", "&lt;/ul&gt;"),
array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
$text = str_replace(array("&lt;ol&gt;", "&lt;/ol&gt;"),
array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
$text = str_replace(array("&lt;ol class='ilc_list_o_NumberedList'&gt;", "&lt;/ol&gt;"),
array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
$text = str_replace(array("&lt;ol class=\"ilc_list_o_NumberedList\"&gt;", "&lt;/ol&gt;"),
array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
$text = str_replace(array("&lt;li&gt;", "&lt;/li&gt;"),
array("<SimpleListItem>", "</SimpleListItem>"), $text);
$text = str_replace(array("&lt;li class='ilc_list_item_StandardListItem'&gt;", "&lt;/li&gt;"),
array("<SimpleListItem>", "</SimpleListItem>"), $text);
$text = str_replace(array("&lt;li class=\"ilc_list_item_StandardListItem\"&gt;", "&lt;/li&gt;"),
array("<SimpleListItem>", "</SimpleListItem>"), $text);
$text = str_replace(array("&lt;li class=\"ilc_list_item_StandardListItem\"/&gt;"),
array("<SimpleListItem></SimpleListItem>"), $text);
$text = str_replace("<SimpleBulletList><br />", "<SimpleBulletList>", $text);
$text = str_replace("<SimpleNumberedList><br />", "<SimpleNumberedList>", $text);
$text = str_replace("<br /><SimpleBulletList>", "<SimpleBulletList>", $text);
$text = str_replace("<br /><SimpleNumberedList>", "<SimpleNumberedList>", $text);
$text = str_replace("</SimpleBulletList><br />", "</SimpleBulletList>", $text);
$text = str_replace("</SimpleNumberedList><br />", "</SimpleNumberedList>", $text);
$text = str_replace("</SimpleListItem><br />", "</SimpleListItem>", $text);
return $text;
}

+ Here is the caller graph for this function:

ilPCParagraph::handleNextBr (   $a_str)

Remove preceding

Definition at line 1321 of file class.ilPCParagraph.php.

Referenced by autoSplit().

{
// do not remove, if next line starts with a "=", otherwise two
// headlines in a row will not be recognized
if (substr($a_str, 0, 6) == "<br />" && substr($a_str, 6, 1) != "=")
{
$a_str = substr($a_str, 6);
}
else
{
// if next line starts with a "=" we need to reinsert the <br />
// otherwise it will not be recognized
if (substr($a_str, 0, 1) == "=")
{
$a_str = "<br />".$a_str;
}
}
return $a_str;
}

+ Here is the caller graph for this function:

ilPCParagraph::init ( )

Init page content component.

Reimplemented from ilPageContent.

Definition at line 25 of file class.ilPCParagraph.php.

References ilPageContent\setType().

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

+ Here is the call graph for this function:

ilPCParagraph::input2xml (   $a_text,
  $a_wysiwyg = 0,
  $a_handle_lists = true 
)

Definition at line 487 of file class.ilPCParagraph.php.

References _input2xml(), and getLanguage().

{
return $this->_input2xml($a_text, $this->getLanguage(), $a_wysiwyg, $a_handle_lists);
}

+ Here is the call graph for this function:

static ilPCParagraph::input2xmlReplaceLists (   $a_text)
static

Converts xml from DB to output in edit textarea.

Parameters
string$a_textxml from db
Returns
string string ready for edit textarea

Definition at line 776 of file class.ilPCParagraph.php.

References $row.

Referenced by _input2xml(), and ilSCORM2004Asset\convertLists().

{
$rows = explode("<br />", $a_text."<br />");
//var_dump($a_text);
$old_level = 0;
$text = "";
foreach ($rows as $row)
{
$level = 0;
if (str_replace("#", "*", substr($row, 0, 3)) == "***")
{
$level = 3;
}
else if (str_replace("#", "*", substr($row, 0, 2)) == "**")
{
$level = 2;
}
else if (str_replace("#", "*", substr($row, 0, 1)) == "*")
{
$level = 1;
}
// end previous line
if ($level < $old_level)
{
for ($i = $old_level; $i > $level; $i--)
{
$text.= "</SimpleListItem></".$clist[$i].">";
}
if ($level > 0)
{
$text.= "</SimpleListItem>";
}
}
else if ($old_level > 0 && $level > 0 && ($level == $old_level))
{
$text.= "</SimpleListItem>";
}
else if (($level == $old_level) && $text != "")
{
$text.= "<br />";
}
// start next line
if ($level > $old_level)
{
for($i = $old_level + 1; $i <= $level; $i++)
{
if (substr($row, $i - 1, 1) == "*")
{
$clist[$i] = "SimpleBulletList";
}
else
{
$clist[$i] = "SimpleNumberedList";
}
$text.= "<".$clist[$i]."><SimpleListItem>";
}
}
else if ($old_level > 0 && $level > 0)
{
$text.= "<SimpleListItem>";
}
$text.= substr($row, $level);
$old_level = $level;
}
// remove "<br />" at the end
if (substr($text, strlen($text) - 6) == "<br />")
{
$text = substr($text, 0, strlen($text) - 6);
}
return $text;
}

+ Here is the caller graph for this function:

ilPCParagraph::removeTrailingBr (   $a_str)

Remove trailing

Definition at line 1344 of file class.ilPCParagraph.php.

Referenced by autoSplit().

{
if (substr($a_str, strlen($a_str) - 6) == "<br />")
{
$a_str = substr($a_str, 0, strlen($a_str) - 6);
}
return $a_str;
}

+ Here is the caller graph for this function:

ilPCParagraph::saveJS (   $a_pg_obj,
  $a_content,
  $a_char,
  $a_pc_id,
  $a_insert_at = "" 
)

Save input coming from ajax.

Parameters
@return

Definition at line 1371 of file class.ilPCParagraph.php.

References $ilUser, $t, exit, handleAjaxContent(), and handleAjaxContentPost().

{
global $ilUser;
$t = self::handleAjaxContent($a_content);
if ($text === false)
{
return false;
}
$pc_id = explode(":", $a_pc_id);
$insert_at = explode(":", $a_insert_at);
$t_id = explode(":", $t["id"]);
// insert new paragraph
if ($a_insert_at != "")
{
$par = new ilPCParagraph($this->dom);
$par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
}
else
{
$par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
}
if ($a_insert_at != "")
{
$pc_id = $a_pg_obj->generatePCId();
$par->writePCId($pc_id);
$this->inserted_pc_id = $pc_id;
}
else
{
$this->inserted_pc_id = $pc_id[1];
}
$par->setLanguage($ilUser->getLanguage());
$par->setCharacteristic($t["class"]);
$t2 = $par->input2xml($t["text"], true, false);
$updated = $par->setText($t2, true);
if ($updated !== true)
{
echo $updated; exit;
return false;
}
$updated = $a_pg_obj->update();
return $updated;
}

+ Here is the call graph for this function:

static ilPCParagraph::segmentString (   $a_haystack,
  $a_needles 
)
static

Segments a string into an array at each position of a substring.

Definition at line 959 of file class.ilPCParagraph.php.

Referenced by xml2outputReplaceLists().

{
$segments = array();
$nothing_found = false;
while (!$nothing_found)
{
$nothing_found = true;
$found = -1;
foreach($a_needles as $needle)
{
$pos = stripos($a_haystack, $needle);
if (is_int($pos) && ($pos < $found || $found == -1))
{
$found = $pos;
$found_needle = $needle;
$nothing_found = false;
}
}
if ($found > 0)
{
$segments[] = substr($a_haystack, 0, $found);
$a_haystack = substr($a_haystack, $found);
}
if ($found > -1)
{
$segments[] = substr($a_haystack, 0, strlen($found_needle));
$a_haystack = substr($a_haystack, strlen($found_needle));
}
}
if ($a_haystack != "")
{
$segments[] = $a_haystack;
}
return $segments;
}

+ Here is the caller graph for this function:

ilPCParagraph::setAutoIndent (   $a_char)

Definition at line 401 of file class.ilPCParagraph.php.

{
if (!empty($a_char))
{
$this->par_node->set_attribute("AutoIndent", $a_char);
}
else
{
if ($this->par_node->has_attribute("AutoIndent"))
{
$this->par_node->remove_attribute("AutoIndent");
}
}
}
ilPCParagraph::setCharacteristic (   $a_char)

Set Characteristic of paragraph.

Parameters
string$a_charCharacteristic

Definition at line 344 of file class.ilPCParagraph.php.

{
if (!empty($a_char))
{
$this->par_node->set_attribute("Characteristic", $a_char);
}
else
{
if ($this->par_node->has_attribute("Characteristic"))
{
$this->par_node->remove_attribute("Characteristic");
}
}
}
ilPCParagraph::setDownloadTitle (   $a_char)

set attribute download title

Definition at line 428 of file class.ilPCParagraph.php.

{
if (!empty($a_char))
{
$this->par_node->set_attribute("DownloadTitle", $a_char);
}
else
{
if ($this->par_node->has_attribute("DownloadTitle"))
{
$this->par_node->remove_attribute("DownloadTitle");
}
}
}
ilPCParagraph::setLanguage (   $a_lang)

set language

Definition at line 474 of file class.ilPCParagraph.php.

{
$this->par_node->set_attribute("Language", $a_lang);
}
ilPCParagraph::setNode ( $a_node)

Set Page Content Node.

Parameters
object$a_nodePage Content DOM Node

Reimplemented from ilPageContent.

Definition at line 35 of file class.ilPCParagraph.php.

{
parent::setNode($a_node); // this is the PageContent node
$childs = $a_node->child_nodes();
for ($i=0; $i<count($childs); $i++)
{
if ($childs[$i]->node_name() == "Paragraph")
{
$this->par_node = $childs[$i]; //... and this the Paragraph node
}
}
}
ilPCParagraph::setShowLineNumbers (   $a_char)

set attribute showlinenumbers

Definition at line 455 of file class.ilPCParagraph.php.

{
$a_char = empty($a_char)?"n":$a_char;
$this->par_node->set_attribute("ShowLineNumbers", $a_char);
}
ilPCParagraph::setSubCharacteristic (   $a_char)

set attribute subcharacteristic

Definition at line 376 of file class.ilPCParagraph.php.

{
if (!empty($a_char))
{
$this->par_node->set_attribute("SubCharacteristic", $a_char);
}
else
{
if ($this->par_node->has_attribute("SubCharacteristic"))
{
$this->par_node->remove_attribute("SubCharacteristic");
}
}
}
ilPCParagraph::setText (   $a_text,
  $a_auto_split = false 
)

Set (xml) content of text paragraph.

Parameters
string$a_texttext content
boolean$a_auto_splitauto split paragraph at headlines true/false

Definition at line 128 of file class.ilPCParagraph.php.

References ilPageContent\$node, $ok, $path, $res, $t, autoSplit(), DOMXML_LOAD_PARSING, domxml_open_mem(), getCharacteristic(), getLanguage(), xpath_eval(), and xpath_new_context().

{
//var_dump($a_text);
if (!is_array($a_text))
{
$text = array(array("level" => 0, "text" => $a_text));
}
else
{
$text = $a_text;
}
if ($a_auto_split)
{
$text = $this->autoSplit($a_text);
}
// DOMXML_LOAD_PARSING, DOMXML_LOAD_VALIDATING, DOMXML_LOAD_RECOVERING
$check = "";
foreach ($text as $t)
{
$check.= "<Paragraph>".$t["text"]."</Paragraph>";
}
/*$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
DOMXML_LOAD_PARSING, $error);*/
$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$check.'</Paragraph>',
//$this->text = $a_text;
// remove all childs
if(empty($error))
{
$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
// delete children of paragraph node
$children = $this->par_node->child_nodes();
for($i=0; $i<count($children); $i++)
{
$this->par_node->remove_child($children[$i]);
}
// copy new content children in paragraph node
$xpc = xpath_new_context($temp_dom);
$path = "//Paragraph";
$res =& xpath_eval($xpc, $path);
if (count($res->nodeset) == 1)
{
$new_par_node =& $res->nodeset[0];
$new_childs = $new_par_node->child_nodes();
for($i=0; $i<count($new_childs); $i++)
{
$cloned_child =& $new_childs[$i]->clone_node(true);
$this->par_node->append_child($cloned_child);
}
$orig_characteristic = $this->getCharacteristic();
// if headlines are entered and current characteristic is a headline
// use no characteristic as standard
if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) == "Headline"))
{
$orig_characteristic = "";
}
if ($text[0]["level"] > 0)
{
$this->par_node->set_attribute("Characteristic", 'Headline'.$text[0]["level"]);
}
}
$ok = true;
$c_node = $this->node;
// add other chunks afterwards
for ($i=1; $i<count($text); $i++)
{
if ($ok)
{
$next_par = new ilPCParagraph($this->dom);
$next_par->createAfter($c_node);
$next_par->setLanguage($this->getLanguage());
if ($text[$i]["level"] > 0)
{
$next_par->setCharacteristic("Headline".$text[$i]["level"]);
}
else
{
$next_par->setCharacteristic($orig_characteristic);
}
$ok = $next_par->setText($text[$i]["text"], false);
$c_node = $next_par->node;
}
}
return true;
}
else
{
// We want the correct number of \n here to have the real lines numbers
$text = str_replace("<br>", "\n", $check); // replace <br> with \n to get correct line
$text = str_replace("<br/>", "\n", $text);
$text = str_replace("<br />", "\n", $text);
$text = str_replace("</SimpleListItem>", "</SimpleListItem>\n", $text);
$text = str_replace("<SimpleBulletList>", "\n<SimpleBulletList>", $text);
$text = str_replace("<SimpleNumberedList>", "\n<SimpleNumberedList>", $text);
$text = str_replace("<Paragraph>\n", "<Paragraph>", $text);
$text = str_replace("</Paragraph>", "</Paragraph>\n", $text);
include_once("./Services/Dom/classes/class.ilDomDocument.php");
$doc = new ilDOMDocument();
$text = '<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text.'</Paragraph>';
//echo htmlentities($text);
$this->success = $doc->loadXML($text);
$error = $doc->errors;
$estr = "";
foreach ($error as $e)
{
$e = str_replace(" in Entity", "", $e);
$estr.= $e."<br />";
}
return $estr;
}
}

+ Here is the call graph for this function:

static ilPCParagraph::xml2output (   $a_text,
  $a_wysiwyg = false,
  $a_replace_lists = true 
)
static

Converts xml from DB to output in edit textarea.

Parameters
string$a_textxml from db
Returns
string string ready for edit textarea

Definition at line 1004 of file class.ilPCParagraph.php.

References $target_id, $target_type, ilObject\_lookupType(), ilUtil\attribsToArray(), and xml2outputReplaceLists().

Referenced by ilPCDataTableGUI\editData(), ilPCDataTableGUI\editDataCl(), ilTermListTableGUI\fillRow(), ilPresentationListTableGUI\fillRow(), and ilPageObject\getPageContentsHashes().

{
// note: the order of the processing steps is crucial
// and should be the same as in input2xml() in REVERSE order!
// xml to bb code
$any = "[^>]*";
$a_text = eregi_replace("<Comment[^>]*>","[com]",$a_text);
$a_text = eregi_replace("</Comment>","[/com]",$a_text);
$a_text = eregi_replace("<Comment/>","[com][/com]",$a_text);
$a_text = eregi_replace("<Emph>","[emp]",$a_text);
$a_text = eregi_replace("</Emph>","[/emp]",$a_text);
$a_text = eregi_replace("<Emph/>","[emp][/emp]",$a_text);
$a_text = eregi_replace("<Strong>","[str]",$a_text);
$a_text = eregi_replace("</Strong>","[/str]",$a_text);
$a_text = eregi_replace("<Strong/>","[str][/str]",$a_text);
$a_text = eregi_replace("<Footnote[^>]*>","[fn]",$a_text);
$a_text = eregi_replace("</Footnote>","[/fn]",$a_text);
$a_text = eregi_replace("<Footnote/>","[fn][/fn]",$a_text);
$a_text = eregi_replace("<Quotation[^>]*>","[quot]",$a_text);
$a_text = eregi_replace("</Quotation>","[/quot]",$a_text);
$a_text = eregi_replace("<Quotation/>","[quot][/quot]",$a_text);
$a_text = eregi_replace("<Code[^>]*>","[code]",$a_text);
$a_text = eregi_replace("</Code>","[/code]",$a_text);
$a_text = eregi_replace("<Code/>","[code][/code]",$a_text);
$a_text = eregi_replace("<Accent>","[acc]",$a_text);
$a_text = eregi_replace("</Accent>","[/acc]",$a_text);
$a_text = eregi_replace("<Important>","[imp]",$a_text);
$a_text = eregi_replace("</Important>","[/imp]",$a_text);
$a_text = eregi_replace("<Keyw>","[kw]",$a_text);
$a_text = eregi_replace("</Keyw>","[/kw]",$a_text);
// replace lists
if ($a_replace_lists)
{
//echo "<br>".htmlentities($a_text);
//echo "<br>".htmlentities($a_text);
}
// internal links
while (eregi("<IntLink($any)>", $a_text, $found))
{
$found[0];
$attribs = ilUtil::attribsToArray($found[1]);
$target = explode("_", $attribs["Target"]);
$target_id = $target[count($target) - 1];
$inst_str = (!is_int(strpos($attribs["Target"], "__")))
? $inst_str = "inst=\"".$target[1]."\" "
: $inst_str = "";
switch($attribs["Type"])
{
case "PageObject":
$tframestr = (!empty($attribs["TargetFrame"]))
? " target=\"".$attribs["TargetFrame"]."\""
: "";
$ancstr = (!empty($attribs["Anchor"]))
? ' anchor="'.$attribs["Anchor"].'"'
: "";
$a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."page=\"".$target_id."\"$tframestr$ancstr]",$a_text);
break;
case "StructureObject":
$tframestr = (!empty($attribs["TargetFrame"]))
? " target=\"".$attribs["TargetFrame"]."\""
: "";
$a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."chap=\"".$target_id."\"$tframestr]",$a_text);
break;
case "GlossaryItem":
$tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
? ""
: " target=\"".$attribs["TargetFrame"]."\"";
$a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."term=\"".$target_id."\"".$tframestr."]",$a_text);
break;
case "MediaObject":
if (empty($attribs["TargetFrame"]))
{
$a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."media=\"".$target_id."\"/]",$a_text);
}
else
{
$a_text = eregi_replace("<IntLink".$found[1].">","[iln media=\"".$target_id."\"".
" target=\"".$attribs["TargetFrame"]."\"]",$a_text);
}
break;
// Repository Item (using ref id)
case "RepositoryItem":
if ($inst_str == "")
{
}
else
{
$rtype = $target[count($target) - 2];
$target_type = $rtype;
}
$a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."$target_type=\"".$target_id."\"".$tframestr."]",$a_text);
break;
// Download File (not in repository, Object ID)
case "File":
$a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."dfile=\"".$target_id."\"".$tframestr."]",$a_text);
break;
default:
$a_text = eregi_replace("<IntLink".$found[1].">","[iln]",$a_text);
break;
}
}
$a_text = eregi_replace("</IntLink>","[/iln]",$a_text);
// external links
while (eregi("<ExtLink($any)>", $a_text, $found))
{
$found[0];
$attribs = ilUtil::attribsToArray($found[1]);
//$found[1] = str_replace("?", "\?", $found[1]);
$tstr = "";
if (in_array($attribs["TargetFrame"], array("FAQ", "Glossary", "Media")))
{
$tstr = ' target="'.$attribs["TargetFrame"].'"';
}
$a_text = str_replace("<ExtLink".$found[1].">","[xln url=\"".$attribs["Href"]."\"$tstr]",$a_text);
}
$a_text = eregi_replace("</ExtLink>","[/xln]",$a_text);
// anchor
while (eregi("<Anchor($any)>", $a_text, $found))
{
$found[0];
$attribs = ilUtil::attribsToArray($found[1]);
$a_text = str_replace("<Anchor".$found[1].">","[anc name=\"".$attribs["Name"]."\"]",$a_text);
}
$a_text = eregi_replace("</Anchor>","[/anc]",$a_text);
// br to linefeed
if (!$a_wysiwyg)
{
$a_text = str_replace("<br />", "\n", $a_text);
$a_text = str_replace("<br/>", "\n", $a_text);
}
if (!$a_wysiwyg)
{
// prevent curly brackets from being swallowed up by template engine
$a_text = str_replace("{", "&#123;", $a_text);
$a_text = str_replace("}", "&#125;", $a_text);
// unmask html
$a_text = str_replace("&lt;", "<", $a_text);
$a_text = str_replace("&gt;", ">",$a_text);
// this is needed to allow html like <tag attribute="value">... in paragraphs
$a_text = str_replace("&quot;", "\"", $a_text);
// make ampersands in (enabled) html attributes work
// e.g. <a href="foo.php?n=4&t=5">hhh</a>
$a_text = str_replace("&amp;", "&", $a_text);
// make &gt; and $lt; work to allow (disabled) html descriptions
$a_text = str_replace("&lt;", "&amp;lt;", $a_text);
$a_text = str_replace("&gt;", "&amp;gt;", $a_text);
}
return $a_text;
//return str_replace("<br />", chr(13).chr(10), $a_text);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPCParagraph::xml2outputReplaceLists (   $a_text)
static

Replaces

with *.

Parameters
string$a_textxml from db
Returns
string string containing * for lists

Definition at line 863 of file class.ilPCParagraph.php.

References segmentString().

Referenced by xml2output().

{
$segments = ilPCParagraph::segmentString($a_text, array("<SimpleBulletList>", "</SimpleBulletList>",
"</SimpleListItem>", "<SimpleListItem>", "<SimpleListItem/>", "<SimpleNumberedList>", "</SimpleNumberedList>"));
$current_list = array();
$text = "";
for ($i=0; $i<= count($segments); $i++)
{
if ($segments[$i] == "<SimpleBulletList>")
{
if (count($current_list) == 0)
{
$list_start = true;
}
array_push($current_list, "*");
$li = false;
}
else if ($segments[$i] == "<SimpleNumberedList>")
{
if (count($current_list) == 0)
{
$list_start = true;
}
array_push($current_list, "#");
$li = false;
}
else if ($segments[$i] == "</SimpleBulletList>")
{
array_pop($current_list);
$li = false;
}
else if ($segments[$i] == "</SimpleNumberedList>")
{
array_pop($current_list);
$li = false;
}
else if ($segments[$i] == "<SimpleListItem>")
{
$li = true;
}
else if ($segments[$i] == "</SimpleListItem>")
{
$li = false;
}
else if ($segments[$i] == "<SimpleListItem/>")
{
if ($list_start)
{
$text.= "<br />";
$list_start = false;
}
foreach($current_list as $list)
{
$text.= $list;
}
$text.= "<br />";
$li = false;
}
else
{
if ($li)
{
if ($list_start)
{
$text.= "<br />";
$list_start = false;
}
foreach($current_list as $list)
{
$text.= $list;
}
}
$text.= $segments[$i];
if ($li)
{
$text.= "<br />";
}
$li = false;
}
}
// remove trailing <br />, if text ends with list
if ($segments[count($segments) - 1] == "</SimpleBulletList>" ||
$segments[count($segments) - 1] == "</SimpleNumberedList>" &&
substr($text, strlen($text) - 6) == "<br />")
{
$text = substr($text, 0, strlen($text) - 6);
}
return $text;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilPCParagraph::$dom

Definition at line 19 of file class.ilPCParagraph.php.

ilPCParagraph::$par_node

Definition at line 20 of file class.ilPCParagraph.php.


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