CC-1799 Put Airtime Storage into a Human Readable File Naming Convention
adding ability to move stor directory.
This commit is contained in:
parent
f1893cebe6
commit
6adce1ba45
6 changed files with 132 additions and 32 deletions
|
@ -10,6 +10,7 @@ class PreferenceController extends Zend_Controller_Action
|
|||
$ajaxContext->addActionContext('register', 'json')
|
||||
->addActionContext('remindme', 'json')
|
||||
->addActionContext('server-browse', 'json')
|
||||
->addActionContext('change-stor-directory', 'json')
|
||||
->addActionContext('reload-watch-directory', 'json')
|
||||
->addActionContext('remove-watch-directory', 'json')
|
||||
->initContext();
|
||||
|
@ -175,12 +176,33 @@ class PreferenceController extends Zend_Controller_Action
|
|||
die(json_encode($result));
|
||||
}
|
||||
|
||||
public function changeStorDirectoryAction()
|
||||
{
|
||||
$chosen = $this->getRequest()->getParam("dir");
|
||||
$element = $this->getRequest()->getParam("element");
|
||||
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
|
||||
$watched_dirs_form->populate(array('storageFolder' => $chosen));
|
||||
$bool = $watched_dirs_form->verifyChosenFolder($element);
|
||||
|
||||
if ($bool === true) {
|
||||
MusicDir::setStorDir($chosen);
|
||||
$data = array();
|
||||
$data["directory"] = $chosen;
|
||||
RabbitMq::SendMessageToMediaMonitor("change_stor", $data);
|
||||
}
|
||||
|
||||
$watched_dirs_form->setWatchedDirs();
|
||||
|
||||
$this->view->subform = $watched_dirs_form->render();
|
||||
}
|
||||
|
||||
public function reloadWatchDirectoryAction()
|
||||
{
|
||||
$chosen = $this->getRequest()->getParam("dir");
|
||||
$element = $this->getRequest()->getParam("element");
|
||||
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
|
||||
$watched_dirs_form->populate(array('watchedFolder' => $chosen));
|
||||
$bool = $watched_dirs_form->verifyChosenFolder();
|
||||
$bool = $watched_dirs_form->verifyChosenFolder($element);
|
||||
|
||||
if ($bool === true) {
|
||||
MusicDir::addWatchedDir($chosen);
|
||||
|
|
|
@ -9,6 +9,17 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm
|
|||
array('ViewScript', array('viewScript' => 'form/preferences_watched_dirs.phtml'))
|
||||
));
|
||||
|
||||
$this->addElement('text', 'storageFolder', array(
|
||||
'class' => 'input_text',
|
||||
'label' => 'Airtime\'s Storage Folder:',
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
'value' => '',
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
$this->addElement('text', 'watchedFolder', array(
|
||||
'class' => 'input_text',
|
||||
'label' => 'Choose a Folder to Watch:',
|
||||
|
@ -21,9 +32,9 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm
|
|||
));
|
||||
}
|
||||
|
||||
public function verifyChosenFolder() {
|
||||
public function verifyChosenFolder($p_form_element_id) {
|
||||
|
||||
$element = $this->getElement('watchedFolder');
|
||||
$element = $this->getElement($p_form_element_id);
|
||||
|
||||
if (!is_dir($element->getValue())) {
|
||||
$element->setErrors(array('Not a valid Directory'));
|
||||
|
|
|
@ -35,6 +35,7 @@ class MusicDir {
|
|||
public function setDirectory($dir)
|
||||
{
|
||||
$this->_dir->setDirectory($dir);
|
||||
$this->_dir->save();
|
||||
}
|
||||
|
||||
public function remove()
|
||||
|
@ -112,6 +113,12 @@ class MusicDir {
|
|||
return $mus_dir;
|
||||
}
|
||||
|
||||
public static function setStorDir($p_dir)
|
||||
{
|
||||
$dir = self::getStorDir();
|
||||
$dir->setDirectory($p_dir);
|
||||
}
|
||||
|
||||
public static function getWatchedDirFromFilepath($p_filepath)
|
||||
{
|
||||
$dirs = CcMusicDirsQuery::create()
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
<dl class="zend_form">
|
||||
|
||||
<dt id="watchedFolder-label" class="block-display">
|
||||
<dt id="storageFolder-label" class="block-display">
|
||||
<label class="required" for="storageFolder"><?php echo $this->element->getElement('storageFolder')->getLabel() ?></label>
|
||||
</dt>
|
||||
<dd id="storageFolder-element">
|
||||
<?php echo $this->element->getElement('storageFolder') ?>
|
||||
<input id="storageFolder-selection" type="button" value="choose folder"></input>
|
||||
<input id="storageFolder-ok" type="button" value="OK"></input>
|
||||
<?php if($this->element->getElement('storageFolder')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('storageFolder')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<div>Current Storage Folder: <?php $stor = MusicDir::getStorDir(); echo $stor->getDirectory(); ?></div>
|
||||
|
||||
<dt id="watchedFolder-label" class="block-display">
|
||||
<label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label>
|
||||
</dt>
|
||||
<dd id="watchedFolder-element">
|
||||
<?php echo $this->element->getElement('watchedFolder') ?>
|
||||
<input id="watchedFolder-selection" type="button" value="choose folder"></input>
|
||||
<input id="watchedFolder-ok" type="button" value="OK"></input>
|
||||
<?php if($this->element->getElement('watchedFolder')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('watchedFolder')->getMessages() as $error): ?>
|
||||
|
@ -14,9 +32,7 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dd>
|
||||
<input id="watchedFolder-ok" type="button" value="OK"></input>
|
||||
</dd>
|
||||
|
||||
<div id="watchedFolder-table">
|
||||
<?php $i = 1; ?>
|
||||
<?php $element = $this->element->getElement("watched_dir_$i"); ?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue