2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_EditAudioMD extends Zend_Form
|
|
|
|
{
|
2023-09-08 15:45:24 +02:00
|
|
|
public function init() {}
|
2019-09-20 02:07:50 +02:00
|
|
|
|
2012-12-05 19:16:25 +01:00
|
|
|
public function startForm($p_id)
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
// Set the method for the display form to POST
|
2010-12-30 23:26:44 +01:00
|
|
|
$this->setMethod('post');
|
2024-04-21 11:13:43 +02:00
|
|
|
$this->setAttrib('id', 'track_edit_' . $p_id);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2015-08-05 01:56:12 +02:00
|
|
|
$file_id = new Zend_Form_Element_Hidden('file_id');
|
|
|
|
$file_id->setValue($p_id);
|
2024-04-21 11:13:43 +02:00
|
|
|
$file_id->setDecorators(['ViewHelper']);
|
2021-10-11 16:10:47 +02:00
|
|
|
$file_id->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
2015-08-05 01:56:12 +02:00
|
|
|
$file_id->removeDecorator('Label');
|
2015-08-07 22:49:05 +02:00
|
|
|
$file_id->setAttrib('class', 'obj_id');
|
2015-08-05 01:56:12 +02:00
|
|
|
$this->addElement($file_id);
|
|
|
|
|
2019-09-20 02:07:50 +02:00
|
|
|
// Add artwork hidden field
|
|
|
|
$artwork = new Zend_Form_Element_Hidden('artwork');
|
2021-10-11 16:10:47 +02:00
|
|
|
$artwork->class = 'input_text artwork_' . $p_id;
|
|
|
|
$artwork->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 2048]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2024-02-03 22:31:00 +01:00
|
|
|
$artwork->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
|
|
|
$artwork->removeDecorator('Label');
|
|
|
|
$artwork->setAttrib('class', 'artwork');
|
2019-09-20 02:07:50 +02:00
|
|
|
$this->addElement($artwork);
|
|
|
|
|
2019-10-30 04:50:01 +01:00
|
|
|
// Set artwork hidden field
|
|
|
|
$set_artwork = new Zend_Form_Element_Hidden('set_artwork');
|
2021-10-11 16:10:47 +02:00
|
|
|
$set_artwork->class = 'input_text set_artwork_' . $p_id;
|
2024-02-03 22:31:00 +01:00
|
|
|
$set_artwork->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
|
|
|
$set_artwork->removeDecorator('Label');
|
|
|
|
$set_artwork->setAttrib('class', 'set_artwork');
|
2019-10-30 04:50:01 +01:00
|
|
|
$this->addElement($set_artwork);
|
|
|
|
|
|
|
|
// Remove artwork hidden field
|
|
|
|
$remove_artwork = new Zend_Form_Element_Hidden('remove_artwork');
|
2021-10-11 16:10:47 +02:00
|
|
|
$remove_artwork->class = 'input_text remove_artwork_' . $p_id;
|
2024-02-03 22:31:00 +01:00
|
|
|
$remove_artwork->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
|
|
|
$remove_artwork->removeDecorator('Label');
|
|
|
|
$remove_artwork->setAttrib('class', 'remove_artwork');
|
2019-10-30 04:50:01 +01:00
|
|
|
$this->addElement($remove_artwork);
|
2019-10-25 16:30:33 +02:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add title field
|
2014-05-26 23:13:45 +02:00
|
|
|
$track_title = new Zend_Form_Element_Text('track_title');
|
|
|
|
$track_title->class = 'input_text';
|
|
|
|
$track_title->setLabel(_('Title:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($track_title);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add artist field
|
2014-05-26 23:13:45 +02:00
|
|
|
$artist_name = new Zend_Form_Element_Text('artist_name');
|
|
|
|
$artist_name->class = 'input_text';
|
|
|
|
$artist_name->setLabel(_('Creator:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($artist_name);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add album field
|
2014-05-26 23:13:45 +02:00
|
|
|
$album_title = new Zend_Form_Element_Text('album_title');
|
|
|
|
$album_title->class = 'input_text';
|
|
|
|
$album_title->setLabel(_('Album:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($album_title);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2019-03-05 16:00:54 +01:00
|
|
|
// Add album field
|
2021-10-11 16:10:47 +02:00
|
|
|
$user_options = [];
|
2019-03-05 16:00:54 +01:00
|
|
|
$users = Application_Model_User::getNonGuestUsers();
|
|
|
|
|
|
|
|
foreach ($users as $host) {
|
|
|
|
$user_options[$host['index']] = $host['label'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$owner_id = new Zend_Form_Element_Select('owner_id');
|
|
|
|
$owner_id->class = 'input_text';
|
|
|
|
$owner_id->setLabel(_('Owner:'));
|
|
|
|
$owner_id->setMultiOptions($user_options);
|
|
|
|
$this->addelement($owner_id);
|
|
|
|
|
2020-01-06 23:15:04 +01:00
|
|
|
// Add track type dropdown
|
2021-10-11 16:10:47 +02:00
|
|
|
$track_type_options = [];
|
2020-01-25 18:09:19 +01:00
|
|
|
$track_types = Application_Model_Tracktype::getTracktypes();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
array_multisort(array_map(function ($element) {
|
2020-12-16 07:28:14 +01:00
|
|
|
return $element['type_name'];
|
|
|
|
}, $track_types), SORT_ASC, $track_types);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
$track_type_options[''] = _('Select a Type');
|
2020-01-06 23:15:04 +01:00
|
|
|
foreach ($track_types as $key => $tt) {
|
2022-06-08 16:31:01 +02:00
|
|
|
$track_type_options[$tt['id']] = $tt['type_name'];
|
2019-10-17 02:20:34 +02:00
|
|
|
}
|
|
|
|
|
2022-06-08 16:31:01 +02:00
|
|
|
$track_type_id = new Zend_Form_Element_Select('track_type_id');
|
|
|
|
$track_type_id->class = 'input_text';
|
|
|
|
$track_type_id->setLabel(_('Track Type:'));
|
|
|
|
$track_type_id->setMultiOptions($track_type_options);
|
|
|
|
$this->addelement($track_type_id);
|
2019-10-17 02:20:34 +02:00
|
|
|
|
2015-09-14 23:00:54 +02:00
|
|
|
// Description field
|
2015-11-03 22:23:17 +01:00
|
|
|
$description = new Zend_Form_Element_Textarea('description');
|
2015-09-14 23:00:54 +02:00
|
|
|
$description->class = 'input_text';
|
|
|
|
$description->setLabel(_('Description:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2015-09-14 23:00:54 +02:00
|
|
|
$this->addElement($description);
|
|
|
|
|
2011-05-26 17:11:12 +02:00
|
|
|
// Add track number field
|
2014-05-26 23:13:45 +02:00
|
|
|
$track_number = new Zend_Form_Element('track_number');
|
|
|
|
$track_number->class = 'input_text';
|
|
|
|
$track_number->setLabel('Track Number:')
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
2022-01-23 19:15:55 +01:00
|
|
|
->setValidators([new Zend_Validate_Int()]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($track_number);
|
2011-05-05 16:55:14 +02:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add genre field
|
2014-05-26 23:13:45 +02:00
|
|
|
$genre = new Zend_Form_Element('genre');
|
|
|
|
$genre->class = 'input_text';
|
|
|
|
$genre->setLabel(_('Genre:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 64]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($genre);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add year field
|
2013-06-06 23:02:01 +02:00
|
|
|
$year = new Zend_Form_Element_Text('year');
|
|
|
|
$year->class = 'input_text';
|
|
|
|
$year->setLabel(_('Year:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 10]),
|
|
|
|
Application_Form_Helper_ValidationTypes::overrrideDateValidator('YYYY-MM-DD'),
|
|
|
|
Application_Form_Helper_ValidationTypes::overrrideDateValidator('YYYY-MM'),
|
|
|
|
Application_Form_Helper_ValidationTypes::overrrideDateValidator('YYYY'),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2013-06-06 23:02:01 +02:00
|
|
|
$this->addElement($year);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add label field
|
2014-05-26 23:13:45 +02:00
|
|
|
$label = new Zend_Form_Element('label');
|
|
|
|
$label->class = 'input_text';
|
|
|
|
$label->setLabel(_('Label:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($label);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add composer field
|
2014-05-26 23:13:45 +02:00
|
|
|
$composer = new Zend_Form_Element('composer');
|
|
|
|
$composer->class = 'input_text';
|
|
|
|
$composer->setLabel(_('Composer:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($composer);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-04-04 00:09:03 +02:00
|
|
|
// Add conductor field
|
2014-05-26 23:13:45 +02:00
|
|
|
$conductor = new Zend_Form_Element('conductor');
|
|
|
|
$conductor->class = 'input_text';
|
|
|
|
$conductor->setLabel(_('Conductor:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($conductor);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add mood field
|
2014-05-26 23:13:45 +02:00
|
|
|
$mood = new Zend_Form_Element('mood');
|
|
|
|
$mood->class = 'input_text';
|
|
|
|
$mood->setLabel(_('Mood:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 64]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($mood);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2011-08-03 18:32:59 +02:00
|
|
|
// Add bmp field
|
2012-04-11 20:09:51 +02:00
|
|
|
$bpm = new Zend_Form_Element_Text('bpm');
|
|
|
|
$bpm->class = 'input_text';
|
2012-11-15 16:59:06 +01:00
|
|
|
$bpm->setLabel(_('BPM:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['min' => 0, 'max' => 8]),
|
2022-07-07 20:01:15 +02:00
|
|
|
new Zend_Validate_Digits(),
|
|
|
|
]);
|
2012-04-11 20:09:51 +02:00
|
|
|
$this->addElement($bpm);
|
2011-05-05 16:55:14 +02:00
|
|
|
|
2011-08-03 18:32:59 +02:00
|
|
|
// Add copyright field
|
2014-05-26 23:13:45 +02:00
|
|
|
$copyright = new Zend_Form_Element('copyright');
|
|
|
|
$copyright->class = 'input_text';
|
|
|
|
$copyright->setLabel(_('Copyright:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($copyright);
|
2011-05-05 16:55:14 +02:00
|
|
|
|
2011-08-03 18:32:59 +02:00
|
|
|
// Add isrc number field
|
2014-05-26 23:13:45 +02:00
|
|
|
$isrc_number = new Zend_Form_Element('isrc_number');
|
|
|
|
$isrc_number->class = 'input_text';
|
|
|
|
$isrc_number->setLabel(_('ISRC Number:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($isrc_number);
|
2011-05-05 16:55:14 +02:00
|
|
|
|
2011-08-03 18:32:59 +02:00
|
|
|
// Add website field
|
2014-05-26 23:13:45 +02:00
|
|
|
$info_url = new Zend_Form_Element('info_url');
|
|
|
|
$info_url->class = 'input_text';
|
|
|
|
$info_url->setLabel(_('Website:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($info_url);
|
2011-08-03 18:32:59 +02:00
|
|
|
|
|
|
|
// Add language field
|
2014-05-26 23:13:45 +02:00
|
|
|
$language = new Zend_Form_Element('language');
|
|
|
|
$language->class = 'input_text';
|
|
|
|
$language->setLabel(_('Language:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->setValidators([
|
|
|
|
new Zend_Validate_StringLength(['max' => 512]),
|
2022-01-23 19:15:55 +01:00
|
|
|
]);
|
2014-05-26 23:13:45 +02:00
|
|
|
$this->addElement($language);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2015-10-23 22:09:38 +02:00
|
|
|
$validCuePattern = '/^(?:[0-9]{1,2}:)?(?:[0-9]{1,2}:)?[0-9]{1,6}(\.\d{1,6})?$/';
|
2015-10-21 16:58:22 +02:00
|
|
|
|
|
|
|
$cueIn = new Zend_Form_Element_Text('cuein');
|
2024-04-21 11:13:43 +02:00
|
|
|
$cueIn->class = 'input_text cuein_' . $p_id;
|
2021-10-11 16:10:47 +02:00
|
|
|
$cueIn->setLabel('Cue In:');
|
2015-10-21 16:58:22 +02:00
|
|
|
$cueInValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator(
|
2021-10-11 16:10:47 +02:00
|
|
|
$validCuePattern,
|
|
|
|
_(sprintf('Specify cue in time in the format %s', '(hh:mm:)ss(.dddddd)'))
|
2015-10-21 16:58:22 +02:00
|
|
|
);
|
2021-10-11 16:10:47 +02:00
|
|
|
$cueIn->setValidators([$cueInValidator]);
|
2015-10-21 16:58:22 +02:00
|
|
|
$this->addElement($cueIn);
|
|
|
|
|
|
|
|
$cueOut = new Zend_Form_Element_Text('cueout');
|
2024-04-21 11:13:43 +02:00
|
|
|
$cueOut->class = 'input_text cueout_' . $p_id;
|
2015-10-21 16:58:22 +02:00
|
|
|
$cueOut->setLabel('Cue Out:');
|
|
|
|
$cueOutValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator(
|
2021-10-11 16:10:47 +02:00
|
|
|
$validCuePattern,
|
|
|
|
_(sprintf('Specify cue out time in the format %s', '(hh:mm:)ss(.dddddd)'))
|
2015-10-21 16:58:22 +02:00
|
|
|
);
|
2021-10-11 16:10:47 +02:00
|
|
|
$cueOut->setValidators([$cueOutValidator]);
|
2015-10-21 16:58:22 +02:00
|
|
|
$this->addElement($cueOut);
|
|
|
|
|
2015-10-29 19:58:30 +01:00
|
|
|
// Add the cancel button
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('button', 'editmdcancel', [
|
|
|
|
'ignore' => true,
|
|
|
|
'class' => 'btn md-cancel',
|
|
|
|
'label' => _('Cancel'),
|
|
|
|
'decorators' => [
|
|
|
|
'ViewHelper',
|
|
|
|
],
|
|
|
|
]);
|
2015-10-29 19:58:30 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add the submit button
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('button', 'editmdsave', [
|
|
|
|
'ignore' => true,
|
|
|
|
'class' => 'btn md-save',
|
|
|
|
'label' => _('Save'),
|
|
|
|
'decorators' => [
|
|
|
|
'ViewHelper',
|
|
|
|
],
|
|
|
|
]);
|
2011-03-31 04:18:05 +02:00
|
|
|
|
2015-10-29 19:58:30 +01:00
|
|
|
// Button to open the publish dialog
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('button', 'publishdialog', [
|
|
|
|
'ignore' => true,
|
|
|
|
'class' => 'btn md-publish',
|
|
|
|
'label' => _('Publish...'),
|
|
|
|
'decorators' => [
|
|
|
|
'ViewHelper',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->addDisplayGroup(['publishdialog', 'editmdsave', 'editmdcancel'], 'submitButtons', [
|
|
|
|
'decorators' => [
|
2015-08-18 00:34:39 +02:00
|
|
|
'FormElements',
|
2021-10-11 16:10:47 +02:00
|
|
|
'DtDdWrapper',
|
|
|
|
],
|
|
|
|
]);
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2015-08-28 19:40:38 +02:00
|
|
|
public function makeReadOnly()
|
|
|
|
{
|
|
|
|
foreach ($this as $element) {
|
|
|
|
$element->setAttrib('readonly', 'readonly');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public function removeOwnerEdit()
|
|
|
|
{
|
2019-03-05 16:00:54 +01:00
|
|
|
$this->removeElement('owner_id');
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2015-08-28 19:40:38 +02:00
|
|
|
public function removeActionButtons()
|
|
|
|
{
|
|
|
|
$this->removeElement('editmdsave');
|
|
|
|
$this->removeElement('editmdcancel');
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|