public function edit()
 {
     parent::edit();
     $data = $this->getData();
     if ($promotion_id = $this->getParam('subscriptionID')) {
         $f = $data->getFieldByName('subscription_id');
         $f->setRowData(0, $promotion_id);
     }
 }
Esempio n. 2
0
 /**
  * @copydoc Grid::edit
  */
 protected function edit()
 {
     $tab = $this->getStateParams();
     if ($tab) {
         $tab = (int) array_pop($tab);
         $this->changeTableName($tab);
     }
     parent::edit();
     $this->getDataDescription()->getFieldDescriptionByName('comment_name')->setType(FieldDescription::FIELD_TYPE_TEXT);
     $this->getDataDescription()->getFieldDescriptionByName('u_id')->setMode(ACCESS_READ);
     $UID = $this->getData()->getFieldByName('u_id');
     $UID->setRowData(0, $this->dbh->getScalar('user_users', 'u_fullname', ['u_id' => $UID->getRowData(0)]));
 }
Esempio n. 3
0
 /**
  * @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());
     }
 }