CC-4090: Make code style PSR compliant - part 4
-forms directory
This commit is contained in:
parent
481616a0d6
commit
b2327472e8
29 changed files with 505 additions and 519 deletions
|
@ -9,7 +9,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
||||||
array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast-absolute.phtml'))
|
array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast-absolute.phtml'))
|
||||||
));
|
));
|
||||||
|
|
||||||
for($i=1; $i<=10; $i++) {
|
for ($i=1; $i<=10; $i++) {
|
||||||
|
|
||||||
$text = new Zend_Form_Element_Text("add_show_rebroadcast_date_absolute_$i");
|
$text = new Zend_Form_Element_Text("add_show_rebroadcast_date_absolute_$i");
|
||||||
$text->setAttrib('class', 'input_text');
|
$text->setAttrib('class', 'input_text');
|
||||||
|
@ -30,43 +30,41 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkReliantFields($formData) {
|
public function checkReliantFields($formData)
|
||||||
|
{
|
||||||
$noError = true;
|
$noError = true;
|
||||||
|
|
||||||
for($i=1; $i<=10; $i++) {
|
for ($i=1; $i<=10; $i++) {
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
$day = $formData['add_show_rebroadcast_date_absolute_'.$i];
|
$day = $formData['add_show_rebroadcast_date_absolute_'.$i];
|
||||||
$time = $formData['add_show_rebroadcast_time_absolute_'.$i];
|
$time = $formData['add_show_rebroadcast_time_absolute_'.$i];
|
||||||
|
|
||||||
if(trim($day) == "" && trim($time) == "") {
|
if (trim($day) == "" && trim($time) == "") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($day) == ""){
|
if (trim($day) == "") {
|
||||||
$this->getElement('add_show_rebroadcast_date_absolute_'.$i)->setErrors(array("Day must be specified"));
|
$this->getElement('add_show_rebroadcast_date_absolute_'.$i)->setErrors(array("Day must be specified"));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim($time) == "") {
|
||||||
if (trim($time) == ""){
|
|
||||||
$this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Time must be specified"));
|
$this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Time must be specified"));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($valid === false) {
|
if ($valid === false) {
|
||||||
$noError = false;
|
$noError = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +82,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
||||||
$rebroad_start = $day." ".$formData['add_show_rebroadcast_time_absolute_'.$i];
|
$rebroad_start = $day." ".$formData['add_show_rebroadcast_time_absolute_'.$i];
|
||||||
$rebroad_start = new DateTime($rebroad_start);
|
$rebroad_start = new DateTime($rebroad_start);
|
||||||
|
|
||||||
if($rebroad_start < $show_end) {
|
if ($rebroad_start < $show_end) {
|
||||||
$this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast"));
|
$this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast"));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$noError = false;
|
$noError = false;
|
||||||
|
@ -94,4 +92,3 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
||||||
return $noError;
|
return $noError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
||||||
$this->addElement($custom_password);
|
$this->addElement($custom_password);
|
||||||
|
|
||||||
$connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
|
$connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
|
||||||
if(trim($connection_url) == ""){
|
if (trim($connection_url) == "") {
|
||||||
$connection_url = "N/A";
|
$connection_url = "N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,21 +53,23 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid($data){
|
public function isValid($data)
|
||||||
|
{
|
||||||
$isValid = parent::isValid($data);
|
$isValid = parent::isValid($data);
|
||||||
|
|
||||||
if($data['cb_custom_auth'] == 1){
|
if ($data['cb_custom_auth'] == 1) {
|
||||||
if(trim($data['custom_username']) == ''){
|
if (trim($data['custom_username']) == '') {
|
||||||
$element = $this->getElement("custom_username");
|
$element = $this->getElement("custom_username");
|
||||||
$element->addError("Username field cannot be empty.");
|
$element->addError("Username field cannot be empty.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
if(trim($data['custom_password']) == ''){
|
if (trim($data['custom_password']) == '') {
|
||||||
$element = $this->getElement("custom_password");
|
$element = $this->getElement("custom_password");
|
||||||
$element->addError("Password field cannot be empty.");
|
$element->addError("Password field cannot be empty.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,14 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
||||||
|
|
||||||
$relativeDates = array();
|
$relativeDates = array();
|
||||||
$relativeDates[""] = "";
|
$relativeDates[""] = "";
|
||||||
for($i=0; $i<=30; $i++) {
|
for ($i=0; $i<=30; $i++) {
|
||||||
$relativeDates["$i days"] = "+$i days";
|
$relativeDates["$i days"] = "+$i days";
|
||||||
}
|
}
|
||||||
|
|
||||||
for($i=1; $i<=10; $i++) {
|
for ($i=1; $i<=10; $i++) {
|
||||||
|
|
||||||
$select = new Zend_Form_Element_Select("add_show_rebroadcast_date_$i");
|
$select = new Zend_Form_Element_Select("add_show_rebroadcast_date_$i");
|
||||||
$select->setAttrib('class', 'input_select');
|
$select->setAttrib('class', 'input_select');
|
||||||
|
@ -35,43 +35,41 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkReliantFields($formData) {
|
public function checkReliantFields($formData)
|
||||||
|
{
|
||||||
$noError = true;
|
$noError = true;
|
||||||
|
|
||||||
for($i=1; $i<=10; $i++) {
|
for ($i=1; $i<=10; $i++) {
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
$days = $formData['add_show_rebroadcast_date_'.$i];
|
$days = $formData['add_show_rebroadcast_date_'.$i];
|
||||||
$time = $formData['add_show_rebroadcast_time_'.$i];
|
$time = $formData['add_show_rebroadcast_time_'.$i];
|
||||||
|
|
||||||
if(trim($days) == "" && trim($time) == "") {
|
if (trim($days) == "" && trim($time) == "") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($days) == ""){
|
if (trim($days) == "") {
|
||||||
$this->getElement('add_show_rebroadcast_date_'.$i)->setErrors(array("Day must be specified"));
|
$this->getElement('add_show_rebroadcast_date_'.$i)->setErrors(array("Day must be specified"));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim($time) == "") {
|
||||||
if (trim($time) == ""){
|
|
||||||
$this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Time must be specified"));
|
$this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Time must be specified"));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($valid === false) {
|
if ($valid === false) {
|
||||||
$noError = false;
|
$noError = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +91,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
||||||
$rebroad_start = new DateTime($rebroad_start);
|
$rebroad_start = new DateTime($rebroad_start);
|
||||||
$rebroad_start->add(new DateInterval("P".$day."D"));
|
$rebroad_start->add(new DateInterval("P".$day."D"));
|
||||||
|
|
||||||
if($rebroad_start < $show_end) {
|
if ($rebroad_start < $show_end) {
|
||||||
$this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast"));
|
$this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast"));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$noError = false;
|
$noError = false;
|
||||||
|
@ -103,4 +101,3 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
||||||
return $noError;
|
return $noError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,28 +56,28 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkReliantFields($formData) {
|
public function checkReliantFields($formData)
|
||||||
|
{
|
||||||
if (!$formData['add_show_no_end']){
|
if (!$formData['add_show_no_end']) {
|
||||||
$start_timestamp = $formData['add_show_start_date'];
|
$start_timestamp = $formData['add_show_start_date'];
|
||||||
$end_timestamp = $formData['add_show_end_date'];
|
$end_timestamp = $formData['add_show_end_date'];
|
||||||
|
|
||||||
$start_epoch = strtotime($start_timestamp);
|
$start_epoch = strtotime($start_timestamp);
|
||||||
$end_epoch = strtotime($end_timestamp);
|
$end_epoch = strtotime($end_timestamp);
|
||||||
|
|
||||||
if($end_epoch < $start_epoch) {
|
if ($end_epoch < $start_epoch) {
|
||||||
$this->getElement('add_show_end_date')->setErrors(array('End date must be after start date'));
|
$this->getElement('add_show_end_date')->setErrors(array('End date must be after start date'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,4 +86,3 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
||||||
array('stringLength', false, array(6, 6))
|
array('stringLength', false, array(6, 6))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
// Add show color input
|
// Add show color input
|
||||||
$this->addElement('text', 'add_show_color', array(
|
$this->addElement('text', 'add_show_color', array(
|
||||||
'label' => 'Text Colour:',
|
'label' => 'Text Colour:',
|
||||||
|
@ -39,22 +38,20 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
||||||
'class' => 'big'
|
'class' => 'big'
|
||||||
))));
|
))));
|
||||||
|
|
||||||
$c->setValidators(array(
|
$c->setValidators(array(
|
||||||
'Hex',
|
'Hex',
|
||||||
array('stringLength', false, array(6, 6))
|
array('stringLength', false, array(6, 6))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,15 +66,13 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null) {
|
public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null)
|
||||||
|
{
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$hours;
|
$hours;
|
||||||
|
@ -96,14 +97,14 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
$nowDateTime = new DateTime();
|
$nowDateTime = new DateTime();
|
||||||
$showStartDateTime = new DateTime($start_time);
|
$showStartDateTime = new DateTime($start_time);
|
||||||
$showEndDateTime = new DateTime($end_time);
|
$showEndDateTime = new DateTime($end_time);
|
||||||
if ($validateStartDate){
|
if ($validateStartDate) {
|
||||||
if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
|
if ($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
|
||||||
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
// if edit action, check if original show start time is in the past. CC-3864
|
// if edit action, check if original show start time is in the past. CC-3864
|
||||||
if($originalStartDate){
|
if ($originalStartDate) {
|
||||||
if($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) {
|
if ($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) {
|
||||||
$this->getElement('add_show_start_time')->setValue($originalStartDate->format("H:i"));
|
$this->getElement('add_show_start_time')->setValue($originalStartDate->format("H:i"));
|
||||||
$this->getElement('add_show_start_date')->setValue($originalStartDate->format("Y-m-d"));
|
$this->getElement('add_show_start_date')->setValue($originalStartDate->format("Y-m-d"));
|
||||||
$this->getElement('add_show_start_time')->setErrors(array('Cannot modify start date/time of the show that is already started'));
|
$this->getElement('add_show_start_time')->setErrors(array('Cannot modify start date/time of the show that is already started'));
|
||||||
|
@ -114,7 +115,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
}
|
}
|
||||||
|
|
||||||
// if end time is in the past, return error
|
// if end time is in the past, return error
|
||||||
if($showEndDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
|
if ($showEndDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
|
||||||
$this->getElement('add_show_end_time')->setErrors(array('End date/time cannot be in the past'));
|
$this->getElement('add_show_end_time')->setErrors(array('End date/time cannot be in the past'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
@ -124,20 +125,19 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
if (preg_match($pattern, $formData['add_show_duration'], $matches) && count($matches) == 3) {
|
if (preg_match($pattern, $formData['add_show_duration'], $matches) && count($matches) == 3) {
|
||||||
$hours = $matches[1];
|
$hours = $matches[1];
|
||||||
$minutes = $matches[2];
|
$minutes = $matches[2];
|
||||||
if( $formData["add_show_duration"] == "00h 00m" ) {
|
if ($formData["add_show_duration"] == "00h 00m") {
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00h 00m'));
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00h 00m'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}elseif(strpos($formData["add_show_duration"], 'h') !== false && $hours >= 24) {
|
} elseif (strpos($formData["add_show_duration"], 'h') !== false && $hours >= 24) {
|
||||||
if ($hours > 24 || ($hours == 24 && $minutes > 0)) {
|
if ($hours > 24 || ($hours == 24 && $minutes > 0)) {
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h'));
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
}elseif( strstr($formData["add_show_duration"], '-') ){
|
} elseif ( strstr($formData["add_show_duration"], '-') ) {
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,11 +188,11 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
*/
|
*/
|
||||||
if (!$overlapping) {
|
if (!$overlapping) {
|
||||||
$startDow = date("w", $show_start->getTimestamp());
|
$startDow = date("w", $show_start->getTimestamp());
|
||||||
foreach($formData["add_show_day_check"] as $day) {
|
foreach ($formData["add_show_day_check"] as $day) {
|
||||||
$repeatShowStart = clone $show_start;
|
$repeatShowStart = clone $show_start;
|
||||||
$repeatShowEnd = clone $show_end;
|
$repeatShowEnd = clone $show_end;
|
||||||
$daysAdd=0;
|
$daysAdd=0;
|
||||||
if ($startDow !== $day){
|
if ($startDow !== $day) {
|
||||||
if ($startDow > $day)
|
if ($startDow > $day)
|
||||||
$daysAdd = 6 - $startDow + 1 + $day;
|
$daysAdd = 6 - $startDow + 1 + $day;
|
||||||
else
|
else
|
||||||
|
@ -263,34 +263,31 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
return $valid;
|
return $valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disableRepeatCheckbox(){
|
public function disableRepeatCheckbox()
|
||||||
|
{
|
||||||
$element = $this->getElement('add_show_repeats');
|
$element = $this->getElement('add_show_repeats');
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disableStartDateAndTime(){
|
public function disableStartDateAndTime()
|
||||||
|
{
|
||||||
$elements = array($this->getElement('add_show_start_date'), $this->getElement('add_show_start_time'));
|
$elements = array($this->getElement('add_show_start_date'), $this->getElement('add_show_start_time'));
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,15 +27,13 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
|
||||||
$this->addElement($hosts);
|
$this->addElement($hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(){
|
public function disable()
|
||||||
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib('disabled','disabled');
|
$element->setAttrib('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,14 @@ class Application_Form_AddUser extends Zend_Form
|
||||||
$this->addElement($submit);
|
$this->addElement($submit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateLogin($data){
|
public function validateLogin($data)
|
||||||
|
{
|
||||||
if (strlen($data['user_id']) == 0){
|
if (strlen($data['user_id']) == 0) {
|
||||||
$count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count();
|
$count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count();
|
||||||
|
|
||||||
if ($count != 0){
|
if ($count != 0) {
|
||||||
$this->getElement('login')->setErrors(array("Login name is not unique."));
|
$this->getElement('login')->setErrors(array("Login name is not unique."));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,4 +107,3 @@ class Application_Form_AddUser extends Zend_Form
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,4 @@ class Application_Form_EditAudioMD extends Zend_Form
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,13 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
|
||||||
'viewHelper'
|
'viewHelper'
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->addElement('checkbox', 'msRequiresAuth', array(
|
$this->addElement('checkbox', 'msRequiresAuth', array(
|
||||||
'label' => 'Requires Authentication',
|
'label' => 'Requires Authentication',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'value' => Application_Model_Preference::GetMailServerRequiresAuth(),
|
'value' => Application_Model_Preference::GetMailServerRequiresAuth(),
|
||||||
'decorators' => array(
|
'decorators' => array(
|
||||||
'viewHelper'
|
'viewHelper'
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
|
||||||
'allowEmpty' => false,
|
'allowEmpty' => false,
|
||||||
'validators' => array(
|
'validators' => array(
|
||||||
new ConditionalNotEmpty(array(
|
new ConditionalNotEmpty(array(
|
||||||
'configureMailServer' => '1'
|
'configureMailServer' => '1'
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -74,7 +74,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
|
||||||
'allowEmpty' => false,
|
'allowEmpty' => false,
|
||||||
'validators' => array(
|
'validators' => array(
|
||||||
new ConditionalNotEmpty(array(
|
new ConditionalNotEmpty(array(
|
||||||
'configureMailServer' => '1',
|
'configureMailServer' => '1',
|
||||||
'msRequiresAuth' => '1'
|
'msRequiresAuth' => '1'
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
@ -89,8 +89,8 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
|
||||||
'allowEmpty' => false,
|
'allowEmpty' => false,
|
||||||
'validators' => array(
|
'validators' => array(
|
||||||
new ConditionalNotEmpty(array(
|
new ConditionalNotEmpty(array(
|
||||||
'configureMailServer' => '1',
|
'configureMailServer' => '1',
|
||||||
'msRequiresAuth' => '1'
|
'msRequiresAuth' => '1'
|
||||||
))
|
))
|
||||||
),
|
),
|
||||||
'renderPassword' => true
|
'renderPassword' => true
|
||||||
|
@ -108,6 +108,4 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||||
));
|
));
|
||||||
|
|
||||||
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
||||||
if($defaultFade == ""){
|
if ($defaultFade == "") {
|
||||||
$defaultFade = '0.500000';
|
$defaultFade = '0.500000';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,8 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||||
$this->addElement($week_start_day);
|
$this->addElement($week_start_day);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTimezones(){
|
private function getTimezones()
|
||||||
|
{
|
||||||
$regions = array(
|
$regions = array(
|
||||||
'Africa' => DateTimeZone::AFRICA,
|
'Africa' => DateTimeZone::AFRICA,
|
||||||
'America' => DateTimeZone::AMERICA,
|
'America' => DateTimeZone::AMERICA,
|
||||||
|
@ -86,9 +87,9 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||||
|
|
||||||
$tzlist = array();
|
$tzlist = array();
|
||||||
|
|
||||||
foreach ($regions as $name => $mask){
|
foreach ($regions as $name => $mask) {
|
||||||
$ids = DateTimeZone::listIdentifiers($mask);
|
$ids = DateTimeZone::listIdentifiers($mask);
|
||||||
foreach ($ids as $id){
|
foreach ($ids as $id) {
|
||||||
$tzlist[$id] = str_replace("_", " ", $id);
|
$tzlist[$id] = str_replace("_", " ", $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,8 +97,8 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||||
return $tzlist;
|
return $tzlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getWeekStartDays()
|
||||||
private function getWeekStartDays() {
|
{
|
||||||
$days = array(
|
$days = array(
|
||||||
'Sunday',
|
'Sunday',
|
||||||
'Monday',
|
'Monday',
|
||||||
|
@ -107,7 +108,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||||
'Friday',
|
'Friday',
|
||||||
'Saturday'
|
'Saturday'
|
||||||
);
|
);
|
||||||
|
|
||||||
return $days;
|
return $days;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
|
|
||||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||||
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
||||||
if($defaultFade == ""){
|
if ($defaultFade == "") {
|
||||||
$defaultFade = '00.000000';
|
$defaultFade = '00.000000';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
$this->addElement($master_username);
|
$this->addElement($master_username);
|
||||||
|
|
||||||
//Master password
|
//Master password
|
||||||
if($isDemo){
|
if ($isDemo) {
|
||||||
$master_password = new Zend_Form_Element_Text('master_password');
|
$master_password = new Zend_Form_Element_Text('master_password');
|
||||||
}else{
|
} else {
|
||||||
$master_password = new Zend_Form_Element_Password('master_password');
|
$master_password = new Zend_Form_Element_Password('master_password');
|
||||||
$master_password->setAttrib('renderPassword','true');
|
$master_password->setAttrib('renderPassword','true');
|
||||||
}
|
}
|
||||||
|
@ -121,19 +121,18 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
$this->addElement($live_dj_mount);
|
$this->addElement($live_dj_mount);
|
||||||
}
|
}
|
||||||
// demo only code
|
// demo only code
|
||||||
if(!$isStreamConfigable){
|
if (!$isStreamConfigable) {
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element) {
|
||||||
{
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||||
if ($element->getType() != 'Zend_Form_Element_Hidden')
|
|
||||||
{
|
|
||||||
$element->setAttrib("disabled", "disabled");
|
$element->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateVariables(){
|
public function updateVariables()
|
||||||
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
||||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||||
|
@ -146,50 +145,52 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid($data){
|
public function isValid($data)
|
||||||
|
{
|
||||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||||
$isValid = parent::isValid($data);
|
$isValid = parent::isValid($data);
|
||||||
if (!$isSaas) {
|
if (!$isSaas) {
|
||||||
$master_harbor_input_port = $data['master_harbor_input_port'];
|
$master_harbor_input_port = $data['master_harbor_input_port'];
|
||||||
$dj_harbor_input_port = $data['dj_harbor_input_port'];
|
$dj_harbor_input_port = $data['dj_harbor_input_port'];
|
||||||
|
|
||||||
if($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != ""){
|
if ($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != "") {
|
||||||
$element = $this->getElement("dj_harbor_input_port");
|
$element = $this->getElement("dj_harbor_input_port");
|
||||||
$element->addError("You cannot use same port as Master DJ port.");
|
$element->addError("You cannot use same port as Master DJ port.");
|
||||||
}
|
}
|
||||||
if($master_harbor_input_port != ""){
|
if ($master_harbor_input_port != "") {
|
||||||
if(is_numeric($master_harbor_input_port)){
|
if (is_numeric($master_harbor_input_port)) {
|
||||||
if($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()){
|
if ($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()) {
|
||||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||||
$res = socket_bind($sock, 0, $master_harbor_input_port);
|
$res = socket_bind($sock, 0, $master_harbor_input_port);
|
||||||
if(!$res){
|
if (!$res) {
|
||||||
$element = $this->getElement("master_harbor_input_port");
|
$element = $this->getElement("master_harbor_input_port");
|
||||||
$element->addError("Port '$master_harbor_input_port' is not available.");
|
$element->addError("Port '$master_harbor_input_port' is not available.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
socket_close($sock);
|
socket_close($sock);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($dj_harbor_input_port != ""){
|
if ($dj_harbor_input_port != "") {
|
||||||
if(is_numeric($dj_harbor_input_port)){
|
if (is_numeric($dj_harbor_input_port)) {
|
||||||
if($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()){
|
if ($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()) {
|
||||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||||
$res = socket_bind($sock, 0, $dj_harbor_input_port);
|
$res = socket_bind($sock, 0, $dj_harbor_input_port);
|
||||||
if(!$res){
|
if (!$res) {
|
||||||
$element = $this->getElement("dj_harbor_input_port");
|
$element = $this->getElement("dj_harbor_input_port");
|
||||||
$element->addError("Port '$dj_harbor_input_port' is not available.");
|
$element->addError("Port '$dj_harbor_input_port' is not available.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
socket_close($sock);
|
socket_close($sock);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ class Application_Form_Login extends Zend_Form
|
||||||
// Set the method for the display form to POST
|
// Set the method for the display form to POST
|
||||||
$this->setMethod('post');
|
$this->setMethod('post');
|
||||||
|
|
||||||
$this->setDecorators(array(
|
$this->setDecorators(array(
|
||||||
array('ViewScript', array('viewScript' => 'form/login.phtml'))
|
array('ViewScript', array('viewScript' => 'form/login.phtml'))
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add username element
|
// Add username element
|
||||||
|
@ -45,10 +45,10 @@ class Application_Form_Login extends Zend_Form
|
||||||
));
|
));
|
||||||
|
|
||||||
$recaptchaNeeded = false;
|
$recaptchaNeeded = false;
|
||||||
if(Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3){
|
if (Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3) {
|
||||||
$recaptchaNeeded = true;
|
$recaptchaNeeded = true;
|
||||||
}
|
}
|
||||||
if($recaptchaNeeded){
|
if ($recaptchaNeeded) {
|
||||||
// recaptcha
|
// recaptcha
|
||||||
$this->addRecaptcha();
|
$this->addRecaptcha();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,8 @@ class Application_Form_Login extends Zend_Form
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRecaptcha(){
|
public function addRecaptcha()
|
||||||
|
{
|
||||||
$pubKey = '6Ld4JsISAAAAAIxUKT4IjjOGi3DHqdoH2zk6WkYG';
|
$pubKey = '6Ld4JsISAAAAAIxUKT4IjjOGi3DHqdoH2zk6WkYG';
|
||||||
$privKey = '6Ld4JsISAAAAAJynYlXdrE4hfTReTSxYFe5szdyv';
|
$privKey = '6Ld4JsISAAAAAJynYlXdrE4hfTReTSxYFe5szdyv';
|
||||||
|
|
||||||
|
@ -84,6 +85,4 @@ class Application_Form_Login extends Zend_Form
|
||||||
$this->addElement($captcha);
|
$this->addElement($captcha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ class Application_Form_PasswordChange extends Zend_Form
|
||||||
{
|
{
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setDecorators(array(
|
$this->setDecorators(array(
|
||||||
array('ViewScript', array('viewScript' => 'form/password-change.phtml'))
|
array('ViewScript', array('viewScript' => 'form/password-change.phtml'))
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->addElement('password', 'password', array(
|
$this->addElement('password', 'password', array(
|
||||||
|
|
|
@ -6,8 +6,8 @@ class Application_Form_PasswordRestore extends Zend_Form
|
||||||
{
|
{
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setDecorators(array(
|
$this->setDecorators(array(
|
||||||
array('ViewScript', array('viewScript' => 'form/password-restore.phtml'))
|
array('ViewScript', array('viewScript' => 'form/password-restore.phtml'))
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->addElement('text', 'email', array(
|
$this->addElement('text', 'email', array(
|
||||||
|
@ -20,7 +20,7 @@ class Application_Form_PasswordRestore extends Zend_Form
|
||||||
'ViewHelper'
|
'ViewHelper'
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->addElement('text', 'username', array(
|
$this->addElement('text', 'username', array(
|
||||||
'label' => 'Username',
|
'label' => 'Username',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -49,4 +49,4 @@ class Application_Form_PasswordRestore extends Zend_Form
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
$this->addElement($cancel);
|
$this->addElement($cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Application_Form_RegisterAirtime extends Zend_Form
|
||||||
$country_list = Application_Model_Preference::GetCountryList();
|
$country_list = Application_Model_Preference::GetCountryList();
|
||||||
|
|
||||||
$privacyChecked = false;
|
$privacyChecked = false;
|
||||||
if(Application_Model_Preference::GetPrivacyPolicyCheck() == 1){
|
if (Application_Model_Preference::GetPrivacyPolicyCheck() == 1) {
|
||||||
$privacyChecked = true;
|
$privacyChecked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,17 +151,17 @@ class Application_Form_RegisterAirtime extends Zend_Form
|
||||||
public function isValid ($data)
|
public function isValid ($data)
|
||||||
{
|
{
|
||||||
$isValid = parent::isValid($data);
|
$isValid = parent::isValid($data);
|
||||||
if($data['Publicise'] != 1){
|
if ($data['Publicise'] != 1) {
|
||||||
$isValid = true;
|
$isValid = true;
|
||||||
}
|
}
|
||||||
if(isset($data["Privacy"])){
|
if (isset($data["Privacy"])) {
|
||||||
$checkPrivacy = $this->getElement('Privacy');
|
$checkPrivacy = $this->getElement('Privacy');
|
||||||
if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){
|
if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") {
|
||||||
$checkPrivacy->addError("You have to agree to privacy policy.");
|
$checkPrivacy->addError("You have to agree to privacy policy.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,4 @@ class Application_Form_ScheduleShow extends Zend_Form
|
||||||
/* Form Elements & Other Definitions Here ... */
|
/* Form Elements & Other Definitions Here ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,6 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
||||||
$endTime->setAttrib('alt', 'time');
|
$endTime->setAttrib('alt', 'time');
|
||||||
$this->addElement($endTime);
|
$this->addElement($endTime);
|
||||||
|
|
||||||
|
|
||||||
// add a select to choose a show.
|
// add a select to choose a show.
|
||||||
$showSelect = new Zend_Form_Element_Select("sb_show_filter");
|
$showSelect = new Zend_Form_Element_Select("sb_show_filter");
|
||||||
$showSelect->setLabel("Show:");
|
$showSelect->setLabel("Show:");
|
||||||
|
@ -84,8 +83,8 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getShowNames() {
|
private function getShowNames()
|
||||||
|
{
|
||||||
$showNames = array("0" => "-------------------------");
|
$showNames = array("0" => "-------------------------");
|
||||||
|
|
||||||
$shows = CcShowQuery::create()
|
$shows = CcShowQuery::create()
|
||||||
|
|
|
@ -1,93 +1,93 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
{
|
{
|
||||||
private $criteriaOptions = array(
|
private $criteriaOptions = array(
|
||||||
0 => "Select criteria",
|
0 => "Select criteria",
|
||||||
"album_title" => "Album",
|
"album_title" => "Album",
|
||||||
"bit_rate" => "Bit Rate (Kbps)",
|
"bit_rate" => "Bit Rate (Kbps)",
|
||||||
"bpm" => "Bpm",
|
"bpm" => "Bpm",
|
||||||
"comments" => "Comments",
|
"comments" => "Comments",
|
||||||
"composer" => "Composer",
|
"composer" => "Composer",
|
||||||
"conductor" => "Conductor",
|
"conductor" => "Conductor",
|
||||||
"artist_name" => "Creator",
|
"artist_name" => "Creator",
|
||||||
"disc_number" => "Disc Number",
|
"disc_number" => "Disc Number",
|
||||||
"genre" => "Genre",
|
"genre" => "Genre",
|
||||||
"isrc_number" => "ISRC",
|
"isrc_number" => "ISRC",
|
||||||
"label" => "Label",
|
"label" => "Label",
|
||||||
"language" => "Language",
|
"language" => "Language",
|
||||||
"mtime" => "Last Modified",
|
"mtime" => "Last Modified",
|
||||||
"lptime" => "Last Played",
|
"lptime" => "Last Played",
|
||||||
"length" => "Length",
|
"length" => "Length",
|
||||||
"lyricist" => "Lyricist",
|
"lyricist" => "Lyricist",
|
||||||
"mood" => "Mood",
|
"mood" => "Mood",
|
||||||
"name" => "Name",
|
"name" => "Name",
|
||||||
"orchestra" => "Orchestra",
|
"orchestra" => "Orchestra",
|
||||||
"rating" => "Rating",
|
"rating" => "Rating",
|
||||||
"sample_rate" => "Sample Rate (kHz)",
|
"sample_rate" => "Sample Rate (kHz)",
|
||||||
"track_title" => "Title",
|
"track_title" => "Title",
|
||||||
"track_number" => "Track Number",
|
"track_number" => "Track Number",
|
||||||
"utime" => "Uploaded",
|
"utime" => "Uploaded",
|
||||||
"year" => "Year"
|
"year" => "Year"
|
||||||
);
|
|
||||||
|
|
||||||
private $criteriaTypes = array(
|
|
||||||
0 => "",
|
|
||||||
"album_title" => "s",
|
|
||||||
"artist_name" => "s",
|
|
||||||
"bit_rate" => "n",
|
|
||||||
"bpm" => "n",
|
|
||||||
"comments" => "s",
|
|
||||||
"composer" => "s",
|
|
||||||
"conductor" => "s",
|
|
||||||
"utime" => "n",
|
|
||||||
"mtime" => "n",
|
|
||||||
"lptime" => "n",
|
|
||||||
"disc_number" => "n",
|
|
||||||
"genre" => "s",
|
|
||||||
"isrc_number" => "s",
|
|
||||||
"label" => "s",
|
|
||||||
"language" => "s",
|
|
||||||
"length" => "n",
|
|
||||||
"lyricist" => "s",
|
|
||||||
"mood" => "s",
|
|
||||||
"name" => "s",
|
|
||||||
"orchestra" => "s",
|
|
||||||
"rating" => "n",
|
|
||||||
"sample_rate" => "n",
|
|
||||||
"track_title" => "s",
|
|
||||||
"track_number" => "n",
|
|
||||||
"year" => "n"
|
|
||||||
);
|
|
||||||
|
|
||||||
private $stringCriteriaOptions = array(
|
|
||||||
"0" => "Select modifier",
|
|
||||||
"contains" => "contains",
|
|
||||||
"does not contain" => "does not contain",
|
|
||||||
"is" => "is",
|
|
||||||
"is not" => "is not",
|
|
||||||
"starts with" => "starts with",
|
|
||||||
"ends with" => "ends with"
|
|
||||||
);
|
|
||||||
|
|
||||||
private $numericCriteriaOptions = array(
|
|
||||||
"0" => "Select modifier",
|
|
||||||
"is" => "is",
|
|
||||||
"is not" => "is not",
|
|
||||||
"is greater than" => "is greater than",
|
|
||||||
"is less than" => "is less than",
|
|
||||||
"is in the range" => "is in the range"
|
|
||||||
);
|
|
||||||
|
|
||||||
private $limitOptions = array(
|
|
||||||
"hours" => "hours",
|
|
||||||
"minutes" => "minutes",
|
|
||||||
"items" => "items"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public function init(){
|
private $criteriaTypes = array(
|
||||||
|
0 => "",
|
||||||
|
"album_title" => "s",
|
||||||
|
"artist_name" => "s",
|
||||||
|
"bit_rate" => "n",
|
||||||
|
"bpm" => "n",
|
||||||
|
"comments" => "s",
|
||||||
|
"composer" => "s",
|
||||||
|
"conductor" => "s",
|
||||||
|
"utime" => "n",
|
||||||
|
"mtime" => "n",
|
||||||
|
"lptime" => "n",
|
||||||
|
"disc_number" => "n",
|
||||||
|
"genre" => "s",
|
||||||
|
"isrc_number" => "s",
|
||||||
|
"label" => "s",
|
||||||
|
"language" => "s",
|
||||||
|
"length" => "n",
|
||||||
|
"lyricist" => "s",
|
||||||
|
"mood" => "s",
|
||||||
|
"name" => "s",
|
||||||
|
"orchestra" => "s",
|
||||||
|
"rating" => "n",
|
||||||
|
"sample_rate" => "n",
|
||||||
|
"track_title" => "s",
|
||||||
|
"track_number" => "n",
|
||||||
|
"year" => "n"
|
||||||
|
);
|
||||||
|
|
||||||
|
private $stringCriteriaOptions = array(
|
||||||
|
"0" => "Select modifier",
|
||||||
|
"contains" => "contains",
|
||||||
|
"does not contain" => "does not contain",
|
||||||
|
"is" => "is",
|
||||||
|
"is not" => "is not",
|
||||||
|
"starts with" => "starts with",
|
||||||
|
"ends with" => "ends with"
|
||||||
|
);
|
||||||
|
|
||||||
|
private $numericCriteriaOptions = array(
|
||||||
|
"0" => "Select modifier",
|
||||||
|
"is" => "is",
|
||||||
|
"is not" => "is not",
|
||||||
|
"is greater than" => "is greater than",
|
||||||
|
"is less than" => "is less than",
|
||||||
|
"is in the range" => "is in the range"
|
||||||
|
);
|
||||||
|
|
||||||
|
private $limitOptions = array(
|
||||||
|
"hours" => "hours",
|
||||||
|
"minutes" => "minutes",
|
||||||
|
"items" => "items"
|
||||||
|
);
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function startForm($p_blockId, $p_isValid = false)
|
public function startForm($p_blockId, $p_isValid = false)
|
||||||
{
|
{
|
||||||
// load type
|
// load type
|
||||||
|
@ -97,8 +97,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
} else {
|
} else {
|
||||||
$blockType = 1;
|
$blockType = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$spType = new Zend_Form_Element_Radio('sp_type');
|
$spType = new Zend_Form_Element_Radio('sp_type');
|
||||||
$spType->setLabel('Set smart block type:')
|
$spType->setLabel('Set smart block type:')
|
||||||
->setDecorators(array('viewHelper'))
|
->setDecorators(array('viewHelper'))
|
||||||
|
@ -108,7 +107,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
))
|
))
|
||||||
->setValue($blockType);
|
->setValue($blockType);
|
||||||
$this->addElement($spType);
|
$this->addElement($spType);
|
||||||
|
|
||||||
$bl = new Application_Model_Block($p_blockId);
|
$bl = new Application_Model_Block($p_blockId);
|
||||||
$storedCrit = $bl->getCriteria();
|
$storedCrit = $bl->getCriteria();
|
||||||
|
|
||||||
|
@ -117,12 +116,12 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
* We need to know this so we display the form elements properly
|
* We need to know this so we display the form elements properly
|
||||||
*/
|
*/
|
||||||
$modRowMap = array();
|
$modRowMap = array();
|
||||||
|
|
||||||
$openSmartBlockOption = false;
|
$openSmartBlockOption = false;
|
||||||
if (!empty($storedCrit)) {
|
if (!empty($storedCrit)) {
|
||||||
$openSmartBlockOption = true;
|
$openSmartBlockOption = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$criteriaKeys = array();
|
$criteriaKeys = array();
|
||||||
if (isset($storedCrit["crit"])) {
|
if (isset($storedCrit["crit"])) {
|
||||||
$criteriaKeys = array_keys($storedCrit["crit"]);
|
$criteriaKeys = array_keys($storedCrit["crit"]);
|
||||||
|
@ -130,15 +129,15 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$numElements = count($this->criteriaOptions);
|
$numElements = count($this->criteriaOptions);
|
||||||
for ($i = 0; $i < $numElements; $i++) {
|
for ($i = 0; $i < $numElements; $i++) {
|
||||||
$criteriaType = "";
|
$criteriaType = "";
|
||||||
|
|
||||||
if (isset($criteriaKeys[$i])) {
|
if (isset($criteriaKeys[$i])) {
|
||||||
$critCount = count($storedCrit["crit"][$criteriaKeys[$i]]);
|
$critCount = count($storedCrit["crit"][$criteriaKeys[$i]]);
|
||||||
} else {
|
} else {
|
||||||
$critCount = 1;
|
$critCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$modRowMap[$i] = $critCount;
|
$modRowMap[$i] = $critCount;
|
||||||
|
|
||||||
/* Loop through all criteria with the same field
|
/* Loop through all criteria with the same field
|
||||||
* Ex: all criteria for 'Album'
|
* Ex: all criteria for 'Album'
|
||||||
*/
|
*/
|
||||||
|
@ -149,7 +148,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
} else {
|
} else {
|
||||||
$invisible = '';
|
$invisible = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j);
|
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j);
|
||||||
$criteria->setAttrib('class', 'input_select sp_input_select'.$invisible)
|
$criteria->setAttrib('class', 'input_select sp_input_select'.$invisible)
|
||||||
->setValue('Select criteria')
|
->setValue('Select criteria')
|
||||||
|
@ -158,13 +157,13 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||||
$criteria->setAttrib('disabled', 'disabled');
|
$criteria->setAttrib('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($criteriaKeys[$i])) {
|
if (isset($criteriaKeys[$i])) {
|
||||||
$criteriaType = $this->criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]];
|
$criteriaType = $this->criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]];
|
||||||
$criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
|
$criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
|
||||||
}
|
}
|
||||||
$this->addElement($criteria);
|
$this->addElement($criteria);
|
||||||
|
|
||||||
/****************** MODIFIER ***********/
|
/****************** MODIFIER ***********/
|
||||||
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j);
|
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j);
|
||||||
$criteriaModifers->setValue('Select modifier')
|
$criteriaModifers->setValue('Select modifier')
|
||||||
|
@ -174,29 +173,29 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$criteriaModifers->setAttrib('disabled', 'disabled');
|
$criteriaModifers->setAttrib('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
if (isset($criteriaKeys[$i])) {
|
if (isset($criteriaKeys[$i])) {
|
||||||
if($criteriaType == "s"){
|
if ($criteriaType == "s") {
|
||||||
$criteriaModifers->setMultiOptions($this->stringCriteriaOptions);
|
$criteriaModifers->setMultiOptions($this->stringCriteriaOptions);
|
||||||
}else{
|
} else {
|
||||||
$criteriaModifers->setMultiOptions($this->numericCriteriaOptions);
|
$criteriaModifers->setMultiOptions($this->numericCriteriaOptions);
|
||||||
}
|
}
|
||||||
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
|
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
|
||||||
}else{
|
} else {
|
||||||
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
||||||
}
|
}
|
||||||
$this->addElement($criteriaModifers);
|
$this->addElement($criteriaModifers);
|
||||||
|
|
||||||
/****************** VALUE ***********/
|
/****************** VALUE ***********/
|
||||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j);
|
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j);
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
||||||
->setDecorators(array('viewHelper'));
|
->setDecorators(array('viewHelper'));
|
||||||
if ($i != 0 && !isset($criteriaKeys[$i])){
|
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
if (isset($criteriaKeys[$i])) {
|
if (isset($criteriaKeys[$i])) {
|
||||||
$criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
$criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
||||||
}
|
}
|
||||||
$this->addElement($criteriaValue);
|
$this->addElement($criteriaValue);
|
||||||
|
|
||||||
/****************** EXTRA ***********/
|
/****************** EXTRA ***********/
|
||||||
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j);
|
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j);
|
||||||
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
||||||
|
@ -204,15 +203,15 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
|
if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
|
||||||
$criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
|
$criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
||||||
}else{
|
} else {
|
||||||
$criteriaExtra->setAttrib('disabled', 'disabled');
|
$criteriaExtra->setAttrib('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
$this->addElement($criteriaExtra);
|
$this->addElement($criteriaExtra);
|
||||||
|
|
||||||
}//for
|
}//for
|
||||||
|
|
||||||
}//for
|
}//for
|
||||||
|
|
||||||
$limit = new Zend_Form_Element_Select('sp_limit_options');
|
$limit = new Zend_Form_Element_Select('sp_limit_options');
|
||||||
$limit->setAttrib('class', 'sp_input_select')
|
$limit->setAttrib('class', 'sp_input_select')
|
||||||
->setDecorators(array('viewHelper'))
|
->setDecorators(array('viewHelper'))
|
||||||
|
@ -221,7 +220,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$limit->setValue($storedCrit["limit"]["modifier"]);
|
$limit->setValue($storedCrit["limit"]["modifier"]);
|
||||||
}
|
}
|
||||||
$this->addElement($limit);
|
$this->addElement($limit);
|
||||||
|
|
||||||
$limitValue = new Zend_Form_Element_Text('sp_limit_value');
|
$limitValue = new Zend_Form_Element_Text('sp_limit_value');
|
||||||
$limitValue->setAttrib('class', 'sp_input_text_limit')
|
$limitValue->setAttrib('class', 'sp_input_text_limit')
|
||||||
->setLabel('Limit to')
|
->setLabel('Limit to')
|
||||||
|
@ -233,7 +232,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
// setting default to 1 hour
|
// setting default to 1 hour
|
||||||
$limitValue->setValue(1);
|
$limitValue->setValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//getting block content candidate count that meets criteria
|
//getting block content candidate count that meets criteria
|
||||||
$bl = new Application_Model_Block($p_blockId);
|
$bl = new Application_Model_Block($p_blockId);
|
||||||
if ($p_isValid) {
|
if ($p_isValid) {
|
||||||
|
@ -243,7 +242,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$files = null;
|
$files = null;
|
||||||
$showPoolCount = false;
|
$showPoolCount = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$generate = new Zend_Form_Element_Button('generate_button');
|
$generate = new Zend_Form_Element_Button('generate_button');
|
||||||
$generate->setAttrib('class', 'ui-button ui-state-default sp-button');
|
$generate->setAttrib('class', 'ui-button ui-state-default sp-button');
|
||||||
$generate->setAttrib('title', 'Generate playlist content and save criteria');
|
$generate->setAttrib('title', 'Generate playlist content and save criteria');
|
||||||
|
@ -251,7 +250,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$generate->setLabel('Generate');
|
$generate->setLabel('Generate');
|
||||||
$generate->setDecorators(array('viewHelper'));
|
$generate->setDecorators(array('viewHelper'));
|
||||||
$this->addElement($generate);
|
$this->addElement($generate);
|
||||||
|
|
||||||
$shuffle = new Zend_Form_Element_Button('shuffle_button');
|
$shuffle = new Zend_Form_Element_Button('shuffle_button');
|
||||||
$shuffle->setAttrib('class', 'ui-button ui-state-default sp-button');
|
$shuffle->setAttrib('class', 'ui-button ui-state-default sp-button');
|
||||||
$shuffle->setAttrib('title', 'Shuffle playlist content');
|
$shuffle->setAttrib('title', 'Shuffle playlist content');
|
||||||
|
@ -266,143 +265,146 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
'showPoolCount' => $showPoolCount))
|
'showPoolCount' => $showPoolCount))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function preValidation($params) {
|
public function preValidation($params)
|
||||||
|
{
|
||||||
$data = Application_Model_Block::organizeSmartPlyalistCriteria($params['data']);
|
$data = Application_Model_Block::organizeSmartPlyalistCriteria($params['data']);
|
||||||
// add elelments that needs to be added
|
// add elelments that needs to be added
|
||||||
// set multioption for modifier according to creiteria_field
|
// set multioption for modifier according to creiteria_field
|
||||||
$modRowMap = array();
|
$modRowMap = array();
|
||||||
foreach ($data['criteria'] as $critKey=>$d) {
|
foreach ($data['criteria'] as $critKey=>$d) {
|
||||||
$count = 1;
|
$count = 1;
|
||||||
foreach($d as $modKey=>$modInfo) {
|
foreach ($d as $modKey=>$modInfo) {
|
||||||
if ($modKey == 0) {
|
if ($modKey == 0) {
|
||||||
$eleCrit = $this->getElement("sp_criteria_field_".$critKey."_".$modKey);
|
$eleCrit = $this->getElement("sp_criteria_field_".$critKey."_".$modKey);
|
||||||
$eleCrit->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]);
|
$eleCrit->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]);
|
||||||
$eleCrit->setAttrib("disabled", null);
|
$eleCrit->setAttrib("disabled", null);
|
||||||
|
|
||||||
$eleMod = $this->getElement("sp_criteria_modifier_".$critKey."_".$modKey);
|
$eleMod = $this->getElement("sp_criteria_modifier_".$critKey."_".$modKey);
|
||||||
$criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']];
|
$criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']];
|
||||||
if ($criteriaType == "s") {
|
if ($criteriaType == "s") {
|
||||||
$eleMod->setMultiOptions($this->stringCriteriaOptions);
|
$eleMod->setMultiOptions($this->stringCriteriaOptions);
|
||||||
} else if ($criteriaType == "n") {
|
} elseif ($criteriaType == "n") {
|
||||||
$eleMod->setMultiOptions($this->numericCriteriaOptions);
|
$eleMod->setMultiOptions($this->numericCriteriaOptions);
|
||||||
} else {
|
} else {
|
||||||
$eleMod->setMultiOptions(array('0' => 'Select modifier'));
|
$eleMod->setMultiOptions(array('0' => 'Select modifier'));
|
||||||
}
|
}
|
||||||
$eleMod->setValue($modInfo['sp_criteria_modifier']);
|
$eleMod->setValue($modInfo['sp_criteria_modifier']);
|
||||||
$eleMod->setAttrib("disabled", null);
|
$eleMod->setAttrib("disabled", null);
|
||||||
|
|
||||||
$eleValue = $this->getElement("sp_criteria_value_".$critKey."_".$modKey);
|
$eleValue = $this->getElement("sp_criteria_value_".$critKey."_".$modKey);
|
||||||
$eleValue->setValue($modInfo['sp_criteria_value']);
|
$eleValue->setValue($modInfo['sp_criteria_value']);
|
||||||
$eleValue->setAttrib("disabled", null);
|
$eleValue->setAttrib("disabled", null);
|
||||||
|
|
||||||
if (isset($modInfo['sp_criteria_extra'])) {
|
if (isset($modInfo['sp_criteria_extra'])) {
|
||||||
$eleExtra = $this->getElement("sp_criteria_extra_".$critKey."_".$modKey);
|
$eleExtra = $this->getElement("sp_criteria_extra_".$critKey."_".$modKey);
|
||||||
$eleExtra->setValue($modInfo['sp_criteria_extra']);
|
$eleExtra->setValue($modInfo['sp_criteria_extra']);
|
||||||
$eleValue->setAttrib('class', 'input_text sp_extra_input_text');
|
$eleValue->setAttrib('class', 'input_text sp_extra_input_text');
|
||||||
$eleExtra->setAttrib("disabled", null);
|
$eleExtra->setAttrib("disabled", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$critKey."_".$modKey);
|
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$critKey."_".$modKey);
|
||||||
$criteria->setAttrib('class', 'input_select sp_input_select sp-invisible')
|
$criteria->setAttrib('class', 'input_select sp_input_select sp-invisible')
|
||||||
->setValue('Select criteria')
|
->setValue('Select criteria')
|
||||||
->setDecorators(array('viewHelper'))
|
->setDecorators(array('viewHelper'))
|
||||||
->setMultiOptions($this->criteriaOptions);
|
->setMultiOptions($this->criteriaOptions);
|
||||||
|
|
||||||
$criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']];
|
$criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']];
|
||||||
$criteria->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]);
|
$criteria->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]);
|
||||||
$this->addElement($criteria);
|
$this->addElement($criteria);
|
||||||
|
|
||||||
/****************** MODIFIER ***********/
|
/****************** MODIFIER ***********/
|
||||||
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$critKey."_".$modKey);
|
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$critKey."_".$modKey);
|
||||||
$criteriaModifers->setValue('Select modifier')
|
$criteriaModifers->setValue('Select modifier')
|
||||||
->setAttrib('class', 'input_select sp_input_select')
|
->setAttrib('class', 'input_select sp_input_select')
|
||||||
->setDecorators(array('viewHelper'));
|
->setDecorators(array('viewHelper'));
|
||||||
|
|
||||||
if ($criteriaType == "s") {
|
if ($criteriaType == "s") {
|
||||||
$criteriaModifers->setMultiOptions($this->stringCriteriaOptions);
|
$criteriaModifers->setMultiOptions($this->stringCriteriaOptions);
|
||||||
} else if ($criteriaType == "n") {
|
} elseif ($criteriaType == "n") {
|
||||||
$criteriaModifers->setMultiOptions($this->numericCriteriaOptions);
|
$criteriaModifers->setMultiOptions($this->numericCriteriaOptions);
|
||||||
} else {
|
} else {
|
||||||
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
||||||
|
}
|
||||||
|
$criteriaModifers->setValue($modInfo['sp_criteria_modifier']);
|
||||||
|
$this->addElement($criteriaModifers);
|
||||||
|
|
||||||
|
/****************** VALUE ***********/
|
||||||
|
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$critKey."_".$modKey);
|
||||||
|
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
||||||
|
->setDecorators(array('viewHelper'));
|
||||||
|
$criteriaValue->setValue($modInfo['sp_criteria_value']);
|
||||||
|
$this->addElement($criteriaValue);
|
||||||
|
|
||||||
|
/****************** EXTRA ***********/
|
||||||
|
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$critKey."_".$modKey);
|
||||||
|
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
||||||
|
->setDecorators(array('viewHelper'));
|
||||||
|
if (isset($modInfo['sp_criteria_extra'])) {
|
||||||
|
$criteriaExtra->setValue($modInfo['sp_criteria_extra']);
|
||||||
|
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
||||||
|
} else {
|
||||||
|
$criteriaExtra->setAttrib('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
$criteriaModifers->setValue($modInfo['sp_criteria_modifier']);
|
|
||||||
$this->addElement($criteriaModifers);
|
|
||||||
|
|
||||||
/****************** VALUE ***********/
|
|
||||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$critKey."_".$modKey);
|
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
$criteriaValue->setValue($modInfo['sp_criteria_value']);
|
|
||||||
$this->addElement($criteriaValue);
|
|
||||||
|
|
||||||
/****************** EXTRA ***********/
|
|
||||||
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$critKey."_".$modKey);
|
|
||||||
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
if (isset($modInfo['sp_criteria_extra'])) {
|
|
||||||
$criteriaExtra->setValue($modInfo['sp_criteria_extra']);
|
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
|
||||||
}else{
|
|
||||||
$criteriaExtra->setAttrib('disabled', 'disabled');
|
|
||||||
}
|
|
||||||
$this->addElement($criteriaExtra);
|
$this->addElement($criteriaExtra);
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$modRowMap[$critKey] = $count;
|
$modRowMap[$critKey] = $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
$decorator = $this->getDecorator("ViewScript");
|
$decorator = $this->getDecorator("ViewScript");
|
||||||
$existingModRow = $decorator->getOption("modRowMap");
|
$existingModRow = $decorator->getOption("modRowMap");
|
||||||
foreach ($modRowMap as $key=>$v) {
|
foreach ($modRowMap as $key=>$v) {
|
||||||
$existingModRow[$key] = $v;
|
$existingModRow[$key] = $v;
|
||||||
}
|
}
|
||||||
$decorator->setOption("modRowMap", $existingModRow);
|
$decorator->setOption("modRowMap", $existingModRow);
|
||||||
|
|
||||||
// reconstruct the params['criteria'] so we can populate the form
|
// reconstruct the params['criteria'] so we can populate the form
|
||||||
$formData = array();
|
$formData = array();
|
||||||
foreach ($params['data'] as $ele) {
|
foreach ($params['data'] as $ele) {
|
||||||
$formData[$ele['name']] = $ele['value'];
|
$formData[$ele['name']] = $ele['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->populate($formData);
|
$this->populate($formData);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValid($params){
|
public function isValid($params)
|
||||||
|
{
|
||||||
$isValid = true;
|
$isValid = true;
|
||||||
$data = $this->preValidation($params);
|
$data = $this->preValidation($params);
|
||||||
$criteria2PeerMap = array(
|
$criteria2PeerMap = array(
|
||||||
0 => "Select criteria",
|
0 => "Select criteria",
|
||||||
"album_title" => "DbAlbumTitle",
|
"album_title" => "DbAlbumTitle",
|
||||||
"artist_name" => "DbArtistName",
|
"artist_name" => "DbArtistName",
|
||||||
"bit_rate" => "DbBitRate",
|
"bit_rate" => "DbBitRate",
|
||||||
"bpm" => "DbBpm",
|
"bpm" => "DbBpm",
|
||||||
"comments" => "DbComments",
|
"comments" => "DbComments",
|
||||||
"composer" => "DbComposer",
|
"composer" => "DbComposer",
|
||||||
"conductor" => "DbConductor",
|
"conductor" => "DbConductor",
|
||||||
"utime" => "DbUtime",
|
"utime" => "DbUtime",
|
||||||
"mtime" => "DbMtime",
|
"mtime" => "DbMtime",
|
||||||
"lptime" => "DbLPtime",
|
"lptime" => "DbLPtime",
|
||||||
"disc_number" => "DbDiscNumber",
|
"disc_number" => "DbDiscNumber",
|
||||||
"genre" => "DbGenre",
|
"genre" => "DbGenre",
|
||||||
"isrc_number" => "DbIsrcNumber",
|
"isrc_number" => "DbIsrcNumber",
|
||||||
"label" => "DbLabel",
|
"label" => "DbLabel",
|
||||||
"language" => "DbLanguage",
|
"language" => "DbLanguage",
|
||||||
"length" => "DbLength",
|
"length" => "DbLength",
|
||||||
"lyricist" => "DbLyricist",
|
"lyricist" => "DbLyricist",
|
||||||
"mood" => "DbMood",
|
"mood" => "DbMood",
|
||||||
"name" => "DbName",
|
"name" => "DbName",
|
||||||
"orchestra" => "DbOrchestra",
|
"orchestra" => "DbOrchestra",
|
||||||
"rating" => "DbRating",
|
"rating" => "DbRating",
|
||||||
"sample_rate" => "DbSampleRate",
|
"sample_rate" => "DbSampleRate",
|
||||||
"track_title" => "DbTrackTitle",
|
"track_title" => "DbTrackTitle",
|
||||||
"track_number" => "DbTrackNumber",
|
"track_number" => "DbTrackNumber",
|
||||||
"year" => "DbYear"
|
"year" => "DbYear"
|
||||||
);
|
);
|
||||||
|
|
||||||
// things we need to check
|
// things we need to check
|
||||||
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
|
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
|
||||||
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
|
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
|
||||||
|
@ -411,107 +413,108 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$error = array();
|
$error = array();
|
||||||
|
|
||||||
// validation start
|
// validation start
|
||||||
if ($data['etc']['sp_limit_options'] == 'hours') {
|
if ($data['etc']['sp_limit_options'] == 'hours') {
|
||||||
$multiplier = 60;
|
$multiplier = 60;
|
||||||
}
|
}
|
||||||
if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') {
|
if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') {
|
||||||
$element = $this->getElement("sp_limit_value");
|
$element = $this->getElement("sp_limit_value");
|
||||||
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
||||||
$element->addError("Limit cannot be empty or smaller than 0");
|
$element->addError("Limit cannot be empty or smaller than 0");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
} else {
|
} else {
|
||||||
$mins = floatval($data['etc']['sp_limit_value']) * $multiplier;
|
$mins = floatval($data['etc']['sp_limit_value']) * $multiplier;
|
||||||
if ($mins > 1440) {
|
if ($mins > 1440) {
|
||||||
$element->addError("Limit cannot be more than 24 hrs");
|
$element->addError("Limit cannot be more than 24 hrs");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$element = $this->getElement("sp_limit_value");
|
$element = $this->getElement("sp_limit_value");
|
||||||
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) {
|
||||||
$element->addError("Limit cannot be empty or smaller than 0");
|
$element->addError("Limit cannot be empty or smaller than 0");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
} else if (!ctype_digit($data['etc']['sp_limit_value'])) {
|
} elseif (!ctype_digit($data['etc']['sp_limit_value'])) {
|
||||||
$element->addError("The value should be an integer");
|
$element->addError("The value should be an integer");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
} else if (intval($data['etc']['sp_limit_value']) > 500) {
|
} elseif (intval($data['etc']['sp_limit_value']) > 500) {
|
||||||
$element->addError("500 is the max item limit value you can set");
|
$element->addError("500 is the max item limit value you can set");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$criteriaFieldsUsed = array();
|
$criteriaFieldsUsed = array();
|
||||||
|
|
||||||
if (isset($data['criteria'])) {
|
if (isset($data['criteria'])) {
|
||||||
foreach ($data['criteria'] as $rowKey=>$row) {
|
foreach ($data['criteria'] as $rowKey=>$row) {
|
||||||
foreach ($row as $key=>$d){
|
foreach ($row as $key=>$d) {
|
||||||
$element = $this->getElement("sp_criteria_field_".$rowKey."_".$key);
|
$element = $this->getElement("sp_criteria_field_".$rowKey."_".$key);
|
||||||
$error = array();
|
$error = array();
|
||||||
// check for not selected select box
|
// check for not selected select box
|
||||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0") {
|
||||||
$element->addError("You must select Criteria and Modifier");
|
$element->addError("You must select Criteria and Modifier");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
} else {
|
} else {
|
||||||
$column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]);
|
$column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]);
|
||||||
// validation on type of column
|
// validation on type of column
|
||||||
if ($d['sp_criteria_field'] == 'length') {
|
if ($d['sp_criteria_field'] == 'length') {
|
||||||
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
|
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
|
||||||
$element->addError("'Length' should be in '00:00:00' format");
|
$element->addError("'Length' should be in '00:00:00' format");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
} elseif ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
|
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
|
||||||
$element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00");
|
$element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
} else {
|
} else {
|
||||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
|
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
|
||||||
if (!$result["success"]) {
|
if (!$result["success"]) {
|
||||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||||
$element->addError($result["errMsg"]);
|
$element->addError($result["errMsg"]);
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($d['sp_criteria_extra'])) {
|
if (isset($d['sp_criteria_extra'])) {
|
||||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
|
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
|
||||||
$element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00");
|
$element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
} else {
|
} else {
|
||||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
|
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
|
||||||
if (!$result["success"]) {
|
if (!$result["success"]) {
|
||||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||||
$element->addError($result["errMsg"]);
|
$element->addError($result["errMsg"]);
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
|
} elseif ($column->getType() == PropelColumnTypes::INTEGER) {
|
||||||
if (!is_numeric($d['sp_criteria_value'])) {
|
if (!is_numeric($d['sp_criteria_value'])) {
|
||||||
$element->addError("The value has to be numeric");
|
$element->addError("The value has to be numeric");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
// length check
|
// length check
|
||||||
if (intval($d['sp_criteria_value']) >= pow(2,31)) {
|
if (intval($d['sp_criteria_value']) >= pow(2,31)) {
|
||||||
$element->addError("The value should be less then 2147483648");
|
$element->addError("The value should be less then 2147483648");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
} else if ($column->getType() == PropelColumnTypes::VARCHAR) {
|
} elseif ($column->getType() == PropelColumnTypes::VARCHAR) {
|
||||||
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
|
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
|
||||||
$element->addError("The value should be less ".$column->getSize()." characters");
|
$element->addError("The value should be less ".$column->getSize()." characters");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($d['sp_criteria_value'] == "") {
|
if ($d['sp_criteria_value'] == "") {
|
||||||
$element->addError("Value cannot be empty");
|
$element->addError("Value cannot be empty");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}//end foreach
|
}//end foreach
|
||||||
}//for loop
|
}//for loop
|
||||||
}//if
|
}//if
|
||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,4 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
|
||||||
$this->addElement($select);
|
$this->addElement($select);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,21 @@ class Application_Form_StreamSetting extends Zend_Form
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSetting($setting){
|
public function setSetting($setting)
|
||||||
|
{
|
||||||
$this->setting = $setting;
|
$this->setting = $setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function startFrom() {
|
public function startFrom()
|
||||||
|
{
|
||||||
$setting = $this->setting;
|
$setting = $this->setting;
|
||||||
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
|
if (Application_Model_Preference::GetPlanLevel() == 'disabled') {
|
||||||
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
|
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
|
||||||
$output_sound_device->setLabel('Hardware Audio Output')
|
$output_sound_device->setLabel('Hardware Audio Output')
|
||||||
->setRequired(false)
|
->setRequired(false)
|
||||||
->setValue(($setting['output_sound_device'] == "true")?1:0)
|
->setValue(($setting['output_sound_device'] == "true")?1:0)
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if (Application_Model_Preference::GetEnableStreamConf() == "false"){
|
if (Application_Model_Preference::GetEnableStreamConf() == "false") {
|
||||||
$output_sound_device->setAttrib("readonly", true);
|
$output_sound_device->setAttrib("readonly", true);
|
||||||
}
|
}
|
||||||
$this->addElement($output_sound_device);
|
$this->addElement($output_sound_device);
|
||||||
|
@ -32,7 +34,7 @@ class Application_Form_StreamSetting extends Zend_Form
|
||||||
->setMultiOptions($output_types)
|
->setMultiOptions($output_types)
|
||||||
->setValue($setting['output_sound_device_type'])
|
->setValue($setting['output_sound_device_type'])
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($setting['output_sound_device'] != "true"){
|
if ($setting['output_sound_device'] != "true") {
|
||||||
$output_type->setAttrib("disabled", "disabled");
|
$output_type->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($output_type);
|
$this->addElement($output_type);
|
||||||
|
@ -43,7 +45,7 @@ class Application_Form_StreamSetting extends Zend_Form
|
||||||
->setRequired(false)
|
->setRequired(false)
|
||||||
->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0)
|
->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0)
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if (Application_Model_Preference::GetEnableStreamConf() == "false"){
|
if (Application_Model_Preference::GetEnableStreamConf() == "false") {
|
||||||
$icecast_vorbis_metadata->setAttrib("readonly", true);
|
$icecast_vorbis_metadata->setAttrib("readonly", true);
|
||||||
}
|
}
|
||||||
$this->addElement($icecast_vorbis_metadata);
|
$this->addElement($icecast_vorbis_metadata);
|
||||||
|
@ -58,18 +60,20 @@ class Application_Form_StreamSetting extends Zend_Form
|
||||||
$this->addElement($stream_format);
|
$this->addElement($stream_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid($data){
|
public function isValid($data)
|
||||||
if(isset($data['output_sound_device'])){
|
{
|
||||||
|
if (isset($data['output_sound_device'])) {
|
||||||
$d = array();
|
$d = array();
|
||||||
$d["output_sound_device"] = $data['output_sound_device'];
|
$d["output_sound_device"] = $data['output_sound_device'];
|
||||||
$d["icecast_vorbis_metadata"] = $data['icecast_vorbis_metadata'];
|
$d["icecast_vorbis_metadata"] = $data['icecast_vorbis_metadata'];
|
||||||
if(isset($data['output_sound_device_type'])){
|
if (isset($data['output_sound_device_type'])) {
|
||||||
$d["output_sound_device_type"] = $data['output_sound_device_type'];
|
$d["output_sound_device_type"] = $data['output_sound_device_type'];
|
||||||
}
|
}
|
||||||
$d["streamFormat"] = $data['streamFormat'];
|
$d["streamFormat"] = $data['streamFormat'];
|
||||||
$this->populate($d);
|
$this->populate($d);
|
||||||
}
|
}
|
||||||
$isValid = parent::isValid($data);
|
$isValid = parent::isValid($data);
|
||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
||||||
|
{
|
||||||
private $prefix;
|
private $prefix;
|
||||||
private $setting;
|
private $setting;
|
||||||
private $stream_types;
|
private $stream_types;
|
||||||
|
@ -10,23 +11,28 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPrefix($prefix){
|
public function setPrefix($prefix)
|
||||||
|
{
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSetting($setting){
|
public function setSetting($setting)
|
||||||
|
{
|
||||||
$this->setting = $setting;
|
$this->setting = $setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStreamTypes($stream_types){
|
public function setStreamTypes($stream_types)
|
||||||
|
{
|
||||||
$this->stream_types = $stream_types;
|
$this->stream_types = $stream_types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStreamBitrates($stream_bitrates){
|
public function setStreamBitrates($stream_bitrates)
|
||||||
|
{
|
||||||
$this->stream_bitrates = $stream_bitrates;
|
$this->stream_bitrates = $stream_bitrates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function startForm(){
|
public function startForm()
|
||||||
|
{
|
||||||
$prefix = "s".$this->prefix;
|
$prefix = "s".$this->prefix;
|
||||||
$stream_number = $this->prefix;
|
$stream_number = $this->prefix;
|
||||||
$setting = $this->setting;
|
$setting = $this->setting;
|
||||||
|
@ -36,16 +42,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
$this->setIsArray(true);
|
$this->setIsArray(true);
|
||||||
$this->setElementsBelongTo($prefix."_data");
|
$this->setElementsBelongTo($prefix."_data");
|
||||||
|
|
||||||
$disable_all = false;
|
$disable_all = Application_Model_Preference::GetEnableStreamConf() == "false";
|
||||||
if(Application_Model_Preference::GetEnableStreamConf() == "false"){
|
|
||||||
$disable_all = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$enable = new Zend_Form_Element_Checkbox('enable');
|
$enable = new Zend_Form_Element_Checkbox('enable');
|
||||||
$enable->setLabel('Enabled:')
|
$enable->setLabel('Enabled:')
|
||||||
->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0)
|
->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0)
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$enable->setAttrib("disabled", "disabled");
|
$enable->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($enable);
|
$this->addElement($enable);
|
||||||
|
@ -55,7 +58,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setMultiOptions($stream_types)
|
->setMultiOptions($stream_types)
|
||||||
->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0)
|
->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0)
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$type->setAttrib("disabled", "disabled");
|
$type->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($type);
|
$this->addElement($type);
|
||||||
|
@ -65,7 +68,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setMultiOptions($stream_bitrates)
|
->setMultiOptions($stream_bitrates)
|
||||||
->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0)
|
->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0)
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$bitrate->setAttrib("disabled", "disabled");
|
$bitrate->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($bitrate);
|
$this->addElement($bitrate);
|
||||||
|
@ -75,7 +78,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast"))
|
->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast"))
|
||||||
->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast")
|
->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast")
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$output->setAttrib("disabled", "disabled");
|
$output->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($output);
|
$this->addElement($output);
|
||||||
|
@ -86,7 +89,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => 'Invalid character entered'))))
|
array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$host->setAttrib("disabled", "disabled");
|
$host->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$host->setAttrib('alt', 'domain');
|
$host->setAttrib('alt', 'domain');
|
||||||
|
@ -98,7 +101,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
||||||
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$port->setAttrib("disabled", "disabled");
|
$port->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($port);
|
$this->addElement($port);
|
||||||
|
@ -109,7 +112,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$pass->setAttrib("disabled", "disabled");
|
$pass->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$pass->setAttrib('alt', 'regular_text');
|
$pass->setAttrib('alt', 'regular_text');
|
||||||
|
@ -119,7 +122,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
$genre->setLabel("Genre")
|
$genre->setLabel("Genre")
|
||||||
->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"")
|
->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"")
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$genre->setAttrib("disabled", "disabled");
|
$genre->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($genre);
|
$this->addElement($genre);
|
||||||
|
@ -130,7 +133,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => 'Invalid character entered'))))
|
array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$url->setAttrib("disabled", "disabled");
|
$url->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$url->setAttrib('alt', 'url');
|
$url->setAttrib('alt', 'url');
|
||||||
|
@ -140,7 +143,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
$name->setLabel("Name")
|
$name->setLabel("Name")
|
||||||
->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"")
|
->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"")
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$name->setAttrib("disabled", "disabled");
|
$name->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($name);
|
$this->addElement($name);
|
||||||
|
@ -149,7 +152,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
$description->setLabel("Description")
|
$description->setLabel("Description")
|
||||||
->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"")
|
->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"")
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$description->setAttrib("disabled", "disabled");
|
$description->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($description);
|
$this->addElement($description);
|
||||||
|
@ -160,7 +163,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$mount->setAttrib("disabled", "disabled");
|
$mount->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$mount->setAttrib('alt', 'regular_text');
|
$mount->setAttrib('alt', 'regular_text');
|
||||||
|
@ -172,7 +175,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
if($disable_all){
|
if ($disable_all) {
|
||||||
$user->setAttrib("disabled", "disabled");
|
$user->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$user->setAttrib('alt', 'regular_text');
|
$user->setAttrib('alt', 'regular_text');
|
||||||
|
@ -185,28 +188,30 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid ($data){
|
public function isValid ($data)
|
||||||
|
{
|
||||||
$f_data = $data['s'.$this->prefix."_data"];
|
$f_data = $data['s'.$this->prefix."_data"];
|
||||||
$isValid = parent::isValid($f_data);
|
$isValid = parent::isValid($f_data);
|
||||||
if($f_data['enable'] == 1){
|
if ($f_data['enable'] == 1) {
|
||||||
if($f_data['host'] == ''){
|
if ($f_data['host'] == '') {
|
||||||
$element = $this->getElement("host");
|
$element = $this->getElement("host");
|
||||||
$element->addError("Server cannot be empty.");
|
$element->addError("Server cannot be empty.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
if($f_data['port'] == ''){
|
if ($f_data['port'] == '') {
|
||||||
$element = $this->getElement("port");
|
$element = $this->getElement("port");
|
||||||
$element->addError("Port cannot be empty.");
|
$element->addError("Port cannot be empty.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
if($f_data['output'] == 'icecast'){
|
if ($f_data['output'] == 'icecast') {
|
||||||
if($f_data['mount'] == ''){
|
if ($f_data['mount'] == '') {
|
||||||
$element = $this->getElement("mount");
|
$element = $this->getElement("mount");
|
||||||
$element->addError("Mount cannot be empty with Icecast server.");
|
$element->addError("Mount cannot be empty with Icecast server.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ class Application_Form_SupportSettings extends Zend_Form
|
||||||
$upload->setAttrib('accept', 'image/*');
|
$upload->setAttrib('accept', 'image/*');
|
||||||
$this->addElement($upload);
|
$this->addElement($upload);
|
||||||
|
|
||||||
if(!$isSass){
|
if (!$isSass) {
|
||||||
//enable support feedback
|
//enable support feedback
|
||||||
$this->addElement('checkbox', 'SupportFeedback', array(
|
$this->addElement('checkbox', 'SupportFeedback', array(
|
||||||
'label' => 'Send support feedback',
|
'label' => 'Send support feedback',
|
||||||
|
@ -126,7 +126,7 @@ class Application_Form_SupportSettings extends Zend_Form
|
||||||
->setRequired(false)
|
->setRequired(false)
|
||||||
->setDecorators(array('ViewHelper'))
|
->setDecorators(array('ViewHelper'))
|
||||||
->setValue(Application_Model_Preference::GetPublicise());
|
->setValue(Application_Model_Preference::GetPublicise());
|
||||||
if(Application_Model_Preference::GetSupportFeedback() == '0'){
|
if (Application_Model_Preference::GetSupportFeedback() == '0') {
|
||||||
$checkboxPublicise->setAttrib("disabled", "disabled");
|
$checkboxPublicise->setAttrib("disabled", "disabled");
|
||||||
}
|
}
|
||||||
$this->addElement($checkboxPublicise);
|
$this->addElement($checkboxPublicise);
|
||||||
|
@ -165,19 +165,19 @@ class Application_Form_SupportSettings extends Zend_Form
|
||||||
public function isValid ($data)
|
public function isValid ($data)
|
||||||
{
|
{
|
||||||
$isValid = parent::isValid($data);
|
$isValid = parent::isValid($data);
|
||||||
if(!$this->isSass){
|
if (!$this->isSass) {
|
||||||
if($data['Publicise'] != 1){
|
if ($data['Publicise'] != 1) {
|
||||||
$isValid = true;
|
$isValid = true;
|
||||||
}
|
}
|
||||||
if(isset($data["Privacy"])){
|
if (isset($data["Privacy"])) {
|
||||||
$checkPrivacy = $this->getElement('Privacy');
|
$checkPrivacy = $this->getElement('Privacy');
|
||||||
if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){
|
if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") {
|
||||||
$checkPrivacy->addError("You have to agree to privacy policy.");
|
$checkPrivacy->addError("You have to agree to privacy policy.");
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $isValid;
|
return $isValid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,20 +32,20 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verifyChosenFolder($p_form_element_id) {
|
public function verifyChosenFolder($p_form_element_id)
|
||||||
|
{
|
||||||
$element = $this->getElement($p_form_element_id);
|
$element = $this->getElement($p_form_element_id);
|
||||||
|
|
||||||
if (!is_dir($element->getValue())) {
|
if (!is_dir($element->getValue())) {
|
||||||
$element->setErrors(array('Not a valid Directory'));
|
$element->setErrors(array('Not a valid Directory'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$element->setValue("");
|
$element->setValue("");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Zend_Filter_ImageSize implements Zend_Filter_Interface {
|
class Zend_Filter_ImageSize implements Zend_Filter_Interface
|
||||||
public function filter($value) {
|
{
|
||||||
|
public function filter($value)
|
||||||
|
{
|
||||||
if (!file_exists($value)) {
|
if (!file_exists($value)) {
|
||||||
throw new Zend_Filter_Exception('Image does not exist: ' . $value);
|
throw new Zend_Filter_Exception('Image does not exist: ' . $value);
|
||||||
}
|
}
|
||||||
|
@ -38,5 +40,3 @@ class Zend_Filter_ImageSize implements Zend_Filter_Interface {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* Check if a field is empty but only when specific fields have specific values
|
* Check if a field is empty but only when specific fields have specific values
|
||||||
*/
|
*/
|
||||||
class ConditionalNotEmpty extends Zend_Validate_Abstract {
|
class ConditionalNotEmpty extends Zend_Validate_Abstract
|
||||||
|
{
|
||||||
const KEY_IS_EMPTY = 'keyIsEmpty';
|
const KEY_IS_EMPTY = 'keyIsEmpty';
|
||||||
|
|
||||||
protected $_messageTemplates = array(
|
protected $_messageTemplates = array(
|
||||||
|
@ -32,8 +32,8 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract {
|
||||||
* this function returns true if the expected values doesn't match the actual user input,
|
* this function returns true if the expected values doesn't match the actual user input,
|
||||||
* or if $value is not empty. Returns false otherwise.
|
* or if $value is not empty. Returns false otherwise.
|
||||||
*
|
*
|
||||||
* @param String $value - this field's value
|
* @param String $value - this field's value
|
||||||
* @param array $context - names and values of the rest of the fields in this form
|
* @param array $context - names and values of the rest of the fields in this form
|
||||||
* @return boolean - true if valid; false otherwise
|
* @return boolean - true if valid; false otherwise
|
||||||
*/
|
*/
|
||||||
public function isValid($value, $context = null)
|
public function isValid($value, $context = null)
|
||||||
|
@ -43,7 +43,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($context)) {
|
if (is_array($context)) {
|
||||||
foreach($this->_fieldValues as $fieldName=>$fieldValue) {
|
foreach ($this->_fieldValues as $fieldName=>$fieldValue) {
|
||||||
if (!isset($context[$fieldName]) || $context[$fieldName] != $fieldValue) {
|
if (!isset($context[$fieldName]) || $context[$fieldName] != $fieldValue) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_error(self::KEY_IS_EMPTY);
|
$this->_error(self::KEY_IS_EMPTY);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PasswordNotEmpty extends ConditionalNotEmpty {
|
class PasswordNotEmpty extends ConditionalNotEmpty
|
||||||
|
{
|
||||||
public function isValid($value, $context = null)
|
public function isValid($value, $context = null)
|
||||||
{
|
{
|
||||||
$result = parent::isValid($value, $context);
|
$result = parent::isValid($value, $context);
|
||||||
|
@ -11,8 +12,7 @@ class PasswordNotEmpty extends ConditionalNotEmpty {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue