cvs: pear /HTML_QuickForm_Livesearch livesearch_select.php package.xml package2.xml /HTML_QuickForm_Livesearch/docs/example auto_server.php index.php
live.js livesearch.class.php myfunction.php shadow.gif shadowAlpha.png style.css /HTML_QuickForm_Livesearch/example .htaccess auto_server.php
index.php live.js livesearch.class.php myfunction.php shadow.gif shadowAlpha.png style.css
| From: | Giuseppe Dess� | Date: | Wed, 29 Aug 2007 08:58:13 +0000 |
| Subject: | cvs: pear /HTML_QuickForm_Livesearch livesearch_select.php package.xml package2.xml /HTML_QuickForm_Livesearch/docs/example auto_server.php index.php live.js livesearch.class.php myfunction.php shadow.gif shadowAlpha.png style.css /HTML_QuickForm_Livesearch/example .htaccess auto_server.php index.php live.js livesearch.class.php myfunction.php shadow.gif shadowAlpha.png style.css |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-48515@lists.php.net to get a copy of this message | ||
thesee Wed Aug 29 08:58:13 2007 UTC
Added files:
/pear/HTML_QuickForm_Livesearch package2.xml
/pear/HTML_QuickForm_Livesearch/docs/example auto_server.php
index.php live.js
livesearch.class.php
myfunction.php
shadow.gif
shadowAlpha.png
style.css
Removed files:
/pear/HTML_QuickForm_Livesearch/example .htaccess auto_server.php
index.php live.js
livesearch.class.php
myfunction.php shadow.gif
shadowAlpha.png style.css
Modified files:
/pear/HTML_QuickForm_Livesearch livesearch_select.php package.xml
Log:
BUG #10835 solved, changed folder for examples
Added option to set autoserver path.
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/livesearch_select.php?r1=1.16&r2=1.17&diff_format=u Index: pear/HTML_QuickForm_Livesearch/livesearch_select.php diff -u pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.16 pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.17 --- pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.16 Thu Dec 21 17:58:24 2006 +++ pear/HTML_QuickForm_Livesearch/livesearch_select.php Wed Aug 29 08:58:12 2007 @@ -13,7 +13,7 @@ // +----------------------------------------------------------------------+ // | Author: Giuseppe Dessì <thesee@fastwebnet.it> | // +----------------------------------------------------------------------+ -// $Id: livesearch_select.php,v 1.16 2006/12/21 17:58:24 thesee Exp $ +// $Id: livesearch_select.php,v 1.17 2007/08/29 08:58:12 thesee Exp $ /** * Class to dynamically create an HTML input text element that @@ -214,9 +214,14 @@ if (isset($this->_options['printStyle']) AND $this->_options['printStyle'] != 1) { $printStyle = 0; } + if (isset($this->_options['autoserverPath']) AND $this->_options['autoserverPath'] != '') { + $autoserverPath = $this->_options['autoserverPath']; + } else { + $autoserverPath = ''; + } if (isset($this->_options['autoComplete']) AND $this->_options['autoComplete'] != 0) { $this->updateAttributes(array( - 'autocomplete' => 'off' + 'autocomplete' => 'off' ) ); } @@ -299,7 +304,7 @@ EOS; } $scriptLoad .= <<<EOS -<script type='text/javascript' src="auto_server.php?client=Util,main,dispatcher,httpclient,request,json,loading,queues,QfLiveSearch&stub=livesearch"></script> +<script type='text/javascript' src="{$autoserverPath}auto_server.php?client=Util,main,dispatcher,httpclient,request,json,loading,queues,QfLiveSearch&stub=livesearch"></script> <script type='text/javascript'>//<![CDATA[ callback = {}; function searchRequest(searchBox, callfunc) { http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/package.xml?r1=1.8&r2=1.9&diff_format=u Index: pear/HTML_QuickForm_Livesearch/package.xml diff -u pear/HTML_QuickForm_Livesearch/package.xml:1.8 pear/HTML_QuickForm_Livesearch/package.xml:1.9 --- pear/HTML_QuickForm_Livesearch/package.xml:1.8 Sun Sep 24 16:58:31 2006 +++ pear/HTML_QuickForm_Livesearch/package.xml Wed Aug 29 08:58:12 2007 @@ -16,16 +16,13 @@ </maintainer> </maintainers> <release> - <version>0.3.2</version> - <date>2006-09-24</date> + <version>0.4.0</version> + <date>2007-03-24</date> <license>PHP License 3.0</license> <state>beta</state> <notes> Changes: -Added option to print or not the default css style, so you can put it in your css. -Added autocomplete On/Off option -The setValue Function use the callback, if the callback is not set, the function set the raw value. -Fixed some HTML code for XHTML compatibilty +Added option to set autoserver path. </notes> <deps> <dep type="pkg" rel="has" optional="no">PEAR</dep> @@ -73,6 +70,19 @@ </release> <changelog> <release> + <version>0.3.2</version> + <date>2006-09-24</date> + <license>PHP License 3.0</license> + <state>beta</state> + <notes> +Changes: +Added option to print or not the default css style, so you can put it in your css. +Added autocomplete On/Off option +The setValue Function use the callback, if the callback is not set, the function set the raw value. +Fixed some HTML code for XHTML compatibilty + </notes> + </release> + <release> <version>0.3.1</version> <date>2006-08-31</date> <license>PHP License 3.0</license> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/package2.xml?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/package2.xml +++ pear/HTML_QuickForm_Livesearch/package2.xml <?xml version="1.0" encoding="UTF-8"?> <package packagerversion="1.5.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>HTML_QuickForm_Livesearch</name> <channel>pear.php.net</channel> <summary>Element for HTML_QuickForm to enable a suggest search.</summary> <description>This package adds an element to the PEAR::HTML_QuickForm package to dynamically create an HTML input text element that at every keypressed javascript event, returns a list of options in a dynamic dropdown select box(live dropdown select). This element use AJAX (Communication from JavaScript to your browser without reloading the page). This type of livesearch is useful when you have a form with a dropdown list with a large number of row. </description> <lead> <name>Giuseppe Dessi</name> <user>Thesee</user> <email>thesee@fastwebnet.it</email> <active>yes</active> </lead> <date>2007-08-29</date> <time>12:00:00</time> <version> <release>0.4.0</release> <api>0.4.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <license>PHP License 3.0</license> <notes>Changes: BUG #10835 solved. Added option to set autoserver path. </notes> <contents> <dir name="/"> <dir name="docs"> <dir name="example"> <file name="auto_server.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="index.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="live.js" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="livesearch.class.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="myfunction.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="shadow.gif" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="shadowAlpha.png" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="style.css" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> </dir> <!-- //example --> </dir><!-- //docs --> <file name="live.js" role="data"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file baseinstalldir="HTML/QuickForm" name="livesearch_select.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>4.0.0</min> </php> <pearinstaller> <min>1.4.0b1</min> </pearinstaller> <package> <name>PEAR</name> <channel>pear.php.net</channel> </package> <package> <name>HTML_QuickForm</name> <channel>pear.php.net</channel> <min>3.2.4</min> <exclude>3.2.4</exclude> </package> <package> <name>HTML_AJAX</name> <channel>pear.php.net</channel> <min>0.4.1</min> <exclude>0.4.1</exclude> </package> </required> </dependencies> <phprelease /> <changelog> <release> <version> <release>0.3.2</release> <api>0.3.2</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-09-24</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Added option to print or not the default css style, so you can put it in your css. Added autocomplete On/Off option The setValue Function use the callback, if the callback is not set, the function set the raw value. Fixed some HTML code for XHTML compatibilty </notes> </release> <release> <version> <release>0.3.1</release> <api>0.3.1</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-08-31</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Added compatibility to new HTML_AJAX 0.5.0 release. </notes> </release> <release> <version> <release>0.3.0</release> <api>0.3.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-06-23</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Solved bug with frozen element. * todo: Do not reset the value when the key is a button that do not alter the text. * todo: Set up the options of an alternative element when jscript disabled </notes> </release> <release> <version> <release>0.2.0</release> <api>0.2.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-05-25</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Single quote issue on liveform variable Added attributes on example. Style coding issue The id value is not reset when the keypressed is left or right arrow * todo: Do not reset the value when the key is a button that do not alter the text. * todo: Set up the options of an alternative element when jscript disabled </notes> </release> <release> <version> <release>0.1.5</release> <api>0.1.5</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <date>2006-04-04</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Now you can set the buffer time Modified Example added an option to set the buffer time Some code style issue fix Now when a key is pressed the value is reset * todo Do not reset the value when the key is an arrow or a function button * todo: Set up the options of an alternative element when jscript disabled * todo: release the Livesearch_Text element. </notes> </release> <release> <version> <release>0.1.0</release> <api>0.1.0</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <date>2006-03-17</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Add styles as class, the user can set as he like. Modified Example with callback for post value recalculation Add 0 length search control Various fix * todo: Make HTML_AJAX_Queue_Interval_SingleBuffer variable * todo: Set up the options of an alternative element when jscript disabled * todo: Checking hidden field for changes. * todo: .... * todo: release the Livesearch_Text element. </notes> </release> </changelog> </package> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/auto_server.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/auto_server.php +++ pear/HTML_QuickForm_Livesearch/docs/example/auto_server.php <?php /** * Advanced usage of HTML_AJAX_Server * Allows for a single server to manage exporting a large number of classes without high overhead per call * Also gives a single place to handle setup tasks especially useful if session setup is required * * The server responds to ajax calls and also serves the js client libraries, so they can be used directly from the PEAR data dir * 304 not modified headers are used when server client libraries so they will be cached on the browser reducing overhead * * @category HTML * @package AJAX * @author Joshua Eichorn <josh@bluga.net> * @copyright 2005 Joshua Eichorn * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_AJAX */ // $Id: auto_server.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ // include the server class include 'HTML/AJAX/Server.php'; // extend HTML_AJAX_Server creating our own custom one with init{ClassName} methods for each class it supports calls on class LiveServer extends HTML_AJAX_Server { // this flag must be set to on init methods var $initMethods = true; // init method for the livesearch class, includes needed files an registers it for ajax function initLivesearch() { include 'livesearch.class.php'; $this->registerClass(new livesearch()); } } // create an instance of our test server $server = new LiveServer(); // you can use HTML_AJAX_Server to deliver your own custom javascript libs, when used with comma seperated client lists you can // use just one javascript include for all your library files // example url: auto_server.php?client=auto_server.php?client=Util,Main,Request,HttpClient,Dispatcher,Behavior,customLib $server->registerJSLibrary('QfLiveSearch','live.js','./'); // handle requests as needed $server->handleRequest(); ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/index.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/index.php +++ pear/HTML_QuickForm_Livesearch/docs/example/index.php <?php // $Id: index.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/livesearch_select.php'; require_once 'myfunction.php'; // Instantiate the HTML_QuickForm object $form = new HTML_QuickForm('firstForm'); // Add some elements to the form $form->addElement('header', null, 'QuickForm example'); $form->addElement('livesearch_select', 'Nome', 'Example: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)', array( 'elementId' => 'search', //element id 'callback' => array('Test', 'getTestName'),//callback function to retrieve value from ID selection // 'dbh' => $db,//optional handler for callback function 'style' => '',//optional class for style not set or '' ==> default 'divstyle' => '',//optional class for style not set or '' ==> default 'ulstyle' => '',//optional class for style not set or '' ==> default 'listyle' => '',//optional class for style not set or '' ==> default 'searchZeroLength' => 1, //enable the search request with 0 length keyword(Default 0) 'buffer' => 350, //set the interval single buffer send time (ms) 'printStyle' => 1, //anything != 0 will render css inline(Default 1), 0 => the default style will not be rendered, you should put it in your style.css(XHTML fix) 'autoComplete' => 1, //if 0 the autocomplete attribute will not be set. Default not set; 'autoserverPath' => '' //path to auto_server.php file with trailing slash NOTE: check path for all files included in autoserver.php ), array('size' => '50') ); $form->addElement('livesearch_select', 'Nome2', 'Example2: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)', array( 'elementId' => 'search2', //element id 'callback' => array('Test', 'getTestName2'),//callback function to retrieve ID from selection // 'dbh' => $db,//optional handler for callback function ), 'size=30' ); $form->addElement('text', 'required_field', '[errorTest]Some data:'); $form->addElement('submit', null, 'View', array('id'=>'submit')); $form->addRule('required_field', 'Data required', 'required', null, 'server'); $form->addRule('Nome', 'Data required', 'required', null, 'server'); //example set default value only if form is not submitted if (!isset($_POST['Nome2']) ) { $el = $form->getElement('Nome2'); $el->setValue(2); } if ($form->validate()) { echo"<pre>";print_r($_POST);echo"</pre>"; $form->freeze(); } // Output the form ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Livesearch QuickForm Test</title> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <p style="font-size:14px;">HTML_AJAX dependent QF_Livesearch DROPDOWN<br> In this example we can find something from database, such a Fourm Post or a word in a News Post...<br> This type of livesearch is useful when you have a form with a dropdown list with a large number of row.<br> With HTML_QuickForm, you can easily do the trick ;).</p> <?php $form->display(); ?> </body> </html> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/live.js?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/live.js +++ pear/HTML_QuickForm_Livesearch/docs/example/live.js /* vim: set number autoindent tabstop=2 shiftwidth=2 softtabstop=2: */ // +----------------------------------------------------------------------+ // | Javascript | // +----------------------------------------------------------------------+ // | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/3_0.txt | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Giuseppe Dessì<thesee@fastwebnet.it> | // | | // | Original JavaScript code | // | Bitflux GmbH <devel@bitflux.ch> | // | http://blog.bitflux.ch/wiki/LiveSearch/#Source_Code | // +----------------------------------------------------------------------+ // $Id: live.js,v 1.1 2007/08/29 08:58:12 thesee Exp $ function liveSearchHover(el) { highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } el.parentNode.setAttribute("id","LSHighlight"); } function liveSearchClicked (valore, text, elementId, realName) { highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } document.getElementById(elementId).value = text; document.getElementById(realName).value = valore; } function liveSearchHide (GetResult) { document.getElementById(GetResult).style.display = "none"; highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } } function liveSearchKeyPress (Obj, event, GetResult, GetShadow, elementId , realName, SearchZero ) { isIE = false; if (navigator.userAgent.indexOf("Safari") > 0) { // } else if (navigator.product == "Gecko") { // } else { isIE = true; } if (event.keyCode == 37 || event.keyCode == 39) { liveSearchHide(GetResult); } else { document.getElementById(realName).value = ''; if (event.keyCode == 13 ) { liveSearchHide(GetResult); } if (event.keyCode == 40 ) //KEY DOWN { highlight = document.getElementById("LSHighlight"); if (!highlight) { highlight = document.getElementById(GetShadow).firstChild.firstChild; } else { highlight.removeAttribute("id"); highlight = highlight.nextSibling; } if (highlight) { highlight.setAttribute("id","LSHighlight"); document.getElementById(elementId).value = highlight.firstChild.getAttribute("text"); document.getElementById(realName).value = highlight.firstChild.getAttribute("value"); } if (!isIE) { event.preventDefault(); } } //KEY UP else if (event.keyCode == 38 ) { highlight = document.getElementById("LSHighlight"); if (!highlight) { highlight = document.getElementById(GetResult).firstChild.firstChild.lastChild; } else { highlight.removeAttribute("id"); highlight = highlight.previousSibling; } if (highlight) { highlight.setAttribute("id","LSHighlight"); document.getElementById(elementId).value = highlight.firstChild.getAttribute("text"); document.getElementById(realName).value = highlight.firstChild.getAttribute("value"); } if (!isIE) { event.preventDefault(); } } //ESC else if (event.keyCode == 27) { highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } document.getElementById(GetResult).style.display = "none"; } else if (Obj.value.length == 0 && SearchZero == 1) { searchRequest(Obj, elementId); } else if (Obj.value.length > 0) searchRequest(Obj, elementId); } } http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/livesearch.class.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/livesearch.class.php +++ pear/HTML_QuickForm_Livesearch/docs/example/livesearch.class.php <?php /** * Simple test class for doing fake livesearch * * @category HTML * @package AJAX * @author Joshua Eichorn <josh@bluga.net> * @copyright 2005 Joshua Eichorn * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_AJAX */ // $Id: livesearch.class.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ class livesearch { /** * Items to search against */ var $livesearch = array( 1 => 'Orange', 2 => 'Apple', 3 => 'Pear', 4 => 'Banana', 5 => 'Blueberry', ); var $livesearch2 = array( 1 => 'Orange-2', 2 => 'Apple-2', 3 => 'Pear-2', 4 => 'Banana-2', 5 => 'Blueberry-2', ); /** * Perform a search * * @return array */ function search($input) { $ret = array(); foreach($this->livesearch as $key => $value) { if (stristr($value,$input)) { $ret[$key] = $value; } } return $ret; } function search2($input) { $ret = array(); foreach($this->livesearch2 as $key => $value) { if (stristr($value,$input)) { $ret[$key] = $value; } } return $ret; } } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/myfunction.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/myfunction.php +++ pear/HTML_QuickForm_Livesearch/docs/example/myfunction.php <?php // $Id: myfunction.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ class Test { function getTestName($dbh, $id) { $livesearch = array( 1 => 'Orange', 2 => 'Apple', 3 => 'Pear', 4 => 'Banana', 5 => 'Blueberry' ); if ($id > 0) { return $livesearch[$id]; } } function getTestName2($dbh, $id) { $livesearch = array( 1 => 'Orange-2', 2 => 'Apple-2', 3 => 'Pear-2', 4 => 'Banana-2', 5 => 'Blueberry-2' ); if ($id > 0) { return $livesearch[$id]; } } } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/style.css?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/style.css +++ pear/HTML_QuickForm_Livesearch/docs/example/style.css BODY, TABLE { margin: 0px; padding: 0px; font-family: Verdana; color: #54616E; font-size: 11px; } A { font-family: Verdana; font-size: 10px; } TABLE, TD, TH, P, DIV, LI, INPUT, TEXTAREA { font-size: 11px; } A:link {color:#54616E; text-decoration: none;} A:visited {color:#54616E; text-decoration: none;} A:active {color:#54616E; text-decoration: none;} A:hover {color:#000000; text-decoration: underline;} ..inputs { width: 90mm; } TABLE.amenu TD A { font-size: 12px; } TABLE.amenu TD.selected { border: 0px; font-weight: bold; } TH { text-align: right; padding-right: 8px; } ..frozen { color: red; } INPUT.error, SELECT.error, TEXTAREA.error { background-color: #FFF0F0; } ..TITLE { font-size: 12px; font-weight: bold; } P { font-size: 11px; font-weight: normal; margin-top: 0px; } P.box, P.box * { font-size: 11px; font-weight: normal; margin-top: 0px; } ..inputs { background-color: #E0EEC1; } #LSHighlight { color: #564b47; background-color: #ccc; }
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/livesearch_select.php?r1=1.16&r2=1.17&diff_format=u Index: pear/HTML_QuickForm_Livesearch/livesearch_select.php diff -u pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.16 pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.17 --- pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.16 Thu Dec 21 17:58:24 2006 +++ pear/HTML_QuickForm_Livesearch/livesearch_select.php Wed Aug 29 08:58:12 2007 @@ -13,7 +13,7 @@ // +----------------------------------------------------------------------+ // | Author: Giuseppe Dessì <thesee@fastwebnet.it> | // +----------------------------------------------------------------------+ -// $Id: livesearch_select.php,v 1.16 2006/12/21 17:58:24 thesee Exp $ +// $Id: livesearch_select.php,v 1.17 2007/08/29 08:58:12 thesee Exp $ /** * Class to dynamically create an HTML input text element that @@ -214,9 +214,14 @@ if (isset($this->_options['printStyle']) AND $this->_options['printStyle'] != 1) { $printStyle = 0; } + if (isset($this->_options['autoserverPath']) AND $this->_options['autoserverPath'] != '') { + $autoserverPath = $this->_options['autoserverPath']; + } else { + $autoserverPath = ''; + } if (isset($this->_options['autoComplete']) AND $this->_options['autoComplete'] != 0) { $this->updateAttributes(array( - 'autocomplete' => 'off' + 'autocomplete' => 'off' ) ); } @@ -299,7 +304,7 @@ EOS; } $scriptLoad .= <<<EOS -<script type='text/javascript' src="auto_server.php?client=Util,main,dispatcher,httpclient,request,json,loading,queues,QfLiveSearch&stub=livesearch"></script> +<script type='text/javascript' src="{$autoserverPath}auto_server.php?client=Util,main,dispatcher,httpclient,request,json,loading,queues,QfLiveSearch&stub=livesearch"></script> <script type='text/javascript'>//<![CDATA[ callback = {}; function searchRequest(searchBox, callfunc) { http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/package.xml?r1=1.8&r2=1.9&diff_format=u Index: pear/HTML_QuickForm_Livesearch/package.xml diff -u pear/HTML_QuickForm_Livesearch/package.xml:1.8 pear/HTML_QuickForm_Livesearch/package.xml:1.9 --- pear/HTML_QuickForm_Livesearch/package.xml:1.8 Sun Sep 24 16:58:31 2006 +++ pear/HTML_QuickForm_Livesearch/package.xml Wed Aug 29 08:58:12 2007 @@ -16,16 +16,13 @@ </maintainer> </maintainers> <release> - <version>0.3.2</version> - <date>2006-09-24</date> + <version>0.4.0</version> + <date>2007-03-24</date> <license>PHP License 3.0</license> <state>beta</state> <notes> Changes: -Added option to print or not the default css style, so you can put it in your css. -Added autocomplete On/Off option -The setValue Function use the callback, if the callback is not set, the function set the raw value. -Fixed some HTML code for XHTML compatibilty +Added option to set autoserver path. </notes> <deps> <dep type="pkg" rel="has" optional="no">PEAR</dep> @@ -73,6 +70,19 @@ </release> <changelog> <release> + <version>0.3.2</version> + <date>2006-09-24</date> + <license>PHP License 3.0</license> + <state>beta</state> + <notes> +Changes: +Added option to print or not the default css style, so you can put it in your css. +Added autocomplete On/Off option +The setValue Function use the callback, if the callback is not set, the function set the raw value. +Fixed some HTML code for XHTML compatibilty + </notes> + </release> + <release> <version>0.3.1</version> <date>2006-08-31</date> <license>PHP License 3.0</license> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/package2.xml?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/package2.xml +++ pear/HTML_QuickForm_Livesearch/package2.xml <?xml version="1.0" encoding="UTF-8"?> <package packagerversion="1.5.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>HTML_QuickForm_Livesearch</name> <channel>pear.php.net</channel> <summary>Element for HTML_QuickForm to enable a suggest search.</summary> <description>This package adds an element to the PEAR::HTML_QuickForm package to dynamically create an HTML input text element that at every keypressed javascript event, returns a list of options in a dynamic dropdown select box(live dropdown select). This element use AJAX (Communication from JavaScript to your browser without reloading the page). This type of livesearch is useful when you have a form with a dropdown list with a large number of row. </description> <lead> <name>Giuseppe Dessi</name> <user>Thesee</user> <email>thesee@fastwebnet.it</email> <active>yes</active> </lead> <date>2007-08-29</date> <time>12:00:00</time> <version> <release>0.4.0</release> <api>0.4.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <license>PHP License 3.0</license> <notes>Changes: BUG #10835 solved. Added option to set autoserver path. </notes> <contents> <dir name="/"> <dir name="docs"> <dir name="example"> <file name="auto_server.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="index.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="live.js" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="livesearch.class.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="myfunction.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="shadow.gif" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="shadowAlpha.png" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file name="style.css" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> </dir> <!-- //example --> </dir><!-- //docs --> <file name="live.js" role="data"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file baseinstalldir="HTML/QuickForm" name="livesearch_select.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>4.0.0</min> </php> <pearinstaller> <min>1.4.0b1</min> </pearinstaller> <package> <name>PEAR</name> <channel>pear.php.net</channel> </package> <package> <name>HTML_QuickForm</name> <channel>pear.php.net</channel> <min>3.2.4</min> <exclude>3.2.4</exclude> </package> <package> <name>HTML_AJAX</name> <channel>pear.php.net</channel> <min>0.4.1</min> <exclude>0.4.1</exclude> </package> </required> </dependencies> <phprelease /> <changelog> <release> <version> <release>0.3.2</release> <api>0.3.2</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-09-24</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Added option to print or not the default css style, so you can put it in your css. Added autocomplete On/Off option The setValue Function use the callback, if the callback is not set, the function set the raw value. Fixed some HTML code for XHTML compatibilty </notes> </release> <release> <version> <release>0.3.1</release> <api>0.3.1</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-08-31</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Added compatibility to new HTML_AJAX 0.5.0 release. </notes> </release> <release> <version> <release>0.3.0</release> <api>0.3.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-06-23</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Solved bug with frozen element. * todo: Do not reset the value when the key is a button that do not alter the text. * todo: Set up the options of an alternative element when jscript disabled </notes> </release> <release> <version> <release>0.2.0</release> <api>0.2.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <date>2006-05-25</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Single quote issue on liveform variable Added attributes on example. Style coding issue The id value is not reset when the keypressed is left or right arrow * todo: Do not reset the value when the key is a button that do not alter the text. * todo: Set up the options of an alternative element when jscript disabled </notes> </release> <release> <version> <release>0.1.5</release> <api>0.1.5</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <date>2006-04-04</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Now you can set the buffer time Modified Example added an option to set the buffer time Some code style issue fix Now when a key is pressed the value is reset * todo Do not reset the value when the key is an arrow or a function button * todo: Set up the options of an alternative element when jscript disabled * todo: release the Livesearch_Text element. </notes> </release> <release> <version> <release>0.1.0</release> <api>0.1.0</api> </version> <stability> <release>alpha</release> <api>alpha</api> </stability> <date>2006-03-17</date> <license uri="http://www.php.net/license/3_0.txt">PHP License 3.0</license> <notes>Changes: Add styles as class, the user can set as he like. Modified Example with callback for post value recalculation Add 0 length search control Various fix * todo: Make HTML_AJAX_Queue_Interval_SingleBuffer variable * todo: Set up the options of an alternative element when jscript disabled * todo: Checking hidden field for changes. * todo: .... * todo: release the Livesearch_Text element. </notes> </release> </changelog> </package> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/auto_server.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/auto_server.php +++ pear/HTML_QuickForm_Livesearch/docs/example/auto_server.php <?php /** * Advanced usage of HTML_AJAX_Server * Allows for a single server to manage exporting a large number of classes without high overhead per call * Also gives a single place to handle setup tasks especially useful if session setup is required * * The server responds to ajax calls and also serves the js client libraries, so they can be used directly from the PEAR data dir * 304 not modified headers are used when server client libraries so they will be cached on the browser reducing overhead * * @category HTML * @package AJAX * @author Joshua Eichorn <josh@bluga.net> * @copyright 2005 Joshua Eichorn * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_AJAX */ // $Id: auto_server.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ // include the server class include 'HTML/AJAX/Server.php'; // extend HTML_AJAX_Server creating our own custom one with init{ClassName} methods for each class it supports calls on class LiveServer extends HTML_AJAX_Server { // this flag must be set to on init methods var $initMethods = true; // init method for the livesearch class, includes needed files an registers it for ajax function initLivesearch() { include 'livesearch.class.php'; $this->registerClass(new livesearch()); } } // create an instance of our test server $server = new LiveServer(); // you can use HTML_AJAX_Server to deliver your own custom javascript libs, when used with comma seperated client lists you can // use just one javascript include for all your library files // example url: auto_server.php?client=auto_server.php?client=Util,Main,Request,HttpClient,Dispatcher,Behavior,customLib $server->registerJSLibrary('QfLiveSearch','live.js','./'); // handle requests as needed $server->handleRequest(); ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/index.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/index.php +++ pear/HTML_QuickForm_Livesearch/docs/example/index.php <?php // $Id: index.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/livesearch_select.php'; require_once 'myfunction.php'; // Instantiate the HTML_QuickForm object $form = new HTML_QuickForm('firstForm'); // Add some elements to the form $form->addElement('header', null, 'QuickForm example'); $form->addElement('livesearch_select', 'Nome', 'Example: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)', array( 'elementId' => 'search', //element id 'callback' => array('Test', 'getTestName'),//callback function to retrieve value from ID selection // 'dbh' => $db,//optional handler for callback function 'style' => '',//optional class for style not set or '' ==> default 'divstyle' => '',//optional class for style not set or '' ==> default 'ulstyle' => '',//optional class for style not set or '' ==> default 'listyle' => '',//optional class for style not set or '' ==> default 'searchZeroLength' => 1, //enable the search request with 0 length keyword(Default 0) 'buffer' => 350, //set the interval single buffer send time (ms) 'printStyle' => 1, //anything != 0 will render css inline(Default 1), 0 => the default style will not be rendered, you should put it in your style.css(XHTML fix) 'autoComplete' => 1, //if 0 the autocomplete attribute will not be set. Default not set; 'autoserverPath' => '' //path to auto_server.php file with trailing slash NOTE: check path for all files included in autoserver.php ), array('size' => '50') ); $form->addElement('livesearch_select', 'Nome2', 'Example2: Live Select, <br>select a name and return an ID <br>(useful for dropdown lists)', array( 'elementId' => 'search2', //element id 'callback' => array('Test', 'getTestName2'),//callback function to retrieve ID from selection // 'dbh' => $db,//optional handler for callback function ), 'size=30' ); $form->addElement('text', 'required_field', '[errorTest]Some data:'); $form->addElement('submit', null, 'View', array('id'=>'submit')); $form->addRule('required_field', 'Data required', 'required', null, 'server'); $form->addRule('Nome', 'Data required', 'required', null, 'server'); //example set default value only if form is not submitted if (!isset($_POST['Nome2']) ) { $el = $form->getElement('Nome2'); $el->setValue(2); } if ($form->validate()) { echo"<pre>";print_r($_POST);echo"</pre>"; $form->freeze(); } // Output the form ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Livesearch QuickForm Test</title> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <p style="font-size:14px;">HTML_AJAX dependent QF_Livesearch DROPDOWN<br> In this example we can find something from database, such a Fourm Post or a word in a News Post...<br> This type of livesearch is useful when you have a form with a dropdown list with a large number of row.<br> With HTML_QuickForm, you can easily do the trick ;).</p> <?php $form->display(); ?> </body> </html> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/live.js?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/live.js +++ pear/HTML_QuickForm_Livesearch/docs/example/live.js /* vim: set number autoindent tabstop=2 shiftwidth=2 softtabstop=2: */ // +----------------------------------------------------------------------+ // | Javascript | // +----------------------------------------------------------------------+ // | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/3_0.txt | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Giuseppe Dessì<thesee@fastwebnet.it> | // | | // | Original JavaScript code | // | Bitflux GmbH <devel@bitflux.ch> | // | http://blog.bitflux.ch/wiki/LiveSearch/#Source_Code | // +----------------------------------------------------------------------+ // $Id: live.js,v 1.1 2007/08/29 08:58:12 thesee Exp $ function liveSearchHover(el) { highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } el.parentNode.setAttribute("id","LSHighlight"); } function liveSearchClicked (valore, text, elementId, realName) { highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } document.getElementById(elementId).value = text; document.getElementById(realName).value = valore; } function liveSearchHide (GetResult) { document.getElementById(GetResult).style.display = "none"; highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } } function liveSearchKeyPress (Obj, event, GetResult, GetShadow, elementId , realName, SearchZero ) { isIE = false; if (navigator.userAgent.indexOf("Safari") > 0) { // } else if (navigator.product == "Gecko") { // } else { isIE = true; } if (event.keyCode == 37 || event.keyCode == 39) { liveSearchHide(GetResult); } else { document.getElementById(realName).value = ''; if (event.keyCode == 13 ) { liveSearchHide(GetResult); } if (event.keyCode == 40 ) //KEY DOWN { highlight = document.getElementById("LSHighlight"); if (!highlight) { highlight = document.getElementById(GetShadow).firstChild.firstChild; } else { highlight.removeAttribute("id"); highlight = highlight.nextSibling; } if (highlight) { highlight.setAttribute("id","LSHighlight"); document.getElementById(elementId).value = highlight.firstChild.getAttribute("text"); document.getElementById(realName).value = highlight.firstChild.getAttribute("value"); } if (!isIE) { event.preventDefault(); } } //KEY UP else if (event.keyCode == 38 ) { highlight = document.getElementById("LSHighlight"); if (!highlight) { highlight = document.getElementById(GetResult).firstChild.firstChild.lastChild; } else { highlight.removeAttribute("id"); highlight = highlight.previousSibling; } if (highlight) { highlight.setAttribute("id","LSHighlight"); document.getElementById(elementId).value = highlight.firstChild.getAttribute("text"); document.getElementById(realName).value = highlight.firstChild.getAttribute("value"); } if (!isIE) { event.preventDefault(); } } //ESC else if (event.keyCode == 27) { highlight = document.getElementById("LSHighlight"); if (highlight) { highlight.removeAttribute("id"); } document.getElementById(GetResult).style.display = "none"; } else if (Obj.value.length == 0 && SearchZero == 1) { searchRequest(Obj, elementId); } else if (Obj.value.length > 0) searchRequest(Obj, elementId); } } http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/livesearch.class.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/livesearch.class.php +++ pear/HTML_QuickForm_Livesearch/docs/example/livesearch.class.php <?php /** * Simple test class for doing fake livesearch * * @category HTML * @package AJAX * @author Joshua Eichorn <josh@bluga.net> * @copyright 2005 Joshua Eichorn * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_AJAX */ // $Id: livesearch.class.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ class livesearch { /** * Items to search against */ var $livesearch = array( 1 => 'Orange', 2 => 'Apple', 3 => 'Pear', 4 => 'Banana', 5 => 'Blueberry', ); var $livesearch2 = array( 1 => 'Orange-2', 2 => 'Apple-2', 3 => 'Pear-2', 4 => 'Banana-2', 5 => 'Blueberry-2', ); /** * Perform a search * * @return array */ function search($input) { $ret = array(); foreach($this->livesearch as $key => $value) { if (stristr($value,$input)) { $ret[$key] = $value; } } return $ret; } function search2($input) { $ret = array(); foreach($this->livesearch2 as $key => $value) { if (stristr($value,$input)) { $ret[$key] = $value; } } return $ret; } } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/myfunction.php?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/myfunction.php +++ pear/HTML_QuickForm_Livesearch/docs/example/myfunction.php <?php // $Id: myfunction.php,v 1.1 2007/08/29 08:58:12 thesee Exp $ class Test { function getTestName($dbh, $id) { $livesearch = array( 1 => 'Orange', 2 => 'Apple', 3 => 'Pear', 4 => 'Banana', 5 => 'Blueberry' ); if ($id > 0) { return $livesearch[$id]; } } function getTestName2($dbh, $id) { $livesearch = array( 1 => 'Orange-2', 2 => 'Apple-2', 3 => 'Pear-2', 4 => 'Banana-2', 5 => 'Blueberry-2' ); if ($id > 0) { return $livesearch[$id]; } } } ?> http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/docs/example/style.css?view=markup&rev=1.1 Index: pear/HTML_QuickForm_Livesearch/docs/example/style.css +++ pear/HTML_QuickForm_Livesearch/docs/example/style.css BODY, TABLE { margin: 0px; padding: 0px; font-family: Verdana; color: #54616E; font-size: 11px; } A { font-family: Verdana; font-size: 10px; } TABLE, TD, TH, P, DIV, LI, INPUT, TEXTAREA { font-size: 11px; } A:link {color:#54616E; text-decoration: none;} A:visited {color:#54616E; text-decoration: none;} A:active {color:#54616E; text-decoration: none;} A:hover {color:#000000; text-decoration: underline;} ..inputs { width: 90mm; } TABLE.amenu TD A { font-size: 12px; } TABLE.amenu TD.selected { border: 0px; font-weight: bold; } TH { text-align: right; padding-right: 8px; } ..frozen { color: red; } INPUT.error, SELECT.error, TEXTAREA.error { background-color: #FFF0F0; } ..TITLE { font-size: 12px; font-weight: bold; } P { font-size: 11px; font-weight: normal; margin-top: 0px; } P.box, P.box * { font-size: 11px; font-weight: normal; margin-top: 0px; } ..inputs { background-color: #E0EEC1; } #LSHighlight { color: #564b47; background-color: #ccc; }