/** * Send new password to defined E-Mail. */ protected function send() { if ($crumbComponent = $this->document->componentManager->getBlockByName('breadCrumbs')) { $crumbComponent->addCrumb(); } if ($component = $this->document->componentManager->getBlockByName('textBlockRestorePassword')) { $component->disable(); } if (!isset($_POST['u_name'])) { $message = $this->translate('ERR_NO_U_NAME'); } else { $uName = $_POST['u_name']; if (!($UID = $this->dbh->getScalar('user_users', 'u_id', array('u_name' => $uName)))) { $message = $this->translate('ERR_NO_U_NAME'); } else { $password = User::generatePassword(); $this->dbh->modify(QAL::UPDATE, 'user_users', array('u_password' => password_hash($password, PASSWORD_DEFAULT)), array('u_id' => $UID)); $user = new User($UID); $template = new MailTemplate('user_restore_password', ['user_login' => $uName, 'user_name' => $user->getValue('u_fullname'), 'user_password' => $password, 'site_url' => E()->getSiteManager()->getCurrentSite()->base, 'site_name' => $this->translate('TXT_SITE_NAME')]); $mailer = new Mail(); $mailer->setFrom($this->getConfigValue('mail.from'))->setSubject($template->getSubject())->setText($template->getBody())->setHtmlText($template->getHTMLBody())->addTo($uName); $message = $this->translate('MSG_PASSWORD_SENT'); try { $mailer->send(); } catch (\Exception $e) { $message = $e->getMessage(); } } } $this->prepare(); $messageField = new Field('restore_password_result'); $messageField->setData($message); $this->getData()->addField($messageField); }
/** * @copydoc ExtendedSaver::setData */ public function setData(Data $data) { parent::setData($data); if (!$data->getFieldByName('news_segment')->getRowData(0)) { $f = new Field('news_segment'); $translitedTitle = Translit::asURLSegment($data->getFieldByName('news_title')->getRowData(0)); $filter = array(); $pkF = $this->getData()->getFieldByName($this->getPK()); if ($pkF = $pkF->getRowData(0)) { $filter[$this->getPK()] = $pkF; } for ($i = 0; $i < 30; $i++) { $tempTitle = $translitedTitle; if ($i) { $tempTitle = $translitedTitle . '-' . $i; } $filter = array('news_segment' => $tempTitle); if (!$this->dbh->getScalar($this->getTableName(), 'news_segment', $filter)) { break; } else { $tempTitle = $translitedTitle . '-' . $i; } } $translitedTitle = $tempTitle; for ($i = 0, $l = sizeof(E()->getLanguage()->getLanguages()); $i < $l; $i++) { $f->setRowData($i, $translitedTitle); } $data->addField($f); } }
/** * Show login form. */ public function showLoginForm() { $this->prepare(); if (isset($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME])) { $messageField = new FieldDescription('message'); $messageField->setType(FieldDescription::FIELD_TYPE_STRING); $this->getDataDescription()->addFieldDescription($messageField); $messageField->setRights(FieldDescription::FIELD_MODE_READ); $messageField = new Field('message'); $messageField->addRowData($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME]); $this->getData()->addField($messageField); E()->getResponse()->deleteCookie(UserSession::FAILED_LOGIN_COOKIE_NAME); } //Во избежание появления empty рекордсета $this->getData()->addField((new Field('username'))->setRowData(0, '')); //Если есть информация о авторизации через фейсбук foreach (array('auth.facebook', 'auth.vk') as $configSectionName) { if ($this->getToolbar()) { list($tbr) = array_values($this->getToolbar()); if ($ctrl = $tbr->getControlByID($configSectionName)) { $ctrl->disable(); } if ($ctrl && $this->getConfigValue($configSectionName)) { if ($appID = $this->getConfigValue($configSectionName . '.appID')) { $ctrl->setAttribute('appID', $appID); $ctrl->enable(); } } } } }
/** * @copydoc ExtendedFeedEditor::add */ protected function add() { parent::add(); $this->getDataDescription()->getFieldDescriptionByName('news_segment')->setType(FieldDescription::FIELD_TYPE_HIDDEN); $f = new Field('news_is_active'); $f->setData(true, true); $this->getData()->addField($f); }
protected function prepare() { parent::prepare(); if (in_array($this->getState(), array('add', 'edit'))) { $fd = new FieldDescription('questions'); $fd->setType(FieldDescription::FIELD_TYPE_TAB); $fd->setProperty('title', $this->translate('TAB_VOTE_QUESTIONS')); $this->getDataDescription()->addFieldDescription($fd); $field = new Field('questions'); $state = $this->getState(); $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/question/'; $field->setData($tab_url, true); $this->getData()->addField($field); } }
private function buildGroups(Field $field) { $builder = new SimpleBuilder(); $data = new Data(); $dd = new DataDescription(); $dd->load(['id' => ['type' => FieldDescription::FIELD_TYPE_INT, 'key' => true], 'link' => ['type' => FieldDescription::FIELD_TYPE_STRING], 'title' => ['type' => FieldDescription::FIELD_TYPE_STRING], 'text' => ['type' => FieldDescription::FIELD_TYPE_HTML_BLOCK]]); $builder->setDataDescription($dd); foreach ($field as $key => $id) { if ($d = $this->dbh->select('SELECT t.top_id as id, top_name as `title`, top_link as link,top_text_rtf as `text` FROM apps_tops t LEFT JOIN apps_tops_translation tt ON (tt.top_id=t.top_id) AND (lang_id=%s) WHERE (t.tg_id =%s) AND top_is_active ORDER BY top_order_num', $this->document->getLang(), $id)) { $data->load($d); $builder->setData($data); $am = new AttachmentManager($dd, $data, 'apps_tops'); $am->createFieldDescription(); $am->createField('top_id', false, $data->getFieldByName('id')->getData()); $builder->build(); $field->setRowData($key, $builder->getResult()); } else { $field->setRowData($key, null); } } }
/** * Edit ad. * Modify input DataDescription argument by adding to it an information about ad. * * @param Data $d Data. * @param DataDescription $dd Data description. */ public function edit(Data $d, DataDescription $dd) { $fds = $this->dbh->getColumnsInfo(self::TABLE_NAME); unset($fds['smap_id']); $fds['ad_id']['key'] = false; foreach ($fds as $key => $value) { $fds[$key]['tabName'] = 'TXT_ADS'; } $dd->load($fds); $data = $this->dbh->select(self::TABLE_NAME, array_keys($fds), array('smap_id' => $d->getFieldByName('smap_id')->getRowData(0))); if (is_array($data)) { //Тут как всегда проблема с загрузкой значений в мультиязычный билдер foreach ($data[0] as $fieldName => $fieldData) { $f = new Field($fieldName); for ($i = 0, $l = sizeof(E()->getLanguage()->getLanguages()); $i < $l; $i++) { $f->setRowData($i, $fieldData); } $d->addField($f); } } }
/** * @copydoc LoginForm::showLoginForm */ public function showLoginForm() { $this->prepare(); if (isset($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME])) { $messageField = new FieldDescription('message'); $messageField->setType(FieldDescription::FIELD_TYPE_STRING); $this->getDataDescription()->addFieldDescription($messageField); $messageField->setRights(FieldDescription::FIELD_MODE_READ); $messageField = new Field('message'); $messageField->addRowData($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME]); $this->getData()->addField($messageField); E()->getResponse()->deleteCookie(UserSession::FAILED_LOGIN_COOKIE_NAME); } //Во избежание появления empty рекордсета $f = new Field('username'); $f->setData(''); $this->getData()->addField($f); //Если есть информация о авторизации через соц. сети foreach (['fb', 'vk', 'ok', 'goo'] as $socialType) { foreach (array_values($this->getToolbar()) as $tbr) { if ($ctrl = $tbr->getControlByID('auth.' . $socialType)) { $ctrl->disable(); } if ($ctrl && $this->getConfigValue('auth.' . $socialType)) { if (($appID = $this->getConfigValue('auth.' . $socialType . '.appID')) && ($secretKey = $this->getConfigValue('auth.' . $socialType . '.appID'))) { $authClassName = 'Energine\\user\\gears\\' . strtoupper($socialType) . 'OAuth'; /** * @var $auth IOAuth */ $auth = new $authClassName(['appId' => $appID, 'secret' => $secretKey, 'public' => $this->getConfigValue('auth.' . $socialType . '.publicKey')]); $ctrl->setAttribute('loginUrl', $auth->getLoginUrl(['redirect_uri' => ($base = E()->getSiteManager()->getCurrentSite()->base) . 'auth.php?' . $socialType . 'Auth&return=' . $this->getReturnUrl(), 'scope' => $ctrl->getAttribute('permissions')])); $ctrl->setAttribute('appID', $appID); $ctrl->enable(); } } } } }
protected function prepare() { parent::prepare(); if (in_array($this->getState(), array('add', 'edit'))) { $fd = new FieldDescription('domains'); $fd->setType(FieldDescription::FIELD_TYPE_TAB); $fd->setProperty('title', $this->translate('TAB_DOMAINS')); $this->getDataDescription()->addFieldDescription($fd); $field = new Field('domains'); $state = $this->getState(); $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/domains/'; $field->setData($tab_url, true); $this->getData()->addField($field); $fd = $this->getDataDescription()->getFieldDescriptionByName('site_folder'); $fd->setType(FieldDescription::FIELD_TYPE_SELECT); $fd->loadAvailableValues($this->loadFoldersData(), 'key', 'value'); if ($this->getData()->getFieldByName('site_is_default')->getRowData(0) == 1) { $this->getDataDescription()->getFieldDescriptionByName('site_is_default')->setMode(FieldDescription::FIELD_MODE_READ); } $tagField = new FieldDescription('tags'); $tagField->setType(FieldDescription::FIELD_TYPE_STRING); $tagField->removeProperty('pattern'); $this->getDataDescription()->addFieldDescription($tagField); if ($this->getState() == 'add') { //Добавляем селект позволяющий скопировать структуру одного из существующих сайтов в новый $fd = new FieldDescription('copy_site_structure'); $fd->setType(FieldDescription::FIELD_TYPE_SELECT); $fd->loadAvailableValues($this->dbh->select('SELECT ss.site_id, site_name FROM share_sites ss LEFT JOIN share_sites_translation sst ON ss.site_id = sst.site_id WHERE lang_id =%s ', $this->document->getLang()), 'site_id', 'site_name'); $this->getDataDescription()->addFieldDescription($fd); } else { $this->getDataDescription()->getFieldDescriptionByName($this->getPK())->setType(FieldDescription::FIELD_TYPE_INT)->setMode(FieldDescription::FIELD_MODE_READ); $tm = new TagManager($this->getDataDescription(), $this->getData(), $this->getTableName()); $tm->createFieldDescription(); $tm->createField(); } } }
protected function prepare() { parent::prepare(); if (in_array($this->getState(), ['add', 'edit'])) { $fd = new FieldDescription('users'); $fd->setType(FieldDescription::FIELD_TYPE_TAB); $fd->setProperty('title', $this->translate('TAB_SUBSCRIBED_USERS')); $this->getDataDescription()->addFieldDescription($fd); $field = new Field('users'); $state = $this->getState(); $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/users/'; $field->setData($tab_url, true); $this->getData()->addField($field); $fd = new FieldDescription('emails'); $fd->setType(FieldDescription::FIELD_TYPE_TAB); $fd->setProperty('title', $this->translate('TAB_SUBSCRIBED_EMAILS')); $this->getDataDescription()->addFieldDescription($fd); $field = new Field('emails'); $state = $this->getState(); $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/email/'; $field->setData($tab_url, true); $this->getData()->addField($field); } }
/** * Build form. * It adds form name and information about the form. */ private function buildForm() { $result = $this->dbh->select('frm_forms_translation', ['form_name', 'form_annotation_rtf', 'form_post_annotation_rtf'], ['form_id' => $this->formID, 'lang_id' => E()->getLanguage()->getCurrent()]); if (is_array($result)) { $this->setTitle($result[0]['form_name']); //Если поля не существует - создаем if (!($field = $this->getData()->getFieldByName('form_date'))) { $field = new Field('form_date'); $this->getData()->addField($field); } //заполняем текущей датой $field->setData(date('Y-m-d H:i:s')); //Если описания не существует - создаем и добавляем if (!($fd = $this->getDataDescription()->getFieldDescriptionByName('form_date'))) { $fd = new FieldDescription('form_date'); $this->getDataDescription()->addFieldDescription($fd); } else { //Удаялем и добавляем //Это нужно для того чтобы перенести поле в конец списка $this->getDataDescription()->removeFieldDescription($fd); $this->getDataDescription()->addFieldDescription($fd); } $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN)->removeProperty('pattern'); $f = new Field('form_description'); $f->setData($result[0]['form_annotation_rtf'], true); $fd = new FieldDescription('form_description'); $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN)->setMode(FieldDescription::FIELD_MODE_READ); $this->getData()->addField($f); $this->getDataDescription()->addFieldDescription($fd); $f = new Field('form_post_description'); $f->setData($result[0]['form_post_annotation_rtf'], true); $fd = new FieldDescription('form_post_description'); $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN)->setMode(FieldDescription::FIELD_MODE_READ); $this->getData()->addField($f); $this->getDataDescription()->addFieldDescription($fd); if (!($this->document->getUser()->isAuthenticated() || $this->getParam('noCaptcha'))) { $fd = new FieldDescription('captcha'); $fd->setType(FieldDescription::FIELD_TYPE_CAPTCHA); $this->getDataDescription()->addFieldDescription($fd); } foreach ($this->getDataDescription() as $fd) { if ($fd->getType() == FieldDescription::FIELD_TYPE_BOOL) { $fd->setProperty('yes', $this->translate('TXT_YES'))->setProperty('no', $this->translate('TXT_NO')); } } } }
/** * 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 the list of additional files. * @param string $tableName Table name. * @param bool $data Data. * @see DivisionEditor * @see ProductEditor * @note It is used for the cases when additional tab with attached files to the record should be created. */ protected function linkExtraManagers($tableName, $data = false) { if ($this->dbh->tableExists($tableName . AttachmentManager::ATTACH_TABLE_SUFFIX) && $this->getState() != 'attachments') { $fd = new FieldDescription('attached_files'); $fd->setType(FieldDescription::FIELD_TYPE_TAB); $fd->setProperty('title', $this->translate('TAB_ATTACHED_FILES')); $fd->setProperty('tableName', $tableName . AttachmentManager::ATTACH_TABLE_SUFFIX); $this->getDataDescription()->addFieldDescription($fd); $field = new Field('attached_files'); $state = $this->getState(); $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/attachments/'; $field->setData($tab_url, true); $this->getData()->addField($field); } if ($this->dbh->getTagsTablename($this->getTableName())) { $tm = new TagManager($this->getDataDescription(), $this->getData(), $this->getTableName()); $tm->createFieldDescription(); $tm->createField(); } }
/** * @copydoc Grid::edit */ protected function edit() { parent::edit(); $this->buildRightsTab($smapID = $this->getData()->getFieldByName('smap_id')->getRowData(0)); //Выводим УРЛ в поле сегмента $field = $this->getData()->getFieldByName('smap_pid'); $site = E()->getSiteManager()->getSiteByID($this->getData()->getFieldByName('site_id')->getRowData(0)); foreach ([Document::TMPL_CONTENT, Document::TMPL_LAYOUT] as $type) { if ($f = $this->getDataDescription()->getFieldDescriptionByName('smap_' . $type)) { $f->setType(FieldDescription::FIELD_TYPE_SELECT); $old_value = $this->getData()->getFieldByName('smap_' . $type)->getRowData(0); $template_data = $this->loadTemplateData($type, $site->folder, $old_value); $f->loadAvailableValues($template_data, 'key', 'value'); } } //Если изменен - вносим исправления в список возможных значений if ($contentXMLFieldData = $this->dbh->getScalar($this->getTableName(), 'smap_content_xml', ['smap_id' => $this->getData()->getFieldByName('smap_id')->getRowData(0)])) { $contentFilename = $this->getData()->getFieldByName('smap_content')->getRowData(0); $contentFD = $this->getDataDescription()->getFieldDescriptionByName('smap_content'); $contentFD->setProperty('reset', $this->translate('TXT_RESET_CONTENT')); $av =& $contentFD->getAvailableValues(); if (isset($av[$contentFilename])) { $av[$contentFilename]['value'] .= ' - ' . $this->translate('TXT_CHANGED'); } $newField = new FieldDescription('smap_content_xml'); $newField->setProperty('nullable', true); $newField->setType(FieldDescription::FIELD_TYPE_CODE); $newField->setProperty('tableName', $this->getTableName()); $newField->setProperty('tabName', $contentFD->getPropertyValue('tabName')); $this->getDataDescription()->addFieldDescription($newField, DataDescription::FIELD_POSITION_AFTER, 'smap_content'); $newField = new Field('smap_content_xml'); $doc = new \DOMDocument(); $doc->loadXML($contentXMLFieldData); $doc->formatOutput = true; $doc->preserveWhiteSpace = true; $newField->setData($doc->saveXML(null, LIBXML_NOEMPTYTAG), true); $this->getData()->addField($newField); unset($contentFilename, $contentFD, $av, $doc, $newField); } $smapSegment = ''; if ($field->getRowData(0) !== null) { $smapSegment = E()->getMap($site->id)->getURLByID($field->getRowData(0)); $this->getDataDescription()->getFieldDescriptionByName('smap_segment')->removeProperty('nullable'); } else { $this->getDataDescription()->getFieldDescriptionByName('smap_pid')->setMode(FieldDescription::FIELD_MODE_READ)->setType(FieldDescription::FIELD_TYPE_HIDDEN); foreach (['smap_is_disabled', 'smap_segment', 'smap_redirect_url', 'smap_meta_robots', 'smap_meta_keywords', 'smap_meta_description'] as $fieldName) { if ($f = $this->getDataDescription()->getFieldDescriptionByName($fieldName)) { $this->getDataDescription()->removeFieldDescription($f); } } } $smapName = $this->dbh->getScalar($this->getTranslationTableName(), 'smap_name', ['smap_id' => $field->getRowData(0), 'lang_id' => $this->document->getLang()]); for ($i = 0; $i < ($langs = count(E()->getLanguage()->getLanguages())); $i++) { $field->setRowProperty($i, 'data_name', $smapName); $field->setRowProperty($i, 'segment', $smapSegment); } $tm = new TagManager($this->getDataDescription(), $this->getData(), $this->getTableName()); $tm->createFieldDescription(); $tm->createField(); $this->getDataDescription()->getFieldDescriptionByName('smap_id')->setType(FieldDescription::FIELD_TYPE_INT)->setMode(FieldDescription::FIELD_MODE_READ); if (class_exists('AdsManager', false) && AdsManager::isActive()) { $ads = new AdsManager(); $ads->edit($this->getData(), $this->getDataDescription()); } }
/** * 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()); }
protected function createData() { $result = parent::createData(); if ($this->getType() != self::COMPONENT_TYPE_LIST) { $f = new Field('group_div_rights'); $f->setData($this->buildDivRightsData()); $result->addField($f); } return $result; }
/** * 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(); }
/** * Add directory. */ protected function addDir() { $sp = $this->getStateParams(true); if (isset($sp['pid'])) { $uplPID = (int) $sp['pid']; } else { $uplPID = ''; } $this->setType(self::COMPONENT_TYPE_FORM_ADD); $this->setBuilder($this->createBuilder()); $this->setDataDescription($this->createDataDescription()); $this->setData(new Data()); $f = new Field('upl_pid'); $f->setData($uplPID); $this->getData()->addField($f); $this->addToolbar($this->loadToolbar()); $this->js = $this->buildJS(); $this->setAction('save-dir/'); }
/** * Create field. * * @param int|array $targetIds Comment ID(s). * @return Field */ protected function createField($targetIds) { $f = new Field($this->commentsFieldName); $f->setRowProperty(0, 'is_tree', (bool) $this->isTree); $f->setRowProperty(0, 'is_editable', (int) E()->getUser()->isAuthenticated()); $data = $this->getBuildedListByIds($targetIds); $f->setData($data); return $f; }
/** * Build for for editing component parameters. * The form creation is based on XML widget's data received per POST request. * * @throws SystemException 'ERR_INSUFFICIENT_DATA' * @throws SystemException 'ERR_BAD_XML_DESCR' */ protected function buildParamsForm() { if (!isset($_POST['modalBoxData'])) { throw new SystemException('ERR_INSUFFICIENT_DATA'); } if (!($widgetXML = simplexml_load_string($_POST['modalBoxData']))) { throw new SystemException('ERR_BAD_XML_DESCR'); } list($componentName) = $this->getStateParams(); $component = ComponentManager::findBlockByName($widgetXML, $componentName); $dd = new DataDescription(); $d = new Data(); $this->setType(self::COMPONENT_TYPE_FORM_ALTER); $this->setDataDescription($dd); $this->setData($d); $this->setBuilder(new Builder()); $this->js = $this->buildJS(); foreach ($component->params->children() as $param) { $paramName = (string) $param['name']; $paramType = isset($param['type']) ? (string) $param['type'] : FieldDescription::FIELD_TYPE_STRING; $fd = new FieldDescription($paramName); if (isset($param['nullable'])) { $fd->setProperty('nullable', true); } $fd->setType($paramType)->setProperty('tabName', E()->Utils->translate('TAB_PARAMS')); if ($paramType == FieldDescription::FIELD_TYPE_SELECT && isset($param['values'])) { $availableValues = array(); foreach (explode('|', (string) $param['values']) as $value) { array_push($availableValues, array('key' => $value, 'value' => $value)); } $fd->loadAvailableValues($availableValues, 'key', 'value'); } $dd->addFieldDescription($fd); $f = new Field($paramName); $f->setRowData(0, $param); $d->addField($f); } $this->addToolbar($this->loadToolbar()); }
/** * 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); }
protected function prepare() { if ($this->getState() == 'deleteComment') { } else { if ($this->bindComponent && $this->bindComponent->getState() == $this->getParam('bind_state') && $this->getState() == 'main' && $this->getParam('show_form') && $this->getParam('show_comments') && $this->isExistsNeedTables()) { parent::prepare(); if (($this->document->getUser()->isAuthenticated() or !$this->getParam('use_captcha')) && ($captcha = $this->getDataDescription()->getFieldDescriptionByName('captcha'))) { $this->getDataDescription()->removeFieldDescription($captcha); } //ID комментируемого элемента $ap = $this->bindComponent->getStateParams(true); //Тут костыль if (is_array($ap)) { $apk = array_keys($ap); $param_idx = $this->getParam('bind_pk_param_idx'); $apName = isset($apk[$param_idx]) ? $apk[$param_idx] : $apk[sizeof($apk) - 1]; $targetId = $ap[$apName]; } else { $targetId = $this->document->getID(); } if ($this->isTargetEditable()) { $this->getDataDescription()->getFieldDescriptionByName('target_id')->setType(FieldDescription::FIELD_TYPE_HIDDEN); $f = new Field('target_id'); $f->setData($targetId); $this->getData()->addField($f); // добавляем переводы для формы $this->addTranslation('COMMENT_DO'); // коментировать $this->addTranslation('COMMENT_DO_NEWS'); // коментировать новость $this->addTranslation('COMMENT_REMAIN'); // осталось $this->addTranslation('COMMENT_SYMBOL1'); // символ $this->addTranslation('COMMENT_SYMBOL2'); // символа $this->addTranslation('COMMENT_SYMBOL3'); // символов $this->addTranslation('COMMENT_REALY_REMOVE'); // Действительно удалить комментарий? } else { // форма нужна только для вывода списка комментариев $this->setProperty('hide_form', 1); } $this->addTranslation('COMMENTS'); // коментирии } else { $this->disable(); } if ($this->getParam('show_comments') && $this->isExistsNeedTables() && is_object($this->bindComponent) && $this->bindComponent->getState() == $this->getParam('bind_state') && $this->bindComponent->getData() && !$this->bindComponent->getData()->isEmpty()) { $this->showComments(); } } }
protected function createData() { $data = new Data(); $field = new Field($this->getName()); $field->setData($this->getContent()); $data->addField($field); return $data; }