1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once 'Services/Form/classes/class.ilTextInputGUI.php'; 5 6/** 7 * @author Michael Jansen <mjansen@databay.de> 8 * @version $Id$ 9 * @ingroup ServicesMail 10 */ 11class ilMailQuickFilterInputGUI extends ilTextInputGUI 12{ 13 /** 14 * @return bool 15 */ 16 public function checkInput() 17 { 18 global $DIC; 19 20 $ok = parent::checkInput(); 21 22 $query = ilUtil::stripSlashes($_POST[$this->getPostVar()]); 23 24 if (!$ok) { 25 return false; 26 } 27 28 include_once 'Services/Mail/classes/class.ilMailLuceneQueryParser.php'; 29 try { 30 ilMailLuceneQueryParser::validateQuery($query); 31 return true; 32 } catch (Exception $e) { 33 $this->setAlert($DIC->language()->txt($e->getMessage())); 34 return false; 35 } 36 } 37 38 public function render($a_mode = "") 39 { 40 global $DIC; 41 42 $tpl = new ilTemplate("tpl.prop_mail_quick_filter_input.html", true, true, "Services/Mail"); 43 if (strlen($this->getValue())) { 44 $tpl->setCurrentBlock("prop_text_propval"); 45 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue())); 46 $tpl->parseCurrentBlock(); 47 } 48 if (strlen($this->getInlineStyle())) { 49 $tpl->setCurrentBlock("stylecss"); 50 $tpl->setVariable("CSS_STYLE", ilUtil::prepareFormOutput($this->getInlineStyle())); 51 $tpl->parseCurrentBlock(); 52 } 53 if (strlen($this->getCssClass())) { 54 $tpl->setCurrentBlock("classcss"); 55 $tpl->setVariable('CLASS_CSS', ilUtil::prepareFormOutput($this->getCssClass())); 56 $tpl->parseCurrentBlock(); 57 } 58 if ($this->getSubmitFormOnEnter()) { 59 $tpl->touchBlock("submit_form_on_enter"); 60 } 61 62 switch ($this->getInputType()) { 63 case 'password': 64 $tpl->setVariable('PROP_INPUT_TYPE', 'password'); 65 break; 66 case 'hidden': 67 $tpl->setVariable('PROP_INPUT_TYPE', 'hidden'); 68 break; 69 case 'text': 70 default: 71 $tpl->setVariable('PROP_INPUT_TYPE', 'text'); 72 } 73 $tpl->setVariable("ID", $this->getFieldId()); 74 $tpl->setVariable("ARIA_LABEL", $this->getTitle()); 75 $tpl->setVariable("SIZE", $this->getSize()); 76 if ($this->getMaxLength() != null) { 77 $tpl->setVariable("MAXLENGTH", $this->getMaxLength()); 78 } 79 if (strlen($this->getSuffix())) { 80 $tpl->setVariable("INPUT_SUFFIX", $this->getSuffix()); 81 } 82 83 $postvar = $this->getPostVar(); 84 if ($this->getMulti() && substr($postvar, -2) != "[]") { 85 $postvar .= "[]"; 86 } 87 88 if ($this->getDisabled()) { 89 if ($this->getMulti()) { 90 $value = $this->getMultiValues(); 91 $hidden = ""; 92 if (is_array($value)) { 93 foreach ($value as $item) { 94 $hidden .= $this->getHiddenTag($postvar, $item); 95 } 96 } 97 } else { 98 $hidden = $this->getHiddenTag($postvar, $this->getValue()); 99 } 100 if ($hidden) { 101 $tpl->setVariable("DISABLED", " disabled=\"disabled\""); 102 $tpl->setVariable("HIDDEN_INPUT", $hidden); 103 } 104 } else { 105 $tpl->setVariable("POST_VAR", $postvar); 106 } 107 108 if ($a_mode == "toolbar") { 109 // block-inline hack, see: http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/ 110 // -moz-inline-stack for FF2 111 // zoom 1; *display:inline for IE6 & 7 112 $tpl->setVariable("STYLE_PAR", 'display: -moz-inline-stack; display:inline-block; zoom: 1; *display:inline;'); 113 } else { 114 $tpl->setVariable("STYLE_PAR", ''); 115 } 116 117 if (is_array($this->sub_items) && $this->sub_items) { 118 $tpl->setVariable("FIELD_ID", $this->getFieldId()); 119 $tpl->setVariable("TXT_PLACEHOLDER", $DIC->language()->txt('mail_filter_field_placeholder')); 120 $tpl->setVariable("TXT_FILTER_MESSAGES_BY", $DIC->language()->txt('mail_filter_txt')); 121 122 $subitem_html = ''; 123 foreach ($this->sub_items as $item) { 124 $subitem_html .= $item->render('toolbar'); 125 } 126 127 $tpl->setVariable('FIELD_SUBITEMS', $subitem_html); 128 } 129 130 return $tpl->get(); 131 } 132} 133