1<?php 2 3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5/** 6 * Input for adv meta data column sorting in glossaries. 7 * Please note, that data us already an array, we do not use the MultipleValues 8 * interface here. 9 * 10 * @author Alex Killing <alex.killing@gmx.de> 11 */ 12class ilGloAdvColSortInputGUI extends ilFormPropertyGUI 13{ 14 15 /** 16 * Constructor 17 * 18 * @param 19 */ 20 public function __construct($a_title = "", $a_id = "") 21 { 22 global $DIC; 23 24 $this->lng = $DIC->language(); 25 parent::__construct($a_title, $a_id); 26 $this->setType("glo_adv_col_sort"); 27 } 28 29 /** 30 * Set Value. 31 * 32 * @param string $a_value Value 33 */ 34 public function setValue($a_value) 35 { 36 $this->value = $a_value; 37 } 38 39 /** 40 * Get Value. 41 * 42 * @return string Value 43 */ 44 public function getValue() 45 { 46 return $this->value; 47 } 48 49 50 /** 51 * Input should always be valid, since we sort only 52 * 53 * @return boolean 54 */ 55 public function checkInput() 56 { 57 if (is_array($_POST[$this->getPostVar()])) { 58 foreach ($_POST[$this->getPostVar()] as $k => $v) { 59 $_POST[$this->getPostVar()][$k]["id"] = ilUtil::stripSlashes($_POST[$this->getPostVar()][$k]["id"]); 60 $_POST[$this->getPostVar()][$k]["text"] = ilUtil::stripSlashes($_POST[$this->getPostVar()][$k]["text"]); 61 } 62 } else { 63 $_POST[$this->getPostVar()] = array(); 64 } 65 66 return true; 67 } 68 69 /** 70 * render 71 */ 72 public function render() 73 { 74 $lng = $this->lng; 75 76 $tpl = new ilTemplate("tpl.adv_col_sort_input.html", true, true, "Modules/Glossary"); 77 if (is_array($this->getValue())) { 78 foreach ($this->getValue() as $k => $v) { 79 $tpl->setCurrentBlock("item"); 80 $tpl->setVariable("TEXT", $v["text"]); 81 $tpl->setVariable("ID", $this->getFieldId() . "~" . $k); 82 $tpl->setVariable("DOWN", ilGlyphGUI::get(ilGlyphGUI::DOWN)); 83 $tpl->setVariable("TXT_DOWN", $lng->txt("down")); 84 $tpl->setVariable("UP", ilGlyphGUI::get(ilGlyphGUI::UP)); 85 $tpl->setVariable("TXT_UP", $lng->txt("up")); 86 $tpl->setVariable('NAME', $this->getPostVar() . "[" . $k . "][id]"); 87 $tpl->setVariable('TNAME', $this->getPostVar() . "[" . $k . "][text]"); 88 $tpl->setVariable('VAL', ilUtil::prepareFormOutput($v["id"])); 89 $tpl->setVariable('TVAL', ilUtil::prepareFormOutput($v["text"])); 90 $tpl->parseCurrentBlock(); 91 } 92 } 93 94 return $tpl->get(); 95 } 96 97 /** 98 * Insert property html 99 * 100 */ 101 public function insert(&$a_tpl) 102 { 103 $a_tpl->setCurrentBlock("prop_generic"); 104 $a_tpl->setVariable("PROP_GENERIC", $this->render()); 105 $a_tpl->parseCurrentBlock(); 106 } 107 108 /** 109 * Set value by array 110 * 111 * @param array $a_values value array 112 */ 113 public function setValueByArray($a_values) 114 { 115 if ($this->getPostVar() && isset($a_values[$this->getPostVar()])) { 116 $this->setValue($a_values[$this->getPostVar()]); 117 } 118 } 119 120 /** 121 * Get HTML for table filter 122 */ 123 public function getTableFilterHTML() 124 { 125 $html = $this->render(); 126 return $html; 127 } 128} 129