Fixing advmultiselect form icons see BT#5768

skala
Julio Montoya 13 years ago
parent 4ac57a8df5
commit bd19ed2d8e
  1. 284
      main/group/group_edit.php
  2. 11
      main/inc/lib/pear/HTML/QuickForm/advanced_settings.php
  3. 583
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  4. 20
      main/inc/lib/pear/HTML/QuickForm/label.php
  5. 75
      main/survey/survey_invite.php

@ -27,12 +27,12 @@ $group_id = api_get_group_id();
$current_group = GroupManager :: get_group_properties($group_id);
$nameTools = get_lang('EditGroup');
$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => 'group_space.php?'.api_get_cidReq(), 'name' => $current_group['name']);
$interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => 'group_space.php?'.api_get_cidReq(), 'name' => $current_group['name']);
$is_group_member = GroupManager :: is_tutor_of_group(api_get_user_id(), $group_id);
if (!api_is_allowed_to_edit(false,true) && !$is_group_member) {
if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
api_not_allowed(true);
}
@ -41,8 +41,13 @@ if (!api_is_allowed_to_edit(false,true) && !$is_group_member) {
/**
* List all users registered to the course
*/
function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword) {
if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos($username, $keyword) !== false || api_strripos($official_code, $keyword) !== false) {
function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword)
{
if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos(
$username,
$keyword
) !== false || api_strripos($official_code, $keyword) !== false
) {
return true;
} else {
return false;
@ -53,7 +58,8 @@ function search_members_keyword($firstname, $lastname, $username, $official_code
/**
* function to sort users after getting the list in the db. Necessary because there are 2 or 3 queries. Called by usort()
*/
function sort_users($user_a, $user_b) {
function sort_users($user_a, $user_b)
{
if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
@ -84,7 +90,8 @@ function sort_users($user_a, $user_b) {
/**
* Function to check the given max number of members per group
*/
function check_max_number_of_members($value) {
function check_max_number_of_members($value)
{
$max_member_no_limit = $value['max_member_no_limit'];
if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
return true;
@ -96,12 +103,16 @@ function check_max_number_of_members($value) {
/**
* Function to check if the number of selected group members is valid
*/
function check_group_members($value) {
function check_group_members($value)
{
if ($value['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
return true;
}
if (isset($value['max_member']) && isset($value['group_members']) && $value['max_member'] < count($value['group_members'])) {
return array ('group_members' => get_lang('GroupTooMuchMembers'));
if (isset($value['max_member']) && isset($value['group_members']) && $value['max_member'] < count(
$value['group_members']
)
) {
return array('group_members' => get_lang('GroupTooMuchMembers'));
}
return true;
}
@ -127,14 +138,17 @@ $form->addElement('hidden', 'referer');
$form->add_textfield('name', get_lang('GroupName'));
// Description
$form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6));
$form->addElement('textarea', 'description', get_lang('Description'), array('class' => 'span6', 'rows' => 6));
$complete_user_list = GroupManager :: fill_groups_list($current_group['id']);
usort($complete_user_list, 'sort_users');
$possible_users = array();
foreach ($complete_user_list as $index => $user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
$possible_users[$user['user_id']] = api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')';
}
// Group tutors
@ -145,27 +159,14 @@ foreach ($group_tutor_list as $index => $user) {
$selected_tutors[] = $user['user_id'];
}
$group_tutors_element = $form->addElement('advmultiselect', 'group_tutors', get_lang('GroupTutors'), $possible_users, 'style="width: 280px;"');
$group_tutors_element->setElementTemplate('
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}<br /><br />{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
');
$group_tutors_element->setButtonAttributes('add', array('class' => 'btn arrowr'));
$group_tutors_element->setButtonAttributes('remove', array('class' => 'btn arrowl'));
$group_tutors_element = $form->addElement('advmultiselect', 'group_tutors', get_lang('GroupTutors'), $possible_users);
$group_tutors_element->setButtonAttributes('add');
$group_tutors_element->setButtonAttributes('remove');
// Group members
$group_member_list = GroupManager :: get_subscribed_users($current_group['id']);
$selected_users = array ();
$selected_users = array();
foreach ($group_member_list as $index => $user) {
$selected_users[] = $user['user_id'];
}
@ -173,33 +174,41 @@ foreach ($group_member_list as $index => $user) {
// possible : number_groups_left > 0 and is group member
$possible_users = array();
foreach ($complete_user_list as $index => $user) {
if ($user['number_groups_left'] > 0 || in_array($user['user_id'], $selected_users) ) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
if ($user['number_groups_left'] > 0 || in_array($user['user_id'], $selected_users)) {
$possible_users[$user['user_id']] = api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')';
}
}
$group_members_element = $form->addElement('advmultiselect', 'group_members', get_lang('GroupMembers'), $possible_users, 'style="width: 280px;"');
$group_members_element->setElementTemplate('
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}<br /><br />{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>');
$group_members_element->setButtonAttributes('add', array('class' => 'btn arrowr'));
$group_members_element->setButtonAttributes('remove', array('class' => 'btn arrowl'));
$group_members_element = $form->addElement(
'advmultiselect',
'group_members',
get_lang('GroupMembers'),
$possible_users
);
$group_members_element->setButtonAttributes('add');
$group_members_element->setButtonAttributes('remove');
$form->addFormRule('check_group_members');
// Members per group
$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), GroupManager::MEMBER_PER_GROUP_NO_LIMIT);
$form->addElement(
'radio',
'max_member_no_limit',
get_lang('GroupLimit'),
get_lang('NoLimit'),
GroupManager::MEMBER_PER_GROUP_NO_LIMIT
);
$group = array();
$group[] = $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1, array('id' => 'max_member_selected'));
$group[] = $form->createElement(
'radio',
'max_member_no_limit',
null,
get_lang('MaximumOfParticipants'),
1,
array('id' => 'max_member_selected')
);
$group[] = $form->createElement('text', 'max_member', null, array('class' => 'span1', 'id' => 'max_member'));
$group[] = $form->createElement('static', null, null, get_lang('GroupPlacesThis'));
$form->addGroup($group, 'max_member_group', null, '', false);
@ -207,58 +216,168 @@ $form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callb
// Self registration
$group = array();
$group[] = $form->createElement('checkbox', 'self_registration_allowed', get_lang('GroupSelfRegistration'), get_lang('GroupAllowStudentRegistration'), 1);
$group[] = $form->createElement('checkbox', 'self_unregistration_allowed', null, get_lang('GroupAllowStudentUnregistration'), 1);
$form->addGroup($group, '', Display::return_icon('user.png', get_lang('GroupSelfRegistration') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupSelfRegistration'), '', false);
$group[] = $form->createElement(
'checkbox',
'self_registration_allowed',
get_lang('GroupSelfRegistration'),
get_lang('GroupAllowStudentRegistration'),
1
);
$group[] = $form->createElement(
'checkbox',
'self_unregistration_allowed',
null,
get_lang('GroupAllowStudentUnregistration'),
1
);
$form->addGroup(
$group,
'',
Display::return_icon('user.png', get_lang('GroupSelfRegistration'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupSelfRegistration'
),
'',
false
);
// Documents settings
$group = array();
$group[] = $form->createElement('radio', 'doc_state', get_lang('GroupDocument'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE);
$group[] = $form->createElement(
'radio',
'doc_state',
get_lang('GroupDocument'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('folder.png', get_lang('GroupDocument') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupDocument'), '', false);
$form->addGroup(
$group,
'',
Display::return_icon('folder.png', get_lang('GroupDocument'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupDocument'
),
'',
false
);
// Work settings
$group = array();
$group[] = $form->createElement('radio', 'work_state', get_lang('GroupWork'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE);
$group[] = $form->createElement(
'radio',
'work_state',
get_lang('GroupWork'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'work_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'work_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('work.png', get_lang('GroupWork') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupWork'), '', false);
$form->addGroup(
$group,
'',
Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_SMALL).' '.get_lang('GroupWork'),
'',
false
);
// Calendar settings
$group = array();
$group[] = $form->createElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE);
$group[] = $form->createElement(
'radio',
'calendar_state',
get_lang('GroupCalendar'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('agenda.png', get_lang('GroupCalendar') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupCalendar'), '', false);
$form->addGroup(
$group,
'',
Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupCalendar'
),
'',
false
);
// Announcements settings
$group = array();
$group[] = $form->createElement('radio', 'announcements_state', get_lang('GroupAnnouncements'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE);
$group[] = $form->createElement(
'radio',
'announcements_state',
get_lang('GroupAnnouncements'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('announce.png', get_lang('GroupAnnouncements') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupAnnouncements'), '', false);
$form->addGroup(
$group,
'',
Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), ICON_SIZE_SMALL).' '.get_lang(
'GroupAnnouncements'
),
'',
false
);
//Forum settings
$group = array();
$group[] = $form->createElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE);
$group[] = $form->createElement(
'radio',
'forum_state',
get_lang('GroupForum'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('forum.png', get_lang('GroupForum') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupForum'), '', false);
$form->addGroup(
$group,
'',
Display::return_icon('forum.png', get_lang('GroupForum'), array(), ICON_SIZE_SMALL).' '.get_lang('GroupForum'),
'',
false
);
// Wiki settings
$group = array();
$group[] = $form->createElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE);
$group[] = $form->createElement(
'radio',
'wiki_state',
get_lang('GroupWiki'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('wiki.png', get_lang('GroupWiki') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupWiki'), '', false);
$form->addGroup(
$group,
'',
Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), ICON_SIZE_SMALL).' '.get_lang('GroupWiki'),
'',
false
);
// Chat settings
$group = array();
$group[] = $form->createElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE);
$group[] = $form->createElement(
'radio',
'chat_state',
get_lang('Chat'),
get_lang('NotAvailable'),
GroupManager::TOOL_NOT_AVAILABLE
);
$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC);
$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE);
$form->addGroup($group, '', Display::return_icon('chat.png', get_lang('Chat') , array(), ICON_SIZE_SMALL).' '.get_lang('Chat'), '', false);
$form->addGroup(
$group,
'',
Display::return_icon('chat.png', get_lang('Chat'), array(), ICON_SIZE_SMALL).' '.get_lang('Chat'),
'',
false
);
// submit button
$form->addElement('style_submit_button', 'submit', get_lang('PropModify'), 'class="save"');
@ -272,7 +391,21 @@ if ($form->validate()) {
}
$self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0;
$self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0;
GroupManager :: set_group_properties($current_group['id'], strip_tags($values['name']), strip_tags($values['description']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_registration_allowed, $self_unregistration_allowed);
GroupManager :: set_group_properties(
$current_group['id'],
strip_tags($values['name']),
strip_tags($values['description']),
$max_member,
$values['doc_state'],
$values['work_state'],
$values['calendar_state'],
$values['announcements_state'],
$values['forum_state'],
$values['wiki_state'],
$values['chat_state'],
$self_registration_allowed,
$self_unregistration_allowed
);
// Storing the tutors (we first remove all the tutors and then add only those who were selected)
GroupManager :: unsubscribe_all_tutors($current_group['id']);
@ -288,10 +421,21 @@ if ($form->validate()) {
// Returning to the group area (note: this is inconsistent with the rest of chamilo)
$cat = GroupManager :: get_category_from_group($current_group['id']);
if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers'));
if (isset($_POST['group_members']) && count(
$_POST['group_members']
) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT
) {
header(
'Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang(
'GroupTooMuchMembers'
)
);
} else {
header('Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']);
header(
'Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang(
'GroupSettingsModified'
).'&category='.$cat['id']
);
}
exit;
}

@ -42,14 +42,15 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
* @access public
* @return void
*/
function accept(&$renderer, $required=false, $error=null)
function accept(&$renderer, $required = false, $error = null)
{
$renderer->renderHtml($this);
} // end func accept
function toHtml() {
return '<div class="control-group ">
function toHtml()
{
return '<div class="control-group">
<label class="control-label"></label>
<div class="controls">
'.HTML_QuickForm_static::toHtml().'
@ -57,5 +58,5 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
</div>
';
} //end func toHtml
} //end class HTML_QuickForm_html
}
}

@ -274,14 +274,21 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
* @return void
* @since version 0.4.0 (2005-06-25)
*/
function HTML_QuickForm_advmultiselect($elementName = null, $elementLabel = null,
$options = null, $attributes = null,
$sort = null)
{
function HTML_QuickForm_advmultiselect(
$elementName = null,
$elementLabel = null,
$options = null,
$attributes = null,
$sort = null
) {
$opts = $options;
$options = null; // prevent to use the default select element load options
$this->HTML_QuickForm_select($elementName, $elementLabel,
$options, $attributes);
$this->HTML_QuickForm_select(
$elementName,
$elementLabel,
$options,
$attributes
);
// allow to load options at once and take care of fancy attributes
$this->load($opts);
@ -295,17 +302,17 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
}
if (is_null($this->getAttribute('style'))) {
// default width of each select box
$this->updateAttributes(array('style' => 'width:100px;'));
//$this->updateAttributes(array('style' => 'min-width:100px;'));
}
$this->_tableAttributes = $this->getAttribute('class');
if (is_null($this->_tableAttributes)) {
// default table layout
$attr = array('border' => '0',
'cellpadding' => '10', 'cellspacing' => '0');
$this->updateAttributes(array('class' => 'span4'));
} else {
$attr = array('class' => $this->_tableAttributes);
$this->_removeAttr('class', $this->_attributes);
}
$this->_tableAttributes = $this->_getAttrString($attr);
// set default add button attributes
@ -395,117 +402,158 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
function setButtonAttributes($button, $attributes = null)
{
if (!is_string($button)) {
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' .
return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'setButtonAttributes is not a string',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception'));
array('level' => 'exception')
);
}
switch ($button) {
case 'add':
if (is_null($attributes)) {
$this->_addButtonAttributes
= array('name' => 'add',
'value' => ' ',
'type' => 'button');
= array(
'name' => 'add',
'value' => '',
'type' => 'button'
);
$this->setValue('<i class="icon-shopping-cart icon-large"></i>');
} else {
$this->_updateAttrArray($this->_addButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_addButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'remove':
if (is_null($attributes)) {
$this->_removeButtonAttributes
= array('name' => 'remove',
= array(
'name' => 'remove',
'value' => ' ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_removeButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_removeButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'all':
if (is_null($attributes)) {
$this->_allButtonAttributes
= array('name' => 'all',
= array(
'name' => 'all',
'value' => ' Select All ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_allButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_allButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'none':
if (is_null($attributes)) {
$this->_noneButtonAttributes
= array('name' => 'none',
= array(
'name' => 'none',
'value' => ' Select None ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_noneButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_noneButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'toggle':
if (is_null($attributes)) {
$this->_toggleButtonAttributes
= array('name' => 'toggle',
= array(
'name' => 'toggle',
'value' => ' Toggle Selection ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_toggleButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_toggleButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'moveup':
if (is_null($attributes)) {
$this->_upButtonAttributes
= array('name' => 'up',
= array(
'name' => 'up',
'value' => ' Up ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_upButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_upButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'movedown':
if (is_null($attributes)) {
$this->_downButtonAttributes
= array('name' => 'down',
= array(
'name' => 'down',
'value' => ' Down ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_downButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_downButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'movetop':
if (is_null($attributes)) {
$this->_topButtonAttributes
= array('name' => 'top',
= array(
'name' => 'top',
'value' => ' Top ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_topButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_topButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
case 'movebottom':
if (is_null($attributes)) {
$this->_bottomButtonAttributes
= array('name' => 'bottom',
= array(
'name' => 'bottom',
'value' => ' Bottom ',
'type' => 'button');
'type' => 'button'
);
} else {
$this->_updateAttrArray($this->_bottomButtonAttributes,
$this->_parseAttributes($attributes));
$this->_updateAttrArray(
$this->_bottomButtonAttributes,
$this->_parseAttributes($attributes)
);
}
break;
default;
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' .
return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'setButtonAttributes has unexpected value',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'error'));
array('level' => 'error')
);
}
}
@ -524,26 +572,24 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$oldTemplate = $this->_elementTemplate;
if (isset($html) && is_string($html)) {
$this->_elementTemplate = $html;
// $this->_elementTemplate = $html;
} else {
/*<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->*/
$this->_elementTemplate = '
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
';
{javascript}
<div class="advmultiselect row">
<div class="span4">{unselected}</div>
<div class="span1">{add} <br /><br />{remove}</div>
<div class="span4">{selected}</div>
</div>
';
}
if ($js == false) {
$this->_elementTemplate = str_replace('{javascript}', '',
$this->_elementTemplate);
$this->_elementTemplate = str_replace('{javascript}', '', $this->_elementTemplate);
}
return $oldTemplate;
//return $oldTemplate;
}
/**
@ -571,14 +617,14 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$css = str_replace('{id}', $id, $this->_elementCSS);
if ($raw !== true) {
$css = '<style type="text/css">' . PHP_EOL
$css = '<style type="text/css">'.PHP_EOL
// Modified by Chamilo team, 16-MAR-2010.
//. '<!--' . $css . '// -->' . PHP_EOL
. '/*<![CDATA[*/' . PHP_EOL
. $css . PHP_EOL
. '/*]]>*/' . PHP_EOL
.'/*<![CDATA[*/'.PHP_EOL
.$css.PHP_EOL
.'/*]]>*/'.PHP_EOL
//
. '</style>';
.'</style>';
}
return $css;
}
@ -599,10 +645,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$tabs = $this->_getTabs();
$tab = $this->_getTab();
$selectId = $this->getName();
$selectName = $this->getName() . '[]';
$selectNameFrom = $this->getName() . '-f[]';
$selectNameTo = $this->getName() . '-t[]';
$selectName = $this->getName().'[]';
$selectNameFrom = $this->getName().'-f[]';
$selectNameTo = $this->getName().'-t[]';
$selected_count = 0;
// placeholder {unselected} existence determines if we will render
@ -612,14 +659,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$id = $this->getAttribute('name');
$strHtmlSelected = $tab . '<div id="qfams_'.$id.'">' . PHP_EOL;
$strHtmlSelected = $tab.'<div id="qfams_'.$id.'">'.PHP_EOL;
$unselected_count = count($this->_options);
$checkbox_id_suffix = 0;
foreach ($this->_options as $option) {
$_labelAttributes
= array('style', 'class', 'onmouseover', 'onmouseout');
$_labelAttributes = array('style', 'class', 'onmouseover', 'onmouseout');
$labelAttributes = array();
foreach ($_labelAttributes as $attr) {
if (isset($option['attr'][$attr])) {
@ -629,7 +675,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
}
if (is_array($this->_values)
&& in_array((string)$option['attr']['value'], $this->_values)) {
&& in_array((string)$option['attr']['value'], $this->_values)
) {
// The items is *selected*
$checked = ' checked="checked"';
$selected_count++;
@ -639,17 +686,17 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
}
$checkbox_id_suffix++;
$strHtmlSelected .= $tab
. '<label'
. $this->_getAttrString($labelAttributes) .'>'
. '<input type="checkbox"'
. ' id="'.$selectId . $checkbox_id_suffix.'"'
. ' name="'.$selectName.'"'
. $checked
. $this->_getAttrString($option['attr'])
. ' />' . $option['text'] . '</label>'
. PHP_EOL;
}
$strHtmlSelected .= $tab . '</div>'. PHP_EOL;
.'<label'
.$this->_getAttrString($labelAttributes).'>'
.'<input type="checkbox"'
.' id="'.$selectId.$checkbox_id_suffix.'"'
.' name="'.$selectName.'"'
.$checked
.$this->_getAttrString($option['attr'])
.' />'.$option['text'].'</label>'
.PHP_EOL;
}
$strHtmlSelected .= $tab.'</div>'.PHP_EOL;
$strHtmlHidden = '';
$strHtmlUnselected = '';
@ -657,30 +704,38 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlRemove = '';
// build the select all button with all its attributes
$jsName = $this->_jsPrefix . $this->_jsPostfix;
$attributes = array('onclick' => $jsName .
"('". $selectId ."', 1);");
$jsName = $this->_jsPrefix.$this->_jsPostfix;
$attributes = array(
'onclick' => $jsName.
"('".$selectId."', 1);"
);
$this->_allButtonAttributes
= array_merge($this->_allButtonAttributes, $attributes);
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes);
$strHtmlAll = "<input$attrStrAll />". PHP_EOL;
$strHtmlAll = "<input$attrStrAll />".PHP_EOL;
// build the select none button with all its attributes
$attributes = array('onclick' => $jsName .
"('". $selectId ."', 0);");
$attributes = array(
'onclick' => $jsName.
"('".$selectId."', 0);"
);
$this->_noneButtonAttributes
= array_merge($this->_noneButtonAttributes, $attributes);
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes);
$strHtmlNone = "<input$attrStrNone />". PHP_EOL;
$strHtmlNone = "<input$attrStrNone />".PHP_EOL;
// build the toggle selection button with all its attributes
$attributes = array('onclick' => $jsName .
"('". $selectId ."', 2);");
$attributes = array(
'onclick' => $jsName.
"('".$selectId."', 2);"
);
$this->_toggleButtonAttributes
= array_merge($this->_toggleButtonAttributes,
$attributes);
= array_merge(
$this->_toggleButtonAttributes,
$attributes
);
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes);
$strHtmlToggle = "<input$attrStrToggle />". PHP_EOL;
$strHtmlToggle = "<input$attrStrToggle />".PHP_EOL;
$strHtmlMoveUp = '';
$strHtmlMoveDown = '';
@ -688,45 +743,51 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlMoveBottom = '';
// default selection counters
$strHtmlSelectedCount = $selected_count . '/' . $unselected_count;
$strHtmlSelectedCount = $selected_count.'/'.$unselected_count;
} else {
// ... or a dual multi-select
$this->_jsPostfix = 'moveSelection';
$jsName = $this->_jsPrefix . $this->_jsPostfix;
$jsName = $this->_jsPrefix.$this->_jsPostfix;
// set name of Select From Box
$this->_attributesUnselected
= array('id' => $selectId . '-f',
= array(
'id' => $selectId.'-f',
'name' => $selectNameFrom,
'ondblclick' => $jsName .
'ondblclick' => $jsName.
"('{$selectId}', ".
"this.form.elements['" . $selectNameFrom . "'], " .
"this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "'], " .
"'add', '{$this->_sort}')");
"this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'add', '{$this->_sort}')"
);
$this->_attributesUnselected
= array_merge($this->_attributes, $this->_attributesUnselected);
$attrUnselected = $this->_getAttrString($this->_attributesUnselected);
// set name of Select To Box
$this->_attributesSelected
= array('id' => $selectId . '-t',
= array(
'id' => $selectId.'-t',
'name' => $selectNameTo,
'ondblclick' => $jsName .
"('{$selectId}', " .
"this.form.elements['" . $selectNameFrom . "'], " .
"this.form.elements['" . $selectNameTo . "'], ".
"this.form.elements['" . $selectName . "'], " .
"'remove', '{$this->_sort}')");
'ondblclick' => $jsName.
"('{$selectId}', ".
"this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'remove', '{$this->_sort}')"
);
$this->_attributesSelected
= array_merge($this->_attributes, $this->_attributesSelected);
$attrSelected = $this->_getAttrString($this->_attributesSelected);
// set name of Select hidden Box
$this->_attributesHidden
= array('name' => $selectName,
'style' => 'overflow: hidden; visibility: hidden; ' .
'width: 1px; height: 0;');
= array(
'name' => $selectName,
'style' => 'overflow: hidden; visibility: hidden; '.
'width: 1px; height: 0;'
);
$this->_attributesHidden
= array_merge($this->_attributes, $this->_attributesHidden);
$attrHidden = $this->_getAttrString($this->_attributesHidden);
@ -746,11 +807,16 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
foreach ($this->_options as $option) {
if (is_array($this->_values)
&& in_array((string)$option['attr']['value'],
$this->_values)) {
&& in_array(
(string)$option['attr']['value'],
$this->_values
)
) {
// Get the post order
$key = array_search($option['attr']['value'],
$this->_values);
$key = array_search(
$option['attr']['value'],
$this->_values
);
/** The items is *selected* so we want to put it
in the 'selected' multi-select */
@ -784,13 +850,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
= array_merge($this->_attributes, $this->_attributesUnselected);
$attrUnselected = $this->_getAttrString($this->_attributesUnselected);
}
$strHtmlUnselected = "<select$attrUnselected>". PHP_EOL;
$strHtmlUnselected = "<select$attrUnselected>".PHP_EOL;
if ($unselected_count > 0) {
foreach ($arrHtmlUnselected as $data) {
$strHtmlUnselected
.= $tabs . $tab
. '<option' . $this->_getAttrString($data['attr']) . '>'
. $data['text'] . '</option>' . PHP_EOL;
.= $tabs.$tab
.'<option'.$this->_getAttrString($data['attr']).'>'
.$data['text'].'</option>'.PHP_EOL;
}
} else {
$strHtmlUnselected .= '<option value="">&nbsp;</option>';
@ -806,13 +872,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
= array_merge($this->_attributes, $this->_attributesSelected);
$attrSelected = $this->_getAttrString($this->_attributesSelected);
}
$strHtmlSelected = "<select$attrSelected>". PHP_EOL;
$strHtmlSelected = "<select$attrSelected>".PHP_EOL;
if ($selected_count > 0) {
foreach ($arrHtmlSelected as $data) {
$strHtmlSelected
.= $tabs . $tab
. '<option' . $this->_getAttrString($data['attr']) . '>'
. $data['text'] . '</option>' . PHP_EOL;
.= $tabs.$tab
.'<option'.$this->_getAttrString($data['attr']).'>'
.$data['text'].'</option>'.PHP_EOL;
}
} else {
$strHtmlSelected .= '<option value="">&nbsp;</option>';
@ -820,133 +886,154 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlSelected .= '</select>';
// The 'hidden' multi-select
$strHtmlHidden = "<select$attrHidden>". PHP_EOL;
$strHtmlHidden = "<select$attrHidden>".PHP_EOL;
if (count($arrHtmlHidden) > 0) {
foreach ($arrHtmlHidden as $data) {
$strHtmlHidden
.= $tabs . $tab
. '<option' . $this->_getAttrString($data['attr']) . '>'
. $data['text'] . '</option>' . PHP_EOL;
.= $tabs.$tab
.'<option'.$this->_getAttrString($data['attr']).'>'
.$data['text'].'</option>'.PHP_EOL;
}
}
$strHtmlHidden .= '</select>';
// build the remove button with all its attributes
$attributes
= array('onclick' => $jsName .
"('{$selectId}', " .
"this.form.elements['" . $selectNameFrom . "'], " .
"this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "'], " .
"'remove', '{$this->_sort}'); return false;");
$attributes = array(
'class' => 'btn btn-block ',
'onclick' => $jsName.
"('{$selectId}', ".
"this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'remove', '{$this->_sort}'); return false;"
);
$this->_removeButtonAttributes
= array_merge($this->_removeButtonAttributes, $attributes);
$attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes);
$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL;
//$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL;
$strHtmlRemove = "<button$attrStrRemove /><i class='icon-arrow-left icon-large'></i></button>".PHP_EOL;
// build the add button with all its attributes
$attributes
= array('onclick' => $jsName .
"('{$selectId}', " .
"this.form.elements['" . $selectNameFrom . "'], " .
"this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "'], " .
"'add', '{$this->_sort}'); return false;");
= array(
'class' => 'btn btn-block ',
'onclick' => $jsName.
"('{$selectId}', ".
"this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'add', '{$this->_sort}'); return false;"
);
$this->_addButtonAttributes
= array_merge($this->_addButtonAttributes, $attributes);
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes);
$strHtmlAdd = "<input$attrStrAdd />". PHP_EOL;
$strHtmlAdd = "<button$attrStrAdd /><i class='icon-arrow-right icon-large'></i></button>".PHP_EOL;
// build the select all button with all its attributes
$attributes
= array('onclick' => $jsName .
"('{$selectId}', " .
"this.form.elements['" . $selectNameFrom . "'], " .
"this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "'], " .
"'all', '{$this->_sort}'); return false;");
= array(
'onclick' => $jsName.
"('{$selectId}', ".
"this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'all', '{$this->_sort}'); return false;"
);
$this->_allButtonAttributes
= array_merge($this->_allButtonAttributes, $attributes);
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes);
$strHtmlAll = "<input$attrStrAll />". PHP_EOL;
$strHtmlAll = "<input$attrStrAll />".PHP_EOL;
// build the select none button with all its attributes
$attributes
= array('onclick' => $jsName .
"('{$selectId}', " .
"this.form.elements['" . $selectNameFrom . "'], " .
"this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "'], " .
"'none', '{$this->_sort}'); return false;");
= array(
'onclick' => $jsName.
"('{$selectId}', ".
"this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'none', '{$this->_sort}'); return false;"
);
$this->_noneButtonAttributes
= array_merge($this->_noneButtonAttributes, $attributes);
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes);
$strHtmlNone = "<input$attrStrNone />". PHP_EOL;
$strHtmlNone = "<input$attrStrNone />".PHP_EOL;
// build the toggle button with all its attributes
$attributes
= array('onclick' => $jsName .
"('{$selectId}', " .
"this.form.elements['" . $selectNameFrom . "'], " .
"this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "'], " .
"'toggle', '{$this->_sort}'); return false;");
= array(
'onclick' => $jsName.
"('{$selectId}', ".
"this.form.elements['".$selectNameFrom."'], ".
"this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."'], ".
"'toggle', '{$this->_sort}'); return false;"
);
$this->_toggleButtonAttributes
= array_merge($this->_toggleButtonAttributes, $attributes);
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes);
$strHtmlToggle = "<input$attrStrToggle />". PHP_EOL;
$strHtmlToggle = "<input$attrStrToggle />".PHP_EOL;
// build the move up button with all its attributes
$attributes
= array('onclick' => "{$this->_jsPrefix}moveUp" .
"(this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "']); " .
"return false;");
= array(
'onclick' => "{$this->_jsPrefix}moveUp".
"(this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_upButtonAttributes
= array_merge($this->_upButtonAttributes, $attributes);
$attrStrUp = $this->_getAttrString($this->_upButtonAttributes);
$strHtmlMoveUp = "<input$attrStrUp />". PHP_EOL;
$strHtmlMoveUp = "<input$attrStrUp />".PHP_EOL;
// build the move down button with all its attributes
$attributes
= array('onclick' => "{$this->_jsPrefix}moveDown" .
"(this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "']); " .
"return false;");
= array(
'onclick' => "{$this->_jsPrefix}moveDown".
"(this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_downButtonAttributes
= array_merge($this->_downButtonAttributes, $attributes);
$attrStrDown = $this->_getAttrString($this->_downButtonAttributes);
$strHtmlMoveDown = "<input$attrStrDown />". PHP_EOL;
$strHtmlMoveDown = "<input$attrStrDown />".PHP_EOL;
// build the move top button with all its attributes
$attributes
= array('onclick' => "{$this->_jsPrefix}moveTop" .
"(this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "']); " .
"return false;");
= array(
'onclick' => "{$this->_jsPrefix}moveTop".
"(this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_topButtonAttributes
= array_merge($this->_topButtonAttributes, $attributes);
$attrStrTop = $this->_getAttrString($this->_topButtonAttributes);
$strHtmlMoveTop = "<input$attrStrTop />". PHP_EOL;
$strHtmlMoveTop = "<input$attrStrTop />".PHP_EOL;
// build the move bottom button with all its attributes
$attributes
= array('onclick' => "{$this->_jsPrefix}moveBottom" .
"(this.form.elements['" . $selectNameTo . "'], " .
"this.form.elements['" . $selectName . "']); " .
"return false;");
= array(
'onclick' => "{$this->_jsPrefix}moveBottom".
"(this.form.elements['".$selectNameTo."'], ".
"this.form.elements['".$selectName."']); ".
"return false;"
);
$this->_bottomButtonAttributes
= array_merge($this->_bottomButtonAttributes, $attributes);
$attrStrBottom = $this->_getAttrString($this->_bottomButtonAttributes);
$strHtmlMoveBottom = "<input$attrStrBottom />". PHP_EOL;
$strHtmlMoveBottom = "<input$attrStrBottom />".PHP_EOL;
// default selection counters
$strHtmlSelectedCount = $selected_count;
}
$strHtmlUnselectedCount = $unselected_count;
$strHtmlSelectedCountId = $selectId .'_selected';
$strHtmlUnselectedCountId = $selectId .'_unselected';
$strHtmlSelectedCountId = $selectId.'_selected';
$strHtmlUnselectedCountId = $selectId.'_unselected';
// render all part of the multi select component with the template
$strHtml = $this->_elementTemplate;
@ -959,7 +1046,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
// render extra labels, if any
if (is_array($labels)) {
foreach ($labels as $key => $text) {
$key = is_int($key)? $key + 2: $key;
$key = is_int($key) ? $key + 2 : $key;
$strHtml = str_replace("{label_{$key}}", $text, $strHtml);
$strHtml = str_replace("<!-- BEGIN label_{$key} -->", '', $strHtml);
$strHtml = str_replace("<!-- END label_{$key} -->", '', $strHtml);
@ -967,31 +1054,53 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
}
// clean up useless label tags
if (strpos($strHtml, '{label_')) {
$strHtml = preg_replace('/\s*<!-- BEGIN label_(\S+) -->'.
'.*<!-- END label_\1 -->\s*/i', '', $strHtml);
$strHtml = preg_replace(
'/\s*<!-- BEGIN label_(\S+) -->'.
'.*<!-- END label_\1 -->\s*/i',
'',
$strHtml
);
}
$placeHolders = array(
'{stylesheet}', '{javascript}',
'{stylesheet}',
'{javascript}',
'{class}',
'{unselected_count_id}', '{selected_count_id}',
'{unselected_count}', '{selected_count}',
'{unselected}', '{selected}',
'{add}', '{remove}',
'{all}', '{none}', '{toggle}',
'{moveup}', '{movedown}',
'{movetop}', '{movebottom}'
'{unselected_count_id}',
'{selected_count_id}',
'{unselected_count}',
'{selected_count}',
'{unselected}',
'{selected}',
'{add}',
'{remove}',
'{all}',
'{none}',
'{toggle}',
'{moveup}',
'{movedown}',
'{movetop}',
'{movebottom}'
);
$htmlElements = array(
$this->getElementCss(false), $this->getElementJs(false),
$this->getElementCss(false),
$this->getElementJs(false),
$this->_tableAttributes,
$strHtmlUnselectedCountId, $strHtmlSelectedCountId,
$strHtmlUnselectedCount, $strHtmlSelectedCount,
$strHtmlUnselected, $strHtmlSelected . $strHtmlHidden,
$strHtmlAdd, $strHtmlRemove,
$strHtmlAll, $strHtmlNone, $strHtmlToggle,
$strHtmlMoveUp, $strHtmlMoveDown,
$strHtmlMoveTop, $strHtmlMoveBottom
$strHtmlUnselectedCountId,
$strHtmlSelectedCountId,
$strHtmlUnselectedCount,
$strHtmlSelectedCount,
$strHtmlUnselected,
$strHtmlSelected.$strHtmlHidden,
$strHtmlAdd,
$strHtmlRemove,
$strHtmlAll,
$strHtmlNone,
$strHtmlToggle,
$strHtmlMoveUp,
$strHtmlMoveDown,
$strHtmlMoveTop,
$strHtmlMoveBottom
);
$strHtml = str_replace($placeHolders, $htmlElements, $strHtml);
@ -999,7 +1108,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$comment = $this->getComment();
if (!empty($comment)) {
$strHtml = $tabs . '<!-- ' . $comment . " //-->" . PHP_EOL . $strHtml;
$strHtml = $tabs.'<!-- '.$comment." //-->".PHP_EOL.$strHtml;
}
return $strHtml;
@ -1017,8 +1126,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
*/
function getElementJs($raw = true, $min = true)
{
$js = '@data_dir@' . DIRECTORY_SEPARATOR
. '@package_name@' . DIRECTORY_SEPARATOR;
$js = '@data_dir@'.DIRECTORY_SEPARATOR
.'@package_name@'.DIRECTORY_SEPARATOR;
$js = api_get_path(LIBRARY_PATH).'javascript'.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR;
@ -1036,11 +1145,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
if ($raw !== true) {
$js = '<script type="text/javascript">'
. PHP_EOL . '//<![CDATA['
. PHP_EOL . $js
. PHP_EOL . '//]]>'
. PHP_EOL . '</script>'
. PHP_EOL;
.PHP_EOL.'//<![CDATA['
.PHP_EOL.$js
.PHP_EOL.'//]]>'
.PHP_EOL.'</script>'
.PHP_EOL;
}
return $js;
}
@ -1063,9 +1172,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
* @throws PEAR_Error
* @see loadArray()
*/
function load(&$options,
$param1 = null, $param2 = null, $param3 = null, $param4 = null)
{
function load(
&$options,
$param1 = null,
$param2 = null,
$param3 = null,
$param4 = null
) {
if (is_array($options)) {
$ret = $this->loadArray($options, $param1);
} else {
@ -1092,10 +1205,12 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
function loadArray($arr, $values = null)
{
if (!is_array($arr)) {
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' .
return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'loadArray is not a valid array',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception'));
array('level' => 'exception')
);
}
if (isset($values)) {
$this->setSelected($values);
@ -1129,19 +1244,23 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
function setPersistantOptions($optionValues, $persistant = true)
{
if (!is_bool($persistant)) {
return PEAR::throwError('Argument 2 of HTML_QuickForm_advmultiselect::' .
return PEAR::throwError(
'Argument 2 of HTML_QuickForm_advmultiselect::'.
'setPersistantOptions is not a boolean',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception'));
array('level' => 'exception')
);
}
if (is_string($optionValues)) {
$optionValues = array($optionValues);
}
if (!is_array($optionValues)) {
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' .
return PEAR::throwError(
'Argument 1 of HTML_QuickForm_advmultiselect::'.
'setPersistantOptions is not a valid array',
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
array('level' => 'exception'));
array('level' => 'exception')
);
}
foreach ($this->_options as $k => $v) {
@ -1182,5 +1301,9 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
// @todo this fires an PHP notice, needed in order to parse the advmultiselect test it in main/group/group_edit.php
if (class_exists('HTML_QuickForm')) {
@HTML_QuickForm::registerElementType('advmultiselect','HTML/QuickForm/advmultiselect.php', 'HTML_QuickForm_advmultiselect');
@HTML_QuickForm::registerElementType(
'advmultiselect',
'HTML/QuickForm/advmultiselect.php',
'HTML_QuickForm_advmultiselect'
);
}

@ -29,7 +29,8 @@ class HTML_QuickForm_label extends HTML_QuickForm_static
* @access public
* @return void
*/
function HTML_QuickForm_label($label = null, $text = null) {
function HTML_QuickForm_label($label = null, $text = null)
{
$this->HTML_QuickForm_static(null, $label, $text);
$this->_type = 'html';
}
@ -44,22 +45,19 @@ class HTML_QuickForm_label extends HTML_QuickForm_static
* @access public
* @return void
*/
function accept(&$renderer, $required=false, $error=null) {
function accept(&$renderer, $required = false, $error = null)
{
$renderer->renderHtml($this);
}
function toHtml() {
return '<div class="control-group ">
function toHtml()
{
return '<div class="control-group">
<label class="control-label">'.$this->getLabel().'</label>
<div class="controls">
'.HTML_QuickForm_static::toHtml().'
</div>
</div>
';
} //end func toHtml
// }}}
} //end class HTML_QuickForm_html
}
}

@ -65,7 +65,7 @@ if (api_is_course_admin()) {
$tool_name = get_lang('SurveyPublication');
// Displaying the header
Display::display_header($tool_name,'Survey');
Display::display_header($tool_name, 'Survey');
echo '<script>
$(function() {
@ -77,7 +77,9 @@ $(function() {
// Checking if there is another survey with this code.
// If this is the case there will be a language choice
$sql = "SELECT * FROM $table_survey WHERE c_id = $course_id AND code='".Database::escape_string($survey_data['code'])."'";
$sql = "SELECT * FROM $table_survey WHERE c_id = $course_id AND code='".Database::escape_string(
$survey_data['code']
)."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 1) {
Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
@ -98,37 +100,32 @@ $form = new FormValidator('publish_form', 'post', api_get_self().'?survey_id='.$
$form->addElement('header', '', $tool_name);
// Course users
$complete_user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname');
$complete_user_list = CourseManager::get_user_list_from_course_code(
api_get_course_id(),
api_get_session_id(),
'',
api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname'
);
$possible_users = array();
foreach ($complete_user_list as & $user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
}
$list = UserManager::generate_user_group_array(api_get_course_id(), api_get_session_id());
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $list, 'style="width: 250px; height: 200px;"');
//$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
$users->setElementTemplate('
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}<br /><br />{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
');
$users->setButtonAttributes('add', array('class' => 'btn arrowr'));
$users->setButtonAttributes('remove', array('class' => 'btn arrowl'));
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $list);
$users->setButtonAttributes('add');
$users->setButtonAttributes('remove');
// Additional users
$form->addElement('textarea', 'additional_users', array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')), array('class' => 'span6', 'rows' => 5));
$form->addElement(
'textarea',
'additional_users',
array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')),
array('class' => 'span6', 'rows' => 5)
);
$form->addElement('html', '<div id="check_mail">');
$form->addElement('checkbox', 'send_mail','', get_lang('SendMail'));
$form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));
$form->addElement('html', '</div>');
$form->addElement('html', '<div id="mail_text">');
@ -136,7 +133,13 @@ $form->addElement('html', '<div id="mail_text">');
// The title of the mail
$form->addElement('text', 'mail_title', get_lang('MailTitle'), array('class' => 'span6'));
// The text of the mail
$form->addElement('html_editor', 'mail_text', array(get_lang('MailText'), get_lang('UseLinkSyntax')), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150'));
$form->addElement(
'html_editor',
'mail_text',
array(get_lang('MailText'), get_lang('UseLinkSyntax')),
null,
array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150')
);
$form->addElement('html', '</div>');
// You cab send a reminder to unanswered people if the survey is not anonymous
if ($survey_data['anonymous'] != 1) {
@ -189,8 +192,14 @@ if ($form->validate()) {
// Save the invitation mail
SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail']));
// Saving the invitations for the course users
$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'],
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
$count_course_users = SurveyUtil::save_invitations(
$values['course_users'],
$values['mail_title'],
$values['mail_text'],
$values['resend_to_all'],
$values['send_mail'],
$values['remindUnAnswered']
);
// Saving the invitations for the additional users
$values['additional_users'] = $values['additional_users'].';'; // This is for the case when you enter only one email
@ -199,8 +208,14 @@ if ($form->validate()) {
for ($i = 0; $i < count($additional_users); $i++) {
$additional_users[$i] = trim($additional_users[$i]);
}
$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'],
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
$counter_additional_users = SurveyUtil::save_invitations(
$additional_users,
$values['mail_title'],
$values['mail_text'],
$values['resend_to_all'],
$values['send_mail'],
$values['remindUnAnswered']
);
// Updating the invited field in the survey table
SurveyUtil::update_count_invited($survey_data['code']);
$total_count = $count_course_users + $counter_additional_users;
@ -228,7 +243,9 @@ if ($form->validate()) {
$defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1;
$defaults['course_users'] = array_keys(UserManager::transform_user_group_array($defaults['course_users'], $defaults['course_groups'], true, true));
$defaults['course_users'] = array_keys(
UserManager::transform_user_group_array($defaults['course_users'], $defaults['course_groups'], true, true)
);
$form->setDefaults($defaults);
$form->display();

Loading…
Cancel
Save