Example #1
0
 protected function view()
 {
     parent::view();
     $this->getDataDescription()->getFieldDescriptionByName('al_date')->setProperty('outputFormat', '%E');
     $this->getDataDescription()->getFieldDescriptionByName('al_data')->setType(FieldDescription::FIELD_TYPE_CODE);
     $this->getDataDescription()->getFieldDescriptionByName('al_classname')->setProperty('outputFormat', 'translate(%s)');
     $this->getData()->getFieldByName('al_data')->setRowData(0, var_export(unserialize($this->getData()->getFieldByName('al_data')->getRowData(0)), true));
 }
    protected function saveData()
    {
        $subscriptionID = parent::saveData();
        $this->dbh->modify('UPDATE mail_subscriptions2users
			SET session_id = NULL, subscription_id=%s
			WHERE (subscription_id IS NULL and session_id = %s) or (subscription_id = %1$s)', $subscriptionID, session_id());
        return $subscriptionID;
    }
Example #3
0
 /**
  * @copydoc Grid::getRawData
  */
 protected function getRawData()
 {
     $params = $this->getStateParams(true);
     if (!empty($params['tag_id'])) {
         $tag_ids = explode(TagManager::TAG_SEPARATOR, urldecode($params['tag_id']));
         if ($tag_ids) {
             $this->addFilterCondition(array(TagManager::TAG_TABLENAME . '.tag_id' => $tag_ids));
         }
     }
     parent::getRawData();
 }
 protected function createDataDescription()
 {
     $result = parent::createDataDescription();
     if (in_array($this->getState(), array('add', 'edit'))) {
         $fd = $result->getFieldDescriptionByName('subscription_id');
         $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN);
         $fd = $result->getFieldDescriptionByName('session_id');
         $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN);
     }
     return $result;
 }
Example #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;
 }
Example #6
0
 protected function createDataDescription()
 {
     $result = parent::createDataDescription();
     $extraFields = [];
     foreach ($result as $name => $fd) {
         if (!($name == $this->getPK() || $name == 'lang_id' || $name == str_replace('_id', '_name', $this->getPK()))) {
             array_push($extraFields, $fd);
         }
     }
     foreach ($extraFields as $fd) {
         $result->removeFieldDescription($fd);
     }
     return $result;
 }
 /**
  * @copydoc Grid::saveData
  */
 protected function saveData()
 {
     //обрезаем лишние незначащие пробелы и прочее в самих тегах и в переводах
     //в переводах - сделано на случай вывода в джаваскрипт
     $_POST[$this->getTableName()]['ltag_name'] = strtoupper(trim($_POST[$this->getTableName()]['ltag_name']));
     foreach (array_keys(E()->getLanguage()->getLanguages()) as $langID) {
         if (isset($_POST[$this->getTranslationTableName()][$langID]['ltag_value_rtf'])) {
             $_POST[$this->getTranslationTableName()][$langID]['ltag_value_rtf'] = trim($_POST[$this->getTranslationTableName()][$langID]['ltag_value_rtf']);
         }
     }
     $result = parent::saveData();
     $c = E()->getCache();
     if ($c->isEnabled()) {
         $c->dispose(Cache::TRANSLATIONS_KEY);
     }
     return $result;
 }
 protected function saveData()
 {
     $subscribersTable = 'mail_email_subscribers';
     if (!isset($_POST[$subscribersTable]['me_name']) || !$_POST[$subscribersTable]['me_name']) {
         throw new SystemException('ERR_NO_DATA', SystemException::ERR_CRITICAL);
     }
     $email = $_POST[$subscribersTable]['me_name'];
     if (!($id = $this->dbh->getScalar($subscribersTable, 'me_id', ['me_name' => $email]))) {
         $id = $this->dbh->modify(QAL::INSERT, $subscribersTable, ['me_date' => date('Y-m-d'), 'me_name' => $_POST[$subscribersTable]['me_name']]);
     }
     unset($_POST[$subscribersTable]);
     if (!($result = $this->dbh->getScalar($this->getTableName(), 'mes_id', ['me_id' => $id]))) {
         $_POST[$this->getTableName()]['me_id'] = $id;
         $result = parent::saveData();
     }
     return $result;
 }
Example #9
0
 /**
  * @copydoc Grid::createDataDescription
  */
 protected function createDataDescription()
 {
     $result = parent::createDataDescription();
     if (in_array($this->getState(), array('main', 'getRawData'))) {
         $result->getFieldDescriptionByName('pk_id')->setType(FieldDescription::FIELD_TYPE_INT);
     }
     return $result;
 }
Example #10
0
 protected function deleteData($id)
 {
     $default_group = $this->dbh->select($this->getTableName(), 'group_id', ['group_id' => $id, 'group_default' => true]);
     if (!empty($default_group)) {
         throw new SystemException('ERR_DEFAULT_GROUP', SystemException::ERR_NOTICE);
     }
     parent::deleteData($id);
 }
 /**
  * @copydoc Grid::add
  */
 protected function add()
 {
     parent::add();
     $this->getData()->getFieldByName('vote_question_counter')->setData(0, true);
 }
Example #12
0
 public function build()
 {
     switch ($this->getState()) {
         case 'showPageToolbar':
             $result = false;
             // вызываем родительский метод построения
             $result = Component::build();
             if ($result instanceof \DOMDocument) {
                 $result->documentElement->appendChild($result->importNode($this->buildJS(), true));
                 $tbs = $this->getToolbar();
                 if (!empty($tbs)) {
                     foreach ($tbs as $toolbar) {
                         $result->documentElement->appendChild($result->importNode($toolbar->build(), true));
                     }
                 }
             }
             break;
         case 'showTransEditor':
             $result = $this->transEditor->build();
             break;
         case 'showUserEditor':
             $result = $this->userEditor->build();
             break;
         case 'showRoleEditor':
             $result = $this->roleEditor->build();
             break;
         case 'showLangEditor':
             $result = $this->langEditor->build();
             break;
         case 'showSiteEditor':
             $result = $this->siteEditor->build();
             break;
         case 'showWidgetEditor':
             $result = $this->widgetEditor->build();
             break;
         default:
             $result = parent::build();
             break;
     }
     return $result;
 }
 public function __construct($name, array $params = null)
 {
     parent::__construct($name, $params);
     $this->setTableName('mail_templates');
     $this->setTitle($this->translate('TXT_MAIL_TEMPLATES_EDITOR'));
 }
Example #14
0
 /**
  * @copydoc Grid::delete
  */
 protected function delete()
 {
     $tab = $this->getStateParams();
     if ($tab) {
         $tab = (int) array_pop($tab);
         $this->changeTableName($tab);
     }
     return parent::delete();
 }
Example #15
0
 /**
  * @copydoc Grid::build
  */
 public function build()
 {
     if ($this->getState() == 'editForm') {
         $result = $this->form->build();
     } elseif ($this->getState() == 'showResult') {
         $result = $this->results->build();
     } else {
         $result = parent::build();
     }
     return $result;
 }
Example #16
0
 protected function createData()
 {
     $result = parent::createData();
     $id = $this->getFilter();
     $id = !empty($id) && is_array($id) ? current($id) : false;
     if ($this->getType() != self::COMPONENT_TYPE_LIST && $id) {
         //создаем переменную содержащую идентификторы групп в которые входит пользователь
         $f = new Field('group_id');
         $result->addField($f);
         $data = $this->dbh->select('user_user_groups', array('group_id'), array('u_id' => $id));
         if (!empty($data)) {
             $f->addRowData(array_keys(convertDBResult($data, 'group_id', true)));
         } else {
             $f->setData(array());
         }
     }
     return $result;
 }
Example #17
0
 /**
  * @copydoc Grid::build
  */
 public function build()
 {
     if ($this->getState() == 'reset') {
         $result = $this->divEditor->build();
     } elseif ($this->getState() == 'domains') {
         $result = $this->domainEditor->build();
     } elseif ($this->getState() == 'properties') {
         $result = $this->propertiesEditor->build();
     } else {
         $result = parent::build();
     }
     return $result;
 }
Example #18
0
 public function __construct($name, array $params = null)
 {
     parent::__construct($name, $params);
     $this->setTableName('ads_types');
     $this->setTitle($this->translate('TXT_ADS_TYPES_EDITOR'));
 }
 protected function defineParams()
 {
     return array_merge(parent::defineParams(), array('siteID' => null));
 }
 public function __construct($name, $module, array $params = NULL)
 {
     parent::__construct($name, $module, $params);
     $this->setTableName('mail_email_subscribers');
     $this->setOrder(['me_date' => QAL::ASC]);
 }
Example #21
0
 /**
  * @copydoc Grid::defineParams
  */
 protected function defineParams()
 {
     $result = array_merge(parent::defineParams(), array('tableName' => 'apps_feedback'));
     return $result;
 }
 public function build()
 {
     switch ($this->getState()) {
         case 'buildWidget':
             $result = $this->tmpComponent->build();
             break;
         default:
             $result = parent::build();
             break;
     }
     return $result;
 }
Example #23
0
 protected function saveData()
 {
     $voteID = parent::saveData();
     $this->dbh->modify('UPDATE apps_vote_question SET vote_id=%s WHERE (vote_id IS NULL) or (vote_id = %1$s)', $voteID);
     return $voteID;
 }
Example #24
0
 protected function saveData()
 {
     if (isset($_POST[$this->getTableName()][$this->getPK()]) && empty($_POST[$this->getTableName()][$this->getPK()])) {
         $_POST[$this->getTableName()]['lang_default'] = '0';
     }
     $langID = parent::saveData();
     if ($this->saver->getMode() == QAL::INSERT) {
         //При создании нового языка для всех таблиц переводов
         //создаем переводы копируя данные из дефолтного языка
         if ($translationTables = $this->dbh->select('SHOW TABLES LIKE "%_translation"')) {
             $defaultLangID = E()->getLanguage()->getDefault();
             foreach ($translationTables as $row) {
                 $tableName = current($row);
                 $fields = array_keys($this->dbh->getColumnsInfo($tableName));
                 $fields[1] = $langID;
                 $this->dbh->modify('INSERT INTO ' . $tableName . ' SELECT ' . implode(',', $fields) . ' FROM ' . $tableName . ' WHERE lang_id=%s', $defaultLangID);
             }
         }
     }
     return $langID;
 }
Example #25
0
 /**
  * @copydoc Grid::getRawData
  */
 protected function getRawData()
 {
     $sp = $this->getStateParams(true);
     if (!isset($sp['pid'])) {
         jump:
         $this->addFilterCondition('(upl_pid IS NULL)');
         $uplPID = '';
     } else {
         $uplPID = (int) $sp['pid'];
         if (isset($_COOKIE[self::STORED_PID])) {
             //проверям а есть ли такое?
             if (!$this->dbh->getScalar($this->getTableName(), 'upl_id', ['upl_id' => $uplPID])) {
                 goto jump;
             }
         }
         $this->addFilterCondition(['upl_pid' => $uplPID]);
     }
     parent::getRawData();
     // Плохо реализован дефолтный механизм подключения билдера
     $this->setBuilder(new JSONRepoBuilder());
     if ($this->pager) {
         $this->getBuilder()->setPager($this->pager);
     }
     if ($uplPID) {
         $data = $this->getData();
         $uplID = $this->dbh->getScalar($this->getTableName(), 'upl_pid', ['upl_id' => $sp['pid']]);
         if (is_null($uplID)) {
             $uplID = 0;
         }
         // инстанс IFileRepository для текущего $uplPID
         $repo = $this->repoinfo->getRepositoryInstanceById($uplPID);
         $newData = ['upl_id' => $uplID, 'upl_pid' => $uplPID, 'upl_title' => '...', 'upl_internal_type' => self::TYPE_FOLDER_UP, 'upl_allows_create_dir' => $repo->allowsCreateDir(), 'upl_allows_upload_file' => $repo->allowsUploadFile(), 'upl_allows_edit_dir' => $repo->allowsEditDir(), 'upl_allows_edit_file' => $repo->allowsEditFile(), 'upl_allows_delete_dir' => $repo->allowsDeleteDir(), 'upl_allows_delete_file' => $repo->allowsDeleteFile()];
         //Так получилось что uplPID содержит текущий идентификатор, а uplID - родительский
         $p = [$uplPID];
         $res = $this->dbh->call('proc_get_upl_pid_list', $p);
         unset($p);
         if (!empty($res)) {
             $breadcrumbsData = [];
             foreach ($res as $row) {
                 $breadcrumbsData[$row['id']] = $row['title'];
             }
             $this->getBuilder()->setBreadcrumbs(array_reverse($breadcrumbsData, true));
         }
         if (!$data->isEmpty()) {
             foreach ($this->getDataDescription()->getFieldDescriptionList() as $fieldName) {
                 if ($f = $data->getFieldByName($fieldName)) {
                     $f->addRowData(isset($newData[$fieldName]) ? $newData[$fieldName] : '', false);
                 }
             }
         } else {
             $data->load([$newData]);
         }
     }
 }
Example #26
0
 /**
  * Apply filter to the grid
  * @param Grid $grid
  * @throws SystemException
  */
 public function apply(Grid $grid)
 {
     if ($this->data) {
         $grid->addFilterCondition((string) $this->data);
     }
 }
 protected function loadData()
 {
     $data = parent::loadData();
     if ($this->getState() == 'getRawData' && $data) {
         $inverted = transpose($data);
         $upl_ids = $inverted['upl_id'];
         $res = $this->dbh->select('share_uploads', ['upl_id', 'upl_path', 'upl_title as upl_name', 'upl_duration'], ['upl_id' => $upl_ids]);
         foreach ($data as $i => $row) {
             if ($res) {
                 $new_row = false;
                 foreach ($res as $row2) {
                     if ($row2['upl_id'] == $row['upl_id']) {
                         $new_row = $row2;
                     }
                 }
                 if ($new_row) {
                     $data[$i]['upl_path'] = $new_row['upl_path'];
                     $data[$i]['upl_name'] = $new_row['upl_name'];
                 }
             }
         }
     }
     return $data;
 }
Example #28
0
 /**
  * @copydoc NewsEditor::build
  */
 public function build()
 {
     if ($this->getState() == 'showSmapSelector') {
         $result = $this->divisionEditor->build();
     } else {
         $result = Grid::build();
     }
     return $result;
 }
Example #29
0
 protected function saveData()
 {
     if (isset($_POST[$this->getTableName()]['domain_root']) && substr($_POST[$this->getTableName()]['domain_root'], -1) != '/') {
         $_POST[$this->getTableName()]['domain_root'] .= '/';
     }
     return parent::saveData();
 }
 /**
  * @copydoc Grid::defineParams
  */
 protected function defineParams()
 {
     return array_merge(parent::defineParams(), array('table_name' => false));
 }