Merge pull request #637 from Robbt/podcastname-edit
Make podcast name editable
This commit is contained in:
commit
0ccf4da1e6
7 changed files with 226 additions and 133 deletions
|
@ -21,6 +21,17 @@ class Rest_Bootstrap extends Zend_Application_Module_Bootstrap
|
|||
);
|
||||
$router->addRoute('podcast-bulk', $podcastBulkRoute);
|
||||
|
||||
|
||||
$smartblockPodcastRoute = new Zend_Controller_Router_Route(
|
||||
'rest/podcast/smartblock',
|
||||
array(
|
||||
'controller' => 'podcast',
|
||||
'action' => 'smartblock',
|
||||
'module' => 'rest'
|
||||
)
|
||||
);
|
||||
$router->addRoute('podcast-smartblock', $smartblockPodcastRoute);
|
||||
|
||||
$stationPodcastRoute = new Zend_Controller_Router_Route(
|
||||
'rest/podcast/station',
|
||||
array(
|
||||
|
|
|
@ -191,6 +191,26 @@ class Rest_PodcastController extends Zend_Rest_Controller
|
|||
$this->_helper->json->sendJson($responseBody);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Endpoint for triggering the generation of a smartblock and playlist to match the podcast name
|
||||
*/
|
||||
|
||||
public function smartblockAction() {
|
||||
|
||||
$title = $this->_getParam('title', []);
|
||||
$id = $this->_getParam('id', []);
|
||||
if (!$id) {
|
||||
return;
|
||||
}
|
||||
$podcast = Application_Service_PodcastService::getPodcastById($id);
|
||||
|
||||
// logging::info($podcast);
|
||||
Application_Service_PodcastService::createPodcastSmartblockAndPlaylist($podcast, $title);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws PodcastNotFoundException
|
||||
*
|
||||
|
|
|
@ -162,49 +162,59 @@ class Application_Service_PodcastService
|
|||
|
||||
/**
|
||||
* @param $podcast
|
||||
* @param $title passed in directly from web UI input
|
||||
* This will automatically create a smartblock and playlist for this podcast.
|
||||
*/
|
||||
|
||||
public static function createPodcastSmartblockAndPlaylist($podcast)
|
||||
public static function createPodcastSmartblockAndPlaylist($podcast, $title = null)
|
||||
{
|
||||
$newBl = new Application_Model_Block();
|
||||
$newBl->setCreator(Application_Model_User::getCurrentUser()->getId());
|
||||
$newBl->setName($podcast->getDbTitle());
|
||||
$newBl->setDescription('Auto-generated smartblock for podcast');
|
||||
$newBl->saveType('dynamic');
|
||||
// limit the smartblock to 1 item
|
||||
$row = new CcBlockcriteria();
|
||||
$row->setDbCriteria('limit');
|
||||
$row->setDbModifier('items');
|
||||
$row->setDbValue(1);
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->save();
|
||||
|
||||
// sort so that it is the newest item
|
||||
$row = new CcBlockcriteria();
|
||||
$row->setDbCriteria('sort');
|
||||
$row->setDbModifier('N/A');
|
||||
$row->setDbValue('newest');
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->save();
|
||||
|
||||
// match the track by ensuring the album title matches the podcast
|
||||
$row = new CcBlockcriteria();
|
||||
$row->setDbCriteria('album_title');
|
||||
$row->setDbModifier('is');
|
||||
$row->setDbValue($newBl->getName());
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->save();
|
||||
|
||||
$newPl = new Application_Model_Playlist();
|
||||
$newPl->setName($podcast->getDbTitle());
|
||||
$newPl->setCreator(Application_Model_User::getCurrentUser()->getId());
|
||||
$row = new CcPlaylistcontents();
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->setDbPlaylistId($newPl->getId());
|
||||
$row->setDbType(2);
|
||||
$row->save();
|
||||
if (is_array($podcast)) {
|
||||
$newpodcast = new Podcast();
|
||||
$newpodcast->fromArray($podcast, BasePeer::TYPE_FIELDNAME);
|
||||
$podcast = $newpodcast;
|
||||
}
|
||||
if ($title == null) {
|
||||
$title = $podcast->getDbTitle();
|
||||
}
|
||||
// Base class
|
||||
$newBl = new Application_Model_Block();
|
||||
$newBl->setCreator(Application_Model_User::getCurrentUser()->getId());
|
||||
$newBl->setName($title);
|
||||
$newBl->setDescription('Auto-generated smartblock for podcast');
|
||||
$newBl->saveType('dynamic');
|
||||
// limit the smartblock to 1 item
|
||||
$row = new CcBlockcriteria();
|
||||
$row->setDbCriteria('limit');
|
||||
$row->setDbModifier('items');
|
||||
$row->setDbValue(1);
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->save();
|
||||
|
||||
// sort so that it is the newest item
|
||||
$row = new CcBlockcriteria();
|
||||
$row->setDbCriteria('sort');
|
||||
$row->setDbModifier('N/A');
|
||||
$row->setDbValue('newest');
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->save();
|
||||
|
||||
// match the track by ensuring the album title matches the podcast
|
||||
$row = new CcBlockcriteria();
|
||||
$row->setDbCriteria('album_title');
|
||||
$row->setDbModifier('is');
|
||||
$row->setDbValue($title);
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->save();
|
||||
|
||||
$newPl = new Application_Model_Playlist();
|
||||
$newPl->setName($title);
|
||||
$newPl->setCreator(Application_Model_User::getCurrentUser()->getId());
|
||||
$row = new CcPlaylistcontents();
|
||||
$row->setDbBlockId($newBl->getId());
|
||||
$row->setDbPlaylistId($newPl->getId());
|
||||
$row->setDbType(2);
|
||||
$row->save();
|
||||
}
|
||||
|
||||
|
||||
public static function createStationPodcast()
|
||||
|
|
|
@ -7,23 +7,36 @@
|
|||
<div class="inner_editor_wrapper">
|
||||
<form class="podcast-metadata">
|
||||
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
|
||||
<div>
|
||||
<div class="podcast-metadata-row">
|
||||
<label for="podcast_name"><?php echo _("Podcast Name: ") ?></label>
|
||||
<span class="podcast-metadata-field">{{podcast.title}}</span>
|
||||
<input name="podcast_name" type="text" ng-model="podcast.title" value={{podcast.title}} >
|
||||
</div>
|
||||
<div>
|
||||
<div class="podcast-metadata-row">
|
||||
<label for="podcast_url"><?php echo _("Podcast URL: ") ?></label>
|
||||
<a href="{{podcast.url}}" target="_blank">
|
||||
<span class="podcast-metadata-field">{{podcast.url}}</span>
|
||||
</a>
|
||||
<a href="{{podcast.url}}" target="_blank" class="podcast-url">{{podcast.url}}</a>
|
||||
</div>
|
||||
<div style="padding-top: 0.1em;">
|
||||
<label for="podcast_auto_ingest"><input name="podcast_auto_ingest" ng-model="podcast.auto_ingest" type="checkbox" class="float-right"/></label>
|
||||
<span class="podcast-metadata-field"><?php echo _("Automatically download latest episodes?") ?></span>
|
||||
<div class="podcast-metadata-row">
|
||||
<div>
|
||||
<input name="podcast_auto_ingest" id="podcast_auto_ingest" ng-model="podcast.auto_ingest" type="checkbox"/>
|
||||
</div>
|
||||
<label for="podcast_auto_ingest"><?php echo _("Automatically download latest episodes") ?></label>
|
||||
</div>
|
||||
<div style="padding-top: 0.1em;">
|
||||
<label for="podcast_album_override"><input name="podcast_album_override" ng-model="podcast.album_override" type="checkbox" class="no-float"/></label>
|
||||
<span class="podcast-metadata-field"><?php echo _("Override album name with podcast name during ingest."); ?></span>
|
||||
<div class="podcast-metadata-row">
|
||||
<div>
|
||||
<input name="podcast_album_override" id="podcast_album_override" ng-model="podcast.album_override" type="checkbox" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="podcast_album_override"><?php echo _("Overwrite episode album names"); ?></label> <span class='album_names help_icon'></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="podcast-metadata-row" >
|
||||
<div></div>
|
||||
<div>
|
||||
<button ng-click="createSmartblock()" ng-disabled="!podcast.album_override" class="btn" type="button" name="smartblock">
|
||||
<?php echo _("Generate Smartblock and Playlist for Podcast") ?>
|
||||
</button>
|
||||
<div class='pc-sb-success success' style='display:none'></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -41,6 +54,6 @@
|
|||
<?php echo _("Save") ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class='success' style='display:none'></span></div>
|
||||
<div class='success' style='display:none'></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue