/** * Return empty recordset. */ private function returnEmptyRecordset() { //Тип форми змінюється для того, щоб xslt опрацював помилку не в Grid'і. $this->setType(self::COMPONENT_TYPE_FORM_ALTER); $this->removeProperty('exttype'); $f = new Field('error_msg'); $fd = new FieldDescription('error_msg'); $fd->setType(FieldDescription::FIELD_TYPE_STRING); $fd->setMode(FieldDescription::FIELD_MODE_READ); $f->setData($this->translate('ERROR_NO_FORM'), true); $d = new Data(); $dd = new DataDescription(); $d->addField($f); $dd->addFieldDescription($fd); $this->setData($d); $this->setDataDescription($dd); $this->setBuilder(new SimpleBuilder()); }
/** * Success. */ protected function success() { $this->setBuilder($this->createBuilder()); $dataDescription = new DataDescription(); $ddi = new FieldDescription('result'); $ddi->setType(FieldDescription::FIELD_TYPE_TEXT); $ddi->setMode(FieldDescription::FIELD_MODE_READ); $ddi->removeProperty('title'); $dataDescription->addFieldDescription($ddi); $data = new Data(); $di = new Field('result'); $di->setData($this->translate('TXT_FEEDBACK_SUCCESS_SEND')); $data->addField($di); $this->setDataDescription($dataDescription); $this->setData($data); $this->setAction(''); $this->addToolbar($this->loadToolbar()); }
/** * Build tab with division rights. * * @return DOMNode */ private function buildDivRightsData() { $builder = new TreeBuilder(); $builder->setTree(TreeConverter::convert($this->dbh->select('share_sitemap', ['smap_id', 'smap_pid'], null, ['smap_order_num' => QAL::ASC]), 'smap_id', 'smap_pid')); $id = $this->getFilter(); $id = !empty($id) ? current($id) : ''; $data = convertDBResult($this->dbh->select('select s.smap_id as Id, smap_pid as Pid, site_id as Site, smap_name as Name ' . 'from share_sitemap s ' . 'left join share_sitemap_translation st on st.smap_id = s.smap_id ' . 'where lang_id=%s', E()->getLanguage()->getCurrent()), 'Id'); foreach ($data as $smapID => $smapInfo) { $data[$smapID]['RightsId'] = E()->getMap($smapInfo['Site'])->getDocumentRights($smapID, $id); $data[$smapID]['Site'] = E()->getSiteManager()->getSiteByID($smapInfo['Site'])->name; } $dataObject = new Data(); $dataObject->load($data); $builder->setData($dataObject); $dataDescriptionObject = new DataDescription(); $f = new FieldDescription('Id'); $f->setType(FieldDescription::FIELD_TYPE_INT); $f->setProperty('key', true); $dataDescriptionObject->addFieldDescription($f); $f = new FieldDescription('Pid'); $f->setType(FieldDescription::FIELD_TYPE_INT); $dataDescriptionObject->addFieldDescription($f); $f = new FieldDescription('Name'); $f->setType(FieldDescription::FIELD_TYPE_STRING); $dataDescriptionObject->addFieldDescription($f); $f = new FieldDescription('Site'); $f->setType(FieldDescription::FIELD_TYPE_STRING); $dataDescriptionObject->addFieldDescription($f); $f = new FieldDescription('RightsId'); $f->setType(FieldDescription::FIELD_TYPE_SELECT); if ($this->getState() == 'view') { $f->setMode(FieldDescription::FIELD_MODE_READ); } $rights = $this->dbh->select('user_group_rights', ['right_id', 'right_const']); $rights = array_merge([['right_id' => 0, 'right_const' => 'NO_RIGHTS']], $rights); foreach ($rights as $key => $value) { $rights[$key]['right_const'] = $this->translate('TXT_' . $value['right_const']); } $f->loadAvailableValues($rights, 'right_id', 'right_const'); $dataDescriptionObject->addFieldDescription($f); $builder->setData($dataObject); $builder->setDataDescription($dataDescriptionObject); $builder->build(); return $builder->getResult(); }
/** * Show registration result. */ protected function success() { //если в сессии нет переменной saved значит этот метод пытаются вызвать напрямую. Не выйдет! /*if (!isset($_SESSION['saved'])) { throw new SystemException('ERR_404', SystemException::ERR_404); }*/ //unset($_SESSION['saved']); if ($textBlock = $this->document->componentManager->getBlockByName('RegTextBlock')) { $textBlock->disable(); } $this->setBuilder($this->createBuilder()); $dataDescription = new DataDescription(); $ddi = new FieldDescription('success_message'); $ddi->setType(FieldDescription::FIELD_TYPE_TEXT); $ddi->setMode(FieldDescription::FIELD_MODE_READ); $ddi->removeProperty('title'); $dataDescription->addFieldDescription($ddi); $data = new Data(); $di = new Field('success_message'); $di->setData($this->translate('TXT_USER_REGISTRED')); $data->addField($di); $this->setDataDescription($dataDescription); $this->setData($data); }
/** * Show message about incorrect password. * * @throws SystemException 'ERR_404' */ protected function error() { //если в сессии нет переменной error, значит этот метод пытаются дернуть напрямую. Не выйдет! if (!isset($_SESSION['error'])) { throw new SystemException('ERR_404', SystemException::ERR_404); } //Мавр сделал свое дело... unset($_SESSION['error']); $this->setBuilder($this->createBuilder()); $dd = new DataDescription(); $this->setDataDescription($dd); $ddi = new FieldDescription('error_message'); $ddi->setType(FieldDescription::FIELD_TYPE_TEXT); $ddi->setMode(FieldDescription::FIELD_MODE_READ); $ddi->removeProperty('title'); $dd->addFieldDescription($ddi); $d = new Data(); $this->setData($d); $di = new Field('error_message'); $di->setData($this->translate('TXT_USER_PROFILE_WRONG_PWD')); $d->addField($di); $this->document->componentManager->getBlockByName('breadCrumbs')->addCrumb(); }
protected function createDataDescription() { $result = parent::createDataDescription(); //для редактирования и добавления нужно сформировать "красивое дерево разделов" if (in_array($this->getState(), ['add', 'edit'])) { $fd = $result->getFieldDescriptionByName('smap_pid'); $fd->setType(FieldDescription::FIELD_TYPE_STRING); //$fd->setMode(FieldDescription::FIELD_MODE_READ); $result->getFieldDescriptionByName('smap_name')->removeProperty('nullable'); if ($this->getState() == 'edit') { $fd = new FieldDescription('smap_last_mod'); $fd->setType(FieldDescription::FIELD_TYPE_DATETIME); $fd->setProperty('outputFormat', '%E'); $fd->setProperty('tableName', $this->getTableName()); $fd->setMode(FieldDescription::FIELD_MODE_READ); $result->addFieldDescription($fd, DataDescription::FIELD_POSITION_AFTER, 'smap_id'); } } else { //Для режима списка нам нужно выводить не значение а ключ if ($this->getType() == self::COMPONENT_TYPE_LIST) { $smapPIDFieldDescription = $result->getFieldDescriptionByName('smap_pid'); if ($smapPIDFieldDescription) { $smapPIDFieldDescription->setType(FieldDescription::FIELD_TYPE_INT); } } if ($this->getState() == 'getRawData') { $field = new FieldDescription('smap_segment'); $field->setType(FieldDescription::FIELD_TYPE_STRING); $field->setProperty('tableName', $this->getTableName()); $result->addFieldDescription($field); } } return $result; }
/** * Return empty recordset. */ private function returnEmptyRecordset() { $f = new Field('error_msg'); $fd = new FieldDescription('error_msg'); $fd->setType(FieldDescription::FIELD_TYPE_STRING); $fd->setMode(FieldDescription::FIELD_MODE_READ); $f->setData('ERROR_NO_FORM', true); $d = new Data(); $dd = new DataDescription(); $d->addField($f); $dd->addFieldDescription($fd); $this->setData($d); $this->setDataDescription($dd); $this->setBuilder(new SimpleBuilder()); }