CC-6079 - merge and remove underscore files

This commit is contained in:
Duncan Sommerville 2015-08-18 15:23:42 -04:00
parent 5ab0850d9a
commit 3f25ab2647
38 changed files with 2131 additions and 9600 deletions

View file

@ -16,7 +16,6 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('error')) ->add(new Zend_Acl_Resource('error'))
->add(new Zend_Acl_Resource('login')) ->add(new Zend_Acl_Resource('login'))
->add(new Zend_Acl_Resource('whmcs-login')) ->add(new Zend_Acl_Resource('whmcs-login'))
->add(new Zend_Acl_Resource('new-playlist'))
->add(new Zend_Acl_Resource('playlist')) ->add(new Zend_Acl_Resource('playlist'))
->add(new Zend_Acl_Resource('plupload')) ->add(new Zend_Acl_Resource('plupload'))
->add(new Zend_Acl_Resource('schedule')) ->add(new Zend_Acl_Resource('schedule'))
@ -25,13 +24,11 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('dashboard')) ->add(new Zend_Acl_Resource('dashboard'))
->add(new Zend_Acl_Resource('preference')) ->add(new Zend_Acl_Resource('preference'))
->add(new Zend_Acl_Resource('showbuilder')) ->add(new Zend_Acl_Resource('showbuilder'))
->add(new Zend_Acl_Resource('show-builder'))
->add(new Zend_Acl_Resource('playouthistory')) ->add(new Zend_Acl_Resource('playouthistory'))
->add(new Zend_Acl_Resource('playouthistorytemplate')) ->add(new Zend_Acl_Resource('playouthistorytemplate'))
->add(new Zend_Acl_Resource('listenerstat')) ->add(new Zend_Acl_Resource('listenerstat'))
->add(new Zend_Acl_Resource('usersettings')) ->add(new Zend_Acl_Resource('usersettings'))
->add(new Zend_Acl_Resource('audiopreview')) ->add(new Zend_Acl_Resource('audiopreview'))
->add(new Zend_Acl_Resource('new-webstream'))
->add(new Zend_Acl_Resource('webstream')) ->add(new Zend_Acl_Resource('webstream'))
->add(new Zend_Acl_Resource('locale')) ->add(new Zend_Acl_Resource('locale'))
->add(new Zend_Acl_Resource('upgrade')) ->add(new Zend_Acl_Resource('upgrade'))
@ -53,12 +50,10 @@ $ccAcl->allow('G', 'index')
->allow('G', 'error') ->allow('G', 'error')
->allow('G', 'user', 'edit-user') ->allow('G', 'user', 'edit-user')
->allow('G', 'showbuilder') ->allow('G', 'showbuilder')
->allow('G', 'show-builder')
->allow('G', 'api') ->allow('G', 'api')
->allow('G', 'schedule') ->allow('G', 'schedule')
->allow('G', 'dashboard') ->allow('G', 'dashboard')
->allow('G', 'audiopreview') ->allow('G', 'audiopreview')
->allow('G', 'new-webstream')
->allow('G', 'webstream') ->allow('G', 'webstream')
->allow('G', 'locale') ->allow('G', 'locale')
->allow('G', 'upgrade') ->allow('G', 'upgrade')
@ -74,7 +69,6 @@ $ccAcl->allow('G', 'index')
->allow('H', 'usersettings') ->allow('H', 'usersettings')
->allow('H', 'plupload') ->allow('H', 'plupload')
->allow('H', 'library') ->allow('H', 'library')
->allow('H', 'new-playlist')
->allow('H', 'playlist') ->allow('H', 'playlist')
->allow('H', 'playouthistory') ->allow('H', 'playouthistory')
->allow('A', 'playouthistorytemplate') ->allow('A', 'playouthistorytemplate')

View file

@ -1,648 +0,0 @@
<?php
class NewPlaylistController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('add-items', 'json')
->addActionContext('move-items', 'json')
->addActionContext('delete-items', 'json')
->addActionContext('set-fade', 'json')
->addActionContext('set-crossfade', 'json')
->addActionContext('set-cue', 'json')
->addActionContext('new', 'json')
->addActionContext('edit', 'json')
->addActionContext('delete', 'json')
->addActionContext('close-playlist', 'json')
->addActionContext('play', 'json')
->addActionContext('set-playlist-fades', 'json')
->addActionContext('get-playlist-fades', 'json')
->addActionContext('set-playlist-name', 'json')
->addActionContext('set-playlist-description', 'json')
->addActionContext('playlist-preview', 'json')
->addActionContext('get-playlist', 'json')
->addActionContext('save', 'json')
->addActionContext('smart-block-generate', 'json')
->addActionContext('smart-block-shuffle', 'json')
->addActionContext('get-block-info', 'json')
->addActionContext('shuffle', 'json')
->addActionContext('empty-content', 'json')
->initContext();
//This controller writes to the session all over the place, so we're going to reopen it for writing here.
session_start(); //Reopen the session for writing
}
private function getPlaylist($p_type)
{
$obj = null;
$objInfo = Application_Model_Library::getObjInfo($p_type);
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
if (isset($obj_sess->id)) {
$obj = new $objInfo['className']($obj_sess->id);
$modified = $this->_getParam('modified', null);
if ($obj->getLastModified("U") !== $modified) {
$this->createFullResponse($obj);
throw new PlaylistOutDatedException(sprintf(_("You are viewing an older version of %s"), $obj->getName()));
}
}
return $obj;
}
private function createUpdateResponse($obj)
{
$formatter = new LengthFormatter($obj->getLength());
$this->view->length = $formatter->format();
$this->view->obj = $obj;
$this->view->contents = $obj->getContents();
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $obj->getName();
$this->view->description = $obj->getDescription();
$this->view->modified = $obj->getLastModified("U");
unset($this->view->obj);
}
private function createFullResponse($obj = null, $isJson = false,
$formIsValid = false)
{
$isBlock = false;
$viewPath = 'playlist/_playlist.phtml';
if ($obj instanceof Application_Model_Block) {
$isBlock = true;
$viewPath = 'playlist/_smart-block.phtml';
}
if (isset($obj)) {
$formatter = new LengthFormatter($obj->getLength());
$this->view->length = $formatter->format();
if ($isBlock) {
$form = new Application_Form_SmartBlockCriteriaNew();
$form->removeDecorator('DtDdWrapper');
$form->startForm($obj->getId(), $formIsValid);
$this->view->form = $form;
$this->view->obj = $obj;
$this->view->type = "sb";
$this->view->id = $obj->getId();
if ($isJson) {
return $this->view->render($viewPath);
} else {
$this->view->html = $this->view->render($viewPath);
}
} else {
$this->view->obj = $obj;
$this->view->type = "pl";
$this->view->id = $obj->getId();
if ($isJson) {
return $this->view->html = $this->view->render($viewPath);
} else {
$this->view->html = $this->view->render($viewPath);
}
unset($this->view->obj);
}
} else {
if ($isJson) {
return $this->view->render($viewPath);
} else {
$this->view->html = $this->view->render($viewPath);
}
}
}
private function playlistOutdated($e)
{
$this->view->error = $e->getMessage();
}
private function blockDynamic($obj)
{
$this->view->error = _("You cannot add tracks to dynamic blocks.");
$this->createFullResponse($obj);
}
private function playlistNotFound($p_type, $p_isJson = false)
{
$p_type = ucfirst($p_type);
$this->view->error = sprintf(_("%s not found"), $p_type);
Logging::info("{$p_type} not found");
Application_Model_Library::changePlaylist(null, $p_type);
if (!$p_isJson) {
$this->createFullResponse(null);
} else {
$this->_helper->json->sendJson(array("error"=>$this->view->error, "result"=>1, "html"=>$this->createFullResponse(null, $p_isJson)));
}
}
private function playlistNoPermission($p_type)
{
$this->view->error = sprintf(_("You don't have permission to delete selected %s(s)."), $p_type);
$this->changePlaylist(null, $p_type);
$this->createFullResponse(null);
}
private function playlistUnknownError($e)
{
$this->view->error = _("Something went wrong.");
Logging::info($e->getMessage());
}
private function wrongTypeToBlock($obj)
{
$this->view->error = _("You can only add tracks to smart block.");
$this->createFullResponse($obj);
}
private function wrongTypeToPlaylist($obj)
{
$this->view->error = _("You can only add tracks, smart blocks, and webstreams to playlists.");
$this->createFullResponse($obj);
}
public function newAction()
{
//$pl_sess = $this->pl_sess;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$type = $this->_getParam('type');
$objInfo = Application_Model_Library::getObjInfo($type);
$name = _('Untitled Playlist');
if ($type == 'block') {
$name = _('Untitled Smart Block');
}
$obj = new $objInfo['className']();
$obj->setName($name);
$obj->setMetadata('dc:creator', $userInfo->id);
Application_Model_Library::changePlaylist($obj->getId(), $type);
$this->createFullResponse($obj);
}
public function editAction()
{
$id = $this->_getParam('id', null);
$type = $this->_getParam('type');
$objInfo = Application_Model_Library::getObjInfo($type);
Logging::info("editing {$type} {$id}");
// if (!is_null($id)) {
Application_Model_Library::changePlaylist($id, $type);
// }
try {
$obj = new $objInfo['className']($id);
$this->createFullResponse($obj);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function deleteAction()
{
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$type = $this->_getParam('type');
$obj = null;
$objInfo = Application_Model_Library::getObjInfo($type);
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$obj_sess = new Zend_Session_Namespace(
UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
try {
Logging::info("Currently active {$type} {$obj_sess->id}");
if (in_array($obj_sess->id, $ids)) {
Logging::info("Deleting currently active {$type}");
Application_Model_Library::changePlaylist(null, $type);
} else {
Logging::info("Not deleting currently active {$type}");
$obj = new $objInfo['className']($obj_sess->id);
}
if (strcmp($objInfo['className'], 'Application_Model_Playlist')==0) {
Application_Model_Playlist::deletePlaylists($ids, $userInfo->id);
} else {
Application_Model_Block::deleteBlocks($ids, $userInfo->id);
}
$this->createFullResponse($obj);
} catch (PlaylistNoPermissionException $e) {
$this->playlistNoPermission($type);
} catch (BlockNoPermissionException $e) {
$this->playlistNoPermission($type);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function closePlaylistAction() {
$type = $this->_getParam('type');
$obj = null;
Application_Model_Library::changePlaylist($obj, $type);
$this->createFullResponse($obj);
}
public function addItemsAction()
{
$ids = $this->_getParam('aItems', array());
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
// this is the obj type of destination
$obj_type = $this->_getParam('obj_type');
try {
$obj = $this->getPlaylist($obj_type);
if ($obj_type == 'playlist') {
foreach ($ids as $id) {
if (is_array($id) && isset($id[1])) {
if ($id[1] == 'playlist') {
throw new WrongTypeToPlaylistException;
}
}
}
$obj->addAudioClips($ids, $afterItem, $addType);
} elseif ($obj->isStatic()) {
// if the dest is a block object
//check if any items are playlists
foreach ($ids as $id) {
if (is_array($id) && isset($id[1])) {
if ($id[1] != 'audioclip') {
throw new WrongTypeToBlockException;
}
}
}
$obj->addAudioClips($ids, $afterItem, $addType);
} else {
throw new BlockDynamicException;
}
$this->createUpdateResponse($obj);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($obj_type);
} catch (WrongTypeToBlockException $e) {
$this->wrongTypeToBlock($obj);
} catch (WrongTypeToPlaylistException $e) {
$this->wrongTypeToPlaylist($obj);
} catch (BlockDynamicException $e) {
$this->blockDynamic($obj);
} catch (BlockNotFoundException $e) {
$this->playlistNotFound($obj_type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function moveItemsAction()
{
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$type = $this->_getParam('obj_type');
try {
$obj = $this->getPlaylist($type);
$obj->moveAudioClips($ids, $afterItem);
$this->createUpdateResponse($obj);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function deleteItemsAction()
{
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$modified = $this->_getParam('modified');
$type = $this->_getParam('obj_type');
try {
$obj = $this->getPlaylist($type);
$obj->delAudioClips($ids);
$this->createUpdateResponse($obj);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function emptyContentAction()
{
$type = $this->_getParam('obj_type');
try {
$obj = $this->getPlaylist($type);
if ($type == 'playlist') {
$obj->deleteAllFilesFromPlaylist();
} else {
$obj->deleteAllFilesFromBlock();
}
$this->createUpdateResponse($obj);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function setCueAction()
{
$id = $this->_getParam('id');
$cueIn = $this->_getParam('cueIn', null);
$cueOut = $this->_getParam('cueOut', null);
$type = $this->_getParam('type');
try {
$obj = $this->getPlaylist($type);
$response = $obj->changeClipLength($id, $cueIn, $cueOut);
if (!isset($response["error"])) {
$this->view->response = $response;
$this->createUpdateResponse($obj);
} else {
$this->view->cue_error = $response["error"];
$this->view->code = $response["type"];
}
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function setFadeAction()
{
$id = $this->_getParam('id');
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
$type = $this->_getParam('type');
try {
$obj = $this->getPlaylist($type);
$response = $obj->changeFadeInfo($id, $fadeIn, $fadeOut);
if (!isset($response["error"])) {
$this->createUpdateResponse($obj);
$this->view->response = $response;
} else {
$this->view->fade_error = $response["error"];
}
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function setCrossfadeAction()
{
$id1 = $this->_getParam('id1', null);
$id2 = $this->_getParam('id2', null);
$type = $this->_getParam('type');
$fadeIn = $this->_getParam('fadeIn', 0);
$fadeOut = $this->_getParam('fadeOut', 0);
$offset = $this->_getParam('offset', 0);
try {
$obj = $this->getPlaylist($type);
$response = $obj->createCrossfade($id1, $fadeOut, $id2, $fadeIn, $offset);
if (!isset($response["error"])) {
$this->createUpdateResponse($obj);
} else {
$this->view->error = $response["error"];
}
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function getPlaylistFadesAction()
{
$type = $this->_getParam('type');
try {
$obj = $this->getPlaylist($type);
$fades = $obj->getFadeInfo(0);
$this->view->fadeIn = $fades[0];
$fades = $obj->getFadeInfo($obj->getSize()-1);
$this->view->fadeOut = $fades[1];
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
/**
* The playlist fades are stored in the elements themselves.
* The fade in is set to the first elements fade in and
* the fade out is set to the last elements fade out.
**/
public function setPlaylistFadesAction()
{
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
$type = $this->_getParam('type');
try {
$obj = $this->getPlaylist($type);
$obj->setfades($fadeIn, $fadeOut);
$this->view->modified = $obj->getLastModified("U");
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function setPlaylistNameDescAction()
{
$name = $this->_getParam('name', _('Unknown Playlist'));
$description = $this->_getParam('description', "");
$type = $this->_getParam('type');
try {
$obj = $this->getPlaylist($type);
$obj->setName(trim($name));
$obj->setDescription($description);
$this->view->description = $description;
$this->view->playlistName = $name;
$this->view->modified = $obj->getLastModified("U");
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($type, true);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function saveAction()
{
$request = $this->getRequest();
$params = $request->getPost();
$result = array();
if ($params['type'] == 'block') {
try {
$bl = new Application_Model_Block($params['obj_id']);
} catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true);
}
$form = new Application_Form_SmartBlockCriteriaNew();
$form->startForm($params['obj_id']);
if ($form->isValid($params)) {
$this->setPlaylistNameDescAction();
$bl->saveSmartBlockCriteria($params['data']);
$result['html'] = $this->createFullResponse($bl, true, true);
$result['result'] = 0;
} else {
$this->view->form = $form;
$this->view->unsavedName = $params['name'];
$this->view->unsavedDesc = $params['description'];
$viewPath = 'playlist/_smart-block.phtml';
$this->view->obj = $bl;
$this->view->id = $bl->getId();
$result['html'] = $this->view->render($viewPath);
$result['result'] = 1;
}
$result['type'] = "sb";
$result['id'] = $bl->getId();
$result["modified"] = $bl->getLastModified("U");
} else if ($params['type'] == 'playlist') {
$this->setPlaylistNameDescAction();
$result["modified"] = $this->view->modified;
}
$this->_helper->json->sendJson($result);
}
public function smartBlockGenerateAction()
{
$request = $this->getRequest();
$params = $request->getPost();
//make sure block exists
try {
$bl = new Application_Model_Block($params['obj_id']);
$form = new Application_Form_SmartBlockCriteriaNew();
$form->startForm($params['obj_id']);
if ($form->isValid($params)) {
$result = $bl->generateSmartBlock($params['data']);
$this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)));
} else {
$this->view->obj = $bl;
$this->view->id = $bl->getId();
$this->view->form = $form;
$viewPath = 'playlist/_smart-block.phtml';
$result['html'] = $this->view->render($viewPath);
$result['result'] = 1;
$this->_helper->json->sendJson($result);
}
} catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true);
} catch (Exception $e) {
Logging::info($e);
$this->playlistUnknownError($e);
}
}
public function smartBlockShuffleAction()
{
$request = $this->getRequest();
$params = $request->getPost();
try {
$bl = new Application_Model_Block($params['obj_id']);
$result = $bl->shuffleSmartBlock();
if ($result['result'] == 0) {
$this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($bl, true)));
} else {
$this->_helper->json->sendJson($result);
}
} catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function shuffleAction()
{
$request = $this->getRequest();
$params = $request->getPost();
try {
$pl = new Application_Model_Playlist($params['obj_id']);
$result = $pl->shuffle();
if ($result['result'] == 0) {
$this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($pl, true)));
} else {
$this->_helper->json->sendJson($result);
}
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound('block', true);
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
}
public function getBlockInfoAction()
{
$request = $this->getRequest();
$params = $request->getPost();
$bl = new Application_Model_Block($params['id']);
if ($bl->isStatic()) {
$out = $bl->getContents();
$out['isStatic'] = true;
} else {
$out = $bl->getCriteria();
$out['isStatic'] = false;
}
$this->_helper->json->sendJson($out);
}
}
class WrongTypeToBlockException extends Exception {}
class WrongTypeToPlaylistException extends Exception {}
class BlockDynamicException extends Exception {}

View file

@ -1,150 +0,0 @@
<?php
class NewWebstreamController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('new', 'json')
->addActionContext('save', 'json')
->addActionContext('edit', 'json')
->addActionContext('delete', 'json')
->initContext();
}
public function newAction()
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
if (!$this->isAuthorized(-1)) {
// TODO: this header call does not actually print any error message
header("Status: 401 Not Authorized");
return;
}
$webstream = new CcWebstream();
//we're not saving this primary key in the DB so it's OK to be -1
$webstream->setDbId(-1);
$webstream->setDbName(_("Untitled Webstream"));
$webstream->setDbDescription("");
$webstream->setDbUrl("http://");
$webstream->setDbLength("00:30:00");
$webstream->setDbName(_("Untitled Webstream"));
$webstream->setDbCreatorId($userInfo->id);
$webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC')));
$webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC')));
//clear the session in case an old playlist was open: CC-4196
Application_Model_Library::changePlaylist(null, null);
$this->view->obj = new Application_Model_Webstream($webstream);
$this->view->action = "new";
$this->view->html = $this->view->render('webstream/_webstream.phtml');
}
public function editAction()
{
$request = $this->getRequest();
$id = $request->getParam("id");
if (is_null($id)) {
throw new Exception("Missing parameter 'id'");
}
$webstream = CcWebstreamQuery::create()->findPK($id);
if ($webstream) {
Application_Model_Library::changePlaylist($id, "stream");
}
$this->view->obj = new Application_Model_Webstream($webstream);
$this->view->action = "edit";
$this->view->html = $this->view->render('webstream/_webstream.phtml');
}
public function deleteAction()
{
$request = $this->getRequest();
$id = $request->getParam("ids");
if (!$this->isAuthorized($id)) {
header("Status: 401 Not Authorized");
return;
}
$type = "stream";
Application_Model_Library::changePlaylist(null, $type);
$webstream = CcWebstreamQuery::create()->findPK($id)->delete();
$this->view->obj = null;
$this->view->action = "delete";
$this->view->html = $this->view->render('webstream/_webstream.phtml');
}
/*TODO : make a user object be passed a parameter into this function so
that it does not have to be fetched multiple times.*/
public function isAuthorized($webstream_id)
{
$user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
return true;
}
if ($user->isHost()) {
// not creating a webstream
if ($webstream_id != -1) {
$webstream = CcWebstreamQuery::create()->findPK($webstream_id);
/*we are updating a playlist. Ensure that if the user is a
host/dj, that he has the correct permission.*/
$user = Application_Model_User::getCurrentUser();
//only allow when webstream belongs to the DJ
return $webstream->getDbCreatorId() == $user->getId();
}
/*we are creating a new stream. Don't need to check whether the
DJ/Host owns the stream*/
return true;
} else {
Logging::info( $user );
}
return false;
}
public function saveAction()
{
$request = $this->getRequest();
$id = $request->getParam("id");
$parameters = array();
foreach (array('id','length','name','description','url') as $p) {
$parameters[$p] = trim($request->getParam($p));
}
if (!$this->isAuthorized($id)) {
header("Status: 401 Not Authorized");
return;
}
list($analysis, $mime, $mediaUrl, $di) = Application_Model_Webstream::analyzeFormData($parameters);
try {
if (Application_Model_Webstream::isValid($analysis)) {
$streamId = Application_Model_Webstream::save($parameters, $mime, $mediaUrl, $di);
Application_Model_Library::changePlaylist($streamId, "stream");
$this->view->statusMessage = "<div class='success'>"._("Webstream saved.")."</div>";
$this->view->streamId = $streamId;
$this->view->length = $di->format("%Hh %Im");
} else {
throw new Exception("isValid returned false");
}
} catch (Exception $e) {
Logging::debug($e->getMessage());
$this->view->statusMessage = "<div class='errors'>"._("Invalid form values.")."</div>";
$this->view->streamId = -1;
$this->view->analysis = $analysis;
}
}
}

View file

@ -41,6 +41,7 @@ class PlaylistController extends Zend_Controller_Action
$objInfo = Application_Model_Library::getObjInfo($p_type); $objInfo = Application_Model_Library::getObjInfo($p_type);
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
if (isset($obj_sess->id)) { if (isset($obj_sess->id)) {
$obj = new $objInfo['className']($obj_sess->id); $obj = new $objInfo['className']($obj_sess->id);
@ -89,6 +90,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->form = $form; $this->view->form = $form;
$this->view->obj = $obj; $this->view->obj = $obj;
$this->view->type = "sb";
$this->view->id = $obj->getId(); $this->view->id = $obj->getId();
if ($isJson) { if ($isJson) {
@ -98,6 +100,7 @@ class PlaylistController extends Zend_Controller_Action
} }
} else { } else {
$this->view->obj = $obj; $this->view->obj = $obj;
$this->view->type = "pl";
$this->view->id = $obj->getId(); $this->view->id = $obj->getId();
if ($isJson) { if ($isJson) {
return $this->view->html = $this->view->render($viewPath); return $this->view->html = $this->view->render($viewPath);
@ -194,9 +197,9 @@ class PlaylistController extends Zend_Controller_Action
$objInfo = Application_Model_Library::getObjInfo($type); $objInfo = Application_Model_Library::getObjInfo($type);
Logging::info("editing {$type} {$id}"); Logging::info("editing {$type} {$id}");
if (!is_null($id)) { // if (!is_null($id)) {
Application_Model_Library::changePlaylist($id, $type); Application_Model_Library::changePlaylist($id, $type);
} // }
try { try {
$obj = new $objInfo['className']($id); $obj = new $objInfo['className']($id);
@ -519,7 +522,7 @@ class PlaylistController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
$result = array(); $result = array();
if ($params['type'] == 'block') { if ($params['type'] == 'block') {
try { try {
$bl = new Application_Model_Block($params['obj_id']); $bl = new Application_Model_Block($params['obj_id']);
@ -534,20 +537,23 @@ class PlaylistController extends Zend_Controller_Action
$result['html'] = $this->createFullResponse($bl, true, true); $result['html'] = $this->createFullResponse($bl, true, true);
$result['result'] = 0; $result['result'] = 0;
} else { } else {
$this->view->obj = $bl;
$this->view->id = $bl->getId();
$this->view->form = $form; $this->view->form = $form;
$this->view->unsavedName = $params['name']; $this->view->unsavedName = $params['name'];
$this->view->unsavedDesc = $params['description']; $this->view->unsavedDesc = $params['description'];
$viewPath = 'playlist/smart-block.phtml'; $viewPath = 'playlist/smart-block.phtml';
$this->view->obj = $bl;
$this->view->id = $bl->getId();
$result['html'] = $this->view->render($viewPath); $result['html'] = $this->view->render($viewPath);
$result['result'] = 1; $result['result'] = 1;
} }
$result['type'] = "sb";
$result['id'] = $bl->getId();
$result["modified"] = $bl->getLastModified("U");
} else if ($params['type'] == 'playlist') { } else if ($params['type'] == 'playlist') {
$this->setPlaylistNameDescAction(); $this->setPlaylistNameDescAction();
$result["modified"] = $this->view->modified;
} }
$result["modified"] = $this->view->modified;
$this->_helper->json->sendJson($result); $this->_helper->json->sendJson($result);
} }

View file

@ -1,86 +0,0 @@
<?php
class ShowBuilderController extends Zend_Controller_Action {
public function init() {
}
public function indexAction() {
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$userType = Application_Model_User::GetCurrentUser()->getType();
//$this->_helper->layout->setLayout("showbuilder");
$this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );");
$this->view->headScript()->appendScript(Application_Common_GoogleAnalytics::generateGoogleTagManagerDataLayerJavaScript());
$this->view->headLink()->appendStylesheet($baseUrl . 'css/redmond/jquery-ui-1.8.8.custom.css?' . $CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.colReorder.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colReorder.min.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/_library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/_library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
// PLUPLOAD
$this->view->headScript()->appendFile($baseUrl.'js/libs/dropzone.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/_main_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
// MEDIA BUILDER
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/_spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playlist/_smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/_showbuilder.css?'.$CC_CONFIG['airtime_version']);
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
$csrf_element = new Zend_Form_Element_Hidden('csrf');
$csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
$this->view->csrf = $csrf_element;
$request = $this->getRequest();
//populate date range form for show builder.
$now = time();
$from = $request->getParam("from", $now);
$to = $request->getParam("to", $now + (3*60*60));
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
$form = new Application_Form_ShowBuilderNew();
$form->populate(array(
'sb_date_start' => $start->format("Y-m-d"),
'sb_time_start' => $start->format("H:i"),
'sb_date_end' => $end->format("Y-m-d"),
'sb_time_end' => $end->format("H:i")
));
$this->view->sb_form = $form;
}
}

View file

@ -20,32 +20,25 @@ class ShowbuilderController extends Zend_Controller_Action
public function indexAction() public function indexAction()
{ {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$request = $this->getRequest();
$response = $this->getResponse();
//Enable AJAX requests from www.airtime.pro because the autologin during the seamless sign-up follows
//a redirect here.
CORSHelper::enableATProCrossOriginRequests($request, $response);
$baseUrl = Application_Common_OsPath::getBaseDir(); $baseUrl = Application_Common_OsPath::getBaseDir();
$userType = Application_Model_User::GetCurrentUser()->getType();
//$this->_helper->layout->setLayout("showbuilder");
$user = Application_Model_User::GetCurrentUser();
$userType = $user->getType();
$this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );"); $this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );");
$this->view->headScript()->appendScript(Application_Common_GoogleAnalytics::generateGoogleTagManagerDataLayerJavaScript()); $this->view->headScript()->appendScript(Application_Common_GoogleAnalytics::generateGoogleTagManagerDataLayerJavaScript());
$this->view->headLink()->appendStylesheet($baseUrl . 'css/redmond/jquery-ui-1.8.8.custom.css?' . $CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.colReorder.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/js-timezone-detect/jstz-1.0.4.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -54,50 +47,32 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colReorder.min.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//Show the timezone and language setup popup, if needed. // PLUPLOAD
$this->checkAndShowSetupPopup($request); $this->view->headScript()->appendFile($baseUrl.'js/libs/dropzone.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
//determine whether to remove/hide/display the library. $this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$showLib = false; $this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
if (!$user->isGuest()) { $this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/main_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$disableLib = false;
$data = Application_Model_Preference::getNowPlayingScreenSettings(); // MEDIA BUILDER
if (!is_null($data)) { $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
if ($data["library"] == "true") { $this->view->headScript()->appendFile($baseUrl.'js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$showLib = true; $this->view->headLink()->appendStylesheet($baseUrl.'css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
}
}
} else {
$disableLib = true;
}
$this->view->disableLib = $disableLib;
$this->view->showLib = $showLib;
//only include library things on the page if the user can see it. $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
if (!$disableLib) { $this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'css/_showbuilder.css?'.$CC_CONFIG['airtime_version']); // TODO
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$data = Application_Model_Preference::getCurrentLibraryTableSetting(); $csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
if (!is_null($data)) { $csrf_element = new Zend_Form_Element_Hidden('csrf');
$libraryTable = json_encode($data); $csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );"); $this->view->csrf = $csrf_element;
} else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );");
}
}
$data = Application_Model_Preference::getTimelineDatatableSetting();
if (!is_null($data)) {
$timelineTable = json_encode($data);
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );");
} else {
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', '' );");
}
$request = $this->getRequest();
//populate date range form for show builder. //populate date range form for show builder.
$now = time(); $now = time();
$from = $request->getParam("from", $now); $from = $request->getParam("from", $now);
@ -113,20 +88,13 @@ class ShowbuilderController extends Zend_Controller_Action
$form = new Application_Form_ShowBuilder(); $form = new Application_Form_ShowBuilder();
$form->populate(array( $form->populate(array(
'sb_date_start' => $start->format("Y-m-d"), 'sb_date_start' => $start->format("Y-m-d"),
'sb_time_start' => $start->format("H:i"), 'sb_time_start' => $start->format("H:i"),
'sb_date_end' => $end->format("Y-m-d"), 'sb_date_end' => $end->format("Y-m-d"),
'sb_time_end' => $end->format("H:i") 'sb_time_end' => $end->format("H:i")
)); ));
$this->view->sb_form = $form; $this->view->sb_form = $form;
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/main_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
} }
/** Check if we need to show the timezone/language setup popup and display it. (eg. on first run) */ /** Check if we need to show the timezone/language setup popup and display it. (eg. on first run) */
@ -192,7 +160,7 @@ class ShowbuilderController extends Zend_Controller_Action
} }
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone()); $displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = $instance->getDbStarts(null); $start = $instance->getDbStarts(null);
$start->setTimezone($displayTimeZone); $start->setTimezone($displayTimeZone);
$end = $instance->getDbEnds(null); $end = $instance->getDbEnds(null);
@ -208,7 +176,7 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml'); $this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
} }
public function checkBuilderFeedAction() public function checkBuilderFeedAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
@ -231,7 +199,7 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction() public function builderFeedAction()
{ {
$current_time = time(); $current_time = time();
$request = $this->getRequest(); $request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0)); $show_filter = intval($request->getParam("showFilter", 0));
$show_instance_filter = intval($request->getParam("showInstanceFilter", 0)); $show_instance_filter = intval($request->getParam("showInstanceFilter", 0));
@ -253,10 +221,10 @@ class ShowbuilderController extends Zend_Controller_Action
public function scheduleAddAction() public function scheduleAddAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$mediaItems = $request->getParam("mediaIds", array()); $mediaItems = $request->getParam("mediaIds", array());
$scheduledItems = $request->getParam("schedIds", array()); $scheduledItems = $request->getParam("schedIds", array());
$log_vars = array(); $log_vars = array();
$log_vars["url"] = $_SERVER['HTTP_HOST']; $log_vars["url"] = $_SERVER['HTTP_HOST'];
$log_vars["action"] = "showbuilder/schedule-add"; $log_vars["action"] = "showbuilder/schedule-add";
@ -264,7 +232,7 @@ class ShowbuilderController extends Zend_Controller_Action
$log_vars["params"]["media_items"] = $mediaItems; $log_vars["params"]["media_items"] = $mediaItems;
$log_vars["params"]["scheduled_items"] = $scheduledItems; $log_vars["params"]["scheduled_items"] = $scheduledItems;
Logging::info($log_vars); Logging::info($log_vars);
try { try {
$scheduler = new Application_Model_Scheduler(); $scheduler = new Application_Model_Scheduler();
$scheduler->scheduleAfter($scheduledItems, $mediaItems); $scheduler->scheduleAfter($scheduledItems, $mediaItems);
@ -281,7 +249,7 @@ class ShowbuilderController extends Zend_Controller_Action
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$items = $request->getParam("items", array()); $items = $request->getParam("items", array());
$log_vars = array(); $log_vars = array();
$log_vars["url"] = $_SERVER['HTTP_HOST']; $log_vars["url"] = $_SERVER['HTTP_HOST'];
$log_vars["action"] = "showbuilder/schedule-remove"; $log_vars["action"] = "showbuilder/schedule-remove";
@ -331,8 +299,7 @@ class ShowbuilderController extends Zend_Controller_Action
public function scheduleReorderAction() public function scheduleReorderAction()
{ {
throw new Exception("this controller is/was a no-op please fix your throw new Exception("this controller is/was a no-op please fix your code");
code");
} }
} }

View file

@ -14,7 +14,6 @@ class WebstreamController extends Zend_Controller_Action
public function newAction() public function newAction()
{ {
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
if (!$this->isAuthorized(-1)) { if (!$this->isAuthorized(-1)) {
// TODO: this header call does not actually print any error message // TODO: this header call does not actually print any error message

View file

@ -69,7 +69,7 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
// add a select to choose a show. // add a select to choose a show.
$showSelect = new Zend_Form_Element_Select("sb_show_filter"); $showSelect = new Zend_Form_Element_Select("sb_show_filter");
$showSelect->setLabel(_("Show:")); $showSelect->setLabel(_("Filter by Show"));
$showSelect->setMultiOptions($this->getShowNames()); $showSelect->setMultiOptions($this->getShowNames());
$showSelect->setValue(null); $showSelect->setValue(null);
$showSelect->setDecorators(array('ViewHelper')); $showSelect->setDecorators(array('ViewHelper'));
@ -85,7 +85,7 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
private function getShowNames() private function getShowNames()
{ {
$showNames = array("0" => "-------------------------"); $showNames = array("0" => _("Filter by Show"));
$shows = CcShowQuery::create() $shows = CcShowQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)

View file

@ -1,103 +0,0 @@
<?php
class Application_Form_ShowBuilderNew extends Zend_Form_SubForm
{
public function init()
{
$user = Application_Model_User::getCurrentUser();
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/show-builder.phtml'))
));
// Add start date element
$startDate = new Zend_Form_Element_Text('sb_date_start');
$startDate->class = 'input_text';
$startDate->setRequired(true)
->setLabel(_('Date Start:'))
->setValue(date("Y-m-d"))
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))))
->setDecorators(array('ViewHelper'));
$startDate->setAttrib('alt', 'date');
$this->addElement($startDate);
// Add start time element
$startTime = new Zend_Form_Element_Text('sb_time_start');
$startTime->class = 'input_text';
$startTime->setRequired(true)
->setValue('00:00')
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('HH:mm')),
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
$startTime->setAttrib('alt', 'time');
$this->addElement($startTime);
// Add end date element
$endDate = new Zend_Form_Element_Text('sb_date_end');
$endDate->class = 'input_text';
$endDate->setRequired(true)
->setLabel(_('Date End:'))
->setValue(date("Y-m-d"))
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))))
->setDecorators(array('ViewHelper'));
$endDate->setAttrib('alt', 'date');
$this->addElement($endDate);
// Add end time element
$endTime = new Zend_Form_Element_Text('sb_time_end');
$endTime->class = 'input_text';
$endTime->setRequired(true)
->setValue('01:00')
->setFilters(array('StringTrim'))
->setValidators(array(
'NotEmpty',
array('date', false, array('HH:mm')),
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
$endTime->setAttrib('alt', 'time');
$this->addElement($endTime);
// add a select to choose a show.
$showSelect = new Zend_Form_Element_Select("sb_show_filter");
$showSelect->setLabel(_("Filter by Show"));
$showSelect->setMultiOptions($this->getShowNames());
$showSelect->setValue(null);
$showSelect->setDecorators(array('ViewHelper'));
$this->addElement($showSelect);
if ($user->getType() === 'H') {
$myShows = new Zend_Form_Element_Checkbox('sb_my_shows');
$myShows->setLabel(_('All My Shows:'))
->setDecorators(array('ViewHelper'));
$this->addElement($myShows);
}
}
private function getShowNames()
{
$showNames = array("0" => _("Filter by Show"));
$shows = CcShowQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->orderByDbName()
->find();
foreach ($shows as $show) {
$showNames[$show->getDbId()] = $show->getDbName();
}
return $showNames;
}
}

View file

@ -341,7 +341,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
} }
$generate = new Zend_Form_Element_Button('generate_button'); $generate = new Zend_Form_Element_Button('generate_button');
$generate->setAttrib('class', 'btn btn-small'); $generate->setAttrib('class', 'sp-button btn');
$generate->setAttrib('title', _('Generate playlist content and save criteria')); $generate->setAttrib('title', _('Generate playlist content and save criteria'));
$generate->setIgnore(true); $generate->setIgnore(true);
$generate->setLabel(_('Generate')); $generate->setLabel(_('Generate'));
@ -349,7 +349,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$this->addElement($generate); $this->addElement($generate);
$shuffle = new Zend_Form_Element_Button('shuffle_button'); $shuffle = new Zend_Form_Element_Button('shuffle_button');
$shuffle->setAttrib('class', 'btn btn-small'); $shuffle->setAttrib('class', 'sp-button btn');
$shuffle->setAttrib('title', _('Shuffle playlist content')); $shuffle->setAttrib('title', _('Shuffle playlist content'));
$shuffle->setIgnore(true); $shuffle->setIgnore(true);
$shuffle->setLabel(_('Shuffle')); $shuffle->setLabel(_('Shuffle'));

View file

@ -1,615 +0,0 @@
<?php
class Application_Form_SmartBlockCriteriaNew extends Zend_Form_SubForm
{
private $criteriaOptions;
private $stringCriteriaOptions;
private $numericCriteriaOptions;
private $sortOptions;
private $limitOptions;
/* We need to know if the criteria value will be a string
* or numeric value in order to populate the modifier
* select list
*/
private $criteriaTypes = array(
0 => "",
"album_title" => "s",
"bit_rate" => "n",
"bpm" => "n",
"composer" => "s",
"conductor" => "s",
"copyright" => "s",
"cuein" => "n",
"cueout" => "n",
"artist_name" => "s",
"encoded_by" => "s",
"utime" => "n",
"mtime" => "n",
"lptime" => "n",
"genre" => "s",
"isrc_number" => "s",
"label" => "s",
"language" => "s",
"length" => "n",
"mime" => "s",
"mood" => "s",
"owner_id" => "s",
"replay_gain" => "n",
"sample_rate" => "n",
"track_title" => "s",
"track_number" => "n",
"info_url" => "s",
"year" => "n"
);
private function getCriteriaOptions($option = null)
{
if (!isset($this->criteriaOptions)) {
$this->criteriaOptions = array(
0 => _("Select criteria"),
"album_title" => _("Album"),
"bit_rate" => _("Bit Rate (Kbps)"),
"bpm" => _("BPM"),
"composer" => _("Composer"),
"conductor" => _("Conductor"),
"copyright" => _("Copyright"),
"cuein" => _("Cue In"),
"cueout" => _("Cue Out"),
"artist_name" => _("Creator"),
"encoded_by" => _("Encoded By"),
"genre" => _("Genre"),
"isrc_number" => _("ISRC"),
"label" => _("Label"),
"language" => _("Language"),
"mtime" => _("Last Modified"),
"lptime" => _("Last Played"),
"length" => _("Length"),
"mime" => _("Mime"),
"mood" => _("Mood"),
"owner_id" => _("Owner"),
"replay_gain" => _("Replay Gain"),
"sample_rate" => _("Sample Rate (kHz)"),
"track_title" => _("Title"),
"track_number" => _("Track Number"),
"utime" => _("Uploaded"),
"info_url" => _("Website"),
"year" => _("Year")
);
}
if (is_null($option)) return $this->criteriaOptions;
else return $this->criteriaOptions[$option];
}
private function getStringCriteriaOptions()
{
if (!isset($this->stringCriteriaOptions)) {
$this->stringCriteriaOptions = array(
"0" => _("Select modifier"),
"contains" => _("contains"),
"does not contain" => _("does not contain"),
"is" => _("is"),
"is not" => _("is not"),
"starts with" => _("starts with"),
"ends with" => _("ends with")
);
}
return $this->stringCriteriaOptions;
}
private function getNumericCriteriaOptions()
{
if (!isset($this->numericCriteriaOptions)) {
$this->numericCriteriaOptions = array(
"0" => _("Select modifier"),
"is" => _("is"),
"is not" => _("is not"),
"is greater than" => _("is greater than"),
"is less than" => _("is less than"),
"is in the range" => _("is in the range")
);
}
return $this->numericCriteriaOptions;
}
private function getLimitOptions()
{
if (!isset($this->limitOptions)) {
$this->limitOptions = array(
"hours" => _("hours"),
"minutes" => _("minutes"),
"items" => _("items")
);
}
return $this->limitOptions;
}
private function getSortOptions()
{
if (!isset($this->sortOptions)) {
$this->sortOptions = array(
"random" => _("random"),
"newest" => _("newest"),
"oldest" => _("oldest")
);
}
return $this->sortOptions;
}
public function init()
{
}
/*
* converts UTC timestamp citeria into user timezone strings.
*/
private function convertTimestamps(&$criteria)
{
$columns = array("utime", "mtime", "lptime");
foreach ($columns as $column) {
if (isset($criteria[$column])) {
foreach ($criteria[$column] as &$constraint) {
$constraint['value'] =
Application_Common_DateHelper::UTCStringToUserTimezoneString($constraint['value']);
if (isset($constraint['extra'])) {
$constraint['extra'] =
Application_Common_DateHelper::UTCStringToUserTimezoneString($constraint['extra']);
}
}
}
}
}
public function startForm($p_blockId, $p_isValid = false)
{
// load type
$out = CcBlockQuery::create()->findPk($p_blockId);
if ($out->getDbType() == "static") {
$blockType = 0;
} else {
$blockType = 1;
}
$spType = new Zend_Form_Element_Radio('sp_type');
$spType->setLabel(_('Set smart block type:'))
->setDecorators(array('viewHelper'))
->setMultiOptions(array(
'static' => _('Static'),
'dynamic' => _('Dynamic')
))
->setValue($blockType);
$this->addElement($spType);
$bl = new Application_Model_Block($p_blockId);
$storedCrit = $bl->getCriteria();
//need to convert criteria to be displayed in the user's timezone if there's some timestamp type.
self::convertTimestamps($storedCrit["crit"]);
/* $modRoadMap stores the number of same criteria
* Ex: 3 Album titles, and 2 Track titles
* We need to know this so we display the form elements properly
*/
$modRowMap = array();
$openSmartBlockOption = false;
if (!empty($storedCrit)) {
$openSmartBlockOption = true;
}
$criteriaKeys = array();
if (isset($storedCrit["crit"])) {
$criteriaKeys = array_keys($storedCrit["crit"]);
}
$numElements = count($this->getCriteriaOptions());
for ($i = 0; $i < $numElements; $i++) {
$criteriaType = "";
if (isset($criteriaKeys[$i])) {
$critCount = count($storedCrit["crit"][$criteriaKeys[$i]]);
} else {
$critCount = 1;
}
$modRowMap[$i] = $critCount;
/* Loop through all criteria with the same field
* Ex: all criteria for 'Album'
*/
for ($j = 0; $j < $critCount; $j++) {
/****************** CRITERIA ***********/
if ($j > 0) {
$invisible = ' sp-invisible';
} else {
$invisible = '';
}
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j);
$criteria->setAttrib('class', 'input_select sp_input_select'.$invisible)
->setValue('Select criteria')
->setDecorators(array('viewHelper'))
->setMultiOptions($this->getCriteriaOptions());
if ($i != 0 && !isset($criteriaKeys[$i])) {
$criteria->setAttrib('disabled', 'disabled');
}
if (isset($criteriaKeys[$i])) {
$criteriaType = $this->criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]];
$criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
}
$this->addElement($criteria);
/****************** MODIFIER ***********/
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j);
$criteriaModifers->setValue('Select modifier')
->setAttrib('class', 'input_select sp_input_select')
->setDecorators(array('viewHelper'));
if ($i != 0 && !isset($criteriaKeys[$i])) {
$criteriaModifers->setAttrib('disabled', 'disabled');
}
if (isset($criteriaKeys[$i])) {
if ($criteriaType == "s") {
$criteriaModifers->setMultiOptions($this->getStringCriteriaOptions());
} else {
$criteriaModifers->setMultiOptions($this->getNumericCriteriaOptions());
}
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
} else {
$criteriaModifers->setMultiOptions(array('0' => _('Select modifier')));
}
$this->addElement($criteriaModifers);
/****************** VALUE ***********/
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j);
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
->setDecorators(array('viewHelper'));
if ($i != 0 && !isset($criteriaKeys[$i])) {
$criteriaValue->setAttrib('disabled', 'disabled');
}
if (isset($criteriaKeys[$i])) {
$criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
}
$this->addElement($criteriaValue);
/****************** EXTRA ***********/
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j);
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
->setDecorators(array('viewHelper'));
if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
$criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
} else {
$criteriaExtra->setAttrib('disabled', 'disabled');
}
$this->addElement($criteriaExtra);
}//for
}//for
$repeatTracks = new Zend_Form_Element_Checkbox('sp_repeat_tracks');
$repeatTracks->setDecorators(array('viewHelper'))
->setLabel(_('Allow Repeat Tracks:'));
if (isset($storedCrit["repeat_tracks"])) {
$repeatTracks->setChecked($storedCrit["repeat_tracks"]["value"] == 1?true:false);
}
$this->addElement($repeatTracks);
$sort = new Zend_Form_Element_Select('sp_sort_options');
$sort->setAttrib('class', 'sp_input_select')
->setDecorators(array('viewHelper'))
->setMultiOptions($this->getSortOptions());
if (isset($storedCrit["sort"])) {
$sort->setValue($storedCrit["sort"]["value"]);
}
$this->addElement($sort);
$limit = new Zend_Form_Element_Select('sp_limit_options');
$limit->setAttrib('class', 'sp_input_select')
->setDecorators(array('viewHelper'))
->setMultiOptions($this->getLimitOptions());
if (isset($storedCrit["limit"])) {
$limit->setValue($storedCrit["limit"]["modifier"]);
}
$this->addElement($limit);
$limitValue = new Zend_Form_Element_Text('sp_limit_value');
$limitValue->setAttrib('class', 'sp_input_text_limit')
->setLabel(_('Limit to'))
->setDecorators(array('viewHelper'));
$this->addElement($limitValue);
if (isset($storedCrit["limit"])) {
$limitValue->setValue($storedCrit["limit"]["value"]);
} else {
// setting default to 1 hour
$limitValue->setValue(1);
}
//getting block content candidate count that meets criteria
$bl = new Application_Model_Block($p_blockId);
if ($p_isValid) {
$files = $bl->getListofFilesMeetCriteria();
$showPoolCount = true;
} else {
$files = null;
$showPoolCount = false;
}
$generate = new Zend_Form_Element_Button('generate_button');
$generate->setAttrib('class', 'sp-button btn');
$generate->setAttrib('title', _('Generate playlist content and save criteria'));
$generate->setIgnore(true);
$generate->setLabel(_('Generate'));
$generate->setDecorators(array('viewHelper'));
$this->addElement($generate);
$shuffle = new Zend_Form_Element_Button('shuffle_button');
$shuffle->setAttrib('class', 'sp-button btn');
$shuffle->setAttrib('title', _('Shuffle playlist content'));
$shuffle->setIgnore(true);
$shuffle->setLabel(_('Shuffle'));
$shuffle->setDecorators(array('viewHelper'));
$this->addElement($shuffle);
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/_smart-block-criteria.phtml', "openOption"=> $openSmartBlockOption,
'criteriasLength' => count($this->getCriteriaOptions()), 'poolCount' => $files['count'], 'modRowMap' => $modRowMap,
'showPoolCount' => $showPoolCount))
));
}
public function preValidation($params)
{
$data = Application_Model_Block::organizeSmartPlaylistCriteria($params['data']);
// add elelments that needs to be added
// set multioption for modifier according to criteria_field
$modRowMap = array();
foreach ($data['criteria'] as $critKey=>$d) {
$count = 1;
foreach ($d as $modKey=>$modInfo) {
if ($modKey == 0) {
$eleCrit = $this->getElement("sp_criteria_field_".$critKey."_".$modKey);
$eleCrit->setValue($this->getCriteriaOptions($modInfo['sp_criteria_field']));
$eleCrit->setAttrib("disabled", null);
$eleMod = $this->getElement("sp_criteria_modifier_".$critKey."_".$modKey);
$criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']];
if ($criteriaType == "s") {
$eleMod->setMultiOptions($this->getStringCriteriaOptions());
} elseif ($criteriaType == "n") {
$eleMod->setMultiOptions($this->getNumericCriteriaOptions());
} else {
$eleMod->setMultiOptions(array('0' => _('Select modifier')));
}
$eleMod->setValue($modInfo['sp_criteria_modifier']);
$eleMod->setAttrib("disabled", null);
$eleValue = $this->getElement("sp_criteria_value_".$critKey."_".$modKey);
$eleValue->setValue($modInfo['sp_criteria_value']);
$eleValue->setAttrib("disabled", null);
if (isset($modInfo['sp_criteria_extra'])) {
$eleExtra = $this->getElement("sp_criteria_extra_".$critKey."_".$modKey);
$eleExtra->setValue($modInfo['sp_criteria_extra']);
$eleValue->setAttrib('class', 'input_text sp_extra_input_text');
$eleExtra->setAttrib("disabled", null);
}
} else {
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$critKey."_".$modKey);
$criteria->setAttrib('class', 'input_select sp_input_select sp-invisible')
->setValue('Select criteria')
->setDecorators(array('viewHelper'))
->setMultiOptions($this->getCriteriaOptions());
$criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']];
$criteria->setValue($this->getCriteriaOptions($modInfo['sp_criteria_field']));
$this->addElement($criteria);
/****************** MODIFIER ***********/
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$critKey."_".$modKey);
$criteriaModifers->setValue('Select modifier')
->setAttrib('class', 'input_select sp_input_select')
->setDecorators(array('viewHelper'));
if ($criteriaType == "s") {
$criteriaModifers->setMultiOptions($this->getStringCriteriaOptions());
} elseif ($criteriaType == "n") {
$criteriaModifers->setMultiOptions($this->getNumericCriteriaOptions());
} else {
$criteriaModifers->setMultiOptions(array('0' => _('Select modifier')));
}
$criteriaModifers->setValue($modInfo['sp_criteria_modifier']);
$this->addElement($criteriaModifers);
/****************** VALUE ***********/
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$critKey."_".$modKey);
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
->setDecorators(array('viewHelper'));
$criteriaValue->setValue($modInfo['sp_criteria_value']);
$this->addElement($criteriaValue);
/****************** EXTRA ***********/
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$critKey."_".$modKey);
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
->setDecorators(array('viewHelper'));
if (isset($modInfo['sp_criteria_extra'])) {
$criteriaExtra->setValue($modInfo['sp_criteria_extra']);
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
} else {
$criteriaExtra->setAttrib('disabled', 'disabled');
}
$this->addElement($criteriaExtra);
$count++;
}
}
$modRowMap[$critKey] = $count;
}
$decorator = $this->getDecorator("ViewScript");
$existingModRow = $decorator->getOption("modRowMap");
foreach ($modRowMap as $key=>$v) {
$existingModRow[$key] = $v;
}
$decorator->setOption("modRowMap", $existingModRow);
// reconstruct the params['criteria'] so we can populate the form
$formData = array();
foreach ($params['data'] as $ele) {
$formData[$ele['name']] = $ele['value'];
}
$this->populate($formData);
return $data;
}
public function isValid($params)
{
$isValid = true;
$data = $this->preValidation($params);
$criteria2PeerMap = array(
0 => "Select criteria",
"album_title" => "DbAlbumTitle",
"artist_name" => "DbArtistName",
"bit_rate" => "DbBitRate",
"bpm" => "DbBpm",
"composer" => "DbComposer",
"conductor" => "DbConductor",
"copyright" => "DbCopyright",
"cuein" => "DbCuein",
"cueout" => "DbCueout",
"encoded_by" => "DbEncodedBy",
"utime" => "DbUtime",
"mtime" => "DbMtime",
"lptime" => "DbLPtime",
"genre" => "DbGenre",
"info_url" => "DbInfoUrl",
"isrc_number" => "DbIsrcNumber",
"label" => "DbLabel",
"language" => "DbLanguage",
"length" => "DbLength",
"mime" => "DbMime",
"mood" => "DbMood",
"owner_id" => "DbOwnerId",
"replay_gain" => "DbReplayGain",
"sample_rate" => "DbSampleRate",
"track_title" => "DbTrackTitle",
"track_number" => "DbTrackNumber",
"year" => "DbYear"
);
// things we need to check
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
// 3. validate formate according to DB column type
$multiplier = 1;
$result = 0;
// validation start
if ($data['etc']['sp_limit_options'] == 'hours') {
$multiplier = 60;
}
if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') {
$element = $this->getElement("sp_limit_value");
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
$element->addError(_("Limit cannot be empty or smaller than 0"));
$isValid = false;
} else {
$mins = floatval($data['etc']['sp_limit_value']) * $multiplier;
if ($mins > 1440) {
$element->addError(_("Limit cannot be more than 24 hrs"));
$isValid = false;
}
}
} else {
$element = $this->getElement("sp_limit_value");
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
$element->addError(_("Limit cannot be empty or smaller than 0"));
$isValid = false;
} elseif (!ctype_digit($data['etc']['sp_limit_value'])) {
$element->addError(_("The value should be an integer"));
$isValid = false;
} elseif (intval($data['etc']['sp_limit_value']) > 500) {
$element->addError(_("500 is the max item limit value you can set"));
$isValid = false;
}
}
if (isset($data['criteria'])) {
foreach ($data['criteria'] as $rowKey=>$row) {
foreach ($row as $key=>$d) {
$element = $this->getElement("sp_criteria_field_".$rowKey."_".$key);
// check for not selected select box
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0") {
$element->addError(_("You must select Criteria and Modifier"));
$isValid = false;
} else {
$column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]);
// validation on type of column
if (in_array($d['sp_criteria_field'], array('length', 'cuein', 'cueout'))) {
if (!preg_match("/^(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
$element->addError(_("'Length' should be in '00:00:00' format"));
$isValid = false;
}
} elseif ($column->getType() == PropelColumnTypes::TIMESTAMP) {
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
$element->addError(_("The value should be in timestamp format (e.g. 0000-00-00 or 0000-00-00 00:00:00)"));
$isValid = false;
} else {
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
if (!$result["success"]) {
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
$element->addError($result["errMsg"]);
$isValid = false;
}
}
if (isset($d['sp_criteria_extra'])) {
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
$element->addError(_("The value should be in timestamp format (e.g. 0000-00-00 or 0000-00-00 00:00:00)"));
$isValid = false;
} else {
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
if (!$result["success"]) {
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
$element->addError($result["errMsg"]);
$isValid = false;
}
}
}
} elseif ($column->getType() == PropelColumnTypes::INTEGER &&
$d['sp_criteria_field'] != 'owner_id') {
if (!is_numeric($d['sp_criteria_value'])) {
$element->addError(_("The value has to be numeric"));
$isValid = false;
}
// length check
if ($d['sp_criteria_value'] >= pow(2,31)) {
$element->addError(_("The value should be less then 2147483648"));
$isValid = false;
}
} elseif ($column->getType() == PropelColumnTypes::VARCHAR) {
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
$element->addError(sprintf(_("The value should be less than %s characters"), $column->getSize()));
$isValid = false;
}
}
}
if ($d['sp_criteria_value'] == "") {
$element->addError(_("Value cannot be empty"));
$isValid = false;
}
}//end foreach
}//for loop
}//if
return $isValid;
}
}

View file

@ -98,15 +98,15 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
</a> </a>
</div> </div>
<div class="media_type_selector" selection_id="1"> <div class="media_type_selector" selection_id="1">
<a href="/show-builder#"><?php echo _("Dashboard") ?></a></div> <a href="/showbuilder#"><?php echo _("Dashboard") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="1"> <div class="media_type_selector dashboard_sub_nav" selection_id="1">
<a href="/show-builder#files"><?php echo _("Files") ?></a></div> <a href="/showbuilder#files"><?php echo _("Files") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="2"> <div class="media_type_selector dashboard_sub_nav" selection_id="2">
<a href="/show-builder#playlists"><?php echo _("Playlists") ?></a></div> <a href="/showbuilder#playlists"><?php echo _("Playlists") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="3"> <div class="media_type_selector dashboard_sub_nav" selection_id="3">
<a href="/show-builder#smart-blocks"><?php echo _("Smart Blocks") ?></a></div> <a href="/showbuilder#smart-blocks"><?php echo _("Smart Blocks") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="4"> <div class="media_type_selector dashboard_sub_nav" selection_id="4">
<a href="/show-builder#webstreams"><?php echo _("Webstreams") ?></a></div> <a href="/showbuilder#webstreams"><?php echo _("Webstreams") ?></a></div>
<hr style="margin-left: 5px; margin-right: 5px"> <hr style="margin-left: 5px; margin-right: 5px">
<div id="nav"> <div id="nav">
<?php echo $this->navigation()->menu(); ?> <?php echo $this->navigation()->menu(); ?>

View file

@ -98,15 +98,15 @@
</a> </a>
</div> </div>
<div class="media_type_selector" selection_id="1"> <div class="media_type_selector" selection_id="1">
<a href="/show-builder"><?php echo _("Dashboard") ?></a></div> <a href="/showbuilder"><?php echo _("Dashboard") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="1"> <div class="media_type_selector dashboard_sub_nav" selection_id="1">
<a href="/show-builder#files"><?php echo _("Files") ?></a></div> <a href="/showbuilder#files"><?php echo _("Files") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="2"> <div class="media_type_selector dashboard_sub_nav" selection_id="2">
<a href="/show-builder#playlists"><?php echo _("Playlists") ?></a></div> <a href="/showbuilder#playlists"><?php echo _("Playlists") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="3"> <div class="media_type_selector dashboard_sub_nav" selection_id="3">
<a href="/show-builder#smart-blocks"><?php echo _("Smart Blocks") ?></a></div> <a href="/showbuilder#smart-blocks"><?php echo _("Smart Blocks") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="4"> <div class="media_type_selector dashboard_sub_nav" selection_id="4">
<a href="/show-builder#webstreams"><?php echo _("Webstreams") ?></a></div> <a href="/showbuilder#webstreams"><?php echo _("Webstreams") ?></a></div>
<hr style="margin-left: 5px; margin-right: 5px"> <hr style="margin-left: 5px; margin-right: 5px">
<div id="nav"> <div id="nav">
<?php echo $this->navigation()->menu(); ?> <?php echo $this->navigation()->menu(); ?>

View file

@ -104,15 +104,15 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
</ul> </ul>
</div> </div>
<div class="media_type_selector" selection_id="1"> <div class="media_type_selector" selection_id="1">
<a href="/show-builder"><?php echo _("Dashboard") ?></a></div> <a href="/showbuilder"><?php echo _("Dashboard") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="1"> <div class="media_type_selector dashboard_sub_nav" selection_id="1">
<a href="/show-builder#files"><?php echo _("Files") ?></a></div> <a href="/showbuilder#files"><?php echo _("Files") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="2"> <div class="media_type_selector dashboard_sub_nav" selection_id="2">
<a href="/show-builder#playlists"><?php echo _("Playlists") ?></a></div> <a href="/showbuilder#playlists"><?php echo _("Playlists") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="3"> <div class="media_type_selector dashboard_sub_nav" selection_id="3">
<a href="/show-builder#smart-blocks"><?php echo _("Smart Blocks") ?></a></div> <a href="/showbuilder#smart-blocks"><?php echo _("Smart Blocks") ?></a></div>
<div class="media_type_selector dashboard_sub_nav" selection_id="4"> <div class="media_type_selector dashboard_sub_nav" selection_id="4">
<a href="/show-builder#webstreams"><?php echo _("Webstreams") ?></a></div> <a href="/showbuilder#webstreams"><?php echo _("Webstreams") ?></a></div>
<div id="nav"> <div id="nav">
<?php echo $this->navigation()->menu() ?> <?php echo $this->navigation()->menu() ?>
</div> </div>

View file

@ -1,148 +0,0 @@
<form class="smart-block-form" method="post" action="">
<dl class='zend_form search-criteria'>
<div id='sp-success' class='success' style='display:none'></div>
<dd id='sp_type-element'>
<label class='sp-label'>
<?php echo $this->element->getElement('sp_type')->getLabel() ?>
</label>
<?php $i=0;
$value = $this->element->getElement('sp_type')->getValue();
foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?>
<label class='sp-label' for='sp_type-<?php echo $i?>'>
<input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if($i == $value){echo 'checked="checked"';}?> ><?php echo $radio ?>
</label>
<?php $i = $i + 1; ?>
<?php endforeach; ?>
<span class='playlist_type_help_icon'></span>
</dd>
<dd id='sp_criteria-element' class='criteria-element'>
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {
// modRowMap holds the number of modifier rows for each criteria element
// i.e. if we have 'Album contains 1' and 'Album contains 2' the modRowMap
// for Album is 2
?>
<?php for ($j = 0; $j < $this->modRowMap[$i]; $j++) {
// determine if logic label should be 'and' or 'or'
if ($this->modRowMap[$i] > 1 && $j != $this->modRowMap[$i]-1) $logicLabel = _('or');
else $logicLabel = _('and');
$disabled = $this->element->getElement("sp_criteria_field_".$i."_".$j)->getAttrib('disabled') == 'disabled'?true:false;
// determine if the next row is disabled and only display the logic label if it isn't
if ($j == $this->modRowMap[$i]-1 && $i < 25) {
$n = $i+1;
$nextIndex = $n."_0";
} elseif ($j+1 <= $this->modRowMap[$i]-1) {
$n = $j+1;
$nextIndex = $i."_".$n;
}
$nextDisabled = $this->element->getElement("sp_criteria_field_".$nextIndex)->getAttrib('disabled') == 'disabled'?true:false;
?>
<div <?php if (($i > 0) && $disabled) {
echo 'style=display:none';
} ?>>
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
<a class='btn btn-small' id='modifier_add_<?php echo $i ?>'>
<i class='icon-white icon-plus'></i>
</a>
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?>
<?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?>
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>><?php echo _(" to "); ?><?php echo $this->element->getElement('sp_criteria_extra_'.$i."_".$j) ?></span>
<a style='margin-right:3px' class='btn btn-small btn-danger' id='criteria_remove_<?php echo $i ?>'>
<i class='icon-white icon-remove'></i>
</a>
<span class='db-logic-label' <?php if ($nextDisabled) echo "style='display:none'"?>>
<?php echo $logicLabel;?>
</span>
<?php if($this->element->getElement("sp_criteria_field_".$i."_".$j)->hasErrors()) : ?>
<?php foreach($this->element->getElement("sp_criteria_field_".$i."_".$j)->getMessages() as $error): ?>
<span class='errors sp-errors'>
<?php echo $error; ?>
</span>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php } ?>
<?php } ?>
</dd>
<dd id='sp_repeat_tracks-element'>
<span class='sp_text_font'><?php echo $this->element->getElement('sp_repeat_tracks')->getLabel() ?></span>
<?php echo $this->element->getElement('sp_repeat_tracks')?>
<?php if($this->element->getElement("sp_repeat_tracks")->hasErrors()) : ?>
<?php foreach($this->element->getElement("sp_repeat_tracks")->getMessages() as $error): ?>
<span class='errors sp-errors'>
<?php echo $error; ?>
</span>
<?php endforeach; ?>
<?php endif; ?>
<span class='repeat_tracks_help_icon'></span>
</dd>
<dd id='sp_sort-element'>
<span class='sp_text_font'>Sort tracks by</span>
<?php echo $this->element->getElement('sp_sort_options') ?>
<?php if($this->element->getElement("sp_sort_options")->hasErrors()) : ?>
<?php foreach($this->element->getElement("sp_sort_options")->getMessages() as $error): ?>
<span class='errors sp-errors'>
<?php echo $error; ?>
</span>
<?php endforeach; ?>
<?php endif; ?>
</dd>
<dd id='sp_limit-element'>
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
<?php echo $this->element->getElement('sp_limit_value')?>
<?php echo $this->element->getElement('sp_limit_options') ?>
<?php if($this->element->getElement("sp_limit_value")->hasErrors()) : ?>
<?php foreach($this->element->getElement("sp_limit_value")->getMessages() as $error): ?>
<span class='errors sp-errors'>
<?php echo $error; ?>
</span>
<?php endforeach; ?>
<?php endif; ?>
</dd>
<?php if ($this->showPoolCount) { ?>
<div class='sp_text_font sp_text_font_bold'>
<span id='sp_pool_count' class='sp_text_font sp_text_font_bold'>
<?php
if ($this->poolCount > 1) {
echo $this->poolCount;
?>
<?php echo _("files meet the criteria")?>
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else if ($this->poolCount == 1) {
echo $this->poolCount;
?>
<?php echo _("file meets the criteria")?>
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else {
?>
0 <?php echo " "._("files meet the criteria")?>
</span>
<span class='sp-warning-icon' id='sp_pool_count_icon'></span>
<?php
}
?>
</div>
<?php } ?>
</dl>
</form>
<div class='btn-toolbar left-floated'>
<div class='btn-group sp-button'>
<?php echo $this->element->getElement('generate_button');?>
</div>
<div class='btn-group sp-button'>
<?php echo $this->element->getElement('shuffle_button');?>
</div>
</div>

View file

@ -1,16 +0,0 @@
<div class="sb-options-form">
<?php echo $this->element->getElement('sb_date_start'); ?>
<?php echo $this->element->getElement('sb_time_start'); ?>
<?php echo $this->element->getElement('sb_date_end'); ?>
<?php echo $this->element->getElement('sb_time_end'); ?>
<a id="sb_submit" class="btn btn-small" href="#" title="Display shows in the specified date and time range">
<i class="icon-white icon-search"></i><?php echo " "._("Find Shows") ?>
</a>
<?php echo $this->element->getElement('sb_show_filter') ?>
<?php if ($this->element->getElement('sb_my_shows')):?>
<label><?php echo $this->element->getElement('sb_my_shows')->getLabel(); ?></label>
<?php echo $this->element->getElement('sb_my_shows'); ?>
<?php endif;?>
</div>

View file

@ -1,25 +1,16 @@
<?php echo $this->element->getElement('sb_date_start'); ?> <div class="sb-options-form">
<?php echo $this->element->getElement('sb_time_start'); ?> <?php echo $this->element->getElement('sb_date_start'); ?>
<?php echo $this->element->getElement('sb_date_end'); ?> <?php echo $this->element->getElement('sb_time_start'); ?>
<?php echo $this->element->getElement('sb_time_end'); ?> <?php echo $this->element->getElement('sb_date_end'); ?>
<?php echo $this->element->getElement('sb_time_end'); ?>
<a id="sb_submit" class="btn btn-small" href="#" title="Display shows in the specified date and time range">
<i class="icon-white icon-search"></i><?php echo " "._("Find Shows") ?>
</a>
<a id="sb_submit" class="btn btn-small" href="#" title="Display shows in the specified date and time range"> <?php echo $this->element->getElement('sb_show_filter') ?>
<i class="icon-white icon-search"></i><?php echo " "._("Find Shows") ?></a>
<div class="sb-advanced-options">
<fieldset class="padded display_field push-down-8 closed">
<legend style="cursor: pointer;">
<span class="ui-icon ui-icon-triangle-2-n-s"></span>
<?php echo _("Filter By Show:")?>
</legend>
<div class="sb-options-form"> <?php if ($this->element->getElement('sb_my_shows')):?>
<label><?php echo $this->element->getElement('sb_show_filter')->getLabel() ?></label> <label><?php echo $this->element->getElement('sb_my_shows')->getLabel(); ?></label>
<?php echo $this->element->getElement('sb_show_filter') ?> <?php echo $this->element->getElement('sb_my_shows'); ?>
<?php endif;?>
<?php if ($this->element->getElement('sb_my_shows')):?>
<label><?php echo $this->element->getElement('sb_my_shows')->getLabel(); ?></label>
<?php echo $this->element->getElement('sb_my_shows'); ?>
<?php endif;?>
</div>
</fieldset>
</div> </div>

View file

@ -1,21 +1,9 @@
<form id="smart-block-form" method="post" action=""> <form class="smart-block-form" method="post" action="">
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed"?> sb-criteria-fieldset' id='smart_block_options'>
<legend style='cursor: pointer;'><span class='ui-icon ui-icon-triangle-2-n-s'></span><?php echo _("Smart Block Options") ?></legend>
<dl class='zend_form search-criteria'> <dl class='zend_form search-criteria'>
<div class='btn-toolbar clearfix'>
<div class='btn-group sp-button'>
<?php echo $this->element->getElement('generate_button') ?>
</div>
<div class='btn-group sp-button'>
<?php echo $this->element->getElement('shuffle_button') ?>
</div>
</div>
<div id='sp-success' class='success' style='display:none'></div> <div id='sp-success' class='success' style='display:none'></div>
<dd id='sp_type-element'> <dd id='sp_type-element'>
<label class='sp-label'> <label class='sp-label'>
<?php echo $this->element->getElement('sp_type')->getLabel() ?> <?php echo $this->element->getElement('sp_type')->getLabel() ?>
<span class='playlist_type_help_icon'></span>
</label> </label>
<?php $i=0; <?php $i=0;
$value = $this->element->getElement('sp_type')->getValue(); $value = $this->element->getElement('sp_type')->getValue();
@ -26,6 +14,7 @@
</label> </label>
<?php $i = $i + 1; ?> <?php $i = $i + 1; ?>
<?php endforeach; ?> <?php endforeach; ?>
<span class='playlist_type_help_icon'></span>
</dd> </dd>
<dd id='sp_criteria-element' class='criteria-element'> <dd id='sp_criteria-element' class='criteria-element'>
@ -79,12 +68,10 @@
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
<br />
</dd> </dd>
<dd id='sp_repeate_tracks-element'> <dd id='sp_repeat_tracks-element'>
<span class='sp_text_font'><?php echo $this->element->getElement('sp_repeat_tracks')->getLabel() ?></span> <span class='sp_text_font'><?php echo $this->element->getElement('sp_repeat_tracks')->getLabel() ?></span>
<span class='repeat_tracks_help_icon'></span>
<?php echo $this->element->getElement('sp_repeat_tracks')?> <?php echo $this->element->getElement('sp_repeat_tracks')?>
<?php if($this->element->getElement("sp_repeat_tracks")->hasErrors()) : ?> <?php if($this->element->getElement("sp_repeat_tracks")->hasErrors()) : ?>
<?php foreach($this->element->getElement("sp_repeat_tracks")->getMessages() as $error): ?> <?php foreach($this->element->getElement("sp_repeat_tracks")->getMessages() as $error): ?>
@ -93,7 +80,7 @@
</span> </span>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<br /> <span class='repeat_tracks_help_icon'></span>
</dd> </dd>
<dd id='sp_sort-element'> <dd id='sp_sort-element'>
<span class='sp_text_font'>Sort tracks by</span> <span class='sp_text_font'>Sort tracks by</span>
@ -105,8 +92,7 @@
</span> </span>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<br /> </dd>
</dd>
<dd id='sp_limit-element'> <dd id='sp_limit-element'>
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span> <span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
<?php echo $this->element->getElement('sp_limit_value')?> <?php echo $this->element->getElement('sp_limit_value')?>
@ -118,7 +104,6 @@
</span> </span>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<br />
</dd> </dd>
<?php if ($this->showPoolCount) { ?> <?php if ($this->showPoolCount) { ?>
@ -135,7 +120,7 @@
} else if ($this->poolCount == 1) { } else if ($this->poolCount == 1) {
echo $this->poolCount; echo $this->poolCount;
?> ?>
<?php echo _("file meet the criteria")?> <?php echo _("file meets the criteria")?>
</span> </span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span> <span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php <?php
@ -149,8 +134,15 @@
?> ?>
</div> </div>
<?php } ?> <?php } ?>
</dl> </dl>
</fieldset>
</form> </form>
<div class='btn-toolbar left-floated'>
<div class='btn-group sp-button'>
<?php echo $this->element->getElement('generate_button');?>
</div>
<div class='btn-group sp-button'>
<?php echo $this->element->getElement('shuffle_button');?>
</div>
</div>

View file

@ -1,71 +0,0 @@
<?php
if (isset($this->obj)) {
$contents = $this->obj->getContents();
$count = count($contents);
}
?>
<?php if (isset($this->obj)) : ?>
<div class="inner_editor_wrapper">
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/>
<input class='obj_type' type='hidden' value='playlist'/>
<div class="playlist_title">
<h3 class="obj_name">
<a class="playlist_name_display" contenteditable="true"><?php echo $this->escape($this->obj->getName()); ?></a>
</h3>
<h4 class="obj_length"><?php echo $this->length; ?></h4>
</div>
<div id='sp-success' class='success' style='display:none'></div>
<dl class="zend_form">
<dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt>
<dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->escape($this->obj->getDescription()); ?></textarea>
</dd>
</dl>
<div class="btn-toolbar spl-no-margin clearfix left-floated">
<div class='btn-group pull-right'>
<button class="btn btn-danger" title='<?php echo _("Empty playlist content") ?>' type="button" id="pl-bl-clear-content"><?php echo _("Clear") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><?php echo _("Shuffle") ?></button>
</div>
<div class='btn-group pull-right'>
<a href="#" id="spl_crossfade" class="btn crossfade-main-button" style="display:<?php echo $count > 0 ?"block;":"none;"?>">
<i class='crossfade-main-icon'></i><span class="ui-button-text"><?php echo _("Playlist crossfade") ?></span>
</a>
</div>
</div>
<?php //echo $this->form; ?>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
<span class="ui-icon ui-icon-closethick sp-closethick-center"></span>
<dl id="spl_editor-main" class="inline-list">
<dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'>(ss.t)</span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_in">00</span></dd>
<dd class="edit-error"></dd>
<dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'>(ss.t)</span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_out">00</span></dd>
<dd class="edit-error"></dd>
</dl>
</div>
</div>
<ul class="spl_sortable">
<?php $this->contents = $contents;
echo $this->render('playlist/update.phtml') ?>
</ul>
<div class="btn-toolbar spl-no-margin clearfix">
<div class="btn-group pull-right">
<button class="btn" type="button" id="cancel_button" name="submit"><?php echo _("Cancel") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn" title='<?php echo _("Save playlist") ?>' type="button" id="save_button"><?php echo _("Save") ?></button>
</div>
</div>
<?php else : ?>
<div><?php echo _("No open playlist") ?></div>
<?php endif; ?>

View file

@ -1,72 +0,0 @@
<?php
if (isset($this->obj)) {
$contents = $this->obj->getContents();
$count = count($contents);
}
?>
<?php if (isset($this->obj)) : ?>
<div class="inner_editor_wrapper">
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/>
<input class='obj_type' type='hidden' value='block'/>
<div class="playlist_title">
<h3 class="obj_name">
<a class="playlist_name_display" contenteditable="true">
<?php
if (isset($this->unsavedName)) echo $this->unsavedName;
else echo $this->escape($this->obj->getName());
?>
</a>
</h3>
<h4 class="obj_length"><?php echo $this->length; ?></h4>
</div>
<div id='sp-success-saved' class='success' style='display:none'></div>
<dl class="zend_form">
<dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt>
<dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php if (isset($this->unsavedDesc)) echo $this->unsavedDesc; else echo $this->obj->getDescription();?></textarea>
</dd>
</dl>
<?php echo $this->form; ?>
<div class="btn-toolbar spl-no-margin clearfix left-floated">
<div class='btn-group pull-right'>
<button class="btn btn-danger" title='<?php echo _("Empty smart block content") ?>' type="button" id="pl-bl-clear-content"><?php echo _("Clear") ?></button>
</div>
<div class='btn-group pull-right'>
<a href="#" id="spl_crossfade" class="btn crossfade-main-button" style="display:<?php echo ($this->obj->isStatic() && $count > 0) ?"block;":"none;"?>">
<i class='crossfade-main-icon'></i><span class="ui-button-text"><?php echo _("Playlist crossfade") ?></span>
</a>
</div>
</div>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
<span class="ui-icon ui-icon-closethick"></span>
<dl id="spl_editor-main" class="inline-list">
<dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)")?></span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_in">00</span></dd>
<dd class="edit-error"></dd>
<dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)")?></span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_out">00</span></dd>
<dd class="edit-error"></dd>
</dl>
</div>
</div>
<ul class="spl_sortable">
<?php $this->contents = $contents;
echo $this->render('playlist/update.phtml') ?>
</ul>
<div class="btn-toolbar spl-no-margin clearfix">
<div class="btn-group pull-right">
<button class="btn" type="button" id="cancel_button" name="submit"><?php echo _("Cancel") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn" title='Save smart block&#39s title, description, and criteria' type="button" id="save_button"><?php echo _("Save") ?></button>
</div>
</div>
<?php else : ?>
<div><?php echo _("No open smart block") ?></div>
<?php endif; ?>

View file

@ -4,83 +4,68 @@ if (isset($this->obj)) {
$count = count($contents); $count = count($contents);
} }
?> ?>
<a href="#" class="close-round" id="lib_pl_close"></a>
<div class="btn-toolbar spl-no-top-margin clearfix">
<div class="btn-group pull-left">
<button id="spl_new" class="btn dropdown-toggle" data-toggle="dropdown" aria-disabled="false">
<?php echo _("New")?> <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li id='lib-new-pl'><a href="#"><?php echo _("New Playlist") ?></a></li>
<li id='lib-new-bl'><a href="#"><?php echo _("New Smart Block") ?></a></li>
<li id='lib-new-ws'><a href="#"><?php echo _("New Webstream") ?></a></li>
</ul>
</div>
<?php if (isset($this->obj)) : ?>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='<?php echo _("Empty playlist content") ?>' type="button" id="pl-bl-clear-content"><?php echo _("Clear") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><?php echo _("Shuffle") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='<?php echo _("Save playlist") ?>' type="button" id="save_button"><?php echo _("Save") ?></button>
</div>
<div class='btn-group pull-right'>
<button id="spl_delete" class="btn" role="button" aria-disabled="false"><?php echo _("Delete") ?></button>
</div>
<div class='btn-group pull-right'>
<a href="#" id="spl_crossfade" class="btn crossfade-main-button" style="display:<?php echo $count > 0 ?"block;":"none;"?>">
<i class='crossfade-main-icon'></i><span class="ui-button-text"><?php echo _("Playlist crossfade") ?></span>
</a>
</div>
<?php endif; ?>
</div>
<?php if (isset($this->obj)) : ?> <?php if (isset($this->obj)) : ?>
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"></input> <div class="inner_editor_wrapper">
<input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"></input> <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class='obj_type' type='hidden' value='playlist'></input> <input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/>
<div class="playlist_title"> <input class='obj_type' type='hidden' value='playlist'/>
<h3 class="obj_name"> <div class="playlist_title">
<a class="playlist_name_display" contenteditable="true"><?php echo $this->escape($this->obj->getName()); ?></a> <h3 class="obj_name">
</h3> <a class="playlist_name_display" contenteditable="true"><?php echo $this->escape($this->obj->getName()); ?></a>
<h4 class="obj_length"><?php echo $this->length; ?></h4> </h3>
</div> <h4 class="obj_length"><?php echo $this->length; ?></h4>
<div id='sp-success' class='success' style='display:none'></div> </div>
<div id='sp-success' class='success' style='display:none'></div>
<fieldset class="toggle closed" id="fieldset-metadate_change">
<legend style="cursor: pointer;"><span class="ui-icon ui-icon-triangle-2-n-s"></span><?php echo _("View / edit description"); ?></legend>
<dl class="zend_form"> <dl class="zend_form">
<dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt> <dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt>
<dd id="description-element"> <dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->escape($this->obj->getDescription()); ?></textarea> <textarea cols="80" rows="24" id="description" name="description"><?php echo $this->escape($this->obj->getDescription()); ?></textarea>
</dd> </dd>
</dl> </dl>
</fieldset>
<?php //echo $this->form; ?>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;"> <div class="btn-toolbar spl-no-margin clearfix left-floated">
<span class="ui-icon ui-icon-closethick sp-closethick-center"></span> <div class='btn-group pull-right'>
<dl id="spl_editor-main" class="inline-list"> <button class="btn btn-danger" title='<?php echo _("Empty playlist content") ?>' type="button" id="pl-bl-clear-content"><?php echo _("Clear") ?></button>
<dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'>(ss.t)</span></dt> </div>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_in">00</span></dd> <div class='btn-group pull-right'>
<dd class="edit-error"></dd> <button class="btn" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><?php echo _("Shuffle") ?></button>
<dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'>(ss.t)</span></dt> </div>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_out">00</span></dd> <div class='btn-group pull-right'>
<dd class="edit-error"></dd> <a href="#" id="spl_crossfade" class="btn crossfade-main-button" style="display:<?php echo $count > 0 ?"block;":"none;"?>">
</dl> <i class='crossfade-main-icon'></i><span class="ui-button-text"><?php echo _("Playlist crossfade") ?></span>
</a>
</div>
</div>
<?php //echo $this->form; ?>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
<span class="ui-icon ui-icon-closethick sp-closethick-center"></span>
<dl id="spl_editor-main" class="inline-list">
<dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'>(ss.t)</span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_in">00</span></dd>
<dd class="edit-error"></dd>
<dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'>(ss.t)</span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_out">00</span></dd>
<dd class="edit-error"></dd>
</dl>
</div>
</div> </div>
<ul class="spl_sortable">
<div class="clear"></div> <?php $this->contents = $contents;
<div class="" style="clear:both; float:none; width:100%;"> echo $this->render('playlist/update.phtml') ?>
<ul class="spl_sortable"> </ul>
<?php $this->contents = $contents; <div class="btn-toolbar spl-no-margin clearfix">
echo $this->render('playlist/update.phtml') ?> <div class="btn-group pull-right">
</ul> <button class="btn" type="button" id="cancel_button" name="submit"><?php echo _("Cancel") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn" title='<?php echo _("Save playlist") ?>' type="button" id="save_button"><?php echo _("Save") ?></button>
</div>
</div> </div>
<?php else : ?> <?php else : ?>
<div><?php echo _("No open playlist") ?></div> <div><?php echo _("No open playlist") ?></div>
<?php endif; ?> <?php endif; ?>

View file

@ -4,86 +4,67 @@ if (isset($this->obj)) {
$count = count($contents); $count = count($contents);
} }
?> ?>
<a href="#" class="close-round" id="lib_pl_close"></a>
<div class="btn-toolbar spl-no-top-margin clearfix">
<div class="btn-group pull-left">
<button id="spl_new" class="btn dropdown-toggle" data-toggle='dropdown' aria-disabled="false">
<?php echo _("New")?> <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li id='lib-new-pl'><a href="#"><?php echo _("New Playlist") ?></a></li>
<li id='lib-new-bl'><a href="#"><?php echo _("New Smart Block") ?></a></li>
<li id='lib-new-ws'><a href="#"><?php echo _("New Webstream") ?></a></li>
</ul>
</div>
<?php if (isset($this->obj)) : ?>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='<?php echo _("Empty smart block content") ?>' type="button" id="pl-bl-clear-content"><?php echo _("Clear") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn btn-inverse" title='Save smart block&#39s title, description, and criteria' type="button" id="save_button"><?php echo _("Save") ?></button>
</div>
<div class='btn-group pull-right'>
<button id="spl_delete" class="btn" role="button" aria-disabled="false"><?php echo _("Delete") ?></button>
</div>
<div class='btn-group pull-right'>
<a href="#" id="spl_crossfade" class="btn crossfade-main-button" style="display:<?php echo ($this->obj->isStatic() && $count > 0) ?"block;":"none;"?>">
<i class='crossfade-main-icon'></i><span class="ui-button-text"><?php echo _("Playlist crossfade") ?></span>
</a>
</div>
<?php endif; ?>
</div>
<?php if (isset($this->obj)) : ?> <?php if (isset($this->obj)) : ?>
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"></input> <div class="inner_editor_wrapper">
<input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"></input> <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class='obj_type' type='hidden' value='block'></input> <input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/>
<div class="playlist_title"> <input class='obj_type' type='hidden' value='block'/>
<h3 class="obj_name"> <div class="playlist_title">
<a id="playlist_name_display" contenteditable="true"> <h3 class="obj_name">
<?php <a class="playlist_name_display" contenteditable="true">
if (isset($this->unsavedName)) echo $this->unsavedName; <?php
else echo $this->escape($this->obj->getName()); if (isset($this->unsavedName)) echo $this->unsavedName;
?> else echo $this->escape($this->obj->getName());
</a> ?>
</h3> </a>
<h4 class="obj_length"><?php echo $this->length; ?></h4> </h3>
</div> <h4 class="obj_length"><?php echo $this->length; ?></h4>
<div id='sp-success-saved' class='success' style='display:none'></div> </div>
<div id='sp-success-saved' class='success' style='display:none'></div>
<fieldset class="toggle closed" id="fieldset-metadate_change">
<legend style="cursor: pointer;"><span class="ui-icon ui-icon-triangle-2-n-s"></span><?php echo _("View / edit description"); ?></legend>
<dl class="zend_form"> <dl class="zend_form">
<dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt> <dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt>
<dd id="description-element"> <dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php <textarea cols="80" rows="24" id="description" name="description"><?php if (isset($this->unsavedDesc)) echo $this->unsavedDesc; else echo $this->obj->getDescription();?></textarea>
if (isset($this->unsavedDesc)) echo $this->unsavedDesc;
else echo $this->obj->getDescription();?>
</textarea>
</dd> </dd>
</dl> </dl>
</fieldset>
<?php echo $this->form; ?>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;"> <?php echo $this->form; ?>
<span class="ui-icon ui-icon-closethick"></span> <div class="btn-toolbar spl-no-margin clearfix left-floated">
<dl id="spl_editor-main" class="inline-list"> <div class='btn-group pull-right'>
<dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)")?></span></dt> <button class="btn btn-danger" title='<?php echo _("Empty smart block content") ?>' type="button" id="pl-bl-clear-content"><?php echo _("Clear") ?></button>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_in">00</span></dd> </div>
<dd class="edit-error"></dd> <div class='btn-group pull-right'>
<dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)")?></span></dt> <a href="#" id="spl_crossfade" class="btn crossfade-main-button" style="display:<?php echo ($this->obj->isStatic() && $count > 0) ?"block;":"none;"?>">
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_out">00</span></dd> <i class='crossfade-main-icon'></i><span class="ui-button-text"><?php echo _("Playlist crossfade") ?></span>
<dd class="edit-error"></dd> </a>
</dl> </div>
</div>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
<span class="ui-icon ui-icon-closethick"></span>
<dl id="spl_editor-main" class="inline-list">
<dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)")?></span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_in">00</span></dd>
<dd class="edit-error"></dd>
<dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)")?></span></dt>
<dd><span contenteditable="true" class="spl_text_input spl_main_fade_out">00</span></dd>
<dd class="edit-error"></dd>
</dl>
</div>
</div> </div>
<ul class="spl_sortable">
<div class="clear"></div> <?php $this->contents = $contents;
<div class="" style="clear:both; float:none; width:100%;"> echo $this->render('playlist/update.phtml') ?>
<ul class="spl_sortable"> </ul>
<?php $this->contents = $contents; <div class="btn-toolbar spl-no-margin clearfix">
echo $this->render('playlist/update.phtml') ?> <div class="btn-group pull-right">
</ul> <button class="btn" type="button" id="cancel_button" name="submit"><?php echo _("Cancel") ?></button>
</div>
<div class='btn-group pull-right'>
<button class="btn" title='Save smart block&#39s title, description, and criteria' type="button" id="save_button"><?php echo _("Save") ?></button>
</div>
</div> </div>
<?php else : ?> <?php else : ?>

View file

@ -1,41 +0,0 @@
<!--<form action="/rest/media" method="post" id="upload_form" class="dropzone dz-clickable" --><?php //if ($this->quotaLimitReached) { ?><!-- class="hidden" --><?php //} ?>
<!-- --><?php //echo $this->csrf ?>
<!-- <div class="dz-message">-->
<!-- --><?php //echo _("Drop files here or click to upload") ?>
<!-- </div>-->
<!--</form>-->
<?php echo $this->csrf ?>
<div id="library_content" class="lib-content tabs content-pane wide-panel">
<div>
<h2 id="library_title">Library</h2>
</div>
<div class="panel-header">
<div id="advanced-options" class="btn-group">
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<div id="advanced_search" class="advanced_search form-horizontal dropdown-menu"></div>
</div>
</div>
<div class="outer-datatable-wrapper">
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
</div>
<div id="show_builder" class="sb-content content-pane wide-panel">
<div class="panel-header">
<ul class="nav nav-tabs">
<li id="schedule-tab" role="presentation" class="active"><a href="#">Scheduled Shows</a></li>
</ul>
</div>
<div class="outer-datatable-wrapper active-tab">
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
<div class="sb-timerange">
<?php echo $this->sb_form; ?>
</div>
</div>
</div>
<?php echo $this->dialog ?>

View file

@ -1,23 +1,41 @@
<?php if (!$this->disableLib): ?> <!--<form action="/rest/media" method="post" id="upload_form" class="dropzone dz-clickable" --><?php //if ($this->quotaLimitReached) { ?><!-- class="hidden" --><?php //} ?>
<div id="library_content" class="lib-content tabs ui-widget ui-widget-content block-shadow alpha-block padded" <!-- --><?php //echo $this->csrf ?>
<?php if (!$this->showLib): ?> <!-- <div class="dz-message">-->
style="display:none" <!-- --><?php //echo _("Drop files here or click to upload") ?>
<?php endif; ?> <!-- </div>-->
> <!--</form>-->
<?php echo $this->render('library/library.phtml') ?>
</div>
<?php endif; ?>
<div id="show_builder" class="sb-content ui-widget ui-widget-content block-shadow omega-block padded"> <?php echo $this->csrf ?>
<div class="sb-timerange">
<?php if(!$this->disableLib && !$this->showLib):?> <div id="library_content" class="lib-content tabs content-pane wide-panel">
<a id="sb_edit" class="btn btn-small" href="#" title="Open library to add or remove content"> <div>
<?php echo _("Add / Remove Content")?> <h2 id="library_title">Library</h2>
</a> </div>
<?php endif; ?> <div class="panel-header">
<?php echo $this->sb_form; ?> <div id="advanced-options" class="btn-group">
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<div id="advanced_search" class="advanced_search form-horizontal dropdown-menu"></div>
</div>
</div>
<div class="outer-datatable-wrapper">
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>
</div> </div>
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
</div> </div>
<?php echo $this->lang_tz_popup_form; ?> <div id="show_builder" class="sb-content content-pane wide-panel">
<div class="panel-header">
<ul class="nav nav-tabs">
<li id="schedule-tab" role="presentation" class="active"><a href="#">Scheduled Shows</a></li>
</ul>
</div>
<div class="outer-datatable-wrapper active-tab">
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
<div class="sb-timerange">
<?php echo $this->sb_form; ?>
</div>
</div>
</div>
<?php echo $this->dialog ?>

View file

@ -1,47 +0,0 @@
<?php if (isset($this->obj)) : ?>
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class="obj_lastMod" type="hidden" value="<?php echo "1";//$this->obj->getLastModified('U'); ?>"/>
<input class="obj_type" type="hidden" value="webstream"/>
<div class="status" style="display:none;"></div>
<div class="playlist_title">
<div id="name-error" class="errors" style="display:none;"></div>
<h3 class="ws_name">
<a class="playlist_name_display" contenteditable="true"><?php echo $this->escape($this->obj->getName()); ?></a>
</h3>
<h4 class="ws_length"><?php echo $this->obj->getDefaultLength(); ?></h4>
</div>
<dl class="zend_form">
<dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt>
<dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
</dd>
</dl>
<dl class="zend_form">
<dt id="submit-label" style="display: none;">&nbsp;</dt>
<div id="url-error" class="errors" style="display:none;"></div>
<dt id="streamurl-label"><label for="streamurl"><?php echo _("Stream URL:"); ?></label></dt>
<dd id="streamurl-element">
<input type="text" value="<?php echo $this->obj->getUrl(); ?>" size="40"/>
</dd>
<div id="length-error" class="errors" style="display:none;"></div>
<dt id="streamlength-label"><label for="streamlength"><?php echo _("Default Length:"); ?></label></dt>
<dd id="streamlength-element">
<input type="text" value="<?php echo $this->obj->getDefaultLength() ?>"/>
</dd>
</dl>
<div class="btn-toolbar spl-no-margin clearfix">
<div class="btn-group pull-right">
<button class="btn" type="button" id="webstream_cancel" name="submit"><?php echo _("Cancel") ?></button>
</div>
<div class="btn-group pull-right">
<button class="btn" type="submit" id="webstream_save" name="submit"><?php echo _("Save") ?></button>
</div>
</div>
<?php else : ?>
<div><?php echo _("No webstream") ?></div>
<?php endif; ?>

View file

@ -1,26 +1,3 @@
<a href="#" class="close-round" id="lib_pl_close"></a>
<div class="btn-toolbar spl-no-top-margin clearfix">
<div class="btn-group pull-left">
<button id="ws_new" class="btn dropdown-toggle" data-toggle="dropdown" aria-disabled="false">
<?php echo _("New")?> <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li id='lib-new-pl'><a href="#"><?php echo _("New Playlist") ?></a></li>
<li id='lib-new-bl'><a href="#"><?php echo _("New Smart Block") ?></a></li>
<li id='lib-new-ws'><a href="#"><?php echo _("New Webstream") ?></a></li>
</ul>
</div>
<?php if (isset($this->obj)) : ?>
<div class="btn-group pull-right">
<button class="btn btn-inverse" type="submit" id="webstream_save" name="submit"><?php echo _("Save") ?></button>
</div>
<div class="btn-group pull-right">
<button id="ws_delete" class="btn" <?php if ($this->action == "new"): ?>style="display:none;"<?php endif; ?>aria-disabled="false"><?php echo _("Delete") ?></button>
</div>
<?php endif; ?>
</div>
<?php if (isset($this->obj)) : ?> <?php if (isset($this->obj)) : ?>
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/> <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class="obj_lastMod" type="hidden" value="<?php echo "1";//$this->obj->getLastModified('U'); ?>"/> <input class="obj_lastMod" type="hidden" value="<?php echo "1";//$this->obj->getLastModified('U'); ?>"/>
@ -35,17 +12,13 @@
<h4 class="ws_length"><?php echo $this->obj->getDefaultLength(); ?></h4> <h4 class="ws_length"><?php echo $this->obj->getDefaultLength(); ?></h4>
</div> </div>
<fieldset class="toggle" id="fieldset-metadate_change"> <dl class="zend_form">
<legend style="cursor: pointer;"><span class="ui-icon ui-icon-triangle-2-n-s"></span><?php echo _("View / edit description"); ?></legend> <dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt>
<dl class="zend_form"> <dd id="description-element">
<dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt> <textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
<dd id="description-element"> </dd>
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea> </dl>
</dd>
</dl>
</fieldset>
<dl class="zend_form"> <dl class="zend_form">
<dt id="submit-label" style="display: none;">&nbsp;</dt> <dt id="submit-label" style="display: none;">&nbsp;</dt>
<div id="url-error" class="errors" style="display:none;"></div> <div id="url-error" class="errors" style="display:none;"></div>
@ -60,6 +33,15 @@
</dd> </dd>
</dl> </dl>
<div class="btn-toolbar spl-no-margin clearfix">
<div class="btn-group pull-right">
<button class="btn" type="button" id="webstream_cancel" name="submit"><?php echo _("Cancel") ?></button>
</div>
<div class="btn-group pull-right">
<button class="btn" type="submit" id="webstream_save" name="submit"><?php echo _("Save") ?></button>
</div>
</div>
<?php else : ?> <?php else : ?>
<div><?php echo _("No webstream") ?></div> <div><?php echo _("No webstream") ?></div>
<?php endif; ?> <?php endif; ?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,350 +0,0 @@
var AIRTIME = (function(AIRTIME) {
var mod;
if (AIRTIME.library === undefined) {
AIRTIME.library = {};
}
mod = AIRTIME.library;
mod.checkAddButton = function() {
var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false,
shows = $('tr.sb-header'), current = $('tr.sb-current-show'),
// TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in.
btnText = (window.location.href.toLowerCase().indexOf("schedule") > -1) ? $.i18n._('Add to show') : $.i18n._('Add to next show');
// make sure library items are selected and a cursor is selected.
if (selected !== 0) {
check = true;
}
if (shows.length === 0) {
check = false;
}
if (check) {
AIRTIME.button.enableButton("btn-group #library-plus", false);
} else {
AIRTIME.button.disableButton("btn-group #library-plus", false);
}
if ($("#show_builder_table").is(":visible")) {
if ($cursor.length !== 0) {
btnText = $.i18n._('Add after selected items');
} else if (current.length !== 0) {
btnText = $.i18n._('Add to current show');
}
} else {
var objType = $('.active-tab .obj_type').val();
if (objType === 'block') {
btnText = $.i18n._('Add to current smart block');
} else {
btnText = $.i18n._('Add to current playlist');
}
}
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), btnText);
};
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var $nRow = $(nRow);
if (aData.ftype === "audioclip") {
$nRow.addClass("lib-audio");
$image = $nRow.find('td.library_type');
if (!isAudioSupported(aData.mime)) {
$image.html('<span class="ui-icon ui-icon-locked"></span>');
aData.image = '<span class="ui-icon ui-icon-locked"></span>';
}
} else if (aData.ftype === "stream") {
$nRow.addClass("lib-stream");
} else {
$nRow.addClass("lib-pl");
}
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen",
"timeline");
};
mod.fnDrawCallback = function fnLibDrawCallback() {
mod.redrawChosen();
mod.checkToolBarIcons();
var cb = $('th.library_checkbox');
if (cb.find("input").length == 0) {
cb.append("<input id='super-checkbox' type='checkbox'>");
}
if ($("#show_builder_table").is(":visible")) {
$('#library_display tr.lib-audio, tr.lib-pl, tr.lib-stream')
.draggable(
{
helper: function () {
var $el = $(this), selected = mod
.getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead
.find("th").length, width = $el.width(), message;
// dragging an element that has an unselected
// checkbox.
if (mod.isChosenItem($el) === false) {
selected++;
}
if (selected === 1) {
message = $.i18n._("Adding 1 Item");
} else {
message = sprintf($.i18n._("Adding %s Items"), selected);
}
container = $('<div/>').attr('id',
'draggingContainer').append('<tr/>')
.find("tr").append('<td/>').find("td")
.attr("colspan", colspan).width(width)
.addClass("ui-state-highlight").append(
message).end().end();
return container;
},
cursor: 'pointer',
//cursorAt: {
// top: 30,
// right: 10
//},
distance: 25, // min-distance for dragging
connectToSortable: '#show_builder_table'
});
} else {
$('#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl, tr.lib-block')
.draggable(
{
helper: function () {
var $el = $(this), selected = mod
.getChosenAudioFilesLength(), container, message,
width = $(this).width(), height = 55;
// dragging an element that has an unselected
// checkbox.
if (mod.isChosenItem($el) === false) {
selected++;
}
if (selected === 1) {
message = $.i18n._("Adding 1 Item");
} else {
message = sprintf($.i18n._("Adding %s Items"), selected);
}
container = $('<div class="helper"/>').append(
"<li/>").find("li").addClass(
"ui-state-default").append("<div/>")
.find("div").addClass(
"list-item-container").append(
message).end().width(width)
.height(height).end();
return container;
},
cursor: 'pointer',
//cursorAt: {
// top: 30,
// right: 10
//},
distance: 25, // min-distance for dragging
connectToSortable: '.active-tab .spl_sortable'
});
}
};
mod.dblClickAdd = function(data, type) {
var i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
if ($("#show_builder_table").is(":visible")) {
// process selected files/playlists.
aMediaIds.push({
"id": data.id,
"type": type
});
$("#show_builder_table tr.sb-selected").each(function (i, el) {
aData.push($(el).data("aData"));
});
// process selected schedule rows to add media after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push({
"id": temp.id,
"instance": temp.instance,
"timestamp": temp.timestamp
});
}
if (aSchedIds.length == 0) {
if (!addToCurrentOrNext(aSchedIds)) {
return;
}
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
} else {
// process selected files/playlists.
aMediaIds.push(new Array(data.id, data.ftype));
// check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist'
|| $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
}
}
};
function addToCurrentOrNext(arr) {
var el;
// Add to the end of the current or next show by getting the footer
el = $(".sb-footer.sb-future:first");
var data = el.prev().data("aData");
if (data === undefined) {
alert($.i18n._("Cannot schedule outside a show.\nTry creating a show first."));
return false;
}
arr.push({
"id" : data.id,
"instance" : data.instance,
"timestamp" : data.timestamp
});
if (!isInView(el)) {
$('.dataTables_scrolling.sb-padded').animate({
scrollTop: el.offset().top
}, 0);
}
return true;
}
mod.setupLibraryToolbar = function() {
var $toolbar = $(".lib-content .fg-toolbar:first");
mod.createToolbarButtons();
mod.moveSearchBarToHeader();
$toolbar.append($menu);
// add to timeline button
$toolbar
.find('#library-plus')
.click(
function() {
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
return;
}
var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
if ($("#show_builder_table").is(":visible")) {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push( {
"id" : data.id,
"type" : data.ftype
});
}
// process selected files/playlists.
$("#show_builder_table tr.sb-selected").each(function(i, el) {
aData.push($(el).data("aData"));
});
// process selected schedule rows to add media
// after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push( {
"id" : temp.id,
"instance" : temp.instance,
"timestamp" : temp.timestamp
});
}
if (aSchedIds.length == 0) {
if (!addToCurrentOrNext(aSchedIds)) {
return;
}
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
} else {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push([data.id, data.ftype]);
}
// check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist'
|| $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
}
}
});
// delete from library.
$toolbar.find('.icon-trash').parent().click(function() {
if (AIRTIME.button.isDisabled('icon-trash') === true) {
return;
}
AIRTIME.library.fnDeleteSelectedItems();
});
$toolbar.find('#sb-new').click(function() {
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) {
return;
}
var selection = $(".media_type_selector.selected").attr("selection_id");
if (selection == 2) {
AIRTIME.playlist.fnNew();
} else if (selection == 3) {
AIRTIME.playlist.fnNewBlock();
} else if (selection == 4) {
AIRTIME.playlist.fnWsNew();
}
});
$toolbar.find('#sb-edit').click(function() {
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
return;
}
var selected = $(".lib-selected");
selected.each(function(i, el) {
var data = $(el).data("aData");
if (data.ftype === "audioclip") {
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function(json){
AIRTIME.playlist.fileMdEdit(json);
//buildEditMetadataDialog(json);
});
} else if (data.ftype === "playlist" || data.ftype === "block") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl+'new-playlist/edit');
AIRTIME.playlist.validatePlaylistElements();
} else if (data.ftype === "stream") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'new-webstream/edit');
}
});
});
mod.createToolbarDropDown();
};
return AIRTIME;
}(AIRTIME || {}));

View file

@ -11,7 +11,7 @@ var AIRTIME = (function(AIRTIME) {
var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false, var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false,
shows = $('tr.sb-header'), current = $('tr.sb-current-show'), shows = $('tr.sb-header'), current = $('tr.sb-current-show'),
// TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in. // TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in.
cursorText = (window.location.href.toLowerCase().indexOf("schedule") > -1) ? $.i18n._('Add to show') : $.i18n._('Add to next show'); btnText = (window.location.href.toLowerCase().indexOf("schedule") > -1) ? $.i18n._('Add to show') : $.i18n._('Add to next show');
// make sure library items are selected and a cursor is selected. // make sure library items are selected and a cursor is selected.
if (selected !== 0) { if (selected !== 0) {
@ -22,18 +22,27 @@ var AIRTIME = (function(AIRTIME) {
check = false; check = false;
} }
if (check === true) { if (check) {
AIRTIME.button.enableButton("btn-group #library-plus", false); AIRTIME.button.enableButton("btn-group #library-plus", false);
} else { } else {
AIRTIME.button.disableButton("btn-group #library-plus", false); AIRTIME.button.disableButton("btn-group #library-plus", false);
} }
if ($cursor.length !== 0) { if ($("#show_builder_table").is(":visible")) {
cursorText = $.i18n._('Add before selected items'); if ($cursor.length !== 0) {
} else if (current.length !== 0) { btnText = $.i18n._('Add after selected items');
cursorText = $.i18n._('Add to current show'); } else if (current.length !== 0) {
btnText = $.i18n._('Add to current show');
}
} else {
var objType = $('.active-tab .obj_type').val();
if (objType === 'block') {
btnText = $.i18n._('Add to current smart block');
} else {
btnText = $.i18n._('Add to current playlist');
}
} }
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), ' '+ cursorText); AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), btnText);
}; };
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) { mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
@ -53,7 +62,7 @@ var AIRTIME = (function(AIRTIME) {
} }
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen", $nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen",
"timeline"); "timeline");
}; };
mod.fnDrawCallback = function fnLibDrawCallback() { mod.fnDrawCallback = function fnLibDrawCallback() {
@ -61,15 +70,20 @@ var AIRTIME = (function(AIRTIME) {
mod.redrawChosen(); mod.redrawChosen();
mod.checkToolBarIcons(); mod.checkToolBarIcons();
$('#library_display tr.lib-audio, tr.lib-pl, tr.lib-stream') var cb = $('th.library_checkbox');
.draggable( if (cb.find("input").length == 0) {
cb.append("<input id='super-checkbox' type='checkbox'>");
}
if ($("#show_builder_table").is(":visible")) {
$('#library_display tr.lib-audio, tr.lib-pl, tr.lib-stream')
.draggable(
{ {
helper : function() { helper: function () {
var $el = $(this), selected = mod var $el = $(this), selected = mod
.getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead .getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead
.find("th").length, width = thead.find( .find("th").length, width = $el.width(), message;
"tr:first").width(), message;
// dragging an element that has an unselected // dragging an element that has an unselected
// checkbox. // checkbox.
@ -84,73 +98,123 @@ var AIRTIME = (function(AIRTIME) {
} }
container = $('<div/>').attr('id', container = $('<div/>').attr('id',
'draggingContainer').append('<tr/>') 'draggingContainer').append('<tr/>')
.find("tr").append('<td/>').find("td") .find("tr").append('<td/>').find("td")
.attr("colspan", colspan).width(width) .attr("colspan", colspan).width(width)
.addClass("ui-state-highlight").append( .addClass("ui-state-highlight").append(
message).end().end(); message).end().end();
return container; return container;
}, },
cursor : 'pointer', cursor: 'pointer',
cursorAt: { //cursorAt: {
top: 30, // top: 30,
left: 100 // right: 10
}, //},
connectToSortable : '#show_builder_table' distance: 25, // min-distance for dragging
connectToSortable: '#show_builder_table'
}); });
} else {
$('#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl, tr.lib-block')
.draggable(
{
helper: function () {
var $el = $(this), selected = mod
.getChosenAudioFilesLength(), container, message,
width = $(this).width(), height = 55;
// dragging an element that has an unselected
// checkbox.
if (mod.isChosenItem($el) === false) {
selected++;
}
if (selected === 1) {
message = $.i18n._("Adding 1 Item");
} else {
message = sprintf($.i18n._("Adding %s Items"), selected);
}
container = $('<div class="helper"/>').append(
"<li/>").find("li").addClass(
"ui-state-default").append("<div/>")
.find("div").addClass(
"list-item-container").append(
message).end().width(width)
.height(height).end();
return container;
},
cursor: 'pointer',
//cursorAt: {
// top: 30,
// right: 10
//},
distance: 25, // min-distance for dragging
connectToSortable: '.active-tab .spl_sortable'
});
}
}; };
mod.dblClickAdd = function(data, type) { mod.dblClickAdd = function(data, type) {
var i, length, temp, aMediaIds = [], aSchedIds = [], aData = []; var i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
// process selected files/playlists. if ($("#show_builder_table").is(":visible")) {
aMediaIds.push( { // process selected files/playlists.
"id" : data.id, aMediaIds.push({
"type" : type "id": data.id,
}); "type": type
$("#show_builder_table tr.sb-selected").each(function(i, el) {
aData.push($(el).prev().data("aData"));
});
// process selected schedule rows to add media after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push( {
"id" : temp.id,
"instance" : temp.instance,
"timestamp" : temp.timestamp
}); });
}
if (aSchedIds.length == 0) { $("#show_builder_table tr.sb-selected").each(function (i, el) {
if (!addToCurrentOrNext(aSchedIds)) { aData.push($(el).data("aData"));
return; });
// process selected schedule rows to add media after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push({
"id": temp.id,
"instance": temp.instance,
"timestamp": temp.timestamp
});
}
if (aSchedIds.length == 0) {
if (!addToCurrentOrNext(aSchedIds)) {
return;
}
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
} else {
// process selected files/playlists.
aMediaIds.push(new Array(data.id, data.ftype));
// check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist'
|| $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
} }
} }
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
}; };
function addToCurrentOrNext(arr) { function addToCurrentOrNext(arr) {
var el; var el;
// Get the show instance id of the first non-data row (id = 0) // Add to the end of the current or next show by getting the footer
// The second last row in the table with that instance id is the el = $(".sb-footer.sb-future:first");
// last schedule item for the first show. (This is important for var data = el.prev().data("aData");
// the Now Playing screen if multiple shows are in view).
el = $("[si_id="+$("#0").attr("si_id")+"]");
var temp = el.eq(-2).data("aData");
if (temp === undefined) { if (data === undefined) {
alert($.i18n._("Cannot schedule outside a show.")); alert($.i18n._("Cannot schedule outside a show.\nTry creating a show first."));
return false; return false;
} }
arr.push({ arr.push({
"id" : temp.id, "id" : data.id,
"instance" : temp.instance, "instance" : data.instance,
"timestamp" : temp.timestamp "timestamp" : data.timestamp
}); });
if (!isInView(el)) { if (!isInView(el)) {
@ -159,57 +223,72 @@ var AIRTIME = (function(AIRTIME) {
}, 0); }, 0);
} }
return arr; return true;
} }
mod.setupLibraryToolbar = function() { mod.setupLibraryToolbar = function() {
var $toolbar = $(".lib-content .fg-toolbar:first"); var $toolbar = $(".lib-content .fg-toolbar:first");
mod.createToolbarButtons(); mod.createToolbarButtons();
mod.moveSearchBarToHeader();
$toolbar.append($menu); $toolbar.append($menu);
// add to timeline button // add to timeline button
$toolbar $toolbar
.find('.icon-plus').parent() .find('#library-plus')
.click( .click(
function() { function() {
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) { if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
return; return;
} }
var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
// process selected files/playlists.
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push( {
"id" : data.id,
"type" : data.ftype
});
}
$("#show_builder_table tr.sb-selected")
.each(function(i, el) {
aData.push($(el).prev().data("aData"));
});
// process selected schedule rows to add media
// after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push( {
"id" : temp.id,
"instance" : temp.instance,
"timestamp" : temp.timestamp
});
}
if (aSchedIds.length == 0) { var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
addToCurrentOrNext(aSchedIds);
if ($("#show_builder_table").is(":visible")) {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push( {
"id" : data.id,
"type" : data.ftype
});
}
// process selected files/playlists.
$("#show_builder_table tr.sb-selected").each(function(i, el) {
aData.push($(el).data("aData"));
});
// process selected schedule rows to add media
// after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push( {
"id" : temp.id,
"instance" : temp.instance,
"timestamp" : temp.timestamp
});
}
if (aSchedIds.length == 0) {
if (!addToCurrentOrNext(aSchedIds)) {
return;
}
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
} else {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push([data.id, data.ftype]);
}
// check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist'
|| $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
}
} }
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
}); });
// delete from library. // delete from library.
@ -222,6 +301,47 @@ var AIRTIME = (function(AIRTIME) {
AIRTIME.library.fnDeleteSelectedItems(); AIRTIME.library.fnDeleteSelectedItems();
}); });
$toolbar.find('#sb-new').click(function() {
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) {
return;
}
var selection = $(".media_type_selector.selected").attr("selection_id");
if (selection == 2) {
AIRTIME.playlist.fnNew();
} else if (selection == 3) {
AIRTIME.playlist.fnNewBlock();
} else if (selection == 4) {
AIRTIME.playlist.fnWsNew();
}
});
$toolbar.find('#sb-edit').click(function() {
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
return;
}
var selected = $(".lib-selected");
selected.each(function(i, el) {
var data = $(el).data("aData");
if (data.ftype === "audioclip") {
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function(json){
AIRTIME.playlist.fileMdEdit(json);
//buildEditMetadataDialog(json);
});
} else if (data.ftype === "playlist" || data.ftype === "block") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl+'playlist/edit');
AIRTIME.playlist.validatePlaylistElements();
} else if (data.ftype === "stream") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'webstream/edit');
}
});
});
mod.createToolbarDropDown(); mod.createToolbarDropDown();
}; };

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,609 +0,0 @@
$(document).ready(function() {
setSmartBlockEvents();
});
function setSmartBlockEvents() {
var activeTab = $('.active-tab'),
form = activeTab.find('.smart-block-form');
/********** ADD CRITERIA ROW **********/
form.find('#criteria_add').live('click', function(){
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
div.find('.db-logic-label').text('and').show();
div = div.next().show();
div.children().removeAttr('disabled');
div = div.next();
if (div.length === 0) {
$(this).hide();
}
appendAddButton();
appendModAddButton();
removeButtonCheck();
});
/********** ADD MODIFIER ROW **********/
form.find('a[id^="modifier_add"]').live('click', function(){
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
//make new modifier row
var newRow = $(this).parent().clone(),
newRowCrit = newRow.find('select[name^="sp_criteria_field"]'),
newRowMod = newRow.find('select[name^="sp_criteria_modifier"]'),
newRowVal = newRow.find('input[name^="sp_criteria_value"]'),
newRowExtra = newRow.find('input[name^="sp_criteria_extra"]'),
newRowRemove = newRow.find('a[id^="criteria_remove"]');
//remove error msg
if (newRow.children().hasClass('errors sp-errors')) {
newRow.find('span[class="errors sp-errors"]').remove();
}
//hide the critieria field select box
newRowCrit.addClass('sp-invisible');
//keep criteria value the same
newRowCrit.val(criteria_value);
//reset all other values
newRowMod.val('0');
newRowVal.val('');
newRowExtra.val('');
disableAndHideExtraField(newRowVal);
sizeTextBoxes(newRowVal, 'sp_extra_input_text', 'sp_input_text');
//remove the 'criteria add' button from new modifier row
newRow.find('#criteria_add').remove();
$(this).parent().after(newRow);
reindexElements();
appendAddButton();
appendModAddButton();
removeButtonCheck();
});
/********** REMOVE ROW **********/
form.find('a[id^="criteria_remove"]').live('click', function(){
var curr = $(this).parent();
var curr_pos = curr.index();
var list = curr.parent();
var list_length = list.find("div:visible").length;
var count = list_length - curr_pos;
var next = curr.next();
var item_to_hide;
var prev;
var index;
//remove error message from current row, if any
var error_element = curr.find('span[class="errors sp-errors"]');
if (error_element.is(':visible')) {
error_element.remove();
}
/* assign next row to current row for all rows below and including
* the row getting removed
*/
for (var i=0; i<count; i++) {
index = getRowIndex(curr);
var criteria = next.find('[name^="sp_criteria_field"]').val();
curr.find('[name^="sp_criteria_field"]').val(criteria);
var modifier = next.find('[name^="sp_criteria_modifier"]').val();
populateModifierSelect(curr.find('[name^="sp_criteria_field"]'), false);
curr.find('[name^="sp_criteria_modifier"]').val(modifier);
var criteria_value = next.find('[name^="sp_criteria_value"]').val();
curr.find('[name^="sp_criteria_value"]').val(criteria_value);
/* if current and next row have the extra criteria value
* (for 'is in the range' modifier), then assign the next
* extra value to current and remove that element from
* next row
*/
if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
&& next.find('#extra_criteria').is(':visible')) {
var criteria_extra = next.find('[name^="sp_criteria_extra"]').val();
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
disableAndHideExtraField(next.find(':first-child'), getRowIndex(next));
/* if only the current row has the extra criteria value,
* then just remove the current row's extra criteria element
*/
} else if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
&& next.find('#extra_criteria').not(':visible')) {
disableAndHideExtraField(curr.find(':first-child'), index);
/* if only the next row has the extra criteria value,
* then add the extra criteria element to current row
* and assign next row's value to it
*/
} else if (next.find('#extra_criteria').is(':visible')) {
criteria_extra = next.find('[name^="sp_criteria_extra"]').val();
enableAndShowExtraField(curr.find(':first-child'), index);
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
}
/* determine if current row is a modifier row
* if it is, make the criteria select invisible
*/
prev = curr.prev();
if (curr.find('[name^="sp_criteria_field"]').val() == prev.find('[name^="sp_criteria_field"]').val()) {
if (!curr.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
curr.find('select[name^="sp_criteria_field"]').addClass('sp-invisible');
}
} else {
if (curr.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
curr.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible');
}
}
curr = next;
next = curr.next();
}
/* Disable the last visible row since it holds the values the user removed
* Reset the values to empty and resize the criteria value textbox
* in case the row had the extra criteria textbox
*/
item_to_hide = list.find('div:visible:last');
item_to_hide.children().attr('disabled', 'disabled');
if (item_to_hide.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
item_to_hide.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible');
}
item_to_hide.find('[name^="sp_criteria_field"]').val(0).end()
.find('[name^="sp_criteria_modifier"]').val(0).end()
.find('[name^="sp_criteria_value"]').val('').end()
.find('[name^="sp_criteria_extra"]').val('');
sizeTextBoxes(item_to_hide.find('[name^="sp_criteria_value"]'), 'sp_extra_input_text', 'sp_input_text');
item_to_hide.hide();
list.next().show();
//check if last row is a modifier row
var last_row = list.find('div:visible:last');
if (last_row.find('[name^="sp_criteria_field"]').val() == last_row.prev().find('[name^="sp_criteria_field"]').val()) {
if (!last_row.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
last_row.find('select[name^="sp_criteria_field"]').addClass('sp-invisible');
}
}
// always put '+' button on the last enabled row
appendAddButton();
reindexElements();
// always put '+' button on the last modifier row
appendModAddButton();
// remove the 'x' button if only one row is enabled
removeButtonCheck();
});
/********** SAVE ACTION **********/
// moved to spl.js
/********** GENERATE ACTION **********/
activeTab.find('button[id="generate_button"]').live("click", function(){
buttonClickAction('generate', 'new-playlist/smart-block-generate');
});
/********** SHUFFLE ACTION **********/
activeTab.find('button[id="shuffle_button"]').live("click", function(){
buttonClickAction('shuffle', 'new-playlist/smart-block-shuffle');
});
/********** CHANGE PLAYLIST TYPE **********/
form.find('dd[id="sp_type-element"]').live("change", function(){
setupUI();
AIRTIME.library.checkAddButton();
});
/********** CRITERIA CHANGE **********/
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"])').live("change", function(){
var index = getRowIndex($(this).parent());
//need to change the criteria value for any modifier rows
var critVal = $(this).val();
var divs = $(this).parent().nextAll(':visible');
$.each(divs, function(i, div){
var critSelect = $(div).children('select[id^="sp_criteria_field"]');
if (critSelect.hasClass('sp-invisible')) {
critSelect.val(critVal);
/* If the select box is visible we know the modifier rows
* have ended
*/
} else {
return false;
}
});
// disable extra field and hide the span
disableAndHideExtraField($(this), index);
populateModifierSelect(this, true);
});
/********** MODIFIER CHANGE **********/
form.find('select[id^="sp_criteria_modifier"]').live("change", function(){
var criteria_value = $(this).next(),
index_num = getRowIndex($(this).parent());
if ($(this).val() == 'is in the range') {
enableAndShowExtraField(criteria_value, index_num);
} else {
disableAndHideExtraField(criteria_value, index_num);
}
});
setupUI();
appendAddButton();
appendModAddButton();
removeButtonCheck();
}
function getRowIndex(ele) {
var id = ele.find('[name^="sp_criteria_field"]').attr('id'),
delimiter = '_',
start = 3,
tokens = id.split(delimiter).slice(start),
index = tokens.join(delimiter);
return index;
}
/* This function appends a '+' button for the last
* modifier row of each criteria.
* If there are no modifier rows, the '+' button
* remains at the criteria row
*/
function appendModAddButton() {
var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_modifier"]').parent(':visible');
$.each(divs, function(i, div){
if (i > 0) {
/* If the criteria field is hidden we know it is a modifier row
* and can hide the previous row's modifier add button
*/
if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
$(div).prev().find('a[id^="modifier_add"]').addClass('sp-invisible');
} else {
$(div).prev().find('a[id^="modifier_add"]').removeClass('sp-invisible');
}
}
//always add modifier add button to the last row
if (i+1 == divs.length) {
$(div).find('a[id^="modifier_add"]').removeClass('sp-invisible');
}
});
}
/* This function re-indexes all the form elements.
* We need to do this everytime a row gets deleted
*/
function reindexElements() {
var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_field"]').parent(),
index = 0,
modIndex = 0;
/* Hide all logic labels
* We will re-add them as each row gets indexed
*/
$('.db-logic-label').text('').hide();
$.each(divs, function(i, div){
if (i > 0 && index < 26) {
/* If the current row's criteria field is hidden we know it is
* a modifier row
*/
if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
if ($(div).is(':visible')) {
$(div).prev().find('.db-logic-label').text('or').show();
}
modIndex++;
} else {
if ($(div).is(':visible')) {
$(div).prev().find('.db-logic-label').text('and').show();
}
index++;
modIndex = 0;
}
$(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex);
$(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex);
$(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex);
$(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex);
$(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex);
$(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex);
$(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex);
$(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex);
$(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index);
$(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex);
} else if (i > 0) {
$(div).remove();
}
});
}
function buttonClickAction(clickType, url){
var data = $('.active-tab .smart-block-form').serializeArray(),
obj_id = $('.active-tab .obj_id').val();
enableLoadingIcon();
$.post(url, {format: "json", data: data, obj_id: obj_id}, function(data){
callback(data, clickType);
disableLoadingIcon();
});
}
function setupUI() {
var activeTab = $('.active-tab'),
playlist_type = activeTab.find('input:radio[name=sp_type]:checked').val();
/* Activate or Deactivate shuffle button
* It is only active if playlist is not empty
*/
var sortable = activeTab.find('.spl_sortable'),
plContents = sortable.children(),
shuffleButton = activeTab.find('.sp-button, #pl-bl-clear-content');
if (!plContents.hasClass('spl_empty')) {
if (shuffleButton.hasClass('ui-state-disabled')) {
shuffleButton.removeClass('ui-state-disabled');
shuffleButton.removeAttr('disabled');
}
} else if (!shuffleButton.hasClass('ui-state-disabled')) {
shuffleButton.addClass('ui-state-disabled');
shuffleButton.attr('disabled', 'disabled');
}
if (activeTab.find('.obj_type').val() == 'block') {
if (playlist_type == "0") {
shuffleButton.parent().show();
sortable.show();
} else {
shuffleButton.parent().hide();
sortable.hide();
}
}
$(".playlist_type_help_icon").qtip({
content: {
text: $.i18n._("A static smart block will save the criteria and generate the block content immediately. This allows you to edit and view it in the Library before adding it to a show.")+"<br /><br />" +
$.i18n._("A dynamic smart block will only save the criteria. The block content will get generated upon adding it to a show. You will not be able to view and edit the content in the Library.")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
}
});
$(".repeat_tracks_help_icon").qtip({
content: {
text: sprintf($.i18n._("The desired block length will not be reached if %s cannot find enough unique tracks to match your criteria. Enable this option if you wish to allow tracks to be added multiple times to the smart block."), PRODUCT_NAME)
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
}
});
}
function enableAndShowExtraField(valEle, index) {
var spanExtra = valEle.nextAll("#extra_criteria");
spanExtra.children('#sp_criteria_extra_'+index).removeAttr("disabled");
spanExtra.show();
//make value input smaller since we have extra element now
var criteria_val = $('#sp_criteria_value_'+index);
sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text');
}
function disableAndHideExtraField(valEle, index) {
var spanExtra = valEle.nextAll("#extra_criteria");
spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled");
spanExtra.hide();
//make value input larger since we don't have extra field now
var criteria_value = $('#sp_criteria_value_'+index);
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
}
function sizeTextBoxes(ele, classToRemove, classToAdd) {
if (ele.hasClass(classToRemove)) {
ele.removeClass(classToRemove).addClass(classToAdd);
}
}
function populateModifierSelect(e, popAllMods) {
var criteria_type = getCriteriaOptionType(e),
index = getRowIndex($(e).parent()),
divs;
if (popAllMods) {
index = index.substring(0, 1);
}
divs = $(e).parents().find('select[id^="sp_criteria_modifier_'+index+'"]');
$.each(divs, function(i, div){
$(div).children().remove();
if (criteria_type == 's') {
$.each(stringCriteriaOptions, function(key, value){
$(div).append($('<option></option>')
.attr('value', key)
.text(value));
});
} else {
$.each(numericCriteriaOptions, function(key, value){
$(div).append($('<option></option>')
.attr('value', key)
.text(value));
});
}
});
}
function getCriteriaOptionType(e) {
var criteria = $(e).val();
return criteriaTypes[criteria];
}
function callback(json, type) {
var dt = $('table[id="library_display"]').dataTable(),
form = $('.active-tab .smart-block-form');
if (type == 'shuffle' || type == 'generate') {
if (json.error !== undefined) {
alert(json.error);
}
AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json);
if (json.result == "0") {
if (type == 'shuffle') {
form.find('.success').text($.i18n._('Smart block shuffled'));
} else if (type == 'generate') {
form.find('.success').text($.i18n._('Smart block generated and criteria saved'));
//redraw library table so the length gets updated
dt.fnStandingRedraw();
}
form.find('.success').show();
}
form.find('#smart_block_options').removeClass("closed");
} else {
AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json);
if (json.result == "0") {
$('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show();
//redraw library table so the length gets updated
dt.fnStandingRedraw();
}
form.find('#smart_block_options').removeClass("closed");
}
setTimeout(removeSuccessMsg, 5000);
}
function appendAddButton() {
var add_button = "<a class='btn btn-small' id='criteria_add'>" +
"<i class='icon-white icon-plus'></i></a>";
var rows = $('.active-tab #smart_block_options'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
rows.find('#criteria_add').remove();
if (enabled.length > 1) {
rows.find('select[name^="sp_criteria_field"]:enabled:last')
.siblings('a[id^="criteria_remove"]')
.after(add_button);
} else {
enabled.siblings('span[id="extra_criteria"]')
.after(add_button);
}
}
function removeButtonCheck() {
var rows = $('.active-tab dd[id="sp_criteria-element"]').children('div'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled'),
rmv_button = enabled.siblings('a[id^="criteria_remove"]');
if (enabled.length == 1) {
rmv_button.attr('disabled', 'disabled');
rmv_button.hide();
} else {
rmv_button.removeAttr('disabled');
rmv_button.show();
}
}
function enableLoadingIcon() {
$(".side_playlist.active-tab").block({
message: $.i18n._("Processing..."),
theme: true,
allowBodyStretch: true,
applyPlatformOpacityRules: false
});
}
function disableLoadingIcon() {
$(".side_playlist.active-tab").unblock()
}
// We need to know if the criteria value will be a string
// or numeric value in order to populate the modifier
// select list
var criteriaTypes = {
0 : "",
"album_title" : "s",
"bit_rate" : "n",
"bpm" : "n",
"composer" : "s",
"conductor" : "s",
"copyright" : "s",
"cuein" : "n",
"cueout" : "n",
"artist_name" : "s",
"encoded_by" : "s",
"utime" : "n",
"mtime" : "n",
"lptime" : "n",
"genre" : "s",
"isrc_number" : "s",
"label" : "s",
"language" : "s",
"length" : "n",
"mime" : "s",
"mood" : "s",
"owner_id" : "s",
"replay_gain" : "n",
"sample_rate" : "n",
"track_title" : "s",
"track_number" : "n",
"info_url" : "s",
"year" : "n"
};
var stringCriteriaOptions = {
"0" : $.i18n._("Select modifier"),
"contains" : $.i18n._("contains"),
"does not contain" : $.i18n._("does not contain"),
"is" : $.i18n._("is"),
"is not" : $.i18n._("is not"),
"starts with" : $.i18n._("starts with"),
"ends with" : $.i18n._("ends with")
};
var numericCriteriaOptions = {
"0" : $.i18n._("Select modifier"),
"is" : $.i18n._("is"),
"is not" : $.i18n._("is not"),
"is greater than" : $.i18n._("is greater than"),
"is less than" : $.i18n._("is less than"),
"is in the range" : $.i18n._("is in the range")
};

View file

@ -3,7 +3,8 @@ $(document).ready(function() {
}); });
function setSmartBlockEvents() { function setSmartBlockEvents() {
var form = $('#smart-block-form'); var activeTab = $('.active-tab'),
form = activeTab.find('.smart-block-form');
/********** ADD CRITERIA ROW **********/ /********** ADD CRITERIA ROW **********/
form.find('#criteria_add').live('click', function(){ form.find('#criteria_add').live('click', function(){
@ -28,6 +29,7 @@ function setSmartBlockEvents() {
form.find('a[id^="modifier_add"]').live('click', function(){ form.find('a[id^="modifier_add"]').live('click', function(){
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val(); var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
//make new modifier row //make new modifier row
var newRow = $(this).parent().clone(), var newRow = $(this).parent().clone(),
newRowCrit = newRow.find('select[name^="sp_criteria_field"]'), newRowCrit = newRow.find('select[name^="sp_criteria_field"]'),
@ -190,13 +192,13 @@ function setSmartBlockEvents() {
// moved to spl.js // moved to spl.js
/********** GENERATE ACTION **********/ /********** GENERATE ACTION **********/
$('button[id="generate_button"]').live("click", function(){ activeTab.find('button[id="generate_button"]').live("click", function(){
buttonClickAction('generate', 'Playlist/smart-block-generate'); buttonClickAction('generate', 'playlist/smart-block-generate');
}); });
/********** SHUFFLE ACTION **********/ /********** SHUFFLE ACTION **********/
$('button[id="shuffle_button"]').live("click", function(){ activeTab.find('button[id="shuffle_button"]').live("click", function(){
buttonClickAction('shuffle', 'Playlist/smart-block-shuffle'); buttonClickAction('shuffle', 'playlist/smart-block-shuffle');
}); });
/********** CHANGE PLAYLIST TYPE **********/ /********** CHANGE PLAYLIST TYPE **********/
@ -262,7 +264,7 @@ function getRowIndex(ele) {
* remains at the criteria row * remains at the criteria row
*/ */
function appendModAddButton() { function appendModAddButton() {
var divs = $('#smart-block-form').find('div select[name^="sp_criteria_modifier"]').parent(':visible'); var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_modifier"]').parent(':visible');
$.each(divs, function(i, div){ $.each(divs, function(i, div){
if (i > 0) { if (i > 0) {
/* If the criteria field is hidden we know it is a modifier row /* If the criteria field is hidden we know it is a modifier row
@ -286,7 +288,7 @@ function appendModAddButton() {
* We need to do this everytime a row gets deleted * We need to do this everytime a row gets deleted
*/ */
function reindexElements() { function reindexElements() {
var divs = $('#smart-block-form').find('div select[name^="sp_criteria_field"]').parent(), var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_field"]').parent(),
index = 0, index = 0,
modIndex = 0; modIndex = 0;
/* Hide all logic labels /* Hide all logic labels
@ -330,8 +332,8 @@ function reindexElements() {
} }
function buttonClickAction(clickType, url){ function buttonClickAction(clickType, url){
var data = $('#smart-block-form').serializeArray(), var data = $('.active-tab .smart-block-form').serializeArray(),
obj_id = $('.obj_id').val(); obj_id = $('.active-tab .obj_id').val();
enableLoadingIcon(); enableLoadingIcon();
$.post(url, {format: "json", data: data, obj_id: obj_id}, function(data){ $.post(url, {format: "json", data: data, obj_id: obj_id}, function(data){
@ -341,17 +343,15 @@ function buttonClickAction(clickType, url){
} }
function setupUI() { function setupUI() {
var playlist_type = $('input:radio[name=sp_type]:checked').val(); var activeTab = $('.active-tab'),
var target_length = $('input[name="sp_limit_value"]').val(); playlist_type = activeTab.find('input:radio[name=sp_type]:checked').val();
if (target_length == '') {
target_length = '0.0';
}
/* Activate or Deactivate shuffle button /* Activate or Deactivate shuffle button
* It is only active if playlist is not empty * It is only active if playlist is not empty
*/ */
var plContents = $('.spl_sortable').children(); var sortable = activeTab.find('.spl_sortable'),
var shuffleButton = $('button[id="shuffle_button"], button[id="playlist_shuffle_button"], button[id="pl-bl-clear-content"]'); plContents = sortable.children(),
shuffleButton = activeTab.find('.sp-button, #pl-bl-clear-content');
if (!plContents.hasClass('spl_empty')) { if (!plContents.hasClass('spl_empty')) {
if (shuffleButton.hasClass('ui-state-disabled')) { if (shuffleButton.hasClass('ui-state-disabled')) {
@ -363,16 +363,13 @@ function setupUI() {
shuffleButton.attr('disabled', 'disabled'); shuffleButton.attr('disabled', 'disabled');
} }
var dynamic_length = target_length; if (activeTab.find('.obj_type').val() == 'block') {
if ($('.obj_type').val() == 'block') {
if (playlist_type == "0") { if (playlist_type == "0") {
$('button[id="generate_button"]').show(); shuffleButton.parent().show();
$('button[id="shuffle_button"]').show(); sortable.show();
$('.spl_sortable').show();
} else { } else {
$('button[id="generate_button"]').hide(); shuffleButton.parent().hide();
$('button[id="shuffle_button"]').hide(); sortable.hide();
$('.spl_sortable').hide();
} }
} }
@ -395,7 +392,7 @@ function setupUI() {
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center"
}, }
}); });
$(".repeat_tracks_help_icon").qtip({ $(".repeat_tracks_help_icon").qtip({
@ -416,7 +413,7 @@ function setupUI() {
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center"
}, }
}); });
} }
@ -481,14 +478,15 @@ function getCriteriaOptionType(e) {
} }
function callback(json, type) { function callback(json, type) {
var dt = $('table[id="library_display"]').dataTable(); var dt = $('table[id="library_display"]').dataTable(),
form = $('.active-tab .smart-block-form');
if (type == 'shuffle' || type == 'generate') { if (type == 'shuffle' || type == 'generate') {
if (json.error !== undefined) { if (json.error !== undefined) {
alert(json.error); alert(json.error);
} }
AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json); AIRTIME.playlist.fnOpenPlaylist(json);
var form = $('#smart-block-form');
if (json.result == "0") { if (json.result == "0") {
if (type == 'shuffle') { if (type == 'shuffle') {
form.find('.success').text($.i18n._('Smart block shuffled')); form.find('.success').text($.i18n._('Smart block shuffled'));
@ -501,14 +499,12 @@ function callback(json, type) {
} }
form.find('#smart_block_options').removeClass("closed"); form.find('#smart_block_options').removeClass("closed");
} else { } else {
AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json); AIRTIME.playlist.fnOpenPlaylist(json);
var form = $('#smart-block-form');
if (json.result == "0") { if (json.result == "0") {
$('#sp-success-saved').text($.i18n._('Smart block saved')); $('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show();
$('#sp-success-saved').show();
//redraw library table so the length gets updated //redraw library table so the length gets updated
var dt = $('table[id="library_display"]').dataTable();
dt.fnStandingRedraw(); dt.fnStandingRedraw();
} }
form.find('#smart_block_options').removeClass("closed"); form.find('#smart_block_options').removeClass("closed");
@ -519,7 +515,7 @@ function callback(json, type) {
function appendAddButton() { function appendAddButton() {
var add_button = "<a class='btn btn-small' id='criteria_add'>" + var add_button = "<a class='btn btn-small' id='criteria_add'>" +
"<i class='icon-white icon-plus'></i></a>"; "<i class='icon-white icon-plus'></i></a>";
var rows = $('#smart_block_options'), var rows = $('.active-tab #smart_block_options'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled'); enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
rows.find('#criteria_add').remove(); rows.find('#criteria_add').remove();
@ -535,7 +531,7 @@ function appendAddButton() {
} }
function removeButtonCheck() { function removeButtonCheck() {
var rows = $('dd[id="sp_criteria-element"]').children('div'), var rows = $('.active-tab dd[id="sp_criteria-element"]').children('div'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled'), enabled = rows.find('select[name^="sp_criteria_field"]:enabled'),
rmv_button = enabled.siblings('a[id^="criteria_remove"]'); rmv_button = enabled.siblings('a[id^="criteria_remove"]');
if (enabled.length == 1) { if (enabled.length == 1) {
@ -548,7 +544,7 @@ function removeButtonCheck() {
} }
function enableLoadingIcon() { function enableLoadingIcon() {
$(".side_playlist").block({ $(".side_playlist.active-tab").block({
message: $.i18n._("Processing..."), message: $.i18n._("Processing..."),
theme: true, theme: true,
allowBodyStretch: true, allowBodyStretch: true,
@ -557,7 +553,7 @@ function enableLoadingIcon() {
} }
function disableLoadingIcon() { function disableLoadingIcon() {
$(".side_playlist").unblock() $(".side_playlist.active-tab").unblock()
} }
// We need to know if the criteria value will be a string // We need to know if the criteria value will be a string
// or numeric value in order to populate the modifier // or numeric value in order to populate the modifier

File diff suppressed because it is too large Load diff

View file

@ -1,360 +0,0 @@
AIRTIME = (function(AIRTIME) {
var viewport,
$lib,
$libWrapper,
$builder,
$fs,
widgetHeight,
screenWidth,
resizeTimeout,
oBaseDatePickerSettings,
oBaseTimePickerSettings,
oRange,
dateStartId = "#sb_date_start",
timeStartId = "#sb_time_start",
dateEndId = "#sb_date_end",
timeEndId = "#sb_time_end",
mod;
if (AIRTIME.builderMain === undefined) {
AIRTIME.builderMain = {};
}
mod = AIRTIME.builderMain;
oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd',
//i18n_months, i18n_days_short are in common.js
monthNames: i18n_months,
dayNamesMin: i18n_days_short,
onClick: function(sDate, oDatePicker) {
$(this).datepicker( "setDate", sDate );
},
onClose: validateTimeRange
};
oBaseTimePickerSettings = {
showPeriodLabels: false,
showCloseButton: true,
closeButtonText: $.i18n._("Done"),
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
};
function setWidgetSize() {
viewport = AIRTIME.utilities.findViewportDimensions();
widgetHeight = viewport.height - 180;
screenWidth = Math.floor(viewport.width - 50);
var libTableHeight = widgetHeight - 175,
builderTableHeight = widgetHeight - 95,
oTable;
if ($fs.is(':visible')) {
builderTableHeight = builderTableHeight - 40;
}
//set the heights of the main widgets.
$builder//.height(widgetHeight)
.find(".dataTables_scrolling")
//.css("max-height", builderTableHeight)
.end();
//.width(screenWidth);
$lib//.height(widgetHeight)
.find(".dataTables_scrolling")
//.css("max-height", libTableHeight)
.end();
if ($lib.filter(':visible').length > 0) {
//$lib.width(Math.floor(screenWidth * 0.47));
$builder//.width(Math.floor(screenWidth * 0.47))
.find("#sb_edit")
.remove()
.end()
.find("#sb_date_start")
.css("margin-left", 0)
.end();
oTable = $('#show_builder_table').dataTable();
//oTable.fnDraw();
}
}
function validateTimeRange() {
var oRange,
inputs = $('.sb-timerange > input'),
start, end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
start = oRange.start;
end = oRange.end;
if (end >= start) {
inputs.removeClass('error');
}
else {
if (!inputs.hasClass('error')) {
inputs.addClass('error');
}
}
return {
start: start,
end: end,
isValid: end >= start
};
}
function showSearchSubmit() {
var fn,
op,
oTable = $('#show_builder_table').dataTable(),
check;
check = validateTimeRange();
if (check.isValid) {
//reset timestamp value since input values could have changed.
AIRTIME.showbuilder.resetTimestamp();
fn = oTable.fnSettings().fnServerData;
fn.start = check.start;
fn.end = check.end;
op = $("div.sb-advanced-options");
if (op.is(":visible")) {
if (fn.ops === undefined) {
fn.ops = {};
}
fn.ops.showFilter = op.find("#sb_show_filter").val();
fn.ops.myShows = op.find("#sb_my_shows").is(":checked") ? 1 : 0;
}
oTable.fnDraw();
}
}
mod.onReady = function() {
// Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
// We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list
Dropzone.options.content = {
url:'/rest/media',
clickable: false,
acceptedFiles: acceptedMimeTypes.join(),
init: function () {
this.on("sending", function (file, xhr, data) {
data.append("csrf_token", $("#csrf").val());
});
},
dictDefaultMessage: '',
createImageThumbnails: false,
previewTemplate : '<div style="display:none"></div>'
};
// define module vars.
$lib = $("#library_content");
$builder = $("#show_builder");
$fs = $builder.find('fieldset');
$("#schedule-tab").on("click", function() {
if (!$(this).hasClass('active')) {
AIRTIME.showbuilder.switchTab($("#show_builder .outer-datatable-wrapper"), $(this));
}
});
/*
* Icon hover states for search.
*/
$builder.on("mouseenter", ".sb-timerange .ui-button", function(ev) {
$(this).addClass("ui-state-hover");
});
$builder.on("mouseleave", ".sb-timerange .ui-button", function(ev) {
$(this).removeClass("ui-state-hover");
});
$builder.find(dateStartId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange);
$builder.find(timeStartId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
$builder.find(dateEndId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange);
$builder.find(timeEndId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId,
dateEndId, timeEndId);
AIRTIME.showbuilder.fnServerData.start = oRange.start;
AIRTIME.showbuilder.fnServerData.end = oRange.end;
//the user might not have the library on the page (guest user)
if (AIRTIME.library !== undefined) {
AIRTIME.library.libraryInit();
}
AIRTIME.showbuilder.builderDataTable();
setWidgetSize();
$libWrapper = $lib.find("#library_display_wrapper");
//$builder.find('.dataTables_scrolling').css("max-height",
// widgetHeight - 95);
$builder.on("click", "#sb_submit", showSearchSubmit);
$builder.on("click", "#sb_edit", function(ev) {
var schedTable = $("#show_builder_table").dataTable();
// reset timestamp to redraw the cursors.
AIRTIME.showbuilder.resetTimestamp();
$lib.show().width(Math.floor(screenWidth * 0.48));
$builder.width(Math.floor(screenWidth * 0.48)).find("#sb_edit")
.remove().end().find("#sb_date_start")
.css("margin-left", 0).end();
schedTable.fnDraw();
$.ajax( {
url : baseUrl+"usersettings/set-now-playing-screen-settings",
type : "POST",
data : {
settings : {
library : true
},
format : "json"
},
dataType : "json",
success : function() {
}
});
});
$lib.on("click", "#sb_lib_close", function() {
var schedTable = $("#show_builder_table").dataTable();
$lib.hide();
$builder.width(screenWidth).find(".sb-timerange").find("#sb_date_start").css("margin-left", 30)
.end().end();
schedTable.fnDraw();
$.ajax( {
url : baseUrl+"usersettings/set-now-playing-screen-settings",
type : "POST",
data : {
settings : {
library : false
},
format : "json"
},
dataType : "json",
success : function() {
}
});
});
$builder.find('legend').click(
function(ev, item) {
if ($fs.hasClass("closed")) {
$fs.removeClass("closed");
//$builder.find('.dataTables_scrolling').css(
// "max-height", widgetHeight - 150);
} else {
$fs.addClass("closed");
// set defaults for the options.
$fs.find('select').val(0);
$fs.find('input[type="checkbox"]').attr("checked",
false);
//$builder.find('.dataTables_scrolling').css(
// "max-height", widgetHeight - 110);
}
});
// set click event for all my shows checkbox.
$builder.on("click", "#sb_my_shows", function(ev) {
if ($(this).is(':checked')) {
$(ev.delegateTarget).find('#sb_show_filter').val(0);
}
showSearchSubmit();
});
//set select event for choosing a show.
$builder.on("change", '#sb_show_filter', function(ev) {
if ($(this).val() !== 0) {
$(ev.delegateTarget).find('#sb_my_shows')
.attr("checked", false);
}
showSearchSubmit();
});
function checkScheduleUpdates() {
var data = {}, oTable = $('#show_builder_table').dataTable(), fn = oTable
.fnSettings().fnServerData, start = fn.start, end = fn.end;
data["format"] = "json";
data["start"] = start;
data["end"] = end;
data["timestamp"] = AIRTIME.showbuilder.getTimestamp();
data["instances"] = AIRTIME.showbuilder.getShowInstances();
if (fn.hasOwnProperty("ops")) {
data["myShows"] = fn.ops.myShows;
data["showFilter"] = fn.ops.showFilter;
data["showInstanceFilter"] = fn.ops.showInstanceFilter;
}
$.ajax( {
"dataType" : "json",
"type" : "GET",
"url" : baseUrl+"showbuilder/check-builder-feed",
"data" : data,
"success" : function(json) {
if (json.update === true) {
oTable.fnDraw();
}
setTimeout(checkScheduleUpdates, 5000);
}
});
//check if the timeline view needs updating.
setTimeout(checkScheduleUpdates, 5000);
}
};
mod.onResize = function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(setWidgetSize, 100);
};
return AIRTIME;
} (AIRTIME || {}));
$(document).ready(AIRTIME.builderMain.onReady);
$(window).resize(AIRTIME.builderMain.onResize);

File diff suppressed because it is too large Load diff

View file

@ -15,12 +15,6 @@ AIRTIME = (function(AIRTIME) {
timeStartId = "#sb_time_start", timeStartId = "#sb_time_start",
dateEndId = "#sb_date_end", dateEndId = "#sb_date_end",
timeEndId = "#sb_time_end", timeEndId = "#sb_time_end",
$toggleLib = $("<a id='sb_edit' class='btn btn-small' href='#' title='"+$.i18n._("Open library to add or remove content")+"'>"+$.i18n._("Add / Remove Content")+"</a>"),
$libClose = $('<a />', {
"class": "close-round",
"href": "#",
"id": "sb_lib_close"
}),
mod; mod;
if (AIRTIME.builderMain === undefined) { if (AIRTIME.builderMain === undefined) {
@ -64,22 +58,22 @@ AIRTIME = (function(AIRTIME) {
} }
//set the heights of the main widgets. //set the heights of the main widgets.
$builder.height(widgetHeight) $builder//.height(widgetHeight)
.find(".dataTables_scrolling") .find(".dataTables_scrolling")
.css("max-height", builderTableHeight) //.css("max-height", builderTableHeight)
.end() .end();
.width(screenWidth); //.width(screenWidth);
$lib.height(widgetHeight) $lib//.height(widgetHeight)
.find(".dataTables_scrolling") .find(".dataTables_scrolling")
.css("max-height", libTableHeight) //.css("max-height", libTableHeight)
.end(); .end();
if ($lib.filter(':visible').length > 0) { if ($lib.filter(':visible').length > 0) {
$lib.width(Math.floor(screenWidth * 0.47)); //$lib.width(Math.floor(screenWidth * 0.47));
$builder.width(Math.floor(screenWidth * 0.47)) $builder//.width(Math.floor(screenWidth * 0.47))
.find("#sb_edit") .find("#sb_edit")
.remove() .remove()
.end() .end()
@ -150,11 +144,33 @@ AIRTIME = (function(AIRTIME) {
} }
mod.onReady = function() { mod.onReady = function() {
// Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
// We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list
Dropzone.options.content = {
url:'/rest/media',
clickable: false,
acceptedFiles: acceptedMimeTypes.join(),
init: function () {
this.on("sending", function (file, xhr, data) {
data.append("csrf_token", $("#csrf").val());
});
},
dictDefaultMessage: '',
createImageThumbnails: false,
previewTemplate : '<div style="display:none"></div>'
};
// define module vars. // define module vars.
$lib = $("#library_content"); $lib = $("#library_content");
$builder = $("#show_builder"); $builder = $("#show_builder");
$fs = $builder.find('fieldset'); $fs = $builder.find('fieldset');
$("#schedule-tab").on("click", function() {
if (!$(this).hasClass('active')) {
AIRTIME.showbuilder.switchTab($("#show_builder .outer-datatable-wrapper"), $(this));
}
});
/* /*
* Icon hover states for search. * Icon hover states for search.
*/ */
@ -196,10 +212,8 @@ AIRTIME = (function(AIRTIME) {
setWidgetSize(); setWidgetSize();
$libWrapper = $lib.find("#library_display_wrapper"); $libWrapper = $lib.find("#library_display_wrapper");
$libWrapper.prepend($libClose); //$builder.find('.dataTables_scrolling').css("max-height",
// widgetHeight - 95);
$builder.find('.dataTables_scrolling').css("max-height",
widgetHeight - 95);
$builder.on("click", "#sb_submit", showSearchSubmit); $builder.on("click", "#sb_submit", showSearchSubmit);
@ -236,11 +250,9 @@ AIRTIME = (function(AIRTIME) {
var schedTable = $("#show_builder_table").dataTable(); var schedTable = $("#show_builder_table").dataTable();
$lib.hide(); $lib.hide();
$builder.width(screenWidth).find(".sb-timerange").prepend( $builder.width(screenWidth).find(".sb-timerange").find("#sb_date_start").css("margin-left", 30)
$toggleLib).find("#sb_date_start").css("margin-left", 30)
.end().end(); .end().end();
$toggleLib.removeClass("ui-state-hover");
schedTable.fnDraw(); schedTable.fnDraw();
$.ajax( { $.ajax( {
@ -264,8 +276,8 @@ AIRTIME = (function(AIRTIME) {
if ($fs.hasClass("closed")) { if ($fs.hasClass("closed")) {
$fs.removeClass("closed"); $fs.removeClass("closed");
$builder.find('.dataTables_scrolling').css( //$builder.find('.dataTables_scrolling').css(
"max-height", widgetHeight - 150); // "max-height", widgetHeight - 150);
} else { } else {
$fs.addClass("closed"); $fs.addClass("closed");
@ -273,8 +285,8 @@ AIRTIME = (function(AIRTIME) {
$fs.find('select').val(0); $fs.find('select').val(0);
$fs.find('input[type="checkbox"]').attr("checked", $fs.find('input[type="checkbox"]').attr("checked",
false); false);
$builder.find('.dataTables_scrolling').css( //$builder.find('.dataTables_scrolling').css(
"max-height", widgetHeight - 110); // "max-height", widgetHeight - 110);
} }
}); });