Пример #1
0
 function generField($filterConf, &$list, $attr)
 {
     // Lokalis parameterek inicializalasa az osztalyvaltozok alapjan:
     foreach (array('width', 'filterText', 'resetOnClick', 'enable') as $a) {
         ${$a} = $this->{$a};
     }
     // A $filterConf-ban erkezo ertekek felulirhatjak a lokalis parametereket:
     if (is_array($filterConf)) {
         foreach (array('width', 'filterText', 'resetOnClick', 'enable') as $a) {
             if (isset($filterConf[$a])) {
                 ${$a} = $filterConf[$a];
             }
         }
         $type = $filterConf['type'];
     } else {
         $type = $filterConf;
     }
     if (!$enable) {
         return "";
     }
     if ($type == "text_filter") {
         $onclick = $resetOnClick ? "onclick=\"this.value='';Table.filter(this,this)\"" : "";
         $s = GenerWidget::generTextField($type, "filter", $filterText, $width, "", " onkeyup=\"Table.filter(this,this)\" {$onclick}");
     } elseif ($type == "select_filter") {
         $values = array_unique(array_map(create_function('$v', "return strip_tags(\$v->showListVal('{$attr}'));"), $list));
         $values[] = "";
         sort($values);
         $labels = $values;
         $labels[0] = "All";
         $s = GenerWidget::generSelectField("filter", $labels, $values, "", "All", 0, $width, "", "onchange=\"Table.filter(this,this)\"");
     }
     return $s;
 }
Пример #2
0
 function generSubmitField($attr, $val, &$lllProp)
 {
     $this->getTextFieldLengths($val, $inputLength, $fieldLength);
     $buttonText = $lllProp->getButtontext();
     $submitName = isset($val["name"]) ? $val["name"] : "gsubmit";
     return GenerWidget::generTextField("submit", $submitName, $buttonText, $inputLength, $fieldLength);
 }
Пример #3
0
 function generDateTextField($name, $value, &$attrInfo, $size = "", $maxlength = "")
 {
     global $now;
     if ($value->isEmpty() && in_array("defaultnow", $attrInfo)) {
         $display = $now->getDbFormat();
     } else {
         $display = $value->getDbFormat();
     }
     $jsCalendar = in_array("jscalendar", $attrInfo);
     $s = GenerWidget::generTextField('text', $name, $display, $size, $maxlength);
     if ($jsCalendar) {
         JavaScript::addInclude(GORUM_JS_DIR . "/jscalendar/calendar.js");
         JavaScript::addInclude(GORUM_JS_DIR . "/jscalendar/lang/calendar-en.js");
         JavaScript::addInclude(GORUM_JS_DIR . "/jscalendar/calendar-setup.js");
         JavaScript::addCss(GORUM_JS_DIR . "/jscalendar/skins/aqua/theme.css");
         //$s.="<button type='reset' id='trigger'>...</button>";
         $s .= "<img src='" . GORUM_JS_DIR . "/jscalendar/img.gif' id='{$name}_trigger'\n             style='cursor: pointer; border: 1px solid red;'\n             title='Date selector'\n             onmouseover=\"this.style.background='red';\"\n             onmouseout=\"this.style.background=''\" >";
         $calendarDisplay = $display ? "'{$display}'" : "null";
         if (!isset($attrInfo["fromyear"])) {
             $fromyear = $now->getYear();
         } elseif ($attrInfo["fromyear"] == "now") {
             $fromyear = $now->getYear();
         } elseif (preg_match("{now-(\\d+)}", $attrInfo["fromyear"], $matches)) {
             $fromyear = $now->getYear() - intval($matches[1]);
         } else {
             $fromyear = $attrInfo["fromyear"];
         }
         if (!isset($attrInfo["toyear"])) {
             $toyear = $now->getYear();
         } elseif ($attrInfo["toyear"] == "now") {
             $toyear = $now->getYear();
         } elseif (preg_match("{now\\+(\\d+)}", $attrInfo["toyear"], $matches)) {
             $toyear = $now->getYear() + intval($matches[1]);
         } else {
             $toyear = $attrInfo["toyear"];
         }
         $format = preg_replace("/\\b\\w\\b/", "%\$0", $attrInfo["display_format"]);
         // minden betu ele beteszunk egy % jelet
         $format = str_replace("%i", "%M", $format);
         $showsTime = in_array("showstime", $attrInfo) ? "true" : "false";
         JavaScript::addOnload("\n          Calendar.setup(\n            {\n              inputField  : '{$name}',         // ID of the input field\n              ifFormat    : '{$format}',    // the date format\n              button      : '{$name}_trigger',       // ID of the button\n              date        : {$calendarDisplay},                 // initial date\n              range       : [{$fromyear}, {$toyear}],   // range of years\n              showsTime       : {$showsTime}\n            }\n          );\n        ");
     }
     return $s;
 }
Пример #4
0
 function showListVal($attr)
 {
     global $gorumroll;
     if ($gorumroll->rollid !== "alternative") {
         return parent::showListVal($attr);
     }
     if ($attr == "name") {
         $s = parent::showListVal($attr);
         if (isset($this->depth)) {
             return "<div style='padding-left: " . 20 * $this->depth . "px;'>{$s}</div>";
         }
         return $s;
     } elseif ($attr == "sortId") {
         return GenerWidget::generTextField("text", "sortId[{$this->id}]", $this->sortId, 6);
     } elseif ($attr == "up") {
         $s = GenerWidget::generTextField("text", "up[{$this->id}]", $this->up, 6);
         $s .= GenerWidget::generHiddenField("name[{$this->id}]", htmlspecialchars($this->name));
         $s .= GenerWidget::generHiddenField("oldUp[{$this->id}]", $this->up);
         return $s;
     } else {
         return parent::showListVal($attr);
     }
 }
Пример #5
0
 function generSelectFilterField($name, &$labels, $width)
 {
     if (!$width) {
         $width = 0;
         foreach ($labels as $label) {
             $width = max($width, strlen($label));
         }
     }
     $s = "Filter:<br>";
     $s .= GenerWidget::generTextField("text", "{$name}_selectfilter", "", $width);
     $s .= "<br>";
     JavaScript::addOnload("\n    function filterSelectField(e)\n    {\n        e=e||window.event;\n        var k=e.charCode||e.keyCode||e.which;\t\t\t\t\t\t                        \n        if(e.ctrlKey || e.altKey) return true;  // ignore\n        else if ((k>=41 && k<=122) ||k==32 || k>186 || k==8)  //typeable characters\n        {\n            var name = this.name.slice(0, -13);  // levagjuk '_selectfilter'-t\n            var filter=this.value.toLowerCase();\n            // betesszuk egy tombbe az osszes option-t\n            if( eval('typeof('+name+'OptionsRepository)!=\"object\"') )\n            {\n                eval(name+'OptionsRepository = new Array;');\n                \$JQ('#' + name).find('option').each(function(){\n                    eval(name+'OptionsRepository').push([\$JQ(this).val(), \$JQ(this).html()]);\n                });\n            }\n            \$JQ('#' + name).find('option').remove();  // kiuritjuk a szelekt mezot teljesen\n            var x=0;\n            \$JQ.each(eval(name+'OptionsRepository'), function(i, val)\n            {\n                // es csak azokat tesszuk vissza, amiben a filter megtalalhato:\n                if( val[1].toLowerCase().indexOf(filter)>-1 )\n                {\n                    \$JQ('#' + name).get(0).options[x++]=new Option(val[1], val[0]);\n                }\n            });\n        }\n    }\n    \$JQ('input[id\$=_selectfilter]').keyup(filterSelectField);\n    ", "filterSelectField");
     return $s;
 }