1<?php
2/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3include_once('./Services/FileSystem/classes/class.ilFileSystemTableGUI.php');
4
5/**
6 * File System Explorer GUI class
7 *
8 *
9 * @author Jesús López <lopez@leifos.com>
10 * @version $Id$
11 *
12 */
13class ilExAssignmentFileSystemTableGUI extends ilFileSystemTableGUI
14{
15    //this property will define if the table needs order column.
16    protected $add_order_column = true;
17    protected $child_class_name = 'ilExAssignmentFileSystemTableGUI';
18
19    public function __construct(
20        $a_parent_obj,
21        $a_parent_cmd,
22        $a_cur_dir,
23        $a_cur_subdir,
24        $a_label_enable = false,
25        $a_file_labels,
26        $a_label_header = "",
27        $a_commands = array(),
28        $a_post_dir_path = false,
29        $a_table_id = ""
30    ) {
31        global $DIC;
32
33        $this->lng = $DIC->language();
34
35        parent::__construct(
36            $a_parent_obj,
37            $a_parent_cmd,
38            $a_cur_dir,
39            $a_cur_subdir,
40            $a_label_enable,
41            $a_file_labels,
42            $a_label_header,
43            $a_commands,
44            $a_post_dir_path,
45            "exc_instr_files"
46        );
47
48        $this->setLimit(9999);
49
50        //default template with order block
51        //$this->setRowTemplate("tpl.exc_ass_instruction_file_row.html", "Modules/Exercise");
52        $this->setDefaultOrderField("order_val");
53        $this->setDefaultOrderDirection("asc");
54    }
55
56    /**
57     * Add Order Values (extension of ilFilesystemgui getEntries)
58     * @param array $a_entries
59     * @return array items
60     */
61    public function getEntries()
62    {
63        $entries = parent::getEntries();
64        if (count($entries) > 0) {
65            $this->addCommandButton("saveFilesOrder", $this->lng->txt("exc_save_order"));
66        }
67        $ass = new ilExAssignment((int) $_GET['ass_id']);
68        return $ass->fileAddOrder($entries);
69    }
70
71    /**
72     *
73     *
74     * @param
75     * @return
76     */
77    public function numericOrdering($a_field)
78    {
79        if ($a_field == "order_val") {
80            return true;
81        }
82        return false;
83    }
84
85
86
87    public function addColumns()
88    {
89        if ($this->has_multi) {
90            $this->setSelectAllCheckbox("file[]");
91            $this->addColumn("", "", "1", true);
92        }
93
94        $this->addColumn($this->lng->txt("exc_presentation_order"), "order_val", "", false, $this->child_class_name);
95
96        $this->addColumn("", "", "1", true); // icon
97
98        $this->addColumn($this->lng->txt("cont_dir_file"), "name");
99        $this->addColumn($this->lng->txt("cont_size"), "size");
100
101        if ($this->label_enable) {
102            $this->addColumn($this->label_header, "label");
103        }
104
105        if (sizeof($this->row_commands)) {
106            $this->addColumn($this->lng->txt("actions"));
107            include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
108        }
109    }
110
111    /**
112     * Fill table row
113     */
114    protected function fillRow($a_set)
115    {
116        $this->tpl->setCurrentBlock("Order");
117        if ($a_set['order_id']) {
118            $this->tpl->setVariable("ID", $a_set['order_id']);
119        }
120        if ($a_set["order_val"]) {
121            $this->tpl->setVariable("ORDER_VAL", $a_set["order_val"]);
122        }
123        $this->tpl->parseCurrentBlock();
124
125        parent::fillRow($a_set);
126    }
127}
128