function getAuthorAddon($aData, $oProfile) { $s = parent::getAuthorAddon($aData, $oProfile); if (!$aData['cat']) { return $s; } if (!($oCat = BxTemplCategory::getObjectInstance('bx_posts_cats'))) { return $s; } if (!($aCats = BxDolForm::getDataItems('bx_posts_cats')) || !isset($aCats[$aData['cat']])) { return $s; } $s = _t('_bx_posts_txt_category_link', $oCat->getCategoryUrl($aData['cat']), $aCats[$aData['cat']]) . '<br />' . $s; return $s; }
/** * Get all categories list * @param $bDisplayEmptyCats display categories with no items, true by default * @return categories list html */ public function getCategoriesList($bDisplayEmptyCats = true) { $a = BxDolForm::getDataItems($this->_aObject['list_name']); if (!$a) { return ''; } $aVars = array('bx_repeat:cats' => array()); foreach ($a as $sValue => $sName) { if (!$sValue) { continue; } $iNum = $this->getItemsNum($sValue); if (!$bDisplayEmptyCats && !$iNum) { continue; } $aVars['bx_repeat:cats'][] = array('url' => $this->getCategoryUrl($sValue), 'name' => $sName, 'value' => $sValue, 'num' => $iNum); } if (!$aVars['bx_repeat:cats']) { return ''; } return $this->_oTemplate->parseHtmlByName('category_list.html', $aVars); }
/** * 'recheck' action handler */ public function performActionAdd() { bx_import('BxTemplFormView'); $aForm = array('form_attrs' => array('id' => 'bx_antispam_form_dnsbl_add', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=bx_antispam_grid_dnsbl&a=add', 'method' => 'post'), 'params' => array('db' => array('table' => 'bx_antispam_dnsbl_rules', 'key' => 'id', 'submit_name' => 'do_submit')), 'inputs' => array('country' => array('type' => 'select', 'name' => 'country', 'caption' => _t('_bx_antispam_field_country'), 'values' => BxDolForm::getDataItems('Country')), 'chain' => array('type' => 'radio_set', 'name' => 'chain', 'caption' => _t('_bx_antispam_field_action'), 'values' => array('spammers' => _t('_bx_antispam_chain_spammers'), 'whitelist' => _t('_bx_antispam_chain_whitelist')), 'value' => 'spammers'), 'submit' => array('type' => 'input_set', 0 => array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_sys_submit')), 1 => array('type' => 'reset', 'name' => 'close', 'value' => _t('_sys_close'), 'attrs' => array('class' => 'bx-def-margin-sec-left', 'onclick' => '$(\'.bx-popup-applied:visible\').dolPopupHide();'))))); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { // if form is submitted and all fields are valid $aCustomValues = array('chain' => $oForm->getCleanValue('chain'), 'zonedomain' => sprintf("%s.countries.nerd.dk.", strtolower($oForm->getCleanValue('country'))), 'postvresp' => '127.0.0.2', 'url' => 'http://countries.nerd.dk/', 'comment' => '_bx_antispam_rule_note_country', 'added' => time(), 'active' => 1); $iRecentId = $oForm->insert($aCustomValues, true); // insert new record if ($iRecentId) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iRecentId); } else { $aRes = array('msg' => _t('_sys_txt_error_occured')); } // if record adding failed, display error message $this->_echoResultJson($aRes, true); } else { // if form is not submitted or some fields are invalid, display popup with form bx_import('BxTemplFunctions'); $s = BxTemplFunctions::getInstance()->popupBox($oForm->getId() . '_form', _t('_bx_antispam_popup_dnsbl_add'), $oForm->getCode() . ' <script> $(document).ready(function () { $("#' . $oForm->getId() . '").ajaxForm({ dataType: "json", beforeSubmit: function (formData, jqForm, options) { bx_loading($("#' . $oForm->getId() . '"), true); }, success: function (data) { $(".bx-popup-applied:visible").dolPopupHide(); glGrids.' . $this->_sObject . '.processJson(data, "add"); } }); }); </script>'); $this->_echoResultJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))), true); } }
public function performActionDelete() { $sAction = 'delete'; $iAffected = 0; $aIds = bx_get('ids'); if (!$aIds || !is_array($aIds)) { $this->_echoResultJson(array()); exit; } $oLanguage = BxDolStudioLanguagesUtils::getInstance(); $aList = array(); $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $aList, false); $aIdsAffected = array(); foreach ($aIds as $iId) { $aValue = array(); $this->oDb->getValues(array('type' => 'by_id', 'value' => (int) $iId), $aValue); if (!is_array($aValue) || empty($aValue)) { continue; } if ((int) $this->_delete($iId) <= 0) { continue; } $oLanguage->deleteLanguageString($aValue['lkey']); $oLanguage->deleteLanguageString($aValue['lkey2']); if ((int) $aList['use_for_sets'] != 1) { $bUseInSets = 1; $aValues = BxDolForm::getDataItems($this->sList); foreach ($aValues as $mixedValue => $sTitle) { if (!$this->canUseForSet($mixedValue)) { $bUseInSets = 0; break; } } if ($bUseInSets == 1) { $this->oDb->updateList($aList['id'], array('use_for_sets' => $bUseInSets)); } } $aIdsAffected[] = $iId; $iAffected++; } $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_form_err_pre_values_delete'))); }
private function onSave(&$oForm) { $aList = array(); $this->oDb->getLists(array('type' => 'by_key', 'value' => $oForm->getCleanValue('Key')), $aList, false); $iUseInSets = 1; $aValues = BxDolForm::getDataItems($aList['key']); foreach ($aValues as $mixedValue => $sTitle) { if (!$this->canUseForSet($mixedValue)) { $iUseInSets = 0; break; } } if ($iUseInSets != (int) $aList['use_for_sets']) { $this->oDb->updateList($aList['id'], array('use_for_sets' => $iUseInSets)); } }
protected function actionValuesList() { if (($sList = bx_get('form_list')) === false) { return array(); } $sList = bx_process_input($sList); $bUseForSets = (int) bx_get('form_use_for_sets') == 1; bx_import('BxDolForm'); $aValues = BxDolForm::getDataItems(trim($sList, BX_DATA_LISTS_KEY_PREFIX . ' '), $bUseForSets); $aTmplVars = array(); foreach ($aValues as $mixedValue => $sTitle) { $aTmplVars[] = array('value' => $mixedValue, 'title' => $sTitle); } return array('content' => BxDolStudioTemplate::getInstance()->parseHtmlByName('forms_select.html', array('bx_repeat:options' => $aTmplVars))); }
protected function getFormEdit($sAction, $sObject) { $aForm = $this->aForm; $aForm['form_attrs']['id'] = 'adm-form-field-edit-' . $this->aParams['display']; $aForm['form_attrs']['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $sObject . '&a=' . $sAction . '&object=' . $this->aParams['object'] . '&display=' . $this->aParams['display'] . '&di_id=' . (int) $this->aField['di_id']; foreach ($aForm['inputs'] as $sKey => $aInput) { if (!in_array($sKey, array('type_display', 'controls'))) { switch ($sKey) { case 'value': $aForm['inputs'][$sKey]['value'] = $this->aField[$sKey]; if (in_array($aForm['inputs']['type']['value'], array('select', 'select_multiple', 'radio_set', 'checkbox_set'))) { $sList = trim($this->getFieldValues($this->aField), BX_DATA_LISTS_KEY_PREFIX . ' '); $bUseForSets = false; if (in_array($aForm['inputs']['type']['value'], array('select_multiple', 'checkbox_set'))) { $aList = array(); $this->oDb->getLists(array('type' => 'by_key', 'value' => $sList), $aList, false); $bUseForSets = (int) $aList['use_for_sets'] == 1; } $aPreValues = BxDolForm::getDataItems($sList, $bUseForSets); foreach ($aPreValues as $mixedValue => $sTitle) { $aForm['inputs'][$sKey]['values'][] = array('key' => $mixedValue, 'value' => $sTitle); } } break; case 'values': if (!empty($this->aField[$sKey])) { $aForm['inputs'][$sKey]['value'] = $this->getFieldValues($this->aField); } if (in_array($aForm['inputs']['type']['value'], array('select', 'select_multiple', 'radio_set', 'checkbox_set'))) { $aForm['inputs'][$sKey]['type'] = 'value'; foreach ($aForm['inputs'][$sKey]['values'] as $aValue) { if ($aValue['key'] == $aForm['inputs'][$sKey]['value']) { $aForm['inputs'][$sKey]['value'] = BxDolStudioTemplate::getInstance()->parseHtmlByName('bx_a.html', array('href' => BX_DOL_URL_STUDIO . 'builder_forms.php?page=pre_values&list=' . trim($aValue['key'], BX_DATA_LISTS_KEY_PREFIX . ' '), 'title' => _t('_adm_form_txt_field_values_manage'), 'bx_repeat:attrs' => array(), 'content' => $aValue['value'])); break; } } unset($aForm['inputs'][$sKey]['values'], $aForm['inputs'][$sKey]['db']); } break; case 'checked': $aForm['inputs'][$sKey]['checked'] = (int) $this->aField[$sKey]; break; case 'collapsed': $aForm['inputs'][$sKey]['checked'] = (int) $this->aField[$sKey]; break; case 'required': $aForm['inputs'][$sKey]['checked'] = (int) $this->aField[$sKey]; if ($aForm['inputs'][$sKey]['checked'] == 1 && isset($aForm['inputs']['checker_func'])) { unset($aForm['inputs']['checker_func']['tr_attrs']['style'], $aForm['inputs']['checker_error']['tr_attrs']['style']); } break; case 'checker_func': $aForm['inputs'][$sKey]['value'] = $this->aField[$sKey]; switch ($aForm['inputs'][$sKey]['value']) { case 'length': unset($aForm['inputs']['checker_params_length_min']['tr_attrs']['style'], $aForm['inputs']['checker_params_length_max']['tr_attrs']['style']); break; case 'preg': unset($aForm['inputs']['checker_params_preg']['tr_attrs']['style']); break; } break; case 'checker_params_length_min': $aParams = unserialize($this->aField['checker_params']); $aForm['inputs'][$sKey]['value'] = isset($aParams['min']) ? (int) $aParams['min'] : 0; break; case 'checker_params_length_max': $aParams = unserialize($this->aField['checker_params']); $aForm['inputs'][$sKey]['value'] = isset($aParams['max']) ? (int) $aParams['max'] : 0; break; case 'checker_params_preg': $aParams = unserialize($this->aField['checker_params']); $aForm['inputs'][$sKey]['value'] = isset($aParams['preg']) ? $aParams['preg'] : ''; break; case 'attrs_min': $aParams = unserialize($this->aField['attrs']); $aForm['inputs'][$sKey]['value'] = isset($aParams['min']) ? (int) $aParams['min'] : 0; break; case 'attrs_max': $aParams = unserialize($this->aField['attrs']); $aForm['inputs'][$sKey]['value'] = isset($aParams['max']) ? (int) $aParams['max'] : 100; break; case 'attrs_step': $aParams = unserialize($this->aField['attrs']); $aForm['inputs'][$sKey]['value'] = isset($aParams['step']) ? (int) $aParams['step'] : 1; break; case 'attrs_src': $aParams = unserialize($this->aField['attrs']); $aForm['inputs'][$sKey]['value'] = isset($aParams['src']) ? $aParams['src'] : ''; break; default: $aForm['inputs'][$sKey]['value'] = $this->aField[$sKey]; } } } if (array_key_exists($aForm['inputs']['type']['value'], $this->aTypesRelated)) { $aForm['inputs']['type'] = $this->getFieldTypesSelector('type', $aForm['inputs']['type']['value'], true); unset($aForm['inputs']['type_display']); } $aForm['inputs']['controls'][0]['value'] = _t('_adm_form_btn_field_save'); return $aForm; }