ftimme
2012-05-15 77dbe51165580e4c1098c0acad3664442068361c
- Implemented FS#2219.
10 files modified
1 files added
372 ■■■■■ changed files
interface/lib/lang/de.lng 1 ●●●● patch | view | raw | blame | history
interface/lib/lang/en.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/form/server_ip.tform.php 11 ●●●● patch | view | raw | blame | history
interface/web/dns/ajax_get_json.php 154 ●●●●● patch | view | raw | blame | history
interface/web/dns/lib/lang/de_dns_wizard.lng 6 ●●●●● patch | view | raw | blame | history
interface/web/dns/lib/lang/en_dns_wizard.lng 6 ●●●●● patch | view | raw | blame | history
interface/web/dns/templates/dns_a_edit.htm 15 ●●●●● patch | view | raw | blame | history
interface/web/dns/templates/dns_aaaa_edit.htm 15 ●●●●● patch | view | raw | blame | history
interface/web/dns/templates/dns_wizard.htm 15 ●●●●● patch | view | raw | blame | history
interface/web/js/jquery.ispconfigsearch.js 25 ●●●● patch | view | raw | blame | history
interface/web/themes/default/css/screen/content_ispc.css 123 ●●●●● patch | view | raw | blame | history
interface/lib/lang/de.lng
@@ -75,4 +75,5 @@
$wb['globalsearch_noresults_text_txt'] = "Keine Treffer.";
$wb['globalsearch_noresults_limit_txt'] = "0 Treffer";
$wb['globalsearch_searchfield_watermark_txt'] = "Suche";
$wb['globalsearch_suggestions_text_txt'] = "Vorschläge";
?>
interface/lib/lang/en.lng
@@ -76,4 +76,5 @@
$wb['globalsearch_noresults_text_txt'] = "No results.";
$wb['globalsearch_noresults_limit_txt'] = "0 results";
$wb['globalsearch_searchfield_watermark_txt'] = "Search";
$wb['globalsearch_suggestions_text_txt'] = "Suggestions";
?>
interface/web/admin/form/server_ip.tform.php
@@ -55,6 +55,11 @@
    Hinweis:
    Das ID-Feld ist nicht bei den Table Values einzufügen.
    Search:
    - searchable = 1 or searchable = 2 include the field in the search
    - searchable = 1: this field will be the title of the search result
    - searchable = 2: this field will be included in the description of the search result
*/
@@ -110,7 +115,8 @@
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6')
            'value'        => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6'),
            'searchable' => 2
        ),
        'ip_address' => array (
            'datatype'    => 'VARCHAR',
@@ -126,7 +132,8 @@
            'width'        => '15',
            'maxlength'    => '15',
            'rows'        => '',
            'cols'        => ''
            'cols'        => '',
            'searchable' => 1
        ),
        'virtualhost' => array (
            'datatype'    => 'VARCHAR',
interface/web/dns/ajax_get_json.php
New file
@@ -0,0 +1,154 @@
<?php
/*
Copyright (c) 2012, ISPConfig UG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('dns');
$app->uses('tform');
$type = $_GET["type"];
//if($_SESSION["s"]["user"]["typ"] == 'admin') {
    if($type == 'get_ipv4'){
        $q = $app->db->quote(trim($_GET["q"]));
        $authsql = " AND ".$app->tform->getAuthSQL('r');
        $modules = explode(',', $_SESSION['s']['user']['modules']);
        $result = array();
        // ipv4
        $result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")");
        $json = $app->functions->json_encode($result);
    }
    if($type == 'get_ipv6'){
        $q = $app->db->quote(trim($_GET["q"]));
        $authsql = " AND ".$app->tform->getAuthSQL('r');
        $modules = explode(',', $_SESSION['s']['user']['modules']);
        $result = array();
        // ipv4
        $result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")");
        $json = $app->functions->json_encode($result);
    }
//}
function _search($module, $section, $additional_sql = ''){
    global $app, $q, $authsql, $modules;
    $result_array = array('cheader' => array(), 'cdata' => array());
    if(in_array($module, $modules) || ($module == 'admin' && $section == 'server_ip')){
        $search_fields = array();
        $desc_fields = array();
        if(is_file('../'.$module.'/form/'.$section.'.tform.php')){
            include_once('../'.$module.'/form/'.$section.'.tform.php');
            $category_title = $form["title"];
            $form_file = $form["action"];
            $db_table = $form["db_table"];
            $db_table_idx = $form["db_table_idx"];
            $order_by = $db_table_idx;
            if(is_array($form["tabs"]) && !empty($form["tabs"])){
                foreach($form["tabs"] as $tab){
                    if(is_array($tab['fields']) && !empty($tab['fields'])){
                        foreach($tab['fields'] as $key => $val){
                            if(isset($val['searchable']) && $val['searchable'] > 0){
                                $search_fields[] = $key." LIKE '%".$q."%'";
                                if($val['searchable'] == 1){
                                    $order_by = $key;
                                    $title_key = $key;
                                }
                                if($val['searchable'] == 2){
                                    $desc_fields[] = $key;
                                }
                            }
                        }
                    }
                }
            }
        }
        unset($form);
        $where_clause = '';
        if(!empty($search_fields)){
            $where_clause = implode(' OR ', $search_fields);
        } else {
            // valid SQL query which returns an empty result set
            $where_clause = '1 = 0';
        }
        if($where_clause != '') $where_clause = '('.$where_clause.')';
        if($additional_sql != '') $where_clause .= ' '.$additional_sql.' ';
        $order_clause = '';
        if($order_by != '') $order_clause = ' ORDER BY '.$order_by;
        $sql = "SELECT * FROM ".$db_table." WHERE ".$where_clause.$authsql.$order_clause." LIMIT 0,10";
        $results = $app->db->queryAllRecords($sql);
        if(is_array($results) && !empty($results)){
            $lng_file = '../'.$module.'/lib/lang/'.$_SESSION['s']['language'].'_'.$section.'.lng';
            if(is_file($lng_file)) include($lng_file);
            $result_array['cheader'] = array('title' => $category_title,
                                            'total' => count($results),
                                            'limit' => count($results)
                                            );
            foreach($results as $result){
                $description = '';
                if(!empty($desc_fields)){
                    $desc_items = array();
                    foreach($desc_fields as $desc_field){
                        if($result[$desc_field] != '') $desc_items[] = $wb[$desc_field.'_txt'].': '.$result[$desc_field];
                    }
                    if(!empty($desc_items)) $description = implode(' - ', $desc_items);
                }
                $result_array['cdata'][] = array(    'title' => $wb[$title_key.'_txt'].': '.$result[$title_key],
                                                    'description' => $description,
                                                    'onclick' => '',
                                                    'fill_text' => $result[$title_key]
                                                );
            }
        }
    }
    return $result_array;
}
header('Content-type: application/json');
echo $json;
?>
interface/web/dns/lib/lang/de_dns_wizard.lng
@@ -26,4 +26,10 @@
$wb['error_ns1_regex'] = 'NS1 beinhaltet ungültige Zeichen.';
$wb['error_ns2_regex'] = 'NS2 beinhaltet ungültige Zeichen.';
$wb['error_email_regex'] = 'E-Mail-Adresse beinhaltet keine gültige Adresse.';
$wb['globalsearch_resultslimit_of_txt'] = "von";
$wb['globalsearch_resultslimit_results_txt'] = "Treffern";
$wb['globalsearch_noresults_text_txt'] = "Keine Treffer.";
$wb['globalsearch_noresults_limit_txt'] = "0 Treffer";
$wb['globalsearch_searchfield_watermark_txt'] = "Suche";
$wb['globalsearch_suggestions_text_txt'] = "Vorschläge";
?>
interface/web/dns/lib/lang/en_dns_wizard.lng
@@ -27,4 +27,10 @@
$wb['error_ns1_regex'] = 'NS1 contains invalid characters.';
$wb['error_ns2_regex'] = 'NS2 contains invalid characters.';
$wb['error_email_regex'] = 'Email does not contain a valid email address.';
$wb['globalsearch_resultslimit_of_txt'] = "of";
$wb['globalsearch_resultslimit_results_txt'] = "results";
$wb['globalsearch_noresults_text_txt'] = "No results.";
$wb['globalsearch_noresults_limit_txt'] = "0 results";
$wb['globalsearch_searchfield_watermark_txt'] = "Search";
$wb['globalsearch_suggestions_text_txt'] = "Suggestions";
?>
interface/web/dns/templates/dns_a_edit.htm
@@ -37,3 +37,18 @@
  </div>
  
</div>
<script language="JavaScript" type="text/javascript">
        jQuery('#data').ispconfigSearch({
            dataSrc: '/dns/ajax_get_json.php?type=get_ipv4',
            resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">',
            ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">',
            noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">',
            noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">',
            minChars: 0,
            cssPrefix: 'df-',
            fillSearchField: true,
            fillSearchFieldWith: 'fill_text',
            searchFieldWatermark: '',
            resultBoxPosition: 'e'
        });
</script>
interface/web/dns/templates/dns_aaaa_edit.htm
@@ -37,3 +37,18 @@
  </div>
  
</div>
<script language="JavaScript" type="text/javascript">
        jQuery('#data').ispconfigSearch({
            dataSrc: '/dns/ajax_get_json.php?type=get_ipv6',
            resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">',
            ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">',
            noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">',
            noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">',
            minChars: 0,
            cssPrefix: 'df-',
            fillSearchField: true,
            fillSearchFieldWith: 'fill_text',
            searchFieldWatermark: '',
            resultBoxPosition: 'e'
        });
</script>
interface/web/dns/templates/dns_wizard.htm
@@ -78,3 +78,18 @@
  </div>
  
</div>
<script language="JavaScript" type="text/javascript">
        jQuery('#ip').ispconfigSearch({
            dataSrc: '/dns/ajax_get_json.php?type=get_ipv4',
            resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">',
            ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">',
            noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">',
            noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">',
            minChars: 0,
            cssPrefix: 'df-',
            fillSearchField: true,
            fillSearchFieldWith: 'fill_text',
            searchFieldWatermark: '',
            resultBoxPosition: 'e'
        });
</script>
interface/web/js/jquery.ispconfigsearch.js
@@ -33,9 +33,11 @@
            timeout: 500,
            minChars: 2,
            resultBox: '-resultbox',
            resultBoxPosition: 's', // n = north, e = east, s = south, w = west
            cssPrefix: 'gs-',
            fillSearchField: false,
            fillSearchFieldWith: 'title',
            ResultsTextPrefix: '',
            resultsLimit: '$ of % results',
            noResultsText: 'No results.',
            noResultsLimit: '0 results',
@@ -50,7 +52,7 @@
        settings.resultBox = $(this).attr('id')+settings.resultBox;
        
        $(this).attr('autocomplete', 'off');
        $(this).val(settings.searchFieldWatermark);
        if($(this).val() == '') $(this).val(settings.searchFieldWatermark);
        $(this).wrap('<div class="'+settings.cssPrefix+'container" />');
        $(this).after('<ul id="'+settings.resultBox+'" class="'+settings.cssPrefix+'resultbox" style="display:none;"></ul>');
        var searchField = $(this);
@@ -63,7 +65,7 @@
                // query value
                var q = searchField.val();
                
                if (settings.minChars > q.length || q == ''){
                if (settings.minChars > q.length || (q == '' && settings.minChars > 0)){
                    resultBox.fadeOut();
                    resetTimer(timeout);
                } else {
@@ -94,7 +96,7 @@
                                }
                                if (!resultsFound){
                                    output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+settings.noResultsText+'</p><p class="'+settings.cssPrefix+'cheader-limit">'+settings.noResultsLimit+'</p></li>';
                                    output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+(settings.ResultsTextPrefix == '' ? '' : settings.ResultsTextPrefix+': ')+settings.noResultsText+'</p><p class="'+settings.cssPrefix+'cheader-limit">'+settings.noResultsLimit+'</p></li>';
                                } else {
                                
                                    $.each(data, function(i, category){
@@ -103,7 +105,7 @@
                                            var limit = category['cheader']['limit'];
                                            var cnt = 0;
                                            output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+category['cheader']['title']+'</p><p class="'+settings.cssPrefix+'cheader-limit">'+settings.resultsLimit.replace("%", category['cheader']['total']).replace("$", (category['cheader']['limit'] < category['cdata'].length ? category['cheader']['limit'] : category['cdata'].length))+'</p></li>';
                                            output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+(settings.ResultsTextPrefix == '' ? '' : settings.ResultsTextPrefix+': ')+category['cheader']['title']+'</p><p class="'+settings.cssPrefix+'cheader-limit">'+settings.resultsLimit.replace("%", category['cheader']['total']).replace("$", (category['cheader']['limit'] < category['cdata'].length ? category['cheader']['limit'] : category['cdata'].length))+'</p></li>';
                                            var fillSearchFieldCode = (settings.fillSearchField) ? 'document.getElementById(\''+searchField.attr('id')+'\').value = \'%\';' : '';
                                            //var fillSearchFieldCode = 'document.getElementById(\''+searchField.attr('id')+'\').value = \'%\';';
@@ -128,7 +130,19 @@
                                    });
                                }
                                resultBox.html(output).css({'position' : 'absolute', 'top' : searchField.position().top+searchField.outerHeight(), 'right' : '0'}).fadeIn();
                                //resultBox.html(output).css({'position' : 'absolute', 'top' : searchField.position().top+searchField.outerHeight(), 'right' : '0'}).fadeIn();
                                if(settings.resultBoxPosition == 'n'){
                                    resultBox.html(output).css({'position' : 'absolute', 'top' : searchField.position().top-resultBox.outerHeight(), 'left' : searchField.position().left+searchField.outerWidth()-resultBox.outerWidth()}).fadeIn();
                                }
                                if(settings.resultBoxPosition == 'e'){
                                    resultBox.html(output).css({'position' : 'absolute', 'top' : searchField.position().top, 'left' : searchField.position().left+searchField.outerWidth()}).fadeIn();
                                }
                                if(settings.resultBoxPosition == 's'){
                                    resultBox.html(output).css({'position' : 'absolute', 'top' : searchField.position().top+searchField.outerHeight(), 'left' : searchField.position().left+searchField.outerWidth()-resultBox.outerWidth()}).fadeIn();
                                }
                                if(settings.resultBoxPosition == 'w'){
                                    resultBox.html(output).css({'position' : 'absolute', 'top' : searchField.position().top, 'left' : searchField.position().left-resultBox.outerWidth()}).fadeIn();
                                }
                                searchField.removeClass(settings.cssPrefix+'loading');
                            }
@@ -150,6 +164,7 @@
                resultBox.fadeIn();
            } else if(searchField.val() == settings.searchFieldWatermark){
                searchField.val('');
                if(settings.minChars == 0) searchField.trigger('keyup');
            } else if (searchField.val() != ''){
                searchField.trigger('keyup');
            }
interface/web/themes/default/css/screen/content_ispc.css
@@ -1126,5 +1126,128 @@
        -ms-border-radius:0 0 5px 5px;
        border-radius:0 0 5px 5px;
    }
    div.df-container{
    }
    div.df-container *{
        margin: 0;
        padding: 0;
        background-position: 0 0;
        text-decoration: none;
        font-size: 1em;
    }
    div.df-container input{
    }
    input.df-loading{
        background-image: url(../../icons/x16/loading.gif);
        background-repeat: no-repeat;
        background-position: center right;
    }
    ul.df-resultbox{
        margin: 0 !important;
        padding: 0 !important;
        min-width: 250px;
        max-width: 500px;
        z-index: 999999;
        border: 1px solid #777;
        font-size: 11px;
        background: #fff;
        -moz-box-shadow: 2px 2px 5px 0 #c5c5c5;
        -webkit-box-shadow: 2px 2px 5px 0 #c5c5c5;
        -khtml-box-shadow: 2px 2px 5px 0 #c5c5c5;
        -o-box-shadow: 2px 2px 5px 0 #c5c5c5;
        -ms-box-shadow: 2px 2px 5px 0 #c5c5c5;
        box-shadow: 2px 2px 5px 0 #c5c5c5;
        list-style: none;
        -moz-border-radius:5px;
        -webkit-border-radius:5px;
        -khtml-border-radius:5px;
        -o-border-radius:5px;
        -ms-border-radius:5px;
        border-radius:5px;
    }
    ul.df-resultbox li{
        float: left;
        width: 100%;
        clear: both;
        cursor: pointer;
    }
    ul.df-resultbox li.df-cheader{
        height: 13px;
        overflow: hidden;
        padding: 5px 0;
        color: #fff;
        background: #6ea6d1;
        cursor:default;
        padding-bottom:10px;
    }
    ul.df-resultbox li.df-cheader p.df-cheader-title{
        margin: 0 !important;
        padding: 0 0 0 10px !important;
        float: left;
        font-size: 12px;
        font-weight: bold;
    }
    ul.df-resultbox li.df-cheader p.df-cheader-limit{
        margin: 0 !important;
        padding: 0 10px 0 0 !important;
        float: right;
        font-size: 11px;
        font-weight: normal;
    }
    ul.df-resultbox li.df-cdata{
        margin: 0 !important;
        padding: 0 !important;
        border-bottom: 1px solid #c5c5c5;
    }
    ul.df-resultbox li.df-cdata:last-child{
        border-bottom: none;
    }
    ul.df-resultbox li.df-cdata:hover{
        background: #eaf4fd;
    }
    ul.df-resultbox li.df-cdata a{
        display: block;
        padding: 5px 10px;
        text-decoration: none !important;
        background: #fff;
    }
    ul.df-resultbox li.df-cdata a:hover{
        background: #cde0ff;
    }
    ul.df-resultbox li.df-cdata img{
        margin-right: 12px;
    }
    ul.df-resultbox li.df-cdata p{
        margin: 0 !important;
        padding: 0 !important;
        color: #444;
        font-size: 10px;
        min-height:30px;
    }
    ul.df-resultbox li.df-cdata p span.df-cdata-title{
        display: inline !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 11px;
        font-weight: bold;
        color: #000;
    }
    ul.df-resultbox li:first-child{
        -moz-border-radius:5px 5px 0 0;
        -webkit-border-radius:5px 5px 0 0;
        -khtml-border-radius:5px 5px 0 0;
        -o-border-radius:5px 5px 0 0;
        -ms-border-radius:5px 5px 0 0;
        border-radius:5px 5px 0 0;
    }
    ul.df-resultbox li:last-child{
        -moz-border-radius:0 0 5px 5px;
        -webkit-border-radius:0 0 5px 5px;
        -khtml-border-radius:0 0 5px 5px;
        -o-border-radius:0 0 5px 5px;
        -ms-border-radius:0 0 5px 5px;
        border-radius:0 0 5px 5px;
    }
}