5 require_once(
'base/functions.php');
37 private $_param = array();
38 private $_cachedMetaUrls = array();
41 private $_classes = array();
57 private $virtualHosts = array();
59 private $mediaSites = array();
60 private $dataSites = array();
62 private static $confs = array();
71 public function __call($function, $params) {
72 if (strpos($function,
'__') !== 0) {
73 $magic_file = $GLOBALS[
'egotec_conf'][
'lib_dir'].
'base/'.get_class($this).
'.'.$function.
'.php';
74 if (file_exists($magic_file)) {
75 require_once($magic_file);
76 return call_user_func($function, $this, $params);
78 throw new Exception(
"Method 'Site.$function' not found");
90 private function _loadConfig($recalc =
false) {
91 if (!$recalc && $this->pageTable && isset(self::$confs[$this->pageTable])) {
95 $this->conf = array();
98 $this->conf =
Ego_System::getJSON($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'/admin/conf.json', $this->conf,
true);
105 if (empty($this->conf[
'site'])) {
108 $this->conf[
'site'] = parse_ini_file($GLOBALS[
'egotec_conf'][
'site_dir'] . $this->name .
'/conf.ini',
true);
115 if (!$this->language) {
116 $this->language = $this->conf[
'site'][
'default_language'];
120 if (!$recalc && isset(self::$confs[$this->pageTable])) {
131 if (empty($this->conf[
'admin'])) {
134 $this->conf[
'admin'] = parse_ini_file($GLOBALS[
'egotec_conf'][
'site_dir'] . $this->name .
'/admin/conf.ini',
true);
140 $allowed_conf_keys = array(
'panel',
'navigation',
'layouts',
'blocks',
'page',
'notification');
143 if (!empty($this->conf[
'site'][
'theme'])) {
144 $theme_paths = array(
145 $GLOBALS[
'egotec_conf'][
'pub_dir'] .
'theme/' . $this->conf[
'site'][
'theme'] .
'/site/admin/conf.json',
146 $this->
globalAllowed() ? $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/' . $this->conf[
'site'][
'theme'] .
'.json' :
''
148 foreach ($theme_paths as $theme_path) {
151 foreach ($allowed_conf_keys as $key) {
152 if (!empty($theme_conf[$key])) {
153 if (empty($this->conf[$key])) {
154 $this->conf[$key] = array();
156 $this->conf[$key] = array_replace_recursive($theme_conf[$key], $this->conf[$key]);
166 foreach ($allowed_conf_keys as $key) {
167 if (!empty($system_conf[$key])) {
168 if (empty($this->conf[$key])) {
169 $this->conf[$key] = array();
171 $this->conf[$key] = array_replace_recursive($system_conf[$key], $this->conf[$key]);
177 $this->conf[
'site'][
'robots'] = $this->conf[
'site'][
'robots_' .
$this->language] ?
178 $this->conf[
'site'][
'robots_' .
$this->language] : ($this->conf[
'site'][
'robots_' . $this->conf[
'site'][
'default_language']] ?
179 $this->conf[
'site'][
'robots_' . $this->conf[
'site'][
'default_language']] :
180 $this->conf[
'site'][
'robots']);
181 $this->conf[
'site'][
'keywords'] = $this->conf[
'site'][
'keywords_' .
$this->language] ?
182 $this->conf[
'site'][
'keywords_' .
$this->language] : ($this->conf[
'site'][
'keywords_' . $this->conf[
'site'][
'default_language']] ?
183 $this->conf[
'site'][
'keywords_' . $this->conf[
'site'][
'default_language']] :
184 $this->conf[
'site'][
'keywords']);
185 $this->conf[
'site'][
'description'] = $this->conf[
'site'][
'description_' .
$this->language] ?
186 $this->conf[
'site'][
'description_' .
$this->language] : ($this->conf[
'site'][
'description_' . $this->conf[
'site'][
'default_language']] ?
187 $this->conf[
'site'][
'description_' . $this->conf[
'site'][
'default_language']] :
188 $this->conf[
'site'][
'description']);
191 if ($this->conf[
'site'][
'type'] ==
'media') {
192 $this->conf[
'admin'][
'enabled_types'][
'multimedia'] = 1;
193 $this->conf[
'admin'][
'enabled_types'][
'multimedia/image'] = 1;
194 $this->conf[
'admin'][
'enabled_types'][
'multimedia/file'] = 1;
195 $this->conf[
'admin'][
'enabled_types'][
'multimedia/category'] = 1;
199 if (!empty($this->conf[
'site'][
'title_' . $this->language])) {
200 $this->conf[
'site'][
'title'] = $this->conf[
'site'][
'title_' .
$this->language];
201 } elseif (!empty($this->conf[
'site'][
'title_' . $this->conf[
'site'][
'default_language']])) {
202 $this->conf[
'site'][
'title'] = $this->conf[
'site'][
'title_' . $this->conf[
'site'][
'default_language']];
203 } elseif (empty($this->conf[
'site'][
'title'])) {
216 $this->loadGlobalConfig();
219 $this->site = &$this->conf[
'site'];
220 $this->admin = &$this->conf[
'admin'];
237 if ($new_site[
'type']==
'media') {
238 Ego_System::mkdir($GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $new_site[
'name']);
241 if (!empty($new_site[
'default_skin'])) {
242 $skin_dir = $GLOBALS[
'egotec_conf'][
'skin_dir'] . $new_site[
'default_skin'];
250 copy($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'template/site/conf.ini', $GLOBALS[
'egotec_conf'][
'site_dir'] . $new_site[
'name'] .
'/conf.ini');
251 Ego_System::mkdir($GLOBALS[
'egotec_conf'][
'site_dir'] . $new_site[
'name'] .
'/admin');
252 copy($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'template/site/admin/conf.ini', $GLOBALS[
'egotec_conf'][
'site_dir'] . $new_site[
'name'] .
'/admin/conf.ini');
254 $newSite =
new Site($new_site[
'name']);
256 if ($new_site[
'lang']) {
257 $new_site[
'default_language'] = $new_site[
'lang'];
258 $new_site[
'languages'] = $new_site[
'lang'];
262 if ($new_site[
'title'] && $new_site[
'default_language']) {
263 $new_site[
'title_' . $new_site[
'default_language']] = $new_site[
'title'];
264 unset($new_site[
'title']);
267 $rights = $new_site[
'rights'];
268 unset($new_site[
'name'], $new_site[
'lang'], $new_site[
'rights']);
270 $newSite->save($new_site);
271 $newSite->createTables();
273 require_once
'base/Ego_Search_Factory.php';
278 $date = date(
'Y-m-d H:i:s');
281 'name' =>
'Homepage',
282 'title' =>
'Homepage',
285 'content' =>
'This is the Homepage of a new site.',
286 'extra' => serialize([]),
290 'a_user' => $GLOBALS[
'auth']->getId(),
291 'c_user' => $GLOBALS[
'auth']->getId(),
292 'm_user' => $GLOBALS[
'auth']->getId(),
293 'type' => $new_site[
'type'] ==
'media' ?
'multimedia/category' : ($new_site[
'type'] ==
'data' ?
'data' :
'page'),
294 'children_order' =>
'type',
299 'release_from' =>
'0000-00-00 00:00:00',
300 'release_until' =>
'0000-00-00 00:00:00',
302 'workflow_state' => 0,
305 $db = new_db_connection();
307 $no_null_rights = explode(
',', $no_null_rights);
316 foreach ($newSite->getLanguages() as $lang) {
317 $db->insert([
'table' => $newSite->name .
'_' . $lang,
'set' => $field]);
318 $insert_rights[
'table'] = $newSite->name .
'_' . $lang .
'_rights';
320 foreach ($no_null_rights as $no_null_right) {
321 if ($no_null_right !=
'live') {
322 $insert_rights[
'set'][
'perm'] = $no_null_right;
323 $db->insert($insert_rights);
329 if ($newSite->site[
'type'] ==
'media') {
330 $newSite->save_admin([
333 'multimedia/image' => 1,
334 'multimedia/file' => 1,
335 'multimedia/category' => 1
338 } elseif($newSite->site[
'type'] ==
'data') {
339 $newSite->save_admin([
343 'data/address/authority' => 1,
344 'data/address/building' => 1,
345 'data/address/department' => 1,
346 'data/address/person' => 1,
348 'data/events/organizer' => 1,
349 'data/events/venue' => 1,
354 $newSite->save_admin([
362 $default_group = is_array($rights) && $rights[
'group'] ? $rights[
'group'] : $GLOBALS[
'egotec_conf'][
'superuser'][
'group'];
363 $default_role = is_array($rights) && $rights[
'role'] ? $rights[
'role'] : $GLOBALS[
'egotec_conf'][
'superuser'][
'role'];
365 $right = $newSite->site[
'right'];
367 foreach ([
'admin',
'translate',
'view',
'linkto',
'addclone',
'newclone',
'trashcan',
'stats',
'liveserver',
'site',
'skin',
'change_type',
'linkchecker',
'nousechecker',
'barriercheck'] as $type) {
368 $right[
"{$type}_group_0"] = $default_group;
369 $right[
"{$type}_role_0"] = $default_role;
372 $newSite->save_admin([
377 self::$confs[$newSite->pageTable];
378 $newSite =
new Site($newSite->name);
381 if ($newSite->getSkinFile(
'layout.tpl') || $newSite->getSkinFile(
'layout.html')) {
382 $newSite->save_admin([
383 'frontend_admin' => 1
435 $this->_onlyActive = $only_active;
436 if ($_REQUEST[
'preview'] && $GLOBALS[
'auth'] && !$GLOBALS[
'auth']->isNobody()) {
437 $this->_onlyActive =
false;
440 $site_name = str_replace(
'/',
'', $site_name);
441 if (!file_exists($GLOBALS[
'egotec_conf'][
'site_dir'].$site_name))
447 $this->_isDefault =
true;
449 $site_name = $GLOBALS[
'egotec_conf'][
'default_site'];
451 $this->name = $site_name;
452 $this->_loadConfig($recalc);
457 $this->skin = $this->site[
'default_skin'];
459 $this->theme = (string) $this->site[
'theme'];
461 if ($GLOBALS[
'virtual_host_site'] && $GLOBALS[
'virtual_host_lang'] && $GLOBALS[
'virtual_host_site']==$this->name)
463 $this->site[
'default_language'] = $GLOBALS[
'virtual_host_lang'];
472 && !$this->admin[
'mediapool'][
'active']
475 'mediapool' => array(
489 $this->_onlyActive = $b;
506 $this->_time = $time;
508 $expire_time = $this->_cache->getExpire();
509 $this->_time = date(
'Y-m-d H:i:s', (
int)($expire_time ? $expire_time : time()));
522 $this->virtualHosts = array();
526 $language = $this->site[
'default_language'];
530 $new_page_table = $this->name.
'_'.
$language;
531 if ($this->_param[
'auth_or'])
533 $this->_param[
'auth_or'] = str_replace($this->pageTable, $new_page_table, $this->_param[
'auth_or']);
535 if ($this->_param[
'deleted_or'])
537 $this->_param[
'deleted_or'] = str_replace($this->pageTable, $new_page_table, $this->_param[
'deleted_or']);
540 $this->pageTable = $new_page_table;
542 $this->language = $this->site[
'default_language'];
543 $this->pageTable = $this->name.
'_'.$this->site[
'default_language'];
548 $path = $this->name.
'/'.$this->language.
'/';
551 $this->_cache->setPath($this->name.
'/'.$this->language.
'/');
554 if (empty($GLOBALS[
"egotec_conf"][
"cachemedia_dir"])) {
555 $GLOBALS[
"egotec_conf"][
"cachemedia_dir"] = $GLOBALS[
"egotec_conf"][
"var_dir"].
"cachemedia/";
558 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type'])
561 require_once(
'base/Ego_Cache_apcu.php');
562 $this->_cache =
new Ego_Cache_apcu($path);
565 require_once($GLOBALS[
'egotec_conf'][
'var_dir'].
'lib/Ego_Cache_custom.php');
566 $this->_cache =
new Ego_Cache_custom($path);
569 require_once(
'base/Ego_Cache_file.php');
570 $this->_cache =
new Ego_Cache_file($path);
573 if ($this->_cache->isExpired()) {
576 $this->_loadConfig();
586 $this->_rights = array_unique($rights);
587 $this->
setParam(array(
'rights' => $this->_rights));
599 $this->_param = array_merge($this->_param, $param);
601 $this->_param = $param;
612 $this->_param = $param;
620 return md5(serialize($this->_param));
630 if (!$this->_languages) {
631 $this->_languages = explode(
',', $this->site[
'languages']);
633 return $this->_languages;
643 $skins = explode(
',', $this->site[
'skins']);
646 if (!in_array($this->site[
'default_skin'], $skins)) {
647 $skins[] = $this->site[
'default_skin'];
651 if (
$theme && !empty($this->theme)) {
655 return array_filter($skins);
668 $id_file = $GLOBALS[
'egotec_conf'][
'cache_dir'] . $this->name .
'/_id/' .
$name;
670 if (file_exists($id_file)) {
671 return file_get_contents($id_file);
673 $db = new_db_connection([
675 'table' => $this->pageTable,
676 'where' =>
'url like :name',
677 'bind' => [
'name' =>
$name]
680 if ($db->nextRecord()) {
681 return (
int) $db->Record[
'id'];
685 'table' => $this->pageTable,
686 'where' =>
'name like :name',
687 'bind' => [
'name' =>
$name],
692 if ($db->nextRecord()) {
693 return (
int) $db->Record[
'id'];
709 return $this->_onlyActive;
755 function getPages($query=array(), $param = array())
757 if (is_array($param))
759 $param = array_merge($this->_param, $param);
761 $param = $this->_param;
770 $site->setLanguage($param[
'lang']);
777 $page_table =
$site->name.
'_'.$param[
'lang'];
779 if (is_string($query)||is_bool($query))
781 egotec_error_log(
'$query wurde als String übergeben Query: '.$query);
782 eval (
"\$query = $query;");
784 if (trim($query[
'where']))
786 $query[
'where'] =
'('.$query[
'where'].
')';
789 $query[
'where'] =
'1=1';
793 if (!isset($query[
'fields2'])) {
794 $query[
'fields2'] = [];
795 } elseif (is_string($query[
'fields2'])) {
796 $query[
'fields2'] = [$query[
'fields2']];
799 if ((
$site->getOnlyActive() && !$param[
'inactive']) || $param[
'only_active'])
801 $query[
'where'] = $query[
'where'].
"
802 and $page_table.inactive=0
804 $query[
'where'] = $query[
'where'].
"
805 and ($page_table.release_until='0000-00-00 00:00:00' or $page_table.release_until >= '".
$site->getTime().
"')
806 and ($page_table.release_from='0000-00-00 00:00:00' or $page_table.release_from < '".
$site->getTime().
"')
808 } elseif (($_REQUEST[
'preview'] || $GLOBALS[
'frontend_admin']) && empty($param[
'expired'])) {
810 $query[
'where'] = $query[
'where'].
"
811 and ($page_table.release_until='0000-00-00 00:00:00' or $page_table.release_until >= '".
$site->getTime().
"')
816 $bitand_query = $this->getBitandQuery($param, $page_table);
817 if (!empty($bitand_query) && !empty($query[
'fields']) && strpos($query[
'fields'],
'nav_hide') ===
false) {
818 $query[
'fields'] .=
','.$page_table.
'.nav_hide';
820 $query[
'bitand'] = $bitand_query;
822 if ((integer)$param[
'deleted']>=0)
824 $query[
'where'] = $query[
'where'].
' AND ('.$page_table.
'.deleted='.
825 (integer)$param[
'deleted'].($param[
'deleted_or']?
' OR '.$param[
'deleted_or']:
'').
')';
827 $query[
'table'] = ($query[
'table']?$query[
'table'].
',':
'').$page_table;
828 if (!isset($param[
'rights']))
830 $param[
'rights'] = array(
'view');
832 if (!isset($query[
'fields']))
834 $query[
'fields'] = $page_table.
'.*';
838 $query[
'where'] = ($query[
'where']?$query[
'where'].
' AND ':
'').
'('.$param[
'where'].
')';
840 if ($param[
'auth_or']!=
'1=1')
842 $query = $GLOBALS[
'auth']->getPageTableQuery($page_table, $param[
'rights'], $query, $param);
844 if ($param[
'fulltext'] || $param[
'extra'] || $param[
'filter'])
846 require_once(
'base/Ego_Search_Factory.php');
849 }
catch (Exception $e) {
855 if ($param[
'extra']) {
857 if (isset($param[
'extra_bind'])) {
859 $param[
'extra-bind'] = $param[
'extra_bind'];
861 $search->setExtraQuery($param[
'extra'], (array) $param[
'extra-bind']);
864 if ($query[
'where'] && preg_match_all(
'/\W'.$this->pageTable.
'\.id in \(([0-9, ]+)\)/i', $query[
'where'], $matches)) {
865 $query[
'id_list'] = [];
866 foreach ($matches[1] as $match) {
867 $query[
'id_list'] = array_merge($query[
'id_list'], array_map(
'trim', explode(
',', $match)));
871 if ($GLOBALS[
'egotec_conf'][
'search_engine'] ==
'sql') {
872 $query = $search->search((
string) $param[
'fulltext'],
$site->pageTable.
'.id', $query,
true);
873 } elseif ($GLOBALS[
'egotec_conf'][
'search_engine'] ==
'lucene' || $GLOBALS[
'egotec_conf'][
'search_engine'] ==
'elastic') {
874 $query = $search->search((
string) $param[
'fulltext'],
$site->pageTable.
'.id', $query, $param[
'filter'], (
bool) $param[
'fuzzy']);
875 if ($GLOBALS[
'egotec_conf'][
'search_engine'] ==
'elastic') {
877 unset($query[
'limit']);
880 $query = $search->search((
string) $param[
'fulltext'],
$site->pageTable.
'.id', $query);
882 $query[
'distinct'] =
true;
885 require_once(
'base/Page_Iterator.php');
889 if ($param[
'without_types'])
891 $query[
'where'].=
' AND '.$page_table.
'.type NOT IN (\''.str_replace(
",",
"','",$param[
'without_types']).
'\')
';
893 if ($param['search_keywords
'])
895 if ($this->admin['keyword_register_own_site
']) {
896 // Neues Schlagwortregister
898 if (is_numeric($param['search_keywords
'])) {
900 'where
' => "type = '_keywords/entry
' AND id = :id",
902 'id' => $param['search_keywords
']
907 'where
' => "type = '_keywords/entry
' AND name = :name",
909 'name
' => $param['search_keywords
']
913 $keywords = $this->getPages(array_merge([
914 'fields
' => 'id, type
',
915 ], $keywords_query));
916 foreach ($keywords as $keyword) {
917 $children = $keyword->getChildren([
918 'fields
' => 'id, type
',
919 'where
' => "type != '_keywords/entry
'"
921 foreach ($children as $child) {
922 $page_ids[] = $child->field['id'];
925 return $this->getPages([
926 'where
' => "id IN ('" . implode("', '", $page_ids) . "')"
929 // Altes Schlagwortregister
930 if ($site->admin['keywords
']['site
'])
932 $keywords_tbl = $site->admin['keywords
']['site
'].'_
'.$site->language;
935 $keywords_tbl = $site->pageTable;
938 $search = new Ego_Search_Sql($keywords_tbl, '_keywords
');
939 $query = $search->search(
940 $param['search_keywords
'],
941 $site->pageTable.'.id
',
947 $site->name.'_keywords_rel.page_id
',
948 ',
'.$site->name.'_keywords_rel
',
949 $site->name.'_keywords_rel.keyword_id=
'.$keywords_tbl.'_keywords.id
',
950 'SELECT SUM(page_id/page_id) FROM
'.$keywords_tbl.'_keywords,
'.$site->name.'_keywords_rel WHERE
'.
951 $site->name.'_keywords_rel.keyword_id=
'.$keywords_tbl.'_keywords.id
',
954 $query['distinct
'] = true;
960 foreach ($query['andor
'] as $ors)
962 $and[] = '(
'.join(') OR (
', $ors).')
';
964 $query['where
'].= "\n AND (".join(") AND (", $and).')
';
965 unset($query['andor
']);
969 $query['where
'].= "\n AND ".join(' AND
', $query['and
']);
970 unset($query['and
']);
974 $query['where
'].= "\n AND ( (".join(")\n OR (", $query['or
']).') )
';
979 $query['fields2
'][] = '(LN((
'.join(') + (
', $query['score
']).'))+1) AS score
';
980 unset($query['score
']);
982 if ($param['has_children
'])
984 $has_children_where = $param['has_children_where
'] ? ' AND (
'.$param['has_children_where
'].')
' : '';
985 if ((integer)$param['deleted
']>=0)
986 { // Gelöschte Seiten ausblenden.
987 $has_children_where.= ' AND (has_table.deleted=
'.
988 (integer)$param['deleted
'].($param['deleted_or
']?' OR
'.$param['deleted_or
']:'').')
';
990 if (($site->getOnlyActive() && !$param['inactive
']) || $param['only_active
'])
991 { // Die ursprüngliche Zeile $query.=... gab beim Aufruf über Smarty eine Fehlermeldung
992 $has_children_where.= ' AND has_table.inactive=0
'.
993 ' AND (has_table.release_until=\
'0000-00-00 00:00:00\' or has_table.release_until>=\''.$site->getTime().
'\')
'.
994 ' AND (has_table.release_from=\
'0000-00-00 00:00:00\' or has_table.release_from<\''.$site->getTime().
'\')
';
995 } elseif (($_REQUEST['preview
'] || $GLOBALS['frontend_admin
']) && empty($param['expired
'])) {
996 // In der Vorschau/Frontend Administration werden inaktive Seiten durch das Freigabe bis Datum nicht angezeigt
997 $has_children_where.= ' AND (has_table.release_until=\
'0000-00-00 00:00:00\' or has_table.release_until>=\''.$site->getTime().
'\')
';
1000 /* Bitand für has_children ermitteln
1001 * (die pageTable muss mit "has_table" ersetzt werden, damit die bitand Anweisungen auch auf den Sub-Select angewendet werden)
1003 $query['field_as_bitand
']['has_children
'] = array_map(function($value) {
1004 $value[0] = str_replace($this->pageTable . '.
', 'has_table.
', $value[0]);
1009 'page_table
' => 'has_table
',
1010 'where
' => $page_table .'.id=
'.$page_table.'_children.page_id
'.
1011 ' AND
'.$page_table.'_children.child=has_table.id
'.
1014 $query['distinct
'] = true;
1016 if ($param['auth_or
']!='1=1
')
1018 $children_query = $GLOBALS['auth
']->getPageTableQuery($page_table, $param['rights
'], $children_query, $param);
1020 $query['field_as
']['has_children
'] = 'SELECT
'.($param['children_count
']===false?'DISTINCT 1
':'count(DISTINCT child)
').
1021 ' FROM
'.$page_table.'_children,
'.$page_table.' has_table
'.
1022 ($children_query['join
']?' LEFT JOIN
'.(is_array($children_query['join
'])?
1023 implode(' LEFT JOIN
', $children_query['join
']):$children_query['join
']):'').
1024 ' WHERE
'.$children_query['where
'];
1025 if ($param['children_count
'] === false) {
1026 $query['field_as_limit
']['has_children
'] = '0,1
';
1029 if ($param['multi_parents
'])
1032 if ((integer)$param['deleted
']>=0)
1033 { // Gelöschte Seiten ausblenden.
1034 $multi_where.= ' AND (multi_table.deleted=
'.
1035 (integer)$param['deleted
'].($param['deleted_or
']?' OR
'.$param['deleted_or
']:'').')
';
1037 if (($site->getOnlyActive() && !$param['inactive
']) || $param['only_active
'])
1038 { // Die ursprüngliche Zeile $query.=... gab beim Aufruf über Smarty eine Fehlermeldung
1039 $multi_where.= ' AND multi_table.inactive=0
'.
1040 ' AND (multi_table.release_until=\
'0000-00-00 00:00:00\' or multi_table.release_until>=\''.$site->getTime().
'\')
'.
1041 ' AND (multi_table.release_from=\
'0000-00-00 00:00:00\' or multi_table.release_from<\''.$site->getTime().
'\')
';
1042 } elseif (($_REQUEST['preview
'] || $GLOBALS['frontend_admin
']) && empty($param['expired
'])) {
1043 // In der Vorschau/Frontend Administration werden inaktive Seiten durch das Freigabe bis Datum nicht angezeigt
1044 $multi_where.= ' AND (multi_table.release_until=\
'0000-00-00 00:00:00\' or multi_table.release_until>=\''.$site->getTime().
'\')
';
1047 // Bitand für multi_parents ermitteln
1048 $query['field_as_bitand
']['multi_parents
'] = $bitand_query;
1050 $query['field_as
']['multi_parents
'] = 'SELECT count(page_id)-1
'.
1051 ' FROM
'.$page_table.'_children,
'.$page_table.' multi_table
'.
1052 ' WHERE
'.$page_table.'.id=child
'.
1053 ' AND
'.$page_table.'_children.page_id=multi_table.id
'.
1055 $query['distinct
'] = true;
1058 if ($GLOBALS['egotec_conf
']['pages_cache
'] && !$param['no_cache
'])
1060 return new Page_Iterator($site, new_db_connection($query, $site->getCache()));
1062 return new Page_Iterator($site, new_db_connection($query));
1074 private function getBitandQuery($param, $page_table = '') {
1077 $page_table = $this->pageTable;
1080 !isset($param['sitemap
'])
1081 && $param['fulltext
']
1082 && !$GLOBALS['admin_area
']
1084 // In der Frontend Suche standardmäßig nur Seiten finden, die auch in der Sitemap angezeigt werden
1085 $param['sitemap
'] = true;
1087 if ($param['no_nav_hide
'])
1088 { // Nur Seiten, die in der Navigation angezeigt werden (nav_hide&1=0)
1089 $query[] = array($page_table.'.nav_hide
', 1, 0);
1090 $param['sitemap
'] = true; // Außerdem nur Seiten, die in der Sitemap angezeigt werden
1092 if ($param['no_intranet
'])
1093 { // Nur Seiten, die auf den Liveserver übertragen werden (nav_hide&2=0)
1094 $query[] = array($page_table.'.nav_hide
', 2, 0);
1096 if ($param['intranet
'])
1097 { // Nur Seiten, die nur im Intranet angezeigt werden (nav_hide&2=2)
1098 $query[] = array($page_table.'.nav_hide
', 2, 2);
1100 if ($param['search
'])
1101 { // Nur Seiten, die nicht von der Suche ausgeschlossen werden (nav_hide&4=0)
1102 $query[] = array($page_table.'.nav_hide
', 4, 0);
1104 if ($param['sitemap
'] && (!$GLOBALS['egotec_conf
']['show_hidden_sitemap
'] || !$GLOBALS['admin_area
']))
1105 { // Nur Seiten, die in der Sitemap angezeigt werden (nav_hide&8=0)
1106 $query[] = array($page_table.'.nav_hide
', 8, 0);
1108 if ($param['nouse
'])
1109 { // Nur Seiten, die im Verwendungsnachweis berücksichtigt werden sollen (nav_hide&16=0)
1110 $query[] = array($page_table.'.nav_hide
', 16, 0);
1112 if (isset($param['flag0
']))
1113 { // Weitere Flag für offene Anwendungsfälle (nav_hide&32=0)
1114 $query[] = array($page_table.'.nav_hide
', 32, $param['flag0
']?32:0);
1116 if (isset($param['flag1
']))
1117 { // Weitere Flag für offene Anwendungsfälle (nav_hide&64=0)
1118 $query[] = array($page_table.'.nav_hide
', 64, $param['flag1
']?64:0);
1120 if (isset($param['flag2
']))
1121 { // Weitere Flag für offene Anwendungsfälle (nav_hide&128=0)
1122 $query[] = array($page_table.'.nav_hide
', 128, $param['flag2
']?128:0);
1124 if (isset($param['flag3
']))
1125 { // Weitere Flag für offene Anwendungsfälle (nav_hide&256=0)
1126 $query[] = array($page_table.'.nav_hide
', 256, $param['flag3
']?256:0);
1128 if (isset($param['flag4
']))
1129 { // Weitere Flag für offene Anwendungsfälle (nav_hide&512=0)
1130 $query[] = array($page_table.'.nav_hide
', 512, $param['flag4
']?512:0);
1132 if (isset($param['flag5
']))
1133 { // Weitere Flag für offene Anwendungsfälle (nav_hide&1024=0)
1134 $query[] = array($page_table.'.nav_hide
', 1024, $param['flag5
']?1024:0);
1136 if (isset($param['flag6
']))
1137 { // Weitere Flag für offene Anwendungsfälle (nav_hide&2048=0)
1138 $query[] = array($page_table.'.nav_hide
', 2048, $param['flag6
']?2048:0);
1140 if (isset($param['flag7
']))
1141 { // Weitere Flag für offene Anwendungsfälle (nav_hide&4096=0)
1142 $query[] = array($page_table.'.nav_hide
', 4096, $param['flag7
']?4096:0);
1154 function getLostPages($deleted = -1)
1156 /* Verlorene Seiten sind:
1157 * 1. Seiten ohne Elternseite
1158 * 2. Seiten die als Elternseite nur Schlagwörter haben (aber selbst kein Schlagwort sind) */
1159 return $this->getPages(
1161 'join
' => array($this->pageTable.'_children ON child =
id'),
1162 'where
' => "id != {$this->rootId} AND (child IS NULL OR (type != '_keywords/entry
' AND id IN (SELECT child FROM {$this->pageTable}_children INNER JOIN {$this->pageTable} ON page_id = id WHERE type = '_keywords/entry
') AND id NOT IN (SELECT child FROM {$this->pageTable}_children INNER JOIN {$this->pageTable} ON page_id = id WHERE type != '_keywords/entry
')))"
1165 'deleted
' => $deleted,
1182 function getPage($id, $param = []) {
1190 $cache_key = md5(serialize([$this->language, $param]));
1192 if ($id == $this->rootId && $page = $this->_root[$cache_key]) {
1196 if (is_numeric($_REQUEST['id']) && $id == $_REQUEST['id']) {
1197 // Falls möglich, die aktuelle abgelaufene Seite anzeigen
1198 $param['expired
'] = true;
1201 if ($param['original
']) {
1202 // Die originale Seite holen (für "Speichern und Veröffentlichen")
1203 $GLOBALS['public_save_get_original_page
'] = true;
1204 unset($param['original
']);
1207 $pages = $this->getPages([
1208 'fields
' => $param['fields
'],
1209 'where
' => 'id=:
id',
1210 'bind
' => ['id' => (int) $id]
1215 $page = $pages->nextPage();
1216 unset($GLOBALS['public_save_get_original_page
']);
1218 if ($id == $this->rootId) { // Die root Seite cachen, da auf diese oft zugefriffen wird.
1219 $this->_root[$cache_key] = $page;
1236 function getRoot($param = array())
1238 return $this->getPage($this->rootId, $param);
1249 function getErrorPage()
1251 $GLOBALS['_SERVER
']['REDIRECT_STATUS
'] = '404
';
1252 if (!($page = $this->getPage($this->site['error_id
'] ? $this->site['error_id
'] : $this->rootId))) {
1253 // Falls die eingestellte Fehlerseite nicht erreichbar ist, wird die Startseite verwendet
1254 $page = $this->getRoot();
1265 function getUrl($param, $page = null)
1267 if (!$this->_onlyActive && !isset($param['nonactive
']))
1268 { // Auch inaktive Seiten anzeigen.
1269 $param['nonactive
'] = true;
1271 if (isset($param['nonactive
']) && !$param['nonactive
'])
1273 unset($param['nonactive
']);
1275 if (!isset($param['lang
']))
1277 $param['lang
'] = $this->language;
1279 if (!isset($param['skin
']) && $this->skin!=$this->site['default_skin
'])
1281 $param['skin
'] = $this->skin;
1283 if (!isset($param['site
']))
1285 $param['site
'] = $this->name;
1288 // Alphabetische Reihenfolge der URL Parameter
1291 if ($param['get_frontend_url
']) {
1292 // Im Adminbereich eine sprechende URL ermitteln
1293 return get_url('index.php
', $param, $page, true, 2);
1295 return get_url('index.php
', $param, $page);
1305 function getPageUrl($page_id, $params = array(), $page = null)
1307 return $page_id?$this->getUrl(array_merge(array('id' => $page_id), $params), $page):$this->getErrorPage();
1323 function getMediaSite($lang = '') {
1325 $this->site['type
'] != 'media
'
1326 && empty($this->site['media
'])
1339 $lang = $this->language;
1342 if (isset($this->mediaSites[$lang])) {
1343 return $this->mediaSites[$lang];
1346 if ($this->site['type
'] == 'media
') {
1347 $media_site = $this;
1349 $media_site = new Site($this->site['media
'], '', '', $this->_onlyActive);
1350 $media_site->setParam($this->_param);
1353 // Prüfen, ob die aktuelle Sprache auch im Multimedia Mandanten existiert
1355 in_array($lang, $media_site->getLanguages())
1356 && $lang != $media_site->language
1358 $media_site->setLanguage($lang);
1361 return $this->mediaSites[$lang] = $media_site;
1373 public function getDataSite($lang = '') {
1375 $this->site['type
'] !== 'data
'
1376 && empty($this->site['data
'])
1382 $lang = $this->language;
1385 if (isset($this->dataSites[$lang])) {
1386 return $this->dataSites[$lang];
1389 if ($this->site['type
'] == 'data
') {
1392 $data_site = new Site($this->site['data
'], '', '', $this->_onlyActive);
1393 $data_site->setParam($this->_param);
1396 // Prüfen, ob die aktuelle Sprache auch im Multimedia Mandanten existiert
1398 in_array($lang, $data_site->getLanguages())
1399 && $lang != $data_site->language
1401 $data_site->setLanguage($lang);
1404 return $this->dataSites[$lang] = $data_site;
1412 public function hasMediaSite() {
1413 return ($this->site['type
'] == 'media
' || !empty($this->site['media
']));
1421 public function hasDataSite() {
1422 return ($this->site['type
'] === 'data
' || !empty($this->site['data
']));
1435 public function getFirstSite($type) {
1437 $method = 'get' . ucfirst($type) .'Site';
1438 if (method_exists($this, $method) && ($connected_site = $this->{$method}()) && $connected_site->hasRight('desktop
')) {
1439 $site = $connected_site;
1441 foreach (Ego_System::getAllSites($GLOBALS['auth
']->user->field['id'], 'desktop
', false, $type) as $connected_site) {
1442 $site = $connected_site;
1456 function getMediaUrl($id, $param = array(), $url_param = array())
1458 if ($param['no_suffix
'])
1460 $url_param['no_suffix
'] = $param['no_suffix
'];
1461 unset($param['no_suffix
']);
1463 return $this->getMediaSite()->getPage($id, $param)->getUrl($url_param);
1472 function clearCache($id=0, $all_languages = false)
1474 if ($all_languages) {
1475 // Cache für alle Sprachen ungültig setzen
1476 $site = clone $this;
1477 foreach ($site->getLanguages() as $lang) {
1478 $site->setLanguage($lang);
1479 $site->clearCache($id);
1484 $language = $this->language;
1485 $pageTable = $this->name.'_
'.$language;
1486 if (!file_exists($GLOBALS['egotec_conf
']['log_dir
'].$this->name.'_
'.$language))
1488 Ego_System::mkdir($GLOBALS['egotec_conf
']['log_dir
'].$this->name.'_
'.$language, 0777, true);
1492 { // Bei Bildern wird nicht der komplette Cache, sondern nur das aktuelle Bild gelöscht
1493 $cache_path = $GLOBALS['egotec_conf
']['cachemedia_dir
'].$this->name.'/
'.$language.'/
';
1494 Ego_System::deldir($cache_path.$id, true);
1502 // Cache, Lebensdauer einstellen nun immer 24h
1503 $new_cache_lifetime = 86400;
1505 $cache_expire = date('Y-m-d H:i:s
', time()+$new_cache_lifetime);
1506 $time = date('Y-m-d H:i:s
');
1507 $db = new_db_connection(array( // Datum der nächsten Änderung durch Ablauf von Freigabefenstern bestimmen.
1509 'table
' => $pageTable,
1510 'where
' => 'release_from>:time
',
1511 'bind
' => array('time
' => $time),
1512 'order
' => 'release_from asc
',
1515 if ($db->nextRecord())
1517 if ($db->Record['release_from
']<$cache_expire)
1519 $cache_expire = $db->Record['release_from
'];
1524 'table
' => $pageTable,
1525 'where
' => 'release_until>:time
',
1526 'bind
' => array('time
' => $time),
1527 'order
' => 'release_until asc
',
1530 if ($db->nextRecord())
1532 if ($db->Record['release_until
']<$cache_expire)
1534 $cache_expire = $db->Record['release_until
'];
1537 $d = preg_split('/[-, ,:]/
', $cache_expire);
1538 $this->_cache->reset();
1540 $this->_cache->setExpire(mktime($d[3], $d[4], $d[5], $d[1], $d[2], $d[0]));
1541 $this->setTime(); // Der Zeitstempel für die Freigabeabfrage muss neu gesetzt werden.
1543 // types.cache und classes.cache löschen
1544 Ego_System::clearTypeCache($this->name);
1546 // Allgemeine Cache löschen (nicht für APCu, da hier die allgemeine Cache die selbe ist wie die Site Cache)
1547 if ($GLOBALS['egotec_conf
']['site_cache_type
'] != 'apcu
') {
1548 $cache = Ego_System::getCache();
1551 Ego_System::clearNginxCache();
1559 public function getGlobalConfig($type) {
1560 if ($this->global !== null && !empty($this->global[$type])) {
1561 return $this->global[$type];
1573 private function loadGlobalConfig($types = ['site
', 'admin
']) {
1574 if ($this->global === null) {
1575 if (Ego_System::file_exists($file = $GLOBALS['egotec_conf
']['var_dir
'] . 'conf/global.json
')) {
1576 $this->global = json_decode(Ego_System::file_get_contents($file), true);
1582 if (!empty($this->global)) {
1592 $set_value = function($meta, $type, $key) {
1593 if (!$this->useGlobalConfig($meta)) {
1597 if (isset($meta['value
'])) {
1598 Ego_System::setAssocValue($this->conf[$type], $key, $meta['value
']);
1599 } elseif (isset($meta['env
'])) {
1600 Ego_System::setAssocValue($this->conf[$type], $key, $_ENV[$meta['env
']]
1601 ?? $_SERVER[$meta['env
']]
1602 ?? (getenv($meta['env
'], true) ?: getenv($meta['env
']))
1607 foreach ($types as $type) {
1608 if (is_array($this->global[$type])) {
1609 foreach ($this->global[$type] as $key => $meta) {
1610 if (is_array($meta['values
'])) {
1611 foreach ($meta['values
'] as $value) {
1612 $set_value($value, $type, $key);
1615 $set_value($meta, $type, $key);
1630 private function setGlobalConfig($type) {
1631 if (!empty($this->global) && is_array($this->global[$type])) {
1632 foreach ($this->global[$type] as $key => $meta) {
1634 Ego_System::getAssocValue($this->{$type}, $key) !== null
1635 && $this->isGlobalConfig($type, $key)
1637 Ego_System::setAssocValue($this->{$type}, $key, null);
1651 private function isGlobalConfig($type, $search_key) {
1652 if (!empty($this->global) && is_array($this->global[$type])) {
1653 foreach ($this->global[$type] as $key => $meta) {
1654 if ($search_key == $key) {
1655 if ($this->useGlobalConfig($meta)) {
1672 public function useGlobalConfig($meta) {
1673 if (is_array($meta['values
'])) {
1674 foreach ($meta['values
'] as $value) {
1675 if ($this->useGlobalConfig($value)) {
1681 if (is_array($meta['include
'])) {
1682 foreach ($meta['include
'] as $value) {
1683 if (strpos($value, 'type:
') === 0) {
1684 if ($this->site['type
'] == substr($value, 5)) {
1687 } elseif ($this->name == $value) {
1692 } elseif (is_array($meta['exclude
'])) {
1693 foreach ($meta['exclude
'] as $value) {
1694 if (strpos($value, 'type:
') === 0) {
1695 if ($this->site['type
'] == substr($value, 5)) {
1698 } elseif ($this->name == $value) {
1714 function save($site) {
1717 // Sprachen müssen migriert werden, wenn die Standardsprache sich ändert, oder eine Sprache gelöscht wird
1718 $migrateLanguages = ($this->site['default_language
'] !== $site['default_language
']) || ($this->site['languages
'] !== $site['languages
']);
1720 $this->site = array_merge($this->site, $site);
1722 // Globale Konfigurationen werden nicht gespeichert
1723 $this->setGlobalConfig('site
');
1725 if (isset($site['icon
'])) {
1726 $this->site['icon
'] = $site['icon
'];
1729 // Diese Keys gibt es nicht mehr und sind mittlerweile unterteilt in Sprachen
1731 $this->site['title
'],
1732 $this->site['robots
'],
1733 $this->site['keywords
'],
1734 $this->site['description
'],
1738 $this->site = Ego_System::cleanTypes($this->site);
1739 Ego_System::write_ini_file($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/conf.ini
', $this->site);
1741 if ($migrateLanguages) {
1745 // Globale Konfigurationen wieder laden
1746 $this->loadGlobalConfig(['site
']);
1757 function save_admin($admin=array())
1760 $original_admin = $this->admin;
1761 $this->admin = array_merge($this->admin, $admin);
1762 $reload_sitemap = false;
1764 // Globale Konfigurationen werden nicht gespeichert
1765 $this->setGlobalConfig('admin
');
1770 $enabled_types = array();
1771 if(is_array($this->admin['enabled_types
']))
1773 foreach ($this->admin['enabled_types
'] as $key => $value)
1777 $enabled_types[$key] = $value;
1781 $this->admin['enabled_types
'] = $enabled_types;
1783 // Schlagwortregister anlegen
1784 if ($this->admin['keyword_register_own_site
']) {
1785 if (!isset($this->admin['keywords
']['site
'])) {
1786 $this->admin['keywords
']['site
'] = $this->name;
1788 $reset = $this->admin['keywords
']['site
'] != $original_admin['keywords
']['site
'];
1789 if ($this->name !== $this->admin['keywords
']['site
']) {
1790 $origin_site = new Site($this->admin['keywords
']['site
']);
1791 $this->createKeywordRegister($origin_site, $reset);
1793 $this->createKeywordRegister(null, $reset);
1796 // Schlagwortregister mit DeepL übersetzen
1797 if (Ego_System::checkLicence($GLOBALS['egotec_conf
']['lib_dir
'] . 'translate
')) {
1798 $keyword_register_page = $this->getPages([
1799 'where
' => "type='_keywords/list
'"
1804 if ($keyword_register_page) {
1805 $language_link = [];
1806 foreach ($this->getLanguages() as $lang) {
1807 $language_link[$lang] = $lang == $this->site['default_language
']
1809 : ($this->admin['deepl_keywords
'] ? 2 : 0);
1812 serialize($keyword_register_page->extra['language_link
'] ?? []) != serialize($language_link)
1813 || $keyword_register_page->extra['language_standard
'] != $this->site['default_language
']
1815 $keyword_register_page->extra['language_link
'] = $language_link;
1816 $keyword_register_page->extra['language_standard
'] = $this->site['default_language
'];
1817 $keyword_register_page->update();
1820 foreach ($keyword_register_page->getDescendants([
1821 'where
' => "type = '_keywords/entry
'"
1826 serialize($keyword->extra['language_link
'] ?? []) != serialize($language_link)
1827 || $keyword->extra['language_standard
'] != $this->site['default_language
']
1829 $keyword->extra['language_link
'] = $language_link;
1830 $keyword->extra['language_standard
'] = $this->site['default_language
'];
1836 } elseif ($original_admin['keyword_register_own_site
'] && !$this->admin['keyword_register_own_site
']) {
1837 // wenn Neues Schlagwortregistermodul nicht mehr verwendet wird, dann Schlagwortregister komplett löschen
1838 $this->createKeywordRegister(null, true, true);
1841 // Seite mit Seitentyp "extern/link" anlegen, falls noch nicht vorhanden
1842 if ($this->admin['smarty
']['external_links
']) {
1843 if ($enabled_types['extern/link
']) {
1844 $extern_link = $this->getPages([
1845 'where
' => "type = 'extern/link
'"
1849 'only_active
' => false
1851 if (!$extern_link) {
1853 'name
' => $GLOBALS['auth
']->translate('Externe Links
'),
1854 'title
' => $GLOBALS['auth
']->translate('Externe Links
'),
1855 'type
' => 'extern/link
'
1857 $this->getRoot()->newChild($field);
1858 $reload_sitemap = true;
1863 // One-Way-Sync: die Datei "ignore_ids" automatisch löschen, wenn diese nicht mehr benötigt wird
1864 $clusters = Ego_System::getCluster($this);
1866 if (!empty($clusters)) {
1867 foreach ($clusters as $cluster) {
1868 if ($cluster['oneway
']) {
1875 foreach ($this->getLanguages() as $lang) {
1876 $ignore_file = $GLOBALS['egotec_conf
']['log_dir
'] . $this->name . '_
' . $lang . '/ignore_ids
';
1877 if (Ego_System::file_exists($ignore_file)) {
1878 @unlink($ignore_file);
1883 $this->admin = Ego_System::cleanTypes($this->admin);
1884 Ego_System::write_ini_file($GLOBALS['egotec_conf
']['site_dir
'].$this->name.DIRECTORY_SEPARATOR.'admin
'.DIRECTORY_SEPARATOR.'conf.ini
', $this->admin);
1885 Ego_System::clearTypeCache($this->name);
1887 // Globale Konfigurationen wieder laden
1888 $this->loadGlobalConfig(['admin
']);
1890 return $reload_sitemap;
1898 public function migrateLanguages() {
1901 'only_active
' => false,
1903 'deleted_or
' => '1=1
',
1907 $pages = $this->getPages([], $params);
1909 foreach ($pages as $page) {
1910 $currentLanguages = explode(',
', $this->site['languages
']);
1912 foreach ($currentLanguages as $currentLanguage) {
1913 $hasChanges = false;
1914 if ($languagePage = $page->getLanguagePage($currentLanguage, $params)) {
1915 if (!in_array($languagePage->extra['language_standard
'] ?: '', $currentLanguages)) {
1916 $languagePage->extra['language_standard
'] = $this->site['default_language
'];
1921 $languagesToDelete = [];
1922 $languageLink = !empty($languagePage->extra['language_link
']) ? $languagePage->extra['language_link
'] : [];
1924 foreach (array_keys($languageLink) as $lang) {
1925 if (!in_array($lang, explode(',
', $this->site['languages
']))) {
1926 $languagesToDelete[] = $lang;
1932 foreach ($languagesToDelete as $languageToDelete) {
1933 unset($languagePage->extra['language_link
'][$languageToDelete]);
1937 $languagePage->update([], true, true);
1952 private function createKeywordRegister($origin_site = null, $reset = false, $delete = false) {
1953 $root_page = $this->getRoot();
1955 // Überprüfen ob es bereits ein Schlagwortregister existiert
1956 $keyword_register_page = $this->getPages([
1957 'where
' => "type='_keywords/list
'"
1962 if ($keyword_register_page) {
1964 // Wenn das Schlagwortregister gewechselt wird, muss es neu angelegt werden
1965 $keyword_register_page->delete(false, false, true, [
1966 'where
' => "type = '_keywords/entry
'"
1968 $this->clearTrashcan([
1969 'where
' => "type = '_keywords/list
' OR type = '_keywords/entry
'"
1972 // Wenn ein Schlagwortregister existiert, dann nicht machen.
1977 if ($origin_site && !$delete) {
1978 // Schlagwortregisterstartseite klonen.
1979 $origin_page = $origin_site->getPages([
1980 'where
' => "type='_keywords/list
'"
1985 if (!$origin_page) { // Wenn beim Originalmandant kein Schlagwortregister existiert,
1986 $keyword_register_field = [
1987 'name
' => "Schlagwortregister",
1988 'title
' => "Schlagwortregister",
1989 'type
' => "_keywords/list",
1991 'nav_hide
' => 1+4+8 // Aus Navigation, Sitemap und Suche ausschließen.
1994 $origin_page = $origin_site->getRoot()->newChild($keyword_register_field); // dann dieses erstellen.
1995 } elseif ($origin_page->isClone()) { // Wenn der ausgewählte Mandant ebenfalls Klone nutzt,
1996 $origin_page = $origin_page->getCloneOriginal(); // so wird das Original geklont.
1998 $clone_page = $root_page->createClone($origin_page);
2000 $keyword_recursive = function($origin_page, $clone_page) use (&$keyword_recursive) {
2001 $origin_children = $origin_page->getChildren([
2002 'where
' => "type='_keywords/entry
'"
2007 foreach ($origin_children as $origin_child) {
2008 // Wenn das Schlagwort ein Klon ist, dann Klon von Original erstellen
2009 if ($origin_child->isClone()) {
2010 $clone_child = $clone_page->createClone($origin_child->getCloneOriginal());
2012 $clone_child = $clone_page->createClone($origin_child);
2014 $keyword_recursive($origin_child, $clone_child);
2017 $keyword_recursive($origin_page, $clone_page);
2018 } elseif (!$delete) {
2019 $keyword_register_field = [
2020 'name
' => "Schlagwortregister",
2021 'title
' => "Schlagwortregister",
2022 'type
' => "_keywords/list",
2024 'nav_hide
' => 1+4+8 // Aus Navigation, Sitemap und Suche ausschließen.
2026 $root_page->newChild($keyword_register_field);
2036 private function _sortTypes(&$arr) {
2038 foreach ($arr as $value) {
2039 $names[] = str_replace(
2040 ['ä
', 'ö
', 'ü
', 'ß
', '-
', ' '],
2041 ['ae
', 'oe
', 'ue
', 'ss
', '_
', '_
'],
2042 mb_strtolower($value['fullname
'])
2046 array_multisort($names, SORT_ASC, SORT_NATURAL, $arr);
2061 private function _getTypesOfDirectory($root_dir, $site_name, $type='', $fullname='', $depth=-1, $site_type='')
2063 $original_root_dir = $root_dir;
2065 file_exists($type_file = rtrim($root_dir.($type?$type.'/
':''), '/
').'/type.ini
')
2067 $root_dir != $GLOBALS['egotec_conf
']['site_dir
'].'_global/
'
2068 && file_exists($type_file = rtrim($GLOBALS['egotec_conf
']['site_dir
'].'_global/
'.($type?$type.'/
':''), '/
').'/type.ini
')
2069 && ($root_dir = $GLOBALS['egotec_conf
']['site_dir
'].'_global/
')
2072 $root_dir != $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'
2073 && file_exists($type_file = rtrim($GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'.($type?$type.'/
':''), '/
').'/type.ini
')
2074 && ($root_dir = $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
')
2077 $entry = parse_ini_file($type_file, true);
2079 $fullname = ($fullname?$fullname.'/
':'').$entry['title
'];
2082 $root_dir == $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'
2083 || $root_dir == $GLOBALS['egotec_conf
']['site_dir
'].'_global/
'
2091 case '_keywords/abbreviations
':
2092 case '_keywords/entry
':
2093 case '_keywords/list
':
2094 if ($this->admin['keyword_register_own_site
']) {
2097 $entry['hidden
'] = true;
2102 $parent_type = explode('/
', $type)[0];
2104 $root_dir == $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'
2105 && !$this->admin['enabled_types
'][$type]
2107 is_dir($GLOBALS['egotec_conf
']['site_dir
'] . "{$this->name}/$parent_type")
2108 || ($this->theme && is_dir($GLOBALS['egotec_conf
']['pub_dir
'] . "theme/{$this->theme}/site/$parent_type"))
2117 'name
' => $entry['title
'],
2118 'fullname
' => $fullname,
2119 'active
' => !$entry['inactive
'],
2120 'hidden
' => (bool) $entry['hidden
'],
2121 'global
' => $global,
2122 'system
' => $system,
2123 'inherit
' => $inherit,
2124 'blacklist
' => $entry['blacklist
'],
2125 'whitelist
' => $entry['whitelist
']
2128 // Blacklist - Wenn der Seitentyp vom Mandanten ausgeschlossen ist.
2129 $excluded_sites = explode(',
', $types['blacklist
']);
2131 if ($types['whitelist
']) {
2132 // Whitelist - Wenn der Seitentyp nur auf bestimmten Mandanten verfügbar ist.
2133 $included_sites = explode(',
', $types['whitelist
']);
2135 // Wenn sich der Seitentyp auf der Blacklist befindet, nicht anzeigen.
2136 if (is_array($excluded_sites) && in_array($site_name, $excluded_sites)) {
2140 // Wenn eine Whitelist vorhanden ist und der Seitentyp nicht auf dieser ist, nicht anzeigen.
2141 if (is_array($included_sites) && !empty($included_sites) && !in_array($site_name, $included_sites) ) {
2145 // Der Seitentyp wird nicht angezeigt
2146 if ($types['hidden
']) {
2150 foreach (array("icon","jquery") as $k)
2154 $types[$k] = $entry[$k];
2160 $get_types = function($this_dir) use ($site_name, $type, $fullname, $depth, $site_type, &$types) {
2161 $dir = dir($this_dir.($type?$type.'/
':''));
2162 while ($file = $dir->read())
2164 if ($file[0]!='.
' && is_dir($dir->path.$file) && ($file!='multimedia
' || $site_type=='media
'))
2166 $type_array = $this->_getTypesOfDirectory($this_dir, $site_name, ($type?$type.'/
':'').$file, $fullname, $depth+1, $site_type);
2169 $types['children
'][$type_array['type
']] = $type_array;
2175 if ($root_dir != $original_root_dir && is_dir($root_dir.($type?$type.'/
':'')))
2177 // Fallback Seitentypen aufnehmen
2178 $get_types($root_dir);
2180 if (is_dir($original_root_dir.($type?$type.'/
':'')))
2182 $get_types($original_root_dir);
2185 if ($types['children
'])
2187 $this->_sortTypes($types['children
']);
2199 private static function _getFlatTypes($tree)
2201 $types_array = array();
2204 foreach ($tree as $item)
2206 $types_array[] = $item;
2207 if ($item['children
'])
2209 $types_array = array_merge($types_array, Site::_getFlatTypes($item['children
']));
2213 return $types_array;
2230 function getTypes($flat=true,$params=array())
2232 $get = function() use ($flat, $params) {
2233 $cache_file = $GLOBALS['egotec_conf
']['cache_dir
'].$this->name.'/types
'.($flat ? 'Flat
' : '').md5(serialize(array($params)));
2235 Ego_System::file_exists($cache_file)
2236 && ($types = @unserialize(Ego_System::file_get_contents($cache_file)))
2241 if ($params['only_system
'])
2242 {//Systemseitentypen die NICHT durch Mandantenspezifische Seitentypen überschrieben werden
2243 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
', $this->name);
2244 $types1 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
'].'type/site/
', $this->name);
2245 $types2 = $this->theme ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
']."theme/{$this->theme}/site/", $this->name) : null;
2246 $types3 = $this->globalAllowed() ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].'_global/
', $this->name) : null;
2247 $types4 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
', $this->name, '', '', -1, $this->site['type
']);
2249 if (is_array($types)) {
2250 $result_types['children
'] = array_diff_key($types4['children
'],$types['children
']);
2252 $result_types = $types4;
2254 if (is_array($types3)) {
2255 $result_types['children
'] = array_diff_key($result_types['children
'],$types3['children
']);
2257 if (is_array($types2)) {
2258 $result_types['children
'] = array_diff_key($result_types['children
'], $types2['children
']);
2260 if (is_array($types1)) {
2261 $result_types['children
'] = array_merge($result_types['children
'],$types1['children
']);
2263 $this->_types = $result_types['children
']?$result_types['children
']:array();
2264 if ($params['include_theme
']) {
2265 $theme_types = $types2['children
']?$types2['children
']:array();
2266 $this->_types = array_merge($this->_types, $theme_types);
2268 if ($params['include_global
']) {
2269 $global_types = $types3['children
']?$types3['children
']:array();
2270 $this->_types = array_merge($this->_types, $global_types);
2272 } elseif ($params['only_global
'])
2274 if ($this->globalAllowed()) {
2275 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].'_global/
', $this->name);
2276 $this->_types = $types['children
']?$types['children
']:array();
2278 $this->_types = array();
2280 } elseif ($params['only_site
'])
2282 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
', $this->name);
2283 $this->_types = $types['children
']?$types['children
']:array();
2284 } elseif ($params['only_theme
'])
2286 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/site/
', $this->name);
2287 $this->_types = $types['children
']?$types['children
']:array();
2292 $types_filename=$GLOBALS['egotec_conf
']['cache_dir
'].$this->name.'/types.cache
';
2293 if (Ego_System::file_exists($types_filename))
2295 $this->_types = @unserialize(Ego_System::file_get_contents($types_filename));
2298 $types = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
', $this->name);
2299 $types1 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
'].'type/site/
', $this->name);
2300 $types2 = $this->theme ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['pub_dir
']."theme/{$this->theme}/site/", $this->name) : null;
2301 $types3 = $this->globalAllowed() ? $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['site_dir
'].'_global/
', $this->name) : null;
2302 $types4 = $this->_getTypesOfDirectory($GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
', $this->name, '', '', -1, $this->site['type
']);
2304 $this->_types = array_merge(
2305 $types4['children
']?$types4['children
']:array(),
2306 $types3['children
']?$types3['children
']:array(),
2307 $types2['children
']?$types2['children
']:array(),
2308 $types1['children
']?$types1['children
']:array(),
2309 $types['children
']?$types['children
']:array()
2311 Ego_System::file_put_contents($types_filename, serialize($this->_types));
2318 $md5 = md5(serialize($params));
2319 if (!$this->_typesFlat[$md5])
2321 $this->_typesFlat[$md5] = Site::_getFlatTypes($this->_types);
2323 $this->_sortTypes($this->_typesFlat[$md5]);
2324 Ego_System::file_put_contents($cache_file, serialize($this->_typesFlat[$md5]));
2325 return $this->_typesFlat[$md5];
2328 $this->_sortTypes($this->_types);
2329 Ego_System::file_put_contents($cache_file, serialize($this->_types));
2330 return $this->_types;
2336 // Kundenspezifischen Filter anwenden
2337 if (Ego_System::file_exists($system_path = $GLOBALS['egotec_conf
']['var_dir
'] . 'lib/site_get_types.php
')) {
2338 require_once $system_path;
2339 if (function_exists('site_get_types
')) {
2340 $types = site_get_types($this, $types, $flat, $params);
2352 function getKeywords($query = []) {
2355 $recursive = function($parent, $depth = 0) use (&$recursive, &$keywords, $query) {
2356 $query_where = "type = '_keywords/entry
'" . ($query['where
'] ? " AND ({$query['where
']})" : '');
2357 unset($query['where
']);
2358 $children = $parent->getChildren(array_merge(['where
' => $query_where], $query), ['sitemap
' => false]);
2359 foreach ($children as $child) {
2360 $child->field['depth
'] = $depth;
2361 $keywords[] = $child;
2362 $recursive($child, $depth + 1);
2366 $keyword_lists = $this->getPages(['where
' => 'type =
"_keywords/list"'], ['sitemap
' => false]);
2367 foreach ($keyword_lists as $keyword_list) {
2368 $recursive($keyword_list);
2380 function getTypeInfo($name) {
2381 if (!empty($this->_types)) {
2382 $parts = explode('/
', $name);
2383 $type = $this->_types[$parts[0]];
2385 foreach ($parts as $index => $part) {
2386 if ($type['type
'] == $name) {
2389 if (empty($child)) {
2392 $child .= '/
'.$part;
2394 if (!empty($type['children
']) && !empty($type['children
'][$child])) {
2395 $type = $type['children
'][$child];
2396 if ($type['type
'] == $name) {
2403 $types = $this->getTypes();
2404 foreach ($types as $type) {
2405 if ($type['type
'] == $name) {
2420 function getTypeFiles($type)
2423 $dirs_to_read = array(
2424 'site »
' => array(
2425 $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'.$type,
2426 $this->globalAllowed() ? $GLOBALS['egotec_conf
']['site_dir
'].'_global/
'.$type : '',
2427 $GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
'.$type,
2429 'site/admin »
' => array(
2430 $GLOBALS['egotec_conf
']['lib_dir
'].'type/site/
'.$type.'/admin
',
2431 $this->globalAllowed() ? $GLOBALS['egotec_conf
']['site_dir
'].'_global/
'.$type.'/admin
' : '',
2432 $GLOBALS['egotec_conf
']['site_dir
'].$this->name.'/
'.$type.'/admin
',
2434 'skin »
' => array(
2435 $GLOBALS['egotec_conf
']['bin_dir
'].'type/skin/
'.$type,
2436 $GLOBALS['egotec_conf
']['lib_dir
'].'type/skin/
'.$type,
2437 $this->globalAllowed() ? $GLOBALS['egotec_conf
']['skin_dir
'].'_global/
'.$type : '',
2438 $GLOBALS['egotec_conf
']['skin_dir
'].$this->skin.'/
'.$type
2441 if (!empty($this->theme)) {
2442 $dirs_to_read[$this->theme.' »
'] = array(
2443 $GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/site/
'.$type,
2444 $GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/skin/
'.$type,
2446 $dirs_to_read[$this->theme.'/admin »
'] = array(
2447 $GLOBALS['egotec_conf
']['pub_dir
'].'theme/
'.$this->theme.'/site/
'.$type.'/admin
'
2451 foreach ($dirs_to_read as $key => $dirs)
2453 foreach ($dirs as $d)
2459 while ($dir && false !== ($f = $dir->read()))
2461 if ($f[0]=='.
' || is_dir($dir->path.'/
'.$f)) continue;
2463 $files[$key.'/
'.$f] = $dir->path.'/
'.$f;
2480 function getSitemapRootIdArray($param = array(), $recalc = false, $user = true, $query = array())
2482 $key = md5($this->pageTable.json_encode($this->_param));
2484 // Aus dem User Objekt holen
2488 && is_array($GLOBALS['auth
']->user->extra['rootIdArray
'])
2489 && is_array($GLOBALS['auth
']->user->extra['rootIdArray
'][$key])
2491 return $GLOBALS['auth
']->user->extra['rootIdArray
'][$key];
2494 $where = $query['where
'];
2495 unset($query['where
']);
2496 $query = array_merge(array(
2497 'fields
' => $this->pageTable.'.id,
'. $this->pageTable.'_children.page_id, parent.type
',
2499 $this->pageTable.'_children ON
'.$this->pageTable.'_children.child=
'.$this->pageTable.'.id
',
2500 $this->pageTable.' AS parent ON
'.$this->pageTable.'_children.page_id=parent.id
'
2504 $query['where
'] = "parent.type != '_keywords/entry
'";
2506 $query['where
'] .= " AND ($where)";
2508 $all_parents = $this->getPages($query, $param);
2511 $parent_string = '';
2512 foreach ($all_parents as $page)
2514 if ($page->field['page_id
']) {
2515 $parent_string = $parent_string.',
'.$page->field['page_id
'];
2517 $id_string = $id_string.',
'.$page->field['id'];
2519 $parent_string = trim($parent_string,',
');
2520 $id_string = trim($id_string,',
');
2524 $parents = empty($parent_string) ? array() : explode(',
', $parent_string);
2525 $all_ids = empty($id_string) ? array() : explode(',
', $id_string);
2526 $parents = array_unique($parents);
2527 $all_ids = array_unique($all_ids);
2529 if ($param['deleted
'] == 1)
2530 { // Die Eltern aller gelöschten Seiten zurückgeben.
2532 } elseif (empty($parents))
2533 { // es gibt keine Eltern
2536 $with_permission = $all_ids; // Alle Eltern bestimmen, auf die der Benutzer eine Berechtigung besitzt.
2537 $ids = array(); // Alle Vorfahren zu den Eltern bestimmen, für die der Benutzer keine Berechtigung besitzt.
2538 $page = $this->getRoot(array('auth_or
' => '1=1
', 'deleted_or
' => '1=1
'));
2540 foreach ($parents as $id)
2542 if (!in_array($id, $with_permission))
2544 $ids = array_merge($ids,$page->_getAncestorsIds(
2545 $this->getPage($id, array('auth_or
' => '1=1
')),
2546 array('limit
' => 1, 'order
' => 'id'),
2547 array('auth_or
' => '1=1
', 'deleted
' => -1)
2554 if ($param['all_ids
']) {
2555 $ids = array_merge($ids, $all_ids);
2558 $ids = array_unique($ids);
2560 // Im User Objekt speichern
2561 if (!isset($param['deleted
']) && $user) {
2562 if (!is_array($GLOBALS['auth
']->user->extra['rootIdArray
'])) {
2563 $GLOBALS['auth
']->user->extra['rootIdArray
'] = array();
2565 $GLOBALS['auth
']->user->extra['rootIdArray
'][$key] = $ids;
2566 $GLOBALS['auth
']->user->update();
2581 function hasRight($right, $flag=false, $user_id = false, $rights = array())
2583 $rights = !empty($rights) ? $rights : $this->admin['right
'];
2584 if ($right == "desktop")
2591 $group = $rights[$right.'_group_
'.$i];
2596 $role = $rights[$right.'_role_
'.$i];
2597 if ($GLOBALS['auth
']->hasPermission($group, $role, $flag, $user_id))
2602 } while ($group!='');
2612 function hasPermission($right)
2614 $rights = $this->admin['right
'];
2616 if (is_array($rights))
2618 foreach ($rights as $r => $value)
2620 if (preg_match('/^
'.$right.'_group_(\d+)/i
', $r, $g))
2624 if (isset($rights[$right.'_role_
'.$group]) && !$this->isPermission($value, $rights[$right.'_role_
'.$group]))
2638 function isPermission($group, $role)
2640 if (empty($group) && empty($role))
2645 $db = new_db_connection(
2647 'fields
' => 'group_id
',
2648 'table
' => 'egotec_group
',
2649 'where
' => 'group_id =:group
',
2655 if($db->nextRecord())
2657 $db = new_db_connection(
2659 'fields
' => 'role_id
',
2660 'table
' => 'egotec_role
',
2661 'where
' => 'role_id =:role
',
2668 return $db->nextRecord();
2687 public function checkCondition($condition) {
2690 $sub_queries = preg_split('/\s+(and|or)\s+/si
', $condition);
2691 foreach ($sub_queries as $sub_query) {
2692 if (preg_match('/(!?(site|admin|conf|egotec_conf)\.([^ !=<>]+))(\s*(like|>=|<=|!=|=|>|<)\s*(.*?))?$/si
', trim($sub_query, '()
'), $matches)) {
2693 $param = $matches[1];
2694 $type = $matches[2];
2695 $operator = mb_strtolower($matches[5]);
2696 $check = trim($matches[6], '\
'"');
2697 $field = $matches[3];
2700 $exclude = $param[0] ==
'!';
2703 if ($type ==
'egotec_conf') {
2710 $valid = !isset($value);
2712 switch ($operator) {
2714 $valid = mb_strpos($check, $value) !==
false;
2717 $valid = $value >= $check;
2720 $valid = $value <= $check;
2723 $valid = $value != $check;
2726 $valid = $value == $check;
2729 $valid = $value > $check;
2732 $valid = $value < $check;
2735 $valid = isset($value);
2753 if ($this->hasRight($right, $flag))
2771 $group = $this->admin[
'right'][$right.
'_group_'.$i];
2775 $role = $this->admin[
'right'][$right.
'_role_'.$i];
2776 $rights[] = array(
'group' => $group,
'role' => $role);
2778 }
while ($group !=
'');
2792 $group = $this->admin[
'right'][$right.
'_group_'.$i];
2796 unset($this->admin[
'right'][$right.
'_group_'.$i]);
2797 unset($this->admin[
'right'][$right.
'_role_'.$i]);
2799 }
while ($group !=
'');
2803 foreach ($rights as $one_right) {
2804 $this->admin[
'right'][$right.
'_group_'.$i] = $one_right[
'group'];
2805 $this->admin[
'right'][$right.
'_role_'.$i] = $one_right[
'role'];
2815 $languages = $this->getLanguages();
2816 $name = $this->name;
2817 foreach($languages as $language)
2819 foreach($ids as $id)
2821 $_dbErase = new_db_connection();
2822 $_dbErase->delete(array(
'from' => $name.
'_'.$language,
'where' =>
'id = \''.$id.
'\''));
2823 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_fulltext',
'where' =>
'id = \''.$id.
'\''));
2824 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_rights',
'where' =>
'page_id = \''.$id.
'\''));
2825 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_users',
'where' =>
'page_id = \''.$id.
'\''));
2826 $_dbErase->delete(array(
'from' => $name.
'_'.$language.
'_v',
'where' =>
'id = \''.$id.
'\''));
2841 if (!$user_id && $GLOBALS[
'auth']->hasSuperuserPermission()) {
2845 $cache_key =
'rights' . md5(serialize([
2846 $GLOBALS[
'auth']->isNobody()
2848 : $GLOBALS[
'auth']->user->field[
'user_id'],
2853 $cache_entry = $this->getCacheEntry($cache_key);
2854 if (!$cache || $cache_entry ===
null) {
2857 'from' => $this->pageTable,
2858 'where' =>
'id='.$id
2860 $db = new_db_connection(
2861 $GLOBALS[
'auth']->getPageTableQuery(
2866 'user_id' => $user_id
2870 $cache_entry = (boolean) $db->nextRecord();
2871 $this->setCacheEntry($cache_key, $cache_entry);
2873 return $cache_entry;
2886 if (isset($this->_cachedMetaUrls[$path])) {
2887 return $this->_cachedMetaUrls[$path];
2889 $db = new_db_connection(array(
2890 'table' => $this->pageTable,
2892 'where' =>
'url = :url',
2897 return $this->_cachedMetaUrls[$path] = ((bool) $db->nextRecord());
2906 return $this->site[
'type'] ==
'content' && $GLOBALS[
'egotec_conf'][
'save_method'] ==
'public';
2916 return 'Site('.$this->name.
'.'.$this->language.
')';
2926 if ($this->_cache) {
2929 $this->_cache = clone $this->_cache;
2943 $need_space = 2*1024*1024*1024;
2944 $dir_name = $GLOBALS[
'egotec_conf'][
'backup_dir'].
'site/'.$this->name;
2949 $dir = dir($GLOBALS[
'egotec_conf'][
'backup_dir'].
'site/'.$this->name);
2950 while (
false !== ($f = $dir->read()))
2952 if (strrpos($f,
'.tar.gz')===strlen($f)-7)
2954 $time = filemtime($dir_name.
'/'.$f);
2955 $times[$time] = filesize($dir_name.
'/'.$f);
2956 $newest = $time > $newest ? $time : $newest;
2961 if (
sizeof($times)>0)
2963 $need_space = intval($times[$newest]) *3;
2971 $dir_name = $GLOBALS[
'egotec_conf'][
'backup_dir'];
2979 if ($need_space < disk_free_space($dir_name))
2995 return $this->_cache;
3005 $expire = (int) $this->admin[
'cache_expire_time'];
3019 if ($_REQUEST[
'preview']) {
3022 if ($_REQUEST[
'c_date']) {
3023 $key .=
'C' . md5($_REQUEST[
'c_date']);
3025 return $this->_cache->get($key);
3037 if ($_REQUEST[
'preview']) {
3040 if ($_REQUEST[
'c_date']) {
3041 $key .=
'C' . md5($_REQUEST[
'c_date']);
3043 $this->_cache->set($key, $value);
3051 return $this->_cache->getLastChanged();
3063 $auth = clone $GLOBALS[
'auth'];
3064 $smarty = clone $GLOBALS[
'smarty'];
3065 $active_cells = $GLOBALS[
'active_cells'] = explode(
',', $GLOBALS[
'auth']->user->extra[$this->name.
'_desktop_cells']);
3068 $desklet_default_content =
'<p class="refresh"><a href="javascript:void(0)" onclick="egoDesktop.refresh()">'
3069 .$GLOBALS[
'auth']->translate(
'Laden Sie den Desktop neu, um den Inhalt dieses Desklets anzuzeigen.')
3071 $smarty->assign(
'desklet_default_content', $desklet_default_content);
3073 $desktop_dir = dir($GLOBALS[
'egotec_conf'][
'lib_dir'].
'desktop/'.($trashcan ?
'trashcan/' :
''));
3074 while ($desktop_file = $desktop_dir->read()) {
3076 is_file($desktop_dir->path.$desktop_file)
3077 && substr($desktop_file, strlen($desktop_file)-4) ==
'.php'
3078 && file_exists($desktop_dir->path.$desktop_file)
3080 require($desktop_dir->path.$desktop_file);
3083 $desktop_dir->close();
3085 if ($this->globalAllowed() && file_exists($GLOBALS[
'egotec_conf'][
'site_dir'].
'_global/admin/desktop/')) {
3086 $desktop_dir = dir($GLOBALS[
'egotec_conf'][
'site_dir'].
'_global/admin/desktop/');
3087 while ($desktop_file = $desktop_dir->read()) {
3089 is_file($desktop_dir->path.$desktop_file)
3090 && substr($desktop_file, strlen($desktop_file)-4) ==
'.php'
3091 && file_exists($desktop_dir->path.$desktop_file)
3093 require($desktop_dir->path.$desktop_file);
3096 $desktop_dir->close();
3098 if (file_exists($GLOBALS[
'egotec_conf'][
'site_dir'].$this->name.
'/admin/desktop/')) {
3099 $desktop_dir = dir($GLOBALS[
'egotec_conf'][
'site_dir'].$this->name.
'/admin/desktop/');
3100 while ($desktop_file = $desktop_dir->read()) {
3102 is_file($desktop_dir->path.$desktop_file)
3103 && substr($desktop_file, strlen($desktop_file)-4) ==
'.php'
3104 && file_exists($desktop_dir->path.$desktop_file)
3106 require($desktop_dir->path.$desktop_file);
3109 $desktop_dir->close();
3111 foreach ($this->getTypes() as $type) {
3112 $desktop_file = $GLOBALS[
'egotec_conf'][
'site_dir'].$this->name.
'/'.$type[
'type'].
'/admin/desktop.php';
3113 if ($this->globalAllowed() && !file_exists($desktop_file)) {
3114 $desktop_file = $GLOBALS[
'egotec_conf'][
'site_dir'].
'_global/'.$type[
'type'].
'/admin/desktop.php';
3116 if (!file_exists($desktop_file)) {
3117 $desktop_file = $GLOBALS[
'egotec_conf'][
'lib_dir'].
'type/site/'.$type[
'type'].
'/admin/desktop.php';
3119 if (file_exists($desktop_file)) {
3120 require($desktop_file);
3124 foreach ($GLOBALS[
'cells'] as $index => &$cell_item) {
3125 if (is_array($cell_item)) {
3126 foreach ($cell_item as &$cell) {
3127 if ($rights && isset($site->admin[
'desklets'][$cell[
'id']])) {
3128 $rights = explode(
';', $site->admin[
'desklets'][$cell[
'id']]);
3129 if (
sizeof($rights) > 0) {
3131 foreach ($rights as $right) {
3132 $group_role = explode(
',', $right);
3134 empty($group_role[0])
3135 || empty($group_role[1])
3136 ||$GLOBALS[
'auth']->hasPermission($group_role[0], $group_role[1])
3142 unset($GLOBALS[
'cells'][$index]);
3147 $cell[
'visible'] = ($cell[
'permanent'] || in_array($this->name.
'_'.$cell[
'id'], $active_cells));
3148 $cell[
'permanent'] = !empty($cell[
'permanent']);
3151 if (trim($cell[
'body']) ==
'') {
3152 $cell[
'body'] = $desklet_default_content;
3158 return $GLOBALS[
'cells'] = array_values($GLOBALS[
'cells']);
3168 if ($custom_crs = $this->getSiteFile(
'admin/crs.json')) {
3181 if ($file = $this->getSiteFile(
'admin/uploader.php')) {
3182 require_once($file);
3183 if (function_exists(
'getUploaderPage')) {
3184 if (!$page && $GLOBALS[
'page']) {
3185 $page = $GLOBALS[
'page'];
3187 return getUploaderPage($this, $page);
3189 } elseif ($this->hasMediaSite()) {
3190 $media_site = $this->getMediaSite();
3191 $media_site->addParam(array(
3194 $_users_page = $media_site->getPages(
3195 array(
'where' =>
'name=\'_users\''),
3199 'only_active' =>
false
3204 $media_root_page = $media_site->getRoot(array(
'auth_or' =>
'1=1'));
3205 if (!$media_root_page) {
3208 $_users_page = $media_root_page->newChild(array(
3210 'title' =>
'_users',
3211 'type' =>
'multimedia/category',
3216 $user_page = $_users_page->getChildren(
3218 'where' =>
'name=:name',
3220 'name' => $GLOBALS[
'auth']->user->field[
'username']
3226 'only_active' =>
false
3229 if (!$user_page && !empty($GLOBALS[
'auth']->user->field[
'username']))
3231 $user_page = $_users_page->newChild(array(
3232 'name' => $GLOBALS[
'auth']->user->field[
'username'],
3233 'title' => $GLOBALS[
'auth']->user->field[
'username'],
3234 'type' =>
'multimedia/category',
3237 $user_page->setUsersArray(array(
3238 'edit' => array(array(
'user_id' => $GLOBALS[
'auth']->getId())),
3239 'child' => array(array(
'user_id' => $GLOBALS[
'auth']->getId())),
3240 'remove' => array(array(
'user_id' => $GLOBALS[
'auth']->getId()))
3244 $rights = $user_page->getRightsArray();
3245 foreach (array(
'edit',
'child',
'remove') as $perm) {
3247 empty($rights[$perm])
3248 || in_array(
'*', array($rights[$perm][0][
'group_id'], $rights[$perm][0][
'role_id']))
3250 $rights[$perm] = array(
3252 'group_id' => $GLOBALS[
'egotec_conf'][
'superuser'][
'group'],
3253 'role_id' => $GLOBALS[
'egotec_conf'][
'superuser'][
'role']
3258 $user_page->setRightsArray($rights);
3271 $deleted = $this->getPages(array(), array(
3275 return (
bool) $deleted->nextPage();
3286 $original_where =
'';
3287 if (empty($query[
'where'])) {
3288 $query[
'where'] =
'1=1';
3290 $original_where = $query[
'where'];
3292 if (count($cluster_list) > 0) {
3294 foreach ($cluster_list as $cluster) {
3295 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.'.$this->name.
'_'.$this->language.
'.'.$cluster[
'id'].
'.up.date';
3296 if (file_exists($log_filename)) {
3297 $time[] = file_get_contents($log_filename);
3301 if (count($time) > 0) {
3302 $query[
'where'].=
" AND ".$this->pageTable.
".m_date<'{$time[0]}'";
3305 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.'.$this->name.
'_'.$this->language.
'.date';
3306 if (!file_exists($log_filename)) {
3307 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.date';
3309 if (file_exists($log_filename)) {
3310 $live_date = file_get_contents($log_filename);
3311 $query[
'where'].=
" AND ".$this->pageTable.
".m_date<'$live_date'";
3315 $del_pages = $this->getPages($query, array(
3318 'only_active' =>
false,
3320 'rights' => array(
'delete')
3322 while ($page = $del_pages->nextPage()) {
3326 $query[
'where'] = $original_where;
3327 $rest = $this->getPages($query, array(
3330 'only_active' =>
false,
3333 $msg = $GLOBALS[
'auth']->translate(
"Der Papierkorb wurde geleert.");
3334 $z = $rest->numRecords();
3336 $msg.=
'<p class="warning">'
3337 . $GLOBALS[
'auth']->translate(
"%z Seiten können wegen mangelnder Berechtigung nicht gelöscht werden oder werden beim nächsten Liveabgleich gelöscht.", [
3351 $cache_key =
'pageClasses';
3352 if (empty($this->_classes)) {
3353 $this->_classes = $this->getCacheEntry($cache_key);
3355 if ($this->_classes ===
null || !isset($this->_classes[$type])) {
3356 if (!is_array($this->_classes)) {
3357 $this->_classes = array();
3359 $this->_classes[$type] = $this->_getPageClass($type);
3360 $this->setCacheEntry($cache_key, $this->_classes);
3363 if (!class_exists($this->_classes[$type][
'class'],
false) && !empty($this->_classes[$type][
'file'])) {
3364 $file = $GLOBALS[
'egotec_conf'][
'egotec_dir'].ltrim($this->_classes[$type][
'file'], DIRECTORY_SEPARATOR);
3365 require_once($file);
3367 return $this->_classes[$type][
'class'];
3377 private function _getPageClass($type) {
3378 $prefix =
'Page' . ($this->conf[
'page'][
'prefix'] ??
'');
3382 foreach (explode(
'/', $type) as $part) {
3383 $class .= ucfirst($part);
3387 if ($file = $this->getSiteFile($type.
'/page.php', array(
'module'),
true,
true)) {
3388 return array(
'file' => $file,
'class' => $this->conf[
'page'][
'extension'][$class] ?? $class);
3392 $class =
'Page' . ucfirst($this->name);
3393 if ($file = $this->getSiteFile(
'page.php', array(
'module',
'global',
'parent_theme'),
true,
true)) {
3394 return array(
'file' => $file,
'class' => $class);
3399 $class =
'Page' . implode(
'', array_map(
'ucfirst', explode(
'-', $this->theme)));
3400 if ($file = $this->getSiteFile(
'page.php', array(
'custom',
'global',
'system',
'module',
'parent_custom'),
true,
true)) {
3401 return array(
'file' => $file,
'class' => $class);
3406 $class =
'PageGlobal';
3407 if ($file = $this->getSiteFile(
'page.php', array(
'custom',
'system',
'module'),
true,
true)) {
3408 return array(
'file' => $file,
'class' => $class);
3412 return array(
'file' =>
'',
'class' =>
'Page');
3425 $this->removeLinks();
3429 'only_active' =>
false,
3434 $site = clone $this;
3435 foreach ($this->getLanguages() as $lang) {
3436 $site->setLanguage($lang);
3437 foreach ($site->getPages(array(), $params) as $page) {
3441 $page->updateLinks(
false,
true);
3457 if($this->site[
'type'] !=
'media') {
3458 echo
"Is not a media site\n";
3462 if ($GLOBALS[
'egotec_conf'][
'openoffice'][
'active'] != 1) {
3463 echo
"index is not active\n";
3467 require_once(
'openoffice/openoffice.php');
3470 $old_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name;
3471 $new_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
"_".$this->language;
3486 $addFile =
function($path, $entry) use (&$files) {
3487 if($entry[0] ===
'.') {
3491 if(preg_match(
'/_/', $entry)) {
3494 $files[$entry] = filemtime($path.
'/'.$entry).
' '.$entry;
3497 $path = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->name;
3506 while (
false !== ($entry = $d->read())) {
3507 if (!is_dir($d->path.
'/'.$entry)) {
3508 $addFile($d->path, $entry);
3515 $d = dir($d->path.
'/'.$this->language);
3516 while (
false !== ($_entry = $d->read())) {
3517 $files[$this->language.
'/'.$_entry] = filemtime($d->path.
'/'.$_entry).
' '.$this->language.
'/'.$_entry;
3523 $startTime = time();
3526 foreach($files as $entry => $fileTime) {
3527 if($resume && $fileTime <= $position) {
3531 $timeRound = strtok($fileTime,
' ');
3535 echo
"[Fs ] $entry ".date(
"Y-m-d H:i:s", $timeRound).
"\n";
3539 $id = preg_replace(
'/^[^\d]+/',
'', $entry);
3540 if (!is_numeric($id)) {
3544 $page = $this->getPage($id, array(
'inactive' => 1,
'auth_or' =>
'1=1'));
3546 echo
"[F] $id not found in DB\n";
3550 echo
"[DS ] ".$entry.
" ".date(
"Y-m-d H:i:s", $timeRound).
"\n";
3552 $extra = $page->extra;
3553 $mime_type = $extra[
'mime_type'];
3554 $file_ext = $extra[
'image_type'];
3556 if (!empty($mime_type)) {
3557 if (!empty($file_ext)) {
3564 # nur Dateien vom Type ^application oder text... versuchen zu importieren
3565 if (!preg_match(
'/^application|text/', $mime_type)) {
3569 if (empty($file_ext)) {
3570 if (!$GLOBALS[
'mime2ext']) {
3574 $file_ext = $GLOBALS[
'mime2ext'][$mime_type];
3577 $content = convert_content($path .
'/' . $entry, $file_ext, $mime_type);
3578 if(!empty($content)) {
3582 $page->update(array(
3587 }
catch(Exception $e) {
3588 echo
"f] " . $e->getMessage() .
"\n";
3589 Ego_System::file_put_contents($new_file.
"/index_error.log", date(
"Y-m-d H:i:s").
" Datei: $entry (".$page->field[
"name"].
"), Datenbankupdate fehlgeschlagen\n", FILE_APPEND);
3592 Ego_System::file_put_contents($new_file.
"/index.log", date(
"Y-m-d H:i:s").
" $entry (".$page->field[
"name"].
".".$extra[
'image_type'].
") [".strlen($content).
"]\n", FILE_APPEND);
3597 echo
"[FCf] $entry (mime_type: $mime_type)\n";
3598 Ego_System::file_put_contents($new_file.
"/index_error.log", date(
"Y-m-d H:i:s").
" Datei: $entry (".$page->field[
"name"].
".".$extra[
'image_type'].
"), konnte nicht konvertiert werden\n", FILE_APPEND);
3605 if ($timeout && time() - $startTime > $timeout) {
3610 $this->clearCache();
3611 echo $this->name.
"_".$this->language.
" Cache cleared.\n";
3621 $db = new_db_connection();
3624 'table' =>
'egotec_links',
3625 'where' =>
'src_site = :site AND src_lang = :lang',
3627 'site' => $this->name,
3633 'table' =>
'egotec_links',
3634 'where' =>
'src_site = :site',
3636 'site' => $this->name
3649 $db = new_db_connection();
3653 'table' =>
'egotec_url',
3654 'where' =>
'site = :site AND lang = :lang',
3656 'site' => $this->name,
3662 'table' =>
'egotec_url',
3663 'where' =>
'site = :site',
3665 'site' => $this->name
3682 $this->removeUrls($this->language);
3684 if ($root = $this->getRoot(array(
3687 'only_active' =>
false
3689 $root->updateUrls($verbose,
null,
true);
3690 unset($GLOBALS[
'__page_update_urls_stack']);
3691 $this->clearCache();
3701 if ($this->site[
'type'] ==
'media') {
3702 return $this->getPages(array(
3703 'join' => array(
'egotec_links ON ('
3704 .
' egotec_links.dest_site = :site'
3705 .
' AND egotec_links.dest_lang = :lang'
3706 .
' AND id = egotec_links.dest_id)'),
3707 'where' =>
"egotec_links.src_id IS NULL"
3709 .
" AND type IN ('multimedia/file', 'multimedia/image')",
3711 'site' => $this->name,
3712 'lang' => $this->language
3717 'only_active' =>
false,
3720 } elseif ($media = $this->getMediaSite()) {
3721 return $media->getUnusedPages();
3734 if ($GLOBALS[
'auth']->isNobody()) {
3740 if (isset($query[
'limit'])) {
3741 [$start, $max] = explode(
',', $query[
'limit']);
3742 $start = trim($start);
3744 unset($query[
'limit']);
3750 $query[
'where'] =
"({$this->pageTable}_v.c_date > {$this->pageTable}.c_date AND {$this->pageTable}_v.c_user = :this_user)"
3751 . ($query[
'where'] ?
" AND {$query['where']}" :
'');
3752 $query[
'bind'] = array_merge($query[
'bind'] ?? [], [
3753 'this_user' => $GLOBALS[
'auth']->user->field[
'user_id']
3755 $query[
'fields'] =
"{$this->pageTable}.*, {$this->pageTable}_v.id, {$this->pageTable}_v.c_user, MAX({$this->pageTable}_v.c_date) AS v_date"
3756 . ($query[
'fields'] ?
", {$query['fields']}" :
'');
3757 $query[
'inner'] = array_merge($query[
'inner'] ?? [], [
3758 "{$this->pageTable}_v ON {$this->pageTable}.id = {$this->pageTable}_v.id"
3760 $query[
'group'] =
"{$this->pageTable}_v.id";
3761 $query[
'order'] = $query[
'order'] ? $query[
'order'] :
"v_date DESC";
3763 $param = array_merge([
3766 'only_active' =>
false
3771 foreach ($this->getPages($query, $param) as $page) {
3772 if ($page->isPublicSave()) {
3773 if ($num >= $start) {
3776 if ($max > 0 && ($num + 1) == $max) {
3813 if ($media = $this->getMediaSite()) {
3814 $pages = $media->getPages([
3815 'fields' => $media->pageTable.
'.*, egotec_links.src_id',
3817 'egotec_links ON ' . $media->pageTable .
'.id = egotec_links.dest_id'
3819 'where' =>
'src_site = :src_site AND src_lang = :src_lang AND dest_site = :dest_site',
3821 'src_site' => $this->name,
3822 'src_lang' => $this->language,
3823 'dest_site' => $media->name
3826 foreach ($pages as $page) {
3827 if ($page->extra[
'copyright'] !==
null) {
3832 } elseif (($m + 1) > $limit) {
3838 $key = md5(mb_strtolower($page->extra[
'copyright']));
3840 if (!isset($copyrights[$key])) {
3841 $copyrights[$key] = [
3842 'title' => $page->extra[
'copyright'],
3847 $identity = $page->getIdentity();
3848 if (!isset($copyrights[$key][
'pages'][$identity])) {
3849 $copyrights[$key][
'pages'][$identity] = [
3850 'page' => $page->getIdentity(),
3856 if ($link = $this->getPage($page->field[
'src_id'])) {
3857 $copyrights[$key][
'pages'][$identity][
'linked'][] = [
3858 'name' => $link->field[
'name'],
3859 'url' => $link->getUrl()
3869 if ($this->admin[
'mediapool'][
'active']) {
3870 $pages = $this->getPages();
3871 foreach ($pages as $page) {
3872 foreach ($page->getMediapool()->list() as $item) {
3873 if ($item[
'copyright']) {
3878 } elseif (($m + 1) > $limit) {
3884 $key = md5(mb_strtolower($item[
'copyright']));
3886 if (!isset($copyrights[$key])) {
3887 $copyrights[$key] = [
3888 'title' => $item[
'copyright'],
3893 $identity = $item[
'name'];
3894 if (!isset($copyrights[$key][
'pages'][$identity])) {
3895 $copyrights[$key][
'pages'][$identity] = [
3896 'page' => $page->getIdentity(),
3902 $copyrights[$key][
'pages'][$identity][
'linked'][] = [
3903 'name' => $page->field[
'name'],
3904 'url' => $page->getUrl()
3913 usort($copyrights,
function($a, $b) {
3914 return strcmp($a[
'title'], $b[
'title']);
3916 return array_values($copyrights);
3931 public function getTemplate($mobile =
false, $name =
'index', $dir =
'', $variant =
'', $suffix =
'', $fallback =
true) {
3932 if (empty($suffix)) {
3933 $suffix = $_SERVER[
'REQUEST_SUFFIX'];
3935 $key =
'template'.md5(serialize(array($this->skin, $mobile, $name, $dir, $variant, $suffix, $fallback)));
3936 $template = $this->getCacheEntry($key);
3937 if ($template ===
null) {
3940 if (!empty($variant)) {
3941 $variant =
".{$variant}";
3943 if ($suffix ==
'.htm') {
3947 $suffix = !in_array($suffix, array(
'.html',
'.php')) ? $suffix :
'';
3948 if ($suffix && $variant == $suffix) {
3951 $base_dir = $dir ? explode(
'/', $dir)[0] :
'';
3952 foreach (array(
'.tpl',
'.html') as $file_suffix) {
3953 if (!empty($template)) {
3956 $file = $mobile ? $name . $variant .
'.mobile' . $suffix . $file_suffix : $name . $variant . $suffix . $file_suffix;
3962 && ($template_file = $this->getSkinFile($base_dir .
'/' . $name . $variant . $file_suffix))
3964 $template = $template_file;
3966 ($dir && ($template_file = $this->getSkinFile($dir .
'/' . $file)))
3967 || ($template_file = $this->getSkinFile($file))
3969 $template = $template_file;
3970 } elseif ($suffix !=
'') {
3971 $file = $mobile ? $name . $variant .
'.mobile' . $suffix . $file_suffix : $name . $variant . $suffix . $file_suffix;
3973 ($dir && ($template_file = $this->getSkinFile($dir .
'/' . $file)))
3974 || ($template_file = $this->getSkinFile($file))
3976 $template = $template_file;
3981 if (empty($template)) {
3984 $template = $this->getTemplate(
false, $name, $dir, $variant, $suffix, $fallback);
3985 } elseif ($variant !=
'' && $suffix !=
'') {
3987 $template = $this->getTemplate(
false, $name, $dir,
'', $suffix, $fallback);
3988 } elseif ($fallback) {
3990 if ($suffix !=
'') {
3992 return $this->getTemplate($mobile, $name, $dir, $variant,
'.html');
3993 } elseif ($variant !=
'') {
3995 return $this->getTemplate($mobile, $name, $dir,
'',
'.html');
3996 } elseif ($name ==
'body') {
3997 $template_file = $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'type/skin/page/body.html';
3999 $template = $template_file;
4004 if (empty($template) && $fallback) {
4007 $this->setCacheEntry($key, $template);
4022 public function getSkinFile($path, $skip = array(
'module'), $url =
false, $relative =
false) {
4023 if (!$this->globalAllowed() && !in_array(
'global', $skip)) {
4040 public function getSiteFile($path, $skip = array(
'module'), $url =
false, $relative =
false) {
4042 !$this->globalAllowed() && !in_array(
'global', $skip)
4061 return $this->getSkinFile($path, array(
'module'),
true);
4063 return $this->getSiteFile($path, array(
'module'),
true);
4080 public function getInheritedFile($mode, $type, $path, $skip = array(
'module'), $url =
false, $relative =
false) {
4081 $parts = explode(
'/', $type);
4082 while (
sizeof($parts) > 0) {
4083 if (($result =
self::{
'get' . ucfirst($mode) .
'File'}(implode(
'/', $parts) .
'/' . $path, $skip, $url, $relative)) !==
'') {
4099 $key =
'variant'.md5(serialize(array($path, $skip)));
4100 $variants = $this->getCacheEntry($key);
4101 if ($variants ===
null) {
4103 $this->setCacheEntry($key, $variants);
4117 $key =
'layout'.md5(serialize(array($path, $skip)));
4118 $layouts = $this->getCacheEntry($key);
4119 if ($layouts ===
null) {
4120 $layouts = array_merge(
4122 $path !=
'' ?
Ego_System::getFiles(
'skin', $this->skin, $path.
'/layouts/*.tpl', $skip, $this->theme,
false,
false) : array()
4124 $layouts = array(
'default' => $layouts[
'_empty']) + $layouts;
4126 $conf = $this->conf[
'layouts'];
4128 if (!empty($conf)) {
4129 foreach ($layouts as $layout => $title) {
4130 if (!empty($conf[$layout][
'title'])) {
4131 $layouts[$layout] = $GLOBALS[
'auth']->translate($conf[$layout][
'title']);
4135 unset($layouts[
'_empty']);
4136 $this->setCacheEntry($key, $layouts);
4149 $key =
'block'.md5(serialize(array($path, $skip)));
4150 $blocks = $this->getCacheEntry($key);
4151 if ($blocks ===
null) {
4152 $blocks = array_merge(
4154 $path !=
'' ?
Ego_System::getFiles(
'skin', $this->skin, $path.
'/blocks/*.tpl', $skip, $this->theme,
false,
false) : array()
4156 $this->setCacheEntry($key, $blocks);
4169 $GLOBALS[
'egotec_conf'][
'blocks'][
'design_disabled'],
4170 $this->admin[
'blocks'][
'design_disabled']
4172 if (!empty($conf)) {
4173 $disabled_blocks = explode(
',', $conf);
4175 foreach ($disabled_blocks as $disabled_block) {
4176 [$name, $key] = explode(
'/', $disabled_block);
4177 if (!empty($key) && $key !== md5(trim(implode(
' ', [$this->theme, $this->skin])))) {
4180 if ($name === $block) {
4196 $templates = array();
4197 $template_dirs = array(
4198 array($GLOBALS[
'egotec_conf'][
'skin_dir'].$this->skin.
'/blocks/', $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->skin.
'/blocks/'),
4199 $this->globalAllowed() ? array($GLOBALS[
'egotec_conf'][
'skin_dir'].
'_global/blocks/', $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/_global/blocks/') : array()
4202 $template_dirs[] = array($GLOBALS[
'egotec_conf'][
'pub_dir'].
"theme/{$this->theme}/skin/blocks/", $GLOBALS[
'egotec_conf'][
'url_dir'].
"pub/theme/{$this->theme}/skin/blocks/");
4204 foreach ($template_dirs as $template_dir) {
4207 $dir = dir($template_dir[0]);
4208 while (($file = $dir->read()) !==
false) {
4210 !in_array($file, array(
'.',
'..'))
4211 && preg_match(
'/^(.*?)\.html$/i', $file, $match)
4217 $url = $template_dir[1].$file;
4224 $description = preg_replace(
'/(\r\n|\r|\n|\t)/msi',
'', strip_tags($description));
4225 $description = str_replace(
"'",
"\'", $description);
4228 $templates[] = array(
4231 'description' => $description
4249 !$GLOBALS[
'egotec_conf'][
'liveserver']
4250 && $this->admin[
'live'][
'login']
4251 && $this->admin[
'live'][
'password']
4263 if (!is_numeric($weight)) {
4268 $default_counts = array(
4277 foreach ($default_counts as $key => $default_value) {
4278 $value = (!empty($this->admin[
'count'][$key]) ? (int)$this->admin[
'count'][$key] : $default_value) + $weight;
4279 $counts[$key] = $value > 0 ? $value : 1;
4292 require_once
'stats/Ego_Piwik.php';
4293 $piwik =
new Ego_Piwik();
4294 $piwiksites = $this->getPages(array(
4295 'where' =>
"extra LIKE '%s:5:\"piwik\"%'"
4297 $hosts = $this->getVirtualHosts();
4299 if ($piwiksites->numRecords()) {
4300 foreach ($piwiksites as $psite) {
4301 if ($psite->extra[
'piwik']) {
4302 if ($psite->extra[
'piwik'][
'auth_token'] ==
'undefined' && $psite->extra[
'piwik'][
'red_id'] ==
'undefined') {
4303 $piwikdata = $psite->addPiwikSite();
4304 $extra = $psite->extra;
4305 $extra[
'piwik'] = $piwikdata;
4306 $psite->updateExtra($extra);
4308 if (!$psite->extra[
'piwik'][
'live_id'] && $this->hasLiveserver()) {
4309 $piwikdata = $piwik->createWebsite($psite,
true);
4310 $extra = $psite->extra;
4311 $extra[
'piwik'] = $piwikdata;
4312 $psite->updateExtra($extra);
4316 $language_hosts = $hosts;
4317 if (is_array($psite->extra[
'language_link']) && $psite->extra[
'language_link'][$this->language]) {
4318 foreach ($psite->extra[
'language_link'] as $lang => $flag) {
4319 if ($flag && $lang != $this->language) {
4322 $lang_site =
new Site($this->name, $lang);
4324 if ($lang == $psite->extra[
'language_standard']) {
4325 $language_hosts = array_merge($lang_site->getVirtualHosts(), $language_hosts);
4327 $language_hosts = array_merge($language_hosts, $lang_site->getVirtualHosts());
4336 $piwik->updateSiteURLs($psite->extra[
'piwik'][
'red_id'], $language_hosts, $psite->extra[
'piwik'][
'live_id'], $this);
4341 $new_psite = $this->getRoot();
4342 if ($new_psite && !$new_psite->extra[
'do_not_track']) {
4343 $piwikdata = $new_psite->addPiwikSite();
4344 $extra = $new_psite->extra;
4345 $extra[
'piwik'] = $piwikdata;
4346 $new_psite->updateExtra($extra);
4359 if ($fallback && !$suffix && $GLOBALS[
'egotec_conf'][
'liveserver']) {
4360 $admin_text = $this->getAdminText(
'_live',
false);
4361 return $admin_text ? $admin_text : $this->getAdminText(
'',
false);
4363 if (!empty($this->admin[
'administration'][
'admin_text'.$suffix])) {
4365 'text' => $GLOBALS[
'auth']->translate($this->admin[
'administration'][
'admin_text'.$suffix]),
4366 'url' => (
string) $this->admin[
'administration'][
'admin_url'.$suffix]
4368 } elseif (!empty($GLOBALS[
'egotec_conf'][
'admin_text'.$suffix])) {
4370 'text' => $GLOBALS[
'auth']->translate($GLOBALS[
'egotec_conf'][
'admin_text'.$suffix]),
4371 'url' => (
string) $GLOBALS[
'egotec_conf'][
'admin_url'.$suffix]
4384 return $this->site[
'type'] ==
'content'
4385 && $this->admin[
'frontend_admin']
4390 && !$GLOBALS[
'auth']->isNobody()
4401 $db = new_db_connection();
4402 if ( in_array(get_class($db), [
"Ego_Sql_mssql",
"Ego_Sql_oci",
"Ego_Sql_sqlite"]) ) {
4407 foreach ($this->getLanguages() as $lang) {
4408 $pageTable = $this->name.
'_'.$lang;
4410 array(
'_v',
'id', $pageTable,
'id'),
4411 array(
'_children',
'page_id', $pageTable,
'id'),
4412 array(
'_rights',
'page_id', $pageTable,
'id'),
4413 array(
'_users',
'page_id', $pageTable,
'id'),
4414 array(
'_rights',
'group_id',
'egotec_group',
'group_id'),
4415 array(
'_rights',
'role_id',
'egotec_role',
'role_id'),
4416 array(
'_users',
'user_id',
'egotec_user',
'user_id')
4419 'table' =>
"{$pageTable}{$v[0]} AS t",
4421 'join' => array(
"{$v[2]} ON t.{$v[1]} = {$v[2]}.{$v[3]}"),
4422 'where' => (in_array($v[1], array(
'group_id',
'role_id',
'user_id')) ?
"t.{$v[1]} != '*' AND " :
'')
4423 .
"{$v[2]}.{$v[3]} IS NULL"
4439 empty($GLOBALS[
'egotec_conf'][
'liveserver'])
4441 || (($page->field[
'nav_hide']&2) == 0
4442 && $page->isPublic()))
4448 foreach ($clusters as $cluster) {
4449 $cluster_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->name.
'/live.'.$this->name.
'_'.$this->language.
'.'.$cluster[
'id'].
'.date';
4452 if (!$live_date || $cluster_date > $live_date) {
4453 $live_date = $cluster_date;
4459 $live_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'] . $this->name .
'/live.' . $this->name .
'_' . $this->language .
'.date';
4461 $live_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'] . $this->name .
'/live.date';
4469 if (!empty($live_date) && (!$page || $page->field[
'm_date'] > $live_date)) {
4472 require_once
'cron/Ego_Cron.php';
4474 foreach ($this->conf[
'admin'] as $key => $values) {
4476 strpos($key,
'cron_') === 0
4477 && !empty($GLOBALS[
'egotec_conf'][$key][
'aktiv'])
4478 && !empty($GLOBALS[
'egotec_conf'][$key][
'interval'])
4479 && (!empty($values[
'live_incr'])
4480 || !empty($values[
'cluster_incr']))
4482 $date = Ego_Cron::getNextDate($GLOBALS[
'egotec_conf'][$key][
'interval'], $page, $live_date);
4483 if (empty($next_date) || $date < $next_date) {
4500 $conf = $GLOBALS[
'egotec_conf'][
'rewrite'] ?? [];
4501 if ($this->conf[
'admin'][
'rewrite'][
'overwrite']) {
4502 $conf = $this->conf[
'admin'][
'rewrite'];
4503 unset($conf[
'overwrite']);
4514 $networks = array();
4517 if (!empty($this->admin[
'social'][
'facebook_page_id']) && !empty($this->admin[
'social'][
'facebook_access_token'])) {
4518 $networks[] =
'facebook';
4522 if (!empty($this->admin[
'social'][
'twitter_access_token'])) {
4523 $networks[] =
'twitter';
4535 if (empty($this->virtualHosts)) {
4538 $identity[
'site'] == $this->name
4539 && $identity[
'lang'] == $this->language
4541 $this->virtualHosts[] = (string) $virtual_host;
4545 if (empty($this->virtualHosts)) {
4547 $host = $_SERVER[
'HTTP_HOST'];
4548 if (!empty($GLOBALS[
'egotec_conf'][
'rewrite'][
'host'])) {
4549 $host = $GLOBALS[
'egotec_conf'][
'rewrite'][
'host'];
4551 $default_host = rtrim($host,
'/');
4552 if ($GLOBALS[
'egotec_conf'][
'default_site'] != $this->name) {
4553 $default_host .=
'/' . $this->name;
4555 if (
sizeof($this->getLanguages()) > 1) {
4556 if ($this->language == $this->site[
'default_language']) {
4558 $this->virtualHosts[] = $default_host;
4560 $default_host .= (strpos($default_host,
'/') ===
false ?
'/' :
'-') . $this->language;
4562 $this->virtualHosts[] = $default_host;
4565 return $this->virtualHosts;
4574 return !$GLOBALS[
'egotec_conf'][
'non_global_sites']
4575 || !in_array($this->name, explode(
',', $GLOBALS[
'egotec_conf'][
'non_global_sites']));
4587 $base =
'files/' . md5(serialize([
4589 $GLOBALS[
'egotec_conf'][
'egotec_version'],
4590 $GLOBALS[
'egotec_conf'][
'project_version']
4592 $path = $GLOBALS[
'egotec_conf'][
'pub_dir'] . $base;
4596 foreach ($files as $file) {
4598 $absolute = $GLOBALS[
'egotec_conf'][
'egotec_dir']
4599 . substr($file, mb_strlen($GLOBALS[
'egotec_conf'][
'url_dir']))
4603 if ($type ==
'css') {
4604 $source = preg_replace_callback(
'/(import|url)\s*\(["\' ]*(.*?)["\' ]*\)/',
function($match) use ($absolute) {
4605 if ($real = @realpath(dirname($absolute) .
'/' . $match[2])) {
4606 return str_replace($match[2], substr($real, mb_strlen($GLOBALS[
'egotec_conf'][
'egotec_dir']) - 1), $match[0]);
4612 $content .=
"\n\n/* ---------- START $file ---------- */\n\n"
4614 .
"\n\n/* ---------- END $file ---------- */";
4620 return $GLOBALS[
'egotec_conf'][
'url_dir'] .
'pub/' . $base;
const PERMISSION_DENIED_TEXT
static start($table='', $param=[], $checkHealthy=false)
static filterNonUtf8($s, $substitute="", $strict=false)
static getCache($path='_system')
static getMimeTypes($ext='')
static file_put_contents($filename, $data, $flags=0, $context=null)
static getAssocValue($a, $k)
static getFallbackFile($type, $name, $path, $skip=array('module'), $url=false, $relative=false, $parent='')
static getVariantFiles($type, $name, $path, $skip=array(), $parent='')
static getCluster($site=null)
static getFiles($type, $name, $path, $skip=array(), $parent='', $return_path=false, $get_variants=true)
static file_exists($file)
static mkdir($dir, $mode=0755, $recursive=true)
static file_get_contents($filename, $utf8=true, $context=null)
static getJSON($path, $values=[], $combine=false, $ignore=[], $replace=true, $no_cache=false)
getSkinFile($path, $skip=array('module'), $url=false, $relative=false)
__call($function, $params)
getPageId($name, $param=[])
getTemplate($mobile=false, $name='index', $dir='', $variant='', $suffix='', $fallback=true)
getUploaderPage($page=null)
static createSite($new_site)
save_admin($admin=array())
compressFiles($type, $files)
isFrontendAdmin($check_rights=true)
getPageClass($type='page')
getNextReplicationDate($page=null)
getFile($path, $type='skin')
getSearchCount($weight=0)
clearTrashcan($query=array())
checkRight($right, $flag=false)
getLayoutFiles($path='', $skip=array(), $conf=array())
setCacheEntry($key, $value)
getPages($query=array(), $param=array())
__construct($site_name='', $language='', $skin='', $only_active=true, $time='', $recalc=false)
getDesklets($rights=false, $trashcan=false)
updateUrls($reset=false, $verbose=false)
setLanguage($language='')
getCopyrights($start=0, $limit=0, &$m=0)
getBlockFiles($path='', $skip=array())
hasRightsOnId($id, $rights, $user_id=false, $cache=true)
getAdminText($suffix='', $fallback=true)
getNonPublicPages($query=[], $param=[])
setRight($right, $rights)
removeLinks($language='')
getVariantFiles($path, $skip=array())
clearCache($id=0, $all_languages=false)
setRights($rights=array())
getInheritedFile($mode, $type, $path, $skip=array('module'), $url=false, $relative=false)
updateMediaIndex($resume, $c_date, $skipFirst, $dryRun, $timeout)
updateLinks($output=false)
getSiteFile($path, $skip=array('module'), $url=false, $relative=false)