Changeset 28707 for trunk/search.php


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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.