Für eins der Beispiele muss folgende Ordner-Struktur in Contenido erstellt werden.
Code: Alles auswählen
contenido
- plugins
- - meine_cec (freiwählbar)
- - - includes
Beispiele 1:
Dieses Beispiel entfernt vorhandene Zeilen.
Code: Alles auswählen
<?php
if(!defined('CON_FRAMEWORK')) die('Illegal call');
global $_cecRegistry, $cfg;
function cecUplEdit_UnsetRows($aRows) {
/* unset professional Rows for simple customer */
unset( $aRows['keywords'] );
unset( $aRows['medianotes'] );
unset( $aRows['copyright'] );
return $aRows;
}
$_cecRegistry->addChainFunction("Contenido.Upl_edit.Rows", "cecUplEdit_UnsetRows");
?>
Hier wird die Zeile für Dateigröße ergänzt.
Code: Alles auswählen
<?php
if(!defined('CON_FRAMEWORK')) die('Illegal call');
global $_cecRegistry, $cfg;
cInclude('classes', 'class.dbfs.php');
function cecUplEdit_AddRowsFileSize($aRows) {
/* add new row after position-x or at row-end */
if( array_key_exists( "description", $aRows ) ) {
$aNewRows = array();
foreach( $aRows as $key => $value ) {
$aNewRows[$key] = $value;
if( $key == "description" ) {
$aNewRows['filesize'] = i18n("Size");
} } }
else {
$aNewRows = array();
$aNewRows = $aRows;
$aNewRows['filesize'] = i18n("File size");
}
return $aNewRows;
}
function cecUplEdit_DisplayFileSize( $iIdupl, $sPath, $sFile, $sListRow) {
if( $sListRow == "filesize") {
global $cfgClient, $client;
$item = new UploadItem();
$item->loadByPrimaryKey($iIdupl);
$aSizes = array('YB', 'ZB', 'EB', 'PB', 'TB', 'GB', 'MB', 'kB', 'B');
$sSize = $item->get("size");
$iTotal = count($aSizes);
while($iTotal-- && $sSize > 1024) {
$sSize /= 1024;
}
return round($sSize, 2).' '.$aSizes[$iTotal];
} }
$_cecRegistry->addChainFunction("Contenido.Upl_edit.Rows", "cecUplEdit_AddRowsFileSize");
$_cecRegistry->addChainFunction("Contenido.Upl_edit.RenderRows", "cecUplEdit_DisplayFileSize");
?>
Dieses Beispiel ergänzt nicht nur eine Zeile sondern bietet auch die Möglichkeit eigene Eingaben zu speichern.
Code: Alles auswählen
<?php
if(!defined('CON_FRAMEWORK')) die('Illegal call');
global $_cecRegistry, $cfg;
function cecUplEdit_AddRowsBdbId($aRows) {
/* add bdbid-Row row after position modified */
$aNewRows = array();
if( array_key_exists( "description", $aRows ) ) {
$aNewRows = array();
foreach( $aRows as $key => $value ) {
$aNewRows[$key] = $value;
if( $key == "description" ) {
$aNewRows['bdbid'] = 'Image-DB-ID';
} } }
else {
$aNewRows = array();
$aNewRows = $aRows;
$aNewRows['bdbid'] = 'Image-DB-ID';
}
return $aNewRows;
}
function cecUplEdit_DisplayBdbId( $iIdupl, $sPath, $sFile, $sListRow) {
global $properties;
if( $sListRow == "bdbid") {
$sBdbId = stripslashes($properties->getValue("upload_cec", $iIdupl, "file", "cec_bdbid", FALSE));
$oBdbId = new cHTMLTextbox("cec_bdbid", $sBdbId, 60 );
$sBdbId = $oBdbId->render();
return $sBdbId;
} }
function cecUplEdit_SaveBdbId( $iIdupl, $sPath, $sFile ) {
global $properties;
if( is_set($_POST['cec_bdbid']) )
$properties->setValue("upload_cec", $iIdupl, "file", "cec_bdbid", stripslashes($_POST['cec_bdbid']) );
}
function cecUplEdit_DeleteBdbId( $iIdupl, $sPath, $sFile ) {
global $properties;
$properties->deleteValue("upload_cec", $iIdupl, "file", "cec_bdbid" );
}
$_cecRegistry->addChainFunction("Contenido.Upl_edit.Rows", "cecUplEdit_AddRowsBdbId");
$_cecRegistry->addChainFunction("Contenido.Upl_edit.RenderRows", "cecUplEdit_DisplayBdbId");
$_cecRegistry->addChainFunction("Contenido.Upl_edit.SaveRows", "cecUplEdit_SaveBdbId");
$_cecRegistry->addChainFunction("Contenido.Upl_edit.Delete", "cecUplEdit_DeleteBdbId");
?>