コード例 #1
0
 public function listRecords()
 {
     global $tpl, $lng, $ilToolbar;
     /**
      * @var $ilToolbar ilToolbarGUI
      * @var $ilToolbar ilToolbarGUI
      */
     // Show tables
     require_once "./Modules/DataCollection/classes/class.ilDataCollectionTable.php";
     if (ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id)) {
         $tables = $this->parent_obj->object->getTables();
     } else {
         $tables = $this->parent_obj->object->getVisibleTables();
     }
     $options = array();
     foreach ($tables as $table) {
         $options[$table->getId()] = $table->getTitle();
     }
     $tpl->addCss("./Modules/DataCollection/css/dcl_reference_hover.css");
     $list = new ilDataCollectionRecordListTableGUI($this, "listRecords", $this->table_obj, $this->mode);
     $list->setExternalSegmentation(true);
     $list->setExternalSorting(true);
     $list->determineLimit();
     $list->determineOffsetAndOrder();
     $data = $this->table_obj->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $list->getLimit(), $list->getOffset(), $list->getFilter());
     $records = $data['records'];
     $total = $data['total'];
     $list->setMaxCount($total);
     $list->setRecordData($records);
     if (count($options) > 0) {
         include_once './Services/Form/classes/class.ilSelectInputGUI.php';
         $table_selection = new ilSelectInputGUI('', 'table_id');
         $table_selection->setOptions($options);
         $table_selection->setValue($this->table_id);
         $ilToolbar->setFormAction($this->ctrl->getFormActionByClass("ilDataCollectionRecordListGUI", "doTableSwitch"));
         $ilToolbar->addText($lng->txt("dcl_table"));
         $ilToolbar->addInputItem($table_selection);
         $ilToolbar->addFormButton($lng->txt('change'), 'doTableSwitch');
         $ilToolbar->addSeparator();
     }
     $permission_to_add_or_import = $this->table_obj->hasPermissionToAddRecord($this->parent_obj->ref_id) and $this->table_obj->hasCustomFields();
     if ($permission_to_add_or_import) {
         $this->ctrl->setParameterByClass("ildatacollectionrecordeditgui", "record_id", NULL);
         $add_new = ilLinkButton::getInstance();
         $add_new->setCaption("dcl_add_new_record");
         $add_new->setUrl($this->ctrl->getFormActionByClass("ildatacollectionrecordeditgui", "create"));
         //			$add_new->addCSSClass('emphsubmit');
         $ilToolbar->addButtonInstance($add_new);
     }
     if ($this->table_obj->getExportEnabled() or $this->table_obj->hasPermissionToFields($this->parent_obj->ref_id)) {
         $export = ilDataCollectionLinkButton::getInstance();
         $export->setCaption("dcl_export_table_excel");
         $export->setUrl($this->ctrl->getFormActionByClass("ildatacollectionrecordlistgui", "exportExcel"));
         if (count($this->table_obj->getExportableFields()) == 0 or $total == 0) {
             $export->setUseWrapper(true);
             $export->setDisabled(true);
             $export->addAttribute('data-toggle', 'datacollection-tooltip', true);
             $export->addAttribute('data-placement', 'bottom', true);
             $export->addAttribute('title', $lng->txt('dcl_no_exportable_fields_or_no_data'), true);
         }
         $ilToolbar->addButtonInstance($export);
     }
     if ($permission_to_add_or_import) {
         $this->ctrl->setParameterByClass("ildatacollectionrecordeditgui", "record_id", NULL);
         $import = ilLinkButton::getInstance();
         $import->setCaption("dcl_import_records .xls");
         $import->setUrl($this->ctrl->getFormActionByClass("ildatacollectionrecordlistgui", "showImportExcel"));
         $ilToolbar->addButtonInstance($import);
     }
     // requested not to implement this way...
     //$tpl->addJavaScript("Modules/DataCollection/js/fastTableSwitcher.js");
     if (count($this->table_obj->getRecordFields()) == 0) {
         ilUtil::sendInfo($lng->txt("dcl_no_fields_yet") . " " . ($this->table_obj->hasPermissionToFields($this->parent_obj->ref_id) ? $lng->txt("dcl_create_fields") : ""));
     }
     $tpl->getStandardTemplate();
     $tpl->setPermanentLink("dcl", $this->parent_obj->ref_id);
     if ($desc = $this->table_obj->getDescription()) {
         $desc = "<div class='ilDclTableDescription'>{$desc}</div>";
     }
     $tpl->setContent($desc . $list->getHTML());
 }