| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaBaseView UNA Base Representation Classes
- * @{
- */
- class BxBaseFormView extends BxDolForm
- {
- protected static $_isToggleJsAdded = false;
- protected static $_isCssJsAdded = false;
- protected static $_isJQueryUIAdded = false;
- protected static $_isCssJsAddedViewMode = false;
- /**
- * Enable or disable error message displaying
- */
- protected $bEnableErrorIcon = true;
- /**
- * HTML Code of this form
- */
- protected $sCode;
- /**
- * Code which will be added to the beginning of the form.
- * For example, hidden inputs.
- * For internal use only
- */
- protected $_sCodeAdd = '';
- /**
- * for internal use only
- */
- protected $_isSectionOpened = false;
- /**
- * Default divider for several inputs
- */
- protected $_sDivider = '<span class="bx-def-margin-left"></span>';
- /**
- * Alternative divider for several inputs
- */
- protected $_sDividerAlt = '<br />';
- /**
- * Form is added dynamically.
- */
- protected $_bDynamicMode = false;
- /**
- * Function name for generation close form section HTML.
- */
- protected $_sSectionClose = 'getCloseSection';
- /**
- * Function name for generation open form section HTML.
- */
- protected $_sSectionOpen = 'getOpenSection';
-
- /**
- * Constructor
- *
- * @param array $aInfo Form contents
- *
- * $aInfo['params'] = array(
- * 'remove_form' => true|false,
- * );
- *
- * @return BxBaseFormView
- */
- function __construct($aInfo, $oTemplate)
- {
- parent::__construct($aInfo, $oTemplate);
- if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
- $this->_sSectionClose = 'getCloseSectionViewMode';
- $this->_sSectionOpen = 'getOpenSectionViewMode';
- }
- }
- /**
- * Return Form code
- * @param $bDynamicMode - set it to true if form is added via JS/AJAX call, for example form in AJAX popup.
- * @return string
- */
- function getCode($bDynamicMode = false)
- {
- $this->_bDynamicMode = $bDynamicMode;
- $this->addCssJs ();
- $this->aFormAttrs = $this->_replaceMarkers($this->aFormAttrs);
- return ($this->sCode = $this->genForm());
- }
- /**
- * Generate the whole form
- *
- * @return string
- */
- function genForm()
- {
- $this->_sCodeAdd = '';
- $sTable = $this->genRows();
- $sHtmlBefore = isset($this->aParams['html_before']) ? $this->aParams['html_before'] : '';
- $sHtmlAfter = isset($this->aParams['html_after']) ? $this->aParams['html_after'] : '';
- if (!empty($this->aParams['remove_form']) || (isset($this->aParams['view_mode']) && $this->aParams['view_mode'])) {
- $sForm = <<<BLAH
- $sHtmlBefore
- {$this->_sCodeAdd}
- <div class="bx-form-advanced-wrapper {$this->id}_wrapper">
- $sTable
- </div>
- $sHtmlAfter
- BLAH;
- } else {
- $sFormAttrs = bx_convert_array2attrs($this->aFormAttrs, 'bx-form-advanced');
- $sForm = <<<BLAH
- $sHtmlBefore
- <form $sFormAttrs>
- {$this->_sCodeAdd}
- <div class="bx-form-advanced-wrapper {$this->id}_wrapper">
- $sTable
- </div>
- </form>
- <script>
- $(document).ready(function() {
- $(this).addWebForms();
- });
- </script>
- $sHtmlAfter
- BLAH;
- }
- return $sForm;
- }
- /**
- * Generate Table HTML code
- *
- * @return string
- */
- function genRows()
- {
- // add CSRF token if it's needed.
- if (!(isset($this->aParams['view_mode']) && $this->aParams['view_mode']) && getParam('sys_security_form_token_enable') == 'on' && (!isset($this->aParams['csrf']['disable']) || (isset($this->aParams['csrf']['disable']) && $this->aParams['csrf']['disable'] !== true)) && ($mixedCsrfToken = BxDolForm::getCsrfToken()) !== false) {
- $this->aInputs['csrf_token'] = array(
- 'type' => 'hidden',
- 'name' => 'csrf_token',
- 'value' => $mixedCsrfToken,
- 'db' => array ('pass' => 'Xss'),
- 'visible_for_levels' => PHP_INT_MAX,
- );
- }
- // check if we need to generate open section clause
- $sOpenSection = '';
- foreach ($this->aInputs as $aInput) {
- if (isset($aInput['type']) && 'hidden' == $aInput['type'])
- continue;
- if (isset($aInput['type']) && 'block_header' != $aInput['type'])
- $sOpenSection = $this->{$this->_sSectionOpen}();
- break;
- }
- // generate rows contents
- $sCont = '';
- $sFuncGenRow = isset($this->aParams['view_mode']) && $this->aParams['view_mode'] ? 'genViewRow' : 'genRow';
- foreach ($this->aInputs as $aInput)
- if (!isset($aInput['visible_for_levels']) || self::isVisible($aInput))
- $sCont .= $this->$sFuncGenRow($aInput);
- $sCloseSection = $this->{$this->_sSectionClose}();
- return $sOpenSection . $sCont . $sCloseSection;
- }
- /**
- * Generate single Table Row
- *
- * @param array $aInput
- * @return string
- */
- function genRow(&$aInput)
- {
- if (!isset($aInput['type']))
- $aInput['type'] = false;
- if (!empty($aInput['name'])) {
- $sCustomMethod = 'genCustomRow' . $this->_genMethodName($aInput['name']);
- if (method_exists($this, $sCustomMethod))
- return $this->$sCustomMethod($aInput);
- }
- switch ($aInput['type']) {
- case 'block_header':
- $sRow = $this->genRowBlockHeader($aInput);
- break;
- case 'block_end':
- $sRow = $this->genBlockEnd($aInput);
- break;
- case 'hidden':
- // do not generate row for hidden inputs
- $sRow = '';
- $this->_sCodeAdd .= $this->genInput($aInput);
- break;
- case 'select_box':
- $sRow = $this->genRowCustom($aInput, 'genInputSelectBox');
- break;
- case 'files':
- $sRow = $this->genRowCustom($aInput, 'genInputFiles');
- break;
- case 'switcher':
- case 'checkbox':
- $sRow = $this->genRowStandard($aInput, true);
- break;
- default:
- $sRow = $this->genRowStandard($aInput);
- }
- return $sRow;
- }
- /**
- * Generate single Table Row for view mode
- *
- * @param array $aInput
- * @return string
- */
- function genViewRow(&$aInput)
- {
- if (!isset($aInput['type']))
- $aInput['type'] = false;
- if (!empty($aInput['name'])) {
- $sCustomMethod = 'genCustomRow' . $this->_genMethodName($aInput['name']);
- if (method_exists($this, $sCustomMethod))
- return $this->$sCustomMethod($aInput);
- }
- switch ($aInput['type']) {
- case 'block_header':
- $sRow = $this->genRowBlockHeader($aInput);
- break;
- case 'block_end':
- $sRow = $this->genBlockEnd($aInput);
- break;
- default:
- $sRow = $this->genViewRowWrapped($aInput);
- }
- return $sRow;
- }
- /**
- * Generate complete wrapped row for view mode form
- *
- * @param array $aInput
- * @return string
- */
- function genViewRowWrapped(&$aInput)
- {
- $sValue = $this->genViewRowValue($aInput);
- if (null === $sValue)
- return '';
- $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption']) : '';
- return <<<EOS
- <div class="bx-form-row-view-wrapper bx-form-row-view-wrapper-{$aInput['type']} bx-def-padding-sec-top">
- <div class="bx-form-row-view-caption">{$sCaption}:</div>
- <div class="bx-form-row-view-value">{$sValue}</div>
- </div>
- EOS;
- }
- /**
- * Generate value for view mode row
- *
- * @param array $aInput
- * @return string
- */
- function genViewRowValue(&$aInput)
- {
- if (!empty($aInput['name'])) {
- $sCustomMethod = 'genCustomViewRowValue' . $this->_genMethodName($aInput['name']);
- if (method_exists($this, $sCustomMethod))
- return $this->$sCustomMethod($aInput);
- }
- switch ($aInput['type']) {
- case 'hidden':
- $sValue = null;
- break;
- case 'select':
- case 'radio_set':
- $sValue = $this->genViewRowValueForSelect($aInput);
- break;
- case 'datepicker':
- $sValue = null;
- if (empty($aInput['value']) || !$aInput['value'] || '0000-00-00' == $aInput['value'])
- break;
- $sValue = BxTemplFunctions::getInstance()->{is_numeric($aInput['value']) ? 'timeForJs' : 'timeForJsFullDate'}($aInput['value'], isset($aInput['date_format']) ? $aInput['date_format'] : BX_FORMAT_DATE, true);
- break;
- case 'date_time':
- case 'datetime':
- $sValue = null;
- if(empty($aInput['value']) || !$aInput['value'] || '0000-00-00 00:00:00' == $aInput['value'] || '0000-00-00 00:00' == $aInput['value'])
- break;
- $sValue = BxTemplFunctions::getInstance()->{is_numeric($aInput['value']) ? 'timeForJs' : 'timeForJsFullDate'}($aInput['value'], isset($aInput['date_format']) ? $aInput['date_format'] : BX_FORMAT_DATE_TIME, true);
- break;
- case 'checkbox_set':
- case 'select_multiple':
- $sValue = null;
- if (!empty($aInput['value']) && is_array($aInput['value'])) {
- $sValue = '';
- foreach ($aInput['value'] as $sVal)
- $sValue .= $aInput['values'][$sVal] . ', ';
- $sValue = trim ($sValue, ', ');
- }
- break;
- case 'checkbox':
- case 'switcher':
- $sValue = isset($aInput['checked']) && $aInput['checked'] ? _t('_sys_form_checkbox_value_on') : _t('_sys_form_checkbox_value_off');
- break;
- case 'textarea':
- if (isset($aInput['value']) && '' !== $aInput['value'])
- $sValue = (isset($aInput['html']) && $aInput['html']) || (isset($aInput['code']) && $aInput['code']) ? $aInput['value'] : bx_process_output($aInput['value'], BX_DATA_TEXT_MULTILINE);
- else
- $sValue = null;
- break;
- case 'text':
- if(isset($aInput['value']) && '' !== $aInput['value'])
- $sValue = bx_linkify(bx_process_output($aInput['value']));
- else
- $sValue = null;
- break;
- default:
- $sValue = isset($aInput['value']) && '' !== $aInput['value'] ? bx_process_output($aInput['value']) : null;
- }
- return $sValue;
- }
- function genViewRowValueForSelect(&$aInput)
- {
- if (!isset($aInput['value']) || !$aInput['value'])
- return null;
- $s = isset($aInput['value']) && isset($aInput['values'][$aInput['value']]) ? $aInput['values'][$aInput['value']] : null;
- if (isset($aInput['values_list_name']) && ($oCategory = BxDolCategory::getObjectInstanceByFormAndList($this->aFormAttrs['name'], $aInput['values_list_name'])))
- return $oCategory->getCategoryLink($s, $aInput['value']);
- return $s;
- }
- /**
- * Generate standard row
- *
- * @param array $aInput
- * @return string
- */
- function genRowStandard(&$aInput, $isOneLine = false)
- {
- $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption'], BX_DATA_HTML) : '';
- $sRequired = !empty($aInput['required']) ? '<span class="bx-form-required">*</span> ' : '';
- $sClassAdd = !empty($aInput['error']) ? ' bx-form-error' : '';
- $sInfoIcon = !empty($aInput['info']) ? $this->genInfoIcon($aInput['info']) : '';
- $sErrorIcon = $this->genErrorIcon(empty($aInput['error']) ? '' : $aInput['error']);
- if (isset($aInput['name']))
- $aInput['tr_attrs']['id'] = "bx-form-element-" . $aInput['name'];
- $sTrAttrs = bx_convert_array2attrs(isset($aInput['tr_attrs']) && is_array($aInput['tr_attrs']) ? $aInput['tr_attrs'] : array(), "bx-form-element-wrapper bx-def-margin-top");
- $sClassOneLineCaption = '';
- $sClassOneLineValue = '';
- if ($isOneLine) {
- $sClassOneLineCaption = ' bx-form-caption-oneline bx-form-caption-oneline-' . $aInput['type'] . ' bx-def-margin-sec-left';
- $sClassOneLineValue = ' bx-form-value-oneline bx-form-value-oneline-' . $aInput['type'];
- $aInput['attrs']['id'] = $this->getInputId($aInput);
- if ($sCaption)
- $sCaption = '<label for="' . $aInput['attrs']['id'] . '">' . $sCaption . '</label>';
- }
- $sInput = $this->genInput($aInput);
- $sCaptionCode = '';
- if ($sCaption)
- $sCaptionCode = '<div class="bx-form-caption' . $sClassOneLineCaption . '">' . $sCaption . $sRequired . '</div>';
- else
- $sInput .= $sRequired;
- $sInputCode = $this->genWrapperInput($aInput, $sInput);
- if (empty($sInputCodeExtra)) $sInputCodeExtra = '';
- if (empty($sInfoIcon)) $sInfoIcon = '';
- if (empty($sInputCode)) $sInputCode = '';
- if (empty($sErrorIcon)) $sErrorIcon = '';
- $sValueCode = '
- <div class="bx-form-value bx-clearfix' . $sClassAdd . $sClassOneLineValue . '">
- ' . $sInputCode . '
- ' . ($isOneLine ? '' : $sInfoIcon . $sErrorIcon) . '
- ' . $sInputCodeExtra . '
- </div>';
- if ($isOneLine)
- $sCode = $sValueCode . $sCaptionCode . '<div class="bx-clear"></div>' . $sInfoIcon . $sErrorIcon;
- else
- $sCode = $sCaptionCode . $sValueCode;
- return "<div $sTrAttrs>" . $sCode . "</div>";
- }
- function genWrapperInput($aInput, $sContent)
- {
- $sAttr = isset($aInput['attrs_wrapper']) && is_array($aInput['attrs_wrapper']) ? bx_convert_array2attrs($aInput['attrs_wrapper']) : '';
- return "<div class=\"bx-form-input-wrapper bx-form-input-wrapper-{$aInput['type']}\" $sAttr>$sContent</div>";
- }
- /**
- * Generate custom row
- *
- * @param array $aInput
- * @param string $sCustomMethod custom method to generate code for input
- * @return string
- */
- function genRowCustom(&$aInput, $sCustomMethod)
- {
- $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption']) : '';
- $sRequired = !empty($aInput['required']) ? '<span class="bx-form-required">*</span> ' : '';
- $sClassAdd = !empty($aInput['error']) ? ' bx-form-error' : '';
- $sInfoIcon = !empty($aInput['info']) ? $this->genInfoIcon($aInput['info']) : '';
- $sErrorIcon = $this->genErrorIcon(empty($aInput['error']) ? '' : $aInput['error']);
- $sInput = $this->$sCustomMethod($aInput, $sInfoIcon, $sErrorIcon);
- if (isset($aInput['name']))
- $aInput['tr_attrs']['id'] = "bx-form-element-" . $aInput['name'];
- $sTrAttrs = bx_convert_array2attrs(empty($aInput['tr_attrs']) ? array() : $aInput['tr_attrs'], "bx-form-element-wrapper bx-def-margin-top");
- $sCaptionCode = '';
- if ($sCaption)
- $sCaptionCode = '<div class="bx-form-caption">' . $sCaption . $sRequired . '</div>';
- $sCode = <<<BLAH
- <div $sTrAttrs>
- $sCaptionCode
- <div class="bx-form-value$sClassAdd">
- <div class="bx-clear"></div>
- $sInput
- <div class="bx-clear"></div>
- </div>
- </div>
- BLAH;
- return $sCode;
- }
- /**
- * Generate Block Headers row
- *
- * @param array $aInput
- * @return string
- */
- function genRowBlockHeader(&$aInput)
- {
- $aAttrs = empty($aInput['attrs']) ? '' : $aInput['attrs'];
- // if there is no caption - show divider only
- if (empty($aInput['caption'])) {
- $sCode = $this->{$this->_sSectionClose}();
- $sCode .= $this->{$this->_sSectionOpen}($aAttrs);
- return $sCode;
- }
- // if section is collapsed by default, add necessary code
- $sClassAddCollapsable = 'bx-form-collapsable';
- if (isset($aInput['collapsed']) and $aInput['collapsed'])
- $sClassAddCollapsable .= ' bx-form-collapsed bx-form-section-hidden';
- // display section with caption
- $sCode = $this->{$this->_sSectionClose}();
- if (empty($aAttrs))
- $aAttrs = array('class' => 'bx-form-collapsable ' . $sClassAddCollapsable);
- else
- $aAttrs['class'] .= ' bx-form-collapsable ' . $sClassAddCollapsable;
- if (isset($this->aParams['view_mode']) && $this->aParams['view_mode'])
- $sLegend = '<legend class="bx-def-padding-left bx-def-padding-sec-right bx-def-font-grayed bx-def-font-h3">' . bx_process_output($aInput['caption']) . '</legend>';
- else
- $sLegend = '<legend class="bx-def-padding-left bx-def-padding-sec-right bx-def-font-grayed bx-def-font-h3"><a href="javascript:void(0);">' . bx_process_output($aInput['caption']) . '</a></legend>';
- $sCode .= $this->{$this->_sSectionOpen}($aAttrs, $sLegend);
- return $sCode;
- }
- function genBlockEnd()
- {
- $aNextTbodyAdd = false; // need to have some default
- $sCode = '';
- $sCode .= $this->{$this->_sSectionClose}();
- $sCode .= $this->{$this->_sSectionOpen}($aNextTbodyAdd);
- return $sCode;
- }
- /**
- * Generate HTML Input Element
- *
- * @param array $aInput
- * @return string Output HTML Code
- */
- function genInput(&$aInput)
- {
- if (!empty($aInput['name'])) {
- $sCustomMethod = 'genCustomInput' . $this->_genMethodName($aInput['name']);
- if (method_exists($this, $sCustomMethod))
- return $this->$sCustomMethod($aInput);
- }
- switch ($aInput['type']) {
- // standard inputs (and non-standard, interpreted as standard)
- case 'text':
- case 'datepicker':
- case 'date_time':
- case 'datetime':
- case 'number':
- case 'checkbox':
- case 'radio':
- case 'image':
- case 'password':
- case 'slider':
- case 'doublerange':
- case 'hidden':
- $sInput = $this->genInputStandard($aInput);
- break;
- case 'file':
- $sInput = $this->genInputFile($aInput);
- break;
- case 'rgb':
- case 'rgba':
- $sClass = 'bx-form-input-' . $aInput['type'];
- $aInput['attrs']['class'] = !empty($aInput['attrs']['class']) ? $aInput['attrs']['class'] . ' ' . $sClass : $sClass;
- $aInput['type'] = 'text';
- $sInput = $this->genInputStandard($aInput);
- break;
- case 'switcher':
- $sInput = $this->genInputSwitcher($aInput);
- break;
- case 'button':
- case 'reset':
- case 'submit':
- $sInput = $this->genInputButton($aInput);
- break;
- case 'textarea':
- $sInput = $this->genInputTextarea($aInput);
- break;
- case 'select':
- $sInput = $this->genInputSelect($aInput);
- break;
- case 'select_multiple':
- $sInput = $this->genInputSelectMultiple($aInput);
- break;
- case 'checkbox_set':
- $sInput = $this->genInputCheckboxSet($aInput);
- break;
- case 'radio_set':
- $sInput = $this->genInputRadioSet($aInput);
- break;
- case 'input_set': // numeric array of inputs
- $sInput = '';
- $sDivider = isset($aInput['dv']) ? $aInput['dv'] : ' ';
- foreach ($aInput as $iKey => $aSubInput) {
- if (!is_int($iKey) or !$aSubInput)
- continue; // parse only integer keys and existing values
- $sInput .= $this->genInput($aSubInput); // recursive call
- $sInput .= $sDivider;
- }
- $sInput .= '<div class="bx-clear"></div>';
- break;
- case 'custom':
- $sInput = isset($aInput['content']) ? $aInput['content'] : '';
- break;
- case 'captcha':
- $sInput = $this->genInputCaptcha($aInput);
- break;
- case 'location':
- $sInput = $this->genInputLocation($aInput);
- break;
- case 'value':
- $sInput = isset($aInput['value']) ? $aInput['value'] : '';
- break;
- default:
- //unknown control type
- $sInput = 'Unknown control type';
- }
- // create input label
- $sInput .= $this->genLabel($aInput);
- return $sInput;
- }
- /**
- * Generate new Input Element id
- *
- * @param array $aInput
- * @return string
- */
- function getInputId(&$aInput)
- {
- if (isset($aInput['id']))
- return $aInput['id'];
- $sName = md5($aInput['name']);
- $sID = $this->id . '_input_' . $sName;
- if ( // multiple elements cause identical id's
- (
- (
- $aInput['type'] == 'checkbox' and
- substr($aInput['name'], -2) == '[]' // it is multiple element
- ) or
- $aInput['type'] == 'radio' // it is always multiple (i think so... hm)
- ) and
- isset($aInput['value']) // if we can make difference
- ) {
- $sValue = md5($aInput['value']);
- // add value
- $sID .= '_' . $sValue;
- }
- $sID = trim($sID, '_');
- $aInput['id'] = $sID; // just for repeated calls
- return $sID;
- }
- /**
- * Generate standard Input Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputStandard(&$aInput)
- {
- // clone attributes for system use ;)
- $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
- // add default className to attributes
- $aAttrs['type'] = $aInput['type'];
- if ('datetime' == $aAttrs['type'])
- $aAttrs['type'] = 'date_time';
- if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
- if (isset($aInput['value'])) $aAttrs['value'] = $aInput['value'];
- // for inputs with labels generate id
- if (isset($aInput['label']))
- $aAttrs['id'] = $this->getInputId($aInput);
- // for checkboxes
- if (isset($aInput['checked']) and $aInput['checked'])
- $aAttrs['checked'] = 'checked';
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
- return "<input $sAttrs />\n";
- }
- /**
- * Generate Switcher Input Element (based on checkbox)
- *
- * @param array $aInput
- * @return string
- */
- function genInputSwitcher(&$aInput)
- {
- $aInput['type'] = 'checkbox';
- $sCheckbox = $this->genInputStandard($aInput);
- $aInput['type'] = 'switcher';
- $sClass = 'off';
- if (isset($aInput['checked']) and $aInput['checked'])
- $sClass = 'on';
- return '
- <div class="bx-switcher-cont ' . $sClass . '">' . $sCheckbox . '
- <div class="bx-switcher-canvas">
- <div class="bx-switcher-on"><i class="sys-icon check"></i></div>
- <div class="bx-switcher-off"><i class="sys-icon times"></i></div>
- <div class="bx-switcher-handler"> </div>
- </div>
- </div>';
- }
- /**
- * Generate Button Input Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputButton(&$aInput)
- {
- // clone attributes for system use ;)
- $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
- // add default className to attributes
- $aAttrs['type'] = $aInput['type'];
- if (isset($aInput['value']))
- $aAttrs['value'] = $aInput['value'];
- if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']} bx-btn" . ('submit' == $aInput['type'] ? ' bx-btn-primary' : ''));
- return "<button $sAttrs>" . $aInput['value'] . "</button>\n";
- }
- /**
- * Generate Textarea Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputTextarea(&$aInput)
- {
- // clone attributes for system use ;)
- $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
- $aAttrs['name'] = $aInput['name'];
- // for inputs with labels generate id
- if (isset($aInput['label']))
- $aAttrs['id'] = $this->getInputId($aInput);
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}" . ((isset($aInput['html']) and $aInput['html'] and $this->addHtmlEditor($aInput['html'], $aInput)) ? ' bx-form-input-html' : ''));
- $sValue = isset($aInput['value']) ? bx_process_output((isset($aInput['html']) && $aInput['html']) || (isset($aInput['code']) && $aInput['code']) ? $aInput['value'] : strip_tags($aInput['value'])) : '';
- return "<textarea $sAttrs>$sValue</textarea>";
- }
- function addHtmlEditor($iViewMode, &$aInput)
- {
- $oEditor = BxDolEditor::getObjectInstance(false, $this->oTemplate);
- if (!$oEditor)
- return false;
- $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode);
- return true;
- }
- /**
- * Generate Select Box Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputSelectBox(&$aInput, $sInfo = '', $sError = '')
- {
- $aNewInput = $aInput;
- $aNewInput['type'] = 'select';
- $aNewInput['name'] .= '[]';
- $sInput = $this->genInput($aNewInput);
- return <<<BLAH
- <div class="bx-form-input-wrapper input-wrapper-{$aInput['type']}">
- $sInput
- </div>
- $sInfo
- $sError
- BLAH;
- }
- /**
- * Generate Browse File Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputFile(&$aInput)
- {
- $sOnChange = "$(this).parents('.bx-form-input-wrapper-file:first').find('.bx-fif-value').html($(this).val());";
- if(!empty($aInput['attrs']['onchange']))
- $aInput['attrs']['onchange'] = $sOnChange . $aInput['attrs']['onchange'];
- else
- $aInput['attrs']['onchange'] = $sOnChange;
- $sInput = $this->genInputStandard($aInput);
- return '<label class="bx-btn">' . $sInput . '<span class="bx-fif-label">' . _t('_sys_form_txt_select_file') . '</span></label><span class="bx-fif-value bx-def-margin-thd-left"></span>';
- }
- /**
- * Generate Select Box Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputFiles(&$aInput, $sInfo = '', $sError = '')
- {
- $sUniqId = genRndPwd (8, false);
- $sUploaders = '';
- $oUploader = null;
- foreach ($aInput['uploaders'] as $sUploaderObject) {
- $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], $sUniqId, $this->oTemplate);
- if (!$oUploader)
- continue;
- $sGhostTemplate = $this->genGhostTemplate($aInput);
- $aAttrs = !empty($aInput['attrs']) ? $aInput['attrs'] : array();
- if (empty($aInput['attrs']['disabled']))
- $aAttrs = array_merge($aAttrs, array('onclick' => $oUploader->getNameJsInstanceUploader() . '.showUploaderForm();'));
-
- $aParams = array(
- 'button_title' => bx_js_string($oUploader->getUploaderButtonTitle(isset($aInput['upload_buttons_titles']) ? $aInput['upload_buttons_titles'] : false)),
- 'content_id' => isset($aInput['content_id']) ? $aInput['content_id'] : '',
- 'storage_private' => isset($aInput['storage_private']) ? $aInput['storage_private'] : '1',
- 'attrs' => bx_convert_array2attrs($aAttrs),
- 'btn_class' => !empty($aInput['attrs']['disabled']) ? 'bx-btn-disabled' : '',
- );
- if (isset($aInput['images_transcoder']) && $aInput['images_transcoder'])
- $aParams['images_transcoder'] = bx_js_string($aInput['images_transcoder']);
- $sUploaders .= $oUploader->getUploaderButton($sGhostTemplate, isset($aInput['multiple']) ? $aInput['multiple'] : true, $aParams);
- }
- return $this->oTemplate->parseHtmlByName('form_field_uploader.html', array(
- 'uploaders_buttons' => $sUploaders,
- 'info' => $sInfo,
- 'error' => $sError,
- 'id_container_errors' => $oUploader ? $oUploader->getIdContainerErrors() : '',
- 'id_container_result' => $oUploader ? $oUploader->getIdContainerResult() : '',
- 'uploader_instance_name' => $oUploader ? $oUploader->getNameJsInstanceUploader() : '',
- 'is_init_ghosts' => isset($aInput['init_ghosts']) && !$aInput['init_ghosts'] ? 0 : 1,
- ));
- }
- protected function genGhostTemplate(&$aInput)
- {
- $sGhostTemplate = false;
- if (isset($aInput['ghost_template']) && is_object($aInput['ghost_template'])) { // form is not submitted and ghost template is BxDolFormNested object
- $oFormNested = $aInput['ghost_template'];
- if ($oFormNested instanceof BxDolFormNested)
- $sGhostTemplate = $oFormNested->genForm();
- } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && isset($aInput['ghost_template']['inputs'])) { // form is not submitted and ghost template is form array
- $oFormNested = new BxDolFormNested($aInput['name'], $aInput['ghost_template'], $this->aParams['db']['submit_name'], $this->oTemplate);
- $sGhostTemplate = $oFormNested->getCode();
- } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && $aInput['ghost_template']) { // form is submitted and ghost template is array of BxDolFormNested objects
- $sGhostTemplate = array ();
- foreach ($aInput['ghost_template'] as $iFileId => $oFormNested)
- if (is_object($oFormNested) && $oFormNested instanceof BxDolFormNested)
- $sGhostTemplate[$iFileId] = $oFormNested->genForm();
- } elseif (isset($aInput['ghost_template']) && is_string($aInput['ghost_template'])) { // ghost template is just string template, without nested form
- $sGhostTemplate = $aInput['ghost_template'];
- }
- return $sGhostTemplate;
- }
- protected function genCustomInputUsernamesSuggestions ($aInput)
- {
- $this->addJsJQueryUI();
- $this->oTemplate->addJs(array(
- 'jquery.form.min.js',
- ));
- $sVals = '';
- if (!empty($aInput['value']) && is_array($aInput['value'])) {
- foreach ($aInput['value'] as $sVal) {
- if (!$sVal || !($oProfile = BxDolProfile::getInstance($sVal)))
- continue;
- $sVals .= '<b class="val bx-def-color-bg-hl bx-def-round-corners"><img class="bx-def-thumb bx-def-thumb-size bx-def-margin-sec-right" src="' . $oProfile->getThumb() . '">' . $oProfile->getDisplayName() . '<input type="hidden" name="' . $aInput['name'] . '[]" value="' . $sVal . '" /></b>';
- }
- $sVals = trim($sVals, ',');
- }
- return $this->oTemplate->parseHtmlByName('form_field_custom_suggestions.html', array(
- 'id' => $aInput['name'] . time() . mt_rand(0, 100),
- 'url_get_recipients' => $aInput['ajax_get_suggestions'],
- 'name' => $aInput['name'],
- 'b_img' => true,
- 'placeholder' => bx_html_attribute(isset($aInput['placeholder']) ? $aInput['placeholder'] : _t('_sys_form_paceholder_profiles_suggestions'), BX_ESCAPE_STR_QUOTE),
- 'vals' => $sVals,
- ));
- }
- /**
- * Generate Select Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputSelect(&$aInput)
- {
- $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
- return $this->_genInputSelect($aInput, false, $sCurValue, '_isSelected');
- }
- /**
- * Generate Multiple Select Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputSelectMultiple(&$aInput)
- {
- $aCurValues = array();
- if (isset($aInput['value']) && $aInput['value'])
- $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
- return $this->_genInputSelect($aInput, true, $aCurValues, '_isSelectedMultiple');
- }
- /**
- * Generate Checkbox Set Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputCheckboxSet(&$aInput)
- {
- $aCurValues = array();
- if (isset($aInput['value']) && $aInput['value'])
- $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
- return $this->_genInputsSet($aInput, 'checkbox', $aCurValues, '_isSelectedMultiple', '[]');
- }
- /**
- * Generate Radiobuttons Set Element
- *
- * @param array $aInput
- * @return string
- */
- function genInputRadioSet(&$aInput)
- {
- $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
- return $this->_genInputsSet($aInput, 'radio', $sCurValue, '_isSelected');
- }
- function _isSelected ($sValue, $sCurValue)
- {
- return ((string)$sValue === (string)$sCurValue);
- }
- function _isSelectedMultiple ($sValue, $aCurValues)
- {
- return in_array($sValue, $aCurValues);
- }
- function _genInputSelect(&$aInput, $isMultiple, $mixedCurrentVal, $sIsSelectedFunc)
- {
- $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
- $aAttrs['name'] = $aInput['name'];
- if ($isMultiple) {
- $aAttrs['name'] .= '[]';
- $aAttrs['multiple'] = 'multiple';
- }
- // for inputs with labels generate id
- if (isset($aInput['label']))
- $aAttrs['id'] = $this->getInputId($aInput);
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
- // generate options
- $sOptions = '';
- if (isset($aInput['values']) and is_array($aInput['values'])) {
- foreach ($aInput['values'] as $sValue => $sTitle) {
- $sClassC = $sStyleC = "";
- if(is_array($sTitle)) {
- if(isset($sTitle['type'])) {
- switch($sTitle['type']) {
- case 'group_header':
- $sTitle = bx_process_output($sTitle['value']);
- $sOptions .= <<<BLAH
- <optgroup label="$sTitle">
- BLAH;
- break;
- case 'group_end':
- $sOptions .= <<<BLAH
- </optgroup>
- BLAH;
- break;
- }
- continue;
- }
- $sClassC = isset($sTitle['class']) ? " class=\"" . $sTitle['class'] . "\"" : "";
- $sStyleC = isset($sTitle['style']) ? " style=\"" . $sTitle['style'] . "\"" : "";
- $sValue = $sTitle['key'];
- $sTitle = $sTitle['value'];
- }
- $sValueC = bx_html_attribute($sValue);
- $sTitleC = bx_process_output($sTitle);
- $sSelected = $this->$sIsSelectedFunc($sValue, $mixedCurrentVal) ? 'selected="selected"' : '';
- $sOptions .= <<<BLAH
- <option value="$sValueC"$sClassC$sStyleC $sSelected>$sTitleC</option>
- BLAH;
- }
- }
- // generate element
- $sCode = <<<BLAH
- <select $sAttrs>
- $sOptions
- </select>
- BLAH;
- return $sCode;
- }
- function _genInputsSet(&$aInput, $sType, $mixedCurrentVal, $sIsCheckedFunc, $sNameAppend = '')
- {
- $aAttrs = empty($aInput['attrs']) || 'radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type'] ? array() : $aInput['attrs'];
- $aAttrs['name'] = $aInput['name'];
- // for inputs with labels generate id
- if (isset($aInput['label']))
- $aAttrs['id'] = $this->getInputId($aInput);
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
- // generate options
- $sDivider = isset($aInput['dv']) ? $aInput['dv'] : $this->_sDivider;
- $sOptions = '';
- if (isset($aInput['values']) and is_array($aInput['values'])) {
- if (count($aInput['values']) > 3 && $sDivider == $this->_sDivider)
- $sDivider = $this->_sDividerAlt;
- // generate complex input using simple standard inputs
- foreach ($aInput['values'] as $sValue => $sLabel) {
- // create new simple input
- $aNewInput = array(
- 'type' => $sType,
- 'name' => $aInput['name'] . $sNameAppend,
- 'value' => $sValue,
- 'checked' => $this->$sIsCheckedFunc($sValue, $mixedCurrentVal),
- 'label' => $sLabel,
- 'attrs' => !empty($aInput['attrs']) && ('radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type']) ? $aInput['attrs'] : false,
- );
- $sNewInput = $this->genInput($aNewInput);
- // attach new input to complex
- $sOptions .= ($sNewInput . $sDivider);
- }
- }
- // generate element
- $sCode = <<<BLAH
- <div $sAttrs>
- $sOptions
- </div>
- BLAH;
- return $sCode;
- }
- function genInputLocation(&$aInput)
- {
- $isManualInput = (int)(isset($aInput['manual_input']) && $aInput['manual_input']);
- $sIdStatus = $this->getInputId($aInput) . '_status';
- $sIdInput = $this->getInputId($aInput) . '_location';
- $sProto = (0 === strncmp('https', BX_DOL_URL_ROOT, 5)) ? 'https' : 'http';
- $this->oTemplate->addJs($sProto . '://maps.google.com/maps/api/js?libraries=places&language=' . bx_lang_name() . '&key=' . trim(getParam('sys_maps_api_key')));
- $aVars = array (
- 'name' => $aInput['name'],
- 'id_status' => $sIdStatus,
- 'id_input' => $sIdInput,
- 'manual_input' => $isManualInput,
- 'bx_if:manual_input' => array(
- 'condition' => $isManualInput,
- 'content' => array(),
- ),
- 'bx_if:auto_input' => array(
- 'condition' => !$isManualInput,
- 'content' => array(
- 'id_status' => $sIdStatus,
- 'location_string' => _t('_sys_location_undefined'),
- ),
- ),
- );
- $aLocationIndexes = array ('lat', 'lng', 'country', 'state', 'city', 'zip', 'street', 'street_number');
- foreach ($aLocationIndexes as $sKey)
- $aVars[$sKey] = $this->getLocationVal($aInput, $sKey);
- if ($aVars['country']) {
- $aCountries = BxDolFormQuery::getDataItems('Country');
- $s = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
- $aVars['bx_if:auto_input']['content']['location_string'] = $s;
- }
- if ($isManualInput) {
- $aInput['type'] = 'text';
- $aInput['attrs']['id'] = $sIdInput;
- $aVars['input'] = $this->genInputStandard($aInput);
- }
- else {
- if ($this->getLocationVal($aInput, 'lat') && $this->getLocationVal($aInput, 'lng'))
- $aInput['checked'] = true;
- else
- $aInput['checked'] = $this->getCleanValue($aInput['name'] . '_lat') && $this->getCleanValue($aInput['name'] . '_lng') ? 1 : 0;
- $aVars['input'] = $isManualInput ? $this->genInputStandard($aInput) : $this->genInputSwitcher($aInput);
- }
- return $this->oTemplate->parseHtmlByName('form_field_location.html', $aVars);
- }
- protected function getLocationVal ($aInput, $sIndex)
- {
- $s = $aInput['name'] . '_' . $sIndex;
- if (isset($this->_aSpecificValues[$s]))
- return $this->_aSpecificValues[$s];
- return $this->getCleanValue($s);
- }
-
- function genInputCaptcha(&$aInput)
- {
- $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
- // for inputs with labels generate id
- if (isset($aInput['label']))
- $aAttrs['id'] = $this->getInputId($aInput);
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
- $oCaptcha = BxDolCaptcha::getObjectInstance();
- return "<div $sAttrs>" . ($oCaptcha ? $oCaptcha->display($this->_bDynamicMode) : _t('_sys_txt_captcha_not_available')) . "</div>";
- }
- /**
- * Generate Label Element
- *
- * @param string $sLabel Text of the Label
- * @param string $sInputID Dependant Input Element ID
- * @return string HTML code
- */
- function genLabel(&$aInput)
- {
- if (!isset($aInput['label']) or empty($aInput['label']))
- return '';
- $sLabel = $aInput['label'];
- $sInputID = $this->getInputId($aInput);
- $sRet = '<label for="' . $sInputID . '">' . bx_process_output($sLabel) . '</label>';
- return $sRet;
- }
- function genInfoIcon($sInfo)
- {
- return '<div class="bx-form-info bx-def-font-grayed bx-def-font-small">' . bx_process_output($sInfo) . '</div>';
- }
- function genErrorIcon( $sError = '' )
- {
- if ($this->bEnableErrorIcon) {
- $sStyle = '';
- if (!$sError)
- $sStyle = 'style="display:none;"';
- return '<div class="bx-form-warn" ' . $sStyle . '>' . $sError . '</div>';
- }
- }
- function getOpenSection($aAttrs = array(), $sLegend = '')
- {
- if (!$this->_isSectionOpened) {
- if (!$aAttrs || !is_array($aAttrs))
- $aAttrs = array();
- if ($sLegend)
- $sClassesAdd = "bx-form-section-header";
- else
- $sClassesAdd = "bx-form-section-divider";
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
- $this->_isSectionOpened = true;
- return "<!-- form header content begins -->\n <div class=\"bx-form-section-wrapper bx-def-margin-top\"> <div $sAttrs> $sLegend <div class=\"bx-form-section-content bx-def-padding-top bx-def-padding-bottom" . ($sLegend ? ' bx-def-padding-left bx-def-padding-right' : '') . "\">\n";
- } else {
- return '';
- }
- }
- function getCloseSection()
- {
- if ($this->_isSectionOpened) {
- $this->_isSectionOpened = false;
- return "</div> </div> </div> \n<!-- form header content ends -->\n";
- } else {
- return '';
- }
- }
- function getOpenSectionViewMode($aAttrs = array(), $sLegend = '')
- {
- if (!$this->_isSectionOpened) {
- if (!$aAttrs || !is_array($aAttrs))
- $aAttrs = array();
- if ($sLegend)
- $sClassesAdd = "bx-form-section-header";
- else
- $sClassesAdd = "bx-form-section-divider";
- $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-form-view-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
- $this->_isSectionOpened = true;
- return "<!-- form header content begins -->\n <div class=\"bx-form-section-wrapper bx-def-margin-top\"> <div $sAttrs> $sLegend <div class=\"bx-form-section-content bx-def-padding-top\">\n";
- } else {
- return '';
- }
- }
- function getCloseSectionViewMode()
- {
- if ($this->_isSectionOpened) {
- $this->_isSectionOpened = false;
- return "</div> </div> </div> \n<!-- form header content ends -->\n";
- } else {
- return '';
- }
- }
- function addCssJs ()
- {
- if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
- if (self::$_isCssJsAddedViewMode)
- return;
- $this->oTemplate->addCss('forms.css');
- self::$_isCssJsAddedViewMode = true;
- } else {
- $this->addJsJQueryUI();
-
- if (self::$_isCssJsAdded)
- return;
- $aCss = array(
- 'forms.css',
- 'jquery-ui/jquery-ui.css',
- 'timepicker-addon/jquery-ui-timepicker-addon.css',
- BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'jquery-minicolors/|jquery.minicolors.css',
- );
- $aUiLangs = array ('af' => 1, 'ar-DZ' => 1, 'ar' => 1, 'az' => 1, 'be' => 1, 'bg' => 1, 'bs' => 1, 'ca' => 1, 'cs' => 1, 'cy-GB' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'en-AU' => 1, 'en-GB' => 1, 'en-NZ' => 1, 'en' => 1, 'eo' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fa' => 1, 'fi' => 1, 'fo' => 1, 'fr-CA' => 1, 'fr-CH' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hi' => 1, 'hr' => 1, 'hu' => 1, 'hy' => 1, 'id' => 1, 'is' => 1, 'it' => 1, 'ja' => 1, 'ka' => 1, 'kk' => 1, 'km' => 1, 'ko' => 1, 'ky' => 1, 'lb' => 1, 'lt' => 1, 'lv' => 1, 'mk' => 1, 'ml' => 1, 'ms' => 1, 'nb' => 1, 'nl-BE' => 1, 'nl' => 1, 'nn' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'rm' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sl' => 1, 'sq' => 1, 'sr-SR' => 1, 'sr' => 1, 'sv' => 1, 'ta' => 1, 'th' => 1, 'tj' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-HK' => 1, 'zh-TW' => 1);
- $aCalendarLangs = array ('af' => 1, 'am' => 1, 'bg' => 1, 'ca' => 1, 'cs' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fa' => 1, 'fi' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hr' => 1, 'hu' => 1, 'id' => 1, 'it' => 1, 'ja' => 1, 'ko' => 1, 'lt' => 1, 'lv' => 1, 'mk' => 1, 'nl' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sl' => 1, 'sr-RS' => 1, 'sr-YU' => 1, 'sv' => 1, 'th' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-TW' => 1);
- $sCalendarLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aCalendarLangs);
- $sUiLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aUiLangs);
- $aJs = array(
- 'jquery.webForms.js',
- 'jquery-ui/i18n/jquery.ui.datepicker-' . $sUiLang . '.js',
- 'jquery-minicolors/jquery.minicolors.min.js',
- 'timepicker-addon/jquery-ui-timepicker-addon.min.js',
- 'timepicker-addon/jquery-ui-sliderAccess.js',
- 'timepicker-addon/i18n/jquery-ui-timepicker-' . $sCalendarLang . '.js',
- );
- foreach ($this->aInputs as $aInput) {
- if (!isset($aInput['type']) || 'files' != $aInput['type'] || !isset($aInput['uploaders']))
- continue;
- foreach ($aInput['uploaders'] as $sUploaderObject) {
- $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], '', $this->oTemplate);
- if ($oUploader)
- $oUploader->addCssJs();
- }
- }
- $this->oTemplate->addJs($aJs);
- $this->oTemplate->addCss($aCss);
- self::$_isCssJsAdded = true;
- }
- }
- function addJsJQueryUI ()
- {
- if (self::$_isJQueryUIAdded)
- return;
- $this->oTemplate->addJs('jquery-ui/jquery-ui.custom.min.js');
- self::$_isJQueryUIAdded = true;
- }
- }
- /** @} */
|