'type' => 'text',
'required' => true,
'use' => 'a'
+ ),
+
+ // Flag to show/exclude home page from search results
+ 'exclude_home_page' => array(
+ 'field' => 'exclude_home_page',
+ 'type' => 'checkbox',
+ 'default' => false,
+ 'use' => 'a'
+ ),
+
+ // Number of rows per result page (default)
+ 'numb_rows' => array (
+ 'field' => 'numb_rows',
+ 'type' => 'integer',
+ 'required' => true,
+ 'use' => 'a'
)
+
);
}
* @access public\r
*/\r
public $filter = true;\r
+ /**\r
+ * Show home page content flag\r
+ *\r
+ * @var $exclude_home_page\r
+ * @access public\r
+ */\r
+ public $exclude_home_page = true;\r
/**\r
* Host Filter Type\r
*\r
* @return void\r
* @access public\r
*/\r
- public function __construct($index, $website, $login, $key, $filterType = false, $filterValue = false)\r
+ public function __construct($index, $website, $login, $key, $exclude_home_page, $filterType = false, $filterValue = false)\r
{\r
\r
// If there's a problem with Filter and validate supplied parameters\r
// Store supplied parameters\r
$this->index = $index;\r
$this->website = $website;\r
+ $this->exclude_home_page = $exclude_home_page;\r
\r
// Build authentication parameters for submissions\r
$this->auth = "login=$login&key=$key";\r
)\r
);\r
\r
+ // Check if we're supposed to exclude the home page contents\r
+ if ($this->exclude_home_page) {\r
+ $this->request['filters'][] = array(\r
+ "type" => "QueryFilter",\r
+ "negative" => true,\r
+ "query" => 'url:"http://'.$this->website.'/"'\r
+ );\r
+ }\r
+\r
} else {\r
unset($this->request['filters']);\r
}\r
* version from this plugin.
*/
define('GLM_MEMBERS_SEARCH_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_SEARCH_PLUGIN_DB_VERSION', '0.0.1');
+define('GLM_MEMBERS_SEARCH_PLUGIN_DB_VERSION', '0.0.3');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
define('GLM_MEMBERS_SEARCH_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.1.9');
$website = $this->config['settings']['website'];
$login = $this->config['settings']['login'];
$key = $this->config['settings']['login_key'];
+ $exclude_home_page = $this->config['settings']['exclude_home_page'];
// Run constructor for members data class
- parent::__construct($index, $website, $login, $key);
+ parent::__construct($index, $website, $login, $key, $exclude_home_page);
}
public function modelAction ($actionData = false)
{
+ $haveSearchRequest = false;
$haveSearchResult = false;
$status = true;
$query = false;
+ $start = 0;
+ $rows = $this->config['settings']['numb_rows'];
$searchResult = array(
'operator' => 'AND'
);
-
/*
* Get input from form
*/
if (isset($_REQUEST['query'])) {
+ $haveSearchRequest = true;
+
+ // Assemble requested query
$query = $_REQUEST['query'];
$operator = 'OR';
if (isset($_REQUEST['matchAll']) && $_REQUEST['matchAll'] == 'on') {
$operator = 'AND';
}
- $start = $_REQUEST['start'];
- $rows = $_REQUEST['rows'];
+ // Set pagination - Note that form may override the number of rows.
+ if (isset($_REQUEST['start'])) {
+ $start = $_REQUEST['start'];
+ }
+ if (isset($_REQUEST['rows'])) {
+ $rows = $_REQUEST['rows'];
+ }
+ // Send request to OpenSearchServer and get results
if (trim($query) != '') {
$searchResult = $this->glmSearch($query, $operator, $start, $rows);
if (is_array($searchResult) && isset($searchResult['totalResults']) && $searchResult['totalResults'] > 0 ) {
// Compile template data
$templateData = array(
+ 'haveSearchRequest' => $haveSearchRequest,
'haveSearchResult' => $haveSearchResult,
'searchResult' => $searchResult,
'query' => $query
+++ /dev/null
--- Gaslight Media Members Database - Search
--- File Created: 12/02/15 15:27:15
--- Database Version: 0.0.1
--- Database Creation Script
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
--- Search Management Settings
-CREATE TABLE {prefix}management (
- id INT NOT NULL AUTO_INCREMENT,
- search_index TINYTEXT NULL, -- OSS Search Index to use (normally "Index_1")
- website TINYTEXT NULL, -- Hostname for the Website
- login TINYTEXT NULL, -- OSS API Login
- login_key TINYTEXT NULL, -- OSS API Login Key
- PRIMARY KEY (id)
-);
-
-----
-
--- Set default package management entry
-INSERT INTO {prefix}management
- ( id, search_index, website, login, login_key )
- VALUES
- ( 1, 'Index_1', 'www.gaslightmedia.com', 'WebsiteServices', '829800701e8440b67a78e3afbefa1049' )
-;
-
--- /dev/null
+-- Gaslight Media Members Database - Search
+-- File Created: 12/02/15 15:27:15
+-- Database Version: 0.0.1
+-- Database Creation Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Search Management Settings
+CREATE TABLE {prefix}management (
+ id INT NOT NULL AUTO_INCREMENT,
+ search_index TINYTEXT NULL, -- OSS Search Index to use (normally "Index_1")
+ website TINYTEXT NULL, -- Hostname for the Website
+ exclude_home_page BOOLEAN NULL, -- Flag to say whether to exclude home page from search results
+ numb_rows SMALLINT NULL, -- Number of rows to show per page in results
+ login TINYTEXT NULL, -- OSS API Login
+ login_key TINYTEXT NULL, -- OSS API Login Key
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Set default package management entry
+INSERT INTO {prefix}management
+ ( id, search_index, website, exclude_home_page, numb_rows, login, login_key )
+ VALUES
+ ( 1, 'Index_1', 'www.gaslightmedia.com', true, 20, 'WebsiteServices', '829800701e8440b67a78e3afbefa1049' )
+;
+
*/
$glmMembersSearchDbVersions = array(
- '0.0.1' => array('version' => '0.0.1', 'tables' => 1)
+ '0.0.1' => array('version' => '0.0.1', 'tables' => 1, 'date' => '6/20/16'),
+ '0.0.2' => array('version' => '0.0.2', 'tables' => 1, 'date' => '7/5/16'),
+ '0.0.3' => array('version' => '0.0.3', 'tables' => 1, 'date' => '7/7/16')
);
--- /dev/null
+-- Gaslight Media Members Database
+-- File Created: 7/5/16 15:27:15
+-- Database Version: 0.0.2
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+ALTER TABLE {prefix}management ADD COLUMN exclude_home_page BOOLEAN;
+
+
+
--- /dev/null
+-- Gaslight Media Members Database
+-- File Created: 7/5/16 15:27:15
+-- Database Version: 0.0.2
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+ALTER TABLE {prefix}management ADD COLUMN numb_rows SMALLINT;
+
+----
+
+UPDATE {prefix}management SET numb_rows = 20;
{if $searchSettings.fieldFail.login_key}<p>{$searchSettings.fieldFail.login_key}</p>{/if}
</td>
</tr>
+ <tr>
+ <th>Exclude Home Page Content<br>From Search Results:</th>
+ <td>
+ <input type="checkbox" name="exclude_home_page"{if $searchSettings.fieldData.exclude_home_page.value} checked="checked"{/if}>
+ </td>
+ </tr>
+ <tr>
+ <th>Default number of rows per result page:</th>
+ <td>
+ <input type="text" name="numb_rows" value="{$searchSettings.fieldData.numb_rows}" class="glm-form-text-input-veryshort">
+ </td>
+ </tr>
</table>
<input type="submit" value="Update Settings" class="button-primary">
</form>
-<div class="wrap">
+<div class="wrap opensearchserver.ignore">
<div id="glm-member-search-front-container" class="glm-member-front-container">
\ No newline at end of file
<form action="{$thisUrl}?glm_action=index" method="post" enctype="multipart/form-data">
Search for: <input type="hidden" name="GLMSearch" value="true">
- <input type="hidden" name="start" value="0">
- <input type="hidden" name="rows" value="10">
<input type="text" name="query" value="{$query}">
<input type="checkbox" name="matchAll" {if $searchResult.operator == 'AND'}checked{/if} value="on"> Match all words
<input type="submit" id="submit" value="Search">
</form>
-{if $haveSearchResult}
+{if $haveSearchRequest}
- {if $searchResult.totalResults > 0}
+ {if $haveSearchResult}
<!-- Results Header - Top -->
{else}
- <h3>No results matching your search.</h3>
+ <h4>No results matching your search.</h4>
{/if}
{else}