/**
  * @copydoc FeedEditor::edit
  */
 protected function edit()
 {
     parent::edit();
     $tm = new TagManager($this->getDataDescription(), $this->getData(), $this->getTableName());
     $tm->createFieldDescription();
     $tm->createField();
 }
Beispiel #2
0
 protected function main()
 {
     parent::main();
     if ($this->getDataDescription()->isEmpty()) {
         $this->getDataDescription()->loadXML(new \SimpleXMLElement('<fields>
                         <field name="Id" type="integer" key="1"/>
                         <field name="Pid" type="integer"/>
                         <field name="Name" type="string"/>
                         <field name="Segment" type="string"/>
                         <field name="DescriptionRtf" type="string"/>
                     </fields>'));
     }
     if (!$this->getData()->isEmpty()) {
         foreach (['Site', 'Redirect'] as $fieldName) {
             $FD = new FieldDescription($fieldName);
             $FD->setType(FieldDescription::FIELD_TYPE_STRING);
             $this->getDataDescription()->addFieldDescription($FD);
         }
     }
     if ($this->getDataDescription()->getFieldDescriptionByName('attachments')) {
         $am = new AttachmentManager($this->getDataDescription(), $this->getData(), 'share_sitemap');
         $am->createFieldDescription();
         if ($f = $this->getData()->getFieldByName('Id')) {
             $am->createField('smap_id', !$this->getParam('allAttachments'), $f->getData());
         }
     }
     if ($this->getDataDescription()->getFieldDescriptionByName('tags')) {
         $m = new TagManager($this->getDataDescription(), $this->getData(), 'share_sitemap');
         $m->createFieldDescription();
         $m->createField();
     }
 }
Beispiel #3
0
 /**
  * @copydoc Feed::main
  */
 protected function main()
 {
     parent::main();
     $m = new AttachmentManager($this->getDataDescription(), $this->getData(), $this->getTableName());
     $m->createFieldDescription();
     $m->createField($this->getPK(), true);
     $m = new TagManager($this->getDataDescription(), $this->getData(), $this->getTableName());
     $m->createFieldDescription();
     $m->createField();
 }
Beispiel #4
0
 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();
         }
     }
 }
Beispiel #5
0
 /**
  * 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());
     }
 }