This commit is contained in:
Naomi 2013-08-02 15:30:35 -04:00
parent c110b4b4df
commit 774027c9bd
3 changed files with 91 additions and 91 deletions

View file

@ -73,9 +73,9 @@ class PlayouthistoryController extends Zend_Controller_Action
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$columns = json_encode($historyService->getDatatablesLogSheetColumns()); $columns = json_encode($historyService->getDatatablesLogSheetColumns());
$script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) ); "; $script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) ); ";
$columns = json_encode($historyService->getDatatablesFileSummaryColumns()); $columns = json_encode($historyService->getDatatablesFileSummaryColumns());
$script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );"; $script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );";
$this->view->headScript()->appendScript($script); $this->view->headScript()->appendScript($script);
} }
@ -213,9 +213,9 @@ class PlayouthistoryController extends Zend_Controller_Action
public function configureTemplateAction() { public function configureTemplateAction() {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir(); $baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
try { try {
@ -226,10 +226,10 @@ class PlayouthistoryController extends Zend_Controller_Action
$template = $historyService->loadTemplate($templateId); $template = $historyService->loadTemplate($templateId);
$templateType = $template["type"]; $templateType = $template["type"];
$supportedTypes = $historyService->getSupportedTemplateTypes(); $supportedTypes = $historyService->getSupportedTemplateTypes();
if (!in_array($templateType, $supportedTypes)) { if (!in_array($templateType, $supportedTypes)) {
throw new Exception("Error: $templateType is not supported."); throw new Exception("Error: $templateType is not supported.");
} }
$getMandatoryFields = "mandatory".ucfirst($templateType)."Fields"; $getMandatoryFields = "mandatory".ucfirst($templateType)."Fields";

View file

@ -1378,11 +1378,11 @@ class Application_Model_Preference
return self::getValue("history_item_template"); return self::getValue("history_item_template");
} }
public static function SetHistoryFileTemplate($value) { public static function SetHistoryFileTemplate($value) {
self::setValue("history_file_template", $value); self::setValue("history_file_template", $value);
} }
public static function GetHistoryFileTemplate() { public static function GetHistoryFileTemplate() {
return self::getValue("history_file_template"); return self::getValue("history_file_template");
} }
} }

View file

@ -640,11 +640,11 @@ class Application_Service_HistoryService
return $fields; return $fields;
} }
public function mandatoryFileFields() { public function mandatoryFileFields() {
$fields = array("played", MDATA_KEY_TITLE, MDATA_KEY_CREATOR); $fields = array("played", MDATA_KEY_TITLE, MDATA_KEY_CREATOR);
return $fields; return $fields;
} }
private function defaultItemTemplate() { private function defaultItemTemplate() {
@ -666,30 +666,30 @@ class Application_Service_HistoryService
/* /*
* Default File Summary Template. Taken from The Czech radio requirements (customer requested this in the past). * Default File Summary Template. Taken from The Czech radio requirements (customer requested this in the past).
*/ */
private function defaultFileTemplate() { private function defaultFileTemplate() {
$template = array(); $template = array();
$fields = array(); $fields = array();
$fields[] = array("name" => MDATA_KEY_TITLE, "type" => TEMPLATE_STRING, "isFileMd" => true); $fields[] = array("name" => MDATA_KEY_TITLE, "type" => TEMPLATE_STRING, "isFileMd" => true);
$fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true); $fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true);
$fields[] = array("name" => "played", "type" => TEMPLATE_INT, "isFileMd" => false); $fields[] = array("name" => "played", "type" => TEMPLATE_INT, "isFileMd" => false);
$fields[] = array("name" => MDATA_KEY_DURATION, "type" => TEMPLATE_STRING, "isFileMd" => true); $fields[] = array("name" => MDATA_KEY_DURATION, "type" => TEMPLATE_STRING, "isFileMd" => true);
$fields[] = array("name" => MDATA_KEY_COMPOSER, "type" => TEMPLATE_STRING, "isFileMd" => true); $fields[] = array("name" => MDATA_KEY_COMPOSER, "type" => TEMPLATE_STRING, "isFileMd" => true);
$fields[] = array("name" => MDATA_KEY_COPYRIGHT, "type" => TEMPLATE_STRING, "isFileMd" => true); $fields[] = array("name" => MDATA_KEY_COPYRIGHT, "type" => TEMPLATE_STRING, "isFileMd" => true);
$template["name"] = "File Summary ".date("Y-m-d H:i:s")." Template"; $template["name"] = "File Summary ".date("Y-m-d H:i:s")." Template";
$template["fields"] = $fields; $template["fields"] = $fields;
return $template; return $template;
} }
public function loadTemplate($id) { public function loadTemplate($id) {
try { try {
if (!is_numeric($id)) { if (!is_numeric($id)) {
throw new Exception("Error: $id is not numeric."); throw new Exception("Error: $id is not numeric.");
} }
$template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con); $template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con);
@ -770,25 +770,25 @@ class Application_Service_HistoryService
return $this->getTemplates(self::TEMPLATE_TYPE_ITEM); return $this->getTemplates(self::TEMPLATE_TYPE_ITEM);
} }
public function getFileTemplates() { public function getFileTemplates() {
return $this->getTemplates(self::TEMPLATE_TYPE_FILE); return $this->getTemplates(self::TEMPLATE_TYPE_FILE);
} }
private function datatablesColumns($template) { private function datatablesColumns($template) {
$columns = array(); $columns = array();
foreach ($template["fields"] as $index=>$field) { foreach ($template["fields"] as $index=>$field) {
$key = $field["name"]; $key = $field["name"];
$columns[] = array( $columns[] = array(
"sTitle"=> $key, "sTitle"=> $key,
"mDataProp"=> $key, "mDataProp"=> $key,
"sClass"=> "his_{$key}" "sClass"=> "his_{$key}"
); );
} }
return $columns; return $columns;
} }
@ -803,15 +803,15 @@ class Application_Service_HistoryService
} }
} }
public function getDatatablesFileSummaryColumns() { public function getDatatablesFileSummaryColumns() {
try { try {
$template = $this->getConfiguredFileTemplate(); $template = $this->getConfiguredFileTemplate();
return $this->datatablesColumns($template); return $this->datatablesColumns($template);
} }
catch (Exception $e) { catch (Exception $e) {
throw $e; throw $e;
} }
} }
public function getConfiguredItemTemplate() { public function getConfiguredItemTemplate() {
@ -841,46 +841,46 @@ class Application_Service_HistoryService
} }
} }
public function getConfiguredFileTemplate() { public function getConfiguredFileTemplate() {
try { try {
$id = Application_Model_Preference::GetHistoryFileTemplate(); $id = Application_Model_Preference::GetHistoryFileTemplate();
if (is_numeric($id)) { if (is_numeric($id)) {
$template = $this->loadTemplate($id); $template = $this->loadTemplate($id);
} }
else { else {
$template = $this->defaultFileTemplate(); $template = $this->defaultFileTemplate();
} }
return $template; return $template;
} }
catch (Exception $e) { catch (Exception $e) {
throw $e; throw $e;
} }
} }
public function setConfiguredFileTemplate($id) { public function setConfiguredFileTemplate($id) {
try { try {
Application_Model_Preference::SetHistoryFileTemplate($id); Application_Model_Preference::SetHistoryFileTemplate($id);
} }
catch (Exception $e) { catch (Exception $e) {
throw $e; throw $e;
} }
} }
public function setConfiguredTemplate($id) { public function setConfiguredTemplate($id) {
try { try {
$template = $this->loadTemplate($id); $template = $this->loadTemplate($id);
$type = $template["type"]; $type = $template["type"];
$setTemplate = "setConfigured".ucfirst($type)."Template"; $setTemplate = "setConfigured".ucfirst($type)."Template";
$this->$setTemplate($id); $this->$setTemplate($id);
} }
catch (Exception $e) { catch (Exception $e) {
throw $e; throw $e;
} }
} }
public function getConfiguredTemplateIds() { public function getConfiguredTemplateIds() {
@ -895,8 +895,8 @@ class Application_Service_HistoryService
$configured[] = $id; $configured[] = $id;
} }
if (is_numeric($id2)) { if (is_numeric($id2)) {
$configured[] = $id2; $configured[] = $id2;
} }
return $configured; return $configured;