| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <?php
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup DolphinView Dolphin Studio Representation classes
- * @ingroup DolphinStudio
- * @{
- */
- defined('BX_DOL') or die('hack attempt');
- bx_import('BxDolStudioFormsDisplays');
- bx_import('BxTemplStudioFormView');
- class BxBaseStudioFormsDisplays extends BxDolStudioFormsDisplays {
- protected $sUrlPage;
- protected $sUrlViewFields;
- function __construct($aOptions, $oTemplate = false) {
- parent::__construct($aOptions, $oTemplate);
- $this->_aOptions['actions_single']['edit']['attr']['title'] = _t('_adm_form_btn_displays_edit');
- $this->sUrlPage = BX_DOL_URL_STUDIO . 'builder_forms.php?page=displays';
- $this->sUrlViewFields = BX_DOL_URL_STUDIO . 'builder_forms.php?page=fields&module=%s&object=%s&display=%s';
- }
- public function performActionEdit() {
- $sAction = 'edit';
- $aIds = bx_get('ids');
- if(!$aIds || !is_array($aIds)) {
- $iId = (int)bx_get('id');
- if(!$iId) {
- $this->_echoResultJson(array());
- exit;
- }
- $aIds = array($iId);
- }
- $iId = $aIds[0];
- $aDisplay = array();
- $iDisplay = $this->oDb->getDisplays(array('type' => 'by_id', 'value' => $iId), $aDisplay);
- if($iDisplay != 1 || empty($aDisplay)){
- $this->_echoResultJson(array());
- exit;
- }
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-form-display-edit',
- 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&object=' . $this->sObject,
- 'method' => BX_DOL_STUDIO_METHOD_DEFAULT
- ),
- 'params' => array (
- 'db' => array(
- 'table' => 'sys_form_displays',
- 'key' => 'id',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'do_submit'
- ),
- ),
- 'inputs' => array (
- 'id' => array(
- 'type' => 'hidden',
- 'name' => 'id',
- 'value' => $iId,
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'title' => array(
- 'type' => 'text_translatable',
- 'name' => 'title',
- 'caption' => _t('_adm_form_txt_displays_title'),
- 'info' => _t('_adm_form_dsc_displays_title'),
- 'value' => $aDisplay['title'],
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'LengthTranslatable',
- 'params' => array(3,100, 'title'),
- 'error' => _t('_adm_form_err_displays_title'),
- ),
- ),
- 'controls' => array(
- 'name' => 'controls',
- 'type' => 'input_set',
- array(
- 'type' => 'submit',
- 'name' => 'do_submit',
- 'value' => _t('_adm_form_btn_displays_save'),
- ),
- array (
- 'type' => 'reset',
- 'name' => 'close',
- 'value' => _t('_adm_form_btn_displays_cancel'),
- 'attrs' => array(
- 'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()",
- 'class' => 'bx-def-margin-sec-left',
- ),
- )
- )
- )
- );
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- if($oForm->update($iId) !== false)
- $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
- else
- $aRes = array('msg' => _t('_adm_form_err_displays_edit'));
- $this->_echoResultJson($aRes, true);
- }
- else {
- bx_import('BxTemplStudioFunctions');
- $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-forms-edit-popup', _t('_adm_form_txt_displays_edit_popup', _t($aDisplay['title'])), $this->_oTemplate->parseHtmlByName('form_add_display.html', array(
- 'form_id' => $aForm['form_attrs']['id'],
- 'form' => $oForm->getCode(true),
- 'object' => $this->_sObject,
- 'action' => $sAction
- )));
- $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
- }
- }
- function getJsObject() {
- return 'oBxDolStudioFormsDisplays';
- }
- function getFormsSelector($sModule = '') {
- bx_import('BxTemplStudioFormView');
- $oForm = new BxTemplStudioFormView(array());
- $aInputForms = array(
- 'type' => 'select',
- 'name' => 'form',
- 'attrs' => array(
- 'id' => 'bx-grid-form-' . $this->_sObject,
- 'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeForm()'
- ),
- 'value' => $this->sObject,
- 'values' => array()
- );
- $aForms = array();
- if(!empty($sModule))
- $this->oDb->getForms(array('type' => 'by_module', 'value' => $sModule), $aForms, false);
- else
- $aInputForms['attrs']['disabled'] = 'disabled';
- if(!empty($aForms)) {
- $aCounter = array();
- $this->oDb->getDisplays(array('type' => 'counter_by_forms'), $aCounter, false);
- foreach($aForms as $aForm)
- $aInputForms['values'][$aForm['object']] = _t($aForm['title']) . " (" . (isset($aCounter[$aForm['object']]) ? $aCounter[$aForm['object']] : "0") . ")";
- asort($aInputForms['values']);
- }
- $aInputForms['values'] = array_merge(array('' => _t('_adm_form_txt_select_form')), $aInputForms['values']);
- return $oForm->genRow($aInputForms);
- }
- function getCode($isDisplayHeader = true) {
- return $this->_oTemplate->parseHtmlByName('forms_displays.html', array(
- 'content' => parent::getCode($isDisplayHeader),
- 'js_object' => $this->getJsObject(),
- 'page_url' => $this->sUrlPage,
- 'grid_object' => $this->_sObject,
- 'params_divider' => $this->sParamsDivider
- ));
- }
- protected function _addJsCss() {
- parent::_addJsCss();
- $this->_oTemplate->addJs(array('jquery.form.js', 'forms_displays.js'));
- bx_import('BxTemplStudioFormView');
- $oForm = new BxTemplStudioFormView(array());
- $oForm->addCssJs();
- }
- protected function _getCellModule($mixedValue, $sKey, $aField, $aRow) {
- $mixedValue = $this->_limitMaxLength($this->getModuleTitle($aRow['module']), $sKey, $aField, $aRow, $this->_isDisplayPopupOnTextOverflow);
- return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
- }
- protected function _getCellFields ($mixedValue, $sKey, $aField, $aRow) {
- $aFields = array();
- $this->oDb->getInputs(array('type' => 'by_object_display', 'object' => $aRow['object'], 'display' => $aRow['display_name']), $aFields, false);
- $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
- 'href' => sprintf($this->sUrlViewFields, $aRow['module'], $aRow['object'], $aRow['display_name']),
- 'title' => _t('_adm_form_txt_displays_manage_fields'),
- 'bx_repeat:attrs' => array(),
- 'content' => _t('_adm_form_txt_forms_n_fields', count($aFields))
- ));
- return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
- }
- protected function _getFilterControls () {
- parent::_getFilterControls();
- $sContent = "";
- bx_import('BxTemplStudioFormView');
- $oForm = new BxTemplStudioFormView(array());
- $aInputModules = array(
- 'type' => 'select',
- 'name' => 'module',
- 'attrs' => array(
- 'id' => 'bx-grid-module-' . $this->_sObject,
- 'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
- ),
- 'value' => $this->sModule,
- 'values' => $this->getModules(false)
- );
- $aCounter = array();
- $this->oDb->getDisplays(array('type' => 'counter_by_modules'), $aCounter, false);
- foreach($aInputModules['values'] as $sKey => $sValue)
- $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
- $aInputModules['values'] = array_merge(array('' => _t('_adm_form_txt_select_module')), $aInputModules['values']);
- $sContent .= $oForm->genRow($aInputModules);
- $sContent .= $this->getFormsSelector($this->sModule);
- $aInputSearch = array(
- 'type' => 'text',
- 'name' => 'keyword',
- 'attrs' => array(
- 'id' => 'bx-grid-search-' . $this->_sObject,
- ),
- 'tr_attrs' => array(
- 'style' => 'display:none;'
- )
- );
- $sContent .= $oForm->genRow($aInputSearch);
- return $sContent;
- }
- }
- /** @} */
|