Couldn't locate the options page.
", 'solrmss'); } } function mss_admin_head() { global $this_plugin_dir_url; // include css if (file_exists(dirname(__FILE__) . '/admin.css')) { printf(__("\n"), $this_plugin_dir_url . 'admin.css'); } ?> \n"), bloginfo('template_url') . '/mss_search.css'); // } else if (file_exists(dirname(__FILE__) . '/template/mss_search.css')) { // // use plugin supplied file // printf(__("\n"), $this_plugin_dir_url . 'template/mss_search.css'); // } if (file_exists(TEMPLATEPATH . '/mss_search_custom.css')) { // use theme file printf(__("\n"), get_template_directory_uri() . '/mss_search_custom.css'); } else if (file_exists(dirname(__FILE__) . '/template/mss_search_custom.css')) { // use plugin custom file printf(__("\n"), this_plugin_dir_url . 'template/mss_search_custom.css'); } else if (file_exists(dirname(__FILE__) . '/template/mss_search.css')) { // use plugin supplied file printf(__("\n"), $this_plugin_dir_url . 'template/mss_search.css'); } } function mss_autosuggest_head() { global $this_plugin_dir_url; // if (file_exists(TEMPLATEPATH . '/mss_autocomplete.css')) { // // use theme file // printf(__("\n"), bloginfo('template_url') . '/mss_autocomplete.css'); // } else if (file_exists(dirname(__FILE__) . '/template/mss_autocomplete.css')) { // // use plugin supplied file // printf(__("\n"), $this_plugin_dir_url . 'template/mss_autocomplete.css'); // } if (file_exists(TEMPLATEPATH . '/mss_autocomplete_custom.css')) { // use theme file printf(__("\n"), get_template_directory_uri() . '/mss_autocomplete_custom.css'); } else if (file_exists(dirname(__FILE__) . '/template/mss_autocomplete_custom.css')) { // use plugin custom file printf(__("\n"), $this_plugin_dir_url . 'template/mss_autocomplete_custom.css'); } else if (file_exists(dirname(__FILE__) . '/template/mss_autocomplete.css')) { // use plugin supplied file printf(__("\n"), $this_plugin_dir_url . 'template/mss_autocomplete.css'); } ?> post_status=='auto-draft' || $post_info->post_status=='draft') return; $options = mss_get_option(); $post_type = $options['mss_post_types']; $aPostTypes = explode(',', $post_type); if (in_array($post_info->post_type, $aPostTypes)) { $docs = array(); $doc = mss_build_document( $options, $post_info ); if ( $doc ) { $docs[] = $doc; mss_post( $options, $docs ); } } } function mss_handle_modified( $post_id ) { global $current_blog; $post_info = get_post( $post_id ); $options = mss_get_option(); $post_type = $options['mss_post_types']; $aPostTypes = explode(',', $post_type); if (in_array($post_info->post_type, $aPostTypes)) { $docs = array(); $doc = mss_build_document( $options, $post_info ); if ( $doc ) { $docs[] = $doc; mss_post( $options, $docs ); } } } function mss_handle_status_change( $post_id ) { global $current_blog; $post_info = get_post( $post_id ); $options = mss_get_option(); $post_type = $options['mss_post_types']; $aPostTypes = explode(',', $post_type); if (in_array($post_info->post_type, $aPostTypes)) { if ( ($_POST['prev_status'] == 'publish' || $_POST['original_post_status'] == 'publish') && ($post_info->post_status == 'draft' || $post_info->post_status == 'private') ) { $solr = new Mss_Solr(); if ($solr->connect($options, true)) { $solr->deleteById( $post_info->ID ); } } } } function mss_handle_delete( $post_id ) { global $current_blog; $post_info = get_post( $post_id ); $options = mss_get_option(); $post_type = $options['mss_post_types']; $aPostTypes = explode(',', $post_type); if (in_array($post_info->post_type, $aPostTypes)) { $solr = new Mss_Solr(); if ($solr->connect($options, true)) { $solr->deleteById( $post_info->ID ); } } } function mss_search_form() { $sort = $_GET['sort']; $order = $_GET['order']; if ($sort == 'date') { $sortval = __(''); } else if ($sort == 'modified') { $sortval = __(''); } else { $sortval = __(''); } if ($order == 'asc') { $orderval = __(''); } else { $orderval = __(''); } $form = __(''); printf($form, htmlspecialchars(stripslashes($_GET['s'])), $sortval, $orderval); } function mss_search_results() { $plugin_mss_settings = mss_get_option(); $output_info = (isset($plugin_mss_settings['mss_output_info'])) ? $plugin_mss_settings['mss_output_info'] : false; $output_facets = (isset($plugin_mss_settings['mss_output_facets'])) ? $plugin_mss_settings['mss_output_facets'] : false; $results_per_page = $plugin_mss_settings['mss_num_results']; $categoy_as_taxonomy = (isset($plugin_mss_settings['mss_cat_as_taxo'])) ? $plugin_mss_settings['mss_cat_as_taxo'] : false; $dym_enabled = $plugin_mss_settings['mss_enable_dym']; $qry = stripslashes($_GET['s']); $offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0; $count = (isset($_GET['count'])) ? $_GET['count'] : $results_per_page; $fq = (isset($_GET['fq'])) ? $_GET['fq'] : ''; $sort = (isset($_GET['sort'])) ? $_GET['sort'] : ''; $order = (isset($_GET['order'])) ? $_GET['order'] : ''; $isdym = (isset($_GET['isdym'])) ? $_GET['isdym'] : 0; $out = array(); if ( ! $qry ) { $qry = ''; } if ( $sort && $order ) { $sortby = $sort . ' ' . $order; } else { $sortby = ''; $order = ''; } $fqstr = ''; $fqitms = split('\|\|', stripslashes($fq)); $selectedfacets = array(); foreach ($fqitms as $fqitem) { if ($fqitem) { $splititm = split(':', $fqitem, 2); $selectedfacet = array(); $label = $splititm[1]; if (mss_endswith($label, '^^"')) $label = substr($label, 0, -3) . '"'; $selectedfacet['name'] = sprintf(__("%s: %s"), ucwords(str_replace('_', ' ', preg_replace('/_str$/i', '', $splititm[0]))), str_replace("^^", "/", $label)); $removelink = ''; foreach($fqitms as $fqitem2) { if ($fqitem2 && !($fqitem2 === $fqitem)) { $splititm2 = split(':', $fqitem2, 2); $removelink = $removelink . urlencode('||') . $splititm2[0] . ':' . urlencode($splititm2[1]); } } if ($removelink) { $selectedfacet['removelink'] = htmlspecialchars(sprintf(__("?s=%s&fq=%s"), urlencode($qry), $removelink)); } else { $selectedfacet['removelink'] = htmlspecialchars(sprintf(__("?s=%s"), urlencode($qry))); } $fqstr = $fqstr . urlencode('||') . $splititm[0] . ':' . urlencode($splititm[1]); $selectedfacets[] = $selectedfacet; } } if ($qry) { $results = mss_query( $qry, $offset, $count, $fqitms, $sortby, $plugin_mss_settings ); if ($results) { $response = $results->response; //echo $results->getRawResponse(); $header = $results->responseHeader; $teasers = get_object_vars($results->highlighting); if (is_object($results->spellcheck)) $didyoumean = $results->spellcheck->suggestions->collation; else $didyoumean= false; $out['hits'] = sprintf(__("%d"), $response->numFound); $out['qtime'] = false; if ($output_info) { $out['qtime'] = sprintf(__("%.3f"), $header->QTime/1000); } $out['dym'] = false; if ($didyoumean && !$isdym && $dym_enabled) { $dymout = array(); $dymout['term'] = htmlspecialchars($didyoumean); $dymout['link'] = htmlspecialchars(sprintf(__("?s=%s&isdym=1"), urlencode($didyoumean))); $out['dym'] = $dymout; } // calculate the number of pages $numpages = ceil($response->numFound / $count); $currentpage = ceil($offset / $count) + 1; $pagerout = array(); if ($numpages == 0) { $numpages = 1; } foreach (range(1, $numpages) as $pagenum) { if ( $pagenum != $currentpage ) { $offsetnum = ($pagenum - 1) * $count; $pageritm = array(); $pageritm['page'] = sprintf(__("%d"), $pagenum); //$pageritm['link'] = htmlspecialchars(sprintf(__("?s=%s&offset=%d&count=%d"), urlencode($qry), $offsetnum, $count)); $pagerlink = sprintf(__("?s=%s&offset=%d&count=%d"), urlencode($qry), $offsetnum, $count); if($fqstr) $pagerlink .= '&fq=' . $fqstr; $pageritm['link'] = htmlspecialchars($pagerlink); $pagerout[] = $pageritm; } else { $pageritm = array(); $pageritm['page'] = sprintf(__("%d"), $pagenum); $pageritm['link'] = ""; $pagerout[] = $pageritm; } } $out['pager'] = $pagerout; if ($output_facets) { // handle facets $facetout = array(); if($results->facet_counts) { foreach ($results->facet_counts->facet_fields as $facetfield => $facet) { if ( ! get_object_vars($facet) ) { continue; } $facetinfo = array(); $facetitms = array(); $facetinfo['name'] = ucwords(str_replace('_', ' ', preg_replace('/_str$/i', '', $facetfield))); // categories is a taxonomy if ($categoy_as_taxonomy && $facetfield == 'categories') { // generate taxonomy and counts $taxo = array(); foreach ($facet as $facetval => $facetcnt) { $taxovals = explode('^^', rtrim($facetval, '^^')); $taxo = mss_gen_taxo_array($taxo, $taxovals); } $facetitms = mss_get_output_taxo($facet, $taxo, '', $fqstr, $facetfield); } else { foreach ($facet as $facetval => $facetcnt) { $facetitm = array(); $facetitm['count'] = sprintf(__("%d"), $facetcnt); $facetitm['link'] = htmlspecialchars(sprintf(__('?s=%s&fq=%s:%s%s', 'solrmss'), urlencode($qry), $facetfield, urlencode('"' . $facetval . '"'), $fqstr)); $facetitm['name'] = $facetval; $facetitms[] = $facetitm; } } $facetinfo['items'] = $facetitms; $facetout[$facetfield] = $facetinfo; } } $facetout['selected'] = $selectedfacets; $out['facets'] = $facetout; $out['facets']['output']=true; } else { $out['facets']['output']=false; } $resultout = array(); if ($response->numFound != 0) { foreach ( $response->docs as $doc ) { $resultinfo = array(); $docid = strval($doc->id); foreach ( $doc as $key=>$value ) { $resultinfo[$key] = $value; } $resultinfo['permalink'] = $doc->permalink; $resultinfo['title'] = $doc->title; $resultinfo['author'] = $doc->author; $resultinfo['authorlink'] = htmlspecialchars($doc->author_s); $resultinfo['numcomments'] = $doc->numcomments; $resultinfo['date'] = $doc->displaydate; if ($doc->numcomments === 0) { $resultinfo['comment_link'] = $doc->permalink . "#respond"; } else { $resultinfo['comment_link'] = $doc->permalink . "#comments"; } $resultinfo['score'] = $doc->score; $resultinfo['id'] = $docid; $docteaser = $teasers[$docid]; if ($docteaser->content) { $resultinfo['teaser'] = sprintf(__("...%s..."), implode("...", $docteaser->content)); } else { $words = split(' ', $doc->content); $teaser = implode(' ', array_slice($words, 0, 30)); $resultinfo['teaser'] = sprintf(__("%s..."), $teaser); } $resultout[] = $resultinfo; } } $out['results'] = $resultout; } } else { $out['hits'] = "0"; } # pager and results count helpers $out['query'] = htmlspecialchars($qry); $out['offset'] = strval($offset); $out['count'] = strval($count); $out['firstresult'] = strval($offset + 1); $out['lastresult'] = strval(min($offset + $count, $out['hits'])); $out['sortby'] = $sortby; $out['order'] = $order; $out['sorting'] = array( 'scoreasc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=score&order=asc', urlencode($qry), stripslashes($fq))), 'scoredesc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=score&order=desc', urlencode($qry), stripslashes($fq))), 'dateasc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=date&order=asc', urlencode($qry), stripslashes($fq))), 'datedesc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=date&order=desc', urlencode($qry), stripslashes($fq))), 'modifiedasc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=modified&order=asc', urlencode($qry), stripslashes($fq))), 'modifieddesc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=modified&order=desc', urlencode($qry), stripslashes($fq))), 'commentsasc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=numcomments&order=asc', urlencode($qry), stripslashes($fq))), 'commentsdesc' => htmlspecialchars(sprintf('?s=%s&fq=%s&sort=numcomments&order=desc', urlencode($qry), stripslashes($fq))) ); return $out; } function mss_print_facet_items($items, $pre = "