openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 260ee350d5634f4d3a735f83966a33ce61740c9f
parent 081b6f530f1453852d720137540810b80a27776f
Author: Jan Dankert <develop@jandankert.de>
Date:   Tue,  9 Mar 2021 09:17:27 +0100

New: Show all links ('references') to the current object.

Diffstat:
Mmodules/cms/action/object/ObjectInfoAction.class.php | 8++++++--
Mmodules/cms/action/page/PageInfoAction.class.php | 28+++++++++++++++++++++++++++-
Mmodules/cms/model/BaseObject.class.php | 27+++++++++++++++++++--------
Amodules/cms/ui/themes/default/html/views/include/references.inc.xml | 30++++++++++++++++++++++++++++++
Mmodules/cms/ui/themes/default/html/views/object/info.php | 66+++++++++++++++++++++++++++++++++++++++---------------------------
Mmodules/cms/ui/themes/default/html/views/object/info.tpl.src.xml | 18+-----------------
Mmodules/cms/ui/themes/default/html/views/page/info.php | 39+++++++++++++++++++++++++++++++++++++++
Mmodules/cms/ui/themes/default/html/views/page/info.tpl.src.xml | 1+
Mmodules/language/Language_CN.class.php | 1+
Mmodules/language/Language_DE.class.php | 1+
Mmodules/language/Language_EN.class.php | 1+
Mmodules/language/Language_ES.class.php | 1+
Mmodules/language/Language_FR.class.php | 1+
Mmodules/language/Language_IT.class.php | 1+
Mmodules/language/Language_RU.class.php | 1+
Mmodules/language/Messages.class.php | 1+
Mmodules/language/language.yml | 7+++++--
17 files changed, 175 insertions(+), 57 deletions(-)

diff --git a/modules/cms/action/object/ObjectInfoAction.class.php b/modules/cms/action/object/ObjectInfoAction.class.php @@ -3,6 +3,7 @@ namespace cms\action\object; use cms\action\Method; use cms\action\ObjectAction; use cms\model\BaseObject; +use cms\model\Permission; use util\ArrayUtils; class ObjectInfoAction extends ObjectAction implements Method { @@ -46,13 +47,14 @@ class ObjectInfoAction extends ObjectAction implements Method { $o = new BaseObject( $languageid ); $o->load(); $list[$languageid] = array(); + $list[$languageid]['id' ] = $o->objectid; $list[$languageid]['name'] = $o->filename; $list[$languageid]['type'] = $o->getType(); } asort( $list ); - $this->setTemplateVar('pages',$list); + $this->setTemplateVar('references',$list); $this->setTemplateVar('size',number_format($this->baseObject->getSize()/1000,0,',','.').' kB' ); @@ -60,7 +62,9 @@ class ObjectInfoAction extends ObjectAction implements Method { $totalSettings = $this->baseObject->getTotalSettings(); $this->setTemplateVar('total_settings', $totalSettings,$pad ); $this->setTemplateVar('settings', ArrayUtils::dryFlattenArray( $totalSettings,$pad ) ); - } + } + + public function post() { } } diff --git a/modules/cms/action/page/PageInfoAction.class.php b/modules/cms/action/page/PageInfoAction.class.php @@ -7,7 +7,11 @@ use cms\generator\PageContext; use cms\generator\PageGenerator; use cms\generator\Producer; use cms\generator\Publisher; +use cms\model\BaseObject; +use cms\model\File; +use cms\model\Permission; use cms\model\Template; +use util\Html; class PageInfoAction extends PageAction implements Method { public function view() { @@ -79,7 +83,29 @@ class PageInfoAction extends PageAction implements Method { $generator = new PageGenerator( $this->createPageContext( Producer::SCHEME_PUBLIC) ); $this->setTemplateVar('tmp_filename' ,$generator->getPublicFilename() ); - } + + $references = []; + + // Schleife ueber alle Objekte in diesem Ordner + foreach( $this->page->getDependentObjectIds() as $id ) + { + /* @var BaseObject */ + $o = new BaseObject( $id ); + $o->load(); + + if ( $o->hasRight(Permission::ACL_READ) ) + { + $references[$id]['name'] = $o->getDefaultName()->name; + $references[$id]['type'] = $o->getType(); + $references[$id]['id' ] = $id; + + $references[$id]['date'] = $o->lastchangeDate; + $references[$id]['user'] = $o->lastchangeUser; + } + } + $this->setTemplateVar( 'references',$references ); + + } public function post() { } } diff --git a/modules/cms/model/BaseObject.class.php b/modules/cms/model/BaseObject.class.php @@ -1241,17 +1241,27 @@ SQL } + /** + * Get all References to this object + * @return array + */ public function getDependentObjectIds() { - $db = \cms\base\DB::get(); - - $sql = $db->sql( 'SELECT {{page}}.objectid FROM {{value}}'. - ' LEFT JOIN {{page}} '. - ' ON {{value}}.pageid = {{page}}.id '. - ' WHERE linkobjectid={objectid}' ); - $sql->setInt( 'objectid',$this->objectid ); + $stmt = DB::sql( <<<SQL + +SELECT {{page}}.objectid FROM {{value}} + LEFT JOIN {{page}} + ON {{value}}.pageid = {{page}}.id + WHERE linkobjectid={myobjectid1} +UNION + SELECT objectid FROM {{link}} + WHERE link_objectid={myobjectid2} +SQL + ); + $stmt->setInt( 'myobjectid1',$this->objectid ); + $stmt->setInt( 'myobjectid2',$this->objectid ); - return $sql->getCol(); + return $stmt->getCol(); } @@ -1260,6 +1270,7 @@ SQL /** * Liefert die Link-Ids, die auf das aktuelle Objekt verweisen. * @return array Liste der gefundenen Objekt-IDs + * @see BaseObject#getDependentObjectIds */ public function getLinksToMe() { diff --git a/modules/cms/ui/themes/default/html/views/include/references.inc.xml b/modules/cms/ui/themes/default/html/views/include/references.inc.xml @@ -0,0 +1,30 @@ +<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openrat.de/template ../../../../../../../template_engine/components/template.xsd"> + <group title="${message:references}"> + + <table> + <row header="true"> + <column header="true" class="table-column-action"> + <text value="${message:TYPE}"/> + </column> + <column header="true" class="table-column-auto"> + <text value="${message:NAME}"/> + </column> + </row> + + <list list="${references}" extract="true"> + <row class="data"> + <column class=""> + <image action="${type}"/> + </column> + <column class="act-clickable"> + <link type="open" id="${id}" name="${name}" action="${type}"> + <text value="${name}"/> + </link> + </column> + + </row> + </list> + </table> + </group> +</output> diff --git a/modules/cms/ui/themes/default/html/views/object/info.php b/modules/cms/ui/themes/default/html/views/object/info.php @@ -105,33 +105,6 @@ </div> </section> <?php } ?> - <section class="<?php echo O::escapeHtml('or-fieldset') ?>"><?php echo O::escapeHtml('') ?> - <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml(''.@O::lang('FILE_PAGES').'') ?></h3> - <div class="<?php echo O::escapeHtml('or-fieldset-value') ?>"><?php echo O::escapeHtml('') ?> - <div class="<?php echo O::escapeHtml('or-table-wrapper') ?>"><?php echo O::escapeHtml('') ?> - <div class="<?php echo O::escapeHtml('or-table-filter') ?>"><?php echo O::escapeHtml('') ?> - <input type="<?php echo O::escapeHtml('search') ?>" name="<?php echo O::escapeHtml('filter') ?>" placeholder="<?php echo O::escapeHtml(''.@O::lang('SEARCH_FILTER').'') ?>" class="<?php echo O::escapeHtml('or-input or-table-filter-input') ?>" /><?php echo O::escapeHtml('') ?> - </div> - <div class="<?php echo O::escapeHtml('or-table-area') ?>"><?php echo O::escapeHtml('') ?> - <table class="<?php echo O::escapeHtml('or-table') ?>"><?php echo O::escapeHtml('') ?> - <?php foreach((array)@$pages as $list_key=>$list_value) { extract($list_value); ?> - <tr><?php echo O::escapeHtml('') ?> - <td><?php echo O::escapeHtml('') ?> - <a target="<?php echo O::escapeHtml('_self') ?>" data-url="<?php echo O::escapeHtml(''.@$url.'') ?>" data-action="<?php echo O::escapeHtml('') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> - <img src="<?php echo O::escapeHtml('./modules/cms/ui/themes/default/images/icon_page.png') ?>" /><?php echo O::escapeHtml('') ?> - <span><?php echo O::escapeHtml(''.@$name.'') ?></span> - </a> - </td> - </tr> - <?php } ?> - </table> - </div> - </div> - <?php $if4=(($pages)==FALSE); if($if4) { ?> - <span><?php echo O::escapeHtml(''.@O::lang('NOT_FOUND').'') ?></span> - <?php } ?> - </div> - </section> </div> </section> @@ -139,6 +112,45 @@ <h2 class="<?php echo O::escapeHtml('or-collapsible-title or-group-title or-collapsible-act-switch') ?>"><?php echo O::escapeHtml('') ?> <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-closed or-collapsible--on-closed') ?>"><?php echo O::escapeHtml('') ?></i> <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-open or-collapsible--on-open') ?>"><?php echo O::escapeHtml('') ?></i> + <span><?php echo O::escapeHtml(''.@O::lang('references').'') ?></span> + </h2> + <div class="<?php echo O::escapeHtml('or-collapsible-value or-group-value') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-table-wrapper') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-table-filter') ?>"><?php echo O::escapeHtml('') ?> + <input type="<?php echo O::escapeHtml('search') ?>" name="<?php echo O::escapeHtml('filter') ?>" placeholder="<?php echo O::escapeHtml(''.@O::lang('SEARCH_FILTER').'') ?>" class="<?php echo O::escapeHtml('or-input or-table-filter-input') ?>" /><?php echo O::escapeHtml('') ?> + </div> + <div class="<?php echo O::escapeHtml('or-table-area') ?>"><?php echo O::escapeHtml('') ?> + <table class="<?php echo O::escapeHtml('or-table') ?>"><?php echo O::escapeHtml('') ?> + <tr class="<?php echo O::escapeHtml('or-table-header') ?>"><?php echo O::escapeHtml('') ?> + <th class="<?php echo O::escapeHtml('or-table-column-action') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('TYPE').'') ?></span> + </th> + <th class="<?php echo O::escapeHtml('or-table-column-auto') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('NAME').'') ?></span> + </th> + </tr> + <?php foreach((array)@$references as $list_key=>$list_value) { extract($list_value); ?> + <tr class="<?php echo O::escapeHtml('or-data') ?>"><?php echo O::escapeHtml('') ?> + <td><?php echo O::escapeHtml('') ?> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--action-'.@$type.'') ?>"><?php echo O::escapeHtml('') ?></i> + </td> + <td class="<?php echo O::escapeHtml('or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-name="<?php echo O::escapeHtml(''.@$name.'') ?>" name="<?php echo O::escapeHtml(''.@$name.'') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml(''.@$type.'') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml(''.@$id.'') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/'.@$type.'/'.@$id.'') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@$name.'') ?></span> + </a> + </td> + </tr> + <?php } ?> + </table> + </div> + </div> + </div> + </section> + + <section class="<?php echo O::escapeHtml('or-group or-collapsible or-collapsible--is-open or-collapsible--show') ?>"><?php echo O::escapeHtml('') ?> + <h2 class="<?php echo O::escapeHtml('or-collapsible-title or-group-title or-collapsible-act-switch') ?>"><?php echo O::escapeHtml('') ?> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-closed or-collapsible--on-closed') ?>"><?php echo O::escapeHtml('') ?></i> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-open or-collapsible--on-open') ?>"><?php echo O::escapeHtml('') ?></i> <span><?php echo O::escapeHtml(''.@O::lang('validity').'') ?></span> </h2> <div class="<?php echo O::escapeHtml('or-collapsible-value or-group-value') ?>"><?php echo O::escapeHtml('') ?> diff --git a/modules/cms/ui/themes/default/html/views/object/info.tpl.src.xml b/modules/cms/ui/themes/default/html/views/object/info.tpl.src.xml @@ -64,24 +64,8 @@ </part> </fieldset> </if> - <fieldset label="${message:FILE_PAGES}"> - <table> - <list list="${pages}" extract="true"> - <row> - <column> - <link url="${url}" target="cms_main"> - <image type="page"/> - <text value="${name}"/> - </link> - </column> - </row> - </list> - </table> - <if empty="${pages}"> - <text value="${message:NOT_FOUND}"/> - </if> - </fieldset> </group> + <include file="../include/references"/> <include file="../include/validity"/> <include file="../include/timestamps"/> <include file="../include/settings"/> diff --git a/modules/cms/ui/themes/default/html/views/page/info.php b/modules/cms/ui/themes/default/html/views/page/info.php @@ -159,6 +159,45 @@ <h2 class="<?php echo O::escapeHtml('or-collapsible-title or-group-title or-collapsible-act-switch') ?>"><?php echo O::escapeHtml('') ?> <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-closed or-collapsible--on-closed') ?>"><?php echo O::escapeHtml('') ?></i> <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-open or-collapsible--on-open') ?>"><?php echo O::escapeHtml('') ?></i> + <span><?php echo O::escapeHtml(''.@O::lang('references').'') ?></span> + </h2> + <div class="<?php echo O::escapeHtml('or-collapsible-value or-group-value') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-table-wrapper') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-table-filter') ?>"><?php echo O::escapeHtml('') ?> + <input type="<?php echo O::escapeHtml('search') ?>" name="<?php echo O::escapeHtml('filter') ?>" placeholder="<?php echo O::escapeHtml(''.@O::lang('SEARCH_FILTER').'') ?>" class="<?php echo O::escapeHtml('or-input or-table-filter-input') ?>" /><?php echo O::escapeHtml('') ?> + </div> + <div class="<?php echo O::escapeHtml('or-table-area') ?>"><?php echo O::escapeHtml('') ?> + <table class="<?php echo O::escapeHtml('or-table') ?>"><?php echo O::escapeHtml('') ?> + <tr class="<?php echo O::escapeHtml('or-table-header') ?>"><?php echo O::escapeHtml('') ?> + <th class="<?php echo O::escapeHtml('or-table-column-action') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('TYPE').'') ?></span> + </th> + <th class="<?php echo O::escapeHtml('or-table-column-auto') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('NAME').'') ?></span> + </th> + </tr> + <?php foreach((array)@$references as $list_key=>$list_value) { extract($list_value); ?> + <tr class="<?php echo O::escapeHtml('or-data') ?>"><?php echo O::escapeHtml('') ?> + <td><?php echo O::escapeHtml('') ?> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--action-'.@$type.'') ?>"><?php echo O::escapeHtml('') ?></i> + </td> + <td class="<?php echo O::escapeHtml('or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-name="<?php echo O::escapeHtml(''.@$name.'') ?>" name="<?php echo O::escapeHtml(''.@$name.'') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml(''.@$type.'') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml(''.@$id.'') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/'.@$type.'/'.@$id.'') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@$name.'') ?></span> + </a> + </td> + </tr> + <?php } ?> + </table> + </div> + </div> + </div> + </section> + + <section class="<?php echo O::escapeHtml('or-group or-collapsible or-collapsible--is-open or-collapsible--show') ?>"><?php echo O::escapeHtml('') ?> + <h2 class="<?php echo O::escapeHtml('or-collapsible-title or-group-title or-collapsible-act-switch') ?>"><?php echo O::escapeHtml('') ?> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-closed or-collapsible--on-closed') ?>"><?php echo O::escapeHtml('') ?></i> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--node-open or-collapsible--on-open') ?>"><?php echo O::escapeHtml('') ?></i> <span><?php echo O::escapeHtml(''.@O::lang('validity').'') ?></span> </h2> <div class="<?php echo O::escapeHtml('or-collapsible-value or-group-value') ?>"><?php echo O::escapeHtml('') ?> diff --git a/modules/cms/ui/themes/default/html/views/page/info.tpl.src.xml b/modules/cms/ui/themes/default/html/views/page/info.tpl.src.xml @@ -102,6 +102,7 @@ </fieldset> </group> + <include file="../include/references"/> <include file="../include/validity"/> <include file="../include/timestamps"/> <include file="../include/settings"/> diff --git a/modules/language/Language_CN.class.php b/modules/language/Language_CN.class.php @@ -1355,5 +1355,6 @@ Thank you.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', +'REFERENZES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_DE.class.php b/modules/language/Language_DE.class.php @@ -1360,5 +1360,6 @@ Vielen Dank.', 'GROUP_PARENT'=>'Übergeordnete Gruppe', 'UNSAVED_CHANGES_CONFIRM'=>'Sie haben ungespeicherte Änderungen. Möchten Sie diese Ansicht tatsächlich verlassen?', 'PROGRESS'=>'Vorgang wird ausgeführt', +'REFERENZES'=>'Referenzen', ];} } \ No newline at end of file diff --git a/modules/language/Language_EN.class.php b/modules/language/Language_EN.class.php @@ -1355,5 +1355,6 @@ Thank you.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', +'REFERENZES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_ES.class.php b/modules/language/Language_ES.class.php @@ -1380,5 +1380,6 @@ MENU_INDEX_ADMINISTRATION_DESC =', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', +'REFERENZES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_FR.class.php b/modules/language/Language_FR.class.php @@ -1356,5 +1356,6 @@ Merci.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', +'REFERENZES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_IT.class.php b/modules/language/Language_IT.class.php @@ -1356,5 +1356,6 @@ Gracias.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', +'REFERENZES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Language_RU.class.php b/modules/language/Language_RU.class.php @@ -1356,5 +1356,6 @@ if you do not know where this mail comes from, please ignore it.', 'GROUP_PARENT'=>'Parent group', 'UNSAVED_CHANGES_CONFIRM'=>'There are unsaved changes. Do you really want to exit?', 'PROGRESS'=>'Work in progress', +'REFERENZES'=>'References', ];} } \ No newline at end of file diff --git a/modules/language/Messages.class.php b/modules/language/Messages.class.php @@ -1309,4 +1309,5 @@ class Messages { const GROUP_PARENT = 'GROUP_PARENT'; const UNSAVED_CHANGES_CONFIRM = 'UNSAVED_CHANGES_CONFIRM'; const PROGRESS = 'PROGRESS'; + const REFERENZES = 'REFERENZES'; } \ No newline at end of file diff --git a/modules/language/language.yml b/modules/language/language.yml @@ -6493,4 +6493,7 @@ UNSAVED_CHANGES_CONFIRM: de: Sie haben ungespeicherte Änderungen. Möchten Sie diese Ansicht tatsächlich verlassen? PROGRESS: en: Work in progress - de: Vorgang wird ausgeführt- \ No newline at end of file + de: Vorgang wird ausgeführt +REFERENZES: + de: Referenzen + en: References+ \ No newline at end of file