openrat-cms

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

commit 7e5ff1adef25710e24230e73fc27eeeb86ec7650
parent 69d996660296b62f06852c6b9bf069b5df3cfc87
Author: Jan Dankert <devnull@localhost>
Date:   Thu, 13 Dec 2018 23:02:34 +0100

Der Publisher gehört in die Basisklasse, da er in allen Objekttypen benutzt wird.

Diffstat:
modules/cms-core/action/FolderAction.class.php | 30+++++++++++++++++++-----------
modules/cms-core/action/PageAction.class.php | 22++++++++++++++--------
modules/cms-core/action/TemplateAction.class.php | 38++++++++++++++++++++------------------
modules/cms-core/model/BaseObject.class.php | 8++++++++
modules/cms-core/model/File.class.php | 8++------
modules/cms-core/model/Folder.class.php | 15+++++----------
modules/cms-core/model/Page.class.php | 9---------
modules/cms-core/model/Project.class.php | 4+---
modules/cms-core/model/Template.class.php | 4+---
modules/cms-ui/themes/default/html/views/folder/createfile.php | 12++++++------
modules/cms-ui/themes/default/html/views/folder/pub.php | 58+++++++++++++++++++++++++++-------------------------------
modules/cms-ui/themes/default/html/views/folder/pub.tpl.src.xml | 134++++++++++++++++++++++++++++++++++++++-----------------------------------------
modules/cms-ui/themes/default/html/views/template/pub.php | 6+++---
modules/cms-ui/themes/default/html/views/template/pub.tpl.src.xml | 2+-
14 files changed, 172 insertions(+), 178 deletions(-)

diff --git a/modules/cms-core/action/FolderAction.class.php b/modules/cms-core/action/FolderAction.class.php @@ -1571,9 +1571,11 @@ class FolderAction extends ObjectAction public function pubView() { // Schalter nur anzeigen, wenn sinnvoll - $this->setTemplateVar('files' ,count($this->folder->getFiles()) > 0 ); - $this->setTemplateVar('pages' ,count($this->folder->getPages()) > 0 ); - $this->setTemplateVar('subdirs',count($this->folder->getSubFolderIds()) > 0 ); + + // TODO texts, urls.... + $this->setTemplateVar('files' ,count($this->folder->getFiles()) >= 0 ); + $this->setTemplateVar('pages' ,count($this->folder->getPages()) > 0 ); + $this->setTemplateVar('subdirs',count($this->folder->getSubFolderIds()) > 0 ); //$this->setTemplateVar('clean' ,$this->folder->isRoot ); // Gefaehrliche Option, da dies bestehende Dateien, die evtl. nicht zum CMS gehören, überschreibt. @@ -1592,21 +1594,27 @@ class FolderAction extends ObjectAction $files = ( $this->hasRequestVar('files' ) ); Session::close(); - $publish = new PublishPublic( $this->projectid ); + $publisher = new PublishPublic( $this->folder->projectid ); - $this->folder->publish = &$publish; + $this->folder->publisher = &$publisher; $this->folder->publish( $pages,$files,$subdirs ); - $this->folder->publish->close(); - $list = array(); - foreach( $publish->publishedObjects as $o ) - $list[] = $o['full_filename']; + $publisher->close(); + + + $list = array_map( + function($obj) + { + return $obj['full_filename']; + }, + $publisher->publishedObjects + ); - $this->addNotice('folder',$this->folder->name,'PUBLISHED',OR_NOTICE_OK,array(),$list); + $this->addNotice('folder',$this->folder->getDefaultName()->name,'PUBLISHED',OR_NOTICE_OK,array(),$list); // Wenn gewuenscht, das Zielverzeichnis aufraeumen if ( $this->hasRequestVar('clean') ) - $publish->clean(); + $publisher->clean(); } diff --git a/modules/cms-core/action/PageAction.class.php b/modules/cms-core/action/PageAction.class.php @@ -11,6 +11,8 @@ use cms\model\Folder; use cms\model\BaseObject; use cms\model\Language; use cms\model\Model; +use cms\publish\PublishPreview; +use cms\publish\PublishPublic; use \Html; use Http; use Logger; @@ -661,6 +663,10 @@ class PageAction extends ObjectAction if ( $this->hasRequestVar('withIcons') ) $this->page->icons = true; + $publisher = new PublishPreview(); + + $this->page->publisher = $publisher; + $this->page->load(); $this->page->generate(); @@ -772,23 +778,23 @@ class PageAction extends ObjectAction Session::close(); - $this->page->public = true; + $publisher = new PublishPublic( $this->page->projectid ); + + $this->page->publisher = $publisher; $this->page->publish(); $this->page->publisher->close(); -// foreach( $this->page->publish->publishedObjects as $o ) -// { -// $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok'); -// } - $this->addNotice( 'page', $this->page->fullFilename, 'PUBLISHED', OR_NOTICE_OK, array(), - array_map(function($obj) { return $obj['full_filename']; - },$this->page->publisher->publishedObjects) + array_map(function($obj) { + return $obj['full_filename']; + },$publisher->publishedObjects) ); + + $publisher->close(); } diff --git a/modules/cms-core/action/TemplateAction.class.php b/modules/cms-core/action/TemplateAction.class.php @@ -10,6 +10,7 @@ use cms\model\Page; use cms\model\TemplateModel; +use cms\publish\PublishPublic; use Session; use \Html; use \Text; @@ -47,8 +48,8 @@ class TemplateAction extends Action /** * @var Template */ - var $template; - var $element; + private $template; + private $element; function __construct() @@ -594,31 +595,32 @@ class TemplateAction extends Action $objectIds = $this->template->getDependentObjectIds(); Session::close(); + + $publisher = new PublishPublic( $this->template->projectid ); foreach( $objectIds as $objectid ) { $page = new Page( $objectid ); + $page->load(); if ( !$page->hasRight( ACL_PUBLISH ) ) continue; - $page->public = true; + $page->publisher = $publisher; $page->publish(); - $page->publisher->close(); - - // foreach( $this->page->publish->publishedObjects as $o ) - // { - // $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok'); - // } - - $this->addNotice( 'page', - $page->fullFilename, - 'PUBLISHED', - OR_NOTICE_OK, - array(), - $page->publisher->log ); - } - } + } + + $this->addNotice( 'template', + $this->template->name, + 'PUBLISHED', + OR_NOTICE_OK, + array(), + array_map( function($obj) { + return $obj['full_filename']; + },$publisher->publishedObjects) ); + + $publisher->close(); + } diff --git a/modules/cms-core/model/BaseObject.class.php b/modules/cms-core/model/BaseObject.class.php @@ -13,6 +13,7 @@ namespace { namespace cms\model { + use cms\publish\Publish; use phpseclib\Math\BigInteger; use Spyc; @@ -197,6 +198,13 @@ namespace cms\model { */ public $settings; + /** + * Strategy for publishing objects. + * + * @var Publish + */ + public $publisher; + /** <strong>Konstruktor</strong> * F?llen des neuen Objektes mit Init-Werten * Es werden die Standardwerte aus der Session benutzt, um diff --git a/modules/cms-core/model/File.class.php b/modules/cms-core/model/File.class.php @@ -465,16 +465,12 @@ EOF public function publish() { - $this->public = true; $this->deleteTmpFile(); - if ( ! is_object($this->publish) ) - $this->publish = new PublishPublic( $this->projectid ); - $this->write(); - $this->publish->copy( $this->tmpfile(),$this->full_filename(),$this->lastchangeDate ); + $this->publisher->copy( $this->tmpfile(),$this->full_filename(),$this->lastchangeDate ); - $this->publish->publishedObjects[] = $this->getProperties(); + $this->publisher->publishedObjects[] = $this->getProperties(); } diff --git a/modules/cms-core/model/Folder.class.php b/modules/cms-core/model/Folder.class.php @@ -17,11 +17,6 @@ class Folder extends BaseObject var $subfolders = array(); var $filenames = true; - /** - * @var Publish - */ - public $publish = null; - function __construct( $objectid='' ) { @@ -224,7 +219,7 @@ class Folder extends BaseObject { $p = new Page( $oid ); $p->load(); - $p->publisher = &$this->publish; + $p->publisher = &$this->publisher; $p->publish(); } @@ -232,7 +227,7 @@ class Folder extends BaseObject { $f = new File( $oid ); $f->load(); - $f->publish = &$this->publish; + $f->publisher = &$this->publisher; $f->publish(); } @@ -240,7 +235,7 @@ class Folder extends BaseObject { $f = new Image( $oid ); $f->load(); - $f->publish = &$this->publish; + $f->publisher = &$this->publisher; $f->publish(); } @@ -248,7 +243,7 @@ class Folder extends BaseObject { $f = new Text( $oid ); $f->load(); - $f->publish = &$this->publish; + $f->publisher = &$this->publisher; $f->publish(); } @@ -256,7 +251,7 @@ class Folder extends BaseObject { $f = new Folder( $oid ); $f->load(); - $f->publish = &$this->publish; + $f->publisher = &$this->publisher; $f->publish( $withPages,$withFiles,true ); } } diff --git a/modules/cms-core/model/Page.class.php b/modules/cms-core/model/Page.class.php @@ -71,11 +71,6 @@ class Page extends BaseObject var $modelid = 0; /** - * @var \Publish - */ - var $publisher; - - /** * @var Value[] */ public $values; @@ -653,10 +648,6 @@ SQL */ public function publish() { - $this->publisher = new PublishPublic( $this->projectid ); - - $this->public = true; - $project = Project::create( $this->projectid ); $allLanguages = $project->getLanguageIds(); diff --git a/modules/cms-core/model/Project.class.php b/modules/cms-core/model/Project.class.php @@ -231,9 +231,7 @@ class Project extends ModelBase */ public function load() { - $db = db_connection(); - - $sql = $db->sql( 'SELECT * FROM {{project}} '. + $sql = db()->sql( 'SELECT * FROM {{project}} '. ' WHERE id={projectid}' ); $sql->setInt( 'projectid',$this->projectid ); diff --git a/modules/cms-core/model/Template.class.php b/modules/cms-core/model/Template.class.php @@ -79,9 +79,7 @@ class Template */ function load() { - $db = db_connection(); - - $stmt = $db->sql( 'SELECT * FROM {{template}}'. + $stmt = db()->sql( 'SELECT * FROM {{template}}'. ' WHERE id={templateid}' ); $stmt->setInt( 'templateid',$this->templateid ); $row = $stmt->getRow(); diff --git a/modules/cms-ui/themes/default/html/views/folder/createfile.php b/modules/cms-ui/themes/default/html/views/folder/createfile.php @@ -8,12 +8,12 @@ <div class="line"> <div class="label"> <label for="<?php echo REQUEST_ID ?>_name" class="label"> - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_FILE')))); ?></span> + <span><?php echo nl2br(encodeHtml(htmlentities(lang('global_FILE')))); ?></span> </label> </div> <div class="input"> - <input size="40" id="req154344041025418490_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" multiple="multiple" /> + <input size="40" id="req0_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" multiple="multiple" /> </div> </div> @@ -29,13 +29,13 @@ </div> <div class="input"> - <span class="text"><?php echo nl2br(encodeHtml(htmlentities($max_size))); ?></span> + <span><?php echo nl2br(encodeHtml(htmlentities($max_size))); ?></span> </div> </div> <div class="line"> <div class="label"> - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'HTTP_URL'.'')))); ?></span> + <span><?php echo nl2br(encodeHtml(htmlentities(lang(''.'HTTP_URL'.'')))); ?></span> </div> <div class="input"> @@ -47,7 +47,7 @@ </div></fieldset> <div class="line"> <div class="label"> - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_NAME')))); ?></span> + <span><?php echo nl2br(encodeHtml(htmlentities(lang('global_NAME')))); ?></span> </div> <div class="input"> @@ -57,7 +57,7 @@ </div> <div class="line"> <div class="label"> - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_DESCRIPTION')))); ?></span> + <span><?php echo nl2br(encodeHtml(htmlentities(lang('global_DESCRIPTION')))); ?></span> </div> <div class="input"> diff --git a/modules/cms-ui/themes/default/html/views/folder/pub.php b/modules/cms-ui/themes/default/html/views/folder/pub.php @@ -7,13 +7,12 @@ </div> <?php } ?> <form name="" target="_self" data-target="view" action="./" data-method="pub" data-action="folder" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="or-form folder" data-async="1" data-autosave=""><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="folder" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="pub" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> - <?php $if3=(isset($pages)); if($if3){?> - <?php $if4=(isset($subdirs)); if($if4){?> - <div class="line"> - <div class="label"> - </div> - <div class="input"> - <?php { $tmpname = 'pages';$default = '';$readonly = '';$required = ''; + <?php $if3=($pages); if($if3){?> + <div class="line"> + <div class="label"> + </div> + <div class="input"> + <?php { $tmpname = 'pages';$default = '';$readonly = '';$required = ''; if ( isset($$tmpname) ) $checked = $$tmpname; else @@ -26,24 +25,22 @@ ?><input type="hidden" name="<?php echo $tmpname ?>" value="1" /><?php } } ?> + + <label for="<?php echo REQUEST_ID ?>_pages" class="label"> + <span><?php echo nl2br('&nbsp;'); ?></span> - <label for="<?php echo REQUEST_ID ?>_pages" class="label"> - <span><?php echo nl2br('&nbsp;'); ?></span> - - <span><?php echo nl2br(encodeHtml(htmlentities(lang('global_pages')))); ?></span> - - </label> - </div> + <span><?php echo nl2br(encodeHtml(htmlentities(lang('global_pages')))); ?></span> + + </label> </div> - <?php } ?> + </div> <?php } ?> - <?php $if3=(isset($files)); if($if3){?> - <?php $if4=($subdirs); if($if4){?> - <div class="line"> - <div class="label"> - </div> - <div class="input"> - <?php { $tmpname = 'files';$default = '';$readonly = '';$required = ''; + <?php $if3=($files); if($if3){?> + <div class="line"> + <div class="label"> + </div> + <div class="input"> + <?php { $tmpname = 'files';$default = '';$readonly = '';$required = ''; if ( isset($$tmpname) ) $checked = $$tmpname; else @@ -56,16 +53,15 @@ ?><input type="hidden" name="<?php echo $tmpname ?>" value="1" /><?php } } ?> + + <label for="<?php echo REQUEST_ID ?>_files" class="label"> + <span><?php echo nl2br('&nbsp;'); ?></span> - <label for="<?php echo REQUEST_ID ?>_files" class="label"> - <span><?php echo nl2br('&nbsp;'); ?></span> - - <span><?php echo nl2br(encodeHtml(htmlentities(lang('global_files')))); ?></span> - - </label> - </div> + <span><?php echo nl2br(encodeHtml(htmlentities(lang('global_files')))); ?></span> + + </label> </div> - <?php } ?> + </div> <?php } ?> <fieldset class="toggle-open-close<?php echo '1'?" open":" closed" ?><?php echo '1'?" show":"" ?>"><legend class="on-click-open-close"><div class="arrow arrow-right on-closed"></div><div class="arrow arrow-down on-open"></div><?php echo lang('options') ?></legend><div> <?php $if4=(isset($subdirs)); if($if4){?> @@ -73,7 +69,7 @@ <div class="label"> </div> <div class="input"> - <?php { $tmpname = 'subdirs';$default = '';$readonly = '';$required = ''; + <?php { $tmpname = 'subdirs';$default = '';$readonly = $subdirs;$required = ''; if ( isset($$tmpname) ) $checked = $$tmpname; else diff --git a/modules/cms-ui/themes/default/html/views/folder/pub.tpl.src.xml b/modules/cms-ui/themes/default/html/views/folder/pub.tpl.src.xml @@ -1,77 +1,73 @@ <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"> + xsi:schemaLocation="http://www.openrat.de/template ../../../../../../template-engine/components/template.xsd"> - <!-- - Falls das Veroeffentlichen deaktiviert ist, eine Warnmeldung anzeigen. - --> - <if true="config:security/nopublish"> - <part class="message warn"> - <text key="GLOBAL_NOPUBLISH_DESC" class="help"></text> - </part> - </if> + <!-- + Falls das Veroeffentlichen deaktiviert ist, eine Warnmeldung anzeigen. + --> + <if true="config:security/nopublish"> + <part class="message warn"> + <text key="GLOBAL_NOPUBLISH_DESC" class="help"></text> + </part> + </if> - <form cancel="false" visible="true" label="message:publish" async="true"> - <if present="pages"> - <if present="subdirs"> + <form cancel="false" visible="true" label="message:publish" async="true"> + <if true="var:pages"> - <part class="line"> - <part class="label"> - </part> - <part class="input"> - <checkbox name="pages"></checkbox> - <label for="pages"> - <text raw="_"></text> - <text text="global_pages"></text> - </label> - </part> - </part> - </if> - </if> - <if present="files"> - <if true="var:subdirs"> - <part class="line"> - <part class="label"> - </part> - <part class="input"> - <checkbox name="files"></checkbox> - <label for="files"> - <text raw="_"></text> - <text text="global_files"></text> - </label> - </part> - </part> + <part class="line"> + <part class="label"> + </part> + <part class="input"> + <checkbox name="pages"></checkbox> + <label for="pages"> + <text raw="_"></text> + <text text="global_pages"></text> + </label> + </part> + </part> + </if> + <if true="var:files"> + <part class="line"> + <part class="label"> + </part> + <part class="input"> + <checkbox name="files"></checkbox> + <label for="files"> + <text raw="_"></text> + <text text="global_files"></text> + </label> + </part> + </part> - </if> - </if> - <group title="message:options"> - <if present="subdirs"> - <part class="line"> - <part class="label"> - </part> - <part class="input"> - <checkbox name="subdirs"></checkbox> - <label for="subdirs"> - <text raw="_"></text> - <text text="GLOBAL_PUBLISH_WITH_SUBDIRS"></text> - </label> - </part> - </part> - </if> - <if present="clean"> - <part class="line"> - <part class="label"> - </part> - <part class="input"> - <checkbox name="clean"></checkbox> - <label for="clean"> - <text raw="_"></text> - <text text="global_CLEAN_AFTER_PUBLISH"></text> - </label> - </part> - </part> - </if> - </group> + </if> + <group title="message:options"> + <if present="subdirs"> + <part class="line"> + <part class="label"> + </part> + <part class="input"> + <checkbox readonly="var:subdirs" name="subdirs"></checkbox> + <label for="subdirs"> + <text raw="_"></text> + <text text="GLOBAL_PUBLISH_WITH_SUBDIRS"></text> + </label> + </part> + </part> + </if> + <if present="clean"> + <part class="line"> + <part class="label"> + </part> + <part class="input"> + <checkbox name="clean"></checkbox> + <label for="clean"> + <text raw="_"></text> + <text text="global_CLEAN_AFTER_PUBLISH"></text> + </label> + </part> + </part> + </if> + </group> - </form> + </form> </output> \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/template/pub.php b/modules/cms-ui/themes/default/html/views/template/pub.php @@ -6,7 +6,7 @@ </div> <?php } ?> - <form name="" target="_self" data-target="view" action="./" data-method="pub" data-action="template" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="template" data-async="" data-autosave=""><input type="submit" class="invisible" /><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="template" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="pub" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> + <form name="" target="_self" data-target="view" action="./" data-method="pub" data-action="template" data-id="<?php echo OR_ID ?>" method="POST" enctype="application/x-www-form-urlencoded" class="or-form template" data-async="1" data-autosave=""><input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="1" /><input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /><input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="template" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="pub" /><input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo OR_ID ?>" /> <fieldset class="toggle-open-close<?php echo '1'?" open":" closed" ?><?php echo '1'?" show":"" ?>"><legend class="on-click-open-close"><div class="arrow arrow-right on-closed"></div><div class="arrow arrow-down on-open"></div><?php echo lang('options') ?></legend><div> <div class="line"> <div class="label"> @@ -27,11 +27,11 @@ } ?> <label for="<?php echo REQUEST_ID ?>_files" class="label"> - <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('publish')))); ?></span> + <span><?php echo nl2br(encodeHtml(htmlentities(lang('publish')))); ?></span> </label> </div> </div> </div></fieldset> - <div class="bottom"><div class="command "><input type="submit" class="submit ok" value="OK" /></div></div></form> + <div class="or-form-actionbar"><input type="submit" class="or-form-btn or-form-btn--primary" value="OK" /></div></form> \ No newline at end of file diff --git a/modules/cms-ui/themes/default/html/views/template/pub.tpl.src.xml b/modules/cms-ui/themes/default/html/views/template/pub.tpl.src.xml @@ -12,7 +12,7 @@ - <form> + <form async="true"> <group title="message:options"> <part class="line">