Skip to content

idies/SQLSearchWP-Casjobs

Repository files navigation

SQLSearchWP-Casjobs

Overview

SQLSearchWP-Casjobs is a WordPress plugin that when implemented on a page displays a form for querying the SDSS astronomy database. The form contains three main sections: Instructions, the search form itself, and Results.

Instructions

The Instructions block displays first on the page and contains text directions for navigting the rest of the form. This section can be disabled if necessary (see Installation and Implementation).

Search Form

The search form occurs after instructions on the left side of the page. It contains a text box to hold the SQL code the user wishes to submit and four colored buttons.

Unlock allows the user to edit the text box, which is disabled by default. Unlocking the text box will change the Unlock button to Lock, which when pressed re-locks the text box. The lock status of the text box is indicated by an image of a lock that will appear right above the text box when locked.

Check Syntax performs a check for proper syntax for any SQL code currently in the text box. The results of the syntax check will appear in the Results section of the form.

Submit processes any SQL code currently in the text box and queries the SDSS database. The results of the query are displayed in the Results section of the form. In addition, checking the Open in New Tab checkbox will also display any results in a new tab. Note: submitting incorrect SQL code could result in errors. Always use the Check Syntax feature to ensure correctness. Additional Note: Line breaks within a long query can be done using a HTML carriage return (
) followed by a line feed (
). These entities will be ignored when the query is processed and thus will have no effect on query results. Example: select top 20 spa.ra, spa.dec, spa.dered_r as magnitude
from specphotoAll as spa

Reset clears the Results section of the form. It does not affect anything else on the page, including the text box.

Results

The Results section occurs after Instructions to the right of the page. The results of running Check Syntax or Submit are displayed here. When no results are present, the message "Results Empty! Check Syntax or Submit to get results" displays. After displaying results from a Submit, a Download button will appear underneath the results table. Clicking this will download the results table as a .csv file named "results.csv".

Installation and Implementation

To install SQLSearchWP-Casjobs on a WordPress site, download the zip file of SQLSearchWP-Casjobs and extract it. Then, copy the entire folder into the wp-content/plugins directory for your site. SQlSearchWP-Casjobs should now be available under "Plugins" in the wp-admin dashboard. Click "activate" to enable the plugin on your site.

Once installed, SQLSearchWP-Casjobs can be implemented on a page using the following shortcode: [sqlsearchwp-casjobs]. However, there are some required and optional parameters for this shortcode.

num (required): This serves as the unique identifier for a certain form. As such, each form on a page must have a unique value for this parameter. Additionally, they must start at 0 and count up from there. For example, three forms on the same page would look like: [sqlsearchwp-casjobs num="0"] [sqlsearchwp-casjobs num="1"] [sqlsearchwp-casjobs num="2"].

default (optional): This serves as the default text to be displayed in the text box within the search form. For example, [sqlsearchwp-casjobs num="0" default="select top 10 * from photoObj"]. There is a built in default query if this parameter is not utilized in the shortcode.

color (optional): This dictates the color of the text within the search form text box. Any HTML supported color will work. For example, [sqlsearchwp-casjobs num="0" color="red"]. The default text color is black if this parameter is not utilized in the shortcode.

instructions (optional): This says whether to display the Instructions section. Setting this parameter to "show" will display it, while setting it to "hide" will not display it. For example, [sqlsearchwp-casjobs num="0" instructions="hide"]. The default value is "show" if this parameter is not utilized in the shortcode.

Example: [sqlsearchwp-casjobs num="0" instructions="hide"] [sqlsearchwp-casjobs num="1" color="green" instructions="show"] [sqlsearchwp-casjobs num="2" color="red" default="select top 10 * from photoObj"]