4 define (
"IL_COL_LEFT",
"left");
5 define (
"IL_COL_RIGHT",
"right");
6 define (
"IL_COL_CENTER",
"center");
8 define (
"IL_SCREEN_SIDE",
"");
9 define (
"IL_SCREEN_CENTER",
"center");
10 define (
"IL_SCREEN_FULL",
"full");
48 "ilNewsForContextBlockGUI" =>
"Services/News/",
49 "ilCalendarBlockGUI" =>
"Services/Calendar/",
50 "ilPDCalendarBlockGUI" =>
"Services/Calendar/",
51 "ilPDNotesBlockGUI" =>
"Services/Notes/",
52 "ilPDMailBlockGUI" =>
"Services/Mail/",
53 "ilUsersOnlineBlockGUI" =>
"Services/PersonalDesktop/",
54 "ilPDSysMessageBlockGUI" =>
"Services/Mail/",
55 "ilPDSelectedItemsBlockGUI" =>
"Services/PersonalDesktop/",
56 "ilBookmarkBlockGUI" =>
"Services/Bookmarks/",
57 "ilPDNewsBlockGUI" =>
"Services/News/",
58 "ilExternalFeedBlockGUI" =>
"Services/Block/",
59 "ilPDExternalFeedBlockGUI" =>
"Services/Feeds/",
60 "ilHtmlBlockGUI" =>
"Services/Block/",
61 'ilPDTaggingBlockGUI' =>
'Services/Tagging/',
62 'ilChatroomBlockGUI' =>
'Modules/Chatroom/',
63 'ilPollBlockGUI' =>
'Modules/Poll/'
67 "ilPDMailBlockGUI" =>
"pdmail",
68 "ilPDNotesBlockGUI" =>
"pdnotes",
69 "ilUsersOnlineBlockGUI" =>
"pdusers",
70 "ilPDNewsBlockGUI" =>
"pdnews",
71 "ilBookmarkBlockGUI" =>
"pdbookm",
72 "ilNewsForContextBlockGUI" =>
"news",
73 "ilCalendarBlockGUI" =>
"cal",
74 "ilPDCalendarBlockGUI" =>
"pdcal",
75 "ilExternalFeedBlockGUI" =>
"feed",
76 "ilPDExternalFeedBlockGUI" =>
"pdfeed",
77 "ilPDSysMessageBlockGUI" =>
"pdsysmess",
78 "ilPDSelectedItemsBlockGUI" =>
"pditems",
79 "ilHtmlBlockGUI" =>
"html",
80 'ilPDTaggingBlockGUI' =>
'pdtag',
81 'ilChatroomBlockGUI' =>
'chatviewer',
82 'ilPollBlockGUI' =>
'poll'
87 "cat" => array(
"ilNewsForContextBlockGUI" =>
IL_COL_RIGHT),
95 "frm" => array(
"ilNewsForContextBlockGUI" =>
IL_COL_RIGHT),
122 "pd" => array(
"ilPDExternalFeedBlockGUI")
128 array(
"news" =>
true,
137 "chatviewer" =>
true);
140 array(
"pdfeed" =>
true);
147 public function __construct($a_col_type =
"", $a_side =
"", $use_std_context =
false)
165 self::$locations[$className] =
$path;
180 self::$block_types[$className] = $identifier;
190 return $_GET[
"col_side"];
200 $this->coltype = $a_coltype;
210 return $this->coltype;
220 $this->side = $a_side;
240 $this->enableedit = $a_enableedit;
260 $this->repositorymode = $a_repositorymode;
280 $this->admincommands = $a_admincommands;
300 $this->movementmode = $a_movementmode;
320 $this->enablemovement = $a_enablemovement;
340 if ($ilCtrl->getCmdClass() ==
"ilcolumngui")
342 switch ($ilCtrl->getCmd())
349 $cur_block_type =
"";
350 if (isset(
$_GET[
"block_type"]) &&
$_GET[
"block_type"])
352 $cur_block_type =
$_GET[
"block_type"];
354 else if (isset(
$_POST[
"block_type"]))
356 $cur_block_type =
$_POST[
"block_type"];
359 if ($class = array_search($cur_block_type, self::$block_types))
361 include_once(
"./".self::$locations[$class].
"classes/".
362 "class.".$class.
".php");
363 return call_user_func(array($class,
'getScreenMode'));
378 $this->block_property[$a_block_type][$a_property] = $a_value;
383 return $this->block_property[$a_block_type];
388 $this->block_property = $a_block_properties;
398 $this->repositoryitems = $a_repositoryitems;
418 $ilCtrl->setParameter($this,
"col_side" ,$this->
getSide());
421 $next_class = $ilCtrl->getNextClass();
422 $cmd = $ilCtrl->getCmd(
"getHTML");
424 $cur_block_type = (
$_GET[
"block_type"])
425 ?
$_GET[
"block_type"]
428 if ($next_class !=
"")
431 if ($gui_class = array_search($cur_block_type, self::$block_types))
433 include_once(
"./".self::$locations[$gui_class].
"classes/".
434 "class.".$gui_class.
".php");
435 $ilCtrl->setParameter($this,
"block_type", $cur_block_type);
436 $block_gui =
new $gui_class();
437 $block_gui->setProperties($this->block_property[$cur_block_type]);
442 if (in_array($gui_class, $this->custom_blocks[$this->
getColType()]) ||
443 in_array($cur_block_type, $this->rep_block_types))
445 $block_class = substr($gui_class, 0, strlen($gui_class)-3);
446 include_once(
"./".self::$locations[$gui_class].
"classes/".
447 "class.".$block_class.
".php");
448 $app_block =
new $block_class(
$_GET[
"block_id"]);
449 $block_gui->setBlock($app_block);
451 $html = $ilCtrl->forwardCommand($block_gui);
452 $ilCtrl->setParameter($this,
"block_type",
"");
459 return $this->
$cmd();
470 $ilBench->start(
"Column",
"getHTML");
472 $ilCtrl->setParameter($this,
"col_side" ,$this->
getSide());
474 $this->tpl =
new ilTemplate(
"tpl.column.html",
true,
true,
"Services/Block");
476 $ilBench->start(
"Column",
"determineBlocks");
478 $ilBench->stop(
"Column",
"determineBlocks");
480 $ilBench->start(
"Column",
"showBlocks");
482 $ilBench->stop(
"Column",
"showBlocks");
486 $this->addHiddenBlockSelector();
489 $ilBench->stop(
"Column",
"getHTML");
491 return $this->tpl->get();
502 $sum_moveable = count($this->blocks[$this->
getSide()]);
504 foreach($this->blocks[$this->
getSide()] as $block)
506 if ($ilCtrl->getContextObjType() !=
"user" ||
508 $ilUser->getId(), $block[
"id"]) > 0)
510 $gui_class = $block[
"class"];
511 $block_class = substr($block[
"class"], 0, strlen($block[
"class"])-3);
514 include_once(
"./".self::$locations[$gui_class].
"classes/".
515 "class.".$gui_class.
".php");
516 $ilBench->start(
"Column",
"instantiate-".$block[
"type"]);
517 $block_gui =
new $gui_class();
518 $ilBench->stop(
"Column",
"instantiate-".$block[
"type"]);
519 if (isset($this->block_property[$block[
"type"]]))
521 $block_gui->setProperties($this->block_property[$block[
"type"]]);
528 if ($block[
"custom"])
530 include_once(
"./".self::$locations[$gui_class].
"classes/".
531 "class.".$block_class.
".php");
532 $app_block =
new $block_class($block[
"id"]);
533 $block_gui->setBlock($app_block);
534 if (isset($block[
"ref_id"]))
536 $block_gui->setRefId($block[
"ref_id"]);
540 $ilCtrl->setParameter($this,
"block_type", $block_gui->getBlockType());
541 $this->tpl->setCurrentBlock(
"col_block");
543 $ilBench->start(
"Column",
"showBlocks-".$block_gui->getBlockType());
544 $html = $ilCtrl->getHTML($block_gui);
545 $ilBench->stop(
"Column",
"showBlocks-".$block_gui->getBlockType());
551 include_once(
"./Services/Block/classes/class.ilDummyBlockGUI.php");
553 $bl->setBlockId($block[
"id"]);
554 $bl->setBlockType($block[
"type"]);
555 $bl->setTitle($lng->txt(
"invisible_block"));
557 $html = $bl->getHTML();
563 $this->tpl->setVariable(
"BLOCK", $html);
564 $this->tpl->parseCurrentBlock();
565 $ilCtrl->setParameter($this,
"block_type",
"");
569 if ($block[
"type"] !=
"pdsysmess" && $block[
"type"] !=
"pdfeedb" &&
570 $block[
"type"] !=
"news")
585 function addHiddenBlockSelector()
596 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
597 $hidden_blocks = array();
599 foreach($this->blocks[$this->
getSide()] as $block)
601 include_once(
"./".self::$locations[$block[
"class"]].
"classes/".
602 "class.".$block[
"class"].
".php");
604 if ($block[
"custom"] ==
false)
606 if ($ilCtrl->getContextObjType() ==
"user")
610 $hidden_blocks[$block[
"type"]] = $lng->txt(
'block_show_'.$block[
"type"]);
613 else if ($ilCtrl->getContextObjType() !=
"")
616 $ilCtrl->getContextObjId()) == 0)
618 $hidden_blocks[$block[
"type"].
"_".$ilCtrl->getContextObjId()] = $lng->txt(
'block_show_'.$block[
"type"]);
627 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
629 $hidden_blocks[$block[
"type"].
"_".$block[
"id"]] = sprintf($lng->txt(
'block_show_x'), $cblock->getTitle());
633 if(count($hidden_blocks) > 0)
635 foreach($hidden_blocks as $id => $title)
637 $ilCtrl->setParameter($this,
'block', $id);
638 $this->action_menu->addItem($title,
'', $ilCtrl->getLinkTarget($this,
'activateBlock'));
639 $ilCtrl->setParameter($this,
'block',
'');
646 $add_blocks = array();
649 if (is_array($this->custom_blocks[$this->
getColType()]))
651 foreach($this->custom_blocks[$this->
getColType()] as $block_class)
653 include_once(
"./".self::$locations[$block_class].
"classes/".
654 "class.".$block_class.
".php");
655 $block_type = call_user_func(array($block_class,
'getBlockType'));
663 $add_blocks[$block_type] = $lng->txt(
'block_create_'.$block_type);
669 if(count($add_blocks) > 0)
671 foreach($add_blocks as $id => $title)
673 $ilCtrl->setParameter($this,
'block_type', $id);
674 $this->action_menu->addItem($title,
'', $ilCtrl->getLinkTarget($this,
'addBlock'));
675 $ilCtrl->setParameter($this,
'block_type',
'');
680 $this->addBlockSorting();
686 protected function addBlockSorting()
697 include_once
'Services/jQuery/classes/class.iljQueryUtil.php';
701 if($ilBrowser->isMobile() || $ilBrowser->isIpad())
703 $tpl->addJavaScript(
'./Services/jQuery/js/jquery.ui.touch-punch.min.js');
705 $tpl->addJavaScript(
'./Services/Block/js/block_sorting.js');
710 $this->tpl->setVariable(
'BLOCK_SORTING_STORAGE_URL', $ilCtrl->getLinkTarget($this,
'saveBlockSortingAsynch',
'',
true,
false));
711 $this->tpl->setVariable(
'BLOCK_COLUMNS', json_encode(array(
'il_left_col',
'il_right_col')));
712 $this->tpl->setVariable(
'BLOCK_COLUMNS_SELECTOR',
'#il_left_col,#il_right_col');
716 $ilCtrl->setParameter($this,
'col_side', $this->
getSide());
729 $sum_moveable = count($this->blocks[$this->
getSide()]);
731 foreach ($this->blocks[$this->
getSide()] as $block)
734 include_once(
"./".self::$locations[$block[
"class"]].
"classes/".
735 "class.".$block[
"class"].
".php");
739 if (!$block[
"custom"] && $ilCtrl->getContextObjType() !=
"" && $ilCtrl->getContextObjType() !=
"user")
741 $block[
"id"] = $ilCtrl->getContextObjId();
746 if (
$_GET[
"block_id"] ==
"block_".$block[
"type"].
"_".$block[
"id"])
748 $gui_class = $block[
"class"];
749 $block_class = substr($block[
"class"], 0, strlen($block[
"class"])-3);
751 $block_gui =
new $gui_class();
752 $block_gui->setProperties($this->block_property[$block[
"type"]]);
758 if ($block[
"custom"])
760 include_once(
"./".self::$locations[$gui_class].
"classes/".
761 "class.".$block_class.
".php");
762 $app_block =
new $block_class($block[
"id"]);
763 $block_gui->setBlock($app_block);
764 $block_gui->setRefId($block[
"ref_id"]);
767 $ilCtrl->setParameter($this,
"block_type", $block[
"type"]);
768 echo $ilCtrl->getHTML($block_gui);
774 if ($block[
"type"] !=
"pdsysmess" && $block[
"type"] !=
"pdfeedb"
775 && $block[
"type"] !=
"news")
784 echo
"Error: ilColumnGUI::updateBlock: Block '".
785 $_GET[
"block_id"].
"' unknown.";
796 if (
$_GET[
"block"] !=
"")
798 $block = explode(
"_",
$_GET[
"block"]);
799 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
803 $ilCtrl->returnToParent($this);
814 $class = array_search(
$_GET[
"block_type"], self::$block_types);
816 $ilCtrl->setCmdClass($class);
817 $ilCtrl->setCmd(
"create");
818 include_once(
"./".self::$locations[$class].
"classes/class.".$class.
".php");
819 $block_gui =
new $class();
820 $block_gui->setProperties($this->block_property[
$_GET[
"block_type"]]);
825 $ilCtrl->setParameter($this,
"block_type", $_GET[
"block_type"]);
826 $html = $ilCtrl->forwardCommand($block_gui);
827 $ilCtrl->setParameter($this,
"block_type",
"");
838 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
848 if (is_array($this->default_blocks[$this->
getColType()]))
850 foreach($this->default_blocks[$this->
getColType()] as $class => $def_side)
852 $type = self::$block_types[$class];
872 if (
$type ==
"pdsysmess")
876 if (
$type ==
"pdfeedb")
886 $this->blocks[
$side][] = array(
898 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
900 $costum_block->setContextObjId($ilCtrl->getContextObjId());
901 $costum_block->setContextObjType($ilCtrl->getContextObjType());
902 $c_blocks = $costum_block->queryBlocksForContext();
904 foreach($c_blocks as $c_block)
906 $type = $c_block[
"type"];
910 $class = array_search(
$type, self::$block_types);
922 $this->blocks[
$side][] = array(
926 "id" => $c_block[
"id"],
933 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
936 foreach($this->rep_block_types as $block_type)
940 if (!is_array($rep_items[$block_type]))
944 foreach($rep_items[$block_type] as $item)
947 $costum_block->setContextObjId($item[
"obj_id"]);
948 $costum_block->setContextObjType($block_type);
949 $c_blocks = $costum_block->queryBlocksForContext();
950 $c_block = $c_blocks[0];
953 $class = array_search(
$type, self::$block_types);
965 $this->blocks[
$side][] = array(
969 "id" => $c_block[
"id"],
971 "ref_id" => $item[
"ref_id"]);
994 if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type])
996 if ($a_type ==
'pdbookm')
998 if (!$ilSetting->get(
"disable_bookmarks"))
1004 else if ($a_type ==
'pdnotes')
1006 if (!$ilSetting->get(
"disable_notes"))
1012 elseif($a_type ==
'news')
1014 include_once
'Services/Container/classes/class.ilContainer.php';
1016 $ilSetting->get(
'block_activated_news') &&
1018 $GLOBALS[
'ilCtrl']->getContextObjId(),
1023 else if ($ilSetting->get(
"block_activated_".$a_type))
1027 elseif($a_type ==
'cal')
1029 include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
1033 elseif($a_type ==
'pdcal')
1035 include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
1050 if ($this->check_nr_limit[$a_type])
1054 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1056 $costum_block->setContextObjId($ilCtrl->getContextObjId());
1057 $costum_block->setContextObjType($ilCtrl->getContextObjType());
1058 $costum_block->setType($a_type);
1059 $res = $costum_block->queryCntBlockForContext();
1060 $cnt = (int)
$res[0][
"cnt"];
1068 if ($ilSetting->get(
"block_limit_".$a_type) > $cnt)
1083 public function saveBlockSortingAsynch()
1090 $response =
new stdClass();
1091 $response->success =
false;
1095 echo json_encode($response);
1099 if(in_array($this->
getColType(), array(
'pd')))
1101 $response->success =
true;
1103 foreach(array(IL_COL_LEFT => (array)
$_POST[IL_COL_LEFT][
'sequence'], IL_COL_RIGHT => (array)
$_POST[IL_COL_RIGHT][
'sequence']) as
$side => $blocks)
1106 foreach($blocks as $block)
1108 $bid = explode(
'_', $block);
1117 echo json_encode($response);