can edit file metadata.
This commit is contained in:
parent
2a37140c4d
commit
0cf89713a9
6 changed files with 136 additions and 19 deletions
|
@ -34,7 +34,7 @@
|
|||
<actionMethod actionName="contextMenu"/>
|
||||
<actionMethod actionName="delete"/>
|
||||
<actionMethod actionName="contents"/>
|
||||
<actionMethod actionName="search"/>
|
||||
<actionMethod actionName="editFileMd"/>
|
||||
</controllerFile>
|
||||
<controllerFile controllerName="Plupload">
|
||||
<actionMethod actionName="index"/>
|
||||
|
@ -145,9 +145,6 @@
|
|||
<viewControllerScriptsDirectory forControllerName="Playlist">
|
||||
<viewScriptFile forActionName="deleteActive"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Library">
|
||||
<viewScriptFile forActionName="search"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Index">
|
||||
<viewScriptFile forActionName="newfield"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
|
@ -229,6 +226,9 @@
|
|||
<viewControllerScriptsDirectory forControllerName="Playlist">
|
||||
<viewScriptFile forActionName="close"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Library">
|
||||
<viewScriptFile forActionName="editFileMd"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
</viewScriptsDirectory>
|
||||
<viewHelpersDirectory/>
|
||||
<viewFiltersDirectory enabled="false"/>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class LibraryController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
protected $pl_sess = null;
|
||||
protected $search_sess = null;
|
||||
|
||||
|
@ -59,6 +58,9 @@ class LibraryController extends Zend_Controller_Action
|
|||
'title' => 'Add to Playlist');
|
||||
}
|
||||
|
||||
$menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'),
|
||||
'title' => 'Info');
|
||||
|
||||
}
|
||||
else if($type === "pl") {
|
||||
|
||||
|
@ -87,7 +89,6 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
//returns format jjmenu is looking for.
|
||||
die(json_encode($menu));
|
||||
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
|
@ -132,9 +133,27 @@ class LibraryController extends Zend_Controller_Action
|
|||
$this->view->files = StoredFile::searchFiles($md, $order);
|
||||
}
|
||||
|
||||
public function searchAction()
|
||||
public function editFileMdAction()
|
||||
{
|
||||
// action body
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_EditAudioMD();
|
||||
|
||||
$file_id = $this->_getParam('id', null);
|
||||
|
||||
$file = StoredFile::Recall($file_id);
|
||||
$form->populate($file->md);
|
||||
|
||||
if ($request->isPost()) {
|
||||
if ($form->isValid($request->getPost())) {
|
||||
|
||||
$formdata = $form->getValues();
|
||||
$file->replaceDbMetadata($formdata);
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,3 +171,5 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$pl_id = $pl->create("Test Zend Auth");
|
||||
$pl->setPLMetaData('dc:creator', $userInfo->login);
|
||||
|
||||
//set this playlist as active id.
|
||||
$this->changePlaylist($pl_id);
|
||||
|
||||
$this->_helper->redirector('metadata');
|
||||
|
@ -100,7 +99,6 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
public function metadataAction()
|
||||
{
|
||||
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_PlaylistMetadata();
|
||||
|
||||
|
|
|
@ -5,7 +5,86 @@ class Application_Form_EditAudioMD extends Zend_Form
|
|||
|
||||
public function init()
|
||||
{
|
||||
/* Form Elements & Other Definitions Here ... */
|
||||
// Set the method for the display form to POST
|
||||
$this->setMethod('post');
|
||||
|
||||
// Add title field
|
||||
$this->addElement('text', 'track_title', array(
|
||||
'label' => 'Title:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
)
|
||||
));
|
||||
|
||||
// Add artist field
|
||||
$this->addElement('text', 'artist_name', array(
|
||||
'label' => 'Artist:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
)
|
||||
));
|
||||
|
||||
// Add bitrate field
|
||||
// $this->addElement('text', 'bit_rate', array(
|
||||
// 'label' => 'Bitrate:',
|
||||
// 'attribs' => array('disabled' => 'disabled')
|
||||
//));
|
||||
|
||||
// Add album field
|
||||
$this->addElement('text', 'album_title', array(
|
||||
'label' => 'Album:',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
|
||||
// Add genre field
|
||||
$this->addElement('text', 'genre', array(
|
||||
'label' => 'Genre:',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
|
||||
// Add year field
|
||||
$this->addElement('text', 'year', array(
|
||||
'label' => 'Year:',
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
array('date', false, array('YYYY-MM-DD')),
|
||||
array('date', false, array('YYYY'))
|
||||
)
|
||||
));
|
||||
|
||||
// Add label field
|
||||
$this->addElement('text', 'label', array(
|
||||
'label' => 'Label:',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
|
||||
// Add composer field
|
||||
$this->addElement('text', 'composer', array(
|
||||
'label' => 'Composer:',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
|
||||
// Add mood field
|
||||
$this->addElement('text', 'mood', array(
|
||||
'label' => 'Mood:',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
|
||||
// Add language field
|
||||
$this->addElement('text', 'language', array(
|
||||
'label' => 'Language:',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
|
||||
// Add the submit button
|
||||
$this->addElement('submit', 'submit', array(
|
||||
'ignore' => true,
|
||||
'label' => 'Submit',
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -537,6 +537,21 @@ class StoredFile {
|
|||
$this->loadMetadata();
|
||||
}
|
||||
|
||||
public function replaceDbMetadata($p_values)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
foreach ($p_values as $category => $value) {
|
||||
$escapedValue = pg_escape_string($value);
|
||||
$columnName = $category;
|
||||
if (!is_null($columnName)) {
|
||||
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
|
||||
." SET $columnName='$escapedValue'"
|
||||
." WHERE gunid = '".$this->gunid."'";
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function clearMetadata()
|
||||
{
|
||||
$metadataColumns = array("format", "bit_rate", "sample_rate", "length",
|
||||
|
|
4
application/views/scripts/library/edit-file-md.phtml
Normal file
4
application/views/scripts/library/edit-file-md.phtml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
$this->form->setAction($this->url());
|
||||
echo $this->form;
|
Loading…
Add table
Add a link
Reference in a new issue