subclassing the template types, files summary table is now fully configurable form wise.
This commit is contained in:
parent
5676decd2d
commit
d83c004fb9
7 changed files with 345 additions and 324 deletions
|
@ -6,14 +6,14 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext
|
$ajaxContext
|
||||||
->addActionContext('aggregate-history-feed', 'json')
|
->addActionContext('file-history-feed', 'json')
|
||||||
->addActionContext('item-history-feed', 'json')
|
->addActionContext('item-history-feed', 'json')
|
||||||
->addActionContext('edit-aggregate-item', 'json')
|
->addActionContext('edit-file-item', 'json')
|
||||||
->addActionContext('create-list-item', 'json')
|
->addActionContext('create-list-item', 'json')
|
||||||
->addActionContext('edit-list-item', 'json')
|
->addActionContext('edit-list-item', 'json')
|
||||||
->addActionContext('delete-list-item', 'json')
|
->addActionContext('delete-list-item', 'json')
|
||||||
->addActionContext('update-list-item', 'json')
|
->addActionContext('update-list-item', 'json')
|
||||||
->addActionContext('update-aggregate-item', 'json')
|
->addActionContext('update-file-item', 'json')
|
||||||
->addActionContext('create-template', 'json')
|
->addActionContext('create-template', 'json')
|
||||||
->addActionContext('update-template', 'json')
|
->addActionContext('update-template', 'json')
|
||||||
->addActionContext('delete-template', 'json')
|
->addActionContext('delete-template', 'json')
|
||||||
|
@ -79,7 +79,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
$this->view->headScript()->appendScript($script);
|
$this->view->headScript()->appendScript($script);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function aggregateHistoryFeedAction()
|
public function fileHistoryFeedAction()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
@ -136,7 +136,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editAggregateItemAction()
|
public function editFileItemAction()
|
||||||
{
|
{
|
||||||
$file_id = $this->_getParam('id');
|
$file_id = $this->_getParam('id');
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateAggregateItemAction()
|
public function updateFileItemAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$params = $request->getPost();
|
$params = $request->getPost();
|
||||||
|
|
211
airtime_mvc/application/forms/EditHistory.php
Normal file
211
airtime_mvc/application/forms/EditHistory.php
Normal file
|
@ -0,0 +1,211 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Application_Form_EditHistory extends Zend_Form
|
||||||
|
{
|
||||||
|
const VALIDATE_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
|
||||||
|
//this is used by the javascript widget, unfortunately h/H is opposite from Zend.
|
||||||
|
const TIMEPICKER_DATETIME_FORMAT = 'yyyy-MM-dd hh:mm:ss';
|
||||||
|
|
||||||
|
const VALIDATE_DATE_FORMAT = 'yyyy-MM-dd';
|
||||||
|
const VALIDATE_TIME_FORMAT = 'HH:mm:ss';
|
||||||
|
|
||||||
|
const ITEM_TYPE = "type";
|
||||||
|
const ITEM_CLASS = "class";
|
||||||
|
const ITEM_OPTIONS = "options";
|
||||||
|
const ITEM_ID_SUFFIX = "name";
|
||||||
|
|
||||||
|
const TEXT_INPUT_CLASS = "input_text";
|
||||||
|
|
||||||
|
private $formElTypes = array(
|
||||||
|
TEMPLATE_DATE => array(
|
||||||
|
"class" => "Zend_Form_Element_Text",
|
||||||
|
"attrs" => array(
|
||||||
|
"class" => self::TEXT_INPUT_CLASS
|
||||||
|
),
|
||||||
|
"validators" => array(
|
||||||
|
array(
|
||||||
|
"class" => "Zend_Validate_Date",
|
||||||
|
"params" => array(
|
||||||
|
"format" => self::VALIDATE_DATE_FORMAT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"filters" => array(
|
||||||
|
"StringTrim"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TEMPLATE_TIME => array(
|
||||||
|
"class" => "Zend_Form_Element_Text",
|
||||||
|
"attrs" => array(
|
||||||
|
"class" => self::TEXT_INPUT_CLASS
|
||||||
|
),
|
||||||
|
"validators" => array(
|
||||||
|
array(
|
||||||
|
"class" => "Zend_Validate_Date",
|
||||||
|
"params" => array(
|
||||||
|
"format" => self::VALIDATE_TIME_FORMAT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"filters" => array(
|
||||||
|
"StringTrim"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TEMPLATE_DATETIME => array(
|
||||||
|
"class" => "Zend_Form_Element_Text",
|
||||||
|
"attrs" => array(
|
||||||
|
"class" => self::TEXT_INPUT_CLASS
|
||||||
|
),
|
||||||
|
"validators" => array(
|
||||||
|
array(
|
||||||
|
"class" => "Zend_Validate_Date",
|
||||||
|
"params" => array(
|
||||||
|
"format" => self::VALIDATE_DATETIME_FORMAT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"filters" => array(
|
||||||
|
"StringTrim"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TEMPLATE_STRING => array(
|
||||||
|
"class" => "Zend_Form_Element_Text",
|
||||||
|
"attrs" => array(
|
||||||
|
"class" => self::TEXT_INPUT_CLASS
|
||||||
|
),
|
||||||
|
"filters" => array(
|
||||||
|
"StringTrim"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TEMPLATE_BOOLEAN => array(
|
||||||
|
"class" => "Zend_Form_Element_Checkbox",
|
||||||
|
"validators" => array(
|
||||||
|
array(
|
||||||
|
"class" => "Zend_Validate_InArray",
|
||||||
|
"options" => array(
|
||||||
|
"haystack" => array(0,1)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TEMPLATE_INT => array(
|
||||||
|
"class" => "Zend_Form_Element_Text",
|
||||||
|
"validators" => array(
|
||||||
|
array(
|
||||||
|
"class" => "Zend_Validate_Int",
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"attrs" => array(
|
||||||
|
"class" => self::TEXT_INPUT_CLASS
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TEMPLATE_FLOAT => array(
|
||||||
|
"class" => "Zend_Form_Element_Text",
|
||||||
|
"attrs" => array(
|
||||||
|
"class" => self::TEXT_INPUT_CLASS
|
||||||
|
),
|
||||||
|
"validators" => array(
|
||||||
|
array(
|
||||||
|
"class" => "Zend_Validate_Float",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
$history_id = new Zend_Form_Element_Hidden($this::ID_PREFIX.'id');
|
||||||
|
$history_id->setValidators(array(
|
||||||
|
new Zend_Validate_Int()
|
||||||
|
));
|
||||||
|
$history_id->setDecorators(array('ViewHelper'));
|
||||||
|
$this->addElement($history_id);
|
||||||
|
|
||||||
|
$dynamic_attrs = new Zend_Form_SubForm();
|
||||||
|
$this->addSubForm($dynamic_attrs, $this::ID_PREFIX.'template');
|
||||||
|
|
||||||
|
// Add the submit button
|
||||||
|
$this->addElement('button', $this::ID_PREFIX.'save', array(
|
||||||
|
'ignore' => true,
|
||||||
|
'class' => 'btn '.$this::ID_PREFIX.'save',
|
||||||
|
'label' => _('Save'),
|
||||||
|
'decorators' => array(
|
||||||
|
'ViewHelper'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
// Add the cancel button
|
||||||
|
$this->addElement('button', $this::ID_PREFIX.'cancel', array(
|
||||||
|
'ignore' => true,
|
||||||
|
'class' => 'btn '.$this::ID_PREFIX.'cancel',
|
||||||
|
'label' => _('Cancel'),
|
||||||
|
'decorators' => array(
|
||||||
|
'ViewHelper'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createFromTemplate($template, $required) {
|
||||||
|
|
||||||
|
$templateSubForm = $this->getSubForm($this::ID_PREFIX.'template');
|
||||||
|
|
||||||
|
for ($i = 0, $len = count($template); $i < $len; $i++) {
|
||||||
|
|
||||||
|
$item = $template[$i];
|
||||||
|
//don't dynamically add this as it should be included in the
|
||||||
|
//init() function already if it should show up in the UI..
|
||||||
|
if (in_array($item["name"], $required)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$formElType = $this->formElTypes[$item[self::ITEM_TYPE]];
|
||||||
|
|
||||||
|
$label = $item[self::ITEM_ID_SUFFIX];
|
||||||
|
$id = $this::ID_PREFIX.$label;
|
||||||
|
$el = new $formElType[self::ITEM_CLASS]($id);
|
||||||
|
$el->setLabel($item["label"]);
|
||||||
|
|
||||||
|
if (isset($formElType["attrs"])) {
|
||||||
|
|
||||||
|
$attrs = $formElType["attrs"];
|
||||||
|
|
||||||
|
foreach ($attrs as $key => $value) {
|
||||||
|
$el->setAttrib($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($formElType["filters"])) {
|
||||||
|
|
||||||
|
$filters = $formElType["filters"];
|
||||||
|
|
||||||
|
foreach ($filters as $filter) {
|
||||||
|
$el->addFilter($filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($formElType["validators"])) {
|
||||||
|
|
||||||
|
$validators = $formElType["validators"];
|
||||||
|
|
||||||
|
foreach ($validators as $index => $arr) {
|
||||||
|
$options = isset($arr[self::ITEM_OPTIONS]) ? $arr[self::ITEM_OPTIONS] : null;
|
||||||
|
$validator = new $arr[self::ITEM_CLASS]($options);
|
||||||
|
|
||||||
|
//extra validator info
|
||||||
|
if (isset($arr["params"])) {
|
||||||
|
|
||||||
|
foreach ($arr["params"] as $key => $value) {
|
||||||
|
$method = "set".ucfirst($key);
|
||||||
|
$validator->$method($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$el->addValidator($validator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$el->setDecorators(array('ViewHelper'));
|
||||||
|
$templateSubForm->addElement($el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,91 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Application_Form_EditHistoryFile extends Zend_Form
|
class Application_Form_EditHistoryFile extends Application_Form_EditHistory
|
||||||
{
|
{
|
||||||
|
const ID_PREFIX = "his_file_";
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
|
|
||||||
/*
|
parent::init();
|
||||||
|
|
||||||
$this->setDecorators(
|
$this->setDecorators(
|
||||||
array(
|
array(
|
||||||
array('ViewScript', array('viewScript' => 'form/edit-history-file.phtml'))
|
array('ViewScript', array('viewScript' => 'form/edit-history-file.phtml'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
*/
|
}
|
||||||
|
|
||||||
$this->setMethod('post');
|
public function createFromTemplate($template, $required) {
|
||||||
|
|
||||||
|
parent::createFromTemplate($template, $required);
|
||||||
$file_id = new Zend_Form_Element_Hidden('his_file_id');
|
|
||||||
$file_id->setValidators(array(
|
|
||||||
new Zend_Validate_Int()
|
|
||||||
));
|
|
||||||
$this->addElement($file_id);
|
|
||||||
|
|
||||||
|
|
||||||
/* Title form element */
|
|
||||||
$title = new Zend_Form_Element_Text('his_file_title');
|
|
||||||
$title->setLabel(_('Title:'));
|
|
||||||
$title->setAttrib('class', 'input_text');
|
|
||||||
$title->addFilter('StringTrim');
|
|
||||||
//$title->setDecorators(array('viewHelper'));
|
|
||||||
$this->addElement($title);
|
|
||||||
|
|
||||||
/* Creator form element */
|
|
||||||
$creator = new Zend_Form_Element_Text('his_file_creator');
|
|
||||||
$creator->setLabel(_('Creator:'));
|
|
||||||
$creator->setAttrib('class', 'input_text');
|
|
||||||
$creator->addFilter('StringTrim');
|
|
||||||
//$creator->setDecorators(array('viewHelper'));
|
|
||||||
$this->addElement($creator);
|
|
||||||
|
|
||||||
/* Composer form element */
|
|
||||||
$composer = new Zend_Form_Element_Text('his_file_composer');
|
|
||||||
$composer->setLabel(_('Composer:'));
|
|
||||||
$composer->setAttrib('class', 'input_text');
|
|
||||||
$composer->addFilter('StringTrim');
|
|
||||||
//$composer->setDecorators(array('viewHelper'));
|
|
||||||
$this->addElement($composer);
|
|
||||||
|
|
||||||
/* Copyright form element */
|
|
||||||
$copyright = new Zend_Form_Element_Text('his_file_copyright');
|
|
||||||
$copyright->setLabel(_('Copyright:'));
|
|
||||||
$copyright->setAttrib('class', 'input_text');
|
|
||||||
$copyright->addFilter('StringTrim');
|
|
||||||
//$copyright->setDecorators(array('viewHelper'));
|
|
||||||
$this->addElement($copyright);
|
|
||||||
|
|
||||||
// Add the submit button
|
|
||||||
$this->addElement('button', 'his_file_save', array(
|
|
||||||
'ignore' => true,
|
|
||||||
'class' => 'btn his_file_save',
|
|
||||||
'label' => _('Save'),
|
|
||||||
'decorators' => array(
|
|
||||||
'ViewHelper'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
// Add the cancel button
|
|
||||||
$this->addElement('button', 'his_file_cancel', array(
|
|
||||||
'ignore' => true,
|
|
||||||
'class' => 'btn his_file_cancel',
|
|
||||||
'label' => _('Cancel'),
|
|
||||||
'decorators' => array(
|
|
||||||
'ViewHelper'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addDisplayGroup(
|
|
||||||
array(
|
|
||||||
'his_file_save',
|
|
||||||
'his_file_cancel'
|
|
||||||
),
|
|
||||||
'submitButtons',
|
|
||||||
array(
|
|
||||||
'decorators' => array(
|
|
||||||
'FormElements',
|
|
||||||
'DtDdWrapper'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,133 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Application_Form_EditHistoryItem extends Zend_Form
|
class Application_Form_EditHistoryItem extends Application_Form_EditHistory
|
||||||
{
|
{
|
||||||
const VALIDATE_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
|
|
||||||
//this is used by the javascript widget, unfortunately h/H is opposite from Zend.
|
|
||||||
const TIMEPICKER_DATETIME_FORMAT = 'yyyy-MM-dd hh:mm:ss';
|
|
||||||
|
|
||||||
const VALIDATE_DATE_FORMAT = 'yyyy-MM-dd';
|
|
||||||
const VALIDATE_TIME_FORMAT = 'HH:mm:ss';
|
|
||||||
|
|
||||||
const ID_PREFIX = "his_item_";
|
const ID_PREFIX = "his_item_";
|
||||||
|
|
||||||
const ITEM_TYPE = "type";
|
|
||||||
const ITEM_CLASS = "class";
|
|
||||||
const ITEM_OPTIONS = "options";
|
|
||||||
const ITEM_ID_SUFFIX = "name";
|
|
||||||
|
|
||||||
const TEXT_INPUT_CLASS = "input_text";
|
|
||||||
|
|
||||||
private $formElTypes = array(
|
|
||||||
TEMPLATE_DATE => array(
|
|
||||||
"class" => "Zend_Form_Element_Text",
|
|
||||||
"attrs" => array(
|
|
||||||
"class" => self::TEXT_INPUT_CLASS
|
|
||||||
),
|
|
||||||
"validators" => array(
|
|
||||||
array(
|
|
||||||
"class" => "Zend_Validate_Date",
|
|
||||||
"params" => array(
|
|
||||||
"format" => self::VALIDATE_DATE_FORMAT
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"filters" => array(
|
|
||||||
"StringTrim"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TEMPLATE_TIME => array(
|
|
||||||
"class" => "Zend_Form_Element_Text",
|
|
||||||
"attrs" => array(
|
|
||||||
"class" => self::TEXT_INPUT_CLASS
|
|
||||||
),
|
|
||||||
"validators" => array(
|
|
||||||
array(
|
|
||||||
"class" => "Zend_Validate_Date",
|
|
||||||
"params" => array(
|
|
||||||
"format" => self::VALIDATE_TIME_FORMAT
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"filters" => array(
|
|
||||||
"StringTrim"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TEMPLATE_DATETIME => array(
|
|
||||||
"class" => "Zend_Form_Element_Text",
|
|
||||||
"attrs" => array(
|
|
||||||
"class" => self::TEXT_INPUT_CLASS
|
|
||||||
),
|
|
||||||
"validators" => array(
|
|
||||||
array(
|
|
||||||
"class" => "Zend_Validate_Date",
|
|
||||||
"params" => array(
|
|
||||||
"format" => self::VALIDATE_DATETIME_FORMAT
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"filters" => array(
|
|
||||||
"StringTrim"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TEMPLATE_STRING => array(
|
|
||||||
"class" => "Zend_Form_Element_Text",
|
|
||||||
"attrs" => array(
|
|
||||||
"class" => self::TEXT_INPUT_CLASS
|
|
||||||
),
|
|
||||||
"filters" => array(
|
|
||||||
"StringTrim"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TEMPLATE_BOOLEAN => array(
|
|
||||||
"class" => "Zend_Form_Element_Checkbox",
|
|
||||||
"validators" => array(
|
|
||||||
array(
|
|
||||||
"class" => "Zend_Validate_InArray",
|
|
||||||
"options" => array(
|
|
||||||
"haystack" => array(0,1)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TEMPLATE_INT => array(
|
|
||||||
"class" => "Zend_Form_Element_Text",
|
|
||||||
"validators" => array(
|
|
||||||
array(
|
|
||||||
"class" => "Zend_Validate_Int",
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"attrs" => array(
|
|
||||||
"class" => self::TEXT_INPUT_CLASS
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TEMPLATE_FLOAT => array(
|
|
||||||
"class" => "Zend_Form_Element_Text",
|
|
||||||
"attrs" => array(
|
|
||||||
"class" => self::TEXT_INPUT_CLASS
|
|
||||||
),
|
|
||||||
"validators" => array(
|
|
||||||
array(
|
|
||||||
"class" => "Zend_Validate_Float",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
|
|
||||||
|
parent::init();
|
||||||
|
|
||||||
$this->setDecorators(array(
|
$this->setDecorators(array(
|
||||||
'PrepareElements',
|
'PrepareElements',
|
||||||
array('ViewScript', array('viewScript' => 'form/edit-history-item.phtml'))
|
array('ViewScript', array('viewScript' => 'form/edit-history-item.phtml'))
|
||||||
));
|
));
|
||||||
|
|
||||||
$history_id = new Zend_Form_Element_Hidden(self::ID_PREFIX.'id');
|
|
||||||
$history_id->setValidators(array(
|
|
||||||
new Zend_Validate_Int()
|
|
||||||
));
|
|
||||||
$history_id->setDecorators(array('ViewHelper'));
|
|
||||||
$this->addElement($history_id);
|
|
||||||
|
|
||||||
$starts = new Zend_Form_Element_Text(self::ID_PREFIX.'starts');
|
$starts = new Zend_Form_Element_Text(self::ID_PREFIX.'starts');
|
||||||
$starts->setValidators(array(
|
$starts->setValidators(array(
|
||||||
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)
|
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)
|
||||||
|
@ -151,95 +36,10 @@ class Application_Form_EditHistoryItem extends Zend_Form
|
||||||
$ends->setDecorators(array('ViewHelper'));
|
$ends->setDecorators(array('ViewHelper'));
|
||||||
$ends->setRequired(true);
|
$ends->setRequired(true);
|
||||||
$this->addElement($ends);
|
$this->addElement($ends);
|
||||||
|
|
||||||
$dynamic_attrs = new Zend_Form_SubForm();
|
|
||||||
$this->addSubForm($dynamic_attrs, self::ID_PREFIX.'template');
|
|
||||||
|
|
||||||
// Add the submit button
|
|
||||||
$this->addElement('button', 'his_item_save', array(
|
|
||||||
'ignore' => true,
|
|
||||||
'class' => 'btn his_item_save',
|
|
||||||
'label' => _('Save'),
|
|
||||||
'decorators' => array(
|
|
||||||
'ViewHelper'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
// Add the cancel button
|
|
||||||
$this->addElement('button', 'his_item_cancel', array(
|
|
||||||
'ignore' => true,
|
|
||||||
'class' => 'btn his_item_cancel',
|
|
||||||
'label' => _('Cancel'),
|
|
||||||
'decorators' => array(
|
|
||||||
'ViewHelper'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createFromTemplate($template, $required) {
|
public function createFromTemplate($template, $required) {
|
||||||
|
|
||||||
$templateSubForm = $this->getSubForm(self::ID_PREFIX.'template');
|
parent::createFromTemplate($template, $required);
|
||||||
|
|
||||||
for ($i = 0, $len = count($template); $i < $len; $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]];
|
|
||||||
|
|
||||||
$label = $item[self::ITEM_ID_SUFFIX];
|
|
||||||
$id = self::ID_PREFIX.$label;
|
|
||||||
$el = new $formElType[self::ITEM_CLASS]($id);
|
|
||||||
$el->setLabel($item["label"]);
|
|
||||||
|
|
||||||
if (isset($formElType["attrs"])) {
|
|
||||||
|
|
||||||
$attrs = $formElType["attrs"];
|
|
||||||
|
|
||||||
foreach ($attrs as $key => $value) {
|
|
||||||
$el->setAttrib($key, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($formElType["filters"])) {
|
|
||||||
|
|
||||||
$filters = $formElType["filters"];
|
|
||||||
|
|
||||||
foreach ($filters as $filter) {
|
|
||||||
$el->addFilter($filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($formElType["validators"])) {
|
|
||||||
|
|
||||||
$validators = $formElType["validators"];
|
|
||||||
|
|
||||||
foreach ($validators as $index => $arr) {
|
|
||||||
$options = isset($arr[self::ITEM_OPTIONS]) ? $arr[self::ITEM_OPTIONS] : null;
|
|
||||||
$validator = new $arr[self::ITEM_CLASS]($options);
|
|
||||||
|
|
||||||
//extra validator info
|
|
||||||
if (isset($arr["params"])) {
|
|
||||||
|
|
||||||
foreach ($arr["params"] as $key => $value) {
|
|
||||||
$method = "set".ucfirst($key);
|
|
||||||
$validator->$method($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$el->addValidator($validator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$el->setDecorators(array('ViewHelper'));
|
|
||||||
$templateSubForm->addElement($el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function fillFields() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -517,17 +517,30 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form = new Application_Form_EditHistoryFile();
|
$form = new Application_Form_EditHistoryFile();
|
||||||
|
$template = $this->getConfiguredFileTemplate();
|
||||||
|
$required = $this->mandatoryFileFields();
|
||||||
|
$form->createFromTemplate($template["fields"], $required);
|
||||||
|
|
||||||
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
||||||
$md = $file->getDbColMetadata();
|
$md = $file->getDbColMetadata();
|
||||||
|
|
||||||
$form->populate(array(
|
$prefix = Application_Form_EditHistoryFile::ID_PREFIX;
|
||||||
'his_file_id' => $id,
|
$formValues = array();
|
||||||
'his_file_title' => $md[MDATA_KEY_TITLE],
|
$formValues["{$prefix}id"] = $id;
|
||||||
'his_file_creator' => $md[MDATA_KEY_CREATOR],
|
|
||||||
'his_file_composer' => $md[MDATA_KEY_COMPOSER],
|
foreach($template["fields"] as $index => $field) {
|
||||||
'his_file_copyright' => $md[MDATA_KEY_COPYRIGHT]
|
|
||||||
));
|
$key = $field["name"];
|
||||||
|
|
||||||
|
if (in_array($key, $required)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = $md[$key];
|
||||||
|
$formValues["$prefix{$key}"] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->populate($formValues);
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
@ -537,6 +550,35 @@ class Application_Service_HistoryService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function populateTemplateFile($values, $id) {
|
||||||
|
|
||||||
|
$this->con->beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
||||||
|
|
||||||
|
$prefix = Application_Form_EditHistoryFile::ID_PREFIX;
|
||||||
|
$prefix_len = strlen($prefix);
|
||||||
|
$templateValues = $values[$prefix."template"];
|
||||||
|
|
||||||
|
$md = array();
|
||||||
|
|
||||||
|
foreach ($templateValues as $index => $value) {
|
||||||
|
|
||||||
|
$key = substr($index, $prefix_len);
|
||||||
|
$md[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file->setDbColMetadata($md);
|
||||||
|
$this->con->commit();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$this->con->rollback();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function populateTemplateItem($values, $id=null) {
|
public function populateTemplateItem($values, $id=null) {
|
||||||
|
|
||||||
$this->con->beginTransaction();
|
$this->con->beginTransaction();
|
||||||
|
@ -627,7 +669,6 @@ class Application_Service_HistoryService
|
||||||
$this->con->rollback();
|
$this->con->rollback();
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPlayedItem($data) {
|
public function createPlayedItem($data) {
|
||||||
|
@ -702,28 +743,32 @@ class Application_Service_HistoryService
|
||||||
/* id is an id in cc_files */
|
/* id is an id in cc_files */
|
||||||
public function editPlayedFile($data) {
|
public function editPlayedFile($data) {
|
||||||
|
|
||||||
$this->con->beginTransaction();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form = new Application_Form_EditHistoryFile();
|
$id = $data["his_file_id"];
|
||||||
|
$form = $form = $this->makeHistoryFileForm($id);
|
||||||
|
$history_id = $form->getElement("his_file_id");
|
||||||
|
$history_id->setRequired(true);
|
||||||
|
|
||||||
$json = $form->processAjax($data);
|
Logging::info($data);
|
||||||
Logging::info($json);
|
$json = array();
|
||||||
|
|
||||||
if ($form->isValid($data)) {
|
if ($form->isValid($data)) {
|
||||||
|
$history_id->setIgnore(true);
|
||||||
|
$values = $form->getValues();
|
||||||
|
|
||||||
$id = $data["his_file_id"];
|
Logging::info("edited list item");
|
||||||
$file = Application_Model_StoredFile::RecallById($id, $this->con);
|
Logging::info($values);
|
||||||
|
|
||||||
$md = array(
|
$this->populateTemplateFile($values, $id);
|
||||||
MDATA_KEY_TITLE => $data['his_file_title'],
|
|
||||||
MDATA_KEY_CREATOR => $data['his_file_creator'],
|
|
||||||
MDATA_KEY_COMPOSER => $data['his_file_composer'],
|
|
||||||
MDATA_KEY_COPYRIGHT => $data['his_file_copyright']
|
|
||||||
);
|
|
||||||
|
|
||||||
$file->setDbColMetadata($md);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$msgs = $form->getMessages();
|
||||||
|
Logging::info($msgs);
|
||||||
|
|
||||||
|
$json["error"] = $msgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $json;
|
||||||
|
|
||||||
$this->con->commit();
|
$this->con->commit();
|
||||||
}
|
}
|
||||||
|
@ -819,7 +864,7 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
public function mandatoryFileFields() {
|
public function mandatoryFileFields() {
|
||||||
|
|
||||||
$fields = array("played", MDATA_KEY_TITLE, MDATA_KEY_CREATOR);
|
$fields = array("played");
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,37 @@
|
||||||
<div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong" id="edit-history-file">
|
<form>
|
||||||
<?php echo $this->form; ?>
|
<?php $form = $this->element ?>
|
||||||
</div>
|
|
||||||
|
<dl class="zend_form">
|
||||||
|
|
||||||
|
<?php $name = "his_file_id"; ?>
|
||||||
|
<dd id="<?php echo $name;?>-element">
|
||||||
|
<?php echo $form->getElement($name); ?>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<?php foreach ($form->getSubForm('his_file_template') as $index=>$el): ?>
|
||||||
|
<?php $name = $el->getName(); ?>
|
||||||
|
|
||||||
|
<dt id="<?php echo $name;?>-label">
|
||||||
|
<label for="<?php echo $name;?>"><?php echo $el->getLabel() ?></label>
|
||||||
|
</dt>
|
||||||
|
<dd id="<?php echo $name;?>-element">
|
||||||
|
<?php echo $el ?>
|
||||||
|
<?php if ($el->hasErrors()): ?>
|
||||||
|
<ul class='errors'>
|
||||||
|
<?php foreach($el->getMessages() as $error): ?>
|
||||||
|
<li><?php echo $error; ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
|
</dd>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<dd id="submitButtons-element">
|
||||||
|
<?php foreach (array("his_file_save", "his_file_cancel") as $name): ?>
|
||||||
|
<?php echo $form->getElement($name); ?>
|
||||||
|
<?php endforeach;?>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
</form>
|
|
@ -99,7 +99,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
fnRowCallback;
|
fnRowCallback;
|
||||||
|
|
||||||
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||||
var editUrl = baseUrl+"Playouthistory/edit-aggregate-item/format/json/id/"+aData.file_id;
|
var editUrl = baseUrl+"Playouthistory/edit-file-item/format/json/id/"+aData.file_id;
|
||||||
|
|
||||||
nRow.setAttribute('url-edit', editUrl);
|
nRow.setAttribute('url-edit', editUrl);
|
||||||
};
|
};
|
||||||
|
@ -112,7 +112,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
"bProcessing": true,
|
"bProcessing": true,
|
||||||
"bServerSide": true,
|
"bServerSide": true,
|
||||||
"sAjaxSource": baseUrl+"playouthistory/aggregate-history-feed",
|
"sAjaxSource": baseUrl+"playouthistory/file-history-feed",
|
||||||
"sAjaxDataProp": "history",
|
"sAjaxDataProp": "history",
|
||||||
"fnServerData": fnServerData,
|
"fnServerData": fnServerData,
|
||||||
"fnRowCallback": fnRowCallback,
|
"fnRowCallback": fnRowCallback,
|
||||||
|
@ -346,12 +346,12 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
var $form = $(this).parents("form");
|
var $form = $(this).parents("form");
|
||||||
var data = $form.serializeArray();
|
var data = $form.serializeArray();
|
||||||
|
|
||||||
var url = baseUrl+"Playouthistory/update-aggregate-item/format/json";
|
var url = baseUrl+"Playouthistory/update-file-item/format/json";
|
||||||
|
|
||||||
$.post(url, data, function(json) {
|
$.post(url, data, function(json) {
|
||||||
|
|
||||||
//TODO put errors on form.
|
//TODO put errors on form.
|
||||||
if (json.data !== "true") {
|
if (json.error !== undefined) {
|
||||||
//makeHistoryDialog(json.dialog);
|
//makeHistoryDialog(json.dialog);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue