diff --git a/.zfproject.xml b/.zfproject.xml
index a12dc522a..a3af0c944 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -34,7 +34,7 @@
-
+
@@ -145,9 +145,6 @@
-
-
-
@@ -229,6 +226,9 @@
+
+
+
diff --git a/application/controllers/LibraryController.php b/application/controllers/LibraryController.php
index feed55806..7af3b62fd 100644
--- a/application/controllers/LibraryController.php
+++ b/application/controllers/LibraryController.php
@@ -2,13 +2,12 @@
class LibraryController extends Zend_Controller_Action
{
-
protected $pl_sess = null;
- protected $search_sess = null;
+ protected $search_sess = null;
public function init()
{
- if(!Zend_Auth::getInstance()->hasIdentity())
+ if(!Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('login/index');
}
@@ -27,7 +26,7 @@ class LibraryController extends Zend_Controller_Action
public function indexAction()
{
- $this->view->headScript()->appendFile('/js/campcaster/onready/library.js','text/javascript');
+ $this->view->headScript()->appendFile('/js/campcaster/onready/library.js','text/javascript');
$this->view->headScript()->appendFile('/js/contextmenu/jjmenu.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
@@ -42,7 +41,7 @@ class LibraryController extends Zend_Controller_Action
public function contextMenuAction()
{
- $id = $this->_getParam('id');
+ $id = $this->_getParam('id');
$type = $this->_getParam('type');
$params = '/format/json/id/#id#/type/#type#';
@@ -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,13 +89,12 @@ class LibraryController extends Zend_Controller_Action
//returns format jjmenu is looking for.
die(json_encode($menu));
-
}
public function deleteAction()
{
$id = $this->_getParam('id');
-
+
if (!is_null($id)) {
$file = StoredFile::Recall($id);
@@ -119,8 +120,8 @@ class LibraryController extends Zend_Controller_Action
public function contentsAction()
{
- $this->view->headScript()->appendFile('/js/campcaster/library/library.js','text/javascript');
-
+ $this->view->headScript()->appendFile('/js/campcaster/library/library.js','text/javascript');
+
$this->_helper->viewRenderer->setResponseSegment('library');
$order["category"] = $this->_getParam('ob', "dc:creator");
@@ -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
+
+
diff --git a/application/controllers/PlaylistController.php b/application/controllers/PlaylistController.php
index 06dffaac2..d73ef2a06 100644
--- a/application/controllers/PlaylistController.php
+++ b/application/controllers/PlaylistController.php
@@ -92,15 +92,13 @@ 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');
}
public function metadataAction()
- {
-
+ {
$request = $this->getRequest();
$form = new Application_Form_PlaylistMetadata();
diff --git a/application/forms/EditAudioMD.php b/application/forms/EditAudioMD.php
index 4f9323a56..37df0e0e9 100644
--- a/application/forms/EditAudioMD.php
+++ b/application/forms/EditAudioMD.php
@@ -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',
+ ));
}
diff --git a/application/models/StoredFile.php b/application/models/StoredFile.php
index 1931f5900..50fca75d7 100644
--- a/application/models/StoredFile.php
+++ b/application/models/StoredFile.php
@@ -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",
diff --git a/application/views/scripts/library/edit-file-md.phtml b/application/views/scripts/library/edit-file-md.phtml
new file mode 100644
index 000000000..41276c253
--- /dev/null
+++ b/application/views/scripts/library/edit-file-md.phtml
@@ -0,0 +1,4 @@
+form->setAction($this->url());
+echo $this->form;