advmultiselect.php 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313
  1. <?php
  2. /**
  3. * Copyright (c) 2005-2009, Laurent Laville <pear@laurent-laville.org>
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * * Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * * Neither the name of the authors nor the names of its contributors
  17. * may be used to endorse or promote products derived from this software
  18. * without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  24. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * PHP versions 4 and 5
  33. *
  34. * @category HTML
  35. * @package HTML_QuickForm_advmultiselect
  36. * @author Laurent Laville <pear@laurent-laville.org>
  37. * @copyright 2005-2009 Laurent Laville
  38. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  39. * @version CVS: $Id: advmultiselect.php,v 1.36 2009/04/05 07:03:39 farell Exp $
  40. * @link http://pear.php.net/package/HTML_QuickForm_advmultiselect
  41. * @since File available since Release 0.4.0
  42. */
  43. /**
  44. * Code
  45. */
  46. /**
  47. * Element for HTML_QuickForm that emulate a multi-select.
  48. *
  49. * The HTML_QuickForm_advmultiselect package adds an element to the
  50. * HTML_QuickForm package that is two select boxes next to each other
  51. * emulating a multi-select.
  52. *
  53. * @category HTML
  54. * @package HTML_QuickForm_advmultiselect
  55. * @author Laurent Laville <pear@laurent-laville.org>
  56. * @copyright 2005-2009 Laurent Laville
  57. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  58. * @version Release: @package_version@
  59. * @link http://pear.php.net/package/HTML_QuickForm_advmultiselect
  60. * @since Class available since Release 0.4.0
  61. */
  62. class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
  63. {
  64. /**
  65. * Prefix function name in javascript move selections
  66. *
  67. * @var string
  68. * @access private
  69. * @since 0.4.0
  70. */
  71. var $_jsPrefix;
  72. /**
  73. * Postfix function name in javascript move selections
  74. *
  75. * @var string
  76. * @access private
  77. * @since 0.4.0
  78. */
  79. var $_jsPostfix;
  80. /**
  81. * Associative array of the multi select container attributes
  82. *
  83. * @var array
  84. * @access private
  85. * @since 0.4.0
  86. */
  87. var $_tableAttributes;
  88. /**
  89. * Associative array of the add button attributes
  90. *
  91. * @var array
  92. * @access private
  93. * @since 0.4.0
  94. */
  95. var $_addButtonAttributes;
  96. /**
  97. * Associative array of the remove button attributes
  98. *
  99. * @var array
  100. * @access private
  101. * @since 0.4.0
  102. */
  103. var $_removeButtonAttributes;
  104. /**
  105. * Associative array of the select all button attributes
  106. *
  107. * @var array
  108. * @access private
  109. * @since 1.1.0
  110. */
  111. var $_allButtonAttributes;
  112. /**
  113. * Associative array of the select none button attributes
  114. *
  115. * @var array
  116. * @access private
  117. * @since 1.1.0
  118. */
  119. var $_noneButtonAttributes;
  120. /**
  121. * Associative array of the toggle selection button attributes
  122. *
  123. * @var array
  124. * @access private
  125. * @since 1.1.0
  126. */
  127. var $_toggleButtonAttributes;
  128. /**
  129. * Associative array of the move up button attributes
  130. *
  131. * @var array
  132. * @access private
  133. * @since 0.5.0
  134. */
  135. var $_upButtonAttributes;
  136. /**
  137. * Associative array of the move up button attributes
  138. *
  139. * @var array
  140. * @access private
  141. * @since 0.5.0
  142. */
  143. var $_downButtonAttributes;
  144. /**
  145. * Associative array of the move top button attributes
  146. *
  147. * @var array
  148. * @access private
  149. * @since 1.5.0
  150. */
  151. var $_topButtonAttributes;
  152. /**
  153. * Associative array of the move bottom button attributes
  154. *
  155. * @var array
  156. * @access private
  157. * @since 1.5.0
  158. */
  159. var $_bottomButtonAttributes;
  160. /**
  161. * Defines if both list (unselected, selected) will have their elements be
  162. * arranged from lowest to highest (or reverse)
  163. * depending on comparaison function.
  164. *
  165. * SORT_ASC is used to sort in ascending order
  166. * SORT_DESC is used to sort in descending order
  167. *
  168. * @var string ('none' == false, 'asc' == SORT_ASC, 'desc' == SORT_DESC)
  169. * @access private
  170. * @since 0.5.0
  171. */
  172. var $_sort;
  173. /**
  174. * Associative array of the unselected item box attributes
  175. *
  176. * @var array
  177. * @access private
  178. * @since 0.4.0
  179. */
  180. var $_attributesUnselected;
  181. /**
  182. * Associative array of the selected item box attributes
  183. *
  184. * @var array
  185. * @access private
  186. * @since 0.4.0
  187. */
  188. var $_attributesSelected;
  189. /**
  190. * Associative array of the internal hidden box attributes
  191. *
  192. * @var array
  193. * @access private
  194. * @since 0.4.0
  195. */
  196. var $_attributesHidden;
  197. /**
  198. * Default Element template string
  199. *
  200. * @var string
  201. * @access private
  202. * @since 0.4.0
  203. */
  204. var $_elementTemplate;
  205. /**
  206. * Default Element stylesheet string
  207. *
  208. * @var string
  209. * @access private
  210. * @since 0.4.0
  211. */
  212. var $_elementCSS = '
  213. #qfams_{id} {
  214. font: 13.3px sans-serif;
  215. background-color: #fff;
  216. overflow: auto;
  217. height: 14.3em;
  218. width: 12em;
  219. border-left: 1px solid #404040;
  220. border-top: 1px solid #404040;
  221. border-bottom: 1px solid #d4d0c8;
  222. border-right: 1px solid #d4d0c8;
  223. }
  224. #qfams_{id} label {
  225. padding-right: 3px;
  226. display: block;
  227. }
  228. ';
  229. /**
  230. * Class constructor
  231. *
  232. * Class constructors :
  233. * Zend Engine 1 uses HTML_QuickForm_advmultiselect, while
  234. * Zend Engine 2 uses __construct
  235. *
  236. * @param string $elementName Dual Select name attribute
  237. * @param mixed $elementLabel Label(s) for the select boxes
  238. * @param mixed $options Data to be used to populate options
  239. * @param mixed $attributes Either a typical HTML attribute string or
  240. * an associative array
  241. * @param integer $sort Either SORT_ASC for auto ascending arrange,
  242. * SORT_DESC for auto descending arrange, or
  243. * NULL for no sort (append at end: default)
  244. *
  245. * @access public
  246. * @return void
  247. * @since version 0.4.0 (2005-06-25)
  248. */
  249. function HTML_QuickForm_advmultiselect(
  250. $elementName = null,
  251. $elementLabel = null,
  252. $options = null,
  253. $attributes = null,
  254. $sort = null
  255. ) {
  256. $opts = $options;
  257. $options = null; // prevent to use the default select element load options
  258. $this->HTML_QuickForm_select(
  259. $elementName,
  260. $elementLabel,
  261. $options,
  262. $attributes
  263. );
  264. // allow to load options at once and take care of fancy attributes
  265. $this->load($opts);
  266. // add multiple selection attribute by default if missing
  267. $this->updateAttributes(array('multiple' => 'multiple'));
  268. if (is_null($this->getAttribute('size'))) {
  269. // default size is ten item on each select box (left and right)
  270. $this->updateAttributes(array('size' => 10));
  271. }
  272. if (is_null($this->getAttribute('style'))) {
  273. // default width of each select box
  274. //$this->updateAttributes(array('style' => 'min-width:100px;'));
  275. }
  276. $this->_tableAttributes = $this->getAttribute('class');
  277. $attr = null;
  278. if (is_null($this->_tableAttributes)) {
  279. $this->updateAttributes(array('class' => 'span4'));
  280. } else {
  281. $attr = array('class' => $this->_tableAttributes);
  282. $this->_removeAttr('class', $this->_attributes);
  283. }
  284. $this->_tableAttributes = $this->_getAttrString($attr);
  285. // set default add button attributes
  286. $this->setButtonAttributes('add');
  287. // set default remove button attributes
  288. $this->setButtonAttributes('remove');
  289. // set default selectall button attributes
  290. $this->setButtonAttributes('all');
  291. // set default selectnone button attributes
  292. $this->setButtonAttributes('none');
  293. // set default toggle selection button attributes
  294. $this->setButtonAttributes('toggle');
  295. // set default move up button attributes
  296. $this->setButtonAttributes('moveup');
  297. // set default move up button attributes
  298. $this->setButtonAttributes('movedown');
  299. // set default move top button attributes
  300. $this->setButtonAttributes('movetop');
  301. // set default move bottom button attributes
  302. $this->setButtonAttributes('movebottom');
  303. // defines javascript functions names
  304. $this->_jsPrefix = 'QFAMS.';
  305. $this->_jsPostfix = 'moveSelection';
  306. // set select boxes sort order (none by default)
  307. if (!isset($sort)) {
  308. $sort = false;
  309. }
  310. if ($sort === SORT_ASC) {
  311. $this->_sort = 'asc';
  312. } elseif ($sort === SORT_DESC) {
  313. $this->_sort = 'desc';
  314. } else {
  315. $this->_sort = 'none';
  316. }
  317. // set the default advmultiselect element template (with javascript embedded)
  318. $this->setElementTemplate();
  319. }
  320. /**
  321. * Sets the button attributes
  322. *
  323. * In <b>custom example 1</b>, the <i>add</i> and <i>remove</i> buttons
  324. * have look set by the css class <i>inputCommand</i>.
  325. *
  326. * In <b>custom example 2</b>, the basic text <i>add</i> and <i>remove</i>
  327. * buttons are now replaced by images.
  328. *
  329. * In <b>custom example 5</b>, we have ability to sort the selection list
  330. * (on right side) by :
  331. * <pre>
  332. * - <b>user-end</b>: with <i>Up</i> and <i>Down</i> buttons
  333. * - <b>programming</b>: with the QF element constructor $sort option
  334. * </pre>
  335. *
  336. * @param string $button Button identifier, either 'add', 'remove',
  337. * 'all', 'none', 'toggle',
  338. * 'movetop', 'movebottom'
  339. * 'moveup' or 'movedown'
  340. * @param mixed $attributes (optional) Either a typical HTML attribute string
  341. * or an associative array
  342. *
  343. * @return void
  344. * @throws PEAR_Error $button argument
  345. * is not a string, or not in range
  346. * (add, remove, all, none, toggle,
  347. * movetop, movebottom, moveup, movedown)
  348. * @access public
  349. * @since version 0.4.0 (2005-06-25)
  350. *
  351. * @example examples/qfams_custom_5.php
  352. * Custom example 5: source code
  353. * @link http://www.laurent-laville.org/img/qfams/screenshot/custom5.png
  354. * Custom example 5: screenshot
  355. *
  356. * @example examples/qfams_custom_2.php
  357. * Custom example 2: source code
  358. * @link http://www.laurent-laville.org/img/qfams/screenshot/custom2.png
  359. * Custom example 2: screenshot
  360. *
  361. * @example examples/qfams_custom_1.php
  362. * Custom example 1: source code
  363. * @link http://www.laurent-laville.org/img/qfams/screenshot/custom1.png
  364. * Custom example 1: screenshot
  365. */
  366. function setButtonAttributes($button, $attributes = null)
  367. {
  368. if (!is_string($button)) {
  369. return PEAR::throwError(
  370. 'Argument 1 of HTML_QuickForm_advmultiselect::'.
  371. 'setButtonAttributes is not a string',
  372. HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
  373. array('level' => 'exception')
  374. );
  375. }
  376. switch ($button) {
  377. case 'add':
  378. if (is_null($attributes)) {
  379. $this->_addButtonAttributes
  380. = array(
  381. 'name' => 'add',
  382. 'value' => '',
  383. 'type' => 'button'
  384. );
  385. $this->setValue('<i class="icon-shopping-cart icon-large"></i>');
  386. } else {
  387. $this->_updateAttrArray(
  388. $this->_addButtonAttributes,
  389. $this->_parseAttributes($attributes)
  390. );
  391. }
  392. break;
  393. case 'remove':
  394. if (is_null($attributes)) {
  395. $this->_removeButtonAttributes
  396. = array(
  397. 'name' => 'remove',
  398. 'value' => ' ',
  399. 'type' => 'button'
  400. );
  401. } else {
  402. $this->_updateAttrArray(
  403. $this->_removeButtonAttributes,
  404. $this->_parseAttributes($attributes)
  405. );
  406. }
  407. break;
  408. case 'all':
  409. if (is_null($attributes)) {
  410. $this->_allButtonAttributes
  411. = array(
  412. 'name' => 'all',
  413. 'value' => ' Select All ',
  414. 'type' => 'button'
  415. );
  416. } else {
  417. $this->_updateAttrArray(
  418. $this->_allButtonAttributes,
  419. $this->_parseAttributes($attributes)
  420. );
  421. }
  422. break;
  423. case 'none':
  424. if (is_null($attributes)) {
  425. $this->_noneButtonAttributes
  426. = array(
  427. 'name' => 'none',
  428. 'value' => ' Select None ',
  429. 'type' => 'button'
  430. );
  431. } else {
  432. $this->_updateAttrArray(
  433. $this->_noneButtonAttributes,
  434. $this->_parseAttributes($attributes)
  435. );
  436. }
  437. break;
  438. case 'toggle':
  439. if (is_null($attributes)) {
  440. $this->_toggleButtonAttributes
  441. = array(
  442. 'name' => 'toggle',
  443. 'value' => ' Toggle Selection ',
  444. 'type' => 'button'
  445. );
  446. } else {
  447. $this->_updateAttrArray(
  448. $this->_toggleButtonAttributes,
  449. $this->_parseAttributes($attributes)
  450. );
  451. }
  452. break;
  453. case 'moveup':
  454. if (is_null($attributes)) {
  455. $this->_upButtonAttributes
  456. = array(
  457. 'name' => 'up',
  458. 'value' => ' Up ',
  459. 'type' => 'button'
  460. );
  461. } else {
  462. $this->_updateAttrArray(
  463. $this->_upButtonAttributes,
  464. $this->_parseAttributes($attributes)
  465. );
  466. }
  467. break;
  468. case 'movedown':
  469. if (is_null($attributes)) {
  470. $this->_downButtonAttributes
  471. = array(
  472. 'name' => 'down',
  473. 'value' => ' Down ',
  474. 'type' => 'button'
  475. );
  476. } else {
  477. $this->_updateAttrArray(
  478. $this->_downButtonAttributes,
  479. $this->_parseAttributes($attributes)
  480. );
  481. }
  482. break;
  483. case 'movetop':
  484. if (is_null($attributes)) {
  485. $this->_topButtonAttributes
  486. = array(
  487. 'name' => 'top',
  488. 'value' => ' Top ',
  489. 'type' => 'button'
  490. );
  491. } else {
  492. $this->_updateAttrArray(
  493. $this->_topButtonAttributes,
  494. $this->_parseAttributes($attributes)
  495. );
  496. }
  497. break;
  498. case 'movebottom':
  499. if (is_null($attributes)) {
  500. $this->_bottomButtonAttributes
  501. = array(
  502. 'name' => 'bottom',
  503. 'value' => ' Bottom ',
  504. 'type' => 'button'
  505. );
  506. } else {
  507. $this->_updateAttrArray(
  508. $this->_bottomButtonAttributes,
  509. $this->_parseAttributes($attributes)
  510. );
  511. }
  512. break;
  513. default;
  514. return PEAR::throwError(
  515. 'Argument 1 of HTML_QuickForm_advmultiselect::'.
  516. 'setButtonAttributes has unexpected value',
  517. HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
  518. array('level' => 'error')
  519. );
  520. }
  521. }
  522. /**
  523. * Sets element template
  524. *
  525. * @param string $html (optional) The HTML surrounding select boxes and buttons
  526. * @param string $js (optional) if we need to include qfams javascript handler
  527. *
  528. * @access public
  529. * @return string
  530. * @since version 0.4.0 (2005-06-25)
  531. */
  532. function setElementTemplate($html = null, $js = true)
  533. {
  534. $oldTemplate = $this->_elementTemplate;
  535. if (isset($html) && is_string($html)) {
  536. // $this->_elementTemplate = $html;
  537. } else {
  538. /*<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
  539. <!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->*/
  540. $this->_elementTemplate = '
  541. {javascript}
  542. <div class="advmultiselect row">
  543. <div class="span4">{unselected}</div>
  544. <div class="span1">{add} <br /><br />{remove}</div>
  545. <div class="span4">{selected}</div>
  546. </div>
  547. ';
  548. }
  549. if ($js == false) {
  550. $this->_elementTemplate = str_replace('{javascript}', '', $this->_elementTemplate);
  551. }
  552. //return $oldTemplate;
  553. }
  554. /**
  555. * Gets default element stylesheet for a single multi-select shape render
  556. *
  557. * In <b>custom example 4</b>, the template defined allows
  558. * a single multi-select checkboxes shape. Useful when javascript is disabled
  559. * (or when browser is not js compliant). In our example, no need to add
  560. * javascript code, but css is mandatory.
  561. *
  562. * @param boolean $raw (optional) html output with style tags or just raw data
  563. *
  564. * @access public
  565. * @return string
  566. * @since version 0.4.0 (2005-06-25)
  567. *
  568. * @example qfams_custom_4.php
  569. * Custom example 4: source code
  570. * @link http://www.laurent-laville.org/img/qfams/screenshot/custom4.png
  571. * Custom example 4: screenshot
  572. */
  573. function getElementCss($raw = true)
  574. {
  575. $id = $this->getAttribute('name');
  576. $css = str_replace('{id}', $id, $this->_elementCSS);
  577. if ($raw !== true) {
  578. $css = '<style type="text/css">'.PHP_EOL
  579. // Modified by Chamilo team, 16-MAR-2010.
  580. //. '<!--' . $css . '// -->' . PHP_EOL
  581. .'/*<![CDATA[*/'.PHP_EOL
  582. .$css.PHP_EOL
  583. .'/*]]>*/'.PHP_EOL
  584. //
  585. .'</style>';
  586. }
  587. return $css;
  588. }
  589. /**
  590. * Returns the HTML generated for the advanced mutliple select component
  591. *
  592. * @access public
  593. * @return string
  594. * @since version 0.4.0 (2005-06-25)
  595. */
  596. function toHtml()
  597. {
  598. if ($this->_flagFrozen) {
  599. return $this->getFrozenHtml();
  600. }
  601. $tabs = $this->_getTabs();
  602. $tab = $this->_getTab();
  603. $selectId = $this->getName();
  604. $selectName = $this->getName().'[]';
  605. $selectNameFrom = $this->getName().'-f[]';
  606. $selectNameTo = $this->getName().'-t[]';
  607. $selected_count = 0;
  608. // placeholder {unselected} existence determines if we will render
  609. if (strpos($this->_elementTemplate, '{unselected}') === false) {
  610. // ... a single multi-select with checkboxes
  611. $this->_jsPostfix = 'editSelection';
  612. $id = $this->getAttribute('name');
  613. $strHtmlSelected = $tab.'<div id="qfams_'.$id.'">'.PHP_EOL;
  614. $unselected_count = count($this->_options);
  615. $checkbox_id_suffix = 0;
  616. foreach ($this->_options as $option) {
  617. $_labelAttributes = array('style', 'class', 'onmouseover', 'onmouseout');
  618. $labelAttributes = array();
  619. foreach ($_labelAttributes as $attr) {
  620. if (isset($option['attr'][$attr])) {
  621. $labelAttributes[$attr] = $option['attr'][$attr];
  622. unset($option['attr'][$attr]);
  623. }
  624. }
  625. if (is_array($this->_values)
  626. && in_array((string)$option['attr']['value'], $this->_values)
  627. ) {
  628. // The items is *selected*
  629. $checked = ' checked="checked"';
  630. $selected_count++;
  631. } else {
  632. // The item is *unselected* so we want to put it
  633. $checked = '';
  634. }
  635. $checkbox_id_suffix++;
  636. $strHtmlSelected .= $tab
  637. .'<label'
  638. .$this->_getAttrString($labelAttributes).'>'
  639. .'<input type="checkbox"'
  640. .' id="'.$selectId.$checkbox_id_suffix.'"'
  641. .' name="'.$selectName.'"'
  642. .$checked
  643. .$this->_getAttrString($option['attr'])
  644. .' />'.$option['text'].'</label>'
  645. .PHP_EOL;
  646. }
  647. $strHtmlSelected .= $tab.'</div>'.PHP_EOL;
  648. $strHtmlHidden = '';
  649. $strHtmlUnselected = '';
  650. $strHtmlAdd = '';
  651. $strHtmlRemove = '';
  652. // build the select all button with all its attributes
  653. $jsName = $this->_jsPrefix.$this->_jsPostfix;
  654. $attributes = array(
  655. 'onclick' => $jsName.
  656. "('".$selectId."', 1);"
  657. );
  658. $this->_allButtonAttributes
  659. = array_merge($this->_allButtonAttributes, $attributes);
  660. $attrStrAll = $this->_getAttrString($this->_allButtonAttributes);
  661. $strHtmlAll = "<input$attrStrAll />".PHP_EOL;
  662. // build the select none button with all its attributes
  663. $attributes = array(
  664. 'onclick' => $jsName.
  665. "('".$selectId."', 0);"
  666. );
  667. $this->_noneButtonAttributes
  668. = array_merge($this->_noneButtonAttributes, $attributes);
  669. $attrStrNone = $this->_getAttrString($this->_noneButtonAttributes);
  670. $strHtmlNone = "<input$attrStrNone />".PHP_EOL;
  671. // build the toggle selection button with all its attributes
  672. $attributes = array(
  673. 'onclick' => $jsName.
  674. "('".$selectId."', 2);"
  675. );
  676. $this->_toggleButtonAttributes
  677. = array_merge(
  678. $this->_toggleButtonAttributes,
  679. $attributes
  680. );
  681. $attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes);
  682. $strHtmlToggle = "<input$attrStrToggle />".PHP_EOL;
  683. $strHtmlMoveUp = '';
  684. $strHtmlMoveDown = '';
  685. $strHtmlMoveTop = '';
  686. $strHtmlMoveBottom = '';
  687. // default selection counters
  688. $strHtmlSelectedCount = $selected_count.'/'.$unselected_count;
  689. } else {
  690. // ... or a dual multi-select
  691. $this->_jsPostfix = 'moveSelection';
  692. $jsName = $this->_jsPrefix.$this->_jsPostfix;
  693. // set name of Select From Box
  694. $this->_attributesUnselected
  695. = array(
  696. 'id' => $selectId.'-f',
  697. 'name' => $selectNameFrom,
  698. 'ondblclick' => $jsName.
  699. "('{$selectId}', ".
  700. "this.form.elements['".$selectNameFrom."'], ".
  701. "this.form.elements['".$selectNameTo."'], ".
  702. "this.form.elements['".$selectName."'], ".
  703. "'add', '{$this->_sort}')"
  704. );
  705. $this->_attributesUnselected
  706. = array_merge($this->_attributes, $this->_attributesUnselected);
  707. $attrUnselected = $this->_getAttrString($this->_attributesUnselected);
  708. // set name of Select To Box
  709. $this->_attributesSelected
  710. = array(
  711. 'id' => $selectId.'-t',
  712. 'name' => $selectNameTo,
  713. 'ondblclick' => $jsName.
  714. "('{$selectId}', ".
  715. "this.form.elements['".$selectNameFrom."'], ".
  716. "this.form.elements['".$selectNameTo."'], ".
  717. "this.form.elements['".$selectName."'], ".
  718. "'remove', '{$this->_sort}')"
  719. );
  720. $this->_attributesSelected
  721. = array_merge($this->_attributes, $this->_attributesSelected);
  722. $attrSelected = $this->_getAttrString($this->_attributesSelected);
  723. // set name of Select hidden Box
  724. $this->_attributesHidden
  725. = array(
  726. 'name' => $selectName,
  727. 'style' => 'overflow: hidden; visibility: hidden; '.
  728. 'width: 1px; height: 0;'
  729. );
  730. $this->_attributesHidden
  731. = array_merge($this->_attributes, $this->_attributesHidden);
  732. $attrHidden = $this->_getAttrString($this->_attributesHidden);
  733. // prepare option tables to be displayed as in POST order
  734. $append = count($this->_values);
  735. if ($append > 0) {
  736. $arrHtmlSelected = array_fill(0, $append, ' ');
  737. } else {
  738. $arrHtmlSelected = array();
  739. }
  740. $options = count($this->_options);
  741. $arrHtmlUnselected = array();
  742. if ($options > 0) {
  743. $arrHtmlHidden = array_fill(0, $options, ' ');
  744. foreach ($this->_options as $option) {
  745. if (is_array($this->_values)
  746. && in_array(
  747. (string)$option['attr']['value'],
  748. $this->_values
  749. )
  750. ) {
  751. // Get the post order
  752. $key = array_search(
  753. $option['attr']['value'],
  754. $this->_values
  755. );
  756. /** The items is *selected* so we want to put it
  757. in the 'selected' multi-select */
  758. $arrHtmlSelected[$key] = $option;
  759. /** Add it to the 'hidden' multi-select
  760. and set it as 'selected' */
  761. if (isset($option['attr']['disabled'])) {
  762. unset($option['attr']['disabled']);
  763. }
  764. $option['attr']['selected'] = 'selected';
  765. $arrHtmlHidden[$key] = $option;
  766. } else {
  767. /** The item is *unselected* so we want to put it
  768. in the 'unselected' multi-select */
  769. $arrHtmlUnselected[] = $option;
  770. // Add it to the hidden multi-select as 'unselected'
  771. $arrHtmlHidden[$append] = $option;
  772. $append++;
  773. }
  774. }
  775. } else {
  776. $arrHtmlHidden = array();
  777. }
  778. // The 'unselected' multi-select which appears on the left
  779. $unselected_count = count($arrHtmlUnselected);
  780. if ($unselected_count == 0) {
  781. $this->_attributesUnselected['disabled'] = 'disabled';
  782. $this->_attributesUnselected
  783. = array_merge($this->_attributes, $this->_attributesUnselected);
  784. $attrUnselected = $this->_getAttrString($this->_attributesUnselected);
  785. }
  786. $strHtmlUnselected = "<select$attrUnselected>".PHP_EOL;
  787. if ($unselected_count > 0) {
  788. foreach ($arrHtmlUnselected as $data) {
  789. $strHtmlUnselected
  790. .= $tabs.$tab
  791. .'<option'.$this->_getAttrString($data['attr']).'>'
  792. .$data['text'].'</option>'.PHP_EOL;
  793. }
  794. } else {
  795. $strHtmlUnselected .= '<option value="">&nbsp;</option>';
  796. }
  797. $strHtmlUnselected .= '</select>';
  798. $strHtmlUnselected = '<input placeholder="'.get_lang('Search').'" id="f-'.$selectId.'-filter" type="text" class="search-query select_class_filter"><br /><br />'.$strHtmlUnselected;
  799. // The 'selected' multi-select which appears on the right
  800. $selected_count = count($arrHtmlSelected);
  801. if ($selected_count == 0) {
  802. $this->_attributesSelected['disabled'] = 'disabled';
  803. $this->_attributesSelected
  804. = array_merge($this->_attributes, $this->_attributesSelected);
  805. $attrSelected = $this->_getAttrString($this->_attributesSelected);
  806. }
  807. $strHtmlSelected = "<select$attrSelected>".PHP_EOL;
  808. if ($selected_count > 0) {
  809. foreach ($arrHtmlSelected as $data) {
  810. if (!empty($data) && isset($data['attr'])) {
  811. $strHtmlSelected
  812. .= $tabs.$tab
  813. .'<option'.$this->_getAttrString($data['attr']).'>'
  814. .$data['text'].'</option>'.PHP_EOL;
  815. }
  816. }
  817. } else {
  818. $strHtmlSelected .= '<option value="">&nbsp;</option>';
  819. }
  820. $strHtmlSelected .= '</select>';
  821. $strHtmlSelected = '<input placeholder="'.get_lang('Search').'" id="t-'.$selectId.'-filter" type="text" class="search-query"><br /><br />'.$strHtmlSelected;
  822. // The 'hidden' multi-select
  823. $strHtmlHidden = "<select$attrHidden>".PHP_EOL;
  824. if (count($arrHtmlHidden) > 0) {
  825. foreach ($arrHtmlHidden as $data) {
  826. if (!empty($data) && isset($data['attr'])) {
  827. $strHtmlHidden
  828. .= $tabs.$tab
  829. .'<option'.$this->_getAttrString($data['attr']).'>'.$data['text'].'</option>'.PHP_EOL;
  830. }
  831. }
  832. }
  833. $strHtmlHidden .= '</select>';
  834. // build the remove button with all its attributes
  835. $attributes = array(
  836. 'class' => 'btn btn-block ',
  837. 'onclick' => $jsName.
  838. "('{$selectId}', ".
  839. "this.form.elements['".$selectNameFrom."'], ".
  840. "this.form.elements['".$selectNameTo."'], ".
  841. "this.form.elements['".$selectName."'], ".
  842. "'remove', '{$this->_sort}'); return false;"
  843. );
  844. $this->_removeButtonAttributes
  845. = array_merge($this->_removeButtonAttributes, $attributes);
  846. $attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes);
  847. //$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL;
  848. $strHtmlRemove = "<button$attrStrRemove /><i class='icon-arrow-left icon-large'></i></button>".PHP_EOL;
  849. // build the add button with all its attributes
  850. $attributes
  851. = array(
  852. 'class' => 'btn btn-block ',
  853. 'onclick' => $jsName.
  854. "('{$selectId}', ".
  855. "this.form.elements['".$selectNameFrom."'], ".
  856. "this.form.elements['".$selectNameTo."'], ".
  857. "this.form.elements['".$selectName."'], ".
  858. "'add', '{$this->_sort}'); return false;"
  859. );
  860. $this->_addButtonAttributes
  861. = array_merge($this->_addButtonAttributes, $attributes);
  862. $attrStrAdd = $this->_getAttrString($this->_addButtonAttributes);
  863. $strHtmlAdd = "<button$attrStrAdd /><i class='icon-arrow-right icon-large'></i></button>".PHP_EOL;
  864. // build the select all button with all its attributes
  865. $attributes
  866. = array(
  867. 'onclick' => $jsName.
  868. "('{$selectId}', ".
  869. "this.form.elements['".$selectNameFrom."'], ".
  870. "this.form.elements['".$selectNameTo."'], ".
  871. "this.form.elements['".$selectName."'], ".
  872. "'all', '{$this->_sort}'); return false;"
  873. );
  874. $this->_allButtonAttributes
  875. = array_merge($this->_allButtonAttributes, $attributes);
  876. $attrStrAll = $this->_getAttrString($this->_allButtonAttributes);
  877. $strHtmlAll = "<input$attrStrAll />".PHP_EOL;
  878. // build the select none button with all its attributes
  879. $attributes
  880. = array(
  881. 'onclick' => $jsName.
  882. "('{$selectId}', ".
  883. "this.form.elements['".$selectNameFrom."'], ".
  884. "this.form.elements['".$selectNameTo."'], ".
  885. "this.form.elements['".$selectName."'], ".
  886. "'none', '{$this->_sort}'); return false;"
  887. );
  888. $this->_noneButtonAttributes
  889. = array_merge($this->_noneButtonAttributes, $attributes);
  890. $attrStrNone = $this->_getAttrString($this->_noneButtonAttributes);
  891. $strHtmlNone = "<input$attrStrNone />".PHP_EOL;
  892. // build the toggle button with all its attributes
  893. $attributes
  894. = array(
  895. 'onclick' => $jsName.
  896. "('{$selectId}', ".
  897. "this.form.elements['".$selectNameFrom."'], ".
  898. "this.form.elements['".$selectNameTo."'], ".
  899. "this.form.elements['".$selectName."'], ".
  900. "'toggle', '{$this->_sort}'); return false;"
  901. );
  902. $this->_toggleButtonAttributes
  903. = array_merge($this->_toggleButtonAttributes, $attributes);
  904. $attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes);
  905. $strHtmlToggle = "<input$attrStrToggle />".PHP_EOL;
  906. // build the move up button with all its attributes
  907. $attributes
  908. = array(
  909. 'onclick' => "{$this->_jsPrefix}moveUp".
  910. "(this.form.elements['".$selectNameTo."'], ".
  911. "this.form.elements['".$selectName."']); ".
  912. "return false;"
  913. );
  914. $this->_upButtonAttributes
  915. = array_merge($this->_upButtonAttributes, $attributes);
  916. $attrStrUp = $this->_getAttrString($this->_upButtonAttributes);
  917. $strHtmlMoveUp = "<input$attrStrUp />".PHP_EOL;
  918. // build the move down button with all its attributes
  919. $attributes
  920. = array(
  921. 'onclick' => "{$this->_jsPrefix}moveDown".
  922. "(this.form.elements['".$selectNameTo."'], ".
  923. "this.form.elements['".$selectName."']); ".
  924. "return false;"
  925. );
  926. $this->_downButtonAttributes
  927. = array_merge($this->_downButtonAttributes, $attributes);
  928. $attrStrDown = $this->_getAttrString($this->_downButtonAttributes);
  929. $strHtmlMoveDown = "<input$attrStrDown />".PHP_EOL;
  930. // build the move top button with all its attributes
  931. $attributes
  932. = array(
  933. 'onclick' => "{$this->_jsPrefix}moveTop".
  934. "(this.form.elements['".$selectNameTo."'], ".
  935. "this.form.elements['".$selectName."']); ".
  936. "return false;"
  937. );
  938. $this->_topButtonAttributes
  939. = array_merge($this->_topButtonAttributes, $attributes);
  940. $attrStrTop = $this->_getAttrString($this->_topButtonAttributes);
  941. $strHtmlMoveTop = "<input$attrStrTop />".PHP_EOL;
  942. // build the move bottom button with all its attributes
  943. $attributes
  944. = array(
  945. 'onclick' => "{$this->_jsPrefix}moveBottom".
  946. "(this.form.elements['".$selectNameTo."'], ".
  947. "this.form.elements['".$selectName."']); ".
  948. "return false;"
  949. );
  950. $this->_bottomButtonAttributes
  951. = array_merge($this->_bottomButtonAttributes, $attributes);
  952. $attrStrBottom = $this->_getAttrString($this->_bottomButtonAttributes);
  953. $strHtmlMoveBottom = "<input$attrStrBottom />".PHP_EOL;
  954. // default selection counters
  955. $strHtmlSelectedCount = $selected_count;
  956. }
  957. $strHtmlUnselectedCount = $unselected_count;
  958. $strHtmlSelectedCountId = $selectId.'_selected';
  959. $strHtmlUnselectedCountId = $selectId.'_unselected';
  960. // render all part of the multi select component with the template
  961. $strHtml = $this->_elementTemplate;
  962. // Prepare multiple labels
  963. $labels = $this->getLabel();
  964. if (is_array($labels)) {
  965. array_shift($labels);
  966. }
  967. // render extra labels, if any
  968. if (is_array($labels)) {
  969. foreach ($labels as $key => $text) {
  970. $key = is_int($key) ? $key + 2 : $key;
  971. $strHtml = str_replace("{label_{$key}}", $text, $strHtml);
  972. $strHtml = str_replace("<!-- BEGIN label_{$key} -->", '', $strHtml);
  973. $strHtml = str_replace("<!-- END label_{$key} -->", '', $strHtml);
  974. }
  975. }
  976. // clean up useless label tags
  977. if (strpos($strHtml, '{label_')) {
  978. $strHtml = preg_replace(
  979. '/\s*<!-- BEGIN label_(\S+) -->'.
  980. '.*<!-- END label_\1 -->\s*/i',
  981. '',
  982. $strHtml
  983. );
  984. }
  985. $placeHolders = array(
  986. '{stylesheet}',
  987. '{javascript}',
  988. '{class}',
  989. '{unselected_count_id}',
  990. '{selected_count_id}',
  991. '{unselected_count}',
  992. '{selected_count}',
  993. '{unselected}',
  994. '{selected}',
  995. '{add}',
  996. '{remove}',
  997. '{all}',
  998. '{none}',
  999. '{toggle}',
  1000. '{moveup}',
  1001. '{movedown}',
  1002. '{movetop}',
  1003. '{movebottom}'
  1004. );
  1005. $htmlElements = array(
  1006. $this->getElementCss(false),
  1007. $this->getElementJs(false),
  1008. $this->_tableAttributes,
  1009. $strHtmlUnselectedCountId,
  1010. $strHtmlSelectedCountId,
  1011. $strHtmlUnselectedCount,
  1012. $strHtmlSelectedCount,
  1013. $strHtmlUnselected,
  1014. $strHtmlSelected.$strHtmlHidden,
  1015. $strHtmlAdd,
  1016. $strHtmlRemove,
  1017. $strHtmlAll,
  1018. $strHtmlNone,
  1019. $strHtmlToggle,
  1020. $strHtmlMoveUp,
  1021. $strHtmlMoveDown,
  1022. $strHtmlMoveTop,
  1023. $strHtmlMoveBottom
  1024. );
  1025. $strHtml = str_replace($placeHolders, $htmlElements, $strHtml);
  1026. $comment = $this->getComment();
  1027. if (!empty($comment)) {
  1028. $strHtml = $tabs.'<!-- '.$comment." //-->".PHP_EOL.$strHtml;
  1029. }
  1030. return $strHtml;
  1031. }
  1032. /**
  1033. * Returns the javascript code generated to handle this element
  1034. *
  1035. * @param boolean $raw (optional) html output with script tags or just raw data
  1036. * @param boolean $min (optional) uses javascript compressed version
  1037. *
  1038. * @access public
  1039. * @return string
  1040. * @since version 0.4.0 (2005-06-25)
  1041. */
  1042. function getElementJs($raw = true, $min = true)
  1043. {
  1044. $js = '@data_dir@'.DIRECTORY_SEPARATOR
  1045. .'@package_name@'.DIRECTORY_SEPARATOR;
  1046. $js = api_get_path(LIBRARY_PATH).'javascript'.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR;
  1047. if ($min) {
  1048. $js .= 'qfamsHandler-min.js';
  1049. } else {
  1050. $js .= 'qfamsHandler.js';
  1051. }
  1052. if (file_exists($js)) {
  1053. $js = file_get_contents($js);
  1054. } else {
  1055. $js = '';
  1056. }
  1057. if ($raw !== true) {
  1058. $js = '<script type="text/javascript">'
  1059. .PHP_EOL.'//<![CDATA['
  1060. .PHP_EOL.$js
  1061. .PHP_EOL.'//]]>'
  1062. .PHP_EOL.'</script>'
  1063. .PHP_EOL;
  1064. }
  1065. return $js;
  1066. }
  1067. /**
  1068. * Loads options from different types of data sources
  1069. *
  1070. * This method overloaded parent method of select element, to allow
  1071. * loading options with fancy attributes.
  1072. *
  1073. * @param mixed &$options Options source currently supports assoc array or DB_result
  1074. * @param mixed $param1 (optional) See function detail
  1075. * @param mixed $param2 (optional) See function detail
  1076. * @param mixed $param3 (optional) See function detail
  1077. * @param mixed $param4 (optional) See function detail
  1078. *
  1079. * @access public
  1080. * @since version 1.5.0 (2009-02-15)
  1081. * @return PEAR_Error|NULL on error and TRUE on success
  1082. * @throws PEAR_Error
  1083. * @see loadArray()
  1084. */
  1085. function load(
  1086. &$options,
  1087. $param1 = null,
  1088. $param2 = null,
  1089. $param3 = null,
  1090. $param4 = null
  1091. ) {
  1092. if (is_array($options)) {
  1093. $ret = $this->loadArray($options, $param1);
  1094. } else {
  1095. $ret = parent::load($options, $param1, $param2, $param3, $param4);
  1096. }
  1097. return $ret;
  1098. }
  1099. /**
  1100. * Loads the options from an associative array
  1101. *
  1102. * This method overloaded parent method of select element, to allow to load
  1103. * array of options with fancy attributes.
  1104. *
  1105. * @param array $arr Associative array of options
  1106. * @param mixed $values (optional) Array or comma delimited string of selected values
  1107. *
  1108. * @since version 1.5.0 (2009-02-15)
  1109. * @access public
  1110. * @return PEAR_Error on error and TRUE on success
  1111. * @throws PEAR_Error
  1112. * @see load()
  1113. */
  1114. function loadArray($arr, $values = null)
  1115. {
  1116. if (!is_array($arr)) {
  1117. return PEAR::throwError(
  1118. 'Argument 1 of HTML_QuickForm_advmultiselect::'.
  1119. 'loadArray is not a valid array',
  1120. HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
  1121. array('level' => 'exception')
  1122. );
  1123. }
  1124. if (isset($values)) {
  1125. $this->setSelected($values);
  1126. }
  1127. if (is_array($arr)) {
  1128. foreach ($arr as $key => $val) {
  1129. if (is_array($val)) {
  1130. $this->addOption($val[0], $key, $val[1]);
  1131. } else {
  1132. $this->addOption($val, $key);
  1133. }
  1134. }
  1135. }
  1136. return true;
  1137. }
  1138. /**
  1139. * Sets which items should be persistant
  1140. *
  1141. * Sets which items should have the disabled attribute
  1142. * to keep it persistant
  1143. *
  1144. * @param mixed $optionValues Options (key-values) that should be persistant
  1145. * @param bool $persistant (optional) TRUE if persistant, FALSE otherwise
  1146. *
  1147. * @since version 1.5.0 (2009-02-15)
  1148. * @access public
  1149. * @return PEAR_Error on error and TRUE on success
  1150. * @throws PEAR_Error
  1151. */
  1152. function setPersistantOptions($optionValues, $persistant = true)
  1153. {
  1154. if (!is_bool($persistant)) {
  1155. return PEAR::throwError(
  1156. 'Argument 2 of HTML_QuickForm_advmultiselect::'.
  1157. 'setPersistantOptions is not a boolean',
  1158. HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
  1159. array('level' => 'exception')
  1160. );
  1161. }
  1162. if (is_string($optionValues)) {
  1163. $optionValues = array($optionValues);
  1164. }
  1165. if (!is_array($optionValues)) {
  1166. return PEAR::throwError(
  1167. 'Argument 1 of HTML_QuickForm_advmultiselect::'.
  1168. 'setPersistantOptions is not a valid array',
  1169. HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT,
  1170. array('level' => 'exception')
  1171. );
  1172. }
  1173. foreach ($this->_options as $k => $v) {
  1174. if (in_array($v['attr']['value'], $optionValues)) {
  1175. if ($persistant) {
  1176. $this->_options[$k]['attr']['disabled'] = 'disabled';
  1177. } else {
  1178. unset($this->_options[$k]['attr']['disabled']);
  1179. }
  1180. }
  1181. }
  1182. return true;
  1183. }
  1184. /**
  1185. * Returns list of persistant options
  1186. *
  1187. * Returns list of persistant options (key-values) that could not
  1188. * be selected or unselected.
  1189. *
  1190. * @since version 1.5.0 (2009-02-15)
  1191. * @access public
  1192. * @return array
  1193. */
  1194. function getPersistantOptions()
  1195. {
  1196. $options = array();
  1197. foreach ($this->_options as $k => $v) {
  1198. if (isset($v['attr']['disabled'])) {
  1199. $options[] = $this->_options[$k]['attr']['value'];
  1200. }
  1201. }
  1202. return $options;
  1203. }
  1204. }
  1205. // @todo this fires an PHP notice, needed in order to parse the advmultiselect test it in main/group/group_edit.php
  1206. if (class_exists('HTML_QuickForm')) {
  1207. @HTML_QuickForm::registerElementType(
  1208. 'advmultiselect',
  1209. 'HTML/QuickForm/advmultiselect.php',
  1210. 'HTML_QuickForm_advmultiselect'
  1211. );
  1212. }