function getHitResults() { $results = NULL; $total = $this->getTotalResults(); $searchwords = getSearchWords(); $searchdate = getSearchDate(); if (!empty($searchdate)) { if (!empty($seachwords)) { $searchwords .= ": "; } $searchwords .= $searchdate; } if (empty($searchwords)) { return NULL; } if ($total > 0) { if ($total > 1) { $results = "{$total} Hits for <em>{$searchwords}</em>"; } else { $results = "1 Hit for <em>{$searchwords}</em>"; } } else { $results = "No Hit for <em>{$searchwords}</em>"; } return $results; }
static function getSearchQuery() { $input = $_GET['words']; $words = getSearchWords(); $date = $_GET['date']; if (isset($date)) { $words = strftime('%B %Y', strtotime("{$date}-01")); } elseif (!isset($input) || $input == '' || $input == DEFAULT_SEARCH_TEXT) { $words = '< ' . gettext('No search criteria') . '>'; //$words = '< ' . 'No search criteria' . '>'; return $words; } if (isset($words) && strlen($words) > 25) { $words = substr($words, 0, 23) . " ... "; } return $words; }
function getSearchWords($word, array $replacements) { $words = array(); foreach ($replacements as $chars => $replacement) { if ($count = substr_count($word, $chars)) { $offset = 0; while (false !== ($pos = strpos($word, $chars, $offset))) { $newWord = substr_replace($word, $replacement, $pos, strlen($chars)); $words[$newWord] = $newWord; $offset = $pos + 1; } } } foreach ($words as $newWord) { $words = array_merge($words, getSearchWords($newWord, $replacements)); } $words = array_merge(array($word => $word), $words); return array_keys(array_flip($words)); }
} ?> </div> <div id="breadcrumb"> <h2><?php printGalleryIndexURL(' » '); printSearchBreadcrumb(" » "); ?> </h2> </div> <div id="content"> <div id="content-left"> <?php $searchwords = getSearchWords(); $searchdate = getSearchDate(); if (!empty($searchdate)) { if (!empty($searchwords)) { $searchwords .= ": "; } $searchwords .= $searchdate; } if ($total > 0) { ?> <h3> <?php printf(ngettext('%1$u Hit for <em>%2$s</em>', '%1$u Hits for <em>%2$s</em>', $total), $total, html_encode($searchwords)); ?> </h3> <?php
$zpmin_metadesc = truncate_string(getBareAlbumDesc(), 150, '...'); printRSSHeaderLink('Album', getAlbumTitle()); $galleryactive = true; $cbscript = true; break; case 'image.php': $zpmin_metatitle = getBareImageTitle() . ' | '; $zpmin_metadesc = truncate_string(getBareImageDesc(), 150, '...'); $galleryactive = true; $cbscript = true; break; case 'archive.php': $zpmin_metatitle = gettext("Archive View") . ' | '; break; case 'search.php': $zpmin_metatitle = gettext('Search') . " | " . html_encode(getSearchWords()) . ' | '; $galleryactive = true; $cbscript = true; $zpmin_social = false; break; case 'pages.php': $zpmin_metatitle = getBarePageTitle() . ' | '; $zpmin_metadesc = strip_tags(truncate_string(getPageContent(), 150, '...')); $cbscript = true; break; case 'news.php': if (is_NewsArticle()) { $zpmin_metatitle = gettext('News') . ' | ' . getBareNewsTitle() . ' | '; $zpmin_metadesc = strip_tags(truncate_string(getNewsContent(), 150, '...')); } else { if ($_zp_current_category) {
if (hasNextPage()) { if (hasPrevPage()) { echo ' '; } ?> <a href="<?php echo htmlspecialchars(getNextPageURL()); ?> " accesskey="x"><?php echo gettext('next page'); ?> »</a> <?php } echo '</p>'; echo "<em class=\"count\">" . sprintf(gettext('Total matches for <em>%1$s</em>: %2$u'), getSearchWords(), $results); } else { echo "<p>" . gettext('Sorry, no matches. Try refining your search.') . "</p>"; } } ?> </div> </div> <p id="path"> <?php printHomeLink('', ' > '); ?> <a href="<?php echo htmlspecialchars(getGalleryIndexURL()); ?>
} else { $titlebreadcrumb = ''; } $zpfocus_metatitle = getBareImageTitle() . ' | ' . getBareAlbumTitle() . $titlebreadcrumb . ' | ' . getBareGalleryTitle(); $zpfocus_metadesc = shortenContent(getBareImageDesc(), 150, '...'); $galleryactive = true; if (function_exists('printCommentForm') && getOption('RSS_comments')) { printRSSHeaderLink('Comments-image', getBareImageTitle() . ' - ' . gettext('Latest Comments'), $lang = '') . "\n"; } break; case 'archive.php': $zpfocus_metatitle = gettext("Archive View") . ' | ' . getBareGalleryTitle(); $zpfocus_metadesc = shortenContent(getBareGalleryDesc(), 150, '...'); break; case 'search.php': $zpfocus_metatitle = gettext('Search') . ' | ' . html_encode(getSearchWords()) . ' | ' . getBareGalleryTitle(); $zpfocus_metadesc = shortenContent(getBareGalleryDesc(), 150, '...'); $galleryactive = true; break; case 'pages.php': $zpfocus_metatitle = getBarePageTitle() . ' | ' . getBareGalleryTitle(); $zpfocus_metadesc = strip_tags(shortenContent(getPageContent(), 150, '...')); break; case 'news.php': if (is_NewsArticle()) { $zpfocus_metatitle = gettext('News') . ' | ' . getBareNewsTitle() . ' | ' . getBareGalleryTitle(); $zpfocus_metadesc = strip_tags(shortenContent(getNewsContent(), 150, '...')); } else { if ($_zp_current_category) { $zpfocus_metatitle = gettext('News') . ' | ' . $_zp_current_category->getTitle() . ' | ' . getBareGalleryTitle(); $zpfocus_metadesc = strip_tags(shortenContent(getNewsCategoryDesc(), 150, '...'));
echo " | " . gettext('Contact'); } if ($_zp_gallery_page == 'pages.php') { echo " | " . getBarePageTitle(); } if ($_zp_gallery_page == 'archive.php') { echo " | " . gettext('Archive View'); } if ($_zp_gallery_page == 'password.php') { echo " | " . gettext('Password Required...'); } if ($_zp_gallery_page == '404.php') { echo " | " . gettext('404 Not Found...'); } if ($_zp_gallery_page == 'search.php') { echo " | " . gettext('Search: ') . html_encode(getSearchWords()); } if ($_zp_gallery_page == 'news.php') { echo " | " . gettext('News'); } if ($_zp_gallery_page == 'news.php' && is_NewsArticle()) { echo " | " . getBareNewsTitle(); } ?> </title> <?php if (getOption('zp_plugin_reCaptcha')) { ?> <script> var RecaptchaOptions = {
/** * Prints the search form * * Search works on a list of tokens entered into the search form. * * Tokens may be part of boolean expressions using &, |, !, and parens. (Comma is retained as a synonom of | for * backwords compatibility.) * * Tokens may be enclosed in quotation marks to create exact pattern matches or to include the boolean operators and * parens as part of the tag.. * * @param string $prevtext text to go before the search form * @param string $id css id for the search form, default is 'search' * @param string $buttonSource optional path to the image for the button * @param string $buttontext optional text for the button ("Search" will be the default text) * @param string $iconsource optional theme based icon for the search fields toggle * @param array $query_fields override selection for enabled fields with this list * @param array $objects_list optional array of things to search eg. [albums]=>[list], etc. * if the list is simply 0, the objects will be omitted from the search * @param string $reseticonsource optional theme based icon for reset search icon * @since 1.1.3 */ function printSearchForm($prevtext = NULL, $id = 'search', $buttonSource = NULL, $buttontext = '', $iconsource = NULL, $query_fields = NULL, $object_list = NULL, $reseticonsource = NULL) { global $_zp_adminJS_loaded; if (!is_null($object_list)) { if (array_key_exists(0, $object_list)) { // handle old form albums list trigger_error(gettext('printSearchForm $album_list parameter is deprecated. Pass array("albums"=>array(album, album, ...)) instead.'), E_USER_NOTICE); $object_list = array('albums' => $object_list); } } if (empty($buttontext)) { $buttontext = gettext("Search"); } else { $buttontext = sanitize($buttontext); } $zf = WEBPATH . "/" . ZENFOLDER; $searchwords = getSearchWords(); if (substr($searchwords, -1, 1) == ',') { $searchwords = substr($searchwords, 0, -1); } if (empty($searchwords)) { $hint = '%s'; } else { $hint = gettext('%s within previous results'); } if (empty($buttonSource)) { $type = 'submit'; $button = 'value="' . $buttontext . '" title="' . sprintf($hint, $buttontext) . '"'; } else { $buttonSource = 'src="' . $buttonSource . '" alt="' . $buttontext . '"'; $button = 'title="' . sprintf($hint, $buttontext) . '"'; $type = 'image'; } if (empty($iconsource)) { $iconsource = WEBPATH . '/' . ZENFOLDER . '/images/searchfields_icon.png'; } if (empty($reseticonsource)) { $reseticonsource = WEBPATH . '/' . ZENFOLDER . '/images/reset_icon.png'; } if (MOD_REWRITE) { $searchurl = '/page/search/'; } else { $searchurl = "/index.php?p=search"; } $engine = new SearchEngine(); $fields = $engine->allowedSearchFields(); if (!$_zp_adminJS_loaded) { $_zp_adminJS_loaded = true; ?> <script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER; ?> /js/admin.js"></script> <?php } ?> <div id="<?php echo $id; ?> "><!-- search form --> <form method="post" action="<?php echo WEBPATH . $searchurl; ?> " id="search_form"> <script type="text/javascript"> // <!-- <![CDATA[ function reset_search() { lastsearch=''; $('#reset_search').hide(); $('#search_submit').attr('title', '<?php echo $buttontext; ?> '); $('#search_input').val(''); } var lastsearch = '<?php echo addslashes(html_entity_decode(addslashes($searchwords))); ?> '; var savedlastsearch = lastsearch; $('#search_form').submit(function(){ if (lastsearch) { var newsearch = $.trim($('#search_input').val()); if (newsearch.substring(newsearch.length - 1)==',') { newsearch = newsearch.substr(0,newsearch.length-1); } if (newsearch.length > 0) { $('#search_input').val('('+lastsearch+') AND ('+newsearch+')'); } else { $('#search_input').val(lastsearch); } } return true; }); // ]]> --> </script> <?php echo $prevtext; ?> <input type="text" name="words" value="" id="search_input" size="10" /> <?php if (count($fields) > 1) { ?> <a href="javascript:toggle('searchextrashow');" ><img src="<?php echo $iconsource; ?> " title="<?php echo gettext('select search fields'); ?> " alt="<?php echo gettext('fields'); ?> " id="searchfields_icon" /></a> <?php } ?> <span style="white-space:nowrap;display:<?php if ($searchwords) { echo 'inline'; } else { echo 'none'; } ?> " id="reset_search"><a href="javascript:reset_search();" title="<?php echo gettext('Clear search'); ?> "><img src="<?php echo $reseticonsource; ?> " alt="<?php echo gettext('Reset search'); ?> " /></a></span> <input type="<?php echo $type; ?> " <?php echo $button; ?> class="pushbutton" id="search_submit" <?php echo $buttonSource; ?> /> <?php if (is_array($object_list)) { foreach ($object_list as $key => $list) { ?> <input type="hidden" name="in<?php echo $key; ?> " value="<?php if (is_array($list)) { echo html_encode(implode(',', $list)); } else { echo html_encode($list); } ?> " /> <?php } } ?> <br /> <?php if (count($fields) > 1) { $fields = array_flip($fields); natcasesort($fields); $fields = array_flip($fields); if (is_null($query_fields)) { $query_fields = $engine->parseQueryFields(); } else { if (!is_array($query_fields)) { $query_fields = $engine->numericFields($query_fields); } } if (count($query_fields) == 0) { $query_fields = $engine->allowedSearchFields(); } ?> <ul style="display:none;" id="searchextrashow"> <?php foreach ($fields as $display => $key) { echo '<li><label><input id="SEARCH_' . $key . '" name="SEARCH_' . $key . '" type="checkbox"'; if (in_array($key, $query_fields)) { echo ' checked="checked" '; } echo ' value="' . $key . '" /> ' . $display . "</label></li>" . "\n"; } ?> </ul> <?php } ?> </form> </div><!-- end of search form --> <?php }