Get started with PHP-Fusion

Start a New Thread

Users Participated

  • Falk
    Post made: 3
  • Craig
    Post made: 2
  • Chan
    Post made: 3

  1. PHP-Fusion Support Forums
  2. Development & Design
  3. Roadmap

Search API

[Development Team Access] All Roadmap items end up here for discussions.

7 Replies 4,104 Views Last Updated on 3 years ago

Falk


Super Admin

#1

Posted 3 years ago

The new API will rely on database settings.
The API need to be able to define searchable sections and default sections in the default site search functions.

It needs to at least have the following fields

1, Name of the application
2, Fields to search. Array with ,separator.
3, Link to the application landing page when you click on results. (infusions/eshop/eshop.php?product="$searchresults['id'].")

We need to add a small note to Infusion SDK how to insert this to the database upon Infusing something that could need a search function.


The current search page will also be replaced with a new template.

Go to roadmap item #1468
Edited by Falk on 14-01-2014 17:27
Need help?, Having trouble?
View our Documentation for Guides, Standards and Functions
Name and Organize your content correctly in the corresponding Forums for best support results
Attaching Log Files and Screenshots when reporting issues will help
Please read and comply with the Code of Conduct

(`._.(`._.*[ Project Manager ]*._.)._.)

Posts: 3725

Joined: 27/09/2005

Chan


Super Admin

#2

Posted 3 years ago

Great post Domi. Accepted gladly.
Lead Developer of PHP-Fusion
Developer Tweet: https://twitter.com/phpfusion_tweetsion_tweet

Posts: 3384

Joined: 25/09/2007

Chan


Super Admin

#3

Posted 3 years ago

We'll follow the v7 method which Robert had excellently done. I managed to port it into my work within an hour and half. His work is extensible and clearly thought out.

I'm enthralled.

What I propose to do for v8 is to extend its search into a designated folder in infusion rather than asking user to deliver it into includes/ folder. With addition of following lines in Robert's search codes..
This was v7..
Code Gist: Download source  


$dh = opendir(INCLUDES."search");
while (false !== ($entry = readdir($dh))) {
   if ($entry != "." && $entry != ".." && preg_match("/include_button.php/i", $entry)) {
      $available[] = str_replace("search_", "", str_replace("_include_button.php", "", $entry));
   }
}
closedir($dh);
$available[] = "all";


Now before $available[] = 'all'; what we can do is.. insert our v8 extensions in.

Code Gist: Download source  



$result = dbquery("SELECT * FROM ".DB_INFUSION.");
while ($data = dbarray($result)) {
$path = $data['inf_folder'];
$dh = opendir($path"/search");
while (false !== ($entry = readdir($dh))) {
   if ($entry != "." && $entry != ".." && preg_match("/include_button.php/i", $entry)) {
      $available[] = str_replace("search_", "", str_replace("_include_button.php", "", $entry));
   }
}
closedir($dh);

}


Now, all infusions/search/sdk_files.. will be extended into a global unified search engine.

With the approach I'll show on Atom-X how to bring up a global search (either thru modal or slider), every page can run searches to which we can max out our UX scores. (User Experience Score Index).

The rest is to complement with a SDK for infusions, to extend a DB_INFUSION search which will pair it to the corresponding file.

I proposed here, the drop of using SQL and go with extending Wooya's good work.
Lead Developer of PHP-Fusion
Developer Tweet: https://twitter.com/phpfusion_tweetsion_tweet

Posts: 3384

Joined: 25/09/2007

Falk


Super Admin

#4

Posted 3 years ago

Good
Need help?, Having trouble?
View our Documentation for Guides, Standards and Functions
Name and Organize your content correctly in the corresponding Forums for best support results
Attaching Log Files and Screenshots when reporting issues will help
Please read and comply with the Code of Conduct

(`._.(`._.*[ Project Manager ]*._.)._.)

Posts: 3725

Joined: 27/09/2005

Craig


Moderator

#5

Posted 3 years ago

Hi,

Using the search we have now an extend it is a good idea hien. Also to consider though...

1. It will need to check what infusions are installed. (Articles, News, etc). Now it is no so easy for non coders to remove search sections like news articles search etc.

2. It must be easy to work with 3rd party infusions, infusion developers needing to use search in their infusions should get shown a basic search api kit for developing to use the maincore search api.

Thats All, I'm sure you know what your doing anyway.

Regards

Posts: 4531

Joined: 27/09/2005

Falk


Super Admin

#6

Posted 3 years ago

It was actually made as modular by Wooya some time ago.
You can just delete the two control files in /includes/search/
Or add new ones, based on the other examples.
Hien will refine this some and we will clarify the API, since it have been
totally neglected.
Need help?, Having trouble?
View our Documentation for Guides, Standards and Functions
Name and Organize your content correctly in the corresponding Forums for best support results
Attaching Log Files and Screenshots when reporting issues will help
Please read and comply with the Code of Conduct

(`._.(`._.*[ Project Manager ]*._.)._.)

Posts: 3725

Joined: 27/09/2005

Craig


Moderator

#7

Posts: 4531

Joined: 27/09/2005

Chan


Super Admin

#8

Posted 3 years ago

The documentation of it is scarce. But fellow developers please check your /includes/search/ folders. The search API was done as good as BBcode was back in the 1950s..

I'll take liberty to document my findings after research.

Wooya did few functions - those are 'shortcuts' api, hence was not written. You can see what they do by looking into the functions.

search_querylike('article_name');
This generates ... "AND article_name LIKE [global %q]"

So, we need to prepare the API with these..


$a = search_querylike("a"); // search column a LIKE $q
$b = search_querylike("b"); // search column b LIKE $q
$c = search_querylike("c");
$d = search_querylike("d");


Now you have this..

Code Gist: Download source  

$fieldsvar = search_fieldsvar($a, $b, $c, $d);


When I print it, it showed me result:

Code Gist: Download source  

(a LIKE '%q%' || b LIKE '%q%' || c LIKE '%q%' || d LIKE '%q%')


Then, what Wooya did was:

Code Gist: Download source  


        if ($fieldsvar) {
            require_once INFUSIONS."addondb/infusion_db.php";
            require_once TEMPLATE."addon.tpl.php";
            // security check
            $result = dbquery(
                "SELECT a.*,b.*
                FROM ".X." a WHERE ".groupaccess('b.access')." AND ".$fieldsvar."  ".($_GET['datelimit'] != 0 ? " AND a.addon_date >=".(time() - $_GET['datelimit']):"")
            );
            $rows = dbrows($result);
        } else {
            $rows = 0;
        }


That will produce your result.

This is all done in search_xyz_include.php - the output page

You need to parse the whole result into a $search_result string which search.php is made to :

echo $search_result; by default.

There are 2 files to do for a custom search.
1. search_whatever_include.php
2. search_whatever_include_button.php

---

The form on 7 global search is using $_GET instead of $_POST.
This is because Wooya wanted to use JS to disable buttons and enable features.

They are in a $form_element string which is declared on search_xyz_include_button.php

What happen was when the user click "search Member" radio button, certain things like "order by", "limit" selector becomes disabled by JS. How it actually worked was to disable them by "ID".

To explain things.. what happen with that is:

Code Gist: Download source  


$(#this_button).bind('clicked', function(data) {
  //var id = "declared by search_addons_include_button.php"; 
  // and attr.('disabled', 'disabled');
});


Each checkbox, fields set has it's own ID and pre-named by Wooya.

This is the document I prepared..

Code Gist: Download source  


if (!defined("IN_FUSION")) { die("Access Denied"); }

    /* To enable or disable choices */
    /*
        // field1 = title and message field [radio]
        // field2 = only message field [radio]
        // field3 = only title. field [radio]
        // order1 = desc field [radio]
        // order2 = ascending field [radio]
        // datelimit = dropdown on date field [radio]
        // sort = sorting field [radio]
        // chars = characters field  [radio]
    */

    $form_elements['addons']['enabled'] = array("datelimit", "fields1",     "fields2", "fields3", "sort", "order1", "order2");
    $form_elements['addons']['disabled'] = array('chars');
    $form_elements['addons']['display'] = array();
    $form_elements['addons']['nodisplay'] = array();

    $radio_button['addons'] = "
<label><input type='radio' name='stype' value='addons'".($_GET['stype'] == "addons" ? " checked='checked'" : "")." onclick=\"display(this.value)\" />
Your Label name goes here...
</label>";



I.e. when you check $radio_button, the $form_element will display/nodisplay/disabled/active. This has nothing to do with the result searching.

What we can do in 8, is to increase the capabilities. Usually I do not change methods, but since the search form is searching only.... We gotta follow it back to be backwards compatible. Since it was not documented in the first place, I am betting that nobody has a custom mod on it.

So, we can change our methods and rewrite the syntax to a single line function to do them both files.

function search( parameters ) {
- to disable buttons
- to enable buttons
- to hide fields
- to show fields
- to readonly fields
- to output search result.
- to read which field to search , and use what kind of operand.
a. X LIKE, X > , X < , X =
- to stitch.
}


1 function to make, and let everyone adapt to. Place the function into same search_XYZ_include.php file, Done deal.
Lead Developer of PHP-Fusion
Developer Tweet: https://twitter.com/phpfusion_tweetsion_tweet

Posts: 3384

Joined: 25/09/2007

Jump to Forum:
5 users are online
0 member and 5 guests