openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit d207fe009283a9a72205311459b6e1af8a6ae2ee
parent 06da78162eb5689311e21c2cc1be2ea88988db57
Author: Jan Dankert <devnull@localhost>
Date:   Sat,  8 Dec 2018 00:50:08 +0100

Fix: Baumobjekte korrigiert.

Diffstat:
modules/cms-core/action/PageelementAction.class.php | 38++++++++++++--------------------------
modules/cms-core/model/BaseObject.class.php | 40++++++++++++++++++++++++++++++++++++++--
modules/cms-core/model/Project.class.php | 9+++++++--
modules/cms-ui/themes/default/html/views/file/edit.php | 2+-
modules/util/Tree.class.php | 105+++++++++++++++++++++++++++++++++++--------------------------------------------
5 files changed, 104 insertions(+), 90 deletions(-)

diff --git a/modules/cms-core/action/PageelementAction.class.php b/modules/cms-core/action/PageelementAction.class.php @@ -171,9 +171,15 @@ class PageelementAction extends Action $this->setTemplateVar('element_type',$this->value->element->type ); $user = new User( $this->value->lastchangeUserId ); - $user->load(); - $this->setTemplateVar('lastchange_user',$user->getProperties()); - $this->setTemplateVar('lastchange_date',$this->value->lastchangeTimeStamp); + + try{ + $user->load(); + }catch (\ObjectNotFoundException $e) { + $user = new User(); // Empty User. + } + + $this->setTemplateVar('lastchange_user',$user->getProperties()); + $this->setTemplateVar('lastchange_date',$this->value->lastchangeTimeStamp); $t = new Template( $this->page->templateid ); $t->load(); @@ -495,35 +501,15 @@ class PageelementAction extends Action else $types = array($type); // gewünschten Typ verwenden - $objects = array(); - - foreach( Folder::getAllObjectIds($types) as $id ) - { - $o = new BaseObject( $id ); - $o->load(); - - // if ( in_array( $o->getType(),$types )) - // { - $f = new Folder( $o->parentid ); - // $f->load(); - - $objects[ $id ] = lang( $o->getType() ).': '; - $objects[ $id ] .= implode( FILE_SEP,$f->parentObjectNames(false,true) ); - $objects[ $id ] .= FILE_SEP.$o->name; - // } - } - - asort( $objects ); // Sortieren - - $this->setTemplateVar('objects' ,$objects); + $this->setTemplateVar('objects' ,array() ); $this->setTemplateVar('linkobjectid',$this->value->linkToObjectId); $this->setTemplateVar('types',implode(',',$types)); if ( $this->getSessionVar('pageaction') != '' ) - $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); + $this->setTemplateVar('old_pageaction',$this->getSessionVar('pageaction')); else - $this->setTemplateVar('old_pageaction','show' ); + $this->setTemplateVar('old_pageaction','show' ); } diff --git a/modules/cms-core/model/BaseObject.class.php b/modules/cms-core/model/BaseObject.class.php @@ -1427,6 +1427,11 @@ SQL } + /** + * Liefert alle Name-Objekte. + * @return array + * @throws \ObjectNotFoundException + */ public function getNames() { $names = array(); @@ -1446,10 +1451,41 @@ SQL /** + * @return Name + */ + public function getDefaultName() + { + $languageId = $this->getProject()->getDefaultLanguageId(); + + $name = new Name(); + $name->objectid = $this->objectid; + $name->languageid = $languageId; + $name->load(); + + return $name; + } + + + /** + * Name of the object. If not exist, the filename will be used. + * @return string Name + */ + public function getName() + { + $name = $this->getDefaultName()->name; + + if ( empty($name)) + $name = $this->filename; + + return $name; + } + + + /** * Speichert Namen und Beschreibung für alle Sprachen. Das ist bei der Neuanlage von Objekten ganz praktisch. * - * @param $nam - * @param $description + * @param $nam string + * @param $description string */ public function setNameForAllLanguages($nam, $description) { diff --git a/modules/cms-core/model/Project.class.php b/modules/cms-core/model/Project.class.php @@ -442,7 +442,12 @@ SQL $sql->setInt( 'projectid',$this->projectid ); $sql->query(); } - + + + /** + * Liefert die Standard-Sprach-Id. If there is no default language, the first language-id will be used. + * @return String + */ public function getDefaultLanguageId() { $db = Session::getDatabase(); @@ -451,7 +456,7 @@ SQL // gelesen wird $sql = $db->sql( 'SELECT id FROM {{language}} '. ' WHERE projectid={projectid}'. - ' ORDER BY is_default DESC' ); + ' ORDER BY is_default DESC, name ASC' ); $sql->setInt('projectid',$this->projectid ); diff --git a/modules/cms-ui/themes/default/html/views/file/edit.php b/modules/cms-ui/themes/default/html/views/file/edit.php @@ -9,7 +9,7 @@ <div class="input"> <br/> - <input size="40" id="req1543971164103282020_file" type="file" name="file" class="upload" /> + <input size="40" id="req1544226406423830540_file" type="file" name="file" class="upload" /> <br/> diff --git a/modules/util/Tree.class.php b/modules/util/Tree.class.php @@ -12,23 +12,6 @@ use cms\model\Group; use cms\model\Folder; use cms\model\Value; -// OpenRat Content Management System -// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - /** * Darstellen einer Baumstruktur mit Administrationfunktionen @@ -359,29 +342,59 @@ class Tree $treeElement->internalId = $id . '_' . $elementid; $treeElement->text = $element->name; $treeElement->action = 'pageelement'; - $treeElement->icon = 'el_' . $element->type; + $treeElement->icon = 'el_' . $element->getTypeName(); $treeElement->extraId = array('elementid' => $elementid, REQ_PARAM_LANGUAGE_ID => $page->languageid, REQ_PARAM_MODEL_ID => $page->modelid); - $treeElement->description = lang('EL_' . $element->type); + $treeElement->description = lang('EL_' . $element->getTypeName()); if ($element->desc != '') - $treeElement->description .= ' - ' . Text::maxLaenge(25, $element->desc); + $treeElement->description .= ' - ' . Text::maxLength( $element->desc,25); else $treeElement->description .= ' - ' . lang('GLOBAL_NO_DESCRIPTION_AVAILABLE'); - if (in_array($element->type, array('link', 'list', 'include'))) { - $treeElement->type = 'value'; - $value = new Value(); - $value->pageid = $page->pageid; - $value->element = $element; - $value->languageid = $page->languageid; - $value->publisher = new \cms\publish\PublishPreview(); - $value->load(); - $treeElement->internalId = $value->valueid; - } + $this->addTreeElement($treeElement); + } + } + } + + + function pageelement($id) + { + $ids = explode('_',$id); + if ( count($ids) > 1 ) + { + list( $pageid, $elementid ) = $ids; + + $page = new Page($pageid); + $page->languageid = $_REQUEST[REQ_PARAM_LANGUAGE_ID]; + $page->modelid = $_REQUEST[REQ_PARAM_MODEL_ID]; + + $page->load(); + + $element = new Element($elementid); + $element->load(); + + $value = new Value(); + $value->pageid = $page->pageid; + $value->element = $element; + $value->languageid = $page->languageid; + $value->publisher = new \cms\publish\PublishPreview(); + $value->load(); + + if ( BaseObject::available($value->linkToObjectId) ) + { + $o = new BaseObject( $value->linkToObjectId ); + $treeElement = new TreeElement(); + $treeElement->type = $o->getType(); + $treeElement->id = $o->objectid; + $treeElement->internalId = $o->objectid; + $treeElement->extraId = array(REQ_PARAM_LANGUAGE_ID => $page->languageid, REQ_PARAM_MODEL_ID => $page->modelid); + $treeElement->text = $o->getName(); + $treeElement->description = lang('GLOBAL_' . $o->getType()) . ' ' . $o->objectid; $this->addTreeElement($treeElement); } + } } @@ -467,7 +480,7 @@ class Tree $f->languageid = $_REQUEST[REQ_PARAM_LANGUAGE_ID]; $f->modelid = $_REQUEST[REQ_PARAM_MODEL_ID]; - foreach ($f->getObjects() as $o) { + foreach ($f->getObjects() as /*@var BaseObject */$o) { // Wenn keine Leseberechtigung if (!$o->hasRight(ACL_READ)) continue; @@ -485,34 +498,8 @@ class Tree $treeElement->description .= ' - ' . lang('GLOBAL_NO_DESCRIPTION_AVAILABLE'); $treeElement->action = $o->getType(); - $treeElement->icon = $o->getType(); - - // Besonderheiten fuer bestimmte Objekttypen - - if ($o->isLink) { - $treeElement->type = 'link'; - } - - if ($o->isPage) { - // Nur wenn die Seite beschreibbar ist, werden die - // Elemente im Baum angezeigt - if ($o->hasRight(ACL_WRITE)) - $treeElement->type = 'page'; - } - - if ($o->isFile) { - $file = new File($o->objectid); - $file->load(); - - if (substr($file->mimeType(), 0, 6) == 'image/') - $treeElement->icon = 'image'; - else $treeElement->icon = 'file'; - } - - if ($o->isFolder) { - $treeElement->type = 'folder'; - } - + $treeElement->icon = $o->getType(); + $treeElement->type = $o->getType(); $this->addTreeElement($treeElement); }