コード例 #1
0
ファイル: Bo.php プロジェクト: mlalbuquerque/silex-skeleton
 public function getColLabels(array $only_these_cols = array())
 {
     if (!empty($only_these_cols)) {
         $cols = array();
         foreach ($only_these_cols as $col) {
             if (!key_exists($col, $this->labels)) {
                 $this->labels[$col] = \Helper\Text::generateLabel($col);
             }
             $cols[$col] = $this->labels[$col];
         }
         return $cols;
     }
     return $this->labels;
 }
コード例 #2
0
 private function getSearchingArea($keys, $values, $options)
 {
     $search = $this->app['request']->get($options['paramName'], array('value' => '', 'field' => ''));
     $btID = isset($options['buttonId']) ? $options['buttonId'] : 'ssk_search_input';
     $selID = isset($options['selectId']) ? $options['selectId'] : 'ssk_search_select';
     $placeholder = isset($options['placeholder']) ? $options['placeholder'] : 'Input search string';
     $default = isset($options['defaultText']) ? $options['defaultText'] : '-- Choose --';
     $text = isset($options['buttonText']) ? $options['buttonText'] : 'Search';
     $container = isset($options['container']) ? $options['container'] : 'ssk_search_container';
     $error = isset($options['error']) ? $options['error'] : 'Must choose field!';
     $html = '<div id="' . $container . '">' . "\n";
     $html .= '<select id="' . $selID . '" name="' . $options['paramName'] . '[field]">' . "\n";
     $html .= '    <option value="">' . $default . '</option>' . "\n";
     foreach ($keys as $idx => $val) {
         $html .= '    <option value="' . $val . '"' . ($search['field'] == $val ? ' selected' : '') . '>' . \Helper\Text::generateLabel($values[$idx]) . '</option>' . "\n";
     }
     $html .= '</select>' . "\n";
     $html .= '<input type="search" name="' . $options['paramName'] . '[value]" value="' . $search['value'] . '" placeholder="' . $placeholder . '" />' . "\n";
     $html .= '<button id="' . $btID . '">' . $text . '</button>' . "\n";
     $html .= '<script>' . "\n";
     $html .= '    var button = document.getElementById("' . $btID . '");' . "\n";
     $html .= '    button.addEventListener("click", sskCallSearch, false);' . "\n";
     $html .= '    function sskCallSearch(evt) {' . "\n";
     $html .= '        evt.preventDefault();' . "\n";
     $html .= '        var form = document.getElementById("ssk_table_modifier_form");' . "\n";
     $html .= '        var selectSearch = document.getElementById("' . $selID . '");' . "\n";
     $html .= '        var searchField = selectSearch.options[selectSearch.selectedIndex].value;' . "\n";
     $html .= '        if (searchField != "")' . "\n";
     $html .= '            form.submit();' . "\n";
     $html .= '        else' . "\n";
     $html .= '            alert("' . $error . '");' . "\n";
     $html .= '    }' . "\n";
     $html .= '</script>' . "\n";
     $html .= '</div>' . "\n";
     return $html;
 }