Beispiel #1
0
 /**
  * Show login form.
  */
 public function showLoginForm()
 {
     $this->prepare();
     if (isset($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME])) {
         $messageField = new FieldDescription('message');
         $messageField->setType(FieldDescription::FIELD_TYPE_STRING);
         $this->getDataDescription()->addFieldDescription($messageField);
         $messageField->setRights(FieldDescription::FIELD_MODE_READ);
         $messageField = new Field('message');
         $messageField->addRowData($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME]);
         $this->getData()->addField($messageField);
         E()->getResponse()->deleteCookie(UserSession::FAILED_LOGIN_COOKIE_NAME);
     }
     //Во избежание появления empty рекордсета
     $this->getData()->addField((new Field('username'))->setRowData(0, ''));
     //Если есть информация о авторизации через фейсбук
     foreach (array('auth.facebook', 'auth.vk') as $configSectionName) {
         if ($this->getToolbar()) {
             list($tbr) = array_values($this->getToolbar());
             if ($ctrl = $tbr->getControlByID($configSectionName)) {
                 $ctrl->disable();
             }
             if ($ctrl && $this->getConfigValue($configSectionName)) {
                 if ($appID = $this->getConfigValue($configSectionName . '.appID')) {
                     $ctrl->setAttribute('appID', $appID);
                     $ctrl->enable();
                 }
             }
         }
     }
 }
Beispiel #2
0
 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();
 }
Beispiel #3
0
 /**
  * @copydoc DataSet::createDataDescription
  */
 protected function createDataDescription()
 {
     $dd = new DataDescription();
     $fd = new FieldDescription('entry');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $dd->addFieldDescription($fd);
     return $dd;
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
 protected function createDataDescrition()
 {
     $result = parent::createDataDescription();
     if (in_array($this->getType(), [self::COMPONENT_TYPE_LIST])) {
         $f = new FieldDescription('u_real_name');
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
         $result->addFieldDescription($f);
         $result->getFieldDescriptionByName('u_name')->setType(FieldDescription::FIELD_TYPE_HIDDEN);
     }
     return $result;
 }
Beispiel #6
0
 protected function createDataDescription()
 {
     $result = parent::createDataDescription();
     if (in_array($this->getState(), ['add', 'edit'])) {
         $fd = new FieldDescription('news_is_top');
         $fd->setType(FieldDescription::FIELD_TYPE_BOOL);
         $fd->setProperty('tag', 'top');
         $result->addFieldDescription($fd, DataDescription::FIELD_POSITION_AFTER, $this->getPK());
     }
     return $result;
 }
 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());
 }
Beispiel #8
0
 protected function prepare()
 {
     parent::prepare();
     if (in_array($this->getState(), array('add', 'edit'))) {
         $fd = new FieldDescription('questions');
         $fd->setType(FieldDescription::FIELD_TYPE_TAB);
         $fd->setProperty('title', $this->translate('TAB_VOTE_QUESTIONS'));
         $this->getDataDescription()->addFieldDescription($fd);
         $field = new Field('questions');
         $state = $this->getState();
         $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/question/';
         $field->setData($tab_url, true);
         $this->getData()->addField($field);
     }
 }
Beispiel #9
0
 /**
  * @copydoc DBDataSet::createDataDescription
  */
 protected function createDataDescription()
 {
     $res = DBDataSet::createDataDescription();
     if (!$res->getFieldDescriptionByName('smap_id')) {
         $f = new FieldDescription('smap_id');
         $f->setType(FieldDescription::FIELD_TYPE_INT)->setProperty('tableName', $this->getTableName());
         $res->addFieldDescription($f);
     }
     if (!$res->getFieldDescriptionByName('category')) {
         $f = new FieldDescription('category');
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
         $res->addFieldDescription($f);
     }
     return $res;
 }
Beispiel #10
0
 /**
  * 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;
 }
Beispiel #11
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'));
 }
 protected function prepare()
 {
     parent::prepare();
     // data description для информера
     if (in_array($this->getState(), ['main'])) {
         $data = $this->getData();
         $dd = $this->getDataDescription();
         if ($data) {
             $fd = new FieldDescription('is_subscribed');
             $fd->setType(FieldDescription::FIELD_TYPE_BOOL);
             $dd->addFieldDescription($fd);
             $f = new Field('is_subscribed');
             $data->addField($f);
             $f_subscription_id = $data->getFieldByName('subscription_id');
             $subscribed = $this->dbh->getColumn('mail_subscriptions2users', 'subscription_id', array('u_id' => $this->document->getUser()->getID()));
             foreach ($f_subscription_id as $i => $row) {
                 $f->setRowData($i, in_array($row, $subscribed) ? '1' : '0');
             }
         }
     }
 }
 /**
  * Build for for editing component parameters.
  * The form creation is based on XML widget's data received per POST request.
  *
  * @throws SystemException 'ERR_INSUFFICIENT_DATA'
  * @throws SystemException 'ERR_BAD_XML_DESCR'
  */
 protected function buildParamsForm()
 {
     if (!isset($_POST['modalBoxData'])) {
         throw new SystemException('ERR_INSUFFICIENT_DATA');
     }
     if (!($widgetXML = simplexml_load_string($_POST['modalBoxData']))) {
         throw new SystemException('ERR_BAD_XML_DESCR');
     }
     list($componentName) = $this->getStateParams();
     $component = ComponentManager::findBlockByName($widgetXML, $componentName);
     $dd = new DataDescription();
     $d = new Data();
     $this->setType(self::COMPONENT_TYPE_FORM_ALTER);
     $this->setDataDescription($dd);
     $this->setData($d);
     $this->setBuilder(new Builder());
     $this->js = $this->buildJS();
     foreach ($component->params->children() as $param) {
         $paramName = (string) $param['name'];
         $paramType = isset($param['type']) ? (string) $param['type'] : FieldDescription::FIELD_TYPE_STRING;
         $fd = new FieldDescription($paramName);
         if (isset($param['nullable'])) {
             $fd->setProperty('nullable', true);
         }
         $fd->setType($paramType)->setProperty('tabName', E()->Utils->translate('TAB_PARAMS'));
         if ($paramType == FieldDescription::FIELD_TYPE_SELECT && isset($param['values'])) {
             $availableValues = array();
             foreach (explode('|', (string) $param['values']) as $value) {
                 array_push($availableValues, array('key' => $value, 'value' => $value));
             }
             $fd->loadAvailableValues($availableValues, 'key', 'value');
         }
         $dd->addFieldDescription($fd);
         $f = new Field($paramName);
         $f->setRowData(0, $param);
         $d->addField($f);
     }
     $this->addToolbar($this->loadToolbar());
 }
Beispiel #14
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);
     }
 }
 /**
  * @copydoc LoginForm::showLoginForm
  */
 public function showLoginForm()
 {
     $this->prepare();
     if (isset($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME])) {
         $messageField = new FieldDescription('message');
         $messageField->setType(FieldDescription::FIELD_TYPE_STRING);
         $this->getDataDescription()->addFieldDescription($messageField);
         $messageField->setRights(FieldDescription::FIELD_MODE_READ);
         $messageField = new Field('message');
         $messageField->addRowData($_COOKIE[UserSession::FAILED_LOGIN_COOKIE_NAME]);
         $this->getData()->addField($messageField);
         E()->getResponse()->deleteCookie(UserSession::FAILED_LOGIN_COOKIE_NAME);
     }
     //Во избежание появления empty рекордсета
     $f = new Field('username');
     $f->setData('');
     $this->getData()->addField($f);
     //Если есть информация о авторизации через соц. сети
     foreach (['fb', 'vk', 'ok', 'goo'] as $socialType) {
         foreach (array_values($this->getToolbar()) as $tbr) {
             if ($ctrl = $tbr->getControlByID('auth.' . $socialType)) {
                 $ctrl->disable();
             }
             if ($ctrl && $this->getConfigValue('auth.' . $socialType)) {
                 if (($appID = $this->getConfigValue('auth.' . $socialType . '.appID')) && ($secretKey = $this->getConfigValue('auth.' . $socialType . '.appID'))) {
                     $authClassName = 'Energine\\user\\gears\\' . strtoupper($socialType) . 'OAuth';
                     /**
                      * @var $auth IOAuth
                      */
                     $auth = new $authClassName(['appId' => $appID, 'secret' => $secretKey, 'public' => $this->getConfigValue('auth.' . $socialType . '.publicKey')]);
                     $ctrl->setAttribute('loginUrl', $auth->getLoginUrl(['redirect_uri' => ($base = E()->getSiteManager()->getCurrentSite()->base) . 'auth.php?' . $socialType . 'Auth&return=' . $this->getReturnUrl(), 'scope' => $ctrl->getAttribute('permissions')]));
                     $ctrl->setAttribute('appID', $appID);
                     $ctrl->enable();
                 }
             }
         }
     }
 }
 protected function prepare()
 {
     parent::prepare();
     if (in_array($this->getState(), ['add', 'edit'])) {
         $fd = new FieldDescription('users');
         $fd->setType(FieldDescription::FIELD_TYPE_TAB);
         $fd->setProperty('title', $this->translate('TAB_SUBSCRIBED_USERS'));
         $this->getDataDescription()->addFieldDescription($fd);
         $field = new Field('users');
         $state = $this->getState();
         $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/users/';
         $field->setData($tab_url, true);
         $this->getData()->addField($field);
         $fd = new FieldDescription('emails');
         $fd->setType(FieldDescription::FIELD_TYPE_TAB);
         $fd->setProperty('title', $this->translate('TAB_SUBSCRIBED_EMAILS'));
         $this->getDataDescription()->addFieldDescription($fd);
         $field = new Field('emails');
         $state = $this->getState();
         $tab_url = ($state != 'add' ? $this->getData()->getFieldByName($this->getPK())->getRowData(0) : '') . '/email/';
         $field->setData($tab_url, true);
         $this->getData()->addField($field);
     }
 }
 /**
  * @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;
 }
Beispiel #18
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;
 }
 /**
  * Change order.
  *
  * @param string $direction Order direction.
  * @param int $fieldIndex Field index.
  */
 public function changeOrder($direction, $fieldIndex)
 {
     $fieldIndex--;
     $cols = array_keys($colsInfo = $this->dbh->getColumnsInfo($this->tableName));
     $srcField = $cols[$fieldIndex];
     $destFieldIndex = $fieldIndex + ($direction == Grid::DIR_UP ? -2 : 1);
     if ($destFieldIndex <= 0 || $destFieldIndex == sizeof($cols)) {
         return;
     }
     $destColField = $cols[$destFieldIndex];
     $query = 'ALTER TABLE ' . $this->tableName . ' MODIFY ' . $srcField . ' ' . self::getFDAsSQLString(FieldDescription::convertType($colsInfo[$srcField]['type'], $srcField, $colsInfo[$srcField]['length'], $colsInfo[$srcField])) . (!$colsInfo[$srcField]['nullable'] ? ' NOT NULL ' : '') . ' AFTER ' . $destColField;
     $this->dbh->modify($query);
 }
Beispiel #20
0
 /**
  * Build result as JSON.
  *
  * @param array $comment Comment.
  * @return IBuilder
  */
 protected function buildResult($comment)
 {
     $builder = new CommentsJSONBuilder();
     $dataDescription = new DataDescription();
     $this->setDataDescription($dataDescription);
     $localData = new Data();
     $this->setData($localData);
     $localData->load($comment);
     $fd = new FieldDescription('comment_id');
     $fd->setType(FieldDescription::FIELD_TYPE_INT);
     $dataDescription->addFieldDescription($fd);
     if ($this->isTree) {
         $fd = new FieldDescription('is_tree');
         $fd->setType(FieldDescription::FIELD_TYPE_BOOL);
         $dataDescription->addFieldDescription($fd);
         if (isset($comment[0]['comment_parent_id'])) {
             $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('comment_name');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $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);
     $fd->setProperty('outputFormat', '%E');
     $dataDescription->addFieldDescription($fd);
     $fd = new FieldDescription('comment_approved');
     $fd->setType(FieldDescription::FIELD_TYPE_BOOL);
     $dataDescription->addFieldDescription($fd);
     $builder->setData($localData);
     $builder->setDataDescription($dataDescription);
     //добавляем поля о прокоментировавшем
     $fd = new FieldDescription('u_fullname');
     $fd->setType(FieldDescription::FIELD_TYPE_STRING);
     $dataDescription->addFieldDescription($fd);
     return $builder;
 }
 protected function createDataDescription()
 {
     $dd = parent::createDataDescription();
     $fd = $dd->getFieldDescriptionByName($this->getParam('pk'));
     $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN);
     $fd = $dd->getFieldDescriptionByName('session_id');
     $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN);
     if ($this->getState() == 'getRawData' || $this->getState() == 'main') {
         $fd = $dd->getFieldDescriptionByName('upl_id');
         $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN);
         $field = new FieldDescription('upl_path');
         $field->setType(FieldDescription::FIELD_TYPE_FILE);
         $field->setProperty('title', 'FIELD_IMG_FILENAME_IMG');
         $field->setProperty('customField', true);
         $dd->addFieldDescription($field);
         $field = new FieldDescription('upl_name');
         $field->setType(FieldDescription::FIELD_TYPE_CUSTOM);
         $field->setProperty('title', 'FIELD_IMG_FILENAME');
         $field->setProperty('customField', true);
         $dd->addFieldDescription($field);
     }
     return $dd;
 }
Beispiel #22
0
 /**
  * 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);
 }
 /**
  * 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;
 }
 /**
  * Create tab for thumbs.
  */
 private function createThumbFields()
 {
     if ($thumbs = $this->getConfigValue('thumbnails')) {
         foreach ($thumbs as $name => $data) {
             $fd = new FieldDescription($name);
             $fd->setType(FieldDescription::FIELD_TYPE_THUMB);
             $this->getDataDescription()->addFieldDescription($fd);
             $fd->setProperty('tabName', E()->Utils->translate('TXT_THUMBS'));
             $fd->setProperty('tableName', 'thumbs');
             foreach ($data as $attrName => $attrValue) {
                 $fd->setProperty($attrName, $attrValue);
             }
         }
     }
 }
Beispiel #25
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 #26
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());
 }
Beispiel #27
0
 /**
  * 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();
 }
Beispiel #28
0
 /**
  * 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());
 }
Beispiel #29
0
 /**
  * Get vote result.
  * @param int|string $voteID Vote ID.
  */
 private function getVoteResults($voteID)
 {
     $this->setProperty('count', $counter = $this->dbh->getScalar('apps_vote_question', 'SUM(vote_question_counter)', ['vote_id' => $voteID]));
     $this->prepare();
     $data = $this->dbh->select('SELECT vote_question_id, vote_question_title, ROUND(100*vote_question_counter/%s) as percent FROM `apps_vote_question` LEFT JOIN apps_vote_question_translation USING(vote_question_id) WHERE lang_id=%s AND vote_id= %s ORDER BY vote_question_order_num', $counter, $this->document->getLang(), $voteID);
     if ($data && is_array($data)) {
         $this->getData()->load($data);
     }
     $this->setProperty('question', $this->dbh->getScalar('apps_vote_translation', 'vote_name', ['vote_id' => $voteID, 'lang_id' => $this->document->getLang()]));
     $this->setProperty('date', E()->Utils->formatDate($this->dbh->getScalar('apps_vote', 'vote_date', ['vote_id' => $voteID]), '%E'));
     $fd = new FieldDescription('percent');
     $fd->setType(FieldDescription::FIELD_TYPE_INT);
     $this->getDataDescription()->addFieldDescription($fd);
 }
 protected function main()
 {
     parent::main();
     if ($f = $this->getDataDescription()->getFieldDescriptionByName('u_id')) {
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
     }
     if ($f = $this->getDataDescription()->getFieldDescriptionByName('target_id')) {
         $f->setType(FieldDescription::FIELD_TYPE_STRING);
     }
     foreach ($this->commentTables as $i => $table) {
         //пропускаем текущую таблицу - для неё уже создана нулевая вкладка
         // посути $this->currTabIndex может быть равен только нулю
         if ($i == $this->currTabIndex) {
             continue;
         }
         $fd = new FieldDescription($table . '_edit');
         $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN);
         $fd->setProperty('tabName', 'TAB_' . $table);
         $this->getDataDescription()->addFieldDescription($fd);
     }
 }