ILIAS  Release_5_0_x_branch Revision 61816
 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.
 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)
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl.

Static Public Member Functions

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 getLangVars ()
 Get lang vars needed for editing.
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content.

Data Fields

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

Static Protected Member Functions

static linkTermsInDom ($a_dom, $a_terms, $a_par_node=null)
 Link terms in a dom page object in bb style.

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:
class.ilPCParagraph.php 56983 2015-01-10 07:36:09Z akill

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

Member Function Documentation

static ilPCParagraph::_deleteAnchors (   $a_parent_type,
  $a_page_id,
  $a_page_lang 
)
static

Delete anchors of a page.

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

References $ilDB.

Referenced by beforePageDelete(), and saveAnchors().

{
global $ilDB;
$ilDB->manipulate("DELETE FROM page_anchor WHERE ".
" page_parent_type = ".$ilDB->quote($a_parent_type, "text").
" AND page_id = ".$ilDB->quote($a_page_id, "integer").
" AND page_lang = ".$ilDB->quote($a_page_lang, "text")
);
}

+ Here is the caller graph for this function:

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

converts user input to xml

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

References ilUtil\attribsToArray(), input2xmlReplaceLists(), intLinks2xml(), 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);
$a_text = self::intLinks2xml($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:

static ilPCParagraph::_readAnchors (   $a_parent_type,
  $a_page_id,
  $a_page_lang = "-" 
)
static

Read anchors of a page.

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

References $ilDB.

Referenced by ilInternalLinkGUI\showLinkHelp().

{
global $ilDB;
$and_lang = ($a_page_lang != "")
? " AND page_lang = ".$ilDB->quote($a_page_lang, "text")
: "";
$set = $ilDB->query("SELECT * FROM page_anchor ".
" WHERE page_parent_type = ".$ilDB->quote($a_parent_type, "text").
" AND page_id = ".$ilDB->quote($a_page_id, "integer").
$and_lang
);
$anchors = array();
while ($rec = $ilDB->fetchAssoc($set))
{
$anchors[] = $rec["anchor_name"];
}
return $anchors;
}

+ Here is the caller graph for this function:

static ilPCParagraph::_saveAnchor (   $a_parent_type,
  $a_page_id,
  $a_page_lang,
  $a_anchor_name 
)
static

Save an anchor.

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

References $ilDB.

Referenced by saveAnchors().

{
global $ilDB;
$ilDB->manipulate("INSERT INTO page_anchor ".
"(page_parent_type, page_id, page_lang, anchor_name) VALUES (".
$ilDB->quote($a_parent_type, "text").",".
$ilDB->quote($a_page_id, "integer").",".
$ilDB->quote($a_page_lang, "text").",".
$ilDB->quote($a_anchor_name, "text").
")");
}

+ Here is the caller graph for this function:

static ilPCParagraph::afterPageHistoryEntry (   $a_page,
DOMDocument  $a_old_domdoc,
  $a_old_xml,
  $a_old_nr 
)
static

After page history entry has been created.

Parameters
object$a_pagepage object
DOMDocument$a_old_domdocold dom document
string$a_old_xmlold xml
integer$a_old_nrhistory number

Reimplemented from ilPageContent.

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

{
}
static ilPCParagraph::afterPageUpdate (   $a_page,
DOMDocument  $a_domdoc,
  $a_xml,
  $a_creation 
)
static

After page has been updated (or created)

Parameters
object$a_pagepage object
DOMDocument$a_domdocdom document
string$a_xmlxml
bool$a_creationtrue on creation, otherwise false

Reimplemented from ilPageContent.

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

References saveAnchors(), and saveMetaKeywords().

{
// pc paragraph
self::saveMetaKeywords($a_page, $a_domdoc);
self::saveAnchors($a_page, $a_domdoc);
}

+ Here is the call graph for this function:

ilPCParagraph::autoLinkGlossaries (   $a_glos)

Auto link glossaries.

Parameters
@return

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

References $t, ilObject\_lookupType(), ilGlossaryTerm\getTermList(), getText(), and linkTermsInDom().

{
if (is_array($a_glos) && count($a_glos) > 0)
{
include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
// check which terms occur in the text (we may
// get some false positives due to the strip_tags, but
// we do not want to find strong or list or other stuff
// within the tags
$text = strip_tags($this->getText());
$found_terms = array();
foreach ($a_glos as $glo)
{
if (ilObject::_lookupType($glo) == "glo")
{
foreach ($terms as $t)
{
if (is_int(stripos($text, $t["term"])))
{
$found_terms[$t["id"]] = $t;
}
}
}
}
// did we find anything? -> modify content
if (count($found_terms) > 0)
{
self::linkTermsInDom($this->dom, $found_terms, $this->par_node);
}
}
}

+ Here is the call graph for this function:

static ilPCParagraph::autoLinkGlossariesPage (   $a_page,
  $a_terms 
)
static

Auto link glossary of whole page.

Parameters
@return

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

References linkTermsInDom().

Referenced by ilObjContentObject\autoLinkGlossaryTerms().

{
$a_page->buildDom();
$a_dom = $a_page->getDom();
self::linkTermsInDom($a_dom, $a_terms);
$a_page->update();
}

+ 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 1215 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:

static ilPCParagraph::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
object$a_pagepage object

Reimplemented from ilPageContent.

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

References _deleteAnchors().

{
// delete anchors
self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
}

+ Here is the call 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 107 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 83 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 54 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 68 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 395 of file class.ilPCParagraph.php.

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

Get characteristic of paragraph.

Returns
string characteristic

Definition at line 363 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 445 of file class.ilPCParagraph.php.

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

get language

Definition at line 481 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 1464 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 277 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 465 of file class.ilPCParagraph.php.

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

get attribute subcharacteristic

Definition at line 418 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 256 of file class.ilPCParagraph.php.

Referenced by autoLinkGlossaries().

{
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 "";
}
}

+ Here is the caller graph for this function:

ilPCParagraph::getType ( )

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

Reimplemented from ilPageContent.

Definition at line 1390 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 1491 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 1593 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 1355 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.

Reimplemented in ilPCSourceCode.

Definition at line 24 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 486 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 796 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:

static ilPCParagraph::intLinks2xml (   $a_text)
static

internal links to xml

Parameters
@return

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

References $t, and ilUtil\attribsToArray().

Referenced by _input2xml(), and linkTermsInDom().

{
global $objDefinition;
$rtypes = $objDefinition->getAllRepositoryTypes();
// internal links
//$any = "[^\]]*"; // this doesn't work :-(
$ws= "[ \t\r\f\v\n]*";
$ltypes = "page|chap|term|media|obj|dfile|sess|wpage|".implode($rtypes, "|");
// 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);
}
// wiki pages
else if (isset($attribs["wpage"]))
{
$tframestr = "";
/* 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."_wpage_".$attribs[wpage]."\" Type=\"WikiPage\" $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
{
foreach ($objDefinition->getAllRepositoryTypes() as $t)
{
if (isset($attribs[$t]))
{
$obj_id = $attribs[$t];
}
}
if (isset($attribs["obj"]))
{
$obj_id = $attribs["obj"];
}
if ($obj_id > 0)
{
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);
return $a_text;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilPCParagraph::linkTermsInDom (   $a_dom,
  $a_terms,
  $a_par_node = null 
)
staticprotected

Link terms in a dom page object in bb style.

Parameters
@return

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

References ilPageContent\$node, $t, DOMXML_LOAD_PARSING, domxml_open_mem(), intLinks2xml(), ilUtil\sortArray(), ilStr\strIPos(), ilStr\strLen(), and ilStr\subStr().

Referenced by autoLinkGlossaries(), and autoLinkGlossariesPage().

{
// sort terms by their length (shortes first)
// to prevent that nested tags are builded
foreach ($a_terms as $k => $t)
{
$a_terms[$k]["termlength"] = strlen($t["term"]);
}
$a_terms = ilUtil::sortArray($a_terms, "termlength", "asc", true);
if ($a_dom instanceof php4DOMDocument)
{
$a_dom = $a_dom->myDOMDocument;
}
if ($a_par_node instanceof php4DOMElement)
{
$a_par_node = $a_par_node->myDOMNode;
}
$xpath = new DOMXPath($a_dom);
if ($a_par_node == null)
{
$parnodes = $xpath->query('//Paragraph');
}
else
{
$parnodes = $xpath->query('//Paragraph', $a_par_node);
}
include_once("./Services/Utilities/classes/class.ilStr.php");
foreach ($parnodes as $parnode)
{
$textnodes = $xpath->query('//text()', $parnode);
foreach ($textnodes as $node)
{
$p = $node->getNodePath();
// we do not change text nodes inside of links
if (!is_int(strpos($p, "/IntLink")) &&
!is_int(strpos($p, "/ExtLink")))
{
$node_val = $node->nodeValue;
// all terms
foreach ($a_terms as $t)
{
$pos = ilStr::strIPos($node_val, $t["term"]);
// if term found
while (is_int($pos))
{
// check if the string is not included in another word
// note that []
$valid_limiters = array("", " ","&nbsp;", ".", ",", ":", ";", "!", "?", "\"", "'", "(", ")");
$b = ($pos > 0)
? ilStr::subStr($node_val, $pos - 1, 1)
: "";
$a = ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]), 1);
if ((in_array($b, $valid_limiters) || htmlentities($b, null, 'utf-8') == "&nbsp;")&& in_array($a, $valid_limiters))
{
$mid = '[iln term="'.$t["id"].'"]'.
ilStr::subStr($node_val, $pos, ilStr::strLen($t["term"])).
"[/iln]";
$node_val = ilStr::subStr($node_val, 0, $pos).
$mid.
ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]))
;
$pos+= ilStr::strLen($mid);
}
else
{
$pos+= ilStr::strLen($t["term"]);
}
$pos = ilStr::strIPos($node_val, $t["term"], $pos);
}
// insert [iln] tags
}
$node->nodeValue = $node_val;
}
// var_dump($p);
// var_dump($node->nodeValue);
}
// dump paragraph node
$text = $a_dom->saveXML($parnode);
$text = substr($text, 0, strlen($text) - strlen("</Paragraph>"));
$text = substr($text, strpos($text, ">") + 1);
// replace [iln] by tags with xml representation
$text = self::intLinks2xml($text);
// "set text"
$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text.'</Paragraph>',
$temp_dom = $temp_dom->myDOMDocument;
if(empty($error))
{
// delete children of paragraph node
$children = $parnode->childNodes;
while ($parnode->hasChildNodes())
{
$parnode->removeChild($parnode->firstChild);
}
// copy new content children in paragraph node
$xpath_temp = new DOMXPath($temp_dom);
$temp_pars = $xpath_temp->query("//Paragraph");
foreach ($temp_pars as $new_par_node)
{
$new_childs = $new_par_node->childNodes;
foreach($new_childs as $new_child)
{
//$cloned_child = $new_child->cloneNode(true);
$cloned_child = $a_dom->importNode($new_child, true);
$parnode->appendChild($cloned_child);
}
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCParagraph::removeTrailingBr (   $a_str)

Remove trailing

Definition at line 1378 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::saveAnchors (   $a_page,
  $a_domdoc 
)

Save anchors.

Parameters
stringxml page code

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

References ilPageContent\$node, _deleteAnchors(), and _saveAnchor().

Referenced by afterPageUpdate().

{
self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
// get all anchors
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query('//Anchor');
$saved = array();
foreach ($nodes as $node)
{
$name = $node->getAttribute("Name");
if (trim($name) != "" && !in_array($name, $saved))
{
self::_saveAnchor($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $name);
$saved[] = $name;
}
}
}

+ Here is the call graph for this function:

+ 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 1405 of file class.ilPCParagraph.php.

References $ilUser, $t, exit, ilPageContent\getPage(), 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->getPage());
$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 = $par->updatePage($a_pg_obj);
//$updated = $a_pg_obj->update();
return $updated;
}

+ Here is the call graph for this function:

ilPCParagraph::saveMetaKeywords (   $a_page,
  $a_domdoc 
)

save all keywords

Parameters
object$a_pagepage object
object$a_domdocdom document

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

References $lang, ilPageContent\$node, and ilUtil\stripSlashes().

Referenced by afterPageUpdate().

{
// not nice, should be set by context per method
if ($a_page->getParentType() == "gdf" ||
$a_page->getParentType() == "lm")
{
// get existing keywords
$keywords = array();
// find all Keyw tags
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query('//Keyw');
foreach($nodes as $node)
{
$k = trim(strip_tags($node->nodeValue));
if (!in_array($k, $keywords))
{
$keywords[] = $k;
}
}
$meta_type = ($a_page->getParentType() == "gdf")
? "gdf"
: "pg";
$meta_rep_id = $a_page->getParentId();
$meta_id = $a_page->getId();
include_once("./Services/MetaData/classes/class.ilMD.php");
$md_obj = new ilMD($meta_rep_id, $meta_id, $meta_type);
$mkeywords = array();
$lang = "";
if(is_object($md_section = $md_obj->getGeneral()))
{
foreach($ids = $md_section->getKeywordIds() as $id)
{
$md_key = $md_section->getKeyword($id);
$mkeywords[] = strtolower($md_key->getKeyword());
if ($lang == "")
{
$lang = $md_key->getKeywordLanguageCode();
}
}
if ($lang == "")
{
foreach($ids = $md_section->getLanguageIds() as $id)
{
$md_lang = $md_section->getLanguage($id);
if ($lang == "")
{
$lang = $md_lang->getLanguageCode();
}
}
}
foreach ($keywords as $k)
{
if (!in_array(strtolower($k), $mkeywords))
{
if (trim($k) != "" && $lang != "")
{
$md_key = $md_section->addKeyword();
$md_key->setKeyword(ilUtil::stripSlashes($k));
$md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
$md_key->save();
}
$mkeywords[] = strtolower($k);
}
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller 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 979 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 400 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 343 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 427 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 473 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 34 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 454 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 375 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 127 of file class.ilPCParagraph.php.

References ilPageContent\$node, $ok, $path, $res, $t, autoSplit(), DOMXML_LOAD_PARSING, domxml_open_mem(), getCharacteristic(), getLanguage(), ilPageContent\getPage(), 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->getPage());
$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:

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

Parameters
@return

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

References $ret.

{
$a_page->beforePageContentUpdate($this);
$ret = $a_page->update();
return $ret;
}
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 1024 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 "WikiPage":
$tframestr = "";
/*$tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
? ""
: " target=\"".$attribs["TargetFrame"]."\"";*/
$a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."wpage=\"".$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"]."\"][/anc]",$a_text);
}
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 883 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 18 of file class.ilPCParagraph.php.

Referenced by ilPCSourceCode\modifyPageContentPostXsl().

ilPCParagraph::$par_node

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


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