コード例 #1
0
ファイル: PageMedia.php プロジェクト: energine-cmf/energine
 protected function main()
 {
     $id = !($id = $this->getParam('id')) ? $this->document->getID() : $id;
     $this->setBuilder(new SimpleBuilder());
     $dd = new DataDescription();
     if ($this->getConfig()->getCurrentStateConfig() && $this->getConfig()->getCurrentStateConfig()->fields) {
         $dd->loadXML($this->getConfig()->getCurrentStateConfig()->fields);
     } else {
         $dd->load(['Id' => ['type' => FieldDescription::FIELD_TYPE_INT], 'Name' => ['type' => FieldDescription::FIELD_TYPE_STRING], 'Title' => ['type' => FieldDescription::FIELD_TYPE_STRING], 'HtmlTitle' => ['type' => FieldDescription::FIELD_TYPE_STRING], 'DescriptionRtf' => ['type' => FieldDescription::FIELD_TYPE_HTML_BLOCK]]);
     }
     $fd = new FieldDescription('Url');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $dd->addFieldDescription($fd);
     $info = E()->getMap()->getDocumentInfo($id);
     $d = new Data();
     $info['Id'] = $id;
     $info['Url'] = E()->getMap()->getURLByID($id);
     $d->load([$info]);
     $this->setDataDescription($dd);
     $this->setData($d);
     $m = new AttachmentManager($this->getDataDescription(), $this->getData(), 'share_sitemap', true);
     $m->createFieldDescription();
     $m->createField('smap_id', false, $id);
     $this->addToolbar($this->loadToolbar());
     $this->js = $this->buildJS();
 }
コード例 #2
0
ファイル: Robots.php プロジェクト: energine-cmf/energine
 /**
  * @copydoc DataSet::createDataDescription
  */
 protected function createDataDescription()
 {
     $dd = new DataDescription();
     $fd = new FieldDescription('entry');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $dd->addFieldDescription($fd);
     return $dd;
 }
コード例 #3
0
 /**
  * Get data description.
  *
  * @return DataDescription
  */
 public function getDataDescription()
 {
     $result = new DataDescription();
     $result->load(array('field_id' => array('nullable' => false, 'length' => 10, 'default' => '', 'key' => true, 'type' => FieldDescription::FIELD_TYPE_INT, 'index' => 'PRI', 'tableName' => 'table_name'), 'lang_id' => array('nullable' => false, 'length' => 10, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_INT, 'index' => 'PRI', 'tableName' => 'table_name', 'languageID' => true), 'field_name' => array('nullable' => false, 'length' => 255, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_STRING, 'index' => false, 'tableName' => 'share_lang_tags_translation', 'isMultilanguage' => true), 'field_type' => array('nullable' => false, 'length' => 255, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_HIDDEN, 'index' => true, 'tableName' => 'table_name'), 'field_type_real' => array('nullable' => false, 'length' => 255, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_STRING, 'index' => true), 'field_is_nullable' => array('nullable' => false, 'length' => 1, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_BOOL, 'index' => false, 'tableName' => 'table_name')));
     $f = $result->getFieldDescriptionByName('field_type');
     $f->setType(FieldDescription::FIELD_TYPE_SELECT);
     $f->loadAvailableValues(array(array('key' => FieldDescription::FIELD_TYPE_STRING, 'value' => $this->translate('FIELD_TYPE_STRING')), array('key' => FieldDescription::FIELD_TYPE_EMAIL, 'value' => $this->translate('FIELD_TYPE_EMAIL')), array('key' => FieldDescription::FIELD_TYPE_PHONE, 'value' => $this->translate('FIELD_TYPE_PHONE')), array('key' => FieldDescription::FIELD_TYPE_BOOL, 'value' => $this->translate('FIELD_TYPE_BOOL')), array('key' => FieldDescription::FIELD_TYPE_TEXT, 'value' => $this->translate('FIELD_TYPE_TEXT')), array('key' => FieldDescription::FIELD_TYPE_MULTI, 'value' => $this->translate('FIELD_TYPE_MULTI')), array('key' => FieldDescription::FIELD_TYPE_SELECT, 'value' => $this->translate('FIELD_TYPE_SELECT')), array('key' => FieldDescription::FIELD_TYPE_DATE, 'value' => $this->translate('FIELD_TYPE_DATE')), array('key' => FieldDescription::FIELD_TYPE_DATETIME, 'value' => $this->translate('FIELD_TYPE_DATETIME')), array('key' => FieldDescription::FIELD_TYPE_FILE, 'value' => $this->translate('FIELD_TYPE_FILE')), array('key' => FieldDescription::FIELD_TYPE_INFO, 'value' => $this->translate('FIELD_TYPE_INFO'))), 'key', 'value');
     return $result;
 }
コード例 #4
0
ファイル: Calendar.php プロジェクト: energine-cmf/energine
 protected function createDataDescription()
 {
     $result = new DataDescription();
     for ($i = 0; $i < 7; $i++) {
         $fd = new FieldDescription('DOW_' . $i);
         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
         $result->addFieldDescription($fd);
     }
     return $result;
 }
コード例 #5
0
 protected function main()
 {
     $this->setBuilder(new FormBuilder());
     $dd = new DataDescription();
     $fd = new FieldDescription('email');
     $fd->setType(FieldDescription::FIELD_TYPE_EMAIL);
     $dd->addFieldDescription($fd);
     $this->setDataDescription($dd);
     $this->setData(new Data());
     $this->js = $this->buildJS();
     $this->addToolbar($this->loadToolbar());
 }
コード例 #6
0
ファイル: AdsManager.php プロジェクト: energine-cmf/energine
 /**
  * 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);
         }
     }
 }
コード例 #7
0
 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);
         }
     }
 }
コード例 #8
0
 /**
  * Create data description.
  *
  * @return DataDescription
  */
 protected function createDataDescription()
 {
     $result = new DataDescription();
     if (!$this->getConfig()->getCurrentStateConfig()) {
         $f = new FieldDescription('lang_id');
         $f->setType(FieldDescription::FIELD_TYPE_INT);
         $result->addFieldDescription($f);
         $f = new FieldDescription('lang_abbr');
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
         $result->addFieldDescription($f);
         $f = new FieldDescription('lang_name');
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
         $result->addFieldDescription($f);
         $f = new FieldDescription('lang_url');
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
         $result->addFieldDescription($f);
         $f = new FieldDescription('lang_real_abbr');
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
         $result->addFieldDescription($f);
     } else {
         $result->loadXML($this->getConfig()->getCurrentStateConfig()->fields);
     }
     return $result;
 }
コード例 #9
0
 /**
  * @copydoc DataSet::createDataDescription
  */
 protected function createDataDescription()
 {
     $result = new DataDescription();
     /*
      <field name="Id" type="integer" key="1"/>
      <field name="Pid" type="integer"/>
      <field name="Name" type="string"/>
      <field name="Segment" type="string"/>
      <field name="Redirect" type="string"/>
     */
     foreach (array('Id', 'Pid', 'Name', 'Segment', 'Redirect') as $fieldName) {
         $fd = new FieldDescription($fieldName);
         if (in_array($fieldName, array('Id', 'Pid'))) {
             $fd->setType(FieldDescription::FIELD_TYPE_INT);
         } else {
             $fd->setType(FieldDescription::FIELD_TYPE_STRING);
         }
         if ($fieldName == 'Id') {
             $fd->setProperty('key', 1);
         }
         $result->addFieldDescription($fd);
     }
     return $result;
 }
コード例 #10
0
ファイル: BreadCrumbs.php プロジェクト: energine-cmf/energine
 /**
  * Create data description.
  *
  * @return DataDescription
  *
  * @note Since it is impossible to change the list of fields, the required values will be forced to reset.
  */
 protected function createDataDescription()
 {
     $result = new DataDescription();
     $field = new FieldDescription('Id');
     $field->setType(FieldDescription::FIELD_TYPE_INT);
     $field->setProperty('key', true);
     $result->addFieldDescription($field);
     $field = new FieldDescription('Name');
     $field->setType(FieldDescription::FIELD_TYPE_STRING);
     $result->addFieldDescription($field);
     $field = new FieldDescription('Segment');
     $field->setType(FieldDescription::FIELD_TYPE_STRING);
     $result->addFieldDescription($field);
     $field = new FieldDescription('Title');
     $field->setType(FieldDescription::FIELD_TYPE_STRING);
     $result->addFieldDescription($field);
     return $result;
 }
コード例 #11
0
ファイル: Form.php プロジェクト: energine-cmf/energine
 /**
  * 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());
 }
コード例 #12
0
ファイル: FormResults.php プロジェクト: energine-cmf/energine
 /**
  * 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());
 }
コード例 #13
0
ファイル: DataSet.php プロジェクト: energine-cmf/energine
 /**
  * Player for embedding in text areas
  */
 protected function embedPlayer()
 {
     $sp = $this->getStateParams();
     list($uplId) = $sp;
     $fileInfo = $this->dbh->select('share_uploads', ['upl_path', 'upl_name', 'upl_title', 'upl_internal_type', 'upl_mime_type', 'upl_data'], ['upl_id' => intval($uplId), 'upl_internal_type' => \Energine\share\gears\FileRepoInfo::META_TYPE_VIDEO]);
     if (!$fileInfo) {
         throw new SystemException('ERROR_NO_VIDEO_FILE', SystemException::ERR_404);
     }
     // Using array_values to transform associative index to key index
     list($file, $name, $title, $type, $mime, $data) = array_values($fileInfo[0]);
     $dd = new DataDescription();
     foreach (['file' => FieldDescription::FIELD_TYPE_STRING, 'name' => FieldDescription::FIELD_TYPE_STRING, 'title' => FieldDescription::FIELD_TYPE_STRING, 'type' => FieldDescription::FIELD_TYPE_STRING, 'mime' => FieldDescription::FIELD_TYPE_STRING, 'data' => FieldDescription::FIELD_TYPE_TEXT] as $fName => $fType) {
         $fd = new FieldDescription($fName);
         $fd->setType($fType);
         $dd->addFieldDescription($fd);
     }
     $this->setBuilder(new SimpleBuilder());
     $this->setDataDescription($dd);
     $d = new Data();
     $d->load([compact('file', 'name', 'title', 'type', 'mime', 'data')]);
     $this->setData($d);
     $this->js = $this->buildJS();
     /**
      * If we want to use custom embed player we need to redefine embed_player.xslt in module transformers dir
      */
     $fn = 'embed_player.xslt';
     if (file_exists($file = sprintf(SITE_DIR . XSLTTransformer::MAIN_TRANSFORMER_DIR, E()->getSiteManager()->getCurrentSite()->folder) . $fn)) {
         E()->getController()->getTransformer()->setFileName($fn);
     } else {
         E()->getController()->getTransformer()->setFileName('core/modules/share/transformers/embed_player.xslt', true);
     }
 }
コード例 #14
0
 /**
  * Edit directory.
  * @param int $uplID Upload ID.
  */
 private function editDir($uplID)
 {
     $this->setFilter(['upl_id' => $uplID]);
     $this->setType(self::COMPONENT_TYPE_FORM_ALTER);
     $this->setBuilder($this->createBuilder());
     $dd = new DataDescription();
     $f = new FieldDescription('upl_id');
     $f->setProperty('tableName', $this->getTableName());
     $f->setType(FieldDescription::FIELD_TYPE_HIDDEN);
     $f->setProperty('key', true);
     $dd->addFieldDescription($f);
     $f = new FieldDescription('upl_pid');
     $f->setProperty('tableName', $this->getTableName());
     $f->setType(FieldDescription::FIELD_TYPE_HIDDEN);
     $dd->addFieldDescription($f);
     $f = new FieldDescription('upl_title');
     $f->setProperty('tableName', $this->getTableName());
     $f->setType(FieldDescription::FIELD_TYPE_STRING);
     $dd->addFieldDescription($f);
     $this->setDataDescription($dd);
     $this->setData($this->createData());
     $this->addToolbar($this->loadToolbar());
     $this->js = $this->buildJS();
     $this->setAction('save-dir/');
 }
コード例 #15
0
ファイル: Register.php プロジェクト: energine-cmf/energine
 /**
  * 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);
 }
コード例 #16
0
ファイル: Grid.php プロジェクト: energine-cmf/energine
 /**
  * Save data.
  * @return mixed
  * @throws SystemException 'ERR_NO_ACTION'
  * @throws SystemException 'ERR_VALIDATE_FORM'
  */
 protected function saveData()
 {
     $result = false;
     //если в POST не пустое значение значение первичного ключа - значит мы находимся в режиме редактирования
     if (isset($_POST[$this->getTableName()][$this->getPK()]) && !empty($_POST[$this->getTableName()][$this->getPK()])) {
         $mode = self::COMPONENT_TYPE_FORM_ALTER;
         $this->setFilter([$this->getPK() => $_POST[$this->getTableName()][$this->getPK()]]);
     } else {
         $mode = self::COMPONENT_TYPE_FORM_ADD;
     }
     //создаем объект описания данных
     $dataDescriptionObject = new DataDescription();
     if (!method_exists($this, $this->getPreviousState())) {
         throw new SystemException('ERR_NO_ACTION', SystemException::ERR_CRITICAL);
     }
     //получаем описание полей для метода
     $configDataDescription = $this->getConfig()->getStateConfig($this->getPreviousState());
     //если в конфиге есть описание полей для метода - загружаем их
     if (isset($configDataDescription->fields)) {
         $dataDescriptionObject->loadXML($configDataDescription->fields);
     }
     //Создаем объект описания данных взятых из БД
     $DBDataDescription = new DataDescription();
     //Загружаем в него инфу о колонках
     $DBDataDescription->load($this->loadDataDescription());
     $this->setDataDescription($dataDescriptionObject->intersect($DBDataDescription));
     //Поле с порядком следования убираем из списка
     /**
      * @todo  Надо бы это как то переделать, потому что разбросано получилось
      * часть кода относящаяся к обработке колонки с нумерацией здесь, часть
      * @see Grid::createDataDescription
      */
     if (($col = $this->getOrderColumn()) && ($field = $this->getDataDescription()->getFieldDescriptionByName($col))) {
         $this->getDataDescription()->removeFieldDescription($field);
     }
     $dataObject = new Data();
     $dataObject->load($this->loadData());
     $this->setData($dataObject);
     //Создаем сейвер
     $saver = $this->getSaver();
     //Устанавливаем его режим
     $saver->setMode($mode);
     $saver->setDataDescription($this->getDataDescription());
     $saver->setData($this->getData());
     if ($saver->validate() === true) {
         $saver->setFilter($this->getFilter());
         $saver->save();
         $result = $saver->getResult();
     } else {
         //выдвигается exception который перехватывается в методе save
         throw new SystemException('ERR_VALIDATE_FORM', SystemException::ERR_WARNING, $this->saver->getErrors());
     }
     //Если у нас режим вставки и определена колонка для порядка следования, изменяем порядок следования
     if (($orderColumn = $this->getOrderColumn()) && $mode == self::COMPONENT_TYPE_FORM_ADD) {
         $this->addFilterCondition([$this->getPK() . '!=' . $result]);
         $request = 'UPDATE ' . $this->getTableName() . ' SET ' . $orderColumn . '=' . $orderColumn . '+1 ' . $this->dbh->buildWhereCondition($this->getFilter());
         $this->dbh->modify($request);
     }
     return $result;
 }
コード例 #17
0
 /**
  * Build tab of rights.
  *
  * @param int $id Division ID.
  *
  * @note By creation of new division use parent ID.
  */
 private function buildRightsTab($id)
 {
     $builder = new Builder($this->getTitle());
     //получаем информацию о всех группах имеющихся в системе
     $groups = $this->dbh->select('user_groups', ['group_id', 'group_name']);
     $groups = convertDBResult($groups, 'group_id');
     //создаем матриц
     //название группы/перечень прав
     foreach (array_keys($groups) as $groupID) {
         $res[] = ['right_id' => 0, 'group_id' => $groupID];
     }
     $resultData = new Data();
     $resultData->load($res);
     $builder->setData($resultData);
     $rightsField = $resultData->getFieldByName('right_id');
     $groupsField = $resultData->getFieldByName('group_id');
     //создаем переменную содержащую идентификторы групп в которые входит пользователь
     $data = $this->dbh->select('share_access_level', ['group_id', 'right_id'], ['smap_id' => $id]);
     if ($data) {
         $data = convertDBResult($data, 'group_id', true);
         for ($i = 0; $i < $resultData->getRowCount(); $i++) {
             //если установлены права для группы  - изменяем в объекте данных
             if (isset($data[$groupsField->getRowData($i)])) {
                 $rightsField->setRowData($i, $data[$groupsField->getRowData($i)]['right_id']);
             }
             $groupsField->setRowProperty($i, 'group_id', $groupsField->getRowData($i));
         }
     }
     for ($i = 0; $i < $resultData->getRowCount(); $i++) {
         $groupsField->setRowProperty($i, 'group_id', $groupsField->getRowData($i));
         $groupsField->setRowData($i, $groups[$groupsField->getRowData($i)]['group_name']);
     }
     $resultDD = new DataDescription();
     $fd = new FieldDescription('group_id');
     $fd->setSystemType(FieldDescription::FIELD_TYPE_STRING);
     $fd->setMode(FieldDescription::FIELD_MODE_READ);
     $fd->setLength(30);
     $resultDD->addFieldDescription($fd);
     $fd = new FieldDescription('right_id');
     $fd->setSystemType(FieldDescription::FIELD_TYPE_SELECT);
     $data = $this->dbh->select('user_group_rights', ['right_id', 'right_const as right_name']);
     $data = array_map(function ($a) {
         $a["right_name"] = translate("TXT_" . $a["right_name"]);
         return $a;
     }, $data);
     $data[] = ['right_id' => 0, 'right_name' => $this->translate('TXT_NO_RIGHTS')];
     $fd->loadAvailableValues($data, 'right_id', 'right_name');
     $resultDD->addFieldDescription($fd);
     $builder->setDataDescription($resultDD);
     $builder->build();
     $field = new Field('page_rights');
     for ($i = 0; $i < count(E()->getLanguage()->getLanguages()); $i++) {
         $field->addRowData($builder->getResult());
     }
     $this->getData()->addField($field);
 }
コード例 #18
0
ファイル: Vote.php プロジェクト: energine-cmf/energine
 /**
  * @copydoc DataSet::prepare
  */
 protected function prepare()
 {
     $data = new Data();
     $dataDescription = new DataDescription();
     $dataDescription->load(['vote_question_id' => ['key' => true, 'nullable' => false, 'type' => FieldDescription::FIELD_TYPE_INT, 'length' => 10, 'index' => 'PRI'], 'vote_question_title' => ['key' => false, 'nullable' => false, 'type' => FieldDescription::FIELD_TYPE_STRING, 'length' => 255, 'index' => false]]);
     $this->setData($data);
     $this->setDataDescription($dataDescription);
     E()->getController()->getTransformer()->setFileName('../../../../core/modules/apps/transformers/single_vote.xslt');
     $this->setBuilder($this->createBuilder());
 }
コード例 #19
0
 /**
  * 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());
 }
コード例 #20
0
 protected function saveData()
 {
     $result = false;
     //если в POST не пустое значение значение первичного ключа - значит мы находимся в режиме редактирования
     if (isset($_POST[$this->getTableName()][$this->getPK()]) && !empty($_POST[$this->getTableName()][$this->getPK()])) {
         $mode = self::COMPONENT_TYPE_FORM_ALTER;
         $this->setFilter([$this->getPK() => $_POST[$this->getTableName()][$this->getPK()]]);
     } else {
         $mode = self::COMPONENT_TYPE_FORM_ADD;
     }
     //создаем объект описания данных
     $dataDescriptionObject = new DataDescription();
     if (!method_exists($this, $this->getPreviousState())) {
         throw new SystemException('ERR_NO_ACTION', SystemException::ERR_CRITICAL);
     }
     //получаем описание полей для метода
     $configDataDescription = $this->getConfig()->getStateConfig($this->getPreviousState());
     //если в конфиге есть описание полей для метода - загружаем их
     if (isset($configDataDescription->fields)) {
         $dataDescriptionObject->loadXML($configDataDescription->fields);
     }
     //Создаем объект описания данных взятых из БД
     $DBDataDescription = new DataDescription();
     //Загружаем в него инфу о колонках
     $DBDataDescription->load($this->loadDataDescription());
     $this->setDataDescription($dataDescriptionObject->intersect($DBDataDescription));
     //Поле с порядком следования убираем из списка
     if (($col = $this->getOrderColumn()) && ($field = $this->getDataDescription()->getFieldDescriptionByName($col))) {
         $this->getDataDescription()->removeFieldDescription($field);
     }
     $dataObject = new Data();
     $dataObject->load($this->loadData());
     $this->setData($dataObject);
     //Создаем сейвер
     $saver = $this->getSaver();
     //Устанавливаем его режим
     $saver->setMode($mode);
     $saver->setDataDescription($this->getDataDescription());
     $saver->setData($this->getData());
     if ($saver->validate() === true) {
         $saver->setFilter($this->getFilter());
         $saver->save();
         $result = $saver->getResult();
     } else {
         //выдвигается exception который перехватывается в методе save
         throw new SystemException('ERR_VALIDATE_FORM', SystemException::ERR_WARNING, $this->saver->getErrors());
     }
     //Если у нас режим вставки и определена колонка для порядка следования,
     // изменяем порядок следования
     if (($orderColumn = $this->getOrderColumn()) && $mode == self::COMPONENT_TYPE_FORM_ADD) {
         $linkedID = $this->getParam('linkedID');
         $pk = $this->getParam('pk');
         if ($linkedID) {
             $new_order_num = $this->dbh->getScalar('SELECT max(' . $orderColumn . ') as max_order_num
                 FROM ' . $this->getTableName() . ' WHERE `' . $pk . '` = %s', $linkedID);
         } else {
             $new_order_num = $this->dbh->getScalar('SELECT max(' . $orderColumn . ') as max_order_num
                 FROM ' . $this->getTableName() . ' WHERE `' . $pk . '` IS NULL AND session_id = %s ', session_id());
         }
         $new_order_num = !$new_order_num ? 1 : $new_order_num + 1;
         $this->addFilterCondition([$this->getPK() . '=' . $result]);
         $request = 'UPDATE ' . $this->getTableName() . ' SET ' . $orderColumn . ' = %s ' . $this->dbh->buildWhereCondition($this->getFilter());
         $this->dbh->modify($request, $new_order_num);
     }
     return $result;
 }
コード例 #21
0
 /**
  * Create new data description.
  *
  * @return DataDescription
  */
 public function createNewDataDescription()
 {
     $dataDescription = new DataDescription();
     $fd = new FieldDescription('comment_id');
     $fd->setType(FieldDescription::FIELD_TYPE_INT);
     $fd->setProperty('key', true);
     // для построения дерева
     $dataDescription->addFieldDescription($fd);
     // если у нас древовидная структура - добавляем предка
     if ($this->isTree) {
         $fd = new FieldDescription('comment_parent_id');
         $fd->setType(FieldDescription::FIELD_TYPE_INT);
         $dataDescription->addFieldDescription($fd);
     }
     // комментиркемая сущность
     $fd = new FieldDescription('target_id');
     $fd->setType(FieldDescription::FIELD_TYPE_INT);
     $dataDescription->addFieldDescription($fd);
     $fd = new FieldDescription('u_id');
     $fd->setType(FieldDescription::FIELD_TYPE_INT);
     $dataDescription->addFieldDescription($fd);
     $fd = new FieldDescription('comment_created');
     $fd->setType(FieldDescription::FIELD_TYPE_DATETIME);
     $dataDescription->addFieldDescription($fd);
     $fd = new FieldDescription('comment_name');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $dataDescription->addFieldDescription($fd);
     $fd = new FieldDescription('comment_approved');
     $fd->setType(FieldDescription::FIELD_TYPE_BOOL);
     $dataDescription->addFieldDescription($fd);
     // Инфа о юзере
     $fd = new FieldDescription('u_fullname');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $dataDescription->addFieldDescription($fd);
     return $dataDescription;
 }
コード例 #22
0
 /**
  * Generate Google Sitemap
  */
 protected function map()
 {
     E()->getController()->getTransformer()->setFileName($this->getParam('map.xslt'), true);
     $dd = new DataDescription();
     foreach (['Id' => FieldDescription::FIELD_TYPE_INT, 'Segment' => FieldDescription::FIELD_TYPE_STRING, 'LastMod' => FieldDescription::FIELD_TYPE_DATETIME] as $fieldName => $fieldType) {
         $fd = new FieldDescription($fieldName);
         if ($fieldName == 'Id') {
             $fd->setType($fieldType)->setProperty('key', 1);
         } else {
             $fd->setType($fieldType);
         }
         $dd->addFieldDescription($fd);
     }
     $dd->getFieldDescriptionByName('LastMod')->setProperty('outputFormat', '%Y-%m-%d');
     $this->setDataDescription($dd);
     $d = new Data();
     $this->setData($d);
     $sitemap = E()->getMap();
     $res = $sitemap->getInfo();
     foreach ($res as $id => $info) {
         if ($info['IsIndexed']) {
             $result[] = ['Id' => $id, 'Name' => $info['Name'], 'LastMod' => $info['LastMod'], 'Segment' => $sitemap->getURLByID($id)];
         }
     }
     $this->getData()->load($result);
     $this->setBuilder(new SimpleBuilder());
 }
コード例 #23
0
ファイル: RoleEditor.php プロジェクト: andykarpov/energine
 /**
  * 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();
 }
コード例 #24
0
ファイル: TextBlock.php プロジェクト: energine-cmf/energine
 /**
  * @copydoc DataSet::createDataDescription
  */
 protected function createDataDescription()
 {
     $dataDescr = new DataDescription();
     $fieldDescr = new FieldDescription($this->getName());
     $fieldDescr->setType(FieldDescription::FIELD_TYPE_HTML_BLOCK);
     $dataDescr->addFieldDescription($fieldDescr);
     return $dataDescr;
 }