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 'ilPDTaggingBlockGUI' =>
'Services/Tagging/',
61 'ilChatroomBlockGUI' =>
'Modules/Chatroom/',
62 'ilPollBlockGUI' =>
'Modules/Poll/',
63 'ilClassificationBlockGUI' =>
'Services/Classification/',
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 'ilPDTaggingBlockGUI' =>
'pdtag',
80 'ilChatroomBlockGUI' =>
'chatviewer',
81 'ilPollBlockGUI' =>
'poll',
82 'ilClassificationBlockGUI' =>
'clsfct',
101 "frm" => array(
"ilNewsForContextBlockGUI" =>
IL_COL_RIGHT),
129 "pd" => array(
"ilPDExternalFeedBlockGUI")
135 array(
"news" =>
true,
144 "chatviewer" =>
true,
148 array(
"pdfeed" =>
true);
155 public function __construct($a_col_type =
"", $a_side =
"", $use_std_context =
false)
173 self::$locations[$className] =
$path;
188 self::$block_types[$className] = $identifier;
198 return $_GET[
"col_side"];
208 $this->coltype = $a_coltype;
218 return $this->coltype;
228 $this->side = $a_side;
248 $this->enableedit = $a_enableedit;
268 $this->repositorymode = $a_repositorymode;
288 $this->admincommands = $a_admincommands;
308 $this->movementmode = $a_movementmode;
328 $this->enablemovement = $a_enablemovement;
348 if ($ilCtrl->getCmdClass() ==
"ilcolumngui")
350 switch ($ilCtrl->getCmd())
357 $cur_block_type =
"";
358 if (isset(
$_GET[
"block_type"]) &&
$_GET[
"block_type"])
360 $cur_block_type =
$_GET[
"block_type"];
362 else if (isset(
$_POST[
"block_type"]))
364 $cur_block_type =
$_POST[
"block_type"];
367 if ($class = array_search($cur_block_type, self::$block_types))
369 include_once(
"./".self::$locations[$class].
"classes/".
370 "class.".$class.
".php");
371 return call_user_func(array($class,
'getScreenMode'));
386 $this->block_property[$a_block_type][$a_property] = $a_value;
391 return $this->block_property[$a_block_type];
396 $this->block_property = $a_block_properties;
406 $this->repositoryitems = $a_repositoryitems;
426 $ilCtrl->setParameter($this,
"col_side" ,$this->
getSide());
429 $next_class = $ilCtrl->getNextClass();
430 $cmd = $ilCtrl->getCmd(
"getHTML");
432 $cur_block_type = (
$_GET[
"block_type"])
433 ?
$_GET[
"block_type"]
436 if ($next_class !=
"")
439 if ($gui_class = array_search($cur_block_type, self::$block_types))
441 include_once(
"./".self::$locations[$gui_class].
"classes/".
442 "class.".$gui_class.
".php");
443 $ilCtrl->setParameter($this,
"block_type", $cur_block_type);
444 $block_gui =
new $gui_class();
445 $block_gui->setProperties($this->block_property[$cur_block_type]);
450 if (in_array($gui_class, $this->custom_blocks[$this->
getColType()]) ||
451 in_array($cur_block_type, $this->rep_block_types))
453 $block_class = substr($gui_class, 0, strlen($gui_class)-3);
454 include_once(
"./".self::$locations[$gui_class].
"classes/".
455 "class.".$block_class.
".php");
456 $app_block =
new $block_class(
$_GET[
"block_id"]);
457 $block_gui->setBlock($app_block);
459 $html = $ilCtrl->forwardCommand($block_gui);
460 $ilCtrl->setParameter($this,
"block_type",
"");
467 return $this->
$cmd();
478 $ilBench->start(
"Column",
"getHTML");
480 $ilCtrl->setParameter($this,
"col_side" ,$this->
getSide());
482 $this->tpl =
new ilTemplate(
"tpl.column.html",
true,
true,
"Services/Block");
484 $ilBench->start(
"Column",
"determineBlocks");
486 $ilBench->stop(
"Column",
"determineBlocks");
488 $ilBench->start(
"Column",
"showBlocks");
490 $ilBench->stop(
"Column",
"showBlocks");
494 $this->addHiddenBlockSelector();
497 $ilBench->stop(
"Column",
"getHTML");
499 return $this->tpl->get();
510 $sum_moveable = count($this->blocks[$this->
getSide()]);
512 foreach($this->blocks[$this->
getSide()] as $block)
514 if ($ilCtrl->getContextObjType() !=
"user" ||
516 $ilUser->getId(), $block[
"id"]) > 0)
518 $gui_class = $block[
"class"];
519 $block_class = substr($block[
"class"], 0, strlen($block[
"class"])-3);
522 include_once(
"./".self::$locations[$gui_class].
"classes/".
523 "class.".$gui_class.
".php");
524 $ilBench->start(
"Column",
"instantiate-".$block[
"type"]);
525 $block_gui =
new $gui_class();
526 $ilBench->stop(
"Column",
"instantiate-".$block[
"type"]);
527 if (isset($this->block_property[$block[
"type"]]))
529 $block_gui->setProperties($this->block_property[$block[
"type"]]);
536 if ($block[
"custom"])
538 $path =
"./".self::$locations[$gui_class].
"classes/".
539 "class.".$block_class.
".php";
540 if(file_exists(
$path))
543 $app_block =
new $block_class($block[
"id"]);
550 $block_gui->setBlock($app_block);
551 if (isset($block[
"ref_id"]))
553 $block_gui->setRefId($block[
"ref_id"]);
557 $ilCtrl->setParameter($this,
"block_type", $block_gui->getBlockType());
558 $this->tpl->setCurrentBlock(
"col_block");
560 $ilBench->start(
"Column",
"showBlocks-".$block_gui->getBlockType());
561 $html = $ilCtrl->getHTML($block_gui);
562 $ilBench->stop(
"Column",
"showBlocks-".$block_gui->getBlockType());
568 include_once(
"./Services/Block/classes/class.ilDummyBlockGUI.php");
570 $bl->setBlockId($block[
"id"]);
571 $bl->setBlockType($block[
"type"]);
572 $bl->setTitle($lng->txt(
"invisible_block"));
574 $html = $bl->getHTML();
580 $this->tpl->setVariable(
"BLOCK", $html);
581 $this->tpl->parseCurrentBlock();
582 $ilCtrl->setParameter($this,
"block_type",
"");
586 if ($block[
"type"] !=
"pdsysmess" && $block[
"type"] !=
"pdfeedb" &&
587 $block[
"type"] !=
"news")
602 function addHiddenBlockSelector()
613 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
614 $hidden_blocks = array();
616 foreach($this->blocks[$this->
getSide()] as $block)
618 include_once(
"./".self::$locations[$block[
"class"]].
"classes/".
619 "class.".$block[
"class"].
".php");
621 if ($block[
"custom"] ==
false)
623 if ($ilCtrl->getContextObjType() ==
"user")
627 $hidden_blocks[$block[
"type"]] = $lng->txt(
'block_show_'.$block[
"type"]);
630 else if ($ilCtrl->getContextObjType() !=
"")
633 $ilCtrl->getContextObjId()) == 0)
635 $hidden_blocks[$block[
"type"].
"_".$ilCtrl->getContextObjId()] = $lng->txt(
'block_show_'.$block[
"type"]);
644 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
646 $hidden_blocks[$block[
"type"].
"_".$block[
"id"]] = sprintf($lng->txt(
'block_show_x'), $cblock->getTitle());
650 if(count($hidden_blocks) > 0)
652 foreach($hidden_blocks as $id => $title)
654 $ilCtrl->setParameter($this,
'block', $id);
655 $this->action_menu->addItem($title,
'', $ilCtrl->getLinkTarget($this,
'activateBlock'));
656 $ilCtrl->setParameter($this,
'block',
'');
663 $add_blocks = array();
666 if (is_array($this->custom_blocks[$this->
getColType()]))
668 foreach($this->custom_blocks[$this->
getColType()] as $block_class)
670 include_once(
"./".self::$locations[$block_class].
"classes/".
671 "class.".$block_class.
".php");
672 $block_type = call_user_func(array($block_class,
'getBlockType'));
680 $add_blocks[$block_type] = $lng->txt(
'block_create_'.$block_type);
686 if(count($add_blocks) > 0)
688 foreach($add_blocks as $id => $title)
690 $ilCtrl->setParameter($this,
'block_type', $id);
691 $this->action_menu->addItem($title,
'', $ilCtrl->getLinkTarget($this,
'addBlock'));
692 $ilCtrl->setParameter($this,
'block_type',
'');
697 $this->addBlockSorting();
703 protected function addBlockSorting()
714 include_once
'Services/jQuery/classes/class.iljQueryUtil.php';
718 if($ilBrowser->isMobile() || $ilBrowser->isIpad())
720 $tpl->addJavaScript(
'./Services/jQuery/js/jquery.ui.touch-punch.min.js');
722 $tpl->addJavaScript(
'./Services/Block/js/block_sorting.js');
727 $this->tpl->setVariable(
'BLOCK_SORTING_STORAGE_URL', $ilCtrl->getLinkTarget($this,
'saveBlockSortingAsynch',
'',
true,
false));
728 $this->tpl->setVariable(
'BLOCK_COLUMNS', json_encode(array(
'il_left_col',
'il_right_col')));
729 $this->tpl->setVariable(
'BLOCK_COLUMNS_SELECTOR',
'#il_left_col,#il_right_col');
733 $ilCtrl->setParameter($this,
'col_side', $this->
getSide());
746 $sum_moveable = count($this->blocks[$this->
getSide()]);
748 foreach ($this->blocks[$this->
getSide()] as $block)
751 include_once(
"./".self::$locations[$block[
"class"]].
"classes/".
752 "class.".$block[
"class"].
".php");
756 if (!$block[
"custom"] && $ilCtrl->getContextObjType() !=
"" && $ilCtrl->getContextObjType() !=
"user")
758 $block[
"id"] = $ilCtrl->getContextObjId();
763 if (
$_GET[
"block_id"] ==
"block_".$block[
"type"].
"_".$block[
"id"])
765 $gui_class = $block[
"class"];
766 $block_class = substr($block[
"class"], 0, strlen($block[
"class"])-3);
768 $block_gui =
new $gui_class();
769 $block_gui->setProperties($this->block_property[$block[
"type"]]);
775 if ($block[
"custom"])
777 include_once(
"./".self::$locations[$gui_class].
"classes/".
778 "class.".$block_class.
".php");
779 $app_block =
new $block_class($block[
"id"]);
780 $block_gui->setBlock($app_block);
781 $block_gui->setRefId($block[
"ref_id"]);
784 $ilCtrl->setParameter($this,
"block_type", $block[
"type"]);
785 echo $ilCtrl->getHTML($block_gui);
791 if ($block[
"type"] !=
"pdsysmess" && $block[
"type"] !=
"pdfeedb"
792 && $block[
"type"] !=
"news")
801 echo
"Error: ilColumnGUI::updateBlock: Block '".
802 $_GET[
"block_id"].
"' unknown.";
813 if (
$_GET[
"block"] !=
"")
815 $block = explode(
"_",
$_GET[
"block"]);
816 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
820 $ilCtrl->returnToParent($this);
831 $class = array_search(
$_GET[
"block_type"], self::$block_types);
833 $ilCtrl->setCmdClass($class);
834 $ilCtrl->setCmd(
"create");
835 include_once(
"./".self::$locations[$class].
"classes/class.".$class.
".php");
836 $block_gui =
new $class();
837 $block_gui->setProperties($this->block_property[
$_GET[
"block_type"]]);
842 $ilCtrl->setParameter($this,
"block_type", $_GET[
"block_type"]);
843 $html = $ilCtrl->forwardCommand($block_gui);
844 $ilCtrl->setParameter($this,
"block_type",
"");
855 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
865 if (is_array($this->default_blocks[$this->
getColType()]))
867 foreach($this->default_blocks[$this->
getColType()] as $class => $def_side)
869 $type = self::$block_types[$class];
889 if (
$type ==
"pdsysmess")
893 if (
$type ==
"pdfeedb")
903 $this->blocks[
$side][] = array(
915 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
917 $custom_block->setContextObjId($ilCtrl->getContextObjId());
918 $custom_block->setContextObjType($ilCtrl->getContextObjType());
919 $c_blocks = $custom_block->queryBlocksForContext();
921 foreach($c_blocks as $c_block)
923 $type = $c_block[
"type"];
927 $class = array_search(
$type, self::$block_types);
939 $this->blocks[
$side][] = array(
943 "id" => $c_block[
"id"],
950 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
953 foreach($this->rep_block_types as $block_type)
957 if (!is_array($rep_items[$block_type]))
961 foreach($rep_items[$block_type] as $item)
964 $costum_block->setContextObjId($item[
"obj_id"]);
965 $costum_block->setContextObjType($block_type);
966 $c_blocks = $costum_block->queryBlocksForContext();
967 $c_block = $c_blocks[0];
970 $class = array_search(
$type, self::$block_types);
982 $this->blocks[
$side][] = array(
986 "id" => $c_block[
"id"],
988 "ref_id" => $item[
"ref_id"]);
994 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
996 $custom_block->setContextObjId($ilCtrl->getContextObjId());
997 $custom_block->setContextObjType($ilCtrl->getContextObjType());
998 $c_blocks = $custom_block->queryBlocksForContext(
false);
1000 foreach($c_blocks as $c_block)
1002 $type = $c_block[
"type"];
1003 $class = array_search(
$type, self::$block_types);
1010 $this->blocks[
$side][] = array(
1014 "id" => $c_block[
"id"],
1037 if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type])
1039 if ($a_type ==
'pdbookm')
1041 if (!$ilSetting->get(
"disable_bookmarks"))
1047 else if ($a_type ==
'pdnotes')
1049 if (!$ilSetting->get(
"disable_notes"))
1055 elseif($a_type ==
'news')
1057 include_once
'Services/Container/classes/class.ilContainer.php';
1059 $ilSetting->get(
'block_activated_news') &&
1061 $GLOBALS[
'ilCtrl']->getContextObjId(),
1066 else if ($ilSetting->get(
"block_activated_".$a_type))
1070 elseif($a_type ==
'cal')
1072 include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
1076 elseif($a_type ==
'pdcal')
1078 include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
1081 elseif($a_type ==
"tagcld")
1084 return (
bool)$tags_active->get(
"enable",
false);
1098 if ($this->check_nr_limit[$a_type])
1102 include_once(
"./Services/Block/classes/class.ilCustomBlock.php");
1104 $costum_block->setContextObjId($ilCtrl->getContextObjId());
1105 $costum_block->setContextObjType($ilCtrl->getContextObjType());
1106 $costum_block->setType($a_type);
1107 $res = $costum_block->queryCntBlockForContext();
1108 $cnt = (int)
$res[0][
"cnt"];
1116 if ($ilSetting->get(
"block_limit_".$a_type) > $cnt)
1131 public function saveBlockSortingAsynch()
1138 $response =
new stdClass();
1139 $response->success =
false;
1143 echo json_encode($response);
1147 if(in_array($this->
getColType(), array(
'pd')))
1149 $response->success =
true;
1151 foreach(array(IL_COL_LEFT => (array)
$_POST[IL_COL_LEFT][
'sequence'], IL_COL_RIGHT => (array)
$_POST[IL_COL_RIGHT][
'sequence']) as
$side => $blocks)
1154 foreach($blocks as $block)
1156 $bid = explode(
'_', $block);
1165 echo json_encode($response);