Changeset 28707


Ignore:
Timestamp:
Jun 16, 2014, 3:53:16 PM (10 years ago)
Author:
plg
Message:

feature 3091: search.php (advanced search), display a list of known authors instead of a text field.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/search.php

    r28587 r28707  
    8484  }
    8585
    86   if ($_POST['search_author'])
    87   {
     86  if (isset($_POST['authors']) and is_array($_POST['authors']) and count($_POST['authors']) > 0)
     87  {
     88    $authors = array();
     89
     90    foreach ($_POST['authors'] as $author)
     91    {
     92      $authors[] = strip_tags($author);
     93    }
     94   
    8895    $search['fields']['author'] = array(
    89       'words' => preg_split(
    90         '/\s+/',
    91         strip_tags($_POST['search_author'])
    92         ),
     96      'words' => $authors,
    9397      'mode' => 'OR',
    9498      );
     
    210214    );
    211215}
     216
     217// authors
     218$query = '
     219SELECT
     220    author,
     221    COUNT(*) AS counter
     222  FROM '.IMAGES_TABLE.' AS i
     223    JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.image_id = i.id
     224  '.get_sql_condition_FandF(
     225    array(
     226      'forbidden_categories' => 'category_id',
     227      'visible_categories' => 'category_id',
     228      'visible_images' => 'ic.image_id'
     229      ),
     230    ' WHERE '
     231    ).'
     232    AND author IS NOT NULL
     233  GROUP BY author
     234  ORDER BY author
     235;';
     236$authors = query2array($query);
     237
     238$template->assign('AUTHORS', $authors);
    212239
    213240//------------------------------------------------------------- categories form
  • trunk/themes/default/template/search.tpl

    r28497 r28707  
    33{include file='include/resize.inc.tpl'}
    44*}
     5
     6{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'}
     7{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.dark.css"}
     8
     9{footer_script}
     10jQuery(document).ready(function() {
     11  jQuery("#authors").selectize({
     12    plugins: ['remove_button']
     13  });
     14});
     15{/footer_script}
    516
    617{if isset($MENUBAR)}{$MENUBAR}{/if}
     
    3445  </ul>
    3546  <label>{'Search for Author'|@translate}
    36     <input type="text" name="search_author" size="35">
     47    <select id="authors" placeholder="{'Type in a search term'|translate}" name="authors[]" multiple style="width:500px;">
     48{foreach from=$AUTHORS item=author}
     49      <option value="{$author.author|strip_tags:false|escape:html}">{$author.author|strip_tags:false} ({'%d photos'|translate:$author.counter})</option>
     50{/foreach}
     51    </select>
    3752  </label>
    3853</fieldset>
  • trunk/themes/default/theme.css

    r27882 r28707  
    508508        padding: 1em;
    509509        margin: 1em;
    510         overflow: hidden; /* <- makes Opera happy */
    511510}
    512511
Note: See TracChangeset for help on using the changeset viewer.