5 require_once
'base/Page_Iterator.php';
6 require_once
'base/Mediapool.php';
28 const CACHE_BROWSER = 1;
29 const CACHE_PROXY = 2;
30 const CACHE_SERVER = 4;
31 const ACTIVE_FLAG = 0;
32 const INACTIVE_FLAG = 1;
33 const RELEASE_FLAG = 2;
34 const IDENTITY_SEPARATOR =
'.';
35 const VIDEO_RESOLUTIONS = array(
47 private $tableSuffix =
'';
48 public $mainOrient =
'center';
50 protected $typeInfo = array();
55 public $archiveOnly =
false;
57 private $lastChangeDate =
'';
58 private $frontendActive =
false;
59 private $editFields = array();
61 public $conf = array();
75 $this->field = $field;
76 $this->extra = $this->field[
'extra']?unserialize($this->field[
'extra']):array();
77 $this->lastChangeDate = $this->field[
'c_date'];
79 if ($_REQUEST[
'c_date'] && $this->field[
'id']) {
80 $c_date = $_REQUEST[
'c_date'];
81 if (is_numeric($c_date)) {
82 $c_date = date(
'Y-m-d H:i:s', $_REQUEST[
'c_date']);
84 $db = new_db_connection(array(
85 'table' => $this->_site->pageTable.
'_v',
86 'where' =>
"id=".$this->field[
'id'].
" AND c_date<=:cdate",
87 'order' =>
'c_date DESC',
89 'bind' => array(
'cdate' => $c_date)
91 if ($db->nextRecord()) {
92 $this->field = $db->Record;
93 $this->extra = $db->Record[
'extra']?unserialize($db->Record[
'extra']):array();
96 $this->lastChangeDate = $this->field[
'c_date'];
99 && $_REQUEST[
'id'] == $field[
'id']
100 && $_REQUEST[
'site'] == $site->name
101 && !$GLOBALS[
'frontend_admin']
102 && $_SESSION[
'egotec_page_preview'][$identity = $this->getIdentity()]
105 $this->field = $_SESSION[
'egotec_page_preview'][$identity][
'field'];
106 $this->extra = $_SESSION[
'egotec_page_preview'][$identity][
'extra']?$_SESSION[
'egotec_page_preview'][$identity][
'extra']:array();
107 $this->lastChangeDate = $this->field[
'c_date'];
111 $this->isPublicSave()
112 && ($GLOBALS[
'is_admin'] || $GLOBALS[
'frontend_admin'] || $_REQUEST[
'preview'])
113 && !empty($GLOBALS[
'site'])
114 && $this->_site->name == $GLOBALS[
'site']->name
115 && in_array($this->field[
'id'], array($_REQUEST[
'list'], $_REQUEST[
'id'], $_REQUEST[
'field'][
'id']))
117 $db = new_db_connection();
119 'table' => $this->_site->pageTable.
'_v',
120 'where' =>
'id = :id',
121 'order' =>
'c_date DESC',
124 'id' => $this->field[
'id']
127 if ($db->nextRecord() && $db->Record[
'c_date'] > $this->field[
'c_date']) {
129 $this->field = $db->Record;
130 $this->extra = $this->field[
'extra']?unserialize($this->field[
'extra']):array();
131 $this->archiveOnly =
true;
134 $current_dir = $this->getMediapool()->dir().$this->getMediapool()->currentDir;
136 $archive_dir = $this->getMediapool()->dir().$this->getMediapool()->currentDir;
149 $this->extra[
'language_standard']
150 && !in_array($this->extra[
'language_standard'], $this->_site->getLanguages())
152 $this->extra[
'language_standard'] = $this->_site->language;
153 $this->updateExtra($this->extra,
true,
true);
158 !empty($GLOBALS[
'frontend_admin'])
159 && !empty($GLOBALS[
'smarty'])
160 && $this->isCurrentPage(
true)
162 $this->frontendAdmin();
165 if ($this->extra[
'mime_type'] && !is_string($this->extra[
'mime_type'])) {
166 $this->extra[
'mime_type'] =
'';
168 $this->field[
'cache'] = (int)$this->field[
'cache'];
171 $this->_loadConfig();
174 if (empty($this->extra[
'_layout'])) {
175 $this->extra[
'_layout'] = $this->conf[
'default_layout'];
179 if (is_array($this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'])) {
180 foreach ($this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'] as $orient => $info) {
181 if (!empty($info[
'default']) && $info[
'static']) {
182 if (!is_array($this->extra[
'_blocks'])) {
183 $this->extra[
'_blocks'] = array();
185 $this->extra[
'_blocks'][$orient] = explode(
',', $info[
'default']);
188 $this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'][$orient][
'allow'] = implode(
',', array_unique($this->extra[
'_blocks'][$orient]));
189 unset($this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'][$orient][
'disallow']);
194 if (is_array($this->extra[
'_blocks'])) {
196 if (isset($this->conf[
'layouts'])) {
198 $validate =
function ($block, $orient, $type) use (&$validate) {
199 $info = $this->conf[
'layouts'][$this->extra[
'_layout']][
'blocks'][$orient];
200 if (isset($info[$type])) {
201 $result = $type ==
'allow' ? false :
true;
202 foreach (explode(
',', $info[$type]) as $name) {
205 if ($name[0] ==
'@') {
206 if ($validate($block, substr($name, 1),
'allow')) {
210 } elseif ($block == $name) {
216 if ($name[0] ==
'@') {
217 if (!$validate($block, substr($name, 1),
'disallow')) {
221 } elseif ($block == $name) {
232 foreach ($this->extra[
'_blocks'] as $orient => $blocks) {
233 if (is_array($blocks)) {
234 foreach ($blocks as $index => $block) {
236 !$validate($block, $orient,
'allow')
237 || !$validate($block, $orient,
'disallow')
240 && $this->conf[
'no_template']
241 && $this->conf[
'blocks'][
'template'][
'removable'] ===
true 244 if (isset($this->extra[
'_blocks'][$orient][$index])) {
245 unset($this->extra[
'_blocks'][$orient][$index]);
247 if (isset($this->extra[
'_contents'][$orient][$index])) {
248 unset($this->extra[
'_contents'][$orient][$index]);
257 foreach ($this->extra[
'_blocks'] as $orient => $blocks) {
258 if (is_array($blocks)) {
261 foreach ($blocks as $index => $block) {
262 if (isset($this->extra[
'_contents'][$orient][$index])) {
264 if ($new_index >= $num + 1) {
266 $this->extra[
'_blocks'][$orient][$new_index] = $block;
267 unset($this->extra[
'_blocks'][$orient][$index]);
269 $contents[$new_index] = $this->extra[
'_contents'][$orient][$index];
270 } elseif (isset($this->conf[
'blocks'][$block][
'default'][$orient])) {
271 $contents[$index] = $this->conf[
'blocks'][$block][
'default'][$orient];
275 $this->extra[
'_contents'][$orient] = $contents;
281 if (isset($this->extra[
'mediapool']) && !is_array($this->extra[
'mediapool'])) {
282 $this->extra[
'mediapool'] = array();
291 private function _loadConfig() {
293 $cache_key =
'pageConf'.md5(serialize(array($this->field[
'type'], $_SERVER[
'REQUEST_SUFFIX'])));
294 $this->conf = $this->_site->getCacheEntry($cache_key);
295 if ($this->conf === null) {
298 $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'page/conf.json',
299 $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'type/site/' . $this->field[
'type'] .
'/admin/conf.json' 302 foreach (array(
'', $_SERVER[
'REQUEST_SUFFIX']) as $suffix) {
303 if (!empty($suffix) && trim(mb_strtolower(ltrim($suffix,
'.'))) !=
'html') {
304 $suffix =
'.' . mb_strtolower(ltrim($suffix,
'.'));
306 if ($suffix ==
'.html') {
311 if ($this->_site->theme) {
312 $confs[] = $GLOBALS[
'egotec_conf'][
'pub_dir'] .
'theme/' . $this->_site->theme .
'/site/admin/conf' . $suffix .
'.json';
316 if ($this->_site->globalAllowed()) {
317 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/conf.json';
320 if ($this->_site->theme) {
321 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/' . $this->_site->theme . $suffix .
'.json';
325 if ($this->_site->skin) {
326 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/admin/' . $this->_site->skin . $suffix .
'.json';
331 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] . $this->_site->name .
'/admin/conf' . $suffix .
'.json';
334 if ($this->_site->theme) {
335 $confs[] = $GLOBALS[
'egotec_conf'][
'pub_dir'] .
'theme/' . $this->_site->theme .
'/site/' . $this->field[
'type'] .
'/admin/conf' . $suffix .
'.json';
339 if ($this->_site->globalAllowed()) {
340 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/' . $this->field[
'type'] .
'/admin/conf' . $suffix .
'.json';
343 if ($this->_site->theme) {
344 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/' . $this->field[
'type'] .
'/admin/' . $this->_site->theme . $suffix .
'.json';
348 if ($this->_site->skin) {
349 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] .
'_global/' . $this->field[
'type'] .
'/admin/' . $this->_site->skin . $suffix .
'.json';
354 $confs[] = $GLOBALS[
'egotec_conf'][
'site_dir'] . $this->_site->name .
'/' . $this->field[
'type'] .
'/admin/conf' . $suffix .
'.json';
357 $this->conf = array();
358 $confs = array_unique($confs);
359 foreach ($confs as $file) {
361 $this->conf =
Ego_System::getJSON($file, $this->conf,
true, [
'plugins',
'toolbar',
'menubar',
'editor.options']);
364 if (empty($this->conf[
'default_layout'])) {
365 $this->conf[
'default_layout'] =
'default';
367 unset($this->conf[
'site'], $this->conf[
'admin']);
368 $this->_site->setCacheEntry($cache_key, $this->conf);
370 if ($this->conf[
'main_orient']) {
372 $this->mainOrient = $this->conf[
'main_orient'];
383 public function __call($function, $params) {
385 if (strpos($function,
'pool') === 0 && is_callable($call = [$this->_pool, lcfirst(substr($function, 4))])) {
386 egotec_deprecated_log(
'18.4',
'Please use getMediapool() and the Mediapool object\'s methods.');
387 return call_user_func_array($call, $params);
391 $key =
'Page.magic'.md5(serialize(array($function, $this->field[
'type'])));
392 $magic_file = $this->_site->getCacheEntry($key);
393 if ($magic_file === null) {
395 "{$this->field['type']}/Page.{$function}.php" 397 $types = explode(
'/', $this->field[
'type']);
398 while (array_pop($types)) {
399 if (!empty($types)) {
400 $files[] = implode(
'/', $types) .
"/Page.{$function}.php";
403 $files[] =
"Page.{$function}.php";
404 foreach ($files as $file) {
405 if ($found = $this->_site->getSiteFile($file)) {
406 $magic_file = $found;
407 $this->_site->setCacheEntry($key, $magic_file);
412 if (empty($magic_file)) {
413 $magic_file = $GLOBALS[
'egotec_conf'][
'lib_dir'] .
'base/Page.' . $function .
'.php';
415 if (!file_exists($magic_file)) {
416 throw new Exception(
"Method 'Page.$function' not found");
418 require_once($magic_file);
419 return call_user_func($function, $this, $params);
428 return $this->tableSuffix;
438 $this->tableSuffix = $suffix;
448 require_once(
'auth/Auth.php');
458 private function _archiveEntry($asis =
false) {
459 if (!$this->getTableSuffix()) {
460 $table = $this->_site->pageTable.
'_v';
461 $db = new_db_connection();
463 $field = $this->field;
467 $field[
'c_date'] = date(
'Y-m-d H:i:s');
468 $extra = unserialize($field[
'extra']);
469 $extra[
'_asis'] = $this->field[
'c_date'];
470 $field[
'extra'] = serialize($extra);
473 $field[
'title'] = $field[
'title'] ? $field[
'title'] :
'';
474 $field[
'a_user'] = $field[
'a_user'] ? $field[
'a_user'] :
'';
475 $field[
'c_user'] = $field[
'c_user'] ? $field[
'c_user'] :
'';
476 unset($field[
'parents']);
480 'primary' => array(
'id',
'c_date'),
485 $this->getMediapool()->archive($field[
'c_date']);
498 private function _insertEntry($field, $lang=
'') {
499 if (!isset($field[
'id']) || $field[
'id']<=0) {
500 $field[
'id'] = $this->_site->nextId();
502 unset($field[
'parents']);
505 foreach ($field as $key => $value) {
506 if (is_string($value)) {
507 if ($key ==
'extra') {
516 foreach (array(
'name',
'title') as $key) {
517 if (isset($field[$key])) {
518 $field[$key] = trim($field[$key]);
522 $db = new_db_connection();
524 'table' => $lang?$this->_site->name.
'_'.$lang:$this->_site->pageTable.$this->getTableSuffix(),
528 $site = clone $this->_site;
529 $site->setLanguage($lang);
531 $site = $this->_site;
533 $class = $site->getPageClass($field[
'type']);
534 $child =
new $class($site, $field);
535 $child->_archiveEntry();
536 if (!isset($field[
'inactive']) || !$field[
'inactive']) {
537 $this->_clearCache();
550 private function _changeEntry($field = array(), $asis =
false) {
551 $db = new_db_connection();
553 $field[
'c_user'] = $GLOBALS[
'auth']->getId() ? $GLOBALS[
'auth']->getId() :
'';
554 $field[
'c_date'] = date(
'Y-m-d H:i:s');
556 unset($this->field[
'idx']);
557 unset($field[
'idx']);
558 if (!isset($field[
'id'])) {
559 $field[
'id'] = $this->field[
'id'];
561 if (isset($field[
'nav_hide']) && !is_numeric($field[
'nav_hide'])) {
562 $field[
'nav_hide'] = 0;
566 if (isset($field[
'type'])) {
567 $this->field[
'type'] = $field[
'type'];
569 if (($info = $this->getTypeInfo()) && isset($info[
'nav_hide'])) {
570 $field[
'nav_hide'] = (int) $info[
'nav_hide'];
574 foreach (array(
'name',
'title') as $key) {
575 if (isset($field[$key])) {
576 $field[$key] = trim($field[$key]);
581 if (isset($field[
'name']) && $field[
'name'] ==
'') {
582 $field[
'name'] = isset($field[
'title']) && $field[
'name'] !=
'' 588 if (isset($field[
'release_from']) && empty($field[
'release_from'])) {
589 $field[
'release_from'] =
'0000-00-00 00:00:00';
591 if (isset($field[
'release_until']) && empty($field[
'release_until'])) {
592 $field[
'release_until'] =
'0000-00-00 00:00:00';
596 if ($field[
'id'] == $this->_site->rootId) {
597 $field[
'inactive'] = self::ACTIVE_FLAG;
601 $cache_complete = isset($field[
'deleted'])
602 && $this->field[
'type'] ==
'multimedia/image' 603 && $this->field[
'deleted'] != $field[
'deleted'];
606 foreach ($field as $key => $value) {
607 if (is_string($value)) {
608 if ($key ==
'extra') {
616 if (!$this->archiveOnly) {
619 'table' => $this->_site->pageTable.$this->getTableSuffix(),
621 'where' =>
'id='.$this->field[
'id']
626 $this->isPublicSave()
627 && $this->getMediapool()->currentDir !=
'current' 633 @rename($this->getMediapool()->dir().
'current', $this->getMediapool()->dir().
'current.backup');
636 Ego_System::copy($this->getMediapool()->dir().$this->getMediapool()->currentDir, $this->getMediapool()->dir().
'current',
'',
true);
640 @rename($this->getMediapool()->dir().
'current.backup', $this->getMediapool()->dir().
'current');
642 Ego_Queue::add(array(
'Ego_System',
'deldir'), array($this->getMediapool()->dir().
'current.backup'));
645 Ego_Queue::add(array($this,
'reset'), array(
false));
648 $this->_clearCache($cache_complete);
649 $this->field = array_merge($this->field, $field);
650 if (isset($field[
'extra'])) {
651 $extra = unserialize($field[
'extra']);
652 $this->extra = $extra?$extra:array();
667 $ancestors_ids = array();
669 $cache_key =
'_getAncestorsIds.' 672 .($query ? md5(serialize($query)) :
'-')
673 .($param ? md5(serialize($param)) :
'-');
674 $cache_val = $page->getSite()->getCacheEntry($cache_key);
678 foreach ($page->getParents($query, $param) as $parent) {
679 $ancestors_ids[] = $parent->field[
'id'];
680 $ancestors_ids = array_merge($ancestors_ids, $this->_getAncestorsIds($parent, $query, $param));
682 $page->getSite()->setCacheEntry($cache_key, $ancestors_ids);
684 return $ancestors_ids;
699 private function _getDescendantsIds($page, $query=array(), $param=array(), &$descendants=array()) {
700 $query[
'hash'].=
':'.$page->field[
'id'];
701 foreach ($page->getChildren($query, $param) as $child) {
702 if (in_array($child->field[
'id'], $descendants)) {
706 $descendants[] = $child->field[
'id'];
707 if ($child->field[
'has_children']) {
708 $this->_getDescendantsIds($child, $query, $param, $descendants);
721 private function _getRights($perm_type=
'') {
722 return new_db_connection(array(
724 'from' => $this->_site->pageTable.
'_rights',
725 'where' =>
"page_id=".$this->field[
'id'].($perm_type?
" AND perm='".$perm_type.
"'":
"")
736 private function _getUsers($perm_type=
'') {
737 return new_db_connection(array(
739 'from' => $this->_site->pageTable.
'_users',
740 'where' =>
"page_id=".$this->field[
'id'].($perm_type?
" AND perm='".$perm_type.
"'":
'')
752 private function _getEmptyEntry($new=array()) {
754 unset($new[
'parents']);
756 $user_id = $GLOBALS[
'auth']->getId() ? $GLOBALS[
'auth']->getId() :
'';
757 $date = date(
'Y-m-d H:i:s');
760 'title' =>
'Neue Seite',
766 'cache' => self::CACHE_BROWSER|self::CACHE_PROXY|self::CACHE_SERVER,
767 'inactive' => self::INACTIVE_FLAG,
768 'release_from' =>
'0000-00-00 00:00:00',
769 'release_until' =>
'0000-00-00 00:00:00',
774 'a_user' => $user_id,
775 'c_user' => $user_id,
777 'children_order'=>
'children',
778 'workflow_state'=> 0,
783 foreach ($new as $key => $value) {
784 if (!is_null($value)) {
785 $empty[$key] = $value;
799 return $this->_site->hasRightsOnId($this->field[
'id'], $rights, $user_id);
810 $rights = $this->getRightsArray($perm);
811 if (!empty($rights[$perm])) {
812 foreach ($rights[$perm] as $right) {
813 if ($right[
'group_id'] !=
'*' && $right[
'role_id'] !=
'*') {
820 $users = $this->getUsersArray($perm);
821 if (!empty($users[$perm])) {
822 foreach ($users[$perm] as $user) {
823 if ($user[
'user_id'] !=
'*') {
842 function newChild($field = array(), $extra = array(), $inherit=
true) {
843 if ($field[
'deleted'] == 1) {
847 if (!$extra[
'release_id'] && $this->_site->admin[
'multi_lang'][
'auto_link']) {
848 $extra[
'language_standard'] = $this->_site->language;
849 foreach ($this->_site->getLanguages() as $lang) {
850 $extra[
'language_link'][$lang] = 1;
852 } elseif(!$extra[
'language_standard']) {
853 if ($this->extra[
'language_standard'] == $this->_site->language) {
855 $extra[
'language_standard'] = $this->extra[
'language_standard'];
856 $extra[
'language_link'] = $this->extra[
'language_link'];
857 if (!$extra[
'language_standard']) {
858 $extra[
'language_standard'] = $this->_site->language;
860 if (!$extra[
'language_link']) {
861 $extra[
'language_link'] = array();
862 foreach ($this->_site->getLanguages() as $lang) {
863 if ($lang == $extra[
'language_standard']) {
864 $extra[
'language_link'][$lang] = 1;
866 $extra[
'language_link'][$lang] = 0;
872 $extra[
'language_standard'] = $this->_site->language;
878 if ($this->_site->admin[
'workflow'][
'enabled'] && $this->field[
'workflow'] && !isset($field[
'workflow'])) {
879 $field[
'workflow'] = $this->field[
'workflow'];
880 if ($this->extra[
'workflows']) {
881 $extra[
'workflows'] = $this->extra[
'workflows'];
886 $field[
'nav_hide'] = ((int) $field[
'nav_hide']) | ((int) $this->field[
'nav_hide']);
890 $this->field[
'type'] == $field[
'type']
891 || (!isset($field[
'type']) && $this->field[
'type'] ==
'page')
893 if (!empty($this->extra[
'_template']) && empty($extra[
'_template'])) {
894 $extra[
'_template'] = $this->extra[
'_template'];
896 if (!empty($this->extra[
'_style']) && empty($extra[
'_style'])) {
897 $extra[
'_style'] = $this->extra[
'_style'];
902 if (empty($extra[
'ip_rights']) && !empty($this->extra[
'ip_rights'])) {
903 $extra[
'ip_rights'] = $this->extra[
'ip_rights'];
906 $field = $this->_getEmptyEntry($field);
908 $field[
'extra'] = serialize($extra);
909 $new_page = $this->_insertEntry($field);
910 $field[
'id'] = $new_page->field[
'id'];
912 !$new_page->isWorkflowCopy()
913 && !$new_page->isReleaseCopy()
914 && !$new_page->isClone()
915 && is_array($new_page->extra[
'language_link'])
917 foreach ($this->_site->getLanguages() as $lang) {
918 if ($lang != $this->_site->language && $new_page->extra[
'language_link'][$lang]) {
919 $lang_page = $new_page->getLanguagePage($lang, array(
'auth_or' =>
'1=1'));
923 $lang_parent = $this->getLanguagePage($lang, array(
'auth_or' =>
'1=1',
'deleted_or' =>
'1=1'));
924 if ($lang_parent && $lang_parent->field[
'deleted']) {
925 $lang_parent->undelete();
927 $lang_page = $this->_insertEntry($field, $lang);
928 $lang_page->addParent($this->field[
'id']);
930 $new_rights = $this->getRightsArray();
931 $new_rights[
'edit'] = $new_rights[
'child'];
932 $new_users = $this->getUsersArray();
933 $new_users[
'edit'] = $new_users[
'child'];
934 $lang_page->setRightsArray($new_rights);
935 $lang_page->setUsersArray($new_users);
939 $new_page->addParent($this->field[
'id']);
940 $this->message = $GLOBALS[
'auth']->translate(
'Neuer Untermenüpunkt wurde erstellt!');
941 if ($new_page->field[
'inactive']) {
942 $this->message.=
"\n".$GLOBALS[
'auth']->translate(
'Diese Seite ist inaktiv (nicht online verfügbar).');
944 $this->message.=
"\n".$GLOBALS[
'auth']->translate(
'Diese Seite ist freigeschaltet.');
948 $new_rights = $this->getRightsArray();
949 $new_rights[
'edit'] = $new_rights[
'child'];
950 $new_users = $this->getUsersArray();
951 $new_users[
'edit'] = $new_users[
'child'];
952 $new_page->setRightsArray($new_rights);
953 $new_page->setUsersArray($new_users);
954 $new_page->updateIndex();
955 $new_page->hookUpdate(
'newchild');
956 $new_page->hookUpdate();
968 public function hasFile($name, $suffix =
'') {
969 $children = $this->getChildren(array(
970 'where' =>
"name = :name AND type IN ('multimedia/file', 'multimedia/image')",
976 'only_active' =>
false 978 if ($page = $children->nextPage()) {
979 if (!$suffix || $page->extra[
'image_type'] == $suffix) {
995 public function newFile($source, $name, $options = array(), $suffix =
'') {
996 if ($this->_site->site[
'type'] ==
'media' && $this->validateFile($source, $name)) {
999 require_once(
'media/functions.php');
1000 require_once(
'base/Ego_MimeType.php');
1003 $GLOBALS[
'mediaType'] = $path_info[
'extension'];
1006 $mime_type = $mime->autoDetect($source);
1008 $is_image = !(strpos($mime_type,
'image') ===
false);
1011 if ($field[
'extra']) {
1012 $extra = $field[
'extra'];
1016 $options[
'name'] ? $options[
'name'] : $name)));
1018 $options[
'title'] ? $options[
'title'] : $field[
'name'])));
1023 if(!empty($options[
'extra'][
'mime_type'])) {
1024 $extra[
'mime_type'] = $options[
'extra'][
'mime_type'];
1026 $extra[
'mime_type'] = $mime_type;
1029 $extra[
'image_type'] = $suffix;
1032 if ($path_info[
'extension']) {
1033 $extra[
'image_type'] = $path_info[
'extension'];
1036 if (!$GLOBALS[
'mime2ext']) {
1039 $extra[
'image_type'] = $GLOBALS[
'mime2ext'][$extra[
'mime_type']];
1043 require_once(
'base/Ego_Image.php');
1045 $imageTransform->load($source);
1047 if (!minimumImageDimensions($imageTransform, $this->_site)) {
1050 scaleImageOnUpload($imageTransform, $this->_site);
1052 $extra[
'origImgWidth'] = $imageTransform->getImageWidth();
1053 $extra[
'origImgHeight'] = $imageTransform->getImageHeight();
1056 getFileInfo($source, $extra);
1059 $field[
'type'] =
'multimedia/'.($is_image ?
'image' :
'file');
1060 $field[
'inactive'] = self::ACTIVE_FLAG;
1061 $field[
'parents'] =
','.trim($this->field[
'id'],
',').
',';
1064 if (!$is_image && $GLOBALS[
'egotec_conf'][
'openoffice'][
'active']) {
1065 require_once(
'openoffice/converter.php');
1066 $field[
'content'] = convert_content($source, $extra[
'image_type'], $extra[
'mime_type']);
1068 $child = $this->newChild($field, $extra);
1071 $media_dir = $GLOBALS[
'egotec_conf'][
'var_dir'].
'media'.DIRECTORY_SEPARATOR.$this->_site->name;
1076 $dest = $media_dir.DIRECTORY_SEPARATOR.$child->getMediaFilename(
true);
1085 $media_dir.DIRECTORY_SEPARATOR.$child->getMediaFilename(
1087 '_'.strtotime($child->field[
'c_date'])
1105 $id = $this->field[
'id'];
1106 $dir = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'import/zip/';
1109 $file = tempnam($dir,
'ZIP_').
'.zip';
1113 if (@move_uploaded_file($source, $file)) {
1114 require_once(
'media/functions.php');
1115 require_once(
'Archive/Zip.php');
1116 $zip =
new Archive_Zip($file);
1120 chdir($GLOBALS[
'egotec_conf'][
'bin_dir'].
'admin');
1121 $num = GetDir($dest,
'', $this->field[
'id'],
true);
1124 if (isset($GLOBALS[
'_GetDir_firstId'])) {
1125 $id = $GLOBALS[
'_GetDir_firstId'];
1126 unset($GLOBALS[
'_GetDir_firstId']);
1129 return $this->_site->getPage($id);
1140 if (!$this->validateFile($source, $name)) {
1144 require_once(
'media/functions.php');
1145 require_once(
'base/Ego_MimeType.php');
1148 $GLOBALS[
'mediaType'] = $path_info[
'extension'];
1151 $mime_type = $mime->autoDetect($source);
1152 $is_image = !(strpos($mime_type,
'image') ===
false);
1155 $extra = $this->extra;
1157 $extra[
'mime_type'] = $mime_type;
1159 if ($path_info[
'extension']) {
1160 $extra[
'image_type'] = $path_info[
'extension'];
1163 if (!$name || !$extra[
'image_type']) {
1165 if (!$GLOBALS[
'mime2ext']) {
1168 $extra[
'image_type'] = $GLOBALS[
'mime2ext'][$extra[
'mime_type']];
1172 $field[
'type'] =
'multimedia/'.($is_image ?
'image' :
'file');
1175 require_once(
'base/Ego_Image.php');
1177 $imageTransform->load($source);
1179 if (!minimumImageDimensions($imageTransform, $this->_site)) {
1182 scaleImageOnUpload($imageTransform);
1184 $extra[
'origImgWidth'] = $imageTransform->getImageWidth();
1185 $extra[
'origImgHeight'] = $imageTransform->getImageHeight();
1188 getFileInfo($source, $extra);
1193 if ($GLOBALS[
'egotec_conf'][
'openoffice'][
'active']) {
1195 require_once(
'openoffice/converter.php');
1196 $field[
'content'] = convert_content($source, $extra[
'image_type'], $extra[
'mime_type']);
1199 $field[
'content'] =
'';
1200 unset($extra[
'_indexed']);
1204 $this->update(array(
1210 if ($this->field[
'type'] ==
'multimedia/image') {
1211 foreach ($this->getChildren(array(), array(
1214 if ($child->extra[
'crop_image']) {
1216 'edit' => $child->extra[
'edit'],
1217 'crop_image' =>
true 1219 $child->updateExtra(array_merge($this->extra, $extra));
1225 $media_dir = $GLOBALS[
'egotec_conf'][
'var_dir'].
'media'.DIRECTORY_SEPARATOR.$this->_site->name;
1232 $this->_site->language == $this->_site->site[
'default_language']
1237 $media_dir.DIRECTORY_SEPARATOR.$this->field[
'id'],
1238 $media_dir.DIRECTORY_SEPARATOR.$this->getMediaFilename(
true)
1241 $mediafiles = glob($media_dir.DIRECTORY_SEPARATOR.$this->field[
'id'].
'_*');
1242 if (is_array($mediafiles)) {
1243 foreach ($mediafiles as $mediafile) {
1244 preg_match(
'/\d+_\d+$/', $mediafile, $name);
1247 $media_dir.DIRECTORY_SEPARATOR.$this->_site->language.DIRECTORY_SEPARATOR.$name[0]
1254 $dest = $media_dir.DIRECTORY_SEPARATOR.$this->getMediaFilename(
true);
1261 $media_dir.DIRECTORY_SEPARATOR.$this->getMediaFilename(
1263 '_'.strtotime($this->field[
'c_date'])
1270 $GLOBALS[
'egotec_conf'][
'cachemedia_dir'].$this->_site->name.DIRECTORY_SEPARATOR.
1271 $this->getMediaFilename(
true)
1275 if ($this->_site->admin[
'video'][
'compress'] && $this->extra[
'mime_type'] ==
'video/mp4') {
1276 Ego_Queue::add(array($this,
'compressVideo'));
1293 function copyTo($id, $recursive =
false, $params = array(), &$copied_pages = array())
1295 if ($this->isClone() || $this->isWorkflowCopy() || $this->isReleaseCopy()) {
1301 'only_active' =>
false,
1306 if (is_a($id,
'Page')) {
1309 } elseif (is_a($params[
'site'],
'Site')) {
1311 $new_parent = $params[
'site']->getPage($id, $param);
1313 $this->_site->name == $GLOBALS[
'site']->name
1314 && $this->_site->language == $GLOBALS[
'site']->language
1317 $new_parent = $this->_site->getPage($id, $param);
1320 if ($this->_site->site[
'type'] ==
'media') {
1321 $new_parent = $GLOBALS[
'site']->getMediaSite()->getPage($id, $param);
1323 $new_parent = $GLOBALS[
'site']->getPage($id, $param);
1326 $site_parent = $new_parent->getSite();
1329 if ($this->_site->name == $site_parent->name) {
1330 $ancestors = $this->_getAncestorsIds(
1332 array(
'fields' =>
'id'),
1333 array(
'auth_or' =>
'1=1')
1335 if (in_array($this->field[
'id'], $ancestors)) {
1341 if (is_array($params[
'field'])) {
1342 $field = $params[
'field'];
1344 $field = $this->field;
1346 if (is_array($params[
'extra'])) {
1347 $extra = $params[
'extra'];
1349 $extra = $this->extra;
1352 unset($field[
'id']);
1353 unset($field[
'extra']);
1354 $field[
'a_user'] = $GLOBALS[
'auth']->user->field[
'user_id'];
1355 $field[
'a_date'] = date(
'Y-m-d H:i:s');
1356 unset($extra[
'workflow_page']);
1359 unset($extra[
'clones']);
1360 foreach (array_keys($extra) as $key) {
1362 strpos($key,
'clone_children_') === 0
1363 || strpos($key,
'clone_release_') === 0
1365 unset($extra[$key]);
1370 if($this->_site->name == $site_parent->name) {
1371 unset($field[
'url']);
1376 list($field, $extra) = $this->copyToFields($field, $extra);
1377 }
catch (Exception $e) {
1381 $copy = $new_parent->newChild($field, $extra);
1383 'rights' => $this->getRightsArray(),
1384 'users' => $this->getUsersArray()
1386 $copy->updateRights($rights,
false);
1389 if (file_exists($GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename())) {
1390 if ($this->_site->name == $site_parent->name && $this->_site->language == $site_parent->language) {
1392 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename(),
1393 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$copy->getMediaFilename(
true),
1399 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename(),
1400 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$site_parent->name.
'/'.$copy->getMediaFilename(
true),
1408 $this->getMediapool()->copy($copy,
'',
false,
false,
false);
1412 !$copy->isReleaseCopy()
1413 && $this->extra[
'language_link']
1415 foreach($this->extra[
'language_link'] as $lang => $flag) {
1416 if ($lang != $this->_site->language) {
1417 if (in_array($lang, $this->_site->getLanguages()) &&
1418 in_array($lang, $copy->getSite()->getLanguages())
1420 $lang_page = $this->getLanguagePage($lang);
1423 $lang_page_field = $lang_page->field;
1424 $lang_page_extra = $lang_page->extra;
1425 $lang_page_field[
'id'] = $copy->field[
'id'];
1429 list($lang_page_field, $lang_page_extra) = $this->copyToFields($lang_page_field, $lang_page_extra);
1430 }
catch (Exception $e) {
1434 $_param = array(
'auth_or'=>
'1=1',
'deleted_or'=>
'1=1',
'inactive'=>
true);
1435 $lang_copy = $copy->getLanguagePage($lang, $_param);
1437 $copy_parent = $new_parent->getLanguagePage($lang, $_param);
1438 if (!$copy_parent) {
1439 $copy_parent = $copy->getSite()->getRoot()->getLanguagePage($lang, $_param);
1441 $lang_copy = $copy_parent->newChild($lang_page_field, $lang_page_extra);
1445 'field' => $lang_page_field,
1446 'extra' => $lang_page_extra
1454 "rights" => $lang_page->getRightsArray()
1455 ,
"users" => $lang_page->getUsersArray()
1457 $lang_copy->updateRights($rights,
false);
1466 if (!isset($copied_pages[$this->field[
'id']])) {
1467 $copied_pages[$this->field[
'id']] = $copy;
1470 $children = $this->getChildren($params[
'children_query'], $params[
'children_param']);
1471 foreach ($children as $child) {
1473 if ($new_child = $copied_pages[$child->field[
'id']]) {
1475 $new_child->addParent($copy->field[
'id'],
true);
1477 $child->copyTo($copy,$recursive,$params,$copied_pages);
1482 if ($new_parent->extra[
'clones']) {
1484 'field' => $new_parent->field
1486 $new_parent->_updateClones($param);
1499 if ($from != $to && $this->addParent($to)) {
1500 $this->delParent($from,
true);
1502 $this->hookUpdate();
1512 $this->addParent($id);
1527 function delete($parent =
false, $nostart =
false, $keeplinks =
true, $query = array()) {
1528 if ($this->isRoot()) {
1534 if ($this->field[
'type'] ==
'_keywords/entry') {
1535 if ($query[
'where']) {
1536 $query[
'where'] =
"({$query['where']}) AND type = '_keywords/entry'";
1538 $query[
'where'] =
"type = '_keywords/entry'";
1542 $this->archiveOnly =
false;
1543 $children = $this->getChildren(
1550 foreach ($children as $child) {
1551 $child->delete($keeplinks ? $this :
false,
false, $keeplinks, $query);
1556 if (is_array($this->extra[
'language_link'])
1557 && $this->extra[
'language_standard']==$this->_site->language
1559 $languages = $this->_site->getLanguages();
1562 $std = $languages[0]==$this->_site->language?$languages[1]:$languages[0];
1566 foreach($languages as $lang) {
1567 $lang_page = $this->getLanguagePage($lang, array(
'deleted' => -1));
1568 if(!is_object($lang_page))
continue;
1571 $extra = $lang_page->extra;
1572 unset($extra[
'language_link']);
1573 $extra[
'language_link'] = $link_a;
1574 if($std) $extra[
'language_standard'] = $std;
1575 $lang_page->_update(array(
'extra' => $extra),
true,
false);
1579 $parents = $this->getParents(
1589 if ($parent && $parents->numRecords() > 1)
1591 $this->unlinkFrom($parent->field[
'id']);
1595 $destroy_ids = array();
1596 if (!empty($this->extra[
'workflow_page'])) {
1597 $destroy_ids[] = $this->extra[
'workflow_page'];
1599 if (!empty($this->extra[
'release_ids'])) {
1600 $destroy_ids = array_merge($destroy_ids, $this->extra[
'release_ids']);
1602 foreach ($destroy_ids as $destroy_id) {
1603 if ($destroy_page = $this->_site->getPage($destroy_id, array(
1604 'only_active' =>
false,
1608 $destroy_page->destroy(
true);
1612 $field[
'deleted'] = 1;
1613 $extra = $this->extra;
1614 unset($extra[
'workflow_page'], $extra[
'release_ids']);
1615 $this->update(array(
'field' => $field,
'extra' => $extra));
1620 if ($this->isClone()) {
1621 $org = $this->getCloneOriginal();
1622 $del_clone = $this->getParents(array(), array(
1626 $del_id = $del_clone->field[
'id'];
1628 $del_url = $this->getCloneUrl();
1630 $clones = array_filter(array_unique(explode(
',', $org->extra[
'clones'])));
1631 $new_clones = array();
1632 foreach ($clones as $clone_url) {
1633 if (!in_array($clone_url, array($del_id, $del_url))) {
1634 $new_clones[] = $clone_url;
1638 $org->extra[
'clones'] = implode(
',', $new_clones);
1639 $org->updateExtra($org->extra);
1644 if ($this->isReleaseCopy()) {
1646 ($org = $this->_site->getPage($this->extra[
'release_id'], array(
1647 'only_active' =>
false,
1651 && is_array($org->extra[
'release_ids'])
1653 $org->extra[
'release_ids'] = array_values(array_diff($org->extra[
'release_ids'], array($this->field[
'id'])));
1654 $org->update(array(),
true,
true);
1668 $db = new_db_connection();
1670 $this->message =
'Diese Seite wurde vernichtet.';
1677 if ($this->field[
'type'] ==
'_keywords/entry') {
1678 $query[
'where'] =
"type = '_keywords/entry'";
1681 $pages = $this->getChildren($query, array(
'deleted' => 1));
1682 $del_array = array();
1683 foreach($pages as $page) {
1684 $del_array[] = $page;
1686 foreach($del_array as $page) {
1687 $page->destroy(
false, $recursive);
1688 $this->message =
'Diese Seite wurde inklusive Unterseiten erfolgreich vernichtet.';
1692 $parents = $this->getParents(array(), array(
'deleted' => -1));
1693 foreach ($parents as $parent) {
1694 $this->unlinkFrom($parent->field[
'id']);
1699 'table' => $this->_site->pageTable,
1700 'where' =>
"id=".$this->field[
'id']
1703 'table' => $this->_site->pageTable.
'_v',
1704 'where' =>
"id=".$this->field[
'id']
1707 'table' => $this->_site->pageTable.
'_rights',
1708 'where' =>
"page_id=".$this->field[
'id']
1711 'table' => $this->_site->pageTable.
'_users',
1712 'where' =>
"page_id=".$this->field[
'id']
1715 'table' => $this->_site->pageTable.
'_children',
1716 'where' =>
'page_id='.$this->field[
'id'].
' OR child='.$this->field[
'id']
1719 if ($db->tableExists($this->_site->pageTable.
'_extra'))
1722 'table' => $this->_site->pageTable.
'_extra',
1723 'where' =>
'page_id='.$this->field[
'id']
1729 $this->destroyFile();
1732 $this->getMediapool()->clear(
'', [],
false);
1735 $this->removeUrls();
1737 $this->message .=
' Eine Wiederherstellung ist nicht möglich.';
1748 public function destroy($force=
false, $recursive=
true) {
1749 if ($this->isRoot()) {
1752 $this->archiveOnly =
false;
1756 $log_filename = $GLOBALS[
'egotec_conf'][
'log_dir'].$GLOBALS[
'site']->name.
'/live.'.$this->_site->name.
'_'.$this->_site->language.
'.'.$cluster[
'id'].
'.up.date';
1757 if (file_exists($log_filename)) {
1758 $time[] = file_get_contents($log_filename);
1764 if (count($time) > 0) {
1765 $live_date = $time[0];
1767 $live_date = time();
1771 $live_date_file = $GLOBALS[
'egotec_conf'][
'log_dir'].$this->_site->name.
'/'.
'live.'.$this->_site->name.
'_'.$this->_site->language.
'.date';
1773 if(file_exists($live_date_file)) {
1774 $live_date = file_get_contents($live_date_file);
1776 $live_date = time();
1782 $GLOBALS[
'egotec_conf'][
'liveserver']
1783 || $this->field[
'c_date'] > $live_date
1784 || !$this->field[
'deleted']
1787 return $this->
delete();
1791 is_array($this->extra[
'language_link'])
1792 && $this->extra[
'language_standard'] == $this->_site->language
1800 foreach($this->extra[
'language_link'] as $lang => $flag) {
1801 if ($flag && $lang != $this->_site->language) {
1803 $lang_page = $this->getLanguagePage($lang, array(
'deleted' => -1,
'auth_or' =>
'1=1'));
1804 if (is_object($lang_page)) {
1805 $lang_page->_destroyEntry($recursive);
1813 $this->_destroyEntry($recursive);
1823 function undelete($recursive =
false, $query = array()) {
1825 $this->message =
'Diese Seite wurde erfolgreich wiederhergestellt.';
1828 ($this->extra[
'language_standard']==$this->_site->language
1829 || $this->_site->admin[
'multi_lang'][
'auto_link'])
1830 && is_array($this->extra[
'language_link'])
1832 foreach($this->extra[
'language_link'] as $lang=>$flag) {
1833 if ($flag || $this->_site->admin[
'multi_lang'][
'auto_link']) {
1834 $lang_page = $this->getLanguagePage($lang, array(
'deleted' => -1));
1835 if (!is_object($lang_page)) {
1838 $lang_page->restore();
1840 $pages = $lang_page->getDescendants(array(), array(
1842 'children_query' => $query
1844 foreach ($pages as $page)
1854 $pages = $this->getDescendants(array(), array(
1856 'children_param' => array(
'deleted' => -1),
1857 'children_query' => $query
1859 if ($pages->numRecords()>0) {
1860 $this->message =
'Diese Seite wurde inklusive Unterseiten erfolgreich wiederhergestellt.';
1862 foreach ($pages as $page) {
1873 private function restore() {
1874 $inactive = $this->field[
'inactive'] == self::RELEASE_FLAG ?
1875 self::RELEASE_FLAG :
1876 self::INACTIVE_FLAG;
1877 if ($this->field[
'type'] ==
'_keywords/entry') {
1878 $inactive = self::ACTIVE_FLAG;
1880 $field = array(
'inactive' => $inactive,
'deleted' => 0);
1881 if (!empty($this->field[
'url']) && !$this->isUniqueUrl($this->field[
'url'])) {
1887 $field[
'parents'] = $this->_site->rootId;
1888 foreach ($this->getParents(array(), array(
'deleted' => 0)) as $parent) {
1889 unset($field[
'parents']);
1893 $this->updateField($field,
false);
1902 $this->_removeParent($remove_from);
1903 if (!$this->field[
'deleted']) {
1905 $parents = $this->getParents(array(), array(
'auth_or' =>
'1=1',
'sitemap' =>
true));
1906 if (!$parents->next()) {
1920 if (!$asis && $field[
'url'] && $field[
'id'] && $this->field[
'url'] != $field[
'url']) {
1922 'table' => $this->_site->name.
'_'.$this->_site->language,
1923 'fields' =>
'id, url',
1924 'where' =>
'url=:url'.
1928 'url' => $field[
'url'],
1929 'id' => $field[
'id']
1932 if ($this->extra[
'original_id']) {
1933 $query[
'where'].=
' AND id!=:originalid';
1934 $query[
'bind'][
'originalid'] = $this->extra[
'original_id'];
1936 $db = new_db_connection($query);
1937 if ($db->nextRecord()) {
1938 $this->message.= $GLOBALS[
'auth']->translate(
'Die URL konnte nicht gespeichert werden, weil sie schon vorhanden ist!') .
'\n';
1939 $field[
'url'] = $this->field[
'url'];
1944 if (isset($field[
'name'])) {
1945 $field[
'name'] = strip_tags($field[
'name']);
1946 if (in_array((isset($field[
'type']) ? $field[
'type'] : $this->field[
'type']), array(
'multimedia/category',
'multimedia/file',
'multimedia/image'))) {
1947 $field[
'name'] = strtr($field[
'name'],
'\/:*?"<>|',
'_________');
1952 if ($this->_site->admin[
'editor'][
'plaintext']) {
1953 if (isset($field[
'title'])) {
1954 $field[
'title'] = strip_tags($field[
'title']);
1956 if (isset($field[
'short']) && !$this->_site->admin[
'editor'][
'short'] && !$GLOBALS[
'egotec_conf'][
'editor'][
'short']) {
1957 $field[
'short'] = strip_tags($field[
'short']);
1962 if (isset($field[
'type']) && empty($field[
'type'])) {
1963 $field[
'type'] = !empty($this->field[
'type']) ? $this->field[
'type'] :
'page';
1966 $this->_cleanEmptyContent($field);
1968 $this->field = array_merge($this->field, $field);
1971 $this->_changeEntry($field, $asis);
1983 if ($this->_site->admin[
'keyword_register_own_site']) {
1984 $keywords = $this->_site->getPages([
'where' =>
"type = '_keywords/list'"])->nextPage();
1986 $abbreviations = $keywords->getDescendants([
1987 'where' =>
"type = '_keywords/entry'" 1989 'extra' =>
'extra.abbreviation = 1' 1993 $old_abbreviations = [];
1994 $new_abbreviations = [];
1995 $current_abbreviations = $this->getParents([
1996 'where' =>
"type = '_keywords/entry'" 1998 'extra' =>
'extra.abbreviation = 1' 2000 foreach ($current_abbreviations as $current_abbreviation) {
2001 if ($current_abbreviation->extra[
'abbreviation']) {
2002 $old_abbreviations[] = $current_abbreviation->field[
'id'];
2006 foreach ($abbreviations as $abbreviation) {
2007 if (!$abbreviation->extra[
'abbreviation']) {
2012 $words = [$abbreviation->field[
'name']];
2015 if ($abbreviation->extra[
'synonym']) {
2016 require_once
'base/Ego_Combo.php';
2017 $combo =
new Ego_Combo($abbreviation->extra[
'synonym']);
2018 foreach ($combo->getText() as $text) {
2019 $words[] = (string) $text;
2024 $search =
function($value) use (&$search, $words) {
2025 if (is_array($value)) {
2026 foreach ($value as $v) {
2032 return is_string($value)
2033 && preg_match(
'/>?[^<]*?\W*(' . implode(
'|', array_map(
function($v) {
2034 return preg_quote($v,
'/');
2035 }, $words)) .
')\W*[^>]*?<?/is', $value);
2039 $search($this->field[
'name'])
2040 || $search($this->field[
'title'])
2041 || $search($this->field[
'short'])
2042 || $search($this->field[
'content'])
2043 || $search($this->field[
'extra'])
2046 if (!$this->hasParent($abbreviation->field[
'id'])) {
2047 $this->addParent($abbreviation->field[
'id'], $asis);
2049 $new_abbreviations[] = $abbreviation->field[
'id'];
2050 } elseif ($this->hasParent($abbreviation->field[
'id'])) {
2052 $this->delParent($abbreviation->field[
'id'], $asis);
2056 $diff1 = array_diff($old_abbreviations, $new_abbreviations);
2057 $diff2 = array_diff($new_abbreviations, $old_abbreviations);
2058 return !empty($diff1) || !empty($diff2);
2071 $db = new_db_connection(array(
2072 'table' => $this->_site->pageTable .
'_children',
2073 'where' =>
'page_id = :page_id',
2075 'page_id' => $this->field[
'id']
2077 'order' =>
'idx ASC' 2079 while ($db->nextRecord()) {
2080 if (!in_array($db->Record[
'child'], $children)) {
2081 array_splice($children, (
int) $db->Record[
'idx'], 0, $db->Record[
'child']);
2085 $ancestors_iterator = $this->getAncestors(
2086 array(
'fields' =>
'id'),
2087 array(
'auth_or' =>
'1=1',
'children_param' => array(
'auth_or' =>
'1=1'))
2089 $ancestors = array();
2090 foreach ($ancestors_iterator as $ancestor_page)
2092 $ancestors[] = $ancestor_page->field[
'id'];
2094 $ancestors[] = $this->field[
'id'];
2096 $db = new_db_connection();
2098 $table = $this->_site->pageTable;
2100 'table' => $table.
'_children',
2101 'where' =>
'page_id='.$this->field[
'id']
2103 $children = array_unique($children);
2105 foreach ($children as $child) {
2107 if (in_array($child, $ancestors)) {
2108 egotec_error_log(
'infinite loop prevention at children: '.$this->_site->pageTable.
' '.$this->field[
'id'].
','.$child);
2111 'table' => $table.
'_children',
2112 'set' => array(
'page_id' => $this->field[
'id'],
'idx' => $idx,
'child' => $child)
2119 $this->_clearCache();
2128 if (empty($parents)) {
2129 egotec_error_log(
'empty parents: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id']);
2132 $current_parents = array();
2133 $db = new_db_connection(array(
2134 'table' => $this->_site->pageTable .
'_children',
2135 'where' =>
'child = :child',
2137 'child' => $this->field[
'id']
2140 while ($db->nextRecord()) {
2141 $current_parents[] = $db->Record[
'page_id'];
2144 $remove_parents = array();
2145 foreach ($current_parents as $current_parent) {
2146 $key = array_search($current_parent, $parents);
2148 unset($parents[$key]);
2151 $remove_parents[] = $current_parent;
2154 foreach ($parents as $parent_id) {
2156 if ($parent_id!=$this->field[
'id']) {
2157 $this->_addParent($parent_id);
2160 egotec_error_log(
'infinite loop prevention at parents: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id'].
','.$parent_id);
2164 if ($num_parents == 0) {
2165 egotec_error_log(
'empty parents 2: '.print_r($parents,
true).
' / '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id']);
2169 foreach ($remove_parents as $remove_parent) {
2170 $this->_removeParent($remove_parent);
2180 private function _removeParent($parent_id) {
2181 $db = new_db_connection();
2183 'table' => $this->_site->pageTable.
'_children',
2184 'where' =>
'page_id = '.$parent_id.
' AND child = '.$this->field[
'id']
2186 $this->_site->clearCache();
2189 $parent = $this->_site->getPage($parent_id);
2190 if ($parent && $parent->extra[
'clones'] && !$this->isReleaseCopy() && !$this->isWorkflowCopy()) {
2191 $clones = explode(
',', $parent->extra[
'clones']);
2192 foreach ($clones as $clone_url) {
2199 'deleted_or' =>
'1=1',
2201 'only_active' =>
false 2208 if ($parent_clone && $parent->extra[
'clone_children_' . $clone_url]) {
2209 foreach ($parent_clone->getChildren(array(), array(
2211 'deleted_or' =>
'1=1',
2213 'only_active' =>
false 2215 if (in_array($clone->getCloneUrl(), explode(
',', $this->extra[
'clones']))) {
2216 $clone->destroyClone();
2229 private function _addParent($parent_id) {
2230 if ($this->field[
'id']==$parent_id) {
2231 egotec_error_log(
'infinite loop prevention: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id'].
','.$parent_id);
2234 $parent = $this->_site->getPage($parent_id, array(
2236 'only_active' =>
false 2241 $ancestors = $this->_getAncestorsIds(
2243 array(
'fields' =>
'id'),
2244 array(
'auth_or' =>
'1=1')
2246 if (in_array($this->field[
'id'], $ancestors)) {
2249 if ($this->hasParent($parent_id)) {
2250 egotec_error_log(
'infinite loop prevention: '.$this->_site->pageTable.$this->getTableSuffix().
' '.$this->field[
'id'].
','.$parent_id);
2253 $db = new_db_connection();
2256 'table' => $this->_site->pageTable.
'_children',
2257 'where' =>
"page_id=".$parent_id,
2258 'order' =>
'idx DESC',
2261 $idx = $db->nextRecord()?$db->Record[
'idx']+1:0;
2263 'table' => $this->_site->pageTable.
'_children',
2264 'set' => array(
'page_id' => $parent_id,
'idx' => $idx,
'child' => $this->field[
'id']),
2265 'primary' => array(
'page_id',
'idx')
2269 if ($parent && $parent->extra[
'clones'] && !$this->isReleaseCopy() && !$this->isWorkflowCopy()) {
2270 $clones = explode(
',', $parent->extra[
'clones']);
2271 foreach ($clones as $clone_url) {
2278 'deleted_or' =>
'1=1',
2280 'only_active' =>
false 2287 if ($clone && $parent->extra[
'clone_children_' . $clone_url]) {
2288 $clone->createClone($this);
2301 private function _clearCache($complete =
false) {
2302 $this->_site->clearCache(!$complete && $this->field[
'type'] ==
'multimedia/image' ? $this->field[
'id'] : 0);
2306 foreach ($this->getLinkedPages() as $link) {
2307 foreach ($link[
'sources'] as $site_name => $source) {
2308 if ($site_name != $this->_site->name && !in_array($site_name, $cleared)) {
2309 $cleared[] = $site_name;
2311 $site =
new Site($site_name);
2312 Ego_Queue::add(array($site,
'clearCache'));
2331 if ($this->isReleaseCopy() || $this->isWorkflowCopy()) {
2334 if ($param[
'extra'][
'clones'] || $this->extra[
'clones']) {
2335 $this_page_url = $this->getCloneUrl();
2337 if (isset($param[
'extra'])) {
2338 $folders = explode(
',', $param[
'extra'][
'clones']);
2339 $param[
'extra'][
'clones'] =
'';
2340 $old_clones = array_filter(array_unique(explode(
',', $this->extra[
'clones'])));
2343 foreach ($old_clones as $old_c) {
2344 if ($old_c ==
'')
continue;
2346 if (!in_array($old_c, $folders)) {
2349 'deleted_or' =>
'1=1',
2351 'only_active' =>
false 2357 unset($param[
'extra'][
'clone_children_' . $old_c], $param[
'extra'][
'clone_release_' . $old_c]);
2360 } elseif (isset($this->extra[
'clones'])) {
2362 $folders = array_filter(array_unique(explode(
',', $this->extra[
'clones'])));
2368 $param[
'field'] = $param[
'field'] ? $param[
'field'] : $this->field;
2369 $param[
'extra'] = $param[
'extra'] ? $param[
'extra'] : $this->extra;
2372 foreach ($folders as $f) {
2374 $remove_parent =
false;
2380 'deleted_or' =>
'1=1',
2382 'only_active' =>
false 2387 $clones = array_filter(explode(
',', $param[
'extra'][
'clones']));
2388 $param[
'extra'][
'clones'] = implode(
',', array_unique(array_merge($clones, array($f))));
2393 'field' => $param[
'field'],
2394 'extra' => $param[
'extra']
2396 $p[
'extra'][
'clone_original'] = $this_page_url;
2397 unset($p[
'field'][
'id']);
2398 unset($p[
'field'][
'parents']);
2399 unset($p[
'field'][
'url']);
2400 unset($p[
'extra'][
'clones']);
2402 foreach ($p[
'extra'] as $key => $value) {
2404 strpos($key,
'clone_children_') === 0
2405 || strpos($key,
'clone_release_') === 0
2407 unset($p[
'extra'][$key]);
2411 if ($clone->isClone()) {
2412 if (isset($clone->conf[
'edit_clone'])) {
2414 $combined_p = array();
2415 foreach ($p as $field => $values) {
2416 $combined_p[$field] = $values;
2417 if (is_array($values) && isset($clone->conf[
'edit_clone'][$field])) {
2418 $clone_edit = explode(
',', $clone->conf[
'edit_clone'][$field]);
2419 foreach ($clone_edit as $edit_key) {
2423 && $clone_value != $value
2426 $value = $clone_value;
2438 $clone_page_url = $clone->getCloneUrl();
2439 if ($param[
'extra'][
'clone_release_' . $clone_page_url]) {
2440 unset($combined_p[
'field'][
'release_from'], $combined_p[
'field'][
'release_until']);
2443 $clone->update($combined_p);
2445 unset($p[
'field'][
'release_from'], $p[
'field'][
'release_until']);
2447 $clone = $clone->newChild($p[
'field'], $p[
'extra']);
2451 $remove_parent =
true;
2455 $this->getMediapool()->copy($clone);
2458 $clone_page_url = $clone->getCloneUrl();
2459 $clones = array_filter(explode(
',', $param[
'extra'][
'clones']));
2460 $param[
'extra'][
'clones'] = implode(
',', array_unique(array_merge($clones, array($clone_page_url))));
2467 $param[
'extra'][
'clone_children_' . $clone_page_url] = $param[
'extra'][
'clone_children_' . $f_url];
2468 $param[
'extra'][
'clone_release_' . $clone_page_url] = $param[
'extra'][
'clone_release_' . $f_url];
2470 unset($param[
'extra'][
'clone_children_' . $f_url], $param[
'extra'][
'clone_release_' . $f_url]);
2473 if ($param[
'extra'][
'clone_release_' . $clone_page_url]) {
2474 $param[
'extra'][
'clone_release_from_' . $clone_page_url] = $param[
'extra'][
'clone_release_from_' . $f_url];
2475 $param[
'extra'][
'clone_release_until_' . $clone_page_url] = $param[
'extra'][
'clone_release_until_' . $f_url];
2477 unset($param[
'extra'][
'clone_release_from_' . $f_url], $param[
'extra'][
'clone_release_until_' . $f_url]);
2482 if ($param[
'extra'][
'clone_release_'.$clone_page_url]) {
2483 $clone_release = array();
2485 if ($param[
'extra'][
'clone_release_from_' . $clone_page_url]) {
2486 $clone_release[
'release_from'] = $param[
'extra'][
'clone_release_from_' . $clone_page_url];
2488 $clone_release[
'release_from'] =
'0000-00-00 00:00:00';
2491 if ($param[
'extra'][
'clone_release_until_' . $clone_page_url]) {
2492 $clone_release[
'release_until'] = $param[
'extra'][
'clone_release_until_' . $clone_page_url];
2494 $clone_release[
'release_until'] =
'0000-00-00 00:00:00';
2497 if (!empty($clone_release)) {
2498 $clone->updateField($clone_release);
2504 $param[
'extra'][
'clone_release_from_' . $clone_page_url],
2505 $param[
'extra'][
'clone_release_until_' . $clone_page_url]
2509 if ($param[
'extra'][
'clone_children_'.$clone_page_url] != $this->extra[
'clone_children_'.$clone_page_url])
2511 if ($param[
'extra'][
'clone_children_'.$clone_page_url] == 1)
2514 $this->_createChildClones($clone);
2519 $this->_destroyChildClones($clone);
2523 } elseif ($this->isClone()) {
2525 $type_info = $this->getTypeInfo();
2527 $type_info[
'clone_link']
2528 && ($page =
Ego_System::urltopage($this->extra[
'clone_original'], array(
'params' => array(
'param' => array(
2530 'deleted_or' =>
'1=1',
2532 'only_active' =>
false 2536 'field' => $param[
'field'],
2537 'extra' => $param[
'extra']
2539 $p[
'extra'][
'clones'] = $page->extra[
'clones'];
2540 foreach ($page->extra as $key => $value) {
2542 strpos($key,
'clone_children_') === 0
2543 || strpos($key,
'clone_release_') === 0
2545 $p[
'extra'][$key] = $value;
2548 unset($p[
'field'][
'id']);
2549 unset($p[
'field'][
'parents']);
2550 unset($p[
'field'][
'url']);
2551 unset($p[
'extra'][
'clone_original']);
2555 $this->getMediapool()->copy($page);
2567 $clone_array = array_filter(array_unique(explode(
',', $this->extra[
'clones'])));
2568 foreach ($clone_array as $clone_index) {
2569 if ($clone_index ==
'')
continue;
2572 'deleted_or' =>
'1=1',
2574 'only_active' =>
false 2593 public function createClone($page, $children =
false, $release =
false, $multiple =
true) {
2594 $_REQUEST[
'var'][
'reload_dlg'] =
true;
2595 return $this->_createClone($page, $children, $release, $multiple);
2607 protected function _createClone($page, $children =
false, $release =
false, $multiple =
true) {
2608 $clone_url = $page->getCloneUrl();
2612 $children2 = $this->getChildren(array(), array(
2615 'only_active' =>
false 2617 foreach ($children2 as $child) {
2618 if ($child->extra[
'clone_original'] == $clone_url) {
2626 'field' => $page->field,
2627 'extra' => $page->extra
2629 $p[
'extra'][
'clone_original'] = $clone_url;
2630 unset($p[
'field'][
'id']);
2631 unset($p[
'field'][
'parents']);
2632 unset($p[
'field'][
'url']);
2633 unset($p[
'extra'][
'clones']);
2635 $clone = $this->newChild($p[
'field'], $p[
'extra']);
2638 $extra = $page->extra;
2640 $clones = array_filter(explode(
',', $extra[
'clones']));
2641 $clone_page_url = $clone->getCloneUrl();
2643 $extra[
'clones'] = implode(
',', array_unique(array_merge($clones, array($clone_page_url))));
2645 $extra[
'clone_children_' . $clone_page_url] = 1;
2648 $extra[
'clone_release_' . $clone_page_url] = 1;
2650 $page->updateExtra($extra);
2662 $children = $this->getChildren(
2669 foreach($children as $child) {
2671 $clone_child = $parent->getChildren(
2673 'where' =>
'name=:n AND a_date=:a',
2675 'n' => $child->field[
'name'],
2676 'a' => $child->field[
'a_date']
2684 if (!$clone_child->numRecords()) {
2685 $parent->createClone($child,
true);
2697 $children = $this->getChildren(
2704 foreach($children as $child) {
2706 $clone_child = $parent->getChildren(
2708 'where' =>
'name=:n AND a_date=:a',
2710 'n' => $child->field[
'name'],
2711 'a' => $child->field[
'a_date']
2719 if ($clone = $clone_child->nextPage()) {
2720 $clone->destroyClone();
2731 $_REQUEST[
'var'][
'reload_dlg'] =
true;
2732 return $this->_destroyClone();
2741 $page = $this->getCloneOriginal();
2745 $extra = $page->extra;
2746 $clones = explode(
',', $extra[
'clones']);
2747 $clone_page_url = $this->getCloneUrl();
2748 if (!in_array($clone_page_url, $clones)) {
2752 $new_clones = array();
2753 foreach($clones as $c) {
2754 if ($c != $clone_page_url) {
2759 $extra[
'clones'] = implode(
',', array_filter(array_unique($new_clones)));
2760 unset($extra[
'clone_children_' . $clone_page_url], $extra[
'clone_release_' . $clone_page_url]);
2762 $page->updateExtra($extra);
2777 $db = new_db_connection();
2778 if ($rights[
'_delete']) {
2779 $delete_query_where =
' AND perm in (\''.join(
'\',\
'', $rights[
'_delete']).
'\')
'; 2780 unset($rights['_delete
']); 2782 $rights['rights
'] = array_merge($this->getRightsArray(),$rights['rights
']); 2783 if ($rights['rights
']) { // Gruppen und Rollen. 2784 $db->delete(array( // Alte Einträge löschen. 2785 'from
' => $this->_site->pageTable.'_rights
', 2786 'where
' => 'page_id=
'.$this->field['id'].$delete_query_where 2788 foreach ($rights['rights
'] as $right => $groups) { 2789 $is_null = true; // Zunächst von keiner Beschränkung ausgehen. 2790 foreach ($groups as $group) { 2791 if (!$group['group_id
'] || !$group['role_id
']) { 2792 if ($rights['users
'] && $rights['users
'][$right] && count($rights['users
'][$right]) != 0) { 2793 // es sind user vorhanden aber keine Group/Role Kombination 2794 $group['group_id
'] = $GLOBALS['egotec_conf
']['superuser
']['group
']; 2795 $group['role_id
'] = $GLOBALS['egotec_conf
']['superuser
']['role
']; 2799 if ($group['group_id
'] && $group['role_id
']) { // Keine leeren Einträge setzen. 2801 'table
' => $this->_site->pageTable.'_rights
', 2803 'page_id
' => $this->field['id'], 2805 'group_id
' => $group['group_id
'], 2806 'role_id
' => $group['role_id
'] 2808 'primary
' => array('page_id
', 'perm
', 'group_id
', 'role_id
') 2810 $is_null = false; // Es wurde eine Beschränkung gesetzt. 2813 if ($is_null && strpos(Auth::NO_NULL_RIGHTS, ',
'.$right.',
')!==false) { // Bei einem Recht, das nicht per IS NULL abgefragt wird 2815 'table
' => $this->_site->pageTable.'_rights
', 2817 'page_id
' => $this->field['id'], 2819 'group_id
' => '*
', // *|* setzen. 2822 'primary
' => array('page_id
', 'perm
', 'group_id
', 'role_id
') 2828 if ($rights['users
']) { 2830 $db->delete(array( // Alte Einträge löschen. 2831 'from
' => $this->_site->pageTable.'_users
', 2832 'where
' => "page_id=".$this->field['id'].$delete_query_where 2834 foreach ($rights['users
'] as $right => $users) { 2835 if (is_array($users)) { 2836 foreach ($users as $user) { 2837 if ($user['user_id
']) { // Leere Einträge vermeiden 2839 'table
' => $this->_site->pageTable.'_users
', 2841 'page_id
' => $this->field['id'], 2843 'user_id
' => trim($user['user_id
'],"'"), 2852 // Multimedia Bilder vererben das Ansichtsrecht an alle Bildausschnitte 2853 if ($this->field['type'] == 'multimedia/image') { 2854 $children = $this->getChildren(array( 2855 'where' => "type =
'multimedia/image'" 2859 'only_active' => false 2861 foreach ($children as $child) { 2862 if ($child->extra['crop_image']) { 2863 $child->update(array( 2866 'view' => $rights['rights']['view'] ? $rights['rights']['view'] : array() 2869 'view' => $rights['users']['view'] ? $rights['users']['view'] : array() 2877 if (!isset($this->field['inactive']) || !$this->field['inactive']) { 2878 $this->_clearCache(); 2893 protected function _update($param, $matrix_flag = true, $asis = false) { 2894 if (!$asis) { // @TODO Ist das notwendig? 2895 $this->_updateClones($param); 2897 $language_standard = $this->extra['language_standard']; 2899 if (isset($param['extra']) && $param['field'] && (int)$param['extra']['original_id']) { // Workflowkopien sind immer inaktiv; 2900 $param['field']['inactive'] = $this->isReleaseCopy() ? self::RELEASE_FLAG : self::INACTIVE_FLAG; 2902 if (isset($param['extra'])) { 2903 $new_extra = array(); 2904 if (is_array($param['extra'])) { 2925 $cleanup = function($value) use (&$cleanup) { 2926 if (is_array($value)) { 2928 $numeric_keys = true; 2929 foreach ($value as $k => $v) { 2931 if (in_array($k, ['', 'undefined'], true) || empty($v)) { 2934 $new_value[$k] = $v; 2935 if (!is_numeric($k)) { 2936 $numeric_keys = false; 2939 if ($numeric_keys) { 2940 // Sicherstellen, dass bei numerischen Schlüsseln immer aufsteigend sortiert ist 2943 $value = $new_value; 2944 } elseif (is_string($value)) { 2945 if (preg_match('/^[1-9]+[0-9]*$/', $value)) { 2946 // Nur Ganzzahlen umwandeln; ansonsten können Werte wie 6.350 in 6,35 umgewandelt werden 2947 // Auch nicht für Ganzzahlen, die mit einer 0 beginnen 2948 $value = $value + 0; 2949 } elseif (in_array($value, ['true', 'false'], true)) { 2950 $value = $value == 'true'; 2951 } elseif (in_array($value, ['null', 'undefined'], true)) { 2958 $new_extra = $cleanup($param['extra']); 2961 // Vererbte Blöcke nicht speichern 2962 if (!empty($new_extra['_inherited'])) { 2963 $blocks = $new_extra['_blocks']; 2964 $contents = $new_extra['_contents']; 2965 foreach ($new_extra['_inherited'] as $orient => $checksum) { 2966 if ($blocks[$orient] && $contents[$orient]) { 2967 $checksum_blocks = Ego_System::getChecksum($blocks[$orient]); 2968 $checksum_contents = Ego_System::getChecksum($contents[$orient]); 2969 if ($checksum_blocks == $checksum['blocks'] && $checksum_contents == $checksum['contents']) { 2970 unset($new_extra['_blocks'][$orient], $new_extra['_contents'][$orient]); 2976 unset($new_extra['_asis'], $new_extra['_inherited']); 2977 $param['extra'] = $new_extra; 2979 if ($param['field'] || $param['extra']) { 2980 // Der Seitentyp wird gewechselt 2982 !empty($param['field']['type']) 2983 && $param['field']['type'] != $this->field['type'] 2984 && $this->isFrontendAdmin() 2986 $this->field['type'] = $param['field']['type']; 2987 $this->_loadConfig(); 2988 if (!empty($this->conf['default_layout'])) { 2989 // Das Standard Layout des neuen Seitentyps verwenden 2990 $param['extra'] = isset($param['extra']) 2993 $param['extra']['_layout'] = $this->conf['default_layout']; 2997 if ($param['field']['children']) { 2998 if (!isset($param['children'])) { 2999 $param['children'] = explode(',', trim($param['field']['children'], ',')); 3001 unset($param['field']['children']); 3003 if ($param['field']['parents']) { 3004 if (!isset($param['parents'])) { 3005 $param['parents'] = explode(',', trim($param['field']['parents'], ',')); 3007 unset($param['field']['parents']); 3010 if (isset($param['extra'])) { 3011 $param['field']['extra'] = serialize($param['extra']); 3014 $this->_updateField($param['field'], true, $asis); 3016 if ($param['children']) { 3017 $this->_updateChildren($param['children']); 3019 if ($param['parents'] && $this->field['id'] != $this->_site->rootId) { 3020 $this->_updateParents($param['parents']); 3023 if ($param['rights']) { 3024 $this->_updateRights($param['rights']); 3027 // Schlagwörter automatisch hinzufügen 3028 $reload = $this->_updateKeywords($asis); 3030 // Mediapool Aktionen ausführen 3031 if ($param['pool']) { 3032 // Dateien umbenennen 3033 if (is_array($param['pool']['rename'])) { 3034 foreach ($param['pool']['rename'] as $info) { 3035 if ($info['name'] != $info['new_name']) { 3036 $this->getMediapool()->edit($info['name'], array( 3037 'new_name' => $info['new_name'] 3038 ), (string) $info['dir']); 3046 && !$this->extra['crop_image'] // Ausschnitte legen keine Archive oder Sprachen an 3047 && (!$asis || $this->isPublicSave()) 3050 $this->_archiveEntry($asis); 3052 // Die Inhalte der Standardsprache in die verknüpften Bereiche speichern. 3054 !$this->archiveOnly // Nicht für Zwischenspeicherungen 3055 && !$this->isWorkflowCopy() 3057 && $language_standard == $this->_site->language 3058 && is_array($param['extra']['language_link']) 3066 $clean_clones = function($extra) { 3067 unset($extra['clones']); 3068 foreach (array_keys($extra) as $key) { 3069 if (strpos($key, 'clone_') === 0) { 3070 unset($extra[$key]); 3076 $languages = array(); 3077 $site_languages = $this->_site->getLanguages(); 3078 foreach ($param['extra']['language_link'] as $lang=>$flag) { 3079 // #173630: Nur wenn es die Sprache auch noch gibt 3080 if (in_array($lang, $site_languages)) { 3081 $matrix_page = $this->getLanguagePage($lang, array( 3084 'only_active' => false, 3088 if ($flag && $lang!=$this->_site->language) { 3090 $param['extra'] = $clean_clones(array_merge($this->extra, $param['extra'])); 3091 if (!isset($param['rights'])) { 3092 $param['rights'] = [ 3093 'rights' => $this->getRightsArray(), 3094 'users' => $this->getUsersArray() 3097 $matrix_page->update($param, false, $asis); 3098 $this->getMediapool()->copy($matrix_page); // Mediapool kopieren 3100 // Wenn bereits eine Sprachkopie existiert und darauß eine Sprachverknpüfung wird, dann alle Multimedia Dateien löschen 3101 if ($this->_site->site['type'] == 'media') { 3102 $media_dir = $GLOBALS['egotec_conf']['var_dir'] . 'media' . DIRECTORY_SEPARATOR . $this->_site->name; 3103 $source = $media_dir . DIRECTORY_SEPARATOR . $matrix_page->getMediaFilename(); 3105 foreach (glob($source . '*') as $media_file) { 3106 @unlink($media_file); 3109 } elseif (!$this->isReleaseCopy()) { // Wenn die Seite noch nicht in dieser Sprache vorhanden ist, dann wird diese erzeugt (außer für Freigabekopien). 3110 $matrix_parent = $this->getParents(array(), array('auth_or' => '1=1')); 3111 if ($matrix_parent) { 3112 $matrix_parent = $matrix_parent->nextPage(); /* @var $matrix_parent Page */ 3113 if ($matrix_parent) { 3114 $matrix_parent = $matrix_parent->getLanguagePage($lang, array( 3116 'only_active' => false, 3117 'deleted_or' => '1=1' 3121 if ($matrix_parent->field['deleted']) { 3122 // Elternseite wiederherstellen 3123 $matrix_parent->undelete(); 3125 if ($matrix_page = $matrix_parent->newChild($this->field, $clean_clones($this->extra))) { 3126 $this->getMediapool()->copy($matrix_page); // Mediapool kopieren 3132 $languages[] = $lang; 3134 elseif ($lang!=$this->_site->language) { 3135 // #204196: Nur wenn diese Sprache keine Sprachverknüpfung ist 3138 !Ego_System::isEqual($matrix_page->extra['language_link'], $param['extra']['language_link']) 3139 || !Ego_System::isEqual($matrix_page->extra['language_standard'], $param['extra']['language_standard']) 3141 $matrix_page_link = $matrix_page->extra['language_link'][$lang]; 3143 $matrix_page_extra = $matrix_page->extra; 3144 $matrix_page_extra['language_link'] = $param['extra']['language_link']; 3145 $matrix_page_extra['language_standard'] = $param['extra']['language_standard']; 3147 $matrix_page->updateExtra($clean_clones($matrix_page_extra), false, $asis); 3149 // Aus einer existierenden Sprachverknüpfung wird eine Sprachkopie 3150 if (!$param['extra']['language_link'][$lang] && $matrix_page_link) { 3151 // Multimedia Dateien müssen kopiert werden 3152 if ($this->_site->site['type'] == 'media') { 3153 $media_dir = $GLOBALS['egotec_conf']['var_dir'] . 'media' . DIRECTORY_SEPARATOR . $this->_site->name; 3154 $source = $media_dir . DIRECTORY_SEPARATOR . $this->getMediaFilename(); 3156 if (Ego_System::file_exists($source)) { 3157 $dest = $media_dir . DIRECTORY_SEPARATOR . $matrix_page->getMediaFilename(true); 3168 $media_dir . DIRECTORY_SEPARATOR . $matrix_page->getMediaFilename( 3170 '_'.strtotime($matrix_page->field['c_date']) 3185 $this->message.= "\n
".$GLOBALS['auth']->translate('Folgende Sprachen wurden auch geändert:').' '.join(', ', $languages)."\n
"; 3186 $this->_updatedLinkLanguages = $languages; 3191 // Wird ein Multimedia Bild gespeichert, muss für alle untergeordneten Ausschnitte 3192 if ($this->field['type'] == 'multimedia/image') { 3193 foreach ($this->getChildren() as $child) { 3194 // ... die Spracheinstellungen vererbt werden 3195 if (isset($param['extra'])) { 3196 $extra = $child->extra; 3197 $extra['language_link'] = $param['extra']['language_link']; 3198 $extra['language_standard'] = $param['extra']['language_standard']; 3199 $child->updateExtra($extra, true, $asis); 3202 // ... der Cache gelöscht werden 3203 $this->_site->clearCache($child->field['id']); 3207 $this->hookUpdate(); 3209 if (!$this->extra['_indexed']) { 3210 $this->updateIndex(); 3222 function hookUpdate($hook = 'update') { 3223 // Zwischenspeicherungen führen keine Hooks aus 3224 if ($hook == 'update' && $this->archiveOnly) { 3228 $cache_key = $this->_site->name.'/'.$this->field['type'].'/'.$hook; 3229 $hook_cache = array(); 3230 if (isset($GLOBALS['hook_cache'][$cache_key])) { 3231 $hook_cache = $GLOBALS['hook_cache'][$cache_key]; 3234 $GLOBALS['egotec_conf']['lib_dir'] . 'type/site/' => 0, // System 3235 $GLOBALS['egotec_conf']['pub_dir'].'theme/'.$this->_site->theme.'/site/' => 'theme', // pub theme 3236 $GLOBALS['egotec_conf']['site_dir'] . '_global/' => 'global', // Global 3237 $GLOBALS['egotec_conf']['site_dir'] . $this->_site->name . '/' => 'misc' // Mandant 3239 foreach ($dirs as $dir => $flag) { 3240 if ($flag == 'global' && !$this->_site->globalAllowed()) { 3243 $script_path = $dir . 'admin/' . $hook . '.php'; 3244 if ($flag && Ego_System::file_exists($script_path)) { 3245 $hook_cache[] = array('path' => $script_path, 'flag' => $flag, 'type' => false); 3247 $script_path = $dir . $this->field['type'] . '/admin/' . $hook . '.php'; 3248 if (Ego_System::file_exists($script_path)) { 3249 $hook_cache[] = array('path' => $script_path, 'flag' => $flag ? $flag : 'misc', 'type' => true); 3252 if (!isset($GLOBALS['hook_cache'])) { 3253 $GLOBALS['hook_cache'] = array(); 3255 $GLOBALS['hook_cache'][$cache_key] = $hook_cache; 3258 if (!$this->field['type']) { 3259 throw new Exception(); 3261 foreach ($hook_cache as $script_path) { 3262 $call_func = $script_path['type'] 3263 ? 'site_'.$hook.'_'.str_replace('/', '_', $this->field['type']).'_'.$script_path['flag'] 3264 : 'site_' . $hook . '_' . $script_path['flag']; 3265 if (!function_exists($call_func)) { 3266 require_once($script_path['path']); 3268 if (function_exists($call_func)) { 3273 if (!isset($GLOBALS['hook_cache'])) { 3274 $GLOBALS['hook_cache'] = array(); 3276 $GLOBALS['hook_cache'][$cache_key] = $hook_cache; 3279 if (!$GLOBALS['egotec_setup']) { 3280 // Alle Verweise dieser Page sammeln 3281 if ($hook == 'update') { 3282 Ego_Queue::add(array($this, 'updateLinks')); 3285 if ($GLOBALS['egotec_conf']['rewrite_engine'] == 'url') { 3286 if ($hook == 'delete' || $this->field['inactive']) { 3287 // URLs dieser Page archivieren 3288 Ego_Queue::add(array($this, 'archiveUrls')); 3290 // URLs dieser Page aktualisieren 3291 if ($hook == 'newchild') { 3292 // Direkt ausführen, da die URLs direkt benötigt werden könnten 3293 $this->updateUrls(); 3295 Ego_Queue::add(array($this, 'updateUrls')); 3309 function updateField($field, $matrix_flag = true, $asis = false) { 3310 return $this->update(array('field' => $field), $matrix_flag, $asis); 3320 function updateChildren($children) { 3321 return $this->update(array('children' => $children), true, true); 3330 function updateParents($parents) { 3331 return $this->update(array('parents' => $parents), true, true); 3341 function updateExtra($extra, $matrix_flag = true, $asis = false) { 3342 return $this->update(array('extra' => $extra), $matrix_flag, $asis); 3355 function updateRights($rights, $matrix_flag = true) { 3356 return $this->update(array('rights' => $rights), $matrix_flag); 3370 function update($param = array(), $matrix_flag = true, $asis = false) { 3371 if (empty($param)) { 3372 // Aktuelle Daten speichern 3373 $reload = $this->_update(array( 3374 'field' => $this->field, 3375 'extra' => $this->extra, 3377 'rights' => $this->getRightsArray(), 3378 'users' => $this->getUsersArray() 3380 ), $matrix_flag, $asis); 3382 $reload = $this->_update($param, $matrix_flag, $asis); 3384 if($this->field['deleted'] == "1
") { 3385 $this->hookUpdate("delete"); 3386 $this->message.= $GLOBALS['auth']->translate('Die Seite wurde gelöscht.'); 3397 function updateIndex($search=null, $queue=true) { 3398 // Erfolgt der Aufruf über den Liveabgleich und ist die "ewige
" Cache aktiv, wird kein Suchindex aktualisiert 3400 // Zwischenspeicherungen aktualisieren nicht den Suchindex 3402 // Erfolgt der Aufruf über den Liveabgleich und ist die "ewige
" Cache aktiv, wird kein Suchindex aktualisiert 3403 || ($_SERVER['HTTP_X_SOAP_CALL'] == 'Replication' && $this->getSite()->getCache()->getEternal()) 3404 || !empty($GLOBALS['__skip_update_index']) 3410 require_once('base/Ego_Search_Factory.php'); 3411 $search = Ego_Search_Factory::start($this->_site->pageTable.$this->getTableSuffix()); 3414 // Relevanz der Felder beachten 3416 Ego_Queue::add(array($search, 'update'), array($this->field['id'], $this, $this->_site->getSearchCount($this->extra['search_weight']))); 3419 $search->update($this->field['id'], $this, $this->_site->getSearchCount($this->extra['search_weight'])); 3436 function getChildren($query=array(), $param=array()) { 3437 $page_table = $this->_site->name.'_'.($param['lang']?$param['lang']:$this->_site->language); 3438 $children_table = $page_table.'_children'; 3439 $query['table'] = $children_table; 3441 $query = $this->buildChildrenOrder($query, $param); 3443 $query['where'] = (isset($query['where'])?'('.$query['where'].') AND ':''). 3444 $children_table.'.page_id='.$this->field['id'].' AND '.$page_table.'.id='.$children_table.'.child'; 3445 return $this->_site->getPages($query, $param); 3455 public function buildChildrenOrder($query=array(), $param=array()) { 3456 $page_table = $this->_site->name.'_'.($param['lang']?$param['lang']:$this->_site->language); 3457 $children_table = $page_table.'_children'; 3458 $order = trim(isset($query['order'])?$query['order']:$this->field['children_order']); 3460 if ($order[strlen($order) -1]=='R') { 3461 // r steht für reverse 3462 $param['reverse'] = !$param['reverse']; 3463 $order = substr($order, 0, strlen($order) -1); 3467 $query['order'] = $page_table.'.title '.($param['reverse']?'desc':'asc'); 3470 $query['order'] = $page_table.'.name '.($param['reverse']?'desc':'asc'); 3473 $query['order'] = $page_table.'.a_date '.($param['reverse']?'desc':'asc'); 3476 $query['order'] = $page_table.'.c_date '.($param['reverse']?'desc':'asc'); 3478 case 'release_from': 3479 $query['order'] = $page_table.'.release_from '.($param['reverse']?'desc':'asc'); 3481 case 'release_until': 3482 $query['order'] = $page_table.'.release_until '.($param['reverse']?'desc':'asc'); 3485 $query['order'] = $page_table.'.order_field '.($param['reverse']?'desc':'asc'); 3488 $query['order'] = $page_table.'.order_field '.($param['reverse']?'asc':'desc'); 3491 $query['order'] = $page_table.'.type '.($param['reverse']?'desc':'asc').','.$page_table.'.name '.($param['reverse']?'desc':'asc'); 3494 unset($query['order']); 3497 $query['order'] = $children_table.'.idx '.($param['reverse']?'desc':'asc'); 3498 $query['fields2'] = ($query['fields2']?$query['fields2'].',':'').$children_table.'.idx'; 3500 if ($query['order'] && $query['order']!='id') { // Um die rückwärts gerichtete Sortierung korrekt zu bekommen, muss immer noch nach der id sortiert werden. 3501 $query['order'].= ','.$page_table.'.id '.($param['reverse']?'desc':'asc'); 3514 public function hasChildren($query = array(), $param = array()) { 3515 if (isset($this->field['has_children'])) { 3516 return !empty($this->field['has_children']); 3518 $children = $this->getChildren($query, $param); 3519 while ($children->nextPage()) { 3536 function getParents($query=array(), $param=array()) { 3537 $page_table = $this->_site->name.'_'.($param['lang']?$param['lang']:$this->_site->language); 3538 $children_table = $page_table.'_children'; 3539 $query['table'] = $children_table; 3540 $query['where'] = (isset($query['where'])?'('.$query['where'].') AND ':''). 3541 $children_table.'.child='.$this->field['id'].' AND '.$page_table.'.id='.$children_table.'.page_id'; 3542 return $this->_site->getPages($query, $param); 3554 function getAncestors($query=array(), $param=array()) { 3555 if ($this->field['deleted']) { 3556 $param = array_merge($param, array('deleted' => -1)); 3558 $ancestors_ids = $this->_getAncestorsIds($this, $param['children_query'], $param['children_param']); 3559 if ($param['id_list']) { 3560 return $ancestors_ids; 3562 if ($ancestors_ids) { 3563 $ancestors_ids = array_reverse($ancestors_ids); 3564 $query['where'] = (isset($query['where'])?'('.$query['where'].') AND ':''). 3565 'id IN ('.join(',', $ancestors_ids).')'; 3566 $query['proposed_order'] = array( 3568 'values' => $ancestors_ids 3570 return $this->_site->getPages($query, $param); 3572 return new Page_Iterator(); 3583 function getDescendants($query=array(), $param=array()) { 3584 $lang = $param['lang']?$param['lang']:$this->_site->language; 3585 $page_table = $this->_site->name.'_'.$lang; 3586 if (!$param['children_query']) { 3587 $param['children_query']['fields'] = 'id'; 3589 $param['children_query']['order'] = ''; 3590 $param['children_query']['hash'] = $this->field['id'].md5(serialize($param['children_query'])); 3591 $param['children_param']['has_children'] = 1; 3592 $param['children_param']['no_cache'] = 1; 3594 $cache = $this->_site->getCache(); 3595 $cache_key = '_desc_'.$this->field['id'].'_'. 3596 ($GLOBALS['auth'] ? $GLOBALS['auth']->getId() : 'guest').'_'. 3597 md5(serialize($param['children_query']).serialize($param['children_param'])).'_'. 3598 md5(serialize($this->_site->getHash())); 3599 $descendants_ids = $cache->get($cache_key); 3600 if ($descendants_ids === null) { 3601 $descendants_ids = array(); 3602 $this->_getDescendantsIds($this, $param['children_query'], $param['children_param'], $descendants_ids); 3603 if ($param['with_root']) { 3604 $descendants_ids[] = $this->field['id']; 3606 $cache->set($cache_key, $descendants_ids); 3608 if ($param['return_ids']) { 3609 return $descendants_ids; 3611 if ($descendants_ids) { 3612 $query['where'] = (isset($query['where'])? 3613 '('.$query['where'].') and ': 3615 // Oracle verträgt max. 1000 Elemente pro Liste 3616 $idgroups = array(); 3617 foreach (array_chunk($descendants_ids, 999) as $ids) 3619 // IDs splitten in 999-Häppchen 3620 $idgroups[] = $page_table.'.id in ('.implode(',', $ids).')'; 3622 $query['where'] .= '('.implode(' or ', $idgroups).')'; 3624 //$page_table.'.id in ('.join(',', $descendants_ids).')'; 3625 return $this->_site->getPages($query, $param); 3627 return new Page_Iterator(); 3646 function getSiblings($query=array(), $param=array(), $proposed_path=array()) { 3648 (!isset($query['limit']) && isset($param['next'])) 3649 || (isset($query['limit']) && !isset($param['next'])) 3650 || (!isset($query['limit']) && !isset($param['next'])) 3653 $parents_query = $param['parents_query']?$param['parents_query']:array(); 3654 if ($proposed_path) { 3655 $parents_query2 = $parents_query; 3656 $parents_query2['where'] = ($parents_query2['where']?$parents_query2['where'].' AND ':'').'id IN ('.join(',', $proposed_path).')'; 3657 $parents = $this->getParents($parents_query2, array( 3660 'only_active' => false 3662 $parent = $parents->nextPage(); 3665 $parent = $this->getParents($parents_query, array( 3668 'only_active' => false 3669 ))->nextPage(); /* @var $parent Page */ 3672 if ($param['without_self']) { 3673 $query['where'] .= (isset($query['where']) ? ' AND ' : '') . 'id != :self_id'; 3674 $query['bind']['self_id'] = $this->field['id']; 3677 $siblings = $parent->getChildren($query, $param); 3678 if ($param['next']) { // Nur die Geschwister ab der aktuellen Seite anzeigen. 3679 $siblings->setHaltId($this->field['id']); 3685 return new Page_Iterator(); 3695 function getLanguagePage($lang, $param = array()) { 3696 $site = clone $this->_site; /* @var $site Site */ 3698 $site->setLanguage($lang); 3699 } catch (Site_Exception $e) { 3700 if ($e->getCode() == Site_Exception::LANG_DOESNT_EXIST) { 3704 return $site->getPage($this->field['id'], $param); 3715 function createLanguagePage($lang, $param = array()) { 3716 if (!in_array($lang, $this->_site->getLanguages())) { 3717 throw new Site_Exception('Die Sprache existiert nicht', Site_Exception::LANG_DOESNT_EXIST); 3720 // Parameter um die Seite in jedem Fall zu erhalten 3723 'deleted_or' => '1=1', 3725 'only_active' => false 3728 if ($l_page = $this->getLanguagePage($lang, $l_param)) { // Übersetzte Seite existiert bereits, diese aktualisieren 3729 $field = is_array($param['field'])? $param['field']:array(); 3730 $extra = is_array($param['extra'])? $param['extra']:array(); 3740 // Felder und Extra vorbereiten 3741 $field = is_array($param['field'])? $param['field']:array(); 3742 $field['id'] = $this->field['id']; 3744 $extra = is_array($param['extra'])? $param['extra']:array(); 3746 // Elternseite ermitteln 3747 $parents = $this->getParents( 3752 'only_active' => false 3756 $parent = $parents->nextPage(); 3758 // Übersetzte Elternseite ermitteln 3759 $l_parent = $parent->getLanguagePage($lang, $l_param); 3761 if (!$l_parent) { // Übersetzte Elternseite existiert nicht, alle benötigten Vorfahren anlegen 3762 $path = $this->getPath(false, $GLOBALS['current_path'], false); 3764 // Ab der übersetzten Startseite alle Vorfahren durchgehen 3765 $_parent = $this->_site->getRoot()->getLanguagePage($lang, $l_param); 3767 foreach ($path as $pid) { 3768 // Übersetzten Vorfahren ermitteln 3769 $p = $this->_site->getPage($pid); 3770 $lp = $p->getLanguagePage( 3775 'only_active' => false 3779 if (!$lp) { // Übersetzter Vorfahre existiert nicht, eine inaktive Sprachkopie anlegen 3780 $copied_field = $p->field; 3781 $copied_field['inactive'] = self::INACTIVE_FLAG; 3783 $copied_extra = $p->extra; 3784 $lp = $_parent->newChild($copied_field, $copied_extra); 3785 } elseif ($lp->field['deleted']) { 3786 // Übersetzter Vorfahre wurde gelöscht, Seite wiederherstellen 3787 $restored_field = $p->field; 3789 unset($restored_field['deleted']); 3790 $restored_field['inactive'] = self::INACTIVE_FLAG; // Sprachkopie deaktivieren 3792 $lp->update($restored_field); 3795 // Nächste Elternseite ist die aktuelle übersetzte Seite 3799 // Alle Vorfahren wurden angelegt, jetzt die erwünschte übersetzte Seite anlegen 3800 $l_child = $_parent->newChild($field, $extra); 3801 } else { // Übersetzte Elternseite existiert, übersetzte Seite anlegen 3802 $l_child = $l_parent->newChild($field, $extra); 3805 // Mediapool kopieren 3806 $this->getMediapool()->copy($l_child); 3807 $l_child->getMediapool()->import(true); 3820 public function getKeywords($language = '', $own_keywords = false) { 3821 // Sprache muss gesetzt sein 3822 if ($language == '') { 3823 $language = $this->_site->language; 3826 // Die Keyword-Tabelle ermitteln: 3827 // Das Schlagwortregister eines anderen Mandanten verwenden 3828 // (kann im Adminbereich pro Mandant eingestellt werden) 3829 if ($this->_site->admin['keywords']['site'] && 3830 $this->_site->admin['keywords']['site'] != $this->_site->name 3832 $keyword_table = $this->_site->admin['keywords']['site'].'_'.$language.'_keywords'; 3834 $keyword_table = $this->_site->name.'_'.$language.'_keywords'; 3837 // In der Relationen-Tabelle befinden sich die Zuweisungen, 3838 // also welches Schlagwort zu welcher Seite gehört 3839 $relation_table = $this->_site->name.'_keywords_rel'; 3841 // Suche durchführen 3842 // Achtung! Diese Suche findet nur die Zuweisungen, 3843 // welche über den Pool verlinkt sind. 3844 // Nicht die eigenen Schlagworte, die in der Seite eingetragen wurden 3845 $db = new_db_connection(); 3847 if (!$db->tableExists($keyword_table)) { 3853 "table
" => "$keyword_table INNER JOIN $relation_table ON $keyword_table.id = $relation_table.keyword_id
", 3854 "where
" => 'page_id = '.$this->field['id'] 3857 // Alle Keywords sammeln 3858 $keywords = array(); 3860 // zunächst die Zuweisungen aus dem Pool 3861 $keywords_list = explode(',', $this->extra['keywords_list']); 3862 while ($result = $db->next()) { 3863 if (in_array($result['id'], $keywords_list)) { 3864 array_push($keywords,$result['word']); 3868 // die eigenen Keywords werden zusätzlich ins Extra-Feld kommasepariert gespeichert und hier auch ausgelesen 3869 if ($own_keywords && $this->extra['keywords_list_own']) { 3870 $tmp = explode(',', $this->extra['keywords_list_own']); 3871 $keywords = array_merge($keywords, $tmp); 3874 // Die Keyword-Liste kommasepariert ausgeben 3875 $keywords = implode(',', $keywords); 3876 return trim($keywords, ','); 3885 function addKeyword($word, $add_to_pool = false) { 3886 // Whitespaces entfernen und Wort prüfen 3887 $word = trim($word); 3893 * Das Schlagwortregister kann auch aus einem andreen Mandanten verwendet werden 3894 * Achtung! Wenn z.B. in einem deutschen Page-Objekt ein Keywords hinzugefügt wird, 3895 * dieser Mandant aber nicht in dieser Sprache existiert, 3896 * dann wird kein Schlagwort erstellt. 3898 if ($this->_site->admin['keywords']['site'] && $this->_site->admin['keywords']['site'] != $this->_site->name) { 3899 // Existenz der Sprache prüfen 3900 $keywordSite = new Site($this->_site->admin['keywords']['site'],$this->_site->language); 3902 $keywordSite = $this->_site; 3908 $k_db = new_db_connection(); 3909 $k_db->select(array( 3910 'table' => $keywordSite->pageTable.'_keywords', 3911 'where' => 'LOWER(word)=:word', 3912 'bind' => array('word' => strtolower($word)) 3920 $maxid = $k_db->Record['id']; 3922 // Die nächst höchste ID herausfinden von allen verfügbaren Sprachen des Mandanten 3924 foreach($keywordSite->getLanguages() as $sprache) { 3925 $u_db = new_db_connection(); 3926 $u_db->select(array( 3928 'table' => $keywordSite->name.'_'.$sprache.'_keywords', 3929 'order' => 'id DESC', 3933 $maxentry = $u_db->next(); 3934 if((int)$maxentry['id'] > $max) { 3935 $max = (int)$maxentry['id']; 3938 $maxid = $max+1; // Neue ID ist höchste ID + 1 3943 $k_db->insert(array( 3944 'table' => $keywordSite->pageTable.'_keywords', 3948 'c_date' => date('Y-m-d H:i:s'), 3949 'main' => 1, // Neues Wort ist immer der Hauptsprachbegriff 3950 'not_in_list' => ($add_to_pool) ? 0 : 1 // Im gesamten Schlagwortregister aufnehmen oder nicht 3966 $db2 = new_db_connection(); 3968 'table' => $keywordSite->name.'_keywords_rel', 3969 'where' => "page_id =
'".$this->field['id']."' AND keyword_id =
'".$maxid."'", 3970 'order' => 'page_id', 3974 return true; // alles ok, Schlagwort ist bereits zugewiesen 3977 if ($k_db->insert(array( 3978 'table' => $keywordSite->name.'_keywords_rel', 3980 'page_id' => $this->field['id'], 3981 'keyword_id' => $maxid, 3982 'c_date' => date('Y-m-d H:i:s') 3983 )))) { // Abwärtskompatibilität Schlagworte auch in die Extra-Felder "keywords_list
" und "keywords_list_own
" schreiben 3984 // Alle zugewiesenden Schlagwort-Ids auslesen 3985 $k_db->select(array( 3986 'table' => $keywordSite->name.'_keywords_rel', 3987 'where' => "page_id =
'".$this->field['id']."'" 3990 while ($entry = $k_db->next()) { 3991 $entries[] = $entry['id']; 3994 // Alle Schlagworte auslesen 3995 $k_db->select(array( 3996 'table' => $keywordSite->pageTable.'_keywords', 3997 'where' => "id IN (
'".implode("',
'", $entries)."')
" 4000 $keywords_list = array(); 4001 $keywords_list_own = array(); 4002 while ($entry = $k_db->next()) { 4004 if ($entry['not_in_list'] == "1
") { 4005 $keywords_list_own[] = $entry['word']; 4007 $keywords_list[] = $entry['id']; 4011 // Schlagworte bzw. SchlagwortIDs kommasepariert ins extra-Feld 4012 if ($keywords_list || $keywords_list_own) { 4013 $this->extra['keywords_list'] = implode(",
",$keywords_list); 4014 $this->extra['keywords_list_own'] = implode(",
",$keywords_list_own); 4015 $this->updateExtra($this->extra,true); 4030 function getUrl($param = array()) { 4031 if (($this->extra['image_type'] || $param['pool']) && !$param['download'] && !$param['thumbnail']) { // Multimediaendung setzen. 4032 if (!$param['no_suffix'] && $this->extra['image_type']) { 4033 $param['suffix'] = $this->extra['image_type']; 4035 unset($param['no_suffix']); 4037 /* Bild URLs müssen immer width und height Parameter beinhalten. 4038 * Wird nur width oder nur height übergeben, dann muss der Gegenwert 4039 * relativ berechnet werden (Skalierung). 4040 * Wird keiner der Parameter übergeben, dann werden die Originalwerte 4041 * verwendet (origImgWidth und origImgHeight). 4042 * Werden beide Parameter übergeben, dann werden diese verwendet. 4043 * Wird ein ungültiger Wert übergeben, dann wird der Parameter aus der URL entfernt. 4044 * Die URL Auflösung skaliert automatisch, 4045 * wenn nur width oder nur height in der URL vorkommt.*/ 4046 $param = $this->addImageParams($param); 4048 if (!$param['lang'] || $param['lang'] == $this->_site->language) { 4049 // Wird die URL für die aktuelle Seite angefordert, ist das Page Objekt bereits bekannt 4050 return $this->_site->getPageUrl($this->field['id'], $param, $this); 4052 return $this->_site->getPageUrl($this->field['id'], $param); 4061 public function getFrontendUrl($param = array()) { 4062 $now = date('Y-m-d H:i:s'); 4064 $this->field['inactive'] > 0 4065 || ($this->field['release_from'] != '0000-00-00 00:00:00' && $this->field['release_from'] > $now) 4066 || ($this->field['release_until'] != '0000-00-00 00:00:00' && $this->field['release_until'] < $now) 4067 || $this->isWorkflowCopy() 4068 || $this->isReleaseCopy() 4072 $param['get_frontend_url'] = true; 4073 return $this->getUrl($param); 4082 public function getLiveUrl($param = array()) { 4083 if (((int) $this->field['nav_hide']&2) == 2) { 4084 // Es gibt keine Liveserver URLs für Seiten, die nicht auf dem Liveserver existieren dürfen 4088 // Immer eine absolute URL erzeugen 4089 $param['return_absolute'] = true; 4091 if (!$GLOBALS['egotec_conf']['liveserver']) { 4092 // URL vom (ersten) Liveserver erzeugen 4093 $clusters = Ego_System::getCluster(); 4094 array_walk($clusters, function (&$value) { 4095 $value = $value['url']; 4097 $liveservers = array_values(array_filter(array_merge([$this->_site->admin['live']['location']], $clusters))); 4099 if (!empty($liveservers)) { 4100 // Liveserver URL setzen 4101 $live = $this->_site->admin['live']; 4102 $live['location'] = $liveservers[0]; 4104 require_once('soap/Ego_SOAP.php'); 4105 $soap = new Ego_SOAP($live, 1); 4107 return $soap->soapCall('pageGetUrl', [ 4108 'site' => $this->_site->name, 4109 'lang' => $this->_site->language, 4110 'id' => $this->field['id'], 4111 'param' => soap_var($param) 4113 } catch (Exception $e) { 4119 // URL von diesem Server erzeugen 4120 return $this->getFrontendUrl($param); 4128 public function getCloneUrl() { 4129 return 'index.php?' . http_build_query(array( 4130 'id' => $this->field['id'], 4131 'site' => $this->_site->name, 4132 'lang' => $this->_site->language 4141 public function getCloneOriginal() { 4142 if ($this->isClone()) { 4145 'deleted_or' => '1=1', 4147 'only_active' => false 4149 if (is_numeric($this->extra['clone_original'])) { // abwärtskompatibel 4150 $page = $this->_site->getPage($this->extra['clone_original'], $param); 4152 $page = Ego_System::urltopage($this->extra['clone_original'], array( 4175 function lock($user_id='') { 4177 $user_id = $GLOBALS['auth']->getId(); 4180 // bei einem anonymen Benutzer wird eine Kombination aus remote_addr und user_agent gespeichert #93240 4181 $user_id = $GLOBALS['auth']->getAnonymousId(); 4184 $db = new_db_connection(array( 4185 'fields' => 'egotec_page_lock.*,egotec_user.*, egotec_page_lock.user_id AS lock_user_id', 4186 'table' => 'egotec_page_lock', 4187 'join' => 'egotec_user on egotec_page_lock.user_id=egotec_user.user_id', 4188 'where' => "(page_table=
'".$this->_site->pageTable."') AND (page=
".$this->field['id'].")
" 4190 if ($db->nextRecord()) { 4192 $db->Record['stamp'] >= (time() - $GLOBALS['egotec_conf']['page_timeout']) 4193 && $db->Record['user_id'] != $user_id 4195 $db->Record['extra'] = unserialize($db->Record['extra']); 4199 'table' => 'egotec_page_lock', 4201 'user_id' => $user_id, 4204 'where' => "page_table =
'{$this->_site->pageTable}' AND page = {$this->field[
'id']}
" 4212 'table' => 'egotec_page_lock', 4214 'page_table' => $this->_site->pageTable, 4215 'page' => $this->field['id'], 4216 'user_id' => $user_id, 4221 } catch (Exception $e) { 4232 function unlock($user_id=false) { 4233 $db = new_db_connection(); 4234 if ($user_id === false) { 4235 $user_id = $GLOBALS['auth']->getId(); 4238 // bei einem anonymen Benutzer wird eine Kombination aus remote_addr und user_agent gespeichert #93240 4239 $user_id = $GLOBALS['auth']->getAnonymousId(); 4242 'table' => 'egotec_page_lock', 4244 (page_table=
'".$this->_site->pageTable."') AND
4245 (page=
".$this->field['id'].") AND
4246 (user_id=
'$user_id')
" 4258 public function isLocked($exclude_self = true) { 4259 $where = 'page_table = :page_table AND page = :page AND stamp >= :stamp'; 4261 'page_table' => $this->_site->pageTable, 4262 'page' => $this->field['id'], 4263 'stamp' => time() - $GLOBALS['egotec_conf']['page_timeout'] 4265 if ($exclude_self) { 4266 $where .= ' AND user_id != :user_id'; 4267 $bind['user_id'] = $GLOBALS['auth']->isNobody() 4268 ? $GLOBALS['auth']->getAnonymousId() 4269 : $GLOBALS['auth']->getId(); 4271 $db = new_db_connection(array( 4272 'table' => 'egotec_page_lock', 4276 if ($db->nextRecord()) { 4278 'user' => new User_SQL($db->Record['user_id']), 4279 'stamp' => $db->Record['stamp'] 4291 function getRightsArray($perm_type='') { 4292 $db = $this->_getRights($perm_type); 4294 while ($db->nextRecord()) { 4295 $a[$db->Record['perm']][] = array( 4296 'group_id' => $db->Record['group_id'], 4297 'role_id' => $db->Record['role_id'] 4300 // Für alle Felder in denen kein IS NULL verwendet werden darf muss später ein *|* eingetragen werden 4302 $no_null_fields = explode(',', trim(Auth::NO_NULL_RIGHTS, ',')); 4303 foreach ($no_null_fields as $f) { 4306 // Das Veröffentlichen Recht ist standardmäßig immer root/Administrator 4308 'group_id' => $GLOBALS['egotec_conf']['superuser']['group'], 4309 'role_id' => $GLOBALS['egotec_conf']['superuser']['role'] 4327 public function getRights($perm_type='') { 4328 return $this->_getRights($perm_type); 4336 function setRightsArray($rights) { 4337 $db = new_db_connection(); 4339 $table = $this->_site->pageTable.'_rights'; 4342 'where' => "page_id=
".$this->field['id'] 4344 $set = array(); // Doppelte Einträge vermeiden 4345 foreach ($rights as $perm => $perm_rights) { 4346 if ($perm_rights) { // $perm_rights könnte auch null sein. 4347 foreach ($perm_rights as $right) { 4348 if ($right['group_id'] && $right['role_id']) { // Nur einfügen, wenn tatsächlich eine GroupID und RoleID angegeben ist. 4349 $key = $this->field['id'].'.'.$perm.'.'.$right['group_id'].'.'.$right['role_id']; 4350 if (!in_array($key, $set)) { 4354 'page_id' => $this->field['id'], 4356 'group_id' => $right['group_id'], 4357 'role_id' => $right['role_id'] 4375 function getUsersArray($perm_type='') { 4376 $db = $this->_getUsers($perm_type); 4378 while ($db->nextRecord()) { 4379 $a[$db->Record['perm']][] = array( 4380 'user_id' => $db->Record['user_id'] 4391 function setUsersArray($users) { 4392 $db = new_db_connection(); 4393 $table = $this->_site->pageTable.'_users'; 4396 'where' => "page_id=
".$this->field['id'] 4398 $set = array(); // Doppelte Einträge vermeiden 4399 foreach ($users as $perm => $perm_users) { 4400 if ($perm_users) { // $perm_users könnte auch null sein. 4401 foreach ($perm_users as $user) { 4402 if ($user['user_id']) { // Nur einfügen, wenn tatsächlich eine UserID angegeben ist. 4403 $key = $this->field['id'].'.'.$perm.'.'.$user['user_id']; 4404 if (!in_array($key, $set)) { 4408 'page_id' => $this->field['id'], 4410 'user_id' => $user['user_id'] 4426 public function getSite() { 4427 return $this->_site; 4435 public function getMediapool() { 4436 return $this->_pool; 4445 public function hasParent($parent_id) { 4446 $db = new_db_connection(array( 4447 'table' => $this->_site->pageTable.'_children', 4448 'where' => 'page_id='.$parent_id.' AND child='.$this->field['id'] 4450 return $db->nextRecord() !== null; 4460 public function addParent($parent_id, $asis=false) { 4461 $this->archiveOnly = false; 4462 if (!$this->_addParent($parent_id)) { 4465 $this->_updateField(array(), true, $asis); // Änderungsdatum aktualisieren und Cache löschen. 4466 $this->hookUpdate(); 4478 public function addChild($child_id='', $child_id2='') { 4480 $child_id = $child_id2; 4482 $this->_site->getPage($child_id)->addParent($this->field['id']); 4492 public function delParent($parent_id, $asis=false) { 4493 $this->archiveOnly = false; 4494 $this->_removeParent($parent_id); 4495 $this->_updateField(array(), true, $asis); // Änderungsdatum aktualisieren und Cache löschen. 4496 $this->hookUpdate(); 4504 public function isWriteable(){ 4505 if (!$this->hasRights(array('edit'))) { 4508 $this->_site->admin['workflow']['enabled'] // Workflow ist aktiviert 4509 && $this->field['workflow'] // UND und für dieser Seite ist ein Workflow zugewiesen 4510 && !(int)$this->extra['original_id'] // UND bei der Site handelt es sich NICHT um eine Worflow-Kopie 4511 && !$this->hasRights('workflow') // UND der aktuelle User hat NICHT das Recht den Workflow zu ändern 4523 public function isRoot() { 4524 return ($this->field['id'] == $this->_site->rootId); 4538 public function getPath($with_root=true, $proposed_path=array(), $return_string=true, $query=array('fields' => 'id,name,url'), $param = array(), &$assorted = null) { 4539 if ($this->field['id'] == $this->_site->rootId) { 4540 // Die Startseite hat keinen Pfad 4542 // ...und gibt maximal sich selbst aus 4543 if ($return_string == 2 && $return_string != 1) { 4544 return array($this); 4545 } elseif ($return_string) { 4546 if ($GLOBALS['egotec_conf']['meta_in_path']) { 4547 return Ego_System::encode_path(empty($this->field['url'])?$this->field['name']:$this->field['url']).'/'; 4549 return Ego_System::encode_path($this->field['name']).'/'; 4552 return array($this->field['id']); 4555 return in_array($return_string, array(1, true), true) ? '' : array(); 4558 !$proposed_path && is_array($GLOBALS['current_path']) 4560 $proposed_path = $GLOBALS['current_path']; 4562 $proposed_path[] = $this->field['id']; 4563 $ancestor_ids = array(); 4565 $this->getAncestors( 4566 array('fields' => 'id'), 4567 array_merge($param, array( 4568 'auth_or' => '1=1', 'inactive' => self::INACTIVE_FLAG, 4569 'children_query' => array('where' => "type !=
'_keywords/entry'"), 4570 'children_param' => array('auth_or' => '1=1', 'inactive' => self::INACTIVE_FLAG) 4573 as $page) { // Alle möglichen Pfade der aktuellen Seite. 4574 $ancestor_ids[] = $page->field['id']; 4576 $ancestor_ids[] = $this->field['id']; 4577 if ($ancestor_ids) { 4578 $ancestor_where = ' AND id IN ('.join(',', $ancestor_ids).')'; 4580 $page = $this->_site->getRoot(array('auth_or' => '1=1')); 4582 if ($return_string == 2 && $return_string != 1) { 4583 $path[] = $this->_site->getPage($this->_site->rootId, array('auth_or' => '1=1')); 4584 } elseif ($return_string) { 4585 if ($GLOBALS['egotec_conf']['meta_in_path']) { 4586 $path = Ego_System::encode_path(empty($page->field['url'])?$page->field['name']:$page->field['url']).'/'; 4588 $path = Ego_System::encode_path($page->field['name']).'/'; 4591 $path[] = $this->_site->rootId; 4594 $path = in_array($return_string, array(1, true), true) ? '' : array(); 4596 while ($page->field['id']!=$this->field['id'] && $page) { 4597 $proposed_id = array_shift($proposed_path); 4598 if ($proposed_id==$page->field['id']) { 4599 $proposed_id = array_shift($proposed_path); 4601 if ($proposed_id && is_numeric($proposed_id)) { 4602 $children = $page->getChildren( 4604 'fields' => $query['fields'], 4605 'where' => 'id=:id'.$ancestor_where, 4608 'id' => $proposed_id 4611 'auth_or' => '1=1', 'inactive' => self::INACTIVE_FLAG 4614 $child = $children->nextPage(); 4619 $children = $page->getChildren( 4621 'fields' => $query['fields'], 4622 'where' => '1=1 '.$ancestor_where, 4625 'auth_or' => '1=1', 'inactive' => self::INACTIVE_FLAG 4628 $child = $children->nextPage(); 4633 if ($child->field['id']==$this->field['id']) { 4636 if ($child->field['inactive'] == self::ACTIVE_FLAG) { 4637 if ($return_string == 2 && $return_string != 1) { 4639 } elseif ($return_string) { 4640 if ($_SESSION['export']) { 4641 $path.='-p-'.$child->field['id'].'/'; 4643 if ($GLOBALS['egotec_conf']['meta_in_path']) { 4644 $path.= Ego_System::encode_path(empty($child->field['url'])?$child->field['name']:$child->field['url']).'/'; 4646 $path.= Ego_System::encode_path($child->field['name']).'/'; 4650 $path[] = $child->field['id']; 4655 // Prüfen, ob der Pfad wirklich eindeutig ist (keine Seite im Pfad hat in selber Ebene eine gleichnamige Seite) 4656 if ($assorted === false) { 4657 $siblings = $page->getSiblings(array( 4658 'fields' => 'id,url,name', 4659 'where' => '(url = :name1 OR name = :name2)', 4661 'name1' => $child->field['name'], 4662 'name2' => $child->field['name'] 4664 ), array('auth_or' => '1=1')); 4665 if ($siblings->numRecords() > 1) { 4680 public function getPaths($with_root = false, $in_root = false) { 4682 $get_path = function($page, $path = array()) use (&$get_path, &$paths, $with_root, $in_root) { 4683 if (!$with_root && $page->field['id'] == $this->_site->rootId) { 4687 $get_name = function($page) { 4688 $names = $page->getUrlNames(); 4690 'name' => $names[0], 4691 'id' => (int) $page->field['id'] 4695 $original_path = $path; 4696 foreach ($page->getParents(array(), array( 4698 'deleted_or' => '1=1', 4700 'only_active' => false 4702 if ($index++ == 0) { 4704 $path[] = $get_name($parent); 4705 $path = $get_path($parent, $path); 4706 if (empty($path) && $in_root && $parent->field['id'] == $page->getSite()->rootId) { 4707 // Pfad direkt unter der Startseite aufnehmen 4710 'id' => $with_root ? (int) $parent->field['id'] : '' 4715 $tmp_path = $original_path; 4716 $tmp_path[] = $get_name($parent); 4717 $paths[] = $get_path($parent, $tmp_path); 4722 $path = $get_path($this); 4723 if (!empty($path)) { 4726 if (!empty($paths)) { 4727 $paths = array_reverse(array_map('array_reverse', $paths)); 4728 $grouped_paths = array(); 4729 foreach ($paths as $index => $path) { 4730 foreach ($path as $entry) { 4731 foreach ($entry as $key => $value) { 4732 $grouped_paths[$index][$key][] = $value; 4736 foreach ($grouped_paths as $index => $path) { 4737 foreach ($path as $key => $values) { 4738 $grouped_paths[$index][$key] = implode($key == 'name' ? '/' : ',', $values); 4741 return $grouped_paths; 4751 public function hasMultiParents(){ 4752 return ((integer)$this->getParents(array(), array('auth_or'=>'1=1'))->numRecords())>1; 4755 static function unserialize ($session_value) { 4756 $obj = @unserialize($session_value); 4757 if (get_class($obj) == '__PHP_Incomplete_Class') { 4763 $session_value = preg_replace('/^O:\d+:"Page.*?
":/msi', 'O:4:"Page":', $session_value); 4764 $obj = @unserialize($session_value); 4765 if (get_class($obj) == '__PHP_Incomplete_Class') { 4772 public function serialize (){ 4773 return serialize($this); 4776 public function __toString(){ 4777 return get_class($this).'('.$this->getIdentity().')'; 4786 protected function _cleanEmptyContent(&$field) { 4787 if ($this->field['type']=="code
") { 4791 if ($field['content']) { // der neue Content 4792 $str = $field['content']; 4793 } else { // der alte Content 4794 $str = $this->field['content']; 4798 if (Ego_System::isEmptyContent($str)) { 4799 $field['content'] = ''; // richtig leeren 4810 public function cleanEmptyContent($asis=false) { 4812 $field['content'] = $this->field['content']; 4813 $vorher = strlen($field['content']); 4814 $this->_cleanEmptyContent($field); 4815 $nachher = strlen($field['content']); 4816 if ($vorher != $nachher) { 4820 $this->update($param,array(),true, $asis); 4836 public function getMediaFilename($force_lang = false, $suffix = "") { 4837 $dir = $GLOBALS['egotec_conf']['var_dir'].'media/'.$this->_site->name.'/'; 4838 $id = $this->field['id'].$suffix; 4839 $filename = $this->_site->language.'/'.$id; 4841 // Verzeichnis für die Sprache anlegen 4842 Ego_System::mkdir($dir.$this->_site->language); 4845 Ego_System::file_exists($dir.$filename) // Datei existiert in dieser Sprache 4846 || $force_lang // ID und Sprache muss ausgegeben werden 4850 $this->_site->language != $this->_site->site['default_language'] 4851 && Ego_System::file_exists($dir.$this->_site->site['default_language'].'/'.$id) 4853 // Datei existiert aber in der Standard Sprache 4854 return $this->_site->site['default_language'].'/'.$id; 4857 // Nur die ID ausgeben 4867 public function addImageParams($param = array()) { 4868 $width = $param['width']; 4869 $height = $param['height']; 4870 $orig_width = $orig_height = null; 4872 // Die originale Breite/Höhe wird übergeben 4873 foreach (array('width', 'height') as $key) { 4874 if (isset($param['original_' . $key])) { 4875 $var = 'orig_' . $key; 4876 ${$var} = (int) $param['original_' . $key]; 4877 unset($param['original_' . $key]); 4887 $use_clip = function($clip) use (&$orig_width, &$orig_height) { 4888 list($x1, $y1, $x2, $y2) = explode(',', $clip, 4); 4889 $orig_width = $x2 - $x1; 4890 $orig_height = $y2 - $y1; 4893 if ($this->extra['image_type']) { 4895 $orig_width = $this->extra['origImgWidth']; 4896 $orig_height = $this->extra['origImgHeight']; 4897 if (!empty($this->extra['edit']['clip'])) { 4898 $use_clip($this->extra['edit']['clip']); 4900 } elseif (isset($param['pool'])) { 4902 $pool = $this->getMediapool()->get($param['pool'], $param['dir']); 4903 if (!empty($pool) && $pool['isImage']) { 4904 $size = getimagesize($pool['file']); 4905 $orig_width = $size[0]; 4906 $orig_height = $size[1]; 4907 if (!empty($pool['clip'])) { 4908 $use_clip($pool['clip']); 4910 } elseif (!$orig_width && !$orig_height) { 4917 if (is_numeric($param['width'])) { 4919 is_numeric($orig_width) 4920 && is_numeric($orig_height) 4921 && !isset($param['height']) 4923 $width = $param['width']; 4924 $height = ceil($orig_height * ($param['width'] / $orig_width)); 4926 } elseif (is_numeric($orig_width) && !isset($param['height'])) { 4927 $width = $orig_width; 4929 if (is_numeric($param['height'])) { 4931 is_numeric($orig_height) 4932 && is_numeric($orig_width) 4933 && !isset($param['width']) 4935 $width = ceil($orig_width * ($param['height'] / $orig_height)); 4936 $height = $param['height']; 4938 } elseif (is_numeric($orig_height) && !isset($param['width'])) { 4939 $height = $orig_height; 4941 if (is_numeric($width)) { 4942 $param['width'] = $width; 4944 unset($param['width']); 4946 if (is_numeric($height)) { 4947 $param['height'] = $height; 4949 unset($param['height']); 4960 public function hasLanguageFile($lang) { 4961 $dir = $GLOBALS['egotec_conf']['var_dir'].'media/'.$this->_site->name.'/'; 4962 $filename = $lang.'/'.$this->field['id']; 4964 return file_exists($dir.$filename); 4975 public function destroyFile(){ 4976 $dir = $GLOBALS['egotec_conf']['var_dir'].'media/'.$this->_site->name.'/'; 4977 $filename = $this->_site->language.'/'.$this->field['id']; 4979 if (file_exists($dir.$filename)) { 4980 unlink($dir.$filename); 4983 $mediafiles = glob($dir.$filename.'_*'); 4984 if (is_array($mediafiles)) { 4985 foreach ($mediafiles as $mediafile) { 4990 // Die Seite existiert ohne Sprache und die aktuelle Sprache ist die Standard Sprache 4991 if ($this->_site->language == $this->_site->site['default_language']) { 4992 $filename = $this->field['id']; 4994 if (file_exists($dir.$filename)) { 4995 unlink($dir.$filename); 4998 $mediafiles = glob($dir.$filename.'_*'); 4999 if (is_array($mediafiles)) { 5000 foreach ($mediafiles as $mediafile) { 5013 public function getProtocol($site = null) { 5015 $site = $GLOBALS['site']; 5018 ($_SERVER['HTTPS'] == 'on' 5020 && $site->name == $this->_site->name 5021 && $site->language == $this->_site->language) 5022 || !empty($this->extra['https']) ? 's' : '' 5031 public function getInformationLocked() { 5033 $params['tpl_name'] = 'information_locked.html'; 5034 if ($this->field['type'] == 'multimedia/image') { 5035 $params['tpl_name'] = 'information_locked_image.html'; 5037 $file_name = $GLOBALS['egotec_conf']['site_dir'].$this->_site->name.'/'.$this->field['type'].'/admin/navigation.ini'; 5038 if (!file_exists($file_name)) { 5039 $file_name = $GLOBALS['egotec_conf']['site_dir'].$this->_site->name.'/admin/navigation.ini'; 5040 if ($this->_site->globalAllowed() && !file_exists($file_name)) { 5041 $file_name = $GLOBALS['egotec_conf']['site_dir'].'_global/admin/navigation.ini'; 5044 if (file_exists($file_name)) { 5045 $navigation = parse_ini_file($file_name, true); 5046 foreach ($navigation as $key => $value) { 5047 if (stripos($value['url'], 'info.php?') === 0) { 5048 if (preg_match_all('/([^\?&=]+)=([^\?&=#]*)/', $value['url'], $matches)) { 5049 foreach ($matches[0] as $index => $match) { 5050 if ($matches[1][$index] != 'tpl_name') { 5051 $params[$matches[1][$index]] = $matches[2][$index]; 5059 $params['url'] = 'extra.php?'.http_build_query($params); 5070 public function getContent($main_orient = false, $variant = '') { 5072 if ($variant != '') { 5073 // Block Variante global weiterreichen, damit alle Aufrufe im fetch() darauf zugreifen können 5074 $GLOBALS['_block_variant'] = $variant; 5076 if ($this->isFrontendAdmin(false)) { 5078 // Nur die Blöcke der Haupt-Orientierung 5079 $content = $this->getBlocks($this->mainOrient, $variant); 5081 require_once('smarty/Ego_Smarty.php'); 5082 $smarty = Ego_Smarty::createFrontend($this->_site, array( 5085 $smarty->autoload_filters['output'] = array('frontend_edit'); 5086 if ($layout = $this->getLayout($GLOBALS['is_mobile'])) { 5087 $content = $smarty->fetch($layout); 5091 if ($content == '') { 5092 $content = $this->field['content']; 5094 unset($GLOBALS['_block_variant']); 5107 public function getLayout($mobile = false, $name = '', $suffix = '', &$script = '') { 5108 // Layout Template ermitteln 5109 if (empty($suffix)) { 5110 $suffix = $_SERVER['REQUEST_SUFFIX']; 5112 $suffix = $suffix != '.html' ? $suffix : ''; 5113 $name = $name ? $name : $this->extra['_layout']; 5114 $cache_key = 'pageLayout'.md5(serialize(array($this->field['type'], $name, $mobile, $suffix))); 5115 $layout = $this->_site->getCacheEntry($cache_key); 5117 if ($layout === null) { 5120 foreach (array('.tpl', '.html') as $file_suffix) { 5121 if (!empty($name) && $name != 'default') { 5123 ($file = $this->_site->getSkinFile("{$this->field[
'type']}/layouts/{$name}{$suffix}{$file_suffix}
")) 5124 || ($file = $this->_site->getSkinFile("layouts/{$name}{$suffix}{$file_suffix}
")) 5130 ($file = $this->_site->getSkinFile("{$this->field[
'type']}/layout{$suffix}{$file_suffix}
")) 5131 || ($file = $this->_site->getSkinFile("layout{$suffix}{$file_suffix}
")) 5137 if (empty($layout)) { 5138 if ($suffix != '') { 5139 $layout = $this->getLayout($mobile, $name, '.html'); 5140 } elseif ($name != $this->conf['default_layout']) { 5141 $layout = $this->getLayout($mobile, $this->conf['default_layout'], '.html'); 5144 $this->_site->setCacheEntry($cache_key, $layout); 5147 // Layout Skript ermitteln 5148 $cache_key = 'pageLayoutScript'.md5(serialize(array($this->field['type'], $name, $mobile, $suffix))); 5149 $script = $this->_site->getCacheEntry($cache_key); 5151 if ($script === null) { 5154 if (!empty($name) && $name != 'default') { 5155 if ($name == 'default') { 5157 ($file = $this->_site->getSiteFile("{$this->field[
'type']}/layout{$suffix}.php
")) 5158 || ($file = $this->_site->getSiteFile("layout{$suffix}.php
")) 5163 ($file = $this->_site->getSiteFile("{$this->field[
'type']}/layouts/{$name}{$suffix}.php
")) 5164 || ($file = $this->_site->getSiteFile("layouts/{$name}{$suffix}.php
")) 5172 ($file = $this->_site->getSiteFile("{$this->field[
'type']}/layout{$suffix}.php
")) 5173 || ($file = $this->_site->getSiteFile("layout{$suffix}.php
")) 5178 $this->_site->setCacheEntry($cache_key, $script); 5190 public function getLayouts($skip = array()) { 5191 $layouts = $this->_site->getLayoutFiles($this->field['type'], $skip, $this->conf['layouts']); 5193 // Nur bestimmte Layouts sind für diese Page erlaubt 5194 $info = $this->getTypeInfo(); 5195 if (!empty($info['layouts'])) { 5196 return array_intersect_key($layouts, array_flip(explode(',', $info['layouts']))); 5199 // Bestimmte Layouts deaktivieren 5200 if (!empty($this->conf['layouts'])) { 5201 foreach ($this->conf['layouts'] as $layout => $conf) { 5202 if ($conf['disabled']) { 5203 unset($layouts[$layout]); 5220 public function getTemplate($mobile = false, $name = 'body', $variant = '') { 5221 return $this->_site->getTemplate($mobile, $name, $this->field['type'], $variant ? $variant : (string) $this->extra['_template']); 5230 public function getContents($orient) { 5231 return $this->extra['_contents'][$orient]; 5245 public function getScripts() { 5247 $GLOBALS['egotec_conf']['site_dir'] . $this->_site->name . '/index.php', 5248 $this->_site->getSiteFile($this->field['type'] . '/index.php') 5250 if ($this->_site->globalAllowed()) { 5251 // Für diesen Mandanten ein globales Skript verwenden 5252 array_unshift($scripts, $GLOBALS['egotec_conf']['site_dir'] . '_global/index.php'); 5254 if (!empty($this->_site->theme)) { 5255 array_splice($scripts, 2, 0, $this->_site->getSiteFile('index.php', array('module', 'custom', 'global', 'parent_custom'))); 5257 $existing_scripts = []; 5258 foreach ($scripts as $script) { 5259 if ($script && Ego_System::file_exists($script)) { 5260 $existing_scripts[] = $script; 5263 return $existing_scripts; 5273 public function hasBlock($block, $orient = '') { 5275 if (is_array($this->extra['_blocks'])) { 5276 foreach ($this->extra['_blocks'] as $_orient => $blocks) { 5277 if (!$orient || $orient == $_orient) { 5278 $values = array_count_values($blocks); 5279 if (isset($values[$block])) { 5280 $n += $values[$block]; 5296 public function getBlocks($orient, $variant = '', $page_frame = false) { 5297 // Keine Blöcke ausgeben 5298 if ($GLOBALS['__no_blocks']) { 5302 if ($variant == '') { 5303 if (isset($GLOBALS['_block_variant'])) { 5304 // Die Block Variante wird global weitergereicht 5305 $variant = $GLOBALS['_block_variant']; 5306 } elseif (in_array($_SERVER['REQUEST_SUFFIX'], array('.pdf', '.print'))) { 5307 // Block Varianten für .pdf und .print verwenden 5308 $variant = ltrim($_SERVER['REQUEST_SUFFIX'], '.'); 5311 $layout = $this->extra['_layout']; 5312 $blocks = $this->extra['_blocks'][$orient]; 5314 if (!is_array($blocks) || empty($blocks)) { 5315 // Standard Blöcke verwenden 5317 if (empty($layout)) { 5318 $layout = $this->conf['default_layout']; // Standard Layout verwenden 5321 if (!empty($this->conf['layouts'][$layout]['blocks'][$orient]['default'])) { 5323 $blocks = explode(',', $this->conf['layouts'][$layout]['blocks'][$orient]['default']); 5325 if (empty($blocks) && $orient == $this->mainOrient && empty($this->conf['no_template'])) { 5326 // Keine Blöcke und die Haupt-Orientierung: Immer das Standard Template verwenden 5327 $blocks[] = 'template'; 5331 // Standard Template immer anzeigen, wenn 5333 $this->field['type'] != 'page' // ...nicht der Standard Seitentyp verwendet wird 5335 // Der Seitentyp besitzt ein eigenes body Template und das Standard Template wird immer angezeigt 5336 // @TODO Nur wenn das Template aus dem Systemstandard kommt? 5337 $body_template = null; 5338 $default_template = $GLOBALS['egotec_conf']['lib_dir'] . 'type/skin/page/body.html'; 5339 $get_body_template = function() use (&$body_template, $variant) { 5340 if (!$body_template) { 5341 $body_template = $this->getTemplate($GLOBALS['is_mobile'], 'body', $variant); 5343 return $body_template; 5346 // Das Standard Template darf nicht entfernt werden, wenn 5348 $this->conf['blocks']['template']['removable'] !== true // ...nicht explizit das Entfernen erlaubt ist 5349 && $get_body_template() != $default_template // ...der Seitentyp ein eigenes body Template besitzt 5351 $this->conf['blocks']['template']['removable'] = false; 5354 // Das Standard Template muss für nicht Standard Seitentypen immer vorhanden sein 5356 $orient == $this->mainOrient // ...nur für die Haupt-Orientierung 5357 && !in_array('template', $blocks) // ...und das Standard Template nicht bereits eingebunden wird 5358 && $this->conf['blocks']['template']['removable'] !== true // ...außer es darf explizit entfernt werden 5359 && $get_body_template() != $default_template // ...der Seitentyp ein eigenes body Template besitzt 5361 $blocks[] = 'template'; 5365 // HTML aller Blöcke zusammenfügen 5367 if (!empty($blocks)) { 5368 foreach ($blocks as $index => $block) { 5369 if ($page_frame && $this->conf['blocks'][$block]['exclude']) { 5370 // Blöcke, die für die Einbindung als dynamischer Inhalt ignoriert werden sollen, überspringen 5374 $removable = !isset($this->conf['blocks'][$block]['removable']) || (bool) $this->conf['blocks'][$block]['removable']; 5375 $template = $this->getTemplateBlock($block, $orient, $index, false, false, $variant, $removable); 5376 if ($template === null) { 5377 // Block existiert nicht 5378 if ($GLOBALS['frontend_admin'] && $this->conf['orients'][$orient]['disabled'] !== true) { 5379 // Einen unbekannten Block darstellen 5380 $html .= $this->getTemplateBlock('unknown', $orient, $index, false, false, $variant, $removable); 5381 $this->extra['_blocks'][$orient][$index] = 'unknown'; 5382 unset($this->extra['_contents'][$orient][$index]); 5390 // Formulare erweitern 5391 if (!empty($this->extra['_forms'][$orient])) { 5392 // Unsichtbare Formular Felder generieren 5393 if (!empty($this->extra['_forms'][$orient]['hidden'])) { 5394 require_once('base/Ego_Combo.php'); 5395 $combo = new Ego_Combo($this->extra['_forms'][$orient]['hidden']); 5396 foreach ($combo->getData() as $field) { 5397 $html .= '<input type="hidden
" name="' . $field->key . '" value="' . $field->value . '">'; 5401 // Mehrfachversand verhindern 5402 require_once 'base/Ego_ValidateForm.php'; 5403 $html .= Ego_ValidateForm::generateToken($orient); 5404 $html .= Ego_ValidateForm::generateCSRF($orient); 5406 // Seiten mit Formularen immer ohne Cache ausliefern, da sonst der eindeutige Token/CSRF mehrfach verwendet werden kann 5407 $this->field['cache'] = 0; 5420 public function getBlockList($layout = null, $template = false) { 5421 $skip = !$this->_site->globalAllowed() ? ['global'] : []; 5422 $cache_key = 'blockList_' . md5(serialize(array( 5425 $this->field['type'], 5427 $this->_site->language, 5428 $GLOBALS['auth']->isNobody() ? '' : $GLOBALS['auth']->user->field['user_id'] 5430 $blocks = $this->_site->getCacheEntry($cache_key); 5432 if ($blocks === null) { 5433 // Sicherstellen, dass Block Informationen immer mit den Backend Übersetzungen ermitteln werden 5434 $original_smarty = $GLOBALS['smarty']; 5435 unset($GLOBALS['translation'][$GLOBALS['t_language']]); 5436 $GLOBALS['smarty'] = Ego_Smarty::createAdmin($this->_site, array( 5442 // Liste der verfügbaren Blöcke generieren 5443 $block_files = $this->_site->getBlockFiles($this->field['type'], $skip); 5445 // Systemeigene Blöcke hinzufügen 5446 $system_conf = Ego_System::getJSON($GLOBALS['egotec_conf']['lib_dir'] . 'page/conf.json'); 5447 foreach ($system_conf['blocks'] as $block => $conf) { 5448 if ($block != 'template' && empty($this->conf['no_' . $block])) { 5449 if (!isset($this->conf['blocks'][$block])) { 5450 $this->conf['blocks'][$block] = $conf; 5452 $this->conf['blocks'][$block] = array_merge($conf, $this->conf['blocks'][$block]); 5454 $this->conf['blocks'][$block]['system'] = strpos($block, 'input_') === 0 5457 $block_files[$block] = $conf['title']; 5462 foreach ($block_files as $block => $title) { 5463 if ($block == 'unknown') { 5465 } elseif ($block == '_empty') { 5466 if (!empty($this->conf['no_template']) && !$template) { 5469 // Das Standard Template ist immer verfügbar 5470 $block = 'template'; 5471 } elseif (empty($this->conf['blocks'][$block])) { 5472 $this->conf['blocks'][$block] = array(); 5474 if (strpos($block, 'input_') === 0) { 5475 // Formular Blöcke automatisch erweitern 5476 if (!isset($this->conf['blocks'][$block]['system'])) { 5477 $this->conf['blocks'][$block]['system'] = 'form'; 5479 if (!isset($this->conf['blocks'][$block]['group'])) { 5480 $this->conf['blocks'][$block]['group'] = 'Formular'; 5482 if (!isset($this->conf['blocks'][$block]['controls'])) { 5483 $this->conf['blocks'][$block]['controls'] = array(); 5485 array_unshift($this->conf['blocks'][$block]['controls'], array( 5487 'name' => substr(strrchr($block, '_'), 1) 5490 $blocks[$block] = array( 5491 'title' => $GLOBALS['auth']->translate($this->conf['blocks'][$block]['title'] ? $this->conf['blocks'][$block]['title'] : $title), 5492 'description' => $GLOBALS['auth']->translate((string)$this->conf['blocks'][$block]['description']), 5493 'image' => $this->conf['blocks'][$block]['image'] ? $GLOBALS['egotec_conf']['url_dir'] . $this->conf['blocks'][$block]['image'] : '', 5494 'max' => (int)$this->conf['blocks'][$block]['max'] 5496 if (isset($this->conf['blocks'][$block]['index'])) { 5497 $blocks[$block]['index'] = (int)$this->conf['blocks'][$block]['index']; 5499 if (!empty($this->conf['blocks'][$block]['uid'])) { 5500 $blocks[$block]['uid'] = $this->conf['blocks'][$block]['uid']; 5502 if (!empty($this->conf['blocks'][$block]['system'])) { 5503 $blocks[$block]['system'] = $this->conf['blocks'][$block]['system']; 5505 if ($controls = $this->getBlockControls($block)) { 5506 $blocks[$block]['controls'] = $controls; 5508 if (!empty($this->conf['blocks'][$block]['group'])) { 5510 foreach (explode(',', $this->conf['blocks'][$block]['group']) as $group) { 5511 $groups[] = $GLOBALS['auth']->translate(trim($group)); 5513 $blocks[$block]['group'] = implode(',', $groups); 5515 if (!empty($this->conf['blocks'][$block]['pattern'])) { 5516 $blocks[$block]['pattern'] = array(); 5517 foreach (explode(',', $this->conf['blocks'][$block]['pattern']) as $index => $pattern) { 5518 if (preg_match_all('/\[([^:=]+?)(:([^=]+?))?(=(.+?))?\]/', $pattern, $matches)) { 5519 $blocks[$block]['pattern'][$index] = array(); 5520 foreach ($matches[0] as $index2 => $match) { 5521 $width = $matches[1][$index2]; 5522 $type = (string) $matches[3][$index2]; 5523 $color = (string) $matches[5][$index2]; 5528 if (strpos($type, 'image:') === 0) { 5529 $data['image'] = $GLOBALS['egotec_conf']['url_dir'] . substr($type, 6); 5531 $data['type'] = $type; 5533 $blocks[$block]['pattern'][$index][] = $data; 5539 $sort[] = mb_strtolower($blocks[$block]['title']); 5542 // Blöcke alphabetisch sortieren 5543 array_multisort($sort, SORT_ASC, SORT_REGULAR, $blocks); 5545 // Blöcke variabel sortieren 5548 foreach ($blocks as $block => $info) { 5551 // Dynamischer Inhalt als letzter Block 5552 $i = sizeof($blocks) + 1; 5555 if (strpos($block, 'input_') === 0) { 5556 // Formular Elemente als vorletzte Blöcke 5557 $i = sizeof($blocks); 5559 // Individuelle Position 5560 if (isset($info['index'])) { 5561 $i = (int)$info['index']; 5563 // Negative Position ausgehend vom letzten Block 5564 $i = sizeof($blocks) - abs($i); 5566 } elseif ($block == 'template') { 5567 // Standard Template als erster Block, wenn nichts anderes angegeben ist 5576 array_multisort($sort, SORT_ASC, SORT_NUMERIC, $blocks); 5578 if ($layout !== null) { 5579 // Alle Blöcke nach Orientierung gruppieren 5580 $block_list = array(); 5581 if (!empty($this->conf['layouts'][$layout]['blocks'])) { 5582 foreach ($this->conf['layouts'][$layout]['blocks'] as $orient => $info) { 5583 $get_blocks = function ($block_list, $type) use ($layout, $info, &$get_blocks) { 5585 if (!empty($info['extend_' . $type])) { 5586 $block_list .= ",{$info[
'extend_'.$type]}
"; 5588 foreach (explode(',', $block_list) as $block) { 5589 if ($block[0] == '@') { 5590 // Blöcke einer anderen Orientierung für dieses Layout verwenden 5591 $orient_block_list = $this->conf['layouts'][$layout]['blocks'][substr($block, 1)][$type]; 5592 if (!empty($orient_block_list)) { 5593 $blocks = array_merge($blocks, $get_blocks($orient_block_list, $type)); 5599 return array_unique($blocks); 5602 if (!empty($info['allow'])) { 5603 // Nur erlaubte Blöcke ausgeben 5604 $block_list[$orient] = array_intersect_key($blocks, array_flip($get_blocks($info['allow'], 'allow'))); 5605 } elseif (!empty($info['disallow'])) { 5606 // Nicht erlaubte Blöcke nicht ausgeben 5607 $block_list[$orient] = array_diff_key($blocks, array_flip($get_blocks($info['disallow'], 'disallow'))); 5611 // Gruppierung nach Haupt-Orientierung muss immer existieren 5612 if (empty($block_list[$this->mainOrient])) { 5613 $block_list[$this->mainOrient] = $blocks; 5616 $blocks = $block_list; 5619 $this->_site->setCacheEntry($cache_key, $blocks); 5620 $GLOBALS['smarty'] = $original_smarty; 5623 // Prüfen, ob dieses Layout Formulare beinhaltet 5624 $has_forms = array(); 5625 if ($file = $this->getLayout(false, $layout)) { 5626 require_once('smarty/Ego_Smarty.php'); 5627 $smarty = Ego_Smarty::createFrontend($this->_site, array( 5630 require_once('base/Ego_DomQuery.php'); 5631 $smarty_clone = clone $smarty; 5632 $GLOBALS['__no_blocks'] = true; // Keine Blöcke ausgeben 5633 $domQuery = new Ego_DomQuery($smarty_clone->fetch($file)); 5634 unset($GLOBALS['__no_blocks']); 5636 $forms = $domQuery->query('form'); 5637 foreach ($forms as $form) { 5638 if ($orient = $form->getAttribute('data-edit-template')) { 5639 $has_forms[] = $orient; 5641 // Verschachtelte Bereiche im Formular finden 5642 $descendants = $domQuery->xpath('*[@data-edit-template]', $form); 5643 foreach ($descendants as $descendant) { 5644 if ($orient = $descendant->getAttribute('data-edit-template')) { 5645 $has_forms[] = $orient; 5650 $has_forms = array_unique($has_forms); 5653 // Formular Blöcke für bestimmte Orientierungen nicht zurückliefern 5654 $filter = function($blocks) { 5655 $filtered = array(); 5656 foreach ($blocks as $key => $block) { 5657 if (strpos($key, 'input_') !== 0) { 5658 $filtered[$key] = $block; 5664 // Sicherstellen, dass die Orientierungen mit Formularen mindestens die Formular Blöcke anzeigen 5665 foreach ($has_forms as $orient) { 5666 if (empty($blocks[$orient])) { 5667 $blocks[$orient] = $blocks[$this->mainOrient]; 5669 foreach ($blocks[$this->mainOrient] as $key => $block) { 5670 if (strpos($key, 'input_') === 0 && !isset($blocks[$orient][$key])) { 5671 $blocks[$orient][$key] = $block; 5676 foreach (array_keys($blocks) as $orient) { 5677 if (!in_array($orient, $has_forms)) { 5678 $blocks[$orient] = $filter($blocks[$orient]); 5681 } elseif (empty($has_forms)) { 5682 $blocks = $filter($blocks); 5694 private function getBlockControls($block) { 5695 if (isset($this->conf['blocks'][$block]['controls'])) { 5696 $controls = array(); 5697 foreach ($this->conf['blocks'][$block]['controls'] as $control) { 5698 if ($control['name'][0] == '@') { 5699 // Steuerelement wird geerbt 5700 list($inherited_block, $name) = explode('.', substr($control['name'], 1)); 5701 if (isset($this->conf['blocks'][$inherited_block]['controls'])) { 5702 foreach ($this->conf['blocks'][$inherited_block]['controls'] as $inherited_control) { 5703 if ($inherited_control['name'] == $name) { 5704 $merged_control = array_merge($inherited_control, $control); 5705 $merged_control['name'] = $inherited_control['name']; 5706 $controls[] = $merged_control; 5712 $controls[] = $control; 5733 public function getTemplateBlock($block = 'template', $orient = '', $index = 0, $empty = false, $replace = false, $variant = '', $removable = true, &$smarty = null) { 5734 if ($orient == '') { 5735 $orient = $this->mainOrient; 5737 $html = $class = ''; 5738 $custom_html = false; 5740 require_once('smarty/Ego_Smarty.php'); 5741 $smarty = Ego_Smarty::createFrontend($this->_site, array( 5746 // Das globale Smarty Objekt für das Block Template mit dem eigenen Smarty Objekt überschreiben, falls innerhalb des Blocks darauf zugegriffen wird 5747 $original_smarty = $GLOBALS['smarty'] ? $GLOBALS['smarty'] : $smarty; 5748 $GLOBALS['smarty'] = $smarty; 5750 // Falls das Extrafeld hier nicht existiert, wird es initialisiert 5751 if (empty($this->extra)) { 5752 $this->extra = unserialize($this->field['extra']); 5755 // Standardwerte für Block Elemente und Extrafeld setzen 5756 if ($empty && !empty($this->conf['blocks'][$block]['default'][$orient])) { 5757 $this->extra['_contents'][$orient][$index] = $this->conf['blocks'][$block]['default'][$orient]; 5760 if (is_array($this->extra['_contents'][$orient][$index]['extra'])) { 5761 // Block Extrafeld als $extra übergeben 5762 $extra = $this->extra['_contents'][$orient][$index]['extra']; 5764 // Leeres Datum nicht übergeben 5765 foreach ($extra as $key => $value) { 5766 if (in_array($value, array('0000-00-00', '0000-00-00 00:00:00'))) { 5767 unset($extra[$key]); 5771 if (strpos($block, 'input_') === 0) { 5772 // Formular Blöcke kriegen ihren ... 5773 if (isset($_POST[$extra['name']])) { 5774 // ... aktuellen Wert übergeben 5775 $smarty->assign('value', $_POST[$extra['name']]); 5776 if (isset($_POST[$extra['name'] . '_input'])) { 5777 $smarty->assign('value_input', $_POST[$extra['name'] . '_input']); 5779 } elseif ($block == 'input_checkbox') { 5780 // ... aktuellen Wert übergeben (Checkbox Listen) 5782 require_once 'base/Ego_Combo.php'; 5783 $combo = new Ego_Combo($extra['values']); 5784 $new_data = array(); 5785 foreach ($combo->getData() as $data) { 5786 if (isset($_POST[$data->field_name])) { 5787 $values[] = $data->field_name; 5790 // Darstellung für required/optional Checkboxen in Formular Blöcken 5791 foreach (array('required', 'optional') as $type) { 5792 if ($data->{$type}) { 5793 $data->label = $GLOBALS['smarty']->fetch('string:' . str_replace('<%>', $data->label, $this->conf['form'][$type] ?? $data->label)); 5796 $new_data[] = $data; 5799 // Geänderte Daten übernehmen 5800 $combo->setData($new_data); 5801 $extra['values'] = $combo->getString(); 5803 $smarty->assign('values', $values); 5804 } elseif (empty($_POST['sendform'][$orient]) && isset($extra['default'])) { 5805 // ... Standardwert übergeben 5806 $smarty->assign('value', $extra['default']); 5809 // Regulärer Ausdruck für die E-Mail Validierung 5810 $smarty->assign(array( 5811 'email_pattern' => Ego_System::REGEX_EMAIL, 5812 'email_pattern_optional' => Ego_System::REGEX_EMAIL_OPTIONAL, 5813 'pattern_optional' => $extra['regex'] ? '$|' . $extra['regex'] : '' 5817 $smarty->assign('extra', $extra); 5819 unset($smarty->_plugins['outputfilter'], $smarty->autoload_filters['output']); 5821 // Diesen Block in der Frontend Administration anzeigen 5822 $frontend_admin = $GLOBALS['frontend_admin'] && $this->conf['orients'][$orient]['disabled'] !== true; 5824 if ($block == 'template') { 5825 // Das Template des Seitentyps 5826 $html .= $this->fetch(array( 5827 '_layout' => $this->extra['_layout'], 5828 '_orient' => $orient, 5832 '_replace' => $replace, 5834 ), false, (bool) $GLOBALS['__egotec_edit_request'], false, $variant); 5836 // Ein bestimmtes Template 5837 $block_found = false; 5838 $suffixes = array('.tpl', '.html'); 5840 // Block Varianten zuerst suchen 5841 array_unshift($suffixes, ".{$variant}.tpl
", ".{$variant}.html
"); 5843 foreach ($suffixes as $file_suffix) { 5845 ($file = $this->_site->getSkinFile("{$this->field[
'type']}/blocks/{$block}{$file_suffix}
")) 5846 || ($file = $this->_site->getSkinFile("blocks/{$block}{$file_suffix}
")) 5848 $file_suffix == '.tpl' // Systemeigenes Template 5849 && ($system_file = $GLOBALS['egotec_conf']['lib_dir'] . "page/t/blocks/{$block}{$file_suffix}
") 5850 && Ego_System::file_exists($system_file) 5851 && ($file = $system_file) 5854 $this->blockProperties = array( 5855 '_layout' => $this->extra['_layout'], 5856 '_orient' => $orient, 5860 '_replace' => $replace, 5861 '_uid' => ($uid = $this->extra['_contents'][$orient][$index]['_uid']) 5863 $smarty->assign(array_merge( 5864 $this->blockProperties, 5865 array('_page' => &$this) 5873 $include_script = function() use ($block, $orient, $index, $extra, $smarty, $uid) { 5875 ($file = $this->_site->getSiteFile("{$this->field[
'type']}/blocks/{$block}.php
")) 5876 || ($file = $this->_site->getSiteFile("blocks/{$block}.php
")) 5878 // Weitere Variablen im Skript verfügbar machen 5880 $site = $page->getSite(); 5881 $auth = $GLOBALS['auth']; 5888 if ($controls = $this->getBlockControls($block)) { 5890 $dom = function() use ($smarty, $file) { 5891 require_once('base/Ego_DomQuery.php'); 5892 $smarty_clone = clone $smarty; 5893 return new Ego_DomQuery($smarty_clone->fetch($file)); 5896 foreach ($controls as $control) { 5897 switch ($control['type']) { 5898 // Block kann um Elemente erweitert werden 5900 // Template generieren 5901 $custom_html = true; 5903 // Anzahl anzuzeigender Elemente ermitteln 5905 if (!$empty && !empty($this->extra['_contents'][$orient][$index][$control['name']])) { 5906 $max = sizeof($this->extra['_contents'][$orient][$index][$control['name']]); 5908 if ($frontend_admin && !$control['optional'] && $max == 0) { 5909 // Wenn keine Elemente vorhanden sind, dann x Elemente automatisch erzeugen 5910 $max = $control['start'] ?? 1; 5913 foreach ($control['elements'] as $element) { 5916 $multiple_items = is_array($element['items']); 5919 if ($multiple_items) { 5921 if (isset($this->extra['_contents'][$orient][$index][$control['name']][$n]['_type'])) { 5922 $j = (int) $this->extra['_contents'][$orient][$index][$control['name']][$n]['_type']; 5924 $item = $element['items'][$j]['item']; 5925 $values = $element['items'][$j]['values']; 5927 $item = $element['item']; 5928 $values = $element['values']; 5930 $items .= $smarty->fetch('string:' . preg_replace_callback('/<%>/', function () use ($values, $n, &$i, $control) { 5931 // Smarty {value} erzeugen 5933 foreach ($values[$i] as $attr => $value) { 5934 if ($attr == 'var') { 5935 $value = "{$control[
'name']}][$n][$value
"; 5937 if (is_array($value)) { 5938 foreach ($value as $sub_attr => $sub_value) { 5939 $func .= " {$attr}.{$sub_attr}=\
"{$sub_value}\"";
5942 $func .=
" {$attr}=\"{$value}\"";
5948 }, str_replace(
'<#>', $n, $item)
5953 if ($n == 0 && $element[
'active']) {
5955 $nodes = $domQuery2->query($element[
'active'][
'selector']);
5956 foreach ($nodes as $node) {
5957 if ($element[
'active'][
'attribute'] ==
'class') {
5958 if ($className = $node->getAttribute(
'class')) {
5959 $classes = explode(
' ', $className);
5963 $classes[] = $element[
'active'][
'value'];
5964 $node->setAttribute(
'class', implode(
' ', $classes));
5966 $node->setAttribute($element[
'active'][
'attribute'], $element[
'active'][
'value']);
5968 $items = $domQuery2->getHTML();
5977 if ($domQuery === null) {
5980 $domQuery->setInnerHTML($domQuery->query($element[
'selector']),
function($node) use ($items) {
5988 $identity = $this->extra[
'_contents'][$orient][$index][$control[
'name']];
5990 $smarty->assign($control[
'name'], $data);
5996 $value = $this->extra[
'_contents'][$orient][$index][$control[
'name']];
5999 $control[
'attribute'] ==
'#text' 6000 || $control[
'preset'] ==
'materialize' 6005 $domQuery->setInnerHTML($domQuery->query($control[
'selector']),
function($node) use ($value, &$custom_html) {
6006 $custom_html =
true;
6013 if ($domQuery && $custom_html) {
6014 $html .= $domQuery->getHTML();
6018 if (!$custom_html) {
6020 $html .= $smarty->fetch($file);
6023 unset($this->blockProperties);
6024 $block_found =
true;
6029 if (!$block_found) {
6031 $GLOBALS[
'smarty'] = $original_smarty;
6037 if (!empty($this->extra[
'_contents'][$orient][$index][
'_anchor'])) {
6038 $html =
"<a id=\"{$this->extra['_contents'][$orient][$index]['_anchor']}\"></a>\n" . $html;
6042 if ($this->conf[
'form'][
'wrapper'] && strpos($block,
'input_') === 0) {
6043 if (is_array($this->conf[
'form'][
'values'])) {
6045 $element = $this->conf[
'form'];
6047 $html = $smarty->fetch(
'string:' . preg_replace_callback(
'/<%>/',
function() use ($element, &$i, $html, $block) {
6048 if (empty($element[
'values'][$i])) {
6054 foreach ($element[
'values'][$i] as $attr => $value) {
6055 if (is_array($value)) {
6056 foreach ($value as $sub_attr => $sub_value) {
6057 $func .=
" {$attr}.{$sub_attr}=\"{$sub_value}\"";
6060 $func .=
" {$attr}=\"{$value}\"";
6067 }, $this->conf[
'form'][
'wrapper']));
6069 $html = str_replace(
'<%>', $html, $this->conf[
'form'][
'wrapper']);
6073 $columns = $this->extra[
'_contents'][$orient][$index][
'extra'][
'_columns'];
6075 $columns = (string) $this->conf[
'form'][
'columns'][
'default'];
6077 $columns = rtrim(
' ' . $columns);
6079 $html = str_replace(
6089 if (!empty($this->conf[
'blocks'][$block][
'modify'])) {
6090 require_once(
'base/Ego_DomQuery.php');
6092 $domQuery->setSmarty($smarty);
6094 foreach ($this->conf[
'blocks'][$block][
'modify'] as $modify) {
6095 $domQuery->modify($modify);
6098 $html = $domQuery->getHTML();
6101 $GLOBALS[
'smarty'] = $original_smarty;
6104 if (!empty($this->conf[
'blocks'][$block][
'class'])) {
6105 $class = $this->conf[
'blocks'][$block][
'class'];
6108 if (!$frontend_admin || !$this->isCurrentPage()) {
6109 return trim($class ?
'<div class="' . $class .
'">' . $html .
'</div>' : $html);
6113 if ($frontend_admin && !empty($columns)) {
6114 $class = trim($class . $columns);
6117 if ($frontend_admin && trim($html) ==
'' && $this->isCurrentPage()) {
6120 if ($this->conf[
'blocks'][$block][
'title']) {
6121 $title = $GLOBALS[
'auth']->translate($this->conf[
'blocks'][$block][
'title']);
6123 $html =
'<div data-edit-placeholder="' . $title .
'"></div>';
6127 if (strpos($block,
'input_') === 0 && !isset($this->conf[
'blocks'][$block][
'group'])) {
6129 $this->conf[
'blocks'][$block][
'group'] =
'Formular';
6131 $group = (string) $this->conf[
'blocks'][$block][
'group'];
6133 $group = $GLOBALS[
'auth']->translate($group);
6136 return trim(($frontend_admin ?
'<div data-edit-block="' . $block .
'" data-edit-block-index="' . $index .
'"' 6138 ($group ?
' data-edit-group="' . $group .
'"' :
'')
6139 . (!$removable ?
' data-edit-static="true"' :
'')
6140 . (!empty($columns) ?
' data-edit-columns="true"' :
'')
6142 . ($class ?
' class="' . $class .
'"' :
'')
6143 .
'>' . $html .
'</div>');
6152 if (!empty($this->conf[
'layouts'][$this->extra[
'_layout']][
'inherit'])) {
6153 foreach (explode(
',', $this->conf[
'layouts'][$this->extra[
'_layout']][
'inherit']) as $orient) {
6154 $blocks_key = implode(array(
'_blocks', $orient),
'.');
6155 $contents_key = implode(array(
'_contents', $orient),
'.');
6156 $extra = $this->inheritExtra(array($blocks_key, $contents_key));
6157 if ($extra[$blocks_key] !== null) {
6161 if ($checksum_blocks != $checksum_original) {
6163 $this->extra[
'_inherited'][$orient] = array(
6164 'blocks' => $checksum_blocks,
6165 'contents' => $checksum_contents
6169 foreach ($extra as $key => $value) {
6170 $this->extra[strstr($key,
'.',
true)][$orient] = $value;
6186 'title' =>
'Headers',
6188 [
'title' =>
'Header 1',
'format' =>
'h1'],
6189 [
'title' =>
'Header 2',
'format' =>
'h2'],
6190 [
'title' =>
'Header 3',
'format' =>
'h3'],
6191 [
'title' =>
'Header 4',
'format' =>
'h4'],
6192 [
'title' =>
'Header 5',
'format' =>
'h5'],
6193 [
'title' =>
'Header 6',
'format' =>
'h6']
6197 'title' =>
'Inline',
6199 [
'title' =>
'Bold',
'icon' =>
'bold',
'format' =>
'bold'],
6200 [
'title' =>
'Italic',
'icon' =>
'italic',
'format' =>
'italic'],
6201 [
'title' =>
'Underline',
'icon' =>
'underline',
'format' =>
'underline'],
6202 [
'title' =>
'Strikethrough',
'icon' =>
'strikethrough',
'format' =>
'strikethrough'],
6203 [
'title' =>
'Superscript',
'icon' =>
'superscript',
'format' =>
'superscript'],
6204 [
'title' =>
'Subscript',
'icon' =>
'subscript',
'format' =>
'subscript'],
6205 [
'title' =>
'Code',
'icon' =>
'code',
'format' =>
'code']
6209 'title' =>
'Blocks',
6211 [
'title' =>
'Paragraph',
'format' =>
'p'],
6212 [
'title' =>
'Blockquote',
'format' =>
'blockquote'],
6213 [
'title' =>
'Div',
'format' =>
'div'],
6214 [
'title' =>
'Pre',
'format' =>
'pre']
6218 'title' =>
'Alignment',
6220 [
'title' =>
'Left',
'icon' =>
'alignleft',
'format' =>
'alignleft'],
6221 [
'title' =>
'Center',
'icon' =>
'aligncenter',
'format' =>
'aligncenter'],
6222 [
'title' =>
'Right',
'icon' =>
'alignright',
'format' =>
'alignright'],
6223 [
'title' =>
'Justify',
'icon' =>
'alignjustify',
'format' =>
'alignjustify']
6229 if (isset($this->conf[
'formats'])) {
6230 $custom_formats = $type && isset($this->conf[
'formats'][$type])
6231 ? $this->conf[
'formats'][$type]
6232 : $this->conf[
'formats'][
'default'];
6233 if (is_array($custom_formats)) {
6234 foreach ($custom_formats as $name => $values) {
6236 if (isset($formats[$name])) {
6238 if ($custom_formats[$name][
'options']) {
6239 $new_items = array();
6240 foreach (explode(
',', $custom_formats[$name][
'options']) as $option) {
6241 foreach ($formats[$name][
'items'] as $item) {
6242 if ($item[
'format'] == $option) {
6244 $new_items[] = $item;
6249 $formats[$name][
'items'] = $new_items;
6252 if (isset($custom_formats[$name]) && empty($custom_formats[$name])) {
6254 unset($formats[$name]);
6255 } elseif (isset($custom_formats[$name][
'items'])) {
6259 if (!empty($custom_formats[$name][
'merge'])) {
6261 foreach ($formats[$name][
'items'] as $item) {
6262 if (is_array($custom_formats[$name][
'items'])) {
6263 foreach ($custom_formats[$name][
'items'] as $new_item) {
6264 if ($item[
'title'] == $new_item[
'title']) {
6265 $items[] = $new_item;
6274 if (is_array($custom_formats[$name][
'items'])) {
6275 foreach ($custom_formats[$name][
'items'] as $new_item) {
6276 foreach ($formats[$name][
'items'] as $item) {
6277 if ($new_item[
'title'] == $item[
'title']) {
6281 $items[] = $new_item;
6284 if (!empty($items)) {
6285 $formats[$name] = array(
6286 'title' => $formats[$name][
'title'],
6291 unset($formats[$name]);
6296 $formats[$name] = $values;
6302 return array_values($formats);
6322 $result[
'plugins'] =
'noneditable advlist autolink lists link image charmap anchor searchreplace visualblocks visualchars code media table contextmenu paste importcss ' 6323 .
'egotecSpellchecker egotecPageFrame egotecImageScale egotecList egotecMaxLength egotecIcons';
6324 $result[
'menubar'] =
'edit insert view table tools';
6325 $result[
'toolbar'] =
'styleselect removeformat | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | media image link unlink | egotecSpellchecker';
6329 $result[
'plugins'] =
'noneditable advlist autolink lists link charmap anchor searchreplace visualblocks visualchars contextmenu paste importcss ' 6330 .
'egotecSpellchecker egotecList egotecMaxLength egotecIcons';
6331 $result[
'menubar'] =
'edit insert view tools';
6332 $result[
'toolbar'] =
'styleselect removeformat | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link unlink | egotecSpellchecker';
6336 $result[
'plugins'] =
'noneditable autolink link anchor contextmenu paste ' 6337 .
'egotecSpellchecker';
6338 $result[
'toolbar'] =
'bold italic | link unlink | egotecSpellchecker';
6342 $result[
'plugins'] =
'noneditable advlist autolink lists link charmap anchor searchreplace visualblocks visualchars table contextmenu paste importcss ' 6343 .
'egotecSpellchecker egotecList egotecMaxLength';
6344 $result[
'menubar'] =
'edit insert view tools';
6345 $result[
'toolbar'] =
'styleselect removeformat | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link unlink | egotecSpellchecker';
6349 $result[
'plugins'] =
'paste ' 6350 .
'egotecSpellchecker egotecPlainText egotecMaxLength';
6351 $result[
'toolbar'] =
'egotecSpellchecker';
6355 $result[
'contextmenu'] =
'link openlink image inserttable | cell row column deletetable';
6357 if ($this->_site->hasRight(
"admin")) {
6359 $result[
'plugins'] .=
' code';
6363 if (!empty($this->conf[
'toolbar'])) {
6364 $custom_toolbar = $this->conf[
'toolbar'][$type];
6365 foreach (array_keys($result) as $name) {
6366 if (isset($custom_toolbar[$name])) {
6367 if (in_array($custom_toolbar[$name], [
'',
false],
true)) {
6368 $result[$name] =
false;
6369 } elseif (preg_match_all(
'/[+-]?[^+-]+/', $custom_toolbar[$name], $matches) !==
false) {
6370 foreach ($matches[0] as $toolbar) {
6371 $toolbar = trim(str_replace(
',',
' ', rtrim($toolbar,
',')),
' |');
6372 if (strpos($toolbar,
'+') === 0) {
6374 $result[$name] .=
' ' . substr($toolbar, 1);
6375 } elseif (strpos($toolbar,
'-') === 0) {
6377 $pattern =
'/(^| )(' . str_replace(
' ',
'|', preg_quote(substr($toolbar, 1))) .
')(|$)/';
6378 $result[$name] = preg_replace($pattern,
'', $result[$name]);
6381 $result[$name] = $toolbar;
6400 $type_path = explode(
'/', $this->field[
'type']);
6402 if ($this->extra[
'_style']) {
6403 $variant =
'.'.$this->extra[
'_style'];
6405 $suffix = $_SERVER[
'REQUEST_SUFFIX'] !=
'.html' ? $_SERVER[
'REQUEST_SUFFIX'] :
'';
6407 foreach($type_path as $path) {
6408 $current_path .= $path.
'/';
6410 ($suffix !=
'' && ($src = $this->_site->getSkinFile($current_path.
'style'.$suffix.
'.css', array(
'system'),
true)))
6411 || ($variant !=
'' && ($src = $this->_site->getSkinFile($current_path.
'style'.$variant.
'.css', array(
'system'),
true)))
6412 || ($src = $this->_site->getSkinFile($current_path.
'style.css', array(
'system'),
true))
6416 if ($src = $this->_site->getSkinFile($current_path.
'script.js', array(),
true)) {
6424 ($suffix !=
'' && ($src = $this->_site->getSkinFile(
'style'.$suffix.
'.css', array(
'system'),
true)))
6425 || ($variant !=
'' && ($src = $this->_site->getSkinFile(
'style'.$variant.
'.css', array(
'system'),
true)))
6426 || ($src = $this->_site->getSkinFile(
'style.css', array(
'system'),
true))
6430 if ($src = $this->_site->getSkinFile(
'script.js', array(
'system'),
true)) {
6445 if ($orient === null) {
6446 $orient = $this->mainOrient;
6447 if (isset($this->blockProperties[
'_orient'])) {
6448 $orient = $this->blockProperties[
'_orient'];
6461 if ($index === null) {
6463 if (isset($this->blockProperties[
'_index'])) {
6464 $index = $this->blockProperties[
'_index'];
6479 public function getValue($name, $orient = null, $index = null, $verbose =
false) {
6481 $orient = $this->getOrient($orient);
6482 $index = $this->getIndex($index);
6483 $extra = unserialize($this->field[
'extra']);
6486 if ($value !== null) {
6492 if (($pos = strrpos($name,
'.')) !==
false) {
6493 $key = implode(
'.', array(
'_contents', $orient, $index, substr($name, 0, $pos)));
6494 $name = substr($name, $pos + 1);
6496 $key = implode(
'.', array(
'_contents', $orient, $index));
6499 if (is_array($values)) {
6500 foreach ($values as $key => $value) {
6501 if (strpos($key,
"{$name}_") === 0) {
6502 $array[substr($key, strlen(
"{$name}_"))] = $value;
6522 public function getValues($name, $orient = null, $verbose =
false) {
6524 $orient = $this->getOrient($orient);
6527 if (is_array($this->extra[
'_contents'][$orient])) {
6528 $list = $this->extra[
'_contents'][$orient];
6529 if (is_array($list)) {
6530 foreach (array_keys($list) as $index) {
6531 $value = $this->getValue($name, $orient, $index, $verbose);
6532 if ($value !== null) {
6551 $orient = $this->getOrient($orient);
6553 if (is_array($this->extra[
'_contents'][$orient])) {
6554 $list = $this->extra[
'_contents'][$orient];
6555 if (is_array($list)) {
6556 foreach (array_keys($list) as $index) {
6557 $value = $this->getValue($name, $orient, $index, $verbose);
6558 if ($value !== null) {
6577 public function getBlockValue($block, $name, $orient = null, $index = null, $verbose =
false) {
6579 $orient = $this->getOrient($orient);
6580 $index = $this->getIndex($index);
6582 if ($this->extra[
'_blocks'][$orient][$index] == $block) {
6583 $value = $this->getValue($name, $orient, $index, $verbose);
6584 if ($value !== null) {
6602 $orient = $this->getOrient($orient);
6605 if (is_array($this->extra[
'_blocks'][$orient])) {
6606 foreach ($this->extra[
'_blocks'][$orient] as $index => $block_name) {
6607 if ($block_name == $block) {
6608 $value = $this->getValue($name, $orient, $index, $verbose);
6609 if ($value !== null) {
6629 $orient = $this->getOrient($orient);
6631 if (is_array($this->extra[
'_blocks'][$orient])) {
6632 foreach ($this->extra[
'_blocks'][$orient] as $index => $block_name) {
6633 if ($block_name == $block) {
6634 $value = $this->getValue($name, $orient, $index, $verbose);
6635 if ($value !== null) {
6652 $original_page = $this->_site->getPage($id, array(
6654 'deleted_or' =>
'1=1',
6656 'only_active' =>
false 6658 if (!$original_page) {
6661 $field = $this->field;
6662 $extra = $this->extra;
6664 unset($field[
'children']);
6665 if ($field[
'children_order'] ==
'children') {
6667 $children_list = array();
6668 $original_children = explode(
',', trim($extra[
'original_children'],
','));
6669 $current_children = $original_page->getChildren(array(), array(
'auth_or' =>
'1=1'));
6670 $current_children_list = array();
6671 foreach ($current_children as $child) {
6672 $current_children_list[] = $child->field[
'id'];
6674 foreach ($original_children as $child_id) {
6675 $key = array_search($child_id, $current_children_list);
6676 if ($key !==
false) {
6677 $children_list[] = $child_id;
6678 unset($current_children_list[$key]);
6681 $children_list = array_merge($children_list, $current_children_list);
6684 $field[
'inactive'] = $extra[
'original_inactive'];
6688 $extra[
'original_id'],
6689 $extra[
'original_children'],
6690 $extra[
'original_inactive'],
6691 $extra[
'workflow_page']
6693 if ($extra[
'original_parents']) {
6694 $original_parents = $extra[
'original_parents'];
6695 unset($extra[
'original_parents']);
6699 $children = $this->getChildren();
6700 foreach ($children as $child) {
6701 $child->move($this->field[
'id'], $original_page->field[
'id']);
6702 $child->updateField(array(
'inactive' => self::ACTIVE_FLAG));
6705 unset($field[
'id']);
6706 unset($field[
'parents']);
6707 unset($field[
'workflow_state']);
6708 if (isset($original_page->field[
'workflow'])) {
6709 $field[
'workflow'] = $original_page->field[
'workflow'];
6711 unset($field[
'workflow']);
6713 if (isset($original_page->extra[
'workflows'])) {
6714 $extra[
'workflows'] = $original_page->extra[
'workflows'];
6716 unset($extra[
'workflows']);
6720 if (!$original_page->isReleaseCopy()) {
6721 unset($extra[
'release_id']);
6722 if ($field[
'inactive'] == self::RELEASE_FLAG) {
6723 $field[
'inactive'] = 0;
6727 if (!is_numeric($field[
'inactive'])) {
6728 $field[
'inactive'] = 0;
6731 if ($this->isReleaseCopy() && $field[
'release_from'] > date(
'Y-m-d H:i:s')) {
6732 $field[
'release_from'] =
'0000-00-00 00:00:00';
6740 if ($children_list) {
6741 $update[
'children'] = $children_list;
6744 if ($original_parents) {
6745 $current_parents = array();
6746 foreach ($this->getParents(array(
'fields' =>
'id')) as $parent) {
6747 $current_parents[] = $parent->field[
'id'];
6749 $update[
'parents'] = $current_parents;
6752 $original_page->field = array_merge($original_page->field, $update[
'field']);
6753 if ($original_page->extra[
'release_ids']) {
6755 $update[
'extra'][
'release_ids'] = array_values(array_diff($original_page->extra[
'release_ids'], array($this->field[
'id'])));
6757 $original_page->extra = $update[
'extra'];
6760 if (
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename())) {
6762 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$this->getMediaFilename(),
6763 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->_site->name.
'/'.$original_page->getMediaFilename(
true)
6768 $this->getMediapool()->copy($original_page, $this->getMediapool()->currentDir);
6769 $this->getMediapool()->copy($original_page,
'workflow',
false,
true);
6772 $update[
'field'] = $original_page->field;
6773 $update[
'extra'] = $original_page->extra;
6774 $original_page->update($update);
6777 return $original_page;
6787 if ($this->field[
'inactive'] != self::RELEASE_FLAG) {
6788 $this->archiveOnly =
false;
6789 $field = $this->field;
6790 $extra = $this->extra;
6791 unset($field[
'id']);
6792 $field[
'inactive'] = self::RELEASE_FLAG;
6794 $field[
'release_from'] = $date;
6797 if ($this->isWorkflowCopy()) {
6799 $extra[
'release_id'] = $extra[
'original_id'];
6800 unset($extra[
'original_id']);
6804 $extra[
'release_id'] = $this->field[
'id'];
6805 unset($extra[
'release_ids']);
6807 'site' => $this->getSite(),
6811 $parents = $this->getParents(array(), array(
'auth_or' =>
'1=1'));
6812 if ($parent = $parents->nextPage()) {
6813 $new_page = $this->copyTo(
6814 $parent->field[
'id'],
6819 if (empty($new_page)) {
6821 $new_page = $this->copyTo(
6830 $original_page = $this->_site->getPage($extra[
'release_id'], array(
6831 'only_active' =>
false,
6834 $extra = $original_page->extra;
6835 if (!is_array($extra[
'release_ids'])) {
6836 $extra[
'release_ids'] = array();
6838 $extra[
'release_ids'][] = $new_page->field[
'id'];
6839 $extra[
'release_ids'] = array_unique($extra[
'release_ids']);
6840 $original_page->updateExtra($extra,
true,
true);
6853 if ($this->isReleaseCopy()) {
6856 $this->field[
'release_until'] !=
'0000-00-00 00:00:00' 6857 && ($original_page = $this->_site->getPage($this->extra[
'release_id'], array(
6859 'only_active' =>
false 6861 && $original_page->field[
'release_until'] ==
'0000-00-00 00:00:00' 6863 $original_page->extra[
'release_ids'] = array_values(array_diff($original_page->extra[
'release_ids'], array($this->field[
'id'])));
6864 $GLOBALS[
'new_release'] = $original_page->newRelease($this->field[
'release_until']);
6867 $this->field[
'release_until'] =
'0000-00-00 00:00:00';
6870 return $this->merge($this->extra[
'release_id']);
6881 return ($this->field[
'workflow'] && $this->extra[
'original_id']);
6890 return ($this->extra[
'release_id'] && $this->field[
'inactive'] == self::RELEASE_FLAG);
6899 return !empty($this->extra[
'clone_original']);
6909 return ($this->extra[
'language_link'][$this->getSite()->language] && $this->extra[
'language_standard'] != $this->getSite()->language);
6918 return $this->archiveOnly || $this->getTableSuffix() ==
'_v';
6927 return !$this->field[
'inactive']
6928 && !$this->field[
'deleted']
6929 && ($this->field[
'release_from'] ==
'0000-00-00 00:00:00' || date(
'Y-m-d H:i:s') > $this->field[
'release_from'])
6930 && ($this->field[
'release_until'] ==
'0000-00-00 00:00:00' || date(
'Y-m-d H:i:s') < $this->field[
'release_until'])
6931 && !$this->isWorkflowCopy()
6932 && !$this->isReleaseCopy();
6941 if ($this->isPublicSave()) {
6942 $db = new_db_connection();
6944 'table' => $this->_site->pageTable .
'_v',
6945 'where' =>
'id = :id AND c_date > :c_date',
6946 'order' =>
'c_date DESC',
6949 'id' => $this->field[
'id'],
6950 'c_date' => $this->lastChangeDate
6953 if ($db->nextRecord()) {
6954 $class = $this->_site->getPageClass($db->Record[
'type']);
6955 return new $class($this->_site, $db->Record);
6969 $descendants = $this->getDescendants();
6970 foreach ($descendants as $descendant) {
6972 ($page = $descendant->getNonPublic())
6973 && (!$c_user || $page->field[
'c_user'] == $c_user)
6987 return $this->_site->isPublicSave()
6988 && ($info = $this->getTypeInfo())
6989 && !$info[
'no_public_save'];
6998 if ($this->isPublicSave()) {
6999 return $this->lastChangeDate == $this->field[
'c_date'];
7011 return $this->lastChangeDate;
7021 $db = new_db_connection();
7023 'table' => $this->_site->pageTable.
'_v',
7024 'where' =>
'id = :id',
7025 'order' =>
'c_date DESC',
7028 'id' => $this->field[
'id']
7033 $params[
'where'] .=
' AND c_date = :c_date';
7034 $params[
'bind'][
'c_date'] = $c_date;
7036 $db->select($params);
7037 if ($db->nextRecord()) {
7038 $page = clone $this;
7039 $page->setTableSuffix(
'_v');
7040 $page->field = $db->Record;
7041 $page->extra = $db->Record[
'extra']
7042 ? unserialize($db->Record[
'extra'])
7057 $query[
'table'] = $this->getSite()->pageTable .
'_v';
7058 if ($query[
'where']) {
7059 $query[
'where'].=
' AND ';
7061 $query[
'where'].=
'id=:id';
7062 $query[
'bind'][
'id'] = $this->field[
'id'];
7063 if (!isset($query[
'order'])) {
7064 $query[
'order'] =
'c_date DESC';
7066 return new Page_Iterator($this->_site, new_db_connection($query));
7075 public function restoreArchivPage($c_date)
7077 $db = new_db_connection();
7079 'table' => $this->getSite()->pageTable.
'_v',
7080 'where' =>
"id=".$this->field[
'id'].
" AND c_date='".$c_date.
"'" 7083 if (!$db->nextRecord()) {
7088 $field = $db->Record;
7089 unset($field[
'id']);
7090 unset($field[
'children']);
7091 unset($field[
'parents']);
7092 $extra = unserialize($field[
'extra']);
7097 if (empty($extra[
'piwik']) && !empty($this->extra[
'piwik'])) {
7099 $extra[
'piwik'] = $this->extra[
'piwik'];
7101 $this->update(array(
7117 if ($file = $this->getSite()->getSiteFile($this->field[
'type'].
'/admin/archive_restore.php')) {
7119 $site = $this->getSite();
7120 $current_page = $this;
7121 $smarty = $GLOBALS[
'smarty'];
7136 public function download($recursive =
true, $target_dir =
'', $write_log =
true) {
7137 $log = $GLOBALS[
'egotec_conf'][
'log_dir'].
'page_download-'.date(
'Y-m-d');
7139 file_put_contents($log,
"\r\n===> ".date(
'Y-m-d H:i:s')
7140 .
" Page Download für " 7141 .
"{$this->_site->name}.{$this->_site->language}.{$this->field['id']}" 7142 .
" beginnt:\r\n", FILE_APPEND);
7147 $dir = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'download'.md5(microtime()).
'/';
7149 $media_dir = $dir.
'media/'.$this->_site->name.
'/';
7151 file_put_contents($log,
"Verzeichnisse anlegen\r\n", FILE_APPEND);
7157 'only_active' =>
false,
7162 $pages = array($this);
7165 file_put_contents($log,
"Alle Nachfahren ermitteln\r\n", FILE_APPEND);
7167 foreach ($this->getDescendants(
7171 $pages[] = $descendant;
7176 $db = new_db_connection();
7178 foreach ($pages as $page) {
7180 file_put_contents($log,
"Seite {$page->field['name']} ({$page->field['id']}) sichern\r\n", FILE_APPEND);
7182 foreach ($this->_site->getLanguages() as $lang) {
7183 $lang_page = $page->getLanguagePage($lang);
7185 file_put_contents($log,
"> Sprache {$lang} sichern\r\n", FILE_APPEND);
7189 $table = $this->_site->name.
'_'.$lang;
7193 'where' =>
'id = :id',
7195 'id' => $page->field[
'id']
7198 while ($db->nextRecord()) {
7199 $s = serialize($db->Record);
7200 $file = $dir.
'db/'.$table;
7201 file_put_contents($file, strlen($s).
"\n".$s, FILE_APPEND);
7203 $path = $GLOBALS[
'egotec_conf'][
'var_dir']
7204 .
'media/'.$this->_site->name.
'/';
7209 file_put_contents($log,
"> Mediapool sichern\r\n", FILE_APPEND);
7213 $path.$lang.
'/pool/'.$page->field[
'id'].
'/',
7214 $media_dir.$lang.
'/pool/'.$page->field[
'id'].
'/' 7220 in_array($page->field[
'type'], array(
'multimedia/file',
'multimedia/image'))
7224 file_put_contents($log,
"> Datei sichern\r\n", FILE_APPEND);
7226 $file = $lang_page->getMediaFilename();
7230 $dir.
'media/'.$this->_site->name.
'/'.$lang.
'/'.$page->field[
'id']
7237 'buchungen' => $table.
'_buchungen',
7238 'children' => $table.
'_children',
7239 'extra' => $table.
'_extra',
7240 'infodienst' => $table.
'_infodienst',
7241 'newsletter_light' => $table.
'_newsletter_light',
7242 'rights' => $table.
'_rights',
7243 'users' => $table.
'_users',
7244 'keywords' => $this->_site->name.
'_keywords_rel',
7248 file_put_contents($log,
"> Verknüpfte Tabellen sichern\r\n", FILE_APPEND);
7250 foreach ($tables as $key => $table) {
7251 if (!$db->tableExists($table)) {
7255 file_put_contents($log,
">> $table\r\n", FILE_APPEND);
7258 case 'newsletter_light':
7259 $where =
'abonnent_id = :id';
7262 $where =
'id = :id';
7265 $where =
'page_id = :id';
7272 'id' => $page->field[
'id']
7275 while ($db->nextRecord()) {
7276 $s = serialize($db->Record);
7277 $file = $dir.
'db/'.$table;
7278 file_put_contents($file, strlen($s).
"\n".$s, FILE_APPEND);
7283 if (!$target_dir && $lang_page) {
7285 file_put_contents($log,
"> Verweise sichern\r\n", FILE_APPEND);
7287 foreach ($lang_page->getLinks() as $link) {
7289 $link_site =
new Site($link[
'dest_site'], $link[
'dest_lang']);
7290 $link_page = $link_site->getPage($link[
'dest_id'], $params);
7292 $link_page->download(
false, $dir,
false);
7295 foreach ($link_page->getParents(array(), $params) as $parent) {
7296 $parent->download(
false, $dir,
false);
7299 }
catch (Exception $e) {
7305 'table' =>
'egotec_links',
7307 'where' =>
"src_site = :site AND src_lang = :lang AND src_id = :id",
7309 'site' => $this->_site->name,
7311 'id' => $page->field[
'id']
7314 while ($db->nextRecord()) {
7315 $s = serialize($db->Record);
7316 $file = $dir.
'db/egotec_links';
7317 file_put_contents($file, strlen($s).
"\n".$s, FILE_APPEND);
7325 file_put_contents($log,
"Archiv erstellen\r\n", FILE_APPEND);
7328 require_once(
'Archive/Tar.php');
7331 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'download');
7332 $zip =
new Archive_Tar($tmp,
'gz');
7338 file_put_contents($log,
"Archiv ausgeben\r\n", FILE_APPEND);
7340 require_once(
'base/Ego_Output.php');
7342 $date = date(
'Ymd-His');
7343 $output->setName(
'page_'.$this->_site->name.
'.'.str_replace(
' ',
'_', $this->field[
'name']).
'.'.$date.
'.tar.gz');
7344 $output->setTemporary(
true);
7345 $output->download();
7355 if ($this->field[
'type'] ==
'multimedia/category') {
7356 $dir = $GLOBALS[
'egotec_conf'][
'tmp_dir'];
7357 $name =
'export'.md5(microtime());
7358 $folder = $name.DIRECTORY_SEPARATOR
7360 $file = $name.
'.tar.gz';
7361 $this->exportArchive($this, $dir.$folder);
7364 require_once(
'Archive/Tar.php');
7367 $zip =
new Archive_Tar($file,
'gz');
7368 $zip->_separator =
',';
7369 $zip->createModify(rtrim($folder, DIRECTORY_SEPARATOR),
'', $name);
7383 private function exportArchive($page, $path) {
7385 foreach ($page->getChildren() as $child) {
7387 if ($child->field[
'type'] ==
'multimedia/category') {
7388 $this->exportArchive($child, $path.$name.DIRECTORY_SEPARATOR);
7389 } elseif (in_array($child->field[
'type'], array(
'multimedia/file',
'multimedia/image'))) {
7390 $dir = $GLOBALS[
'egotec_conf'][
'var_dir'].
7391 'media'.DIRECTORY_SEPARATOR.$this->_site->name.DIRECTORY_SEPARATOR;
7392 $file = $child->getMediaFilename();
7393 if ($child->extra[
'image_type']) {
7394 $name .=
'.'.$child->extra[
'image_type'];
7407 if (!$this->frontendActive) {
7408 $this->frontendActive =
true;
7409 $GLOBALS[
'frontend_admin'] =
true;
7410 if (!$_SESSION[
'login'][
'live_preview']) {
7411 $_REQUEST[
'preview'] = $_REQUEST[
'nonactive'] = 1;
7413 unset($_REQUEST[
'preview'], $_REQUEST[
'nonactive']);
7417 $this->_site->setOnlyActive(!$_REQUEST[
'preview']);
7419 $lock = $this->lock();
7421 $settings = $this->getEditFieldSettings();
7423 if (!empty($this->conf[
'noneditable'])) {
7425 $settings = array_diff_key($settings, array_flip(explode(
',', $this->conf[
'noneditable'])));
7429 $this->createEditField(
'content', $settings[
'content']);
7430 } elseif ($GLOBALS[
'smarty']) {
7432 $GLOBALS[
'smarty']->assign(
'inlineedit_lock',
true);
7443 private function getEditFieldSettings($name =
'') {
7445 $short_type = !$this->_site->admin[
'editor'][
'short'] && !$GLOBALS[
'egotec_conf'][
'editor'][
'short']
7446 ?
'text' :
'content';
7449 $plaintext = (bool) $this->_site->admin[
'editor'][
'plaintext'];
7455 'title' => $GLOBALS[
'auth']->translate(
'Name'),
7458 'perm' =>
'extra_information',
7459 'mandatory' =>
true,
7465 'title' => $GLOBALS[
'auth']->translate(
'Titel'),
7468 'perm' =>
'extra_information',
7470 'plaintext' => $plaintext
7474 'title' => $GLOBALS[
'auth']->translate(
'Kurzbeschreibung'),
7476 'type' => $short_type,
7477 'perm' =>
'extra_information',
7478 'plaintext' => $plaintext && $short_type ==
'text' 7482 'title' => $GLOBALS[
'auth']->translate(
'Inhalt'),
7487 if (!empty($this->conf[
'fields'])) {
7488 $settings = array_replace_recursive($settings, $this->conf[
'fields']);
7493 if (isset($settings[$name])) {
7494 return $settings[$name];
7513 public function createEditField($name, $setting = array(), $empty =
false, $orient =
'', $index = 0, $block =
'', $replace =
false) {
7514 if (empty($setting) && !($setting = $this->getEditFieldSettings($name))) {
7518 $field = $setting[
'field'] ?
'field' :
'extra';
7521 if (isset($this->editFields[$field][$name])) {
7522 return $this->editFields[$field][$name];
7526 if (isset($setting[
'default']) && strpos($setting[
'default'],
'@') === 0) {
7527 $parts = explode(
'.', substr($setting[
'default'], 1), 2);
7528 $parts[1] = str_replace(array(
'@orient',
'@index',
'@block'), array($orient, $index, $block), $parts[1]);
7533 if (is_array($this->conf[
'values'][$orient][$setting[
'type']])) {
7534 foreach ($this->conf[
'values'][$orient][$setting[
'type']] as $param => $value) {
7535 if (!isset($setting[$param])) {
7536 $setting[$param] = $value;
7546 $edit_field =
function() use ($field, $name, $setting, $empty, $orient, $index, $block, $replace) {
7548 if ($field ==
'extra' || $this_value !== null) {
7549 $frontend_admin = $GLOBALS[
'frontend_admin'] && $this->conf[
'orients'][$orient][
'disabled'] !==
true && $this->isCurrentPage();
7550 $title = $setting[
'title'] ? $GLOBALS[
'auth']->translate($setting[
'title']) : $setting[
'var'];
7551 $dir = $setting[
'dir'] ? $setting[
'dir'] :
'right';
7553 $type = $setting[
'type'];
7554 if ($setting[
'type'] ==
'media') {
7564 if (strpos($setting[
'var'],
'=') === 0) {
7565 list($field, $name) = explode(
'.', substr($setting[
'var'], 1), 2);
7573 if (!empty($this->conf[
'blocks'][$block][
'default'][$orient])) {
7574 $sub_name = implode(
'.', array_slice(explode(
'.', $name), 3));
7575 if (($default_value =
Ego_System::getAssocValue($this->conf[
'blocks'][$block][
'default'][$orient], $sub_name)) !== null) {
7576 $edit_value = $default_value;
7580 $edit_value = $this_value;
7584 $layout = $this->extra[
'_layout'];
7585 if (empty($layout)) {
7586 $layout = $this->conf[
'default_layout'];
7591 !$setting[
'default']
7592 && !$setting[
'optional']
7593 && !empty($this->conf[
'layouts'][$layout][
'blocks'][$orient][
'default'])
7594 && in_array($block, explode(
',', $this->conf[
'layouts'][$layout][
'blocks'][$orient][
'default']))
7595 && !in_array($type, array(
'image',
'media',
'video',
'audio',
'table'))
7597 $setting[
'default'] = $title;
7600 if (($empty || $replace) && $frontend_admin && $edit_value ==
'' && in_array($type, array(
'text',
'minimal',
'content',
'editor',
'link'))) {
7602 if ($type ==
'link') {
7604 $edit_value = $setting[
'default'] ? $setting[
'default'] :
'';
7607 $edit_value = $setting[
'default'] ? $setting[
'default'] : $title;
7611 if ($frontend_admin && in_array($type, array(
'image',
'video',
'audio'))) {
7612 $type_class =
"egotec_type_{$type}";
7613 if (empty($setting[
'attr'][
'class'])) {
7614 $setting[
'attr'][
'class'] =
"egotec_media {$type_class}";
7616 $setting[
'attr'][
'class'] .=
" egotec_media {$type_class}";
7626 if (isset($setting[
'attr'])) {
7627 $tag_name = $type ==
'text' ?
'span' :
'div';
7628 $wrapper =
'<' . $tag_name;
7629 foreach ($setting[
'attr'] as $attr => $value) {
7630 $wrapper .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
7632 $wrapper .=
'>' . $edit_value .
'</' . $tag_name .
'>';
7633 $edit_value = $wrapper;
7643 require_once(
'smarty/plugins/function.video.php');
7644 $edit_value = smarty_function_video(array_replace_recursive(array(
7645 'src' => $edit_value,
7652 'fallback' => $frontend_admin,
7653 'audio' => $type ==
'audio' 7654 ), $setting), $GLOBALS[
'smarty']);
7655 if (empty($edit_value)) {
7656 $setting[
'empty'] =
true;
7662 if (!$frontend_admin && empty($edit_value) && !$setting[
'default']) {
7668 foreach (array(
'alt',
'title') as $attr) {
7669 if (!isset($setting[
'attr'][$attr])) {
7671 $setting[
'attr'][$attr] = $attr_value;
7675 if (isset($setting[
'attr'][
'class'])) {
7677 $setting[
'attr'][
'class'] = trim($setting[
'attr'][
'class']);
7679 $setting[
'attr'][
'class'] = $attr_value;
7683 require_once(
'smarty/plugins/function.picture.php');
7684 $edit_value = smarty_function_picture(array_replace_recursive(array(
7685 'src' => $edit_value,
7688 'fallback' => $frontend_admin
7689 ), $setting), $GLOBALS[
'smarty']);
7690 if (empty($edit_value)) {
7691 $setting[
'empty'] =
true;
7697 if (!$frontend_admin && empty($edit_value)) {
7703 $default =
'<a href=""';
7704 $a =
'<a href="' . $edit_value .
'"';
7705 if (!is_array($setting[
'attr'])) {
7706 $setting[
'attr'] = array();
7708 foreach (array(
'class',
'title',
'target') as $attr) {
7709 if (!isset($setting[
'attr'][$attr])) {
7711 } elseif ($attr ==
'class') {
7713 $setting[
'attr'][
'class'] = trim($setting[
'attr'][
'class']);
7716 foreach ($setting[
'attr'] as $attr => $value) {
7717 if ($attr !=
'href' && $value !=
'') {
7718 if ($attr !=
'target') {
7719 $default .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
7721 $a .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
7724 $default .=
'>' . ($setting[
'default'] ? $setting[
'default'] : $title) .
'</a>';
7726 $setting[
'default'] = $default;
7727 $edit_value = empty($edit_value) ? $default : $a;
7732 if (!$frontend_admin && empty($edit_value)) {
7738 foreach ([
'rows_edit',
'cols_edit',
'cols_size'] as $key) {
7739 if (!isset($setting[$key]) || !empty($setting[$key])) {
7740 $setting[$key] =
true;
7754 $create =
function($name1, $name2, $rows, $cols, $contents =
'') {
7755 $contents = explode(
'|', is_string($contents) ? $contents :
'');
7756 $html =
"<{$name1}>";
7757 for ($r = 0; $r < $rows; $r++) {
7759 for ($c = 0; $c < $cols; $c++) {
7760 $content = isset($contents[$c]) && trim($contents[$c]) !=
'' 7761 ? $GLOBALS[
'auth']->translate(trim($contents[$c]))
7763 $html .=
"<{$name2}>{$content}</{$name2}>";
7767 $html .=
"</{$name1}>";
7772 $rows = $setting[
'rows'] ? (int) $setting[
'rows'] : 2;
7773 $cols = $setting[
'cols'] ? (int) $setting[
'cols'] : 2;
7776 if (is_array($setting[
'attr'])) {
7778 foreach ($setting[
'attr'] as $attr => $value) {
7779 $table .=
' ' . $attr .
'="' . str_replace(
'"',
'\"', $value) .
'"';
7784 $table .= ($setting[
'thead'] ? $create(
'thead',
'th', 1, $cols, $setting[
'thead']) :
'')
7785 . $create(
'tbody',
'td', $rows, $cols)
7786 . ($setting[
'tfoot'] ? $create(
'tfoot',
'td', 1, $cols, $setting[
'tfoot']) :
'')
7790 $setting[
'default'] = $table;
7791 if (empty($edit_value)) {
7792 $edit_value = $table;
7795 require_once(
'base/Ego_DomQuery.php');
7797 $table = $dom->doc->firstChild;
7799 if ($table->hasAttributes()) {
7800 foreach ($table->attributes as $attribute) {
7802 !is_array($setting[
'attr'])
7803 || empty($setting[
'attr'])
7804 || !in_array($table->nodeName, array_keys($setting[
'attr']))
7807 $table->removeAttribute($attribute->nodeName);
7812 if (is_array($setting[
'attr'])) {
7813 foreach ($setting[
'attr'] as $attr => $value) {
7814 if (!$table->hasAttribute($attr) || $table->getAttribute($attr) != $value) {
7816 $table->setAttribute($attr, $value);
7822 $edit_value = $dom->getHTML();
7839 $get_value =
function($value, $setting) use ($type) {
7840 if (empty($value)) {
7841 $value = !empty($setting[
'default']) ? $setting[
'default'] :
'';
7844 if ($type ==
'date' && preg_match(
'/^<%(.*?)>$/', $value, $match)) {
7848 if (!empty($setting[
'format']) && !empty($value)) {
7849 $value = date($setting[
'format'], strtotime($value));
7851 if (!empty($setting[
'value'])) {
7852 $value = str_replace(
'<%>', $value, $setting[
'value']);
7860 && (($block_name = $block) || ($block_name = $this->extra[
'_blocks'][$orient][$index]))
7861 && ($controls = $this->getBlockControls($block_name))
7863 $value_name = ltrim(strrchr($name,
'.'),
'.');
7864 foreach ($controls as $select) {
7865 if ($select[
'name'] == $value_name) {
7866 $value = $get_value($value, $select);
7872 $value = $get_value($value, $setting);
7877 if (empty($edit_value)) {
7878 if (!$frontend_admin) {
7882 $edit_value = $setting[
'default'] ? $setting[
'default'] : $title;
7886 $languages = $setting[
'languages'] ?? $this->conf[
'code'][
'languages'] ?? array();
7887 if (!is_array($languages)) {
7888 $languages_array = explode(
',', $languages);
7889 $languages = array();
7890 foreach ($languages_array as $language) {
7891 $languages[$language] = $language;
7894 $first_language = null;
7895 foreach ($languages as $value => $text) {
7896 $first_language = $value;
7903 ?? $this->conf[
'code'][
'mode']
7907 $smarty = Ego_Smarty::createFrontend($this->getSite(), array(
7908 'id' =>
'code-' . md5($name),
7910 'value' => $edit_value,
7911 'theme' => $setting[
'theme'] ?? $this->conf[
'code'][
'theme'] ??
'monokai',
7912 'mode' => mb_strtolower($mode),
7913 'label' => $setting[
'label'] ?? $languages[$mode] ?? $mode,
7914 'min' => $setting[
'min'] ?? $this->conf[
'code'][
'min'] ?? 3,
7915 'max' => $setting[
'max'] ?? $this->conf[
'code'][
'max'] ?? 20,
7916 'languages' => $languages
7918 $edit_value = $smarty->fetch($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'page/t/input/code.tpl');
7921 $original_value = $edit_value;
7924 if ($frontend_admin) {
7931 $escape =
function($s) {
7932 return htmlspecialchars(
7933 preg_replace(
'/\s+/',
' ', $s),
7940 foreach (array(
'toolbar',
'menubar') as $key) {
7941 if (isset($setting[$key]) && is_bool($setting[$key])) {
7942 $setting[$key] = $setting[$key] ===
true ?
'true' :
'false';
7947 $additional_attributes = array();
7948 if (!empty($setting[
'attr'])) {
7949 foreach ($setting[
'attr'] as $attr => $value) {
7950 if (in_array($setting[
'type'], array(
'link',
'table'))) {
7954 $additional_attributes[] = $attr .
'="' . $escape($value) .
'"';
7958 $edit_value =
'<div' 7959 . ($setting[
'field'] ?
' data-edit-field="' . $name .
'"' :
' data-edit-extra="' . $name .
'"')
7960 .
' data-edit-tooltip="' . $escape($title) .
'"' 7961 .
' data-edit-tooltip-dir="' . $dir .
'"' 7962 .
' data-edit-type="' . $setting[
'type'] .
'"' 7963 . ($setting[
'default'] ?
' data-edit-default="' . $escape($setting[
'default']) .
'"' :
'')
7964 . ($setting[
'perm'] && !$this->hasRights(explode(
',', $setting[
'perm'])) ?
' data-edit-locked="true"' :
'')
7965 . ($setting[
'style'] ?
' style="' . $setting[
'style'] .
'"' :
'')
7966 . ($setting[
'mandatory'] ?
' data-edit-mandatory="true"' :
'')
7967 . ($setting[
'readonly'] ?
' data-edit-readonly="true"' :
'')
7968 . ($setting[
'rows_edit'] ?
' data-edit-rows="true"' :
'')
7969 . ($setting[
'cols_edit'] ?
' data-edit-cols="true"' :
'')
7970 . ($setting[
'cols_size'] ?
' data-edit-cols-size="true"' :
'')
7971 . ($setting[
'maxlength'] ?
' data-edit-maxlength="' . $setting[
'maxlength'] .
'"' :
'')
7972 . ($setting[
'empty'] ?
' data-edit-empty="true"' :
'')
7973 . ($setting[
'href'] ===
false ?
' data-edit-href="false"' :
'')
7974 . ($setting[
'optional'] ?
' data-edit-optional="true"' :
'')
7975 . ($setting[
'plaintext'] ?
' data-edit-plaintext="true"' :
'')
7976 . ($setting[
'root'] ?
' data-edit-root="true"' :
'')
7977 . ($setting[
'unsafe'] ?
' data-edit-unsafe="true"' :
'')
7978 . ($setting[
'hooks'] ?
' data-edit-hooks="' . $setting[
'hooks'] .
'"' :
'')
7979 . ($setting[
'plugins'] ?
' data-edit-plugins="' . $setting[
'plugins'] .
'"' :
'')
7980 . ($setting[
'toolbar'] ?
' data-edit-toolbar="' . $setting[
'toolbar'] .
'"' :
'')
7981 . ($setting[
'menubar'] ?
' data-edit-menubar="' . $setting[
'menubar'] .
'"' :
'')
7982 . ($setting[
'paste_tags'] ?
' data-edit-paste-tags="' . $setting[
'paste_tags'] .
'"' :
'')
7983 . ($setting[
'paste_attrs'] ?
' data-edit-paste-attrs="' . $setting[
'paste_attrs'] .
'"' :
'')
7984 . ($setting[
'edit'] ?
' data-edit-media="' . $escape(json_encode($setting[
'edit'], JSON_FORCE_OBJECT)) .
'"' :
'')
7985 . (!empty($setting[
'attr']) ?
' data-edit-attr="' . $escape(json_encode($setting[
'attr'], JSON_FORCE_OBJECT)) .
'"' :
'')
7986 . implode(
' ', $additional_attributes)
7987 .
'>' . $edit_value .
'</div>';
7992 foreach (array(
'required',
'optional') as $display_type) {
7994 $this->conf[
'form'][$display_type]
7995 && $setting[
'var'] ==
'label' 7996 && trim($original_value) !=
'' 7997 && strpos($block,
'input_') === 0
7998 && $this->extra[
'_contents'][$orient][$index][
'extra'][$display_type]
8000 $edit_value = $GLOBALS[
'smarty']->fetch(
'string:' . str_replace(
'<%>', $edit_value, $this->conf[
'form'][$display_type]));
8004 if (in_array($type, array(
'video',
'audio',
'image',
'media'))) {
8006 $caption = $this->conf[
'caption'];
8007 if (isset($this->conf[
'blocks'][$block][
'caption'])) {
8008 $caption = $this->conf[
'blocks'][$block][
'caption'];
8010 if (isset($setting[
'caption'])) {
8011 $caption = $setting[
'caption'];
8015 if ($frontend_admin) {
8017 require_once(
'smarty/plugins/function.value.php');
8018 $var = substr(strrchr($name,
'.'), 1);
8019 $caption_value = smarty_function_value(array(
8020 'var' =>
"{$var}_caption",
8021 'type' =>
'minimal',
8022 'title' => $setting[
'type'] ==
'image' 8023 ? $GLOBALS[
'auth']->translate(
'Bildbeschreibung')
8024 : $GLOBALS[
'auth']->translate(
'Beschreibung'),
8025 'orient' => $orient,
8027 ), $GLOBALS[
'smarty']);
8031 if ($caption_value !=
'') {
8032 $edit_value = str_replace(array(
'<%>',
'<#>'), array($edit_value, $caption_value), $caption);
8037 if ($setting[
'wrapper'] && ($frontend_admin || $edit_value !=
'')) {
8039 $edit_value = str_replace(
'<%>', $edit_value, $setting[
'wrapper']);
8042 if ($setting[
'url']) {
8046 if ($frontend_admin || !$href) {
8048 $href =
'javascript:void(0)';
8051 require_once(
'base/Ego_DomQuery.php');
8053 $links = $dom->query($setting[
'url']);
8054 foreach ($links as $link) {
8055 $link->setAttribute(
'href', $href);
8057 $link->setAttribute(
'target', $target);
8060 $edit_value = $dom->getHTML();
8068 return $this->editFields[$field][$name] = $edit_field();
8084 public function updateUrls($verbose =
false, $force_recursive =
false) {
8086 $GLOBALS[
'egotec_conf'][
'rewrite_engine'] !=
'url' 8088 $_SERVER[
'HTTP_X_SOAP_CALL'] ==
'Replication' 8089 && $this->getSite()->getCache()->getEternal()
8091 || $this->field[
'deleted']
8092 || ($this->field[
'nav_hide']&8) == 8
8093 || $this->isWorkflowCopy()
8094 || $this->isReleaseCopy()
8095 || strpos($this->field[
'type'],
'/occupancy/')
8100 $db = new_db_connection();
8107 $get_current_urls =
function() use ($db) {
8109 'table' =>
'egotec_url',
8110 'fields' =>
'site, lang, id, domain, dir, path, canonical',
8111 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical = 1',
8113 'site' => $this->_site->name,
8114 'lang' => $this->_site->language,
8115 'id' => $this->field[
'id']
8119 while ($db->nextRecord()) {
8120 $urls[] = $db->Record;
8125 $old_urls = $get_current_urls();
8127 if (!$this->field[
'inactive']) {
8128 $now = date(
'Y-m-d H:i:s');
8131 $virtual_hosts = $this->_site->getVirtualHosts();
8134 $conf = $this->_site->getRewriteConf();
8139 if (!empty($this->field[
'url'])) {
8144 $space = $conf[
'space'];
8145 if (empty($space)) {
8148 $name = str_replace(
' ', $space, $this->field[
'url']);
8149 $names = array($name);
8151 if (!$conf[
'flat']) {
8153 $paths = $this->getPaths(
false,
true);
8155 if (empty($paths)) {
8163 $names = $this->getUrlNames();
8165 if ($this->field[
'id'] == $this->_site->rootId) {
8167 array_unshift($names,
'');
8170 foreach ($names as $ni => $name) {
8171 foreach ($paths as $pi => $path) {
8172 $dir = trim($GLOBALS[
'egotec_conf'][
'url_dir'] . implode(
'/', array_filter(array($path[
'name'], $name))),
'/');
8173 foreach ($virtual_hosts as $vi => $virtual_host) {
8176 $virtual_host = rtrim($virtual_host,
'/');
8177 if ($part = strstr($virtual_host,
'/')) {
8178 $virtual_host = strstr($virtual_host,
'/',
true);
8179 $this_dir = trim($part .
"/{$dir}",
'/');
8183 'site' => $this->_site->name,
8184 'lang' => $this->_site->language,
8185 'id' => $this->field[
'id'],
8186 'domain' => $virtual_host,
8188 'path' => (
string)$path[
'id']
8192 $unique_dir = $this_dir;
8193 $duplicate_params = $params;
8194 unset($duplicate_params[
'site'], $duplicate_params[
'lang'], $duplicate_params[
'id']);
8197 $duplicate_params[
'dir'] = $unique_dir;
8199 'table' =>
'egotec_url',
8200 'where' =>
'domain = :domain AND dir = :dir AND path = :path',
8201 'bind' => $duplicate_params
8203 if ($db->nextRecord()) {
8205 $db->Record[
'site'] == $this->_site->name
8206 && $db->Record[
'lang'] == $this->_site->language
8207 && $db->Record[
'id'] == $this->field[
'id']
8208 && !$db->nextRecord()
8212 if ($db->Record[
'canonical'] == 0) {
8214 'table' =>
'egotec_url',
8215 'where' =>
'site = :site AND lang = :lang AND id = :id AND domain = :domain AND dir = :dir AND path = :path AND canonical = 0',
8217 'site' => $db->Record[
'site'],
8218 'lang' => $db->Record[
'lang'],
8219 'id' => $db->Record[
'id'],
8220 'domain' => $db->Record[
'domain'],
8221 'dir' => $db->Record[
'dir'],
8222 'path' => $db->Record[
'path']
8226 $unique_dir = $this_dir .
'-' . $n++;
8232 $params[
'dir'] = $unique_dir;
8237 'table' =>
'egotec_url',
8238 'where' =>
'domain = :domain AND dir = :dir',
8240 'domain' => $params[
'domain'],
8241 'dir' => $params[
'dir']
8247 'table' =>
'egotec_url',
8248 'set' => array_merge($params, array(
8249 'canonical' => $ni == 0 && $vi == 0 ? 1 : 2,
8260 'table' =>
'egotec_url',
8261 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical = 3',
8263 'site' => $this->_site->name,
8264 'lang' => $this->_site->language,
8265 'id' => $this->field[
'id']
8270 foreach ($virtual_hosts as $vi => $virtual_host) {
8274 $virtual_host = rtrim($virtual_host,
'/');
8275 if ($part = strstr($virtual_host,
'/')) {
8276 $virtual_host = strstr($virtual_host,
'/',
true);
8277 $dir = ltrim($part .
'/',
'/');
8281 'table' =>
'egotec_url',
8283 'site' => $this->_site->name,
8284 'lang' => $this->_site->language,
8285 'id' => $this->field[
'id'],
8286 'domain' => $virtual_host,
8287 'dir' =>
"{$dir}-{$this->field['id']}",
8292 'primary' => [
'domain',
'dir' ]
8299 'table' =>
'egotec_url',
8300 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical > 0 AND c_date < :c_date',
8302 'site' => $this->_site->name,
8303 'lang' => $this->_site->language,
8304 'id' => $this->field[
'id'],
8321 $this->field[
'id'] != $this->_site->rootId
8322 && serialize($old_urls) != serialize($get_current_urls())
8325 $children = $this->getChildren(array(), array(
8328 'only_active' =>
false,
8331 foreach ($children as $child) {
8332 $child->updateUrls($verbose, $force_recursive);
8343 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'url') {
8344 $db = new_db_connection();
8348 'table' =>
'egotec_url',
8349 'where' =>
'site = :site AND lang = :lang AND id = :id AND canonical > 0',
8351 'site' => $this->_site->name,
8352 'lang' => $this->_site->language,
8353 'id' => $this->field[
'id']
8370 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'url') {
8371 $db = new_db_connection();
8375 'table' =>
'egotec_url',
8376 'where' =>
'site = :site AND lang = :lang AND id = :id',
8378 'site' => $this->_site->name,
8379 'lang' => $this->_site->language,
8380 'id' => $this->field[
'id']
8395 $name = $this->field[
'name'];
8398 $conf = $this->_site->getRewriteConf();
8401 if ($conf[
'umlauts']) {
8402 $name = str_replace(array(
'Ä',
'Ö',
'Ü',
'ä',
'ö',
'ü',
'ß'), array(
'Ae',
'Oe',
'Ue',
'ae',
'oe',
'ue',
'ss'), $name);
8406 switch ($conf[
'case']) {
8409 $name = mb_strtoupper($name);
8414 $name = mb_strtolower($name);
8418 $space = $conf[
'space'];
8419 if (empty($space)) {
8422 $name = str_replace(
' ', $space, $name);
8425 $name = strtr($name,
"%\n\r\t,;#?:&/'\".\\",
'_______________');
8427 if ($name[0] ==
'-') {
8433 $url_file = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'lib/url.php';
8435 require_once $url_file;
8436 $result = get_url_names($this, $conf, $name);
8437 if (
sizeof($result) > 0) {
8438 foreach ($result as $key => $value) {
8439 if ($value[0] ==
'-') {
8441 $result[$key][0] =
'_';
8448 return array($name);
8462 $this->removeLinks();
8464 if (!$this->field[
'deleted']) {
8466 if (!in_array($this->field[
'type'], array(
'multimedia/file',
'multimedia/image'))) {
8467 $this->updateLinksRecursive($links, $this->field[
'content'],
true);
8469 $this->updateLinksRecursive($links, $this->extra);
8471 $db = new_db_connection();
8473 foreach ($links as $link) {
8475 'table' =>
'egotec_links',
8483 if ($inherited && $this->_site->site[
'type'] ==
'media') {
8486 'only_active' =>
false,
8491 foreach ($this->getAncestors(array(
8492 'where' =>
"type = 'multimedia/category'" 8493 ), $params) as $ancestor) {
8495 'table' =>
'egotec_links',
8496 'where' =>
'dest_site = :site AND dest_lang = :lang AND dest_id = :id',
8498 'site' => $this->_site->name,
8499 'lang' => $this->_site->language,
8500 'id' => $ancestor->field[
'id']
8503 while ($db->nextRecord()) {
8505 $site =
new Site($db->Record[
'src_site'], $db->Record[
'src_lang']);
8506 if ($page = $site->getPage($db->Record[
'src_id'], $params)) {
8507 $page->updateLinks(
false);
8528 private function updateLinksRecursive(&$links, $data, $only_nodes =
false, $extra = array(), $num = 0) {
8532 'only_active' =>
false,
8537 if (is_array($data)) {
8538 foreach ($data as $key => $value) {
8541 $this->updateLinksRecursive($links, $value, $only_nodes, $tmp, $num);
8543 } elseif (!empty($extra)) {
8545 if ($media = $this->_site->getMediaSite()) {
8546 $more_links = array();
8547 switch ($this->field[
'type']) {
8550 end($extra) ==
'gallery_path' 8551 && ($page = $media->getPage($data, array(
'internal' =>
true)))
8553 $more_links[] = $page;
8554 foreach ($page->getChildren(array(), $params) as $child) {
8555 $more_links[] = $child;
8560 if (end($extra) ==
'media_verz') {
8563 $more_links[] = $page;
8564 foreach ($page->getChildren(array(), $params) as $child) {
8565 $more_links[] = $child;
8571 case 'buergerservice/leistung/entry':
8572 if (end($extra) ==
'multimedia_id') {
8573 if (is_numeric($data)) {
8574 $page = $media->getPage($data, array(
'internal' =>
true));
8579 $more_links[] = $page;
8580 foreach ($page->getDescendants(array(), $params) as $descendant) {
8581 $more_links[] = $descendant;
8586 case 'buergerservice/leistung/list':
8588 end($extra) ==
'mm_mainDir' 8589 && ($page = $media->getPage($data, array(
'internal' =>
true)))
8591 $more_links[] = $page;
8592 foreach ($page->getDescendants(array(), $params) as $descendant) {
8593 $more_links[] = $descendant;
8597 case 'wiki/diskussion':
8598 case 'wiki/kommentar':
8600 case 'wiki/portal_list':
8602 if (end($extra) ==
'documents') {
8603 foreach (explode(
',', $data) as $id) {
8604 if ($page = $media->getPage($id)) {
8605 $more_links[] = $page;
8616 $more_links = array_merge($more_links, $this->getMoreLinks());
8617 }
catch (Exception $e) {
8622 foreach ($more_links as $link) {
8627 'src_site' => $this->_site->name,
8628 'src_lang' => $this->_site->language,
8629 'src_id' => $this->field[
'id'],
8630 'dest_site' => $link->getSite()->name,
8631 'dest_lang' => $link->getSite()->language,
8632 'dest_id' => $link->field[
'id'],
8636 'extra_key' => implode(
',', $extra)
8644 if (is_string($data)) {
8647 $pattern =
'/(<([^> ]+) [^>]*)(href="|src="|data="|value="|archive="|class="|url\(\')([^,"\']*(index\.php\?|-site-)([^,"\']+))(["\'][^>]*>((.*?)<\/\\2>)?)/ims';
8649 $pattern =
'/(<([^> ]+) [^>]*)?(href="|src="|data="|value="|archive="|class="|url\(\')?([^,"\']*(index\.php\?|-site-)([^,"\']+))(["\'][^>]*>((.*?)<\/\\2>)?)?/ims';
8651 if (preg_match_all($pattern, $data, $matches)) {
8652 foreach ($matches[0] as $index => $value) {
8653 $url = rtrim($matches[4][$index],
'\\');
8659 if ($info[
'params'][
'p']) {
8660 $info[
'params'][
'id'] = $info[
'params'][
'p'];
8662 if ($info[
'params'][
'site'] && $info[
'params'][
'id']) {
8663 $lang = $info[
'params'][
'lang'];
8666 $site =
new Site($info[
'params'][
'site']);
8667 $site->addParam($params);
8668 }
catch (Exception $e) {
8671 $lang = $site->language;
8675 }
catch (Exception $e) {
8681 $text = (string)$matches[9][$index];
8683 'src_site' => $this->_site->name,
8684 'src_lang' => $this->_site->language,
8685 'src_id' => $this->field[
'id'],
8686 'dest_site' => (
string)$info[
'params'][
'site'],
8687 'dest_lang' => (
string)$lang,
8688 'dest_id' => (
int)$info[
'params'][
'id'],
8689 'tag' => (
string)$matches[2][$index],
8692 'extra_key' => implode(
',', $extra)
8694 if (trim($text) !=
'') {
8695 $this->updateLinksRecursive($links, $text, $only_nodes, $extra, $num);
8697 if (stripos($matches[0][$index],
'target="_lightbox"') !==
false) {
8699 foreach ($page->getSiblings() as $sibling) {
8701 $sibling->field[
'type'] ==
'multimedia/image' 8702 && !$sibling->field[
'deleted']
8703 && !$sibling->field[
'inactive']
8706 'src_site' => $this->_site->name,
8707 'src_lang' => $this->_site->language,
8708 'src_id' => $this->field[
'id'],
8709 'dest_site' => (
string)$info[
'params'][
'site'],
8710 'dest_lang' => (
string)$lang,
8711 'dest_id' => $sibling->field[
'id'],
8712 'tag' => (
string)$matches[2][$index],
8715 'extra_key' => implode(
',', $extra)
8725 $pattern =
'/^\{.*?"pages":\[\{.*?"(site|lang|id)":.*?\}\].*\}$/ims';
8726 if (preg_match_all($pattern, $data, $matches)) {
8727 require_once(
'base/Ego_Combo.php');
8728 foreach ($matches[0] as $value) {
8731 foreach ($combo->getPages(
true) as $page) {
8733 'src_site' => $this->_site->name,
8734 'src_lang' => $this->_site->language,
8735 'src_id' => $this->field[
'id'],
8736 'dest_site' => $page->getSite()->name,
8737 'dest_lang' => $page->getSite()->language,
8738 'dest_id' => $page->field[
'id'],
8742 'extra_key' => implode(
',', $extra)
8752 $pattern =
'/[a-z0-9_]+' 8753 .preg_quote(self::IDENTITY_SEPARATOR,
'/')
8755 .preg_quote(self::IDENTITY_SEPARATOR,
'/')
8757 if (preg_match_all($pattern, $data, $matches)) {
8758 foreach ($matches[0] as $value) {
8760 $page = self::byIdentity($value, $params);
8763 'src_site' => $this->_site->name,
8764 'src_lang' => $this->_site->language,
8765 'src_id' => $this->field[
'id'],
8766 'dest_site' => $page->getSite()->name,
8767 'dest_lang' => $page->getSite()->language,
8768 'dest_id' => $page->field[
'id'],
8772 'extra_key' => implode(
',', $extra)
8789 $db = new_db_connection();
8791 'table' =>
'egotec_links',
8792 'where' =>
"src_site = '{$this->_site->name}'" 8793 .
" AND src_lang = '{$this->_site->language}'" 8794 .
" AND src_id = '{$this->field['id']}'" 8807 $db = new_db_connection();
8809 'table' =>
'egotec_links',
8810 'where' =>
"src_site = :site AND src_lang = :lang AND src_id = :id",
8812 'site' => $this->_site->name,
8813 'lang' => $this->_site->language,
8814 'id' => $this->field[
'id']
8817 while ($db->nextRecord()) {
8818 $record = $db->Record;
8825 'deleted_or' =>
'1=1',
8827 'only_active' =>
false 8830 $site =
new Site($db->Record[
'dest_site'], $db->Record[
'dest_lang']);
8831 $page = $site->getPage($db->Record[
'dest_id'], $param);
8833 if ($page->field[
'type'] ==
'multimedia/category') {
8834 $descendants = $page->getDescendants(array(), $param);
8835 $record[
'descendants'] = 0;
8836 foreach ($descendants as $descendant) {
8837 $record[
'descendants']++;
8838 $link = $db->Record;
8839 $link[
'dest_id'] = $descendant->field[
'id'];
8840 $link[
'recursive'] =
true;
8867 'only_active' =>
false,
8873 $db = new_db_connection();
8875 foreach ($this->_site->getLanguages() as $lang) {
8876 if ($page = $this->getLanguagePage($lang, $param)) {
8878 'table' =>
'egotec_links',
8879 'where' =>
"dest_site = :site1 AND dest_lang = :lang AND dest_id = :id1" 8880 .
" AND (src_site != :site2 OR src_id != :id2)",
8882 'site1' => $this->_site->name,
8884 'id1' => $this->field[
'id'],
8885 'site2' => $this->_site->name,
8886 'id2' => $this->field[
'id']
8889 if ($db->nextRecord()) {
8892 'sources' => array()
8897 if ($page->extra[
'clones']) {
8898 foreach (explode(
',', $page->extra[
'clones']) as $clone) {
8900 $clones[] = self::createIdentity($info[
'params']);
8905 $record = $db->Record;
8908 if (!empty($clones) && in_array(self::createIdentity(array(
8909 'site' => $record[
'src_site'],
8910 'lang' => $record[
'src_lang'],
8911 'id' => $record[
'src_id']
8918 $db2 = new_db_connection(array(
8919 'table' => $record[
'src_site'] .
'_' . $record[
'src_lang'],
8920 'where' =>
'id = :id',
8922 'id' => $record[
'src_id']
8928 while (!$db2->nextRecord()) {
8932 $src_site = $record[
'src_site'];
8933 $src_lang = $record[
'src_lang'];
8934 $src_id = $record[
'src_id'];
8935 $num = $record[
'num'];
8936 $link[
'sources'][$src_site][$src_lang][$src_id][$num] = $record;
8937 }
while ($db->nextRecord());
8938 if (!empty($link[
'sources'])) {
8947 $descendants = $this->getDescendants(array(), $param);
8948 foreach ($descendants as $descendant) {
8949 $links = array_merge($links, $descendant->getLinkedPages());
8964 if ($this->extra[
'crop_image']) {
8965 return $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/16x16/crop.png';
8969 : ($folder && $this->hasChildren(array(), array(
'auth_or' =>
'1=1'))
8970 ? $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/16x16/folder.png' 8971 : $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/16x16/page.png');
8972 $this->getTypeInfo();
8973 if (!empty($this->typeInfo)) {
8974 if (!empty($this->typeInfo[
'icon'])) {
8975 $icon = $this->typeInfo[
'icon'];
8976 $get_path =
function() use ($icon) {
8977 $real_path = (string) realpath($icon);
8978 $dir_pos = strpos($real_path, $GLOBALS[
'egotec_conf'][
'egotec_dir']);
8979 if ($dir_pos ===
false) {
8981 $dir = DIRECTORY_SEPARATOR
8982 . array_pop(explode(DIRECTORY_SEPARATOR, trim($GLOBALS[
'egotec_conf'][
'egotec_dir'], DIRECTORY_SEPARATOR)))
8983 . DIRECTORY_SEPARATOR;
8984 if ($dir_pos = strpos($real_path, $dir)) {
8985 return substr($real_path, $dir_pos + strlen($dir));
8988 return substr($real_path, $dir_pos + strlen($GLOBALS[
'egotec_conf'][
'egotec_dir']));
8990 $path = $get_path();
8994 chdir($GLOBALS[
'egotec_conf'][
'egotec_dir']);
8995 $path = $get_path();
8998 $url = $GLOBALS[
'egotec_conf'][
'url_dir'] . $path;
8999 } elseif (!empty($this->extra[
'image_type']) && !$folder) {
9000 $mime = strtolower($this->extra[
'image_type']);
9011 if (
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'bin_dir'].
'admin_skin/egotec/img/icons/small/2013/'.$mime.
'.png')) {
9012 $url = $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/admin_skin/egotec/img/icons/small/2013/'.$mime.
'.png';
9025 if (empty($this->typeInfo)) {
9026 $key =
'type'.md5(serialize(array($this->_site->name, $this->field[
'type'])));
9027 $cache = $this->_site->getCacheEntry($key);
9028 if ($cache === null) {
9029 if ($file = $this->_site->getSiteFile($this->field[
'type'] . DIRECTORY_SEPARATOR .
'type.ini')) {
9030 $this->typeInfo = @parse_ini_file($file,
true);
9031 $this->_site->setCacheEntry($key, is_array($this->typeInfo) ? $this->typeInfo : array());
9034 $this->typeInfo = $cache;
9037 return $this->typeInfo;
9046 $type_info = $this->getTypeInfo();
9047 return $this->_site->hasRight(
'change_type') && empty($type_info[
'unchangeable']);
9059 $css[
'skin'][
'table'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/table.css";
9061 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/table.css")) {
9062 $css[
'global'][
'table'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/table.css";
9065 $css[
'skin'][
'span'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/span.css";
9067 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/span.css")) {
9068 $css[
'global'][
'span'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/span.css";
9071 $css[
'skin'][
'img'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/img.css";
9073 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/img.css")) {
9074 $css[
'global'][
'img'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/img.css";
9077 $css[
'skin'][
'link'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/link.css";
9079 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/link.css")) {
9080 $css[
'global'][
'link'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/link.css";
9082 if (
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].$this->_site->skin.
"/".$this->field[
'type'].
"/style.css")) {
9083 $css[
'type'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/".$this->_site->skin.
"/".$this->field[
'type'].
"/style.css";
9084 $content_css = $css[
'type'][
'style'];
9087 $css[
'skin'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'skin/'.$this->_site->skin.
"/style.css";
9088 $content_css = $css[
'skin'][
'style'];
9090 if ($this->_site->globalAllowed() &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'skin_dir'].
"_global/style.css")) {
9091 $css[
'global'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
"skin/_global/style.css";
9092 $content_css = $css[
'global'][
'style'];
9095 $this->extra[
'_style']
9096 && ($file = $this->_site->getSkinFile($this->field[
'type'].
'/style.'.$this->extra[
'_style'].
'.css', array(),
true))
9098 $css[
'variant'][
'style'] = $file;
9099 $content_css = $css[
'variant'][
'style'];
9103 if ($this->_site->theme) {
9104 if (empty($css[
'theme'][
'table']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/table.css")) {
9105 $css[
'theme'][
'table'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/table.css";
9107 if (empty($css[
'theme'][
'span']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/span.css")) {
9108 $css[
'theme'][
'span'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/span.css";
9110 if (empty($css[
'theme'][
'img']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/img.css")) {
9111 $css[
'theme'][
'img'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/img.css";
9113 if (empty($css[
'theme'][
'link']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/link.css")) {
9114 $css[
'theme'][
'link'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/link.css";
9116 if (empty($css[
'theme'][
'style']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/".$this->field[
'type'].
"/style.css")) {
9117 $css[
'theme'][
'type'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/".$this->field[
'type'].
"/style.css";
9119 if (empty($css[
'theme'][
'style']) &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'pub_dir'].
'theme/'.$this->_site->theme.
"/skin/style.css")) {
9120 $css[
'theme'][
'style'] = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/theme/'.$this->_site->theme.
"/skin/style.css";
9125 if ($GLOBALS[
'admin_area'] && ($file = $this->_site->getSkinFile(
'admin.css', array(),
true))) {
9126 $css[
'admin'][
'style'] = $file;
9131 'content_css' => $content_css
9141 return $this->field[
'name'];
9150 return self::createIdentity(array(
9151 'site' => $this->_site->name,
9152 'lang' => $this->_site->language,
9153 'id' => $this->field[
'id']
9164 return is_string($identity) && preg_match(
'/^[a-z0-9_]+' . preg_quote(self::IDENTITY_SEPARATOR,
'/') .
'[a-z]{2}' . preg_quote(self::IDENTITY_SEPARATOR,
'/') .
'\d+$/i', $identity);
9174 return implode(self::IDENTITY_SEPARATOR, array($params[
'site'], $params[
'lang'], $params[
'id']));
9186 list($name, $lang, $id) = explode(self::IDENTITY_SEPARATOR, $identity);
9190 && $GLOBALS[
'site']->site == $name
9191 && $GLOBALS[
'site']->language == $lang
9193 $site = $GLOBALS[
'site'];
9195 $site =
new Site($name, $lang,
'', !$GLOBALS[
'admin_area'] || $_SESSION[
'login'][
'live_preview']);
9197 if (!is_array($param)) {
9200 return $site->getPage($id, $param);
9216 public function inheritExtra($keys, $mixed =
false, $types = array(), $no_rights =
true) {
9219 if (!empty($keys)) {
9221 if (!empty($types)) {
9223 $query[
'where'] = array();
9224 $query[
'bind'] = array();
9226 foreach ($types as $type) {
9227 $query[
'where'][] =
'type = :type'.(++$n);
9228 $query[
'bind'][
'type'.$n] = $type;
9230 $query[
'where'] = implode(
' OR ', $query[
'where']);
9235 $param[
'auth_or'] =
'1=1';
9238 $ancestors = array();
9240 foreach ($this->getAncestors($query, $param) as $ancestor) {
9241 $ancestors[] = $ancestor;
9243 $ancestors = array_reverse($ancestors);
9244 array_unshift($ancestors, $this);
9245 foreach ($ancestors as $ancestor) {
9246 foreach ($keys as $key) {
9248 if ($value !== null && !isset($values[$key])) {
9249 $values[$key] = $value;
9252 foreach ($keys as $k) {
9276 require_once
'stats/Ego_Piwik.php';
9277 $piwik =
new Ego_Piwik();
9278 $piwikdata = $piwik->createWebsite($this);
9279 if (!is_array($piwikdata)) {
9292 $ignore_ids = array($this->field[
'id']);
9295 if ($this->isWorkflowCopy()) {
9296 $ignore_ids[] = (int) $this->extra[
'original_id'];
9298 $original_page = $this->_site->getPage((
int) $this->extra[
'original_id']);
9299 if (!empty($original_page->extra[
'release_ids'])) {
9300 foreach ($original_page->extra[
'release_ids'] as $release_id) {
9301 $ignore_ids[] = (int) $release_id;
9305 if ($this->isReleaseCopy()) {
9306 $ignore_ids[] = (int) $this->extra[
'release_id'];
9308 $original_page = $this->_site->getPage((
int) $this->extra[
'release_id']);
9309 if (!empty($original_page->extra[
'workflow_page'])) {
9310 $ignore_ids[] = (int) $original_page->extra[
'workflow_page'];
9315 if (!empty($this->extra[
'release_ids'])) {
9316 foreach ($this->extra[
'release_ids'] as $release_id) {
9317 $ignore_ids[] = (int) $release_id;
9320 if (!empty($this->extra[
'workflow_page'])) {
9321 $ignore_ids[] = (int) $this->extra[
'workflow_page'];
9324 $db = new_db_connection(array(
9325 'table' => $this->_site->pageTable,
9326 'where' =>
'url = :url AND deleted = 0 AND id NOT IN (' . implode(
', ', array_unique($ignore_ids)) .
')',
9331 if (!$db->nextRecord()) {
9333 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'flat') {
9335 'table' => $this->_site->pageTable,
9336 'where' =>
'name = :name AND id != :id AND deleted = 0',
9339 'id' => $this->field[
'id']
9342 if ($db->nextRecord()) {
9348 if (empty($GLOBALS[
'egotec_conf'][
'rewrite_engine'])) {
9350 'table' => $this->_site->pageTable,
9351 'where' =>
'page_id = :root_id AND name = :name AND id != :id AND deleted = 0',
9352 'join' => $this->_site->pageTable.
'_children ON ('.$this->_site->pageTable.
'_children.child = id)',
9354 'root_id' => $this->_site->rootId,
9356 'id' => $this->field[
'id']
9359 if ($db->nextRecord()) {
9366 if ($site->name == $url) {
9384 public function validateFile($source, $name =
'', $form = array(), $files_conf = array()) {
9385 $files_list = array();
9388 if (!empty($files_conf)) {
9389 $files_list[] = $files_conf;
9393 if (!empty($form) && !empty($this->extra[
'mandatory'][$form[
'form']][$form[
'field']][
'files'])) {
9394 $files_list[] = $this->extra[
'mandatory'][$form[
'form']][$form[
'field']][
'files'];
9398 if (!empty($this->_site->admin[
'files'])) {
9399 $files_list[] = $this->_site->admin[
'files'];
9403 if (!empty($GLOBALS[
'egotec_conf'][
'files'])) {
9404 $files_list[] = $GLOBALS[
'egotec_conf'][
'files'];
9407 if (!empty($files_list)) {
9408 require_once(
'base/Ego_MimeType.php');
9410 $prepare_type =
function($t) {
9411 return trim(ltrim(mb_strtolower($t),
"."));
9413 $type = $prepare_type(pathinfo($name ? $name : @basename($source), PATHINFO_EXTENSION));
9414 $size = @filesize($source);
9415 foreach ($files_list as $files) {
9416 if (!empty($files[
'whitelist']) || !empty($files[
'blacklist']) || !empty($files[
'filesize'])) {
9417 $whitelist = array_map($prepare_type, explode(
',', (
string) $files[
'whitelist']));
9418 $blacklist = array_map($prepare_type, explode(
',', (
string) $files[
'blacklist']));
9420 (!empty($files[
'whitelist']) && (!in_array($type, $whitelist) || !$mime->hasMimeType($source, $whitelist)))
9421 || (!empty($files[
'blacklist']) && empty($files[
'whitelist']) && (in_array($type, $blacklist) || $mime->hasMimeType($source, $blacklist)))
9422 || (!empty($files[
'filesize']) && $size > (int) $files[
'filesize'])
9443 $info = $this->getTypeInfo();
9444 return $this->_site->isFrontendAdmin($check_rights)
9445 && !$info[
'frontend_ignore']
9448 || $this->hasRights(array(
'view'))
9459 return ($_REQUEST[
'site'] ? $_REQUEST[
'site'] : $GLOBALS[
'default_site']) == $this->_site->name
9460 && (!$lang || ($_REQUEST[
'lang'] ? $_REQUEST[
'lang'] : $this->_site->site[
'default_language']) == $this->_site->language)
9461 && ($_REQUEST[
'id'] ? $_REQUEST[
'id'] : ($_REQUEST[
'list'] ? $_REQUEST[
'list'] : $this->_site->rootId)) == $this->field[
'id'];
9470 $_REQUEST[
'site'] = $this->_site->name;
9471 $_REQUEST[
'lang'] = $this->_site->language;
9472 $_REQUEST[
'id'] = $this->field[
'id'];
9473 $GLOBALS[
'site'] = &$this->_site;
9474 $GLOBALS[
'page'] = &$this;
9484 $db = new_db_connection();
9490 'table' => $this->_site->pageTable.
'_v',
9491 'where' =>
"id = {$this->field['id']} AND c_date > :date",
9493 'date' => $this->lastChangeDate
9499 'table' => $this->_site->pageTable.
'_v',
9500 'where' =>
"id = {$this->field['id']} AND c_date > :date1 AND c_date != :date2",
9502 'date1' => $this->lastChangeDate,
9503 'date2' => $this->field[
'c_date']
9511 foreach (glob($this->getMediapool()->dir().
'*', GLOB_ONLYDIR) as $dir) {
9512 $dir_c_date = basename($dir);
9514 is_numeric($dir_c_date)
9515 && (
int) $dir_c_date != $this_c_date
9516 && (
int) $dir_c_date > $last_c_date
9529 return $this->_site->getNextReplicationDate($this);
9538 return $this->_site->getCacheEntry(
"{$key}_{$this->field['id']}");
9549 $this->_site->setCacheEntry(
"{$key}_{$this->field['id']}", $value);
9561 foreach ($this->getChildren(array(
9565 'only_active' =>
false 9567 $child->field[
'identity'] = $child->getIdentity();
9580 $this->newChild(array(
9581 'name' => (
string) $params[
'data']->name,
9582 'title' => (
string) $params[
'data']->name,
9583 'type' => $params[
'type'] ? $params[
'type'] :
'page' 9594 if ($page = self::byIdentity($params[
'identity'])) {
9608 foreach ($params[
'data']->identities as $identity) {
9609 if ($page = self::byIdentity($identity)) {
9623 $children = array();
9624 foreach ($params[
'data'] as $identity) {
9625 list($name, $lang, $id) = explode(self::IDENTITY_SEPARATOR, $identity);
9626 if ($name == $this->_site->name && $lang == $this->_site->language) {
9627 $children[] = (int) $id;
9631 $this->archiveOnly =
false;
9632 $this->update(array(
9634 'children_order' =>
'children' 9636 'children' => $children
9649 'title' => $GLOBALS[
'auth']->translate(
'Empfangen'),
9650 'formatter' =>
'date' 9653 if (is_array($this->extra[
'_blocks'][$orient])) {
9655 foreach ($this->extra[
'_blocks'][$orient] as $index => $block) {
9656 if (strpos($block,
'input_') === 0 && $block !=
'input_submit' && isset($this->extra[
'_contents'][$orient][$index])) {
9657 if ($block ==
'input_file' && $this->extra[
'_forms'][$orient][
'export'] ==
'page') {
9661 $content = $this->extra[
'_contents'][$orient][$index];
9662 $label = $content[
'label'] ? trim($content[
'label'],
' :') : $content[
'extra'][
'name'];
9663 if ($block ==
'input_checkbox') {
9664 require_once
'base/Ego_Combo.php';
9665 $combo =
new Ego_Combo($content[
'extra'][
'values']);
9666 foreach ($combo->getData() as $data) {
9667 $conf[
"data.{$data->field_name}"] = array(
9668 'title' => $label .
': ' . ($data->label ? trim($data->label,
' :') : $data->field_name),
9672 } elseif (isset($content[
'extra'][
'name'])) {
9673 $conf[
"data.{$content['extra']['name']}"] = array(
9674 'title' => $content[
'label'] ? trim($content[
'label'],
' :') : $content[
'extra'][
'name'],
9682 $conf[
'pool'] = array(
9683 'title' => $GLOBALS[
'auth']->translate(
'Dateien'),
9684 'formatter' =>
'pool',
9703 public function fetch($params = array(), $outputfilter =
false, $script =
true, $includes =
true, $variant =
'') {
9704 if ($template = $this->getTemplate($GLOBALS[
'is_mobile'],
'body', $variant)) {
9705 $original_site = $GLOBALS[
'site'];
9706 $original_page = $GLOBALS[
'page'];
9707 $original_smarty = $GLOBALS[
'smarty'];
9708 $GLOBALS[
'site'] = $site = $this->getSite();
9709 $GLOBALS[
'page'] = $page = $this;
9712 $GLOBALS[
'smarty'] = $smarty = Ego_Smarty::createFrontend($site, array(
9717 $require_script =
function($filename) use ($site, $page, $smarty) {
9720 if ($script && ($filename = $site->getSiteFile($page->field[
'type'].
'/index.php'))) {
9721 $require_script($filename);
9723 if (!$outputfilter) {
9724 unset($smarty->_plugins[
'outputfilter'], $smarty->autoload_filters[
'output']);
9726 $smarty->assign(array_merge(array(
9732 $html = $includes ? $page->getHtml(
false) :
'';
9733 $html .= $smarty->fetch($template);
9735 $GLOBALS[
'site'] = $original_site;
9736 $GLOBALS[
'page'] = $original_page;
9737 $GLOBALS[
'smarty'] = $original_smarty;
9739 $html = $this->field[
'content'];
9752 switch ($this->_site->site[
'type']) {
9756 in_array($this->field[
'type'], array(
'multimedia/file',
'multimedia/image'))
9757 && !empty($this->extra[
'image_type'])
9758 &&
'.' . $this->extra[
'image_type'] != $suffix
9765 $suffixes = $this->_site->getCacheEntry($key);
9766 $type = $this->field[
'type'];
9767 if ($GLOBALS[
'is_mobile']) {
9770 $result = $suffixes[$type][$suffix];
9771 if (!is_bool($result)) {
9776 !in_array($suffix, array(
'.html',
'.rss',
'.ical',
'.ics'))
9777 && ($template = $this->getTemplate($GLOBALS[
'is_mobile'],
'index'))
9778 && strpos(basename($template),
"index{$suffix}.") !== 0
9779 && ($template = $this->getTemplate($GLOBALS[
'is_mobile'],
'body'))
9780 && strpos(basename($template),
"body{$suffix}.") !== 0
9784 $suffixes[$type][$suffix] = $result;
9785 $this->_site->setCacheEntry($key, $suffixes);
9797 if (in_array($this->field[
'type'], explode(
',', $this->_site->admin[
'social'][
'types']))) {
9798 return $this->_site->getSocialNetworks();
9812 $media_dir = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->_site->name;
9813 $dest = $media_dir . DIRECTORY_SEPARATOR . $this->getMediaFilename(
true);
9830 $this->getMediapool()->clear();
9832 foreach (self::VIDEO_RESOLUTIONS as $height => $scale) {
9833 if ($resolution > $height) {
9834 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'video');
9837 require_once
'base/Ego_Progress.php';
9838 $progress =
new Ego_Progress(
'worker_' . $this->getIdentity() .
'_' . $height .
'p');
9856 $this->getMediapool()->put($tmp,
"{$height}p.mp4");
9875 public function getThumbnail($width, $height = 0, $pool =
'', $dir =
'', $params = []) {
9877 $thumbnail = $GLOBALS[
'egotec_conf'][
'cachemedia_dir']
9878 . $this->_site->name .
'/' 9879 . $this->_site->language .
'/' 9880 . $this->field[
'id'] .
'/' 9881 . strtotime($this->field[
'c_date']) .
'/' 9882 .
'thumb_' . $width .
'x' . $height .
'_' . md5(serialize([$pool, $dir, $params]));
9889 $info = $this->getMediapool()->get($pool, $dir);
9890 if (!empty($info)) {
9891 $file = $info[
'file'];
9892 $mime = $info[
'mime'];
9894 } elseif (in_array($this->field[
'type'], [
'multimedia/file',
'multimedia/image'])) {
9896 $file = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'media/' . $this->_site->name .
'/' . $this->getMediaFilename();
9897 $mime = $this->extra[
'mime_type'];
9901 $thumbnail_dir = dirname($thumbnail);
9908 if ($mime ==
'application/pdf' || strpos($mime,
'image') === 0) {
9910 require_once
'base/Ego_Image.php';
9911 $image =
new Ego_Image($file .
'[' . ($params[
'index'] ?? 0) .
']');
9912 if ($tmp = $image->thumbnail($width, $height, $params)) {
9914 @rename($tmp, $thumbnail);
9926 if ($params[
'get_url']) {
9927 return $this->getUrl(array_filter([
9928 'thumbnail' => implode(
'x', array_filter([$width, $height, (
int) $params[
'index']])),
newChild($field=array(), $extra=array(), $inherit=true)
static includeHtml($src, $once=true)
getLinks($recursive=false)
validateFile($source, $name='', $form=array(), $files_conf=array())
updateUrls($verbose=false, $force_recursive=false)
download($recursive=true, $target_dir='', $write_log=true)
static getChecksum($value)
_updateKeywords($asis=false)
static checkLicence($ini_path)
static stringEncode($string, $from='UTF-8', $to='UTF-8')
fetch($params=array(), $outputfilter=false, $script=true, $includes=true, $variant='')
static deldir($location, $del=true, $without='', $rename=true)
static getUserRecord($user_id)
_destroyEntry($recursive=true)
setCacheEntry($key, $value)
isCurrentPage($lang=false)
_getAncestorsIds($page, $query, $param=array())
static urltopage($url, $params=array(), $only_site=false, $error_page=false, $commit_params=false)
getValue($name, $orient=null, $index=null, $verbose=false)
static encode_path($url, $id=0)
getThumbnail($width, $height=0, $pool='', $dir='', $params=[])
hasFile($name, $suffix='')
static getJSON($path, $values=array(), $combine=false, $ignore=[])
updateLinks($inherited=true)
static getAllSites($username='', $perm='', $table=false, $type='')
_destroyChildClones($parent)
getArchivePages($query=array())
static file_exists($file)
isFrontendAdmin($check_rights=true)
getArchivePage($c_date='')
_updateChildren($children)
__call($function, $params)
__construct(Site $site, $field)
updateFile($source, $name='')
static getMimeTypes($ext='')
hasRights($rights, $user_id=false)
static mkdir($dir, $mode=0755, $recursive=true)
static getCluster($site=null)
static isIdentity($identity)
copyTo($id, $recursive=false, $params=array(), &$copied_pages=array())
newFile($source, $name, $options=array(), $suffix='')
getValues($name, $orient=null, $verbose=false)
_updateField($field, $update=true, $asis=false)
static createIdentity($params)
getLinkedPages($recursive=false, $self=true)
getIconUrl($test=false, $folder=false)
static setAssocValue(&$a, $k, $v)
static getAssocValue($a, $k)
static getUrlInfo($url, $encode=false)
createClone($page, $children=false, $release=false, $multiple=true)
getBlockValues($block, $name, $orient=null, $verbose=false)
destroy($force=false, $recursive=true)
getBlockValue($block, $name, $orient=null, $index=null, $verbose=false)
static copy($src, $dest, $except='', $useLinks=false)
static byIdentity($identity, $param=array())
getNonPublics($c_user=null)
inheritExtra($keys, $mixed=false, $types=array(), $no_rights=true)
setTableSuffix($suffix='')
static dateEncode($string)
_createClone($page, $children=false, $release=false, $multiple=true)
static filterNonUtf8($s, $substitute="", $strict=false)
getFirstBlockValue($block, $name, $orient=null, $verbose=false)
static exec(String $command, Array $params=array(), Array &$output=null, &$return_var=null)
getFirstValue($name, $orient=null, $verbose=false)
removeSelectedListItem($params)
createEditField($name, $setting=array(), $empty=false, $orient='', $index=0, $block='', $replace=false)
_createChildClones($parent)
undelete($recursive=false, $query=array())