I wonder if I can add "covers" to sound files as well with this; that is another area that should have had an image that one could associate with the sound file.
Add "Covers" to Sound Files
Make backups of your original files before this modification in case something goes wrong. Then...
1) Open the modules/boonex/sounds/classes/BxSoundsUploader.php
Search and find this code:
function GenSendFileInfoForm($iFileID, $aDefaultValues = array()) {
Add this function before that code line:
function _GenSendFileInfoForm($iFileID, $aDefaultValues = array(), $aPossibleImage = array(), $aPossibleDuration = array()) {
header("Content-type: text/html; charset=utf-8");
$this->addJsTranslation(array(
'_bx_' . $this->sUploadTypeLC . 's_val_title_err',
'_bx_' . $this->sUploadTypeLC . 's_val_descr_err'
));
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aFormCategories['categories'] = $oCategories->getGroupChooser('bx_' . $this->sUploadTypeLC . 's', $this->_iOwnerId, true);
$aFormCategories['categories']['required'] = false;
$sKey = 'album';
$aAlbums = array();
if ($this->_aExtras[$sKey] != '') {
$aAlbums[BX_DOL_UPLOADER_EP_PREFIX . $sKey] = array (
'type' => 'hidden',
'name' => BX_DOL_UPLOADER_EP_PREFIX . $sKey,
'value' => stripslashes($this->_aExtras[$sKey])
);
} else {
$oAlbum = new BxDolAlbums('bx_' . $this->sUploadTypeLC . 's');
$aAlbumList = $oAlbum->getAlbumList(array('owner'=>$this->_iOwnerId));
if (count($aAlbumList) > 0) {
foreach ($aAlbumList as $aValue)
$aList[$aValue['ID']] = stripslashes($aValue['Caption']);
}
else {
$sDefName = $oAlbum->getAlbumDefaultName();
$aList[$sDefName] = stripslashes($sDefName);
}
$aAlbums['album'] = array(
'type' => 'select_box',
'name' => BX_DOL_UPLOADER_EP_PREFIX . $sKey,
'caption' => _t('_sys_album'),
'values' => $aList
);
}
$sCaptionVal = ($this->sSendFileInfoFormCaption != '') ? $this->sSendFileInfoFormCaption : _t('_Info');
// processing of possible default values
$aInputValues = array('title', 'tags', 'description', 'type', $this->sUploadTypeLC);
foreach ($aInputValues as $sField) {
$sEmpty = $sField == 'type' ? 'upload' : '';
$sTemp = isset($aDefaultValues[$sField]) ? strip_tags($aDefaultValues[$sField]) : $sEmpty;
$aDefaultValues[$sField] = $sTemp;
}
$aForm = array(
'form_attrs' => array(
'id' => $this->sUploadTypeLC . '_file_info_form',
'method' => 'post',
'action' => $this->sWorkingFile,
'target' => 'upload_file_info_frame_' . $iFileID,
'enctype' => 'multipart/form-data',
),
'inputs' => array(
'header2' => array(
'type' => 'block_header',
'caption' => $sCaptionVal,
'collapsable' => true
),
'title' => array(
'type' => 'text',
'name' => 'title',
'caption' => _t('_Title'),
'required' => true,
'value' => $aDefaultValues['title']
),
'tags' => array(
'type' => 'text',
'name' => 'tags',
'caption' => _t('_Tags'),
'info' => _t('_Tags_desc'),
'value' => $aDefaultValues['tags']
),
'description' => array(
'type' => 'textarea',
'name' => 'description',
'caption' => _t('_Description'),
'required' => true,
'value' => $aDefaultValues['description']
),
'image' => array(
'type' => 'file',
'name' => 'image',
'caption' => _t('_Upload image'),
),
'media_id' => array(
'type' => 'hidden',
'name' => 'file_id',
'value' => $iFileID,
),
'hidden_action' => array(
'type' => 'hidden',
'name' => 'action',
'value' => 'accept_file_info'
),
$this->sUploadTypeLC => array(
'type' => 'hidden',
'name' => $this->sUploadTypeLC,
'value' => $aDefaultValues[$this->sUploadTypeLC]
),
'type' => array(
'type' => 'hidden',
'name' => 'type',
'value' => $aDefaultValues['type']
)
),
);
//--- Process Extras ---//
foreach($this->_aExtras as $sKey => $mixedValue)
$aForm['inputs'][BX_DOL_UPLOADER_EP_PREFIX . $sKey] = array (
'type' => 'hidden',
'name' => BX_DOL_UPLOADER_EP_PREFIX . $sKey,
'value' => $mixedValue
);
// merging categories
$aForm['inputs'] = $this->getUploadFormArray($aForm['inputs'], array($aFormCategories, $aAlbums));
if (is_array($aPossibleImage) && count($aPossibleImage)>0)
$aForm['inputs'] = array_merge($aForm['inputs'], $aPossibleImage);
if (is_array($aPossibleDuration) && count($aPossibleDuration)>0)
$aForm['inputs'] = array_merge($aForm['inputs'], $aPossibleDuration);
$aForm['inputs'][] = array(
'type' => 'input_set',
'colspan' => true,
0 => array(
'type' => 'submit',
'name' => 'upload',
'value' => _t('_Submit'),
'colspan' => true,
'attrs' => array(
'onclick' => "return parent." . $this->_sJsPostObject . ".doValidateFileInfo(this, '" . $iFileID . "');",
)
),
1 => array(
'type' => 'button',
'name' => 'close',
'value' => _t('_bx_'.$this->sUploadTypeLC.'s_close'),
'colspan' => true,
'attrs' => array(
'onclick' => "return parent." . $this->_sJsPostObject . ".cancelSendFileInfo('" . $iFileID . "', ''); ",
)
),
2 => array(
'type' => 'button',
'name' => 'delete',
'value' => _t('_bx_'.$this->sUploadTypeLC.'s_admin_delete'),
'colspan' => true,
'attrs' => array(
'onclick' => "return parent." . $this->_sJsPostObject . ".cancelSendFileInfo('" . $iFileID . "', '" . $this->sWorkingFile . "'); ",
)
)
);
$oForm = new BxTemplFormView($aForm);
$sForm = $oForm->getCode();
$sFormSafeJS = str_replace(array("'", "r", "n"), array("'"), $sForm);
return "<script src='" . BX_DOL_URL_ROOT . "inc/js/jquery.webForms.js' type='text/javascript' language='javascript'></script><script type='text/javascript'>parent." . $this->_sJsPostObject . ".genSendFileInfoForm('" . $iFileID . "', '" . $sFormSafeJS . "'); parent." . $this->_sJsPostObject . "._loading(false);</script>";
}
In the same file, find this code:
$oCateg->reparseObjTags('bx_sounds', $iMusicID);
And add this code below it:
if( isset($_FILES['image']['type']) ) {
$this -> oModule -> uploadSoundThumb($_FILES['image'], $iMusicID);
}
2. Open the modules/boonex/sounds/classes/BxSoundsConfig.php
Search and find this code:
$this->aFilePostfix = array(
'.mp3',
'.jpg'
);
Add this code below it:
$this -> iSoundThumbWidth = 148;
$this -> iSoundThumbHeight = 110;
$this -> aAllowedFileType = array('image/jpeg', 'image/png', 'image/gif', 'image/jpg');
$this -> sThumbSaveDir = BX_DIRECTORY_PATH_ROOT . 'flash/modules/mp3/files/';
$this -> sThumbUrl = BX_DOL_URL_ROOT . 'flash/modules/mp3/files/';
3. Open the modules/boonex/sounds/classes/BxSoundsModule.php
Search and find this code:
function serviceGetProfileCat () {
return PROFILE_SOUND_CATEGORY;
}
Add this code below that:
function actionEdit ($iFileId) {
$iFileId = (int)$iFileId > 0 ? (int)$iFileId : (int)$_POST['fileId'];
if ($iFileId == 0)
exit;
$this->aPageTmpl['name_index'] = 44;
$sJsCode = '<script language="javascript">window.setTimeout(function () { window.parent.opener.location = window.parent.opener.location; window.parent.close(); }, 3000); </script>';
$aManageArray = array('medTitle', 'medTags', 'medDesc', 'medProfId', 'Categories');
$aInfo = $this->_oDb->getFileInfo(array('fileId'=>$iFileId), false, $aManageArray);
if (!$this->isAllowedEdit($aInfo))
$sCode = MsgBox(_t('_' . $this->_oConfig->getMainPrefix() . '_access_denied')) . $sJsCode;
else {
$oCategories = new BxDolCategories();
$oCategories->getTagObjectConfig();
$aCategories = $oCategories->getGroupChooser($this->_oConfig->getMainPrefix(), $this->_iProfileId, true);
$aCategories['value'] = explode(CATEGORIES_DIVIDER, $aInfo['Categories']);
$sThumbImage = $this -> _oConfig -> sThumbSaveDir . $iFileId . '.jpg';
$aForm = array(
'form_attrs' => array(
'id' => $this->_oConfig->getMainPrefix() . '_upload_form',
'method' => 'post',
'action' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iFileId,
'enctype' => 'multipart/form-data',
),
'params' => array (
'db' => array(
'submit_name' => 'submit',
),
'checker_helper' => 'BxSupportCheckerHelper',
),
'inputs' => array(
'header' => array(
'type' => 'block_header',
'caption' => _t('_Info'),
),
'title' => array(
'type' => 'text',
'name' => 'medTitle',
'caption' => _t('_Title'),
'required' => true,
'value' => $aInfo['medTitle'],
'checker' => array (
'func' => 'length',
'params' => array(3, 128),
'error' => _t('_td_err_incorrect_length'),
),
),
'tags' => array(
'type' => 'text',
'name' => 'medTags',
'caption' => _t('_Tags'),
'info' => _t('_Tags_desc'),
'value' => $aInfo['medTags']
),
'description' => array(
'type' => 'textarea',
'name' => 'medDesc',
'caption' => _t('_Description'),
'required' => true,
'value' => $aInfo['medDesc'],
'checker' => array (
'func' => 'length',
'params' => array(3, 65536),
'error' => _t('_td_err_incorrect_length'),
),
),
'image' => array(
'type' => 'file',
'name' => 'image',
'caption' => _t('_Upload image'),
),
'current_image' => array(
'type' => 'custom',
'content' => _t('_Delete') . ' <input name="delete_thumb" type="checkbox"><br /><img src="'
. $this -> _oConfig -> sThumbUrl . $iFileId . '.jpg" />',
),
'categories' => $aCategories,
'fileId' => array(
'type' => 'hidden',
'name' => 'fileId',
'value' => $iFileId,
),
'medProfId' => array(
'type' => 'hidden',
'name' => 'medProfId',
'value' => $aInfo['medProfId'],
),
'submit' => array(
'type' => 'submit',
'name' => 'submit',
'value' => _t('_Submit'),
'colspan' => true,
),
),
);
$bThumbExist = file_exists($sThumbImage) ? true : false;
if(!$bThumbExist) {
unset($aForm['inputs']['current_image']);
}
$oForm = new BxTemplFormView($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid()) {
$aValues = array();
foreach ($aManageArray as $sKey) {
if ($sKey != 'Categories')
$aValues[$sKey] = $_POST[$sKey];
else {
$aValues[$sKey] = implode(CATEGORIES_DIVIDER, $_POST[$sKey]);
}
}
$bUploadRes = false;
if( isset($_POST['delete_thumb']) && $bThumbExist ) {
//delete thumb
@unlink($sThumbImage);
$bUploadRes = true;
}
if( isset($_FILES['image']['type']) ) {
$this -> uploadSoundThumb($_FILES['image'], $iFileId);
$bUploadRes = true;
}
if ($this->_oDb->updateData($iFileId, $aValues) || $bUploadRes) {
$sType = $this->_oConfig->getMainPrefix();
bx_import('BxDolCategories');
$oTag = new BxDolTags();
$oTag->reparseObjTags($sType, $iFileId);
$oCateg = new BxDolCategories();
$oCateg->reparseObjTags($sType, $iFileId);
$sCode = MsgBox(_t('_' . $this->_oConfig->getMainPrefix() . '_save_success')) . $sJsCode;
}
}
else {
$sCode = $oForm->getCode();
$this->aPageTmpl['css_name'] = array('forms_adv.css', 'explanation.css');
}
}
$this->aPageTmpl['header'] = _t('_Edit');
$this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => $sCode));
}
function uploadSoundThumb($aThumbInfo, $iFileId)
{
if( isset($aThumbInfo['type'], $aThumbInfo['tmp_name'])
&& in_array($aThumbInfo['type'], $this -> _oConfig -> aAllowedFileType) ) {
//upload and resize thumb image
return imageResize($aThumbInfo['tmp_name']
, $this -> _oConfig -> sThumbSaveDir . $iFileId . '.jpg'
, $this -> _oConfig -> iSoundThumbWidth
, $this -> _oConfig -> iSoundThumbHeight);
}
}
4. Open the flash/modules/mp3/inc/actions.inc.php
Search and remove these lines of code:
case 'screenshot':
//--- Prepare data ---//
$iWidth = isset($_REQUEST['width']) ? (int)$_REQUEST['width'] : 0;
$iHeight = isset($_REQUEST['height']) ? (int)$_REQUEST['height'] : 0;
$sData = isset($_REQUEST['data']) ? process_db_input($_REQUEST['data']) : "";
$aImageData = explode(',', $sData);
$iLength = count($aImageData);
for($i=0; $i<$iLength; $i++)
$aImageData[$i] = base_convert($aImageData[$i], 36, 10);
if($iLength != $iWidth * $iHeight || !function_exists("imagecreatetruecolor")) break;
//--- Create Image Resource ---//
$rImage = @imagecreatetruecolor($iWidth, $iHeight);
for ($i = 0, $y = 0; $y < $iHeight; $y++ )
for ( $x = 0; $x < $iWidth; $x++, $i++)
@imagesetpixel ($rImage, $x, $y, $aImageData[$i]);
//--- Save image file ---//
$sUser = process_db_input($_REQUEST['user']);
if(empty($sId)) $sId = $sUser . TEMP_FILE_NAME;
$sFileName = $sFilesPathMp3 . $sId . SCREENSHOT_EXT;
@imagejpeg($rImage, $sFileName, 100);
break;
This hack was posted by Esase, just reposting it. Seems to work as far as I can tell.