<?php /** * this view generates fields for search form * <br/><br/> * @author Sybille Buers, Gabriele Droege, Patricia Kelbert (BGBM, GGBN/DNA Bank Network) <contact@dnabank-network.org> * @version yii 2.0.3 * @package View * @var $this SearchController * @var $model SearchForm * @var $selectionLists - created in the controller * @var $form CActiveForm * @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org * <br/>The contents of this file are subject to the Mozilla Public License Version 1.1 * @filesource * @license http://www.mozilla.org/MPL/ MPL */ use yii\helpers\Html; use yii\jui\Accordion; use ggbn\CreateFormManager; use app\controllers\SearchController; use kartik\field\FieldRange; use kartik\widgets\ActiveForm; use yii\web\View; $this->title = 'GGBN Portal'; // $this->title = 'Search'; // $this->params ['breadcrumbs'] [] = $this->title; $this->registerJs ( " $('.tabs-search .tab-links a').on('click', function(e) { var currentAttrValue = $(this).attr('href'); // Show/Hide Tabs $(currentAttrValue).show(); $(currentAttrValue).siblings().hide(); // Change/remove current tab to active $(this).parent('li').addClass('active hop').siblings().removeClass('active'); e.preventDefault(); }); $('#searchform-kingdom').change(function() { var kingdom=$('#searchform-kingdom').val(); if (kingdom != '' && kingdom!='---')kingdom='&kingdom='+kingdom; else kingdom=''; var url='/ggbn_new/serverscripts/suggestion-list?listTitle=fullScientificName'+kingdom+'&term=%QUERY'; searchform_fullscientificname_data_1.clear(); searchform_fullscientificname_data_1.remote.url=url; searchform_fullscientificname_data_1.initialize(true); }); ", View::POS_READY ); ?> <!-- icon world.png from Silvestre Herrera - GPL --> <script type="text/javascript"> $(document).ready(function(){ $(".dropDownLabel" ).change(function(){ var $chosen=this.value; // hide all input fields... $(".hasSelectableLabel_".concat($( this ).attr("id2"))).hide(); $(".hasSelectableLabel_".concat($( this ).attr("id2"))).val(""); // ... and show the chosen one $("#SearchForm_".concat($chosen)).show(); event.preventDefault(); return false; }); $('form').submit(function(e){ var filled=false; $("form input[type=text]").each(function(){ var input=$(this); if ($.trim(this.value).length >0) filled=true; }); $("form select").each(function(){ var input=$(this); if ($.trim(this.value).length >0 && this.value != "---") filled=true; }); $("form input[type=radio]:checked").each(function(){ var input=$(this); if ($.trim(this.value).length >0 && this.value != "include") filled=true; }); if(!filled){ alert("Fill at least one value "); return false; } else{ var emptyinputs = $(this).find('input').filter(function(){ return !$.trim(this.value).length; // get all empty fields }).prop('disabled',true); var emptyinputs2 = $(this).find('select').filter(function(){ return (this.value) == ('---'); // get all empty fields }).prop('disabled',true); <?php $_GET=[];?> } }); }); </script> <div class="jumbotron"> <h2> <?php echo $model->extendedSearchFormTitle; ?> </h2> </div> <div class="container"> <div class="tabs-search"> <ul class="tab-links"> <li class="active"><a href="#Data">Search GGBN data</a></li> <li><a href="#Site">Search website</a></li> </ul> </div> <div class="tab-content"> <div id="Data" class="tab active"> <?php $elements = $model->getParameters (); $form = ActiveForm::begin ( [ 'method' => 'get', 'enableClientValidation' => true, 'validateOnSubmit' => true ] ); // this is redundant because it's true by default echo $form->errorSummary ( $model ); echo "<!-- search fields: -->"; foreach ( $elements as $key => $param ) { $tohandle = false; foreach ( $param as $k => $toto ) { try { if (isset ( $param ['type'] )) { if (isset ( $param ['hidden'] )) $tohandle = false; else $tohandle = TRUE; $type = $param ['type']; } } catch ( Exception $e ) { } } if ($tohandle) { // 1. preparation for the field generation $htmlOpts = isset ( $param ['config'] ) ? $param ['config'] : array (); // if the field is hideable // it's set not displayed in the first place // and it gets a button to hide it again: if (isset ( $param ['hideable'] ) && $param ['hideable'] == 'true') { $hide_option = "style=\"display:none;\""; $hide_button = "<img src=\"" . Yii::$app->request->baseUrl . "/images/close.png \" parent_name=\"" . $key . "\" class=\"hide_button\" alt=\"close\"/>"; } else { $hide_option = ""; $hide_button = ""; } // use default size if no size is given if (! isset ( $param ['config'] ['size'] )) { $param ['config'] ['size'] = $model->getFieldSize (); } // surround label and fields with div echo "<div class='complete_field searchfields' id='" . $key . "_area' " . $hide_option . ">"; // echo "<table class='searchfields'><tr><td class='labelSearch'>"; // 2. label - could be common text label or drop down choice // choose whether the label is a dropdown choice: if (isset ( $param ['alt'] ) && is_array ( $param ['alt'] ) && sizeof ( $param ['alt'] > 0 )) { $altList = array ( $key ) + $param ['alt']; // Yii::info ( "altList : " . implode ( $altList, "\n" ) ); // echo "<div class=\"dropDownLabel\" >"; echo Html::dropDownList ( $key, $key, $altList, $htmlOptions = array ( 'class' => "dropDownLabel", 'id2' => $key ) ); $htmlOpts += array ( "class" => "hasSelectableLabel_" . $key, "id2" => $key ); $alt = true; } else { $altList = null; $form->field ( $model, $key )->label ( $key ); $alt = false; } echo $hide_button; // 3. field itself (different types -depending on $type CreateFormManager::createField ( $this, $model, $form, $key, $param, $selectionLists, $htmlOpts, $selectedValue = NULL, $hide_option, $hide_button ); // if there are alternate fields create them and hide them: if ($alt) { if (isset ( $htmlOpts ['style'] )) { $htmlOpts ['style'] += " display:none;"; } else { $htmlOpts ['style'] = "display:none;"; } foreach ( $altList as $altField ) { unset ( $param ['valueList'] ); CreateFormManager::createField ( $this, $model, $form, $altField, $param, $selectionLists, $htmlOpts, $selectedValue = NULL ); } } echo "</div>"; } } echo $this->render ( '/search/mapSearch' ); ?> <div class="clearer"></div> <div class="col"> <?php // 0. this provides the pulldown thing that contains the search field list echo "<!-- button for search field selection -->"; echo "<div class='col-lg-3'>"; echo Html::submitButton ( 'Submit', [ 'class' => 'btn btn-primary' ] ); echo " "; echo "</div><div class='col-lg-3'>"; echo Accordion::widget ( [ 'items' => [ [ 'header' => "add Search Field", 'content' => $this->render ( 'searchFieldSelection', [ 'hideable_fields' => $model->getHideableListFields (), 'hidden_elements' => $model->getHideableList () ], true ) ] ], 'options' => [ 'tag' => 'div', 'autoHeight' => false, 'active' => false, 'delay' => '100' ], 'itemOptions' => [ 'tag' => 'div', 'class' => 'balmusette_search' ], 'headerOptions' => [ 'tag' => 'button', 'class' => 'btn btn-primary' ] , 'clientOptions' => [ 'collapsible' => true, 'active' => false ] ] ); echo "</div></div>"; ActiveForm::end (); ?> </div> <div id="Site" class="tab"> The search with wildcard is not fully working yet. Please search for complete words (or sentences) only.<br /> <br /> <?php $form2 = ActiveForm::begin(['id' => 'form-websearch','action' => $submitWebsearch]); ?> <?= $form2->field($modelwebsite, 'content')?> <div class="form-group"> <?= Html::submitButton('Search', ['class' => 'btn btn-primary', 'name' => 'website-button'])?> </div> <?php ActiveForm::end(); ?> </div> </div> </div> <script type="text/javascript"> $(document).ready(function() { init(); $('#w3.input-group').parent().append('<br/><div id="opener" title="Show/Hide Map"> Or pick coordinates on the map <img parent_name="coordinates" src="<?php echo Yii::$app->request->baseUrl?>/images/world.png" title="Show/Hide Map" alt="Show/Hide Map"/></div>' ); $( '#mapdialog' ).hide(); $("#coordinates_area").on("click",'#opener', function() { var isVisible = $('#mapdialog').is(':visible'); if(isVisible) $( '#mapdialog' ).hide(); else $( '#mapdialog' ).show(); }); }); <?php /** * this view generates fields for search form * <br/><br/> * @author Sybille Buers, Gabriele Droege, Patricia Kelbert (BGBM, GGBN/DNA Bank Network) <contact@dnabank-network.org> * @version yii 2.0.3 * @package View * @var $this SearchController * @var $model SearchForm * @var $selectionLists - created in the controller * @var $form CActiveForm * @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org * <br/>The contents of this file are subject to the Mozilla Public License Version 1.1 * @filesource * @license http://www.mozilla.org/MPL/ MPL */ use yii\helpers\Html; use yii\jui\Accordion; use ggbn\CreateFormManager; use app\controllers\SearchController; use kartik\field\FieldRange; use kartik\widgets\ActiveForm; use yii\web\View; $this->title = 'GGBN Portal'; // $this->title = 'Search'; // $this->params ['breadcrumbs'] [] = $this->title; $this->registerJs ( " $('.tabs-search .tab-links a').on('click', function(e) { var currentAttrValue = $(this).attr('href'); // Show/Hide Tabs $(currentAttrValue).show(); $(currentAttrValue).siblings().hide(); // Change/remove current tab to active $(this).parent('li').addClass('active hop').siblings().removeClass('active'); e.preventDefault(); }); $('#searchform-kingdom').change(function() { var kingdom=$('#searchform-kingdom').val(); if (kingdom != '' && kingdom!='---')kingdom='&kingdom='+kingdom; else kingdom=''; var url='/ggbn_new/serverscripts/suggestion-list?listTitle=fullScientificName'+kingdom+'&term=%QUERY'; searchform_fullscientificname_data_1.clear(); searchform_fullscientificname_data_1.remote.url=url; searchform_fullscientificname_data_1.initialize(true); }); ", View::POS_READY ); ?> <!-- icon world.png from Silvestre Herrera - GPL --> <!-- <link href="/ggbn_new/css/jquery.dataTables.css" rel="stylesheet"> --> <!-- <script src="/ggbn_new/js/jquery.dataTables.js"></script> --> <script type="text/javascript"> $(document).ready(function(){ $(".dropDownLabel" ).change(function(){ var $chosen=this.value; // hide all input fields... $(".hasSelectableLabel_".concat($( this ).attr("id2"))).hide(); $(".hasSelectableLabel_".concat($( this ).attr("id2"))).val(""); // ... and show the chosen one $("#SearchForm_".concat($chosen)).show(); event.preventDefault(); return false; }); $('form').submit(function(e){ var filled=false; $("form input[type=text]").each(function(){ var input=$(this); if ($.trim(this.value).length >0) filled=true; }); $("form select").each(function(){ var input=$(this); if ($.trim(this.value).length >0 && this.value != "---") filled=true; }); $("form input[type=radio]:checked").each(function(){ var input=$(this); if ($.trim(this.value).length >0 && this.value != "include") filled=true; }); if(!filled){ alert("Fill at least one value "); return false; } else{ var emptyinputs = $(this).find('input').filter(function(){ return !$.trim(this.value).length; // get all empty fields }).prop('disabled',true); var emptyinputs2 = $(this).find('select').filter(function(){ return (this.value) == ('---'); // get all empty fields }).prop('disabled',true); <?php $_GET=[];?> } }); }); </script> <div class="jumbotron"><h2> <?php echo $model->extendedSearchFormTitle; ?> </h2></div> <div class="body-content"> <div class="tabs-search"> <ul class="tab-links"> <li class="active"><a href="#Data">Search GGBN data</a></li> <li><a href="#Site">Search website</a></li> </ul> </div> <div class="tab-content"> <div id="Data" class="tab active"> <?php $elements = $model->getParameters (); $form = ActiveForm::begin ( [ 'method' => 'get', 'enableClientValidation' => true, 'validateOnSubmit' => true, ] ) // this is redundant because it's true by default ; echo $form->errorSummary ( $model ); echo "<!-- search fields: -->"; foreach ( $elements as $key => $param ) { $tohandle = false; foreach ( $param as $k => $toto ) { try { if (isset ( $param ['type'] )) // echo "PARAM ".$k." vs. ".$toto."<br/>"; $tohandle = TRUE; $type = $param ['type']; } catch ( Exception $e ) { // echo "no type"; } } if ($tohandle) { // 1. preparation for the field generation $htmlOpts = isset ( $param ['config'] ) ? $param ['config'] : array (); // if the field is hideable // it's set not displayed in the first place // and it gets a button to hide it again: if (isset ( $param ['hideable'] ) && $param ['hideable'] == 'true') { $hide_option = "style=\"display:none;\""; $hide_button = "<img src=\"" . Yii::$app->request->baseUrl . "/images/close.png \" parent_name=\"" . $key . "\" class=\"hide_button\" alt=\"close\"/>"; } else { $hide_option = ""; $hide_button = ""; } // use default size if no size is given if (! isset ( $param ['config'] ['size'] )) { $param ['config'] ['size'] = $model->getFieldSize (); } // surround label and fields with div echo "<div class='complete_field searchfields' id='" . $key . "_area' " . $hide_option . ">"; // echo "<table class='searchfields'><tr><td class='labelSearch'>"; // 2. label - could be common text label or drop down choice // choose whether the label is a dropdown choice: if (isset ( $param ['alt'] ) && is_array ( $param ['alt'] ) && sizeof ( $param ['alt'] > 0 )) { $altList = array ( $key ) + $param ['alt']; Yii::info("altList : ".implode($altList,"\n")); // echo "<div class=\"dropDownLabel\" >"; echo Html::dropDownList ( $key, $key, $altList, $htmlOptions = array ( 'class' => "dropDownLabel", 'id2' => $key ) ) ; $htmlOpts += array ( "class" => "hasSelectableLabel_" . $key, "id2" => $key ); $alt = true; } else { $altList = null; $form->field ( $model, $key )->label ( $key ); $alt = false; } echo $hide_button; // 3. field itself (different types -depending on $type CreateFormManager::createField ( $this, $model, $form, $key, $param, $selectionLists, $htmlOpts, $selectedValue = NULL, $hide_option, $hide_button ); // if there are alternate fields create them and hide them: if ($alt) { if (isset ( $htmlOpts ['style'] )) { $htmlOpts ['style'] += " display:none;"; } else { $htmlOpts ['style'] = "display:none;"; } foreach ( $altList as $altField ) { unset ( $param ['valueList'] ); CreateFormManager::createField ( $this, $model, $form, $altField, $param, $selectionLists, $htmlOpts, $selectedValue = NULL ); } } echo "</div>"; } } echo $this->render ( '/search/mapSearch'); ?> <div class="clearer"></div> <div class="col"> <?php // 0. this provides the pulldown thing that contains the search field list echo "<!-- button for search field selection -->"; echo "<div class='col-lg-2'>"; echo Html::submitButton('Submit', ['class' => 'btn btn-primary']); echo " "; echo "</div><div class='col-lg-2'>"; echo Accordion::widget ( [ 'items' => [ [ 'header' => "add Search Field", 'content' => $this->render ( 'searchFieldSelection', [ 'hideable_fields' => $model->getHideableListFields (), 'hidden_elements' => $model->getHideableList () , ], true ) ] ], 'options' => [ 'tag' => 'div', 'autoHeight' => false, 'active' => false, 'delay' => '100' , ], 'itemOptions' => [ 'tag' => 'div' , 'class' => 'balmusette_search' ], 'headerOptions' => [ 'tag' => 'button', 'class' => 'btn btn-primary', ], 'clientOptions' => [ 'collapsible' => true ,'active' => false, ] ] ); echo "</div></div>"; ActiveForm::end(); ?> </div> <div id="Site" class="tab"> The search with wildcard is not fully working yet. Please search for complete words (or sentences) only.<br/><br/> <?php $form2 = ActiveForm::begin(['id' => 'form-websearch','action' => $submitWebsearch]); ?> <?= $form2->field($modelwebsite, 'content')?> <div class="form-group"> <?= Html::submitButton('Search', ['class' => 'btn btn-primary', 'name' => 'website-button'])?> </div> <?php ActiveForm::end(); ?> </div> </div> </div> <script type="text/javascript"> $(document).ready(function() { init(); $('#w3.input-group').parent().append('<br/><div id="opener" title="Show/Hide Map"> Or pick coordinates on the map <img parent_name="coordinates" src="<?php echo Yii::$app->request->baseUrl?>/images/world.png" title="Show/Hide Map" alt="Show/Hide Map"/></div>' ); $( '#mapdialog' ).hide(); $("#coordinates_area").on("click",'#opener', function() { var isVisible = $('#mapdialog').is(':visible'); if(isVisible) $( '#mapdialog' ).hide(); else $( '#mapdialog' ).show(); }); }); </script>