openrat-cms

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

commit b632f29f767248f01547db968333741abc14c561
parent b4ad4c952fa97d9b6b30f5048a08207102c76ada
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 14 Mar 2021 02:14:31 +0100

Fix: The public filename of files must contain their path...

Diffstat:
Mmodules/cms/action/folder/FolderPubAction.class.php | 8++++----
Mmodules/cms/generator/FileGenerator.class.php | 2+-
Mmodules/cms/generator/PageGenerator.class.php | 2+-
Mmodules/cms/generator/ValueGenerator.class.php | 1-
Mmodules/cms/macros/macro/SearchIndex.class.php | 2+-
Mmodules/cms/model/Folder.class.php | 19++++++++++++-------
6 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/modules/cms/action/folder/FolderPubAction.class.php b/modules/cms/action/folder/FolderPubAction.class.php @@ -15,6 +15,7 @@ use cms\model\Page; use cms\model\Permission; use cms\model\Folder; use cms\model\Template; +use language\Messages; use util\Session; @@ -42,8 +43,6 @@ class FolderPubAction extends FolderAction implements Method { public function post() { - if ( !$this->folder->hasRight( Permission::ACL_PUBLISH ) ) - throw new \util\exception\SecurityException('no rights for publish'); $project = $this->folder->getProject(); $project->load(); @@ -97,6 +96,7 @@ class FolderPubAction extends FolderAction implements Method { } } + // Publish all files if ( $this->request->has('files' ) ) { @@ -122,9 +122,9 @@ class FolderPubAction extends FolderAction implements Method { $this->addNoticeFor( $this->folder, - 'PUBLISHED', + Messages::PUBLISHED, array(), - implode("\n",$publisher->getDestinationFilenames() ) + 'Published items:'."\n".implode("\n",$publisher->getDestinationFilenames() ) ); } } diff --git a/modules/cms/generator/FileGenerator.class.php b/modules/cms/generator/FileGenerator.class.php @@ -35,7 +35,7 @@ class FileGenerator extends BaseGenerator if ( $file->extension ) $filename .= '.'.$file->extension; - return $filename; + return $file->path().'/'.$filename; } diff --git a/modules/cms/generator/PageGenerator.class.php b/modules/cms/generator/PageGenerator.class.php @@ -52,7 +52,7 @@ class PageGenerator extends BaseGenerator // neues Inhaltobjekt erzeugen $valueContext = new ValueContext($this->context); $valueContext->elementid = $elementid; - $valueGenerator = new ValueGenerator( $valueContext ); + $valueGenerator = new ValueGenerator( $valueContext );$this->getPublicFilename() try { $values[$elementid] = $valueGenerator->getCache()->get(); } catch( \Exception $e ) { diff --git a/modules/cms/generator/ValueGenerator.class.php b/modules/cms/generator/ValueGenerator.class.php @@ -776,7 +776,6 @@ class ValueGenerator extends BaseGenerator $runner = new MacroRunner(); try { - //$inhalt .= print_r($pageContext,true); $inhalt .= $runner->executeMacro( $macroName, $macroSettings,$page, $pageContext ); } catch( \Exception $e ) { diff --git a/modules/cms/macros/macro/SearchIndex.class.php b/modules/cms/macros/macro/SearchIndex.class.php @@ -40,7 +40,7 @@ class SearchIndex extends Macro $f = new Folder( $project->getRootObjectId() ); $f->load(); - foreach ($f->getAllSubFolderIds() as $fid) { + foreach ( array_merge( [$f],$f->getAllSubFolderIds() ) as $fid) { $tf = new Folder($fid); $tf->load(); diff --git a/modules/cms/model/Folder.class.php b/modules/cms/model/Folder.class.php @@ -313,14 +313,19 @@ class Folder extends BaseObject * Returns a list of files. * @return array */ - function getFiles() + public function getFiles() { - $db = \cms\base\DB::get(); - - $sql = $db->sql('SELECT id FROM {{object}} '. - ' WHERE parentid={objectid} AND typeid='.BaseObject::TYPEID_FILE. - ' ORDER BY orderid ASC' ); - $sql->setInt( 'objectid' ,$this->objectid ); + $sql = DB::sql( <<<SQL + SELECT id FROM {{object}} + WHERE parentid={objectid} + AND typeid IN ( {typefile},{typeimage},{typetext} ) + ORDER BY orderid ASC +SQL + ); + $sql->setInt( 'objectid' ,$this->objectid ); + $sql->setInt( 'typefile' ,BaseObject::TYPEID_FILE ); + $sql->setInt( 'typeimage' ,BaseObject::TYPEID_IMAGE ); + $sql->setInt( 'typetext' ,BaseObject::TYPEID_TEXT ); return $sql->getCol(); }