From: <du...@us...> - 2012-10-08 20:39:36
|
Revision: 10207 http://sourceforge.net/p/xoops/svn/10207 Author: dugris Date: 2012-10-08 20:39:33 +0000 (Mon, 08 Oct 2012) Log Message: ----------- Add two form type : <input type='mail' .....> <input type='url' .....> Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php XoopsCore/branches/2.6.x/2.6.0/htdocs/language/english/global.php Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formmail.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formurl.php Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formmail.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formmail.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formmail.php 2012-10-08 20:39:33 UTC (rev 10207) @@ -0,0 +1,131 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program 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. +*/ + +/** + * XOOPS form element of text + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package class + * @subpackage xoopsform + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +/** + * A simple text field + */ +class XoopsFormMail extends XoopsFormElement +{ + /** + * Size + * + * @var int + * @access private + */ + private $_size; + + /** + * Maximum length of the text + * + * @var int + * @access private + */ + + private $_maxlength; + + /** + * placeholder for this element + * + * @var string + * @access private + */ + private $_placeholder; + + /** + * Constructor + * + * @param string $caption Caption + * @param string $name "name" attribute + * @param int $size Size + * @param int $maxlength Maximum length of text + * @param string $value Initial text + * @param string $placeholder placeholder for this element. + */ + public function __construct($caption, $name, $size, $maxlength, $value = '', $placeholder = '') + { + $this->setCaption($caption); + $this->setName($name); + $this->_size = intval($size); + $this->_maxlength = intval($maxlength); + $this->setValue($value); + $this->_placeholder = $placeholder; + $this->setPattern('[^@]+@[^@]+\.[a-zA-Z]{2,6}', _FORM_VALID_MAIL); + } + + /** + * Get size + * + * @return int + */ + public function getSize() + { + return $this->_size; + } + + /** + * Get maximum text length + * + * @return int + */ + public function getMaxlength() + { + return $this->_maxlength; + } + + /** + * Get placeholder for this element + * + * @return string + */ + public function getPlaceholder() + { + if (empty($this->_placeholder)) { + return ''; + } + return $this->_placeholder; + } + + /** + * Prepare HTML for output + * + * @return string HTML + */ + public function render() + { + $name = $this->getName(); + if ($this->getSize() > $this->getMaxcols()) { + $maxcols = 5; + } else { + $maxcols = $this->getSize(); + } + $class = ($this->getClass() != '' ? " class='span" . $maxcols . " " . $this->getClass() . "'" : " class='span" . $maxcols . "'"); + $list = ($this->isDatalist() != '' ? " list='list_" . $name . "'" : ''); + $pattern = ($this->getPattern() != '' ? " pattern='" . $this->getPattern() . "'" : ''); + $placeholder = ($this->getPlaceholder() != '' ? " placeholder='" . $this->getPlaceholder() . "'" : ''); + $extra = ($this->getExtra() != '' ? " " . $this->getExtra() : ''); + $required = ($this->isRequired() ? ' required' : ''); + return "<input type='email' name='" . $name . "' title='" . $this->getTitle() . "' id='" . $name . "'" . $class ." maxlength='" . $this->getMaxlength() . "' value='" . $this->getValue() . "'" . $list . $pattern . $placeholder . $extra . $required . ">"; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formmail.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formurl.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formurl.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formurl.php 2012-10-08 20:39:33 UTC (rev 10207) @@ -0,0 +1,131 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program 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. +*/ + +/** + * XOOPS form element of text + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package class + * @subpackage xoopsform + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +/** + * A simple text field + */ +class XoopsFormUrl extends XoopsFormElement +{ + /** + * Size + * + * @var int + * @access private + */ + private $_size; + + /** + * Maximum length of the text + * + * @var int + * @access private + */ + + private $_maxlength; + + /** + * placeholder for this element + * + * @var string + * @access private + */ + private $_placeholder; + + /** + * Constructor + * + * @param string $caption Caption + * @param string $name "name" attribute + * @param int $size Size + * @param int $maxlength Maximum length of text + * @param string $value Initial text + * @param string $placeholder placeholder for this element. + */ + public function __construct($caption, $name, $size, $maxlength, $value = '', $placeholder = '') + { + $this->setCaption($caption); + $this->setName($name); + $this->_size = intval($size); + $this->_maxlength = intval($maxlength); + $this->setValue($value); + $this->_placeholder = $placeholder; + $this->setPattern('https?://.+', _FORM_VALID_URL); + } + + /** + * Get size + * + * @return int + */ + public function getSize() + { + return $this->_size; + } + + /** + * Get maximum text length + * + * @return int + */ + public function getMaxlength() + { + return $this->_maxlength; + } + + /** + * Get placeholder for this element + * + * @return string + */ + public function getPlaceholder() + { + if (empty($this->_placeholder)) { + return ''; + } + return $this->_placeholder; + } + + /** + * Prepare HTML for output + * + * @return string HTML + */ + public function render() + { + $name = $this->getName(); + if ($this->getSize() > $this->getMaxcols()) { + $maxcols = 5; + } else { + $maxcols = $this->getSize(); + } + $class = ($this->getClass() != '' ? " class='span" . $maxcols . " " . $this->getClass() . "'" : " class='span" . $maxcols . "'"); + $list = ($this->isDatalist() != '' ? " list='list_" . $name . "'" : ''); + $pattern = ($this->getPattern() != '' ? " pattern='" . $this->getPattern() . "'" : ''); + $placeholder = ($this->getPlaceholder() != '' ? " placeholder='" . $this->getPlaceholder() . "'" : ''); + $extra = ($this->getExtra() != '' ? " " . $this->getExtra() : ''); + $required = ($this->isRequired() ? ' required' : ''); + return "<input type='url' name='" . $name . "' title='" . $this->getTitle() . "' id='" . $name . "'" . $class ." maxlength='" . $this->getMaxlength() . "' value='" . $this->getValue() . "'" . $list . $pattern . $placeholder . $extra . $required . ">"; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formurl.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-10-08 20:18:31 UTC (rev 10206) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-10-08 20:39:33 UTC (rev 10207) @@ -302,6 +302,8 @@ 'xoopsformtextarea' => XOOPS_ROOT_PATH . '/class/xoopsform/formtextarea.php', 'xoopsformtextdateselect' => XOOPS_ROOT_PATH . '/class/xoopsform/formtextdateselect.php', 'xoopsgroupformcheckbox' => XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php', + 'xoopsformmail' => XOOPS_ROOT_PATH . '/class/xoopsform/formmail.php', + 'xoopsformurl' => XOOPS_ROOT_PATH . '/class/xoopsform/formurl.php', 'xoopsgrouppermform' => XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php', 'xoopsguestuser' => XOOPS_ROOT_PATH . '/kernel/user.php', 'xoopsmailer' => XOOPS_ROOT_PATH . '/class/xoopsmailer.php', Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/language/english/global.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/language/english/global.php 2012-10-08 20:18:31 UTC (rev 10206) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/language/english/global.php 2012-10-08 20:39:33 UTC (rev 10207) @@ -108,7 +108,7 @@ define("_MD_STRTYOPENG","This can not be changed afterwards!"); define("_MD_ASFILE","Store as files (in uploads directory)"); define("_MD_INDB","Store in the database (as binary \"blob\" data)"); -define("_MD_IMGMAIN","Category"); +define("_MD_IMGMAIN","Category"); define("_MD_EDITIMGCAT","Images Settings"); define('_IMGMANAGER','Image Manager'); define('_NUMIMAGES','%s images'); @@ -213,4 +213,10 @@ **/ define('_RESET','Reset'); define('_RE','Re:'); + +/** +* Additions to 2.6.0 +**/ +define('_FORM_VALID_URL','Starting with http or https'); +define('_FORM_VALID_MAIL','Enter a valid email address'); ?> \ No newline at end of file |