Source for file URLTextInput.class.php
Documentation is available at URLTextInput.class.php
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
echo "<h3>You have to define the constant CLASSPATH!</h3>\r\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\r\n";
* Including language specific messages.
include CLASSPATH. "/forms/items/URLTextInput/". LANG. ".inc.php";
echo "<h3>You have to define the constant LANG!</h3>\n";
echo "Example for german: define( 'LANG', 'de' );\n";
require_once CLASSPATH. "forms/items/HTMLTextInput.class.php";
* A class to generate text input fields that can only carry URLs.
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (C) 2006 Daniel Pluecken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* Carries all prefixes for the protocol that are allowed to put in the
* textfield, like "http://" or/and "ftp://" etc.
* @var array $protocol_prefix_arr
* @author Daniel Plücken <daniel@debakel.net>
* Stores the value of this item's "onBlur"-attribute.
* @author Daniel Plücken <daniel@debakel.net>
* Adds a new protocol type to the array of all prefixes for the protocol
* that are allowed to put in the textfield, like "http://" or/and "ftp://"
* @author Daniel Plücken <daniel@debakel.net>
* Returns a javascript to probe if the value, that was typed in the
* textfield, is a number.
* @author Daniel Plücken <daniel@debakel.net>
if( empty( $JSTOCHECKURL ) )
$out = "\r\n\r\n<script language=\"javascript\">\r\n";
$out .= " function checkURLText( which, protocol )\r\n";
$out .= " reg_obj = new RegExp( "
. "'^(?:' + protocol + ')?"
. "(?:[^\\\\s\\/?&\\\\#\\\"\\':\\\\.]{2,}\\\\.?)*" // Domain
. "|[1-9]\\\\d{1,3}" // 10-9999
. "|[1-5]\\\\d{4,4}" // 10000-59999
. "|6[0-4]\\\\d\\\\d\\\\d" // 60000-64999
. "|65[0-4]\\\\d\\\\d" // 65000-65499
. "|655[0-2]\\\\d" // 65500-65529
. "|6553[0-5]" // 65530-65535
. "(?:\\/[^\\\\s\\/?&\\\\#\\\"\\':]+)*" // Folder & Files
. "(?:\\\\?[-_a-z%0-9]+(?:=[^ &]*)?){1,1}" // First
. "(?:&[-_a-z%0-9]+(?:=[^ &]*)?)*" // Following
$out .= " if ( reg_obj.test( which.value ) )\r\n";
$out .= " return true;\r\n";
$out .= " which.focus();\r\n";
$out .= " return false;\r\n";
$out .= "</script>\r\n\r\n\r\n";
* Returns an if-order of a javascript to check whether the value of this
* item has the correct format.
* @author Daniel Plücken <daniel@debakel.net>
* @param string $formName
$out = "checkURLText( document."
* Returns an if-order of a javascript to check whether this item is NOT
* @author Daniel Plücken <daniel@debakel.net>
$out = "document.". $this->parentform->getName(). "."
. $this->name. ".value == \"\"";
$out .= " || document.". $this->parentform->getName(). "."
. $this->name. ".value == \"". $str_tmp. "\"";
* Generates the sourcecode to build this object and returns it.
* @author Daniel Plücken <daniel@debakel.net>
$out = "unset( \x24value );\r\n";
$out .= "\x24value = \x24_POST[\"". $this->getName(). "\"]\r\n"
. " .\x24_GET[\"". $this->getName(). "\"];\r\n";
$out .= "\x24input[] = new URLTextInput(\r\n"
? "if( \x24value === \"\" )\r\n"
. " \x24input[count(\x24input)-1]"
. "->setValue( \"". $tmp. "\" );\r\n\r\n"
* Returns a generated string based on the attributes of this object.
* @author Daniel Plücken <daniel@debakel.net>
} // END of class NumberTextInput
|