[TYPO3-dam] sorting files code
Nico Potvin
nico.potvin at kandesign.com
Mon Oct 9 11:54:40 CEST 2006
hi,
i found this in the archives, coorect me if i am wro,g, does this code
add the ppossibility to manually sort the files in the dam?
and did anyone try this?
greets nico
Hi Frank,
i didn't connect to the author, since i already made some
updates
and contacted
the author concerning the problems with field length in the DAM
and
got no response
The changes are the following:
Place the following source line in
class.tx_dam_actionsRecord.php
after the class: tx_dam_action_lockWarningRec
/
************************************************************************
***
***/
/**
* MoveUp record action
*
* @author Axel Klarmann
* @package DAM-Component
* @subpackage Action
* @see tx_dam_actionbase
*/
class tx_dam_action_moveUpRec extends tx_dam_action_recordBase {
/**
* Returns true if the action is of the wanted type
*
* @param string $type Action type
* @param array $itemInfo Item info array. Eg
pathInfo, meta data array
* @param array $env Environment array. Can be
set
with setEnv() too.
* @return boolean
*/
function isValid ($type, $itemInfo=NULL, $env=NULL) {
global $TCA;
$valid = parent::isValid ($type, $itemInfo, $env);
if ($valid) {
$valid = ($this->env['permsEdit']);
}
if($valid)
{
$valid = isset($itemInfo['prevSorting']);
};
return $valid;
}
/**
* Returns the icon image tag.
* Additional attributes to the image tagcan be added.
*
* @param string $addAttribute Additional
attributes
* @return string
*/
function getIcon ($addAttribute='') {
global $TCA;
if ($this->disabled) {
$icon = '<img src="clear.gif"
'.t3lib_iconWorks::skinImg($this->backPath,'gfx/
button_up.gif','width="11"
height="10"',2).' alt="" />';
} else {
$iconFile = 'gfx/button_up.gif';
$icon =
'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], $iconFile,
'width="12" height="12"').$this->_cleanAttribute($addAttribute).' alt=""
/>';
}
return $icon;
}
/**
* Returns a short description for tooltips for example like:
Delete
folder recursivley
*
* @return string
*/
function getDescription () {
return
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.moveup');
}
/**
* Returns a command array for the current type
*
* @return array Command array
* @access private
*/
function _getCommand() {
$params =
'&cmd['.$this->itemInfo['__table'].']['.$this-
>itemInfo['uid'].'][move]='.$t
his->itemInfo["prev"];
$title = $this->itemInfo['title'].'
('.$this->itemInfo['file_name'].')';
$onClick =
'jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params, -1).'\');
return
false;';
$commands['href'] = '#';
$commands['onclick'] = $onClick;
return $commands;
}
}
/**
* MoveDown record action
*
* @author Axel Klarmann
* @package DAM-Component
* @subpackage Action
* @see tx_dam_actionbase
*/
class tx_dam_action_moveDownRec extends tx_dam_action_recordBase {
/**
* Returns true if the action is of the wanted type
*
* @param string $type Action type
* @param array $itemInfo Item info array. Eg
pathInfo, meta data array
* @param array $env Environment array. Can be
set
with setEnv() too.
* @return boolean
*/
function isValid ($type, $itemInfo=NULL, $env=NULL) {
global $TCA;
$valid = parent::isValid ($type, $itemInfo, $env);
if ($valid) {
$valid = ($this->env['permsEdit']);
}
if($valid)
{
$valid = isset($itemInfo['nextSorting']);
};
return $valid;
}
/**
* Returns the icon image tag.
* Additional attributes to the image tagcan be added.
*
* @param string $addAttribute Additional
attributes
* @return string
*/
function getIcon ($addAttribute='') {
global $TCA;
if ($this->disabled) {
$icon = '<img src="clear.gif"
'.t3lib_iconWorks::skinImg($this->backPath,'gfx/
button_down.gif','width="11"
height="10"',2).' alt="" />';
} else {
$iconFile = 'gfx/button_down.gif';
$icon =
'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], $iconFile,
'width="12" height="12"').$this->_cleanAttribute($addAttribute).' alt=""
/>';
}
return $icon;
}
/**
* Returns a short description for tooltips for example like:
Delete
folder recursivley
*
* @return string
*/
function getDescription () {
return
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.movedown');
}
/**
* Returns a command array for the current type
*
* @return array Command array
* @access private
*/
function _getCommand() {
$params =
'&cmd['.$this->itemInfo['__table'].']['.$this-
>itemInfo['uid'].'][move]='.$t
his->itemInfo["next"];
$title = $this->itemInfo['title'].'
('.$this->itemInfo['file_name'].')';
$onClick =
'jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params, -1).'\');
return
false;';
$commands['href'] = '#';
$commands['onclick'] = $onClick;
return $commands;
}
}
/
************************************************************************
***
*********/
This will add the appropriate actions to the control.
Then add this actions to the ext_tables.php file. To get the
order
of the buttons like the
file menu you should place this lines
tx_dam::register_action ('tx_dam_action_moveUpRec',
'EXT:dam/components/class.tx_dam_actionsRecord.php:
&tx_dam_action_moveUpRec'
);
tx_dam::register_action ('tx_dam_action_moveDownRec',
'EXT:dam/components/class.tx_dam_actionsRecord.php:
&tx_dam_action_moveDownRe
c');
before
tx_dam::register_action ('tx_dam_action_hideRec',
'EXT:dam/components/class.tx_dam_actionsRecord.php:
&tx_dam_action_hideRec');
Finally the most importend point is to update the way the DAM
delivers records for listing in class.tx_dam_listrecords.php
Look for the following lines in function renderList:
$this->currentTable['prev'][$row['uid']] = $prevPrevUid;
$this->currentTable['next'][$prevUid] = '-'.$row['uid'];
$this->currentTable['prevUid'][$row['uid']] = $prevUid;
And append
$accRows[$row['uid']]['prev'] = $prevPrevUid;
$accRows[$prevUid]['next'] =
'-'.$row['uid'];
right after this lines. That will store the previous and next
item
in the row delivered to
the actions .. so the chain is closed :o)
I can also send the full files if required to the persons
interested.
Hope that helps,
Axel
--
Nico Potvin
KAN Design
Antwerpen - Belgium
Phone: +32 (0)3 203 41 69
Fax: +32 (0)3 225 14 05
E-mail: nico.potvin at kandesign.com
http://www.kandesign.com
More information about the TYPO3-project-dam
mailing list