can add a new list item using the template.
set a default item template working on sql to get a table with unified columns for file md and manually entered metadata without a file.
This commit is contained in:
parent
06e21029d0
commit
7ca3048f36
13 changed files with 456 additions and 163 deletions
|
@ -17,8 +17,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
->addActionContext('create-template', 'json')
|
->addActionContext('create-template', 'json')
|
||||||
->addActionContext('edit-template', 'json')
|
->addActionContext('edit-template', 'json')
|
||||||
->addActionContext('delete-template', 'json')
|
->addActionContext('delete-template', 'json')
|
||||||
->addActionContext('create-template-field', 'json')
|
->addActionContext('set-item-template-default', 'json')
|
||||||
->addActionContext('delete-template-field', 'json')
|
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,12 +129,18 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function createListItemAction()
|
public function createListItemAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
try {
|
||||||
$params = $request->getPost();
|
$request = $this->getRequest();
|
||||||
Logging::info($params);
|
$params = $request->getPost();
|
||||||
|
Logging::info($params);
|
||||||
$historyService = new Application_Service_HistoryService();
|
|
||||||
$historyService->createPlayedItem($params);
|
$historyService = new Application_Service_HistoryService();
|
||||||
|
$historyService->createPlayedItem($params);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Logging::info($e);
|
||||||
|
Logging::info($e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editListItemAction()
|
public function editListItemAction()
|
||||||
|
@ -190,20 +195,34 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function configureItemTemplateAction() {
|
public function configureItemTemplateAction() {
|
||||||
|
|
||||||
$CC_CONFIG = Config::getConfig();
|
$request = $this->getRequest();
|
||||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
$params = $request->getPost();
|
||||||
|
Logging::info($params);
|
||||||
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
||||||
|
try {
|
||||||
$template_id = $this->_getParam('id', null);
|
$CC_CONFIG = Config::getConfig();
|
||||||
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||||
$historyService = new Application_Service_HistoryService();
|
|
||||||
$mandatoryFields = $historyService->mandatoryItemTemplate();
|
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
$this->view->template_id = $template_id;
|
$template_id = $this->_getParam('id', null);
|
||||||
$this->view->fileMD = $historyService->getFileMetadataTypes();
|
|
||||||
$this->view->fields = $historyService->getFieldTypes();
|
$historyService = new Application_Service_HistoryService();
|
||||||
$this->view->required = $mandatoryFields;
|
$mandatoryFields = $historyService->mandatoryItemFields();
|
||||||
|
$template = $historyService->getItemTemplate($template_id);
|
||||||
|
|
||||||
|
$this->view->template_id = $template_id;
|
||||||
|
$this->view->template_name = $template["name"];
|
||||||
|
$this->view->template_fields = $template["fields"];
|
||||||
|
$this->view->template_list = $historyService->getListItemTemplates();
|
||||||
|
$this->view->fileMD = $historyService->getFileMetadataTypes();
|
||||||
|
$this->view->fields = $historyService->getFieldTypes();
|
||||||
|
$this->view->required_fields = $mandatoryFields;
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Logging::info($e);
|
||||||
|
Logging::info($e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createTemplateAction()
|
public function createTemplateAction()
|
||||||
|
@ -212,8 +231,36 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
$params = $request->getPost();
|
$params = $request->getPost();
|
||||||
Logging::info($params);
|
Logging::info($params);
|
||||||
|
|
||||||
$historyService = new Application_Service_HistoryService();
|
try {
|
||||||
$historyService->createItemTemplate($params);
|
$historyService = new Application_Service_HistoryService();
|
||||||
|
$historyService->createItemTemplate($params);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Logging::info($e);
|
||||||
|
Logging::info($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setItemTemplateDefaultAction()
|
||||||
|
{
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$params = $request->getPost();
|
||||||
|
Logging::info($params);
|
||||||
|
|
||||||
|
$template_id = $this->_getParam('id', null);
|
||||||
|
|
||||||
|
if (empty($template_id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$historyService = new Application_Service_HistoryService();
|
||||||
|
$historyService->setConfiguredItemTemplate($template_id);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Logging::info($e);
|
||||||
|
Logging::info($e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editTemplateAction()
|
public function editTemplateAction()
|
||||||
|
@ -225,14 +272,4 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createTemplateFieldAction()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteTemplateFieldAction()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,13 +173,17 @@ class Application_Form_EditHistoryItem extends Zend_Form
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createFromTemplate($template) {
|
public function createFromTemplate($template, $required) {
|
||||||
|
|
||||||
$templateSubForm = $this->getSubForm(self::ID_PREFIX.'template');
|
$templateSubForm = $this->getSubForm(self::ID_PREFIX.'template');
|
||||||
|
|
||||||
for ($i = 0, $len = count($template); $i < $len; $i++) {
|
for ($i = 0, $len = count($template); $i < $len; $i++) {
|
||||||
|
|
||||||
$item = $template[$i];
|
$item = $template[$i];
|
||||||
|
//don't dynamically add this as it should be included in the init() function already.
|
||||||
|
if (in_array($item["name"], $required)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$formElType = $this->formElTypes[$item[self::ITEM_TYPE]];
|
$formElType = $this->formElTypes[$item[self::ITEM_TYPE]];
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ class CcPlayoutHistoryTemplateTableMap extends TableMap {
|
||||||
$this->setPrimaryKeyMethodInfo('cc_playout_history_template_id_seq');
|
$this->setPrimaryKeyMethodInfo('cc_playout_history_template_id_seq');
|
||||||
// columns
|
// columns
|
||||||
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||||
$this->addColumn('TEMPLATE_NAME', 'DbName', 'VARCHAR', true, 128, null);
|
$this->addColumn('NAME', 'DbName', 'VARCHAR', true, 128, null);
|
||||||
|
$this->addColumn('TYPE', 'DbType', 'VARCHAR', true, 35, null);
|
||||||
// validators
|
// validators
|
||||||
} // initialize()
|
} // initialize()
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,16 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
protected $id;
|
protected $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value for the template_name field.
|
* The value for the name field.
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $template_name;
|
protected $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the type field.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array CcPlayoutHistoryTemplateField[] Collection to store aggregation of CcPlayoutHistoryTemplateField objects.
|
* @var array CcPlayoutHistoryTemplateField[] Collection to store aggregation of CcPlayoutHistoryTemplateField objects.
|
||||||
|
@ -66,13 +72,23 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the [template_name] column value.
|
* Get the [name] column value.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDbName()
|
public function getDbName()
|
||||||
{
|
{
|
||||||
return $this->template_name;
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [type] column value.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDbType()
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,7 +112,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
} // setDbId()
|
} // setDbId()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of [template_name] column.
|
* Set the value of [name] column.
|
||||||
*
|
*
|
||||||
* @param string $v new value
|
* @param string $v new value
|
||||||
* @return CcPlayoutHistoryTemplate The current object (for fluent API support)
|
* @return CcPlayoutHistoryTemplate The current object (for fluent API support)
|
||||||
|
@ -107,14 +123,34 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
$v = (string) $v;
|
$v = (string) $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->template_name !== $v) {
|
if ($this->name !== $v) {
|
||||||
$this->template_name = $v;
|
$this->name = $v;
|
||||||
$this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::TEMPLATE_NAME;
|
$this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
} // setDbName()
|
} // setDbName()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of [type] column.
|
||||||
|
*
|
||||||
|
* @param string $v new value
|
||||||
|
* @return CcPlayoutHistoryTemplate The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setDbType($v)
|
||||||
|
{
|
||||||
|
if ($v !== null) {
|
||||||
|
$v = (string) $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->type !== $v) {
|
||||||
|
$this->type = $v;
|
||||||
|
$this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setDbType()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the columns in this object are only set to default values.
|
* Indicates whether the columns in this object are only set to default values.
|
||||||
*
|
*
|
||||||
|
@ -148,7 +184,8 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
|
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
|
||||||
$this->template_name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
|
$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
|
||||||
|
$this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
|
||||||
$this->resetModified();
|
$this->resetModified();
|
||||||
|
|
||||||
$this->setNew(false);
|
$this->setNew(false);
|
||||||
|
@ -157,7 +194,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
$this->ensureConsistency();
|
$this->ensureConsistency();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $startcol + 2; // 2 = CcPlayoutHistoryTemplatePeer::NUM_COLUMNS - CcPlayoutHistoryTemplatePeer::NUM_LAZY_LOAD_COLUMNS).
|
return $startcol + 3; // 3 = CcPlayoutHistoryTemplatePeer::NUM_COLUMNS - CcPlayoutHistoryTemplatePeer::NUM_LAZY_LOAD_COLUMNS).
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new PropelException("Error populating CcPlayoutHistoryTemplate object", $e);
|
throw new PropelException("Error populating CcPlayoutHistoryTemplate object", $e);
|
||||||
|
@ -480,6 +517,9 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
case 1:
|
case 1:
|
||||||
return $this->getDbName();
|
return $this->getDbName();
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
return $this->getDbType();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
break;
|
break;
|
||||||
|
@ -505,6 +545,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
$result = array(
|
$result = array(
|
||||||
$keys[0] => $this->getDbId(),
|
$keys[0] => $this->getDbId(),
|
||||||
$keys[1] => $this->getDbName(),
|
$keys[1] => $this->getDbName(),
|
||||||
|
$keys[2] => $this->getDbType(),
|
||||||
);
|
);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -542,6 +583,9 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
case 1:
|
case 1:
|
||||||
$this->setDbName($value);
|
$this->setDbName($value);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
$this->setDbType($value);
|
||||||
|
break;
|
||||||
} // switch()
|
} // switch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,6 +612,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
|
|
||||||
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
|
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
|
||||||
if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
|
if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
|
||||||
|
if (array_key_exists($keys[2], $arr)) $this->setDbType($arr[$keys[2]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -580,7 +625,8 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
$criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME);
|
$criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME);
|
||||||
|
|
||||||
if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::ID)) $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $this->id);
|
if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::ID)) $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $this->id);
|
||||||
if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::TEMPLATE_NAME)) $criteria->add(CcPlayoutHistoryTemplatePeer::TEMPLATE_NAME, $this->template_name);
|
if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::NAME)) $criteria->add(CcPlayoutHistoryTemplatePeer::NAME, $this->name);
|
||||||
|
if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::TYPE)) $criteria->add(CcPlayoutHistoryTemplatePeer::TYPE, $this->type);
|
||||||
|
|
||||||
return $criteria;
|
return $criteria;
|
||||||
}
|
}
|
||||||
|
@ -642,7 +688,8 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
*/
|
*/
|
||||||
public function copyInto($copyObj, $deepCopy = false)
|
public function copyInto($copyObj, $deepCopy = false)
|
||||||
{
|
{
|
||||||
$copyObj->setDbName($this->template_name);
|
$copyObj->setDbName($this->name);
|
||||||
|
$copyObj->setDbType($this->type);
|
||||||
|
|
||||||
if ($deepCopy) {
|
if ($deepCopy) {
|
||||||
// important: temporarily setNew(false) because this affects the behavior of
|
// important: temporarily setNew(false) because this affects the behavior of
|
||||||
|
@ -815,7 +862,8 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
|
||||||
public function clear()
|
public function clear()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->template_name = null;
|
$this->name = null;
|
||||||
|
$this->type = null;
|
||||||
$this->alreadyInSave = false;
|
$this->alreadyInSave = false;
|
||||||
$this->alreadyInValidation = false;
|
$this->alreadyInValidation = false;
|
||||||
$this->clearAllReferences();
|
$this->clearAllReferences();
|
||||||
|
|
|
@ -26,7 +26,7 @@ abstract class BaseCcPlayoutHistoryTemplatePeer {
|
||||||
const TM_CLASS = 'CcPlayoutHistoryTemplateTableMap';
|
const TM_CLASS = 'CcPlayoutHistoryTemplateTableMap';
|
||||||
|
|
||||||
/** The total number of columns. */
|
/** The total number of columns. */
|
||||||
const NUM_COLUMNS = 2;
|
const NUM_COLUMNS = 3;
|
||||||
|
|
||||||
/** The number of lazy-loaded columns. */
|
/** The number of lazy-loaded columns. */
|
||||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||||
|
@ -34,8 +34,11 @@ abstract class BaseCcPlayoutHistoryTemplatePeer {
|
||||||
/** the column name for the ID field */
|
/** the column name for the ID field */
|
||||||
const ID = 'cc_playout_history_template.ID';
|
const ID = 'cc_playout_history_template.ID';
|
||||||
|
|
||||||
/** the column name for the TEMPLATE_NAME field */
|
/** the column name for the NAME field */
|
||||||
const TEMPLATE_NAME = 'cc_playout_history_template.TEMPLATE_NAME';
|
const NAME = 'cc_playout_history_template.NAME';
|
||||||
|
|
||||||
|
/** the column name for the TYPE field */
|
||||||
|
const TYPE = 'cc_playout_history_template.TYPE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An identiy map to hold any loaded instances of CcPlayoutHistoryTemplate objects.
|
* An identiy map to hold any loaded instances of CcPlayoutHistoryTemplate objects.
|
||||||
|
@ -53,12 +56,12 @@ abstract class BaseCcPlayoutHistoryTemplatePeer {
|
||||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||||
*/
|
*/
|
||||||
private static $fieldNames = array (
|
private static $fieldNames = array (
|
||||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', ),
|
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbType', ),
|
||||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', ),
|
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbType', ),
|
||||||
BasePeer::TYPE_COLNAME => array (self::ID, self::TEMPLATE_NAME, ),
|
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::TYPE, ),
|
||||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TEMPLATE_NAME', ),
|
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'TYPE', ),
|
||||||
BasePeer::TYPE_FIELDNAME => array ('id', 'template_name', ),
|
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'type', ),
|
||||||
BasePeer::TYPE_NUM => array (0, 1, )
|
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,12 +71,12 @@ abstract class BaseCcPlayoutHistoryTemplatePeer {
|
||||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||||
*/
|
*/
|
||||||
private static $fieldKeys = array (
|
private static $fieldKeys = array (
|
||||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, ),
|
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbType' => 2, ),
|
||||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, ),
|
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbType' => 2, ),
|
||||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TEMPLATE_NAME => 1, ),
|
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::TYPE => 2, ),
|
||||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TEMPLATE_NAME' => 1, ),
|
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'TYPE' => 2, ),
|
||||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'template_name' => 1, ),
|
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'type' => 2, ),
|
||||||
BasePeer::TYPE_NUM => array (0, 1, )
|
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,10 +149,12 @@ abstract class BaseCcPlayoutHistoryTemplatePeer {
|
||||||
{
|
{
|
||||||
if (null === $alias) {
|
if (null === $alias) {
|
||||||
$criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::ID);
|
$criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::ID);
|
||||||
$criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::TEMPLATE_NAME);
|
$criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::NAME);
|
||||||
|
$criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::TYPE);
|
||||||
} else {
|
} else {
|
||||||
$criteria->addSelectColumn($alias . '.ID');
|
$criteria->addSelectColumn($alias . '.ID');
|
||||||
$criteria->addSelectColumn($alias . '.TEMPLATE_NAME');
|
$criteria->addSelectColumn($alias . '.NAME');
|
||||||
|
$criteria->addSelectColumn($alias . '.TYPE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,12 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @method CcPlayoutHistoryTemplateQuery orderByDbId($order = Criteria::ASC) Order by the id column
|
* @method CcPlayoutHistoryTemplateQuery orderByDbId($order = Criteria::ASC) Order by the id column
|
||||||
* @method CcPlayoutHistoryTemplateQuery orderByDbName($order = Criteria::ASC) Order by the template_name column
|
* @method CcPlayoutHistoryTemplateQuery orderByDbName($order = Criteria::ASC) Order by the name column
|
||||||
|
* @method CcPlayoutHistoryTemplateQuery orderByDbType($order = Criteria::ASC) Order by the type column
|
||||||
*
|
*
|
||||||
* @method CcPlayoutHistoryTemplateQuery groupByDbId() Group by the id column
|
* @method CcPlayoutHistoryTemplateQuery groupByDbId() Group by the id column
|
||||||
* @method CcPlayoutHistoryTemplateQuery groupByDbName() Group by the template_name column
|
* @method CcPlayoutHistoryTemplateQuery groupByDbName() Group by the name column
|
||||||
|
* @method CcPlayoutHistoryTemplateQuery groupByDbType() Group by the type column
|
||||||
*
|
*
|
||||||
* @method CcPlayoutHistoryTemplateQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
* @method CcPlayoutHistoryTemplateQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||||
* @method CcPlayoutHistoryTemplateQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
* @method CcPlayoutHistoryTemplateQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||||
|
@ -24,10 +26,12 @@
|
||||||
* @method CcPlayoutHistoryTemplate findOneOrCreate(PropelPDO $con = null) Return the first CcPlayoutHistoryTemplate matching the query, or a new CcPlayoutHistoryTemplate object populated from the query conditions when no match is found
|
* @method CcPlayoutHistoryTemplate findOneOrCreate(PropelPDO $con = null) Return the first CcPlayoutHistoryTemplate matching the query, or a new CcPlayoutHistoryTemplate object populated from the query conditions when no match is found
|
||||||
*
|
*
|
||||||
* @method CcPlayoutHistoryTemplate findOneByDbId(int $id) Return the first CcPlayoutHistoryTemplate filtered by the id column
|
* @method CcPlayoutHistoryTemplate findOneByDbId(int $id) Return the first CcPlayoutHistoryTemplate filtered by the id column
|
||||||
* @method CcPlayoutHistoryTemplate findOneByDbName(string $template_name) Return the first CcPlayoutHistoryTemplate filtered by the template_name column
|
* @method CcPlayoutHistoryTemplate findOneByDbName(string $name) Return the first CcPlayoutHistoryTemplate filtered by the name column
|
||||||
|
* @method CcPlayoutHistoryTemplate findOneByDbType(string $type) Return the first CcPlayoutHistoryTemplate filtered by the type column
|
||||||
*
|
*
|
||||||
* @method array findByDbId(int $id) Return CcPlayoutHistoryTemplate objects filtered by the id column
|
* @method array findByDbId(int $id) Return CcPlayoutHistoryTemplate objects filtered by the id column
|
||||||
* @method array findByDbName(string $template_name) Return CcPlayoutHistoryTemplate objects filtered by the template_name column
|
* @method array findByDbName(string $name) Return CcPlayoutHistoryTemplate objects filtered by the name column
|
||||||
|
* @method array findByDbType(string $type) Return CcPlayoutHistoryTemplate objects filtered by the type column
|
||||||
*
|
*
|
||||||
* @package propel.generator.airtime.om
|
* @package propel.generator.airtime.om
|
||||||
*/
|
*/
|
||||||
|
@ -155,7 +159,7 @@ abstract class BaseCcPlayoutHistoryTemplateQuery extends ModelCriteria
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the query on the template_name column
|
* Filter the query on the name column
|
||||||
*
|
*
|
||||||
* @param string $dbName The value to use as filter.
|
* @param string $dbName The value to use as filter.
|
||||||
* Accepts wildcards (* and % trigger a LIKE)
|
* Accepts wildcards (* and % trigger a LIKE)
|
||||||
|
@ -173,7 +177,29 @@ abstract class BaseCcPlayoutHistoryTemplateQuery extends ModelCriteria
|
||||||
$comparison = Criteria::LIKE;
|
$comparison = Criteria::LIKE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::TEMPLATE_NAME, $dbName, $comparison);
|
return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::NAME, $dbName, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the type column
|
||||||
|
*
|
||||||
|
* @param string $dbType The value to use as filter.
|
||||||
|
* Accepts wildcards (* and % trigger a LIKE)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByDbType($dbType = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (null === $comparison) {
|
||||||
|
if (is_array($dbType)) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
} elseif (preg_match('/[\%\*]/', $dbType)) {
|
||||||
|
$dbType = str_replace('*', '%', $dbType);
|
||||||
|
$comparison = Criteria::LIKE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::TYPE, $dbType, $comparison);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,9 @@ class Application_Service_HistoryService
|
||||||
{
|
{
|
||||||
private $con;
|
private $con;
|
||||||
private $timezone;
|
private $timezone;
|
||||||
|
|
||||||
|
const TEMPLATE_TYPE_ITEM = "item";
|
||||||
|
const TEMPLATE_TYPE_AGGREGATE = "aggregate";
|
||||||
|
|
||||||
private $mDataPropMap = array (
|
private $mDataPropMap = array (
|
||||||
"artist" => "artist_name",
|
"artist" => "artist_name",
|
||||||
|
@ -39,6 +42,43 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
public function getListView($startDT, $endDT, $opts)
|
public function getListView($startDT, $endDT, $opts)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
|
||||||
|
select * from (
|
||||||
|
|
||||||
|
select track_title.value as track_title, track_title.history_id
|
||||||
|
from (select * from cc_playout_history_metadata as phm
|
||||||
|
where key = 'track_title')
|
||||||
|
as track_title
|
||||||
|
|
||||||
|
) as track_filter
|
||||||
|
|
||||||
|
INNER JOIN
|
||||||
|
|
||||||
|
(
|
||||||
|
select artist_name.value as artist_name, artist_name.history_id
|
||||||
|
from (select * from cc_playout_history_metadata as phm
|
||||||
|
where key = 'artist_name')
|
||||||
|
as artist_name
|
||||||
|
|
||||||
|
) as artist_filter
|
||||||
|
|
||||||
|
USING (history_id)
|
||||||
|
|
||||||
|
INNER JOIN
|
||||||
|
|
||||||
|
(
|
||||||
|
select album_title.value as album_title, album_title.history_id
|
||||||
|
from (select * from cc_playout_history_metadata as phm
|
||||||
|
where key = 'album_title')
|
||||||
|
as album_title
|
||||||
|
|
||||||
|
) as album_filter
|
||||||
|
|
||||||
|
USING (history_id)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
$this->translateColumns($opts);
|
$this->translateColumns($opts);
|
||||||
|
|
||||||
$select = array (
|
$select = array (
|
||||||
|
@ -172,9 +212,9 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form = new Application_Form_EditHistoryItem();
|
$form = new Application_Form_EditHistoryItem();
|
||||||
$template = $this->getItemTemplate();
|
$template = $this->getConfiguredItemTemplate();
|
||||||
|
$required = $this->mandatoryItemFields();
|
||||||
$form->createFromTemplate($template);
|
$form->createFromTemplate($template["fields"], $required);
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +254,7 @@ class Application_Service_HistoryService
|
||||||
$this->con->beginTransaction();
|
$this->con->beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$template = $this->getItemTemplate();
|
$template = $this->getConfiguredItemTemplate();
|
||||||
$prefix = Application_Form_EditHistoryItem::ID_PREFIX;
|
$prefix = Application_Form_EditHistoryItem::ID_PREFIX;
|
||||||
$historyRecord = new CcPlayoutHistory();
|
$historyRecord = new CcPlayoutHistory();
|
||||||
|
|
||||||
|
@ -233,39 +273,42 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
$file = $historyRecord->getCcFiles();
|
$file = $historyRecord->getCcFiles();
|
||||||
|
|
||||||
|
$md = array();
|
||||||
$metadata = array();
|
$metadata = array();
|
||||||
|
$fields = $template["fields"];
|
||||||
|
$required = $this->mandatoryItemFields();
|
||||||
|
|
||||||
for ($i = 0, $len = count($template); $i < $len; $i++) {
|
for ($i = 0, $len = count($fields); $i < $len; $i++) {
|
||||||
|
|
||||||
$item = $template[$i];
|
$field = $fields[$i];
|
||||||
$key = $item["name"];
|
$key = $field["name"];
|
||||||
$isFileMd = $item["isFileMd"];
|
|
||||||
|
//required is delt with before this loop.
|
||||||
|
if (in_array($key, $required)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$isFileMd = $field["isFileMd"];
|
||||||
$entry = $templateValues[$prefix.$key];
|
$entry = $templateValues[$prefix.$key];
|
||||||
|
|
||||||
if (!$isFileMd) {
|
if ($isFileMd && isset($file)) {
|
||||||
Logging::info("adding metadata");
|
Logging::info("adding metadata associated to a file for {$key}");
|
||||||
}
|
$md[$key] = $entry;
|
||||||
else if ($isFileMd && isset($file)) {
|
|
||||||
Logging::info("adding file metadata associated to a file");
|
|
||||||
}
|
|
||||||
else if ($isFileMd && empty($file)) {
|
|
||||||
Logging::info("adding file metadata NOT associated to a file");
|
|
||||||
$metadata[$key] = $entry;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logging::info("doing something else");
|
Logging::info("adding metadata for {$key}");
|
||||||
|
$metadata[$key] = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($metadata) > 0) {
|
if (count($md) > 0) {
|
||||||
$meta = new CcPlayoutHistoryMetaData();
|
$f = Application_Model_StoredFile::createWithFile($file, $this->con);
|
||||||
|
$f->setDbColMetadata($md);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($metadata as $key => $val) {
|
foreach ($metadata as $key => $val) {
|
||||||
|
|
||||||
|
$meta = new CcPlayoutHistoryMetaData();
|
||||||
$meta->setDbKey($key);
|
$meta->setDbKey($key);
|
||||||
$meta->setDbValue($val);
|
$meta->setDbValue($val);
|
||||||
|
|
||||||
|
@ -273,12 +316,10 @@ class Application_Service_HistoryService
|
||||||
}
|
}
|
||||||
|
|
||||||
$historyRecord->save($this->con);
|
$historyRecord->save($this->con);
|
||||||
|
|
||||||
$this->con->commit();
|
$this->con->commit();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$this->con->rollback();
|
$this->con->rollback();
|
||||||
Logging::info($e);
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,14 +342,11 @@ class Application_Service_HistoryService
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logging::info("created list item NOT VALID");
|
Logging::info("created list item NOT VALID");
|
||||||
|
Logging::info($form->getMessages());
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging::info($form->getMessages());
|
|
||||||
|
|
||||||
//return $json;
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
Logging::info($e);
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,18 +473,16 @@ class Application_Service_HistoryService
|
||||||
return $fileMD;
|
return $fileMD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mandatoryItemTemplate() {
|
public function mandatoryItemFields() {
|
||||||
|
|
||||||
$fields = array();
|
$fields = array("starts", "ends");
|
||||||
|
|
||||||
$fields[] = array("name" => "starts", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
|
||||||
$fields[] = array("name" => "ends", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function defaultItemTemplate() {
|
private function defaultItemTemplate() {
|
||||||
|
|
||||||
|
$template = array();
|
||||||
$fields = array();
|
$fields = array();
|
||||||
|
|
||||||
$fields[] = array("name" => "starts", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
$fields[] = array("name" => "starts", "type" => TEMPLATE_DATETIME, "isFileMd" => false);
|
||||||
|
@ -454,15 +490,48 @@ class Application_Service_HistoryService
|
||||||
$fields[] = array("name" => MDATA_KEY_TITLE, "type" => TEMPLATE_STRING, "isFileMd" => true); //these fields can be populated from an associated file.
|
$fields[] = array("name" => MDATA_KEY_TITLE, "type" => TEMPLATE_STRING, "isFileMd" => true); //these fields can be populated from an associated file.
|
||||||
$fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
$fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true);
|
||||||
|
|
||||||
return $fields;
|
$template["name"] = "";
|
||||||
|
$template["fields"] = $fields;
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadTemplate($id) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con);
|
||||||
|
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->addAscendingOrderByColumn(CcPlayoutHistoryTemplateFieldPeer::POSITION);
|
||||||
|
$config = $template->getCcPlayoutHistoryTemplateFields($c, $this->con);
|
||||||
|
$fields = array();
|
||||||
|
|
||||||
|
foreach ($config as $item) {
|
||||||
|
|
||||||
|
$fields[] = array(
|
||||||
|
"name" => $item->getDbName(),
|
||||||
|
"type" => $item->getDbType(),
|
||||||
|
"isFileMd" => $item->getDbIsFileMD(),
|
||||||
|
"id" => $item->getDbId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data["name"] = $template->getDbName();
|
||||||
|
$data["fields"] = $fields;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getItemTemplate() {
|
public function getItemTemplate($id) {
|
||||||
|
|
||||||
$template_id = Application_Model_Preference::GetHistoryItemTemplate();
|
if (is_numeric($id)) {
|
||||||
|
Logging::info("template id is: $id");
|
||||||
if (is_numeric($template_id)) {
|
$template = $this->loadTemplate($id);
|
||||||
Logging::info("template id is: $template_id");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logging::info("Using default template");
|
Logging::info("Using default template");
|
||||||
|
@ -472,6 +541,46 @@ class Application_Service_HistoryService
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getListItemTemplates() {
|
||||||
|
|
||||||
|
$list = array();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$templates = CcPlayoutHistoryTemplateQuery::create()
|
||||||
|
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||||
|
->findByDbType(self::TEMPLATE_TYPE_ITEM);
|
||||||
|
|
||||||
|
foreach ($templates as $template) {
|
||||||
|
$list[$template->getDbId()] = $template->getDbName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConfiguredItemTemplate() {
|
||||||
|
try {
|
||||||
|
$id = Application_Model_Preference::GetHistoryItemTemplate();
|
||||||
|
return $this->getItemTemplate($id);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setConfiguredItemTemplate($id) {
|
||||||
|
try {
|
||||||
|
Application_Model_Preference::SetHistoryItemTemplate($id);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function createItemTemplate($config) {
|
public function createItemTemplate($config) {
|
||||||
|
|
||||||
$this->con->beginTransaction();
|
$this->con->beginTransaction();
|
||||||
|
@ -480,15 +589,18 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
$template = new CcPlayoutHistoryTemplate();
|
$template = new CcPlayoutHistoryTemplate();
|
||||||
$template->setDbName($config["name"]);
|
$template->setDbName($config["name"]);
|
||||||
|
$template->setDbType(self::TEMPLATE_TYPE_ITEM);
|
||||||
|
|
||||||
$fields = $config["fields"];
|
$fields = $config["fields"];
|
||||||
|
|
||||||
foreach ($fields as $index=>$field) {
|
foreach ($fields as $index=>$field) {
|
||||||
|
|
||||||
|
$isMd = ($field["filemd"] == 'true') ? true : false;
|
||||||
|
|
||||||
$templateField = new CcPlayoutHistoryTemplateField();
|
$templateField = new CcPlayoutHistoryTemplateField();
|
||||||
$templateField->setDbName($field["name"]);
|
$templateField->setDbName($field["name"]);
|
||||||
$templateField->setDbType($field["type"]);
|
$templateField->setDbType($field["type"]);
|
||||||
$templateField->setDbIsFileMD($field["filemd"]);
|
$templateField->setDbIsFileMD($isMd);
|
||||||
$templateField->setDbPosition($index);
|
$templateField->setDbPosition($index);
|
||||||
|
|
||||||
$template->addCcPlayoutHistoryTemplateField($templateField);
|
$template->addCcPlayoutHistoryTemplateField($templateField);
|
||||||
|
@ -496,13 +608,17 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
$template->save($this->con);
|
$template->save($this->con);
|
||||||
|
|
||||||
|
$doSetDefault = $config['setDefault'];
|
||||||
|
if (isset($doSetDefault) && $doSetDefault) {
|
||||||
|
$this->setConfiguredItemTemplate($template->getDbid());
|
||||||
|
}
|
||||||
|
|
||||||
$this->con->commit();
|
$this->con->commit();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$this->con->rollback();
|
$this->con->rollback();
|
||||||
Logging::info($e);
|
throw $e;
|
||||||
throw $e;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,40 +1,14 @@
|
||||||
<div id="configure_item_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
<div id="configure_item_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||||
<button id="template_item_save" data-template="<?php echo $this->template_id; ?>">Save</button>
|
|
||||||
|
|
||||||
<div><label>Name<input id="template_name" type="text"></label></div>
|
|
||||||
|
|
||||||
<?php $i = 0; ?>
|
|
||||||
|
|
||||||
<ul class="template_item_list">
|
|
||||||
<?php foreach ($this->required as $field): ?>
|
|
||||||
|
|
||||||
<li id="<?php echo "field_".$i?>" data-name="<?php echo $field["name"]?>" data-type="<?php echo $field["type"]?>" data-filemd="<?php echo var_export($field["isFileMd"], true)?>">
|
|
||||||
<span><?php echo $field["name"]?></span>
|
|
||||||
<span><?php echo $field["type"]?></span>
|
|
||||||
</li>
|
|
||||||
<?php $i++; ?>
|
|
||||||
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<ul class="template_file_md">
|
|
||||||
<?php foreach ($this->fileMD as $md): ?>
|
|
||||||
|
|
||||||
<li id="<?php echo "md_".$md["name"]?>" data-name="<?php echo $md["name"]?>" data-type="<?php echo $md["type"]?>"><?php echo $md["name"] ?></li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="template_item_add">
|
|
||||||
<div>Add New Field</div>
|
|
||||||
<div>
|
<div>
|
||||||
<input type="text">
|
<select id="template_list">
|
||||||
<select>
|
<option value="">New</option>
|
||||||
<?php foreach ($this->fields as $field): ?>
|
<?php foreach ($this->template_list as $id=>$name): ?>
|
||||||
<option value="<?php echo $field; ?>"><?php echo $field; ?></option>
|
<option value="<?php echo $id; ?>"><?php echo $name; ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<button>Add</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<?php echo $this->render('playouthistory/item-template.phtml'); ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
|
@ -0,0 +1,43 @@
|
||||||
|
<div>
|
||||||
|
<button id="template_set_default" data-template="<?php echo $this->template_id; ?>">Set Default Template</button>
|
||||||
|
<button id="template_item_save" data-template="<?php echo $this->template_id; ?>">Save</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div><label>Name<input id="template_name" type="text" value="<?php echo $this->template_name; ?>"></label></div>
|
||||||
|
|
||||||
|
<?php $i = 0; ?>
|
||||||
|
|
||||||
|
<ul class="template_item_list">
|
||||||
|
<?php foreach ($this->template_fields as $field): ?>
|
||||||
|
|
||||||
|
<li id="<?php echo "field_".$i?>" data-id="<?php echo isset($field["id"]) ? $field["id"] : ""; ?>" data-name="<?php echo $field["name"]?>" data-type="<?php echo $field["type"]?>" data-filemd="<?php echo var_export($field["isFileMd"], true)?>">
|
||||||
|
<span><?php echo $field["name"]?></span>
|
||||||
|
<span><?php echo $field["type"]?></span>
|
||||||
|
<?php if(!in_array($field["name"], $this->required_fields)): ?>
|
||||||
|
<span class="template_item_remove">Remove</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</li>
|
||||||
|
<?php $i++; ?>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul class="template_file_md">
|
||||||
|
<?php foreach ($this->fileMD as $md): ?>
|
||||||
|
|
||||||
|
<li id="<?php echo "md_".$md["name"]?>" data-name="<?php echo $md["name"]?>" data-type="<?php echo $md["type"]?>"><?php echo $md["name"] ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="template_item_add">
|
||||||
|
<div>Add New Field</div>
|
||||||
|
<div>
|
||||||
|
<input type="text">
|
||||||
|
<select>
|
||||||
|
<?php foreach ($this->fields as $field): ?>
|
||||||
|
<option value="<?php echo $field; ?>"><?php echo $field; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<button>Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,4 +1,3 @@
|
||||||
<div id="history_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
<div id="history_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||||
|
|
||||||
<a href="<?php echo $this->baseUrl("Playouthistory/configure-item-template"); ?>">Configure Item Template</a>
|
<a href="<?php echo $this->baseUrl("Playouthistory/configure-item-template"); ?>">Configure Item Template</a>
|
||||||
</div>
|
</div>
|
|
@ -499,7 +499,8 @@
|
||||||
</table>
|
</table>
|
||||||
<table name="cc_playout_history_template" phpName="CcPlayoutHistoryTemplate">
|
<table name="cc_playout_history_template" phpName="CcPlayoutHistoryTemplate">
|
||||||
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
||||||
<column name="template_name" phpName="DbName" type="VARCHAR" size="128" required="true" />
|
<column name="name" phpName="DbName" type="VARCHAR" size="128" required="true" />
|
||||||
|
<column name="type" phpName="DbType" type="VARCHAR" size="35" required="true" />
|
||||||
</table>
|
</table>
|
||||||
<table name="cc_playout_history_template_field" phpName="CcPlayoutHistoryTemplateField">
|
<table name="cc_playout_history_template_field" phpName="CcPlayoutHistoryTemplateField">
|
||||||
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
||||||
|
|
|
@ -803,7 +803,8 @@ DROP TABLE "cc_playout_history_template" CASCADE;
|
||||||
CREATE TABLE "cc_playout_history_template"
|
CREATE TABLE "cc_playout_history_template"
|
||||||
(
|
(
|
||||||
"id" serial NOT NULL,
|
"id" serial NOT NULL,
|
||||||
"template_name" VARCHAR(128) NOT NULL,
|
"name" VARCHAR(128) NOT NULL,
|
||||||
|
"type" VARCHAR(35) NOT NULL,
|
||||||
PRIMARY KEY ("id")
|
PRIMARY KEY ("id")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var AIRTIME = (function(AIRTIME) {
|
var AIRTIME = (function(AIRTIME) {
|
||||||
var mod;
|
var mod;
|
||||||
|
var $templateDiv;
|
||||||
var $templateList;
|
var $templateList;
|
||||||
var $fileMDList;
|
var $fileMDList;
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
name: $el.data("name"),
|
name: $el.data("name"),
|
||||||
type: $el.data("type"),
|
type: $el.data("type"),
|
||||||
filemd: $el.data("filemd"),
|
filemd: $el.data("filemd"),
|
||||||
|
id: $el.data("id")
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,12 +79,12 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
mod.onReady = function() {
|
mod.onReady = function() {
|
||||||
|
|
||||||
|
$templateDiv = $("#configure_item_template");
|
||||||
$templateList = $(".template_item_list");
|
$templateList = $(".template_item_list");
|
||||||
$fileMDList = $(".template_file_md");
|
$fileMDList = $(".template_file_md");
|
||||||
|
|
||||||
|
|
||||||
$fileMDList.find("li").draggable({
|
$fileMDList.find("li").draggable({
|
||||||
//helper: "clone",
|
|
||||||
helper: function(event, ui) {
|
helper: function(event, ui) {
|
||||||
var $li = $(this);
|
var $li = $(this);
|
||||||
var name = $li.data("name");
|
var name = $li.data("name");
|
||||||
|
@ -96,11 +98,11 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
$templateList.sortable(fieldSortable);
|
$templateList.sortable(fieldSortable);
|
||||||
|
|
||||||
$templateList.on("click", ".template_item_remove", function() {
|
$templateDiv.on("click", ".template_item_remove", function() {
|
||||||
$(this).parents("li").remove();
|
$(this).parents("li").remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".template_item_add").on("click", "button", function() {
|
$templateDiv.on("click", ".template_item_add button", function() {
|
||||||
var $div = $(this).parents("div.template_item_add");
|
var $div = $(this).parents("div.template_item_add");
|
||||||
|
|
||||||
var name = $div.find("input").val();
|
var name = $div.find("input").val();
|
||||||
|
@ -109,8 +111,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
addField(name, type, false, false);
|
addField(name, type, false, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#template_item_save").click(function(){
|
function createUpdateTemplate(template_id, isDefault) {
|
||||||
var template_id = $(this).data("template");
|
|
||||||
var createUrl = baseUrl+"Playouthistory/create-template/format/json";
|
var createUrl = baseUrl+"Playouthistory/create-template/format/json";
|
||||||
var updateUrl = baseUrl+"Playouthistory/update-template/format/json";
|
var updateUrl = baseUrl+"Playouthistory/update-template/format/json";
|
||||||
var url;
|
var url;
|
||||||
|
@ -130,9 +131,46 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
data[i] = getFieldData($li);
|
data[i] = getFieldData($li);
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post(url, {name: templateName, fields: data}, function(json) {
|
$.post(url, {'name': templateName, 'fields': data, 'setDefault': isDefault}, function(json) {
|
||||||
var x;
|
var x;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$templateDiv.on("click", "#template_item_save", function(){
|
||||||
|
var template_id = $(this).data("template");
|
||||||
|
|
||||||
|
createUpdateTemplate(template_id, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
$templateDiv.on("click", "#template_set_default", function(){
|
||||||
|
var template_id = $(this).data("template");
|
||||||
|
|
||||||
|
if (isNaN(parseInt(template_id, 10))) {
|
||||||
|
|
||||||
|
createUpdateTemplate(template_id, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
var url = baseUrl+"Playouthistory/set-item-template-default/format/json";
|
||||||
|
|
||||||
|
$.post(url, {id: template_id}, function(json) {
|
||||||
|
var x;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#template_list").change(function(){
|
||||||
|
var template_id = $(this).find(":selected").val(),
|
||||||
|
url;
|
||||||
|
|
||||||
|
if (!isNaN(parseInt(template_id, 10))) {
|
||||||
|
url = baseUrl+"Playouthistory/configure-item-template/id/"+template_id;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
url = baseUrl+"Playouthistory/configure-item-template";
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.href = url;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue