Skip to content

Instantly share code, notes, and snippets.

@dave1010
Created January 31, 2009 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave1010/55510 to your computer and use it in GitHub Desktop.
Save dave1010/55510 to your computer and use it in GitHub Desktop.
/*
TODO:
match beginnings of function names
say if no functions found
if > 1 function result, have a list of them
option to show more details of function?
get it working with gotapi.com and all languages it supports
*/
CmdUtils.CreateCommand({
name: "search-php",
homepage: "http://createopen.com/blog/",
author: { name: "David Hulbert", email: "dave1010+ubiquity@gmail.com"},
icon: "http://static.php.net/www.php.net/favicon.ico",
license: "MPL",
takes: {"function": noun_arb_text},
description: "Searches PHP for a function.",
help: "Searches PHP for a function and previews the description. Example: 'search-php strpos'",
preview: function(pblock, term) {
if (term.text) {
pblock.innerHTML = "Searching PHP.net...";
var url = "http://php.net/{QUERY}";
var query = term.text;
var urlString = url.replace("{QUERY}", query);
jQuery.get(urlString, {}, function(d){
if( d.length > 0 ) {
var desc = jQuery(".description", d).html();
var title = jQuery(".refpurpose", d).html();
}
if (title.length || desc.length) {
pblock.innerHTML = title + desc;
} else {
pblock.innerHTML = 'No match found';
}
});
} else {
pblock.innerHTML = "Search PHP for a function"
}
},
execute: function(functionname) {
var url = "http://php.net/{QUERY}"
var query = functionname.text;
var urlString = url.replace("{QUERY}", query);
Utils.openUrlInBrowser(urlString);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment