3 | Posts |
I want to the search into special link html output.
Out of the box plugin output was not include into the gpeasy search function.
I've play arround with the search hook:
;Addon_Name
Addon_Name = 'Test'
;Addon_Unique_ID
Addon_Unique_ID = 676
;Addon_Version
Addon_Version = 0.4
;min_gpeasy_version
min_gpeasy_version = 1.5RC2
;A description about your addon,
; may contain some html: <div>,<p>,<a>,<b>,<br/>,<span>,<tt>,<em>,<i>,<b>,<sup>,<sub>,<strong>,<u>
About = 'Test';
[Special_Link:ELMA diag system]
label = 'System diag'
script = 'system.php'
;class = 'Configuration'
[Special_Link:ELMA diag rsyslog]
label = 'rsyslog diag'
script = 'rsyslog.php'
;class = 'Configuration'
[Search]
script = 'Search.php'
class = 'DiagSearch'
My tries with search.php:
<?php defined('is_running') or die('Not an entry point...');
class DiagSearch{
function DiagSearch($args){
$search_obj = $args[0];
$PluginFile = '/srv/www/htdocs/elma/addons/ELMA Diagnostics/system.php';
$diagtitle = "Diagnostics";
$diaglink="ELMA_diag_system";
$diaglabel = common::GetLabel($diagtitle);
include($PluginFile);
$diagcontent = ob_get_clean();
$search_obj->FindString($diagcontent, $diaglabel, $diaglink);
}
}
?>
This finds the search pattern, but in case of not matching search pattern it is also in hit list.
Is there a more dynamic way to address all defined special link inside a plugin?
Any help would be fine.
Joerg
263 | Posts |
20.6K | Downloads |
1 | Themes |
8 | Plugins |
$diagcontent = ob_get_clean();
Now $diagcontent contains the gpEasy buffer content which itself contains the html code echo-ed by the special_gpsearch::Search() method including the search string.
This explains why your content is always returned in the search results whether it matches the search pattern or not.
I don't know what is the content of your system.php file but assuming it echo-es your plugin html content, adding an ob_start(); instruction just before the include should do the trick.
ob_start();
include($PluginFile);
$diagcontent = ob_get_clean();
3 | Posts |
This procedure works fine if in plugin code is no class defined.
But if there are classes the content value becomes empty.
I've tested with Plugins_Examples:
;Map Example
[Special_Link:Example_Map]
label = 'Example_Map'
script = '01_Map.php'
class = 'Example_Map'
;Ajax Example
[Special_Link:Example_Ajax]
label = 'Example_Ajax'
script = '02_Ajax.php'
class = 'Example_Ajax'
[Search]
script = 'Search.php'
class = 'Example_Search'
<?php
defined('is_running') or die('Not an entry point...');
class Example_Search {
function PluginSearchContent($File){
if( file_exists($File) ){
echo $File."<br>";
ob_start();
include($File);
$Content = ob_get_clean();
}
return $Content;
}
function Example_Search($args){
global $addonPathCode;
$search_obj = $args[0];
$Label = "Example_Map";
$Link="Example_Map";
$File = $addonPathCode.'/01_Map.php';
$search_obj->FindString($this->PluginSearchContent($File), $Label, $Link);
$Label = "Example_Ajax";
$Link="Example_Ajax";
$File = $addonPathCode.'/02_Ajax.php';
$search_obj->FindString($this->PluginSearchContent($File), $Label, $Link);
}
}
?>
263 | Posts |
20.6K | Downloads |
1 | Themes |
8 | Plugins |
A new release for Typesetter is in the works with a lot of improvements including the ... Read More
Typesetter 5.1Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More
More NewsFind out more about our Provider Spotlight
What CMS: Find out what CMS a site is using.
Who Hosts This: Find out who is hosting any web site
WordPress Theme Detect: Find out which theme a WordPress site is using