コード例 #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
ファイル: 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;
 }
コード例 #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 mainState()
 {
     $dd = new DataDescription();
     $fd = new FieldDescription('id');
     $fd->setProperty('key', true);
     $fd->setType(FieldDescription::FIELD_TYPE_INT);
     $dd->addFieldDescription($fd);
     $fd = new FieldDescription('name');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $dd->addFieldDescription($fd);
     $fd = new FieldDescription('data');
     $fd->setType(FieldDescription::FIELD_TYPE_CUSTOM);
     $dd->addFieldDescription($fd);
     $d = new Data();
     $d->load($this->dbh->select('SELECT t.tg_id as id, tg_name as `name`, t.tg_id as data FROM apps_top_groups t LEFT JOIN apps_top_groups_translation tt ON (tt.tg_id = t.tg_id) AND (lang_id=%s) WHERE site_id = %s ORDER by tg_order_num', $this->document->getLang(), E()->getSiteManager()->getCurrentSite()->id));
     $this->setData($d);
     $this->setDataDescription($dd);
     $this->js = $this->buildJS();
     $this->buildGroups($this->getData()->getFieldByName('data'));
 }
コード例 #6
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());
 }
コード例 #7
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;
 }
コード例 #8
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;
 }
コード例 #9
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());
 }
コード例 #10
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());
 }
コード例 #11
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());
 }
コード例 #12
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);
     }
 }
コード例 #13
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);
 }
コード例 #14
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);
 }
コード例 #15
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();
 }
コード例 #16
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());
 }
コード例 #17
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/');
 }
コード例 #18
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;
 }
コード例 #19
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;
 }