ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPCParagraphGUI Class Reference

Class ilPCParagraphGUI User Interface for Paragraph Editing. More...

+ Inheritance diagram for ilPCParagraphGUI:
+ Collaboration diagram for ilPCParagraphGUI:

Public Member Functions

 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
 
 executeCommand ()
 execute command More...
 
 determineCharacteristic (bool $a_insert=false)
 Determine current characteristic. More...
 
 editJS ()
 Edit paragraph (Ajax mode, sends the content of the paragraph) More...
 
 outputError (array $a_err)
 Output error. More...
 
 cancel ()
 
 insertCharacteristicTable (ilTemplate $a_tpl, string $a_seleted_value)
 Insert characteristic table. More...
 
 insertHelp (ilTemplate $a_tpl)
 Insert Help. More...
 
- Public Member Functions inherited from ilPageContentGUI
 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id="", string $a_pc_id="0")
 
 setContentObject (ilPageContent $a_val)
 
 getContentObject ()
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 setPageConfig (ilPageConfig $a_val)
 
 getPageConfig ()
 
 setStyleId (int $a_styleid)
 
 getStyleId ()
 
 getStyle ()
 
 getCharacteristicsOfCurrentStyle (array $a_type)
 Get characteristics of current style and call setCharacteristics, if style is given. More...
 
 setCharacteristics (array $a_chars)
 
 getCharacteristics ()
 
 getHierId ()
 
 setHierId (string $a_hier_id)
 set hierarchical id in dom object More...
 
 delete ()
 
 displayValidationError ()
 
 cancelCreate ()
 cancel creating page content More...
 
 cancelUpdate ()
 cancel update More...
 
 cancel ()
 Cancel. More...
 
 deactivate ()
 gui function set enabled if is not enabled and vice versa More...
 
 cut ()
 Cut single element. More...
 
 copy ()
 Copy single element. More...
 
 getTemplateOptions (string $a_type="")
 Get table templates. More...
 

Static Public Member Functions

static _getStandardCharacteristics ()
 Get standard characteristics. More...
 
static _getStandardTextCharacteristics ()
 Get standard characteristics. More...
 
static _getCharacteristics (int $a_style_id)
 Get characteristics. More...
 
static xml2outputJS (string $s_text)
 Prepare content for js output. More...
 
- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 

Protected Attributes

ilObjUser $user
 
- Protected Attributes inherited from ilPageContentGUI
ILIAS COPage Editor GUIService $editor_gui
 
ILIAS COPage InternalGUIService $gui
 
EditSessionRepository $edit_repo
 
string $pc_id = ""
 
array $chars
 
ilObjStyleSheet $style = null
 
LOMServices $lom_services
 
ilLogger $log
 
int $styleid = 0
 
EditGUIRequest $request
 
string $sub_command = ""
 
int $requested_ref_id = 0
 
ILIAS GlobalScreen ScreenContext ContextServices $tool_context
 
Style Content CharacteristicManager $char_manager
 

Private Member Functions

 setStyle ()
 

Additional Inherited Members

- Data Fields inherited from ilPageContentGUI
ilPageContent $content_obj
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilPageObject $pg_obj
 
string $hier_id = ""
 
DOMDocument $dom
 
 $updated
 
string $target_script = ""
 
string $return_location = ""
 
ilPageConfig $page_config = null
 
- Static Public Attributes inherited from ilPageContentGUI
static string $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;"
 
- Protected Member Functions inherited from ilPageContentGUI
 redirectToParent (string $hier_id="")
 
 getParentReturn (string $hier_id="")
 
 updateAndReturn ()
 
 setCurrentTextLang (string $lang_key)
 
 getCurrentTextLang ()
 
 setEditorToolContext ()
 
 initEditor ()
 
 getEditorScriptTag (string $form_pc_id="", string $form_cname="")
 
- Static Protected Attributes inherited from ilPageContentGUI
static array $common_bb_buttons
 

Detailed Description

Class ilPCParagraphGUI User Interface for Paragraph Editing.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file class.ilPCParagraphGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPCParagraphGUI::__construct ( ilPageObject  $a_pg_obj,
?ilPageContent  $a_content_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

Definition at line 30 of file class.ilPCParagraphGUI.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), _getStandardCharacteristics(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilPageContentGUI\setCharacteristics(), and ILIAS\Repository\user().

35  {
36  global $DIC;
37 
38  $this->user = $DIC->user();
39  $this->ctrl = $DIC->ctrl();
40  $this->lng = $DIC->language();
41  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
42 
43  // characteristics (should be flexible in the future)
45  }
setCharacteristics(array $a_chars)
static _getStandardCharacteristics()
Get standard characteristics.
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ _getCharacteristics()

static ilPCParagraphGUI::_getCharacteristics ( int  $a_style_id)
static

Get characteristics.

Definition at line 79 of file class.ilPCParagraphGUI.php.

References ilPageContentGUI\$char_manager, ilPageContentGUI\$chars, $DIC, ilPageContentGUI\$request, ilPageContentGUI\$requested_ref_id, $service, ilPageContentGUI\$style, _getStandardCharacteristics(), and ilObject\_lookupType().

Referenced by ParagraphStyleSelector\getStyleSelector(), and ilPageEditorGUI\initCharacteristicForm().

79  : array
80  {
81  global $DIC;
82  $request = $DIC->copage()->internal()
83  ->gui()
84  ->pc()
85  ->editRequest();
86  $requested_ref_id = $request->getRefId();
87 
88  $service = $DIC->contentStyle()->internal();
89 
92  if ($a_style_id > 0 &&
93  ilObject::_lookupType($a_style_id) == "sty") {
94  $access_manager = $service->domain()->access(
96  $DIC->user()->getId()
97  );
98  $char_manager = $service->domain()->characteristic(
99  $a_style_id,
100  $access_manager
101  );
102 
103  $chars = $char_manager->getByTypes(
104  ["text_block", "heading1", "heading2", "heading3"],
105  false,
106  false
107  );
108  $new_chars = array();
109  foreach ($chars as $char) {
110  if (($st_chars[$char->getCharacteristic()] ?? "") != "") { // keep lang vars for standard chars
111  $title = $char_manager->getPresentationTitle(
112  $char->getType(),
113  $char->getCharacteristic()
114  );
115  if ($title == "") {
116  $title = $st_chars[$char->getCharacteristic()];
117  }
118  $new_chars[$char->getCharacteristic()] = $title;
119  } else {
120  $new_chars[$char->getCharacteristic()] = $char_manager->getPresentationTitle(
121  $char->getType(),
122  $char->getCharacteristic()
123  );
124  }
125  }
126  $chars = $new_chars;
127  }
128 
129  return $chars;
130  }
static _getStandardCharacteristics()
Get standard characteristics.
Style Content CharacteristicManager $char_manager
global $DIC
Definition: shib_login.php:22
static _lookupType(int $id, bool $reference=false)
$service
Definition: ltiservices.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getStandardCharacteristics()

static ilPCParagraphGUI::_getStandardCharacteristics ( )
static

Get standard characteristics.

Definition at line 50 of file class.ilPCParagraphGUI.php.

References $DIC, ilPageContentGUI\$lng, and ilLanguage\txt().

Referenced by __construct(), and _getCharacteristics().

50  : array
51  {
52  global $DIC;
53 
54  $lng = $DIC->language();
55 
56  return array("Standard" => $lng->txt("cont_standard"),
57  "Headline1" => $lng->txt("cont_Headline1"),
58  "Headline2" => $lng->txt("cont_Headline2"),
59  "Headline3" => $lng->txt("cont_Headline3"),
60  "Book" => $lng->txt("cont_Book"),
61  "Numbers" => $lng->txt("cont_Numbers"),
62  "Verse" => $lng->txt("cont_Verse"),
63  "List" => $lng->txt("cont_List"),
64  "TableContent" => $lng->txt("cont_TableContent")
65  );
66  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getStandardTextCharacteristics()

static ilPCParagraphGUI::_getStandardTextCharacteristics ( )
static

Get standard characteristics.

Definition at line 71 of file class.ilPCParagraphGUI.php.

71  : array
72  {
73  return ["Mnemonic", "Attention"];
74  }

◆ cancel()

ilPCParagraphGUI::cancel ( )

Definition at line 382 of file class.ilPCParagraphGUI.php.

References ILIAS\Repository\ctrl().

382  : void
383  {
384  $this->log->debug("ilPCParagraphGUI, cancel(): return to parent: jump" . $this->hier_id);
385  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
386  }
+ Here is the call graph for this function:

◆ determineCharacteristic()

ilPCParagraphGUI::determineCharacteristic ( bool  $a_insert = false)

Determine current characteristic.

Definition at line 214 of file class.ilPCParagraphGUI.php.

References ILIAS\Repository\ctrl(), and ilPageContentGUI\getHierId().

Referenced by editJS().

214  : string
215  {
216  $cmd = $this->ctrl->getCmd();
217  // language and characteristic selection
218  if (!$a_insert) {
219  if ($cmd == "update") {
220  $s_char = $this->request->getString("par_characteristic");
221  } else {
222  $s_char = $this->content_obj->getCharacteristic();
223  if ($s_char == "") {
224  $s_char = "Standard";
225  }
226  }
227  } else {
228  if ($cmd == "create") {
229  $s_char = $this->request->getString("par_characteristic");
230  } else {
231  $s_char = "Standard";
232 
233  // set characteristic of new paragraphs in list items to "List"
234  $cont_obj = $this->pg_obj->getContentObject($this->getHierId());
235  if (is_object($cont_obj)) {
236  if ($cont_obj->getType() == "li" ||
237  ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "List")) {
238  $s_char = "List";
239  }
240 
241  if ($cont_obj->getType() == "td" ||
242  ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "TableContent")) {
243  $s_char = "TableContent";
244  }
245  }
246  }
247  }
248  return $s_char;
249  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editJS()

ilPCParagraphGUI::editJS ( )

Edit paragraph (Ajax mode, sends the content of the paragraph)

Definition at line 254 of file class.ilPCParagraphGUI.php.

References determineCharacteristic(), exit, and xml2outputJS().

254  : void
255  {
256  $s_text = $this->content_obj->getText();
257  $this->log->debug("step 1: " . substr($s_text, 0, 1000));
258 
259  //echo "\n<br><br>".htmlentities($s_text);
260  $s_text = $this->content_obj->xml2output($s_text, true, false);
261  $this->log->debug("step 2: " . substr($s_text, 0, 1000));
262 
263  //echo "\n<br><br>".htmlentities($s_text);
264  $char = $this->determineCharacteristic(false);
265  $s_text = ilPCParagraphGUI::xml2outputJS($s_text);
266  $this->log->debug("step 3: " . substr($s_text, 0, 1000));
267 
268  //echo "\n<br><br>".htmlentities($s_text);
269  $ids = "###" . $this->content_obj->readHierId() . ":" . $this->content_obj->readPCId() . "###" .
270  $char . "###";
271  echo $ids . $s_text;
272  $this->log->debug("step 4: " . substr($ids . $s_text, 0, 1000));
273  exit;
274  }
static xml2outputJS(string $s_text)
Prepare content for js output.
determineCharacteristic(bool $a_insert=false)
Determine current characteristic.
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ executeCommand()

ilPCParagraphGUI::executeCommand ( )

execute command

Returns
mixed

Definition at line 187 of file class.ilPCParagraphGUI.php.

References ILIAS\Repository\ctrl(), and ilPageContentGUI\getCharacteristicsOfCurrentStyle().

188  {
189  // get next class that processes or forwards current command
190  $next_class = $this->ctrl->getNextClass($this);
191 
193  array("text_block", "heading1", "heading2", "heading3")
194  ); // scorm-2004
195 
196  // get current command
197  $cmd = $this->ctrl->getCmd();
198 
199  $this->log->debug("ilPCParagraphGUI: executeCommand " . $cmd);
200 
201  switch ($next_class) {
202  default:
203  $ret = $this->$cmd();
204  break;
205  }
206 
207  return $ret;
208  }
getCharacteristicsOfCurrentStyle(array $a_type)
Get characteristics of current style and call setCharacteristics, if style is given.
+ Here is the call graph for this function:

◆ insertCharacteristicTable()

ilPCParagraphGUI::insertCharacteristicTable ( ilTemplate  $a_tpl,
string  $a_seleted_value 
)

Insert characteristic table.

Definition at line 391 of file class.ilPCParagraphGUI.php.

References ilPageContentGUI\$chars, ilPageContentGUI\getCharacteristics(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilTemplate\touchBlock().

394  : void {
395  $i = 0;
396 
397  $chars = $this->getCharacteristics();
398 
399  if ($chars[$a_seleted_value] == "" && ($a_seleted_value != "")) {
400  $chars = array_merge(
401  array($a_seleted_value => $a_seleted_value),
402  $chars
403  );
404  }
405 
406  foreach ($chars as $char => $char_lang) {
407  $a_tpl->setCurrentBlock("characteristic_cell");
408  $a_tpl->setVariable(
409  "CHAR_HTML",
410  '<div class="ilc_text_block_' . $char . '" style="margin-top:2px; margin-bottom:2px; position:static;">' . $char_lang . "</div>"
411  );
412  $a_tpl->setVariable("CHAR_VALUE", $char);
413  if ($char == $a_seleted_value) {
414  $a_tpl->setVariable(
415  "SELECTED",
416  ' checked="checked" '
417  );
418  }
419  $a_tpl->parseCurrentBlock();
420  if ((($i + 1) % 3) == 0) { //
421  $a_tpl->touchBlock("characteristic_row");
422  }
423  $i++;
424  }
425  $a_tpl->touchBlock("characteristic_table");
426  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
touchBlock(string $block)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ insertHelp()

ilPCParagraphGUI::insertHelp ( ilTemplate  $a_tpl)

Insert Help.

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

References ilPageContentGUI\$lng, ilPageContentGUI\getPageConfig(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilLanguage\txt().

445  : void
446  {
447  $lng = $this->lng;
448 
449  $a_tpl->setCurrentBlock("help_item");
450  $a_tpl->setVariable("TXT_HELP", "<strong>" . $lng->txt("cont_syntax_help") . "</strong>");
451  $a_tpl->parseCurrentBlock();
452  $a_tpl->setCurrentBlock("help_item");
453  $a_tpl->setVariable("TXT_HELP", "* " . $lng->txt("cont_bullet_list"));
454  $a_tpl->parseCurrentBlock();
455  $a_tpl->setCurrentBlock("help_item");
456  $a_tpl->setVariable("TXT_HELP", "# " . $lng->txt("cont_numbered_list"));
457  $a_tpl->parseCurrentBlock();
458  $a_tpl->setCurrentBlock("help_item");
459  $a_tpl->setVariable("TXT_HELP", "=" . $lng->txt("cont_Headline1") . "=<br />" .
460  "==" . $lng->txt("cont_Headline2") . "==<br />" .
461  "===" . $lng->txt("cont_Headline3") . "===");
462  $a_tpl->parseCurrentBlock();
463 
464  if ($this->getPageConfig()->getEnableWikiLinks()) {
465  $a_tpl->setCurrentBlock("help_item");
466  $a_tpl->setVariable("TXT_HELP", "[[" . $lng->txt("cont_wiki_page_link") . "]]");
467  $a_tpl->parseCurrentBlock();
468  }
469 
470  $a_tpl->setCurrentBlock("help");
471  $a_tpl->parseCurrentBlock();
472  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ outputError()

ilPCParagraphGUI::outputError ( array  $a_err)

Output error.

Definition at line 371 of file class.ilPCParagraphGUI.php.

References exit.

371  : void
372  {
373  $err_str = "";
374  foreach ($a_err as $err) {
375  $err_str .= $err[1] . "<br />";
376  }
377  echo $err_str;
378  $this->log->debug("ilPCParagraphGUI, outputError() and exit: " . substr($err_str, 0, 100));
379  exit;
380  }
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setStyle()

ilPCParagraphGUI::setStyle ( )
private

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

References ilObjContentObject\_lookupStyleSheetId(), and ilObjStyleSheet\getContentStylePath().

428  : void
429  {
430  if ($this->pg_obj->getParentType() == "term" ||
431  $this->pg_obj->getParentType() == "lm") {
432  if ($this->pg_obj->getParentType() != "term") {
433  $this->tpl->addCss(ilObjStyleSheet::getContentStylePath(
434  ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())
435  ));
436  } else {
437  $this->tpl->addCss(ilObjStyleSheet::getContentStylePath(0));
438  }
439  }
440  }
static _lookupStyleSheetId(int $a_cont_obj_id)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
+ Here is the call graph for this function:

◆ xml2outputJS()

static ilPCParagraphGUI::xml2outputJS ( string  $s_text)
static

Prepare content for js output.

Definition at line 279 of file class.ilPCParagraphGUI.php.

References ilPageContentGUI\_getCommonBBButtons(), and ilPCParagraph\attribsToArray().

Referenced by editJS(), ilPCDataTableGUI\getCellContent(), ilPCTable\getModel(), ilPCParagraph\getModel(), and ilPCParagraphModelProvider\getModels().

279  : string
280  {
281  // lists
282  $s_text = str_replace(
283  array("<SimpleBulletList>", "</SimpleBulletList>"),
284  array('<ul class="ilc_list_u_BulletedList">', "</ul>"),
285  $s_text
286  );
287  while (preg_match('~<SimpleBulletList Class=\"([^\"]*)\">~i', $s_text, $found)) {
288  $class = $found[1];
289  $s_text = str_replace('<SimpleBulletList Class="' . $class . '">', '<ul class="ilc_list_u_' . $class . '">', $s_text);
290  }
291  $s_text = str_replace(
292  array("<SimpleNumberedList>", "</SimpleNumberedList>"),
293  array('<ol class="ilc_list_o_NumberedList">', "</ol>"),
294  $s_text
295  );
296  while (preg_match('~<SimpleNumberedList Class=\"([^\"]*)\">~i', $s_text, $found)) {
297  $class = $found[1];
298  $s_text = str_replace('<SimpleNumberedList Class="' . $class . '">', '<ol class="ilc_list_o_' . $class . '">', $s_text);
299  }
300  $s_text = str_replace(
301  array("<SimpleListItem>", "</SimpleListItem>"),
302  array('<li class="ilc_list_item_StandardListItem">', "</li>"),
303  $s_text
304  );
305  $s_text = str_replace(
306  array("<SimpleListItem/>"),
307  array('<li class="ilc_list_item_StandardListItem"></li>'),
308  $s_text
309  );
310  while (preg_match('~<SimpleListItem Class=\"([^\"]*)\">~i', $s_text, $found)) {
311  $class = $found[1];
312  $s_text = str_replace('<SimpleListItem Class="' . $class . '">', '<li class="ilc_list_item_' . $class . '">', $s_text);
313  }
314 
315  // spans
316  foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl) {
317  if (!in_array($bb, array("code", "tex", "fn", "xln", "sub", "sup"))) {
318  $s_text = str_replace(
319  "[" . $bb . "]",
320  '<span class="ilc_text_inline_' . $cl . '">',
321  $s_text
322  );
323  $s_text = str_replace(
324  "[/" . $bb . "]",
325  '</span>',
326  $s_text
327  );
328  }
329  }
330 
331  // marked text spans
332  $ws = "[ \t\r\f\v\n]*";
333  while (preg_match("~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $s_text, $found)) {
334  $attribs = ilPCParagraph::attribsToArray($found[2]);
335  if (isset($attribs["class"])) {
336  $s_text = str_replace("[" . $found[1] . "]", "<span class=\"ilc_text_inline_" . $attribs["class"] . "\">", $s_text);
337  } else {
338  $s_text = str_replace("[" . $found[1] . "]", "[error:marked" . $found[1] . "]", $s_text);
339  }
340  }
341  $s_text = preg_replace('~\[\/marked\]~i', "</span>", $s_text);
342 
343 
344  // code
345  $s_text = str_replace(
346  array("[code]", "[/code]"),
347  array("<code>", "</code>"),
348  $s_text
349  );
350 
351  // sup
352  $s_text = str_replace(
353  array("[sup]", "[/sup]"),
354  array('<sup class="ilc_sup_Sup">', "</sup>"),
355  $s_text
356  );
357 
358  // sub
359  $s_text = str_replace(
360  array("[sub]", "[/sub]"),
361  array('<sub class="ilc_sub_Sub">', "</sub>"),
362  $s_text
363  );
364 
365  return $s_text;
366  }
static attribsToArray(string $a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $user

ilObjUser ilPCParagraphGUI::$user
protected

Definition at line 28 of file class.ilPCParagraphGUI.php.


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