plugins/gallery/search.php
author Dan
Thu, 23 Jul 2009 17:22:17 -0400
changeset 36 60e80cd47b61
parent 31 3e8d2acd7388
child 42 7c6e2e97aa08
permissions -rw-r--r--
Added .htaccess with far future Expires + mod_gzip
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     1
<?php
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     3
/*
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     4
 * Snapr
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     5
 * Version 0.1 beta 1
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     6
 * Copyright (C) 2007 Dan Fuhry
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     7
 *
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    10
 *
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    13
 */
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    14
 
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    15
//
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    16
// Search results hook
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    17
//
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    18
31
3e8d2acd7388 Fixed a minor offset issue in search hook
Dan
parents: 16
diff changeset
    19
$plugins->attachHook('search_results', 'if ( !isset($offset) ) $offset =& $start; gal_searcher($q, $offset);');
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    20
$plugins->attachHook('search_global_inner', 'snapr_search_new_api($query, $query_phrase, $scores, $page_data, $case_sensitive, $word_list);');
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    21
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    22
$plugins->attachHook('compile_template', '
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    23
  // CSS for gallery browser
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    24
  $template->add_header(\'<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/browser.css" type="text/css" />\');
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    25
  $template->add_header(\'<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/dropdown.css" type="text/css" />\');
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    26
  ');
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    27
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    28
function gal_searcher($q, $offset)
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    29
{
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    30
  global $db, $session, $paths, $template, $plugins; // Common objects
15
ac7d3dedcc44 Fix wrong namespace for search results
Dan
parents: 13
diff changeset
    31
  if ( defined('SNAPR_SEARCH_USING_NEW_API') || version_compare(enano_version(true), '1.0.2', '>=') )
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    32
    return false;
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    33
  
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    34
  $fulltext_col = 'MATCH(img_title, img_desc) AGAINST (\'' . $db->escape($q) . '\' IN BOOLEAN MODE)';
4
ad3b061a1c76 A few minor bugfixes and visual enhancements for admins
Dan
parents: 2
diff changeset
    35
  $sql = "SELECT img_id, img_title, img_desc, is_folder, $fulltext_col AS score, CHAR_LENGTH(img_desc) AS length FROM ".table_prefix."gallery
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    36
              WHERE $fulltext_col > 0
4
ad3b061a1c76 A few minor bugfixes and visual enhancements for admins
Dan
parents: 2
diff changeset
    37
                AND ( ( is_folder=1 AND folder_parent IS NULL ) OR is_folder!=1 )
ad3b061a1c76 A few minor bugfixes and visual enhancements for admins
Dan
parents: 2
diff changeset
    38
              ORDER BY is_folder DESC, score DESC, img_title ASC;";
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    39
  if ( !$db->sql_unbuffered_query($sql) )
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    40
  {
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    41
    echo $db->get_error();
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    42
    return false;
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    43
  }
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    44
  echo "<h3>Image results</h3>";
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    45
  if ( $row = $db->fetchrow() )
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    46
  {
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    47
    echo '<ul class="snapr-gallery">';
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    48
    $renderer = new SnaprFormatter();
4
ad3b061a1c76 A few minor bugfixes and visual enhancements for admins
Dan
parents: 2
diff changeset
    49
    $fullpage = $paths->fullpage;
ad3b061a1c76 A few minor bugfixes and visual enhancements for admins
Dan
parents: 2
diff changeset
    50
    $paths->fullpage = $paths->nslist['Special'] . 'Gallery';
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    51
    do
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    52
    {
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    53
      echo $renderer->render(false, $row, false);
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    54
    }
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    55
    while ( $row = $db->fetchrow() );
4
ad3b061a1c76 A few minor bugfixes and visual enhancements for admins
Dan
parents: 2
diff changeset
    56
    $paths->fullpage = $fullpage;
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    57
    echo '</ul><span class="menuclear"></span>';
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    58
  }
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    59
  else
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    60
  {
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    61
    echo '<p>No image results.</p>';
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    62
  }
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    63
}
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
    64
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    65
function snapr_search_new_api(&$query, &$query_phrase, &$scores, &$page_data, &$case_sensitive, &$word_list)
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    66
{
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    67
  global $db, $session, $paths, $template, $plugins; // Common objects
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    68
  
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    69
  if ( !defined('SNAPR_SEARCH_USING_NEW_API') )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    70
    define('SNAPR_SEARCH_USING_NEW_API', 1);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    71
  
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    72
  // Let's do this all in one query
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    73
  $terms = array(
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    74
      'any' => array_merge($query['any'], $query_phrase['any']),
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    75
      'req' => array_merge($query['req'], $query_phrase['req']),
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    76
      'not' => $query['not']
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    77
    );
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    78
  $where = array('any' => array(), 'req' => array(), 'not' => array());
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    79
  $where_any =& $where['any'];
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    80
  $where_req =& $where['req'];
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    81
  $where_not =& $where['not'];
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    82
  $title_col = ( $case_sensitive ) ? 'img_title' : 'lcase(img_title)';
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    83
  $desc_col = ( $case_sensitive ) ? 'img_desc' : 'lcase(img_desc)';
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    84
  foreach ( $terms['any'] as $term )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    85
  {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    86
    $term = escape_string_like($term);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    87
    if ( !$case_sensitive )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    88
      $term = strtolower($term);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    89
    $where_any[] = "( $title_col LIKE '%{$term}%' OR $desc_col LIKE '%{$term}%' )";
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    90
  }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    91
  foreach ( $terms['req'] as $term )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    92
  {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    93
    $term = escape_string_like($term);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    94
    if ( !$case_sensitive )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    95
      $term = strtolower($term);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    96
    $where_req[] = "( $title_col LIKE '%{$term}%' OR $desc_col LIKE '%{$term}%' )";
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    97
  }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    98
  foreach ( $terms['not'] as $term )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
    99
  {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   100
    $term = escape_string_like($term);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   101
    if ( !$case_sensitive )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   102
      $term = strtolower($term);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   103
    $where_not[] = "$title_col NOT LIKE '%{$term}%' AND $desc_col NOT LIKE '%{$term}%'";
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   104
  }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   105
  if ( empty($where_any) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   106
    unset($where_any, $where['any']);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   107
  if ( empty($where_req) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   108
    unset($where_req, $where['req']);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   109
  if ( empty($where_not) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   110
    unset($where_not, $where['not']);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   111
  
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   112
  $where_any = '(' . implode(' OR ', $where_any) . '' . ( isset($where['req']) || isset($where['not']) ? ' OR 1 = 1' : '' ) . ')';
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   113
  
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   114
  if ( isset($where_req) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   115
    $where_req = implode(' AND ', $where_req);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   116
  if ( isset($where_not) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   117
  $where_not = implode( 'AND ', $where_not);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   118
  
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   119
  $where = implode(' AND ', $where);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   120
  $sql = "SELECT img_id, img_title, img_desc FROM " . table_prefix . "gallery WHERE ( $where ) AND is_folder = 0;";
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   121
  
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   122
  if ( !($q = $db->sql_unbuffered_query($sql)) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   123
  {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   124
    $db->_die('Error is in auto-generated SQL query in the Snapr plugin search module');
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   125
  }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   126
  
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   127
  if ( $row = $db->fetchrow() )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   128
  {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   129
    do
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   130
    {
15
ac7d3dedcc44 Fix wrong namespace for search results
Dan
parents: 13
diff changeset
   131
      $idstring = 'ns=Gallery;pid=' . $row['img_id'];
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   132
      foreach ( $word_list as $term )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   133
      {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   134
        if ( $case_sensitive )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   135
        {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   136
          if ( strstr($row['img_title'], $term) || strstr($row['img_desc'], $term) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   137
          {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   138
            ( isset($scores[$idstring]) ) ? $scores[$idstring]++ : $scores[$idstring] = 1;
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   139
          }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   140
        }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   141
        else
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   142
        {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   143
          if ( strstr(strtolower($row['img_title']), strtolower($term)) || strstr(strtolower($row['img_desc']), strtolower($term)) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   144
          {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   145
            ( isset($scores[$idstring]) ) ? $scores[$idstring]++ : $scores[$idstring] = 1;
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   146
          }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   147
        }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   148
      }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   149
      // Generate text...
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   150
      $text = highlight_and_clip_search_result(htmlspecialchars($row['img_desc']), $word_list);
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   151
      
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   152
      $preview_and_text = '
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   153
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   154
          <tr>
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   155
            <td valign="top">
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   156
              ' . $text . '
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   157
            </td>
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   158
            <td valign="top" style="text-align: right; width: 80px; padding-left: 10px;">
16
36dd990c0c25 Apparently didn't nail the last of that namespace typo
Dan
parents: 15
diff changeset
   159
              <a href="' . makeUrlNS('Gallery', $row['img_id']) . '"><img alt="[thumbnail]" src="' . makeUrlNS('Special', "GalleryFetcher/thumb/{$row['img_id']}") . '" /></a>
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   160
            </td>
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   161
          </tr>
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   162
        </table>
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   163
      ';
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   164
      
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   165
      // Inject result
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   166
      
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   167
      if ( isset($scores[$idstring]) )
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   168
      {
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   169
        // echo('adding image "' . $row['img_title'] . '" to results<br />');
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   170
        $page_data[$idstring] = array(
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   171
          'page_name' => highlight_search_result(htmlspecialchars($row['img_title']), $word_list),
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   172
          'page_text' => $preview_and_text,
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   173
          'score' => $scores[$idstring],
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   174
          'page_note' => '[Gallery image]',
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   175
          'page_id' => strval($row['img_id']),
15
ac7d3dedcc44 Fix wrong namespace for search results
Dan
parents: 13
diff changeset
   176
          'namespace' => 'Gallery',
13
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   177
          'page_length' => strlen($row['img_desc']),
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   178
        );
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   179
      }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   180
    }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   181
    while ( $row = $db->fetchrow() );
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   182
    
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   183
  }
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   184
}
f6ca7cead82c Updated with support for Enano's new search API
Dan
parents: 4
diff changeset
   185
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents:
diff changeset
   186
?>