Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Added new DCA table config flags (see #5254)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 26, 2013
1 parent 6a1db2a commit 3503e2e
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 15 deletions.
12 changes: 12 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Contao Open Source CMS Changelog
Version 3.2.beta1 (2013-XX-XX)
------------------------------

### New
Added new DCA table config flags (see #5254):

* `closed`: no new rows can be added at all
* `notEditable`: the rows cannot be edited
* `notDeletable`: the rows cannot be deleted
* `notSortable`: the order of the rows cannot be altered (new)
* `notCopyable`: existing rows cannot be duplicated (new)
* `notCreatable`: prevents to create rows but allows to duplicate rows (new)

The `closed` flag hence is a combination of `notCreatable` and `notCopyable`.

### Improved
Always show the save buttons in the modal windows (see #5985).

Expand Down
45 changes: 41 additions & 4 deletions system/modules/core/drivers/DC_Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public function showAll()
$return = '
<div id="tl_buttons">'.((\Input::get('act') == 'select') ? '
<a href="'.$this->getReferer(true).'" class="header_back" title="'.specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']).'" accesskey="b" onclick="Backend.getScrollOffset()">'.$GLOBALS['TL_LANG']['MSC']['backBT'].'</a> ' : '') . ((\Input::get('act') != 'select' && !$blnClipboard) ? '
<a href="'.$this->addToUrl($hrfNew).'" class="'.$clsNew.'" title="'.specialchars($ttlNew).'" accesskey="n" onclick="Backend.getScrollOffset()">'.$lblNew.'</a> ' . (!$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] ? '<a href="'.$this->addToUrl('&amp;act=paste&amp;mode=move').'" class="header_new" title="'.specialchars($GLOBALS['TL_LANG'][$this->strTable]['move'][1]).'" onclick="Backend.getScrollOffset()">'.$GLOBALS['TL_LANG'][$this->strTable]['move'][0].'</a> ' : '') . $this->generateGlobalButtons(true) : '') . ($blnClipboard ? '<a href="'.$this->addToUrl('clipboard=1').'" class="header_clipboard" title="'.specialchars($GLOBALS['TL_LANG']['MSC']['clearClipboard']).'" accesskey="x">'.$GLOBALS['TL_LANG']['MSC']['clearClipboard'].'</a> ' : '') . '
<a href="'.$this->addToUrl($hrfNew).'" class="'.$clsNew.'" title="'.specialchars($ttlNew).'" accesskey="n" onclick="Backend.getScrollOffset()">'.$lblNew.'</a> ' . ((!$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] && !$GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable']) ? '<a href="'.$this->addToUrl('&amp;act=paste&amp;mode=move').'" class="header_new" title="'.specialchars($GLOBALS['TL_LANG'][$this->strTable]['move'][1]).'" onclick="Backend.getScrollOffset()">'.$GLOBALS['TL_LANG'][$this->strTable]['move'][0].'</a> ' : '') . $this->generateGlobalButtons(true) : '') . ($blnClipboard ? '<a href="'.$this->addToUrl('clipboard=1').'" class="header_clipboard" title="'.specialchars($GLOBALS['TL_LANG']['MSC']['clearClipboard']).'" accesskey="x">'.$GLOBALS['TL_LANG']['MSC']['clearClipboard'].'</a> ' : '') . '
</div>' . \Message::generate(true) . ((\Input::get('act') == 'select') ? '
<form action="'.ampersand(\Environment::get('request'), true).'" id="tl_select" class="tl_form" method="post">
Expand Down Expand Up @@ -357,8 +357,15 @@ public function showAll()
$arrButtons['delete'] = '<input type="submit" name="delete" id="delete" class="tl_submit" accesskey="d" onclick="return confirm(\''.$GLOBALS['TL_LANG']['MSC']['delAllConfirm'].'\')" value="'.specialchars($GLOBALS['TL_LANG']['MSC']['deleteSelected']).'">';
}

$arrButtons['cut'] = '<input type="submit" name="cut" id="cut" class="tl_submit" accesskey="x" value="'.specialchars($GLOBALS['TL_LANG']['MSC']['moveSelected']).'">';
$arrButtons['copy'] = '<input type="submit" name="copy" id="copy" class="tl_submit" accesskey="c" value="'.specialchars($GLOBALS['TL_LANG']['MSC']['copySelected']).'">';
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['notSortable'])
{
$arrButtons['cut'] = '<input type="submit" name="cut" id="cut" class="tl_submit" accesskey="x" value="'.specialchars($GLOBALS['TL_LANG']['MSC']['moveSelected']).'">';
}

if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['notCopyable'])
{
$arrButtons['copy'] = '<input type="submit" name="copy" id="copy" class="tl_submit" accesskey="c" value="'.specialchars($GLOBALS['TL_LANG']['MSC']['copySelected']).'">';
}

if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['notEditable'])
{
Expand Down Expand Up @@ -414,6 +421,12 @@ public function show()
*/
public function create()
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable'])
{
$this->log('Table "'.$this->strTable.'" is not creatable', 'DC_Folder create()', TL_ERROR);
$this->redirect('contao/main.php?act=error');
}

$this->import('Files');
$strFolder = \Input::get('pid', true);

Expand All @@ -439,6 +452,12 @@ public function create()
*/
public function cut($source=null)
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notSortable'])
{
$this->log('Table "'.$this->strTable.'" is not sortable', 'DC_Folder cut()', TL_ERROR);
$this->redirect('contao/main.php?act=error');
}

$strFolder = \Input::get('pid', true);
$blnDoNotRedirect = ($source !== null);

Expand Down Expand Up @@ -510,6 +529,12 @@ public function cut($source=null)
*/
public function cutAll()
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notSortable'])
{
$this->log('Table "'.$this->strTable.'" is not sortable', 'DC_Folder cutAll()', TL_ERROR);
$this->redirect('contao/main.php?act=error');
}

// PID is mandatory
if (!strlen(\Input::get('pid', true)))
{
Expand Down Expand Up @@ -537,6 +562,12 @@ public function cutAll()
*/
public function copy($source=null, $destination=null)
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notCopyable'])
{
$this->log('Table "'.$this->strTable.'" is not copyable', 'DC_Folder copy()', TL_ERROR);
$this->redirect('contao/main.php?act=error');
}

$strFolder = \Input::get('pid', true);
$blnDoNotRedirect = ($source !== null);

Expand Down Expand Up @@ -634,6 +665,12 @@ public function copy($source=null, $destination=null)
*/
public function copyAll()
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notCopyable'])
{
$this->log('Table "'.$this->strTable.'" is not copyable', 'DC_Folder copyAll()', TL_ERROR);
$this->redirect('contao/main.php?act=error');
}

// PID is mandatory
if (!strlen(\Input::get('pid', true)))
{
Expand Down Expand Up @@ -2206,7 +2243,7 @@ protected function generateTree($path, $intMargin, $mount=false, $blnProtected=f
}

// Upload button
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] && \Input::get('act') != 'select')
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] && !$GLOBALS['TL_DCA'][$this->strTable]['config']['notCreatable'] && \Input::get('act') != 'select')
{
$return .= ' <a href="'.$this->addToUrl('&amp;act=move&amp;mode=2&amp;pid='.$currentEncoded).'" title="'.specialchars(sprintf($GLOBALS['TL_LANG']['tl_files']['uploadFF'], $currentEncoded)).'">'.\Image::getHtml('new.gif', $GLOBALS['TL_LANG'][$this->strTable]['move'][0]).'</a>';
}
Expand Down
Loading

0 comments on commit 3503e2e

Please sign in to comment.