track type management
This commit is contained in:
parent
33928eaf73
commit
1d7d937a7f
29 changed files with 3082 additions and 74 deletions
|
@ -27,6 +27,7 @@ class ApiController extends Zend_Controller_Action
|
|||
"show-schedules",
|
||||
"show-logo",
|
||||
"track",
|
||||
"track-types",
|
||||
"stream-m3u"
|
||||
);
|
||||
|
||||
|
@ -635,6 +636,22 @@ class ApiController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function trackTypesAction()
|
||||
{
|
||||
if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) {
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$tracktypes = Application_Model_Tracktype::getTracktypes();
|
||||
$this->_helper->json->sendJson($tracktypes);
|
||||
} else {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print _('You are not allowed to access this resource. ');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API endpoint to provide station metadata
|
||||
*/
|
||||
|
|
109
airtime_mvc/application/controllers/TracktypeController.php
Normal file
109
airtime_mvc/application/controllers/TracktypeController.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
class TracktypeController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('get-tracktype-data-table-info', 'json')
|
||||
->addActionContext('get-tracktype-data', 'json')
|
||||
->addActionContext('remove-tracktype', 'json')
|
||||
->initContext();
|
||||
}
|
||||
|
||||
public function addTracktypeAction()
|
||||
{
|
||||
// Start the session to re-open write permission to the session so we can
|
||||
// create the namespace for our csrf token verification
|
||||
SessionHelper::reopenSessionForWriting();
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
Zend_Layout::getMvcInstance()->assign('parent_page', 'Settings');
|
||||
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
|
||||
$js_files = array(
|
||||
'js/datatables/js/jquery.dataTables.js?',
|
||||
'js/datatables/plugin/dataTables.pluginAPI.js?',
|
||||
'js/airtime/tracktype/tracktype.js?'
|
||||
);
|
||||
|
||||
foreach ($js_files as $js) {
|
||||
$this->view->headScript()->appendFile(
|
||||
$baseUrl.$js.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
}
|
||||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/tracktypes.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
$form = new Application_Form_AddTracktype();
|
||||
|
||||
$this->view->successMessage = "";
|
||||
|
||||
if ($request->isPost()) {
|
||||
$params = $request->getPost();
|
||||
$postData = explode('&', $params['data']);
|
||||
$formData = array();
|
||||
foreach($postData as $k=>$v) {
|
||||
$v = explode('=', $v);
|
||||
$formData[$v[0]] = urldecode($v[1]);
|
||||
}
|
||||
|
||||
if ($form->validateCode($formData)) {
|
||||
$tracktype = new Application_Model_Tracktype($formData['tracktype_id']);
|
||||
if (empty($formData['tracktype_id'])) {
|
||||
$tracktype->setCode($formData['code']);
|
||||
}
|
||||
$tracktype->setTypeName($formData['type_name']);
|
||||
$tracktype->setDescription($formData['description']);
|
||||
$tracktype->setVisibility($formData['visibility']);
|
||||
$tracktype->save();
|
||||
|
||||
$form->reset();
|
||||
$this->view->form = $form;
|
||||
|
||||
if (strlen($formData['tracktype_id']) == 0) {
|
||||
$this->view->successMessage = "<div class='success'>"._("Track Type added successfully!")."</div>";
|
||||
} else {
|
||||
$this->view->successMessage = "<div class='success'>"._("Track Type updated successfully!")."</div>";
|
||||
}
|
||||
|
||||
$this->_helper->json->sendJson(array("valid"=>"true", "html"=>$this->view->render('tracktype/add-tracktype.phtml')));
|
||||
} else {
|
||||
$this->view->form = $form;
|
||||
$this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('tracktype/add-tracktype.phtml')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function getTracktypeDataTableInfoAction()
|
||||
{
|
||||
$post = $this->getRequest()->getPost();
|
||||
$tracktypes = Application_Model_Tracktype::getTracktypesDataTablesInfo($post);
|
||||
|
||||
$this->_helper->json->sendJson($tracktypes);
|
||||
}
|
||||
|
||||
public function getTracktypeDataAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
$this->view->entries = Application_Model_Tracktype::GetTracktypeData($id);
|
||||
}
|
||||
|
||||
public function removeTracktypeAction()
|
||||
{
|
||||
// action body
|
||||
$delId = $this->_getParam('id');
|
||||
|
||||
$tracktype = new Application_Model_Tracktype($delId);
|
||||
|
||||
# Delete the track type
|
||||
$this->view->entries = $tracktype->delete();
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1,3 @@
|
|||
ALTER TABLE cc_files DROP COLUMN IF EXISTS track_type;
|
||||
|
||||
DROP TABLE IF EXISTS "cc_track_types" CASCADE;
|
|
@ -1 +1,25 @@
|
|||
ALTER TABLE cc_files ADD COLUMN track_type VARCHAR(16);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "cc_track_types"
|
||||
(
|
||||
"id" integer DEFAULT nextval('cc_subjs_id_seq'::regclass) NOT NULL,
|
||||
"code" VARCHAR(16) NOT NULL,
|
||||
"type_name" VARCHAR(64),
|
||||
"description" VARCHAR(255),
|
||||
"visibility" boolean DEFAULT true NOT NULL,
|
||||
CONSTRAINT "cc_track_types_pkey" PRIMARY KEY ("id"),
|
||||
CONSTRAINT "cc_track_types_code_key" UNIQUE ("code")
|
||||
);
|
||||
|
||||
INSERT INTO cc_track_types VALUES (1, 'MUS', 'Music', 'This is used for tracks containing music.', true);
|
||||
INSERT INTO cc_track_types VALUES (2, 'SID', 'Station ID', 'This is used for Station IDs', true);
|
||||
INSERT INTO cc_track_types VALUES (3, 'INT', 'Show Intro', 'This can be used for organizing all the show introductions.', true);
|
||||
INSERT INTO cc_track_types VALUES (4, 'OUT', 'Show Outro', 'This can be used for organizing all the show outroductions.', true);
|
||||
INSERT INTO cc_track_types VALUES (5, 'SWP', 'Sweeper', 'This is used for segues between songs.', true);
|
||||
INSERT INTO cc_track_types VALUES (6, 'JIN', 'Jingle', 'A short song or tune, normally played during commercial breaks. Contains one or more hooks.', true);
|
||||
INSERT INTO cc_track_types VALUES (7, 'PRO', 'Promo', 'For promotional use.', true);
|
||||
INSERT INTO cc_track_types VALUES (8, 'SHO', 'Shout Out', 'A message of congratulation, greeting. support, or appreciation. ', true);
|
||||
INSERT INTO cc_track_types VALUES (9, 'NWS', 'News', 'This is used for noteworthy information, announcements.', true);
|
||||
INSERT INTO cc_track_types VALUES (10, 'COM', 'Commercial', 'This is used for commerical advertising.', true);
|
||||
INSERT INTO cc_track_types VALUES (11, 'ITV', 'Interview', 'This is used for radio interviews', true);
|
||||
INSERT INTO cc_track_types VALUES (12, 'VTR', 'Voice Tracking', 'Also referred as robojock or taped. Make announcements without actually being in the station.', true);
|
Loading…
Add table
Add a link
Reference in a new issue