commit c2391e009535f03f4694f0f851711c09e117b965
parent 90487383438f6803fea0e1149a1d9b71fe24bee2
Author: Jan Dankert <devnull@localhost>
Date: Sun, 9 Sep 2018 21:14:16 +0200
Die Methode 'add()' bei Ordnern delegiert an die anderen, speziellen Methoden zum Anlegen von Objekten. Das spart doppelten Code und vereinfacht hoffentlich das UI für die Benutzer.
Diffstat:
5 files changed, 134 insertions(+), 357 deletions(-)
diff --git a/modules/cms-core/action/FolderAction.class.php b/modules/cms-core/action/FolderAction.class.php
@@ -62,149 +62,6 @@ class FolderAction extends ObjectAction
- /**
- * Neues Objekt anlegen.<br>
- * Dies kann ein(e) Verzeichnis, Seite, Verkn�pfung oder Datei sein.<br>
- */
- public function createPost()
- {
- global $conf;
- $type = $this->getRequestVar('type' );
-
- switch( $type )
- {
- case 'folder':
- $name = $this->getRequestVar('folder_name');
-
- if ( !empty($name) )
- {
- $f = new Folder();
- $f->name = $name;
- $f->parentid = $this->folder->objectid;
- $f->add();
- $this->folder->setTimestamp();
- $this->addNotice('folder',$f->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('folder_name');
- $this->callSubAction('create');
- }
- break;
-
- case 'file':
- $upload = new Upload();
-
- if ( !$upload->isValid() )
- {
- $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
- $this->callSubAction('createfile');
- return;
- }
- // Pr�fen der maximal erlaubten Dateigr��e.
- elseif ( $upload->size > $this->maxFileSize() )
- {
- // Maximale Dateigr��e ist �berschritten
- $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED');
- $this->callSubAction('createfile');
- return;
- }
- elseif( $upload->size > 0 )
- {
- $file = new File();
- $file->desc = '';
- $file->filename = $upload->filename;
- $file->name = $upload->filename;
- $file->extension = $upload->extension;
- $file->size = $upload->size;
- $file->parentid = $this->folder->objectid;
-
- $file->value = $upload->value;
-
- $file->add(); // Datei hinzufuegen
- $this->folder->setTimestamp();
- $this->addNotice('file',$file->name,'ADDED','ok');
- }
-
- break;
-
- case 'page':
-
- $name = $this->getRequestVar('page_name');
- if ( !empty($name) )
- {
- $page = new Page();
- $page->name = $name;
- $page->templateid = $this->getRequestVar('page_templateid');
- $page->parentid = $this->folder->objectid;
- $page->add();
- $this->folder->setTimestamp();
-
- $this->addNotice('page',$page->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('page_name');
- $this->callSubAction('create');
- }
- break;
-
- case 'link':
-
- $name = $this->getRequestVar('link_name');
- if ( !empty($name) )
- {
- $link = new Link();
- $link->name = $name;
- $link->parentid = $this->folder->objectid;
-
- $link->add();
- $this->folder->setTimestamp();
-
- $this->addNotice('link',$link->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('link_name');
- $this->callSubAction('create');
- }
-
- break;
-
- case 'url':
-
- $urlValue = $this->getRequestVar('url');
- if ( !empty($urlValue) )
- {
- $url = new Url();
- $url->name = $urlValue;
- $url->parentid = $this->folder->objectid;
-
- $url->url = $urlValue;
-
- $url->add();
- $this->folder->setTimestamp();
-
- $this->addNotice('url',$url->name,'ADDED','ok');
- }
- else
- {
- $this->addValidationError('url');
- $this->callSubAction('create');
- }
-
- break;
-
- default:
- $this->addValidationError('type');
- $this->callSubAction('create');
-
- }
-
- }
-
-
-
public function createfolderPost()
{
$name = $this->getRequestVar('name' );
@@ -981,19 +838,14 @@ class FolderAction extends ObjectAction
public function createView()
{
- // Maximale Dateigroesse.
- $maxSizeBytes = $this->maxFileSize();
- $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' );
- $this->setTemplateVar('maxlength',$maxSizeBytes );
-
- $project = new Project( $this->folder->projectid );
- $all_templates = $project->getTemplates();
- $this->setTemplateVar('templates' ,$all_templates );
+ $this->setTemplateVar('mayCreateFolder',$this->folder->hasRight( ACL_CREATE_FOLDER ) );
+ $this->setTemplateVar('mayCreateFile' ,$this->folder->hasRight( ACL_CREATE_FILE ) );
+ $this->setTemplateVar('mayCreateText' ,$this->folder->hasRight( ACL_CREATE_FILE ) );
+ $this->setTemplateVar('mayCreateImage' ,$this->folder->hasRight( ACL_CREATE_FILE ) );
+ $this->setTemplateVar('mayCreatePage' ,$this->folder->hasRight( ACL_CREATE_PAGE ) );
+ $this->setTemplateVar('mayCreateUrl' ,$this->folder->hasRight( ACL_CREATE_LINK ) );
+ $this->setTemplateVar('mayCreateLink' ,$this->folder->hasRight( ACL_CREATE_LINK ) );
- if ( count($all_templates) == 0 )
- $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN);
-
- $this->setTemplateVar('objectid' ,$this->folder->objectid );
}
diff --git a/modules/cms-core/action/ProjectlistAction.class.php b/modules/cms-core/action/ProjectlistAction.class.php
@@ -75,6 +75,9 @@ class ProjectlistAction extends Action
function addView()
{
+ if( ! $this->userIsAdmin() )
+ throw new \SecurityException('user is not allowed to add a project');
+
$this->setTemplateVar( 'projects',Project::getAllProjects() );
}
diff --git a/modules/cms-ui/themes/default/html/views/folder/create.php b/modules/cms-ui/themes/default/html/views/folder/create.php
@@ -1,107 +1,68 @@
+ <span class="text"><?php echo nl2br('test'); ?></span>
-
- <form name="" target="_self" data-target="view" action="./" data-method="create" data-action="folder" data-id="<?php echo OR_ID ?>" method="POST" enctype="multipart/form-data" class="folder" 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="folder" /><input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="create" /><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('folder') ?></legend><div>
- <div class="line">
- <div class="label">
- <input class="radio" type="radio" id="<?php echo REQUEST_ID ?>_type_folder" name="type" value="folder"<?php if('folder'==@$type)echo ' checked="checked"' ?> />
-
- <label for="<?php echo REQUEST_ID ?>_type_folder" class="label">
- <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_folder')))); ?></span>
-
- </label>
- </div>
- <div class="input">
- <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_folder_name" name="folder_name<?php if ('') echo '_disabled' ?>" type="text" maxlength="250" class="name" value="<?php echo Text::encodeHtml('') ?>" /><?php if ('') { ?><input type="hidden" name="folder_name" value="<?php '' ?>"/><?php } ?></div>
-
- </div>
- </div>
- </div></fieldset>
- <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('file') ?></legend><div>
- <div class="line">
- <div class="label">
- <input class="radio" type="radio" id="<?php echo REQUEST_ID ?>_type_file" name="type" value="file"<?php if('file'==@$type)echo ' checked="checked"' ?> />
-
- <label for="<?php echo REQUEST_ID ?>_type_file" class="label">
- <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_FILE')))); ?></span>
-
- </label>
- </div>
- <div class="input">
- <input size="30" id="req15365188552120055508_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" />
-
- <br/>
-
- <span class="help"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'file_max_size'.'')))); ?></span>
-
- <span class="text"><?php echo nl2br(' '); ?></span>
-
- <span class="text"><?php echo nl2br(encodeHtml(htmlentities($max_size))); ?></span>
-
- </div>
- </div>
- </div></fieldset>
- <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('page') ?></legend><div>
- <div class="line">
- <div class="label">
- <input class="radio" type="radio" id="<?php echo REQUEST_ID ?>_type_page" name="type" value="page"<?php if('page'==@$type)echo ' checked="checked"' ?> />
-
- <label for="<?php echo REQUEST_ID ?>_type_page" class="label">
- <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_TEMPLATE')))); ?></span>
-
- </label>
- </div>
- <div class="input">
- <div class="inputholder"><select id="<?php echo REQUEST_ID ?>_page_templateid" name="page_templateid" title="" class=""<?php if (count($templates)<=1) echo ' disabled="disabled"'; ?> size=1"><?php include_once( 'modules/template-engine/components/html/selectbox/component-select-box.php') ?><?php component_select_option_list($templates,'',0,0) ?><?php if (count($templates)==0) { ?><input type="hidden" name="page_templateid" value="" /><?php } ?><?php if (count($templates)==1) { ?><input type="hidden" name="page_templateid" value="<?php echo array_keys($templates)[0] ?>" /><?php } ?>
- </select></div>
- </div>
- </div>
- <div class="line">
- <div class="label">
- <label for="<?php echo REQUEST_ID ?>_type_page" class="label">
- <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_NAME')))); ?></span>
-
- </label>
- </div>
- <div class="input">
- <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_page_name" name="page_name<?php if ('') echo '_disabled' ?>" type="text" maxlength="250" class="name" value="<?php echo Text::encodeHtml(@$page_name) ?>" /><?php if ('') { ?><input type="hidden" name="page_name" value="<?php $page_name ?>"/><?php } ?></div>
-
- </div>
- </div>
- </div></fieldset>
- <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('link') ?></legend><div>
- <div class="line">
- <div class="label">
- <input class="radio" type="radio" id="<?php echo REQUEST_ID ?>_type_link" name="type" value="link"<?php if('link'==@$type)echo ' checked="checked"' ?> />
-
- <label for="<?php echo REQUEST_ID ?>_type_link" class="label">
- <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('global_NAME')))); ?></span>
-
- </label>
- </div>
- <div class="input">
- <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_link_name" name="link_name<?php if ('') echo '_disabled' ?>" type="text" maxlength="250" class="name" value="<?php echo Text::encodeHtml(@$link_name) ?>" /><?php if ('') { ?><input type="hidden" name="link_name" value="<?php $link_name ?>"/><?php } ?></div>
-
- </div>
- </div>
- </div></fieldset>
- <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('url') ?></legend><div>
- <div class="line">
- <div class="label">
- <input class="radio" type="radio" id="<?php echo REQUEST_ID ?>_type_url" name="type" value="url"<?php if('url'==@$type)echo ' checked="checked"' ?> />
-
- <label for="<?php echo REQUEST_ID ?>_type_link" class="label">
- <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang('url')))); ?></span>
-
- </label>
- </div>
- <div class="input">
- <div class="inputholder"><input id="<?php echo REQUEST_ID ?>_url" name="url<?php if ('') echo '_disabled' ?>" type="text" maxlength="250" class="name" value="<?php echo Text::encodeHtml(@$url) ?>" /><?php if ('') { ?><input type="hidden" name="url" value="<?php $url ?>"/><?php } ?></div>
-
- </div>
- </div>
- </div></fieldset>
- <div class="bottom"><div class="command "><input type="submit" class="submit ok" value="OK" /></div></div></form>
+ <?php $if2=($mayCreateFolder); if($if2){?>
+ <div class="clickable line">
+ <a target="_self" data-type="dialog" data-action="" data-method="createfolder" data-id="<?php echo OR_ID ?>" data-extra="{'dialogAction':null,'dialogMethod':'createfolder'}" href="<?php echo Html::url('','createfolder','',array('dialogAction'=>'','dialogMethod'=>'createfolder')) ?>">
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_createfolder'.'')))); ?></span>
+
+ </a>
+
+ </div>
+ <?php } ?>
+ <?php $if2=($mayCreatePage); if($if2){?>
+ <div class="clickable line">
+ <a target="_self" data-type="dialog" data-action="" data-method="createpage" data-id="<?php echo OR_ID ?>" data-extra="{'dialogAction':null,'dialogMethod':'createpage'}" href="<?php echo Html::url('','createpage','',array('dialogAction'=>'','dialogMethod'=>'createpage')) ?>">
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_createpage'.'')))); ?></span>
+
+ </a>
+
+ </div>
+ <?php } ?>
+ <?php $if2=($mayCreateFile); if($if2){?>
+ <div class="clickable line">
+ <a target="_self" data-type="dialog" data-action="" data-method="createfile" data-id="<?php echo OR_ID ?>" data-extra="{'dialogAction':null,'dialogMethod':'createfile'}" href="<?php echo Html::url('','createfile','',array('dialogAction'=>'','dialogMethod'=>'createfile')) ?>">
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_createfile'.'')))); ?></span>
+
+ </a>
+
+ </div>
+ <?php } ?>
+ <?php $if2=($mayCreateImage); if($if2){?>
+ <div class="clickable line">
+ <a target="_self" data-type="dialog" data-action="" data-method="createimage" data-id="<?php echo OR_ID ?>" data-extra="{'dialogAction':null,'dialogMethod':'createimage'}" href="<?php echo Html::url('','createimage','',array('dialogAction'=>'','dialogMethod'=>'createimage')) ?>">
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_createimage'.'')))); ?></span>
+
+ </a>
+
+ </div>
+ <?php } ?>
+ <?php $if2=($mayCreateText); if($if2){?>
+ <div class="clickable line">
+ <a target="_self" data-type="dialog" data-action="" data-method="createtext" data-id="<?php echo OR_ID ?>" data-extra="{'dialogAction':null,'dialogMethod':'createtext'}" href="<?php echo Html::url('','createtext','',array('dialogAction'=>'','dialogMethod'=>'createtext')) ?>">
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_createltext'.'')))); ?></span>
+
+ </a>
+
+ </div>
+ <?php } ?>
+ <?php $if2=($mayCreateUrl); if($if2){?>
+ <div class="clickable line">
+ <a target="_self" data-type="dialog" data-action="" data-method="createurl" data-id="<?php echo OR_ID ?>" data-extra="{'dialogAction':null,'dialogMethod':'createurl'}" href="<?php echo Html::url('','createurl','',array('dialogAction'=>'','dialogMethod'=>'createurl')) ?>">
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_createurl'.'')))); ?></span>
+
+ </a>
+
+ </div>
+ <?php } ?>
+ <?php $if2=($mayCreateLink); if($if2){?>
+ <div class="clickable line">
+ <a target="_self" data-type="dialog" data-action="" data-method="createlink" data-id="<?php echo OR_ID ?>" data-extra="{'dialogAction':null,'dialogMethod':'createlink'}" href="<?php echo Html::url('','createlink','',array('dialogAction'=>'','dialogMethod'=>'createlink')) ?>">
+ <span class="text"><?php echo nl2br(encodeHtml(htmlentities(lang(''.'menu_createlink'.'')))); ?></span>
+
+ </a>
+
+ </div>
+ <?php } ?>
\ No newline at end of file
diff --git a/modules/cms-ui/themes/default/html/views/folder/create.tpl.src.xml b/modules/cms-ui/themes/default/html/views/folder/create.tpl.src.xml
@@ -1,100 +1,61 @@
<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">
- <header back="true" views="createfolder,createlink,createpage,createfile,createurl"></header>
- <form enctype="multipart/form-data">
- <group title="message:folder">
-
- <part class="line">
- <part class="label">
- <radio name="type" value="folder" children="folder_name"></radio>
- <label for="type_folder">
- <text text="global_folder"></text>
- </label>
- </part>
- <part class="input">
- <input name="folder_name" size="30" maxlength="250" default=""
- class="name"></input>
- </part>
- </part>
-
- </group>
-
- <group title="message:file">
-
- <part class="line">
- <part class="label">
- <radio name="type" value="file" children="file"></radio>
- <label for="type_file">
- <text text="global_FILE"></text>
- </label>
- </part>
- <part class="input">
- <upload name="file" size="30" maxlength="var:maxlength"></upload>
- <newline></newline>
- <text class="help" key="file_max_size"></text>
- <text raw="_"></text>
- <text var="max_size"></text>
- </part>
- </part>
- </group>
-
- <group title="message:page">
-
- <part class="line">
- <part class="label">
- <radio name="type" value="page" children="page_templateid,page_name"></radio>
- <label for="type_page">
- <text text="global_TEMPLATE"></text>
- </label>
- </part>
- <part class="input">
- <selectbox name="page_templateid" default="" list="templates"></selectbox>
- </part>
- </part>
-
-
-
- <part class="line">
- <part class="label">
- <label for="type_page">
- <text text="global_NAME"></text>
- </label>
- </part>
- <part class="input">
- <input name="page_name" size="30" maxlength="250" class="name"></input>
- </part>
- </part>
-
- </group>
- <group title="message:link">
-
- <part class="line">
- <part class="label">
- <radio name="type" value="link" children="link_name"></radio>
- <label for="type_link">
- <text text="global_NAME"></text>
- </label>
- </part>
- <part class="input">
- <input name="link_name" size="30" maxlength="250" class="name"></input>
- </part>
- </part>
- </group>
-
- <group title="message:url">
-
- <part class="line">
- <part class="label">
- <radio name="type" value="url" children="url"></radio>
- <label for="type_link">
- <text text="url"></text>
- </label>
- </part>
- <part class="input">
- <input name="url" size="50" maxlength="250" class="name"></input>
- </part>
- </part>
- </group>
-
- </form>
+ xsi:schemaLocation="http://www.openrat.de/template ../../../../../../template-engine/components/template.xsd">
+
+ <text raw="test"/>
+
+ <if true="var:mayCreateFolder">
+ <part class="clickable line">
+ <link type="dialog" subaction="createfolder">
+ <text key="menu_createfolder"></text>
+ </link>
+ </part>
+ </if>
+
+ <if true="var:mayCreatePage">
+ <part class="clickable line">
+ <link type="dialog" subaction="createpage">
+ <text key="menu_createpage"></text>
+ </link>
+ </part>
+ </if>
+
+ <if true="var:mayCreateFile">
+ <part class="clickable line">
+ <link type="dialog" subaction="createfile">
+ <text key="menu_createfile"></text>
+ </link>
+ </part>
+ </if>
+
+ <if true="var:mayCreateImage">
+ <part class="clickable line">
+ <link type="dialog" subaction="createimage">
+ <text key="menu_createimage"></text>
+ </link>
+ </part>
+ </if>
+
+ <if true="var:mayCreateText">
+ <part class="clickable line">
+ <link type="dialog" subaction="createtext">
+ <text key="menu_createltext"></text>
+ </link>
+ </part>
+ </if>
+
+ <if true="var:mayCreateUrl">
+ <part class="clickable line">
+ <link type="dialog" subaction="createurl">
+ <text key="menu_createurl"></text>
+ </link>
+ </part>
+ </if>
+
+ <if true="var:mayCreateLink">
+ <part class="clickable line">
+ <link type="dialog" subaction="createlink">
+ <text key="menu_createlink"></text>
+ </link>
+ </part>
+ </if>
</output>
\ No newline at end of file
diff --git a/modules/cms-ui/themes/default/html/views/folder/createfile.php b/modules/cms-ui/themes/default/html/views/folder/createfile.php
@@ -13,7 +13,7 @@
</label>
</div>
<div class="input">
- <input size="40" id="req1536518518663476572_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" multiple="multiple" />
+ <input size="40" id="req15365203172110525094_file" type="file" maxlength="<?php echo $maxlength ?>" name="file" class="upload" multiple="multiple" />
</div>
</div>