Esempio n. 1
0
 /**
  * @param array $data Data.
  */
 public function __construct($data)
 {
     parent::__construct();
     $this->data = E()->Utils->convertFieldNames($data, 'site_');
     if (is_null(self::$isPropertiesTableExists)) {
         self::$isPropertiesTableExists = $this->dbh->tableExists('share_sites_properties');
     }
 }
Esempio n. 2
0
 public function __construct($_ = [])
 {
     if (is_array($_) != true) {
         throw new \Exception();
     }
     $_ = array_map(function ($_) {
         return primval($_);
     }, $_);
     parent::__construct($_);
 }
Esempio n. 3
0
 /**
  * @param bool|int $id User ID.
  */
 public function __construct($id = false)
 {
     parent::__construct();
     $this->id = $id;
     $this->userGroup = E()->UserGroup;
     //Если пользователь существует  - загружаем его информацию
     if ($this->id) {
         $this->loadInfo($this->id);
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     parent::__construct();
     /*
      * Загружаем инфомацию о группах пользователей в структуру вида:
      *     array(
      *         $group_id => array(group info)
      *     );
      */
     $this->groups = convertDBResult($this->dbh->select('user_groups'), 'group_id', true);
 }
Esempio n. 5
0
 /**
  * @copydoc DBWorker::__construct
  *
  * @throws SystemException 'ERR_NO_LANG_INFO'
  */
 public function __construct()
 {
     parent::__construct();
     // получаем все языки, определённые в системе
     $res = $this->dbh->select('share_languages', true, null, array('lang_order_num' => QAL::ASC));
     if (!$res) {
         throw new SystemException('ERR_NO_LANG_INFO', SystemException::ERR_CRITICAL, $this->dbh->getLastRequest());
     }
     // формируем набор языков вида array(langID => langInfo)
     foreach ($res as $langInfo) {
         $this->languages[$langInfo['lang_id']] = $langInfo;
         unset($this->languages[$langInfo['lang_id']]['lang_id']);
     }
 }
Esempio n. 6
0
 /**
  * @param DataDescription $dataDescription Data description.
  * @param Data $data Data.
  * @param string $tableName Table name.
  */
 public function __construct(DataDescription $dataDescription, Data $data, $tableName)
 {
     parent::__construct();
     if ($this->isActive = $this->dbh->tableExists($this->tableName = $tableName . '_tags')) {
         $this->dataDescription = $dataDescription;
         $this->data = $data;
         foreach ($this->dataDescription as $fd) {
             if ($fd->getPropertyValue('key')) {
                 $this->pk = $fd;
                 break;
             }
         }
     }
 }
Esempio n. 7
0
 /**
  * @copydoc DBWorker::__construct
  *
  * @throws SystemException 'ERR_NO_SITE'
  * @throws SystemException 'ERR_403'
  */
 public function __construct()
 {
     parent::__construct();
     $uri = URI::create();
     $this->data = Site::load();
     if (!($this->getConfigValue('site.debug') && ($res = $this->getConfigValue('site.dev_domains')))) {
         $request = 'SELECT d . * , site_id as domain_site
                   FROM `share_domains` d
                   LEFT JOIN share_domain2site d2c
                   USING ( domain_id ) ';
         $res = $this->dbh->select($request);
     }
     if (!$res) {
         throw new SystemException('ERR_NO_SITE', SystemException::ERR_DEVELOPER);
     }
     foreach ($res as $domainData) {
         $domainData = E()->Utils->convertFieldNames($domainData, 'domain_');
         //Если не установлен уже домен - для сайта - дописываем
         //по сути первый домен будет дефолтным
         if (isset($domainData['site']) && is_null($this->data[$domainData['site']]->base)) {
             $tmp = $domainData;
             unset($tmp['id'], $tmp['site']);
             $this->data[$domainData['site']]->setDomain($tmp);
             unset($tmp);
         }
         if ($domainData['protocol'] == $uri->getScheme() && $domainData['host'] == $uri->getHost() && $domainData['port'] == $uri->getPort()) {
             $realPathSegments = array_values(array_filter(explode('/', $domainData['root'])));
             $pathSegments = array_slice($uri->getPath(false), 0, sizeof($realPathSegments));
             if ($realPathSegments == $pathSegments) {
                 $this->currentSiteID = $domainData['site'];
                 unset($domainData['id'], $domainData['site']);
                 $this->data[$this->currentSiteID]->setDomain($domainData);
             }
         }
     }
     if (is_null($this->currentSiteID)) {
         foreach ($this->data as $siteID => $site) {
             if ($site->isDefault == 1) {
                 $this->currentSiteID = $siteID;
             }
         }
     }
     //Если текущий сайт не активный
     if (!$this->data[$this->currentSiteID]->isActive) {
         throw new SystemException('ERR_403', SystemException::ERR_403);
     }
 }
Esempio n. 8
0
    /**
     * @param int $siteID Site ID.
     *
     * @throws SystemException 'ERR_NO_TRANSLATION'
     * @throws SystemException 'ERR_404'
     */
    public function __construct($siteID)
    {
        parent::__construct();
        $this->siteID = $siteID;
        $this->langID = E()->getLanguage()->getCurrent();
        $userGroups = array_keys(E()->UserGroup->asArray());
        //Загружаем идентификаторы для последующего формирования древовидной стркутуры
        $res = $this->dbh->select('SELECT s.smap_id, s.smap_pid FROM share_sitemap s ' . 'LEFT JOIN share_sitemap_translation st ON st.smap_id = s.smap_id ' . 'WHERE st.smap_is_disabled = 0 AND s.site_id = %s AND st.lang_id = %s ' . 'AND s.smap_id IN( ' . ' SELECT smap_id ' . ' FROM share_access_level ' . ' WHERE group_id IN (' . implode(',', E()->getUser()->getGroups()) . ')) ' . 'ORDER BY smap_order_num', $this->siteID, $this->langID);
        //@todo Нужно бы накладывать ограничение в подзапросе на сайт, не факт правда что это увеличит быстродействие
        /*
        SELECT s.smap_id, s.smap_pid FROM share_sitemap s LEFT JOIN share_sitemap_translation st ON st.smap_id = s.smap_id WHERE st.smap_is_disabled = 0 AND s.site_id = '6' AND st.lang_id = '1' AND s.smap_id IN(
        SELECT a.smap_id
        FROM share_access_level  a
        LEFT JOIN share_sitemap s USING(smap_id)
        WHERE group_id IN (1) AND s.site_id=6
        ) ORDER BY smap_order_num
        */
        if (empty($res)) {
            return;
            throw new SystemException('ERR_NO_TRANSLATION', SystemException::ERR_CRITICAL, $this->dbh->getLastRequest());
        }
        //Кешируем уровни доступа к страницам сайта
        //Формируем матрицу вида
        //[идентификатор раздела][идентификатор роли] = идентификатор уровня доступа
        $rightsMatrix = $this->dbh->select('share_access_level', true, ['smap_id' => array_map(create_function('$a', 'return $a["smap_id"];'), $res)]);
        if (!$rightsMatrix) {
            throw new SystemException('ERR_404', SystemException::ERR_404);
        }
        foreach ($rightsMatrix as $data) {
            foreach ($userGroups as $groupID) {
                //todo проверить вариант с пересечением array_diff
                if (!isset($this->cacheAccessLevels[$data['smap_id']][$groupID])) {
                    $this->cacheAccessLevels[$data['smap_id']][$groupID] = ACCESS_NONE;
                }
            }
            $this->cacheAccessLevels[$data['smap_id']][$data['group_id']] = (int) $data['right_id'];
        }
        //Загружаем перечень идентификаторов в объект дерева
        $this->tree = TreeConverter::convert($res, 'smap_id', 'smap_pid');
        $site = E()->getSiteManager()->getSiteByID($this->siteID);
        $res = $this->dbh->select('
		  SELECT s.smap_id FROM share_sitemap s
            WHERE s.site_id = %s AND s.smap_pid IS NULL
		', $this->siteID);
        list($res) = $res;
        $this->defaultID = $res['smap_id'];
        $this->defaultMetaKeywords = $site->metaKeywords;
        $this->defaultMetaDescription = $site->metaDescription;
        $this->defaultMetaRobots = $site->metaRobots;
        $this->getSitemapData(array_keys($this->tree->asList()));
    }
Esempio n. 9
0
 /**
  * @param string $name Field name.
  */
 public function __construct($name = self::EMPTY_FIELD_NAME)
 {
     parent::__construct();
     $this->name = $name;
     $this->systemName = $name;
     $this->isMultilanguage = false;
     $this->additionalProperties = $this->additionalPropertiesLower = [];
     // формируем название поля добавляя префикс 'FIELD_'
     if ($name != self::EMPTY_FIELD_NAME) {
         $this->setProperty('title', 'FIELD_' . $name);
         //$this->setProperty('title', $this->translate('FIELD_'.$name));
     }
 }
Esempio n. 10
0
 /**
  * Constructor.
  *
  * It checks the object's activity and fills the main properties.
  *
  * @param DataDescription $dataDescription Data description.
  * @param Data $data Data.
  * @param string $tableName Main table name.
  * @param bool $addToOG Flag that shows the necessity to generate 'image' tags for OG.
  */
 public function __construct(DataDescription $dataDescription, Data $data, $tableName, $addToOG = false)
 {
     parent::__construct();
     if ($this->isActive = $this->dbh->tableExists($this->tableName = $tableName . self::ATTACH_TABLE_SUFFIX)) {
         $this->hasTags = $this->dbh->tableExists($this->tableName . '_tags');
         $this->dataDescription = $dataDescription;
         $this->data = $data;
         $this->addOG = $addToOG;
         foreach ($this->dataDescription as $fd) {
             if ($fd->getPropertyValue('key')) {
                 $this->pk = $fd;
                 break;
             }
         }
     }
 }
Esempio n. 11
0
 public function __construct()
 {
     parent::__construct();
     $this->finfo = new \finfo(FILEINFO_MIME_TYPE);
     $this->getFInfoSQL = $this->dbh->getPDO()->prepare('SELECT upl_internal_type as type, upl_mime_type as mime, upl_width as width, upl_height as height, upl_is_mp4 as is_mp4, upl_is_webm as is_webm, upl_is_flv as is_flv FROM share_uploads WHERE upl_path = ?');
 }
Esempio n. 12
0
 public function __construct($name = null, $owner = null)
 {
     parent::__construct($name, $owner);
 }
 public function __construct(array $value_ = [])
 {
     parent::__construct($value_);
 }