Skip to content

Commit

Permalink
update with latest changes from ODB (1.35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Kühn committed Apr 26, 2024
1 parent 663fbe6 commit 5d0ced7
Show file tree
Hide file tree
Showing 22 changed files with 679 additions and 265 deletions.
10 changes: 6 additions & 4 deletions DefaultSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ function ($query, $userGroups, $userName) {
$fsgDateTimePropertyClusters = [];

/**
* User configurable category drop-down
* User configurable category drop-down of the form ["label" => "Category"].
* The first entry determines the default.
* The entry with an empty key '' represents "no selected category filter".
*/
global $fsgCategoryFilter;
$fsgCategoryFilter = [];
Expand Down Expand Up @@ -280,7 +282,7 @@ function ($query, $userGroups, $userName) {
$fsgIndexImageURL = false;

/**
* Pages of these namespaces are shown in the global search field (requires a patch)
* Properties which have custom content in the facet dialog
*/
global $fsgNamespacesForSearchField;
$fsgNamespacesForSearchField = [ NS_MAIN ];
global $fsgFacetsDialogWithCustomContent;
$fsgFacetsDialogWithCustomContent = [];
6 changes: 6 additions & 0 deletions EnhancedRetrieval.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use DIQA\FacetedSearch\FSGlobalFunctions;
use DIQA\FacetedSearch\Proxy\SolrProxy\ConfigLoader;
use DIQA\FacetedSearch\Specials\FSFacetedSearchSpecial;
use DIQA\FacetedSearch\UserPreference;

/*
* Copyright (C) Vulcan Inc., DIQA-Projektmanagement GmbH
Expand Down Expand Up @@ -47,7 +48,12 @@

global $wgHooks;
$wgHooks['ParserFirstCallInit'][] = 'DIQA\FacetedSearch\FSGlobalFunctions::initializeBeforeParserInit';
$wgHooks['BeforePageDisplay'][] = 'DIQA\FacetedSearch\FSGlobalFunctions::onBeforePageDisplay';
$wgHooks['fs_extendedFilters'][] = 'DIQA\FacetedSearch\FacetedCategoryFilter::addFilter';
$wgHooks['GetPreferences'][] = 'DIQA\FacetedSearch\UserPreference::setupPreferences';

global $wgDefaultUserOptions;
$wgDefaultUserOptions['er-sort-order-preferences'] = UserPreference::$defaultSortOrder;

global $wgAPIModules;
$wgAPIModules['fs_dialogapi'] = 'DIQA\FacetedSearch\Util\DialogAjaxAPI';
Expand Down
47 changes: 33 additions & 14 deletions maintenance/updateSOLR.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __construct()
parent::__construct();
$this->mDescription = "Updates SOLR index";
$this->addOption('v', 'Verbose mode', false, false);
$this->addOption('g', 'Get the maximum ID of pages that would be updated (all other parameters are ignored if this is present)', false, false);
$this->addOption('d', 'Delay every 100 pages (miliseconds)', false, true);
$this->addOption('x', 'Debug mode', false, false);
$this->addOption('p', 'Page title(s), separated by ","', false, true);
Expand All @@ -32,6 +33,16 @@ public function __construct()

public function execute()
{
if( !defined( 'ER_EXTENSION_VERSION' ) ) {
echo("ERROR: The enhanced retrievel extension is not properly installed or configured.\n");
die(1);
}

if( $this->hasOption('g') ) {
$max = $this->getMaxId();
print "$max\n";
return;
}

// when indexing everything, dependent pages do not need special treatment
global $fsUpdateOnlyCurrentArticle;
Expand Down Expand Up @@ -192,31 +203,39 @@ private function getStartId()
*/
private function getEndId($start)
{
if ($this->hasOption('e')) { // Note: this might reasonably be larger than the page count
if ($this->hasOption('e')) {
// Note: this might reasonably be larger than the page count
$end = intval($this->getOption('e'));

} elseif ($this->hasOption('n')) {
$end = $start + intval($this->getOption('n'));

} elseif ($this->hasOption('f')) {
$title = Title::newFromText($this->getOption('f'));
$start = $title->getArticleID();
$end = $title->getArticleID();

} else {
$db = wfGetDB(DB_REPLICA);
$page_table = $db->tableName("page");
$query = "SELECT MAX(page_id) as maxid FROM $page_table";
$res = $db->query($query);
if ($db->numRows($res) > 0) {
while ($row = $db->fetchObject($res)) {
$end = $row->maxid;
}
if ($end == '') {
echo "\nThere are no pages. Nothing to do.\n";
die();
}
}
$end = $this->getMaxId();
}
return $end;
}

private function getMaxId() {
$db = wfGetDB(DB_REPLICA);
$page_table = $db->tableName("page");
$query = "SELECT MAX(page_id) as maxid FROM $page_table";
$res = $db->query($query);
if ($db->numRows($res) > 0) {
$row = $db->fetchObject($res);
if( $row ) {
return $row->maxid;
}
}
return 0;
}


}

$maintClass = "UpdateSolr";
Expand Down
35 changes: 19 additions & 16 deletions scripts/FacetedSearch/Enhancements/fs_categoryFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@ console.log("ER: Loading scripts/FacetedSearch/Enhancements/fs_categoryFilter.js
var CategoryFilter = function() {

var that = {};

that.init = function() {
$('select#fs_category_filter').change(that.onCategoryChange);

var searchstring = window.location.href.substring(window.location.href.indexOf('?') + 1);
searchstring = decodeURIComponent(searchstring);
var regex = new RegExp('smwh_categories:([^&]*)');
var result = regex.exec(searchstring);
if (result == null) {
return;
}
// mark the category from the URI as selected in the drop down menu
$('select#fs_category_filter option[value="'+result[1]+'"]').prop('selected', true);
};


that.onCategoryChange = function(event) {
var category = $('select#fs_category_filter option:selected').val();
that.selectCategory(category);
Expand All @@ -36,7 +22,24 @@ console.log("ER: Loading scripts/FacetedSearch/Enhancements/fs_categoryFilter.js

fsm.doRequest(0);
};


that.init = function() {
$('select#fs_category_filter').change(that.onCategoryChange);

var searchstring = window.location.href.substring(window.location.href.indexOf('?') + 1);
searchstring = decodeURIComponent(searchstring);
var regex = new RegExp('smwh_categories:([^&]*)');
var result = regex.exec(searchstring);

if (result == null) {
$('select#fs_category_filter option').first().prop('selected', true);
} else {
// mark the category from the URI as selected in the drop down menu
$('select#fs_category_filter option[value="'+result[1]+'"]').prop('selected', true);
}

};

return that;
};

Expand Down
Loading

0 comments on commit 5d0ced7

Please sign in to comment.