ILIAS  release_4-4 Revision
ilPCParagraph Class Reference

Class ilPCParagraph. More...

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

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode (&$a_node)
 Set Page Content Node. More...
 
 createAtNode (&$node)
 Create new page content (incl. More...
 
 createBeforeNode (&$node)
 Create new page content (incl. More...
 
 createAfter ($node)
 Create paragraph node (incl. More...
 
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 Create paragraph node (incl. More...
 
 setText ($a_text, $a_auto_split=false)
 Set (xml) content of text paragraph. More...
 
 getText ($a_short_mode=false)
 Get (xml) content of paragraph. More...
 
 getParagraphSequenceContent ($a_pg_obj)
 Get paragraph sequenc of current paragraph. More...
 
 setCharacteristic ($a_char)
 Set Characteristic of paragraph. More...
 
 getCharacteristic ()
 Get characteristic of paragraph. More...
 
 setSubCharacteristic ($a_char)
 set attribute subcharacteristic More...
 
 getAutoIndent ()
 Get AutoIndent (Code Paragraphs) More...
 
 setAutoIndent ($a_char)
 
 getSubCharacteristic ()
 get attribute subcharacteristic More...
 
 setDownloadTitle ($a_char)
 set attribute download title More...
 
 getDownloadTitle ()
 get attribute download title More...
 
 setShowLineNumbers ($a_char)
 set attribute showlinenumbers More...
 
 getShowLineNumbers ()
 get attribute showlinenumbers More...
 
 setLanguage ($a_lang)
 set language More...
 
 getLanguage ()
 get language More...
 
 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. More...
 
 handleNextBr ($a_str)
 Remove preceding
More...
 
 removeTrailingBr ($a_str)
 Remove trailing
More...
 
 getType ()
 Need to override getType from ilPageContent to distinguish between Pararagraph and Source. More...
 
 saveJS ($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at="")
 Save input coming from ajax. More...
 
 getLastSavedPCId ($a_pg_obj, $a_as_ajax_str=false)
 Get last inserted pc ids. More...
 
 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) More...
 
 autoLinkGlossaries ($a_glos)
 Auto link glossaries. More...
 
 saveAnchors ($a_page, $a_domdoc)
 Save anchors. More...
 
 saveMetaKeywords ($a_page, $a_domdoc)
 save all keywords More...
 
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 init ()
 Init object. More...
 
 getType ()
 Get type of page content. More...
 
 setNode (&$a_node)
 Set xml node of page content. More...
 
getNode ()
 Get xml node of page content. More...
 
 getJavascriptFiles ()
 Get Javascript files. More...
 
 getCssFiles ()
 Get css files. More...
 
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure. More...
 
 getHierId ()
 Get hierarchical id. More...
 
 lookupHierId ()
 Get hierarchical id from dom. More...
 
 readHierId ()
 Read PC Id. More...
 
 setPcId ($a_pcid)
 Set PC Id. More...
 
 getPCId ()
 Get PC Id. More...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b. More...
 
 setEnabled ($value)
 Set Enabled value for page content component. More...
 
 enable ()
 Enable page content. More...
 
 disable ()
 Disable page content. More...
 
 isEnabled ()
 Check whether page content is enabled. More...
 
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl. More...
 

Static Public Member Functions

static _input2xml ($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
 converts user input to xml More...
 
static intLinks2xml ($a_text)
 internal links to xml More...
 
static input2xmlReplaceLists ($a_text)
 Converts xml from DB to output in edit textarea. More...
 
static xml2outputReplaceLists ($a_text)
 Replaces

with *. More...

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

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. More...
 

Additional Inherited Members

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

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

Member Function Documentation

◆ _deleteAnchors()

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

Delete anchors of a page.

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

1897  {
1898  global $ilDB;
1899 
1900  $ilDB->manipulate("DELETE FROM page_anchor WHERE ".
1901  " page_parent_type = ".$ilDB->quote($a_parent_type, "text").
1902  " AND page_id = ".$ilDB->quote($a_page_id, "integer").
1903  " AND page_lang = ".$ilDB->quote($a_page_lang, "text")
1904  );
1905  }

◆ _input2xml()

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(), and ilUtil\stripSlashes().

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

495  {
496  if (!$a_wysiwyg)
497  {
498  $a_text = ilUtil::stripSlashes($a_text, false);
499  }
500 
501  if ($a_wysiwyg)
502  {
503  $a_text = str_replace("<br />", chr(10), $a_text);
504  }
505 
506  // note: the order of the processing steps is crucial
507  // and should be the same as in xml2output() in REVERSE order!
508  $a_text = trim($a_text);
509 
510 //echo "<br>between:".htmlentities($a_text);
511 
512  // mask html
513 if (!$a_wysiwyg)
514 {
515  $a_text = str_replace("&","&amp;",$a_text);
516 }
517  $a_text = str_replace("<","&lt;",$a_text);
518  $a_text = str_replace(">","&gt;",$a_text);
519 
520  // Reconvert PageTurn and BibItemIdentifier
521  $a_text = preg_replace('/&lt;([\s\/]*?PageTurn.*?)&gt;/i',"<$1>",$a_text);
522  $a_text = preg_replace('/&lt;([\s\/]*?BibItemIdentifier.*?)&gt;/i',"<$1>",$a_text);
523 
524 //echo "<br>second:".htmlentities($a_text);
525 
526  // mask curly brackets
527 /*
528 echo htmlentities($a_text);
529  $a_text = str_replace("{", "&#123;", $a_text);
530  $a_text = str_replace("}", "&#125;", $a_text);
531 echo htmlentities($a_text);*/
532  // linefeed to br
533  $a_text = str_replace(chr(13).chr(10),"<br />",$a_text);
534  $a_text = str_replace(chr(13),"<br />", $a_text);
535  $a_text = str_replace(chr(10),"<br />", $a_text);
536 
537  if ($a_handle_lists)
538  {
539  $a_text = ilPCParagraph::input2xmlReplaceLists($a_text);
540  }
541 
542  // remove empty tags
543  $atags = array("com", "emp", "str", "fn", "quot", "code", "acc", "imp", "kw");
544  foreach ($atags as $at)
545  {
546  $a_text = str_replace("[".$at."][/".$at."]", "", $a_text);
547  }
548 
549  // bb code to xml
550  $a_text = eregi_replace("\[com\]","<Comment Language=\"".$a_lang."\">",$a_text);
551  $a_text = eregi_replace("\[\/com\]","</Comment>",$a_text);
552  $a_text = eregi_replace("\[emp\]","<Emph>",$a_text);
553  $a_text = eregi_replace("\[\/emp\]","</Emph>",$a_text);
554  $a_text = eregi_replace("\[str\]","<Strong>",$a_text);
555  $a_text = eregi_replace("\[\/str\]","</Strong>",$a_text);
556  $a_text = eregi_replace("\[fn\]","<Footnote>",$a_text);
557  $a_text = eregi_replace("\[\/fn\]","</Footnote>",$a_text);
558  $a_text = eregi_replace("\[quot\]","<Quotation Language=\"".$a_lang."\">",$a_text);
559  $a_text = eregi_replace("\[\/quot\]","</Quotation>",$a_text);
560  $a_text = eregi_replace("\[code\]","<Code>",$a_text);
561  $a_text = eregi_replace("\[\/code\]","</Code>",$a_text);
562  $a_text = eregi_replace("\[acc\]","<Accent>",$a_text);
563  $a_text = eregi_replace("\[\/acc\]","</Accent>",$a_text);
564  $a_text = eregi_replace("\[imp\]","<Important>",$a_text);
565  $a_text = eregi_replace("\[\/imp\]","</Important>",$a_text);
566  $a_text = eregi_replace("\[kw\]","<Keyw>",$a_text);
567  $a_text = eregi_replace("\[\/kw\]","</Keyw>",$a_text);
568 
569  $a_text = self::intLinks2xml($a_text);
570 
571  // external link
572  $ws= "[ \t\r\f\v\n]*";
573  // remove empty external links
574  while (eregi("\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]", $a_text, $found))
575  {
576  $a_text = str_replace($found[0], "",$a_text);
577  }
578  while (eregi("\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]", $a_text, $found))
579  {
580  $a_text = str_replace($found[0], "",$a_text);
581  }
582  // external links
583  while (eregi("\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]", $a_text, $found))
584  {
585  $attribs = ilUtil::attribsToArray($found[2]);
586  if (isset($attribs["url"]))
587  {
588  $a2 = ilUtil::attribsToArray($found[4]);
589  $tstr = "";
590  if (in_array($a2["target"], array("FAQ", "Glossary", "Media")))
591  {
592  $tstr = ' TargetFrame="'.$a2["target"].'"';
593  }
594  $a_text = str_replace("[".$found[1]."]", "<ExtLink Href=\"".$attribs["url"]."\"$tstr>", $a_text);
595  }
596  else
597  {
598  $a_text = str_replace("[".$found[1]."]", "[error: xln".$found[1]."]",$a_text);
599  }
600  }
601 
602  // ie/tinymce fix for links without "", see bug #8391
603  while (eregi("\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]", $a_text, $found))
604  {
605  if ($found[3] != "")
606  {
607  $a_text = str_replace("[".$found[1]."]", "<ExtLink Href=\"".$found[3]."\">", $a_text);
608  }
609  else
610  {
611  $a_text = str_replace("[".$found[1]."]", "[error: xln".$found[1]."]",$a_text);
612  }
613  }
614  $a_text = eregi_replace("\[\/xln\]","</ExtLink>",$a_text);
615 
616  // anchor
617  $ws= "[ \t\r\f\v\n]*";
618  while (eregi("\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]", $a_text, $found))
619  {
620  $attribs = ilUtil::attribsToArray($found[2]);
621  $a_text = str_replace("[".$found[1]."]", "<Anchor Name=\"".$attribs["name"]."\">", $a_text);
622  }
623  $a_text = eregi_replace("\[\/anc\]","</Anchor>",$a_text);
624 //echo htmlentities($a_text); exit;
625  return $a_text;
626  }
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
static input2xmlReplaceLists($a_text)
Converts xml from DB to output in edit textarea.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _readAnchors()

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

Read anchors of a page.

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

Referenced by ilInternalLinkGUI\showLinkHelp().

1927  {
1928  global $ilDB;
1929 
1930  $and_lang = ($a_page_lang != "")
1931  ? " AND page_lang = ".$ilDB->quote($a_page_lang, "text")
1932  : "";
1933 
1934  $set = $ilDB->query("SELECT * FROM page_anchor ".
1935  " WHERE page_parent_type = ".$ilDB->quote($a_parent_type, "text").
1936  " AND page_id = ".$ilDB->quote($a_page_id, "integer").
1937  $and_lang
1938  );
1939  $anchors = array();
1940  while ($rec = $ilDB->fetchAssoc($set))
1941  {
1942  $anchors[] = $rec["anchor_name"];
1943  }
1944  return $anchors;
1945  }
+ Here is the caller graph for this function:

◆ _saveAnchor()

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

Save an anchor.

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

1911  {
1912  global $ilDB;
1913 
1914  $ilDB->manipulate("INSERT INTO page_anchor ".
1915  "(page_parent_type, page_id, page_lang, anchor_name) VALUES (".
1916  $ilDB->quote($a_parent_type, "text").",".
1917  $ilDB->quote($a_page_id, "integer").",".
1918  $ilDB->quote($a_page_lang, "text").",".
1919  $ilDB->quote($a_anchor_name, "text").
1920  ")");
1921  }

◆ afterPageHistoryEntry()

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

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

1865  {
1866  }

◆ afterPageUpdate()

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

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

1839  {
1840  // pc paragraph
1841  self::saveMetaKeywords($a_page, $a_domdoc);
1842  self::saveAnchors($a_page, $a_domdoc);
1843  }

◆ autoLinkGlossaries()

ilPCParagraph::autoLinkGlossaries (   $a_glos)

Auto link glossaries.

Parameters

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

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

1644  {
1645  if (is_array($a_glos) && count($a_glos) > 0)
1646  {
1647  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1648 
1649  // check which terms occur in the text (we may
1650  // get some false positives due to the strip_tags, but
1651  // we do not want to find strong or list or other stuff
1652  // within the tags
1653  $text = strip_tags($this->getText());
1654  $found_terms = array();
1655  foreach ($a_glos as $glo)
1656  {
1657  if (ilObject::_lookupType($glo) == "glo")
1658  {
1659  $terms = ilGlossaryTerm::getTermList($glo);
1660  foreach ($terms as $t)
1661  {
1662  if (is_int(stripos($text, $t["term"])))
1663  {
1664  $found_terms[$t["id"]] = $t;
1665  }
1666  }
1667  }
1668  }
1669 
1670  // did we find anything? -> modify content
1671  if (count($found_terms) > 0)
1672  {
1673  self::linkTermsInDom($this->dom, $found_terms, $this->par_node);
1674  }
1675  }
1676  }
static getTermList($a_glo_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, $a_amet_filter="")
Get all terms for given set of glossary ids.
getText($a_short_mode=false)
Get (xml) content of paragraph.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ autoLinkGlossariesPage()

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

Auto link glossary of whole page.

Parameters

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

Referenced by ilObjContentObject\autoLinkGlossaryTerms().

1821  {
1822  $a_page->buildDom();
1823  $a_dom = $a_page->getDom();
1824 
1825  self::linkTermsInDom($a_dom, $a_terms);
1826 
1827  $a_page->update();
1828  }
+ Here is the caller graph for this function:

◆ autoSplit()

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

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

Referenced by setText().

1210  {
1211  $a_text = str_replace ("=<SimpleBulletList>", "=<br /><SimpleBulletList>", $a_text);
1212  $a_text = str_replace ("=<SimpleNumberedList>", "=<br /><SimpleNumberedList>", $a_text);
1213  $a_text = str_replace ("</SimpleBulletList>=", "</SimpleBulletList><br />=", $a_text);
1214  $a_text = str_replace ("</SimpleNumberedList>=", "</SimpleNumberedList><br />=", $a_text);
1215  $a_text = "<br />".$a_text."<br />"; // add preceding and trailing br
1216 
1217  $chunks = array();
1218  $c_text = $a_text;
1219 //echo "0";
1220  while ($c_text != "")
1221  {
1222 //var_dump($c_text); flush();
1223 //echo "1";
1224  $s1 = strpos($c_text, "<br />=");
1225  if (is_int($s1))
1226  {
1227 //echo "2";
1228  $s2 = strpos($c_text, "<br />==");
1229  if (is_int($s2) && $s2 <= $s1)
1230  {
1231 //echo "3";
1232  $s3 = strpos($c_text, "<br />===");
1233  if (is_int($s3) && $s3 <= $s2) // possible level three header
1234  {
1235 //echo "4";
1236  $n = strpos($c_text, "<br />", $s3 + 1);
1237  if ($n > ($s3+9) && substr($c_text, $n-3, 9) == "===<br />")
1238  {
1239 //echo "5";
1240  // found level three header
1241  if ($s3 > 0 || $head != "")
1242  {
1243 //echo "6";
1244  $chunks[] = array("level" => 0,
1245  "text" => $this->removeTrailingBr($head.substr($c_text, 0, $s3)));
1246  $head = "";
1247  }
1248  $chunks[] = array("level" => 3,
1249  "text" => trim(substr($c_text, $s3+9, $n-$s3-12)));
1250  $c_text = $this->handleNextBr(substr($c_text, $n+6));
1251  }
1252  else
1253  {
1254 //echo "7";
1255  $head.= substr($c_text, 0, $n);
1256  $c_text = substr($c_text, $n);
1257  }
1258  }
1259  else // possible level two header
1260  {
1261 //echo "8";
1262  $n = strpos($c_text, "<br />", $s2 + 1);
1263  if ($n > ($s2+8) && substr($c_text, $n-2, 8) == "==<br />")
1264  {
1265 //echo "9";
1266  // found level two header
1267  if ($s2 > 0 || $head != "")
1268  {
1269 //echo "A";
1270  $chunks[] = array("level" => 0,
1271  "text" => $this->removeTrailingBr($head.substr($c_text, 0, $s2)));
1272  $head = "";
1273  }
1274  $chunks[] = array("level" => 2, "text" => trim(substr($c_text, $s2+8, $n-$s2-10)));
1275  $c_text = $this->handleNextBr(substr($c_text, $n+6));
1276  }
1277  else
1278  {
1279 //echo "B";
1280  $head.= substr($c_text, 0, $n);
1281  $c_text = substr($c_text, $n);
1282  }
1283  }
1284  }
1285  else // possible level one header
1286  {
1287 //echo "C";
1288  $n = strpos($c_text, "<br />", $s1 + 1);
1289  if ($n > ($s1+7) && substr($c_text, $n-1, 7) == "=<br />")
1290  {
1291 //echo "D";
1292  // found level one header
1293  if ($s1 > 0 || $head != "")
1294  {
1295 //echo "E";
1296  $chunks[] = array("level" => 0,
1297  "text" => $this->removeTrailingBr($head.substr($c_text, 0, $s1)));
1298  $head = "";
1299  }
1300  $chunks[] = array("level" => 1, "text" => trim(substr($c_text, $s1+7, $n-$s1-8)));
1301  $c_text = $this->handleNextBr(substr($c_text, $n+6));
1302 //echo "<br>ctext:".htmlentities($c_text)."<br>";
1303  }
1304  else
1305  {
1306  $head.= substr($c_text, 0, $n);
1307  $c_text = substr($c_text, $n);
1308 //echo "<br>head:".$head."c_text:".$c_text."<br>";
1309  }
1310  }
1311  }
1312  else
1313  {
1314 //echo "G";
1315  $chunks[] = array("level" => 0, "text" => $head.$c_text);
1316  $head = "";
1317  $c_text = "";
1318  }
1319  }
1320  if (count($chunks) == 0)
1321  {
1322  $chunks[] = array("level" => 0, "text" => "");
1323  }
1324 
1325 
1326  // remove preceding br
1327  if (substr($chunks[0]["text"], 0, 6) == "<br />")
1328  {
1329  $chunks[0]["text"] = substr($chunks[0]["text"], 6);
1330  }
1331 
1332  // remove trailing br
1333  if (substr($chunks[count($chunks) - 1]["text"],
1334  strlen($chunks[count($chunks) - 1]["text"]) - 6, 6) == "<br />")
1335  {
1336  $chunks[count($chunks) - 1]["text"] =
1337  substr($chunks[count($chunks) - 1]["text"], 0, strlen($chunks[count($chunks) - 1]["text"]) - 6);
1338  if ($chunks[count($chunks) - 1]["text"] == "")
1339  {
1340  unset($chunks[count($chunks) - 1]);
1341  }
1342  }
1343  return $chunks;
1344  }
removeTrailingBr($a_str)
Remove trailing
$n
Definition: RandomTest.php:80
handleNextBr($a_str)
Remove preceding
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beforePageDelete()

static ilPCParagraph::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
object$a_pagepage object

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

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

◆ create()

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.

108  {
109 //echo "-$a_pc_id-";
110 //echo "<br>-".htmlentities($a_pg_obj->getXMLFromDom())."-<br><br>"; mk();
111  $this->node =& $this->dom->create_element("PageContent");
112 
113  // this next line kicks out placeholders, if something is inserted
114  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
115 
116  $this->par_node =& $this->dom->create_element("Paragraph");
117  $this->par_node =& $this->node->append_child($this->par_node);
118  $this->par_node->set_attribute("Language", "");
119  }
const IL_INSERT_AFTER

◆ createAfter()

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().

84  {
85  $this->node = $this->createPageContentNode(false);
86  if($succ_node = $node->next_sibling())
87  {
88  $this->node = $succ_node->insert_before($this->node, $succ_node);
89  }
90  else
91  {
92  $parent_node = $node->parent_node();
93  $this->node = $parent_node->append_child($this->node);
94  }
95  $this->par_node = $this->dom->create_element("Paragraph");
96  $this->par_node = $this->node->append_child($this->par_node);
97  $this->par_node->set_attribute("Language", "");
98  }
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ createAtNode()

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().

55  {
56  $this->node = $this->createPageContentNode();
57  $this->par_node =& $this->dom->create_element("Paragraph");
58  $this->par_node =& $this->node->append_child($this->par_node);
59  $this->par_node->set_attribute("Language", "");
60  $node->append_child ($this->node);
61  }
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ createBeforeNode()

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().

69  {
70  $this->node = $this->createPageContentNode();
71  $this->par_node =& $this->dom->create_element("Paragraph");
72  $this->par_node =& $this->node->append_child($this->par_node);
73  $this->par_node->set_attribute("Language", "");
74  $node->insert_before($this->node, $node);
75  }
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ getAutoIndent()

ilPCParagraph::getAutoIndent ( )

Get AutoIndent (Code Paragraphs)

Parameters
stringAuto Indent attribute

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

396  {
397  return $this->par_node->get_attribute("AutoIndent");
398  }

◆ getCharacteristic()

ilPCParagraph::getCharacteristic ( )

Get characteristic of paragraph.

Returns
string characteristic

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

Referenced by getType(), and setText().

364  {
365  if (is_object($this->par_node))
366  {
367  return $this->par_node->get_attribute("Characteristic");
368  }
369  }
+ Here is the caller graph for this function:

◆ getDownloadTitle()

ilPCParagraph::getDownloadTitle ( )

get attribute download title

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

446  {
447  return $this->par_node->get_attribute("DownloadTitle");
448  }

◆ getLanguage()

ilPCParagraph::getLanguage ( )

get language

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

Referenced by input2xml(), and setText().

482  {
483  return $this->par_node->get_attribute("Language");
484  }
+ Here is the caller graph for this function:

◆ getLastSavedPCId()

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

Get last inserted pc ids.

Parameters

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

References ilPageContent\$hier_id.

1459  {
1460  if ($a_as_ajax_str)
1461  {
1462  $a_pg_obj->stripHierIDs();
1463  $a_pg_obj->addHierIds();
1464  $ids = "###";
1465 //var_dump($this->inserted_pc_ids);
1466  $combined = $a_pg_obj->getHierIdsForPCIds(
1467  array($this->inserted_pc_id));
1468  foreach ($combined as $pc_id => $hier_id)
1469  {
1470 //echo "1";
1471  $ids.= $sep.$hier_id.":".$pc_id;
1472  $sep = ";";
1473  }
1474  $ids.= "###";
1475  return $ids;
1476  }
1477 
1478  return $this->inserted_pc_id;
1479  }

◆ getParagraphSequenceContent()

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().

278  {
279  $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
280  $seq = array();
281  $cur_seq = array();
282  $found = false;
283  $pc_id = $this->readPCId();
284  $hier_id = $this->readHierId();
285  for($i=0; $i<count($childs); $i++)
286  {
287  $pchilds = $childs[$i]->child_nodes();
288  if ($pchilds[0]->node_name() == "Paragraph" &&
289  $pchilds[0]->get_attribute("Characteristic") != "Code")
290  {
291  $cur_seq[] = $childs[$i];
292 
293  // check whether this is the sequence of the current paragraph
294  if ($childs[$i]->get_attribute("PCID") == $pc_id &&
295  $childs[$i]->get_attribute("HierId") == $hier_id)
296  {
297  $found = true;
298  }
299 
300  // if this is the current sequenc, get it
301  if ($found)
302  {
303  $seq = $cur_seq;
304  }
305  }
306  else
307  {
308  // non-paragraph element found -> init the current sequence
309  $cur_seq = array();
310  $found = false;
311  }
312  }
313 
314  $content = "";
315  $ids = "###";
316  $id_sep = "";
317  foreach ($seq as $p_node)
318  {
319  $ids.= $id_sep.$p_node->get_attribute("HierId").":".$p_node->get_attribute("PCID");
320  $po = $a_pg_obj->getContentObject($p_node->get_attribute("HierId"),
321  $p_node->get_attribute("PCID"));
322  $s_text = $po->getText();
323  $s_text = $po->xml2output($s_text, true, false);
324  $char = $po->getCharacteristic();
325  if ($char == "")
326  {
327  $char = "Standard";
328  }
329  $s_text = ilPCParagraphGUI::xml2outputJS($s_text, $char, $po->readPCId());
330  $content.= $s_text;
331  $id_sep = ";";
332  }
333  $ids.= "###";
334 
335  return $ids.$content;
336  }
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
readPCId()
Read PC Id.
readHierId()
Read PC Id.
+ Here is the call graph for this function:

◆ getShowLineNumbers()

ilPCParagraph::getShowLineNumbers ( )

get attribute showlinenumbers

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

466  {
467  return $this->par_node->get_attribute("ShowLineNumbers");
468  }

◆ getSubCharacteristic()

ilPCParagraph::getSubCharacteristic ( )

get attribute subcharacteristic

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

419  {
420  return $this->par_node->get_attribute("SubCharacteristic");
421  }

◆ getText()

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().

257  {
258  if (is_object($this->par_node))
259  {
260  $content = "";
261  $childs = $this->par_node->child_nodes();
262  for($i=0; $i<count($childs); $i++)
263  {
264  $content .= $this->dom->dump_node($childs[$i]);
265  }
266  return $content;
267  }
268  else
269  {
270  return "";
271  }
272  }
+ Here is the caller graph for this function:

◆ getType()

ilPCParagraph::getType ( )

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

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

References getCharacteristic().

1385  {
1386  return ($this->getCharacteristic() == "Code")?"src":parent::getType();
1387  }
getCharacteristic()
Get characteristic of paragraph.
+ Here is the call graph for this function:

◆ handleAjaxContent()

static ilPCParagraph::handleAjaxContent (   $a_content)
static

Handle ajax content.

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

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

Referenced by ilPCDataTableGUI\updateJS().

1486  {
1487  $a_content = "<dummy>".$a_content."</dummy>";
1488 
1489  $doc = new DOMDocument();
1490 
1491  $content = ilUtil::stripSlashes($a_content, false);
1492 
1493 // $content = str_replace("&lt;", "<", $content);
1494 // $content = str_replace("&gt;", ">", $content);
1495 //echo "<br><br>".htmlentities($content); mk();
1496  $res = $doc->loadXML($content);
1497 
1498  if (!$res)
1499  {
1500  return false;
1501  }
1502 
1503  // convert tags
1504  $xpath = new DOMXpath($doc);
1505 
1506  $elements = $xpath->query("//span");
1507  include_once("./Services/Utilities/classes/class.ilDOM2Util.php");
1508  while (!is_null($elements) && !is_null($element = $elements->item(0)))
1509  {
1510  //$element = $elements->item(0);
1511  $class = $element->getAttribute("class");
1512  if (substr($class, 0, 16) == "ilc_text_inline_")
1513  {
1514  $class_arr = explode(" ", $class);
1515  $cnode = ilDOM2Util::changeName($element, "il".substr($class_arr[0], 16), false);
1516  for ($i = 1; $i < count($class_arr); $i++)
1517  {
1518  $cnode = ilDOM2Util::addParent($cnode, "il".substr($class_arr[$i], 16));
1519  }
1520  }
1521  else
1522  {
1523  ilDOM2Util::replaceByChilds($element);
1524  }
1525 
1526  $elements = $xpath->query("//span");
1527  }
1528 
1529  // convert tags
1530  $xpath = new DOMXpath($doc);
1531  $elements = $xpath->query("/dummy/div");
1532 
1533  $ret = array();
1534  if (!is_null($elements))
1535  {
1536  foreach ($elements as $element)
1537  {
1538  $id = $element->getAttribute("id");
1539  $class = $element->getAttribute("class");
1540  $class = substr($class, 15);
1541  if (trim($class) == "")
1542  {
1543  $class = "Standard";
1544  }
1545 
1546  $text = $doc->saveXML($element);
1547  $text = str_replace("<br/>", "\n", $text);
1548 
1549  // remove wrapping div
1550  $pos = strpos($text, ">");
1551  $text = substr($text, $pos + 1);
1552  $pos = strrpos($text, "<");
1553  $text = substr($text, 0, $pos);
1554 
1555  // todo: remove empty spans <span ...> </span>
1556 
1557  // replace tags by bbcode
1558  foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl)
1559  {
1560  if (!in_array($bb, array("code", "tex", "fn", "xln")))
1561  {
1562  $text = str_replace("<il".$cl.">",
1563  "[".$bb."]", $text);
1564  $text = str_replace("</il".$cl.">",
1565  "[/".$bb."]", $text);
1566  $text = str_replace("<il".$cl."/>", "", $text);
1567  }
1568  }
1569  $text = str_replace(array("<code>", "</code>"),
1570  array("[code]", "[/code]"), $text);
1571 
1572  $text = str_replace("<code/>", "", $text);
1573  $text = str_replace('<ul class="ilc_list_u_BulletedList"/>', "", $text);
1574  $text = str_replace('<ul class="ilc_list_o_NumberedList"/>', "", $text);
1575 
1576  $ret[] = array("text" => $text, "id" => $id, "class" => $class);
1577  }
1578  }
1579 
1580  // we should only have one here!
1581  return $ret[0];
1582  }
static replaceByChilds($node)
Replace a node by its child.
static changeName($node, $name, $keep_attributes=true)
Change name of a node.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static addParent($node, $name)
Add parent.
static _getCommonBBButtons()
Get common bb buttons.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleAjaxContentPost()

static ilPCParagraph::handleAjaxContentPost (   $text)
static

Post input2xml handling of ajax content.

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

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

1588  {
1589  $text = str_replace(array("&lt;ul&gt;", "&lt;/ul&gt;"),
1590  array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
1591  $text = str_replace(array("&lt;ul class='ilc_list_u_BulletedList'&gt;", "&lt;/ul&gt;"),
1592  array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
1593  $text = str_replace(array("&lt;ul class=\"ilc_list_u_BulletedList\"&gt;", "&lt;/ul&gt;"),
1594  array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
1595  $text = str_replace(array("&lt;ol&gt;", "&lt;/ol&gt;"),
1596  array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
1597  $text = str_replace(array("&lt;ol class='ilc_list_o_NumberedList'&gt;", "&lt;/ol&gt;"),
1598  array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
1599  $text = str_replace(array("&lt;ol class=\"ilc_list_o_NumberedList\"&gt;", "&lt;/ol&gt;"),
1600  array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
1601  $text = str_replace(array("&lt;li&gt;", "&lt;/li&gt;"),
1602  array("<SimpleListItem>", "</SimpleListItem>"), $text);
1603  $text = str_replace(array("&lt;li class='ilc_list_item_StandardListItem'&gt;", "&lt;/li&gt;"),
1604  array("<SimpleListItem>", "</SimpleListItem>"), $text);
1605  $text = str_replace(array("&lt;li class=\"ilc_list_item_StandardListItem\"&gt;", "&lt;/li&gt;"),
1606  array("<SimpleListItem>", "</SimpleListItem>"), $text);
1607 
1608  $text = str_replace(array("&lt;li class=\"ilc_list_item_StandardListItem\"/&gt;"),
1609  array("<SimpleListItem></SimpleListItem>"), $text);
1610 
1611  $text = str_replace("<SimpleBulletList><br />", "<SimpleBulletList>", $text);
1612  $text = str_replace("<SimpleNumberedList><br />", "<SimpleNumberedList>", $text);
1613  $text = str_replace("<br /><SimpleBulletList>", "<SimpleBulletList>", $text);
1614  $text = str_replace("<br /><SimpleNumberedList>", "<SimpleNumberedList>", $text);
1615  $text = str_replace("</SimpleBulletList><br />", "</SimpleBulletList>", $text);
1616  $text = str_replace("</SimpleNumberedList><br />", "</SimpleNumberedList>", $text);
1617  $text = str_replace("</SimpleListItem><br />", "</SimpleListItem>", $text);
1618 
1619  return $text;
1620  }
+ Here is the caller graph for this function:

◆ handleNextBr()

ilPCParagraph::handleNextBr (   $a_str)

Remove preceding

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

Referenced by autoSplit().

1350  {
1351  // do not remove, if next line starts with a "=", otherwise two
1352  // headlines in a row will not be recognized
1353  if (substr($a_str, 0, 6) == "<br />" && substr($a_str, 6, 1) != "=")
1354  {
1355  $a_str = substr($a_str, 6);
1356  }
1357  else
1358  {
1359  // if next line starts with a "=" we need to reinsert the <br />
1360  // otherwise it will not be recognized
1361  if (substr($a_str, 0, 1) == "=")
1362  {
1363  $a_str = "<br />".$a_str;
1364  }
1365  }
1366  return $a_str;
1367  }
+ Here is the caller graph for this function:

◆ init()

ilPCParagraph::init ( )

Init page content component.

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

References ilPageContent\setType().

25  {
26  $this->setType("par");
27  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ input2xml()

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

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

References _input2xml(), and getLanguage().

487  {
488  return $this->_input2xml($a_text, $this->getLanguage(), $a_wysiwyg, $a_handle_lists);
489  }
getLanguage()
get language
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
+ Here is the call graph for this function:

◆ input2xmlReplaceLists()

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().

797  {
798  $rows = explode("<br />", $a_text."<br />");
799 //var_dump($a_text);
800 
801  $old_level = 0;
802 
803  $text = "";
804 
805  foreach ($rows as $row)
806  {
807  $level = 0;
808  if (str_replace("#", "*", substr($row, 0, 3)) == "***")
809  {
810  $level = 3;
811  }
812  else if (str_replace("#", "*", substr($row, 0, 2)) == "**")
813  {
814  $level = 2;
815  }
816  else if (str_replace("#", "*", substr($row, 0, 1)) == "*")
817  {
818  $level = 1;
819  }
820 
821  // end previous line
822  if ($level < $old_level)
823  {
824  for ($i = $old_level; $i > $level; $i--)
825  {
826  $text.= "</SimpleListItem></".$clist[$i].">";
827  }
828  if ($level > 0)
829  {
830  $text.= "</SimpleListItem>";
831  }
832  }
833  else if ($old_level > 0 && $level > 0 && ($level == $old_level))
834  {
835  $text.= "</SimpleListItem>";
836  }
837  else if (($level == $old_level) && $text != "")
838  {
839  $text.= "<br />";
840  }
841 
842  // start next line
843  if ($level > $old_level)
844  {
845  for($i = $old_level + 1; $i <= $level; $i++)
846  {
847  if (substr($row, $i - 1, 1) == "*")
848  {
849  $clist[$i] = "SimpleBulletList";
850  }
851  else
852  {
853  $clist[$i] = "SimpleNumberedList";
854  }
855  $text.= "<".$clist[$i]."><SimpleListItem>";
856  }
857  }
858  else if ($old_level > 0 && $level > 0)
859  {
860  $text.= "<SimpleListItem>";
861  }
862  $text.= substr($row, $level);
863 
864  $old_level = $level;
865  }
866 
867  // remove "<br />" at the end
868  if (substr($text, strlen($text) - 6) == "<br />")
869  {
870  $text = substr($text, 0, strlen($text) - 6);
871  }
872 
873  return $text;
874  }
+ Here is the caller graph for this function:

◆ intLinks2xml()

static ilPCParagraph::intLinks2xml (   $a_text)
static

internal links to xml

Parameters

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

References $t, and ilUtil\attribsToArray().

635  {
636  global $objDefinition;
637 
638  $rtypes = $objDefinition->getAllRepositoryTypes();
639 
640  // internal links
641  //$any = "[^\]]*"; // this doesn't work :-(
642  $ws= "[ \t\r\f\v\n]*";
643  $ltypes = "page|chap|term|media|obj|dfile|sess|wpage|".implode($rtypes, "|");
644  // empty internal links
645  while (eregi("\[(iln$ws((inst$ws=$ws([\"0-9])*)?$ws".
646  "((".$ltypes.")$ws=$ws([\"0-9])*)$ws".
647  "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]", $a_text, $found))
648  {
649  $a_text = str_replace($found[0], "",$a_text);
650  }
651 
652  while (eregi("\[(iln$ws((inst$ws=$ws([\"0-9])*)?$ws".
653  "((".$ltypes.")$ws=$ws([\"0-9])*)$ws".
654  "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]", $a_text, $found))
655  {
656  $attribs = ilUtil::attribsToArray($found[2]);
657  $inst_str = $attribs["inst"];
658  // pages
659  if (isset($attribs["page"]))
660  {
661  $tframestr = "";
662  if (!empty($found[10]))
663  {
664  $tframestr = " TargetFrame=\"".$found[10]."\" ";
665  }
666  $ancstr = "";
667  if ($attribs["anchor"] != "")
668  {
669  $ancstr = ' Anchor="'.$attribs["anchor"].'" ';
670  }
671  $a_text = eregi_replace("\[".$found[1]."\]",
672  "<IntLink Target=\"il_".$inst_str."_pg_".$attribs[page]."\" Type=\"PageObject\"".$tframestr.$ancstr.">", $a_text);
673  }
674  // chapters
675  else if (isset($attribs["chap"]))
676  {
677  if (!empty($found[10]))
678  {
679  $tframestr = " TargetFrame=\"".$found[10]."\" ";
680  }
681  else
682  {
683  $tframestr = "";
684  }
685  $a_text = eregi_replace("\[".$found[1]."\]",
686  "<IntLink Target=\"il_".$inst_str."_st_".$attribs[chap]."\" Type=\"StructureObject\"".$tframestr.">", $a_text);
687  }
688  // glossary terms
689  else if (isset($attribs["term"]))
690  {
691  switch ($found[10])
692  {
693  case "New":
694  $tframestr = " TargetFrame=\"New\" ";
695  break;
696 
697  default:
698  $tframestr = " TargetFrame=\"Glossary\" ";
699  break;
700  }
701  $a_text = eregi_replace("\[".$found[1]."\]",
702  "<IntLink Target=\"il_".$inst_str."_git_".$attribs[term]."\" Type=\"GlossaryItem\" $tframestr>", $a_text);
703  }
704  // wiki pages
705  else if (isset($attribs["wpage"]))
706  {
707  $tframestr = "";
708 /* switch ($found[10])
709  {
710  case "New":
711  $tframestr = " TargetFrame=\"New\" ";
712  break;
713 
714  default:
715  $tframestr = " TargetFrame=\"Glossary\" ";
716  break;
717  }*/
718  $a_text = eregi_replace("\[".$found[1]."\]",
719  "<IntLink Target=\"il_".$inst_str."_wpage_".$attribs[wpage]."\" Type=\"WikiPage\" $tframestr>", $a_text);
720  }
721  // media object
722  else if (isset($attribs["media"]))
723  {
724  if (!empty($found[10]))
725  {
726  $tframestr = " TargetFrame=\"".$found[10]."\" ";
727  $a_text = eregi_replace("\[".$found[1]."\]",
728  "<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"".$tframestr.">", $a_text);
729  }
730  else
731  {
732  $a_text = eregi_replace("\[".$found[1]."\]",
733  "<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"/>", $a_text);
734  }
735  }
736  // direct download file (no repository object)
737  else if (isset($attribs["dfile"]))
738  {
739  $a_text = eregi_replace("\[".$found[1]."\]",
740  "<IntLink Target=\"il_".$inst_str."_dfile_".$attribs[dfile]."\" Type=\"File\">", $a_text);
741  }
742  // repository items (id is ref_id (will be used internally but will
743  // be replaced by object id for export purposes)
744  else
745  {
746  foreach ($objDefinition->getAllRepositoryTypes() as $t)
747  {
748  if (isset($attribs[$t]))
749  {
750  $obj_id = $attribs[$t];
751  }
752  }
753  if (isset($attribs["obj"]))
754  {
755  $obj_id = $attribs["obj"];
756  }
757 
758  if ($obj_id > 0)
759  {
760  if ($inst_str == "")
761  {
762  $a_text = eregi_replace("\[".$found[1]."\]",
763  "<IntLink Target=\"il_".$inst_str."_obj_".$obj_id."\" Type=\"RepositoryItem\">", $a_text);
764  }
765  else
766  {
767  $a_text = eregi_replace("\[".$found[1]."\]",
768  "<IntLink Target=\"il_".$inst_str."_".$found[6]."_".$obj_id."\" Type=\"RepositoryItem\">", $a_text);
769  }
770  }
771  else
772  {
773  $a_text = eregi_replace("\[".$found[1]."\]", "[error: iln".$found[1]."]",$a_text);
774  }
775  }
776  }
777  while (eregi("\[(iln$ws((inst$ws=$ws([\"0-9])*)?".$ws."media$ws=$ws([\"0-9])*)$ws)/\]", $a_text, $found))
778  {
779  $attribs = ilUtil::attribsToArray($found[2]);
780  $inst_str = $attribs["inst"];
781  $a_text = eregi_replace("\[".$found[1]."/\]",
782  "<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"/>", $a_text);
783  }
784  $a_text = eregi_replace("\[\/iln\]","</IntLink>",$a_text);
785  return $a_text;
786  }
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
+ Here is the call graph for this function:

◆ linkTermsInDom()

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

Link terms in a dom page object in bb style.

Parameters

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

References ilPageContent\$node, $t, DOMXML_LOAD_PARSING, domxml_open_mem(), and ilUtil\sortArray().

1685  {
1686  // sort terms by their length (shortes first)
1687  // to prevent that nested tags are builded
1688  foreach ($a_terms as $k => $t)
1689  {
1690  $a_terms[$k]["termlength"] = strlen($t["term"]);
1691  }
1692  $a_terms = ilUtil::sortArray($a_terms, "termlength", "asc", true);
1693 
1694 
1695  if ($a_dom instanceof php4DOMDocument)
1696  {
1697  $a_dom = $a_dom->myDOMDocument;
1698  }
1699  if ($a_par_node instanceof php4DOMElement)
1700  {
1701  $a_par_node = $a_par_node->myDOMNode;
1702  }
1703 
1704  $xpath = new DOMXPath($a_dom);
1705 
1706  if ($a_par_node == null)
1707  {
1708  $parnodes = $xpath->query('//Paragraph');
1709  }
1710  else
1711  {
1712  $parnodes = $xpath->query('//Paragraph', $a_par_node);
1713  }
1714 
1715  foreach ($parnodes as $parnode)
1716  {
1717  $textnodes = $xpath->query('//text()', $parnode);
1718  foreach ($textnodes as $node)
1719  {
1720  $p = $node->getNodePath();
1721 
1722  // we do not change text nodes inside of links
1723  if (!is_int(strpos($p, "/IntLink")) &&
1724  !is_int(strpos($p, "/ExtLink")))
1725  {
1726  $node_val = $node->nodeValue;
1727 
1728  // all terms
1729  foreach ($a_terms as $t)
1730  {
1731  $pos = stripos($node_val, $t["term"]);
1732 
1733  // if term found
1734  while (is_int($pos))
1735  {
1736  // check if the string is not included in another word
1737  // note that []
1738  $valid_limiters = array("", " ", ".", ",", ":", ";", "!", "?", "\"", "'", "(", ")");
1739  $b = substr($node_val, $pos - 1, 1);
1740  $a = substr($node_val, $pos + strlen($t["term"]), 1);
1741  if (in_array($b, $valid_limiters) && in_array($a, $valid_limiters))
1742  {
1743  $mid = '[iln term="'.$t["id"].'"]'.
1744  substr($node_val, $pos, strlen($t["term"])).
1745  "[/iln]";
1746 
1747  $node_val = substr($node_val, 0, $pos).
1748  $mid.
1749  substr($node_val, $pos + strlen($t["term"]))
1750  ;
1751 
1752  $pos+= strlen($mid);
1753  }
1754  else
1755  {
1756  $pos+= strlen($t["term"]) + 1;
1757  }
1758  $pos = stripos($node_val, $t["term"], $pos);
1759  }
1760 
1761  // insert [iln] tags
1762  }
1763 
1764  $node->nodeValue = $node_val;
1765  }
1766 
1767  // var_dump($p);
1768  // var_dump($node->nodeValue);
1769  }
1770 
1771 
1772  // dump paragraph node
1773  $text = $a_dom->saveXML($parnode);
1774  $text = substr($text, 0, strlen($text) - strlen("</Paragraph>"));
1775  $text = substr($text, strpos($text, ">") + 1);
1776 
1777  // replace [iln] by tags with xml representation
1778  $text = self::intLinks2xml($text);
1779 
1780  // "set text"
1781  $temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text.'</Paragraph>',
1782  DOMXML_LOAD_PARSING, $error);
1783  $temp_dom = $temp_dom->myDOMDocument;
1784 
1785  if(empty($error))
1786  {
1787  // delete children of paragraph node
1788  $children = $parnode->childNodes;
1789  while ($parnode->hasChildNodes())
1790  {
1791  $parnode->removeChild($parnode->firstChild);
1792  }
1793 
1794  // copy new content children in paragraph node
1795  $xpath_temp = new DOMXPath($temp_dom);
1796  $temp_pars = $xpath_temp->query("//Paragraph");
1797 
1798  foreach ($temp_pars as $new_par_node)
1799  {
1800  $new_childs = $new_par_node->childNodes;
1801 
1802  foreach($new_childs as $new_child)
1803  {
1804  //$cloned_child = $new_child->cloneNode(true);
1805  $cloned_child = $a_dom->importNode($new_child, true);
1806  $parnode->appendChild($cloned_child);
1807  }
1808  }
1809  }
1810  }
1811  }
const DOMXML_LOAD_PARSING
domxml_open_mem($str, $mode=DOMXML_LOAD_PARSING, &$error=NULL)
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
php4DomElement
+ Here is the call graph for this function:

◆ removeTrailingBr()

ilPCParagraph::removeTrailingBr (   $a_str)

Remove trailing

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

Referenced by autoSplit().

1373  {
1374  if (substr($a_str, strlen($a_str) - 6) == "<br />")
1375  {
1376  $a_str = substr($a_str, 0, strlen($a_str) - 6);
1377  }
1378  return $a_str;
1379  }
+ Here is the caller graph for this function:

◆ saveAnchors()

ilPCParagraph::saveAnchors (   $a_page,
  $a_domdoc 
)

Save anchors.

Parameters
stringxml page code

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

References ilPageContent\$node.

1874  {
1875  self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
1876 
1877  // get all anchors
1878  $xpath = new DOMXPath($a_domdoc);
1879  $nodes = $xpath->query('//Anchor');
1880  $saved = array();
1881  foreach ($nodes as $node)
1882  {
1883  $name = $node->getAttribute("Name");
1884  if (trim($name) != "" && !in_array($name, $saved))
1885  {
1886  self::_saveAnchor($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $name);
1887  $saved[] = $name;
1888  }
1889  }
1890 
1891  }

◆ saveJS()

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

Save input coming from ajax.

Parameters

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

References $ilUser, $t, exit, ilPageContent\getPage(), and handleAjaxContentPost().

1400  {
1401  global $ilUser;
1402 
1403  $t = self::handleAjaxContent($a_content);
1404  if ($text === false)
1405  {
1406  return false;
1407  }
1408 
1409  $pc_id = explode(":", $a_pc_id);
1410  $insert_at = explode(":", $a_insert_at);
1411  $t_id = explode(":", $t["id"]);
1412 
1413  // insert new paragraph
1414  if ($a_insert_at != "")
1415  {
1416  $par = new ilPCParagraph($this->getPage());
1417  $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
1418  }
1419  else
1420  {
1421  $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
1422  }
1423 
1424  if ($a_insert_at != "")
1425  {
1426  $pc_id = $a_pg_obj->generatePCId();
1427  $par->writePCId($pc_id);
1428  $this->inserted_pc_id = $pc_id;
1429  }
1430  else
1431  {
1432  $this->inserted_pc_id = $pc_id[1];
1433  }
1434 
1435  $par->setLanguage($ilUser->getLanguage());
1436  $par->setCharacteristic($t["class"]);
1437 
1438  $t2 = $par->input2xml($t["text"], true, false);
1440  $updated = $par->setText($t2, true);
1441 
1442  if ($updated !== true)
1443  {
1444  echo $updated; exit;
1445  return false;
1446  }
1447  $updated = $par->updatePage($a_pg_obj);
1448  //$updated = $a_pg_obj->update();
1449  return $updated;
1450  }
exit
Definition: login.php:54
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
Class ilPCParagraph.
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ saveMetaKeywords()

ilPCParagraph::saveMetaKeywords (   $a_page,
  $a_domdoc 
)

save all keywords

Parameters
object$a_pagepage object
object$a_domdocdom document

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

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

1954  {
1955  // not nice, should be set by context per method
1956  if ($a_page->getParentType() == "gdf" ||
1957  $a_page->getParentType() == "lm")
1958  {
1959  // get existing keywords
1960  $keywords = array();
1961 
1962  // find all Keyw tags
1963  $xpath = new DOMXPath($a_domdoc);
1964  $nodes = $xpath->query('//Keyw');
1965  foreach($nodes as $node)
1966  {
1967  $k = trim(strip_tags($node->nodeValue));
1968  if (!in_array($k, $keywords))
1969  {
1970  $keywords[] = $k;
1971  }
1972  }
1973 
1974  $meta_type = ($a_page->getParentType() == "gdf")
1975  ? "gdf"
1976  : "pg";
1977  $meta_rep_id = $a_page->getParentId();
1978  $meta_id = $a_page->getId();
1979 
1980  include_once("./Services/MetaData/classes/class.ilMD.php");
1981  $md_obj = new ilMD($meta_rep_id, $meta_id, $meta_type);
1982  $mkeywords = array();
1983  $lang = "";
1984  if(is_object($md_section = $md_obj->getGeneral()))
1985  {
1986  foreach($ids = $md_section->getKeywordIds() as $id)
1987  {
1988  $md_key = $md_section->getKeyword($id);
1989  $mkeywords[] = strtolower($md_key->getKeyword());
1990  if ($lang == "")
1991  {
1992  $lang = $md_key->getKeywordLanguageCode();
1993  }
1994  }
1995  if ($lang == "")
1996  {
1997  foreach($ids = $md_section->getLanguageIds() as $id)
1998  {
1999  $md_lang = $md_section->getLanguage($id);
2000  if ($lang == "")
2001  {
2002  $lang = $md_lang->getLanguageCode();
2003  }
2004  }
2005  }
2006  foreach ($keywords as $k)
2007  {
2008  if (!in_array(strtolower($k), $mkeywords))
2009  {
2010  if (trim($k) != "" && $lang != "")
2011  {
2012  $md_key = $md_section->addKeyword();
2013  $md_key->setKeyword(ilUtil::stripSlashes($k));
2014  $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
2015  $md_key->save();
2016  }
2017  $mkeywords[] = strtolower($k);
2018  }
2019  }
2020  }
2021  }
2022  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:

◆ segmentString()

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().

980  {
981  $segments = array();
982 
983  $nothing_found = false;
984  while (!$nothing_found)
985  {
986  $nothing_found = true;
987  $found = -1;
988  foreach($a_needles as $needle)
989  {
990  $pos = stripos($a_haystack, $needle);
991  if (is_int($pos) && ($pos < $found || $found == -1))
992  {
993  $found = $pos;
994  $found_needle = $needle;
995  $nothing_found = false;
996  }
997  }
998  if ($found > 0)
999  {
1000  $segments[] = substr($a_haystack, 0, $found);
1001  $a_haystack = substr($a_haystack, $found);
1002  }
1003  if ($found > -1)
1004  {
1005  $segments[] = substr($a_haystack, 0, strlen($found_needle));
1006  $a_haystack = substr($a_haystack, strlen($found_needle));
1007  }
1008  }
1009  if ($a_haystack != "")
1010  {
1011  $segments[] = $a_haystack;
1012  }
1013 
1014  return $segments;
1015  }
+ Here is the caller graph for this function:

◆ setAutoIndent()

ilPCParagraph::setAutoIndent (   $a_char)

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

401  {
402  if (!empty($a_char))
403  {
404  $this->par_node->set_attribute("AutoIndent", $a_char);
405  }
406  else
407  {
408  if ($this->par_node->has_attribute("AutoIndent"))
409  {
410  $this->par_node->remove_attribute("AutoIndent");
411  }
412  }
413  }

◆ setCharacteristic()

ilPCParagraph::setCharacteristic (   $a_char)

Set Characteristic of paragraph.

Parameters
string$a_charCharacteristic

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

344  {
345  if (!empty($a_char))
346  {
347  $this->par_node->set_attribute("Characteristic", $a_char);
348  }
349  else
350  {
351  if ($this->par_node->has_attribute("Characteristic"))
352  {
353  $this->par_node->remove_attribute("Characteristic");
354  }
355  }
356  }

◆ setDownloadTitle()

ilPCParagraph::setDownloadTitle (   $a_char)

set attribute download title

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

428  {
429  if (!empty($a_char))
430  {
431  $this->par_node->set_attribute("DownloadTitle", $a_char);
432  }
433  else
434  {
435  if ($this->par_node->has_attribute("DownloadTitle"))
436  {
437  $this->par_node->remove_attribute("DownloadTitle");
438  }
439  }
440  }

◆ setLanguage()

ilPCParagraph::setLanguage (   $a_lang)

set language

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

474  {
475  $this->par_node->set_attribute("Language", $a_lang);
476  }

◆ setNode()

ilPCParagraph::setNode ( $a_node)

Set Page Content Node.

Parameters
object$a_nodePage Content DOM Node

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

35  {
36  parent::setNode($a_node); // this is the PageContent node
37 
38  $childs = $a_node->child_nodes();
39  for ($i=0; $i<count($childs); $i++)
40  {
41  if ($childs[$i]->node_name() == "Paragraph")
42  {
43  $this->par_node = $childs[$i]; //... and this the Paragraph node
44  }
45  }
46  }

◆ setShowLineNumbers()

ilPCParagraph::setShowLineNumbers (   $a_char)

set attribute showlinenumbers

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

455  {
456  $a_char = empty($a_char)?"n":$a_char;
457 
458  $this->par_node->set_attribute("ShowLineNumbers", $a_char);
459  }

◆ setSubCharacteristic()

ilPCParagraph::setSubCharacteristic (   $a_char)

set attribute subcharacteristic

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

376  {
377  if (!empty($a_char))
378  {
379  $this->par_node->set_attribute("SubCharacteristic", $a_char);
380  }
381  else
382  {
383  if ($this->par_node->has_attribute("SubCharacteristic"))
384  {
385  $this->par_node->remove_attribute("SubCharacteristic");
386  }
387  }
388  }

◆ setText()

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().

128  {
129 
130 //var_dump($a_text);
131  if (!is_array($a_text))
132  {
133  $text = array(array("level" => 0, "text" => $a_text));
134  }
135  else
136  {
137  $text = $a_text;
138  }
139 
140  if ($a_auto_split)
141  {
142  $text = $this->autoSplit($a_text);
143  }
144 
145  // DOMXML_LOAD_PARSING, DOMXML_LOAD_VALIDATING, DOMXML_LOAD_RECOVERING
146  $check = "";
147  foreach ($text as $t)
148  {
149  $check.= "<Paragraph>".$t["text"]."</Paragraph>";
150  }
151  /*$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
152  DOMXML_LOAD_PARSING, $error);*/
153  $temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$check.'</Paragraph>',
154  DOMXML_LOAD_PARSING, $error);
155 
156  //$this->text = $a_text;
157  // remove all childs
158  if(empty($error))
159  {
160  $temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
161  DOMXML_LOAD_PARSING, $error);
162 
163  // delete children of paragraph node
164  $children = $this->par_node->child_nodes();
165  for($i=0; $i<count($children); $i++)
166  {
167  $this->par_node->remove_child($children[$i]);
168  }
169 
170  // copy new content children in paragraph node
171  $xpc = xpath_new_context($temp_dom);
172  $path = "//Paragraph";
173  $res =& xpath_eval($xpc, $path);
174  if (count($res->nodeset) == 1)
175  {
176  $new_par_node =& $res->nodeset[0];
177  $new_childs = $new_par_node->child_nodes();
178 
179  for($i=0; $i<count($new_childs); $i++)
180  {
181  $cloned_child =& $new_childs[$i]->clone_node(true);
182  $this->par_node->append_child($cloned_child);
183  }
184  $orig_characteristic = $this->getCharacteristic();
185 
186  // if headlines are entered and current characteristic is a headline
187  // use no characteristic as standard
188  if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) == "Headline"))
189  {
190  $orig_characteristic = "";
191  }
192  if ($text[0]["level"] > 0)
193  {
194  $this->par_node->set_attribute("Characteristic", 'Headline'.$text[0]["level"]);
195  }
196  }
197 
198  $ok = true;
199 
200  $c_node = $this->node;
201  // add other chunks afterwards
202  for ($i=1; $i<count($text); $i++)
203  {
204  if ($ok)
205  {
206  $next_par = new ilPCParagraph($this->getPage());
207  $next_par->createAfter($c_node);
208  $next_par->setLanguage($this->getLanguage());
209  if ($text[$i]["level"] > 0)
210  {
211  $next_par->setCharacteristic("Headline".$text[$i]["level"]);
212  }
213  else
214  {
215  $next_par->setCharacteristic($orig_characteristic);
216  }
217  $ok = $next_par->setText($text[$i]["text"], false);
218  $c_node = $next_par->node;
219  }
220  }
221 
222  return true;
223  }
224  else
225  {
226  // We want the correct number of \n here to have the real lines numbers
227  $text = str_replace("<br>", "\n", $check); // replace <br> with \n to get correct line
228  $text = str_replace("<br/>", "\n", $text);
229  $text = str_replace("<br />", "\n", $text);
230  $text = str_replace("</SimpleListItem>", "</SimpleListItem>\n", $text);
231  $text = str_replace("<SimpleBulletList>", "\n<SimpleBulletList>", $text);
232  $text = str_replace("<SimpleNumberedList>", "\n<SimpleNumberedList>", $text);
233  $text = str_replace("<Paragraph>\n", "<Paragraph>", $text);
234  $text = str_replace("</Paragraph>", "</Paragraph>\n", $text);
235  include_once("./Services/Dom/classes/class.ilDomDocument.php");
236  $doc = new ilDOMDocument();
237  $text = '<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text.'</Paragraph>';
238 //echo htmlentities($text);
239  $this->success = $doc->loadXML($text);
240  $error = $doc->errors;
241  $estr = "";
242  foreach ($error as $e)
243  {
244  $e = str_replace(" in Entity", "", $e);
245  $estr.= $e."<br />";
246  }
247  return $estr;
248  }
249  }
const DOMXML_LOAD_PARSING
domxml_open_mem($str, $mode=DOMXML_LOAD_PARSING, &$error=NULL)
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
Class ilPCParagraph.
getLanguage()
get language
getCharacteristic()
Get characteristic of paragraph.
autoSplit($a_text)
This function splits a paragraph text that has been already processed with input2xml at each header p...
$path
Definition: index.php:22
+ Here is the call graph for this function:

◆ updatePage()

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

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

References $ret.

1630  {
1631  $a_page->beforePageContentUpdate($this);
1632 
1633  $ret = $a_page->update();
1634  return $ret;
1635  }

◆ xml2output()

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(), ilPresentationListTableGUI\fillRow(), ilTermListTableGUI\fillRow(), and ilPageObject\getPageContentsHashes().

1025  {
1026  // note: the order of the processing steps is crucial
1027  // and should be the same as in input2xml() in REVERSE order!
1028 
1029  // xml to bb code
1030  $any = "[^>]*";
1031  $a_text = eregi_replace("<Comment[^>]*>","[com]",$a_text);
1032  $a_text = eregi_replace("</Comment>","[/com]",$a_text);
1033  $a_text = eregi_replace("<Comment/>","[com][/com]",$a_text);
1034  $a_text = eregi_replace("<Emph>","[emp]",$a_text);
1035  $a_text = eregi_replace("</Emph>","[/emp]",$a_text);
1036  $a_text = eregi_replace("<Emph/>","[emp][/emp]",$a_text);
1037  $a_text = eregi_replace("<Strong>","[str]",$a_text);
1038  $a_text = eregi_replace("</Strong>","[/str]",$a_text);
1039  $a_text = eregi_replace("<Strong/>","[str][/str]",$a_text);
1040  $a_text = eregi_replace("<Footnote[^>]*>","[fn]",$a_text);
1041  $a_text = eregi_replace("</Footnote>","[/fn]",$a_text);
1042  $a_text = eregi_replace("<Footnote/>","[fn][/fn]",$a_text);
1043  $a_text = eregi_replace("<Quotation[^>]*>","[quot]",$a_text);
1044  $a_text = eregi_replace("</Quotation>","[/quot]",$a_text);
1045  $a_text = eregi_replace("<Quotation/>","[quot][/quot]",$a_text);
1046  $a_text = eregi_replace("<Code[^>]*>","[code]",$a_text);
1047  $a_text = eregi_replace("</Code>","[/code]",$a_text);
1048  $a_text = eregi_replace("<Code/>","[code][/code]",$a_text);
1049  $a_text = eregi_replace("<Accent>","[acc]",$a_text);
1050  $a_text = eregi_replace("</Accent>","[/acc]",$a_text);
1051  $a_text = eregi_replace("<Important>","[imp]",$a_text);
1052  $a_text = eregi_replace("</Important>","[/imp]",$a_text);
1053  $a_text = eregi_replace("<Keyw>","[kw]",$a_text);
1054  $a_text = eregi_replace("</Keyw>","[/kw]",$a_text);
1055 
1056  // replace lists
1057  if ($a_replace_lists)
1058  {
1059 //echo "<br>".htmlentities($a_text);
1060  $a_text = ilPCParagraph::xml2outputReplaceLists($a_text);
1061 //echo "<br>".htmlentities($a_text);
1062  }
1063 
1064  // internal links
1065  while (eregi("<IntLink($any)>", $a_text, $found))
1066  {
1067  $found[0];
1068  $attribs = ilUtil::attribsToArray($found[1]);
1069  $target = explode("_", $attribs["Target"]);
1070  $target_id = $target[count($target) - 1];
1071  $inst_str = (!is_int(strpos($attribs["Target"], "__")))
1072  ? $inst_str = "inst=\"".$target[1]."\" "
1073  : $inst_str = "";
1074  switch($attribs["Type"])
1075  {
1076  case "PageObject":
1077  $tframestr = (!empty($attribs["TargetFrame"]))
1078  ? " target=\"".$attribs["TargetFrame"]."\""
1079  : "";
1080  $ancstr = (!empty($attribs["Anchor"]))
1081  ? ' anchor="'.$attribs["Anchor"].'"'
1082  : "";
1083  $a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."page=\"".$target_id."\"$tframestr$ancstr]",$a_text);
1084  break;
1085 
1086  case "StructureObject":
1087  $tframestr = (!empty($attribs["TargetFrame"]))
1088  ? " target=\"".$attribs["TargetFrame"]."\""
1089  : "";
1090  $a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."chap=\"".$target_id."\"$tframestr]",$a_text);
1091  break;
1092 
1093  case "GlossaryItem":
1094  $tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
1095  ? ""
1096  : " target=\"".$attribs["TargetFrame"]."\"";
1097  $a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."term=\"".$target_id."\"".$tframestr."]",$a_text);
1098  break;
1099 
1100  case "WikiPage":
1101  $tframestr = "";
1102  /*$tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
1103  ? ""
1104  : " target=\"".$attribs["TargetFrame"]."\"";*/
1105  $a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."wpage=\"".$target_id."\"".$tframestr."]",$a_text);
1106  break;
1107 
1108  case "MediaObject":
1109  if (empty($attribs["TargetFrame"]))
1110  {
1111  $a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."media=\"".$target_id."\"/]",$a_text);
1112  }
1113  else
1114  {
1115  $a_text = eregi_replace("<IntLink".$found[1].">","[iln media=\"".$target_id."\"".
1116  " target=\"".$attribs["TargetFrame"]."\"]",$a_text);
1117  }
1118  break;
1119 
1120  // Repository Item (using ref id)
1121  case "RepositoryItem":
1122  if ($inst_str == "")
1123  {
1125  }
1126  else
1127  {
1128  $rtype = $target[count($target) - 2];
1129  $target_type = $rtype;
1130  }
1131  $a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."$target_type=\"".$target_id."\"".$tframestr."]",$a_text);
1132  break;
1133 
1134  // Download File (not in repository, Object ID)
1135  case "File":
1136  $a_text = eregi_replace("<IntLink".$found[1].">","[iln ".$inst_str."dfile=\"".$target_id."\"".$tframestr."]",$a_text);
1137  break;
1138 
1139  default:
1140  $a_text = eregi_replace("<IntLink".$found[1].">","[iln]",$a_text);
1141  break;
1142  }
1143  }
1144  $a_text = eregi_replace("</IntLink>","[/iln]",$a_text);
1145 
1146  // external links
1147  while (eregi("<ExtLink($any)>", $a_text, $found))
1148  {
1149  $found[0];
1150  $attribs = ilUtil::attribsToArray($found[1]);
1151  //$found[1] = str_replace("?", "\?", $found[1]);
1152  $tstr = "";
1153  if (in_array($attribs["TargetFrame"], array("FAQ", "Glossary", "Media")))
1154  {
1155  $tstr = ' target="'.$attribs["TargetFrame"].'"';
1156  }
1157  $a_text = str_replace("<ExtLink".$found[1].">","[xln url=\"".$attribs["Href"]."\"$tstr]",$a_text);
1158  }
1159  $a_text = eregi_replace("</ExtLink>","[/xln]",$a_text);
1160 
1161  // anchor
1162  while (eregi("<Anchor($any)>", $a_text, $found))
1163  {
1164  $found[0];
1165  $attribs = ilUtil::attribsToArray($found[1]);
1166  $a_text = str_replace("<Anchor".$found[1].">","[anc name=\"".$attribs["Name"]."\"]",$a_text);
1167  }
1168  $a_text = eregi_replace("</Anchor>","[/anc]",$a_text);
1169 
1170 
1171  // br to linefeed
1172  if (!$a_wysiwyg)
1173  {
1174  $a_text = str_replace("<br />", "\n", $a_text);
1175  $a_text = str_replace("<br/>", "\n", $a_text);
1176  }
1177 
1178 if (!$a_wysiwyg)
1179 {
1180  // prevent curly brackets from being swallowed up by template engine
1181  $a_text = str_replace("{", "&#123;", $a_text);
1182  $a_text = str_replace("}", "&#125;", $a_text);
1183 
1184  // unmask html
1185  $a_text = str_replace("&lt;", "<", $a_text);
1186  $a_text = str_replace("&gt;", ">",$a_text);
1187 
1188  // this is needed to allow html like <tag attribute="value">... in paragraphs
1189  $a_text = str_replace("&quot;", "\"", $a_text);
1190 
1191  // make ampersands in (enabled) html attributes work
1192  // e.g. <a href="foo.php?n=4&t=5">hhh</a>
1193  $a_text = str_replace("&amp;", "&", $a_text);
1194 
1195  // make &gt; and $lt; work to allow (disabled) html descriptions
1196  $a_text = str_replace("&lt;", "&amp;lt;", $a_text);
1197  $a_text = str_replace("&gt;", "&amp;gt;", $a_text);
1198 }
1199  return $a_text;
1200  //return str_replace("<br />", chr(13).chr(10), $a_text);
1201  }
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
static xml2outputReplaceLists($a_text)
Replaces with *.
$target_type
Definition: goto.php:87
$target_id
Definition: goto.php:88
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xml2outputReplaceLists()

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().

884  {
885  $segments = ilPCParagraph::segmentString($a_text, array("<SimpleBulletList>", "</SimpleBulletList>",
886  "</SimpleListItem>", "<SimpleListItem>", "<SimpleListItem/>", "<SimpleNumberedList>", "</SimpleNumberedList>"));
887 
888  $current_list = array();
889  $text = "";
890  for ($i=0; $i<= count($segments); $i++)
891  {
892  if ($segments[$i] == "<SimpleBulletList>")
893  {
894  if (count($current_list) == 0)
895  {
896  $list_start = true;
897  }
898  array_push($current_list, "*");
899  $li = false;
900  }
901  else if ($segments[$i] == "<SimpleNumberedList>")
902  {
903  if (count($current_list) == 0)
904  {
905  $list_start = true;
906  }
907  array_push($current_list, "#");
908  $li = false;
909  }
910  else if ($segments[$i] == "</SimpleBulletList>")
911  {
912  array_pop($current_list);
913  $li = false;
914  }
915  else if ($segments[$i] == "</SimpleNumberedList>")
916  {
917  array_pop($current_list);
918  $li = false;
919  }
920  else if ($segments[$i] == "<SimpleListItem>")
921  {
922  $li = true;
923  }
924  else if ($segments[$i] == "</SimpleListItem>")
925  {
926  $li = false;
927  }
928  else if ($segments[$i] == "<SimpleListItem/>")
929  {
930  if ($list_start)
931  {
932  $text.= "<br />";
933  $list_start = false;
934  }
935  foreach($current_list as $list)
936  {
937  $text.= $list;
938  }
939  $text.= "<br />";
940  $li = false;
941  }
942  else
943  {
944  if ($li)
945  {
946  if ($list_start)
947  {
948  $text.= "<br />";
949  $list_start = false;
950  }
951  foreach($current_list as $list)
952  {
953  $text.= $list;
954  }
955  }
956  $text.= $segments[$i];
957  if ($li)
958  {
959  $text.= "<br />";
960  }
961  $li = false;
962  }
963  }
964 
965  // remove trailing <br />, if text ends with list
966  if ($segments[count($segments) - 1] == "</SimpleBulletList>" ||
967  $segments[count($segments) - 1] == "</SimpleNumberedList>" &&
968  substr($text, strlen($text) - 6) == "<br />")
969  {
970  $text = substr($text, 0, strlen($text) - 6);
971  }
972 
973  return $text;
974  }
static segmentString($a_haystack, $a_needles)
Segments a string into an array at each position of a substring.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $dom

ilPCParagraph::$dom

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

◆ $par_node

ilPCParagraph::$par_node

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


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