Skip to content

Commit

Permalink
Removed Unused Search API from pre Geeklog 1.5.1
Browse files Browse the repository at this point in the history
For improvement #1042
  • Loading branch information
eSilverStrike committed Jan 14, 2022
1 parent 51aabc6 commit 97294de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 61 deletions.
6 changes: 5 additions & 1 deletion public_html/docs/history
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ Explanation of list item:

For more in-depth explanation of the issues below see: https://github.com/Geeklog-Core/geeklog/milestone/48?closed=1

-
- [Improvement] [#1042] Removed support for old Search API (pre Geeklog 1.5.1) [Tom]
-
-
-

The following items are all current Geeklog API, functions, and/or global variables that are planned to be either required or depreciated by a current Geeklog version. Plugin and Theme developers please take note of these changes in case they affect you.

Since Geeklog v2.2.2

- [Depreciated] [#1042] By Geeklog 2.2.2 - Search now requires use of Search API 2

Since Geeklog v2.2.1sr1

- [Depreciated] [#1052] By Geeklog 3.0.0 - Article should not depend on hardcoded file locations for print.css for a theme. Use PLG_getThemeItem('core-file-print-css', 'core'); instead
Expand Down
61 changes: 1 addition & 60 deletions system/classes/search.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ public function setDebug($switch)
* search API. Backwards compatibility has been incorporated
* in this function to allow legacy support to plugins using
* the old API calls defined versions prior to Geeklog 1.5.1
* AS of Geeklog 2.2.2 Search API 2 required (which was introduced in Geeklog 1.5.1)
*
* @return string HTML output for search results
*/
Expand Down Expand Up @@ -486,8 +487,6 @@ public function doSearch()
);

// Loop through all plugins separating the new API from the old
$new_api = 0;
$old_api = 0;
$num_results = 0;

foreach ($result_plugins as $result) {
Expand All @@ -496,7 +495,6 @@ public function doSearch()

if ($this->_type !== 'all' && $this->_type != $result->getName()) {
if ($this->debug) {
$new_api++;
COM_errorLog($debug_info . '. Skipped as type is not ' . $this->_type);
}
continue;
Expand Down Expand Up @@ -527,68 +525,11 @@ public function doSearch()
$this->_append_query[$result->getName()] = $result->isAppendQuery();

if ($this->debug) {
$new_api++;
COM_errorLog($debug_info);
}
} elseif (is_a($result, 'Plugin') && $result->num_searchresults != 0) {
// Some backwards compatibility
if ($this->debug) {
$old_api++;
$debug_info = $result->plugin_name . ' using APIv1 with backwards compatibility.';
$debug_info .= ' Count: ' . $result->num_searchresults;
$debug_info .= ' Headings: ' . implode(',', $result->searchheading);
COM_errorLog($debug_info);
}

// Find the column heading names that closely match what we are looking for
// There may be issues here on different languages, but this _should_ capture most of the data
$col_title = $this->_findColumn($result->searchheading, array($LANG09[16], $LANG31[4], 'Question', 'Site Page'));//Title,Subject
$col_desc = $this->_findColumn($result->searchheading, array($LANG09[63], 'Answer'));
$col_date = $this->_findColumn($result->searchheading, array($LANG09[17]));//'Date','Date Added','Last Updated','Date & Time'
$col_user = $this->_findColumn($result->searchheading, array($LANG09[18], 'Submited by'));
$col_hits = $this->_findColumn($result->searchheading, array($LANG09[50], $LANG09[23], 'Downloads', 'Clicks'));//'Hits','Views'

$label = str_replace($LANG09[59], '', $result->searchlabel);
$num_results += $result->num_itemssearched;

// Extract the results
for ($i = 0; $i < 5; $i++) {
// If the plugin does not respect the $perpage parameter, then force it here.
$j = ($i + ($page * 5)) - 5;
if ($j >= count($result->searchresults)) {
break;
}

$old_row = $result->searchresults[$j];
if ($col_date != -1) {
// Convert the date back to a timestamp
$date = $old_row[$col_date];
$date = substr($date, 0, strpos($date, '@'));
$date = ($date == '' ? $old_row[$col_date] : strtotime($date));
}

$api_results = array(
LF_SOURCE_NAME => $result->plugin_name,
LF_SOURCE_TITLE => $label,
'title' => $col_title == -1 ? '<i>' . $LANG09[70] . '</i>' : $old_row[$col_title],
'description' => $col_desc == -1 ? '<i>' . $LANG09[70] . '</i>' : $old_row[$col_desc],
'date' => $col_date == -1 ? '&nbsp;' : $date,
'uid' => $col_user == -1 ? '&nbsp;' : $old_row[$col_user],
'hits' => $col_hits == -1 ? '0' : str_replace(',', '', $old_row[$col_hits]),
);
preg_match('/href="([^"]+)"/i', $api_results['title'], $links);
$api_results['url'] = empty($links) ? '#' : $links[1];

$obj->addResult($api_results);
}
}
}

// Find out how many plugins are on the old/new system
if ($this->debug) {
COM_errorLog('Search Plugins using APIv1: ' . $old_api . ' APIv2: ' . $new_api);
}

// Execute the queries
$results = $obj->ExecuteQueries();

Expand Down

0 comments on commit 97294de

Please sign in to comment.