protected function createDataDescription()
 {
     $result = parent::createDataDescription();
     if ($result->isEmpty()) {
         $result->load(['title' => ['type' => FieldDescription::FIELD_TYPE_STRING], 'message' => ['type' => FieldDescription::FIELD_TYPE_STRING], "hint" => ['type' => FieldDescription::FIELD_TYPE_TEXT]]);
     }
     return $result;
 }
Beispiel #2
0
 protected function buildJS()
 {
     if (!($result = parent::buildJS())) {
         $result = $this->doc->createElement('javascript');
         $behavior = $this->doc->createElement('behavior');
         $result->appendChild($behavior);
         $behavior->setAttribute('name', 'TOTP');
         $behavior->setAttribute('use', 'jquery');
     }
     return $result;
 }
Beispiel #3
0
 /**
  * @copydoc DataSet::main
  */
 protected function main()
 {
     parent::main();
     //Сначала проверили есть ли свой код баннера
     $result = $this->dbh->select(AdsManager::TABLE_NAME, true, array('smap_id' => $this->document->getID()), array('smap_id' => QAL::DESC), 1);
     //Если нет собственного  - ищем у родителей
     if (!is_array($result)) {
         $result = false;
         //Список идентфикаторов родителей в порядке увелечения уровня
         $IDs = array_reverse(array_keys(E()->getMap()->getParents($this->document->getID())));
         $tmp = $this->dbh->select(AdsManager::TABLE_NAME, true, array('smap_id' => $IDs));
         if (is_array($tmp)) {
             $tmp = convertDBResult($tmp, 'smap_id');
         }
         //перебираем записи родителей
         foreach ($IDs as $id) {
             //если есть родитель с рекламой
             if (isset($tmp[$id])) {
                 $result = array($tmp[$id]);
                 //дальше смотреть нет смысла
                 break;
             }
         }
     }
     if (is_array($result)) {
         //We don't need smap_id, so don't write it to Data
         unset($result[0]['smap_id']);
         foreach ($result[0] as $key => $value) {
             $fd = new FieldDescription($key);
             if (in_array($key, array('ad_id'))) {
                 $fd->setType(FieldDescription::FIELD_TYPE_INT);
             } else {
                 $fd->setType(FieldDescription::FIELD_TYPE_TEXT);
             }
             $this->getDataDescription()->addFieldDescription($fd);
         }
         $this->getData()->load($result);
     }
 }
Beispiel #4
0
 protected function defineParams()
 {
     return array_merge(parent::defineParams(), ['id' => false]);
 }
Beispiel #5
0
 protected function defineParams()
 {
     $result = array_merge(parent::defineParams(), ['tags' => '', 'recordsPerPage' => false, 'site' => false]);
     return $result;
 }
Beispiel #6
0
 /**
  * @copydoc DataSet::__construct
  */
 public function __construct($name, array $params = NULL)
 {
     parent::__construct($name, $params);
     $this->setType(self::COMPONENT_TYPE_LIST);
 }
Beispiel #7
0
 /**
  * @copydoc DataSet::__construct
  */
 public function __construct($name, array $params = null)
 {
     parent::__construct($name, $params);
     $this->setType(self::COMPONENT_TYPE_LIST);
     $this->setProperty('site', E()->getSiteManager()->getCurrentSite()->name);
 }
 protected function defineParams()
 {
     $result = array_merge(parent::defineParams(), array('active' => true));
     return $result;
 }
Beispiel #9
0
 /**
  * Save data.
  */
 public function save()
 {
     //Основные данные для сохранения
     $data = [];
     //Данные для сохранения в связанные таблицы или в mysql set
     //Начальное значение false, поскольку пустой массив будет говорить о том что поле существует. но ничего не выбрано
     $m2mData = false;
     $m2mFDs = $this->getDataDescription()->getFieldDescriptionsByType(FieldDescription::FIELD_TYPE_MULTI);
     if (!empty($m2mFDs)) {
         foreach ($m2mFDs as $fieldInfo) {
             if (is_null($fieldInfo->getPropertyValue('customField'))) {
                 //@todo На хера оно здесь?
                 //с 260 тот же самый код - пока не убираю но нужно разобраться
                 if (!in_array($fieldInfo->getSystemType(), [QAL::COLTYPE_ENUM, QAL::COLTYPE_SET])) {
                     //Определяем имя m2m таблицы
                     list($m2mTableName, $m2mPKName) = array_values($fieldInfo->getPropertyValue('key'));
                     //Определяем имя поля
                     $m2mInfo = $this->dbh->getColumnsInfo($m2mTableName);
                     unset($m2mInfo[$m2mPKName]);
                     $m2mData[$m2mTableName]['pk'] = $m2mPKName;
                 }
             }
         }
     }
     for ($i = 0; $i < $this->getData()->getRowCount(); $i++) {
         foreach ($this->getDataDescription() as $fieldName => $fieldInfo) {
             // исключаем поля, которым нет соответствия в БД
             if (is_null($fieldInfo->getPropertyValue('customField')) && $this->getData()->getFieldByName($fieldName)) {
                 $fieldValue = $this->getData()->getFieldByName($fieldName)->getRowData($i);
                 if ($fieldInfo->getType() == FieldDescription::FIELD_TYPE_HTML_BLOCK) {
                     $fieldValue = DataSet::cleanupHTML($fieldValue);
                 }
                 // сохраняем поля из основной таблицы
                 if ($fieldInfo->isMultilanguage() == false && $fieldInfo->getPropertyValue('key') !== true && $fieldInfo->getPropertyValue('languageID') == false) {
                     switch ($fieldInfo->getType()) {
                         case FieldDescription::FIELD_TYPE_FLOAT:
                             $fieldValue = str_replace(',', '.', $fieldValue);
                             break;
                         case FieldDescription::FIELD_TYPE_MULTI:
                             /**
                              * @todo необходимо оптимизировать алгоритм, а то произошло дублирование кода
                              *
                              */
                             //many 2 many relations stored in tables
                             if (!in_array($fieldInfo->getSystemType(), [QAL::COLTYPE_ENUM, QAL::COLTYPE_SET])) {
                                 $m2mValues = $fieldValue;
                                 //Поскольку мультиполе реально фейковое
                                 //записываем в него NULL
                                 $fieldValue = '';
                                 //Определяем имя m2m таблицы
                                 list($m2mTableName, $m2mPKName) = array_values($fieldInfo->getPropertyValue('key'));
                                 //Определяем имя поля
                                 $m2mInfo = $this->dbh->getColumnsInfo($m2mTableName);
                                 unset($m2mInfo[$m2mPKName]);
                                 foreach ($m2mValues as $val) {
                                     $m2mData[$m2mTableName]['pk'] = $m2mPKName;
                                     $m2mData[$m2mTableName][key($m2mInfo)][] = $val;
                                 }
                                 unset($m2mValues, $m2mPKName, $m2mInfo, $m2mTableName);
                             } else {
                                 $fieldValue = implode(',', $fieldValue);
                             }
                             break;
                     }
                     $data[$fieldInfo->getPropertyValue('tableName')][$fieldName] = $fieldValue;
                 } elseif ($fieldInfo->isMultilanguage() || $fieldInfo->getPropertyValue('languageID')) {
                     $data[$fieldInfo->getPropertyValue('tableName')][$this->data->getFieldByName('lang_id')->getRowData($i)][$fieldName] = $fieldValue;
                 } elseif ($fieldInfo->getPropertyValue('key') === true) {
                     $pkName = $fieldName;
                     // имя первичного ключа
                     $mainTableName = $fieldInfo->getPropertyValue('tableName');
                     // имя основной таблицы
                 }
             }
         }
     }
     if ($this->getMode() == QAL::INSERT) {
         $data[$mainTableName] = !isset($data[$mainTableName]) ? [] : $data[$mainTableName];
         $id = $this->dbh->modify(QAL::INSERT, $mainTableName, $data[$mainTableName]);
         unset($data[$mainTableName]);
         foreach ($data as $tableName => $langRow) {
             foreach ($langRow as $row) {
                 $row[$pkName] = $id;
                 /*$result = */
                 $this->dbh->modify(QAL::INSERT, $tableName, $row);
             }
         }
         $result = $id;
     } else {
         if (isset($data[$mainTableName])) {
             /*$result = */
             $this->dbh->modify(QAL::UPDATE, $mainTableName, $data[$mainTableName], $this->getFilter());
             unset($data[$mainTableName]);
         }
         foreach ($data as $tableName => $langRow) {
             foreach ($langRow as $langID => $row) {
                 try {
                     /*$result = */
                     $this->dbh->modify(QAL::INSERT, $tableName, array_merge($row, $this->getFilter()));
                 } catch (\Exception $e) {
                     /*$result = */
                     $this->dbh->modify(QAL::UPDATE, $tableName, $row, array_merge($this->getFilter(), ['lang_id' => $langID]));
                 }
             }
         }
         if ($pkName) {
             $result = $this->getData()->getFieldByName($pkName)->getRowData(0);
         } else {
             $result = true;
         }
     }
     if (is_array($m2mData) && is_numeric($result)) {
         foreach ($m2mData as $tableName => $m2mInfo) {
             $this->dbh->modify(QAL::DELETE, $tableName, NULL, [$m2mInfo['pk'] => $result]);
         }
         foreach ($m2mData as $tableName => $m2mInfo) {
             $pk = $m2mInfo['pk'];
             unset($m2mInfo['pk']);
             if ($m2mInfo) {
                 foreach (current($m2mInfo) as $fieldValue) {
                     $this->dbh->modify(QAL::INSERT_IGNORE, $tableName, [key($m2mInfo) => $fieldValue, $pk => $result]);
                 }
             }
         }
     }
     return $this->result = $result;
 }
 protected function defineParams()
 {
     $result = array_merge(parent::defineParams(), array('tags' => ''));
     return $result;
 }
Beispiel #11
0
 /**
  * Save text.
  */
 protected function saveText()
 {
     $result = '';
     if ($this->getParam('editable') && isset($_POST['ID']) && isset($_POST['num']) && isset($_POST['data'])) {
         $result = DataSet::cleanupHTML($_POST['data']);
         $langID = E()->getLanguage()->getCurrent();
         $entityId = (int) $_POST['ID'];
         $field = $_POST['num'];
         $this->dbh->modify(gears\QAL::UPDATE, $this->getTranslationTableName(), [$field => $result], ['lang_id' => $langID, $this->getPK() => $entityId]);
     }
     $this->response->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $this->response->write($result);
     $this->response->commit();
 }
Beispiel #12
0
 /**
  * @copydoc DataSet::__construct
  */
 public function __construct($name, array $params = null)
 {
     parent::__construct($name, $params);
     $this->setProperty('exttype', 'calendar');
 }
Beispiel #13
0
 protected function defineParams()
 {
     $result = array_merge(parent::defineParams(), ['limit' => 5, 'bind' => '']);
     return $result;
 }
Beispiel #14
0
 protected function main()
 {
     parent::main();
     if ($this->getParam('bind')) {
         $this->bindComponent = $this->document->componentManager->getBlockByName($this->getParam('bind'));
         if (!$this->isTree and $this->pager) {
             $ap = $this->bindComponent->getStateParams(true);
             $subUrl = '';
             if (isset($ap['themeID'])) {
                 $subUrl = $ap['themeID'] . '/';
             }
             $this->pager->setProperty('additional_url', $subUrl);
         }
     }
 }
Beispiel #15
0
 /**
  * @copydoc DataSet::__construct
  */
 public function __construct($name, array $params = null)
 {
     $params['active'] = true;
     parent::__construct($name, $params);
     $this->setProperty('recordsPerPage', false);
 }
Beispiel #16
0
 /**
  * @copydoc DataSet::loadData
  */
 protected function loadData()
 {
     $result = false;
     switch ($this->getState()) {
         case 'showLogoutForm':
             foreach ($this->getDataDescription()->getFieldDescriptionList() as $fieldName) {
                 $result[] = array($fieldName => $this->document->user->getValue($fieldName));
             }
             break;
         default:
             $result = parent::loadData();
     }
     return $result;
 }
Beispiel #17
0
 protected function main()
 {
     E()->getController()->getTransformer()->setFileName('../core/modules/seo/transformers/robots_txt.xslt', true);
     parent::main();
     $this->setBuilder(new SimpleBuilder());
 }
Beispiel #18
0
 /**
  * @copydoc DataSet::build
  */
 public function build()
 {
     $result = '';
     switch ($this->getState()) {
         case 'ban':
             $result = $this->userEditor->build();
             break;
         case 'banip':
             $result = $this->banIPEditor->build();
             break;
         default:
             $result = parent::build();
             break;
     }
     return $result;
 }
Beispiel #19
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();
     }
 }
 protected function defineParams()
 {
     return array_merge(parent::defineParams(), ['active' => true]);
 }
Beispiel #21
0
 /**
  * Save data.
  */
 protected function save()
 {
     $this->dbh->beginTransaction();
     try {
         if (!isset($_POST['data']) && !isset($_POST['num'])) {
             throw new SystemException('ERR_DEV_NO_DATA', SystemException::ERR_DEVELOPER);
         }
         $langID = $this->document->getLang();
         $docID = isset($_POST['ID']) ? $_POST['ID'] : '';
         //пытаемся определить есть ли у нас запись о содержимом блока в основной таблице
         $tbID = $this->getTextBlockID($docID, $_POST['num']);
         $result = DataSet::cleanupHTML($_POST['data']);
         //$result = $_POST['data'];
         if (trim($result)) {
             if (!$tbID) {
                 $tbID = $this->dbh->modify(QAL::INSERT, $this->tableName, array('smap_id' => $docID, 'tb_num' => $_POST['num']));
             }
             $tableName = $this->tableName . '_translation';
             $res = $this->dbh->select($tableName, array('tb_id'), array('tb_id' => $tbID, 'lang_id' => $langID));
             //если есть запись в таблице переводов - апдейтим
             if (!empty($res)) {
                 $this->dbh->modify(QAL::UPDATE, $tableName, array('tb_content' => $result), array('tb_id' => $tbID, 'lang_id' => $langID));
             } else {
                 //если нет - вставляем
                 $this->dbh->modify(QAL::INSERT, $tableName, array('tb_content' => $result, 'tb_id' => $tbID, 'lang_id' => $langID));
             }
         } elseif ($tbID) {
             $this->dbh->modify(QAL::DELETE, $this->tableName, null, array('tb_id' => $tbID));
         }
         $this->dbh->commit();
     } catch (\Exception $e) {
         $this->dbh->rollback();
         $result = $e->getMessage();
     }
     $this->response->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $this->response->write($result);
     $this->response->commit();
 }