diff --git a/core/Format SQL.spBundle/command.plist b/core/Format SQL.spBundle/command.plist index 13e8614..7762b76 100644 --- a/core/Format SQL.spBundle/command.plist +++ b/core/Format SQL.spBundle/command.plist @@ -2,36 +2,36 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>author</key> - <string>Hans-Jörg Bibiko</string> - <key>category</key> - <string>Format</string> - <key>command</key> - <string> + <key>author</key> + <string>Hans-Jörg Bibiko</string> + <key>category</key> + <string>Format</string> + <key>command</key> + <string> # check for empty STDIN SQL=$(cat) if [ -z "$SQL" ]; then - echo "No SQL statements passed." - exit $SP_BUNDLE_EXIT_SHOW_AS_TEXT_TOOLTIP + echo "No SQL statements passed." + exit $SP_BUNDLE_EXIT_SHOW_AS_TEXT_TOOLTIP fi # check if connected to the internet and if server is up connected=$(/sbin/ping -t 8 -c 1 -on www.dpriver.com 2> /dev/null | grep '69\.5\.11\.169' | wc -l) if [ $connected -eq "0" ]; then - echo "<font color=red>You are probably not connected to the internet or http://www.dpriver.com/ server is down.</font>" - exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP + echo "<font color=red>You are probably not connected to the internet or http://www.dpriver.com/ server is down.</font>" + exit $SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP fi # show info alert about sending the SQL statements to an online service if [ ! -e infoShowed ]; then - touch infoShowed - osascript -e 'tell app "Sequel Pro" to display dialog "This command will send the SQL statement(s) - unencrypted - to an online service (http://www.dpriver.com). Please consider this before sending confidential data!\n\nThis message will only be displayed once." with icon caution' 2> 1 - if [ `cat 1 | wc -c` -ne 0 ]; then - rm -f 1 - exit $SP_BUNDLE_EXIT_NONE - fi - rm -f 1 + touch infoShowed + osascript -e 'tell app "Sequel Pro" to display dialog "This command will send the SQL statement(s) - unencrypted - to an online service (http://www.dpriver.com). Please consider this before sending confidential data!\n\nThis message will only be displayed once." with icon caution' 2> 1 + if [ `cat 1 | wc -c` -ne 0 ]; then + rm -f 1 + exit $SP_BUNDLE_EXIT_NONE + fi + rm -f 1 fi # send SQL to www.dpriver.com and replace the formatted SQL string in first responder; if a parser error occurred @@ -40,164 +40,339 @@ cat <<HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> - <base href="http://www.dpriver.com/pp/"> - <title>Connecting www.dpriver.com</title> - <script> - function lookForResult() { - if(document.all.outputsql.value.length > 8) { - if(document.all.errorhint.style.display == "inline") { - var errormes = document.all.outputsql.value; - var re = /.*?\(\d+\s*,\s*(\d+)\).*/; - re.exec(errormes); - var pos = parseInt(RegExp.\$1) - 1; - re = /.*?(\d+).*/; - re.exec('$SP_SELECTED_TEXT_RANGE'); - var offset = parseInt(RegExp.\$1); - pos = pos + offset; - alert(document.all.outputsql.value); - window.system.setSelectedTextRange(pos+''); - } else { - var txt = document.all.outputsql.value; - var len = txt.length; - window.system.setSelectedTextRange('$SP_SELECTED_TEXT_RANGE'); - window.system.insertText(txt.slice(0,len-2)); - } - window.system.closeHTMLOutputWindow(); - } else { - setTimeout("lookForResult()",50); - } - } - - function waitForResult() { - window.system.suppressExceptionAlert(); - setTimeout("lookForResult()",50); - } - </script> - <script language="JavaScript" type="text/javascript" src="pp.js"></script> + <base href="http://www.dpriver.com/pp/"> + <title>Connecting www.dpriver.com</title> + <script> + function lookForResult() { + if(document.all.outputsql.value.length > 8) { + if(document.all.errorhint.style.display == "inline") { + var errormes = document.all.outputsql.value; + var re = /.*?\(\d+\s*,\s*(\d+)\).*/; + re.exec(errormes); + var pos = parseInt(RegExp.\$1) - 1; + re = /.*?(\d+).*/; + re.exec('$SP_SELECTED_TEXT_RANGE'); + var offset = parseInt(RegExp.\$1); + pos = pos + offset; + alert(document.all.outputsql.value); + window.system.setSelectedTextRange(pos+''); + } else { + var txt = document.all.outputsql.value; + var len = txt.length; + window.system.setSelectedTextRange('$SP_SELECTED_TEXT_RANGE'); + window.system.insertText(txt.slice(0,len-2)); + } + window.system.closeHTMLOutputWindow(); + } else { + setTimeout("lookForResult()",50); + } + } + + function waitForResult() { + window.system.suppressExceptionAlert(); + setTimeout("lookForResult()",50); + } + </script> + <script language="JavaScript" type="text/javascript" src="pp.js"></script> </head> <body onload='window.resizeTo(300,200);SQLFMT.format(document.all.sp_submit);waitForResult()'> -<div id="retvalues"></div> -<p><b>Copyright &copy; 2001-2010 Gudu Software<br>All Rights Reserved<br><a href="mailto:support@dpriver.com">Contact US</a></b></p> -<br><br><br><br><br> -<p align=right>Please wait…</p> -<div class="page-container-1" style="display:none;"> - <div id="container"> - <div id="wrapper"> - <div id="content"> - <form id="SqlFmtForm" name="frm_sqlformat" method="post" action="/cgi-bin/ppserver" onsubmit="return false;"> - <div id="secondpanel"> - <div id="sp_database"> - <label class="desc" style="display:inline;">Database</label> - <select name="dbvendor"> - <option value="mysql" selected>MySQL</option> - </select> - <label class="desc" style="display:inline;padding:0 0 0px 40px; border:0px solid;">Output:</label> - <select name="outputfmt"> - <option value="SQL" selected>SQL(Text)</option> - </select> - </div> - </div> - <div id="sqlpanel"> - <div id="sp_inputsql"> - <textarea id ="inputsql" name="inputsql" cols="1" rows="1" wrap="off"> - $SQL - </textarea> - </div> - <div id="sp_submit"> - <input type="button" id="btnformat" name="print" value="Format SQL" onclick="SQLFMT.format(this)" value="Format SQL"> - <label style="display:none;">(Time used: <span id="timestamp">0</span> seconds)</label> - </div> - <div id="sp_submit" style="text-align:left;"> - </div> - <label id="errorhint" class="desc" style="color:#DF0000 !important;display:none;"> - Can't format input sql, make sure there is no syntax error and select correct database. - <a href="" style="display:none;">OR Report a bug of this sql beautifier</a> - </label> - <iframe id="ioutputsql" ></iframe> - <div id="sp_outputsql" style="display:none;"> - <textarea id = "outputsql" name="outputsql" cols="80" rows="15" wrap="off" > - </textarea> - </div> - <div id="sp_errormsg" style="display:none;"> - Error message goes to here! - </div> - </div> - <div id="formatoptions"> - <select name="keywordcs"> - <option value="Uppercase" selected >Uppercase</option> - <option value="Lowercase" >Lowercase</option> - <option value="InitCap" >InitCap</option> - <option value="Unchanged" >Unchanged</option> - </select> - <select name="identifiercs"> - <option value="Uppercase" >Uppercase</option> - <option value="Lowercase" selected >Lowercase</option> - <option value="InitCap" >InitCap</option> - <option value="Unchanged" >Unchanged</option> - <option value="initcapeachword" >Init cap each word</option> - </select> - <select name="functioncs"> - <option value="Uppercase" >Uppercase</option> - <option value="Lowercase" >Lowercase</option> - <option value="InitCap" selected >InitCap</option> - <option value="Unchanged" >Unchanged</option> - </select> - <input type="radio" name="lnbrwithcomma" value="after" checked > After - <input type="radio" name="lnbrwithcomma" value="before" > Before - <input type="radio" name="lnbrwithcomma" value= "beforewithspace" > Before with space - <input type="radio" name="liststyle" value="stack" checked>Stacked - <input type="radio" name="liststyle" value="nostack">Not Stacked - <input type="radio" name="salign" value="sleft" checked> Align left - <input type="radio" name="salign" value="sright" > Align right - <input type="checkbox" name="andorunderwhere" value="yes" checked> And/Or under Where - <input type="checkbox" name="removelnbr" value="no" checked> Remove Linebreak before beautify - <input type="checkbox" name="trimquotechar" value="yes"> Trim Quoted Char of Each Line quoted char of eachline: <input type="text" name="quotechar" value= "&#34" size = 5 > - <input type="checkbox" name="compactmode" value="yes"> Compact the output of sql output - <input type="text" name="maxlenincm" value= "80" size = 5 > - </div> - <input type="hidden" name="clientid" value="4149-9094-8133-2031" /> - </form> - </div> - </div> - </div> + <div id="retvalues"></div> + <p><b>Copyright &copy; 2001-2010 Gudu Software<br>All Rights Reserved<br><a href="mailto:support@dpriver.com">Contact US</a></b></p> + <br><br><br><br><br> + <p align=right>Please wait…</p> + <div class="page-container-1" style="display:none;"> + <div id="container"> + <div id="wrapper"> + <div id="content"> + + <form id="SqlFmtForm" name="frm_sqlformat" method="post" action="/cgi-bin/ppserver" onsubmit="return false;"> + + <div id="secondpanel"> + + + <div id="sp_database"> + + <label class="desc" style="display:inline;">Database</label> + <select name="dbvendor"> + <option value="access">MS ACCESS</option> + <option value="db2">DB2</option> + <option value="mssql">MSSQL</option> + <option value="mysql" selected>MySQL</option> + <option value="oracle">Oracle/PLSQL</option> + <option value="mdx">MDX</option> + <option value="generic">Generic</option> + </select> + + <label class="desc" style="display:inline;padding:0 0 0px 40px; border:0px solid;">Output:</label> + <select name="outputfmt"> + <option value="html">SQL(html:span)</option> + <option value="html2">SQL(html:font)</option> + <option value="SQL" selected>SQL(Text)</option> + + <option value="htmlkeeplayout">SQL(html:span,keep layout)</option> + <option value="htmlkeeplayout2">SQL(html:font,keep layout)</option> + <option value="htmlkeeplayoutmodifycase">SQL(html:span,keep layout,modify case)</option> + <option value="htmlkeeplayout2modifycase">SQL(html:font,keep layout,modify case)</option> + <option value="txtmodifycase">SQL(Text, keep layout, change case only)</option> + <option value="C#">C#</option> + <option value="C# String Builder">C# String Builder</option> + <option value="Delphi">Delphi</option> + <option value="Java">Java</option> + <option value="Java String Buffer">Java String Buffer</option> + <option value="PHP">PHP</option> + <option value="VB">VB</option> + <option value="VBSBD">VB String Builder</option> + <option value="VC">VC</option> + <option value="dbobject">List DB Object</option> + <option value="proc">Pro*C</option> + <option value="procobol">Pro*Cobol</option> + <option value="xml">XML output</option> + + </select> + &nbsp; &nbsp;<a href="/isf" style="display:inline;">100+ options version</a> + + </div> + + <div id="sp_example"> + <div class="nav4-container" style="border:0px solid;"> + <div class="nav1"> + <ul> + <li><a href="/products/sqlpp/sqlexamples.php" target="blank">SQL Beautifier Examples: 1</a></li> + <li><a href="/products/sqlpp/sqlexamples2.php" target="blank">2</a></li> + <li><a href="/products/sqlpp/sqlexamples3.php" target="blank">3</a></li> + <li><a href="/products/sqlpp/sqlexamples4.php" target="blank">4</a></li> + + </ul> + </div> + </div> + + </div> + </div> + + <div id="sqlpanel"> + + + <div id="sp_inputsql"> + <textarea id="inputsql" name="inputsql" cols="80" rows="15" wrap="off" onfocus="this.value='';this.onfocus=null;"> + $SQL + </textarea> + </div> + + <div id="sp_submit"> + <input type="button" id="btnformat" name="print" value="Format SQL" onclick="SQLFMT.format(this)"> + <label style="display:none;">(Time used: <span id="timestamp">0</span> seconds)</label> + <input type="button" name="clear" value=" Clear " onclick="document.frm_sqlformat.inputsql.value = ''"> + <input type="button" name="cptoclipboard" value="Copy Formatted SQL To Clipboard" onclick="SQLFMT.copy2()"> + <input type="button" name="cptoinputtext" value="Copy Formatted SQL To Input Text" onclick="SQLFMT.copy1()"> + &nbsp;&nbsp;&nbsp;<a href="/videos/sqlpp_getting_started">Short Video 1</a>&nbsp;&nbsp;&nbsp;&nbsp; + <a href="/videos/sqlpp_desktop_hotkey">Short Video 2</a> + </div> + + <div id="sp_submit" style="text-align:left;"> + + + &nbsp;&nbsp; + <a href="http://www.sqlparser.com/index.php?ref=isf"> + <img src="/images/leaderboard_728_90.jpg" width="728" height="90" border="0" alt="General SQL Parser" style="display: none !important;"> + </a> + + + + </div> + + <label id="errorhint" class="desc" style="display: none; color: rgb(223, 0, 0) !important;"> + Can't format input sql, make sure there is no syntax error and select correct database. + <a href="" style="display:none;">OR Report a bug of this sql beautifier</a> + </label> + + + + <iframe id="ioutputsql"> + </iframe> + + <div id="sp_outputsql" style="display: none;"> + <label class="desc" style="margin:0px;display:inline;">Following html code can be used in website such as blog, wiki, forum...</label> + <input type="button" name="cphtmltoclipboard" style="margin-left:30px;" value="Copy Html To Clipboard" onclick="SQLFMT.copyhtmlcode()"> + + <textarea id="outputsql" name="outputsql" cols="80" rows="15" wrap="off"></textarea> + + </div> + + <div id="sp_errormsg" style="display:none;"> + Error message goes to here! + </div> + + + </div> + + <div id="formatoptions"> + + + <label class="desc">Keywords case:</label> + <select name="keywordcs"> + <option value="Uppercase" selected="">Uppercase</option> + <option value="Lowercase">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Table name case:</label> + <select name="tablenamecs"> + <option value="Uppercase">Uppercase</option> + <option value="Lowercase" selected="">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Column name case:</label> + <select name="columnnamecs"> + <option value="Uppercase">Uppercase</option> + <option value="Lowercase" selected="">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Function case:</label> + <select name="functioncs"> + <option value="Uppercase">Uppercase</option> + <option value="Lowercase">Lowercase</option> + <option value="InitCap" selected="">InitCap</option> + <option value="Unchanged">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Datatype case:</label> + <select name="datatypecs"> + <option value="Uppercase" selected="">Uppercase</option> + <option value="Lowercase">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Variable case:</label> + <select name="variablecs"> + <option value="Uppercase">Uppercase</option> + <option value="Lowercase">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged" selected="">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Alias case:</label> + <select name="aliascs"> + <option value="Uppercase">Uppercase</option> + <option value="Lowercase">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged" selected="">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Quoted identifier case:</label> + <select name="quotedidentifiercs"> + <option value="Uppercase">Uppercase</option> + <option value="Lowercase">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged" selected="">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <label class="desc">Other identifier case:</label> + <select name="identifiercs"> + <option value="Uppercase">Uppercase</option> + <option value="Lowercase" selected="">Lowercase</option> + <option value="InitCap">InitCap</option> + <option value="Unchanged">Unchanged</option> + <option value="initcapeachword">Init cap each word</option> + </select> + + <hr> + <label class="desc">Linebreaks with comma:</label> + + <input type="radio" name="lnbrwithcomma" value="after" checked=""> After + <input type="radio" name="lnbrwithcomma" value="before"> Before + <input type="radio" name="lnbrwithcomma" value="beforewithspace"> Before with space + <hr> + <label class="desc">List and Parameters Style:</label> + <input type="radio" name="liststyle" value="stack" checked=""> Stacked + <input type="radio" name="liststyle" value="nostack"> Not Stacked + <hr> + + <label class="desc"> Stacked align:</label> + <input type="radio" name="salign" value="sleft" checked=""> Align left + <input type="radio" name="salign" value="sright"> Align right + <hr> + + <label class="desc">And/Or under Where Clause:</label> + <input type="checkbox" name="andorunderwhere" value="yes"> And/Or under Where + <hr> + + <label class="desc">Remove linebreak before beautify:</label> + <input type="checkbox" name="removelnbr" value="yes"> Remove Linebreak before beautify + <hr> + + <label class="desc">Trim Quoted Char of Each Line:</label> + <input type="checkbox" name="trimquotechar" value="yes"> Trim Quoted Char of Each Line + quoted char of eachline: <input type="text" name="quotechar" value="&quot;" size="5"> + <hr> + + <label class="desc"> Compact mode:</label> + <input type="checkbox" name="compactmode" value="yes"> Compact the output of sql output + + <label class="desc">Max length per line in compact mode:</label> + <input type="text" name="maxlenincm" value="80" size="5"> + + </div> + + <input type="hidden" name="clientid" value="dpriver-9094-8133-2031"> + </form> + + </div> + </div> +</div> </div> </body> </html> HTML </string> - <key>contact</key> - <string>znvy@ovovxb.qr</string> - <key>description</key> - <string>Send the current query or selection to www.dpriver.com and replace the current query or selection of the first responder by the server's formatted output. If a parser error occurred alert that error and tries to jump to the error location. + <key>contact</key> + <string>znvy@ovovxb.qr</string> + <key>defaultBundleWasModified</key> + <true/> + <key>description</key> + <string>Send the current query or selection to www.dpriver.com and replace the current query or selection of the first responder by the server's formatted output. If a parser error occurred alert that error and tries to jump to the error location. Version 1.0</string> - <key>input</key> - <string>selectedtext</string> - <key>input_fallback</key> - <string>currentquery</string> - <key>internalKeyEquivalent</key> - <dict> - <key>characters</key> - <string>T</string> - <key>keyCode</key> - <integer>17</integer> - <key>modifierFlags</key> - <integer>1835008</integer> - </dict> - <key>keyEquivalent</key> - <string>^~@t</string> - <key>name</key> - <string>Format SQL</string> - <key>output</key> - <string>showashtml</string> - <key>scope</key> - <string>inputfield</string> - <key>tooltip</key> - <string>Send query or selection to www.dpriver.com to insert the SQL statement formatted</string> - <key>uuid</key> - <string>36E1F94D-D6C4-460A-A663-C694AF85E099</string> - <key>isDefaultBundle</key> - <true/> + <key>input</key> + <string>selectedtext</string> + <key>input_fallback</key> + <string>currentquery</string> + <key>internalKeyEquivalent</key> + <dict> + <key>characters</key> + <string>T</string> + <key>keyCode</key> + <integer>17</integer> + <key>modifierFlags</key> + <integer>1835008</integer> + </dict> + <key>isDefaultBundle</key> + <true/> + <key>keyEquivalent</key> + <string>^~@t</string> + <key>name</key> + <string>Format SQL</string> + <key>output</key> + <string>showashtml</string> + <key>scope</key> + <string>inputfield</string> + <key>tooltip</key> + <string>Send query or selection to www.dpriver.com to insert the SQL statement formatted</string> + <key>uuid</key> + <string>36E1F94D-D6C4-460A-A663-C694AF85E099</string> </dict> </plist>