From: <txm...@us...> - 2015-02-19 09:38:01
|
Revision: 13002 http://sourceforge.net/p/xoops/svn/13002 Author: txmodxoops Date: 2015-02-19 09:37:52 +0000 (Thu, 19 Feb 2015) Log Message: ----------- Updated form elements to bootstrap 3 Modified Paths: -------------- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formdhtmltextarea.php XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formselect.php XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/modules/profile/templates/profile_form.html Added Paths: ----------- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formpassword.php XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtext.php XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtextarea.php XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/grouppermform.php Modified: XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formdhtmltextarea.php =================================================================== --- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formdhtmltextarea.php 2015-02-18 23:25:57 UTC (rev 13001) +++ XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formdhtmltextarea.php 2015-02-19 09:37:52 UTC (rev 13002) @@ -152,7 +152,7 @@ $ret .= "<input type='button' class='btn btn-info' onclick=\"XoopsCheckLength('" . $this->getName() . "', '" . @$this->configs['maxlength'] . "', '" . _XOOPS_FORM_ALT_LENGTH . "', '" . _XOOPS_FORM_ALT_LENGTH_MAX . "');\" value=' ? ' title='" . _XOOPS_FORM_ALT_CHECKLENGTH . "' />"; $ret .= "<br />\n"; // the textarea box - $ret .= "<textarea id='" . $this->getName() . "' name='" . $this->getName() . "' title='". $this->getTitle() . "' onselect=\"xoopsSavePosition('" . $this->getName() . "');\" onclick=\"xoopsSavePosition('" . $this->getName() . "');\" onkeyup=\"xoopsSavePosition('" . $this->getName() . "');\" cols='" . $this->getCols() . "' rows='" . $this->getRows() . "'" . $this->getExtra() . ">" . $this->getValue() . "</textarea><br />\n"; + $ret .= "<textarea id='" . $this->getName() . "' name='" . $this->getName() . "' class=\"form-control\" title='". $this->getTitle() . "' onselect=\"xoopsSavePosition('" . $this->getName() . "');\" onclick=\"xoopsSavePosition('" . $this->getName() . "');\" onkeyup=\"xoopsSavePosition('" . $this->getName() . "');\" cols='" . $this->getCols() . "' rows='" . $this->getRows() . "'" . $this->getExtra() . ">" . $this->getValue() . "</textarea><br />\n"; if (empty($this->skipPreview)) { if (empty($GLOBALS['xoTheme'])) { @@ -214,20 +214,20 @@ $textarea_id = $this->getName(); $hiddentext = $this->_hiddenText; - $fontStr = "<script type=\"text/javascript\">" . "var _editor_dialog = ''" . "+ '<select id=\'{$textarea_id}Size\' onchange=\'xoopsSetElementAttribute(\"size\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" . "+ '<option value=\'SIZE\'>" . _SIZE . "</option>'"; + $fontStr = "<script type=\"text/javascript\">" . "var _editor_dialog = ''" . "+ '<select class=\"form-control\" id=\'{$textarea_id}Size\' onchange=\'xoopsSetElementAttribute(\"size\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" . "+ '<option value=\'SIZE\'>" . _SIZE . "</option>'"; foreach ($GLOBALS["formtextdhtml_sizes"] as $_val => $_name) { $fontStr .= " + '<option value=\'{$_val}\'>{$_name}</option>'"; } ; $fontStr .= " + '</select> '"; - $fontStr .= "+ '<select id=\'{$textarea_id}Font\' onchange=\'xoopsSetElementAttribute(\"font\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" . "+ '<option value=\'FONT\'>" . _FONT . "</option>'"; + $fontStr .= "+ '<select class=\"form-control\" id=\'{$textarea_id}Font\' onchange=\'xoopsSetElementAttribute(\"font\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" . "+ '<option value=\'FONT\'>" . _FONT . "</option>'"; $fontarray = ! empty($GLOBALS["formtextdhtml_fonts"]) ? $GLOBALS["formtextdhtml_fonts"] : array("Arial" , "Courier" , "Georgia" , "Helvetica" , "Impact" , "Verdana" , "Haettenschweiler"); foreach ($fontarray as $font) { $fontStr .= " + '<option value=\'{$font}\'>{$font}</option>'"; } ; $fontStr .= " + '</select> '"; - $fontStr .= "+ '<select id=\'{$textarea_id}Color\' onchange=\'xoopsSetElementAttribute(\"color\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" . "+ '<option value=\'COLOR\'>" . _COLOR . "</option>';" . "var _color_array = new Array('00', '33', '66', '99', 'CC', 'FF'); + $fontStr .= "+ '<select class=\"form-control\" id=\'{$textarea_id}Color\' onchange=\'xoopsSetElementAttribute(\"color\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" . "+ '<option value=\'COLOR\'>" . _COLOR . "</option>';" . "var _color_array = new Array('00', '33', '66', '99', 'CC', 'FF'); for (var i = 0; i < _color_array.length; i ++) { for (var j = 0; j < _color_array.length; j ++) { for (var k = 0; k < _color_array.length; k ++) { Added: XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formpassword.php =================================================================== --- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formpassword.php (rev 0) +++ XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formpassword.php 2015-02-19 09:37:52 UTC (rev 13002) @@ -0,0 +1,132 @@ +<?php +/** + * Password form element + * + * 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. + * + * @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 kernel + * @subpackage form + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @author Taiwen Jiang <ph...@us...> + * @version $Id: formpassword.php 12537 2014-05-19 14:19:33Z beckmi $ + */ +defined('XOOPS_ROOT_PATH') || die('Restricted access'); + +/** + * Password Field + */ +class XoopsFormPassword extends XoopsFormElement +{ + /** + * Size of the field. + * + * @var int + * @access private + */ + var $_size; + + /** + * Maximum length of the text + * + * @var int + * @access private + */ + var $_maxlength; + + /** + * Initial content of the field. + * + * @var string + * @access private + */ + var $_value; + + /** + * Cache password with browser. Disabled by default for security consideration + * Added in 2.3.1 + * + * @var boolean + * @access public + */ + var $autoComplete = false; + + /** + * Constructor + * + * @param string $caption Caption + * @param string $name "name" attribute + * @param int $size Size of the field + * @param int $maxlength Maximum length of the text + * @param string $value Initial value of the field. + * <strong>Warning:</strong> this is readable in cleartext in the page's source! + * @param bool $autoComplete To enable autoComplete or browser cache + */ + function XoopsFormPassword($caption, $name, $size, $maxlength, $value = '', $autoComplete = false) + { + $this->setCaption($caption); + $this->setName($name); + $this->_size = intval($size); + $this->_maxlength = intval($maxlength); + $this->setValue($value); + $this->autoComplete = ! empty($autoComplete); + } + + /** + * Get the field size + * + * @return int + */ + function getSize() + { + return $this->_size; + } + + /** + * Get the max length + * + * @return int + */ + function getMaxlength() + { + return $this->_maxlength; + } + + /** + * Get the "value" attribute + * + * @param bool $encode To sanitizer the text? + * @return string + */ + function getValue($encode = false) + { + return $encode ? htmlspecialchars($this->_value, ENT_QUOTES) : $this->_value; + } + + /** + * Set the initial value + * + * @patam $value string + */ + function setValue($value) + { + $this->_value = $value; + } + + /** + * Prepare HTML for output + * + * @return string HTML + */ + function render() + { + return '<input type="password" name="' . $this->getName() . '" id="' . $this->getName() . '" class="form-control" size="' . $this->getSize() . '" maxlength="' . $this->getMaxlength() . '" value="' . $this->getValue() . '"' . $this->getExtra() . ' ' . ($this->autoComplete ? '' : 'autocomplete="off" ') . '/>'; + } +} Modified: XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formselect.php =================================================================== --- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formselect.php 2015-02-18 23:25:57 UTC (rev 13001) +++ XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formselect.php 2015-02-19 09:37:52 UTC (rev 13002) @@ -204,7 +204,7 @@ $ele_title = $this->getTitle(); $ele_value = $this->getValue(); $ele_options = $this->getOptions(); - $ret = '<select size="' . $this->getSize() . '"' . $this->getExtra(); + $ret = '<select class="form-control" size="' . $this->getSize() . '"' . $this->getExtra(); if ($this->isMultiple() != false) { $ret .= ' multiple name="' . $ele_name . '[]" id="' . $ele_name . '" title="'. $ele_title. '">'; } else { Added: XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtext.php =================================================================== --- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtext.php (rev 0) +++ XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtext.php 2015-02-19 09:37:52 UTC (rev 13002) @@ -0,0 +1,120 @@ +<?php +/** + * XOOPS form element + * + * 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. + * + * @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 kernel + * @subpackage form + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @version $Id: formtext.php 12537 2014-05-19 14:19:33Z beckmi $ + */ + +defined('XOOPS_ROOT_PATH') || die('Restricted access'); + +/** + * A simple text field + */ +class XoopsFormText extends XoopsFormElement +{ + /** + * Size + * + * @var int + * @access private + */ + var $_size; + + /** + * Maximum length of the text + * + * @var int + * @access private + */ + var $_maxlength; + + /** + * Initial text + * + * @var string + * @access private + */ + var $_value; + + /** + * 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 + */ + function XoopsFormText($caption, $name, $size, $maxlength, $value = '') + { + $this->setCaption($caption); + $this->setName($name); + $this->_size = intval($size); + $this->_maxlength = intval($maxlength); + $this->setValue($value); + } + + /** + * Get size + * + * @return int + */ + function getSize() + { + return $this->_size; + } + + /** + * Get maximum text length + * + * @return int + */ + function getMaxlength() + { + return $this->_maxlength; + } + + /** + * Get initial content + * + * @param bool $encode To sanitizer the text? Default value should be "true"; however we have to set "false" for backward compatibility + * @return string + */ + function getValue($encode = false) + { + return $encode ? htmlspecialchars($this->_value, ENT_QUOTES) : $this->_value; + } + + /** + * Set initial text value + * + * @param $value string + */ + function setValue($value) + { + $this->_value = $value; + } + + /** + * Prepare HTML for output + * + * @return string HTML + */ + function render() + { + return "<input type='text' name='" . $this->getName() . "' class='form-control' title='" . $this->getTitle() . "' id='" . $this->getName() . "' size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $this->getValue() . "'" . $this->getExtra() . " />"; + } +} \ No newline at end of file Added: XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtextarea.php =================================================================== --- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtextarea.php (rev 0) +++ XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/formtextarea.php 2015-02-19 09:37:52 UTC (rev 13002) @@ -0,0 +1,122 @@ +<?php +/** + * XOOPS form element + * + * 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. + * + * @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 kernel + * @subpackage form + * @since 2.0.0 + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ + * @version $Id: formtextarea.php 12537 2014-05-19 14:19:33Z beckmi $ + */ + +defined('XOOPS_ROOT_PATH') || die('Restricted access'); + +xoops_load('XoopsFormElement'); + +/** + * A textarea + */ +class XoopsFormTextArea extends XoopsFormElement +{ + /** + * number of columns + * + * @var int + * @access private + */ + var $_cols; + + /** + * number of rows + * + * @var int + * @access private + */ + var $_rows; + + /** + * initial content + * + * @var string + * @access private + */ + var $_value; + + /** + * Constuctor + * + * @param string $caption caption + * @param string $name name + * @param string $value initial content + * @param int $rows number of rows + * @param int $cols number of columns + */ + function XoopsFormTextArea($caption, $name, $value = "", $rows = 5, $cols = 50) + { + $this->setCaption($caption); + $this->setName($name); + $this->_rows = intval($rows); + $this->_cols = intval($cols); + $this->setValue($value); + } + + /** + * get number of rows + * + * @return int + */ + function getRows() + { + return $this->_rows; + } + + /** + * Get number of columns + * + * @return int + */ + function getCols() + { + return $this->_cols; + } + + /** + * Get initial content + * + * @param bool $encode To sanitizer the text? Default value should be "true"; however we have to set "false" for backward compatibility + * @return string + */ + function getValue($encode = false) + { + return $encode ? htmlspecialchars($this->_value) : $this->_value; + } + + /** + * Set initial content + * + * @param $value string + */ + function setValue($value) + { + $this->_value = $value; + } + + /** + * prepare HTML for output + * + * @return sting HTML + */ + function render() + { + return "<textarea name='" . $this->getName() . "' id='" . $this->getName() . "' class=\"form-control\" title='" . $this->getTitle() . "' rows='" . $this->getRows() . "' cols='" . $this->getCols() . "'" . $this->getExtra() . ">" . $this->getValue() . "</textarea>"; + } +} Added: XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/grouppermform.php =================================================================== --- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/grouppermform.php (rev 0) +++ XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/class/xoopsform/grouppermform.php 2015-02-19 09:37:52 UTC (rev 13002) @@ -0,0 +1,320 @@ +<?php +/** + * XOOPS form element + * + * 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. + * + * @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 kernel + * @subpackage form + * @since 2.0.0 + * @version $Id: grouppermform.php 12537 2014-05-19 14:19:33Z beckmi $ + */ + +defined('XOOPS_ROOT_PATH') || die('Restricted access'); + +xoops_load('XoopsFormElement'); +xoops_load('XoopsFormHidden'); +xoops_load('XoopsFormHiddenToken'); +xoops_load('XoopsForm'); +xoops_load('XoopsFormElementTray'); +xoops_load('XoopsFormButton'); + +/** + * Renders a form for setting module specific group permissions + */ +class XoopsGroupPermForm extends XoopsForm +{ + /** + * Module ID + * + * @var int + */ + var $_modid; + /** + * Tree structure of items + * + * @var array + */ + var $_itemTree = array(); + /** + * Name of permission + * + * @var string + */ + var $_permName; + /** + * Description of permission + * + * @var string + */ + var $_permDesc; + + /** + * Whether to include anonymous users + * + * @var bool + */ + var $_showAnonymous; + + /** + * Constructor + */ + function XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url = '', $anonymous = true) + { + $this->XoopsForm($title, 'groupperm_form', XOOPS_URL . '/modules/system/admin/groupperm.php', 'post'); + $this->_modid = intval($modid); + $this->_permName = $permname; + $this->_permDesc = $permdesc; + $this->addElement(new XoopsFormHidden('modid', $this->_modid)); + $this->addElement(new XoopsFormHiddenToken($permname)); + if ($url != "") { + $this->addElement(new XoopsFormHidden('redirect_url', $url)); + } + $this->_showAnonymous = $anonymous; + } + + /** + * Adds an item to which permission will be assigned + * + * @param string $itemName + * @param int $itemId + * @param int $itemParent + * @access public + */ + function addItem($itemId, $itemName, $itemParent = 0) + { + $this->_itemTree[$itemParent]['children'][] = $itemId; + $this->_itemTree[$itemId]['parent'] = $itemParent; + $this->_itemTree[$itemId]['name'] = $itemName; + $this->_itemTree[$itemId]['id'] = $itemId; + } + + /** + * Loads all child ids for an item to be used in javascript + * + * @param int $itemId + * @param array $childIds + * @access private + */ + function _loadAllChildItemIds($itemId, &$childIds) + { + if (! empty($this->_itemTree[$itemId]['children'])) { + $first_child = $this->_itemTree[$itemId]['children']; + foreach($first_child as $fcid) { + array_push($childIds, $fcid); + if (! empty($this->_itemTree[$fcid]['children'])) { + foreach($this->_itemTree[$fcid]['children'] as $_fcid) { + array_push($childIds, $_fcid); + $this->_loadAllChildItemIds($_fcid, $childIds); + } + } + } + } + } + + /** + * Renders the form + * + * @return string + * @access public + */ + function render() + { + // load all child ids for javascript codes + foreach(array_keys($this->_itemTree) as $item_id) { + $this->_itemTree[$item_id]['allchild'] = array(); + $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); + } + $gperm_handler = &xoops_gethandler('groupperm'); + $member_handler = &xoops_gethandler('member'); + $glist = $member_handler->getGroupList(); + foreach(array_keys($glist) as $i) { + if ($i == XOOPS_GROUP_ANONYMOUS && ! $this->_showAnonymous) + continue; + // get selected item id(s) for each group + $selected = $gperm_handler->getItemIds($this->_permName, $i, $this->_modid); + $ele = new XoopsGroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); + $ele->setOptionTree($this->_itemTree); + $this->addElement($ele); + unset($ele); + } + $tray = new XoopsFormElementTray(''); + $tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); + $tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset')); + $this->addElement($tray); + + $ret = '<h4>' . $this->getTitle() . '</h4>'; + if ($this->_permDesc) { + $ret .= $this->_permDesc . '<br /><br />'; + } + $ret .= '<form title="' . str_replace('"', '', $this->getTitle()) . '" name="' . $this->getName() . '" id="' . $this->getName() . '" action="' . $this->getAction() . '" method="' . $this->getMethod() . '"' . $this->getExtra() . '>' . '<table width="100%" class="outer" cellspacing="1" valign="top">' ; + $elements = $this->getElements(); + $hidden = ''; + foreach(array_keys($elements) as $i) { + if (! is_object($elements[$i])) { + $ret .= $elements[$i]; + } elseif (! $elements[$i]->isHidden()) { + $ret .= '<tr valign="top" class="left"><td class="head">' . $elements[$i]->getCaption(); + if ($elements[$i]->getDescription() != "") { + $ret .= "<br /><br /><span style='font-weight: normal;'>" . $elements[$i]->getDescription() . "</span>"; + } + $ret .= '</td>' . '<td class="even">' . $elements[$i]->render() . '</td></tr>' . ''; + } else { + $hidden .= $elements[$i]->render(); + } + } + $ret .= '</table>' . $hidden . '</form>'; + $ret .= $this->renderValidationJS(true); + return $ret; + } +} + +/** + * Renders checkbox options for a group permission form + */ +class XoopsGroupFormCheckBox extends XoopsFormElement +{ + /** + * Pre-selected value(s) + * + * @var array ; + */ + var $_value = array(); + /** + * Group ID + * + * @var int + */ + var $_groupId; + /** + * Option tree + * + * @var array + */ + var $_optionTree = array(); + + /** + * Constructor + */ + function XoopsGroupFormCheckBox($caption, $name, $groupId, $values = null) + { + $this->setCaption($caption); + $this->setName($name); + if (isset($values)) { + $this->setValue($values); + } + $this->_groupId = $groupId; + } + + /** + * Sets pre-selected values + * + * @param mixed $value A group ID or an array of group IDs + * @access public + */ + function setValue($value) + { + if (is_array($value)) { + foreach($value as $v) { + $this->setValue($v); + } + } else { + $this->_value[] = $value; + } + } + + /** + * Sets the tree structure of items + * + * @param array $optionTree + * @access public + */ + function setOptionTree(&$optionTree) + { + $this->_optionTree = &$optionTree; + } + + /** + * Renders checkbox options for this group + * + * @return string + * @access public + */ + function render() + { + $ele_name = $this->getName(); + $ret = '<table class="table table-bordered"><tr><td class="odd"><table class="table table-striped"><tr>'; + $cols = 1; + foreach($this->_optionTree[0]['children'] as $topitem) { + if ($cols > 4) { + $ret .= '</tr><tr>'; + $cols = 1; + } + $tree = '<td valign="top">'; + $prefix = ''; + $this->_renderOptionTree($tree, $this->_optionTree[$topitem], $prefix); + $ret .= $tree . '</td>'; + $cols ++; + } + $ret .= '</tr></table></td><td class="even" valign="top">'; + $option_ids = array(); + foreach(array_keys($this->_optionTree) as $id) { + if (! empty($id)) { + $option_ids[] = "'" . $ele_name . '[groups][' . $this->_groupId . '][' . $id . ']' . "'"; + } + } + $checkallbtn_id = $ele_name . '[checkallbtn][' . $this->_groupId . ']'; + $option_ids_str = implode(', ', $option_ids); + $ret .= _ALL . " <input id=\"" . $checkallbtn_id . "\" type=\"checkbox\" value=\"\" onclick=\"var optionids = new Array(" . $option_ids_str . "); xoopsCheckAllElements(optionids, '" . $checkallbtn_id . "');\" />"; + $ret .= '</td></tr></table>'; + return $ret; + } + + /** + * Renders checkbox options for an item tree + * + * @param string $tree + * @param array $option + * @param string $prefix + * @param array $parentIds + * @access private + */ + function _renderOptionTree(&$tree, $option, $prefix, $parentIds = array()) + { + $ele_name = $this->getName(); + $tree .= $prefix . "<input type=\"checkbox\" name=\"" . $ele_name . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" id=\"" . $ele_name . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" onclick=\""; + // If there are parent elements, add javascript that will + // make them selecteded when this element is checked to make + // sure permissions to parent items are added as well. + foreach($parentIds as $pid) { + $parent_ele = $ele_name . '[groups][' . $this->_groupId . '][' . $pid . ']'; + $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if(ele.checked != true) {ele.checked = this.checked;}"; + } + // If there are child elements, add javascript that will + // make them unchecked when this element is unchecked to make + // sure permissions to child items are not added when there + // is no permission to this item. + foreach($option['allchild'] as $cid) { + $child_ele = $ele_name . '[groups][' . $this->_groupId . '][' . $cid . ']'; + $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if(this.checked != true) {ele.checked = false;}"; + } + $tree .= '" value="1"'; + if (in_array($option['id'], $this->_value)) { + $tree .= ' checked="checked"'; + } + $tree .= " />" . $option['name'] . "<input type=\"hidden\" name=\"" . $ele_name . "[parents][" . $option['id'] . "]\" value=\"" . implode(':', $parentIds) . "\" /><input type=\"hidden\" name=\"" . $ele_name . "[itemname][" . $option['id'] . "]\" value=\"" . htmlspecialchars($option['name']) . "\" /><br />\n"; + if (isset($option['children'])) { + foreach($option['children'] as $child) { + array_push($parentIds, $option['id']); + $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); + } + } + } +} Modified: XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/modules/profile/templates/profile_form.html =================================================================== --- XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/modules/profile/templates/profile_form.html 2015-02-18 23:25:57 UTC (rev 13001) +++ XoopsCore/branches/2.5.x/2.5.8_timgno/htdocs/modules/profile/templates/profile_form.html 2015-02-19 09:37:52 UTC (rev 13002) @@ -1,6 +1,6 @@ <{$xoForm.javascript}> - <form id="<{$xoForm.name}>" name="<{$xoForm.name}>" action="<{$xoForm.action}>" method="<{$xoForm.method}>" <{$xoForm.extra}> > + <form class='form-inline' id="<{$xoForm.name}>" name="<{$xoForm.name}>" action="<{$xoForm.action}>" method="<{$xoForm.method}>" <{$xoForm.extra}> > <table class="table table-bordered" id="profile-form-<{$xoForm.name}>"> <tbody> <{foreach item=element from=$xoForm.elements}> @@ -16,7 +16,9 @@ <{/if}> </td> <td class="<{cycle values='odd, even'}>"> - <{$element.body}> + <div class="form-group"> + <{$element.body}> + </div> </td> </tr> <{/if}> |