1<?php 2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once './Services/Table/classes/class.ilTable2GUI.php'; 5 6/** 7 * Defines a system check task 8 * 9 * @author Stefan Meyer <smeyer.ilias@gmx.de> 10 */ 11class ilSCTreeDuplicatesTableGUI extends ilTable2GUI 12{ 13 /** 14 * Constructor 15 * @param type $a_parent_obj 16 * @param type $a_parent_cmd 17 */ 18 public function __construct($a_parent_obj, $a_parent_cmd = "") 19 { 20 $this->setId('sysc_tree_duplicates'); 21 parent::__construct($a_parent_obj, $a_parent_cmd); 22 } 23 24 /** 25 * Init Table 26 */ 27 public function init() 28 { 29 $this->setExternalSorting(true); 30 $this->setFormAction($GLOBALS['DIC']['ilCtrl']->getFormAction($this->getParentObject())); 31 32 $this->setDisableFilterHiding(true); 33 $this->setRowTemplate('tpl.sc_tree_duplicates_row.html', 'Services/Tree'); 34 35 $this->addColumn($this->lng->txt('sysc_duplicates_repository'), ''); 36 $this->addColumn($this->lng->txt('sysc_duplicates_trash'), ''); 37 38 $this->addCommandButton('deleteDuplicatesFromRepository', $this->lng->txt('sysc_delete_duplicates_from_repository')); 39 $this->addCommandButton('deleteDuplicatesFromTrash', $this->lng->txt('sysc_delete_duplicates_from_trash')); 40 } 41 42 /** 43 * parse data 44 */ 45 public function parse($a_duplicate_id) 46 { 47 $this->setData(array(array('id' => $a_duplicate_id))); 48 } 49 50 51 /** 52 * 53 * @param type $a_set 54 */ 55 public function fillRow($a_set) 56 { 57 include_once './Services/Tree/classes/class.ilSCTreeTasks.php'; 58 $duplicates = ilSCTreeTasks::findDuplicates($a_set['id']); 59 60 $this->tpl->setVariable('DUP_ID', $a_set['id']); 61 62 63 $GLOBALS['DIC']['ilLog']->write('---------------------------- ' . print_r($duplicates, true)); 64 65 foreach ($duplicates as $a_id => $node) { 66 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': DUPPSSSSSSSSSSSSSSSSSSS ' . print_r($node, true)); 67 if ($node['tree'] == 1) { 68 include_once './Services/Tree/classes/class.ilSCTreeTasks.php'; 69 $childs = ilSCTreeTasks::getChilds($node['tree'], $node['child']); 70 71 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': DUPPSSSSSSSSSSSSSSSSSSS CHILDSSSSSSSSSSS' . print_r($childs, true)); 72 $start_depth = $node['depth']; 73 74 $this->fillObjectRow($node['tree'], $node['child'], $start_depth, ''); 75 76 include_once './Services/Tree/classes/class.ilPathGUI.php'; 77 $path = new ilPathGUI(); 78 $path->enableHideLeaf(true); 79 $path->enableTextOnly(false); 80 $this->tpl->setVariable('PATH', $path->getPath(ROOT_FOLDER_ID, $node['child'])); 81 82 83 foreach ($childs as $child) { 84 $this->fillObjectRow($node['tree'], $child, $start_depth, ''); 85 } 86 } 87 if ($node['tree'] < 1) { 88 include_once './Services/Tree/classes/class.ilSCTreeTasks.php'; 89 $childs = ilSCTreeTasks::getChilds($node['tree'], $node['child']); 90 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': TRASJH DUPPSSSSSSSSSSSSSSSSSSS CHILDSSSSSSSSSSS' . print_r($childs, true)); 91 92 $start_depth = $node['depth']; 93 94 $this->fillObjectRow($node['tree'], $node['child'], $start_depth, 'b'); 95 96 foreach ($childs as $child) { 97 $this->fillObjectRow($node['tree'], $child, $start_depth, 'b'); 98 } 99 } 100 } 101 } 102 103 /** 104 * 105 * @param type $a_ref_id 106 * @param type $a_start_depth 107 * @param type $a_prefix 108 */ 109 protected function fillObjectRow($a_tree_id, $a_ref_id, $a_start_depth, $a_prefix) 110 { 111 include_once './Services/Tree/classes/class.ilSCTreeTasks.php'; 112 $child_data = ilSCTreeTasks::getNodeInfo($a_tree_id, $a_ref_id); 113 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': ' . print_r($child_data, true)); 114 115 for ($i = $a_start_depth; $i <= $child_data['depth']; $i++) { 116 $this->tpl->touchBlock($a_prefix . 'padding'); 117 $this->tpl->touchBlock($a_prefix . 'end_padding'); 118 } 119 $this->tpl->setVariable($a_prefix . 'OBJ_TITLE', $child_data['title']); 120 121 if ($child_data['description']) { 122 $this->tpl->setVariable($a_prefix . 'VAL_DESC', $child_data['description']); 123 } 124 $this->tpl->setVariable($a_prefix . 'TYPE_IMG', ilUtil::getTypeIconPath($child_data['type'], $child_data['obj_id'])); 125 $this->tpl->setVariable($a_prefix . 'TYPE_STR', $this->lng->txt('obj_' . $child_data['type'])); 126 } 127} 128