5 require_once
'base/Page_Iterator.php';
6 require_once
'base/Mediapool.php';
42 private $tableSuffix =
'';
53 private $lastChangeDate =
'';
54 private $frontendActive =
false;
55 private $editFields = array();
59 private static $nextIds = array();
74 $this->extra = $this->field[
'extra']?
unserialize($this->field[
'extra']):array();
75 $this->lastChangeDate = $this->field[
'm_date'];
76 $this->originalType = $this->field[
'type'];
78 if ($_REQUEST[
'c_date'] && $this->field[
'id']) {
79 $c_date = $_REQUEST[
'c_date'];
80 if (is_numeric($c_date)) {
81 $c_date = date(
'Y-m-d H:i:s', $_REQUEST[
'c_date']);
83 $db = new_db_connection(array(
84 'table' => $this->_site->pageTable.
'_v',
85 'where' =>
"id=".$this->field[
'id'].
" AND m_date<=:cdate",
86 'order' =>
'm_date DESC',
88 'bind' => array(
'cdate' => $c_date)
90 if ($db->nextRecord()) {
91 $this->field = $db->Record;
92 $this->extra = $db->Record[
'extra']?
unserialize($db->Record[
'extra']):array();
95 $this->lastChangeDate = $this->field[
'm_date'];
98 && $_REQUEST[
'id'] ==
$field[
'id']
99 && $_REQUEST[
'site'] == $site->name
100 && !$GLOBALS[
'frontend_admin']
101 && $_SESSION[
'egotec_page_preview'][$identity = $this->getIdentity()]
104 $this->field = $_SESSION[
'egotec_page_preview'][$identity][
'field'];
106 $this->lastChangeDate = $this->field[
'm_date'];
113 && ($GLOBALS[
'is_admin'] || $GLOBALS[
'frontend_admin'] || $_REQUEST[
'preview'])
114 && !empty($GLOBALS[
'site'])
115 && empty($GLOBALS[
'public_save_get_original_page'])
116 && empty($GLOBALS[
'auto_translate_get_original_page'])
117 && $this->_site->name == $GLOBALS[
'site']->name
118 && in_array($this->field[
'id'], array($_REQUEST[
'list'], $_REQUEST[
'id'], $_REQUEST[
'field'][
'id']))
121 $db = new_db_connection();
123 'table' => $this->_site->pageTable.
'_v',
124 'where' =>
'id = :id',
125 'order' =>
'm_date DESC',
128 'id' => $this->field[
'id']
131 if ($db->nextRecord() && $db->Record[
'm_date'] > $this->field[
'm_date']) {
133 $this->field = $db->Record;
134 $this->extra = $this->field[
'extra']?
unserialize($this->field[
'extra']):array();
135 $this->archiveOnly =
true;
138 if (empty($_REQUEST[
'input'])) {
139 $current_dir = $this->
getMediapool()->dir().$this->getMediapool()->currentDir;
141 $archive_dir = $this->
getMediapool()->dir().$this->getMediapool()->currentDir;
155 $this->extra[
'language_standard']
156 && !in_array($this->extra[
'language_standard'], $this->_site->getLanguages())
158 $this->extra[
'language_standard'] = $this->_site->language;
164 !empty($GLOBALS[
'frontend_admin'])
165 && !empty($GLOBALS[
'smarty'])
171 if ($this->extra[
'mime_type'] && !is_string($this->extra[
'mime_type'])) {
172 $this->extra[
'mime_type'] =
'';
174 $this->field[
'cache'] = (int)$this->field[
'cache'];
177 $this->_loadConfig();
180 if (empty($this->extra[
'_layout'])) {
181 $this->extra[
'_layout'] = $this->conf[
'default_layout'];
185 if (is_array($this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'])) {
186 foreach ($this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'] as $orient => $info) {
187 if (!empty($info[
'default']) && $info[
'static']) {
188 if (!is_array($this->extra[
'_blocks'])) {
189 $this->extra[
'_blocks'] = array();
191 $this->extra[
'_blocks'][$orient] = explode(
',', $info[
'default']);
194 $this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'][$orient][
'allow'] = implode(
',', array_unique($this->extra[
'_blocks'][$orient]));
195 unset($this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'][$orient][
'disallow']);
200 if (is_array($this->extra[
'_blocks'])) {
202 if (isset($this->conf[
'layouts'])) {
204 $validate =
function ($block, $orient, $type) use (&$validate) {
205 $info = $this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'][$orient];
206 if (isset($info[$type])) {
207 $result = $type ==
'allow' ? false :
true;
208 foreach (explode(
',', $info[$type]) as $name) {
211 if ($name[0] ==
'@') {
212 if ($validate($block, substr($name, 1),
'allow')) {
216 } elseif ($block == $name) {
222 if ($name[0] ==
'@') {
223 if (!$validate($block, substr($name, 1),
'disallow')) {
227 } elseif ($block == $name) {
238 foreach ($this->extra[
'_blocks'] as $orient => $blocks) {
239 if (is_array($blocks)) {
240 foreach ($blocks as $index => $block) {
242 !$validate($block, $orient,
'allow')
243 || !$validate($block, $orient,
'disallow')
246 && $this->conf[
'template_block'] !==
true
247 && $this->conf[
'blocks'][
'template'][
'removable'] ===
true
250 if (isset($this->extra[
'_blocks'][$orient][$index])) {
251 unset($this->extra[
'_blocks'][$orient][$index]);
253 if (isset($this->extra[
'_contents'][$orient][$index])) {
254 unset($this->extra[
'_contents'][$orient][$index]);
263 foreach ($this->extra[
'_blocks'] as $orient => $blocks) {
264 if (is_array($blocks)) {
267 foreach ($blocks as $index => $block) {
268 if (isset($this->extra[
'_contents'][$orient][$index])) {
270 if ($new_index >= $num + 1) {
272 $this->extra[
'_blocks'][$orient][$new_index] = $block;
273 unset($this->extra[
'_blocks'][$orient][$index]);
275 $contents[$new_index] = $this->extra[
'_contents'][$orient][$index];
276 } elseif (isset($this->conf[
'blocks'][$block][
'default'][$orient])) {
277 $contents[$index] = $this->conf[
'blocks'][$block][
'default'][$orient];
281 $this->extra[
'_contents'][$orient] = $contents;
287 if (isset($this->extra[
'mediapool']) && !is_array($this->extra[
'mediapool'])) {
288 $this->extra[
'mediapool'] = array();
292 $this->field[
'id'] = (int) $this->field[
'id'];
293 $this->field[
'name'] = (string) $this->field[
'name'];
294 $this->field[
'title'] = (string) $this->field[
'title'];
295 $this->field[
'url'] = (string) $this->field[
'url'];
296 $this->field[
'short'] = (string) $this->field[
'short'];
297 $this->field[
'content'] = (string) $this->field[
'content'];
298 $this->field[
'extra'] = (string) $this->field[
'extra'];
299 $this->field[
'a_date'] = (string) $this->field[
'a_date'];
300 $this->field[
'c_date'] = (string) $this->field[
'c_date'];
301 $this->field[
'a_user'] = (string) $this->field[
'a_user'];
302 $this->field[
'c_user'] = (string) $this->field[
'c_user'];
303 $this->field[
'type'] = (string) $this->field[
'type'];
304 $this->field[
'children_order'] = (string) $this->field[
'children_order'];
305 $this->field[
'order_field'] = (int) $this->field[
'order_field'];
306 $this->field[
'nav_hide'] = (int) $this->field[
'nav_hide'];
307 $this->field[
'inactive'] = (int) $this->field[
'inactive'];
308 $this->field[
'cache'] = (int) $this->field[
'cache'];
309 $this->field[
'release_from'] = (string) $this->field[
'release_from'];
310 $this->field[
'release_until'] = (string) $this->field[
'release_until'];
311 $this->field[
'workflow'] = (string) $this->field[
'workflow'];
312 $this->field[
'workflow_state'] = (int) $this->field[
'workflow_state'];
313 $this->field[
'deleted'] = (int) $this->field[
'deleted'];
321 private function _loadConfig() {
323 $cache_key =
'pageConf'.md5(
serialize(array($this->field[
'type'], $_SERVER[
'REQUEST_SUFFIX'])));
324 $this->conf = $this->_site->getCacheEntry($cache_key);
325 if ($this->conf ===
null) {
328 $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'page/conf.json'
337 $get_type_confs =
function($path) use (&$confs) {
338 $parts = explode(
'/', $this->field[
'type']);
341 $confs[] = str_replace(
'*', implode(
'/', array_slice($parts, 0, ++$i)), $path);
342 }
while ($i <
sizeof($parts));
345 $get_type_confs($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'type/site/*/admin/conf.json');
347 foreach (array(
'', $_SERVER[
'REQUEST_SUFFIX']) as $suffix) {
348 if (!empty($suffix) && trim(mb_strtolower(ltrim($suffix,
'.'))) !=
'html') {
349 $suffix =
'.' . mb_strtolower(ltrim($suffix,
'.'));
351 if ($suffix ==
'.html') {
356 if ($this->_site->theme) {
357 $confs[] = $GLOBALS[
'egotec_conf'][
'pub_dir'] .
'theme/' . $this->_site->theme .
'/site/admin/conf' . $suffix .
'.json';
361 if ($this->_site->globalAllowed()) {
362 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/conf.json';
365 if ($this->_site->theme) {
366 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/' . $this->_site->theme . $suffix .
'.json';
370 if ($this->_site->skin) {
371 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/' . $this->_site->skin . $suffix .
'.json';
376 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] . $this->_site->name .
'/admin/conf' . $suffix .
'.json';
379 if ($this->_site->theme) {
380 $get_type_confs($GLOBALS[
'egotec_conf'][
'pub_dir'] .
'theme/' . $this->_site->theme .
'/site/*/admin/conf' . $suffix .
'.json');
384 if ($this->_site->globalAllowed()) {
385 $get_type_confs($GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/*/admin/conf' . $suffix .
'.json');
388 if ($this->_site->theme) {
389 $get_type_confs($GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/*/admin/' . $this->_site->theme . $suffix .
'.json');
393 if ($this->_site->skin) {
394 $get_type_confs($GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/*/admin/' . $this->_site->skin . $suffix .
'.json');
399 $get_type_confs($GLOBALS[
'egotec_conf'][
'site_dir'] . $this->_site->name .
'/*/admin/conf' . $suffix .
'.json');
402 $this->conf = array();
403 $confs = array_unique($confs);
404 foreach ($confs as $file) {
406 $this->conf =
Ego_System::getJSON($file, $this->conf,
true, [
'plugins',
'toolbar',
'menubar',
'editor.options']);
409 if (empty($this->conf[
'default_layout'])) {
410 $this->conf[
'default_layout'] =
'default';
412 unset($this->conf[
'site'], $this->conf[
'admin']);
413 $this->_site->setCacheEntry($cache_key, $this->conf);
415 if ($this->conf[
'main_orient']) {
417 $this->mainOrient = $this->conf[
'main_orient'];
428 public function __call($function, $params) {
430 if (strpos($function,
'pool') === 0 && is_callable($call = [$this->
getMediapool(), lcfirst(substr($function, 4))])) {
431 egotec_deprecated_log(
'18.4',
'Please use getMediapool() and the Mediapool object\'s methods.');
432 return call_user_func_array($call, $params);
436 $key =
'Page.magic'.md5(
serialize(array($function, $this->field[
'type'])));
437 $magic_file = $this->_site->getCacheEntry($key);
438 if ($magic_file ===
null) {
440 "{$this->field['type']}/Page.{$function}.php"
442 $types = explode(
'/', $this->field[
'type']);
443 while (array_pop($types)) {
444 if (!empty($types)) {
445 $files[] = implode(
'/', $types) .
"/Page.{$function}.php";
448 $files[] =
"Page.{$function}.php";
449 foreach ($files as $file) {
450 if ($found = $this->_site->getSiteFile($file)) {
451 $magic_file = $found;
452 $this->_site->setCacheEntry($key, $magic_file);
458 if ($magic_file ===
null) {
459 $this->_site->setCacheEntry($key,
'');
462 if (empty($magic_file)) {
463 $magic_file = $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'base/Page.' . $function .
'.php';
465 if (!file_exists($magic_file)) {
468 require_once($magic_file);
469 return call_user_func($function, $this, $params);
478 return $this->tableSuffix;
488 $this->tableSuffix = $suffix;
498 require_once(
'auth/Auth.php');
507 private function _archiveEntry() {
509 $table = $this->_site->pageTable.
'_v';
510 $db = new_db_connection();
513 unset(
$field[
'has_children']);
522 'primary' => array(
'id',
'm_date'),
540 private function _insertEntry(
$field, $lang=
'') {
542 $field[
'id'] = $this->_site->nextId();
547 foreach (
$field as $key => $value) {
548 if (is_string($value)) {
549 if ($key ==
'extra') {
558 foreach (array(
'name',
'title') as $key) {
559 if (isset(
$field[$key])) {
564 $db = new_db_connection();
566 'table' => $lang?$this->_site->name.
'_'.$lang:$this->_site->pageTable.$this->getTableSuffix(),
570 $site = clone $this->_site;
571 $site->setLanguage($lang);
573 $site = $this->_site;
575 $class = $site->getPageClass(
$field[
'type']);
576 $child =
new $class($site,
$field);
577 $child->_archiveEntry();
578 if (!isset(
$field[
'inactive']) || !
$field[
'inactive']) {
579 $this->_clearCache();
583 self::$nextIds[] = $child->field[
'id'];
597 private function _changeEntry(
$field = array(), $asis =
false, $silent =
false) {
598 $db = new_db_connection();
600 $field[
'm_user'] = $GLOBALS[
'auth']->getId() ? $GLOBALS[
'auth']->getId() :
'';
601 $field[
'm_date'] = date(
'Y-m-d H:i:s');
607 unset($this->field[
'idx']);
609 if (!isset(
$field[
'id'])) {
610 $field[
'id'] = $this->field[
'id'];
612 if (isset(
$field[
'nav_hide']) && !is_numeric(
$field[
'nav_hide'])) {
617 if (isset(
$field[
'type'])) {
618 $this->field[
'type'] =
$field[
'type'];
619 $this->typeInfo = [];
621 if (($info = $this->
getTypeInfo()) && isset($info[
'nav_hide'])) {
622 $field[
'nav_hide'] = (int) $info[
'nav_hide'];
626 foreach (array(
'name',
'title') as $key) {
627 if (isset(
$field[$key])) {
640 if (isset(
$field[
'release_from']) && empty(
$field[
'release_from'])) {
641 $field[
'release_from'] =
'0000-00-00 00:00:00';
643 if (isset(
$field[
'release_until']) && empty(
$field[
'release_until'])) {
644 $field[
'release_until'] =
'0000-00-00 00:00:00';
648 if (
$field[
'id'] == $this->_site->rootId) {
653 $cache_complete = isset(
$field[
'deleted'])
654 && $this->field[
'type'] ==
'multimedia/image'
655 && $this->field[
'deleted'] !=
$field[
'deleted'];
658 $filter =
function($value) use (&$filter) {
659 if (is_array($value)) {
660 foreach ($value as $k => $v) {
661 $value[$k] = $filter($v);
666 if (is_string($value)) {
669 !empty($GLOBALS[
'egotec_conf'][
'editor'][
'filter_unicode'])
670 || !empty($this->_site->admin[
'editor'][
'filter_unicode'])
680 foreach (
$field as $key => $value) {
681 if (is_string($value)) {
682 if ($key ==
'extra') {
685 $field[$key] = $filter($value);
690 if (!$this->archiveOnly) {
693 'table' => $this->_site->pageTable.$this->getTableSuffix(),
695 'where' =>
'id='.$this->field[
'id']
722 $this->_clearCache($cache_complete);
723 $this->field = array_merge($this->field,
$field);
724 if (isset(
$field[
'extra'])) {
741 $ancestors_ids = array();
743 $cache_key =
'_getAncestorsIds.'
747 .($param ? md5(
serialize($param)) :
'-');
748 $cache_val = $page->getSite()->getCacheEntry($cache_key);
752 foreach ($page->getParents($query, $param) as $parent) {
753 $ancestors_ids[] = $parent->field[
'id'];
754 $ancestors_ids = array_merge($ancestors_ids, $this->
_getAncestorsIds($parent, $query, $param));
756 $page->getSite()->setCacheEntry($cache_key, $ancestors_ids);
758 return $ancestors_ids;
773 private function _getDescendantsIds($page, $query=array(), $param=array(), &$descendants=array()) {
774 $query[
'hash'].=
':'.$page->field[
'id'];
775 foreach ($page->getChildren($query, $param) as $child) {
776 if (in_array($child->field[
'id'], $descendants)) {
780 $descendants[] = $child->field[
'id'];
781 if ($child->field[
'has_children']) {
782 $this->_getDescendantsIds($child, $query, $param, $descendants);
795 private function _getRights($perm_type=
'') {
796 return new_db_connection(array(
798 'from' => $this->_site->pageTable.
'_rights',
799 'where' =>
"page_id=".$this->field[
'id'].($perm_type?
" AND perm='".$perm_type.
"'":
"")
810 private function _getUsers($perm_type=
'') {
811 return new_db_connection(array(
813 'from' => $this->_site->pageTable.
'_users',
814 'where' =>
"page_id=".$this->field[
'id'].($perm_type?
" AND perm='".$perm_type.
"'":
'')
826 private function _getEmptyEntry($new=array()) {
828 unset($new[
'parents']);
830 $user_id = $GLOBALS[
'auth']->getId() ? $GLOBALS[
'auth']->getId() :
'';
831 $date = date(
'Y-m-d H:i:s');
834 'title' =>
'Neue Seite',
840 'cache' => self::CACHE_BROWSER|self::CACHE_PROXY|self::CACHE_SERVER,
841 'inactive' => self::INACTIVE_FLAG,
842 'release_from' =>
'0000-00-00 00:00:00',
843 'release_until' =>
'0000-00-00 00:00:00',
849 'a_user' => $user_id,
850 'c_user' => $user_id,
851 'm_user' => $user_id,
853 'children_order'=>
'children',
854 'workflow_state'=> 0,
859 foreach ($new as $key => $value) {
860 if (!is_null($value)) {
861 $empty[$key] = $value;
876 function hasRights($rights, $user_id =
false, $cache =
true) {
877 return $this->_site->hasRightsOnId($this->field[
'id'], $rights, $user_id, $cache);
888 public function hasUserRight(
string $right_type,
string $user_id): bool {
891 if (isset($user_rights[$right_type])) {
892 foreach ($user_rights[$right_type] as $user_right) {
893 if ($user_right[
'user_id'] === $user_id) {
910 $rights = $this->getRightsArray($perm);
911 if (!empty($rights[$perm])) {
912 foreach ($rights[$perm] as $right) {
913 if ($right[
'group_id'] !=
'*' && $right[
'role_id'] !=
'*') {
920 $users = $this->getUsersArray($perm);
921 if (!empty($users[$perm])) {
922 foreach ($users[$perm] as $user) {
923 if ($user[
'user_id'] !=
'*') {
942 function newChild($field = array(), $extra = array(), $inherit=
true) {
943 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
944 $GLOBALS[
'__egotec_skip_replication'] =
'newChild';
947 $original_field = !isset($field) ? ($field = array()) : $field;
948 $original_extra = !isset($extra) ? ($extra = array()) : $extra;
950 if ($field[
'deleted'] == 1) {
954 if (!$extra[
'release_id'] && $this->_site->admin[
'multi_lang'][
'auto_link']) {
955 $extra[
'language_standard'] = $this->_site->language;
956 foreach ($this->_site->getLanguages() as $lang) {
957 $extra[
'language_link'][$lang] = $lang != $extra[
'language_standard']
959 && $this->extra[
'language_link'][$lang] == 2
962 } elseif(!$extra[
'language_standard']) {
963 if ($this->extra[
'language_standard'] == $this->_site->language) {
965 $extra[
'language_standard'] = $this->extra[
'language_standard'];
966 $extra[
'language_link'] = $this->extra[
'language_link'];
967 if (!$extra[
'language_standard']) {
968 $extra[
'language_standard'] = $this->_site->language;
970 if (!$extra[
'language_link']) {
971 $extra[
'language_link'] = array();
972 foreach ($this->_site->getLanguages() as $lang) {
973 if ($lang == $extra[
'language_standard']) {
974 $extra[
'language_link'][$lang] = 1;
976 $extra[
'language_link'][$lang] = 0;
982 $extra[
'language_standard'] = $this->_site->language;
988 if ($this->_site->admin[
'workflow'][
'enabled'] && $this->field[
'workflow']) {
989 $field[
'workflow'] = $this->field[
'workflow'];
990 if ($this->extra[
'workflows']) {
991 $extra[
'workflows'] = $this->extra[
'workflows'];
996 $field[
'nav_hide'] = $field[
'nav_hide'] === 0 ? 0 : ((int) $field[
'nav_hide']) | ((int) $this->field[
'nav_hide']);
1000 $this->field[
'type'] == $field[
'type']
1001 || (!isset($field[
'type']) && $this->field[
'type'] ==
'page')
1003 if (!empty($this->extra[
'_template']) && empty($extra[
'_template'])) {
1004 $extra[
'_template'] = $this->extra[
'_template'];
1006 if (!empty($this->extra[
'_style']) && empty($extra[
'_style'])) {
1007 $extra[
'_style'] = $this->extra[
'_style'];
1012 if (empty($extra[
'ip_rights']) && !empty($this->extra[
'ip_rights'])) {
1013 $extra[
'ip_rights'] = $this->extra[
'ip_rights'];
1016 $field = $this->_getEmptyEntry($field);
1019 if ($this->extra[
'area_password'] && !$extra[
'area_password']) {
1020 $extra[
'area_password'] = $this->extra[
'area_password'];
1024 $field[
'extra'] = serialize($extra);
1026 $new_page = $this->_insertEntry($field);
1027 $new_page->addParent($this->field[
'id']);
1028 $field[
'id'] = $new_page->field[
'id'];
1030 !$new_page->isWorkflowCopy()
1031 && !$new_page->isReleaseCopy()
1032 && !$new_page->isClone()
1033 && is_array($new_page->extra[
'language_link'])
1035 foreach ($this->_site->getLanguages() as $lang) {
1036 if ($lang != $this->_site->language && $new_page->extra[
'language_link'][$lang]) {
1037 $lang_page = $new_page->getLanguagePage($lang, array(
'auth_or' =>
'1=1',
'inactive' =>
true,
'only_active' =>
false));
1041 $lang_parent = $this->getLanguagePage($lang, array(
'auth_or' =>
'1=1',
'deleted_or' =>
'1=1',
'inactive' =>
true,
'only_active' =>
false));
1042 if ($lang_parent && $lang_parent->field[
'deleted']) {
1043 $lang_parent->undelete();
1047 $translated = $new_page->autoTranslate([
1052 $lang_page = $this->_insertEntry($translated[
'field'], $lang);
1053 $new_page->createPath($lang);
1054 $lang_page->addParent($this->field[
'id']);
1056 $new_rights = $this->getRightsArray();
1057 $new_rights[
'edit'] = $new_rights[
'child'];
1058 $new_users = $this->getUsersArray();
1059 $new_users[
'edit'] = $new_users[
'child'];
1060 $lang_page->setRightsArray($new_rights);
1061 $lang_page->setUsersArray($new_users);
1066 $this->message = $GLOBALS[
'auth']->translate(
'Neue Seite wurde erstellt!');
1067 if ($new_page->field[
'inactive']) {
1068 $this->message.=
"\n".$GLOBALS[
'auth']->translate(
'Diese Seite ist inaktiv (nicht online verfügbar).');
1070 $this->message.=
"\n".$GLOBALS[
'auth']->translate(
'Diese Seite ist freigeschaltet.');
1074 $new_rights = $this->getRightsArray();
1075 $new_rights[
'edit'] = $new_rights[
'child'];
1076 $new_users = $this->getUsersArray();
1077 $new_users[
'edit'] = $new_users[
'child'];
1078 $new_page->setRightsArray($new_rights);
1079 $new_page->setUsersArray($new_users);
1082 $new_page->_updateCloneRights();
1084 $new_page->updateIndex();
1085 $new_page->hookUpdate(
'newchild');
1086 $new_page->hookUpdate();
1088 $this->replicate(
'newChild', $original_field, $original_extra, $inherit);
1090 if ($new_page->_site->admin[
'video'][
'convert'] && preg_match(
'/video/', $new_page->extra[
'mime_type']) && $new_page->extra[
'mime_type'] !=
'video/mp4') {
1093 } elseif($new_page->_site->admin[
'video'][
'compress'] && $new_page->extra[
'mime_type'] ==
'video/mp4') {
1109 $children = $this->getChildren(array(
1110 'where' =>
"name = :name AND type IN ('multimedia/file', 'multimedia/image')",
1116 'only_active' =>
false
1118 if ($page = $children->nextPage()) {
1119 if (!$suffix || $page->extra[
'image_type'] == $suffix) {
1140 public function newFile($source, $name, $options = array(), $suffix =
'') {
1141 if ($this->_site->site[
'type'] ==
'media' && $this->validateFile($source, $name)) {
1145 if (!isset($GLOBALS[
'site'])) {
1146 $GLOBALS[
'site'] = $this->getSite();
1149 require_once
'media/functions.php';
1150 require_once
'base/Ego_MimeType.php';
1155 if (!$path_info[
'extension'] && $suffix) {
1156 $path_info[
'extension'] = $suffix;
1159 $GLOBALS[
'mediaType'] = $path_info[
'extension'];
1163 $mime_type = $mime->autoDetect($source);
1165 $is_image = !(strpos($mime_type,
'image') ===
false);
1169 if ($field[
'extra']) {
1170 $extra = $field[
'extra'];
1171 unset($field[
'extra']);
1181 if (!empty($options[
'extra'][
'mime_type'])) {
1182 $extra[
'mime_type'] = $options[
'extra'][
'mime_type'];
1184 $extra[
'mime_type'] = $mime_type;
1188 $extra[
'image_type'] = $suffix;
1191 if ($path_info[
'extension']) {
1192 $extra[
'image_type'] = $path_info[
'extension'];
1195 if (!$GLOBALS[
'mime2ext']) {
1199 if ($extra[
'mime_type'] ==
'image/svg') {
1200 $extra[
'mime_type'] =
'image/svg+xml';
1203 $extra[
'image_type'] = $GLOBALS[
'mime2ext'][$extra[
'mime_type']];
1209 if ($is_image && $extra[
'origFileSize'] > 0) {
1210 require_once
'base/Ego_Image.php';
1213 $imageTransform->load($source);
1215 if (!minimumImageDimensions($imageTransform, $this->_site)) {
1219 scaleImageOnUpload($imageTransform, $this->_site);
1221 $extra[
'origImgWidth'] = $imageTransform->getImageWidth();
1222 $extra[
'origImgHeight'] = $imageTransform->getImageHeight();
1225 setExifData($field, $extra, $keywords, $imageTransform, $this);
1227 getFileInfo($source, $extra);
1230 $field[
'type'] =
'multimedia/' . ($is_image ?
'image' :
'file');
1231 $field[
'inactive'] = self::ACTIVE_FLAG;
1232 $field[
'parents'] =
','.trim($this->field[
'id'],
',').
',';
1235 if (!$is_image && $GLOBALS[
'egotec_conf'][
'openoffice'][
'active']) {
1236 require_once
'openoffice/converter.php';
1237 $field[
'content'] = convert_content($source, $extra[
'image_type'], $extra[
'mime_type']);
1240 $child = $this->newChild($field, $extra);
1242 if (isset($keywords) && !empty($keywords)) {
1243 foreach ($keywords as $keyword) {
1244 $child->addParent($keyword);
1249 $media_dir = $GLOBALS[
'egotec_conf'][
'var_dir'].
'media'.DIRECTORY_SEPARATOR.$this->_site->name;
1254 $dest = $media_dir.DIRECTORY_SEPARATOR.$child->getMediaFilename(
true);
1263 $media_dir.DIRECTORY_SEPARATOR.$child->getMediaFilename(
1265 '_'.strtotime($child->field[
'm_date'])
1288 $id = $this->field[
'id'];
1289 $dir = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'import/zip/';
1295 $file = tempnam($dir,
'ZIP_').
'.zip';
1296 if (@move_uploaded_file($source, $file)) {
1297 require_once(
'media/functions.php');
1298 require_once(
'Archive/Zip.php');
1299 $zip =
new Archive_Zip($file);
1303 chdir($GLOBALS[
'egotec_conf'][
'bin_dir'].
'admin');
1304 $num = GetDir($dest,
'', $this->field[
'id'],
true, $images);
1307 if (isset($GLOBALS[
'_GetDir_firstId'])) {
1308 $id = $GLOBALS[
'_GetDir_firstId'];
1309 unset($GLOBALS[
'_GetDir_firstId']);
1312 return $this->_site->getPage($id);
1323 if (!$this->validateFile($source, $name)) {
1328 if (!isset($GLOBALS[
'site'])) {
1329 $GLOBALS[
'site'] = $this->getSite();
1332 require_once(
'media/functions.php');
1333 require_once(
'base/Ego_MimeType.php');
1336 $GLOBALS[
'mediaType'] = $path_info[
'extension'];
1339 $mime_type = $mime->autoDetect($source);
1340 $is_image = !(strpos($mime_type,
'image') ===
false);
1343 $extra = $this->extra;
1345 $extra[
'mime_type'] = $mime_type;
1347 if ($path_info[
'extension']) {
1348 $extra[
'image_type'] = $path_info[
'extension'];
1351 if (!$name || !$extra[
'image_type']) {
1353 if (!$GLOBALS[
'mime2ext']) {
1356 $extra[
'image_type'] = $GLOBALS[
'mime2ext'][$extra[
'mime_type']];
1360 $field[
'type'] =
'multimedia/'.($is_image ?
'image' :
'file');
1363 require_once(
'base/Ego_Image.php');
1365 $imageTransform->load($source);
1367 if (!minimumImageDimensions($imageTransform, $this->_site)) {
1374 scaleImageOnUpload($imageTransform);
1376 $extra[
'origImgWidth'] = $imageTransform->getImageWidth();
1377 $extra[
'origImgHeight'] = $imageTransform->getImageHeight();
1380 setExifData($field, $extra, $keywords, $imageTransform, $this);
1382 $oldKeywords = array_reduce(
1383 iterator_to_array($this->getParents([
'where' =>
"type = '_keywords/entry'"])),
1384 function($carry, $item) {
1385 return array_merge($carry, [$item->field[
'id']]);
1391 foreach ($oldKeywords as $oldKeyword) {
1392 $this->unlinkFrom($oldKeyword);
1396 if (isset($keywords) && !empty($keywords)) {
1397 foreach ($keywords as $keyword) {
1398 $this->addParent($keyword);
1402 getFileInfo($source, $extra);
1407 if ($GLOBALS[
'egotec_conf'][
'openoffice'][
'active']) {
1409 require_once(
'openoffice/converter.php');
1410 $field[
'content'] = convert_content($source, $extra[
'image_type'], $extra[
'mime_type']);
1413 $field[
'content'] =
'';
1414 unset($extra[
'_indexed']);
1418 $this->update(array(
1424 if ($this->field[
'type'] ==
'multimedia/image') {
1425 foreach ($this->getChildren(array(), array(
1428 if ($child->extra[
'crop_image']) {
1430 'edit' => $child->extra[
'edit'],
1431 'crop_image' =>
true
1433 $child->updateExtra(array_merge($this->extra, $extra));
1439 $media_dir = $GLOBALS[
'egotec_conf'][
'var_dir'].
'media'.DIRECTORY_SEPARATOR.$this->_site->name;
1446 $this->_site->language == $this->_site->site[
'default_language']
1451 $media_dir.DIRECTORY_SEPARATOR.$this->field[
'id'],
1452 $media_dir.DIRECTORY_SEPARATOR.$this->getMediaFilename(
true)
1455 $mediafiles = glob($media_dir.DIRECTORY_SEPARATOR.$this->field[
'id'].
'_*');
1456 if (is_array($mediafiles)) {
1457 foreach ($mediafiles as $mediafile) {
1458 preg_match(
'/\d+_\d+$/', $mediafile, $name);
1461 $media_dir.DIRECTORY_SEPARATOR.$this->_site->language.DIRECTORY_SEPARATOR.$name[0]
1468 $dest = $media_dir.DIRECTORY_SEPARATOR.$this->getMediaFilename(
true);
1475 $media_dir.DIRECTORY_SEPARATOR.$this->getMediaFilename(
1477 '_'.strtotime($this->field[
'm_date'])
1484 $GLOBALS[
'egotec_conf'][
'cachemedia_dir'].$this->_site->name.DIRECTORY_SEPARATOR.
1485 $this->getMediaFilename(
true)
1488 if ($this->_site->admin[
'video'][
'convert'] && preg_match(
'/video/', $this->extra[
'mime_type']) && $this->extra[
'mime_type'] !=
'video/mp4') {
1491 } elseif($this->_site->admin[
'video'][
'compress'] && $this->extra[
'mime_type'] ==
'video/mp4') {
1506 if ($this->_site->site[
'type'] ==
'media') {
1508 if ($this->field[
'type'] ==
'multimedia/file') {
1509 $file = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->_site->name .
'/' . $this->getMediaFilename();
1512 $this->updateFile($tmp_file, $this->field[
'name'] .
'.' . $this->extra[
'image_type']);
1517 } elseif (!empty($this->_site->admin[
'mediapool'][
'active'])) {
1519 $mediapool = $this->getMediapool();
1520 foreach ($mediapool->getDirs() as $dir) {
1521 foreach ($mediapool->list($dir, [
'only_files' =>
true]) as $item) {
1522 if (
Ego_System::file_exists($tmp_file = $GLOBALS[
'egotec_conf'][
'tmp_dir'] .
'document-' . md5($item[
'file']))) {
1524 $mediapool->put($tmp_file, $item[
'name'], $dir);
1544 function copyTo($id, $recursive =
false, $params = array(), &$copied_pages = array())
1546 $original_copied_pages = $copied_pages;
1548 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
1549 $GLOBALS[
'__egotec_skip_replication'] =
'copyTo';
1552 if ($this->isClone() || $this->isWorkflowCopy() || $this->isReleaseCopy()) {
1558 'only_active' =>
false,
1563 if (is_a($id,
'Page')) {
1566 } elseif (is_a($params[
'site'],
'Site')) {
1568 $new_parent = $params[
'site']->getPage($id, $param);
1570 $this->_site->name == $GLOBALS[
'site']->name
1571 && $this->_site->language == $GLOBALS[
'site']->language
1574 $new_parent = $this->_site->getPage($id, $param);
1577 if ($this->_site->site[
'type'] ==
'media') {
1578 $new_parent = $GLOBALS[
'site']->getMediaSite()->getPage($id, $param);
1580 $new_parent = $GLOBALS[
'site']->getPage($id, $param);
1583 $site_parent = $new_parent->getSite();
1586 if ($this->_site->name == $site_parent->name) {
1587 $ancestors = $this->_getAncestorsIds(
1589 array(
'fields' =>
'id'),
1590 array(
'auth_or' =>
'1=1')
1592 if (in_array($this->field[
'id'], $ancestors)) {
1598 if (is_array($params[
'field'])) {
1599 $field = $params[
'field'];
1601 $field = $this->field;
1603 if (is_array($params[
'extra'])) {
1604 $extra = $params[
'extra'];
1606 $extra = $this->extra;
1609 unset($field[
'id']);
1610 unset($field[
'extra']);
1611 $field[
'a_user'] = $GLOBALS[
'auth']->user->field[
'user_id'];
1612 $field[
'a_date'] = date(
'Y-m-d H:i:s');
1613 unset($extra[
'workflow_page']);
1616 unset($extra[
'clones']);
1617 foreach (array_keys($extra) as $key) {
1619 strpos($key,
'clone_children_') === 0
1620 || strpos($key,
'clone_rights_') === 0
1621 || strpos($key,
'clone_release_') === 0
1623 unset($extra[$key]);
1628 if($this->_site->name == $site_parent->name) {
1629 unset($field[
'url']);
1633 if ($params[
'cleanup']) {
1635 $field[
'inactive'] = 1;
1638 unset($extra[
'history']);
1643 [$field, $extra] = $this->copyToFields($field, $extra);
1644 }
catch (Exception $e) {
1648 $copy = $new_parent->newChild($field, $extra);
1651 if (file_exists($GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename())) {
1652 if ($this->_site->name == $site_parent->name && $this->_site->language == $site_parent->language) {
1654 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename(),
1655 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$copy->getMediaFilename(
true),
1661 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename(),
1662 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$site_parent->name.
'/'.$copy->getMediaFilename(
true),
1670 $this->getMediapool()->copy($copy,
'',
false,
false,
false);
1674 !$copy->isReleaseCopy()
1676 foreach($this->_site->getLanguages() as $lang) {
1677 if ($lang != $this->_site->language) {
1678 if (in_array($lang, $this->_site->getLanguages()) &&
1679 in_array($lang, $copy->getSite()->getLanguages())
1681 $lang_page = $this->getLanguagePage($lang);
1684 $lang_page_field = $lang_page->field;
1685 $lang_page_extra = $lang_page->extra;
1686 $lang_page_field[
'id'] = $copy->field[
'id'];
1690 [$lang_page_field, $lang_page_extra] = $this->copyToFields($lang_page_field, $lang_page_extra);
1691 }
catch (Exception $e) {
1695 $_param = array(
'auth_or'=>
'1=1',
'deleted_or'=>
'1=1',
'inactive'=>
true);
1696 $lang_copy = $copy->getLanguagePage($lang, $_param);
1698 $copy_parent = $new_parent->getLanguagePage($lang, $_param);
1699 if (!$copy_parent) {
1700 $copy_parent = $copy->getSite()->getRoot()->getLanguagePage($lang, $_param);
1702 $lang_copy = $copy_parent->newChild($lang_page_field, $lang_page_extra);
1706 'field' => $lang_page_field,
1707 'extra' => $lang_page_extra
1715 "rights" => $lang_page->getRightsArray()
1716 ,
"users" => $lang_page->getUsersArray()
1718 $lang_copy->updateRights($rights,
false);
1728 if (!isset($copied_pages[$this->field[
'id']])) {
1729 $copied_pages[$this->field[
'id']] = $copy;
1732 if ($params[
'children_param'][
'sitemap'] !==
false) {
1733 $params[
'children_param'][
'sitemap'] =
true;
1736 $children = $this->getChildren($params[
'children_query'], $params[
'children_param']);
1738 foreach ($children as $child) {
1740 if ($new_child = $copied_pages[$child->field[
'id']]) {
1742 $new_child->addParent($copy->field[
'id'],
true);
1744 $child->copyTo($copy,$recursive,$params,$copied_pages);
1749 if ($new_parent->extra[
'clones']) {
1751 'field' => $new_parent->field
1753 $new_parent->_updateClones($param);
1756 $this->replicate(
'copyTo', $id, $recursive, $params, $original_copied_pages);
1769 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
1770 $GLOBALS[
'__egotec_skip_replication'] =
'move';
1773 if ($from != $to && $this->addParent($to)) {
1774 $this->delParent($from,
true);
1776 $this->hookUpdate();
1778 $this->replicate(
'move', $from, $to);
1788 $this->addParent($id);
1803 function delete($parent =
false, $nostart =
false, $keeplinks =
true, $query = array()) {
1804 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
1805 $GLOBALS[
'__egotec_skip_replication'] =
'delete';
1808 if ($this->isRoot()) {
1814 if ($this->field[
'type'] ==
'_keywords/entry') {
1815 if ($query[
'where']) {
1816 $query[
'where'] =
"({$query['where']}) AND type = '_keywords/entry'";
1818 $query[
'where'] =
"type = '_keywords/entry'";
1822 $this->archiveOnly =
false;
1823 $children = $this->getChildren(
1830 foreach ($children as $child) {
1831 $child->delete($keeplinks ? $this :
false,
false, $keeplinks, $query);
1832 if (isset($child->extra[
'main_category']) && $child->extra[
'main_category'] == $this->field[
'id']) {
1833 unset($child->extra[
'main_category']);
1834 $child->update([],
true,
true);
1840 is_array($this->extra[
'language_link'])
1841 && $this->extra[
'language_standard'] == $this->_site->language
1843 $languages = $this->_site->getLanguages();
1846 $standard = $languages[0] == $this->_site->language
1851 foreach ($languages as $lang) {
1852 if ($lang == $this->_site->language) {
1857 $this->extra[
'language_link'][$lang] = 0;
1860 ($lang_page = $this->getLanguagePage($lang, [
'deleted' => -1]))
1861 && is_array($lang_page->extra[
'language_link'])
1862 && $lang_page->extra[
'language_link'][$this->_site->language]
1865 $extra = $lang_page->extra;
1866 $extra[
'language_link'][$this->_site->language] = 0;
1867 $extra[
'language_link'][$standard] = 1;
1868 $extra[
'language_standard'] = $standard;
1870 $lang_page->update(array(
'extra' => $extra));
1875 $lang_page = $this->getLanguagePage($standard, [
'deleted' => -1]);
1876 $this->extra[
'language_link'] = $lang_page->extra[
'language_link'];
1877 $this->extra[
'language_standard'] = $lang_page->extra[
'language_standard'];
1880 $parents = $this->getParents(
1883 'where' =>
"type != '_keywords/entry'"
1891 if ($parent && $parents->numRecords() > 1)
1893 $this->unlinkFrom($parent->field[
'id']);
1897 $destroy_ids = array();
1898 if (!empty($this->extra[
'workflow_page'])) {
1899 $destroy_ids[] = $this->extra[
'workflow_page'];
1901 if (!empty($this->extra[
'release_ids'])) {
1902 $destroy_ids = array_merge($destroy_ids, $this->extra[
'release_ids']);
1904 foreach ($destroy_ids as $destroy_id) {
1905 if ($destroy_page = $this->_site->getPage($destroy_id, array(
1906 'only_active' =>
false,
1910 $destroy_page->destroy(
true);
1915 $field[
'deleted'] = 1;
1916 $extra = $this->extra;
1917 unset($extra[
'workflow_page'], $extra[
'release_ids']);
1918 $this->update(array(
'field' => $field,
'extra' => $extra));
1923 if ($this->isClone()) {
1924 $org = $this->getCloneOriginal();
1925 $del_clone = $this->getParents(array(), array(
1929 $del_id = $del_clone->field[
'id'];
1931 $del_url = $this->getCloneUrl();
1933 $clones = array_filter(array_unique(explode(
',', $org->extra[
'clones'])));
1934 $new_clones = array();
1935 foreach ($clones as $clone_url) {
1936 if (!in_array($clone_url, array($del_id, $del_url))) {
1937 $new_clones[] = $clone_url;
1941 $org->extra[
'clones'] = implode(
',', $new_clones);
1942 $org->updateExtra($org->extra);
1947 if ($this->isReleaseCopy()) {
1949 ($org = $this->_site->getPage($this->extra[
'release_id'], array(
1950 'only_active' =>
false,
1954 && is_array($org->extra[
'release_ids'])
1956 $org->extra[
'release_ids'] = array_values(array_diff($org->extra[
'release_ids'], array($this->field[
'id'])));
1957 $org->update(array(),
true,
true);
1970 if ($this->getSite()->admin[
'keyword_register_own_site']) {
1971 $keyword_parents = $this->getParents([
'where' =>
"type = '_keywords/entry'"]);
1973 if ($keyword_parents->numRecords() > 0) {
1974 foreach ($keyword_parents as $keyword_parent) {
1975 if ($keyword_parent->isClone() && !$keyword_parent->hasChildren()
1976 && $keyword_parent->getCloneOriginal()->getSite()->name != $this->getSite()->admin[
'keywords'][
'site']) {
1977 $this->_deleteCloneKeywords($this, $keyword_parent);
1978 } elseif (!$keyword_parent->isClone() && $keyword_parent->extra[
'clones']) {
1979 $keyword_clones = $keyword_parent->getClones();
1980 foreach ($keyword_clones as $keyword_clone) {
1981 if ($keyword_clone->getSite()->name != $keyword_parent->getSite()->admin[
'keywords'][
'site']
1982 && !$keyword_clone->hasChildren()) {
1983 $this->_deleteCloneKeywords($keyword_parent, $keyword_clone);
1991 $this->replicate(
'delete', $parent, $nostart, $keeplinks, $query);
2003 $db = new_db_connection();
2005 $this->message =
'Diese Seite wurde vernichtet.';
2012 if ($this->field[
'type'] ==
'_keywords/entry') {
2013 $query[
'where'] =
"type = '_keywords/entry'";
2016 $pages = $this->getChildren($query, array(
'deleted' => 1));
2017 $del_array = array();
2018 foreach($pages as $page) {
2019 $del_array[] = $page;
2021 foreach($del_array as $page) {
2022 $page->destroy(
false, $recursive);
2023 $this->message =
'Diese Seite wurde inklusive Unterseiten erfolgreich vernichtet.';
2027 $parents = $this->getParents(array(), array(
'deleted' => -1));
2028 foreach ($parents as $parent) {
2029 $this->unlinkFrom($parent->field[
'id']);
2034 'table' => $this->_site->pageTable,
2035 'where' =>
"id=".$this->field[
'id']
2038 'table' => $this->_site->pageTable.
'_v',
2039 'where' =>
"id=".$this->field[
'id']
2042 'table' => $this->_site->pageTable.
'_rights',
2043 'where' =>
"page_id=".$this->field[
'id']
2046 'table' => $this->_site->pageTable.
'_users',
2047 'where' =>
"page_id=".$this->field[
'id']
2050 'table' => $this->_site->pageTable.
'_children',
2051 'where' =>
'page_id='.$this->field[
'id'].
' OR child='.$this->field[
'id']
2054 if ($db->tableExists($this->_site->pageTable.
'_extra'))
2057 'table' => $this->_site->pageTable.
'_extra',
2058 'where' =>
'page_id='.$this->field[
'id']
2064 $this->destroyFile();
2067 $this->getMediapool()->clear(
'', [],
false);
2070 $this->removeUrls();
2073 require_once(
'base/Ego_Search_Factory.php');
2076 $search->delete($this->field[
'id']);
2077 }
catch (Exception $e) {
2081 $this->message .=
' Eine Wiederherstellung ist nicht möglich.';
2093 public function destroy($force=
false, $recursive=
true, $destroy_links=
true) {
2094 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
2095 $GLOBALS[
'__egotec_skip_replication'] =
'destroy';
2098 if ($this->isRoot()) {
2101 $this->archiveOnly =
false;
2105 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$GLOBALS[
'site']->name.
'/live.'.$this->_site->name.
'_'.$this->_site->language.
'.'.$cluster[
'id'].
'.up.date';
2106 if (file_exists($log_filename)) {
2107 $time[] = file_get_contents($log_filename);
2113 if (count($time) > 0) {
2114 $live_date = $time[0];
2116 $live_date = date(
'Y-m-d H:i:s', time());
2120 $live_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->_site->name.
'/'.
'live.'.$this->_site->name.
'_'.$this->_site->language.
'.date';
2122 if(file_exists($live_date_file)) {
2123 $live_date = file_get_contents($live_date_file);
2125 $live_date = date(
'Y-m-d H:i:s', time());
2131 ($GLOBALS[
'egotec_conf'][
'liveserver'] && !$this->getSite()->admin[
'live'][
'live_only'])
2132 || $this->field[
'm_date'] > $live_date
2133 || !$this->field[
'deleted']
2136 return $this->
delete();
2141 && is_array($this->extra[
'language_link'])
2142 && $this->extra[
'language_standard'] == $this->_site->language
2150 foreach($this->_site->getLanguages() as $lang) {
2151 $flag = !empty($this->extra[
'language_link'][$lang]);
2152 if ($flag && $lang != $this->_site->language) {
2154 if ($lang_page = $this->getLanguagePage($lang, array(
'deleted' => -1,
'auth_or' =>
'1=1'))) {
2155 $lang_page->_destroyEntry($recursive);
2167 $this->replicate(
'destroy', $force, $recursive);
2169 $this->_destroyEntry($recursive);
2179 function undelete($recursive =
false, $query = array()) {
2180 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
2181 $GLOBALS[
'__egotec_skip_replication'] =
'undelete';
2185 $this->message =
'Diese Seite wurde erfolgreich wiederhergestellt.';
2188 ($this->extra[
'language_standard']==$this->_site->language
2189 || $this->_site->admin[
'multi_lang'][
'auto_link'])
2190 && is_array($this->extra[
'language_link'])
2192 foreach($this->_site->getLanguages() as $lang) {
2193 $flag = ($this->extra[
'language_link'] && !empty($this->extra[
'language_link'][$lang]))
2194 || $lang == $this->extra[
'language_standard'];
2195 if ($flag || $this->_site->admin[
'multi_lang'][
'auto_link']) {
2196 $lang_page = $this->getLanguagePage($lang, array(
'deleted' => -1));
2197 if (!is_object($lang_page)) {
2200 $lang_page->restore();
2202 $pages = $lang_page->getDescendants(array(), array(
2204 'children_query' => $query
2206 foreach ($pages as $page)
2216 $pages = $this->getDescendants(array(), array(
2218 'children_param' => array(
'deleted' => -1),
2219 'children_query' => $query
2221 if ($pages->numRecords()>0) {
2222 $this->message =
'Diese Seite wurde inklusive Unterseiten erfolgreich wiederhergestellt.';
2224 foreach ($pages as $page) {
2229 $this->replicate(
'undelete', $recursive, $query);
2237 private function restore() {
2238 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
2239 $GLOBALS[
'__egotec_skip_replication'] =
'restore';
2242 $inactive = $this->field[
'inactive'] == self::RELEASE_FLAG ?
2243 self::RELEASE_FLAG :
2244 self::INACTIVE_FLAG;
2245 if ($this->field[
'type'] ==
'_keywords/entry') {
2246 $inactive = self::ACTIVE_FLAG;
2248 $field = array(
'inactive' => $inactive,
'deleted' => 0);
2249 if (!empty($this->field[
'url']) && !$this->isUniqueUrl($this->field[
'url'])) {
2255 $field[
'parents'] = $this->_site->rootId;
2256 foreach ($this->getParents(array(), array(
'deleted' => 0)) as $parent) {
2257 unset($field[
'parents']);
2261 $this->updateField($field,
false);
2263 $this->replicate(
'restore');
2272 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
2273 $GLOBALS[
'__egotec_skip_replication'] =
'unlinkFrom';
2276 $this->_removeParent($remove_from);
2277 if (!$this->field[
'deleted']) {
2279 $parents = $this->getParents(array(
'fields' =>
'id'), array(
2284 if (!$parents->next()) {
2289 $this->replicate(
'unlinkFrom', $remove_from);
2300 protected function _updateField($field, $update=
true, $asis=
false, $silent=
false) {
2301 if (!$asis && $field[
'url'] && $field[
'id'] && $this->field[
'url'] != $field[
'url']) {
2303 'table' => $this->_site->name.
'_'.$this->_site->language,
2304 'fields' =>
'id, url',
2305 'where' =>
'url=:url'.
2309 'url' => $field[
'url'],
2310 'id' => $field[
'id']
2313 if ($this->extra[
'original_id']) {
2314 $query[
'where'].=
' AND id!=:originalid';
2315 $query[
'bind'][
'originalid'] = $this->extra[
'original_id'];
2317 $db = new_db_connection($query);
2318 if ($db->nextRecord()) {
2319 $this->message.= $GLOBALS[
'auth']->translate(
'Die URL konnte nicht gespeichert werden, weil sie schon vorhanden ist!') .
'\n';
2320 $field[
'url'] = $this->field[
'url'];
2325 if (isset($field[
'name'])) {
2326 $field[
'name'] = strip_tags($field[
'name']);
2327 if (in_array((isset($field[
'type']) ? $field[
'type'] : $this->field[
'type']), array(
'multimedia/category',
'multimedia/file',
'multimedia/image'))) {
2328 $field[
'name'] = strtr($field[
'name'],
'\/:*?"<>|',
'_________');
2333 if ($this->_site->admin[
'editor'][
'plaintext']) {
2334 if (isset($field[
'title'])) {
2335 $field[
'title'] = strip_tags($field[
'title']);
2337 if (isset($field[
'short']) && !$this->_site->admin[
'editor'][
'short'] && !$GLOBALS[
'egotec_conf'][
'editor'][
'short']) {
2338 $field[
'short'] = strip_tags($field[
'short']);
2343 if (isset($field[
'type']) && empty($field[
'type'])) {
2344 $field[
'type'] = !empty($this->field[
'type']) ? $this->field[
'type'] :
'page';
2347 $this->_cleanEmptyContent($field);
2349 $this->field = array_merge($this->field, $field);
2352 $this->_changeEntry($field, $asis, $silent);
2364 if ($this->_site->admin[
'keyword_register_own_site']) {
2365 $keywords = $this->_site->getPages([
'where' =>
"type = '_keywords/list'"])->nextPage();
2368 $abbreviations = $this->_site->getPages([], [
2369 'extra' =>
"type = '_keywords/entry' AND deleted = 0 AND extra.abbreviation = 1"
2373 $old_abbreviations = [];
2374 $new_abbreviations = [];
2375 $current_abbreviations = $this->getParents([
2376 'where' =>
"type = '_keywords/entry'"
2378 foreach ($current_abbreviations as $current_abbreviation) {
2379 if ($current_abbreviation->extra[
'abbreviation']) {
2380 $old_abbreviations[] = $current_abbreviation->field[
'id'];
2384 foreach ($abbreviations as $abbreviation) {
2386 $words = [$abbreviation->field[
'name']];
2389 if ($abbreviation->extra[
'synonym']) {
2390 require_once
'base/Ego_Combo.php';
2391 $combo =
new Ego_Combo($abbreviation->extra[
'synonym']);
2392 foreach ($combo->getText() as $text) {
2393 $words[] = (string) $text;
2398 $search =
function($value) use (&$search, $words) {
2399 if (is_array($value)) {
2400 foreach ($value as $v) {
2406 return is_string($value)
2407 && preg_match(
'/>?[^<]*?\W*(' . implode(
'|', array_map(
function($v) {
2408 return preg_quote($v,
'/');
2409 }, $words)) .
')\W*[^>]*?<?/is', $value);
2413 $search($this->field[
'name'])
2414 || $search($this->field[
'title'])
2415 || $search($this->field[
'short'])
2416 || $search($this->field[
'content'])
2417 || $search($this->field[
'extra'])
2420 if (!$this->hasParent($abbreviation->field[
'id'])) {
2421 $this->addParent($abbreviation->field[
'id'], $asis);
2423 $new_abbreviations[] = $abbreviation->field[
'id'];
2424 } elseif ($this->hasParent($abbreviation->field[
'id'])) {
2426 $this->delParent($abbreviation->field[
'id'], $asis);
2430 $diff1 = array_diff($old_abbreviations, $new_abbreviations);
2431 $diff2 = array_diff($new_abbreviations, $old_abbreviations);
2432 return !empty($diff1) || !empty($diff2);
2447 $db = new_db_connection([
2448 'table' => $this->_site->pageTable .
'_children',
2449 'where' =>
'page_id = :page_id',
2451 'page_id' => $this->field[
'id']
2453 'order' =>
'idx ASC'
2455 while ($db->nextRecord()) {
2456 if (!in_array($db->Record[
'child'], $children)) {
2457 array_splice($children, (
int)$db->Record[
'idx'], 0, $db->Record[
'child']);
2462 $ancestors_iterator = $this->getAncestors(
2463 array(
'fields' =>
'id'),
2464 array(
'auth_or' =>
'1=1',
'children_param' => array(
'auth_or' =>
'1=1'))
2466 $ancestors = array();
2467 foreach ($ancestors_iterator as $ancestor_page)
2469 $ancestors[] = $ancestor_page->field[
'id'];
2471 $ancestors[] = $this->field[
'id'];
2473 $db = new_db_connection();
2475 $table = $this->_site->pageTable;
2477 'table' => $table.
'_children',
2478 'where' =>
'page_id='.$this->field[
'id']
2480 $children = array_unique($children);
2482 foreach ($children as $child) {
2484 if (in_array($child, $ancestors)) {
2485 egotec_error_log(
'infinite loop prevention at children: '.$this->_site->pageTable.
' '.$this->field[
'id'].
','.$child);
2488 'table' => $table.
'_children',
2489 'set' => array(
'page_id' => $this->field[
'id'],
'idx' => $idx,
'child' => $child)
2497 $this->_updateCloneChildren();
2499 $this->_clearCache();
2508 if (empty($parents)) {
2509 egotec_error_log(
'empty parents: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id']);
2512 $current_parents = array();
2513 $db = new_db_connection(array(
2514 'table' => $this->_site->pageTable .
'_children',
2515 'where' =>
'child = :child',
2517 'child' => $this->field[
'id']
2520 while ($db->nextRecord()) {
2521 $current_parents[] = $db->Record[
'page_id'];
2524 $remove_parents = array();
2525 foreach ($current_parents as $current_parent) {
2526 $key = array_search($current_parent, $parents);
2528 unset($parents[$key]);
2531 $remove_parents[] = $current_parent;
2534 foreach ($parents as $parent_id) {
2536 if ($parent_id!=$this->field[
'id']) {
2537 if ($this->_addParent($parent_id)) {
2541 egotec_error_log(
'infinite loop prevention at parents: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id'].
','.$parent_id);
2545 if ($num_parents == 0) {
2546 egotec_error_log(
'empty parents 2: '.print_r($parents,
true).
' / '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id']);
2550 foreach ($remove_parents as $remove_parent) {
2551 $this->_removeParent($remove_parent);
2561 private function _removeParent($parent_id) {
2562 $db = new_db_connection();
2564 'table' => $this->_site->pageTable.
'_children',
2565 'where' =>
'page_id = '.$parent_id.
' AND child = '.$this->field[
'id']
2567 $this->_site->clearCache();
2569 $parent = $this->_site->getPage($parent_id);
2571 if (isset($parent) && isset($this->extra[
'main_category']) && $this->extra[
'main_category'] == $parent->field[
'id']) {
2573 unset($this->extra[
'main_category']);
2574 $this->update([],
true,
true);
2581 if ($parent && $parent->field[
'type'] ==
'_keywords/entry' && $parent->isClone()
2582 && $this->_site->admin[
'keyword_register_own_site'] && $parent->getCloneOriginal()->getSite()->name != $this->_site->admin[
'keywords'][
'site']
2583 && !$parent->hasChildren()) {
2584 $this->_deleteCloneKeywords($this, $parent);
2585 } elseif ($parent && $parent->extra[
'clones'] && !$this->isReleaseCopy() && !$this->isWorkflowCopy()) {
2587 $clones = explode(
',', $parent->extra[
'clones']);
2588 foreach ($clones as $clone_url) {
2595 'deleted_or' =>
'1=1',
2597 'only_active' =>
false
2604 if ($parent_clone && ($parent->extra[
'clone_children_' . $clone_url] || $parent_clone->field[
'type'] ==
'_keywords/entry')) {
2605 foreach ($parent_clone->getChildren([], [
2607 'deleted_or' =>
'1=1',
2609 'only_active' =>
false
2611 if (in_array($clone->getCloneUrl(), explode(
',', $this->extra[
'clones']))) {
2613 if ($clone->hasMultiParents()) {
2614 $clone->delParent($parent_clone->field[
'id']);
2620 if ($parent_clone->field[
'type'] ==
'_keywords/entry' && !$parent_clone->hasChildren()
2621 && $clone->getSite()->admin[
'keyword_register_own_site']
2622 && $parent_clone->getCloneOriginal()->getSite()->name != $clone->getSite()->admin[
'keywords'][
'site']) {
2623 $this->_deleteCloneKeywords($clone, $parent_clone);
2626 $clone->destroyClone();
2640 private function _addParent($parent_id) {
2641 if ($this->field[
'id']==$parent_id) {
2642 egotec_error_log(
'infinite loop prevention: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id'].
','.$parent_id);
2645 $parent = $this->_site->getPage($parent_id, [
2647 'only_active' =>
false
2652 $ancestors = $this->_getAncestorsIds(
2654 array(
'fields' =>
'id'),
2655 array(
'auth_or' =>
'1=1')
2657 if (in_array($this->field[
'id'], $ancestors)) {
2660 if ($this->hasParent($parent_id)) {
2661 egotec_error_log(
'infinite loop prevention: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id'].
','.$parent_id);
2664 $db = new_db_connection();
2667 'table' => $this->_site->pageTable .
'_children',
2668 'where' =>
"page_id=" . $parent_id,
2669 'order' =>
'idx DESC',
2672 $idx = $db->nextRecord() ? $db->Record[
'idx'] + 1 : 0;
2674 'table' => $this->_site->pageTable .
'_children',
2675 'set' => [
'page_id' => $parent_id,
'idx' => $idx,
'child' => $this->field[
'id']],
2676 'primary' => [
'page_id',
'idx']
2680 if ($parent && $parent->field[
'type'] ==
'_keywords/entry' && !$this->isClone()) {
2681 $my_clones = $this->getClones();
2683 foreach ($my_clones as $my_clone) {
2684 $this->_updateCloneKeywords($this, $my_clone);
2686 } elseif ($parent && $parent->extra[
'clones'] && !$this->isReleaseCopy() && !$this->isWorkflowCopy()) {
2688 $clones = explode(
',', $parent->extra[
'clones']);
2689 foreach ($clones as $clone_url) {
2696 'deleted_or' =>
'1=1',
2698 'only_active' =>
false
2705 if ($clone && $clone->isClone() && $parent->extra[
'clone_children_' . $clone_url]) {
2707 $_clones = $this->getClones();
2708 foreach ($_clones as $_clone) {
2710 $_clone->getSite()->name == $clone->getSite()->name
2711 && !$_clone->hasParent($clone->field[
'id'])
2713 $_clone->addParent($clone->field[
'id']);
2718 $clone->createClone(
2721 $parent->extra[
'clone_rights_' . $clone_url],
2722 $parent->extra[
'clone_release_' . $clone_url]
2737 private function _clearCache($complete =
false) {
2738 if ($this->archiveOnly) {
2743 $this->_site->clearCache(!$complete && $this->field[
'type'] ==
'multimedia/image' ? $this->field[
'id'] : 0);
2747 foreach ($this->getLinkedPages() as $link) {
2748 foreach ($link[
'sources'] as $site_name => $source) {
2749 if ($site_name != $this->_site->name && !in_array($site_name, $cleared)) {
2750 $cleared[] = $site_name;
2752 $site =
new Site($site_name);
2772 if ($this->isReleaseCopy() || $this->isWorkflowCopy()) {
2775 if ($param[
'extra'][
'clones'] || $this->extra[
'clones']) {
2776 $this_page_url = $this->getCloneUrl();
2778 if (isset($param[
'extra'])) {
2779 $folders = explode(
',', $param[
'extra'][
'clones']);
2780 $param[
'extra'][
'clones'] =
'';
2781 $old_clones = array_filter(array_unique(explode(
',', $this->extra[
'clones'])));
2784 foreach ($old_clones as $old_c) {
2785 if ($old_c ==
'')
continue;
2787 if (!in_array($old_c, $folders)) {
2790 'deleted_or' =>
'1=1',
2792 'only_active' =>
false
2798 unset($param[
'extra'][
'clone_children_' . $old_c], $param[
'extra'][
'clone_rights_' . $old_c], $param[
'extra'][
'clone_release_' . $old_c]);
2801 } elseif (isset($this->extra[
'clones'])) {
2803 $folders = array_filter(array_unique(explode(
',', $this->extra[
'clones'])));
2809 $param[
'field'] = $param[
'field'] ? $param[
'field'] : $this->field;
2810 $param[
'extra'] = $param[
'extra'] ? $param[
'extra'] : $this->extra;
2813 foreach ($folders as $f) {
2815 $remove_parent =
false;
2821 'deleted_or' =>
'1=1',
2823 'only_active' =>
false
2828 $clones = array_filter(explode(
',', $param[
'extra'][
'clones']));
2829 $param[
'extra'][
'clones'] = implode(
',', array_unique(array_merge($clones, array($f))));
2834 'field' => $param[
'field'],
2835 'extra' => $param[
'extra']
2837 $p[
'extra'][
'clone_original'] = $this_page_url;
2838 unset($p[
'field'][
'id']);
2839 unset($p[
'field'][
'parents']);
2840 unset($p[
'field'][
'url']);
2841 unset($p[
'extra'][
'clones']);
2843 foreach ($p[
'extra'] as $key => $value) {
2845 strpos($key,
'clone_children_') === 0
2846 || strpos($key,
'clone_rights_') === 0
2847 || strpos($key,
'clone_release_') === 0
2849 unset($p[
'extra'][$key]);
2853 if (isset($p[
'extra'][
'main_category'])) {
2854 $main_category = $this->_site->getPage($p[
'extra'][
'main_category'], [
2856 'deleted_or' =>
'1=1',
2858 'only_active' =>
false
2861 unset($p[
'extra'][
'main_category']);
2863 if ($main_category) {
2864 $main_category_clones = $main_category->getClones();
2865 $clone_parents = $clone->getParents([
2867 'deleted_or' =>
'1=1',
2869 'only_active' =>
false
2872 foreach ($main_category_clones as $main_category_clone) {
2873 foreach ($clone_parents as $clone_parent) {
2874 if ($clone_parent->getIdentity() == $main_category_clone->getIdentity()) {
2875 $p[
'extra'][
'main_category'] = $clone_parent->field[
'id'];
2883 if ($clone->isClone()) {
2884 if (isset($clone->conf[
'edit_clone'])) {
2886 $combined_p = array();
2887 foreach ($p as $field => $values) {
2888 $combined_p[$field] = $values;
2889 if (is_array($values) && isset($clone->conf[
'edit_clone'][$field])) {
2890 $clone_edit = explode(
',', $clone->conf[
'edit_clone'][$field]);
2891 foreach ($clone_edit as $edit_key) {
2895 && $clone_value != $value
2898 $value = $clone_value;
2910 $clone_page_url = $clone->getCloneUrl();
2911 if ($param[
'extra'][
'clone_release_' . $clone_page_url]) {
2912 unset($combined_p[
'field'][
'release_from'], $combined_p[
'field'][
'release_until']);
2915 $clone->update($combined_p);
2917 $clone = $clone->newChild($p[
'field'], $p[
'extra']);
2922 $remove_parent =
true;
2926 $original = $clone->getCloneOriginal();
2930 $this->_updateCloneKeywords($original, $clone);
2934 $this->getMediapool()->copy($clone);
2937 $clone_page_url = $clone->getCloneUrl();
2938 $clones = array_filter(explode(
',', $param[
'extra'][
'clones']));
2939 $param[
'extra'][
'clones'] = implode(
',', array_unique(array_merge($clones, array($clone_page_url))));
2946 $param[
'extra'][
'clone_children_' . $clone_page_url] = $param[
'extra'][
'clone_children_' . $f_url];
2947 $param[
'extra'][
'clone_rights_' . $clone_page_url] = $param[
'extra'][
'clone_rights_' . $f_url];
2948 $param[
'extra'][
'clone_release_' . $clone_page_url] = $param[
'extra'][
'clone_release_' . $f_url];
2950 unset($param[
'extra'][
'clone_children_' . $f_url], $param[
'extra'][
'clone_rights_' . $f_url], $param[
'extra'][
'clone_release_' . $f_url]);
2953 if ($param[
'extra'][
'clone_release_' . $clone_page_url]) {
2954 $param[
'extra'][
'clone_release_from_' . $clone_page_url] = $param[
'extra'][
'clone_release_from_' . $f_url];
2955 $param[
'extra'][
'clone_release_until_' . $clone_page_url] = $param[
'extra'][
'clone_release_until_' . $f_url];
2957 unset($param[
'extra'][
'clone_release_from_' . $f_url], $param[
'extra'][
'clone_release_until_' . $f_url]);
2962 if ($param[
'extra'][
'clone_release_'.$clone_page_url]) {
2963 $clone_release = array();
2965 if ($param[
'extra'][
'clone_release_from_' . $clone_page_url]) {
2966 $clone_release[
'release_from'] = $param[
'extra'][
'clone_release_from_' . $clone_page_url];
2968 $clone_release[
'release_from'] =
'0000-00-00 00:00:00';
2971 if ($param[
'extra'][
'clone_release_until_' . $clone_page_url]) {
2972 $clone_release[
'release_until'] = $param[
'extra'][
'clone_release_until_' . $clone_page_url];
2974 $clone_release[
'release_until'] =
'0000-00-00 00:00:00';
2977 if (!empty($clone_release)) {
2978 $clone->updateField($clone_release);
2984 $param[
'extra'][
'clone_release_from_' . $clone_page_url],
2985 $param[
'extra'][
'clone_release_until_' . $clone_page_url]
2990 $param[
'extra'][
'clone_children_'.$clone_page_url] != $this->extra[
'clone_children_'.$clone_page_url]
2991 || $param[
'extra'][
'_update_child_clones']
2994 unset($param[
'extra'][
'_update_child_clones']);
2995 if ($param[
'extra'][
'clone_children_'.$clone_page_url] == 1)
2998 $this->_createChildClones($clone);
3003 $this->_destroyChildClones($clone);
3007 } elseif ($this->isClone()) {
3009 $type_info = $this->getTypeInfo();
3011 $type_info[
'clone_link']
3012 && ($page =
Ego_System::urltopage($this->extra[
'clone_original'], array(
'params' => array(
'param' => array(
3014 'deleted_or' =>
'1=1',
3016 'only_active' =>
false
3020 'field' => $param[
'field'],
3021 'extra' => $param[
'extra']
3023 $p[
'extra'][
'clones'] = $page->extra[
'clones'];
3024 foreach ($page->extra as $key => $value) {
3026 strpos($key,
'clone_children_') === 0
3027 || strpos($key,
'clone_rights_') === 0
3028 || strpos($key,
'clone_release_') === 0
3030 $p[
'extra'][$key] = $value;
3033 unset($p[
'field'][
'id']);
3034 unset($p[
'field'][
'parents']);
3035 unset($p[
'field'][
'url']);
3036 unset($p[
'extra'][
'clone_original']);
3040 $this->getMediapool()->copy($page);
3052 $clone_array = array_filter(array_unique(explode(
',', $this->extra[
'clones'])));
3053 foreach ($clone_array as $clone_index) {
3054 if ($clone_index ==
'')
continue;
3057 'deleted_or' =>
'1=1',
3059 'only_active' =>
false
3061 if (($clone && $target_site ==
'all') || ($clone && $target_site !=
'all' && $target_site == $clone->getSite()->name)) {
3079 public function createClone($page, $children =
false, $rights =
false, $release =
false, $multiple =
true) {
3080 $_REQUEST[
'var'][
'reload_dlg'] =
true;
3081 return $this->_createClone($page, $children, $rights, $release, $multiple);
3094 protected function _createClone($page, $children =
false, $rights =
false, $release =
false, $multiple =
true) {
3095 $clone_url = $page->getCloneUrl();
3099 $children2 = $this->getChildren(array(), array(
3102 'only_active' =>
false
3104 foreach ($children2 as $child) {
3105 if ($child->extra[
'clone_original'] == $clone_url) {
3113 'field' => $page->field,
3114 'extra' => $page->extra
3116 $p[
'extra'][
'clone_original'] = $clone_url;
3117 unset($p[
'field'][
'id']);
3118 unset($p[
'field'][
'parents']);
3119 unset($p[
'field'][
'url']);
3120 unset($p[
'extra'][
'clones']);
3122 $clone = $this->newChild($p[
'field'], $p[
'extra']);
3125 $extra = $page->extra;
3127 $clones = array_filter(explode(
',', $extra[
'clones']));
3128 $clone_page_url = $clone->getCloneUrl();
3130 $extra[
'clones'] = implode(
',', array_unique(array_merge($clones, array($clone_page_url))));
3132 $extra[
'clone_children_' . $clone_page_url] = 1;
3135 $extra[
'clone_rights_' . $clone_page_url] = 1;
3138 $extra[
'clone_release_' . $clone_page_url] = 1;
3145 $page->updateExtra($extra,
true,
true,
true);
3148 if (strpos($page->field[
'type'],
'_keywords/') !== 0) {
3149 $page->extra[
'_update_child_clones'] =
true;
3153 $this->_updateCloneKeywords($page, $clone);
3164 if (isset($this->extra[
'clones']) && !$this->isClone()) {
3165 foreach (explode(
',', $this->extra[
'clones']) as $clone_url) {
3166 if (!empty($this->extra[
'clone_rights_'.$clone_url])) {
3170 'only_active' =>
false
3173 $clone->setRightsArray($this->getRightsArray());
3174 $clone->setUsersArray($this->getUsersArray());
3187 if ($this->field[
'children_order'] ==
'children' && isset($this->extra[
'clones']) && !$this->isClone()) {
3188 foreach (explode(
',', $this->extra[
'clones']) as $clone_url) {
3189 if ($this->extra[
'clone_children_'.$clone_url]) {
3193 'only_active' =>
false
3196 $clone_children = [];
3197 $children = $this->getChildren([], [
3200 'only_active' =>
false
3203 foreach ($children as $child) {
3204 if (!empty($child->extra[
'clones'])) {
3205 foreach (explode(
',', $child->extra[
'clones']) as $clone_child_url) {
3209 'only_active' =>
false
3212 $clone_child_parents = $clone_child->getParents([], [
3215 'only_active' =>
false
3217 foreach ($clone_child_parents as $clone_child_parent) {
3218 if ($clone_child_parent->getIdentity() == $clone->getIdentity()) {
3219 $clone_children[] = $clone_child->field[
'id'];
3228 if (!empty($clone_children)) {
3229 $clone->updateChildren($clone_children);
3244 $children = $this->getChildren(array(), array(
3247 'only_active' =>
false
3250 foreach($children as $child) {
3253 $clones = $child->getClones();
3255 foreach ($clones as $clone) {
3257 $clone->getSite()->name == $parent->getSite()->name
3258 && !$clone->hasParent($parent->field[
'id'])
3260 $clone->addParent($parent->field[
'id']);
3266 $clone_child = $parent->getChildren(
3268 'where' =>
'name=:n AND a_date=:a',
3270 'n' => $child->field[
'name'],
3271 'a' => $child->field[
'a_date']
3279 if (!$clone_child->numRecords()) {
3280 $parent->createClone(
3283 !!$this->extra[
'clone_rights_'.$parent->getCloneUrl()],
3284 !!$this->extra[
'clone_release_'.$parent->getCloneUrl()]
3297 if ($clone->field[
'type'] !=
'_keywords/entry') {
3298 $keywords = $original->getParents([
'where' =>
"type = '_keywords/entry'"]);
3301 foreach ($keywords as $keyword) {
3302 $clones_keyword = $keyword->getClones($clone->getSite()->name);
3304 if ($clone->getSite()->admin[
'keyword_register_own_site'] && empty($clones_keyword)) {
3305 $keyword_list = $clone->getSite()->getPages([
'where' =>
"type = '_keywords/list'"])->nextPage();
3307 $createCloneKeywords =
function($keyword_list, $keyword, $siteName) {
3308 if (empty($keyword->getClones($siteName))) {
3309 $current_keyword = $keyword;
3310 $parent_keywords = [];
3313 while ($current_keyword = $current_keyword->getParents([
'where' =>
"type = '_keywords/entry'"])->nextPage()) {
3314 array_unshift($parent_keywords, $current_keyword);
3318 if (!empty($parent_keywords)) {
3319 foreach ($parent_keywords as $key => $parent_keyword) {
3321 if (!$parent_keyword->getClones($siteName)) {
3324 $current_keyword = $keyword_list->createClone($parent_keyword);
3327 $current_keyword = $current_keyword->createClone($parent_keyword);
3331 $current_keyword = $parent_keyword->getClones($siteName)[0];
3336 $current_keyword->createClone($keyword);
3339 $keyword_list->createClone($keyword);
3345 $createCloneKeywords($keyword_list, $keyword, $keyword_list->getSite()->name);
3348 if ($keyword_list->isClone()) {
3349 $original_keyword_list = $keyword_list->getCloneOriginal();
3351 $createCloneKeywords($original_keyword_list, $keyword, $original_keyword_list->getSite()->name);
3353 foreach ($original_keyword_list->getClones() as $keyword_list_clone) {
3354 if ($keyword_list->getSite()->name != $keyword_list_clone->getSite()->name) {
3355 $createCloneKeywords($keyword_list_clone, $keyword, $keyword_list_clone->getSite()->name);
3360 $clones_keyword = $keyword->getClones($clone->getSite()->name);
3363 if ($clones_keyword) {
3365 foreach ($clones_keyword as $clone_keyword) {
3366 if (!$clone->hasParent($clone_keyword->field[
'id'])) {
3367 $clone->addParent($clone_keyword->field[
'id']);
3382 $current_keyword = $clone_to_delete;
3383 $parent_keywords = [];
3385 while ($current_keyword = $current_keyword->getParents([
'where' =>
"type = '_keywords/entry'"])->nextPage()) {
3386 $parent_keywords[] = $current_keyword;
3389 $clone_to_delete->destroyClone();
3391 if (!empty($parent_keywords)) {
3392 foreach ($parent_keywords as $parent_keyword) {
3397 if ($parent_keyword->field[
'type'] ==
'_keywords/entry' && !$parent_keyword->hasChildren()
3398 && $clone_check->getSite()->admin[
'keyword_register_own_site']
3399 && $parent_keyword->getCloneOriginal()->getSite()->name != $clone_check->getSite()->admin[
'keywords'][
'site']) {
3400 $parent_keyword->destroyClone();
3413 $children = $this->getChildren(array(), array(
3416 'only_active' =>
false
3419 foreach($children as $child) {
3421 $clone_child = $parent->getChildren(
3423 'where' =>
'name=:n AND a_date=:a',
3425 'n' => $child->field[
'name'],
3426 'a' => $child->field[
'a_date']
3434 if ($clone = $clone_child->nextPage()) {
3435 $clone->destroyClone();
3446 $_REQUEST[
'var'][
'reload_dlg'] =
true;
3447 return $this->_destroyClone();
3456 $page = $this->getCloneOriginal();
3460 $extra = $page->extra;
3461 $clones = explode(
',', $extra[
'clones']);
3462 $clone_page_url = $this->getCloneUrl();
3463 if (!in_array($clone_page_url, $clones)) {
3467 $new_clones = array();
3468 foreach($clones as $c) {
3469 if ($c != $clone_page_url) {
3474 $extra[
'clones'] = implode(
',', array_filter(array_unique($new_clones)));
3475 unset($extra[
'clone_children_' . $clone_page_url], $extra[
'clone_release_' . $clone_page_url]);
3477 $page->updateExtra($extra);
3493 $db = new_db_connection();
3494 if ($rights[
'_delete']) {
3495 $delete_query_where =
' AND perm in (\''.join(
'\',\
'', $rights[
'_delete']).
'\')
';
3496 unset($rights['_delete
']);
3498 $rights['rights
'] = array_merge($this->getRightsArray(),$rights['rights
']);
3499 if ($rights['rights
']) { // Gruppen und Rollen.
3500 $db->delete(array( // Alte Einträge löschen.
3501 'from
' => $this->_site->pageTable.'_rights
',
3502 'where
' => 'page_id=
'.$this->field['id'].$delete_query_where
3504 foreach ($rights['rights
'] as $right => $groups) {
3505 $is_null = true; // Zunächst von keiner Beschränkung ausgehen.
3506 foreach ($groups as $group) {
3507 if (!$group['group_id
'] || !$group['role_id
']) {
3508 if ($rights['users
'] && $rights['users
'][$right] && count($rights['users
'][$right]) != 0) {
3509 // es sind user vorhanden aber keine Group/Role Kombination
3510 $group['group_id
'] = $GLOBALS['egotec_conf
']['superuser
']['group
'];
3511 $group['role_id
'] = $GLOBALS['egotec_conf
']['superuser
']['role
'];
3515 if ($group['group_id
'] && $group['role_id
']) { // Keine leeren Einträge setzen.
3517 'table
' => $this->_site->pageTable.'_rights
',
3519 'page_id
' => $this->field['id'],
3521 'group_id
' => $group['group_id
'],
3522 'role_id
' => $group['role_id
']
3524 'primary
' => array('page_id
', 'perm
', 'group_id
', 'role_id
')
3526 $is_null = false; // Es wurde eine Beschränkung gesetzt.
3529 if ($is_null && strpos(Auth::NO_NULL_RIGHTS, ',
'.$right.',
')!==false) { // Bei einem Recht, das nicht per IS NULL abgefragt wird
3531 'table
' => $this->_site->pageTable.'_rights
',
3533 'page_id
' => $this->field['id'],
3535 'group_id
' => '*
', // *|* setzen.
3538 'primary
' => array('page_id
', 'perm
', 'group_id
', 'role_id
')
3544 if ($rights['users
']) {
3546 $db->delete(array( // Alte Einträge löschen.
3547 'from
' => $this->_site->pageTable.'_users
',
3548 'where
' => "page_id=".$this->field['id'].$delete_query_where
3550 foreach ($rights['users
'] as $right => $users) {
3551 if (is_array($users)) {
3552 foreach ($users as $user) {
3553 if ($user['user_id
']) { // Leere Einträge vermeiden
3555 'table
' => $this->_site->pageTable.'_users
',
3557 'page_id
' => $this->field['id'],
3559 'user_id
' => trim($user['user_id
'],"'"),
3568 // Multimedia Bilder vererben das Ansichtsrecht an alle Bildausschnitte
3569 if ($this->field['type'] == 'multimedia/image') {
3570 $children = $this->getChildren(array(
3571 'where' => "type =
'multimedia/image'"
3575 'only_active' => false
3577 foreach ($children as $child) {
3578 if ($child->extra['crop_image']) {
3579 $child->update(array(
3582 'view' => $rights['rights']['view'] ? $rights['rights']['view'] : array()
3585 'view' => $rights['users']['view'] ? $rights['users']['view'] : array()
3593 // Die eingetragenen Rechte klonen
3595 $this->_updateCloneRights();
3598 if (!isset($this->field['inactive']) || !$this->field['inactive']) {
3599 $this->_clearCache();
3615 protected function _update($param, $matrix_flag = true, $asis = false, $silent = false) {
3616 $language_standard = $this->extra['language_standard'];
3618 // Automatisch übersetzen
3619 $param = $this->autoTranslate($param, $this->_site->language, !($param['translate_no_diff'] === true));
3621 if (!$asis) { // @TODO Ist das notwendig?
3622 $this->_updateClones($param);
3625 if (isset($param['extra']) && $param['field'] && (int)$param['extra']['original_id']) { // Workflowkopien sind immer inaktiv;
3626 $param['field']['inactive'] = $this->isReleaseCopy() ? self::RELEASE_FLAG : self::INACTIVE_FLAG;
3628 if (isset($param['extra'])) {
3629 $new_extra = array();
3630 if (is_array($param['extra'])) {
3631 $new_extra = Ego_System::cleanTypes($param['extra']);
3633 $area_password_changed = 0;
3634 if($new_extra['area_pw'] != '') {
3635 $salt = sha1($this->field['id']);
3636 $new_extra['area_password'] = crypt($new_extra['area_pw'], '$6$rounds=5000$' . $salt . '$');
3637 $area_password_changed = 1;
3640 if ($new_extra['area_pw_reset'] == true) {
3641 unset($new_extra['area_pw_reset']);
3642 unset($new_extra['area_password']);
3643 $area_password_changed = 2;
3646 unset($new_extra['area_pw']);
3648 if ($area_password_changed > 0) {
3649 foreach ($this->getChildren() as $child) {
3650 $child_extra = $child->extra;
3651 switch ($area_password_changed) {
3653 $child_extra['area_password'] = $new_extra['area_password'];
3656 unset($child_extra['area_password']);
3658 $child->updateExtra($child_extra, true, $asis, $silent);
3663 // Vererbte Blöcke nicht speichern
3664 if (!empty($new_extra['_inherited'])) {
3665 $blocks = $new_extra['_blocks'];
3666 $contents = $new_extra['_contents'];
3667 foreach ($new_extra['_inherited'] as $orient => $checksum) {
3668 if ($blocks[$orient] && $contents[$orient]) {
3669 $checksum_blocks = Ego_System::getChecksum($blocks[$orient]);
3670 $checksum_contents = Ego_System::getChecksum($contents[$orient]);
3671 if ($checksum_blocks == $checksum['blocks'] && $checksum_contents == $checksum['contents']) {
3672 unset($new_extra['_blocks'][$orient], $new_extra['_contents'][$orient]);
3678 unset($new_extra['_inherited']);
3680 unset($new_extra['_asis']);
3682 $param['extra'] = $new_extra;
3684 if ($param['field'] || $param['extra']) {
3685 // Der Seitentyp wird gewechselt
3687 !empty($param['field']['type'])
3688 && $param['field']['type'] != $this->field['type']
3689 && $this->isFrontendAdmin()
3691 $this->field['type'] = $param['field']['type'];
3692 $this->_loadConfig();
3693 if (!empty($this->conf['default_layout'])) {
3694 // Das Standard Layout des neuen Seitentyps verwenden
3695 $param['extra'] = isset($param['extra'])
3698 $param['extra']['_layout'] = $this->conf['default_layout'];
3702 if ($param['field']['children']) {
3703 if (!isset($param['children'])) {
3704 $param['children'] = explode(',', trim($param['field']['children'], ','));
3706 unset($param['field']['children']);
3708 if ($param['field']['parents']) {
3709 if (!isset($param['parents'])) {
3710 $param['parents'] = explode(',', trim($param['field']['parents'], ','));
3712 unset($param['field']['parents']);
3715 if (isset($param['extra'])) {
3716 $param['field']['extra'] = serialize($param['extra']);
3719 $this->_updateField($param['field'], true, $asis, $silent);
3722 // Mediapool Aktionen ausführen
3723 if ($param['pool']) {
3724 // Dateien umbenennen
3725 if (is_array($param['pool']['rename'])) {
3726 foreach ($param['pool']['rename'] as $info) {
3727 if ($info['name'] != $info['new_name']) {
3728 $this->getMediapool()->edit($info['name'], array(
3729 'new_name' => $info['new_name']
3730 ), (string) $info['dir']);
3736 if ($param['children']) {
3737 $this->_updateChildren($param['children'], !($param['merge_children'] === false));
3739 if ($param['parents'] && $this->field['id'] != $this->_site->rootId) {
3740 $this->_updateParents($param['parents']);
3743 if ($param['rights']) {
3744 $this->_updateRights($param['rights'], $asis);
3747 // Schlagwörter automatisch hinzufügen
3748 $reload = $this->_updateKeywords($asis);
3752 && !$this->extra['crop_image'] // Ausschnitte legen keine Archive oder Sprachen an
3756 $this->_archiveEntry();
3758 // Die Inhalte der Standardsprache in die verknüpften Bereiche speichern.
3760 !$this->archiveOnly // Nicht für Zwischenspeicherungen
3761 && !$this->isWorkflowCopy()
3763 && $language_standard == $this->_site->language
3764 && is_array($param['extra']['language_link'])
3772 $clean_clones = function($extra) {
3773 unset($extra['clones'], $extra['area_domain']);
3774 foreach (array_keys($extra) as $key) {
3775 if (strpos($key, 'clone_') === 0) {
3776 unset($extra[$key]);
3782 $languages = array();
3783 $site_languages = $this->_site->getLanguages();
3784 foreach ($site_languages as $lang) {
3785 // #173630: Nur wenn es die Sprache auch noch gibt
3786 $matrix_page = $this->getLanguagePage($lang, array(
3789 'only_active' => false,
3792 $flag = $param['extra']['language_link'][$lang];
3793 if ($flag && $lang!=$this->_site->language) {
3795 $param['extra'] = $clean_clones(array_merge($this->extra, $param['extra']));
3796 if (!isset($param['rights'])) {
3797 $param['rights'] = [
3798 'rights' => $this->getRightsArray(),
3799 'users' => $this->getUsersArray()
3803 $matrix_param = $param;
3804 if (!empty($param['extra']['language_urls'][$lang])) {
3805 $matrix_param['field']['url'] = $param['extra']['language_urls'][$lang];
3808 // Meta URL für Sprachverknüpfung setzen
3809 $matrix_page->update($matrix_param, false, $asis, $silent);
3811 // Mediapool kopieren
3812 $this->getMediapool()->copy($matrix_page, '', false, false, true, true, false, '', false);
3814 // Wenn bereits eine Sprachkopie existiert und darauß eine Sprachverknpüfung wird, dann alle Multimedia Dateien löschen
3815 if ($this->_site->site['type'] == 'media') {
3816 $media_dir = $GLOBALS['egotec_conf']['var_dir'] . 'media' . DIRECTORY_SEPARATOR . $this->_site->name;
3817 $source = $media_dir . DIRECTORY_SEPARATOR . $matrix_page->getMediaFilename(true);
3819 foreach (glob($source . '*') as $media_file) {
3820 @unlink($media_file);
3823 } elseif (!$this->isReleaseCopy()) { // Wenn die Seite noch nicht in dieser Sprache vorhanden ist, dann wird diese erzeugt (außer für Freigabekopien).
3824 $matrix_parent = $this->getParents(array(), array('auth_or' => '1=1'));
3825 if ($matrix_parent) {
3826 $matrix_parent = $matrix_parent->nextPage(); /* @var $matrix_parent Page */
3827 if ($matrix_parent) {
3828 $matrix_parent = $matrix_parent->getLanguagePage($lang, array(
3831 'only_active' => false,
3832 'deleted_or' => '1=1'
3836 if ($matrix_parent->field['deleted']) {
3837 // Elternseite wiederherstellen
3838 $matrix_parent->undelete();
3840 if ($matrix_page = $matrix_parent->newChild($this->field, $clean_clones($this->extra))) {
3841 // Mediapool kopieren
3842 $this->getMediapool()->copy($matrix_page, '', false, false, true, true, false, '', false);
3848 $languages[] = $lang;
3850 elseif (!$this->field['deleted'] && $lang!=$this->_site->language) {
3851 // #204196: Nur wenn diese Sprache keine Sprachverknüpfung (und nicht gelöscht) ist
3854 !Ego_System::isEqual($matrix_page->extra['language_link'], $param['extra']['language_link'])
3855 || !Ego_System::isEqual($matrix_page->extra['language_standard'], $param['extra']['language_standard'])
3857 $matrix_page_link = $matrix_page->extra['language_link'][$lang];
3859 $matrix_page_extra = $matrix_page->extra;
3860 $matrix_page_extra['language_link'] = $param['extra']['language_link'];
3861 $matrix_page_extra['language_standard'] = $param['extra']['language_standard'];
3863 $matrix_page->updateExtra($clean_clones($matrix_page_extra), false, $asis, $silent);
3865 // Aus einer existierenden Sprachverknüpfung wird eine Sprachkopie
3866 if (!$param['extra']['language_link'][$lang] && $matrix_page_link) {
3867 // Multimedia Dateien müssen kopiert werden
3868 if ($this->_site->site['type'] == 'media') {
3869 $media_dir = $GLOBALS['egotec_conf']['var_dir'] . 'media' . DIRECTORY_SEPARATOR . $this->_site->name;
3870 $source = $media_dir . DIRECTORY_SEPARATOR . $this->getMediaFilename();
3872 if (Ego_System::file_exists($source)) {
3873 $dest = $media_dir . DIRECTORY_SEPARATOR . $matrix_page->getMediaFilename(true);
3884 $media_dir . DIRECTORY_SEPARATOR . $matrix_page->getMediaFilename(
3886 '_'.strtotime($matrix_page->field['m_date'])
3900 $this->message.= "\n
".$GLOBALS['auth']->translate('Folgende Sprachen wurden auch geändert:').' '.join(', ', $languages)."\n
";
3901 $this->_updatedLinkLanguages = $languages;
3906 // Wird ein Multimedia Bild gespeichert, muss für alle untergeordneten Ausschnitte
3907 if ($this->field['type'] == 'multimedia/image') {
3908 foreach ($this->getChildren() as $child) {
3909 // ... die Spracheinstellungen vererbt werden
3910 if (isset($param['extra'])) {
3911 $extra = $child->extra;
3912 $extra['language_link'] = $param['extra']['language_link'];
3913 $extra['language_standard'] = $param['extra']['language_standard'];
3914 $child->updateExtra($extra, true, $asis, $silent);
3917 // ... der Cache gelöscht werden
3918 $this->_site->clearCache($child->field['id']);
3922 $this->hookUpdate();
3923 $this->updateIndex();
3926 Ego_Queue::add([$this, 'convertImages']);
3937 function hookUpdate($hook = 'update') {
3938 // Zwischenspeicherungen führen keine Hooks aus
3939 if ($hook == 'update' && $this->archiveOnly) {
3943 $cache_key = $this->_site->name.'/'.$this->field['type'].'/'.$hook;
3944 $hook_cache = array();
3945 if (isset($GLOBALS['hook_cache'][$cache_key])) {
3946 $hook_cache = $GLOBALS['hook_cache'][$cache_key];
3949 $GLOBALS['egotec_conf']['lib_dir'] . 'type/site/' => 0, // System
3950 $GLOBALS['egotec_conf']['pub_dir'].'theme/'.$this->_site->theme.'/site/' => 'theme', // pub theme
3951 $GLOBALS['egotec_conf']['site_dir'] . '_global/' => 'global', // Global
3952 $GLOBALS['egotec_conf']['site_dir'] . $this->_site->name . '/' => 'misc' // Mandant
3954 foreach ($dirs as $dir => $flag) {
3955 if ($flag == 'global' && !$this->_site->globalAllowed()) {
3958 $script_path = $dir . 'admin/' . $hook . '.php';
3959 if ($flag && Ego_System::file_exists($script_path)) {
3960 $hook_cache[] = array('path' => $script_path, 'flag' => $flag, 'type' => false);
3962 $script_path = $dir . $this->field['type'] . '/admin/' . $hook . '.php';
3963 if (Ego_System::file_exists($script_path)) {
3964 $hook_cache[] = array('path' => $script_path, 'flag' => $flag ? $flag : 'misc', 'type' => true);
3967 if (!isset($GLOBALS['hook_cache'])) {
3968 $GLOBALS['hook_cache'] = array();
3970 $GLOBALS['hook_cache'][$cache_key] = $hook_cache;
3973 if (!$this->field['type']) {
3974 throw new Exception();
3976 foreach ($hook_cache as $script_path) {
3977 $call_func = $script_path['type']
3978 ? 'site_'.$hook.'_'.str_replace('/', '_', $this->field['type']).'_'.$script_path['flag']
3979 : 'site_' . $hook . '_' . $script_path['flag'];
3980 if (!function_exists($call_func)) {
3981 require_once($script_path['path']);
3983 if (function_exists($call_func)) {
3988 if (!isset($GLOBALS['hook_cache'])) {
3989 $GLOBALS['hook_cache'] = array();
3991 $GLOBALS['hook_cache'][$cache_key] = $hook_cache;
3994 if (!$GLOBALS['egotec_setup']) {
3995 // Alle Verweise dieser Page sammeln
3996 if ($hook == 'update') {
3997 Ego_Queue::add(array($this, 'updateLinks'));
4000 if ($GLOBALS['egotec_conf']['rewrite_engine'] == 'url') {
4004 || $this->field['inactive']
4006 && !$this->isWorkflowCopy()
4008 // URLs dieser Page archivieren
4009 Ego_Queue::add(array($this, 'archiveUrls'));
4011 // URLs dieser Page aktualisieren
4012 if ($hook == 'newchild') {
4013 // Direkt ausführen, da die URLs direkt benötigt werden könnten
4014 $this->updateUrls();
4016 Ego_Queue::add(array($this, 'updateUrls'));
4030 function updateField($field, $matrix_flag = true, $asis = false, $silent = false) {
4031 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4032 $GLOBALS['__egotec_skip_replication'] = 'updateField';
4035 $this->replicate('updateField', $field, $matrix_flag, $asis, $silent);
4037 return $this->update(array('field' => $field), $matrix_flag, $asis, $silent);
4047 function updateChildren($children) {
4048 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4049 $GLOBALS['__egotec_skip_replication'] = 'updateChildren';
4052 $this->replicate('updateChildren', $children);
4054 return $this->update(array('children' => $children), true, true);
4063 function updateParents($parents) {
4064 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4065 $GLOBALS['__egotec_skip_replication'] = 'updateParents';
4068 $this->replicate('updateParents', $parents);
4070 return $this->update(array('parents' => $parents), true, true);
4081 function updateExtra($extra, $matrix_flag = true, $asis = false, $silent = false) {
4082 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4083 $GLOBALS['__egotec_skip_replication'] = 'updateExtra';
4086 $this->replicate('updateExtra', $extra, $matrix_flag, $asis, $silent);
4088 return $this->update(array('extra' => $extra), $matrix_flag, $asis, $silent);
4102 function updateRights($rights, $matrix_flag = true, $asis = false) {
4103 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4104 $GLOBALS['__egotec_skip_replication'] = 'updateRights';
4107 $this->replicate('updateRights', $rights, $matrix_flag, $asis);
4109 return $this->update(array('rights' => $rights), $matrix_flag, $asis);
4124 function update($param = array(), $matrix_flag = true, $asis = false, $silent = false) {
4125 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4126 $GLOBALS['__egotec_skip_replication'] = 'update';
4129 if (empty($param)) {
4130 // Aktuelle Daten speichern
4131 $reload = $this->_update(array(
4132 'field' => $this->field,
4133 'extra' => $this->extra,
4135 'rights' => $this->getRightsArray(),
4136 'users' => $this->getUsersArray()
4138 ), $matrix_flag, $asis, $silent);
4140 $reload = $this->_update($param, $matrix_flag, $asis, $silent);
4142 if($this->field['deleted'] == "1
") {
4143 $this->hookUpdate("delete");
4144 $this->message.= $GLOBALS['auth']->translate('Die Seite wurde gelöscht.');
4147 $this->replicate('update', $param, $matrix_flag, $asis, $silent);
4159 public function updateIndex($search=null, $queue=true, $recursive=true) {
4161 // Zwischenspeicherungen aktualisieren nicht den Suchindex
4163 // Erfolgt der Aufruf über den Liveabgleich und ist die "ewige
" Cache aktiv, wird kein Suchindex aktualisiert
4164 || ($_SERVER['HTTP_X_SOAP_CALL'] == 'Replication' && $this->getSite()->getCache()->getEternal())
4165 || !empty($GLOBALS['__skip_update_index'])
4170 // Bei einer rekursiven Suchindex Aktualisierung sicherstellen, dass die selben Seiten nicht mehrfach aktualisiert werden
4171 if (isset($GLOBALS['__page_update_index_stack']) && in_array($this->getIdentity(), $GLOBALS['__page_update_index_stack'])) {
4174 if (!isset($GLOBALS['__page_update_index_stack'])) {
4175 $GLOBALS['__page_update_index_stack'] = [];
4177 $GLOBALS['__page_update_index_stack'][] = $this->getIdentity();
4180 require_once('base/Ego_Search_Factory.php');
4182 $search = Ego_Search_Factory::start($this->_site->pageTable.$this->getTableSuffix(), ['throw_exception' => true]);
4183 } catch (Exception $e) {
4184 // Ist die Suche nicht erreichbar, darf es hier zu keinem Abbruch kommen
4185 Ego_Action::add(Ego_Action::PAGE_UPDATE_INDEX, [
4186 'identity' => $this->getIdentity(),
4187 'recursive' => $recursive
4193 // Relevanz der Felder beachten
4195 Ego_Queue::add(array($search, 'update'), array($this->field['id'], $this, $this->_site->getSearchCount($this->extra['search_weight']), $recursive));
4198 $search->update($this->field['id'], $this, $this->_site->getSearchCount($this->extra['search_weight']), $recursive);
4208 public function convertImages($reset = false) {
4211 // Die relevanten Mandanten für die Einstellungen ermitteln
4213 if ($this->_site->site['type'] == 'media') {
4214 $convert_type = 'multimedia';
4216 foreach (Ego_System::getAllSites('', '', false, 'content') as $site) {
4218 $site->site['media'] == $this->_site->name
4219 && !empty($site->admin['image']['convert'])
4225 $this->_site->site['type'] == 'content'
4226 && !empty($this->_site->admin['mediapool']['active'])
4227 && !empty($this->_site->admin['image']['convert'])
4229 $convert_type = 'mediapool';
4231 $sites[] = $this->_site;
4234 // Liste aller bereits durchgeführten Umwandlungen
4237 foreach ($sites as $site) {
4240 $convert_type == 'multimedia'
4241 && $this->field['type'] == 'multimedia/image'
4243 || $convert_type == 'mediapool'
4245 require_once 'base/Ego_Output.php';
4247 foreach (explode(',', $site->admin['image']['convert']) as $format) {
4248 if (!in_array($format, $converted)) {
4249 switch ($convert_type) {
4253 !empty($this->field['extra']['convert_ignore'])
4254 && in_array($format, explode(',', $this->field['extra']['convert_ignore']))
4256 // Umwandlung ignorieren
4260 $output = new Ego_Output($this);
4261 $output->convertImage($format, $reset);
4266 $mediapool = $this->getMediapool();
4267 foreach ($mediapool->getDirs() as $dir) {
4268 foreach ($mediapool->list($dir) as $item) {
4271 && !empty($item['convertIgnore'])
4272 && in_array($format, $item['convertIgnore'])
4274 // Umwandlung ignorieren
4279 $output = new Ego_Output($this, $item['name'], $dir);
4280 $output->convertImage($format, $reset);
4284 $converted[] = $format;
4297 public function clearConvertedImages() {
4298 Ego_System::deldir($GLOBALS['egotec_conf']['var_dir']
4300 . $this->_site->name . '/'
4301 . $this->_site->language . '/'
4302 . $this->field['id']);
4318 function getChildren($query=array(), $param=array()) {
4319 $page_table = $this->_site->name.'_'.($param['lang']?$param['lang']:$this->_site->language);
4320 $children_table = $page_table.'_children';
4321 $query['table'] = $children_table;
4323 $query = $this->buildChildrenOrder($query, $param);
4325 $query['where'] = (isset($query['where'])?'('.$query['where'].') AND ':'').
4326 $children_table.'.page_id='.$this->field['id'].' AND '.$page_table.'.id='.$children_table.'.child';
4327 return $this->_site->getPages($query, $param);
4337 public function buildChildrenOrder($query=array(), $param=array()) {
4338 $page_table = $this->_site->name.'_'.($param['lang']?$param['lang']:$this->_site->language);
4339 $children_table = $page_table.'_children';
4340 $order = trim(isset($query['order'])?$query['order']:$this->field['children_order']);
4342 if ($order[strlen($order) -1]=='R') {
4343 // r steht für reverse
4344 $param['reverse'] = !$param['reverse'];
4345 $order = substr($order, 0, strlen($order) -1);
4349 $query['order'] = $page_table.'.title '.($param['reverse']?'desc':'asc');
4352 $query['order'] = $page_table.'.name '.($param['reverse']?'desc':'asc');
4355 $query['order'] = $page_table.'.a_date '.($param['reverse']?'desc':'asc');
4358 $query['order'] = $page_table.'.c_date '.($param['reverse']?'desc':'asc');
4360 case 'release_from':
4361 $query['order'] = $page_table.'.release_from '.($param['reverse']?'desc':'asc');
4363 case 'release_until':
4364 $query['order'] = $page_table.'.release_until '.($param['reverse']?'desc':'asc');
4367 $query['order'] = $page_table.'.order_field '.($param['reverse']?'desc':'asc');
4370 $query['order'] = $page_table.'.order_field '.($param['reverse']?'asc':'desc');
4373 $query['order'] = $page_table.'.type '.($param['reverse']?'desc':'asc').','.$page_table.'.name '.($param['reverse']?'desc':'asc');
4376 unset($query['order']);
4379 $query['order'] = $children_table.'.idx '.($param['reverse']?'desc':'asc');
4380 if (!isset($query['fields2'])) {
4381 $query['fields2'] = [];
4382 } elseif (is_string($query['fields2'])) {
4383 $query['fields2'] = [$query['fields2']];
4385 $query['fields2'][] = $children_table.'.idx';
4387 if ($query['order'] && $query['order']!='id') { // Um die rückwärts gerichtete Sortierung korrekt zu bekommen, muss immer noch nach der id sortiert werden.
4388 $query['order'].= ','.$page_table.'.id '.($param['reverse']?'desc':'asc');
4401 public function hasChildren($query = array(), $param = array()) {
4402 if (isset($this->field['has_children'])) {
4403 return !empty($this->field['has_children']);
4405 $children = $this->getChildren($query, $param);
4406 while ($children->nextPage()) {
4423 function getParents($query=array(), $param=array()) {
4424 $page_table = $this->_site->name.'_'.($param['lang']?$param['lang']:$this->_site->language);
4425 $children_table = $page_table.'_children';
4426 $query['table'] = $children_table;
4427 $query['where'] = (isset($query['where'])?'('.$query['where'].') AND ':'').
4428 $children_table.'.child='.$this->field['id'].' AND '.$page_table.'.id='.$children_table.'.page_id';
4430 // Die Hauptkategorie ist das erste Elter (nur wenn nicht bereits explizit sortiert wird)
4431 if (!empty($this->extra['main_category']) && !isset($query['order'])) {
4432 $field2 = "CASE WHEN {$page_table}.id = {$this->extra[
'main_category']} THEN 1 ELSE 0 END AS main_category
";
4433 if (!isset($query['fields2'])) {
4434 $query['fields2'] = [];
4436 $query['fields2'][] = $field2;
4437 $query['order'] = "main_category DESC, {$page_table}.id ASC
";
4440 return $this->_site->getPages($query, $param);
4452 function getAncestors($query=array(), $param=array()) {
4453 if ($this->field['deleted']) {
4454 $param = array_merge($param, array('deleted' => -1));
4456 $ancestors_ids = $this->_getAncestorsIds($this, $param['children_query'], $param['children_param']);
4457 if ($param['id_list']) {
4458 return $ancestors_ids;
4460 if ($ancestors_ids) {
4461 $ancestors_ids = array_reverse($ancestors_ids);
4462 $query['where'] = (isset($query['where'])?'('.$query['where'].') AND ':'').
4463 'id IN ('.join(',', $ancestors_ids).')';
4464 $query['proposed_order'] = array(
4466 'values' => $ancestors_ids
4468 return $this->_site->getPages($query, $param);
4470 return new Page_Iterator();
4481 function getDescendants($query=array(), $param=array()) {
4482 $lang = $param['lang']?$param['lang']:$this->_site->language;
4483 $page_table = $this->_site->name.'_'.$lang;
4484 if (!$param['children_query']) {
4485 $param['children_query']['fields'] = 'id';
4487 $param['children_query']['order'] = '';
4488 $param['children_query']['hash'] = $this->field['id'].md5(serialize($param['children_query']));
4489 $param['children_param']['has_children'] = 1;
4490 $param['children_param']['no_cache'] = 1;
4492 $cache = $this->_site->getCache();
4493 $cache_key = '_desc_'.$this->field['id'].'_'.
4494 ($GLOBALS['auth'] ? $GLOBALS['auth']->getId() : 'guest').'_'.
4495 md5(serialize($param['children_query']).serialize($param['children_param'])).'_'.
4496 md5(serialize($this->_site->getHash()));
4497 $descendants_ids = $cache->get($cache_key);
4498 if ($descendants_ids === null) {
4499 $descendants_ids = array();
4500 $this->_getDescendantsIds($this, $param['children_query'], $param['children_param'], $descendants_ids);
4501 if ($param['with_root']) {
4502 $descendants_ids[] = $this->field['id'];
4504 $cache->set($cache_key, $descendants_ids);
4506 if ($param['return_ids']) {
4507 return $descendants_ids;
4509 if ($descendants_ids) {
4510 $query['where'] = (isset($query['where'])?
4511 '('.$query['where'].') and ':
4513 // Oracle verträgt max. 1000 Elemente pro Liste
4514 $idgroups = array();
4515 foreach (array_chunk($descendants_ids, 999) as $ids)
4517 // IDs splitten in 999-Häppchen
4518 $idgroups[] = $page_table.'.id in ('.implode(',', $ids).')';
4520 $query['where'] .= '('.implode(' or ', $idgroups).')';
4522 //$page_table.'.id in ('.join(',', $descendants_ids).')';
4523 return $this->_site->getPages($query, $param);
4525 return new Page_Iterator();
4544 function getSiblings($query=array(), $param=array(), $proposed_path=array()) {
4546 (!isset($query['limit']) && isset($param['next']))
4547 || (isset($query['limit']) && !isset($param['next']))
4548 || (!isset($query['limit']) && !isset($param['next']))
4551 $parents_query = $param['parents_query']?$param['parents_query']:array();
4552 if ($proposed_path) {
4553 $parents_query2 = $parents_query;
4554 $parents_query2['where'] = ($parents_query2['where']?$parents_query2['where'].' AND ':'').'id IN ('.join(',', $proposed_path).')';
4555 $parents = $this->getParents($parents_query2, array(
4558 'only_active' => false
4560 $parent = $parents->nextPage();
4563 $parent = $this->getParents($parents_query, array(
4566 'only_active' => false
4567 ))->nextPage(); /* @var $parent Page */
4570 if ($param['without_self']) {
4571 $query['where'] .= (isset($query['where']) ? ' AND ' : '') . 'id != :self_id';
4572 $query['bind']['self_id'] = $this->field['id'];
4575 $siblings = $parent->getChildren($query, $param);
4576 if ($param['next']) { // Nur die Geschwister ab der aktuellen Seite anzeigen.
4577 $siblings->setHaltId($this->field['id']);
4583 return new Page_Iterator();
4593 function getLanguagePage($lang, $param = array()) {
4594 $site = clone $this->_site; /* @var $site Site */
4596 $site->setLanguage($lang);
4597 } catch (Site_Exception $e) {
4598 if ($e->getCode() == Site_Exception::LANG_DOESNT_EXIST) {
4602 return $site->getPage($this->field['id'], $param);
4613 function createLanguagePage($lang, $param = array()) {
4614 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4615 $GLOBALS['__egotec_skip_replication'] = 'createLanguagePage';
4618 if (!in_array($lang, $this->_site->getLanguages())) {
4619 throw new Site_Exception('Die Sprache existiert nicht', Site_Exception::LANG_DOESNT_EXIST);
4622 // Parameter um die Seite in jedem Fall zu erhalten
4625 'deleted_or' => '1=1',
4627 'only_active' => false
4630 if ($l_page = $this->getLanguagePage($lang, $l_param)) { // Übersetzte Seite existiert bereits, diese aktualisieren
4631 $field = is_array($param['field'])? $param['field']:$this->field;
4632 $extra = is_array($param['extra'])? $param['extra']:$this->extra;
4634 // Keine Workflow Historie übernehmen
4635 unset($extra['history']);
4645 // Felder und Extra vorbereiten
4646 $field = is_array($param['field'])? $param['field']:$this->field;
4647 $field['id'] = $this->field['id'];
4649 $extra = is_array($param['extra'])? $param['extra']:$this->extra;
4651 // Keine Workflow Historie übernehmen
4652 unset($extra['history']);
4654 // Elternseite ermitteln
4655 $parents = $this->getParents(array(), $l_param);
4657 $parent = $parents->nextPage();
4659 // Übersetzte Elternseite ermitteln
4660 $l_parent = $parent->getLanguagePage($lang, $l_param);
4662 if (!$l_parent) { // Übersetzte Elternseite existiert nicht, alle benötigten Vorfahren anlegen
4663 $path = $this->getPath(false, $GLOBALS['current_path'], false);
4665 // Ab der übersetzten Startseite alle Vorfahren durchgehen
4666 $_parent = $this->_site->getRoot()->getLanguagePage($lang, $l_param);
4668 foreach ($path as $pid) {
4669 // Übersetzten Vorfahren ermitteln
4670 $p = $this->_site->getPage($pid, $l_param);
4671 $lp = $p->getLanguagePage($lang, $l_param);
4673 if (!$lp) { // Übersetzter Vorfahre existiert nicht, eine inaktive Sprachkopie anlegen
4674 $copied_field = $p->field;
4675 $copied_field['inactive'] = self::INACTIVE_FLAG;
4677 $copied_extra = $p->extra;
4678 $lp = $_parent->newChild($copied_field, $copied_extra);
4679 } elseif ($lp->field['deleted']) {
4680 // Übersetzter Vorfahre wurde gelöscht, Seite wiederherstellen
4681 $restored_field = $p->field;
4683 unset($restored_field['deleted']);
4684 $restored_field['inactive'] = self::INACTIVE_FLAG; // Sprachkopie deaktivieren
4686 $lp->updateField($restored_field);
4689 // Nächste Elternseite ist die aktuelle übersetzte Seite
4693 // Alle Vorfahren wurden angelegt, jetzt die erwünschte übersetzte Seite anlegen
4694 $l_child = $_parent->newChild($field, $extra);
4695 } else { // Übersetzte Elternseite existiert, übersetzte Seite anlegen
4696 if ($l_parent->field['deleted']) {
4697 // Übersetzter Vorfahre wurde gelöscht, Seite wiederherstellen
4698 $restored_field = $l_parent->field;
4700 unset($restored_field['deleted']);
4701 $restored_field['inactive'] = self::INACTIVE_FLAG; // Sprachkopie deaktivieren
4703 $l_parent->updateField($restored_field);
4706 $l_child = $l_parent->newChild($field, $extra);
4709 // Mediapool kopieren
4710 $this->getMediapool()->copy($l_child);
4711 $l_child->getMediapool()->import(true);
4713 $this->replicate('createLanguagePage', $lang, $param);
4726 public function getKeywords($language = '', $own_keywords = false) {
4727 // Sprache muss gesetzt sein
4728 if ($language == '') {
4729 $language = $this->_site->language;
4732 // Die Keyword-Tabelle ermitteln:
4733 // Das Schlagwortregister eines anderen Mandanten verwenden
4734 // (kann im Adminbereich pro Mandant eingestellt werden)
4735 if ($this->_site->admin['keywords']['site'] &&
4736 $this->_site->admin['keywords']['site'] != $this->_site->name
4738 $keyword_table = $this->_site->admin['keywords']['site'].'_'.$language.'_keywords';
4740 $keyword_table = $this->_site->name.'_'.$language.'_keywords';
4743 // In der Relationen-Tabelle befinden sich die Zuweisungen,
4744 // also welches Schlagwort zu welcher Seite gehört
4745 $relation_table = $this->_site->name.'_keywords_rel';
4747 // Suche durchführen
4748 // Achtung! Diese Suche findet nur die Zuweisungen,
4749 // welche über den Pool verlinkt sind.
4750 // Nicht die eigenen Schlagworte, die in der Seite eingetragen wurden
4751 $db = new_db_connection();
4753 if (!$db->tableExists($keyword_table)) {
4759 "table
" => "$keyword_table INNER JOIN $relation_table ON $keyword_table.id = $relation_table.keyword_id
",
4760 "where
" => 'page_id = '.$this->field['id']
4763 // Alle Keywords sammeln
4764 $keywords = array();
4766 // zunächst die Zuweisungen aus dem Pool
4767 $keywords_list = explode(',', $this->extra['keywords_list']);
4768 while ($result = $db->next()) {
4769 if (in_array($result['id'], $keywords_list)) {
4770 array_push($keywords,$result['word']);
4774 // die eigenen Keywords werden zusätzlich ins Extra-Feld kommasepariert gespeichert und hier auch ausgelesen
4775 if ($own_keywords && $this->extra['keywords_list_own']) {
4776 $tmp = explode(',', $this->extra['keywords_list_own']);
4777 $keywords = array_merge($keywords, $tmp);
4780 // Die Keyword-Liste kommasepariert ausgeben
4781 $keywords = implode(',', $keywords);
4782 return trim($keywords, ',');
4791 function addKeyword($word, $add_to_pool = false) {
4792 if (!isset($GLOBALS['__egotec_skip_replication'])) {
4793 $GLOBALS['__egotec_skip_replication'] = 'addKeyword';
4796 // Whitespaces entfernen und Wort prüfen
4797 $word = trim($word);
4803 * Das Schlagwortregister kann auch aus einem andreen Mandanten verwendet werden
4804 * Achtung! Wenn z.B. in einem deutschen Page-Objekt ein Keywords hinzugefügt wird,
4805 * dieser Mandant aber nicht in dieser Sprache existiert,
4806 * dann wird kein Schlagwort erstellt.
4808 if ($this->_site->admin['keywords']['site'] && $this->_site->admin['keywords']['site'] != $this->_site->name) {
4809 // Existenz der Sprache prüfen
4810 $keywordSite = new Site($this->_site->admin['keywords']['site'],$this->_site->language);
4812 $keywordSite = $this->_site;
4818 $k_db = new_db_connection();
4819 $k_db->select(array(
4820 'table' => $keywordSite->pageTable.'_keywords',
4821 'where' => 'LOWER(word)=:word',
4822 'bind' => array('word' => strtolower($word))
4830 $maxid = $k_db->Record['id'];
4832 // Die nächst höchste ID herausfinden von allen verfügbaren Sprachen des Mandanten
4834 foreach($keywordSite->getLanguages() as $sprache) {
4835 $u_db = new_db_connection();
4836 $u_db->select(array(
4838 'table' => $keywordSite->name.'_'.$sprache.'_keywords',
4839 'order' => 'id DESC',
4843 $maxentry = $u_db->next();
4844 if((int)$maxentry['id'] > $max) {
4845 $max = (int)$maxentry['id'];
4848 $maxid = $max+1; // Neue ID ist höchste ID + 1
4853 $k_db->insert(array(
4854 'table' => $keywordSite->pageTable.'_keywords',
4858 'c_date' => date('Y-m-d H:i:s'),
4859 'main' => 1, // Neues Wort ist immer der Hauptsprachbegriff
4860 'not_in_list' => ($add_to_pool) ? 0 : 1 // Im gesamten Schlagwortregister aufnehmen oder nicht
4876 $db2 = new_db_connection();
4878 'table' => $keywordSite->name.'_keywords_rel',
4879 'where' => "page_id =
'".$this->field['id']."' AND keyword_id =
'".$maxid."'",
4880 'order' => 'page_id',
4884 return true; // alles ok, Schlagwort ist bereits zugewiesen
4887 if ($k_db->insert(array(
4888 'table' => $keywordSite->name.'_keywords_rel',
4890 'page_id' => $this->field['id'],
4891 'keyword_id' => $maxid,
4892 'c_date' => date('Y-m-d H:i:s')
4893 )))) { // Abwärtskompatibilität Schlagworte auch in die Extra-Felder "keywords_list
" und "keywords_list_own
" schreiben
4894 // Alle zugewiesenden Schlagwort-Ids auslesen
4895 $k_db->select(array(
4896 'table' => $keywordSite->name.'_keywords_rel',
4897 'where' => "page_id =
'".$this->field['id']."'"
4900 while ($entry = $k_db->next()) {
4901 $entries[] = $entry['id'];
4904 // Alle Schlagworte auslesen
4905 $k_db->select(array(
4906 'table' => $keywordSite->pageTable.'_keywords',
4907 'where' => "id IN (
'".implode("',
'", $entries)."')
"
4910 $keywords_list = array();
4911 $keywords_list_own = array();
4912 while ($entry = $k_db->next()) {
4914 if ($entry['not_in_list'] == "1
") {
4915 $keywords_list_own[] = $entry['word'];
4917 $keywords_list[] = $entry['id'];
4921 // Schlagworte bzw. SchlagwortIDs kommasepariert ins extra-Feld
4922 if ($keywords_list || $keywords_list_own) {
4923 $this->extra['keywords_list'] = implode(",
",$keywords_list);
4924 $this->extra['keywords_list_own'] = implode(",
",$keywords_list_own);
4925 $this->updateExtra($this->extra,true);
4928 $this->replicate('addKeyword', $word);
4942 function getUrl($param = array()) {
4943 if (($this->extra['image_type'] || $param['pool']) && !$param['download'] && !$param['thumbnail']) { // Multimediaendung setzen.
4944 if (!$param['no_suffix'] && $this->extra['image_type']) {
4945 $param['suffix'] = $this->extra['image_type'];
4947 unset($param['no_suffix']);
4949 /* Bild URLs müssen immer width und height Parameter beinhalten.
4950 * Wird nur width oder nur height übergeben, dann muss der Gegenwert
4951 * relativ berechnet werden (Skalierung).
4952 * Wird keiner der Parameter übergeben, dann werden die Originalwerte
4953 * verwendet (origImgWidth und origImgHeight).
4954 * Werden beide Parameter übergeben, dann werden diese verwendet.
4955 * Wird ein ungültiger Wert übergeben, dann wird der Parameter aus der URL entfernt.
4956 * Die URL Auflösung skaliert automatisch,
4957 * wenn nur width oder nur height in der URL vorkommt.*/
4958 $param = $this->addImageParams($param);
4960 if (!$param['lang'] || $param['lang'] == $this->_site->language) {
4961 // Wird die URL für die aktuelle Seite angefordert, ist das Page Objekt bereits bekannt
4962 return $this->_site->getPageUrl($this->field['id'], $param, $this);
4964 return $this->_site->getPageUrl($this->field['id'], $param);
4973 public function getFrontendUrl($param = array()) {
4974 $now = date('Y-m-d H:i:s');
4976 $this->field['inactive'] > 0
4977 || ($this->field['release_from'] != '0000-00-00 00:00:00' && $this->field['release_from'] > $now)
4978 || ($this->field['release_until'] != '0000-00-00 00:00:00' && $this->field['release_until'] < $now)
4979 || $this->isWorkflowCopy()
4980 || $this->isReleaseCopy()
4984 $param['get_frontend_url'] = true;
4985 return $this->getUrl($param);
4994 public function getLiveUrl($param = array()) {
4995 if (((int) $this->field['nav_hide']&2) == 2) {
4996 // Es gibt keine Liveserver URLs für Seiten, die nicht auf dem Liveserver existieren dürfen
5000 // Immer eine absolute URL erzeugen
5001 $param['return_absolute'] = true;
5003 if (!$GLOBALS['egotec_conf']['liveserver']) {
5004 // URL vom (ersten) Liveserver erzeugen
5005 $clusters = Ego_System::getCluster();
5006 array_walk($clusters, function (&$value) {
5007 $value = $value['url'];
5009 $liveservers = array_values(array_filter(array_merge([$this->_site->admin['live']['location']], $clusters)));
5011 if (!empty($liveservers)) {
5012 // Liveserver URL setzen
5013 $live = $this->_site->admin['live'];
5014 $live['location'] = $liveservers[0];
5016 require_once('soap/Ego_SOAP.php');
5017 $soap = new Ego_SOAP($live, 1);
5019 return $soap->soapCall('pageGetUrl', [
5020 'site' => $this->_site->name,
5021 'lang' => $this->_site->language,
5022 'id' => $this->field['id'],
5023 'param' => soap_var($param)
5025 } catch (Exception $e) {
5031 // URL von diesem Server erzeugen
5032 return $this->getFrontendUrl($param);
5040 public function getCloneUrl() {
5041 return 'index.php?' . http_build_query(array(
5042 'id' => $this->field['id'],
5043 'site' => $this->_site->name,
5044 'lang' => $this->_site->language
5053 public function getCloneOriginal() {
5054 if ($this->isClone()) {
5057 'deleted_or' => '1=1',
5059 'only_active' => false
5061 if (is_numeric($this->extra['clone_original'])) { // abwärtskompatibel
5062 $page = $this->_site->getPage($this->extra['clone_original'], $param);
5064 $page = Ego_System::urltopage($this->extra['clone_original'], array(
5087 function lock($user_id='') {
5088 if (!isset($GLOBALS['__egotec_skip_replication'])) {
5089 $GLOBALS['__egotec_skip_replication'] = 'lock';
5093 $user_id = $GLOBALS['auth']->getId();
5096 // bei einem anonymen Benutzer wird eine Kombination aus remote_addr und user_agent gespeichert #93240
5097 $user_id = $GLOBALS['auth']->getAnonymousId();
5100 $db = new_db_connection(array(
5101 'fields' => 'egotec_page_lock.*,egotec_user.*, egotec_page_lock.user_id AS lock_user_id',
5102 'table' => 'egotec_page_lock',
5103 'join' => 'egotec_user on egotec_page_lock.user_id=egotec_user.user_id',
5104 'where' => "(page_table=
'".$this->_site->pageTable."') AND (page=
".$this->field['id'].")
"
5106 if ($db->nextRecord()) {
5108 $db->Record['stamp'] >= (time() - $GLOBALS['egotec_conf']['page_timeout'])
5109 && $db->Record['user_id'] != $user_id
5111 $db->Record['extra'] = unserialize($db->Record['extra']);
5115 'table' => 'egotec_page_lock',
5117 'user_id' => $user_id,
5120 'where' => "page_table =
'{$this->_site->pageTable}' AND page = {$this->field[
'id']}
"
5128 'table' => 'egotec_page_lock',
5130 'page_table' => $this->_site->pageTable,
5131 'page' => $this->field['id'],
5132 'user_id' => $user_id,
5137 } catch (Exception $e) {
5141 $this->replicate('lock', $user_id);
5151 function unlock($user_id=false) {
5152 if (!isset($GLOBALS['__egotec_skip_replication'])) {
5153 $GLOBALS['__egotec_skip_replication'] = 'unlock';
5156 $db = new_db_connection();
5157 if ($user_id === false) {
5158 $user_id = $GLOBALS['auth']->getId();
5161 // bei einem anonymen Benutzer wird eine Kombination aus remote_addr und user_agent gespeichert #93240
5162 $user_id = $GLOBALS['auth']->getAnonymousId();
5165 'table' => 'egotec_page_lock',
5167 (page_table=
'".$this->_site->pageTable."') AND
5168 (page=
".$this->field['id'].") AND
5169 (user_id=
'$user_id')
"
5172 $this->replicate('unlock', $user_id);
5183 public function isLocked($exclude_self = true) {
5184 $where = 'page_table = :page_table AND page = :page AND stamp >= :stamp';
5186 'page_table' => $this->_site->pageTable,
5187 'page' => $this->field['id'],
5188 'stamp' => time() - $GLOBALS['egotec_conf']['page_timeout']
5190 if ($exclude_self) {
5191 $where .= ' AND user_id != :user_id';
5192 $bind['user_id'] = $GLOBALS['auth']->isNobody()
5193 ? $GLOBALS['auth']->getAnonymousId()
5194 : $GLOBALS['auth']->getId();
5196 $db = new_db_connection(array(
5197 'table' => 'egotec_page_lock',
5201 if ($db->nextRecord()) {
5203 $user = new User_SQL($db->Record['user_id']);
5204 } catch (User_Exception $e) {
5209 'stamp' => $db->Record['stamp']
5222 function getRightsArray($perm_type='', $no_null=false) {
5223 $db = $this->_getRights($perm_type);
5225 while ($db->nextRecord()) {
5226 $a[$db->Record['perm']][] = array(
5227 'group_id' => $db->Record['group_id'],
5228 'role_id' => $db->Record['role_id']
5231 // Für alle Felder in denen kein IS NULL verwendet werden darf muss später ein *|* eingetragen werden
5233 $no_null_fields = explode(',', trim(Auth::NO_NULL_RIGHTS, ','));
5234 foreach ($no_null_fields as $f) {
5237 // Das Veröffentlichen Recht ist standardmäßig immer root/Administrator
5239 'group_id' => $GLOBALS['egotec_conf']['superuser']['group'],
5240 'role_id' => $GLOBALS['egotec_conf']['superuser']['role']
5242 } elseif ($no_null) {
5263 public function getRights($perm_type='') {
5264 return $this->_getRights($perm_type);
5272 function setRightsArray($rights) {
5273 if (!isset($GLOBALS['__egotec_skip_replication'])) {
5274 $GLOBALS['__egotec_skip_replication'] = 'setRightsArray';
5277 $db = new_db_connection();
5279 $table = $this->_site->pageTable.'_rights';
5282 'where' => "page_id=
".$this->field['id']
5284 $set = array(); // Doppelte Einträge vermeiden
5285 foreach ($rights as $perm => $perm_rights) {
5286 if ($perm_rights) { // $perm_rights könnte auch null sein.
5287 foreach ($perm_rights as $right) {
5288 if ($right['group_id'] && $right['role_id']) { // Nur einfügen, wenn tatsächlich eine GroupID und RoleID angegeben ist.
5289 $key = $this->field['id'].'.'.$perm.'.'.$right['group_id'].'.'.$right['role_id'];
5290 if (!in_array($key, $set)) {
5294 'page_id' => $this->field['id'],
5296 'group_id' => $right['group_id'],
5297 'role_id' => $right['role_id']
5308 $this->replicate('setRightsArray', $rights);
5317 function getUsersArray($perm_type='') {
5318 $db = $this->_getUsers($perm_type);
5320 while ($db->nextRecord()) {
5321 $a[$db->Record['perm']][] = array(
5322 'user_id' => $db->Record['user_id']
5333 function setUsersArray($users) {
5334 if (!isset($GLOBALS['__egotec_skip_replication'])) {
5335 $GLOBALS['__egotec_skip_replication'] = 'setUsersArray';
5338 $db = new_db_connection();
5339 $table = $this->_site->pageTable.'_users';
5342 'where' => "page_id=
".$this->field['id']
5344 $set = array(); // Doppelte Einträge vermeiden
5345 foreach ($users as $perm => $perm_users) {
5346 if ($perm_users) { // $perm_users könnte auch null sein.
5347 foreach ($perm_users as $user) {
5348 if ($user['user_id']) { // Nur einfügen, wenn tatsächlich eine UserID angegeben ist.
5349 $key = $this->field['id'].'.'.$perm.'.'.$user['user_id'];
5350 if (!in_array($key, $set)) {
5354 'page_id' => $this->field['id'],
5356 'user_id' => $user['user_id']
5366 $this->replicate('setUsersArray', $users);
5374 public function getSite() {
5375 return $this->_site;
5383 public function getMediapool() {
5384 return new Mediapool($this);
5393 public function hasParent($parent_id) {
5394 $db = new_db_connection(array(
5395 'table' => $this->_site->pageTable.'_children',
5396 'where' => 'page_id='.$parent_id.' AND child='.$this->field['id']
5398 return $db->nextRecord() !== null;
5408 public function addParent($parent_id, $asis=false) {
5409 if (!isset($GLOBALS['__egotec_skip_replication'])) {
5410 $GLOBALS['__egotec_skip_replication'] = 'addParent';
5413 $this->archiveOnly = false;
5414 if (!$this->_addParent($parent_id)) {
5417 $this->_updateField(array(), true, $asis, $asis); // Änderungsdatum aktualisieren und Cache löschen.
5418 $this->hookUpdate();
5420 $this->replicate('addParent', $parent_id, $asis);
5433 public function addChild($child_id='', $child_id2='') {
5434 if (!isset($GLOBALS['__egotec_skip_replication'])) {
5435 $GLOBALS['__egotec_skip_replication'] = 'addChild';
5439 $child_id = $child_id2;
5441 $this->_site->getPage($child_id)->addParent($this->field['id']);
5443 $this->replicate('addChild', $child_id, $child_id2);
5453 public function delParent($parent_id, $asis=false) {
5454 if (!isset($GLOBALS['__egotec_skip_replication'])) {
5455 $GLOBALS['__egotec_skip_replication'] = 'delParent';
5458 $this->archiveOnly = false;
5459 $this->_removeParent($parent_id);
5460 $this->_updateField(array(), true, $asis, $asis); // Änderungsdatum aktualisieren und Cache löschen.
5461 $this->hookUpdate();
5463 $this->replicate('delParent', $parent_id, $asis);
5471 public function isWriteable(){
5472 if (!$this->hasRights(array('edit'))) {
5475 $this->_site->admin['workflow']['enabled'] // Workflow ist aktiviert
5476 && $this->field['workflow'] // UND und für dieser Seite ist ein Workflow zugewiesen
5477 && !(int)$this->extra['original_id'] // UND bei der Site handelt es sich NICHT um eine Worflow-Kopie
5478 && !$this->hasRights('workflow') // UND der aktuelle User hat NICHT das Recht den Workflow zu ändern
5490 public function isRoot() {
5491 return ($this->field['id'] == $this->_site->rootId);
5505 public function getPath($with_root=true, $proposed_path=array(), $return_string=true, $query=array('fields' => 'id,name,url,inactive'), $param = array(), &$assorted = null) {
5506 $return_pages = $return_string == 2 && $return_string != 1;
5507 if ($return_pages) {
5508 /* Werden Page Objekte zurückgeliefert, dann diese immer mit allen Daten.
5509 * Ansonsten können Methoden wie update(), newChild(), usw. auf diesen Page Objekten Probleme machen. */
5510 unset($query['fields']);
5512 if (!isset($param['inactive'])) {
5513 // Falls die Einstellung zu inaktiven Seiten nicht explizit übergeben wird, wird die des Site Objekts verwendet.
5514 $param['only_active'] = $this->_site->getOnlyActive();
5515 $param['inactive'] = !$param['only_active'];
5518 $cache_key = 'path'.md5(serialize([$this->getIdentity(), $with_root, $proposed_path, $return_string, $query, $param]));
5519 $cache_entry = $this->_site->getCacheEntry($cache_key);
5521 if ($cache_entry === null) {
5523 !empty($this->extra['main_category'])
5524 && empty($proposed_path)
5525 && ($category = $this->_site->getPage($this->extra['main_category'], array_merge($param, array(
5529 $proposed_path = $category->getPath(false, [], false);
5530 $proposed_path[] = $category->field['id'];
5533 if ($this->field['id'] == $this->_site->rootId) {
5534 // Die Startseite hat keinen Pfad
5536 // ...und gibt maximal sich selbst aus
5537 if ($return_pages) {
5538 $path = array($this);
5539 } elseif ($return_string) {
5540 if ($GLOBALS['egotec_conf']['meta_in_path']) {
5541 $path = Ego_System::encode_path(empty($this->field['url'])?$this->field['name']:$this->field['url']).'/';
5543 $path = Ego_System::encode_path($this->field['name']).'/';
5546 $path = array($this->field['id']);
5549 $path = in_array($return_string, array(1, true), true) ? '' : array();
5553 !$proposed_path && is_array($GLOBALS['current_path'])
5555 $proposed_path = $GLOBALS['current_path'];
5557 $proposed_path[] = $this->field['id'];
5558 $ancestor_ids = array();
5559 $ancestor_order = false;
5560 $hidden_ancestor_ids = array();
5562 $this->getAncestors(
5563 array('fields' => 'id,nav_hide'),
5566 'inactive' => self::INACTIVE_FLAG,
5567 'children_query' => array('where' => "type !=
'_keywords/entry'"),
5568 'children_param' => array_merge(array('auth_or' => '1=1', 'inactive' => self::INACTIVE_FLAG), $param)
5571 as $page) { // Alle möglichen Pfade der aktuellen Seite.
5572 if (!$GLOBALS['admin_area'] && $page->field['nav_hide']&1 == 1) {
5573 $hidden_ancestor_ids[] = $page->field['id'];
5575 $ancestor_ids[] = $page->field['id'];
5578 if (!empty($hidden_ancestor_ids)) {
5579 // Pfade im Frontend möglichst nur aus Seiten generieren, die in der Navigation erreichbar sind
5580 $ancestor_ids = array_merge($ancestor_ids, $hidden_ancestor_ids);
5581 if (!empty($ancestor_ids)) {
5582 $ancestor_order = '(CASE id';
5583 foreach ($ancestor_ids as $index => $ancestor_id) {
5584 $ancestor_order .= ' WHEN ' . $ancestor_id . ' THEN ' . ($index + 1);
5586 $ancestor_order .= ' ELSE ' . (sizeof($ancestor_ids) + 1) . ' END)';
5589 $ancestor_ids[] = $this->field['id'];
5590 if ($ancestor_ids) {
5591 $ancestor_where = ' AND id IN ('.join(',', $ancestor_ids).')';
5593 $page = $this->_site->getRoot(array_merge(array('auth_or' => '1=1'), $param));
5595 if ($return_pages) {
5596 $path[] = $this->_site->getPage($this->_site->rootId, array_merge(array('auth_or' => '1=1'), $param));
5597 } elseif ($return_string) {
5598 if ($GLOBALS['egotec_conf']['meta_in_path']) {
5599 $path = Ego_System::encode_path(empty($page->field['url'])?$page->field['name']:$page->field['url']).'/';
5601 $path = Ego_System::encode_path($page->field['name']).'/';
5604 $path[] = $this->_site->rootId;
5607 $path = in_array($return_string, array(1, true), true) ? '' : array();
5609 while ($page->field['id']!=$this->field['id'] && $page) {
5610 $proposed_id = array_shift($proposed_path);
5611 if ($proposed_id==$page->field['id']) {
5612 $proposed_id = array_shift($proposed_path);
5614 if (in_array($proposed_id, $hidden_ancestor_ids)) {
5615 $proposed_id = null;
5617 if ($proposed_id && is_numeric($proposed_id)) {
5618 $children = $page->getChildren(
5620 'fields' => $query['fields'] ?? $this->_site->pageTable . '.*',
5621 'where' => 'id=:id'.$ancestor_where,
5622 'order' => $ancestor_order,
5624 'id' => $proposed_id
5626 ), array_merge(array(
5627 'auth_or' => '1=1', 'inactive' => self::INACTIVE_FLAG
5630 $child = $children->nextPage();
5635 $children = $page->getChildren(
5637 'fields' => $query['fields'] ?? $this->_site->pageTable . '.*',
5638 'where' => '1=1 '.$ancestor_where,
5639 'order' => $ancestor_order
5640 ), array_merge(array(
5641 'auth_or' => '1=1', 'inactive' => self::INACTIVE_FLAG
5644 $child = $children->nextPage();
5649 if ($child->field['id']==$this->field['id']) {
5653 $child->field['inactive'] == self::ACTIVE_FLAG
5654 || !empty($param['inactive']) // Falls inaktive Seiten im Pfad abgefragt werden
5656 if ($return_pages) {
5658 } elseif ($return_string) {
5659 if ($_SESSION['export']) {
5660 $path.='-p-'.$child->field['id'].'/';
5662 if ($GLOBALS['egotec_conf']['meta_in_path']) {
5663 $path.= Ego_System::encode_path(empty($child->field['url'])?$child->field['name']:$child->field['url']).'/';
5665 $path.= Ego_System::encode_path($child->field['name']).'/';
5669 $path[] = $child->field['id'];
5674 // Prüfen, ob der Pfad wirklich eindeutig ist (keine Seite im Pfad hat in selber Ebene eine gleichnamige Seite)
5675 if ($assorted === false) {
5676 $siblings = $page->getSiblings(array(
5677 'fields' => 'id,url,name',
5678 'where' => '(url = :name1 OR name = :name2)',
5680 'name1' => $child->field['name'],
5681 'name2' => $child->field['name']
5683 ), array_merge(array('auth_or' => '1=1'), $param));
5684 if ($siblings->numRecords() > 1) {
5691 $this->_site->setCacheEntry($cache_key, [
5692 'path' => $return_pages ? array_map(function($page) {
5693 // Pages in Identitäten umwandeln
5694 return $page->getIdentity();
5696 'assorted' => $assorted
5699 $path = $return_pages && is_array($cache_entry['path']) ? array_map(function($identity) use ($param) {
5700 // Identitäten in Pages umwandeln
5701 return self::isIdentity($identity) ? Page::byIdentity($identity, $param) : $identity;
5702 }, $cache_entry['path']) : $cache_entry['path'];
5703 $assorted = $cache_entry['assorted'];
5716 private function getPaths($with_root = false, $in_root = false, $area_domain = false) {
5718 $get_path = function($page, $path = array()) use (&$get_path, &$paths, $with_root, $in_root, $area_domain) {
5722 $page->field['id'] == $this->_site->rootId
5723 || ($area_domain && $page->extra['area_domain'])
5729 $get_name = function($page) {
5730 $names = $page->getUrlNames();
5732 'name' => $names[0],
5733 'id' => (int) $page->field['id']
5737 $original_path = $path;
5738 foreach ($page->getParents(array(), array(
5740 'deleted_or' => '1=1',
5742 'only_active' => false
5744 // Alle Pfade dieser Seite aus dem Cache verwenden
5745 $cache_key = 'getPaths' . md5(serialize([$parent->field['id'], $with_root, $in_root, $area_domain]));
5746 $cached_paths = $this->_site->getCacheEntry($cache_key);
5747 if ($cached_paths !== null) {
5748 $cached_path = array_pop($cached_paths);
5751 if ($cached_path[sizeof($cached_path) - 1]['name'] === '') {
5752 // Die Startseite im Pfad ist nur für Seiten direkt unterhalb der Startseite relevant
5753 array_pop($cached_path);
5755 array_unshift($cached_path, $get_name($parent));
5756 $path = array_merge($path, $cached_path);
5757 } elseif (!empty($cached_paths)) {
5758 $paths = array_merge($paths, $cached_paths);
5765 if ($index++ == 0) {
5767 $path[] = $get_name($parent);
5768 $path = $get_path($parent, $path);
5769 if (empty($path) && $in_root && $parent->field['id'] == $this->_site->rootId) {
5770 // Pfad direkt unter der Startseite aufnehmen
5773 'id' => $with_root ? (int) $parent->field['id'] : ''
5778 $tmp_path = $original_path;
5779 $tmp_path[] = $get_name($parent);
5780 $paths[] = $get_path($parent, $tmp_path);
5785 $path = $get_path($this);
5786 if (!empty($path)) {
5790 // Alle Pfade im Cache speichern, um sie später wiederverwenden zu können
5791 if (sizeof($paths) > 0) {
5792 $cache_key = 'getPaths' . md5(serialize([$this->field['id'], $with_root, $in_root, $area_domain]));
5793 $this->_site->setCacheEntry($cache_key, $paths);
5796 if (!empty($paths)) {
5797 $paths = array_reverse(array_map('array_reverse', $paths));
5798 $grouped_paths = array();
5799 foreach ($paths as $index => $path) {
5800 foreach ($path as $entry) {
5801 foreach ($entry as $key => $value) {
5802 $grouped_paths[$index][$key][] = $value;
5806 foreach ($grouped_paths as $index => $path) {
5807 foreach ($path as $key => $values) {
5808 $grouped_paths[$index][$key] = implode($key == 'name' ? '/' : ',', $values);
5811 return $grouped_paths;
5826 public function createPath($lang) {
5827 $parents = $this->getParents([], ['auth_or' => '1=1', 'deleted_or' => '1=1']);
5829 $root = $this->_site->getRoot();
5830 foreach ($parents as $parent) {
5831 $lang_parent = $parent->getLanguagePage($lang, ['auth_or' => '1=1', 'deleted_or' => '1=1']);
5832 if (!$lang_parent) { // Wenn die Elternseite nicht existiert, dann alle benötigten Vorfahren anlegen
5833 $_vorfahr = $parent->getPath(false, [], 2, [], ['auth_or' => '1=1', 'deleted_or' => '1=1', 'only_active' => false, 'inactive' => true]);
5834 $_vorfahr[] = $parent;
5836 $opa = $root->getLanguagePage($lang, ['auth_or' => '1=1', 'deleted_or' => '1=1', 'only_active' => false, 'inactive' => true]);
5837 foreach ($_vorfahr as $vorfahr) {
5838 $vorfahr_field = $vorfahr->field;
5839 unset($vorfahr_field['a_user']);
5840 unset($vorfahr_field['a_date']);
5841 $vorfahr_extra = $vorfahr->extra;
5842 unset($vorfahr_extra['workflow_page']);
5843 $vorfahr_field['inactive'] = 1; // Sprachkopien müssen immer inaktiv sein.
5845 $vater = $vorfahr->getLanguagePage($lang, ['auth_or' => '1=1', 'deleted_or' => '1=1', 'only_active' => false, 'inactive' => true]);
5848 if ($vater->field['deleted']) { // Falls die Sprachseite gelöscht ist, wird sie wiederhergestellt und bekommt die Inhalte kopiert.
5849 $vater->update(['field' => $vorfahr_field, 'extra' => $vorfahr_extra]);
5851 } else { // Seite ist nicht vorhanden und muss angelegt werden
5852 // Keine Workflow Historie übernehmen
5853 unset($vorfahr_extra['history']);
5855 $vater = $opa->newChild($vorfahr_field, $vorfahr_extra);
5856 // Rechte von der Original Sprachseite übernehmen
5857 $vater->setRightsArray($vorfahr->getRightsArray());
5858 $vater->setUsersArray($vorfahr->getUsersArray());
5863 } elseif ($lang_parent->field['deleted']) {
5864 // Elternseite wiederherstellen
5865 $lang_parent->undelete();
5875 public function hasMultiParents(){
5876 return ((integer)$this->getParents(array(), array('auth_or'=>'1=1'))->numRecords())>1;
5879 static function unserialize ($session_value) {
5880 $obj = @unserialize($session_value);
5881 if (get_class($obj) == '__PHP_Incomplete_Class') {
5887 $session_value = preg_replace('/^O:\d+:"Page.*?
":/msi', 'O:4:"Page":', $session_value);
5888 $obj = @unserialize($session_value);
5889 if (get_class($obj) == '__PHP_Incomplete_Class') {
5896 public function serialize (){
5897 return serialize($this);
5900 public function __toString(){
5901 return get_class($this).'('.$this->getIdentity().')';
5910 protected function _cleanEmptyContent(&$field) {
5911 if ($this->field['type']=="code
") {
5915 if ($field['content']) { // der neue Content
5916 $str = $field['content'];
5917 } else { // der alte Content
5918 $str = $this->field['content'];
5922 if (Ego_System::isEmptyContent($str)) {
5923 $field['content'] = ''; // richtig leeren
5936 public function cleanEmptyContent($asis=false, $silent=false) {
5938 $field['content'] = $this->field['content'];
5939 $vorher = strlen($field['content']);
5940 $this->_cleanEmptyContent($field);
5941 $nachher = strlen($field['content']);
5942 if ($vorher != $nachher) {
5946 $this->update($param,array(),true, $asis, $silent);
5962 public function getMediaFilename($force_lang = false, $suffix = "") {
5963 $dir = $GLOBALS['egotec_conf']['var_dir'].'media/'.$this->_site->name.'/';
5964 $id = $this->field['id'].$suffix;
5965 $filename = $this->_site->language.'/'.$id;
5967 // Verzeichnis für die Sprache anlegen
5968 Ego_System::mkdir($dir.$this->_site->language);
5971 Ego_System::file_exists($dir.$filename) // Datei existiert in dieser Sprache
5972 || $force_lang // ID und Sprache muss ausgegeben werden
5976 $this->_site->language != $this->_site->site['default_language']
5977 && Ego_System::file_exists($dir.$this->_site->site['default_language'].'/'.$id)
5979 // Datei existiert aber in der Standard Sprache
5980 return $this->_site->site['default_language'].'/'.$id;
5983 // Nur die ID ausgeben
5993 public function addImageParams($param = array()) {
5994 $width = $param['width'];
5995 $height = $param['height'];
5996 $orig_width = $orig_height = null;
5998 // Die originale Breite/Höhe wird übergeben
5999 foreach (array('width', 'height') as $key) {
6000 if (isset($param['original_' . $key])) {
6001 $var = 'orig_' . $key;
6002 ${$var} = (int) $param['original_' . $key];
6003 unset($param['original_' . $key]);
6013 $use_clip = function($clip) use (&$orig_width, &$orig_height) {
6014 [$x1, $y1, $x2, $y2] = explode(',', $clip, 4);
6015 $orig_width = $x2 - $x1;
6016 $orig_height = $y2 - $y1;
6019 if ($this->extra['image_type']) {
6021 if ($this->extra['mime_type'] == 'image/svg+xml') {
6025 $orig_width = $this->extra['origImgWidth'];
6026 $orig_height = $this->extra['origImgHeight'];
6027 if (!empty($this->extra['edit']['clip'])) {
6028 $use_clip($this->extra['edit']['clip']);
6030 } elseif (isset($param['pool'])) {
6032 $pool = $this->getMediapool()->get($param['pool'], $param['dir']);
6033 if (!empty($pool) && $pool['isImage'] && !in_array($pool['mime'], array('image/svg', 'image/svg+xml'))) {
6034 require_once 'base/Ego_Image.php';
6035 [$orig_width, $orig_height] = Ego_Image::getDimensions($pool['file']);
6036 if (!empty($pool['clip'])) {
6037 $use_clip($pool['clip']);
6039 } elseif (!$orig_width && !$orig_height) {
6046 if (is_numeric($param['width'])) {
6048 is_numeric($orig_width)
6049 && is_numeric($orig_height)
6050 && !isset($param['height'])
6052 $width = $param['width'];
6053 $height = ceil($orig_height * ($param['width'] / $orig_width));
6055 } elseif (is_numeric($orig_width) && !isset($param['height'])) {
6056 $width = $orig_width;
6058 if (is_numeric($param['height'])) {
6060 is_numeric($orig_height)
6061 && is_numeric($orig_width)
6062 && !isset($param['width'])
6064 $width = ceil($orig_width * ($param['height'] / $orig_height));
6065 $height = $param['height'];
6067 } elseif (is_numeric($orig_height) && !isset($param['width'])) {
6068 $height = $orig_height;
6070 if (is_numeric($width)) {
6071 $param['width'] = $width;
6073 unset($param['width']);
6075 if (is_numeric($height)) {
6076 $param['height'] = $height;
6078 unset($param['height']);
6089 public function hasLanguageFile($lang) {
6090 $dir = $GLOBALS['egotec_conf']['var_dir'].'media/'.$this->_site->name.'/';
6091 $filename = $lang.'/'.$this->field['id'];
6093 return file_exists($dir.$filename);
6104 public function destroyFile(){
6105 $dir = $GLOBALS['egotec_conf']['var_dir'].'media/'.$this->_site->name.'/';
6106 $filename = $this->_site->language.'/'.$this->field['id'];
6108 if (file_exists($dir.$filename)) {
6109 unlink($dir.$filename);
6112 $mediafiles = glob($dir.$filename.'_*');
6113 if (is_array($mediafiles)) {
6114 foreach ($mediafiles as $mediafile) {
6119 // Die Seite existiert ohne Sprache und die aktuelle Sprache ist die Standard Sprache
6120 if ($this->_site->language == $this->_site->site['default_language']) {
6121 $filename = $this->field['id'];
6123 if (file_exists($dir.$filename)) {
6124 unlink($dir.$filename);
6127 $mediafiles = glob($dir.$filename.'_*');
6128 if (is_array($mediafiles)) {
6129 foreach ($mediafiles as $mediafile) {
6142 public function getProtocol($site = null) {
6144 $site = $GLOBALS['site'];
6147 ($_SERVER['HTTPS'] == 'on'
6149 && $site->name == $this->_site->name
6150 && $site->language == $this->_site->language)
6151 || !empty($this->extra['https']) ? 's' : ''
6160 public function getInformationLocked() {
6162 $params['tpl_name'] = 'information_locked.html';
6163 if ($this->field['type'] == 'multimedia/image') {
6164 $params['tpl_name'] = 'information_locked_image.html';
6166 $file_name = $GLOBALS['egotec_conf']['site_dir'].$this->_site->name.'/'.$this->field['type'].'/admin/navigation.ini';
6167 if (!file_exists($file_name)) {
6168 $file_name = $GLOBALS['egotec_conf']['site_dir'].$this->_site->name.'/admin/navigation.ini';
6169 if ($this->_site->globalAllowed() && !file_exists($file_name)) {
6170 $file_name = $GLOBALS['egotec_conf']['site_dir'].'_global/admin/navigation.ini';
6173 if (file_exists($file_name)) {
6174 $navigation = parse_ini_file($file_name, true);
6175 foreach ($navigation as $key => $value) {
6176 if (stripos($value['url'], 'info.php?') === 0) {
6177 if (preg_match_all('/([^\?&=]+)=([^\?&=#]*)/', $value['url'], $matches)) {
6178 foreach ($matches[0] as $index => $match) {
6179 if ($matches[1][$index] != 'tpl_name') {
6180 $params[$matches[1][$index]] = $matches[2][$index];
6188 $params['url'] = 'extra.php?'.http_build_query($params);
6200 public function getContent($main_orient = false, $variant = '', $include_scripts = false) {
6202 if ($variant != '') {
6203 // Block Variante global weiterreichen, damit alle Aufrufe im fetch() darauf zugreifen können
6204 $GLOBALS['_block_variant'] = $variant;
6206 if ($this->isFrontendAdmin(false)) {
6208 // Nur die Blöcke der Haupt-Orientierung
6209 $content = $this->getBlocks($this->mainOrient, $variant, $include_scripts);
6210 } elseif ($layout = $this->getLayout($GLOBALS['is_mobile'])) {
6211 require_once 'smarty/Ego_Smarty.php';
6212 $smarty = Ego_Smarty::createFrontend($this->_site, array(
6215 $smarty->autoload_filters['output'] = array('frontend_edit');
6217 // Seiten spezifische Skripte einbinden
6218 if ($include_scripts) {
6219 $include_script = function($file) use ($smarty) {
6220 // Weitere Variablen im Skript verfügbar machen
6222 $site = $page->getSite();
6223 $auth = $GLOBALS['auth'];
6225 $length = strlen($needle = "/{$this->field[
'type']}/index.php
");
6226 if (substr($file, -$length) === $needle) {
6227 // Nur das Seitentyp spezifische Skript mehrmals einbinden
6233 foreach ($this->getScripts() as $file) {
6234 $include_script($file);
6238 $original_smarty = $GLOBALS['smarty'];
6239 $GLOBALS['smarty'] = $smarty;
6240 $content = $smarty->fetch($layout);
6241 $GLOBALS['smarty'] = $original_smarty;
6244 if ($content == '') {
6245 $content = $this->field['content'];
6247 unset($GLOBALS['_block_variant']);
6261 public function getLayout($mobile = false, $name = '', $suffix = '', &$script = '', $skip = array('module')) {
6262 // Layout Template ermitteln
6263 if (empty($suffix)) {
6264 $suffix = $_SERVER['REQUEST_SUFFIX'];
6266 $suffix = $suffix != '.html' ? $suffix : '';
6267 $name = $name ? $name : $this->extra['_layout'];
6268 $cache_key = 'pageLayout'.md5(serialize(array($this->field['type'], $name, $mobile, $suffix, $skip)));
6269 $layout = $this->_site->getCacheEntry($cache_key);
6271 if ($layout === null) {
6273 $set_to_default = false;
6275 if ($name !== $this->conf['default_layout']) {
6276 // Prüfen, ob das Layout vom Seitentyp aus erlaubt ist
6277 $typeInfo = $this->getTypeInfo();
6278 if (isset($typeInfo['layouts']) && !in_array($name, explode(',', $typeInfo['layouts']))) {
6279 $layout = $this->getLayout($mobile, $this->conf['default_layout'], '.html', $script, $skip);
6280 $set_to_default = true;
6283 // Prüfen, ob das Layout in der conf.json deaktiviert ist
6285 !empty($this->conf['layouts'])
6286 && isset($this->conf['layouts'][$name]['disabled'])
6287 && $this->conf['layouts'][$name]['disabled']
6289 $layout = $this->getLayout($mobile, $this->conf['default_layout'], '.html', $script, $skip);
6290 $set_to_default = true;
6294 if (!$set_to_default) {
6295 foreach (array('.tpl', '.html') as $file_suffix) {
6296 if (!empty($name) && $name != 'default') {
6298 ($file = $this->_site->getSkinFile("{$this->field[
'type']}/layouts/{$name}{$suffix}{$file_suffix}
", $skip))
6299 || ($file = $this->_site->getSkinFile("layouts/{$name}{$suffix}{$file_suffix}
", $skip))
6305 ($file = $this->_site->getSkinFile("{$this->field[
'type']}/layout{$suffix}{$file_suffix}
", $skip))
6306 || ($file = $this->_site->getSkinFile("layout{$suffix}{$file_suffix}
", $skip))
6313 if (empty($layout)) {
6314 if ($suffix != '') {
6315 $layout = $this->getLayout($mobile, $name, '.html', $script, $skip);
6316 } elseif ($name != $this->conf['default_layout']) {
6317 $layout = $this->getLayout($mobile, $this->conf['default_layout'], '.html', $script, $skip);
6322 $this->_site->setCacheEntry($cache_key, $layout);
6325 // Layout Skript ermitteln
6326 $cache_key = 'pageLayoutScript'.md5(serialize(array($this->field['type'], $name, $mobile, $suffix, $skip)));
6327 $script = $this->_site->getCacheEntry($cache_key);
6329 if ($script === null) {
6332 if (!empty($name) && $name != 'default') {
6333 if ($name == 'default') {
6335 ($file = $this->_site->getSiteFile("{$this->field[
'type']}/layout{$suffix}.php
", $skip))
6336 || ($file = $this->_site->getSiteFile("layout{$suffix}.php
", $skip))
6341 ($file = $this->_site->getSiteFile("{$this->field[
'type']}/layouts/{$name}{$suffix}.php
", $skip))
6342 || ($file = $this->_site->getSiteFile("layouts/{$name}{$suffix}.php
", $skip))
6350 ($file = $this->_site->getSiteFile("{$this->field[
'type']}/layout{$suffix}.php
", $skip))
6351 || ($file = $this->_site->getSiteFile("layout{$suffix}.php
", $skip))
6356 $this->_site->setCacheEntry($cache_key, $script);
6368 public function getLayouts($skip = array()) {
6369 $layouts = $this->_site->getLayoutFiles($this->field['type'], $skip, $this->conf['layouts']);
6371 // Nur bestimmte Layouts sind für diese Page erlaubt
6372 $info = $this->getTypeInfo();
6373 if (!empty($info['layouts'])) {
6374 return array_intersect_key($layouts, array_flip(explode(',', $info['layouts'])));
6377 // Bestimmte Layouts deaktivieren
6378 if (!empty($this->conf['layouts'])) {
6379 foreach ($this->conf['layouts'] as $layout => $conf) {
6380 if ($conf['disabled']) {
6381 unset($layouts[$layout]);
6394 public function isMovable() {
6395 $info = $this->getTypeInfo();
6397 // Darf es verschoben werden?
6398 if (array_key_exists('movable', $info)) {
6399 if ($info['movable']) {
6405 // Bildausschnitte dürfen nicht verschoben werden
6406 if ($this->extra['crop_image']) {
6410 // Nicht gesetzt -> Automatisch true
6418 public function getMovableList($type) {
6419 $info = $this->getTypeInfo();
6420 if (isset($info['movable_' . $type . 'list'])) {
6421 return array_map('trim', explode(',', $info['movable_' . $type . 'list']));
6435 public function getTemplate($mobile = false, $name = 'body', $variant = '') {
6436 return $this->_site->getTemplate($mobile, $name, $this->field['type'], $variant ? $variant : (string) $this->extra['_template']);
6445 public function getContents($orient) {
6446 return $this->extra['_contents'][$orient];
6460 public function getScripts() {
6462 $GLOBALS['egotec_conf']['site_dir'] . $this->_site->name . '/index.php',
6463 $this->_site->getSiteFile($this->field['type'] . '/index.php')
6465 if ($this->_site->globalAllowed()) {
6466 // Für diesen Mandanten ein globales Skript verwenden
6467 array_unshift($scripts, $GLOBALS['egotec_conf']['site_dir'] . '_global/index.php');
6469 if (!empty($this->_site->theme)) {
6470 array_splice($scripts, 2, 0, $this->_site->getSiteFile('index.php', array('module', 'custom', 'global', 'parent_custom')));
6472 $existing_scripts = [];
6473 foreach ($scripts as $script) {
6474 if ($script && Ego_System::file_exists($script)) {
6475 $existing_scripts[] = $script;
6478 return $existing_scripts;
6487 public function hasContent($orient = null) {
6488 if ($this->isFrontendAdmin(false)) {
6489 return $this->field['type'] != 'page' // @TODO Muss auch für andere Seitentypen funktionieren
6491 isset($this->extra['_contents'])
6492 && !empty($this->extra['_contents'])
6496 isset($this->extra['_contents'][$orient])
6497 && !empty($this->extra['_contents'][$orient])
6502 return !Ego_System::isEmptyContent($this->field['content']);
6512 public function hasBlock($block, $orient = '') {
6514 if (is_array($this->extra['_blocks'])) {
6515 foreach ($this->extra['_blocks'] as $_orient => $blocks) {
6516 if (!$orient || $orient == $_orient) {
6517 $values = array_count_values($blocks);
6518 if (isset($values[$block])) {
6519 $n += $values[$block];
6536 public function addBlock($orient, $name, $content = [], $index = -1) {
6537 $content = array_merge([
6538 '_uid' => Ego_System::createUID()
6542 '_contents' => $content
6544 foreach ($keys as $key => $value) {
6545 if (!isset($this->extra[$key][$orient])) {
6546 $this->extra[$key][$orient] = [$value];
6547 } elseif ($index >= 0) {
6548 array_splice($this->extra[$key][$orient], $index, 0, [$value]);
6550 $this->extra[$key][$orient][] = $value;
6562 public function removeBlockByName($orient, $name) {
6563 if (isset($this->extra['_blocks'][$orient])) {
6565 while (($index = array_search($name, $this->extra['_blocks'][$orient])) !== false) {
6566 $this->removeBlockByIndex($orient, $index);
6581 public function removeBlockByIndex($orient, $index) {
6582 if (isset($this->extra['_blocks'][$orient][$index])) {
6584 $this->extra['_blocks'][$orient][$index],
6585 $this->extra['_contents'][$orient][$index]
6587 $this->extra['_blocks'][$orient] = array_values($this->extra['_blocks'][$orient]);
6588 $this->extra['_contents'][$orient] = array_values($this->extra['_contents'][$orient]);
6605 public function removeAllBlocks(string $orients = ''): array {
6611 if ($orients != '') {
6612 foreach (explode(',', $orients) as $orient) {
6613 $array_return['_blocks'][$orient] = $this->extra['_blocks'][$orient];
6614 $array_return['_contents'][$orient] = $this->extra['_contents'][$orient];
6617 $this->extra['_blocks'][$orient],
6618 $this->extra['_contents'][$orient]
6622 $array_return['_blocks'] = $this->extra['_blocks'];
6623 $array_return['_contents'] = $this->extra['_contents'];
6626 $this->extra['_blocks'],
6627 $this->extra['_contents']
6631 return $array_return;
6642 public function getBlocks($orient, $variant = '', $page_frame = false) {
6643 // Wird diese Methode innerhalb eines Attach Element Templates aufgerufen, werden die Namen nicht erweitert
6644 $restore_value_prefix = '';
6645 if (isset($GLOBALS['_smarty_value_prefix'])) {
6646 $restore_value_prefix = $GLOBALS['_smarty_value_prefix'];
6647 unset($GLOBALS['_smarty_value_prefix']);
6650 if ($variant == '') {
6651 if (isset($GLOBALS['_block_variant'])) {
6652 // Die Block Variante wird global weitergereicht
6653 $variant = $GLOBALS['_block_variant'];
6654 } elseif (in_array($_SERVER['REQUEST_SUFFIX'], array('.pdf', '.print'))) {
6655 // Block Varianten für .pdf und .print verwenden
6656 $variant = ltrim($_SERVER['REQUEST_SUFFIX'], '.');
6657 } elseif ($this->extra['_template']) {
6658 // Template Variante als Block Variante verwenden
6659 $variant = $this->extra['_template'];
6662 $layout = $this->extra['_layout'];
6663 $blocks = $this->extra['_blocks'][$orient];
6665 if (!is_array($blocks) || empty($blocks)) {
6666 // Standard Blöcke verwenden
6668 if (empty($layout)) {
6669 $layout = $this->conf['default_layout']; // Standard Layout verwenden
6672 if (!empty($this->conf['layouts'][$layout]['blocks'][$orient]['default'])) {
6674 $blocks = explode(',', $this->conf['layouts'][$layout]['blocks'][$orient]['default']);
6676 if (empty($blocks) && $orient == $this->mainOrient && $this->conf['template_block'] === true) {
6677 // Keine Blöcke und die Haupt-Orientierung: Immer das Standard Template verwenden
6678 $blocks[] = 'template';
6682 // Standard Template immer anzeigen, wenn
6684 $this->field['type'] != 'page' // ...nicht der Standard Seitentyp verwendet wird
6686 // Der Seitentyp besitzt ein eigenes body Template und das Standard Template wird immer angezeigt
6687 // @TODO Nur wenn das Template aus dem Systemstandard kommt?
6688 $body_template = null;
6689 $default_template = $GLOBALS['egotec_conf']['lib_dir'] . 'type/skin/page/body.html';
6690 $get_body_template = function() use (&$body_template, $variant) {
6691 if (!$body_template) {
6692 $body_template = $this->getTemplate($GLOBALS['is_mobile'], 'body', $variant);
6694 return $body_template;
6697 // Das Standard Template darf nicht entfernt werden, wenn
6699 $this->conf['blocks']['template']['removable'] !== true // ...nicht explizit das Entfernen erlaubt ist
6700 && $get_body_template() != $default_template // ...der Seitentyp ein eigenes body Template besitzt
6702 $this->conf['blocks']['template']['removable'] = false;
6705 // Das Standard Template muss für nicht Standard Seitentypen immer vorhanden sein
6707 $orient == $this->mainOrient // ...nur für die Haupt-Orientierung
6708 && !in_array('template', $blocks) // ...und das Standard Template nicht bereits eingebunden wird
6709 && $this->conf['blocks']['template']['removable'] !== true // ...außer es darf explizit entfernt werden
6710 && $get_body_template() != $default_template // ...der Seitentyp ein eigenes body Template besitzt
6712 $blocks[] = 'template';
6716 // HTML aller Blöcke zusammenfügen
6718 if (!empty($blocks)) {
6719 $system_blocks = $this->getSystemBlocks();
6721 foreach ($blocks as $index => $block) {
6722 if ($block != 'template' && isset($this->conf['blocks'][$block]['system']) && !isset($system_blocks[$block])) {
6723 // Deaktivierte System Blöcke nicht anzeigen
6727 if ($page_frame && $this->conf['blocks'][$block]['exclude']) {
6728 // Blöcke, die für die Einbindung als dynamischer Inhalt ignoriert werden sollen, überspringen
6732 $removable = !isset($this->conf['blocks'][$block]['removable']) || (bool) $this->conf['blocks'][$block]['removable'];
6733 $template = $this->getTemplateBlock($block, $orient, $index, false, false, $variant, $removable, false, $page_frame);
6734 if ($template === null) {
6735 // Block existiert nicht
6736 if ($GLOBALS['frontend_admin'] && $this->conf['orients'][$orient]['disabled'] !== true) {
6737 // Einen unbekannten Block darstellen
6738 $html .= $this->getTemplateBlock('unknown', $orient, $index, false, false, $variant, $removable, false, $page_frame);
6739 $this->extra['_blocks'][$orient][$index] = 'unknown';
6740 unset($this->extra['_contents'][$orient][$index]);
6749 // Formulare erweitern
6750 if (!empty($this->extra['_forms'][$orient])) {
6751 // Unsichtbare Formular Felder generieren
6752 if (!empty($this->extra['_forms'][$orient]['hidden'])) {
6753 require_once('base/Ego_Combo.php');
6754 $combo = new Ego_Combo($this->extra['_forms'][$orient]['hidden']);
6755 foreach ($combo->getData() as $field) {
6756 $html .= '<input type="hidden
" name="' . $field->key . '" value="' . $field->value . '">';
6760 // Mehrfachversand verhindern
6761 require_once 'base/Ego_ValidateForm.php';
6762 $html .= Ego_ValidateForm::generateToken($orient);
6763 $html .= Ego_ValidateForm::generateCSRF($orient);
6765 // Seiten mit Formularen immer ohne Cache ausliefern, da sonst der eindeutige Token/CSRF mehrfach verwendet werden kann
6766 $this->field['cache'] = 0;
6769 // Vorangestellten Namen für Attach Element Templates wiederherstellen
6770 if (!empty($restore_value_prefix)) {
6771 $GLOBALS['_smarty_value_prefix'] = $restore_value_prefix;
6786 public function getBlock($orient, $uid, $variant = '', $page_frame = false) {
6788 $blocks = $this->extra['_blocks'][$orient];
6790 if (is_numeric($uid)) {
6791 // Abwärtskompatibilität: UID ist die Position des Blocks
6793 if (!empty($blocks) && isset($blocks[$index])) {
6794 $block = $blocks[$index];
6796 $removable = !isset($this->conf['blocks'][$block]['removable']) || (bool) $this->conf['blocks'][$block]['removable'];
6797 $template = $this->getTemplateBlock($block, $orient, $index, false, false, $variant, $removable, false, $page_frame);
6798 if ($template !== null) {
6802 } elseif (is_array($blocks)) {
6803 foreach ($blocks as $index => $block) {
6804 if ($this->extra['_contents'][$orient][$index]['_uid'] == $uid) {
6805 $removable = !isset($this->conf['blocks'][$block]['removable']) || (bool) $this->conf['blocks'][$block]['removable'];
6806 $template = $this->getTemplateBlock($block, $orient, $index, false, false, $variant, $removable, false, $page_frame);
6807 if ($template !== null) {
6823 private function getSystemBlocks() {
6826 $system_conf = Ego_System::getJSON($GLOBALS['egotec_conf']['lib_dir'] . 'page/conf.json');
6827 foreach ($system_conf['blocks'] as $block => $conf) {
6828 $this->conf['blocks'][$block]['system'] = strpos($block, 'input_') === 0
6832 if ($block != 'template' && empty($this->conf['no_' . $block])) {
6833 // Deaktivierte Systemeigene Blöcke ausschließen
6835 isset($this->_site->admin['blocks']['overwrite'])
6836 && !empty($this->_site->admin['blocks']['overwrite'])
6839 isset($this->_site->admin['blocks']['system_disabled'])
6840 && in_array($block, explode(',', $this->_site->admin['blocks']['system_disabled']))
6845 isset($GLOBALS['egotec_conf']['blocks']['system_disabled'])
6846 && in_array($block, explode(',', $GLOBALS['egotec_conf']['blocks']['system_disabled']))
6851 if (!isset($this->conf['blocks'][$block])) {
6852 $this->conf['blocks'][$block] = $conf;
6854 $this->conf['blocks'][$block] = array_merge($conf, $this->conf['blocks'][$block]);
6857 $blocks[$block] = $conf['title'];
6872 public function getBlockList($layout = null, $template = false, $for_orient = '') {
6873 $skip = !$this->_site->globalAllowed() ? ['global'] : [];
6874 $cache_key = 'blockList_' . md5(serialize(array(
6878 $this->field['type'],
6880 $this->_site->language,
6881 $GLOBALS['auth']->isNobody() ? '' : $GLOBALS['auth']->user->field['user_id']
6883 $blocks = $this->_site->getCacheEntry($cache_key);
6885 if ($blocks === null) {
6886 // Sicherstellen, dass Block Informationen immer mit den Backend Übersetzungen ermitteln werden
6887 $original_smarty = $GLOBALS['smarty'];
6888 unset($GLOBALS['translation'][$GLOBALS['t_language']]);
6889 $GLOBALS['smarty'] = Ego_Smarty::createAdmin($this->_site, array(
6895 // Liste der verfügbaren Blöcke generieren (auch von übergeordneten Seitentypen erben)
6898 foreach (explode('/', $this->field['type']) as $path) {
6899 $current_path .= '/' . $path;
6900 $block_files = array_merge($block_files, $this->_site->getBlockFiles(ltrim($current_path, '/'), $skip));
6903 // Systemeigene Blöcke hinzufügen
6904 $block_files = array_merge($block_files, $this->getSystemBlocks());
6907 foreach ($block_files as $block => $title) {
6908 if ($block == 'unknown') {
6910 } elseif ($block == '_empty') {
6911 if ($this->conf['template_block'] !== true && !$template) {
6914 // Das Standard Template ist immer verfügbar
6915 $block = 'template';
6916 } elseif ($this->_site->isDisabledBlock($block)) {
6917 // Block ist deaktiviert
6919 } elseif (empty($this->conf['blocks'][$block])) {
6920 $this->conf['blocks'][$block] = array();
6922 if (strpos($block, 'input_') === 0) {
6923 // Formular Blöcke automatisch erweitern
6924 if (!isset($this->conf['blocks'][$block]['system'])) {
6925 $this->conf['blocks'][$block]['system'] = 'form';
6927 if (!isset($this->conf['blocks'][$block]['group'])) {
6928 $this->conf['blocks'][$block]['group'] = 'Formular';
6930 if (!isset($this->conf['blocks'][$block]['controls'])) {
6931 $this->conf['blocks'][$block]['controls'] = array();
6933 array_unshift($this->conf['blocks'][$block]['controls'], array(
6935 'name' => substr(strrchr($block, '_'), 1)
6938 $blocks[$block] = array(
6939 'title' => $GLOBALS['auth']->translate($this->conf['blocks'][$block]['title'] ? $this->conf['blocks'][$block]['title'] : $title),
6940 'description' => $GLOBALS['auth']->translate((string)$this->conf['blocks'][$block]['description']),
6941 'image' => $this->conf['blocks'][$block]['image'] ? $GLOBALS['egotec_conf']['url_dir'] . $this->conf['blocks'][$block]['image'] : '',
6942 'max' => (int)$this->conf['blocks'][$block]['max'],
6943 'translate' => $this->conf['blocks'][$block]['translate'] !== false
6945 if (isset($this->conf['blocks'][$block]['index'])) {
6946 $blocks[$block]['index'] = (int)$this->conf['blocks'][$block]['index'];
6948 if (!empty($this->conf['blocks'][$block]['system'])) {
6949 $blocks[$block]['system'] = $this->conf['blocks'][$block]['system'];
6951 if ($controls = $this->getBlockControls($block)) {
6952 $blocks[$block]['controls'] = $controls;
6954 if (!empty($this->conf['blocks'][$block]['group'])) {
6956 foreach (explode(',', $this->conf['blocks'][$block]['group']) as $group) {
6957 $groups[] = $GLOBALS['auth']->translate(trim($group));
6959 $blocks[$block]['group'] = implode(',', $groups);
6961 if (!empty($this->conf['blocks'][$block]['pattern'])) {
6962 $blocks[$block]['pattern'] = array();
6963 foreach (explode(',', $this->conf['blocks'][$block]['pattern']) as $index => $pattern) {
6964 if (preg_match_all('/\[([^:=]+?)(:([^=]+?))?(=(.+?))?\]/', $pattern, $matches)) {
6965 $blocks[$block]['pattern'][$index] = array();
6966 foreach ($matches[0] as $index2 => $match) {
6967 $width = $matches[1][$index2];
6968 $type = (string) $matches[3][$index2];
6969 $color = (string) $matches[5][$index2];
6974 if (strpos($type, 'image:') === 0) {
6975 $data['image'] = $GLOBALS['egotec_conf']['url_dir'] . substr($type, 6);
6977 $data['type'] = $type;
6979 $blocks[$block]['pattern'][$index][] = $data;
6985 $sort[] = mb_strtolower($blocks[$block]['title']);
6988 // Blöcke alphabetisch sortieren
6989 array_multisort($sort, SORT_ASC, SORT_REGULAR, $blocks);
6991 // Blöcke variabel sortieren
6994 foreach ($blocks as $block => $info) {
6997 // Dynamischer Inhalt als letzter Block
6998 $i = sizeof($blocks) + 1;
7001 if (strpos($block, 'input_') === 0) {
7002 // Formular Elemente als vorletzte Blöcke
7003 $i = sizeof($blocks);
7005 // Individuelle Position
7006 if (isset($info['index'])) {
7007 $i = (int)$info['index'];
7009 // Negative Position ausgehend vom letzten Block
7010 $i = sizeof($blocks) - abs($i);
7012 } elseif ($block == 'template') {
7013 // Standard Template als erster Block, wenn nichts anderes angegeben ist
7022 array_multisort($sort, SORT_ASC, SORT_NUMERIC, $blocks);
7024 if ($layout !== null) {
7025 // Alle Blöcke nach Orientierung gruppieren
7026 $block_list = array();
7027 if (!empty($this->conf['layouts'][$layout]['blocks'])) {
7028 foreach ($this->conf['layouts'][$layout]['blocks'] as $orient => $info) {
7029 $get_blocks = function ($block_list, $type) use ($layout, $info, &$get_blocks) {
7031 if (!empty($info['extend_' . $type])) {
7032 $block_list .= ",{$info[
'extend_'.$type]}
";
7034 foreach (explode(',', $block_list) as $block) {
7035 if ($block[0] == '@') {
7036 // Blöcke einer anderen Orientierung für dieses Layout verwenden
7037 $orient_block_list = $this->conf['layouts'][$layout]['blocks'][substr($block, 1)][$type];
7038 if (!empty($orient_block_list)) {
7039 $blocks = array_merge($blocks, $get_blocks($orient_block_list, $type));
7045 return array_unique($blocks);
7048 if (!empty($info['allow'])) {
7049 // Nur erlaubte Blöcke ausgeben
7050 $block_list[$orient] = array_intersect_key($blocks, array_flip($get_blocks($info['allow'], 'allow')));
7051 } elseif (!empty($info['disallow'])) {
7052 // Nicht erlaubte Blöcke nicht ausgeben
7053 $block_list[$orient] = array_diff_key($blocks, array_flip($get_blocks($info['disallow'], 'disallow')));
7056 } elseif (!empty($for_orient)) {
7057 $block_list[$for_orient] = $blocks;
7059 // Gruppierung nach Haupt-Orientierung muss immer existieren
7060 if (empty($block_list[$this->mainOrient])) {
7061 $block_list[$this->mainOrient] = $blocks;
7064 $blocks = $block_list;
7067 $this->_site->setCacheEntry($cache_key, $blocks);
7068 $GLOBALS['smarty'] = $original_smarty;
7071 // Prüfen, ob dieses Layout Formulare beinhaltet
7072 $has_forms = $this->hasForms($layout);
7074 // Formular Blöcke für bestimmte Orientierungen nicht zurückliefern
7075 $filter = function($blocks) {
7076 $filtered = array();
7077 foreach ($blocks as $key => $block) {
7078 if (strpos($key, 'input_') !== 0) {
7079 $filtered[$key] = $block;
7085 // Sicherstellen, dass die Orientierungen mit Formularen mindestens die Formular Blöcke anzeigen
7086 foreach ($has_forms as $orient) {
7087 if (empty($blocks[$orient])) {
7088 $blocks[$orient] = $blocks[$this->mainOrient];
7090 foreach ($blocks[$this->mainOrient] as $key => $block) {
7091 if (strpos($key, 'input_') === 0 && !isset($blocks[$orient][$key])) {
7092 $blocks[$orient][$key] = $block;
7097 foreach (array_keys($blocks) as $orient) {
7098 if (!in_array($orient, $has_forms)) {
7099 $blocks[$orient] = $filter($blocks[$orient]);
7102 } elseif (empty($has_forms)) {
7103 $blocks = $filter($blocks);
7106 if (!empty($for_orient)) {
7107 return $blocks[$for_orient];
7118 public function hasForms($layout = '') {
7119 $cache_key = 'hasForms'.md5(serialize(array($this->getIdentity(), $layout)));
7120 $has_forms = $this->_site->getCacheEntry($cache_key);
7122 if ($has_forms === null) {
7123 $conf_forms = $this->conf['layouts'][$layout ?: 'default']['form'];
7124 if (!empty($conf_forms)) {
7125 $this->_site->setCacheEntry($cache_key, $conf_forms);
7129 if ($file = $this->getLayout(false, $layout)) {
7130 $has_forms = array();
7132 if (preg_match_all('/<form([^>]*)>(.*?)<\/form>/ims', Ego_System::file_get_contents($file), $matches)) {
7133 foreach (array_keys($matches[0]) as $index) {
7135 // Das Formular ist bereits die Orientierung
7136 preg_match('/data-edit-template=["\
'](.+?)["\']/ims', $matches[1][$index], $match)
7138 || preg_match(
'/<[^>]+data-edit-template=["\'](.+?)["\'][^>]*>/ims', $matches[2][$index], $match)
7140 $has_forms[] = $match[1];
7144 $has_forms = array_unique($has_forms);
7146 $this->_site->setCacheEntry($cache_key, $has_forms);
7160 if (isset($this->conf[
'blocks'][$block][
'controls'])) {
7161 $controls = array();
7162 foreach ($this->conf[
'blocks'][$block][
'controls'] as $control) {
7163 if ($control[
'name'][0] ==
'@') {
7165 [$inherited_block, $name] = explode(
'.', substr($control[
'name'], 1));
7166 if (isset($this->conf[
'blocks'][$inherited_block][
'controls'])) {
7167 foreach ($this->conf[
'blocks'][$inherited_block][
'controls'] as $inherited_control) {
7168 if ($inherited_control[
'name'] == $name) {
7169 $merged_control = array_merge($inherited_control, $control);
7170 $merged_control[
'name'] = $inherited_control[
'name'];
7171 $controls[] = $merged_control;
7177 $controls[] = $control;
7201 public function getTemplateBlock($block =
'template', $orient =
'', $index = 0, $empty =
false, $replace =
false, $variant =
'', $removable =
true, $do_save =
false, $page_frame =
false, $element_types = [], &$smarty =
null) {
7202 if ($orient ==
'') {
7203 $orient = $this->mainOrient;
7207 $GLOBALS[
'__egotec_edit_do_save'] = $do_save;
7210 $uid = $this->extra[
'_contents'][$orient][$index][
'_uid'];
7212 $html = $class =
'';
7213 $custom_html =
false;
7215 require_once(
'smarty/Ego_Smarty.php');
7216 $smarty = Ego_Smarty::createFrontend($this->_site, array(
7222 $original_smarty = $GLOBALS[
'smarty'] ? $GLOBALS[
'smarty'] : $smarty;
7223 $GLOBALS[
'smarty'] = $smarty;
7226 if (empty($this->extra)) {
7227 $this->extra = unserialize($this->field[
'extra']);
7231 if ($empty && !empty($this->conf[
'blocks'][$block][
'default'][$orient])) {
7232 $this->extra[
'_contents'][$orient][$index] = $this->conf[
'blocks'][$block][
'default'][$orient];
7235 if (is_array($this->extra[
'_contents'][$orient][$index][
'extra'])) {
7237 $extra = $this->extra[
'_contents'][$orient][$index][
'extra'];
7240 foreach ($extra as $key => $value) {
7241 if (in_array($value, array(
'0000-00-00',
'0000-00-00 00:00:00'),
true)) {
7242 unset($extra[$key]);
7246 if (strpos($block,
'input_') === 0) {
7248 if (isset($_POST[$extra[
'name']])) {
7250 $smarty->assign(
'value', $_POST[$extra[
'name']]);
7251 if (isset($_POST[$extra[
'name'] .
'_input'])) {
7252 $smarty->assign(
'value_input', $_POST[$extra[
'name'] .
'_input']);
7254 } elseif ($block ==
'input_checkbox') {
7257 require_once
'base/Ego_Combo.php';
7258 $combo =
new Ego_Combo($extra[
'values']);
7259 $new_data = array();
7260 foreach ($combo->getData() as $data) {
7261 if (isset($_POST[$data->field_name])) {
7262 $values[] = $data->field_name;
7266 foreach (array(
'required',
'optional') as $type) {
7267 if ($data->{$type}) {
7268 $data->label = $GLOBALS[
'smarty']->fetch(
'string:' . str_replace(
'<%>', $data->label, $this->conf[
'form'][$type] ?? $data->label));
7271 $new_data[] = $data;
7275 if (empty($new_data) && isset($extra[
'name'])) {
7278 $combo->setData($new_data);
7279 $extra[
'values'] = $combo->getString();
7282 $smarty->assign(
'values', $values);
7283 } elseif (empty($_POST[
'sendform'][$orient]) && isset($extra[
'default'])) {
7285 $smarty->assign(
'value', $extra[
'default']);
7289 if (!empty($extra[
'disabled'])) {
7290 $smarty->assign(
'disabled',
true);
7294 $smarty->assign(array(
7297 'pattern_optional' => $extra[
'regex'] ?
'$|' . $extra[
'regex'] :
''
7304 strpos($block,
'input_') === 0
7305 && isset($GLOBALS[
'_sendform_error'])
7306 && $GLOBALS[
'_sendform_error'][
'orient'] == $orient
7308 $GLOBALS[
'_sendform_error'][
'index'] == $index
7310 $GLOBALS[
'_sendform_error'][
'block'] ==
'input_captcha'
7311 && $block == $GLOBALS[
'_sendform_error'][
'block']
7315 $smarty->assign(
'error', $GLOBALS[
'_sendform_error'][
'title']);
7318 $smarty->assign(
'extra', $extra ?? []);
7319 unset($smarty->_plugins[
'outputfilter'], $smarty->autoload_filters[
'output']);
7322 $frontend_admin = $GLOBALS[
'frontend_admin'] && $this->conf[
'orients'][$orient][
'disabled'] !==
true;
7324 if ($block ==
'template') {
7334 $include_type_script =
function() use ($block, $orient, $index, $extra, $smarty, $variant) {
7338 && ($file = $this->_site->getSiteFile(
"{$this->field['type']}/index.{$variant}.php"))
7339 ) || ($file = $this->_site->getSiteFile(
"{$this->field['type']}/index.php"))
7343 $site = $page->getSite();
7344 $auth = $GLOBALS[
'auth'];
7349 $include_type_script();
7352 $html .= $this->fetch(array(
7353 '_layout' => $this->extra[
'_layout'],
7354 '_orient' => $orient,
7358 '_replace' => $replace,
7360 ),
false, (
bool) $GLOBALS[
'__egotec_edit_request'],
false, $variant);
7363 $block_found =
false;
7364 $suffixes = array(
'.tpl',
'.html');
7367 array_unshift($suffixes,
".{$variant}.tpl",
".{$variant}.html");
7369 foreach ($suffixes as $file_suffix) {
7371 ($file = $this->_site->getInheritedFile(
'skin', $this->field[
'type'],
"blocks/{$block}{$file_suffix}"))
7372 || ($file = $this->_site->getSkinFile(
"blocks/{$block}{$file_suffix}"))
7375 $this->blockProperties = array(
7376 '_layout' => $this->extra[
'_layout'],
7377 '_orient' => $orient,
7381 '_replace' => $replace,
7384 $smarty->assign(array_merge(
7385 $this->blockProperties,
7386 array(
'_page' => &$this)
7394 $include_block_script =
function() use ($block, $orient, $index, $extra, $smarty, $uid, $variant) {
7397 $site = $page->getSite();
7398 $auth = $GLOBALS[
'auth'];
7404 && ($file = $this->_site->getSiteFile(
"blocks.{$variant}.php"))
7405 ) || ($file = $this->_site->getSiteFile(
'blocks.php'))
7415 ($file = $this->_site->getSiteFile(
"{$this->field['type']}/blocks/{$block}.{$variant}.php"))
7416 || ($file = $this->_site->getSiteFile(
"blocks/{$block}.{$variant}.php"))
7418 ) || ($file = $this->_site->getSiteFile(
"{$this->field['type']}/blocks/{$block}.php"))
7419 || ($file = $this->_site->getSiteFile(
"blocks/{$block}.php"))
7425 $include_block_script();
7427 if ($controls = $this->getBlockControls($block)) {
7429 $dom =
function() use ($smarty, $file) {
7430 require_once(
'base/Ego_DomQuery.php');
7431 $smarty_clone = clone $smarty;
7436 $element_vars = $element_vars_default = [];
7437 foreach ($controls as $control) {
7438 if ($control[
'type'] ==
'attach') {
7440 if (!$empty && !empty($this->extra[
'_contents'][$orient][$index][$control[
'name']])) {
7441 $max =
sizeof($this->extra[
'_contents'][$orient][$index][$control[
'name']]);
7443 if ($frontend_admin && !$control[
'optional'] && $max == 0) {
7445 $max = $control[
'start'] ?? 1;
7447 $element_vars[$control[
'name']] = $element_vars_default[$control[
'name']] = [
7448 'index' => min($max, $control[
'start'] ?? 1) - 1,
7454 foreach ($controls as $ci => $control) {
7455 switch ($control[
'type']) {
7459 $custom_html =
true;
7462 $max = $element_vars[$control[
'name']][
'count'];
7464 foreach ($control[
'elements'] as $ei => $element) {
7467 $multiple_items = is_array($element[
'items']);
7470 if ($multiple_items) {
7471 $j = $element_types[$ci][$ei] ?? 0;
7472 if (isset($this->extra[
'_contents'][$orient][$index][$control[
'name']][$n][
'_type'])) {
7473 $j = (int) $this->extra[
'_contents'][$orient][$index][$control[
'name']][$n][
'_type'];
7475 $item = $element[
'items'][$j][
'item'];
7476 $script = $element[
'items'][$j][
'script'];
7477 $values = $element[
'items'][$j][
'values'];
7479 $item = $element[
'item'];
7480 $script = $element[
'script'];
7481 $values = $element[
'values'];
7485 $element_vars[$control[
'name']] = array_merge(array_filter($this->extra[
'_contents'][$orient][$index][$control[
'name']][$n] ?? [],
function($key) {
7486 return $key !=
'_element';
7487 }, ARRAY_FILTER_USE_KEY), $element_vars_default[$control[
'name']]);
7488 $element_vars[$control[
'name']][
'index'] = $n;
7489 $smarty->assign(
'_element', $element_vars);
7492 if (!empty($script) && ($file = $this->_site->getSiteFile($script))) {
7493 $load_script =
function($file) use (&$smarty, $extra, $element_vars) {
7494 $element = $element_vars;
7497 $load_script($file);
7501 if (strpos($item,
'@') === 0) {
7503 $GLOBALS[
'_smarty_value_prefix'] =
"{$control['name']}][$n][";
7505 unset($GLOBALS[
'_smarty_value_prefix']);
7508 $items .= $smarty->fetch(
'string:' . preg_replace_callback(
'/<%>/',
function () use ($values, $n, &$i, $control) {
7511 foreach ($values[$i] as $attr => $value) {
7512 if ($attr ==
'var') {
7513 $value =
"{$control['name']}][$n][$value";
7515 if (is_array($value)) {
7516 foreach ($value as $sub_attr => $sub_value) {
7517 $func .=
" {$attr}.{$sub_attr}=\"{$sub_value}\"";
7520 $func .=
" {$attr}=\"{$value}\"";
7526 }, str_replace([
'<#>',
'<##>'], [$n + 1, $max], $item)
7531 if ($n == 0 && $element[
'active']) {
7533 $nodes = $domQuery2->query($element[
'active'][
'selector']);
7534 foreach ($nodes as $node) {
7535 if ($element[
'active'][
'attribute'] ==
'class') {
7536 if ($className = $node->getAttribute(
'class')) {
7537 $classes = explode(
' ', $className);
7541 $classes[] = $element[
'active'][
'value'];
7542 $node->setAttribute(
'class', implode(
' ', $classes));
7544 $node->setAttribute($element[
'active'][
'attribute'], $element[
'active'][
'value']);
7546 $items = $domQuery2->getHTML();
7555 if ($domQuery ===
null) {
7558 $domQuery->setInnerHTML($domQuery->query($element[
'selector']),
function($node) use ($items) {
7566 $identity = $this->extra[
'_contents'][$orient][$index][$control[
'name']];
7570 && $data->getIdentity() !== $this->getIdentity()
7574 $data->getSite()->language != $this->getSite()->language
7575 && ($lang_data = $data->getLanguagePage($this->getSite()->language))
7581 $control[
'name'] => $data,
7582 "{$control['name']}_block" => $this->extra[
'_contents'][$orient][$index][$control[
'name'] .
'_block']
7589 $value = $this->extra[
'_contents'][$orient][$index][$control[
'name']];
7592 $control[
'attribute'] ==
'#text'
7593 || $control[
'preset'] ==
'materialize'
7598 $domQuery->setInnerHTML($domQuery->query($control[
'selector']),
function($node) use ($value, &$custom_html) {
7599 $custom_html =
true;
7606 if ($domQuery && $custom_html) {
7607 $html .= $domQuery->getHTML();
7611 if (!$custom_html) {
7613 $html .= $smarty->fetch($file);
7616 unset($this->blockProperties);
7617 $block_found =
true;
7622 if (!$block_found) {
7624 $GLOBALS[
'smarty'] = $original_smarty;
7630 if ($this->conf[
'form'][
'wrapper']) {
7631 $replace_form =
false;
7632 if (strpos($block,
'input_') === 0) {
7635 $block ==
'medialist'
7636 && !empty($this->extra[
'_contents'][$orient][$index][
'extra'])
7637 && preg_match(
'/<form[^>]*>.*?<\/form>/ims', $html, $matches)
7640 $form_html = $matches[0];
7641 $replace_form =
true;
7646 if ($form_html !=
'') {
7647 if (is_array($this->conf[
'form'][
'values'])) {
7649 $element = $this->conf[
'form'];
7651 $form_html = $smarty->fetch(
'string:' . preg_replace_callback(
'/<%>/',
function() use ($element, &$i, $form_html, $block) {
7652 if (empty($element[
'values'][$i])) {
7658 foreach ($element[
'values'][$i] as $attr => $value) {
7659 if (is_array($value)) {
7660 foreach ($value as $sub_attr => $sub_value) {
7661 $func .=
" {$attr}.{$sub_attr}=\"{$sub_value}\"";
7664 $func .=
" {$attr}=\"{$value}\"";
7671 }, $this->conf[
'form'][
'wrapper']));
7673 $form_html = str_replace(
'<%>', $form_html, $this->conf[
'form'][
'wrapper']);
7677 $columns = $this->extra[
'_contents'][$orient][$index][
'extra'][
'_columns'];
7679 $columns = (string) $this->conf[
'form'][
'columns'][
'default'];
7681 if (isset($this->conf[
'form'][
'columns'][
'value'])) {
7682 $columns = str_replace(
'<%>', $columns, $this->conf[
'form'][
'columns'][
'value']);
7684 $columns = trim($columns);
7686 $form_html = str_replace(
7694 if ($replace_form) {
7695 $html = preg_replace(
'/<form[^>]*>.*?<\/form>/ims', $form_html, $html);
7703 $modify_list = array_filter([
7704 $this->conf[
'blocks'][$block][
'modify'],
7705 $this->conf[
'modify']
7707 if (!empty($modify_list)) {
7708 require_once(
'base/Ego_DomQuery.php');
7710 $domQuery->setSmarty($smarty);
7711 $domQuery->setSite($this->getSite());
7714 foreach ($modify_list as $modify_entry) {
7715 foreach ($modify_entry as $modify) {
7716 if (isset($modify[
'scope']) && $modify[
'scope'] ==
'document') {
7721 if (isset($modify[
'value'])) {
7723 'orient' => $orient,
7726 'id' => $this->field[
'id'],
7729 foreach ($placeholders as $placeholder => $value) {
7730 $modify[
'value'] = str_replace(
"<%{$placeholder}>", $value, $modify[
'value']);
7734 $domQuery->modify($modify,
true);
7740 $html = $domQuery->getHTML();
7745 if (!empty($this->extra[
'_contents'][$orient][$index][
'_anchor'])) {
7746 $anchor =
"<a id=\"{$this->extra['_contents'][$orient][$index]['_anchor']}\"></a>\n";
7748 if (!empty($this->conf[
'anchor'])) {
7750 require_once(
'base/Ego_DomQuery.php');
7752 $domQuery->setSmarty($smarty);
7753 $domQuery->setSite($this->getSite());
7755 $domQuery->insertNode($anchor, $this->conf[
'anchor']);
7757 $html = $domQuery->getHTML();
7760 $html = $anchor . $html;
7765 $hash = md5(implode(
'-', [$this->getIdentity(), $block, $orient, $index]));
7766 $cache_key =
'blockStyles' . $hash;
7767 $cached_tpl = $this->_site->getCacheEntry($cache_key);
7768 if ($cached_tpl ===
null) {
7773 ($tpl = $cached_tpl[$block]) !==
null
7774 || ($tpl = $this->_site->getSkinFile(
"{$this->field['type']}/blocks/$block.style.tpl"))
7775 || ($tpl = $this->_site->getSkinFile(
"{$this->field['type']}/blocks/$block.style.html"))
7776 || ($tpl = $this->_site->getSkinFile(
"blocks/$block.style.tpl"))
7777 || ($tpl = $this->_site->getSkinFile(
"blocks/$block.style.html"))
7781 $css_file = $GLOBALS[
'egotec_conf'][
'bin_dir'] .
'tmp/' . $hash .
'.css';
7783 $css_file = $GLOBALS[
'egotec_conf'][
'url_dir'] .
'bin/tmp/' . basename($css_file);
7784 $html .=
"\n" .
'<link rel="stylesheet" property="stylesheet" href="' . $css_file .
'">';
7788 $cached_tpl[$block] = $tpl;
7789 $GLOBALS[
'site']->setCacheEntry($cache_key, $cached_tpl);
7791 $GLOBALS[
'smarty'] = $original_smarty;
7794 if (!empty($this->conf[
'blocks'][$block][
'class'])) {
7795 $class = $this->conf[
'blocks'][$block][
'class'];
7799 if (empty($this->conf[
'blocks'][$block][
'no_files'])) {
7802 "{$this->field['type']}/blocks/{$block}"
7804 foreach (array(
'css',
'js') as $extension) {
7805 foreach ($patterns as $pattern) {
7806 $path =
"$pattern.$extension";
7807 if ($file = $this->_site->getSkinFile($path, array(),
true)) {
7815 if ($this->extra[
'_contents'][$orient][$index][
'_classified']) {
7816 $classes = explode(
' ', $class);
7817 $classes[] =
'egotec-classified';
7818 $class = implode(
' ', array_filter($classes));
7821 if (empty($_REQUEST[
'page_block_preview']) && (!$frontend_admin || !$this->isCurrentPage())) {
7822 return trim($class ?
'<div class="' . $class .
'">' . $html .
'</div>' : $html);
7826 if (!empty($columns)) {
7827 $class = trim($class . $columns);
7830 if (trim($html) ==
'' && $this->isCurrentPage()) {
7833 if ($this->conf[
'blocks'][$block][
'title']) {
7834 $title = $GLOBALS[
'auth']->translate($this->conf[
'blocks'][$block][
'title']);
7836 $html =
'<div data-edit-empty-block="' . $title .
'"></div>';
7840 if (strpos($block,
'input_') === 0 && !isset($this->conf[
'blocks'][$block][
'group'])) {
7842 $this->conf[
'blocks'][$block][
'group'] =
'Formular';
7844 $group = (string) $this->conf[
'blocks'][$block][
'group'];
7846 $group = $GLOBALS[
'auth']->translate($group);
7850 $backend_options =
'';
7851 if (!empty($this->conf[
'panel'][
'options'])) {
7852 foreach ($this->conf[
'panel'][
'options'] as $option => $name) {
7854 if ($value !==
null) {
7855 $backend_options .=
' data-edit-option-' . $option .
'="' . $value .
'"';
7860 return trim(
'<div data-edit-block="' . $block .
'" data-edit-block-index="' . $index .
'" data-edit-block-uid="' . $uid .
'"'
7862 ($group ?
' data-edit-group="' . $group .
'"' :
'')
7863 . (!$removable ?
' data-edit-static="true"' :
'')
7864 . (!empty($columns) ?
' data-edit-columns="true"' :
'')
7867 . ($class ?
' class="' . $class .
'"' :
'')
7868 .
'>' . $html .
'</div>');
7883 if (!empty($this->conf[
'layouts'][$this->extra[
'_layout']][
'inherit'])) {
7884 if (isset($this->extra[
'_inherit_disabled']) && !empty($this->extra[
'_inherit_disabled'])) {
7887 foreach (explode(
',', $this->conf[
'layouts'][$this->extra[
'_layout']][
'inherit']) as $orient) {
7888 $blocks_key = implode(
'.', array(
'_blocks', $orient));
7889 $contents_key = implode(
'.', array(
'_contents', $orient));
7890 $extra = $this->inheritExtra(array($blocks_key, $contents_key));
7891 if ($extra[$blocks_key] !==
null) {
7895 if ($checksum_blocks != $checksum_original) {
7897 $this->extra[
'_inherited'][$orient] = array(
7898 'blocks' => $checksum_blocks,
7899 'contents' => $checksum_contents
7903 foreach ($extra as $key => $value) {
7904 $this->extra[strstr($key,
'.',
true)][$orient] = $value;
7922 'title' =>
'Headers',
7924 [
'title' =>
'Header 1',
'format' =>
'h1'],
7925 [
'title' =>
'Header 2',
'format' =>
'h2'],
7926 [
'title' =>
'Header 3',
'format' =>
'h3'],
7927 [
'title' =>
'Header 4',
'format' =>
'h4'],
7928 [
'title' =>
'Header 5',
'format' =>
'h5'],
7929 [
'title' =>
'Header 6',
'format' =>
'h6']
7933 'title' =>
'Inline',
7935 [
'title' =>
'Bold',
'icon' =>
'bold',
'format' =>
'bold'],
7936 [
'title' =>
'Italic',
'icon' =>
'italic',
'format' =>
'italic'],
7937 [
'title' =>
'Underline',
'icon' =>
'underline',
'format' =>
'underline'],
7938 [
'title' =>
'Strikethrough',
'icon' =>
'strike-through',
'format' =>
'strikethrough'],
7939 [
'title' =>
'Superscript',
'icon' =>
'superscript',
'format' =>
'superscript'],
7940 [
'title' =>
'Subscript',
'icon' =>
'subscript',
'format' =>
'subscript'],
7941 [
'title' =>
'Code',
'icon' =>
'sourcecode',
'format' =>
'code']
7945 'title' =>
'Blocks',
7947 [
'title' =>
'Paragraph',
'format' =>
'p'],
7948 [
'title' =>
'Blockquote',
'format' =>
'blockquote'],
7949 [
'title' =>
'Div',
'format' =>
'div'],
7950 [
'title' =>
'Pre',
'format' =>
'pre']
7954 'title' =>
'Alignment',
7956 [
'title' =>
'Left',
'icon' =>
'align-left',
'format' =>
'alignleft'],
7957 [
'title' =>
'Center',
'icon' =>
'align-center',
'format' =>
'aligncenter'],
7958 [
'title' =>
'Right',
'icon' =>
'align-right',
'format' =>
'alignright'],
7959 [
'title' =>
'Justify',
'icon' =>
'align-justify',
'format' =>
'alignjustify']
7965 if ($this->getSite()->admin[
'editor'][
'allow_classified']) {
7966 $formats[
'inline'][
'items'][] = [
'title' =>
'Im Druck einschwärzen',
'icon' =>
'invert',
'inline' =>
'span',
'classes' =>
'egotec-classified'];
7970 if (isset($this->conf[
'formats'])) {
7971 $custom_formats = $type && isset($this->conf[
'formats'][$type])
7972 ? $this->conf[
'formats'][$type]
7973 : $this->conf[
'formats'][
'default'];
7975 if (is_array($custom_formats)) {
7976 foreach ($custom_formats as $name => $values) {
7978 if (isset($formats[$name])) {
7980 if (is_array($values) && $values[
'options']) {
7983 foreach (explode(
',', $values[
'options']) as $option) {
7984 foreach ($formats[$name][
'items'] as $item) {
7985 if ($item[
'format'] == $option) {
7987 $new_items[] = $item;
7992 $formats[$name][
'items'] = $new_items;
7995 if (isset($values) && empty($values)) {
7997 unset($formats[$name]);
7998 } elseif (is_array($values) && isset($values[
'items'])) {
8001 if ($values[
'merge']) {
8003 $items = $formats[$name][
'items'];
8005 if (is_array($values[
'items'])) {
8006 foreach ($values[
'items'] as $custom_item) {
8007 if (($index = array_search($custom_item[
'title'], array_column($items,
'title'))) !==
false) {
8008 $items[$index] = $custom_item;
8010 $items[] = $custom_item;
8014 }
else if (is_array($values[
'items'])) {
8016 $items = $values[
'items'];
8019 if (!empty($items)) {
8021 'title' => $formats[$name][
'title'],
8026 unset($formats[$name]);
8031 $formats[$name] = $values;
8037 return array_values($formats);
8051 'contextmenu' =>
'',
8055 'items' =>
'undo redo | pastetext selectall | searchreplace'
8058 'title' =>
'Insert',
8059 'items' =>
'link | charmap egotecIcons | anchor | egotecAccessibility'
8063 'items' =>
'visualaid visualchars visualblocks'
8067 'items' =>
'inserttable | cell row column | tableprops deletetable'
8071 'items' =>
'egotecCode | help'
8079 $result[
'plugins'] =
'advlist autolink lists egotecLink image charmap anchor searchreplace visualblocks visualchars media table importcss help '
8080 .
'egotecSpellchecker egotecPageFrame egotecImageScale egotecList egotecMaxLength egotecIcons egotecAccessibility';
8081 $result[
'menubar'] =
'edit insert view table tools';
8082 $result[
'toolbar'] =
'styles removeformat | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist egotecBullist egotecNumlist | outdent indent | media image link unlink | egotecSpellchecker';
8083 $result[
'menu'][
'insert'][
'items'] .=
' | image media | table';
8084 $result[
'contextmenu'] =
'table | ';
8088 $result[
'plugins'] =
'advlist autolink lists egotecLink charmap anchor searchreplace visualblocks visualchars importcss help '
8089 .
'egotecSpellchecker egotecSplit egotecList egotecMaxLength egotecIcons egotecAccessibility';
8090 $result[
'menubar'] =
'edit insert view tools';
8091 $result[
'toolbar'] =
'styles removeformat | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist egotecBullist egotecNumlist | outdent indent | link unlink | egotecSpellchecker | egotecSplit';
8095 $result[
'plugins'] =
'autolink egotecLink anchor '
8096 .
'egotecSpellchecker egotecSplit egotecAccessibility';
8097 $result[
'toolbar'] =
'bold italic | link unlink | egotecSpellchecker | egotecSplit';
8101 $result[
'plugins'] =
'advlist autolink lists egotecLink charmap anchor searchreplace visualblocks visualchars table importcss help '
8102 .
'egotecSpellchecker egotecList egotecMaxLength egotecAccessibility egotecTable';
8103 $result[
'menubar'] =
'edit insert view tools';
8104 $result[
'toolbar'] =
'styles removeformat | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist egotecBullist egotecNumlist | outdent indent | link unlink | egotecSpellchecker | egotecSplit';
8105 $result[
'contextmenu'] =
'cell row column | ';
8109 $result[
'plugins'] =
'egotecSpellchecker egotecSplit egotecPlainText egotecMaxLength egotecAccessibility';
8110 $result[
'toolbar'] =
'egotecSpellchecker | egotecSplit';
8114 $result[
'contextmenu'] .=
'link | egotecAccessibility egotecSpellchecker-suggestions';
8116 if ($this->_site->hasRight(
"admin")) {
8118 $result[
'plugins'] .=
' egotecCode';
8122 $result[
'plugins'] .=
' egotecFix';
8125 if (!empty($this->conf[
'toolbar'])) {
8126 $custom_toolbar = $this->conf[
'toolbar'][$type];
8127 foreach (array_keys($result) as $name) {
8128 if (isset($custom_toolbar[$name])) {
8129 if (in_array($custom_toolbar[$name], [
'',
false],
true)) {
8130 $result[$name] =
false;
8131 } elseif (preg_match_all(
'/[+-]?[^+-]+/', $custom_toolbar[$name], $matches) !==
false) {
8132 foreach ($matches[0] as $toolbar) {
8133 $toolbar = trim(str_replace(
',',
' ', rtrim($toolbar,
',')),
' |');
8134 if (strpos($toolbar,
'+') === 0) {
8136 $result[$name] .=
' ' . substr($toolbar, 1);
8137 } elseif (strpos($toolbar,
'-') === 0) {
8139 $pattern =
'/(^| )(' . str_replace(
' ',
'|', preg_quote(substr($toolbar, 1))) .
')(|$)/';
8140 $result[$name] = preg_replace($pattern,
'', $result[$name]);
8143 $result[$name] = $toolbar;
8162 $type_path = explode(
'/', $this->field[
'type']);
8163 $type_info = $this->getTypeInfo();
8164 $inherit = isset($type_info[
'inherit']) ? explode(
',', (
string) $type_info[
'inherit']) : [
8168 if ($this->extra[
'_style']) {
8169 $variant =
'.'.$this->extra[
'_style'];
8171 $suffix = $_SERVER[
'REQUEST_SUFFIX'] !=
'.html' ? $_SERVER[
'REQUEST_SUFFIX'] :
'';
8173 foreach ($type_path as $path) {
8174 $current_path .= $path.
'/';
8177 in_array(
'style', $inherit)
8178 || rtrim($current_path,
'/') == $this->field[
'type']
8181 ($suffix !=
'' && ($src = $this->_site->getSkinFile($current_path.
'style'.$suffix.
'.css', array(
'system'),
true)))
8182 || ($variant !=
'' && ($src = $this->_site->getSkinFile($current_path.
'style'.$variant.
'.css', array(
'system'),
true)))
8183 || ($src = $this->_site->getSkinFile($current_path.
'style.css', array(
'system'),
true))
8190 in_array(
'script', $inherit)
8191 || rtrim($current_path,
'/') == $this->field[
'type']
8193 && ($src = $this->_site->getSkinFile($current_path.
'script.js', array(),
true))
8202 ($suffix !=
'' && ($src = $this->_site->getSkinFile(
'style'.$suffix.
'.css', array(
'system'),
true)))
8203 || ($variant !=
'' && ($src = $this->_site->getSkinFile(
'style'.$variant.
'.css', array(
'system'),
true)))
8204 || ($src = $this->_site->getSkinFile(
'style.css', array(
'system'),
true))
8208 if ($src = $this->_site->getSkinFile(
'script.js', array(
'system'),
true)) {
8223 if ($orient ===
null) {
8224 $orient = $this->mainOrient;
8225 if (isset($this->blockProperties[
'_orient'])) {
8226 $orient = $this->blockProperties[
'_orient'];
8239 if ($index ===
null) {
8241 if (isset($this->blockProperties[
'_index'])) {
8242 $index = $this->blockProperties[
'_index'];
8257 public function getValue($name, $orient =
null, $index =
null, $verbose =
false) {
8259 $orient = $this->getOrient($orient);
8260 $index = $this->getIndex($index);
8263 if (strpos($name,
',') !==
false) {
8264 foreach (explode(
',', $name) as $sub_name) {
8265 $value = $this->getValue($sub_name, $orient, $index, $verbose);
8266 if ($value !==
null) {
8273 if (($pos = strpos($name,
'.?.')) !==
false) {
8274 $array = $this->getValue(substr($name, 0, $pos), $orient, $index, $verbose);
8275 if (is_array($array)) {
8276 foreach ($array as $i => $value) {
8277 $value = $this->getValue(substr($name, 0, $pos) .
".$i." . substr($name, $pos + 3), $orient, $index, $verbose);
8278 if ($value !==
null) {
8287 $extra = unserialize($this->field[
'extra']);
8290 if ($value !==
null) {
8296 if (($pos = strrpos($name,
'.')) !==
false) {
8297 $key = implode(
'.', array(
'_contents', $orient, $index, substr($name, 0, $pos)));
8298 $name = substr($name, $pos + 1);
8300 $key = implode(
'.', array(
'_contents', $orient, $index));
8303 if (is_array($values)) {
8304 foreach ($values as $key => $value) {
8305 if (strpos($key,
"{$name}_") === 0) {
8306 $array[substr($key, strlen(
"{$name}_"))] = $value;
8307 } elseif ($key ==
'extra') {
8308 $array[$key] = $value;
8328 public function getValues($name, $orient =
null, $verbose =
false) {
8330 $orient = $this->getOrient($orient);
8333 if (is_array($this->extra[
'_contents'][$orient])) {
8334 $list = $this->extra[
'_contents'][$orient];
8335 if (is_array($list)) {
8336 foreach (array_keys($list) as $index) {
8337 $value = $this->getValue($name, $orient, $index, $verbose);
8338 if ($value !==
null) {
8357 $orient = $this->getOrient($orient);
8359 if (is_array($this->extra[
'_contents'][$orient])) {
8360 $list = $this->extra[
'_contents'][$orient];
8361 if (is_array($list)) {
8362 foreach (array_keys($list) as $index) {
8363 $value = $this->getValue($name, $orient, $index, $verbose);
8364 if ($value !==
null) {
8384 public function getFirstMediaValue(
string $name,
string $type =
'image',
string $orient =
null,
bool $verbose =
false) {
8385 $orient = $this->getOrient($orient);
8386 $list = $this->extra[
'_contents'][$orient];
8388 if (is_array($list)) {
8389 foreach (array_keys($list) as $index) {
8390 $value = $this->getValue($name, $orient, $index, $verbose);
8391 if ($value !==
null && $this->extra[
'_contents'][$orient][$index][$name .
'_type'] == $type) {
8410 public function getBlockValue($block, $name, $orient =
null, $index =
null, $verbose =
false) {
8412 $orient = $this->getOrient($orient);
8413 $index = $this->getIndex($index);
8415 if ($this->extra[
'_blocks'][$orient][$index] == $block) {
8416 $value = $this->getValue($name, $orient, $index, $verbose);
8417 if ($value !==
null) {
8435 $orient = $this->getOrient($orient);
8438 if (is_array($this->extra[
'_blocks'][$orient])) {
8439 foreach ($this->extra[
'_blocks'][$orient] as $index => $block_name) {
8440 if ($block_name == $block) {
8441 $value = $this->getValue($name, $orient, $index, $verbose);
8442 if ($value !==
null) {
8462 $orient = $this->getOrient($orient);
8464 if (is_array($this->extra[
'_blocks'][$orient])) {
8465 foreach ($this->extra[
'_blocks'][$orient] as $index => $block_name) {
8466 if ($block_name == $block) {
8467 $value = $this->getValue($name, $orient, $index, $verbose);
8468 if ($value !==
null) {
8485 public function merge($id, $replicate =
true) {
8486 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
8487 $GLOBALS[
'__egotec_skip_replication'] =
'merge';
8490 $original_page = $this->_site->getPage($id, array(
8492 'deleted_or' =>
'1=1',
8494 'only_active' =>
false
8496 if (!$original_page) {
8499 $field = $this->field;
8500 $extra = $this->extra;
8502 unset($field[
'children']);
8503 if ($field[
'children_order'] ==
'children') {
8505 $children_list = array();
8506 $original_children = explode(
',', trim($extra[
'original_children'],
','));
8507 $current_children = $original_page->getChildren(array(), array(
'auth_or' =>
'1=1'));
8508 $current_children_list = array();
8509 foreach ($current_children as $child) {
8510 $current_children_list[] = $child->field[
'id'];
8512 foreach ($original_children as $child_id) {
8513 $key = array_search($child_id, $current_children_list);
8514 if ($key !==
false) {
8515 $children_list[] = $child_id;
8516 unset($current_children_list[$key]);
8519 $children_list = array_merge($children_list, $current_children_list);
8522 $field[
'inactive'] = $extra[
'original_inactive'];
8526 $extra[
'original_id'],
8527 $extra[
'original_children'],
8528 $extra[
'original_inactive'],
8529 $extra[
'workflow_page']
8531 if ($extra[
'original_parents']) {
8532 $original_parents = $extra[
'original_parents'];
8533 unset($extra[
'original_parents']);
8537 $children = $this->getChildren();
8538 foreach ($children as $child) {
8539 $child->move($this->field[
'id'], $original_page->field[
'id']);
8540 $child->updateField(array(
'inactive' => self::ACTIVE_FLAG));
8543 unset($field[
'id']);
8544 unset($field[
'parents']);
8545 unset($field[
'workflow_state']);
8546 if (isset($original_page->field[
'workflow'])) {
8547 $field[
'workflow'] = $original_page->field[
'workflow'];
8549 unset($field[
'workflow']);
8551 if (isset($original_page->extra[
'workflows'])) {
8552 $extra[
'workflows'] = $original_page->extra[
'workflows'];
8554 unset($extra[
'workflows']);
8558 if (!$original_page->isReleaseCopy()) {
8559 unset($extra[
'release_id']);
8560 if ($field[
'inactive'] == self::RELEASE_FLAG) {
8561 $field[
'inactive'] = 0;
8565 if (!is_numeric($field[
'inactive'])) {
8566 $field[
'inactive'] = 0;
8569 if ($this->isReleaseCopy() && $field[
'release_from'] > date(
'Y-m-d H:i:s')) {
8570 $field[
'release_from'] =
'0000-00-00 00:00:00';
8578 if ($children_list) {
8579 $update[
'children'] = $children_list;
8582 if ($original_parents) {
8583 $current_parents = array();
8584 foreach ($this->getParents(array(
'fields' =>
'id')) as $parent) {
8585 $current_parents[] = $parent->field[
'id'];
8587 $update[
'parents'] = $current_parents;
8590 $original_page->field = array_merge($original_page->field, $update[
'field']);
8591 if ($original_page->extra[
'release_ids']) {
8593 $update[
'extra'][
'release_ids'] = array_values(array_diff($original_page->extra[
'release_ids'], array($this->field[
'id'])));
8595 $original_page->extra = $update[
'extra'];
8598 if (
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename())) {
8600 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename(),
8601 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$original_page->getMediaFilename(
true)
8606 $this->getMediapool()->copy($original_page, $this->getMediapool()->currentDir);
8607 $this->getMediapool()->copy($original_page,
'workflow',
false,
true);
8610 $original_page->update([
8611 'field' => $original_page->field,
8612 'extra' => $original_page->extra,
8613 'parents' => $update[
'parents'],
8614 'children' => $update[
'children']
8620 $this->replicate(
'merge', $id);
8623 return $original_page;
8633 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
8634 $GLOBALS[
'__egotec_skip_replication'] =
'newRelease';
8637 if ($this->field[
'inactive'] != self::RELEASE_FLAG) {
8638 $this->archiveOnly =
false;
8639 $field = $this->field;
8640 $extra = $this->extra;
8641 unset($field[
'id']);
8642 $field[
'inactive'] = self::RELEASE_FLAG;
8644 $field[
'release_from'] = $date;
8647 if ($this->isWorkflowCopy()) {
8649 $extra[
'release_id'] = $extra[
'original_id'];
8650 unset($extra[
'original_id']);
8654 $extra[
'release_id'] = $this->field[
'id'];
8655 unset($extra[
'release_ids']);
8656 $parents = $this->getParents(array(), array(
'auth_or' =>
'1=1'));
8657 if ($parent = $parents->nextPage()) {
8658 $new_page = $parent->newChild($field, $extra);
8660 if (empty($new_page)) {
8662 $new_page = $this->newChild($field, $extra);
8667 $original_page = $this->_site->getPage($extra[
'release_id'], array(
8668 'only_active' =>
false,
8671 $extra = $original_page->extra;
8672 if (!is_array($extra[
'release_ids'])) {
8673 $extra[
'release_ids'] = array();
8675 $extra[
'release_ids'][] = $new_page->field[
'id'];
8676 $extra[
'release_ids'] = array_unique($extra[
'release_ids']);
8677 $original_page->updateExtra($extra,
true,
true);
8679 $this->replicate(
'newRelease', $date);
8694 if (!isset($GLOBALS[
'__egotec_skip_replication'])) {
8695 $GLOBALS[
'__egotec_skip_replication'] =
'release';
8698 if ($this->isReleaseCopy()) {
8701 $this->field[
'release_until'] !=
'0000-00-00 00:00:00'
8702 && ($original_page = $this->_site->getPage($this->extra[
'release_id'], array(
8704 'only_active' =>
false
8706 && $original_page->field[
'release_until'] ==
'0000-00-00 00:00:00'
8708 $release_ids = $original_page->extra[
'release_ids'] ?? array();
8709 $original_page->extra[
'release_ids'] = array_values(array_diff($release_ids, array($this->field[
'id'])));
8710 $GLOBALS[
'new_release'] = $original_page->newRelease($this->field[
'release_until']);
8713 $this->field[
'release_until'] =
'0000-00-00 00:00:00';
8716 $this->replicate(
'release');
8718 return $this->merge($this->extra[
'release_id'],
false);
8729 require_once
'workflow/Ego_Workflow.php';
8730 require_once
'base/template/Ego_Template_Mail.php';
8731 require_once
'base/Ego_Combo.php';
8732 require_once
'rights/User_SQL.php';
8736 $tmp_history = $this->extra[
'history'];
8737 if (is_array($this->extra[
'history'])) {
8739 foreach ($this->extra[
'history'] as $workflow_id => $list) {
8740 if (!is_array($list)) {
8744 $workflow =
new Ego_Workflow($workflow_id);
8746 $grouped_list = array();
8748 ksort($list, SORT_NUMERIC);
8749 foreach ($list as $time => $entry) {
8752 if ($entry[
'old_phase'] ==
'-' && !$group[
'start']) {
8754 $group[
'start'] = $time;
8755 } elseif ($entry[
'old_phase'] ==
'-' && $group[
'start']) {
8757 $grouped_list[] = $group;
8759 $group[
'start'] = $time;
8762 $entry[
'new_phase'] ==
'1'
8766 '/^\{APPROVAL:.*?\}$/msi',
8771 || $entry[
'new_phase'] ==
'c'
8774 $group[
'end'] = $time;
8779 if ($entry[
'user'] !=
'SYSTEM') {
8780 $user = new_db_connection(array(
8781 'table' =>
'egotec_user',
8782 'where' =>
'user_id = :user_id',
8784 'user_id' => $entry[
'user']
8787 if ($user->nextRecord()) {
8788 $user_sql =
new User_SQL($user->Record[
'user_id'], $user->Record);
8789 $entry[
'username'] = $user_sql->getFullname();
8794 $entry[
'old_phase_name'] = $workflow->extra[
'phases'][$entry[
'old_phase']][
'name'];
8795 $entry[
'new_phase_name'] = $workflow->extra[
'phases'][$entry[
'new_phase']][
'name'];
8796 if (preg_match(
'/^\{SWITCH:([^:]+):([^:]+)\}$/ims', $entry[
'comment'], $matches)) {
8797 $from =
new Ego_Workflow($matches[1]);
8798 $to =
new Ego_Workflow($matches[2]);
8799 $msg = $GLOBALS[
'auth']->translate(
'Wechsel von <b>%from</b> nach <b>%to</b>');
8800 $msg = str_replace(
'%from', $from->field[
'name'], $msg);
8801 $msg = str_replace(
'%to', $to->field[
'name'], $msg);
8802 $entry[
'comment'] =
'';
8803 $entry[
'system'] = $msg;
8807 if (preg_match(
'/^\{APPROVAL:([^:]+)\}$/ims', $entry[
'comment'], $matches)) {
8808 $msg = $GLOBALS[
'auth']->translate(
'Genehmigung von <b>%user</b>');
8810 $user =
new User_SQL($matches[1]);
8811 $msg = str_replace(
'%user', $user->getFullname(), $msg);
8812 }
catch (User_Exception $e) {
8813 $msg = str_replace(
'%user', $GLOBALS[
'auth']->translate(
'unbekannt'), $msg);
8815 $entry[
'comment'] =
'';
8816 $entry[
'system'] = $msg;
8820 if (is_array($entry[
'actions'])) {
8821 foreach ($entry[
'actions'] as $key => $action) {
8823 switch ($action[
'type']) {
8825 if ($action[
'parent']) {
8828 $info = $GLOBALS[
'auth']->translate(
'Die Seite wurde verschoben nach %parent.');
8829 $parent_site = $parent->getSite();
8830 $url = $GLOBALS[
'egotec_conf'][
'url_dir'].
'admin.php?site='.$parent_site->name.
'&lang='.$parent_site->language.
'&list='.$parent->field[
'id'];
8831 $info = str_replace(
'%parent',
'<a href="'.$url.
'">'.$parent->field[
'name'].
'</a>', $info);
8839 if ($action[
'workflow']) {
8840 $new_workflow =
new Ego_Workflow($action[
'workflow']);
8841 $info = $GLOBALS[
'auth']->translate(
'Der Workflow wurde gewechselt zu %workflow.');
8842 $info = str_replace(
'%workflow', $new_workflow->field[
'name'], $info);
8846 if ($action[
'template']) {
8849 if (is_string($action[
'recipients'])) {
8850 $recipients = (array) json_decode($action[
'recipients']);
8851 if (!empty($recipients)) {
8852 foreach ($recipients as $type => $combo) {
8856 $suffix =
' (<span style=\'color:#2dabff !important;\'>CC</span>)';
8859 $suffix =
' (<span style=\'color:#e63f2d !important;\'>BCC</span>)';
8864 foreach ($combo->getRights() as $r) {
8865 $list[] =
'<b>'.$r[
'group']->field[
'group_name'].
'/'.$r[
'role']->field[
'role_name'].
'</b>'.$suffix;
8867 foreach ($combo->getUsers() as $u) {
8868 $list[] =
'<u>'.$u->getFullname().
'</u>'.$suffix;
8870 foreach ($combo->getText() as $text) {
8871 $list[] =
'<i>'.$text.
'</i>'.$suffix;
8876 if (!empty($list)) {
8877 $info = $GLOBALS[
'auth']->translate(
'Die E-Mail wurde versendet an:').
'<br/>';
8878 $info .= implode(
', ', $list);
8881 $template =
new Ego_Template_Mail($action[
'template']);
8882 $info = $GLOBALS[
'auth']->translate(
'Die E-Mail wurde versendet an die Empfänger des Templates:').
'<br/>'.$template->field[
'name'];
8883 }
catch (Ego_Template_Exception $e) {
8884 $info = $GLOBALS[
'auth']->translate(
'Die E-Mail wurde nicht versendet, da ein ungültiges Template ausgewählt ist.');
8887 }
catch (Exception $e) {
8894 if (is_string($action[
'combo'])) {
8895 $combo =
new Ego_Combo($action[
'combo']);
8897 foreach ($combo->getRights() as $r) {
8898 $list[] =
'<b>'.$r[
'group']->field[
'group_name'].
'/'.$r[
'role']->field[
'role_name'].
'</b>';
8900 foreach ($combo->getUsers() as $u) {
8901 $list[] =
'<u>'.$u->getFullname().
'</u>';
8904 if (!empty($list)) {
8905 $info = $GLOBALS[
'auth']->translate(
'Folgende Bearbeiter wurden ausgewählt:').
'<br/>';
8906 $info .= implode(
', ', $list);
8911 if (is_string($action[
'approval_users'])) {
8912 $combo =
new Ego_Combo($action[
'approval_users']);
8914 foreach ($combo->getUsers() as $u) {
8915 $list[] =
'<u>'.$u->getFullname().
'</u>';
8918 if (!empty($list)) {
8919 $info = $GLOBALS[
'auth']->translate(
'Folgende Freigeber wurden ausgewählt:').
'<br/>';
8920 $info .= implode(
', ', $list);
8924 if ($action[
'file']) {
8925 $info = $GLOBALS[
'auth']->translate(
'Folgendes Skript wurde ausgeführt:').
'<br/>';
8926 $info .= $action[
'file'];
8930 $info = $GLOBALS[
'auth']->translate(
'Es sind keine Informationen verfügbar.');
8932 $entry[
'actions'][$key][
'_info'] = $info;
8936 if (!is_array($group[
'list'])) {
8937 $group[
'list'] = array();
8939 $entry[
'time'] = $time;
8940 $group[
'list'][$time] = $entry;
8942 $grouped_list[] = $group;
8947 if (empty($cleared) && !empty($group)) {
8949 $grouped_list[] = $group;
8953 'id' => $workflow_id,
8954 'name' => $workflow->field[
'name'],
8955 'list' => $grouped_list
8969 return ($this->field[
'workflow'] && $this->extra[
'original_id']);
8978 return ($this->extra[
'release_id'] && $this->field[
'inactive'] == self::RELEASE_FLAG);
8987 return !empty($this->extra[
'clone_original']);
8997 return ($this->extra[
'language_link'][$this->getSite()->language] && $this->extra[
'language_standard'] != $this->getSite()->language);
9006 return $this->archiveOnly || $this->getTableSuffix() ==
'_v';
9015 return !$this->field[
'inactive']
9016 && !$this->field[
'deleted']
9017 && ($this->field[
'release_from'] ==
'0000-00-00 00:00:00' || date(
'Y-m-d H:i:s') > $this->field[
'release_from'])
9018 && ($this->field[
'release_until'] ==
'0000-00-00 00:00:00' || date(
'Y-m-d H:i:s') < $this->field[
'release_until'])
9019 && !$this->isWorkflowCopy()
9020 && !$this->isReleaseCopy();
9029 return $this->getSite()->admin[
'editor'][
'allow_classified'] && !empty($this->extra[
'_classified']);
9038 if ($this->isPublicSave()) {
9039 $db = new_db_connection();
9041 'table' => $this->_site->pageTable .
'_v',
9042 'where' =>
'id = :id AND m_date > :c_date',
9043 'order' =>
'm_date DESC',
9046 'id' => $this->field[
'id'],
9047 'c_date' => $this->lastChangeDate
9050 if ($db->nextRecord()) {
9051 $class = $this->_site->getPageClass($db->Record[
'type']);
9052 return new $class($this->_site, $db->Record);
9064 return $this->_site->isPublicSave()
9065 && !$this->isWorkflowCopy()
9066 && !$this->isReleaseCopy()
9067 && ($info = $this->getTypeInfo(
false))
9068 && !$info[
'no_public_save'];
9077 if ($this->isPublicSave()) {
9078 return $this->lastChangeDate == $this->field[
'm_date'];
9090 return $this->lastChangeDate;
9100 $db = new_db_connection();
9102 'table' => $this->_site->pageTable.
'_v',
9103 'where' =>
'id = :id',
9104 'order' =>
'm_date DESC',
9107 'id' => $this->field[
'id']
9112 $params[
'where'] .=
' AND m_date = :c_date';
9113 $params[
'bind'][
'c_date'] = $c_date;
9115 $db->select($params);
9116 if ($db->nextRecord()) {
9117 $page = clone $this;
9118 $page->setTableSuffix(
'_v');
9119 $page->field = $db->Record;
9120 $page->extra = $db->Record[
'extra']
9121 ? unserialize($db->Record[
'extra'])
9136 $query[
'table'] = $this->getSite()->pageTable .
'_v';
9137 if ($query[
'where']) {
9138 $query[
'where'].=
' AND ';
9140 $query[
'where'].=
'id=:id';
9141 $query[
'bind'][
'id'] = $this->field[
'id'];
9142 if (!isset($query[
'order'])) {
9143 $query[
'order'] =
'm_date DESC';
9145 return new Page_Iterator($this->_site, new_db_connection($query));
9154 public function restoreArchivPage($c_date)
9156 $db = new_db_connection();
9158 'table' => $this->getSite()->pageTable.
'_v',
9159 'where' =>
"id=".$this->field[
'id'].
" AND m_date='".$c_date.
"'"
9162 if (!$db->nextRecord()) {
9167 $field = $db->Record;
9168 unset($field[
'id']);
9169 unset($field[
'children']);
9170 unset($field[
'parents']);
9171 $extra = unserialize($field[
'extra']);
9176 if (empty($extra[
'piwik']) && !empty($this->extra[
'piwik'])) {
9178 $extra[
'piwik'] = $this->extra[
'piwik'];
9180 $this->update(array(
9196 if ($file = $this->getSite()->getSiteFile($this->field[
'type'].
'/admin/archive_restore.php')) {
9198 $site = $this->getSite();
9199 $current_page = $this;
9200 $smarty = $GLOBALS[
'smarty'];
9215 public function download($recursive =
true, $target_dir =
'', $write_log =
true) {
9216 $log = $GLOBALS[
'egotec_conf'][
'log_dir'].
'page_download-'.date(
'Y-m-d');
9218 file_put_contents($log,
"\r\n===> ".date(
'Y-m-d H:i:s')
9219 .
" Page Download für "
9220 .
"{$this->_site->name}.{$this->_site->language}.{$this->field['id']}"
9221 .
" beginnt:\r\n", FILE_APPEND);
9226 $dir = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'download'.md5(microtime()).
'/';
9228 $media_dir = $dir.
'media/'.$this->_site->name.
'/';
9230 file_put_contents($log,
"Verzeichnisse anlegen\r\n", FILE_APPEND);
9236 'only_active' =>
false,
9241 $pages = array($this);
9244 file_put_contents($log,
"Alle Nachfahren ermitteln\r\n", FILE_APPEND);
9246 foreach ($this->getDescendants(
9250 $pages[] = $descendant;
9255 $db = new_db_connection();
9257 foreach ($pages as $page) {
9259 file_put_contents($log,
"Seite {$page->field['name']} ({$page->field['id']}) sichern\r\n", FILE_APPEND);
9261 foreach ($this->_site->getLanguages() as $lang) {
9262 $lang_page = $page->getLanguagePage($lang);
9264 file_put_contents($log,
"> Sprache {$lang} sichern\r\n", FILE_APPEND);
9268 $table = $this->_site->name.
'_'.$lang;
9272 'where' =>
'id = :id',
9274 'id' => $page->field[
'id']
9277 while ($db->nextRecord()) {
9278 $s = serialize($db->Record);
9279 $file = $dir.
'db/'.$table;
9280 file_put_contents($file, strlen($s).
"\n".$s, FILE_APPEND);
9282 $path = $GLOBALS[
'egotec_conf'][
'var_dir']
9283 .
'media/'.$this->_site->name.
'/';
9288 file_put_contents($log,
"> Mediapool sichern\r\n", FILE_APPEND);
9292 $path.$lang.
'/pool/'.$page->field[
'id'].
'/',
9293 $media_dir.$lang.
'/pool/'.$page->field[
'id'].
'/'
9299 in_array($page->field[
'type'], array(
'multimedia/file',
'multimedia/image'))
9303 file_put_contents($log,
"> Datei sichern\r\n", FILE_APPEND);
9305 $file = $lang_page->getMediaFilename();
9309 $dir.
'media/'.$this->_site->name.
'/'.$lang.
'/'.$page->field[
'id']
9316 'buchungen' => $table.
'_buchungen',
9317 'children' => $table.
'_children',
9318 'extra' => $table.
'_extra',
9319 'infodienst' => $table.
'_infodienst',
9320 'newsletter_light' => $table.
'_newsletter_light',
9321 'rights' => $table.
'_rights',
9322 'users' => $table.
'_users',
9323 'keywords' => $this->_site->name.
'_keywords_rel',
9327 file_put_contents($log,
"> Verknüpfte Tabellen sichern\r\n", FILE_APPEND);
9329 foreach ($tables as $key => $table) {
9330 if (!$db->tableExists($table)) {
9334 file_put_contents($log,
">> $table\r\n", FILE_APPEND);
9337 case 'newsletter_light':
9338 $where =
'abonnent_id = :id';
9341 $where =
'id = :id';
9344 $where =
'page_id = :id';
9351 'id' => $page->field[
'id']
9354 while ($db->nextRecord()) {
9355 $s = serialize($db->Record);
9356 $file = $dir.
'db/'.$table;
9357 file_put_contents($file, strlen($s).
"\n".$s, FILE_APPEND);
9362 if (!$target_dir && $lang_page) {
9364 file_put_contents($log,
"> Verweise sichern\r\n", FILE_APPEND);
9366 foreach ($lang_page->getLinks() as $link) {
9368 $link_site =
new Site($link[
'dest_site'], $link[
'dest_lang']);
9369 $link_page = $link_site->getPage($link[
'dest_id'], $params);
9371 $link_page->download(
false, $dir,
false);
9374 foreach ($link_page->getParents(array(), $params) as $parent) {
9375 $parent->download(
false, $dir,
false);
9378 }
catch (Exception $e) {
9384 'table' =>
'egotec_links',
9386 'where' =>
"src_site = :site AND src_lang = :lang AND src_id = :id",
9388 'site' => $this->_site->name,
9390 'id' => $page->field[
'id']
9393 while ($db->nextRecord()) {
9394 $s = serialize($db->Record);
9395 $file = $dir.
'db/egotec_links';
9396 file_put_contents($file, strlen($s).
"\n".$s, FILE_APPEND);
9404 file_put_contents($log,
"Archiv erstellen\r\n", FILE_APPEND);
9407 require_once(
'Archive/Tar.php');
9410 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'download');
9411 $zip =
new Archive_Tar($tmp,
'gz');
9417 file_put_contents($log,
"Archiv ausgeben\r\n", FILE_APPEND);
9419 require_once(
'base/Ego_Output.php');
9421 $date = date(
'Ymd-His');
9422 $output->setName(
'page_'.$this->_site->name.
'.'.str_replace(
' ',
'_', $this->field[
'name']).
'.'.$date.
'.tar.gz');
9423 $output->setTemporary(
true);
9424 $output->download();
9434 if ($this->field[
'type'] ==
'multimedia/category') {
9435 $dir = $GLOBALS[
'egotec_conf'][
'tmp_dir'];
9436 $name =
'export'.md5(microtime());
9437 $folder = $name.DIRECTORY_SEPARATOR
9439 $file = $name.
'.tar.gz';
9440 $this->exportArchive($this, $dir.$folder);
9443 require_once(
'Archive/Tar.php');
9446 $zip =
new Archive_Tar($file,
'gz');
9447 $zip->_separator =
',';
9448 $zip->createModify(rtrim($folder, DIRECTORY_SEPARATOR),
'', $name);
9462 private function exportArchive($page, $path) {
9464 foreach ($page->getChildren() as $child) {
9466 if ($child->field[
'type'] ==
'multimedia/category') {
9467 $this->exportArchive($child, $path.$name.DIRECTORY_SEPARATOR);
9468 } elseif (in_array($child->field[
'type'], array(
'multimedia/file',
'multimedia/image'))) {
9469 $dir = $GLOBALS[
'egotec_conf'][
'var_dir'].
9470 'media'.DIRECTORY_SEPARATOR.$this->_site->name.DIRECTORY_SEPARATOR;
9471 $file = $child->getMediaFilename();
9472 if ($child->extra[
'image_type']) {
9473 $name .=
'.'.$child->extra[
'image_type'];
9486 if (!$this->frontendActive) {
9487 $this->frontendActive =
true;
9488 $GLOBALS[
'frontend_admin'] =
true;
9489 unset($GLOBALS[
'admin_area']);
9490 if (!$_SESSION[
'login'][
'live_preview']) {
9491 $_REQUEST[
'preview'] = $_REQUEST[
'nonactive'] = 1;
9493 unset($_REQUEST[
'preview'], $_REQUEST[
'nonactive']);
9497 $this->_site->setOnlyActive(!$_REQUEST[
'preview']);
9499 $lock = $this->lock();
9501 $settings = $this->getEditFieldSettings();
9503 if (!empty($this->conf[
'noneditable'])) {
9505 $settings = array_diff_key($settings, array_flip(explode(
',', $this->conf[
'noneditable'])));
9509 $this->createEditField(
'content', $settings[
'content']);
9510 } elseif ($GLOBALS[
'smarty']) {
9512 $GLOBALS[
'smarty']->assign(
'inlineedit_lock',
true);
9525 $short_type = !$this->_site->admin[
'editor'][
'short'] && !$GLOBALS[
'egotec_conf'][
'editor'][
'short']
9526 ?
'text' :
'content';
9529 $plaintext = (bool) $this->_site->admin[
'editor'][
'plaintext'];
9535 'title' => $GLOBALS[
'auth']->translate(
'Name'),
9538 'perm' =>
'extra_information',
9539 'mandatory' =>
true,
9545 'title' => $GLOBALS[
'auth']->translate(
'Titel'),
9548 'perm' =>
'extra_information',
9550 'plaintext' => $plaintext
9554 'title' => $GLOBALS[
'auth']->translate(
'Kurzbeschreibung'),
9556 'type' => $short_type,
9557 'perm' =>
'extra_information',
9558 'plaintext' => $plaintext && $short_type ==
'text'
9562 'title' => $GLOBALS[
'auth']->translate(
'Inhalt'),
9567 if (!empty($this->conf[
'fields'])) {
9568 $settings = array_replace_recursive($settings, $this->conf[
'fields']);
9573 if (isset($settings[$name])) {
9574 return $settings[$name];
9593 public function createEditField($name, $setting = array(), $empty =
false, $orient =
'', $index = 0, $block =
'', $replace =
false) {
9594 $field = $setting[
'field'] ?
'field' :
'extra';
9597 if (isset($this->editFields[$field][$name])) {
9598 return $this->editFields[$field][$name];
9602 if (isset($setting[
'default']) && strpos($setting[
'default'],
'@') === 0) {
9603 $parts = explode(
'.', substr($setting[
'default'], 1), 2);
9604 $parts[1] = str_replace(array(
'@orient',
'@index',
'@block'), array($orient, $index, $block), $parts[1]);
9609 if (is_array($this->conf[
'values'][$orient][$setting[
'type']])) {
9610 foreach ($this->conf[
'values'][$orient][$setting[
'type']] as $param => $value) {
9611 if (!isset($setting[$param])) {
9612 $setting[$param] = $value;
9618 if (!isset($setting[
'title'])) {
9619 $setting[
'title'] = $setting[
'var'];
9623 if (!isset($setting[
'placeholder'])) {
9624 $setting[
'placeholder'] = $setting[
'title'];
9632 $edit_field =
function() use ($field, $name, $setting, $empty, $orient, $index, $block, $replace) {
9633 $this_value = $setting[
'no_auto'] && !empty($setting[
'value'])
9636 if ($field ==
'extra' || $this_value !==
null) {
9637 $frontend_admin = $GLOBALS[
'frontend_admin'] && $this->conf[
'orients'][$orient][
'disabled'] !==
true && $this->isCurrentPage();
9638 $title = $setting[
'title'] ? $GLOBALS[
'auth']->translate($setting[
'title']) : $setting[
'var'];
9639 $dir = $setting[
'dir'] ? $setting[
'dir'] :
'right';
9641 $type = $setting[
'type'];
9642 if ($setting[
'type'] ==
'media') {
9652 if (strpos($setting[
'var'],
'=') === 0) {
9653 [$field, $name] = explode(
'.', substr($setting[
'var'], 1), 2);
9657 if (($empty || $replace) && isset($setting[
'initial'])) {
9659 $edit_value = $setting[
'initial'];
9664 if (!empty($this->conf[
'blocks'][$block][
'default'][$orient])) {
9665 $sub_name = implode(
'.', array_slice(explode(
'.', $name), 3));
9666 if (($default_value =
Ego_System::getAssocValue($this->conf[
'blocks'][$block][
'default'][$orient], $sub_name)) !==
null) {
9667 $edit_value = $default_value;
9671 $edit_value = $this_value;
9675 $layout = $this->extra[
'_layout'];
9676 if (empty($layout)) {
9677 $layout = $this->conf[
'default_layout'];
9682 !$setting[
'default']
9683 && !$setting[
'optional']
9684 && !empty($this->conf[
'layouts'][$layout][
'blocks'][$orient][
'default'])
9685 && in_array($block, explode(
',', $this->conf[
'layouts'][$layout][
'blocks'][$orient][
'default']))
9686 && !in_array($type, array(
'image',
'media',
'video',
'audio',
'table'))
9688 $setting[
'default'] = $title;
9691 if (($empty || ($replace && !$GLOBALS[
'__egotec_edit_do_save'])) && $frontend_admin && $edit_value ==
'' && in_array($type, array(
'text',
'minimal',
'content',
'editor',
'link'))) {
9693 if ($type ==
'link') {
9695 $edit_value = $setting[
'default'] ??
'';
9698 $edit_value = $setting[
'default'];
9702 if ($frontend_admin && in_array($type, array(
'image',
'video',
'audio'))) {
9703 $type_class =
"egotec_type_{$type}";
9704 if (!empty($setting[
'attr'][
'class'])) {
9705 $setting[
'attr'][
'_class'] = $setting[
'attr'][
'class'];
9707 $setting[
'attr'][
'class'] =
"egotec_media {$type_class}";
9715 if (!$frontend_admin) {
9717 if (isset($setting[
'attr'])) {
9718 $tag_name = $type ==
'text' ?
'span' :
'div';
9719 $wrapper =
'<' . $tag_name;
9720 foreach ($setting[
'attr'] as $attr => $value) {
9721 $wrapper .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
9723 $wrapper .=
'>' . $edit_value .
'</' . $tag_name .
'>';
9724 $edit_value = $wrapper;
9735 require_once
'smarty/plugins/function.video.php';
9736 $edit_value = smarty_function_video(array_replace_recursive(array(
9737 'src' => $edit_value,
9745 'fallback' => $frontend_admin,
9746 'audio' => $type ==
'audio'
9747 ), $setting), $GLOBALS[
'smarty']);
9749 if (empty($edit_value)) {
9750 $setting[
'empty'] =
true;
9757 if (!$frontend_admin && empty($edit_value) && !$setting[
'default']) {
9763 foreach (array(
'alt',
'title') as $attr) {
9764 if (!isset($setting[
'attr'][$attr])) {
9766 $setting[
'attr'][$attr] = $attr_value;
9770 if (isset($setting[
'attr'][
'class'])) {
9772 $setting[
'attr'][
'class'] = trim($setting[
'attr'][
'class']);
9774 $setting[
'attr'][
'class'] = $attr_value;
9779 $setting[
'attr'][
'data-href'] = $image_href;
9787 require_once(
'smarty/plugins/function.picture.php');
9788 $edit_value = smarty_function_picture(array_replace_recursive(array(
9789 'src' => $edit_value,
9790 'href' => !$setting[
'url'] ? $image_href :
'',
9792 'fallback' => $frontend_admin
9794 'viewports' => $viewports
9795 ]), $GLOBALS[
'smarty']);
9796 if (empty($edit_value)) {
9797 $setting[
'empty'] =
true;
9803 if (!$frontend_admin && empty($edit_value) && !$setting[
'default']) {
9809 $default = $GLOBALS[
'egotec_conf'][
'url_dir'] .
'bin/page/blocks/file.html';
9812 $ratio = str_replace(
':',
'/', $setting[
'ratio'] ??
'16:9');
9814 $setting[
'misc'] = array_merge([
9816 'style' =>
'width: 100%; height: auto; aspect-ratio: ' . $ratio,
9817 'allowfullscreen' =>
'',
9819 ], $setting[
'attr'] ?? []);
9822 if (isset($setting[
'attr'])) {
9823 unset($setting[
'attr']);
9826 $iframe =
'<iframe';
9827 foreach ($setting[
'misc'] as $attr => $value) {
9828 if ($attr ==
'src') {
9832 && !empty($GLOBALS[
'egotec_conf'][
'document'][
'blocks_enabled'])
9833 && !empty($edit_value)
9834 && strpos(ltrim($edit_value,
'/'),
'index.php') === 0
9837 return in_array($key, [
'site',
'lang',
'id',
'pool',
'dir']);
9838 }, ARRAY_FILTER_USE_KEY);
9839 $edit_value = $GLOBALS[
'egotec_conf'][
'url_dir'] .
'bin/document/editor.php?' . http_build_query($info);
9842 $value = $edit_value ?: $value;
9844 $iframe .=
' ' . $attr . ($value ===
'' ?
'' :
'="' . $value .
'"');
9846 $iframe .=
'></iframe>';
9848 $edit_value = $iframe;
9849 if ($frontend_admin) {
9850 $edit_value =
'<div>' . $edit_value .
'</div>';
9854 $setting[
'misc'] = array_filter($setting[
'misc'],
function($value) {
9855 return $value !==
null;
9861 if (!$frontend_admin && empty($edit_value)) {
9867 $default =
'<a href=""';
9868 $a =
'<a href="' . $edit_value .
'"';
9869 if (!is_array($setting[
'attr'])) {
9870 $setting[
'attr'] = array();
9872 foreach (array(
'class',
'title',
'target') as $attr) {
9873 if (!isset($setting[
'attr'][$attr])) {
9875 } elseif ($attr ==
'class') {
9877 $setting[
'attr'][
'class'] = trim($setting[
'attr'][
'class']);
9880 foreach ($setting[
'attr'] as $attr => $value) {
9881 if ($attr !=
'href' && $value !=
'') {
9882 if ($attr !=
'target') {
9883 $default .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
9885 $a .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
9888 $default .=
'>' . ($setting[
'default'] ? $setting[
'default'] : $title) .
'</a>';
9890 $setting[
'default'] = $default;
9891 $edit_value = empty($edit_value) ? $default : $a;
9896 if (!$frontend_admin && empty($edit_value)) {
9901 if (strpos($this->field[
'type'],
'e2e/') !== 0) {
9903 foreach ([
'rows_edit',
'cols_edit',
'cols_size'] as $key) {
9904 if (!isset($setting[$key]) || !empty($setting[$key])) {
9905 $setting[$key] =
true;
9920 $create =
function ($name1, $name2, $rows, $cols, $contents =
'') {
9921 $contents = explode(
'|', is_string($contents) ? $contents :
'');
9922 $html =
"<{$name1}>";
9923 for ($r = 0; $r < $rows; $r++) {
9925 for ($c = 0; $c < $cols; $c++) {
9926 $content = isset($contents[$c]) && trim($contents[$c]) !=
''
9927 ? $GLOBALS[
'auth']->translate(trim($contents[$c]))
9929 $html .=
"<{$name2}>{$content}</{$name2}>";
9933 $html .=
"</{$name1}>";
9937 if (!empty($setting[
'default'])) {
9939 $table = trim($setting[
'default']);
9942 $rows = $setting[
'rows'] ? (int)$setting[
'rows'] : 2;
9943 $cols = $setting[
'cols'] ? (int)$setting[
'cols'] : 2;
9946 if (is_array($setting[
'attr'])) {
9948 foreach ($setting[
'attr'] as $attr => $value) {
9949 $table .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
9954 $table .= ($setting[
'thead'] ? $create(
'thead',
'th', 1, $cols, $setting[
'thead']) :
'')
9955 . $create(
'tbody',
'td', $rows, $cols)
9956 . ($setting[
'tfoot'] ? $create(
'tfoot',
'td', 1, $cols, $setting[
'tfoot']) :
'')
9960 $setting[
'default'] = $table;
9963 if (empty($edit_value)) {
9964 $edit_value = $table;
9967 require_once(
'base/Ego_DomQuery.php');
9969 $table = $dom->doc->firstChild;
9971 if ($table->hasAttributes()) {
9972 foreach ($table->attributes as $attribute) {
9974 !is_array($setting[
'attr'])
9975 || empty($setting[
'attr'])
9976 || !in_array($table->nodeName, array_keys($setting[
'attr']))
9979 $table->removeAttribute($attribute->nodeName);
9984 if (is_array($setting[
'attr'])) {
9985 foreach ($setting[
'attr'] as $attr => $value) {
9986 if (!$table->hasAttribute($attr) || $table->getAttribute($attr) != $value) {
9988 $table->setAttribute($attr, $value);
9994 $edit_value = $dom->getHTML();
10012 $get_value =
function($value, $select) use ($type, $setting) {
10013 if (empty($value)) {
10014 $value = !empty($select[
'default'])
10015 ? $select[
'default']
10016 : (!empty($setting[
'default'])
10017 ? $setting[
'default']
10021 if ($type ==
'date' && preg_match(
'/^<%(.*?)>$/', $value, $match)) {
10022 $value = $match[1];
10025 if (!empty($select[
'format']) && !empty($value)) {
10026 $value = date($select[
'format'], strtotime($value));
10028 if (!empty($select[
'value'])) {
10029 $value = str_replace(
'<%>', $value, $select[
'value']);
10037 && (($block_name = $block) || ($block_name = $this->extra[
'_blocks'][$orient][$index]))
10038 && ($controls = $this->getBlockControls($block_name))
10040 $value_name = ltrim(strrchr($name,
'.'),
'.');
10041 foreach ($controls as $select) {
10042 if ($select[
'name'] == $value_name) {
10043 $value = $get_value($value, $select);
10049 $value = $get_value($value, $setting);
10054 if (empty($edit_value)) {
10055 if (!$frontend_admin) {
10059 $edit_value = $setting[
'default'] ?? $title;
10063 $languages = $setting[
'languages'] ?? $this->conf[
'code'][
'languages'] ?? array();
10064 if (!is_array($languages)) {
10065 $languages_array = explode(
',', $languages);
10066 $languages = array();
10067 foreach ($languages_array as $language) {
10068 $languages[$language] = $language;
10071 asort($languages, SORT_NATURAL);
10072 $first_language =
null;
10073 foreach ($languages as $value => $text) {
10074 $first_language = $value;
10080 ?? $setting[
'mode']
10081 ?? $this->conf[
'code'][
'mode']
10085 $smarty = Ego_Smarty::createFrontend($this->getSite(), array(
10086 'id' =>
'code-' . md5($name),
10088 'value' => $edit_value,
10089 'theme' => $setting[
'theme'] ?? $this->conf[
'code'][
'theme'] ??
'monokai',
10090 'mode' => mb_strtolower($mode),
10091 'selected_mode' => $mode,
10092 'label' => $setting[
'label'] ?? $languages[$mode] ?? $mode,
10093 'min' => $setting[
'min'] ?? $this->conf[
'code'][
'min'] ?? 3,
10094 'max' => $setting[
'max'] ?? $this->conf[
'code'][
'max'] ?? 20,
10095 'languages' => $languages
10097 $edit_value = $smarty->fetch($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'page/t/input/code.tpl');
10106 $label_callback =
function($callback) use ($setting, $orient, $index, $block) {
10107 if ($setting[
'var'] ==
'label') {
10108 foreach (array(
'required',
'optional') as $display_type) {
10110 $this->conf[
'form'][$display_type]
10111 && strpos($block,
'input_') === 0
10112 && $this->extra[
'_contents'][$orient][$index][
'extra'][$display_type]
10114 $callback($display_type);
10121 $label_callback(
function($display_type) use (&$edit_value, &$setting, $title) {
10122 if (trim($edit_value) ==
'') {
10123 $edit_value = $setting[
'default'] = $setting[
'default'] ?? $title;
10128 $autofill = $this->conf[
'autofill'];
10129 if (isset($this->conf[
'blocks'][$block][
'autofill'])) {
10130 $autofill = $this->conf[
'blocks'][$block][
'autofill'];
10132 if (isset($setting[
'autofill'])) {
10133 $autofill = $setting[
'autofill'];
10137 if ($frontend_admin) {
10144 $escape =
function($s) {
10145 return htmlspecialchars(
10146 preg_replace(
'/\s+/',
' ', $s),
10153 foreach (array(
'toolbar',
'menubar') as $key) {
10154 if (isset($setting[$key]) && is_bool($setting[$key])) {
10155 $setting[$key] = $setting[$key] ===
true ?
'true' :
'false';
10160 $additional_attributes = array();
10161 if (!empty($setting[
'attr'])) {
10162 foreach ($setting[
'attr'] as $attr => $value) {
10166 || in_array($setting[
'type'], array(
'link',
'table'))
10171 if ($attr ==
'class' && isset($setting[
'attr'][
'_class'])) {
10172 $setting[
'attr'][
'class'] = implode(
' ', array_unique(array_merge(explode(
' ', $value), explode(
' ', $setting[
'attr'][
'_class']))));
10173 unset($setting[
'attr'][
'_class']);
10177 if ($attr ===
'class' && in_array($setting[
'type'], [
'image',
'media'])) {
10178 $classes = explode(
' ', $value);
10182 foreach ($classes as $class) {
10183 if (!in_array($class, $image_classes)) {
10184 $div_classes[] = $class;
10188 $value = implode(
' ', $div_classes);
10191 $additional_attributes[] = $attr .
'="' . $escape($value) .
'"';
10195 $tag_name = $setting[
'tag_name'] ??
'div';
10196 $edit_value =
'<' . $tag_name
10197 . ($setting[
'field'] ?
' data-edit-field="' . $name .
'"' :
' data-edit-extra="' . $name .
'"')
10198 .
' data-edit-type="' . $setting[
'type'] .
'"'
10199 . ($setting[
'default'] ?
' data-edit-default="' . $escape($GLOBALS[
'auth']->translate($setting[
'default'])) .
'"' :
'')
10200 . ($setting[
'perm'] && !$this->hasRights(explode(
',', $setting[
'perm'])) ?
' data-edit-locked="true"' :
'')
10201 . ($setting[
'style'] ?
' style="' . $setting[
'style'] .
'"' :
'')
10202 . ($setting[
'mandatory'] ?
' data-edit-mandatory="true"' :
'')
10203 . ($setting[
'readonly'] ?
' data-edit-readonly="true"' :
'')
10204 . ($setting[
'no_auto'] ?
' data-edit-no-auto="true"' :
'')
10205 . ($setting[
'rows_edit'] ?
' data-edit-rows="true"' :
'')
10206 . ($setting[
'cols_edit'] ?
' data-edit-cols="true"' :
'')
10207 . ($setting[
'cols_size'] ?
' data-edit-cols-size="true"' :
'')
10208 . ($setting[
'maxlength'] ?
' data-edit-maxlength="' . $setting[
'maxlength'] .
'"' :
'')
10209 . ($setting[
'srcset'] ?
' data-edit-srcset="' . $setting[
'srcset'] .
'"' :
'')
10210 . ($setting[
'empty'] ?
' data-edit-empty="true"' :
'')
10211 . ($setting[
'href'] ===
false ?
' data-edit-href="false"' :
'')
10212 . ($setting[
'optional'] ?
' data-edit-optional="true"' :
'')
10213 . ($setting[
'plaintext'] ?
' data-edit-plaintext="true"' :
'')
10214 . ($setting[
'root'] ?
' data-edit-root="true"' :
'')
10215 . ($setting[
'unsafe'] ?
' data-edit-unsafe="true"' :
'')
10216 . ($setting[
'hooks'] ?
' data-edit-hooks="' . $setting[
'hooks'] .
'"' :
'')
10217 . ($setting[
'plugins'] ?
' data-edit-plugins="' . $setting[
'plugins'] .
'"' :
'')
10218 . ($setting[
'toolbar'] ?
' data-edit-toolbar="' . $setting[
'toolbar'] .
'"' :
'')
10219 . ($setting[
'menubar'] ?
' data-edit-menubar="' . $setting[
'menubar'] .
'"' :
'')
10220 . ($setting[
'paste_tags'] ?
' data-edit-paste-tags="' . $setting[
'paste_tags'] .
'"' :
'')
10221 . ($setting[
'paste_attrs'] ?
' data-edit-paste-attrs="' . $setting[
'paste_attrs'] .
'"' :
'')
10222 . ($setting[
'placeholder'] ?
' data-edit-placeholder="' . $escape($GLOBALS[
'auth']->translate($setting[
'placeholder'])) .
'"' :
'')
10223 . ($setting[
'edit'] !==
false ?
' data-edit-media="' . $escape(json_encode($setting[
'edit'] ??
true, JSON_FORCE_OBJECT)) .
'"' :
'')
10224 . (!empty($setting[
'attr']) ?
' data-edit-attr="' . $escape(json_encode($setting[
'attr'], JSON_FORCE_OBJECT)) .
'"' :
'')
10225 . (!empty($setting[
'misc']) ?
' data-edit-misc="' . $escape(json_encode($setting[
'misc'], JSON_FORCE_OBJECT)) .
'"' :
'')
10226 . (!empty($autofill) ?
' data-edit-autofill="' . $escape(json_encode($autofill, JSON_FORCE_OBJECT)) .
'"' :
'')
10227 . ((!empty($setting[
'caption']) && !empty($setting[
'url'])) || !empty($setting[
'no_link']) ?
' data-edit-hide-link="1"' :
'')
10228 . implode(
' ', $additional_attributes)
10229 .
'>' . $edit_value .
'</' . $tag_name .
'>';
10234 $label_callback(
function($display_type) use (&$edit_value) {
10235 $edit_value = $GLOBALS[
'smarty']->fetch(
'string:' . str_replace(
'<%>', $edit_value, $this->conf[
'form'][$display_type]));
10238 if (in_array($type, array(
'video',
'audio',
'image',
'media'))) {
10240 $caption = $this->conf[
'caption'];
10241 if (isset($this->conf[
'blocks'][$block][
'caption'])) {
10242 $caption = $this->conf[
'blocks'][$block][
'caption'];
10244 if (isset($setting[
'caption'])) {
10245 $caption = $setting[
'caption'];
10249 $caption_autofill = !empty($autofill[
'caption'][
'readonly']);
10250 $caption_value =
'';
10253 if ($caption_autofill && !empty($this_value) && ($media_page =
Ego_System::urltopage($this_value, [
'inactive' =>
true,
'only_active' =>
false]))) {
10255 $caption_value = (string) $result[
'caption'][
'value'];
10258 if ($frontend_admin) {
10260 require_once(
'smarty/plugins/function.value.php');
10261 $var = substr(strrchr($name,
'.'), 1);
10262 $caption_value = smarty_function_value(array(
10263 'var' =>
"{$var}_caption",
10264 'type' =>
'minimal',
10265 'title' => $setting[
'type'] ==
'image'
10266 ? $GLOBALS[
'auth']->translate(
'Bildbeschreibung')
10267 : $GLOBALS[
'auth']->translate(
'Beschreibung'),
10268 'orient' => $orient,
10270 'readonly' => $caption_autofill,
10271 'no_auto' => $caption_autofill,
10272 'value' => $caption_value
10273 ), $GLOBALS[
'smarty']);
10274 } elseif (!$caption_autofill) {
10277 if ($caption_value !=
'') {
10278 $edit_value = str_replace(array(
'<%>',
'<#>'), array($edit_value, $caption_value), $caption);
10283 if ($setting[
'tag_name'] && !$frontend_admin && $edit_value !=
'') {
10285 $edit_value =
"<{$setting['tag_name']}>$edit_value</{$setting['tag_name']}>";
10288 if ($setting[
'wrapper'] && ($frontend_admin || $edit_value !=
'')) {
10290 $edit_value = str_replace(
'<%>', $edit_value, $setting[
'wrapper']);
10293 if ($setting[
'url']) {
10297 if ($frontend_admin || !$href) {
10299 $href =
'javascript:void(0)';
10302 require_once(
'base/Ego_DomQuery.php');
10304 $links = $dom->query($setting[
'url']);
10305 foreach ($links as $link) {
10306 $link->setAttribute(
'href', $href);
10308 $link->setAttribute(
'target', $target);
10311 $edit_value = $dom->getHTML();
10314 return $edit_value;
10319 return $this->editFields[$field][$name] = $edit_field();
10337 public function updateUrls($verbose =
false, $domain =
null, $force_recursive =
false, $called_recursive =
false) {
10339 $GLOBALS[
'egotec_conf'][
'rewrite_engine'] !=
'url'
10341 $_SERVER[
'HTTP_X_SOAP_CALL'] ==
'Replication'
10342 && $this->getSite()->getCache()->getEternal()
10344 || $this->field[
'deleted']
10345 || $this->isReleaseCopy()
10346 || strpos($this->field[
'type'],
'/occupancy/')
10352 if (isset($GLOBALS[
'__page_update_urls_stack']) && in_array($this->getIdentity(), $GLOBALS[
'__page_update_urls_stack'])) {
10355 if (!isset($GLOBALS[
'__page_update_urls_stack'])) {
10356 $GLOBALS[
'__page_update_urls_stack'] = [];
10358 $GLOBALS[
'__page_update_urls_stack'][] = $this->getIdentity();
10360 $db = new_db_connection();
10367 $get_current_urls =
function() use ($db) {
10369 'table' =>
'egotec_url',
10370 'fields' =>
'site, lang, id, domain, dir, path, canonical',
10371 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical = 1',
10373 'site' => $this->_site->name,
10374 'lang' => $this->_site->language,
10375 'id' => $this->field[
'id']
10379 while ($db->nextRecord()) {
10380 $urls[] = $db->Record;
10385 $old_urls = $get_current_urls();
10388 $virtual_hosts = $this->_site->getVirtualHosts();
10392 $use_area_domain = $GLOBALS[
'egotec_conf'][
'liveserver'] || !$this->_site->hasLiveserver();
10393 if ($use_area_domain) {
10395 $area_domain = $domain;
10397 if ($this->extra[
'area_domain']) {
10399 array_unshift($area_domain, mb_strtolower($this->extra[
'area_domain']));
10403 if (!$called_recursive && empty($domain)) {
10404 $ancestors = $this->getAncestors();
10405 $inherited_domains = [];
10406 foreach ($ancestors as $ancestor) {
10407 if ($ancestor->extra[
'area_domain']) {
10408 $inherited_domains[] = mb_strtolower($ancestor->extra[
'area_domain']);
10411 if (!empty($inherited_domains)) {
10412 $inherited_domains = array_reverse($inherited_domains);
10413 foreach ($inherited_domains as $inherited_domain) {
10414 $area_domain[] = $inherited_domain;
10418 if (!empty($area_domain)) {
10419 for ($i = 0; $i <
sizeof($area_domain); $i++) {
10420 $area_domain[$i] = rtrim(preg_replace(
'/^https?:\/\//',
'', $area_domain[$i]),
'/');
10422 $virtual_hosts = $area_domain;
10426 if (!$this->field[
'inactive'] || $this->isWorkflowCopy()) {
10427 $now = date(
'Y-m-d H:i:s');
10430 $conf = $this->_site->getRewriteConf();
10433 $first_url_inserted = 0;
10443 $insert_urls =
function($names, $paths, $exists =
false) use ($db, $domain, $virtual_hosts, $now, &$first_url_inserted) {
10444 foreach ($names as $ni => $name) {
10445 foreach ($paths as $pi => $path) {
10446 $dir = trim($GLOBALS[
'egotec_conf'][
'url_dir'] . implode(
'/', array_filter(array($path[
'name'], $name))),
'/');
10448 foreach ($virtual_hosts as $vi => $virtual_host) {
10451 $virtual_host = rtrim($virtual_host,
'/');
10452 if ($part = strstr($virtual_host,
'/')) {
10453 $virtual_host = strstr($virtual_host,
'/',
true);
10454 $this_dir = trim($part .
"/{$dir}",
'/');
10458 'site' => $this->_site->name,
10459 'lang' => $this->_site->language,
10460 'id' => $this->field[
'id'],
10461 'domain' => $virtual_host,
10462 'dir' => $this_dir,
10463 'path' => (
string)$path[
'id']
10467 $unique_dir = $this_dir;
10468 $duplicate_params = $params;
10470 $duplicate_params[
'site'],
10471 $duplicate_params[
'lang'],
10472 $duplicate_params[
'id'],
10473 $duplicate_params[
'path']
10476 while ($this_dir !=
'') {
10477 $duplicate_params[
'dir'] = $unique_dir;
10479 'table' =>
'egotec_url',
10480 'where' =>
'domain = :domain AND dir = :dir',
10481 'bind' => $duplicate_params
10483 if ($db->nextRecord()) {
10485 $db->Record[
'site'] == $this->_site->name
10486 && $db->Record[
'lang'] == $this->_site->language
10487 && $db->Record[
'id'] == $this->field[
'id']
10488 && !$db->nextRecord()
10492 if ($db->Record[
'canonical'] == 0) {
10494 'table' =>
'egotec_url',
10495 'where' =>
'site = :site AND lang = :lang AND id = :id AND domain = :domain AND dir = :dir AND path = :path AND canonical = 0',
10497 'site' => $db->Record[
'site'],
10498 'lang' => $db->Record[
'lang'],
10499 'id' => $db->Record[
'id'],
10500 'domain' => $db->Record[
'domain'],
10501 'dir' => $db->Record[
'dir'],
10502 'path' => $db->Record[
'path']
10506 $unique_dir = $this_dir .
'-' . $n++;
10512 $params[
'dir'] = $unique_dir;
10517 'table' =>
'egotec_url',
10518 'where' =>
'domain = :domain AND dir = :dir AND canonical > 0',
10520 'domain' => $params[
'domain'],
10521 'dir' => $params[
'dir']
10524 if ($db->nextRecord()) {
10527 'table' =>
'egotec_url',
10528 'where' =>
'domain = :domain AND dir = :dir AND canonical > 0',
10530 'domain' => $params[
'domain'],
10531 'dir' => $params[
'dir']
10545 'table' =>
'egotec_url',
10546 'where' =>
'domain = :domain AND dir = :dir',
10548 'domain' => $params[
'domain'],
10549 'dir' => $params[
'dir']
10555 'table' =>
'egotec_url',
10556 'set' => array_merge($params, array(
10557 'canonical' => $first_url_inserted == 0 && $ni == 0 && $vi == 0 ? ($first_url_inserted = 1) : 2,
10572 if (empty($this->field[
'url']) || $conf[
'meta']) {
10573 if (!$conf[
'flat']) {
10575 $paths = $this->getPaths(
false,
true, $use_area_domain);
10578 $names = $this->getUrlNames();
10582 if ($this->field[
'id'] == $this->_site->rootId || ($use_area_domain && $this->extra[
'area_domain'])) {
10583 array_unshift($names,
'');
10586 if (!empty($names)) {
10587 if (empty($paths)) {
10594 $insert_urls($names, $paths);
10598 if (!empty($this->field[
'url'])) {
10599 $paths = array(array(
10602 $space = $conf[
'space'];
10603 if (empty($space)) {
10606 $name = str_replace(
' ', $space, $this->field[
'url']);
10607 $names = array($name);
10609 $insert_urls($names, $paths,
true);
10614 'table' =>
'egotec_url',
10615 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical = 3',
10617 'site' => $this->_site->name,
10618 'lang' => $this->_site->language,
10619 'id' => $this->field[
'id']
10624 foreach ($virtual_hosts as $vi => $virtual_host) {
10628 $virtual_host = rtrim($virtual_host,
'/');
10629 if ($part = strstr($virtual_host,
'/')) {
10630 $virtual_host = strstr($virtual_host,
'/',
true);
10631 $dir = ltrim($part .
'/',
'/');
10634 $db->replace(array(
10635 'table' =>
'egotec_url',
10637 'site' => $this->_site->name,
10638 'lang' => $this->_site->language,
10639 'id' => $this->field[
'id'],
10640 'domain' => $virtual_host,
10641 'dir' =>
"{$dir}-{$this->field['id']}",
10646 'primary' => [
'domain',
'dir' ]
10653 'table' =>
'egotec_url',
10654 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical > 0 AND c_date < :c_date',
10656 'site' => $this->_site->name,
10657 'lang' => $this->_site->language,
10658 'id' => $this->field[
'id'],
10675 $this->field[
'id'] != $this->_site->rootId
10676 && serialize($old_urls) != serialize($get_current_urls())
10679 $children = $this->getChildren(array(), array(
10680 'auth_or' =>
'1=1',
10681 'inactive' =>
true,
10682 'only_active' =>
false
10684 foreach ($children as $child) {
10685 $child->updateUrls($verbose, $area_domain, $force_recursive,
true);
10696 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'url') {
10697 $db = new_db_connection();
10701 'table' =>
'egotec_url',
10702 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical > 0',
10704 'site' => $this->_site->name,
10705 'lang' => $this->_site->language,
10706 'id' => $this->field[
'id']
10723 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'url') {
10724 $db = new_db_connection();
10728 'table' =>
'egotec_url',
10729 'where' =>
'site = :site AND lang = :lang AND id = :id',
10731 'site' => $this->_site->name,
10732 'lang' => $this->_site->language,
10733 'id' => $this->field[
'id']
10748 $name = $this->field[
'name'];
10751 $conf = $this->_site->getRewriteConf();
10754 if ($conf[
'umlauts']) {
10755 $name = str_replace(array(
'Ä',
'Ö',
'Ü',
'ä',
'ö',
'ü',
'ß'), array(
'Ae',
'Oe',
'Ue',
'ae',
'oe',
'ue',
'ss'), $name);
10759 switch ($conf[
'case']) {
10762 $name = mb_strtoupper($name);
10767 $name = mb_strtolower($name);
10771 $space = $conf[
'space'];
10772 if (empty($space)) {
10775 $name = str_replace(
' ', $space, $name);
10778 if (!empty($conf[
'ampersand'])) {
10779 $language = $this->extra[
'language_link'][$this->_site->language] == 1
10780 ? $this->extra[
'language_standard']
10781 : $this->_site->language;
10782 $replace = $GLOBALS[
'auth']->translate(
'und', array(), $language);
10783 $name = str_replace(
'&', $replace, $name);
10787 $invalid_characters =
"%\n\r\t,;#!?:&/'\".\\";
10788 $default_special =
'_';
10789 $special = $conf[
'special'];
10790 if (empty($special)) {
10791 $special = $default_special;
10793 $name = strtr($name, $invalid_characters, str_repeat($special, mb_strlen($invalid_characters)));
10794 if ($special != $default_special) {
10796 $name = strtr($name, $invalid_characters, str_repeat($default_special, mb_strlen($invalid_characters)));
10799 if ($name[0] ==
'-') {
10801 $name[0] = $special !=
'-' ? $special : $default_special;
10805 $name = preg_replace(
'/' . preg_quote($special,
'/') .
'{2,}/', $special, $name);
10808 $url_file = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'lib/url.php';
10810 require_once $url_file;
10811 $result = get_url_names($this, $conf, $name);
10812 if (
sizeof($result) > 0) {
10813 foreach ($result as $key => $value) {
10814 if ($value[0] ==
'-') {
10816 $result[$key][0] =
'_';
10823 return array($name);
10833 return $this->getUrl([
10834 'return_absolute' =>
true,
10835 'return_permalink' =>
true
10851 $title = $GLOBALS[
'auth']->translate(
'Ansicht');
10854 $title = $GLOBALS[
'auth']->translate(
'Bearbeiten');
10857 $title = $GLOBALS[
'auth']->translate(
'Freigabe ändern');
10860 $title = $GLOBALS[
'auth']->translate(
'Löschen');
10863 $title = $GLOBALS[
'auth']->translate(
'Ausschnitte/Seite anlegen');
10866 $title = $GLOBALS[
'auth']->translate(
'Workflow ändern');
10869 $title = $GLOBALS[
'auth']->translate(
'Verlinkung erlauben');
10872 $title = $GLOBALS[
'auth']->translate(
'Übertragen');
10876 case 'view_newsletter':
10877 $title = $GLOBALS[
'auth']->translate(
'Newsletter');
10880 $title = $GLOBALS[
'auth']->translate(
'Meta');
10882 case 'view_keywords':
10883 $title = $GLOBALS[
'auth']->translate(
'Schlagwortregister');
10885 case 'view_release':
10886 $title = $GLOBALS[
'auth']->translate(
'Freigabe');
10889 $title = $GLOBALS[
'auth']->translate(
'Navigation');
10892 $title = $GLOBALS[
'auth']->translate(
'Statistik');
10894 case 'view_workflow':
10895 $title = $GLOBALS[
'auth']->translate(
'Workflow');
10897 case 'view_rights':
10898 $title = $GLOBALS[
'auth']->translate(
'Rechte');
10901 $title = $GLOBALS[
'auth']->translate(
'Klone');
10903 case 'view_archive':
10904 $title = $GLOBALS[
'auth']->translate(
'Archiv');
10907 $title = $GLOBALS[
'auth']->translate(
'Media');
10911 $tabs = $this->getTabs();
10912 $real_perm = preg_replace(
'/^extra_/',
'', $perm);
10913 if (isset($tabs[$real_perm])) {
10914 $title = $GLOBALS[
'auth']->translate($tabs[$real_perm][
'title']);
10926 $nav_file = $GLOBALS[
'egotec_conf'][
'site_dir'].$this->_site->name.
'/'.$this->field[
'type'].
'/admin/navigation.ini';
10930 $nav_file = $GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
'/site/'.$this->field[
'type'].
'/admin/navigation.ini';
10935 $nav_file = $GLOBALS[
'egotec_conf'][
'site_dir'].
'_global/'.$this->field[
'type'].
'/admin/navigation.ini';
10939 $nav_file = $GLOBALS[
'egotec_conf'][
'lib_dir'].
'type/site/'.$this->field[
'type'].
'/admin/navigation.ini';
10944 $nav_file = $GLOBALS[
'egotec_conf'][
'site_dir'].$this->_site->name.
'/page/admin/navigation.ini';
10949 $nav_file = $GLOBALS[
'egotec_conf'][
'lib_dir'].
'type/site/page/admin/navigation.ini';
10952 $reiter = parse_ini_file($nav_file,
true);
10953 $nav_file = $GLOBALS[
'egotec_conf'][
'site_dir'].$this->_site->name.
'/admin/navigation.ini';
10957 $reiter = array_merge($reiter, parse_ini_file($nav_file,
true));
10960 if ($this->_site->theme) {
10961 $nav_file = $GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
'/site/admin/navigation.ini';
10964 $reiter = array_merge($reiter, parse_ini_file($nav_file,
true));
10968 if ($this->_site->globalAllowed()) {
10969 $nav_file = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/navigation.ini';
10971 if (file_exists($nav_file)) {
10972 $reiter = array_merge($reiter, parse_ini_file($nav_file,
true));
10992 $this->removeLinks();
10995 if (!$this->field[
'deleted']) {
10997 if (!in_array($this->field[
'type'], array(
'multimedia/file',
'multimedia/image'))) {
10998 $this->updateLinksRecursive($links, $this->field[
'content'],
true);
11000 $this->updateLinksRecursive($links, $this->field[
'short'],
true);
11001 $this->updateLinksRecursive($links, $this->extra);
11004 if (is_array($this->extra[
'_blocks'])) {
11005 foreach ($this->extra[
'_blocks'] as $orient => $blocks) {
11006 foreach ($blocks as $index => $block) {
11008 if (is_array($this->extra[
'_contents'][$orient][$index])) {
11009 $data = $this->extra[
'_contents'][$orient][$index];
11017 $data[
'extra'][
'source'] ==
'multimedia'
11018 && !empty($data[
'extra'][
'category'])
11021 $children = $category->getChildren([
'where' =>
"type IN ('multimedia/file', 'multimedia/image')"]);
11022 foreach ($children as $child) {
11023 $links[
'pages'][] = array(
11024 'src_site' => $this->_site->name,
11025 'src_lang' => $this->_site->language,
11026 'src_id' => $this->field[
'id'],
11027 'dest_site' => $child->getSite()->name,
11028 'dest_lang' => $child->getSite()->language,
11029 'dest_id' => $child->field[
'id'],
11033 'extra_key' => implode(
',', [
'_contents', $orient, $index,
'extra',
'category'])
11043 foreach ($this->getUsersArray() as $perm => $users) {
11044 foreach ($users as $user) {
11045 $links[
'users'][] = array(
11046 'src_site' => $this->_site->name,
11047 'src_lang' => $this->_site->language,
11048 'src_id' => $this->field[
'id'],
11049 'src_perm' => $perm,
11054 'dest_user' => $user[
'user_id'],
11060 $db = new_db_connection();
11062 foreach ($links as $type => $link_list) {
11063 $table = $type ==
'pages' ?
'egotec_links' :
'egotec_user_links';
11064 if ($db->tableExists($table)) {
11065 foreach ($link_list as $link) {
11077 if ($inherited && $this->_site->site[
'type'] ==
'media') {
11079 'inactive' =>
true,
11080 'only_active' =>
false,
11081 'no_cache' =>
true,
11082 'auth_or' =>
'1=1',
11085 foreach ($this->getAncestors(array(
11086 'where' =>
"type = 'multimedia/category'"
11087 ), $params) as $ancestor) {
11089 'table' =>
'egotec_links',
11090 'where' =>
'dest_site = :site AND dest_lang = :lang AND dest_id = :id',
11092 'site' => $this->_site->name,
11093 'lang' => $this->_site->language,
11094 'id' => $ancestor->field[
'id']
11097 while ($db->nextRecord()) {
11099 $site =
new Site($db->Record[
'src_site'], $db->Record[
'src_lang']);
11100 if ($page = $site->getPage($db->Record[
'src_id'], $params)) {
11101 $page->updateLinks(
false, $cleared);
11122 private function updateLinksRecursive(&$links, $data, $only_nodes =
false, $extra = array(), $num = 0) {
11125 'inactive' =>
true,
11126 'only_active' =>
false,
11127 'no_cache' =>
true,
11128 'auth_or' =>
'1=1',
11131 if (is_array($data)) {
11132 foreach ($data as $key => $value) {
11135 $this->updateLinksRecursive($links, $value, $only_nodes, $tmp, $num);
11137 } elseif (!empty($extra)) {
11139 if ($media = $this->_site->getMediaSite()) {
11140 $more_links = array();
11141 switch ($this->field[
'type']) {
11144 end($extra) ==
'gallery_path'
11145 && ($page = $media->getPage($data, array(
'internal' =>
true)))
11147 $more_links[] = $page;
11148 foreach ($page->getChildren(array(), $params) as $child) {
11149 $more_links[] = $child;
11154 if (end($extra) ==
'media_verz') {
11157 $more_links[] = $page;
11158 foreach ($page->getChildren(array(), $params) as $child) {
11159 $more_links[] = $child;
11165 case 'buergerservice/leistung/entry':
11166 if (end($extra) ==
'multimedia_id') {
11167 if (is_numeric($data)) {
11168 $page = $media->getPage($data, array(
'internal' =>
true));
11173 $more_links[] = $page;
11174 foreach ($page->getDescendants(array(), $params) as $descendant) {
11175 $more_links[] = $descendant;
11180 case 'buergerservice/leistung/list':
11182 end($extra) ==
'mm_mainDir'
11183 && ($page = $media->getPage($data, array(
'internal' =>
true)))
11185 $more_links[] = $page;
11186 foreach ($page->getDescendants(array(), $params) as $descendant) {
11187 $more_links[] = $descendant;
11191 case 'wiki/diskussion':
11192 case 'wiki/kommentar':
11193 case 'wiki/portal':
11194 case 'wiki/portal_list':
11196 if (end($extra) ==
'documents') {
11197 foreach (explode(
',', $data) as $id) {
11198 if ($page = $media->getPage($id)) {
11199 $more_links[] = $page;
11209 $more_links = array_merge($more_links, $this->getMoreLinks());
11212 foreach ($more_links as $link) {
11216 $links[
'pages'][] = array(
11217 'src_site' => $this->_site->name,
11218 'src_lang' => $this->_site->language,
11219 'src_id' => $this->field[
'id'],
11220 'dest_site' => $link->getSite()->name,
11221 'dest_lang' => $link->getSite()->language,
11222 'dest_id' => $link->field[
'id'],
11226 'extra_key' => implode(
',', $extra)
11234 if (is_string($data)) {
11237 $pattern =
'/(<([^> ]+) [^>]*)(href="|src="|data="|value="|archive="|class="|url\(\')([^,"\']*(index\.php\?|-site-)([^,"\']+))(["\'][^>]*>((.*?)<\/\\2>)?)/ims';
11239 $pattern =
'/(<([^> ]+) [^>]*)?(href="|src="|data="|value="|archive="|class="|url\(\')?([^,"\']*(index\.php\?|-site-)([^,"\']+))(["\'][^>]*>((.*?)<\/\\2>)?)?/ims';
11241 if (preg_match_all($pattern, $data, $matches)) {
11242 foreach ($matches[0] as $index => $value) {
11243 $url = rtrim($matches[4][$index],
'\\');
11249 if(strlen($info[
'params'][
'lang']) != 2) {
11252 if ($info[
'params'][
'p']) {
11253 $info[
'params'][
'id'] = $info[
'params'][
'p'];
11255 if ($info[
'params'][
'site'] && $info[
'params'][
'id']) {
11256 $lang = $info[
'params'][
'lang'];
11257 if (empty($lang)) {
11259 $site =
new Site($info[
'params'][
'site']);
11260 $site->addParam($params);
11261 }
catch (Exception $e) {
11264 $lang = $site->language;
11268 }
catch (Exception $e) {
11274 $text = (string)$matches[9][$index];
11275 $links[
'pages'][] = array(
11276 'src_site' => $this->_site->name,
11277 'src_lang' => $this->_site->language,
11278 'src_id' => $this->field[
'id'],
11279 'dest_site' => (
string)$info[
'params'][
'site'],
11280 'dest_lang' => (
string)$lang,
11281 'dest_id' => (
int)$info[
'params'][
'id'],
11282 'tag' => (
string)$matches[2][$index],
11285 'extra_key' => implode(
',', $extra)
11287 if (trim($text) !=
'') {
11288 $this->updateLinksRecursive($links, $text, $only_nodes, $extra, $num);
11290 if (stripos($matches[0][$index],
'target="_lightbox"') !==
false) {
11292 foreach ($page->getSiblings() as $sibling) {
11294 $sibling->field[
'type'] ==
'multimedia/image'
11295 && !$sibling->field[
'deleted']
11296 && !$sibling->field[
'inactive']
11298 $links[
'pages'][] = array(
11299 'src_site' => $this->_site->name,
11300 'src_lang' => $this->_site->language,
11301 'src_id' => $this->field[
'id'],
11302 'dest_site' => (
string)$info[
'params'][
'site'],
11303 'dest_lang' => (
string)$lang,
11304 'dest_id' => $sibling->field[
'id'],
11305 'tag' => (
string)$matches[2][$index],
11308 'extra_key' => implode(
',', $extra)
11318 $pattern =
'/^\{.*?"pages":\[\{.*?"(site|lang|id)":.*?\}\].*\}$/ims';
11319 if (preg_match_all($pattern, $data, $matches)) {
11320 require_once(
'base/Ego_Combo.php');
11321 foreach ($matches[0] as $value) {
11324 foreach ($combo->getPages(
true) as $page) {
11325 $links[
'pages'][] = array(
11326 'src_site' => $this->_site->name,
11327 'src_lang' => $this->_site->language,
11328 'src_id' => $this->field[
'id'],
11329 'dest_site' => $page->getSite()->name,
11330 'dest_lang' => $page->getSite()->language,
11331 'dest_id' => $page->field[
'id'],
11335 'extra_key' => implode(
',', $extra)
11345 $pattern =
'/[a-z0-9_]+'
11346 .preg_quote(self::IDENTITY_SEPARATOR,
'/')
11348 .preg_quote(self::IDENTITY_SEPARATOR,
'/')
11350 if (preg_match_all($pattern, $data, $matches)) {
11351 foreach ($matches[0] as $value) {
11353 $page = self::byIdentity($value, $params);
11355 $links[
'pages'][] = array(
11356 'src_site' => $this->_site->name,
11357 'src_lang' => $this->_site->language,
11358 'src_id' => $this->field[
'id'],
11359 'dest_site' => $page->getSite()->name,
11360 'dest_lang' => $page->getSite()->language,
11361 'dest_id' => $page->field[
'id'],
11365 'extra_key' => implode(
',', $extra)
11375 if ($extra[0] !=
'history') {
11376 $pattern =
'/(?<![a-z0-9])([a-z0-9]{32})(?![a-z0-9])/i';
11377 if (preg_match_all($pattern, $data, $matches)) {
11378 foreach ($matches[0] as $index => $values) {
11379 $db = new_db_connection([
11380 'table' =>
'egotec_user',
11381 'where' =>
'user_id = :user_id',
11383 'user_id' => $matches[1][$index]
11386 if ($db->nextRecord()) {
11387 $links[
'users'][] = array(
11388 'src_site' => $this->_site->name,
11389 'src_lang' => $this->_site->language,
11390 'src_id' => $this->field[
'id'],
11396 'dest_user' => $db->Record[
'user_id'],
11397 'extra_key' => implode(
',', $extra)
11412 $db = new_db_connection();
11416 'table' =>
'egotec_links',
11417 'where' =>
"src_site = '{$this->_site->name}'"
11418 .
" AND src_lang = '{$this->_site->language}'"
11419 .
" AND src_id = '{$this->field['id']}'"
11423 if ($db->tableExists(
'egotec_user_links')) {
11425 'table' =>
'egotec_user_links',
11426 'where' =>
"src_site = '{$this->_site->name}'"
11427 .
" AND src_lang = '{$this->_site->language}'"
11428 .
" AND src_id = '{$this->field['id']}'"
11440 public function getLinks($recursive =
false, $c_date =
false) {
11442 $c_dates = array();
11444 $db = new_db_connection();
11446 'table' =>
'egotec_links',
11447 'where' =>
"src_site = :site AND src_lang = :lang AND src_id = :id",
11449 'site' => $this->_site->name,
11450 'lang' => $this->_site->language,
11451 'id' => $this->field[
'id']
11454 while ($db->nextRecord()) {
11455 $record = $db->Record;
11456 $key = md5(serialize(array($db->Record[
'dest_site'], $db->Record[
'dest_lang'])));
11459 if ($recursive || $c_date) {
11464 'auth_or' =>
'1=1',
11465 'deleted_or' =>
'1=1',
11466 'inactive' =>
true,
11467 'only_active' =>
false
11470 $site =
new Site($db->Record[
'dest_site'], $db->Record[
'dest_lang']);
11471 $page = $site->getPage($db->Record[
'dest_id'], $param);
11476 if (!isset($c_dates[$key])) {
11477 $c_dates[$key] =
'';
11480 if (!empty($clusters)) {
11482 foreach ($clusters as $cluster) {
11483 $file = $GLOBALS[
'egotec_conf'][
'log_dir'] . $db->Record[
'dest_site'] .
'/live.' . $db->Record[
'dest_site'] .
'_' . $db->Record[
'dest_lang'] .
'.' . $cluster[
'id'] .
'.date';
11486 if (empty($c_dates[$key]) || $date < $c_dates[$key]) {
11487 $c_dates[$key] = $date;
11493 $file = $GLOBALS[
'egotec_conf'][
'log_dir'] . $db->Record[
'dest_site'] .
'/live.' . $db->Record[
'dest_site'] .
'_' . $db->Record[
'dest_lang'] .
'.date';
11500 if (!empty($c_dates[$key])) {
11501 $query[
'where'] =
'm_date > :c_date';
11502 $query[
'bind'] = array(
11503 'c_date' => $c_dates[$key]
11508 if ($recursive && $page->field[
'type'] ==
'multimedia/category') {
11509 $descendants = $page->getDescendants($query, $param);
11510 $record[
'descendants'] = 0;
11511 foreach ($descendants as $descendant) {
11512 $record[
'descendants']++;
11513 $link = $db->Record;
11514 $link[
'dest_id'] = $descendant->field[
'id'];
11515 $link[
'recursive'] =
true;
11525 if ($c_date && !empty($c_dates[$key]) && $page && $page->field[
'm_date'] <= $c_dates[$key] && empty($record[
'descendants'])) {
11530 $links[] = $record;
11547 'inactive' =>
true,
11548 'only_active' =>
false,
11549 'no_cache' =>
true,
11550 'auth_or' =>
'1=1',
11554 $db = new_db_connection();
11556 foreach ($this->_site->getLanguages() as $lang) {
11557 if ($page = $this->getLanguagePage($lang, $param)) {
11559 'table' =>
'egotec_links',
11560 'where' =>
"dest_site = :site1 AND dest_lang = :lang AND dest_id = :id1"
11561 .
" AND (src_site != :site2 OR src_id != :id2)",
11563 'site1' => $this->_site->name,
11565 'id1' => $this->field[
'id'],
11566 'site2' => $this->_site->name,
11567 'id2' => $this->field[
'id']
11569 'order' =>
'num ASC'
11571 if ($db->nextRecord()) {
11574 'sources' => array()
11579 if ($page->extra[
'clones']) {
11580 foreach (explode(
',', $page->extra[
'clones']) as $clone) {
11582 $clones[] = self::createIdentity($info[
'params']);
11587 $record = $db->Record;
11590 if (!empty($clones) && in_array(self::createIdentity(array(
11591 'site' => $record[
'src_site'],
11592 'lang' => $record[
'src_lang'],
11593 'id' => $record[
'src_id']
11600 $db2 = new_db_connection(array(
11601 'table' => $record[
'src_site'] .
'_' . $record[
'src_lang'],
11602 'where' =>
'id = :id',
11604 'id' => $record[
'src_id']
11610 while (!$db2->nextRecord()) {
11614 $src_site = $record[
'src_site'];
11615 $src_lang = $record[
'src_lang'];
11616 $src_id = $record[
'src_id'];
11619 $record[
'json'] =
false;
11620 if ($record[
'extra_key']) {
11622 'site' => $src_site,
11623 'lang' => $src_lang,
11626 'inactive' =>
true,
11627 'only_active' =>
false,
11633 if (strpos($src_value,
'{') === 0 && @json_decode($src_value)) {
11634 $record[
'json'] =
true;
11639 $link[
'sources'][$src_site][$src_lang][$src_id][] = $record;
11640 }
while ($db->nextRecord());
11641 if (!empty($link[
'sources'])) {
11650 $descendants = $this->getDescendants(array(), $param);
11651 foreach ($descendants as $descendant) {
11652 $links = array_merge($links, $descendant->getLinkedPages());
11662 $db = new_db_connection();
11663 foreach ($this->_site->getLanguages() as $lang) {
11665 'table' =>
'egotec_user_links, egotec_user',
11666 'fields' =>
'`egotec_user_links`.*, `egotec_user`.username',
11667 'where' =>
"`egotec_user_links`.src_user = `egotec_user`.user_id AND dest_site = :site AND dest_lang = :lang AND dest_id = :id",
11669 'site' => $this->_site->name,
11671 'id' => $this->field[
'id'],
11673 'order' =>
'`egotec_user`.username ASC'
11676 if ($db->nextRecord()) {
11678 $record = $db->Record;
11679 $user =
new User_SQL($record[
'src_user']);
11682 'extra' => $record[
'extra_key'],
11683 'username' => $user->getFullname(),
11684 'edit' => $GLOBALS[
'auth']->hasPermissionOn($user),
11685 'url' => get_url(
'admin.php', [
11687 'user_id' => $record[
'src_user']
11690 }
while ($db->nextRecord());
11715 public function getIconUrl($test =
false, $folder =
false, $quarantine =
true) {
11716 if ($quarantine && ($this->extra[
'quarantine'] || stristr($this->field[
'extra'],
'"quarantine"'))) {
11718 return $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/16x16/attention.png';
11720 if ($this->extra[
'crop_image']) {
11722 return $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/16x16/crop.png';
11726 : ($folder && $this->hasChildren(array(), array(
'auth_or' =>
'1=1'))
11727 ? $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/16x16/folder.png'
11728 : $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/16x16/page.png');
11729 $this->getTypeInfo();
11730 if (!empty($this->typeInfo)) {
11731 if (!empty($this->typeInfo[
'icon'])) {
11732 $icon = $this->typeInfo[
'icon'];
11733 $get_path =
function() use ($icon) {
11734 $real_path = (string) realpath($icon);
11735 $dir_pos = strpos($real_path, $GLOBALS[
'egotec_conf'][
'egotec_dir']);
11736 if ($dir_pos ===
false) {
11738 $tmp = explode(DIRECTORY_SEPARATOR, trim($GLOBALS[
'egotec_conf'][
'egotec_dir'], DIRECTORY_SEPARATOR));
11740 $dir = DIRECTORY_SEPARATOR
11742 . DIRECTORY_SEPARATOR;
11743 if ($dir_pos = strpos($real_path, $dir)) {
11744 return substr($real_path, $dir_pos + strlen($dir));
11747 return substr($real_path, $dir_pos + strlen($GLOBALS[
'egotec_conf'][
'egotec_dir']));
11749 $path = $get_path();
11753 chdir($GLOBALS[
'egotec_conf'][
'egotec_dir']);
11754 $path = $get_path();
11757 $url = $GLOBALS[
'egotec_conf'][
'url_dir'] . $path;
11758 } elseif (!empty($this->extra[
'image_type']) && !$folder) {
11759 $mime = strtolower($this->extra[
'image_type']);
11770 if (
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'bin_dir'].
'admin_skin/egotec/img/icons/small/2013/'.$mime.
'.png')) {
11771 $url = $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/icons/small/2013/'.$mime.
'.png';
11785 if (!$cache || empty($this->typeInfo)) {
11786 $key =
'type'.md5(serialize(array($this->_site->name, $this->field[
'type'])));
11787 $cache = $this->_site->getCacheEntry($key);
11788 if ($cache ===
null) {
11789 if ($file = $this->_site->getSiteFile($this->field[
'type'] . DIRECTORY_SEPARATOR .
'type.ini')) {
11790 $this->typeInfo = @parse_ini_file($file,
true);
11791 $this->_site->setCacheEntry($key, is_array($this->typeInfo) ? $this->typeInfo : array());
11794 $this->typeInfo = $cache;
11797 return $this->typeInfo;
11806 $type_info = $this->getTypeInfo();
11807 return $this->_site->hasRight(
'change_type') && empty($type_info[
'unchangeable']);
11819 $css[
'skin'][
'editor'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/editor.css";
11821 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/editor.css")) {
11822 $css[
'global'][
'editor'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/editor.css";
11825 $css[
'skin'][
'table'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/table.css";
11827 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/table.css")) {
11828 $css[
'global'][
'table'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/table.css";
11831 $css[
'skin'][
'span'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/span.css";
11833 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/span.css")) {
11834 $css[
'global'][
'span'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/span.css";
11837 $css[
'skin'][
'img'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/img.css";
11839 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/img.css")) {
11840 $css[
'global'][
'img'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/img.css";
11843 $css[
'skin'][
'link'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/link.css";
11845 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/link.css")) {
11846 $css[
'global'][
'link'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/link.css";
11848 if (
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].$this->_site->skin.
"/".$this->field[
'type'].
"/style.css")) {
11849 $css[
'type'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/".$this->_site->skin.
"/".$this->field[
'type'].
"/style.css";
11850 $content_css = $css[
'type'][
'style'];
11853 $css[
'skin'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/style.css";
11854 $content_css = $css[
'skin'][
'style'];
11856 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/style.css")) {
11857 $css[
'global'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/style.css";
11858 $content_css = $css[
'global'][
'style'];
11861 $this->extra[
'_style']
11862 && ($file = $this->_site->getSkinFile($this->field[
'type'].
'/style.'.$this->extra[
'_style'].
'.css', array(),
true))
11864 $css[
'variant'][
'style'] = $file;
11865 $content_css = $css[
'variant'][
'style'];
11869 if ($this->_site->theme) {
11870 if (empty($css[
'theme'][
'editor']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/editor.css")) {
11871 $css[
'theme'][
'editor'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/editor.css";
11873 if (empty($css[
'theme'][
'table']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/table.css")) {
11874 $css[
'theme'][
'table'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/table.css";
11876 if (empty($css[
'theme'][
'span']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/span.css")) {
11877 $css[
'theme'][
'span'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/span.css";
11879 if (empty($css[
'theme'][
'img']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/img.css")) {
11880 $css[
'theme'][
'img'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/img.css";
11882 if (empty($css[
'theme'][
'link']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/link.css")) {
11883 $css[
'theme'][
'link'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/link.css";
11885 if (empty($css[
'theme'][
'style']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/".$this->field[
'type'].
"/style.css")) {
11886 $css[
'theme'][
'type'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/".$this->field[
'type'].
"/style.css";
11888 if (empty($css[
'theme'][
'style']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/style.css")) {
11889 $css[
'theme'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/style.css";
11894 if ($GLOBALS[
'admin_area'] && ($file = $this->_site->getSkinFile(
'admin.css', array(),
true))) {
11895 $css[
'admin'][
'style'] = $file;
11900 'content_css' => $content_css
11910 return $this->field[
'name'];
11919 return self::createIdentity(array(
11920 'site' => $this->_site->name,
11921 'lang' => $this->_site->language,
11922 'id' => $this->field[
'id']
11933 return is_string($identity)
11934 && ($v = explode(self::IDENTITY_SEPARATOR, $identity))
11936 && !is_numeric($v[0])
11937 && strlen($v[1]) == 2
11938 && is_numeric($v[2]);
11948 return implode(self::IDENTITY_SEPARATOR, array($params[
'site'], $params[
'lang'], $params[
'id']));
11960 public static function byIdentity($identity, $param = array(), $site =
null) {
11961 [$name, $lang, $id] = explode(self::IDENTITY_SEPARATOR, $identity);
11965 || $site->name != $name
11966 || $site->language != $lang
11970 && $GLOBALS[
'site']->name == $name
11971 && $GLOBALS[
'site']->language == $lang
11973 $site = $GLOBALS[
'site'];
11975 $site =
new Site($name, $lang,
'', !$GLOBALS[
'admin_area'] || $_SESSION[
'login'][
'live_preview']);
11978 if (!is_array($param)) {
11981 return $site->getPage($id, $param);
11997 public function inheritExtra($keys, $mixed =
false, $types = array(), $no_rights =
true) {
11998 $cache_key =
'inherit'.md5(serialize([$this->getIdentity(), $keys, $mixed, $types, $no_rights]));
11999 $cache_entry = $this->_site->getCacheEntry($cache_key);
12001 if ($cache_entry ===
null) {
12004 if (!empty($keys)) {
12006 if (!empty($types)) {
12008 $query[
'where'] = array();
12009 $query[
'bind'] = array();
12011 foreach ($types as $type) {
12012 $query[
'where'][] =
'type = :type'.(++$n);
12013 $query[
'bind'][
'type'.$n] = $type;
12015 $query[
'where'] = implode(
' OR ', $query[
'where']);
12020 $param[
'auth_or'] =
'1=1';
12023 $ancestors = array();
12025 foreach ($this->getAncestors($query, $param) as $ancestor) {
12026 $ancestors[] = $ancestor;
12028 $ancestors = array_reverse($ancestors);
12029 array_unshift($ancestors, $this);
12030 foreach ($ancestors as $ancestor) {
12031 foreach ($keys as $key) {
12033 if ($value !==
null && !isset($values[$key])) {
12034 $values[$key] = $value;
12037 foreach ($keys as $k) {
12052 $this->_site->setCacheEntry($cache_key, $values);
12054 $values = $cache_entry;
12065 require_once
'stats/Ego_Piwik.php';
12066 $piwik =
new Ego_Piwik();
12067 $piwikdata = $piwik->createWebsite($this);
12068 if (!is_array($piwikdata)) {
12081 $ignore_ids = array($this->field[
'id']);
12084 if ($this->isWorkflowCopy()) {
12085 $ignore_ids[] = (int) $this->extra[
'original_id'];
12087 $original_page = $this->_site->getPage((
int) $this->extra[
'original_id']);
12088 if (!empty($original_page->extra[
'release_ids'])) {
12089 foreach ($original_page->extra[
'release_ids'] as $release_id) {
12090 $ignore_ids[] = (int) $release_id;
12094 if ($this->isReleaseCopy()) {
12095 $ignore_ids[] = (int) $this->extra[
'release_id'];
12097 $original_page = $this->_site->getPage((
int) $this->extra[
'release_id']);
12098 if (!empty($original_page->extra[
'workflow_page'])) {
12099 $ignore_ids[] = (int) $original_page->extra[
'workflow_page'];
12104 if (!empty($this->extra[
'release_ids'])) {
12105 foreach ($this->extra[
'release_ids'] as $release_id) {
12106 $ignore_ids[] = (int) $release_id;
12109 if (!empty($this->extra[
'workflow_page'])) {
12110 $ignore_ids[] = (int) $this->extra[
'workflow_page'];
12113 $db = new_db_connection(array(
12114 'table' => $this->_site->pageTable,
12115 'where' =>
'url = :url AND deleted = 0 AND id NOT IN (' . implode(
', ', array_unique($ignore_ids)) .
')',
12120 if (!$db->nextRecord()) {
12122 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'flat') {
12124 'table' => $this->_site->pageTable,
12125 'where' =>
'name = :name AND id != :id AND deleted = 0',
12128 'id' => $this->field[
'id']
12131 if ($db->nextRecord()) {
12137 if (empty($GLOBALS[
'egotec_conf'][
'rewrite_engine'])) {
12139 'table' => $this->_site->pageTable,
12140 'where' =>
'page_id = :root_id AND name = :name AND id != :id AND deleted = 0',
12141 'join' => $this->_site->pageTable.
'_children ON ('.$this->_site->pageTable.
'_children.child = id)',
12143 'root_id' => $this->_site->rootId,
12145 'id' => $this->field[
'id']
12148 if ($db->nextRecord()) {
12155 if ($site->name == $url) {
12173 public function validateFile($source, $name =
'', $form = array(), $files_conf = array()) {
12174 $files_list = array();
12177 if (!empty($files_conf)) {
12178 $files_list[] = $files_conf;
12182 if (!empty($form) && !empty($this->extra[
'mandatory'][$form[
'form']][$form[
'field']][
'files'])) {
12183 $files_list[] = $this->extra[
'mandatory'][$form[
'form']][$form[
'field']][
'files'];
12187 if (!empty($this->_site->admin[
'files'])) {
12188 $files_list[] = $this->_site->admin[
'files'];
12192 if (!empty($GLOBALS[
'egotec_conf'][
'files'])) {
12193 $files_list[] = $GLOBALS[
'egotec_conf'][
'files'];
12196 if (!empty($files_list)) {
12198 foreach ($files_list as $files) {
12199 if ($files[
'validate_files']) {
12202 }
catch (Exception $e) {
12203 egotec_error_log($e->getMessage());
12213 require_once(
'base/Ego_MimeType.php');
12215 $prepare_type =
function($t) {
12216 return trim(ltrim(mb_strtolower($t),
"."));
12218 $type = $prepare_type(pathinfo($name ? $name : @basename($source), PATHINFO_EXTENSION));
12219 $size = @filesize($source);
12221 foreach ($files_list as $files) {
12223 !empty($files[
'whitelist'])
12224 || !empty($files[
'blacklist'])
12225 || !empty($files[
'filesize'])
12227 $whitelist = array_map($prepare_type, explode(
',', (
string) $files[
'whitelist']));
12228 $blacklist = array_map($prepare_type, explode(
',', (
string) $files[
'blacklist']));
12230 (!empty($files[
'whitelist']) && (!in_array($type, $whitelist) || !$mime->hasMimeType($source, $whitelist)))
12231 || (!empty($files[
'blacklist']) && empty($files[
'whitelist']) && (in_array($type, $blacklist) || $mime->hasMimeType($source, $blacklist)))
12232 || (!empty($files[
'filesize']) && $size > (
int) $files[
'filesize'])
12253 $info = $this->getTypeInfo();
12254 return $this->_site->isFrontendAdmin($check_rights)
12255 && !$info[
'frontend_ignore']
12258 || $this->hasRights(array(
'view'))
12269 return ($_REQUEST[
'site'] ? $_REQUEST[
'site'] : $GLOBALS[
'default_site']) == $this->_site->name
12270 && (!$lang || ($_REQUEST[
'lang'] ? $_REQUEST[
'lang'] : $this->_site->site[
'default_language']) == $this->_site->language)
12271 && ($_REQUEST[
'id'] ? $_REQUEST[
'id'] : ($_REQUEST[
'list'] ? $_REQUEST[
'list'] : $this->_site->rootId)) == $this->field[
'id'];
12280 $_REQUEST[
'site'] = $this->_site->name;
12281 $_REQUEST[
'lang'] = $this->_site->language;
12282 $_REQUEST[
'id'] = $this->field[
'id'];
12283 $GLOBALS[
'site'] = &$this->_site;
12284 $GLOBALS[
'page'] = &$this;
12294 $db = new_db_connection();
12300 'table' => $this->_site->pageTable.
'_v',
12301 'where' =>
"id = {$this->field['id']} AND m_date > :date",
12303 'date' => $this->lastChangeDate
12309 'table' => $this->_site->pageTable.
'_v',
12310 'where' =>
"id = {$this->field['id']} AND m_date > :date1 AND m_date != :date2",
12312 'date1' => $this->lastChangeDate,
12313 'date2' => $this->field[
'm_date']
12321 foreach (glob($this->getMediapool()->dir().
'*', GLOB_ONLYDIR) as $dir) {
12322 $dir_c_date = basename($dir);
12324 is_numeric($dir_c_date)
12325 && (
int) $dir_c_date != $this_c_date
12326 && (
int) $dir_c_date > $last_c_date
12339 return $this->_site->getNextReplicationDate($this);
12348 return $this->_site->getCacheEntry(
"{$key}_{$this->field['id']}");
12359 $this->_site->setCacheEntry(
"{$key}_{$this->field['id']}", $value);
12373 $limit = (isset($_REQUEST[
'dt'][
'start']) && !$no_limit
12374 ? $_REQUEST[
'dt'][
'start'] .
',' . $_REQUEST[
'dt'][
'length']
12380 isset($_REQUEST[
'dt'][
'order'])
12381 && isset($_REQUEST[
'dt'][
'order'][
'dir'])
12382 && isset($_REQUEST[
'dt'][
'order'][
'field'])
12384 switch ($_REQUEST[
'dt'][
'order'][
'dir']) {
12386 $order = $_REQUEST[
'dt'][
'order'][
'field'] .
' ASC';
12389 $order = $_REQUEST[
'dt'][
'order'][
'field'] .
' DESC';
12397 if ($limit !=
'') {
12398 $query[
'limit'] = $limit;
12399 $query[
'order'] = $order ==
'' ?
'id ASC' : $order;
12402 foreach ($this->getChildren($query, array(
12403 'inactive' =>
true,
12404 'only_active' =>
false
12406 $child->field[
'identity'] = $child->getIdentity();
12411 if (isset($_REQUEST[
'dt'][
'start'])) {
12412 $_REQUEST[
'dt'][
'total'] = $this->getChildren(array(
12415 'inactive' =>
true,
12416 'only_active' =>
false
12430 $this->newChild(array(
12431 'name' => (
string) $params[
'data']->name,
12432 'title' => (
string) $params[
'data']->name,
12433 'type' => $params[
'type'] ? $params[
'type'] :
'page'
12444 if ($page = self::byIdentity($params[
'identity'])) {
12458 foreach ($params[
'data']->identities as $identity) {
12459 if ($page = self::byIdentity($identity)) {
12473 $children = array();
12474 foreach ($params[
'data'] as $identity) {
12475 [$name, $lang, $id] = explode(self::IDENTITY_SEPARATOR, $identity);
12476 if ($name == $this->_site->name && $lang == $this->_site->language) {
12477 $children[] = (int) $id;
12481 $this->archiveOnly =
false;
12482 $this->update(array(
12484 'children_order' =>
'children'
12486 'children' => $children
12499 'title' => $GLOBALS[
'auth']->translate(
'Empfangen'),
12500 'formatter' =>
'date',
12501 'sortable' =>
true,
12505 if (is_array($this->extra[
'_blocks'][$orient])) {
12507 foreach ($this->extra[
'_blocks'][$orient] as $index => $block) {
12508 if (strpos($block,
'input_') === 0 && $block !=
'input_submit' && isset($this->extra[
'_contents'][$orient][$index])) {
12509 if ($block ==
'input_file' && $this->extra[
'_forms'][$orient][
'export'] ==
'page') {
12513 $content = $this->extra[
'_contents'][$orient][$index];
12514 $label = $content[
'label'] ? trim($content[
'label'],
' :') : $content[
'extra'][
'name'];
12515 if ($block ==
'input_checkbox') {
12516 require_once
'base/Ego_Combo.php';
12517 $combo =
new Ego_Combo($content[
'extra'][
'values']);
12518 foreach ($combo->getData() as $data) {
12519 $conf[
"data.{$data->field_name}"] = array(
12520 'title' => $label .
': ' . ($data->label ? trim($data->label,
' :') : $data->field_name),
12522 'sortable' =>
false
12525 } elseif (isset($content[
'extra'][
'name'])) {
12526 $conf[
"data.{$content['extra']['name']}"] = array(
12527 'title' => $content[
'label'] ? trim($content[
'label'],
' :') : $content[
'extra'][
'name'],
12529 'sortable' =>
false
12536 $conf[
'pool'] = array(
12537 'title' => $GLOBALS[
'auth']->translate(
'Dateien'),
12538 'formatter' =>
'pool',
12540 'align' =>
'center',
12541 'sortable' =>
false
12557 $files =
Ego_System::getFiles(
'site', $this->_site->name, ($type ?: $this->field[
'type']) .
'/admin/data.json', [], $this->_site->theme,
true);
12558 foreach (array_keys(array_reverse($files)) as $file) {
12559 if ($file !=
'_empty') {
12561 if ($new_data[
'extend']) {
12563 $data = array_merge_recursive($data, $new_data);
12584 public function fetch($params = array(), $outputfilter =
false, $script =
true, $includes =
true, $variant =
'') {
12585 if ($template = $this->getTemplate($GLOBALS[
'is_mobile'],
'body', $variant)) {
12586 $original_site = $GLOBALS[
'site'];
12587 $original_page = $GLOBALS[
'page'];
12588 $original_smarty = $GLOBALS[
'smarty'];
12589 $GLOBALS[
'site'] = $site = $this->getSite();
12590 $GLOBALS[
'page'] = $page = $this;
12591 $auth = $GLOBALS[
'auth'];
12594 $GLOBALS[
'smarty'] = $smarty = Ego_Smarty::createFrontend($site, array(
12599 $require_script =
function($filename) use ($site, $page, $smarty, $auth) {
12600 require($filename);
12602 if ($script && ($filename = $site->getSiteFile($page->field[
'type'].
'/index.php'))) {
12603 $require_script($filename);
12605 if (!$outputfilter) {
12606 unset($smarty->_plugins[
'outputfilter'], $smarty->autoload_filters[
'output']);
12608 $smarty->assign(array_merge(array(
12614 $html = $includes ? $page->getHtml(
false) :
'';
12615 $html .= $smarty->fetch($template);
12617 $GLOBALS[
'site'] = $original_site;
12618 $GLOBALS[
'page'] = $original_page;
12619 $GLOBALS[
'smarty'] = $original_smarty;
12621 $html = $this->field[
'content'];
12634 switch ($this->_site->site[
'type']) {
12637 require_once
'base/Ego_Output.php';
12639 if ($suffix ==
".$type" && $this->field[
'type'] ==
'multimedia/image') {
12645 in_array($this->field[
'type'], array(
'multimedia/file',
'multimedia/image'))
12646 && !empty($this->extra[
'image_type'])
12647 &&
'.' . $this->extra[
'image_type'] != $suffix
12654 $suffixes = $this->_site->getCacheEntry($key);
12655 $type = $this->field[
'type'];
12656 if ($GLOBALS[
'is_mobile']) {
12657 $type .=
'@mobile';
12659 $result = $suffixes[$type][$suffix];
12660 if (!is_bool($result)) {
12665 !in_array($suffix, array(
'.html',
'.rss',
'.ical',
'.ics'))
12666 && ($template = $this->getTemplate($GLOBALS[
'is_mobile'],
'index'))
12667 && strpos(basename($template),
"index{$suffix}.") !== 0
12668 && ($template = $this->getTemplate($GLOBALS[
'is_mobile'],
'body'))
12669 && strpos(basename($template),
"body{$suffix}.") !== 0
12673 $suffixes[$type][$suffix] = $result;
12674 $this->_site->setCacheEntry($key, $suffixes);
12686 if (in_array($this->field[
'type'], explode(
',', $this->_site->admin[
'social'][
'types']))) {
12687 return $this->_site->getSocialNetworks();
12698 @set_time_limit(0);
12701 $media_dir = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->_site->name;
12702 $dest = $media_dir . DIRECTORY_SEPARATOR . $this->getMediaFilename(
true);
12719 $this->getMediapool()->clear();
12722 if ($resolution >= $height) {
12723 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'video');
12724 $scale = preg_replace(
'/^\d+:/',
'-2:', $scale);
12727 require_once
'base/Ego_Progress.php';
12728 $progress =
new Ego_Progress(
'worker_' . $this->getIdentity() .
'_' . $height .
'p');
12746 $this->getMediapool()->put($tmp,
"{$height}p.mp4");
12750 $progress->clear();
12764 @set_time_limit(0);
12767 $media_dir = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->_site->name;
12768 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'video');
12769 $scale =
"$width:$height";
12770 $name =
"{$width}_$height";
12773 require_once
'base/Ego_Progress.php';
12774 $progress =
new Ego_Progress(
'worker_' . $this->getIdentity() .
'_' . $name);
12777 $media_dir . DIRECTORY_SEPARATOR . $this->getMediaFilename(
true),
12792 $this->getMediapool()->put($tmp,
"$name.mp4");
12796 $progress->clear();
12803 $original_file = $GLOBALS[
'egotec_conf'][
'var_dir'] .
"media/" . $this->_site->name .
"/" . $this->getMediaFilename();
12804 $target_file = tempnam($GLOBALS[
'egotec_conf'][
'var_dir'] .
'tmp',
'convert');
12806 $log_file = $GLOBALS[
'egotec_conf'][
'tmp_dir'] .
'ffmpeg_log';
12821 $this->updateFile($target_file, $this->field[
'name'] .
'_converted.mp4');
12822 if ($this->_site->admin[
'video'][
'compress']) {
12824 $this->compressVideo();
12840 public function getThumbnail($width, $height = 0, $pool =
'', $dir =
'', $params = []) {
12842 $thumbnail = $GLOBALS[
'egotec_conf'][
'cachemedia_dir']
12843 . $this->_site->name .
'/'
12844 . $this->_site->language .
'/'
12845 . $this->field[
'id'] .
'/'
12846 . strtotime($this->field[
'm_date']) .
'/'
12847 .
'thumb_' . $width .
'x' . $height .
'_' . md5(serialize([$pool, $dir, $params]));
12854 $info = $this->getMediapool()->get($pool, $dir);
12855 if (!empty($info) && !$info[
'quarantine']) {
12856 $file = $info[
'file'];
12857 $mime = $info[
'mime'];
12860 in_array($this->field[
'type'], [
'multimedia/file',
'multimedia/image'])
12861 && !$this->extra[
'quarantine']
12864 $file = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->_site->name .
'/' . $this->getMediaFilename();
12865 $mime = $this->extra[
'mime_type'];
12869 $thumbnail_dir = dirname($thumbnail);
12876 if ($mime ==
'application/pdf' || strpos($mime,
'image') === 0) {
12878 require_once
'base/Ego_Image.php';
12879 $image =
new Ego_Image($file .
'[' . ($params[
'index'] ?? 0) .
']');
12880 if ($tmp = $image->thumbnail($width, $height, $params)) {
12882 @rename($tmp, $thumbnail);
12894 if ($params[
'get_url']) {
12895 return $this->getUrl(array_filter([
12896 'thumbnail' => implode(
'x', array_filter([$width, $height, (
int) $params[
'index']])),
12913 if ($GLOBALS[
'__egotec_skip_replication'] === $method) {
12914 unset($GLOBALS[
'__egotec_skip_replication']);
12920 $this->getSite()->admin[
'cluster'][
'replication']
12921 && $GLOBALS[
'egotec_conf'][
'liveserver']
12922 && !$_SERVER[
'HTTP_X_REPLICATION']
12923 && !$GLOBALS[
'__egotec_skip_replication']
12925 require_once
'base/Ego_REST_Client.php';
12928 if ($pool = (($parts = explode(
'.', $method, 2))[0] ==
'pool')) {
12929 $method = $parts[1];
12933 $rest = parse_ini_file($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'base/rest.ini',
true);
12935 ($pool && ($conf = $rest[
'pool'][$method]))
12936 || ($conf = $rest[
'page'][$method])
12938 [$action] = explode(
':', $conf, 2);
12944 $replication =
function() use ($method, $params, $action, $pool) {
12949 $user_id = new_db_connection([
12950 'table' =>
'egotec_user',
12951 'where' =>
'username = :username',
12953 'username' => $this->getSite()->admin[
'live'][
'login']
12955 ])->nextRecord()[
'user_id'];
12956 $user =
new User_SQL($user_id);
12957 $path = implode(
'/', array_filter([
12958 $this->getSite()->name,
12959 $this->getSite()->language,
12960 $this->field[
'id'],
12961 $pool ?
'pool' :
null,
12971 $convert_pages =
function ($values) use (&$convert_pages) {
12972 foreach ($values as $key => $value) {
12973 if (is_array($value)) {
12974 $values[$key] = $convert_pages($value);
12975 } elseif (is_a($value,
'Page')) {
12976 $values[$key] =
'@identity:' . $value->getIdentity();
12981 $params = $convert_pages($params);
12984 $data = $files = [];
12985 foreach ($params as $key => $value) {
12987 if (is_string($value) && strpos($value,
'@file:') === 0) {
12988 $data[$key] =
'@file';
12989 $files[] =
new CURLFile($source = substr($value, 6));
12991 $data[$key] = $value;
12996 self::$nextIds = array_unique(self::$nextIds);
12997 $replicateIds = self::$nextIds;
13000 foreach ($clusters as $cluster) {
13001 if (!$cluster[
'oneway']) {
13005 $host = parse_url($cluster[
'url'], PHP_URL_HOST);
13011 $url = rtrim($cluster[
'url'],
'/') .
'/rest/';
13012 $client =
new Ego_REST_Client($url, $user->field[
'user_id'], $user->extra[
'api_token']);
13015 $client->{strtolower($action)}(
13017 array_merge([
'@data' => json_encode($data)], $files),
13019 "X-REPLICATION: $host",
13020 "X-NEXT-IDS: " . implode(
',', self::$nextIds)
13027 if ((
sizeof(self::$nextIds) > 1)) {
13028 self::$nextIds = array_slice($replicateIds, 1);
13031 self::$nextIds = $replicateIds;
13045 return $this->getAncestors([
"where" =>
"type = '_template/list'"])->next() ? true :
false;
13054 $info = $this->getTypeInfo();
13055 if (isset($info[
'editor'][
'short'])) {
13056 return (
bool) $info[
'editor'][
'short'];
13058 return $this->_site->admin[
'editor'][
'short'] || $GLOBALS[
'egotec_conf'][
'editor'][
'short'];
13070 if (count($conf) === 0) {
13071 $conf = $this->conf;
13074 $extra_values = [];
13076 if (isset($conf[
'extra_fields']) && is_array($conf[
'extra_fields'])) {
13077 $src = $conf[
'extra_fields'];
13079 if ($csv && isset($conf[
'extra_fields'][
'csv']) && count($conf[
'extra_fields'][
'csv']) !== 0) {
13080 $src = $conf[
'extra_fields'][
'csv'];
13084 foreach ($src as $field => $items) {
13085 if ($field ===
'csv') {
13090 foreach ($items as $item) {
13091 $value = $this->$field[$item[
'value']];
13094 if (!is_array($value)) {
13096 if (isset($item[
'modifier'])) {
13097 switch ($item[
'modifier'][
'type'] ??
null) {
13100 $value = date($item[
'modifier'][
'format'], $item[
'modifier'][
'timestamp'] ? $value : strtotime($value));
13106 $true = $item[
'modifier'][
'true'][
'type'] ===
'image'
13107 ? ($GLOBALS[
'egotec_conf'][
'url_dir'] . $item[
'modifier'][
'true'][
'value'])
13108 : $item[
'modifier'][
'true'][
'value'];
13110 $false = $item[
'modifier'][
'false'][
'type'] ===
'image'
13111 ? ($GLOBALS[
'egotec_conf'][
'url_dir'] . $item[
'modifier'][
'false'][
'value'])
13112 : $item[
'modifier'][
'false'][
'value'];
13115 switch ($item[
'modifier'][
'mode'] ??
null) {
13117 if (isset($value) && !empty($value)) {
13125 $value = $value === $item[
'modifier'][
'value'] ? $true : $false;
13135 isset($item[
'modifier'][
'function'])
13136 && isset($item[
'modifier'][
'file'])
13139 require_once ($GLOBALS[
'egotec_conf'][
'var_dir'] . $item[
'modifier'][
'file']);
13141 $value = call_user_func($item[
'modifier'][
'function'], $this);
13151 if ($item[
'default'] && empty($value)) {
13152 $value = $item[
'default'];
13156 if ($item[
'type'] ===
'image') {
13157 $extra_values[] = [
13160 'lightbox' => $item[
'lightbox']
13163 $extra_values[] = [
'value' => $value];
13165 }
else if (isset($item[
'default'])) {
13166 $extra_values[] = [
13167 'value' => $item[
'default']
13174 return $extra_values;
13186 require_once
'base/Ego_Output.php';
13188 $csv_file = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'csv');
13193 $extra_fields = [];
13197 $src = $this->conf[
'extra_fields'] ?? [];
13199 if (isset($src[
'csv'])) {
13200 $src = $src[
'csv'];
13204 if (is_array($src)) {
13205 foreach ($src as $field) {
13206 foreach ($field as $item) {
13207 $extra_fields[] = $item[
'name'];
13213 $data[0] = array_merge([
13214 $GLOBALS[
'auth']->translate(
'Name'),
13215 $GLOBALS[
'auth']->translate(
'Seitentyp'),
13216 $GLOBALS[
'auth']->translate(
'Ersteller'),
13217 $GLOBALS[
'auth']->translate(
'Erstellungsdatum'),
13218 $GLOBALS[
'auth']->translate(
'Letzter Bearbeiter'),
13219 $GLOBALS[
'auth']->translate(
'Bearbeitungsdatum'),
13220 $GLOBALS[
'auth']->translate(
'Freigabe von'),
13221 $GLOBALS[
'auth']->translate(
'Freigabe bis'),
13222 $GLOBALS[
'auth']->translate(
'Aktiv'),
13223 ], ($this->_site->admin[
'workflow'][
'enabled'] ? [$GLOBALS[
'auth']->translate(
'Ist im Workflow')] : []), $extra_fields);
13226 if (count($ids) > 0 && !$downloadAll) {
13227 foreach ($ids as $id) {
13228 $children[] = $this->_site->getPage((
int) $id, [
'inactive' =>
true]);
13230 }
else if ($downloadAll) {
13231 $children = $this->getDescendants([], [
'inactive' =>
true]);
13233 $children = $this->getChildren([], [
'inactive' =>
true]);
13237 foreach ($children as $child) {
13239 if ($child->isWorkflowCopy())
continue;
13241 $extra_values = [];
13244 $typeInfo = $child->getTypeInfo();
13246 $a_user = $GLOBALS[
'auth']->translate(
'unbekannt');
13247 $c_user = $GLOBALS[
'auth']->translate(
'unbekannt');
13250 $a_user = (
new User_SQL($child->field[
'a_user']))->getFullname(
false);
13251 }
catch (Exception $e) {}
13254 $c_user = (
new User_SQL($child->field[
'c_user']))->getFullname(
false);
13255 }
catch (Exception $e) {}
13257 foreach ($child->getExtraValues($this->conf,
true) as $value) {
13258 $extra_values[] = $value[
'value'];
13262 $data[] = array_merge([
13263 $child->field[
'name'],
13264 $typeInfo[
'title'] .
' (' . $child->field[
'type'] .
')',
13266 $child->field[
'a_date'],
13268 $child->field[
'c_date'],
13269 $child->field[
'release_from'] !==
'0000-00-00 00:00:00' ? $child->field[
'release_from'] :
'-',
13270 $child->field[
'release_until'] !==
'0000-00-00 00:00:00' ? $child->field[
'release_until'] :
'-',
13271 $child->isActive() ? $GLOBALS[
'auth']->translate(
'Ja') : $GLOBALS[
'auth']->translate(
'Nein'),
13272 ], $this->_site->admin[
'workflow'][
'enabled'] ? ([isset($child->extra[
'workflow_page']) ? $GLOBALS[
'auth']->translate(
'Ja') : $GLOBALS[
'auth']->translate(
'Nein')]) : [], $extra_values);
13280 $ego_output->setName($this->field[
'title'] .
'_Unterseiten.csv');
13281 $ego_output->download();
13294 foreach ($autofill as $type => $data) {
13295 $result[$type][
'value'] = preg_replace_callback(
'/%([a-z0-9_]+)/ims',
function($match) use ($info) {
13298 if ($info[
'pool']) {
13302 $key =
'description';
13305 $file = $this->getMediapool()->get($info[
'pool'], (
string) $info[
'dir']);
13310 case 'description':
13330 case 'description':
13331 if (!preg_match(
'/<[^>]+>/ms', $value)) {
13332 $value =
'<p>' . nl2br($value) .
'</p>';
13337 }, $data[
'value']);
13339 $result[$type][
'readonly'] = (bool) $data[
'readonly'];
13358 public function autoTranslate($param = [], $language =
'', $diff =
true, $force =
false, $glossary =
'', $source =
'', $target =
'', $original =
true) {
13359 $language = $language ?: $this->_site->language;
13363 !empty($GLOBALS[
'__auto_translate_no_diff'])
13365 $GLOBALS[
'__auto_translate_no_diff'] ===
true
13366 || in_array($language, explode(
',', (
string) $GLOBALS[
'__auto_translate_no_diff']))
13373 if (empty($param)) {
13375 'field' => $this->field,
13376 'extra' => $this->extra
13381 $language_standard = !empty($param[
'extra'][
'language_standard'])
13382 ? $param[
'extra'][
'language_standard']
13383 : $this->extra[
'language_standard'];
13384 if (empty($language_standard)) {
13385 $language_standard = $this->_site->site[
'default_language'];
13389 $source = $source ?: $language_standard;
13390 $target = $target ?: $language;
13395 && $_SERVER[
'HTTP_X_SOAP_CALL'] !==
'Replication'
13397 && !$this->archiveOnly
13398 && empty($param[
'field'][
'deleted'])
13399 && !$this->isWorkflowCopy()
13400 && !$this->isReleaseCopy()
13401 && !$this->isClone()
13409 $auto_translate =
function($check_diff) use (&$param, $language, $language_standard, $glossary, $source, $target, $original) {
13411 $GLOBALS[
'auto_translate_get_original_page'] =
true;
13413 $language_page = $this->getLanguagePage($language_standard, [
13414 'inactive' =>
true,
13415 'only_active' =>
false,
13416 'auth_or' =>
'1=1',
13417 'deleted_or' =>
'1=1'
13420 $language_page = $this;
13422 unset($GLOBALS[
'auto_translate_get_original_page']);
13423 if (!$language_page) {
13428 $fields = $this->getTranslationFields(
false);
13430 foreach ($fields as $field => $keys) {
13433 $result_values = [];
13435 foreach ($keys as $pattern) {
13437 if (is_array($results)) {
13438 foreach ($results as $key => $value) {
13443 && !empty($this->extra[
'auto_translated'])
13448 $param[
'extra'][
'auto_translated'][md5($key)] = $this->extra[
'auto_translated'][md5($key)];
13452 $result_keys[] = $key;
13453 $result_values[] = $value;
13460 if (
sizeof($result_values) > 0) {
13462 require_once
'translate/Ego_DeepL.php';
13463 $deepl =
new Ego_DeepL($this->getSite());
13464 $translated_values = $deepl->translate($source, $target, $result_values, $glossary);
13466 if (
sizeof($translated_values) !=
sizeof($result_values)) {
13468 foreach ($result_keys as $result_key) {
13473 foreach ($translated_values as $i => $translated_value) {
13475 $param[
'extra'][
'auto_translated'][md5($result_keys[$i])] = md5($result_values[$i]);
13482 $recursive =
function(&$value) use (&$recursive) {
13483 if (is_array($value)) {
13484 foreach ($value as &$v) {
13488 $value = preg_replace_callback(
'/\/?index\.php\?[^ "]+/i',
function($matches) {
13491 && $page->getSite()->name == $this->getSite()->name
13492 && $page->getSite()->language == $this->extra[
'language_standard']
13493 && $page->getLanguagePage($this->getSite()->language)
13495 return str_replace(
'lang=' . $page->getSite()->language,
'lang=' . $this->getSite()->language, $matches[0]);
13497 return $matches[0];
13501 foreach ([
'field',
'extra'] as $field) {
13502 $recursive($param[$field]);
13506 if (isset($param[
'field']) && isset($param[
'extra'])) {
13507 $param[
'field'][
'extra'] = serialize($param[
'extra']);
13511 if (isset($param[
'extra'])) {
13515 !empty($param[
'extra'][
'language_link'][$language])
13516 && $param[
'extra'][
'language_link'][$language] == 2
13519 $auto_translate(!$force && $param[
'extra'][
'language_link'][$language] != $this->extra[
'language_link'][$language]
13527 !empty($this->extra[
'language_link'][$language])
13528 && $this->extra[
'language_link'][$language] == 2
13531 $auto_translate($diff);
13550 empty($this->extra[
'language_link'][$this->_site->language])
13551 || $this->extra[
'language_link'][$this->_site->language] == 1
13566 'admin/translate.json',
13567 $this->field[
'type'] .
'/admin/translate.json'
13569 if ($json = $this->_site->getSiteFile($path)) {
13571 if (!empty($custom_conf[
'merge'])) {
13572 foreach ($custom_conf as $key => $value) {
13573 if (is_array($value)) {
13574 $custom_conf[$key] = array_merge($conf[$key] ?? [], $value);
13578 $conf = $custom_conf;
13583 'field' => [
'name',
'title',
'short',
'content'],
13584 'extra' => $conf[
'extra'] ?? [],
13585 'title' => $conf[
'title'] ?? []
13595 $cache_key =
'mandatory'.md5(serialize(array($this->_site->name, $this->field[
'type'])));
13596 $mandatory = $this->_site->getCacheEntry($cache_key);
13598 if ($mandatory ===
null) {
13602 $this->_site->getSiteFile(
'admin/mandatory.ini'),
13603 $this->_site->getSiteFile($this->field[
'type'] .
'/admin/mandatory.ini')
13606 $conf = parse_ini_file($file,
true);
13609 if (isset($conf[
'ignore_types']) && in_array($this->field[
'type'], explode(
',', $conf[
'ignore_types']))) {
13613 foreach ($conf as $key => $value) {
13614 if (is_array($value)) {
13615 if (isset($value[
'ignore_types']) && in_array($this->field[
'type'], explode(
',', $value[
'ignore_types']))) {
13620 $mandatory[$key] = $value;
13626 $this->_site->setCacheEntry($cache_key, $mandatory);
13639 $allUsers = $GLOBALS[
'auth']->user->getAllUsers([
'auth_or' =>
'1=1']);
13640 $groupRoleRights = $this->getRightsArray()[
'edit'] ?? [];
13641 $userRights = $this->getUsersArray()[
'edit'] ?? [];
13643 foreach ($allUsers as $user) {
13644 if (empty($userRights) && empty($groupRoleRights)) {
13649 foreach ($userRights as $userRight) {
13650 if ($user->field[
'user_id'] === $userRight[
'user_id']) {
13656 foreach ($groupRoleRights as $groupRoleRight) {
13657 if ($GLOBALS[
'auth']->hasPermission($groupRoleRight[
'group_id'], $groupRoleRight[
'role_id'],
false, $user->field[
'user_id'])) {
13674 '@context' =>
'https://schema.org',
13675 '@type' =>
'WebPage',
13676 'name' => $this->field[
'title'],
13677 'description' => $this->extra[
'meta_descr'] ?: $this->field[
'short'],
13678 'mainEntityOfPage' => [
13679 '@type' =>
'WebPage',
13680 '@id' => $this->getFrontendUrl([
'return_absolute' => true])
13691 $site = $this->getSite();
13694 $file_name = $site->getSiteFile($this->field[
'type'] .
'/admin/navigation.ini');
13696 $file_name = $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'type/site/page/admin/navigation.ini';
13699 if (!$file_name || !file_exists($file_name)) {
13700 $file_name = $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'/type/site/multimedia/category/admin/navigation.ini';
13704 if ($file_name = $site->getSiteFile($this->field[
'type'] .
'/admin/navigation.ini')) {
13705 $this->mergeTabs($file_name, $navigation);
13708 $this->mergeTabs($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'type/site/page/admin/navigation.ini', $navigation);
13712 if ($file_name = $site->getSiteFile(
'admin/navigation.ini', [
'module',
'system',
'global'])) {
13713 $this->mergeTabs($file_name, $navigation);
13717 if ($site->globalAllowed()) {
13718 $file_name = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/navigation.ini';
13721 $this->mergeTabs($file_name, $navigation);
13725 return !empty($navigation[
'content']);
13735 public function mergeTabs(
string $file_name, array &$navigation) {
13736 $navigation2 = parse_ini_file($file_name,
true);
13738 foreach ($navigation2 as $key => $value) {
13739 if ($navigation[$key]) {
13745 if ($value[
'ignore_sites']) {
13746 $sites = explode(
',', $value[
'ignore_sites']);
13747 if (in_array($this->getSite()->name, $sites)) {
13753 if ($value[
'ignore_types']) {
13754 $types = explode(
',', $value[
'ignore_types']);
13756 if (in_array($this->field[
'type'], $types)) {
13762 !empty($value[
'if'])
13767 if (strpos($value[
'if'],
'!') === 0) {
13769 $value[
'if'] = substr($value[
'if'], 1);
13772 if (strpos($value[
'if'],
'?') === 0) {
13774 $value[
'if'] = substr($value[
'if'], 1);
13777 [$field_key, $value_to_test] = explode(
'=', $value[
'if'], 2);
13778 [$field, $key2] = explode(
'.', $field_key, 2);
13780 if (strpos($key2,
'.') !==
false) {
13783 $test_value = $this->{$field}[$key2];
13789 (preg_match($value_to_test, $test_value) && !$invert)
13790 || (!preg_match($value_to_test, $test_value) && $invert)
13793 $navigation[$key] = $value;
13796 && !empty($value_to_test)
13798 ($test_value == $value_to_test && !$invert)
13799 || ($test_value != $value_to_test && $invert)
13802 $navigation[$key] = $value;
13805 && empty($value_to_test)
13807 (isset($test_value) && !$invert)
13808 || (empty($test_value) && $invert)
13811 $navigation[$key] = $value;
13814 $navigation[$key] = $value;
13829 if ($this->field[
'deleted']) {
13832 'text' => $GLOBALS[
'auth']->translate(
'Die Seite ist gelöscht.')
13837 if (!$this->field[
'deleted'] && !$this->isActive()) {
13840 'text' => $GLOBALS[
'auth']->translate(
'Die Seite ist inaktiv.')
13845 if (!$GLOBALS[
'egotec_conf'][
'liveserver'] && $this->_site->hasLiveserver() && ($this->field[
'nav_hide']&2) == 2) {
13847 'type' =>
'warning',
13848 'text' => $GLOBALS[
'auth']->translate(
'Die Seite wird nicht auf den Liveserver übertragen.')
13853 if (!empty($params[
'type']) && !in_array($this->field[
'type'], explode(
',', $params[
'type']))) {
13855 'type' =>
'warning',
13856 'text' => $GLOBALS[
'auth']->translate(
'Der ausgewählte Seitentyp stimmt nicht.')
13861 if (!empty($params[
'view']) && $this->hasRightsOn(
'view')) {
13863 'type' =>
'warning',
13864 'text' => $GLOBALS[
'auth']->translate(
'Die Seite hat Ansichtsrechte.')
static getUserRecord($user_id)
static add(callable $call, $params=array(), $first=false)
static start($table='', $param=[], $checkHealthy=false)
static filterNonUtf8($s, $substitute="", $strict=false)
static urltopage($url, $params=array(), $only_site=false, $error_page=false, $commit_params=false)
static getUrlParams($url='')
static exec(String $command, Array $params=array(), &$output=null, &$return_var=null, $log=true)
static getMimeTypes($ext='')
static file_put_contents($filename, $data, $flags=0, $context=null)
static encode_path($url, $id=0)
static getAssocValue($a, $k)
static getAssocValues($a, $k, $o='')
static cleanTypes($value)
static getChecksum($value)
static getDefaultLocalServerIps()
static deldir($location, $del=true, $without='', $rename=true)
static createCSV($path, $data, $delimiter=',', $enclosure='"', $escape_char = '\'')
const REGEX_EMAIL_OPTIONAL
static checkLicence($ini_path)
static dateEncode($string)
static getCluster($site=null)
static includeHtml($src, $once=true)
static isDevMode($ignore=true)
static getFiles($type, $name, $path, $skip=array(), $parent='', $return_path=false, $get_variants=true)
static getUrlInfo($url, $encode=false)
static getAllSites($username='', $perm='', $table=false, $type='')
static file_exists($file)
static setAssocValue(&$a, $k, $v)
static mkdir($dir, $mode=0755, $recursive=true)
static isEmptyContent($str)
static file_get_contents($filename, $utf8=true, $context=null)
static getJSON($path, $values=[], $combine=false, $ignore=[], $replace=true, $no_cache=false)
static scan(string $path, bool $remove=false, bool $recursive=true, ?array &$summary=[])
static stringEncode($string, $from='UTF-8', $to='UTF-8')
static copy($src, $dest, $except='', $useLinks=false, $noArchive=false, $preserveDate=false)
addResolution(int $width, int $height)
static unserialize($session_value)
__call($function, $params)
getArchivePages($query=array())
createEditField($name, $setting=array(), $empty=false, $orient='', $index=0, $block='', $replace=false)
createClone($page, $children=false, $rights=false, $release=false, $multiple=true)
__construct(Site $site, $field, $archive=false)
newChild($field=array(), $extra=array(), $inherit=true)
download($recursive=true, $target_dir='', $write_log=true)
mergeTabs(string $file_name, array &$navigation)
getAutoFill($autofill, $info=[])
exportChildrenAsCSV(array $ids, bool $downloadAll=false)
updateUrls($verbose=false, $domain=null, $force_recursive=false, $called_recursive=false)
destroy($force=false, $recursive=true, $destroy_links=true)
_getAncestorsIds($page, $query, $param=array())
isFrontendAdmin($check_rights=true)
static createIdentity($params)
hasUserRight(string $right_type, string $user_id)
getClones($target_site='all')
_updateRights($rights, $asis=false)
getFirstMediaValue(string $name, string $type='image', string $orient=null, bool $verbose=false)
updateFile($source, $name='')
removeSelectedListItem($params)
getLinkedPages($recursive=false, $self=true)
getTranslationFields($check=true)
autoTranslate($param=[], $language='', $diff=true, $force=false, $glossary='', $source='', $target='', $original=true)
updateDocumentFiles($remove=false)
getIconUrl($test=false, $folder=false, $quarantine=true)
static byIdentity($identity, $param=array(), $site=null)
getFirstValue($name, $orient=null, $verbose=false)
getLinks($recursive=false, $c_date=false)
extractFile($source, &$images=array())
merge($id, $replicate=true)
getListItems($where='', $no_limit=false)
getFirstBlockValue($block, $name, $orient=null, $verbose=false)
_updateKeywords($asis=false)
validateFile($source, $name='', $form=array(), $files_conf=array())
_updateChildren($children, $merge=true)
setCacheEntry($key, $value)
getThumbnail($width, $height=0, $pool='', $dir='', $params=[])
newFile($source, $name, $options=array(), $suffix='')
hasFile($name, $suffix='')
setTableSuffix($suffix='')
_updateField($field, $update=true, $asis=false, $silent=false)
_createChildClones($parent)
getBlockValue($block, $name, $orient=null, $index=null, $verbose=false)
_createClone($page, $children=false, $rights=false, $release=false, $multiple=true)
getArchivePage($c_date='')
getExtraValues(array $conf=[], bool $csv=false)
isCurrentPage($lang=false)
hasRights($rights, $user_id=false, $cache=true)
replicate($method,... $params)
fetch($params=array(), $outputfilter=false, $script=true, $includes=true, $variant='')
undelete($recursive=false, $query=array())
updateLinks($inherited=true, $cleared=false)
inheritExtra($keys, $mixed=false, $types=array(), $no_rights=true)
copyTo($id, $recursive=false, $params=array(), &$copied_pages=array())
getEditFieldSettings($name='')
getBlockValues($block, $name, $orient=null, $verbose=false)
_destroyEntry($recursive=true)
getValues($name, $orient=null, $verbose=false)
getValue($name, $orient=null, $index=null, $verbose=false)
getTemplateBlock($block='template', $orient='', $index=0, $empty=false, $replace=false, $variant='', $removable=true, $do_save=false, $page_frame=false, $element_types=[], &$smarty=null)
static isIdentity($identity)
updateExtra($extra, $matrix_flag=true, $asis=false, $silent=false)
_deleteCloneKeywords($clone_check, $clone_to_delete)
getUsersArray($perm_type='')
_updateCloneKeywords($original, $clone)
_destroyChildClones($parent)