Esempio n. 1
0
 /**
  * An ajax method that will search the index (you can specify the driver)
  * and return results in JSON format.
  */
 public static function search()
 {
     $driver = WPSearch_Utility::arrayGet($_POST, 'driver');
     $term = WPSearch_Utility::arrayGet($_POST, 'q');
     $page = WPSearch_Utility::arrayGet($_POST, 'p', 0);
     $per_page = WPSearch_Utility::arrayGet($_POST, 'n', 5);
     if (!$term) {
         die(json_encode(array('success' => false)));
     }
     try {
         $search = new WPSearch_Search($driver);
         $start = microtime(true);
         $results = $search->search($term, $page, $per_page);
         $search_time = round(microtime(true) - $start, 3);
         # Return seconds without the leading 0
         if (substr($search_time, 0, 1) == '0') {
             $search_time = substr($search_time, 1);
         }
     } catch (WPSearch_Exception $ex) {
         WPSearch_Log::add('error', "Exception during AJAX search call: " . $ex->__toString());
         die(json_encode(array('success' => false)));
     }
     die(json_encode(array('success' => true, 'search_time' => $search_time, 'result' => $results)));
 }
Esempio n. 2
0
echo $about;
?>
        </div>
      </div>
      <div class="right_column">
          <a href="http://oconf.org" target="_blank">
            <img class="oconf_logo" src="<?php 
echo WPSearch_Utility::getImageBaseURL();
?>
oconf.jpg" alt="" />
          </a>
          <?php 
if (WPSearch_Config::get('driver') == 'phplucene') {
    ?>
          <?php 
    if ($message = WPSearch_Utility::getWPSearchMessage()) {
        echo $message;
    }
    ?>
          <h3>Your Search Can Be Even Better</h3>
          <p>
              <strong>
                  You're using WPSearch Free, the second-best Wordpress
                  search plugin of all time!
              </strong>
          </p>
          <p>
              When your site grows to the point where WPSearch Free starts to
              get a little winded, be sure to check out
              <a href="#">WPSearch Premium</a>, which will handle up to 500,000
              published posts with amazing speed. It's a must for any
Esempio n. 3
0
 private function _doesSearchCategories()
 {
     return WPSearch_Utility::getOption(WPSearch_Core::KEY_SEARCH_CATEGORIES) == 'true';
 }
Esempio n. 4
0
 /**
  * The callback that is executed when the user is loading the admin page.
  *  Basically, output the page content for the admin page. The function
  *  acts just like a controller method for and MVC app. That is, it loads
  *  a view.
  */
 public function adminMenuCallback()
 {
     WPSearch_Log::add('debug', "Admin page callback executed");
     WPSearch_Utility::sendInstallReportIfNew();
     $stats = WPSearch_Search::instance()->getStats();
     $about = WPSearch_Search::instance()->getAbout();
     $errors = WPSearch_Search::instance()->runTests();
     $search_types = unserialize(WPSearch_Utility::getOption(self::KEY_SEARCH_TYPES, FALSE));
     $search_types = $search_types !== FALSE ? $search_types : self::$_defaultSearchTypes;
     $data = array();
     if ($about) {
         $data['is_alive'] = true;
         $data['total_docs'] = $stats->total;
         $data['indexed_docs'] = $stats->current;
         $data['is_building'] = $stats->reindexing;
         $data['last_reindex'] = $stats->last_rebuild;
         $data['about'] = $about;
         $data['errors'] = $errors;
         $data['searched_types'] = $search_types;
         $data['post_types'] = get_post_types();
         $data['index_comments'] = WPSearch_Utility::getOption(self::KEY_INDEX_COMMENTS) == 'true';
         $data['index_categories'] = WPSearch_Utility::getOption(self::KEY_INDEX_CATEGORIES) == 'true';
         $data['indexed_comments'] = WPSearch_Utility::getOption(self::KEY_INDEXED_COMMENTS) == 'true';
         $data['indexed_categories'] = WPSearch_Utility::getOption(self::KEY_INDEXED_CATEGORIES) == 'true';
         $data['title_boost'] = WPSearch_Utility::getOption(self::KEY_TITLE_BOOST, self::DEFAULT_TITLE_BOOST);
         $data['content_boost'] = WPSearch_Utility::getOption(self::KEY_CONTENT_BOOST, self::DEFAULT_CONTENT_BOOST);
         $data['service_tag'] = WPSearch_Utility::getServiceTag();
     } else {
         $data['is_alive'] = false;
         $data['error_message'] = 'The backend WPSearch Driver is not responding.';
     }
     WPSearch_View::load('admin', $data);
 }