manowicie zainstalowałem Gallery2 (aplikacje tworzącą gallerie) była w nej wyszukiwarka ale wszyszukiwała tylko po jednym argunecie. znanalazłem na jakimś forum kawałek kodu który umożliwia szukanie kilku wyrazów. wszystko działa bardzo dobrze dopuki nie szukamy czegoś takiego wyzar1 AND wyraz2 i jeden wyraz jest w słowach kluczach a drugi w opisie wtedy nie znajduje nic. więc wpadłem na pomysł żeby podczas ladowania danych do zmiennej z opisem dopisywać do niej słowa klucze po przestudiowaniu znalazłem gdzie to trzeba zrobić
w tej funkcji
function search($options, $criteria, $offset=1, $count=-2) {
global $gallery;
$whereList = array();
$whereData = array();
$columnNumber = 0;
foreach (array('descriptions' => '[GalleryItem::description] '+ '[GalleryItem::keywords]',
'keywords' => '[GalleryItem::keywords]',
'summaries' => '[GalleryItem::summary]',
'titles' => '[GalleryItem::title]')
as $key => $column) {
Dodanie wartości zaznaczonej na czerwono. Próbowałem dodać jak tesksty czyli &a.&b ale nie działa ma ktoś może jakiś pomysł jak to zrobić


zlączam też cały kod wyszukiwarki
<?php /* * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2008 Bharat Mediratta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ GalleryCoreApi::requireOnce('modules/search/classes/GallerySearchInterface_1_0.class'); /** * This is an implementation of the search module's SearchInterface_1_0 * @package GalleryCore * @subpackage Classes * @author Bharat Mediratta <bharat@menalto.com> * @version $Revision: 17580 $ */ class GalleryCoreSearch extends GallerySearchInterface_1_0 { /** * @see GallerySearchInterface_1_0.getSearchModuleInfo */ function getSearchModuleInfo() { list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'core'); if ($ret) { } 'description' => $module->translate('Gallery Core Module'), 'description' => $module->translate('Search descriptions'), 'enabled' => 1), 'description' => $module->translate('Search keywords'), 'enabled' => 1), 'description' => $module->translate('Search summaries'), 'enabled' => 1), 'enabled' => 1))); } /** * @see GallerySearchInterface_1_0.search */ function search($options, $criteria, $offset=0, $count=-1) { $columnNumber = 0; 'keywords' => '[GalleryItem::keywords]', 'summaries' => '[GalleryItem::summary]', 'titles' => '[GalleryItem::title]') as $key => $column) { /* Replace it with this part * IT ADDS A BASIC BOOLEAN SEARCH * START NEW CODE */ $loop_index = 0; $countWhere = "("; // to group for AND start while ($loop_index < $total_items) { $criteria_item = { if (($total_items > 1) and ($loop_index > 0)) { // more words so AND or OR needed /* checks if advanced search parameters are entered * such as + for AND, - for AND NOT and translates them in SQL * then removes the used special characters for search * @author Francois Voisard <francois.voisard<at>gmx.ch> */ { $countWhere .= "OR $column LIKE ?"; } { $countWhere .= "AND $column NOT LIKE ?"; } else { $countWhere .= "AND $column LIKE ?"; } } else { { $countWhere .= " $column LIKE ?"; } { $countWhere .= " $column LIKE ?"; } else { $countWhere .= " $column LIKE ?"; } } //make each question mark to inject data later $whereData[] = '%' . $criteria_item . '%'; } $loop_index++; } // end loop $selectMap[$column] = $columnNumber++; $selectList[] = $column; $countWhere .= ") "; // to group $whereList[] = $countWhere; } // end isset /* * END NEW BOOLEAN CODE */ } /* Always select back title and summary */ $selectMap[$column] = $columnNumber++; $selectList[] = $column; } } $storage =& $gallery->getStorage(); list ($ret, $aclIds) = GalleryCoreApi::fetchAccessListIds( 'core.view', $gallery->getActiveUserId()); if ($ret) { } } SELECT COUNT([GalleryItem::id]) FROM [GalleryItem], [GalleryAccessSubscriberMap] WHERE AND [GalleryItem::id] = [GalleryAccessSubscriberMap::itemId] AND [GalleryAccessSubscriberMap::accessListId] IN (%s) ', $aclMarkers); SELECT [GalleryItem::id], [GalleryUser::fullName], [GalleryUser::userName], [GalleryEntity::modificationTimestamp], ' . FROM [GalleryItem], [GalleryAccessSubscriberMap], [GalleryEntity], [GalleryUser] WHERE AND [GalleryItem::id] = [GalleryAccessSubscriberMap::itemId] AND [GalleryItem::id] = [GalleryEntity::id] AND [GalleryUser::id] = [GalleryItem::ownerId] AND [GalleryAccessSubscriberMap::accessListId] IN (%s) ORDER BY [GalleryEntity::modificationTimestamp] DESC, [GalleryItem::id] DESC ', $aclMarkers); $data = $whereData; /* Find the total */ list ($ret, $results) = $gallery->search($countQuery, $data); if ($ret) { } $result = $results->nextResult(); $numRows = (int)$result[0]; /* Get the results that we're interested in */ list ($ret, $results) = $gallery->search( if ($ret) { } list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'core'); if ($ret) { } $text['description'] = $module->translate('Description'); $text['keywords'] = $module->translate('Keywords'); $text['summary'] = $module->translate('Summary'); $text['title'] = $module->translate('Title'); $text['owner'] = $module->translate('Owner'); while ($result = $results->nextResult()) { '[GalleryItem::summary]' => $text['summary'], '[GalleryItem::keywords]' => $text['keywords'], '[GalleryItem::description]' => $text['description']) as $columnName => $fieldText) { /* * Remember that our field columns start at column index 4 * (id, date, full name, username are columns 0-3) */ 'key' => $fieldText, 'value' => $result[$selectMap[$columnName]+4]); } } } 'count' => $numRows, 'results' => $searchResults); } } ?>